Re: Weird python behavior
Forafo San ppv.g...@gmail.com wrote: OK, lesson learned: Take care not to have module names that conflict with python's built ins. Sorry for being so obtuse. You don't have to apologize. We've all been bitten by this at least once. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: baffled classes within a function namespace. Evaluation order.
On Fri, 26 Apr 2013 07:39:32 +0200, Peter Otten wrote: A class body is basically a function body that is executed once. To allow an assignment x = 42 class A: ... x = x ... which is not possible inside a function As far as I can tell, the documentation says that this assignment should also be impossible inside a class. Unless I'm missing something, I think this is a bug. http://docs.python.org/3/reference/executionmodel.html [...] However, while the above gives some technical background it doesn't explain why this scheme was chosen. My guess is that when Python got closures nobody was willing to do the extra work to make class bodies namespace-aware. The alternative, disallowing x = x in classes, would have seriously broken backwards-compatibility. Not so. x = x was not allowed in classes before there were closures: [steve@ando ~]$ python1.5 Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam def f(): ... x = 1 ... class Test: ... x = x ... return Test ... T = f() Traceback (innermost last): File stdin, line 1, in ? File stdin, line 3, in f File stdin, line 4, in Test NameError: x -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Weird python behavior
On Apr 26, 11:04 am, Tim Roberts t...@probo.com wrote: Forafo San ppv.g...@gmail.com wrote: OK, lesson learned: Take care not to have module names that conflict with python's built ins. Sorry for being so obtuse. You don't have to apologize. We've all been bitten by this at least once. Yes… When it comes to keywords it is reasonable to expect the programmer to know all the keywords and if he uses one for a function/variable the error will be immediate. When it comes to modules it is less reasonable to expect the programmer to know all available modules. To present these kind of errors, Erlang has a concept of sticky modules -- those that come from the system -- for which special efforts need to be made to 'unstick' them if one wants them overridden. This is helpful because the default which is to raise an error, is in most cases a more sound option than to silently override a builtin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Quesion about running a exe file in Python(Not enough memory)
On Fri, Apr 26, 2013 at 8:00 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 25 Apr 2013 14:18:58 -0700, yuyaxuan0 wrote: #cmd = D:\\programs\\MIRAX_SlideAC_SDK\\Bin\\MrxSlideExport.exe -s D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Slides\\L10 -e -o D:\\fit\\projects\\bayer\\KidneyLiver\\MiraxScanner\\Output\\L10 -z 5 -f png You can simplify Windows pathnames by using forward slashes. These paths are being given to an external tool, so I wouldn't guarantee that forward slashes will work. But you can use a raw string literal to avoid doubling them all up. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Warning in python file when i m using pychecker.
hi, I am trying to run my file using pychecker, but it's showing warning. I am unable to get these warning. Please help me, how to remove these warning. I am using pychecker first time. avin@HP:~/github/UdacitySiteData$ pychecker udacity_to_jsonFinal.py Processing module udacity_to_jsonFinal (udacity_to_jsonFinal.py)... Warnings... [system path]/dist-packages/bs4/__init__.py:206: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:209: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:213: Local variable (tag) not used [system path]/dist-packages/bs4/element.py:306: Parameter (kwargs) not used [system path]/dist-packages/bs4/element.py:507: (id) shadows builtin [system path]/dist-packages/bs4/element.py:791: (next) shadows builtin [system path]/dist-packages/bs4/element.py:903: Invalid arguments to (__repr__), got 2, expected 1 Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: PCAP Files
On 25Apr2013 21:55, Hasil Sharma hasilshar...@gmail.com wrote: | I m having network dumps in the form of pcap files and I want to | extract the html,css, image files etc etc all that can be extracted | from those pcap files , can anyone please tell me how to accomplish | such a task in python ? I would reassemble the TCP packets into data streams and then handle them to an HTTP or MIME parser. For the first part, have you tried a google search? Like this: https://www.google.com.au/search?q=reassemble+pcap+files+into+tcp+streams Looks promising, particularly the streams and tcpreplay stuff. Or even search the Python Package Index for pcap, even indirectly via google: https://www.google.com.au/search?q=pypi+pcapie=utf-8oe=utf-8aq=trls=org.mozilla:en-GB:officialclient=firefox-betachannel=fflb Then just handle the data streams to a normal Python MIME parser to figure out what's in them. Cheers, -- Cameron Simpson c...@zip.com.au I have come here to chew bubblegum and kick ass, and I'm all out of bubblegum. - Roddy Piper -- http://mail.python.org/mailman/listinfo/python-list
Re: Warning in python file when i m using pychecker.
Read the warnings carefully. They are pretty clear. On 26 Apr 2013 07:48, Avnesh Shakya avnesh.n...@gmail.com wrote: hi, I am trying to run my file using pychecker, but it's showing warning. I am unable to get these warning. Please help me, how to remove these warning. I am using pychecker first time. avin@HP:~/github/UdacitySiteData$ pychecker udacity_to_jsonFinal.py Processing module udacity_to_jsonFinal (udacity_to_jsonFinal.py)... Warnings... [system path]/dist-packages/bs4/__init__.py:206: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:209: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:213: Local variable (tag) not used [system path]/dist-packages/bs4/element.py:306: Parameter (kwargs) not used [system path]/dist-packages/bs4/element.py:507: (id) shadows builtin [system path]/dist-packages/bs4/element.py:791: (next) shadows builtin [system path]/dist-packages/bs4/element.py:903: Invalid arguments to (__repr__), got 2, expected 1 Thanks. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Warning in python file when i m using pychecker.
On 04/26/2013 02:42 AM, Avnesh Shakya wrote: hi, I am trying to run my file using pychecker, but it's showing warning. I am unable to get these warning. Please help me, how to remove these warning. I am using pychecker first time. avin@HP:~/github/UdacitySiteData$ pychecker udacity_to_jsonFinal.py Processing module udacity_to_jsonFinal (udacity_to_jsonFinal.py)... Warnings... [system path]/dist-packages/bs4/__init__.py:206: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:209: Parameter (successor) not used [system path]/dist-packages/bs4/__init__.py:213: Local variable (tag) not used [system path]/dist-packages/bs4/element.py:306: Parameter (kwargs) not used [system path]/dist-packages/bs4/element.py:507: (id) shadows builtin [system path]/dist-packages/bs4/element.py:791: (next) shadows builtin [system path]/dist-packages/bs4/element.py:903: Invalid arguments to (__repr__), got 2, expected 1 Thanks. What's not clear about any of these? On line 206, you defined some function and one of the formal parameters was called successor. You don't use that value anywhere in the function. The fix? Omit the unused parameter in the function definition, and change all the caller sites. Sometimes this is impractical, for example in functions that are callbacks from code you don't control. Likewise for the next 3. id() is a built-in function, so you shouldn't use that name for your own functions or variables. rename it. Likewise next, which is even more likely to cause confusion, since next is frequently used in real code, while id() is more likely a debugging aid. If you want anything more detailed, perhaps you should show the context around each warning. You have the line numbers, so that should be easy. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Weird python behavior
On Apr 26, 11:25 am, rusi rustompm...@gmail.com wrote: To present these kind of errors, Erlang has a concept of sticky modules -- those that come from the system… ??present?? should have been 'prevent' -- http://mail.python.org/mailman/listinfo/python-list
Re: baffled classes within a function namespace. Evaluation order.
Steven D'Aprano wrote: On Fri, 26 Apr 2013 07:39:32 +0200, Peter Otten wrote: A class body is basically a function body that is executed once. To allow an assignment x = 42 class A: ... x = x ... which is not possible inside a function As far as I can tell, the documentation says that this assignment should also be impossible inside a class. Unless I'm missing something, I think this is a bug. http://docs.python.org/3/reference/executionmodel.html Will have a look. [...] However, while the above gives some technical background it doesn't explain why this scheme was chosen. My guess is that when Python got closures nobody was willing to do the extra work to make class bodies namespace-aware. The alternative, disallowing x = x in classes, would have seriously broken backwards-compatibility. Not so. x = x was not allowed in classes before there were closures: [steve@ando ~]$ python1.5 Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam def f(): ... x = 1 ... class Test: ... x = x ... return Test ... T = f() Traceback (innermost last): File stdin, line 1, in ? File stdin, line 3, in f File stdin, line 4, in Test NameError: x Define a global variable x and run it again. I don't have an ancient Python lying around but my prediction is x = 42 f().x 42 which would be the same behaviour as that of Python 3.3. -- http://mail.python.org/mailman/listinfo/python-list
Re: Fixing escaped characters python-xbee
the following in gmane.comp.python.general: I am using a XBee to receive data from an arduino network. But they have AP=2 which means escaped characters are used when a 11 or 13 appears (and some more...) When this occurs, XBee sends 7D and inmediatly XOR operation with char and 0x20. I am trying to recover the original character in python but I don't know ho to do it. I tried something like this: read = ser.read(4) #Read 4 chars from serial port Why read 4 at a time if you need to detect the escape marker... PSEUDO_CODE -- UNTESTED: for c in ser.read():#presumes it will function as an iterator if ord(c) == 0x7D: c =chr(ord(ser.read(1)) ^ 0x20) #do something with c (save to a list for later joining as a string?) #probably need some condition to exit the read loop too def logical_xor(str1, str2): return bool(str1) ^ bool(str2) bool() returns True or False based on the argument... Any non-empty string will be True. Instead what you want is to x-or the bits of the character itself. -- It works! Thank you so much. Now I can go ahead with my work! -- http://mail.python.org/mailman/listinfo/python-list
Nested For loop not running full
Hello everyone, I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. Thanks in Advance for your suggestions -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison Style
On 25/04/2013 21:35, Steve Simmons wrote: The Ying Tong song - a classic of its time. But eminently suited to the chorally challenged. Released on a classic EP with Major Dennis Bloodnok's Rock and Roll Call Rumba, I'm walking Backwards for Christmas and Bluebottle Blues. Bravado, bravado. What a voice! (What a bank balance!) -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
inshu chauhan wrote: I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. My crystal ball says that the 'for sy...' and 'for sx...' loops are running to completion, but you don't get the coordinates printed because you put them into the 'for l in f' loop which will only run once. The quick and dirty fix is to replace f = open(...) in the code you are not showing with f == list(open(...)) The reasonable thing to do is of course to move the preprocessing (e.g. csv- parsing) out of the sy and sx loops. -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
On 4/26/2013 4:48 AM, inshu chauhan wrote: Hello everyone, I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? *A* reason could be that segimage.height and .width are both 1. I would print them out to see what they are. The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. Thanks in Advance for your suggestions -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten __pete...@web.de wrote: inshu chauhan wrote: I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. My crystal ball says that the 'for sy...' and 'for sx...' loops are running to completion, but you don't get the coordinates printed because you put them into the 'for l in f' loop which will only run once. Is there any means by which I can run this 'For l in f' loop again and again ? The quick and dirty fix is to replace f = open(...) in the code you are not showing with f == list(open(...)) f is just a text file(csv format).. so why list ?? The reasonable thing to do is of course to move the preprocessing (e.g. csv- parsing) out of the sy and sx loops. I did this but again then what I intend to do is not really happening, For every pixel I read, I want to traverse the full file, so that the information I am taking from pixel have to match in one of the line in the file. Can this be done by modifying my code ? or something new has to be devised ? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
On 26 April 2013 10:36, inshu chauhan insidesh...@gmail.com wrote: On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten __pete...@web.de wrote: My crystal ball says that the 'for sy...' and 'for sx...' loops are running to completion, but you don't get the coordinates printed because you put them into the 'for l in f' loop which will only run once. Is there any means by which I can run this 'For l in f' loop again and again ? The quick and dirty fix is to replace f = open(...) in the code you are not showing with f == list(open(...)) f is just a text file(csv format).. so why list ?? So that you can run the for l in f loop again and again. You can loop over a list as many times as you like but only once over a file (unless you reset the file pointer). Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
On Fri, Apr 26, 2013 at 7:36 PM, inshu chauhan insidesh...@gmail.com wrote: On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten __pete...@web.de wrote: f = open(...) in the code you are not showing with f == list(open(...)) f is just a text file(csv format).. so why list ?? (That should be =, not ==) Instead of having an open file object, you would instead have a list of the lines in the file. That can be iterated over more than once. The reasonable thing to do is of course to move the preprocessing (e.g. csv- parsing) out of the sy and sx loops. I did this but again then what I intend to do is not really happening, For every pixel I read, I want to traverse the full file, so that the information I am taking from pixel have to match in one of the line in the file. Can this be done by modifying my code ? or something new has to be devised ? How large is the file? There are two easy solutions: 1) Open and close the file every time you touch a pixel 2) Open the file once, read it all into memory, and then iterate over the in-memory copy every pixel If your file is insanely large then the first option may be better, but for anything less than five yottabytes, go with the second. (Okay, I may be exaggerating slightly... let's say anything less than half your RAM. So if you have 10YB of memory, then I wasn't exaggerating.) That's why Peter suggested creating a list; you iterate over the list. Another way to do it is to parse the file once and retain a more efficient and useful structured form of the data... which is the other thing Peter suggested (move the preprocessing (e.g. csv- parsing) out of the sy and sx loops). So, yeah. Listen to Peter Otten, he knows what he's talking about :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
inshu chauhan wrote: On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten __pete...@web.de wrote: inshu chauhan wrote: I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. My crystal ball says that the 'for sy...' and 'for sx...' loops are running to completion, but you don't get the coordinates printed because you put them into the 'for l in f' loop which will only run once. Is there any means by which I can run this 'For l in f' loop again and again ? The quick and dirty fix is to replace f = open(...) in the code you are not showing with f == list(open(...)) f is just a text file(csv format).. so why list ?? Can you figure it out yourself from the following? f = open(tmp.data) for i in range(3): ... for line in f: print repr(line) ... 'alpha\n' 'beta\n' 'gamma\n' f = list(open(tmp.data)) for i in range(3): ... for line in f: print repr(line) ... 'alpha\n' 'beta\n' 'gamma\n' 'alpha\n' 'beta\n' 'gamma\n' 'alpha\n' 'beta\n' 'gamma\n' The reasonable thing to do is of course to move the preprocessing (e.g. csv- parsing) out of the sy and sx loops. I did this but again then what I intend to do is not really happening, For every pixel I read, I want to traverse the full file, so that the information I am taking from pixel have to match in one of the line in the file. Can this be done by modifying my code ? or something new has to be devised ? I think I have already answered this, but here's another alternative: f = open(tmp.data) for i in range(3): ... f.seek(0) ... for line in f: print(repr(line)) ... 'alpha\n' 'beta\n' 'gamma\n' 'alpha\n' 'beta\n' 'gamma\n' 'alpha\n' 'beta\n' 'gamma\n' -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
inshu chauhan insidesh...@gmail.com wrote: I have this part of my code where I am trying to traverse over an image by running a for loop for both x and y co-ordinate axis. But the loop is terminating by just reading first pixel. Can think of a reason why this is happening ? The code is: for sy in xrange(0, segimage.height): for sx in xrange(0, segimage.width): if segimage[sy,sx] == (0.0, 0.0, 0.0): continue else: seg_color = segimage[sy,sx] blue = int(seg_color[0]) green = int(seg_color[1]) red = int(seg_color[2]) reg_num = blue + 256 * green + 65536 * red for l in f: sp = l.split(,) if len(sp) == 14: print sy, sx # for checking which pixel its reading currently print reg_num, sp[0] # for checking whats happening if reg_num == int(sp[0].strip()): print reg_num, sp[0].strip() # for checking whats happening classification = int(sp[13].strip()) The inside for loop is for reading a csv format file from which I am extracting some information. Are you sure that the loop is only run once? In that case the most likely thing is that the image consists of only a single pixel (or all except the first one are black, then it might also look as if the loop would be run only once;-) But what looks strange is the innermost loop. You never tell what exactly 'f' is but I would tend to assume that it is a file object for your CSV file, which you opened somewhere before. And now you read it in completely when dealing with the very first pixel of your image. Afterwards, when dealing with the other pixels of the image, there's nothing left to be read in, so the inner loop won't be run again, making it appear as if the outer loops would only be run once. If my assumptions are correct and you want to read in the file again and again for each pixel then you should either open it again and again for each pixel or, probably better, reset the file object so that it points back to the start of the file before the start of the innermost loop, using the seek() method - a simple f.seek(0) should do the job (assuming that this is a normal file, i.e. one that can be rewound and not e.g. a re- directed pipe). An even better solution (if you have enough memory) might be to read in the whole file into a list and iterate over that instead of the file itself. And better than that might be to build a dictionary of values in the file that you can use later on, so you don't have to run over the whole file again and again: d = { } for l in f : sp = split( l, ',' ) if len( sp ) == 14 : d[ int( sp[ 0 ].strip( ) ) ] = int( sp[ 13 ].strip( ) ) Then you can later check directly if some color value (what you have named 'reg_num') is in the file by using if reg_num in d : and the corresponding value from the file (what you assign to 'classification') is simply the value of the dictionary for the key given by 'reg_num'. i.e. classification = d[ reg_num ] Regards, Jens -- \ Jens Thoms Toerring ___ j...@toerring.de \__ http://toerring.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Nested For loop not running full
, 2013 at 3:15 PM, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 26, 2013 at 7:36 PM, inshu chauhan insidesh...@gmail.com wrote: On Fri, Apr 26, 2013 at 2:39 PM, Peter Otten __pete...@web.de wrote: f = open(...) in the code you are not showing with f == list(open(...)) f is just a text file(csv format).. so why list ?? (That should be =, not ==) Instead of having an open file object, you would instead have a list of the lines in the file. That can be iterated over more than once. The reasonable thing to do is of course to move the preprocessing (e.g. csv- parsing) out of the sy and sx loops. I did this but again then what I intend to do is not really happening, For every pixel I read, I want to traverse the full file, so that the information I am taking from pixel have to match in one of the line in the file. Can this be done by modifying my code ? or something new has to be devised ? How large is the file? There are two easy solutions: 1) Open and close the file every time you touch a pixel 2) Open the file once, read it all into memory, and then iterate over the in-memory copy every pixel If your file is insanely large then the first option may be better, but for anything less than five yottabytes, go with the second. (Okay, I may be exaggerating slightly... let's say anything less than half your RAM. So if you have 10YB of memory, then I wasn't exaggerating.) That's why Peter suggested creating a list; you iterate over the list. Another way to do it is to parse the file once and retain a more efficient and useful structured form of the data... which is the other thing Peter suggested (move the preprocessing (e.g. csv- parsing) out of the sy and sx loops). So, yeah. Listen to Peter Otten, he knows what he's talking about :) ChrisA Yes I am trying Peter's way and my file is just 500 KB .. :) -- http://mail.python.org/mailman/listinfo/python-list
New Dropbox alternative with 10GB free space
Everybody, there is a new online storage startup, similar to Dropbox or box.com, get your free 10 GB easily, 5GB on signup and 5GB if you use the following referral link. * hit the referral link https://copy.com?r=WGQBHr * create an account (5GB) * install client on any device (5GB) Have fun! -- http://mail.python.org/mailman/listinfo/python-list
TypeError: Can't convert 'int' object to str implicitly
Hey, Let me explain what my program is supposed to do... I am using a macro program in conjunction with a python script I am writing. The macro inputs data into a database we use at my job, blah blah blah. The script asks how many numbers (devices) you need to enter. Next, it asks you to input the device numbers. When you input them, it creates a list with all of the devices. I then tell it to go into the script of the Macro (firstdev.ahk) that will run on the back-end, and replace the word device with the first device in the list. It then should execute the Macro, change the device number back to the word Device for future use, and then delete the first number from the list. It will repeat as long as there are numbers in the list. The error I receive is TypeError: Can't convert 'int' object to str implicitly when it tries to put the device into the macro script. It worked fine when I just had it input one device into the script without the use of lists, but for whatever reason, using a list does not play nice with replacing the words Device with the number from the list. Here is my script. I will give you up until the part that the error occurs, as everything afterwords is pointless. I am fairly new to python, so if anything looks screwed up or like I am an idiot, it is because I am. import fileinput, sys, os devlist = [] maxdev = int(input(How many devices to add: )) curdev = int(0) while curdev maxdev: try: Number = int(input(Enter Device number: )) devlist.append(Number) curdev = curdev + 1 except ValueError: print(Please enter a valid number) ready = 0 while ready != Y and ready != y and ready != yes and ready != YES and ready != ready and ready != Ready: try: ready = input(Confirm when you are ready ) except ValueError: print(shit broke. ) ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(device, devlist[0]) sys.stdout.write(line) ##next step runs firstdev.ahk os.system('firstdev.ahk') ##next step is replacing devlist[0] with device for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(devlist[0], device) sys.stdout.write(line) del devlist[0] #deleting the first item from the list. next steps will repeat. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
tunacu...@gmail.com wrote: Hey, Let me explain what my program is supposed to do... I am using a macro program in conjunction with a python script I am writing. The macro inputs data into a database we use at my job, blah blah blah. The script asks how many numbers (devices) you need to enter. Next, it asks you to input the device numbers. When you input them, it creates a list with all of the devices. I then tell it to go into the script of the Macro (firstdev.ahk) that will run on the back-end, and replace the word device with the first device in the list. It then should execute the Macro, change the device number back to the word Device for future use, and then delete the first number from the list. It will repeat as long as there are numbers in the list. The error I receive is TypeError: Can't convert 'int' object to str implicitly when it tries to put the device into the macro script. Python is trying hard to give you a meaningful error message and shows the line causing the error in the traceback. It pays to read carefully -- or to post it here if it doesn't make sense to you. devlist = [] ... Number = int(input(Enter Device number: )) devlist.append(Number) ... line = line.replace(devlist[0], device) devList is a list of integers, and devlist[0] is thus an int. foo device bar\n.replace(42, device) Traceback (most recent call last): File stdin, line 1, in module TypeError: Can't convert 'int' object to str implicitly Implicitly? So let's try and convert the int /explicitly/ . foo device bar\n.replace(str(42), device) 'foo device bar\n' No error, but probably still not what you expected. Can you sort it out yourself? I am fairly new to python, so if anything looks screwed up or like I am an idiot, it is because I am. I like to see a bit of self-deprecation now and then, but on this list complete tracebacks find even more love ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Sat, Apr 27, 2013 at 12:26 AM, tunacu...@gmail.com wrote: Hey, The error I receive is TypeError: Can't convert 'int' object to str implicitly when it tries to put the device into the macro script. It worked fine when I just had it input one device into the script without the use of lists, but for whatever reason, using a list does not play nice with replacing the words Device with the number from the list. Here is my script. I will give you up until the part that the error occurs, as everything afterwords is pointless. I am fairly new to python, so if anything looks screwed up or like I am an idiot, it is because I am. Welcome to Python. One thing that you'll quickly learn is that the full traceback is REALLY helpful; in this case, there won't be much traceback, but at least you'll get the line number. I'm looking at this line as being the culprit: line = line.replace(device, devlist[0]) All you need to do is convert that to a string: line = line.replace(device, str(devlist[0])) and that should fix your problem. But while I'm here, may I offer a few other tips? (By the way, I'm going to assume you're using Python 3 here, because otherwise your confirm when ready would be bombing. But it helps to say what version you're using.) import fileinput, sys, os devlist = [] maxdev = int(input(How many devices to add: )) curdev = int(0) Just 'curdev = 0' would work here. No need to convert a string to an integer - just use a literal integer. while curdev maxdev: UI suggestion: Let the user keep on inputting device numbers until some kind of sentinel (eg a blank line), unless it makes really good sense to ask for the number up-front. try: Number = int(input(Enter Device number: )) devlist.append(Number) curdev = curdev + 1 except ValueError: print(Please enter a valid number) You can save the hassle of maintaining curdev by simply looking at len(devlist) - that is, change your condition to while len(devlist) maxdev. ready = 0 while ready != Y and ready != y and ready != yes and ready != YES and ready != ready and ready != Ready: Here's a really cool tip. You can simply check set membership: while ready not in {Y,y,yes,YES,ready,Ready}: But I'd be inclined to make the UI a bit tighter here and make it something like: ready = input(Confirm when you are ready y/N: ) and then just look for either Y or y, nothing more. But that's up to you. You know who's going to use this program, I don't. (The capitalized N representing that the default is No is a convention you may or may not want to follow.) try: ready = input(Confirm when you are ready ) except ValueError: print(shit broke. ) Drop the try/except; if there's something wrong (and, btw, I'm not sure what circumstances would trigger a ValueError here - maybe someone else knows of something?), just let the exception terminate the program. There's nothing useful to do here anyway :) ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(device, devlist[0]) sys.stdout.write(line) You're reading a single file with constant name here. Save yourself some trouble: just open the file directly. for line in open(firstdev.ahk): print(line.replace(device, str(devlist[0]))) Though I'm not sure why you want to write to stdout here. Were you intending to write back to another file? I'm getting a bit lost in your code here. My understanding of your intentions, from your comments, is that you actually want to repeat most of the code from here on for each device number entered - that strongly suggests a 'for' loop bracketing the whole thing. Is that what you meant this to do? Currently, it'll get to the 'del' at the bottom, and then just terminate. ##next step runs firstdev.ahk os.system('firstdev.ahk') ##next step is replacing devlist[0] with device for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(devlist[0], device) sys.stdout.write(line) And here you repeat everything from above. Again, not sure what you're intending to do here. del devlist[0] #deleting the first item from the list. next steps will repeat. The steps won't repeat by themselves, so this is where I'm thinking you actually want a for loop. I hope you don't take this the wrong way, as I feel now (on skimming over this email prior to sending) that I've kinda pulled your code to pieces a bit! It's just advice, just suggestions; this is your code and nobody else's. You may very well disagree with any or all of what I've said, and that's to be expected. It's also a great way to get discussion going, and discussion is one of the best ways for everyone to learn :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Sat, Apr 27, 2013 at 12:26 AM, tunacu...@gmail.com wrote: ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(device, devlist[0]) sys.stdout.write(line) ##next step runs firstdev.ahk os.system('firstdev.ahk') ##next step is replacing devlist[0] with device for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(devlist[0], device) sys.stdout.write(line) I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. I haven't looked into the details, as I haven't actually done this lately in Python, but you should be able to use tempfile.NamedTemporaryFile(delete=False) [1], write to it, make it executable, run it, and unlink it. That way, you're creating a temporary file to run, not running the original. This is semantically different from your code, but I think it'd be a lot safer. [1] http://docs.python.org/3.3/library/tempfile.html#tempfile.NamedTemporaryFile ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Friday, April 26, 2013 10:53:44 AM UTC-4, Peter Otten wrote: tunacu...@gmail.com wrote: Hey, Let me explain what my program is supposed to do... I am using a macro program in conjunction with a python script I am writing. The macro inputs data into a database we use at my job, blah blah blah. The script asks how many numbers (devices) you need to enter. Next, it asks you to input the device numbers. When you input them, it creates a list with all of the devices. I then tell it to go into the script of the Macro (firstdev.ahk) that will run on the back-end, and replace the word device with the first device in the list. It then should execute the Macro, change the device number back to the word Device for future use, and then delete the first number from the list. It will repeat as long as there are numbers in the list. The error I receive is TypeError: Can't convert 'int' object to str implicitly when it tries to put the device into the macro script. Python is trying hard to give you a meaningful error message and shows the line causing the error in the traceback. It pays to read carefully -- or to post it here if it doesn't make sense to you. devlist = [] ... Number = int(input(Enter Device number: )) devlist.append(Number) ... line = line.replace(devlist[0], device) devList is a list of integers, and devlist[0] is thus an int. foo device bar\n.replace(42, device) Traceback (most recent call last): File stdin, line 1, in module TypeError: Can't convert 'int' object to str implicitly Implicitly? So let's try and convert the int /explicitly/ . foo device bar\n.replace(str(42), device) 'foo device bar\n' No error, but probably still not what you expected. Can you sort it out yourself? I am fairly new to python, so if anything looks screwed up or like I am an idiot, it is because I am. I like to see a bit of self-deprecation now and then, but on this list complete tracebacks find even more love ;) Thank you, Peter. This was a tremendous help. Got it working. -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Friday, April 26, 2013 11:05:29 AM UTC-4, Chris Angelico wrote: On Sat, Apr 27, 2013 at 12:26 AM, tunacu...@gmail.com wrote: ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(device, devlist[0]) sys.stdout.write(line) ##next step runs firstdev.ahk os.system('firstdev.ahk') ##next step is replacing devlist[0] with device for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(devlist[0], device) sys.stdout.write(line) I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. I haven't looked into the details, as I haven't actually done this lately in Python, but you should be able to use tempfile.NamedTemporaryFile(delete=False) [1], write to it, make it executable, run it, and unlink it. That way, you're creating a temporary file to run, not running the original. This is semantically different from your code, but I think it'd be a lot safer. [1] http://docs.python.org/3.3/library/tempfile.html#tempfile.NamedTemporaryFile ChrisA Thank you, Chris! I got it working and am going to take your advice on the tempfile idea. I actually ran into the problem you were referring to, and kept the .ahk files backed up elsewhere for when this situation arose. I appreciate the help! -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Sat, Apr 27, 2013 at 1:22 AM, tunacu...@gmail.com wrote: I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. I haven't looked into the details, as I haven't actually done this lately in Python, but you should be able to use tempfile.NamedTemporaryFile(delete=False) [1], write to it, make it executable, run it, and unlink it. That way, you're creating a temporary file to run, not running the original. This is semantically different from your code, but I think it'd be a lot safer. Thank you, Chris! I got it working and am going to take your advice on the tempfile idea. I actually ran into the problem you were referring to, and kept the .ahk files backed up elsewhere for when this situation arose. I appreciate the help! Awesome! Hey, you want to know an easy way to show your appreciation for the people who answer your questions? It's really simple: Step 1: Don't use Google Groups to post. Step 2: Profit! Have a look at the quoted text in your responses. See how it's double-spaced and really obnoxious? That's not your fault, it's because Google Groups is buggy. There are plenty of other ways to read and post; I personally have subscribed to the mailing list and read it using Gmail, and there are a variety of other ways too. If you _must_ use Google Groups, check out this page for some recommendations on how to not offend people. http://wiki.python.org/moin/GoogleGroupsPython There are a number of non-G-rated terms going around that fairly accurately describe what Google Groups posts look like, but since I prefer milder language, I'll just repeat the word obnoxious, as it carries all the meaning I need. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Automatic context managers
On Sat, Apr 27, 2013 at 1:54 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 26/04/2013 14:02, anatoly techtonik wrote: This circular reference problem is interesting. In object space it probably looks like a stellar detached from the visible (attached) universe. Is the main problem in detecting it? The problem is in knowing in which order the objects should be collected. For example, if A refers to B and B refers to A, should you collect A then B, or B then A? If you collect A first, then, for a time, B will be referring to a non-existent object. That's not good if the objects have destructors which need to be run. Spin-off thread from python-ideas to discuss a more general question of garbage collection of cyclic structures. Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. Is this a plausible (never mind viable yet, just conceptually plausible) alternative to sticking them into gc.garbage and ignoring them? It'd allow a double-linked list/tree to function cleanly - imagine, for instance, something like the DOM facilities available to web browser scripts: class DOMObject: def __init__(self,parent): self.parent=parent self.firstchild=self.sibling=None if not parent: return if not parent.firstchild: parent.firstchild=self else: child=parent.firstchild while child.sibling: child=child.sibling child.sibling=self def __del__(self): print(Disposing of id #%d%id(self)) document=DOMObject(None) body=DOMObject(document) p=DOMObject(body) p=DOMObject(body) p=DOMObject(body) del document,body,p gc.collect() The __del__ method would need to clean up the external resources used by this object, but wouldn't have to walk the tree. Yet, just because there is a reference loop and there are __del__ methods, the garbage collector gives up and leaves it to the program author to deal with. I can understand if this is considered too complicated and too unusual a circumstance to be worth bothering to support, but I'm curious as to whether it's at least conceptually reasonable to do something like this. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
[[ Resending under a more appropriate subject line... sorry about that, ignore the other one as it'll only confuse matters ]] On Sat, Apr 27, 2013 at 1:54 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 26/04/2013 14:02, anatoly techtonik wrote: This circular reference problem is interesting. In object space it probably looks like a stellar detached from the visible (attached) universe. Is the main problem in detecting it? The problem is in knowing in which order the objects should be collected. For example, if A refers to B and B refers to A, should you collect A then B, or B then A? If you collect A first, then, for a time, B will be referring to a non-existent object. That's not good if the objects have destructors which need to be run. Spin-off thread from python-ideas to discuss a more general question of garbage collection of cyclic structures. Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. Is this a plausible (never mind viable yet, just conceptually plausible) alternative to sticking them into gc.garbage and ignoring them? It'd allow a double-linked list/tree to function cleanly - imagine, for instance, something like the DOM facilities available to web browser scripts: class DOMObject: def __init__(self,parent): self.parent=parent self.firstchild=self.sibling=None if not parent: return if not parent.firstchild: parent.firstchild=self else: child=parent.firstchild while child.sibling: child=child.sibling child.sibling=self def __del__(self): print(Disposing of id #%d%id(self)) document=DOMObject(None) body=DOMObject(document) p=DOMObject(body) p=DOMObject(body) p=DOMObject(body) del document,body,p gc.collect() The __del__ method would need to clean up the external resources used by this object, but wouldn't have to walk the tree. Yet, just because there is a reference loop and there are __del__ methods, the garbage collector gives up and leaves it to the program author to deal with. I can understand if this is considered too complicated and too unusual a circumstance to be worth bothering to support, but I'm curious as to whether it's at least conceptually reasonable to do something like this. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On 04/26/2013 11:05 AM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 12:26 AM, tunacu...@gmail.com wrote: ##This next step will seek out the word Device within firstdev.ahk, and replace with devlist[0] for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(device, devlist[0]) sys.stdout.write(line) ##next step runs firstdev.ahk os.system('firstdev.ahk') ##next step is replacing devlist[0] with device for line in fileinput.input([firstdev.ahk], inplace=True): line = line.replace(devlist[0], device) sys.stdout.write(line) I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. I haven't looked into the details, as I haven't actually done this lately in Python, but you should be able to use tempfile.NamedTemporaryFile(delete=False) [1], write to it, make it executable, run it, and unlink it. That way, you're creating a temporary file to run, not running the original. This is semantically different from your code, but I think it'd be a lot safer. [1] http://docs.python.org/3.3/library/tempfile.html#tempfile.NamedTemporaryFile ChrisA fileinput.Fileinput class already creates the temp file when you specify inplace=True If it didn't, I'd also have to point out the hazards of doing in-place updates in a text file where the new data and old is a different length. There still may be reasons to make an explicit backup, but I don't know what they are. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel d...@davea.name wrote: On 04/26/2013 11:05 AM, Chris Angelico wrote: I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. fileinput.Fileinput class already creates the temp file when you specify inplace=True If it didn't, I'd also have to point out the hazards of doing in-place updates in a text file where the new data and old is a different length. There still may be reasons to make an explicit backup, but I don't know what they are. That's true if something goes wrong during the actual writing of the file only. But if the process bombs in the middle of the execution phase (which in the Python script is a single os.system() call), then the file will have been one-way changed on the disk - hence, damaged. The explicit temporary file (and executing the temp file) is a much safer way to do it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On 04/26/2013 12:54 PM, Chris Angelico wrote: [[ Resending under a more appropriate subject line... sorry about that, ignore the other one as it'll only confuse matters ]] On Sat, Apr 27, 2013 at 1:54 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 26/04/2013 14:02, anatoly techtonik wrote: This circular reference problem is interesting. In object space it probably looks like a stellar detached from the visible (attached) universe. Is the main problem in detecting it? The problem is in knowing in which order the objects should be collected. For example, if A refers to B and B refers to A, should you collect A then B, or B then A? If you collect A first, then, for a time, B will be referring to a non-existent object. That's not good if the objects have destructors which need to be run. Spin-off thread from python-ideas to discuss a more general question of garbage collection of cyclic structures. Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. Is this a plausible (never mind viable yet, just conceptually plausible) alternative to sticking them into gc.garbage and ignoring them? It'd allow a double-linked list/tree to function cleanly - imagine, for instance, something like the DOM facilities available to web browser scripts: class DOMObject: def __init__(self,parent): self.parent=parent self.firstchild=self.sibling=None if not parent: return if not parent.firstchild: parent.firstchild=self else: child=parent.firstchild while child.sibling: child=child.sibling child.sibling=self def __del__(self): print(Disposing of id #%d%id(self)) document=DOMObject(None) body=DOMObject(document) p=DOMObject(body) p=DOMObject(body) p=DOMObject(body) del document,body,p gc.collect() The __del__ method would need to clean up the external resources used by this object, but wouldn't have to walk the tree. Yet, just because there is a reference loop and there are __del__ methods, the garbage collector gives up and leaves it to the program author to deal with. I can understand if this is considered too complicated and too unusual a circumstance to be worth bothering to support, but I'm curious as to whether it's at least conceptually reasonable to do something like this. ChrisA I don't see what your special temporary object actually accomplishes. Seems to me you need to declare that your __del__() methods promise not to reference each other, and the gc would then check all objects in the cycle, and do its present behavior if any of the destructors is not specially declared. I'm not sure how often you'd have a non-trivial destructor that wouldn't reference any objects. And doing a static analysis of what will happen during the destructor would be pretty messy. So the best I and come up with is to keep the declaration, but require a try/catch to cleanly terminate each destructor if it ever references anything in the tree. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On 04/26/2013 01:28 PM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel d...@davea.name wrote: On 04/26/2013 11:05 AM, Chris Angelico wrote: I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. fileinput.Fileinput class already creates the temp file when you specify inplace=True If it didn't, I'd also have to point out the hazards of doing in-place updates in a text file where the new data and old is a different length. There still may be reasons to make an explicit backup, but I don't know what they are. That's true if something goes wrong during the actual writing of the file only. But if the process bombs in the middle of the execution phase (which in the Python script is a single os.system() call), then the file will have been one-way changed on the disk - hence, damaged. The explicit temporary file (and executing the temp file) is a much safer way to do it. Only two of those sentences makes sense to me. I have no idea what execution phase means, and don't know what would be done via an os.system() call. I don't know what one-way change means If I were specifying the fileinput stuff, I'd have said the new data should be written to the temp file, so that at no time was the original file in an in-between state. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Sat, Apr 27, 2013 at 3:42 AM, Dave Angel da...@davea.name wrote: I don't see what your special temporary object actually accomplishes. Seems to me you need to declare that your __del__() methods promise not to reference each other, and the gc would then check all objects in the cycle, and do its present behavior if any of the destructors is not specially declared. It wouldn't be declared; it'd simply throw an exception if anything different happened. I'm not sure how often you'd have a non-trivial destructor that wouldn't reference any objects. And doing a static analysis of what will happen during the destructor would be pretty messy. So the best I and come up with is to keep the declaration, but require a try/catch to cleanly terminate each destructor if it ever references anything in the tree. And yeah. If you catch the exception inside __del__, you can cope with the destructed object yourself (or LBLY, if you wish). Alternatively, you just proceed as normal, and when your __del__ throws an exception, the gc then copes (not sure *how* it should cope - log it to stderr and carry on?). Same as normal exception handling. The advantage of this style is that the code to deal with the cycle is kept right in the cyclic object's destructor - right where the problem is. Doing it through gc.garbage requires that some other operation periodically check for garbage - after the GC has done its own periodic check. Seems simpler/cleaner to do it as part of the gc run itself. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On Sat, Apr 27, 2013 at 3:52 AM, Dave Angel da...@davea.name wrote: On 04/26/2013 01:28 PM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 3:23 AM, Dave Angel d...@davea.name wrote: On 04/26/2013 11:05 AM, Chris Angelico wrote: I've checked out what fileinput.input() is doing here (ought to have done that earlier, sorry!) and I now understand this block of code more. You're replacing that word _in the file, on disk_, and then making the inverse replacement. This strikes me as dangerous; if anything happens to your process in the middle, the file will be damaged on disk. I would STRONGLY recommend rewriting this to use some other file - for instance, a temporary file. fileinput.Fileinput class already creates the temp file when you specify inplace=True If it didn't, I'd also have to point out the hazards of doing in-place updates in a text file where the new data and old is a different length. There still may be reasons to make an explicit backup, but I don't know what they are. That's true if something goes wrong during the actual writing of the file only. But if the process bombs in the middle of the execution phase (which in the Python script is a single os.system() call), then the file will have been one-way changed on the disk - hence, damaged. The explicit temporary file (and executing the temp file) is a much safer way to do it. Only two of those sentences makes sense to me. I have no idea what execution phase means, and don't know what would be done via an os.system() call. I don't know what one-way change means If I were specifying the fileinput stuff, I'd have said the new data should be written to the temp file, so that at no time was the original file in an in-between state. Here's a massive simplification of the OP's program: 1. Build a list of device IDs 2. Edit the file firstdev.ahk and replace all instances of device with the device ID 3. Execute the now-edited firstdev.ahk using os.system() 4. Reverse the edit of firstdev.ahk, replacing all instances of the device ID with the word device. Apart from the risk of accidentally changing back something that wasn't changed in the first place (which the OP may know to be impossible, eg if the macro file has no numbers in it), this has the risk that a computer failure in step 3 will leave the file on disk in its edited state. That's what I'm concerned about. By writing the modified .ahk content to a different file and then executing the other file, he would avoid editing the template at all. It'd also then be multi-process safe, for what that's worth. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyxl] Re: xlrd 0.9.2 released!
Hi Ondrej, I don't know what a Fedora/EPEL update is. If you're going to have two versions, I would suggest: 0.7.9 - for backwards compatibility with Python 2.5 and less, and older 0.6 and 0.7 xlrd releases. 0.9.2 - for Python 3 support, and with the latest and greatest features. cheers, Chris On 23/04/2013 12:24, Ondrej Ján wrote: Hello. Can you please tell me, how compatible is this version with older versions? In Fedora/CentOS we have versions 0.7 and 0.6. Can I release and Fedora/EPEL update to 0.9.2? Thank you. SAL Dňa utorok, 9. apríla 2013 21:38:30 UTC+2 Chris Withers napísal(-a): Hi All, I'm pleased to announce the release of xlrd 0.9.2: http://pypi.python.org/pypi/xlrd/0.9.2 http://pypi.python.org/pypi/xlrd/0.9.2 This release includes the following changes: - Fix some packaging issues that meant docs and examples were missing from the tarball. - Fixed a small but serious regression that caused problems opening .xlsx files. If you find any problems, please ask about them on the python...@googlegroups.com javascript: list, or submit an issue on GitHub: https://github.com/python-excel/xlrd/issues https://github.com/python-excel/xlrd/issues Full details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message because you are subscribed to the Google Groups python-excel group. To unsubscribe from this group and stop receiving emails from it, send an email to python-excel+unsubscr...@googlegroups.com. To post to this group, send an email to python-ex...@googlegroups.com. Visit this group at http://groups.google.com/group/python-excel?hl=en-GB. For more options, visit https://groups.google.com/groups/opt_out. __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __ -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: QTableWidget updating columns in a single row
On Wednesday, April 24, 2013 11:51:04 AM UTC-7, Vincent Vande Vyvre wrote: Thanks. I think I should be able to figure out from here. I appreciate all of the help! Le 24/04/2013 19:12, Sara Lochtie a écrit : On Tuesday, April 23, 2013 11:22:29 PM UTC-7, Sara Lochtie wrote: I have written a GUI that gets data sent to it in real time and this data is displayed in a table. Every time data is sent in it is displayed in the table in a new row. My problem is that I would like to have the data just replace the old in the first row. The table has 6 columns (A, B, C, D, E, F) I want the new data to continue replacing the old data in the same row unless the data that goes under column A changes, at which point a new row would be added. Does anyone have tips on how to approach this? I can post a portion of my code to get a better idea of what I have done. So that is where I am stuck. I don't how to compare them and I am trying to avoiding saving the data to a file. This is the code that I have: if msg.arg2() != ERROR: entry = (A, B, C, D, E, F) self.data.append(entry) data = self.data # Display how many runs occurred self.statusBar().showMessage('Data read. %s Run(s) Occurred.' % self.runCount) # Populates table by adding only new entries to the end of the table lastRow = self.table.rowCount() self.table.setRowCount(len(data)) for entryPos in range(lastRow, len(data)): for fieldPos in range(6): item = QtGui.QTableWidgetItem(str(data[entryPos][fieldPos])) self.table.setItem(entryPos, fieldPos, item) self.table.resizeColumnsToContents() self.table.horizontalHeader().setStretchLastSection(True) self.currentRunLabel.setText('Current Run: ' + str(self.runCount)) self.currentLineLabel.setText('Number of lines: ' + str(len(self.data))) print('End of %s. run:%s. entries found' % (self.runCount, len(self.data))) As sayed by Chris Kwpolska, you can compare the new data with the data of the first row. Something like that: # Get the content of row 0, column A first = str(self.table.item(0, 0).text()) for entryPos in range(lastRow, len(data)): if str(data[entryPos][0]) == first: self.update_first_row(data[entryPos]) else: self.add_new_row(data[entryPos]) -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: Can't convert 'int' object to str implicitly
On 04/26/2013 02:02 PM, Chris Angelico wrote: SNIP Here's a massive simplification of the OP's program: 1. Build a list of device IDs 2. Edit the file firstdev.ahk and replace all instances of device with the device ID 3. Execute the now-edited firstdev.ahk using os.system() 4. Reverse the edit of firstdev.ahk, replacing all instances of the device ID with the word device. Apart from the risk of accidentally changing back something that wasn't changed in the first place (which the OP may know to be impossible, eg if the macro file has no numbers in it), this has the risk that a computer failure in step 3 will leave the file on disk in its edited state. That's what I'm concerned about. By writing the modified .ahk content to a different file and then executing the other file, he would avoid editing the template at all. It'd also then be multi-process safe, for what that's worth. OK, thanks. That makes perfect sense. Somehow I missed that it was the altered file that was being used as a script. I just assumed it was like a config file for some program, where the name is hardwired. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On 04/26/2013 01:57 PM, Chris Angelico wrote: On Sat, Apr 27, 2013 at 3:42 AM, Dave Angel da...@davea.name wrote: I don't see what your special temporary object actually accomplishes. Seems to me you need to declare that your __del__() methods promise not to reference each other, and the gc would then check all objects in the cycle, and do its present behavior if any of the destructors is not specially declared. It wouldn't be declared; it'd simply throw an exception if anything different happened. I'm not sure how often you'd have a non-trivial destructor that wouldn't reference any objects. And doing a static analysis of what will happen during the destructor would be pretty messy. So the best I and come up with is to keep the declaration, but require a try/catch to cleanly terminate each destructor if it ever references anything in the tree. And yeah. If you catch the exception inside __del__, you can cope with the destructed object yourself (or LBLY, if you wish). Alternatively, you just proceed as normal, and when your __del__ throws an exception, the gc then copes (not sure *how* it should cope - log it to stderr and carry on?). Same as normal exception handling. The advantage of this style is that the code to deal with the cycle is kept right in the cyclic object's destructor - right where the problem is. Doing it through gc.garbage requires that some other operation periodically check for garbage - after the GC has done its own periodic check. Seems simpler/cleaner to do it as part of the gc run itself. You must think me dense by now. But I don't understand what the two different garbage collection operations are that you're positing. As far as I know, there's ref counting, which is quick, and frees something as soon as the count goes to zero. Then there's gc, which has to scan through all the objects from a known starting set, and identify those things which aren't accessible, and free any that don't have a __del__() method. And it's only in the gc step that cycles and such are identifiable. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: [pyxl] Re: xlrd 0.9.2 released!
Hello, Fedora is an Linux distribution maintained by Red Hat. (www.fedoraproject.org). EPEL are packages fro Red Hat Enterprise Linux and CentOS Linux distribution. As an maintainer I am creating and updating packages available for these distributions. If users have python-xlrd installed, package maintainer should release only updates, which are API compatible with older versions. Both Fedora and CentOS has python=2.6, python3 is available for Fedora too (no plans to release python3-xlrd now). So can I release an update for all my Linux distributions with backward compatibility of this package? xlrd-0.8 was requested for xlsx support. Are there some howtos describing upgrading applications using xlrd to newer versions? These documents can help me to choose, if I can release an update. Thank you SAL On Fri, Apr 26, 2013 at 06:47:08PM +0100, Chris Withers wrote: Hi Ondrej, I don't know what a Fedora/EPEL update is. If you're going to have two versions, I would suggest: 0.7.9 - for backwards compatibility with Python 2.5 and less, and older 0.6 and 0.7 xlrd releases. 0.9.2 - for Python 3 support, and with the latest and greatest features. cheers, Chris On 23/04/2013 12:24, Ondrej Ján wrote: Hello. Can you please tell me, how compatible is this version with older versions? In Fedora/CentOS we have versions 0.7 and 0.6. Can I release and Fedora/EPEL update to 0.9.2? Thank you. SAL Dňa utorok, 9. apríla 2013 21:38:30 UTC+2 Chris Withers napísal(-a): Hi All, I'm pleased to announce the release of xlrd 0.9.2: http://pypi.python.org/pypi/xlrd/0.9.2 http://pypi.python.org/pypi/xlrd/0.9.2 This release includes the following changes: - Fix some packaging issues that meant docs and examples were missing from the tarball. - Fixed a small but serious regression that caused problems opening .xlsx files. If you find any problems, please ask about them on the python...@googlegroups.com javascript: list, or submit an issue on GitHub: https://github.com/python-excel/xlrd/issues https://github.com/python-excel/xlrd/issues Full details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message because you are subscribed to the Google Groups python-excel group. To unsubscribe from this group and stop receiving emails from it, send an email to python-excel+unsubscr...@googlegroups.com. To post to this group, send an email to python-ex...@googlegroups.com. Visit this group at http://groups.google.com/group/python-excel?hl=en-GB. For more options, visit https://groups.google.com/groups/opt_out. __ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com __ -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Automatic context managers
Chris Angelico於 2013年4月27日星期六UTC+8上午12時52分38秒寫道: On Sat, Apr 27, 2013 at 1:54 AM, MRAB pyt...@mrabarnett.plus.com wrote: On 26/04/2013 14:02, anatoly techtonik wrote: This circular reference problem is interesting. In object space it probably looks like a stellar detached from the visible (attached) universe. Is the main problem in detecting it? The problem is in knowing in which order the objects should be collected. For example, if A refers to B and B refers to A, should you collect A then B, or B then A? If you collect A first, then, for a time, B will be referring to a non-existent object. That's not good if the objects have destructors which need to be run. Spin-off thread from python-ideas to discuss a more general question of garbage collection of cyclic structures. Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. Is this a plausible (never mind viable yet, just conceptually plausible) alternative to sticking them into gc.garbage and ignoring them? It'd allow a double-linked list/tree to function cleanly - imagine, for instance, something like the DOM facilities available to web browser scripts: class DOMObject: def __init__(self,parent): self.parent=parent self.firstchild=self.sibling=None if not parent: return if not parent.firstchild: parent.firstchild=self else: child=parent.firstchild while child.sibling: child=child.sibling child.sibling=self def __del__(self): print(Disposing of id #%d%id(self)) document=DOMObject(None) body=DOMObject(document) p=DOMObject(body) p=DOMObject(body) p=DOMObject(body) del document,body,p gc.collect() The __del__ method would need to clean up the external resources used by this object, but wouldn't have to walk the tree. Yet, just because there is a reference loop and there are __del__ methods, the garbage collector gives up and leaves it to the program author to deal with. I can understand if this is considered too complicated and too unusual a circumstance to be worth bothering to support, but I'm curious as to whether it's at least conceptually reasonable to do something like this. ChrisA Please use the deep-copy methods from time to time to disentangle referenced objects in python. The cyclic reference cycle has to be broken by some mean first in python to proceed for further actions in the gc. -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Fri, Apr 26, 2013 at 10:54 AM, Chris Angelico ros...@gmail.com wrote: Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. I think it still boils down to the same problem -- how should Python *predictably* choose which object will be disposed of in order to break the cycle? I don't see that this question is any different than asking how should Python choose which __del__ method should be called first, since the object so disposed of would still need its __del__ method called. -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Fri, Apr 26, 2013 at 1:31 PM, Dave Angel da...@davea.name wrote: On 04/26/2013 01:57 PM, Chris Angelico wrote: And yeah. If you catch the exception inside __del__, you can cope with the destructed object yourself (or LBLY, if you wish). Alternatively, you just proceed as normal, and when your __del__ throws an exception, the gc then copes (not sure *how* it should cope - log it to stderr and carry on?). Same as normal exception handling. The advantage of this style is that the code to deal with the cycle is kept right in the cyclic object's destructor - right where the problem is. Doing it through gc.garbage requires that some other operation periodically check for garbage - after the GC has done its own periodic check. Seems simpler/cleaner to do it as part of the gc run itself. You must think me dense by now. But I don't understand what the two different garbage collection operations are that you're positing. As far as I know, there's ref counting, which is quick, and frees something as soon as the count goes to zero. Then there's gc, which has to scan through all the objects from a known starting set, and identify those things which aren't accessible, and free any that don't have a __del__() method. And it's only in the gc step that cycles and such are identifiable. Whenever the GC finds a cycle that is unreferenced but uncollectable, it stores those objects in the list gc.garbage. At that point, if the user wishes to clean up those cycles, it is up to them to delve into gc.garbage, untangle the objects contained within, break the cycles, and remove them from the list so that they can be freed by the ref counter. This user-supplied step is what Chris is referring to as some other periodic check. If the user does not do this, then those objects simply remain in the gc.garbage list until the program terminates. -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On 04/26/2013 06:43 PM, Ian Kelly wrote: SNIP Whenever the GC finds a cycle that is unreferenced but uncollectable, it stores those objects in the list gc.garbage. At that point, if the user wishes to clean up those cycles, it is up to them to delve into gc.garbage, untangle the objects contained within, break the cycles, and remove them from the list so that they can be freed by the ref counter. This user-supplied step is what Chris is referring to as some other periodic check. If the user does not do this, then those objects simply remain in the gc.garbage list until the program terminates. I didn't know there was a callback that a user could hook into. That's very interesting. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On 04/26/2013 06:50 PM, Ian Kelly wrote: On Fri, Apr 26, 2013 at 10:54 AM, Chris Angelico ros...@gmail.com wrote: Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. I think it still boils down to the same problem -- how should Python *predictably* choose which object will be disposed of in order to break the cycle? I don't see that this question is any different than asking how should Python choose which __del__ method should be called first, since the object so disposed of would still need its __del__ method called. Perhaps if the __del__ methods disposed of the non-cyclic parts first, an exception doing the cyclic cleanups wouldn't hurt. Picture a doubly-linked list of file-type objects. Each one could release its file before trying to do anything with the links. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
Whenever the GC finds a cycle that is unreferenced but uncollectable, it stores those objects in the list gc.garbage. At that point, if the user wishes to clean up those cycles, it is up to them to delve into gc.garbage, untangle the objects contained within, break the cycles, and remove them from the list so that they can be freed by the ref counter. I wonder if it would be useful to provide a gc.garbagehook analogous to sys.excepthook? Users could assign a function of their choice to much the cyclic garbage periodically. Just a thought, flying out of my fingers before my brain could stop it... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Sat, Apr 27, 2013 at 8:50 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Apr 26, 2013 at 10:54 AM, Chris Angelico ros...@gmail.com wrote: Once it's been proven that there's an unreferenced cycle, why not simply dispose of one of the objects, and replace all references to it (probably only one - preferably pick an object with the fewest references) with a special temporary object? In fact, that could probably be done in CPython by wiping out the object in memory and replacing it with a special marker of some sort, which would then automatically take over all references to the old object. Any attempt to manipulate this object could simply pop back with a DestructedObject exception or something. I think it still boils down to the same problem -- how should Python *predictably* choose which object will be disposed of in order to break the cycle? I don't see that this question is any different than asking how should Python choose which __del__ method should be called first, since the object so disposed of would still need its __del__ method called. It wouldn't need to. It just chooses arbitrarily. Maybe it picks the one with the lowest id(), maybe it picks the object that takes up the most space, maybe the one that would have been put into gc.garbage first. But it's got to die tomorrow, so it really doesn't matter[1], and there's no way for the GC to know which one won't be referenced by the other's __del__ method. [1] I'm involved in a Gilbert and Sullivan Society performance, curtain up in less than three hours, so I'm morally obligated to quote GS somewhere. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Sat, Apr 27, 2013 at 9:45 AM, Dave Angel da...@davea.name wrote: I didn't know there was a callback that a user could hook into. That's very interesting. On Sat, Apr 27, 2013 at 10:22 AM, Skip Montanaro s...@pobox.com wrote: Whenever the GC finds a cycle that is unreferenced but uncollectable, it stores those objects in the list gc.garbage. At that point, if the user wishes to clean up those cycles, it is up to them to delve into gc.garbage, untangle the objects contained within, break the cycles, and remove them from the list so that they can be freed by the ref counter. I wonder if it would be useful to provide a gc.garbagehook analogous to sys.excepthook? Users could assign a function of their choice to much the cyclic garbage periodically. Just a thought, flying out of my fingers before my brain could stop it... As far as I know, Dave, there isn't currently one; Skip, that's close to what I'm talking about - it saves on the periodic check. But burying it in gc.garbagehook implies having a separate piece of code that knows how to break the reference cycles, whereas the __del__ method puts the code right there in the code that has the problem. Actually, *ANY* solution to this problem implies having __del__ able to cope with the cycle being broken. Here's an example, perhaps a silly one, but not far different in nature from some things I've done in C++. (Granted, all the Python implementations of those same algorithms have involved built-in types rather than linked lists, but still.) class DLCircList: def __init__(self,payload): self.payload=payload self.next=self.prev=self print(Creating node: %s%self.payload) def __del__(self): print(Deleting node %s from cycle %s%(self.payload,self.enum())) self.prev.next=self.next self.next.prev=self.prev def attach(self,other): assert(self.next==self) # Don't attach twice self.prev=other self.next=other.next other.next=self self.next.prev=self print(Adding node %s to cycle %s%(self.payload,self.enum())) def enum(self): Return a list of all node payloads in this cycle. ptr=self.next nodes=[self.payload] while ptr!=self: nodes.append(ptr.payload) ptr=ptr.next return nodes lst=DLCircList(foo) DLCircList(bar).attach(lst) DLCircList(quux).attach(lst) DLCircList(asdf).attach(lst) DLCircList(qwer).attach(lst) DLCircList(zxcv).attach(lst) print(Enumerating list: %s%lst.enum()) del lst import gc gbg=gc.collect() print(And we have garbage: %s%gbg) print(gc.garbage) Supposing you did this many many times, and you wanted decent garbage collection. How would you write a __del__ method, how would you write something to clean up gc.garbage? One way or another, something will have to deal with the possibility that the invariants have been broken, so my theory is that that possibility should be entirely within __del__. (Since __del__ calls enum(), it's possible for enum() to throw DestructedObject or whatever, but standard exception handling will deal with that.) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
From the Zen of Python: In the face of ambiguity, refuse the temptation to guess. I believe the reason something isn't already done to break cycles is that the authors of the cyclic garbage collector considered the above aphorism. They rely on the author of the code with the cycles to figure out how to break them. All I was suggesting was that Python could provide a hook where the programmer could codify his algorithm for breaking cycles. Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython's cyclic garbage collector (was [Python-ideas] Automatic context managers)
On Sat, Apr 27, 2013 at 12:12 PM, Skip Montanaro s...@pobox.com wrote: From the Zen of Python: In the face of ambiguity, refuse the temptation to guess. I believe the reason something isn't already done to break cycles is that the authors of the cyclic garbage collector considered the above aphorism. They rely on the author of the code with the cycles to figure out how to break them. All I was suggesting was that Python could provide a hook where the programmer could codify his algorithm for breaking cycles. Sure, and that makes good sense. The hook would be an improvement (maybe it gets passed a list of garbage that's about to be added to gc.garbage, but will be re-checked for cycles after the hook, so all you have to do is break the cycle in the hook and it'll work), but the implication is that an external piece of code knows about the possible cycles and how to deal with them. I'd really rather have something right there in the class. Effectively, something like this: whenever gc.garbage has content: turn_into(gc.garbage[0],None) # or a special I am destroyed object del gc.garbage[:] It doesn't matter which one gets taken out. Yes, I suppose that's a form of guessing, but whatever rules get put in place - whether by the language or by your own script - it'll always be possible to conjure a scenario where tossing a coin is the only way to pick which one goes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: baffled classes within a function namespace. Evaluation order.
On Fri, 26 Apr 2013 09:15:51 +0200, Peter Otten wrote: Define a global variable x and run it again. I don't have an ancient Python lying around but my prediction is x = 42 f().x 42 which would be the same behaviour as that of Python 3.3. /facepalm You're absolutely right. Sorry for the noise. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
File Read issue by using module binascii
When I run the readbmp on an example.bmp(about 100k),the Shell is become to No respose,when I change f.read() to f.read(1000),it is ok,could someone tell me the excat reason for this? Thank you in advance! Python Code as below!! import binascii def read_bmp(): f = open('example.bmp','rb') rawdata = f.read() #f.read(1000) is ok hexstr = binascii.b2a_hex(rawdata) #Get an HEX number bsstr = bin (int(hexstr,16))[2:] f.close() print('bin: ',bsstr,type(bsstr)) return -- http://mail.python.org/mailman/listinfo/python-list
Re: File Read issue by using module binascii
when I commet the line of print('bin: ',bsstr,type(bsstr)) ,it can be run,so maybe the problem is the memory allocate of so long strings..Am I right? 在 2013年4月27日星期六UTC+8上午11时57分45秒,Jimmie He写道: When I run the readbmp on an example.bmp(about 100k),the Shell is become to No respose,when I change f.read() to f.read(1000),it is ok,could someone tell me the excat reason for this? Thank you in advance! Python Code as below!! import binascii def read_bmp(): f = open('example.bmp','rb') rawdata = f.read() #f.read(1000) is ok hexstr = binascii.b2a_hex(rawdata) #Get an HEX number bsstr = bin (int(hexstr,16))[2:] f.close() print('bin: ',bsstr,type(bsstr)) return -- http://mail.python.org/mailman/listinfo/python-list
[issue17845] Clarify successful build message
Ezio Melotti added the comment: See also #13472 for a related discussion. -- keywords: +easy stage: - needs patch type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17810] Implement PEP 3154 (pickle protocol 4)
Charles-François Natali added the comment: I would like to see Proto4 include an option for compression (zlib,bz2) or somesuch and become self-decompressing upon unpickling. I don't see what this would bring over explicit compression: - depending on the use case, you may want to use different compression algorithms, e.g. for disk you may want higher compression ratio like bzip2/lzma, but for wire you'd prefer something fast like snappy - supporting multiple compression algorithms and levels would complicate the API - this would probably complicate the code, since you'd have to support optional compression, and have a way to indicate which format is used - that's really mixing two entirely different concepts (serialization vs compression) -- nosy: +neologix ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17810 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17810] Implement PEP 3154 (pickle protocol 4)
Antoine Pitrou added the comment: I don't see what this would bring over explicit compression: - depending on the use case, you may want to use different compression algorithms, e.g. for disk you may want higher compression ratio like bzip2/lzma, but for wire you'd prefer something fast like snappy - supporting multiple compression algorithms and levels would complicate the API - this would probably complicate the code, since you'd have to support optional compression, and have a way to indicate which format is used - that's really mixing two entirely different concepts (serialization vs compression) I agree with Charles-François. A feature that may be actually nice to have in the pickle protocol would be some framing, to help with streaming unpickling (right now unpickling a stream can read almost one byte at a time, IIRC). However, that would also make the protocol and the pickler significantly more complex. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17810 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6028] Interpreter aborts when chaining an infinite number of exceptions
Antoine Pitrou added the comment: Closing as won't fix. There is no sane way around the current behaviour. -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6028 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17794] Priority Queue
Changes by Mark Dickinson dicki...@gmail.com: Removed file: http://bugs.python.org/file30019/issue17794.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17794] Priority Queue
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: -mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17794 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13355] random.triangular error when low = high=mode
Mark Dickinson added the comment: Raymond: have you had time to look at this yet? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17839] base64 module should use memoryview
Kushal Das added the comment: A patch with tests update to use memoryview in base64 module. -- keywords: +patch Added file: http://bugs.python.org/file30022/issue17839_v1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17810] Implement PEP 3154 (pickle protocol 4)
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17810 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17848] issue about compile with clang and build a shared lib
New submission from leon zheng: build with prefix point to a arbitrary path, can't find the dynamic lib, and libffi upstream bug: ./configure --prefix=xxx --enable-shared --enable-ipv6 --with-threads CC=clang -- components: Build files: mywork.pitch messages: 187838 nosy: matrixsystem priority: normal severity: normal status: open title: issue about compile with clang and build a shared lib type: compile error versions: Python 3.4 Added file: http://bugs.python.org/file30023/mywork.pitch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17848 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13355] random.triangular error when low = high=mode
Raymond Hettinger added the comment: Soonish -- priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17826] Setting a side_effect on mock from create_autospec doesn't work
Michael Foord added the comment: This illustrates the difference: from mock import Mock, create_autospec some_list = [1, 2, 3] m = Mock() m.side_effect = some_list m.side_effect listiterator object at 0x1004ab7d0 m2 = create_autospec(lambda: None) m2.side_effect = some_list m2.side_effect [1, 2, 3] When setting a side_effect on a function (created by create_autospec) the side_effect setter is not used - so turning the list into an iterator needs to be done on first use instead. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17839] base64 module should use memoryview
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti stage: needs patch - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15693] expose glossary link on hover
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15693 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper
New submission from Miroslav Stampar: httplib module's auxiliary class LineAndFileWrapper contains a readline() method having no arguments (than self). It's being used in code where commented with assume it's a Simple-Response from an 0.9 server as a wrapper for response stream (self.fp = LineAndFileWrapper(line, self.fp)). In some cases readline() method requires a size argument (e.g. used with size argument inside HTTPMessage/readheaders(), HTTPResponse/begin(), HTTPResponse/_read_chunked, HTTPConnection/_tunnel, at least in Python 2.7.1+ (r271:86832, Sep 27 2012, 21:12:17)). This bug is hard to be reproduced as it requires a little help of divine intervention. One such exception looks like (reproduced on one user machine): ... conn = urllib2.urlopen(req) File /usr/lib/python2.7/urllib2.py, line 127, in urlopen return _opener.open(url, data, timeout) File /usr/lib/python2.7/urllib2.py, line 401, in open response = self._open(req, data) File /usr/lib/python2.7/urllib2.py, line 419, in _open '_open', req) File /usr/lib/python2.7/urllib2.py, line 379, in _call_chain result = func(*args) File /usr/share/sqlmap/lib/request/httpshandler.py, line 64, in https_open return self.do_open(HTTPSConnection if ssl else httplib.HTTPSConnection, req) File /usr/lib/python2.7/urllib2.py, line 1178, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File /usr/lib/python2.7/httplib.py, line 962, in request self._send_request(method, url, body, headers) File /usr/lib/python2.7/httplib.py, line 996, in _send_request self.endheaders(body) File /usr/lib/python2.7/httplib.py, line 958, in endheaders self._send_output(message_body) File /usr/lib/python2.7/httplib.py, line 818, in _send_output self.send(msg) File /usr/lib/python2.7/httplib.py, line 780, in send self.connect() File /usr/share/sqlmap/lib/request/httpshandler.py, line 46, in connect sock = create_sock() File /usr/share/sqlmap/lib/request/httpshandler.py, line 39, in create_sock self._tunnel() File /usr/lib/python2.7/httplib.py, line 748, in _tunnel line = response.fp.readline(_MAXLINE + 1) TypeError: readline() takes exactly 1 argument (2 given) -- components: Library (Lib) messages: 187841 nosy: stamparm priority: normal severity: normal status: open title: Missing size argument in readline() method for httplib's class LineAndFileWrapper versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper
Miroslav Stampar added the comment: Mentioned divine intervention could be: 1) Argument strict should be set to 0/False when instantiating HTTPResponse 2) No status should be returned from the backend server (hence the # assume it's a Simple-Response from an 0.9 server) 3) Any part of response should be read (body, headers, etc.) as HTTPResponse's method begin() uses self.fp.readline(_MAXLINE + 1) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17721] Help button on preference window doesn't work
Guilherme Simões added the comment: Attached is a patch that removes the Help button from the Preferences window. Maybe it would be nice to have the Help button open a text file describing every possible option, but while this doesn't happen it is better to remove this button. -- keywords: +patch Added file: http://bugs.python.org/file30024/Issue17721.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17721 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17826] Setting a side_effect on mock from create_autospec doesn't work
Kushal Das added the comment: Working on this. -- nosy: +kushaldas ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17826] Setting a side_effect on mock from create_autospec doesn't work
Kushal Das added the comment: Patch along with a test for the same. -- keywords: +patch Added file: http://bugs.python.org/file30025/issue17826_v1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17826 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16133] asyncore.dispatcher.recv doesn't handle EAGAIN / EWOULDBLOCK
Giampaolo Rodola' added the comment: I confirm I can reproduce this issue also in pyftpdlib: https://code.google.com/p/pyftpdlib/issues/detail?id=255 Current proposed patch returning '' is not ideal as for asynchat '' is an alias for 'connection lost'. In summary recv() in case of EAGAIN should return None and asynchat.handle_read() should take that into account. Will provide a patch later. -- assignee: - giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16133 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17837] Support for building on ppc64p7
David Edelsohn added the comment: If you look at the top of config.sub it says: # Please send patches with a ChangeLog entry to config-patc...@gnu.org. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD I do not know Python's policy on merging these types of patches, but most projects want the patch in the upstream repository from which they import. They do not need to update to the latest, but at least backport the patch from config.sub HEAD instead of diverging and potentially losing the patch with the next update. I do not see your patch there now. I'm surprised that it's not there already if needed for Fedora. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17837 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16133] asyncore.dispatcher.recv doesn't handle EAGAIN / EWOULDBLOCK
Giampaolo Rodola' added the comment: Patch is in attachment. I'm a bit worried about Python versions 3.4 because this kinds of breaks backward compatibility as recv() is not expected to return None but I see no other saner solution. -- keywords: +patch Added file: http://bugs.python.org/file30026/issue16133.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16133 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17837] Support for building on ppc64p7
Bohuslav Slavek Kabrda added the comment: Hmm, good point. I'll try to discuss with Fedora people who work on secondary arches. Thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17837 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper
R. David Murray added the comment: Thanks for the report. Looks like it is a fairly rare case, which I suppose is why it hasn't been reported before. If the could be turns out to be sufficient, that should be enough for someone to write a test for this. The patch itself should be even easier. -- keywords: +easy nosy: +r.david.murray stage: - needs patch type: - behavior versions: -Python 2.6, Python 3.1, Python 3.2, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17837] Support for building on ppc64p7
David Edelsohn added the comment: I meant I don't see the equivalent of your patch in the upstream repository, so no one from the Fedora community appears to have contributed something equivalent yet. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17837 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17850] unicode_escape encoding fails for '\\Upsilon'
New submission from Edward K. Ream: On both windows and Linux the following fails on Python 2.7: s = '\\Upsilon' unicode(s,unicode_escape) UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-7: end of string in escape sequence BTW, the six.py package uses this call. If this call doesn't work, six is broken. -- components: Library (Lib) messages: 187852 nosy: Edward.K..Ream priority: normal severity: normal status: open title: unicode_escape encoding fails for '\\Upsilon' type: crash versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17850] unicode_escape encoding fails for '\\Upsilon'
Ezio Melotti added the comment: This is not a bug, \U should be followed by 8 hex digits and it indicates a Unicode codepoint: '\\u0065'.decode('unicode_escape') u'e' '\\U0065'.decode('unicode_escape') u'e' '\\Upsilon'.decode('unicode_escape') Traceback (most recent call last): File stdin, line 1, in module UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-7: end of string in escape sequence u'\Upsilon' File stdin, line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-7: end of string in escape sequence u'\U0065' u'e' -- nosy: +ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed type: crash - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17850] unicode_escape encoding fails for '\\Upsilon'
Edward K. Ream added the comment: Thanks for your quick reply. If this is not a bug, why does six define six.u as unicode(s,unicode_escape) for *all* u constants?? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17850] unicode_escape encoding fails for '\\Upsilon'
R. David Murray added the comment: Because as Ezio demonstrated, it produces the same result as using the 'u' prefix on the same string. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper
Serhiy Storchaka added the comment: Python 3.3 doesn't support HTTP/0.9 and doesn't have LineAndFileWrapper class. -- nosy: +christian.heimes, serhiy.storchaka versions: -Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17838] Can't assign a different value for sys.stdin in IDLE
Roger Serwy added the comment: If we remove .close() then we'll need to then have an alternative way to allow exit() and quit() to actually close IDLE. The RPC proxy already transfers exceptions between the subprocess and the front-end, so we could catch the SystemExit exception and handle it by calling close(). That's perfectably doable, and likely the right way to do it. If anyone wants to write that patch, I'll gladly offer guidance if necessary. Here's a dirty hack that also solves the issue. Garbage collection on the PseudoInputFile for sys.stdin calls .close(). As long as we hold an extra reference to it, it won't close. The attached patch holds an extra reference to sys.stdin in Lib/idlelib/run.py. -- keywords: +patch Added file: http://bugs.python.org/file30027/hold_stdin.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17838 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17850] unicode_escape encoding fails for '\\Upsilon'
Edward K Ream added the comment: On Fri, Apr 26, 2013 at 8:51 AM, Edward K. Ream rep...@bugs.python.orgwrote: If this is not a bug, why does six define six.u as unicode(s,unicode_escape) for *all* u constants?? Oops. The following works:: s = r'\\Upsilon' unicode(s,unicode_escape) My apologies for the noise. Edward -- nosy: +edreamleo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17850 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17721] Help button on preference window doesn't work
Changes by Roger Serwy roger.se...@gmail.com: -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17721 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17842] Add base64 module tests for a bytearray argument
Serhiy Storchaka added the comment: Needed tests for decoders. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17842 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11218] pattern=None when following documentation for load_tests and unittest.main()
Changes by vila v.ladeuil+bugs-pyt...@free.fr: -- nosy: +vila ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11218 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16662] load_tests not invoked in package/__init__.py
Changes by vila v.ladeuil+bugs-pyt...@free.fr: -- nosy: +vila ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16662 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17839] base64 module should use memoryview
Serhiy Storchaka added the comment: Not only memoryview should be supported, but any class which supports the buffer protocol and is C-contiguous (i.e. array.array). -- nosy: +serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16316] Support xz compression in mimetypes module
Serhiy Storchaka added the comment: Xz-related mimetypes was added because Python 3.3+ supports xz compression. Backporting them to 3.3 makes sense. But backporting to 2.7 is more questionable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16316 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15535] Fix pickling efficiency of named tuples in 2.7.3
Antoine Pitrou added the comment: I would like to call this a critical regression. Under 2.7 and 3.2, all pickle protocols are affected. Under 3.3 and 3.4, pickle protocols 0 and 1 are affected. (unfortunately, 3.2 doesn't receive bugfixes anymore) -- nosy: +benjamin.peterson, pitrou priority: high - release blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17834] Add Heap (and DynamicHeap) classes to heapq module
Antoine Pitrou added the comment: queue.PriorityQueue is a locked class for use in multi-threaded code. That's like saying Queue is a good substitute for list :-) OTOH, the proposed patch raises a lot of warning signs for me. I will wait for a decision on the feature's desirability before making a review. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17834 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17838] Can't assign a different value for sys.stdin in IDLE
Serhiy Storchaka added the comment: This issue is not important enough. We can defer fixing until a better patch will be proposed. In any case please add an explaining comment to your patch when committing it. Otherwise some future code will depend on self.stdin. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17838 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15535] Fix pickling efficiency of named tuples in 2.7.3
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +georg.brandl, larry stage: - needs patch versions: +Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15535 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17834] Add Heap (and DynamicHeap) classes to heapq module
Serhiy Storchaka added the comment: From my multilingual experience I can say that priority queue is very rarely used type of collections (but if it needed it is very usefull). On one hand, Python stdlib already contains one such type, and this type will be good enough in non-performance-critical applications. On other hand, a non-locked implementation using heapq is trivial (just encapsulate a list inside a class), no one will implement it wrong (if do not over-complicate the interface). I don't see the need for yet one priority queue. The presence of two very similar types in the stdlib will lead to confusion. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17834 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17827] Document codecs.encode and codecs.decode
Tshepang Lekhonkhobe added the comment: So, why place them in What's New? -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17827] Document codecs.encode and codecs.decode
Ezio Melotti added the comment: To advertise them? It should be explained that they are not new, but that now they are documented and can/should be used. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17827 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com