Search Results

Search found 8942 results on 358 pages for 'print r'.

Page 100/358 | < Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >

  • Merge decorator function as class

    - by SyetemHog
    How to make this merge function as class decorator? def merge(*arg, **kwarg): # get decorator args & kwargs def func(f): def tmp(*args, **kwargs): # get function args & kwargs kwargs.update(kwarg) # merge two dictionaries return f(*args, **kwargs) # return merged data return tmp return func Usage: @other_decorator # return *args and **kwarg @merge(list=['one','two','three']) # need to merge with @other_decorator def test(*a, **k): # get merged args and kwargs print 'args:', a print 'kwargs:', k

    Read the article

  • Python: for statement behavior

    - by BandGap
    Hi all. My question concerns the output of this statement: for x in range(4), y in range(4): print x print y Results in: [0, 1, 2, 3] 2 True 2 It seems there is a comparison involved, I just can't figure out why the output is structured like this.

    Read the article

  • Rewrite code from Threads to AnyEvent

    - by user1779868
    I wrote a code: use LWP::UserAgent; use HTTP::Cookies; use threads; use threads::shared; $| = 1; $threads = 50; my @urls : shared = loadf('url.txt'); my @thread_list = (); $thread_list[$_] = threads->create(\&thread) for 0 .. $threads - 1; $_->join for @thread_list; thread(); sub thread { my ($web, $ck) = browser(); while(1) { my $url = shift @urls; if(!$url) { last; } $code = $web->get($url)->code; print "[+] $url - code: $code\n"; if($code == 200) { open F, ">>200.txt"; print F $url."\n"; close F; } elsif($code == 301) { open F, ">>301.txt"; print F $url."\n"; close F; } else { open F, ">>else.txt"; print F "$url code - $code\n"; close F; } } } sub loadf { open (F, "<".$_[0]) or erroropen($_[0]); chomp(my @data = <F>); close F; return @data; } sub browser { my $web = new LWP::UserAgent; my $ck = new HTTP::Cookies; $web->cookie_jar($ck); $web->agent('Opera/9.80 (Windows 7; U; en) Presto/2.9.168 Version/11.50'); $web->timeout(5); return $web, $ck; } After its working for some time physical storage is full. Can u help me to re-write it with AnyEvent. I tried but my code didn't work. I read that it will help me to safe some memory. Thanks a lot to any helpers.

    Read the article

  • Enable "Current Page" in PrintDialog

    - by mizipzor
    Im using a System.Windows.Controls.PrintDialog to let the user print one or more pages from my application. This is what I currently got: PrintDialog printDialog = new PrintDialog(); printDialog.PageRangeSelection = PageRangeSelection.AllPages; printDialog.UserPageRangeEnabled = true; if (printDialog.ShowDialog() == true) { // do print ... } Im looking for the option to enable the Current Page radio button in the dialog. How to enable it?

    Read the article

  • Count numbers in words.

    - by bachchan
    I need an assembler 8080 software which counts words (delimited by space) which have more than two number in it. Example : this sh0uld b3 l1ke th1s would print : 0 words but Example : this sh0uld b3 l1k3 th1s f000k would print : 2 words <- word l1k3 contain number 1,3 and f000k number 0,0,0 the output should be displayer in hexadecimal format (optional)

    Read the article

  • Python new-style classes and __subclasses__ function

    - by Fraser Graham
    Can somebody explain to me why this works (in Python 2.5) : class Foo(object): pass class Bar(Foo): pass print(Foo.__subclasses__()) but this doesn't : class Foo(): pass class Bar(Foo): pass print(Foo.__subclasses__()) The latter returns "AttributeError: class Foo has no attribute '__subclasses__'" but i'm not sure why. I know this is related to old-style vs. new-style classes but i'm not clear on why that would make this functionality unavailable.

    Read the article

  • Perl, foreach order

    - by Mike
    Does Perl's foreach loop operator require that the list items be presented in order? For example my @a=(1,2,3); foreach my $item (@a) { print $item; } will always print 1 2 3? I suspect so, but I can't find it documented.

    Read the article

  • Perl ENV variable contains newline and tab

    - by Michael
    Say I have an environment variable myvar myvar=\tapple\n when the following command will print out this variable perl -e 'print "$ENV{myvar}"' I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it? In the real world $ENV residing in substitution, but I hope the answer will cover that.

    Read the article

  • passing back answers in prolog

    - by AhmadAssaf
    i have this code than runs perfectly .. returns a true .. when tracing the values are ok .. but its not returning back the answer .. it acts strangely when it ends and always return empty list .. uninstantiated variable .. test :- extend(4,12,[4,3,1,2],[[1,5],[3,4],[6]],_ExtendedBins). %printing basic information about the extend(NumBins,Capacity,RemainingNumbers,BinsSoFar,_ExtendedBins) :- getNumberofBins(BinsSoFar,NumberOfBins), msort(RemainingNumbers,SortedRemaining),nl, format("Current Number of Bins is :~w\n",[NumberOfBins]), format("Allowed Capacity is :~w\n",[Capacity]), format("maximum limit in bin is :~w\n",[NumBins]), format("Trying to fit :~w\n\n",[SortedRemaining]), format("Possible Solutions :\n\n"), fitElements(NumBins,NumberOfBins, Capacity,SortedRemaining,BinsSoFar,[]). %this is were the creation for possibilities will start %will check first if the number of bins allowed is less than then %we create a new list with all the possible combinations %after that we start matching to other bins with capacity constraint fitElements(NumBins,NumberOfBins, Capacity,RemainingNumbers,Bins,ExtendedBins) :- ( NumberOfBins < NumBins -> print('Creating new set: '); print('Sorry, Cannot create New Sets')), createNewList(Capacity,RemainingNumbers,Bins,ExtendedBins). createNewList(Capacity,RemainingNumbers,Bins,ExtendedBins) :- createNewList(Capacity,RemainingNumbers,Bins,[],ExtendedBins), print(ExtendedBins). createNewList(0,Bins,Bins,ExtendedBins,ExtendedBins). createNewList(_,[],_,ExtendedBins,ExtendedBins). createNewList(Capacity,[Element|Rest],Bins,Temp,ExtendedBins) :- conjunct_to_list(Element,ListedElement), append(ListedElement,Temp,NewList), sumlist(NewList,Sum), (Sum =< Capacity, append(ListedElement,ExtendedBins,Result); Capacity = 0), createNewList(Capacity,Rest,Bins,NewList,Result). fit(0,[],ExtendedBins,ExtendedBins). fit(Capacity,[Element|Rest],Bin,ExtendedBins) :- conjunct_to_list(Element,Listed), append(Listed,Bin,NewBin), sumlist(NewBin,Sum), (Sum =< Capacity -> fit(Capacity,Rest,NewBin,ExtendedBins); Capacity = 0, append(NewBin,ExtendedBins,NewExtendedBins), print(NewExtendedBins), fit(0,[],NewBin,ExtendedBins)). %get the number of bins provided getNumberofBins(List,NumberOfBins) :- getNumberofBins(List,0,NumberOfBins). getNumberofBins([],NumberOfBins,NumberOfBins). getNumberofBins([_List|Rest],TempCount,NumberOfBins) :- NewCount is TempCount + 1, %calculate the count getNumberofBins(Rest,NewCount,NumberOfBins). %recursive call %Convert set of terms into a list - used when needed to append conjunct_to_list((A,B), L) :- !, conjunct_to_list(A, L0), conjunct_to_list(B, L1), append(L0, L1, L). conjunct_to_list(A, [A]). Greatly appreciate the help

    Read the article

  • urllib open - how to control the number of retries

    - by user1641071
    how can i control the number of retries of the "opener.open"? for example, in the following code, it will send about 6 "GET" HTTP requests (i saw it in the Wireshark sniffer) before it goes to the " except urllib.error.URLError" success/no-success lines. password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() password_mgr.add_password(None,url, username, password) handler = urllib.request.HTTPBasicAuthHandler(password_mgr) opener = urllib.request.build_opener(handler) try: resp = opener.open(url,None,1) except urllib.error.URLError as e: print ("no success") else: print ("success!")

    Read the article

  • session variable values are not being passed between pages

    - by ravi nankani
    hi, i am a little new to php and although i have managed to pass values of session variables before this piece of code is leaving me puzzled <form action="team_reg2.php" method="post" name="form1" class="cent" id="form1"> Team Registration "; print "member$i"; print "\n"; print "\n"; print "Please enter only id\n"; } ? now this will pass via post to team_reg2.php echo " please note your team id is 1 "; echo " your team members are : "; for($i=1;$i<=$num;$i++) { $name='mem'.$i; echo "$_POST[$name]"; } } else { $str="select * from $query where ("; for($i=1;$i<=$num;$i++) { $name='mem'.$i; $text="p_id='$_POST[$name]'"; if($i==1) $str=$str.$text; else $str=$str.' or '.$text; } $str=$str.')'; $query2=$str; echo "$str"; // echo "$query2"; $que=mysql_query($query2,$con) or die(mysql_error()); $num=mysql_num_rows($que); if($num!=0) { while($result=mysql_fetch_array($que)) { echo "$result[p_id] is already registered in team $result[t_id]"; } //include("reg_team.html"); } else if($num==0) { //echo $query; $query2="select max(t_id) from $query"; $que=mysql_query($query2,$con) or die(mysql_error()); //echo "$que"; $result=mysql_fetch_array($que); $max=$result['max(t_id)']; $max++; $num=$_SESSION['max_team']; for($i=1;$i<=$num;$i++) { $name='mem'.$i; if($_POST[$name]!="") { $query2="insert into $query values($max,'$_POST[$name]')"; $que=mysql_query($query2,$con); } } echo " please note your team id is $max "; echo " your team members are : "; for($i=1;$i<=$num;$i++) { $name='mem'.$i; echo "$_POST[$name]"; } } } ? i have done session_start(); at the beginning of the page itself. The problem is that echoing $_SESSION variables in second file is not printing anything. someone please explain me whats going on. thank you

    Read the article

  • A version of the Windows "FILE:" port which does not prompt for the file name but autogenerates one.

    - by Thorbjørn Ravn Andersen
    Hi. I have a process where one of the things to do is to capture the output from a print into a file for further processing. For this I have configured a "FILE:" printer port which works very nicely but asks everytime for the file name to use. Unfortunately "FILE" is not a very descriptive word when trying to use a search engine :( Is there a small driver somewhere which does exactly the same as the FILE: driver, but can automatically generate a filename (perhaps based on a pattern) and just print to that?

    Read the article

  • How to retrieve items from a django queryset?

    - by sharataka
    I'm trying to get the video element in a queryset but am having trouble retrieving it. user_channel = Everything.objects.filter(profile = request.user, playlist = 'Channel') print user_channel[0] #returns the first result without error print user_channel[0]['video'] #returns error Models.py: class Everything(models.Model): profile = models.ForeignKey(User) playlist = models.CharField('Playlist', max_length = 2000, null=True, blank=True) platform = models.CharField('Platform', max_length = 2000, null=True, blank=True) video = models.CharField('VideoID', max_length = 2000, null=True, blank=True) video_title = models.CharField('Title of Video', max_length = 2000, null=True, blank=True) def __unicode__(self): return u'%s %s %s %s %s' % (self.profile, self.playlist, self.platform, self.video, self.video_title)

    Read the article

  • Space as grouping separator in printf

    - by blekione
    I know how to use comma in printf as grouping separator to print value in format like 1,000,000.00 to print it that way I'm using command System.out.printf ("%,.2f", value); but how to use space as grouping separator to format value like 1 000 000.00 I tried to find solution but solutions with using DecimalFormat look at now to complicate for me (beginner level). Is there as easy way as in example with comma to do it?

    Read the article

  • Why does my table values return nil when i clearly initialized them?

    - by user3717078
    players = {} function newPlayer(name) players[name]={x = 200, y = 100} --assign each player their x and y coordinates, which is x: 200 and y: 100 end function checkPosition(name?) -- Do i need a parameter? if players[name].x == 200 and players[name].y == 100 then --says players[name].x is a nil value print("good") else print("bad") end end Error: attempt to index ? (a nil value) Current Situation: The code above says players[name].x is a nil value, I would like to know why since i thought i assigned it in the function newPlayer.

    Read the article

  • Variable Binding Class

    - by Davis
    Hi, I believe this is a tough one... I'm trying to create a collection of variable binding in a class. It is intended to look something like this: Dim x as integer, s as string Dim c as new VBindClass x = 1 s = "Hello" c.Add x, s Debug.Print c.value(x) '= 1 Debug.Print c.value(s) '= "Hello" Is there some function that allow us to retrieve a unique ID for a given variable and also get/set based on variable?

    Read the article

  • In Ruby, how to write a method to display any object's instance variable names and its values

    - by Jian Lin
    Given any object in Ruby (on Rails), how can I write a method so that it will display that object's instance variable names and its values, like this: @x: 1 @y: 2 @link_to_point: #<Point:0x10031b298 @y=20, @x=38> I also want to be able to print <br> to the end of each instance variable's value so as to print them out nicely on a webpage. the difficulty now seems to be that not every instance variable has an accessor, so it can't be called with obj.send(var_name) (the var_name has the "@" removed, so "@x" becomes "x")

    Read the article

  • CSS files that have numbers in their query string?

    - by every
    <link href="/stylesheets/blueprint/screen.css?1268721265" media="screen, projection" rel="stylesheet" type="text/css" /> <link href="/stylesheets/blueprint/print.css?1268721265" media="print" rel="stylesheet" type="text/css" /> Why does the css file URL have 1268721265 in it? Any ideas? Thanks.

    Read the article

  • UnicodeDecodeError in pyton 2.7

    - by user2913962
    i try to write this code to process Arabic language by python import codecs file = codecs.open("C:\Python27\CCA_raw_utf8.txt","r","utf-8") text= file.read() #################################### print "\n "," --------------------------------------------" text=text[1:] words=text.split() for w in words: if w == unicode ("?????","utf-8"): print w but it doesn't and take error " if w == unicode ("?????","utf-8"): UnicodeDecodeError: 'utf8' codec can't decode byte 0xc7 in position 0: invalid continuation byte " why program gives this result and how we can correct that??

    Read the article

  • How can I interpolate literal \t and \n in Perl strings?

    - by Michael
    Say I have an environment variable myvar: myvar=\tapple\n When the following command will print out this variable perl -e 'print "$ENV{myvar}"' I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it? In the real world $ENV residing in substitution, but I hope the answer will cover that.

    Read the article

< Previous Page | 96 97 98 99 100 101 102 103 104 105 106 107  | Next Page >