[ANN] Leipzig Python User Group - Meeting, December 14, 2010, 08:00pm
=== Leipzig Python User Group === We will meet on Tuesday, December, 14th, 8:00 pm at the training center of Python Academy in Leipzig, Germany ( http://www.python-academy.com/center/find.html ). Food and soft drinks are provided. Please send a short confirmation mail to i...@python-academy.de, so we can prepare appropriately. Everybody who uses Python, plans to do so or is interested in learning more about the language is welcome. While the meeting language will be mainly German, we will provide English translation if needed. Current information about the meetings are at http://www.python-academy.com/user-group . Stefan == Leipzig Python User Group === Wir treffen uns am Dienstag, 14. Dezember 2010 um 20:00 Uhr im Schulungszentrum der Python Academy in Leipzig ( http://www.python-academy.de/Schulungszentrum/anfahrt.html ). Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter i...@python-academy.de wäre nett, damit wir genug Essen besorgen können. Willkommen ist jeder, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Viele Grüße Stefan -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: cssutils 0.9.8a1
what is it -- A Python package to parse and build CSS Cascading Style Sheets. (Not a renderer though!) about this release -- 0.9.8a1 is an early alpha release. Please note the *major* changes in the css value API. main changes + **API CHANGE (major)** replace CSSValue with PropertyValue, Value and other classes. NEW CLASSES: :class:`cssutils.css.PropertyValue` replaces CSSValue and CSSValueList - is iterable (iterates over all single Value objects which in soruce CSS might be separated by , / or - a comma separated list of IDENT values is no longer handled as a single String (e.g. ``Arial, sans-serif``) :class:`cssutils.css.Value` replaces CSSPrimitiveValue with separate ``value`` and ``type`` info (value is typed, so e.g. string for e.g. STRING, IDENT or URI values, int or float) and is base class for more specific values like: :class:`cssutils.css.URIValue` replaces CSSPrimitiveValue, additional attribute ``uri`` :class:`cssutils.css.DimensionValue` replaces CSSPrimitiveValue, additional attribute ``dimension`` :class:`cssutils.css.ColorValue` replaces CSSPrimitiveValue, additional attribute ``red``, ``green``, ``blue`` and ``alpha`` **TODO: Not yet complete, only rgb, rgba, hsl, hsla and has values use this object and color and alpha information no done yet!** :class:`cssutils.css.CSSFunction` replaces CSSPrimitiveValue function, not complete yet also renamed ``ExpressionValue`` to :class:`cssutils.css.MSValue` with new API - IMPROVEMENT/CHANGE: Validation of color values is tighter now. Values like ``hsl(1, 2, 3)`` do not validate as it must be ``hsl(1, 2%, 3%)``. This mostly effects HSL/A and RGB/A notation. - **IMPROVEMENT**: New Value parsing and API accelerate parsing of style declarations which take about 20-30% less time now. Of course this depends on the complexity of your styles. + BUGFIX: fixes issue #41, #42, #45, #46 PropertyValue.value returns value without any comments now, else use PropertyValue.cssText - FEATURE: ``cssutils.replaceUrls()`` accepts as first argument a `cssutils.css.CSSStyleSheet` but now also a :class:`cssutils.css.CSSStyle license --- cssutils is published under the LGPL version 3 or later, see http://cthedot.de/cssutils/ If you have other licensing needs please let me know. download For download options see http://cthedot.de/cssutils/ cssutils needs Python 2.4 and higher or Jython 2.5 and higher (tested with Python 2.7.1(x64), 2.6.5(x64), 2.5.4(x32), 2.4.4(x32) and Jython 2.5.1 on Win7x64 only) Bug reports (via Google code), comments, etc are very much appreciated! Thanks. Christof -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Ways of accessing this mailing list?
Harishankar v.harishan...@gmail.com writes: The advantage of a proper newsreader [program] is that it quotes correctly (i.e. quote at top, reply below). That's a function of the person typing into it, not of the program. Placing the cursor at the top of the message allows the person to trim the superfluous parts of the quoted material, replying in-line to each point as they work their way down. -- \ “No matter how far down the wrong road you've gone, turn back.” | `\ —Turkish proverb | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Ways of accessing this mailing list?
On Sun, 12 Dec 2010 19:18:52 +1100, Ben Finney wrote: That's a function of the person typing into it, not of the program. I was talking about the default program behaviour. Yes, you can move the cursor up or down, but I was talking about the way regular e-mail clients generally handle quoted blocks. -- Harishankar (http://harishankar.org http://lawstudentscommunity.com) -- http://mail.python.org/mailman/listinfo/python-list
Re: Bind C++ program for use with both Python 2.x and 3.x
Peter C., 11.12.2010 23:41: Hello, I am looking at the possibility of making a program in C++. The catch is it will require the ability to work with binding for use with scripting in both Python 2.x and 3.x for various tool plugins. Do I read this right that you want your program to be written in C++, and use an embedded Python interpreter to provide scripting capabilities? Is there a reason you'd want to write the application itself in C++ in the first place? If it's new code, it's likely faster to write it Python directly. Usually, that also leads to a lot less code, which helps in keeping the code more maintainable. Is there any way to bind a C++ app to work with both Python 2.x and 3.x using the Python C API? Note if I could I'd just do Python 3, however I need Python 2 support to allow for the use of this application as a plugin in apps that use Python 2 as well. The easiest (and fastest etc.) way to do that is to write the glue code in Cython. It generates portable C/C++ code that supports Python 2.3 to 3.2. However, if you ship binaries, you will still need to provide them for the different Python versions (even for different Py2.x versions), as the runtimes are not binary compatible. Stefan -- http://mail.python.org/mailman/listinfo/python-list
default argument in method
Hi, I'd like to have a reference to an instance attribute as default argument in a method. It doesn't work because self is not defined at the time the method signature is evaluated. For example: class C(object): def __init__(self): self.foo = 5 def m(self, val=self.foo): return val Raises NameError because 'self' is not defined. The obvious solution is put val=None in the signature and set val to the appropriate value inside the method (if val is None: ...), but I wonder if there's another way. Cheers, Ernest -- http://mail.python.org/mailman/listinfo/python-list
Re: default argument in method
On Sun, Dec 12, 2010 at 3:35 AM, ernest nfdi...@gmail.com wrote: Hi, I'd like to have a reference to an instance attribute as default argument in a method. It doesn't work because self is not defined at the time the method signature is evaluated. For example: class C(object): def __init__(self): self.foo = 5 def m(self, val=self.foo): return val Raises NameError because 'self' is not defined. The obvious solution is put val=None in the signature and set val to the appropriate value inside the method (if val is None: ...), but I wonder if there's another way. Nope, not really. There are some more complicated slight variations on the same theme (e.g. hoisting the idiom into a decorator), but they're of fairly dubious merit; just use the straightforward idiom you already outlined. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Get careers in Management stage.
Great careers in Management work. Institutional careers in Management http://topcareer.webs.com/humanresourcemgmt.htm http://rojgars.webs.com/bankingjobs.htm Full ranges of Banking and insurance banking jobs, railway jobs opportunities to make career. http://rojgars.webs.com/bankingjobs.htm -- http://mail.python.org/mailman/listinfo/python-list
Re: class browser
On Dec 8, 11:24 pm, Adam Tauno Williams awill...@whitemice.org wrote: On Wed, 2010-12-08 at 13:18 +0530, Rustom Mody wrote: If I have a medium to large python code base to browse/study, what are the class browsers available? Monodevelop has good Python support which includes a working Python class browser for Python projects solutions. http://www.mono-project.com/Main_Page Ok downloaded mono. How do I import an existing project? -- http://mail.python.org/mailman/listinfo/python-list
Re: python-parser running Beautiful Soup needs to be reviewed
I've no opinion. I'm just struggling with BeautifulSoup myself, finding it one of the toughest libs I've seen ;-) Really? While I'm by no means an expert, I find it very easy to work with. It's very well structured IMHO. I think the cause lies in the documentation. The PySide documentation is much easier to understand (at least for me) http://www.pyside.org/docs/pyside/PySide/QtWebKit/QWebElement.html cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Objects and validation
I have a routine in Python which is extracting information from a website. This information is read and inserted into objects. I currently have all the validations and checks implemented in the routines which are reading the HTML and creating the objects. It is however also possible to move all the validations into the class itself. What is considered the best practice for this: validation in the functions which read the information and creates the objects or in the class itself? Thijs -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading by positions plain text files
On Dec 1, 7:15 am, Tim Harig user...@ilthio.net wrote: On 2010-12-01, javivd javiervan...@gmail.com wrote: On Nov 30, 11:43 pm, Tim Harig user...@ilthio.net wrote: On 2010-11-30, javivd javiervan...@gmail.com wrote: I have a case now in wich anotherfilehas been provided (besides the database) that tells me in wich column of thefileis every variable, because there isn't any blank or tab character that separates the variables, they are stick together. This secondfilespecify the variable name and his position: VARIABLE NAME POSITION (COLUMN) INFILE var_name_1 123-123 var_name_2 124-125 var_name_3 126-126 .. .. var_name_N 512-513 (last positions) I am unclear on the format of these positions. They do not look like what I would expect from absolute references in the data. For instance, 123-123 may only contain one byte??? which could change for different encodings and how you mark line endings. Frankly, the use of the world columns in the header suggests that the data *is* separated by line endings rather then absolute position and the position refers to the line number. In which case, you can use splitlines() to break up the data and then address the proper line by index. Nevertheless, you can usefile.seek() to move to an absolute offset in thefile, if that really is what you are looking for. I work in a survey research firm. the data im talking about has a lot of 0-1 variables, meaning yes or no of a lot of questions. so only one position of a character is needed (not byte), explaining the 123-123 kind of positions of a lot of variables. Thenfile.seek() is what you are looking for; but, you need to be aware of line endings and encodings as indicated. Make sure that you open thefile using whatever encoding was used when it was generated or you could have problems with multibyte characters affecting the offsets. I've tried your advice and something is wrong. Here is my code, f = open(r'c:c:\somefile.txt', 'w') f.write('0123456789\n0123456789\n0123456789') f.close() f = open(r'c:\somefile.txt', 'r') for line in f: f.seek(3,0) print f.read(1) #just to know if its printing the rigth column I used .seek() in this manner, but is not working. Let me put the problem in another way. I have .txt file with NO headers, and NO blanks between any columns. But i know that from columns, say 13 to 15, is variable VARNAME_1 (of course, a three digit var). How can extract that column in a list call VARNAME_1?? Obviously, this should extend to all the positions and variables i have to extract from the file. Thanks! J -- http://mail.python.org/mailman/listinfo/python-list
while True or while 1
I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
Am 12.12.2010 15:14, schrieb Max Countryman: I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? In Python 2.x, while 1 is slightly faster than while True. The interpreter can't optimize while True because the name True can be bind to another value. In Python 3.x it's no longer possible to rebind the names True and False just like None in Python 2.x Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On Sun, Dec 12, 2010 at 3:14 PM, Max Countryman m...@me.com wrote: I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? It's just silly to use 1 since it will evaluate to True either way. -- http://mail.python.org/mailman/listinfo/python-list
Re: Objects and validation
On 12 Gru, 15:28, pyt...@lists.fastmail.net wrote: I have a routine in Python which is extracting information from a website. This information is read and inserted into objects. I currently have all the validations and checks implemented in the routines which are reading the HTML and creating the objects. It is however also possible to move all the validations into the class itself. What is considered the best practice for this: validation in the functions which read the information and creates the objects or in the class itself? setter Data sources may differ, and may be used for many reasons, so validating data there is not a good idea. Object has to keep correct data, so it should validate it. If you want to have object created no matter what, you can add validate() method, but you may also use setters for this - error will be raised every try to set wrong data. -- http://mail.python.org/mailman/listinfo/python-list
Re: stuck with Pexpect script need help!!
On 12/10/2010 10:02 PM Darshak Bavishi said... snip Pexpect is intended for UNIX-like operating systems.) snip Can we use pexpect from windows host machine ?! I expect not... Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Ways of accessing this mailing list?
On 12/12/2010 2:07 AM Harishankar said... On Sun, 12 Dec 2010 19:18:52 +1100, Ben Finney wrote: That's a function of the person typing into it, not of the program. I was talking about the default program behaviour. Yes, you can move the cursor up or down, but I was talking about the way regular e-mail clients generally handle quoted blocks. http://web.archive.org/web/20041224190115/lists.suse.com/archive/suse-linux-e/2002-Oct/1698.html Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: stuck with Pexpect script need help!!
On 12.12.2010 17:06, Emile van Sebille wrote: On 12/10/2010 10:02 PM Darshak Bavishi said... snip Pexpect is intended for UNIX-like operating systems.) snip Can we use pexpect from windows host machine ?! I expect not... Emile According to [1] you might get it working with the Cygwin port of Python. Alternatively try WinPexpect [2] [1] http://www.noah.org/wiki/Pexpect#Python [2] http://bitbucket.org/geertj/winpexpect/wiki/Home -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/12/2010 10:30 AM, Christian Heimes wrote: Am 12.12.2010 15:14, schrieb Max Countryman: I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? In Python 2.x, while 1 is slightly faster than while True. The interpreter can't optimize while True because the name True can be bind to another value. In Python 3.x it's no longer possible to rebind the names True and False just like None in Python 2.x Would you care to quantify how much CPU time that optimization will typically save for a loop of fair magnitude (say, a billion iterations)? Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... and is, I'd say, therefore to be preferred (except in a code base intended to compile on 2.2 and before). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading by positions plain text files
On 2010-12-12, javivd javiervan...@gmail.com wrote: On Dec 1, 7:15 am, Tim Harig user...@ilthio.net wrote: On 2010-12-01, javivd javiervan...@gmail.com wrote: On Nov 30, 11:43 pm, Tim Harig user...@ilthio.net wrote: encodings and how you mark line endings. Frankly, the use of the world columns in the header suggests that the data *is* separated by line endings rather then absolute position and the position refers to the line number. In which case, you can use splitlines() to break up the data and then address the proper line by index. Nevertheless, ^^ Note that I specifically questioned the use of absolute file position vs. postion within a column. These are two different things. You use different methods to extract each. I work in a survey research firm. the data im talking about has a lot of 0-1 variables, meaning yes or no of a lot of questions. so only one position of a character is needed (not byte), explaining the 123-123 kind of positions of a lot of variables. Thenfile.seek() is what you are looking for; but, you need to be aware of line endings and encodings as indicated. Make sure that you open thefile using whatever encoding was used when it was generated or you could have problems with multibyte characters affecting the offsets. f = open(r'c:c:\somefile.txt', 'w') I suspect you don't need to use the c: twice. f.write('0123456789\n0123456789\n0123456789') Note that the file you a writing contains three lines. Is the data that you are looking for located at an absolute position in the file or on a position within a individual line? If the latter, not that line endings may be composed of more then a single character. f.write('0123456789\n0123456789\n0123456789') ^ postion 3 using fseek() for line in f: Perhaps you meant: for character in f.read(): or for line in f.read().splitlines() f.seek(3,0) This will always take you back to the exact fourth position in the file (indicated above). I used .seek() in this manner, but is not working. It is working the way it is supposed to. If you want the absolution position 3 in a file then: f = open('somefile.txt', 'r') f.seek(3) variable = f.read(1) If you want the absolute position in a column: f = open('somefile.txt', 'r').read().splitlines() for column in f: variable = column[3] -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
So far, the only situation I can find where method names necessarily overlap is for the basics like __init__(), close(), flush(), and save() where multiple parents need to have their own initialization and finalization. One other possibility is subclasses of the JSONEncoder class. For example the writer of class X provides a class, XJSONEncoder, which is able to serialize X instances (by extending the default method). Similarly there is a YJSONEncoder class, which can serialize Y instances. Those classes implement the default method like this: def default(self, o): if isinstance(o, X): ... # serialize the X instance else: return super().default(o) # let the next in the MRO try to handle it If YJSONEncoder encodes Y instances similarly, one can create an encoder class, which can encode both X and Y instances: class XYJSONEncoder(XJSONEncoder, YJSONEncoder): pass It is usable this way: json.dumps([X(), Y()], cls=XYJSONEncoder) Regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading by positions plain text files
On 2010-12-12, Tim Harig user...@ilthio.net wrote: I used .seek() in this manner, but is not working. It is working the way it is supposed to. If you want the absolute position in a column: f = open('somefile.txt', 'r').read().splitlines() for column in f: variable = column[3] or: f = open('somefile.txt', 'r') for column in f.readlines(): variable = column[3] -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
Am 12.12.2010 19:31, schrieb Steve Holden: Would you care to quantify how much CPU time that optimization will typically save for a loop of fair magnitude (say, a billion iterations)? The difference is minimal but measurable for very tight loops. $ python -m timeit -n20 -- i = 0 while 1: i+=1 if i == 100: break 20 loops, best of 3: 89.7 msec per loop $ python -m timeit -n20 -- i = 0 while True: i+=1 if i == 100: break 20 loops, best of 3: 117 msec per loop In Python 2.x the peep hole optimizer can't remove the global lookup and check for trueness for while True. def while1(): ... while 1: ... pass ... import dis dis.dis(while1) 2 0 SETUP_LOOP 3 (to 6) 3 3 JUMP_ABSOLUTE3 6 LOAD_CONST 0 (None) 9 RETURN_VALUE def whiletrue(): ... while True: ... pass ... dis.dis(whiletrue) 2 0 SETUP_LOOP 12 (to 15) 3 LOAD_GLOBAL 0 (True) 6 JUMP_IF_FALSE4 (to 13) 9 POP_TOP 3 10 JUMP_ABSOLUTE3 13 POP_TOP 14 POP_BLOCK 15 LOAD_CONST 0 (None) 18 RETURN_VALUE Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... No argue with that! I was merely making a point that while 1 executes different byte code than while True. Readability is important but sometimes speed is of the essence. while 1 is one of the few tricks to speed up tight loops a bit. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Wanted: slow regexes
Hello, On Wed, Dec 08, 2010 at 04:24:02PM +, MRAB wrote: Interestingly, that webpage says that: (a x 10) =~ /^(ab?)*$/ caused Perl to segfault. I tried it and it didn't segfault, but it didn't match either It doesn't segfault but produces a warning with -w: xr...@xrgtn-q40:~$ perl -wse 'print((a x 10) =~ /^(ab?)*$/)' Complex regular subexpression recursion limit (32766) exceeded at -e line 1. xr...@xrgtn-q40:~$ -- With best regards, xrgtn -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... No argue with that! I actually want to argue with that: I find while 1 more legible. That's probably because a) I'm use to it, and b) the English words while and True don't mean much to me, I need recognize them, and recognizing True is slightly more difficult than recognizing 1. In the end, in any project, there should be coding conventions, and authors should follow them. What is legible is IMO much more determined by convention than intuition, at least to experienced programmers (i.e. those that have been following the convention for a long time). Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Python on wikipedia
Snapshot in time, hey look at that; someone used Python as THE example of what a programming language is on Wikipedia. http://en.wikipedia.org/wiki/Programming_language -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on wikipedia
On 12 Gru, 22:21, DevPlayer devpla...@gmail.com wrote: Snapshot in time, hey look at that; someone used Python as THE example of what a programming language is on Wikipedia.http://en.wikipedia.org/wiki/Programming_language aand? what is the catch? -- http://mail.python.org/mailman/listinfo/python-list
Directly calling python's function arguments dispatcher
Hello I've encountered several times, when dealing with adaptation of function signatures, the need for explicitly resolving complex argument sets into a simple variable mapping. Explanations. Consider that function: def foo(a1, a2, *args, **kwargs): pass calling foo(1, a2=2, a3=3) will map these arguments to local variables like these: { 'a1': 1, 'a2': 2, 'args': tuple(), 'kwarg's: {'a3': 3} } That's a quite complex resolution mechanism, which must handle positional and keyword arguments, and deal with both collision and missing argument cases. Normally, the simplest way to invoke this mechanism is to define a function with the proper signature, and then call it (like, here, foo()). But there are cases where a more meta approach would suit me well. For example when adapting xmlrpc methods : due to the limitations of xmlrpc (no keyword arguments), we use a trick, i.e our xmlrpc functions only accept a single argument, a struct (python dict) which gets unpacked on arrival, when calling the real functions exposed by the xmlrpc server. But on client side, I'd like to offer a more native interface (allowing both positional and keyword arguments), without having to manually define an adapter function for each xmlrpc method. To summarize, I'd like to implement a magic method like this one (please don't care about performance isues for now): class XmlrpcAdapter: def __getattr__(self, funcname): # we create an on-the-fly adapter def adapter(*args, **kwargs): xmlrpc_kwargs = _resolve_func_signature(funcname, *args, **kwargs) # we call the remote function with an unique dict argument self.xmlrpc_server.call(funcname, xmlrpc_kwargs) return adapter As you see, all I need is _resolve_func_signature(), which is actually the routine (internal to the python runtime) which transforms complex function calls in a simple mapping of variables to be added to the function local namespace. Of course this routine would need information about the target functions' signature, but I have that info available (for example, via a set of functions that are a mockup of the real xmlrpc API). Is that routine exposed to python, somewhere ? Does anybody know a working implementation here or there ? Thanks for the help, regards, Pakal -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On Sun, 12 Dec 2010 16:33:41 +0100, Krister Svanlund wrote: On Sun, Dec 12, 2010 at 3:14 PM, Max Countryman m...@me.com wrote: I'm sure this has been brought up many times, but a quick Googling didn't yield the decisive results I was hoping for, so I apologize if this has already been addressed in great detail somewhere else. I am wondering what the rationale is behind preferring while True over while 1? For me, it seems that using True provides more clarity, but is that the only benefit? Is while 1 more prone to errors? It's just silly to use 1 since it will evaluate to True either way. With the while True idiom in Python 2.x, you can easily exit out of an infinite loop without using break: while True: ... print Looping ... True = 0 ... Looping while True: # Execute an infinite loop in 0 seconds. ... print Looping ... *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Tkinter polling example: file copy with progress bar
Attached below is a Tkinter script that demonstrates polling, that is, performing a long-running process in parallel with the GUI. The script asks for an input file name and an output file name and copies the input file to the output file. The copy operation is done in a child process managed with pexpect, and the GUI reports the progress of the file copy using a Scale widget as a progress bar. Cordially, John W. Shipman, NM Tech Computer Center, Socorro, NM; j...@nmt.edu #!/usr/bin/env python # # copyprogress: File copy with a progress bar for Tkinter 8.4. # - Demonstrates Tkinter .after() and the pexpect module. # Written by John W. Shipman (j...@nmt.edu), New Mexico Tech # Computer Center, Socorro, NM 87801 USA. This script is in # the public domain. # # - - - - - I m p o r t s import sys, os, stat import Tkinter as tk import tkFileDialog, tkMessageBox import pexpect # - - - - - M a n i f e s t c o n s t a n t s BUTTON_FONT = (Helvetica, 17) LABEL_FONT = (Helvetica, 14) ENTRY_FONT = (DejaVu Sans Mono, 12) POLL_TIME = 50 # Polling frequency in milliseconds # - - - - - m a i n def main(): app = App() app.master.title(Copy with progress bar) app.mainloop() # - - - - - c l a s s A p p class App(tk.Frame): '''Copies a file with a progress bar. Widgets: .fromFileVar:StringVar for source file name .fromFileEntry: Entry for source file name .fromFileBrowse: Browse button for source file name .fromFileLabel: Label for above .toFileVar: StringVar for destination file name .toFileEntry:Entry for destination file name .toFileBrowse: Browse button for destination file name .toFileLabel:Label for above .copyButton: Button to start copying .progressVar:DoubleVar for progress scale .progressScale: Scale to show progress Grid plan: 01 2 ++-++ 0 | .fromFileEntry | .fromFileBrowse | .fromFileLabel | ++-++ 1 | .toFileEntry | .toFileBrowse | .toFileLabel | ++-++ 2 | .progress | .copyButton | .quitButton| ++-++ Internal state: .fromFileSize: Source file size in bytes .child: pexpect child process to do the copy ''' # - - - A p p . _ _ i n i t _ _ def __init__(self, master=None): tk.Frame.__init__(self, master) self.grid() self.__createWidgets() # - - - A p p . _ _ c r e a t e w i d g e t s def __createWidgets(self): '''Create all widgets and associated variables. ''' self.fromFileVar = tk.StringVar() self.fromFileEntry = tk.Entry ( self, textvariable=self.fromFileVar, font=ENTRY_FONT, width=50 ) rowx, colx = 0, 0 self.fromFileEntry.grid(row=rowx, column=colx, sticky=tk.E) self.fromFileBrowse = tk.Button ( self, command=self.__browseFrom, font=BUTTON_FONT, text=Browse ) colx += 1 self.fromFileBrowse.grid(row=rowx, column=colx) self.fromFileLabel = tk.Label ( self, font=LABEL_FONT, text=Source file ) colx += 1 self.fromFileLabel.grid(row=rowx, column=colx, sticky=tk.W) self.toFileVar = tk.StringVar() self.toFileEntry = tk.Entry ( self, textvariable=self.toFileVar, font=ENTRY_FONT, width=50 ) rowx, colx = rowx+1, 0 self.toFileEntry.grid(row=rowx, column=colx, sticky=tk.E) self.toFileBrowse = tk.Button ( self, command=self.__browseTo, font=BUTTON_FONT, text=Browse ) colx += 1 self.toFileBrowse.grid(row=rowx, column=colx) self.toFileLabel = tk.Label ( self, font=LABEL_FONT, text=Destination file) colx += 1 self.toFileLabel.grid(row=rowx, column=colx, sticky=tk.W) self.progressVar = tk.DoubleVar() self.progressScale = tk.Scale ( self, length=400, orient=tk.HORIZONTAL, from_=0.0, to=100.0, resolution=0.1, tickinterval=20.0, variable=self.progressVar, label=Percent completion, font=LABEL_FONT ) rowx, colx = rowx+1, 0 self.progressScale.grid(row=rowx, column=colx, sticky=tk.E) self.copyButton = tk.Button ( self, command=self.__copyHandler, font=BUTTON_FONT, text=Copy ) colx += 1 self.copyButton.grid(row=rowx, column=colx ) self.quitButton = tk.Button ( self, command=self.quit,
Re: Python on wikipedia
On 12/12/2010 4:38 PM, pakalk wrote: On 12 Gru, 22:21, DevPlayerdevpla...@gmail.com wrote: Snapshot in time, hey look at that; someone used Python as THE example of what a programming language is on Wikipedia.http://en.wikipedia.org/wiki/Programming_language aand? what is the catch? Wikipedia entries can be edited. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Directly calling python's function arguments dispatcher
Pascal Chambon wrote: I've encountered several times, when dealing with adaptation of function signatures, the need for explicitly resolving complex argument sets into a simple variable mapping. Explanations. Consider that function: def foo(a1, a2, *args, **kwargs): pass calling foo(1, a2=2, a3=3) will map these arguments to local variables like these: { 'a1': 1, 'a2': 2, 'args': tuple(), 'kwarg's: {'a3': 3} } That's a quite complex resolution mechanism, which must handle positional and keyword arguments, and deal with both collision and missing argument cases. Is that routine exposed to python, somewhere ? Does anybody know a working implementation here or there ? http://docs.python.org/library/inspect.html#inspect.getcallargs -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on wikipedia
Yeah, I noticed that a while back too. Kinda cool. --Bill On Sun, Dec 12, 2010 at 3:21 PM, DevPlayer devpla...@gmail.com wrote: Snapshot in time, hey look at that; someone used Python as THE example of what a programming language is on Wikipedia. http://en.wikipedia.org/wiki/Programming_language -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On 12/12/2010 2:32 PM, Christian Heimes wrote: Am 12.12.2010 19:31, schrieb Steve Holden: Would you care to quantify how much CPU time that optimization will typically save for a loop of fair magnitude (say, a billion iterations)? The difference is minimal but measurable for very tight loops. $ python -m timeit -n20 -- i = 0 while 1: i+=1 if i == 100: break 20 loops, best of 3: 89.7 msec per loop $ python -m timeit -n20 -- i = 0 while True: i+=1 if i == 100: break 20 loops, best of 3: 117 msec per loop In Python 2.x the peep hole optimizer can't remove the global lookup and check for trueness for while True. Yes, you said that already and I certainly didn't disagree. [...] Python is designed to provide readable code. Writing while True: ... is much more legible than its pre-True couterpart while 1: ... No argue with that! I was merely making a point that while 1 executes different byte code than while True. Readability is important but sometimes speed is of the essence. while 1 is one of the few tricks to speed up tight loops a bit. OK, but the figures you quote save you 27.3 ms per million iterations, for a grand total saving of 27.3 ns per iteration. So a bit is hardly worth considering for most programs, is it? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Is there any way to SSH from Python ?!
Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? Because when i use telenet it not showing the no result !! As earlier it was suggested that i should try with exit first and than read_all() but still issue persist and getting hang import getpass import sys import telnetlib import time HOST = *.*.*.* #user = raw_input(Enter your remote account: ) #password = getpass.getpass() user = Darshak2 password = tn = telnetlib.Telnet(HOST , 5400) print 1 tn.read_until(login: , 5) print 2 tn.write(user + \n) print 3 if password: tn.read_until(Password: ) tn.write(password + \n) print 4 tn.write(set alarm = off + \n) tn.write(set event = off + \n) print 5 tn.write(Cd /Office-Parameters/Mobility-Config-Parameters/Subscriber-Query-by-IMSI-MSISDN-or-IMEI + \n) print 6 tn.write(\n) tn.write(\n) tn.write(vlrsubquery msisdn=*** + \n) tn.write(\n) tn.write(exit + \n) print tn.read_all() tn.close() -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any way to SSH from Python ?!
On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi bavishi.dars...@gmail.com wrote: Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? http://www.lag.net/paramiko/ Did you try googling ssh python? Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any way to SSH from Python ?!
i am trying from last week but no luck !! one thing only found that pexpect it not useful in windows pls help out of this On Mon, Dec 13, 2010 at 10:39 AM, Chris Rebert c...@rebertia.com wrote: On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi bavishi.dars...@gmail.com wrote: Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? http://www.lag.net/paramiko/ Did you try googling ssh python? Cheers, Chris -- http://blog.rebertia.com -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
On Sun, 12 Dec 2010 23:20:40 -0500, Steve Holden wrote: On 12/12/2010 2:32 PM, Christian Heimes wrote: [...] No argue with that! I was merely making a point that while 1 executes different byte code than while True. Readability is important but sometimes speed is of the essence. while 1 is one of the few tricks to speed up tight loops a bit. OK, but the figures you quote save you 27.3 ms per million iterations, for a grand total saving of 27.3 ns per iteration. So a bit is hardly worth considering for most programs, is it? I don't think anyone is saying that people should routinely use while 1 for loops because they're faster than the alternatives. But it is a real, if small, optimization for a particular class of tight loops. Using the figures shown by Christian, it could be a 20-25% speed up on extremely tight loops. You're right though, it's hardly worth the effort for large, expensive loops though -- but then on the other hand, while 1 is not so unreadable that it should be avoided. I'm actually quite fond of the look of while 1:, and sometimes use it, not because it's faster, but just because I like it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: while True or while 1
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I'm actually quite fond of the look of while 1:, and sometimes use it, not because it's faster, but just because I like it. for v in itertools.repeat(True): ... ;-) -- http://mail.python.org/mailman/listinfo/python-list
[issue10683] PreLinkEvent error under VC2010
Martin v. Löwis mar...@v.loewis.de added the comment: The problem is different: there is a stray in pythoncore\getbuildinfo.o. Kristjan, this is your change: can you take a look? -- nosy: +krisvale, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9922] subprocess.getstatusoutput can fail with utf8 UnicodeDecodeError
Ned Deily n...@acm.org added the comment: Update 31 backport patch to reflect revert of unittest method names prior to 3.1.3 release. -- Added file: http://bugs.python.org/file20023/issue9922-31-rev1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9922 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9922] subprocess.getstatusoutput can fail with utf8 UnicodeDecodeError
Changes by Ned Deily n...@acm.org: Removed file: http://bugs.python.org/file18972/issue9922-31.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9922 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7213] subprocess leaks open file descriptors between Popen instances causing hangs
STINNER Victor victor.stin...@haypocalc.com added the comment: fd_status.py: +try: +_MAXFD = os.sysconf(SC_OPEN_MAX) +except: +_MAXFD = 256 It looks like this code (256 constant) comes from subprocess.py. Is that a good value? On Linux, SC_OPEN_MAX is usually 1024, and it can be 4096. Should we keep the default value 256, or use 1024 or 4096 instead? I don't know on which OS SC_OPEN_MAX is missing. -- fd_status.py: isopen(fd) uses fcntl.fcntl(fd, fcntl.F_GETFD, 0). Is it always available? If not, we can add fstat() as a fallback. The buildbots will tell us :-) -- subprocess.py: _create_pipe() doesn't use pipe2() because Python doesn't provide pipe2(). We should maybe add it to the posix module (open maybe a new issue for that). The CLOEXEC flag needs to be set atomically (or at least in a way that another subprocess won't start in the middle of it) For the Python implementation, the GIL is not enough to ensure the atomicity of a process creation. That's why _posixsubprocess was created. I suppose that other parts of subprocess are not atomic and a lock is required to ensure that the creation of subprocess is atomic. -- _posixsubprocess.c: is FD_CLOEXEC flag always available? fcntlmodule.c uses a #ifdef FD_CLOEXEC. Can you add a comment to explain why you can release the GIL here? (because the operation is atomic) +Py_BEGIN_ALLOW_THREADS +res = pipe2(fds, O_CLOEXEC); +Py_END_ALLOW_THREADS -- test_subprocess.py: test_pipe_cloexec() and test_pipe_cloexec_real_tools() should maybe be skipped if fcntl has no attribute FD_CLOEXEC. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7213 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10684] Shutil.move deletes file/folder in windows while renaming
New submission from harish nsharish@gmail.com: Shutil.move method deletes a file/folder when the file/folder is renamed to same name but different case. eg. shutil.move('folder','Folder') -- components: Windows messages: 123833 nosy: harish priority: normal severity: normal status: open title: Shutil.move deletes file/folder in windows while renaming type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10684 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9232] Allow trailing comma in any function argument list.
Changes by Nick Coghlan ncogh...@gmail.com: -- stage: needs patch - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9344] please add posix.getgrouplist()
Ross Lagerwall rosslagerw...@gmail.com added the comment: Attached is a patch (against the latest revision, 87178) which adds the functionality to the posix module as well as adds a testcase for it. I haven't added it to the os module, I'm not sure if that should be done. I tested it on Linux FreeBSD and it works as expected. Since I don't have an OS X system, I could not test it on there. -- keywords: +patch nosy: +rosslagerwall Added file: http://bugs.python.org/file20024/9344.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9344 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10261] tarfile iterator without members caching
Lars Gustäbel l...@gustaebel.de added the comment: There is no trivial or backwards-compatible solution to this problem. The way it is now, there is no alternative to storing all TarInfo objects: there is no central table of contents in an archive we could use, so we must create our own. In other words, tarfile does not burn memory without a reason. The problem you encounter is somehow a corner case, fortunately with a simple workaround: for tarinfo in tar: ... tar.members = [] There are two things that I will clearly refuse to do. One thing is to add yet another option to the TarFile class to switch off caching as this would make many TarFile methods dysfunctional without the user knowing why. The other thing is to add an extra non-caching Iterator class. Sorry, that I have nothing more to offer. Maybe, someone else comes up with a brilliant idea. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10261 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10685] trace does nto ignore --ignore-module
New submission from Rusi rustompm...@gmail.com: When running trace, I get a a lot of lines like: filename: /usr/lib/python2.7/cmd.py, modulename: cmd, funcname: Cmd That is to say system modules are shown in the trace whereas I only want to see the code I am working on Ive tried python2.7 -m trace --listfuncs tt.py --ignore-dir '/usr/lib' const-dir.trace python2.7 -m trace --listfuncs --ignore-module cmd tt.py const.trace python2.7 -m trace --ignore-module --listfuncs cmd tt.py const.trace -- messages: 123836 nosy: RusiMody priority: normal severity: normal status: open title: trace does nto ignore --ignore-module type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10685 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7213] subprocess leaks open file descriptors between Popen instances causing hangs
Milko Krachounov pyt...@milko.3mhz.net added the comment: For the Python implementation, the GIL is not enough to ensure the atomicity of a process creation. That's why _posixsubprocess was created. I suppose that other parts of subprocess are not atomic and a lock is required to ensure that the creation of subprocess is atomic. Both _posixsubprocess.fork_process and _posixsubprocess.cloexec_pipe (without HAVE_PIPE2) hold the GIL. They can't be running at the same time, so in regards to each other, they will be atomic. Or at least that's the idea. You don't need a separate lock when the GIL is already held. Neither a lock nor the GIL make the operation to be atomic (e.g. if someone forks from multiprocessing, the effect might be different, though os.fork() also holds the GIL and I think multiprocessing uses it). The idea of _posixsubprocess is that fork() isn't thread-safe, because Python might call malloc() or free() in the child, which might be currently locked by another thread, which might cause the child to hang. Nothing to do with atomicity. Can you add a comment to explain why you can release the GIL here? (because the operation is atomic) I release the GIL because I copy-pasted the code from os.pipe(). It makes sense that pipe() and pipe2() are called in the same way. In the other implementation it is held to (ab)use it to avoid the race, but there's no need to hold it here because pipe2() *is* atomic. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7213 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown
Nick Coghlan ncogh...@gmail.com added the comment: Tidy ups committed in r87182. Shutdown problems now result in a slightly more meaningful message on stderr, a ResourceWarning is triggered when an implicit teardown occurs and the chances of an AttributeError due to an exception in __init__ are minimised. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10188 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10682] With '*args' or even bare '*' in def/call argument list, trailing comma causes SyntaxError
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10682 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10684] Shutil.move deletes file/folder in windows while renaming
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +brian.curtin, tarek, tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10684 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown
R. David Murray rdmur...@bitdance.com added the comment: The tests are failing on windows: http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/3770/steps/test/logs/stdio == ERROR: test_mkdtemp_failure (test.test_tempfile.test_TemporaryDirectory) -- Traceback (most recent call last): File D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_tempfile.py, line 933, in test_mkdtemp_failure tempfile.TemporaryDirectory(prefix=[]?*!:) File D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\tempfile.py, line 624, in __init__ self.name = mkdtemp(suffix, prefix, dir) File D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\tempfile.py, line 301, in mkdtemp _os.mkdir(file, 0o700) WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'c:\\docume~1\\db3l\\locals~1\\temp\\[]?*!:9ohp4a' == FAIL: test_warnings_on_cleanup (test.test_tempfile.test_TemporaryDirectory) -- Traceback (most recent call last): File D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_tempfile.py, line 1001, in test_warnings_on_cleanup self.assertIn(d.name, message) AssertionError: 'c:\\docume~1\\db3l\\locals~1\\temp\\94ifn5\\ujobx5' not found in 'ERROR: TypeError(\'NoneType\' object is not callable,) while cleaning up TemporaryDirectory \'c:docume~1db3llocals~1temp94ifn5ujobx5\'\n' -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10188 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown
R. David Murray rdmur...@bitdance.com added the comment: There's also a typo in the issue number in your commit message (10888 instead of 10188). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10188 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10367] python setup.py sdist upload --show-response can fail with UnboundLocalError: local variable 'result' referenced before assignment
Changes by R. David Murray rdmur...@bitdance.com: -- priority: - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10367 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4391] use proper gettext plurals forms in argparse and optparse
Changes by R. David Murray rdmur...@bitdance.com: -- priority: - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4391 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1459867] Message.as_string should use mangle_from_=unixfrom?
R. David Murray rdmur...@bitdance.com added the comment: On balance I think this would be a backward incompatible change that has insufficient benefit to be worth doing. People who have working code will be depending on the existing defaults of the two methods, and changing this out from under them would be unkind. -- resolution: - wont fix stage: unit test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1459867 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10686] email.Generator should use unknown-8bit encoded words for headers with 8 bit data
New submission from R. David Murray rdmur...@bitdance.com: This is a followon to Issue 4661. The fix for that issue introduced a way to parse messages containing 8bit bytes. When Generator is called on a model containing 8 bit bytes, it converts it to 7bit clean. There is, however, a bug in this conversion process: currently when encountering 8bit bytes in headers, it simply replaces then with ?. According to the RFCs[*], what it should do instead is to replace them with encoded words using the 'charset' unknown-8bit. [*] I'm specifically referring to RFC 1428...email is effectively acting as a translating gateway when requested to do the 8bit to 7bit conversion. Although that RFC does not explicitly say that the unknown-8bit charset should be used in encoded words, it does imply it strongly in its section 3 prescription. -- assignee: r.david.murray messages: 123842 nosy: r.david.murray priority: high severity: normal stage: needs patch status: open title: email.Generator should use unknown-8bit encoded words for headers with 8 bit data type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10686 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4661] email.parser: impossible to read messages encoded in a different encoding
R. David Murray rdmur...@bitdance.com added the comment: I've opened a issue 10686 to address improving the RFC conformance by using unknown-8bit encoded words for 8bit bytes in headers. -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4661 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4766] email documentation needs to be precise about strings/bytes
R. David Murray rdmur...@bitdance.com added the comment: The wording was clarified for 3.2 as part of the fix for issue 4661. This does not help the 3.1 docs, so if someone wants to suggest a patch for the 3.1 docs we can reopen the issue. -- resolution: postponed - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4766 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10687] Python fails to install with empty ABI flags
New submission from Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: $ make DESTDIR=/var/tmp/portage/dev-lang/python-3.2_pre20101212/image/ altinstall Creating directory /usr/bin Creating directory /usr/lib64 /usr/bin/install -c python /var/tmp/portage/dev-lang/python-3.2_pre20101212/image//usr/bin/python3.2 if test -f /var/tmp/portage/dev-lang/python-3.2_pre20101212/image//usr/bin/python3.2 -o -h /var/tmp/portage/dev-lang/python-3.2_pre20101212/image//usr/bin/python3.2; \ then rm -f /var/tmp/portage/dev-lang/python-3.2_pre20101212/image//usr/bin/python3.2; \ else true; \ fi (cd /var/tmp/portage/dev-lang/python-3.2_pre20101212/image//usr/bin; ln python3.2 python3.2) ln: accessing `python3.2': No such file or directory make: *** [altbininstall] Error 1 -- components: Build messages: 123845 nosy: Arfrever, barry priority: normal severity: normal status: open title: Python fails to install with empty ABI flags versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10687 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10631] ZipFile and current directory change
Martin v. Löwis mar...@v.loewis.de added the comment: So, Martin, are you then arguing that this should in fact be considered a bug in ZipFile? The documentation for the constructor says Open a ZIP file, where file can be either a path to a file (a string) or a file-like object. Reading that I would certainly expect it to accept a relative path, and for that path to be relative to the CWD at the time I called ZipFile, not at the time I called extractall. You have a point here. So I now think that this should be changed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10631 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10634] Windows timezone changes not reflected by time.localtime
Changes by Eric Pruitt eric.pru...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10682] With '*args' or even bare '*' in def/call argument list, trailing comma causes SyntaxError
Raymond Hettinger rhettin...@users.sourceforge.net added the comment: The current behavior for function definitions is beneficial because a trailing comma in the argument list is likely to signal a real error (omitted variable). In contrast, the trailing comma for lists is useful because entries on separate lines in a repeating pattern that makes it easy to add or remove entries. The use cases for both function definitions and lists are best served by the current behavior, more so that a notion driven by foolish consistency. Recommend rejecting and closing. -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10682 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10682] With '*args' or even bare '*' in def/call argument list, trailing comma causes SyntaxError
Brett Cannon br...@python.org added the comment: I'm with Raymond; this is unneeded consistency. I honestly would rather see what little support there is for a trailing comma to go away, but w/o looking at the grammar I am willing to bet that would be a pain to get right and not be worth the effort. -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10682 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1243654] Faster output if message already has a boundary
R. David Murray rdmur...@bitdance.com added the comment: Committed a simpler fix in r87196, backported to 3.1 in r87195, and 2.7 in r87196. -- resolution: - fixed stage: unit test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1243654 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10682] With '*args' or even bare '*' in def/call argument list, trailing comma causes SyntaxError
Martin v. Löwis mar...@v.loewis.de added the comment: Ok, so closing as rejected. -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10682 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9232] Allow trailing comma in any function argument list.
Martin v. Löwis mar...@v.loewis.de added the comment: In #10682, several committers indicated that they would prefer not to change this. So I'm closing this as rejected. Per convention, it would probably require a PEP to modify Python in this aspect (as there is no clear consensus). -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9893] Usefulness of the Misc/Vim/ files?
Brett Cannon br...@python.org added the comment: So I just looked at the syntax file linked by Antoine and that is definitely *not* what he meant to link to; probably meant http://www.vim.org/scripts/script.php?script_id=790 . As for the indentation file, it's out-of-date and so doesn't support 'with' statements (looks like people have already started to fork it: http://www.vim.org/scripts/script.php?script_id=3003). At this point I'm willing to either hand maintenance of the files over to someone else or to delete the files and shift what we point people at. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10688] pydoc removes lib directory
New submission from CZ hua...@qualcomm.com: when pydoc is run with python -m (e.g., python -m pydoc map), you will receive an error message: No module named tempfile. The reason is pydoc removes 'C:\Python26\lib' (in my case) from sys.path. But you can run it as python full path to pydoc.py because the lib directory appears twice in the sys.path in such situation. -- messages: 123853 nosy: CZ priority: normal severity: normal status: open title: pydoc removes lib directory type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10688] pydoc removes lib directory
R. David Murray rdmur...@bitdance.com added the comment: This is a duplicate of issue 2029. -- nosy: +r.david.murray resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - python -m pydoc -g fails ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10688 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10683] PreLinkEvent error under VC2010
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Yes, I have VC2010 so I'll see what happens... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9286] email.utils.parseaddr returns garbage for invalid input
R. David Murray rdmur...@bitdance.com added the comment: OK, I've studied this more, and it looks to me like the legacy address format allows multiple atoms separated by white space in the local part of the address. This means that the correct parse would be ('', 'merwok w...@rusty.com') How useful this parse is is a good question. It is arguably better than losing the white space; however, the fact that it represents a behavior change and there's no actual user bug against this argues against backport. I do think it is better to conform to the RFC as much as possible, though, so I'd like to fix this in 3.2. Attached is a patch to the parser that preserves whitespace runs in between unquoted atoms in the local part. It would be interesting to know what other email programs do with such addresses. -- keywords: +patch stage: - patch review versions: -Python 2.7, Python 3.1 Added file: http://bugs.python.org/file20025/preserve_unquoted_white_space_in_local_part.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9286 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10689] _scproxy extension is NOT build
New submission from Pierre Vinet v...@globetrotter.net: From Python 2.7 http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tar.bz2 released on November 27th, 2010. At compile time : $ ../Python-2.7.1/configure --enable-framework $ make we obtain within standard output: building '_scproxy' extension creating build/Python-2.7.1 creating build/Python-2.7.1/Mac creating build/Python-2.7.1/Mac/Modules /sw/lib/gcc4.2/bin/gcc -fno-strict-aliasing -fno-common -dynamic -O2 -Wall -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/vinp/Documents/informatique/python/installation/version-2.7.1/Python-2.7.1/Mac/Include -I. -IInclude -I../Python-2.7.1/Include -I/sw/include -I/opt/macports/include -I/opt/include -I/usr/X11R6/include -I/usr/include -I/usr/local/include -I/Users/vinp/Documents/informatique/python/installation/version-2.7.1/Python-2.7.1/Include -I/Users/vinp/Documents/informatique/python/installation/version-2.7.1/objet_fwk -c ../Python-2.7.1/Mac/Modules/_scproxy.c -o build/temp.macosx-10.3-ppc-2.7/../Python-2.7.1/Mac/Modules/_scproxy.o ../Python-2.7.1/Mac/Modules/_scproxy.c: In function ‘get_proxy_settings’: ../Python-2.7.1/Mac/Modules/_scproxy.c:67: error: lvalue required as unary ‘’ operand Then the module _scproxy is not build, which yield to 35 tests crashes: test_SimpleHTTPServer test___all__ test_cgi test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_cookielib test_distutils test_email test_email_codecs test_email_renamed test_httpservers test_mailbox test_mimetypes test_normalization test_old_mailbox test_pyclbr test_robotparser test_sax test_site test_smtplib test_smtpnet test_ssl test_sundry test_urllib test_urllib2 test_urllib2_localnet test_urllib2net test_urllibnet test_wsgiref test_xml_etree test_xml_etree_c test_xmlrpc $ uname -a Darwin ts-77.rmkipqxaas02.globetrotter.net 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc Compiler gcc (GCC) is 4.2.4 (2007) Thanks, Pierre Vinet -- assignee: ronaldoussoren components: Build, Macintosh, Tests messages: 123857 nosy: ronaldoussoren, vinp priority: normal severity: normal status: open title: _scproxy extension is NOT build type: compile error versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10689 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9234] argparse: aliases for positional arguments (subparsers)
Adrian Sampson asamp...@cs.washington.edu added the comment: Thanks for the pointer, Éric. Here's a quick patch that integrates the same functionality into the existing subparser class. -- keywords: +patch Added file: http://bugs.python.org/file20026/argparse-aliases.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9234 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10690] IDLE Crash when running/saving Module
New submission from David mapstonsis...@yahoo.com: Hello, Python version 2.7.1 x64 Mac OS X 10.6.5 x86_64 Tk/Tcl version 8.5/4 Python will crash when saving/running/checking a module, i tried googling for a few hours to come up to NOTHING for a solution. Hopefully we can both get this fixed. Thank you. Attached is a Python crash log. -- components: IDLE files: Python_2010-12-12-214329_Darwin.txt messages: 123859 nosy: David_Anon priority: normal severity: normal status: open title: IDLE Crash when running/saving Module type: crash versions: Python 2.7 Added file: http://bugs.python.org/file20027/Python_2010-12-12-214329_Darwin.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10690 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown
Nick Coghlan ncogh...@gmail.com added the comment: Sorry, I realised after I had logged off and gone to bed that I hadn't finished the last test. Fixed in r87204 with an approach that should exercise the relevant behaviour regardless of platform. The commit message has also been updated to refer to the correct issue. I'm actually going to close this now - the problem of misbehaviour due to modules being nulled out at shutdown is a more universal problem being tracked elsewhere, and I think the behaviour I just added is the best we can hope for until that is fixed. -- resolution: - fixed status: open - closed type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10188 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10683] PreLinkEvent error under VC2010
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Ok the problem is this line in the pre-link step, that must have gotten changed during the conversion: $(SolutionDir)make_buildinfo.exe Debug $(IntDir) should be $(SolutionDir)make_buildinfo.exe Debug $(IntDir)\ This is because ($IntDir) will expand to a path ending in a backslash, thus escaping the quotes. We have to escape the backslash using this notation. The backslash gets removed during the automatic update of the project files. Is there an official VS2010 build project? If there is one, I can fix this there. There is an alternative. We can catch this particular error by skiping a trailing in the path name. This is perhaps good too, since others are bound to run into this problem. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10683] PreLinkEvent error under VC2010
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Implemented the trailing quote removal defensive programming strategy in revision 87205. Others that autoconvert the solution will not be hit by this problem. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10683 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7213] subprocess leaks open file descriptors between Popen instances causing hangs
Gregory P. Smith g...@krypto.org added the comment: The close_fds default has been fixed in r87206 to remove the DeprecationWarning and remain False on Windows. It changes to True on POSIX. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7213 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com