asciitable 0.4.0
I'd like to announce the release of version 0.4.0 of asciitable, an extensible module for reading and writing ASCII tables. This release adds the capability to handle bad or missing values in the input table. Thanks to Moritz Guenther for contributing this new feature. Please see: http://cxc.harvard.edu/contrib/asciitable/#replace-bad-or-missing-values Regards, Tom Aldcroft -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Which non SQL Database ?
On 12/4/2010 8:44 PM, Monte Milanuk wrote: On 12/4/10 3:43 PM, Jorge Biquez wrote: I do not see a good reason for not using Sqlite3 BUT if for some reason would not be an option what plain schema of files would you use? Would shelve work? There are some systems for storing key-value pairs in files. Underneath shelve is some primitive database, dbm, gdbm or bsddb. bsddb is deprecated and was removed from Python 3.x. dbm has some classic problems. gdbm is an improved version of dbm. None of these handle access from multiple processes, or crash recovery. We're looking at 1979 technology here. SQLite works right when accessed from multiple processes. SQLite is the entry-level database technology for Python today. It handles the hard cases, like undoing transactions after a crash and locking against multiple accesses. Lookup performance is good; simultaneous update by multiple processes, though, is not so good. When you have a web site that has many processes hitting the same database, it's time to move up to MySQL or Postgres. There's a lot of interest in non-SQL databases for very large distributed systems. You worry about this if you're Facebook or Google, or are running a big game server farm. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Perceived inconsistency in py3k documentation
Hello, This is my first post here, so if this is not the correct place to ask this, please direct me to the best place. In looking at the py3k documentation for comparing two classes, two different view points are expressed (at least it seems so to me). 1) At http://docs.python.org/py3k/reference/datamodel.html: There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__()... -- This seems to support the view that if in our code, we would like to use comparison operators , , =, !=, etc. then we should define a __lt__(), __gt__(), __eq__(), __ne__(), etc. for each comparison operator we would like. This appears to contrast 2) At http://docs.python.org/py3k/library/stdtypes.html: Instances of a class cannot be ordered with respect to other instances of the same class, or other types of object, unless the class defines enough of the methods __lt__(), __le__(), __gt__(), and __ge__() (in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators). -- This seems to imply that to get all of the operators, only __lt__() and __eq__() need to be defined (just __lt__() should suffice though I thought). So, which is it supposed to be? Or am I reading the documentation wrong? Thanks! -Greg- -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
Tim Harig user...@ilthio.net writes: The fact that I bothered to create classes for the dice and roles, rather then simply iterating over a list of numbers, should tell you that I produced was of a far more flexible nature; including the support for roles with dice having different numbers of sides. from itertools import product def n_sided_die(n): return xrange(1, n+1) # make one 3-sided die, one 4-sided die, and one 5-sided die dice = (n_sided_die(3), n_sided_die(4), n_sided_die(5)) for roll in product(*dice): print roll I merely posted a simplied description of the dice-role objects because I thought that it demonstrated how exceptions can provide eligance of control for situations that don't involve what would traditionally be defined as an error. Exceptions (though sometimes necessary) are messy and I'm having a hard time trying to envision that code being cleaner with them than without them. If you post the actual code maybe that will help me understand. -- http://mail.python.org/mailman/listinfo/python-list
Deditor 0.2.3
A new version of the python dedicated linux text-editor has been released! This editor is python specific offering some features to python users like code analyzing, code inspecting, syntax highlighting, ... Information about this project: http://launchpad.net/deditor Information about the latest release: http://kruptein.alwaysdata.net/blag -- http://mail.python.org/mailman/listinfo/python-list
s;hlhdlhlah
lhdglfhglshglhash -- http://mail.python.org/mailman/listinfo/python-list
Re: Perceived inconsistency in py3k documentation
Greg wrote: This is my first post here, so if this is not the correct place to ask this, please direct me to the best place. This is a good place to get general advice and to discuss potential bugs when you are unsure whether they actually are bugs. If you are sure that you ran into a bug in python or want to suggest an improvement of the documentation where it is wrong or unclear or hard to understand you can report to http://bugs.python.org . In looking at the py3k documentation for comparing two classes, two different view points are expressed (at least it seems so to me). 1) At http://docs.python.org/py3k/reference/datamodel.html: There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__()... -- This seems to support the view that if in our code, we would like to use comparison operators , , =, !=, etc. then we should define a __lt__(), __gt__(), __eq__(), __ne__(), etc. for each comparison operator we would like. This appears to contrast 2) At http://docs.python.org/py3k/library/stdtypes.html: Instances of a class cannot be ordered with respect to other instances of the same class, or other types of object, unless the class defines enough of the methods __lt__(), __le__(), __gt__(), and __ge__() (in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators). -- This seems to imply that to get all of the operators, only __lt__() and __eq__() need to be defined (just __lt__() should suffice though I thought). So, which is it supposed to be? Or am I reading the documentation wrong? I agree with you that the documentation is at least unclear. The following experiment suggests that list.sort() works correctly if only __lt__() and __eq__() are implemented which in my reading is what your second quote intends to convey. But enough of the methods... is a fuzzy statement. The other finding: (1) a != b is emulated with not (a == b) (2) a b is emulated with b a is not something I'd expect after reading your first quote, but technically (2) is covered by ... __lt__() and __gt__() are each other’s reflection ... $ cat py3compare.py report = True class A: def __init__(self, key, side=A): self.key = key self.side = side def __eq__(self, other): result = self.key == other.key if report: print(self, __eq__, other, --, result) return result def __lt__(self, other): result = self.key other.key if report: print(self, __lt__, other, --, result) return result def __str__(self): return {}({}).format(self.side, self.key) def __repr__(self): return str(self.key) a = A(1, L) for k in range(3): b = A(k, R) print({} != {}: {}\n.format(a, b, a != b)) print({} {}: {}\n.format(a, b, a b)) print() import random items = [] for n in 10, 20: items.extend(map(A, range(n))) random.shuffle(items) report = False items.sort() print(items) print(a = b) $ python3 py3compare.py L(1) __eq__ R(0) -- False L(1) != R(0): True R(0) __lt__ L(1) -- True L(1) R(0): True L(1) __eq__ R(1) -- True L(1) != R(1): False R(1) __lt__ L(1) -- False L(1) R(1): False L(1) __eq__ R(2) -- False L(1) != R(2): True R(2) __lt__ L(1) -- False L(1) R(2): False [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Traceback (most recent call last): File py3compare.py, line 39, in module print(a = b) TypeError: unorderable types: A() = A() $ Conclusion: If you can come up with a text that is both correct and clear, don't hesitate to tell us, here or on the bug tracker. Peter PS: The painless way out: always use @functools.total_ordering or the equivalent cookbok recipe. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Pyclewn: Vim as a front end to pdb
Pyclewn 1.5 has been released at http://pyclewn.sourceforge.net/ Pyclewn is a python program that allows the use of Vim as a front end to gdb and pdb. This release adds support for ``pdb``, the python debugger. + A python script may be run under the control of ``pdb``. For example the current vim buffer may be started and debugged with the vim command ``:Pyclewn pdb %:p`` + One may also attach to a running python process, interrupt the process, manage a debugging session and terminate the debugging session by detaching from the process. A new debugging session may be conducted later on this same process, possibly from another Vim instance. + All the ``pdb`` commands are supported except ``list`` and ``commands``. This includes alias expansion and executing a python statement in the context of the current frame. The new command ``threadstack`` prints the instantaneous backtrace of all the threads, including those that are stuck in a deadlock. * Pdb is currently supported on unix platforms and requires the latest Vim version: Vim 7.3. Python3 is not supported yet. -- Xavier Les Chemins de Lokoti: http://lokoti.alwaysdata.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 2010-12-05, Paul Rubin no.em...@nospam.invalid wrote: Tim Harig user...@ilthio.net writes: The fact that I bothered to create classes for the dice and roles, rather then simply iterating over a list of numbers, should tell you that I produced was of a far more flexible nature; including the support for roles with dice having different numbers of sides. from itertools import product def n_sided_die(n): return xrange(1, n+1) # make one 3-sided die, one 4-sided die, and one 5-sided die dice = (n_sided_die(3), n_sided_die(4), n_sided_die(5)) for roll in product(*dice): print roll Notice that you had to change the structure of your program to accomodate the new possiblity; and, if I throw further requirements at you, you will have to change them again. I didn't want that. What the dice returned may or may not have returned an easy to compute sequence. In fact, for all of the rest of the logic cared, the dice could have computed their value from a previous role of another dice. All of the logic of about what the dice may have returned when asked for their value and how they derived, was encapsilated in the dice themselves. It did not need to be known anywhere else in the program logic. The DSL effectively provided a way do define how the dice decided how to increment themselves, how to choose the value that they returned for their face, and how to know when they could no longer be incremented. The DSL parser generated the dice set from the description given. Creating new dice objects was much easier then attempting to change the logic of how they were rolled. I merely posted a simplied description of the dice-role objects because I thought that it demonstrated how exceptions can provide eligance of control for situations that don't involve what would traditionally be defined as an error. Exceptions (though sometimes necessary) are messy and I'm having a hard time trying to envision that code being cleaner with them than without them. If you post the actual code maybe that will help me understand. Let me get this straight, the same person that was trying to tell me setjmp/longjmp weren't messy thinks exceptions are messy? I have used both. I much prefer the exceptions. I not have to code here to post. The cleanliness of using the exception and calling the dice increments recursively, was that there was no need to figure out which dice needed to be incremented whenever the first die needed to be reset. When a dice needed to be reset, it would raise an exception. This exception would rise through the recursion stack, and thus through the dice, resetting each along the way until it found the one which needed to be incremented or raised past the top call indicating that all of the combinations has been exhausted. There, once the reset condition for the previous dice had been effectively handled, it would be supprested. Had this been done using in band data: 1. The roll object would have needed logic to determine when a reset condition needed to take place, effectively leaking some of the logic from the dice object to the role object. 2. The roll object would have needed logic to determine how to follow the dice which needed to be reset until it found which one needed incrementing. Once again, this logic was better left to the dice walking the resets was automatically handled by the progression of the exception. Even if it wasn't an error, the resets were effectively a exceptional condition from the normal flow of the role object (the primary flow simply being to increment the first die). By using exceptions, I effectively isolated each into its own separate independent flow; and, because they where called separatly, neither needed to have control conditions to detect which was needed. They simply allowed the dice object to decide. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 2010-12-05, Tim Harig user...@ilthio.net wrote: On 2010-12-05, Paul Rubin no.em...@nospam.invalid wrote: Tim Harig user...@ilthio.net writes: The fact that I bothered to create classes for the dice and roles, rather then simply iterating over a list of numbers, should tell you that I produced was of a far more flexible nature; including the support for roles with dice having different numbers of sides. from itertools import product def n_sided_die(n): return xrange(1, n+1) # make one 3-sided die, one 4-sided die, and one 5-sided die dice = (n_sided_die(3), n_sided_die(4), n_sided_die(5)) for roll in product(*dice): print roll Notice that you had to change the structure of your program to accomodate the new possiblity; and, if I throw further requirements at you, you will have to change them again. I didn't want that. What the dice returned may or may not have returned an easy to compute sequence. In fact, for all of the rest of the logic cared, the dice could have computed their value from a previous role of another dice. All of the logic of about what the dice may have returned when asked for their value and how they derived, was encapsilated in the dice themselves. It did not need to be known anywhere else in the program logic. The DSL effectively provided a way do define how the dice decided how to increment themselves, how to choose the value that they returned for their face, and how to know when they could no longer be incremented. The DSL parser generated the dice set from the description given. Creating new dice objects was much easier then attempting to change the logic of how they were rolled. I merely posted a simplied description of the dice-role objects because I thought that it demonstrated how exceptions can provide eligance of control for situations that don't involve what would traditionally be defined as an error. Exceptions (though sometimes necessary) are messy and I'm having a hard time trying to envision that code being cleaner with them than without them. If you post the actual code maybe that will help me understand. Let me get this straight, the same person that was trying to tell me setjmp/longjmp weren't messy thinks exceptions are messy? I have used both. I much prefer the exceptions. I not have to code here to post. The cleanliness of using the exception and calling the dice increments recursively, was that there was no need to figure out which dice needed to be incremented whenever the first die needed to be reset. When a dice needed to be reset, it would raise an exception. This exception would rise through the recursion stack, and thus through the dice, resetting each along the way until it found the one which needed to be incremented or raised past the top call indicating that all of the combinations has been exhausted. There, once the reset condition for the previous dice had been effectively handled, it would be supprested. Had this been done using in band data: 1. The roll object would have needed logic to determine when a reset condition needed to take place, effectively leaking some of the logic from the dice object to the role object. 2. The roll object would have needed logic to determine how to follow the dice which needed to be reset until it found which one needed incrementing. Once again, this logic was better left to the dice walking the resets was automatically handled by the progression of the exception. Even if it wasn't an error, the resets were effectively a exceptional condition from the normal flow of the role object (the primary flow simply being to increment the first die). By using exceptions, I effectively isolated each into its own separate independent flow; and, because they where called separatly, neither needed to have control conditions to detect which was needed. They simply allowed the dice object to decide. Okay, it occures to me that you don't really need to see much to know what was going on, here is the basic idea of how the role function of the object would have looked like: def role(self, dice): try: self.role(dice.previous()) except diceReset: dice.increment() except endOfDice: raise diceReset -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On 12/05/10 10:43, Jorge Biquez wrote: I do not see a good reason for not using Sqlite3 BUT if for some reason would not be an option what plain schema of files would you use? Assuming you don't want SQL, you can use filesystem-based database. Most people doesn't realize that a filesystem is essentially a database (of files) and a file explorer is a (sort of) DBMS. It is relatively easy to create a robust (as robust as the filesystem) and fast (as fast as the filesystem) database system by using folders and files (and optionally hard and symbolic links) to store data in hierarchical topology. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 12/04/2010 11:42 PM, Steven D'Aprano wrote: On Sun, 05 Dec 2010 04:13:02 +, Tim Harig wrote: str.find is more troublesome, because the sentinel -1 doesn't propagate and is a common source of errors: result = string[string.find(delim):] will return a plausible-looking but incorrect result if delim is missing from string. But the convenience and familiarity of str.find means it will probably be around forever. Fortunately, string objects offer both .find() and .index() so you can choose whether you want sentinels or exceptions according to your use-case. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On 12/05/2010 03:41 AM, Alan Gauld wrote: Why not use SQL? SQLlite comes with Python, is small, easy to use and if necessary can be used in-memory and as such fast. The only reason I could see using something other than sqlite3 for such a use-case would be if the OP has to support Python before version 2.5 and can't add/install the sqlite libraries to his deployment platform(s). I've got a couple targets still running 2.4 and regularly mutter under my breath when I reach for sqlite to find it's not there. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add data into exisitng Excel file at next open row?
On 12/3/2010 6:21 PM, noydb wrote: How can you determine the next open row in an existing Excel file such that you can start adding data to the cells in that row? As in below, I want a variable in place of the 6 (row 6 in the four ws1.Cells(x,1) lines), but have no other way of knowing what row I am on besides looking to the first free cell in column A. How to do? Examples I see make it seem really complicated - this can't be that hard. Thanks for any help. worksheet = C:\\Excel_Reports\\ea + ea + report# + .xls xlApp = win32com.client.Dispatch(Excel.Application) xlApp.Visible = 1 xlApp.Workbooks.Open(worksheet) ## for existing file ##xlApp.SheetsInNewWorkbook = 1 ##wb = xlApp.Workbooks() ws1 = xlApp.Worksheets(1) ws1.Cells(6,1).Value = selection ws1.Cells(6,2).Value = count ws1.Cells(6,3).Value = epcFloat ws1.Cells(6,8).Value = currentGMT wb.SaveAs(worksheet) wb.Close(False) ## False/1 You might want to take a look at the xlrd library. This lets you read Excel spreadsheets even on Unix platforms and without the use of COM magic. There's also an xlwt module for writing spreadsheets. However I understand that the two together may not be as convenient as modifying a spreadsheet in place. In particular, if sh is a spreadsheet then sh.nrows gives you the number of rows currently used in the sheet. 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: Which non SQL Database ?
In article 4cfb802...@dnews.tpgi.com.au, Lie Ryan lie.1...@gmail.com wrote: On 12/05/10 10:43, Jorge Biquez wrote: I do not see a good reason for not using Sqlite3 BUT if for some reason would not be an option what plain schema of files would you use? Assuming you don't want SQL, you can use filesystem-based database. Most people doesn't realize that a filesystem is essentially a database (of files) and a file explorer is a (sort of) DBMS. It is relatively easy to create a robust (as robust as the filesystem) and fast (as fast as the filesystem) database system by using folders and files (and optionally hard and symbolic links) to store data in hierarchical topology. Another possibility is one of the new breed of non-relational databases. We've been using MongoDB (http://www.mongodb.org/) and so far are happy with it. You can find a bunch of other alternatives in Wikipedia's NoSQL article. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unknown function operation deciphering, exercise in readability by program reasoning
On Dec 5, 3:34 am, jvt vincent.to...@gmail.com wrote: On Dec 4, 4:49 pm, Barb Knox s...@sig.below wrote: In article 46365e1d-42d8-4b3b-8e69-941472467...@u25g2000pra.googlegroups.com, small Pox smallpox...@gmail.com wrote: Rules : No need to add any additional hurdles -- the code as presented is thoroughly unreadable by humans. @1@ No execution of the function, only checking syntax What about desk checking (a lost art from the oldene dayes)? @2@ No profiling using a debugger or profiler @3@ Editing allowed to make simpler variables Maybe if you had done that yourself before posting it then I would have tried to understand it. As it is, no way. (defun unknown-function (nano-thermite-911-FBI-fat-per-diem-bustards- kept-their-odious-mouth-shut-on-anthrax-and-911-lie) (let (BERNARD-MADOFF-PHILIP-MARKOFF-MIKHAIL-KHODORKOVSKY-NEOCONS- PAUL-WOLFOWITZ-LEWIS-SCOOTER-LIBBY-MOSHE-KATSEV-MOSSAD-DUBAI-MURDERERS I-AM-THE-WITNESS-DOT-COM-has-MR-BENJAMIN-FREEDMAN-SPEECH-ON-KHAZARS) (while (or I-AM-THE-WITNESS-DOT-COM-has-MR-BENJAMIN-FREEDMAN- SPEECH-ON-KHAZARS nano-thermite-911-FBI-fat-per-diem-bustards-kept- their-odious-mouth-shut-on-anthrax-and-911-lie) (if nano-thermite-911-FBI-fat-per-diem-bustards-kept-their- odious-mouth-shut-on-anthrax-and-911-lie (if (consp nano-thermite-911-FBI-fat-per-diem-bustards-kept- their-odious-mouth-shut-on-anthrax-and-911-lie) (setq I-AM-THE-WITNESS-DOT-COM-has-MR-BENJAMIN-FREEDMAN- SPEECH-ON-KHAZARS (cons (cdr nano-thermite-911-FBI-fat-per-diem- bustards-kept-their-odious-mouth-shut-on-anthrax-and-911-lie) I-AM-THE-WITNESS-DOT-COM-has-MR- BENJAMIN-FREEDMAN-SPEECH-ON-KHAZARS) nano-thermite-911-FBI-fat-per-diem-bustards-kept- their-odious-mouth-shut-on-anthrax-and-911-lie (car nano-thermite-911- FBI-fat-per-diem-bustards-kept-their-odious-mouth-shut-on-anthrax- and-911-lie)) (setq BERNARD-MADOFF-PHILIP-MARKOFF-MIKHAIL-KHODORKOVSKY- NEOCONS-PAUL-WOLFOWITZ-LEWIS-SCOOTER-LIBBY-MOSHE-KATSEV-MOSSAD-DUBAI- MURDERERS (cons nano-thermite-911-FBI-fat-per-diem-bustards-kept-their- odious-mouth-shut-on-anthrax-and-911-lie BERNARD-MADOFF-PHILIP-MARKOFF- MIKHAIL-KHODORKOVSKY-NEOCONS-PAUL-WOLFOWITZ-LEWIS-SCOOTER-LIBBY-MOSHE- KATSEV-MOSSAD-DUBAI-MURDERERS) nano-thermite-911-FBI-fat-per-diem-bustards-kept- their-odious-mouth-shut-on-anthrax-and-911-lie nil)) (setq nano-thermite-911-FBI-fat-per-diem-bustards-kept-their- odious-mouth-shut-on-anthrax-and-911-lie (car I-AM-THE-WITNESS-DOT-COM- has-MR-BENJAMIN-FREEDMAN-SPEECH-ON-KHAZARS) I-AM-THE-WITNESS-DOT-COM-has-MR-BENJAMIN-FREEDMAN-SPEECH- ON-KHAZARS (cdr I-AM-THE-WITNESS-DOT-COM-has-MR-BENJAMIN-FREEDMAN- SPEECH-ON-KHAZARS BERNARD-MADOFF-PHILIP-MARKOFF-MIKHAIL-KHODORKOVSKY-NEOCONS-PAUL- WOLFOWITZ-LEWIS-SCOOTER-LIBBY-MOSHE-KATSEV-MOSSAD-DUBAI-MURDERERS)) -- --- | BBB b \ Barbara at LivingHistory stop co stop uk | B B aa rrr b | | BBB a a r bbb | Quidquid latine dictum sit, | B B a a r b b | altum videtur. | BBB aa a r bbb | - I think this is correct: (defun unknown-function (sym0) (let (sym1 sym2) (while (or sym2 sym0) (if sym0 (if (consp sym0) (setq sym2 (cons (cdr sym0) sym2) sym0 (car sym0)) (setq sym3 sym4 (cons sym0 sym1) sym0 nil)) (setq sym0 (car sym2) sym2 (cdr sym2 sym1)) Thank emacs, not me. Lisp? Still can't read it... ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unknown function operation deciphering, exercise in readability by program reasoning
On Dec 5, 9:13 am, rupertlssm...@googlemail.com rupertlssm...@googlemail.com wrote: On Dec 5, 3:34 am, jvt vincent.to...@gmail.com wrote: I think this is correct: (defun unknown-function (sym0) (let (sym1 sym2) (while (or sym2 sym0) (if sym0 (if (consp sym0) (setq sym2 (cons (cdr sym0) sym2) sym0 (car sym0)) (setq sym3 sym4 (cons sym0 sym1) sym0 nil)) (setq sym0 (car sym2) sym2 (cdr sym2 sym1)) Thank emacs, not me. Lisp? Still can't read it... ;-)- Hide quoted text - This is because madhu did not explain how he reasoned. Does it appear to you that she broke first two rules. its a list flattener that also reverses the operation. it appears that she took the consp predicate and/or flatten and started googling ... naughty girl. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unknown function operation deciphering, exercise in readability by program reasoning
On Dec 4, 11:37 pm, Madhu enom...@meer.net wrote: * jvt 5e1f79ab-5432-4f18-b896-362b7406c...@i18g2000yqn.googlegroups.com : Wrote on Sat, 4 Dec 2010 19:34:53 -0800 (PST): | | I think this is correct: | | | (defun unknown-function (sym0) | (let (sym1 sym2) | (while (or sym2 sym0) | (if sym0 | (if (consp sym0) | (setq sym2 (cons (cdr sym0) sym2) sym0 (car sym0)) | (setq sym3 sym4 (cons sym0 sym1) sym0 nil)) | (setq sym0 (car sym2) sym2 (cdr sym2 | sym1)) | Thank emacs, not me. Not quite. You didn't account for the original poster's go- ogle masters mangling his message. But your function appears to be a list flattener: explanation (defun unknown-function (list) (let (stack ret) (while (or ret list) (if list (if (consp list) (setq ret (cons (cdr list) ret) ;; hint: this is a push followed by list (car list)) ;; pop (setq stack (cons list stack) ;; and so is this list nil)) (setq list (car ret) ret (cdr ret stack)) --- Madhu I will post an explanation in a few days if no one does this before since its not urgent for anyone and i have some job assignments to finish. -- http://mail.python.org/mailman/listinfo/python-list
Framework design question
Hi, When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/' format needs to be converted to a Python date-object or '-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yy', but that can cause problems when data is retrieved). Question - at what point should the data be converted? a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called). b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command). In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing? Any opinions would be appreciated. Alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Framework design question
On 05/12/2010 18:20, Alan Harris-Reid wrote: Hi, When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/' format needs to be converted to a Python date-object or '-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yy', but that can cause problems when data is retrieved). Question - at what point should the data be converted? a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called). b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command). In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing? Any opinions would be appreciated. I would use a standardised 'international' form as much as possible, converting to it as early as possible and from it as late as possible. This applies to dates, text (using Unicode internally), etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to add data into exisitng Excel file at next open row?
On Dec 5, 8:42 am, Steve Holden st...@holdenweb.com wrote: On 12/3/2010 6:21 PM, noydb wrote: How can you determine the next open row in an existing Excel file such that you can start adding data to the cells in that row? As in below, I want a variable in place of the 6 (row 6 in the four ws1.Cells(x,1) lines), but have no other way of knowing what row I am on besides looking to the first free cell in column A. How to do? Examples I see make it seem really complicated - this can't be that hard. Thanks for any help. worksheet = C:\\Excel_Reports\\ea + ea + report# + .xls xlApp = win32com.client.Dispatch(Excel.Application) xlApp.Visible = 1 xlApp.Workbooks.Open(worksheet) ## for existing file ##xlApp.SheetsInNewWorkbook = 1 ##wb = xlApp.Workbooks() ws1 = xlApp.Worksheets(1) ws1.Cells(6,1).Value = selection ws1.Cells(6,2).Value = count ws1.Cells(6,3).Value = epcFloat ws1.Cells(6,8).Value = currentGMT wb.SaveAs(worksheet) wb.Close(False) ## False/1 You might want to take a look at the xlrd library. This lets you read Excel spreadsheets even on Unix platforms and without the use of COM magic. There's also an xlwt module for writing spreadsheets. However I understand that the two together may not be as convenient as modifying a spreadsheet in place. In particular, if sh is a spreadsheet then sh.nrows gives you the number of rows currently used in the sheet. 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/- Hide quoted text - - Show quoted text - Thanks, good to keep in mind. I have used xlrd before in cases where i'm not sure if excel is installed on a user's machine. Someone else helped, provided this NextRow = ws1.Range(A1).SpecialCells(xlLastCell).Row + 1 Although to get it to work for me, I have to use the number code for some reason, like NextRow = ws1.Range(A1).SpecialCells(11).Row + 1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Perceived inconsistency in py3k documentation
On 12/5/2010 3:31 AM, Greg wrote: For future reference, 1) At http://docs.python.org/py3k/reference/datamodel.html: 2) At http://docs.python.org/py3k/library/stdtypes.html: do not work because of the trailing :s, at least not with FireFox. 1) At http://docs.python.org/py3k/reference/datamodel.html : 2) At http://docs.python.org/py3k/library/stdtypes.html : These, with space after the url, should. Other puctuation can be a problem too, so it is best to always follow urls with whitespace. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On 04-12-2010 23:42, Jorge Biquez wrote: Hello all. Newbie question. Sorry. As part of my process to learn python I am working on two personal applications. Both will do it fine with a simple structure of data stored in files. I now there are lot of databases around I can use but I would like to know yoor advice on what other options you would consider for the job (it is training so no pressure on performance). One application will run as a desktop one,under Windows, Linux, Macintosh, being able to update data, not much, not complex, not many records. The second application, running behind web pages, will do the same, I mean, process simple data, updating showing data. not much info, not complex. As an excersice it is more than enough I guess and will let me learn what I need for now. Talking with a friend about what he will do (he use C only) he suggest to take a look on dBase format file since it is a stable format, fast and the index structure will be fine or maybe go with BD (Berkley) database file format (I hope I understood this one correctly) . Plain files it is not an option since I would like to have option to do rapid searches. What would do you suggest to take a look? If possible available under the 3 plattforms. Thanks in advance for your comments. Jorge Biquez You should take a look at one of the database wrappers. I use the DAL of Web2Py, the main advantages are - easy use of database (more easy than SQL) - easy migration of database structure (is done automatically) - same interface on desktop and in web applications - all major database (including SQLite and Postgres) supported and can be switched easily cheers, Stef -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
result = myfunction (vars) if not result: # error condition Now above I first realized that the function can also return an empty list under some conditions and so changed it to If your function returns a list when successful, it should not return False in the error case. Instead, it should return None (indicating that there is no list). Then the condition changes to result = myfunction() if result is None: # error condition Using None for no result available is very common in Python. Using False for the same purpose (i.e. returning either a list or False) is not. If you return False from a function, the only other possible result should be True. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Which non SQL Database ?
On Sun, Dec 5, 2010 at 12:01 AM, John Nagle na...@animats.com wrote: On 12/4/2010 8:44 PM, Monte Milanuk wrote: On 12/4/10 3:43 PM, Jorge Biquez wrote: I do not see a good reason for not using Sqlite3 BUT if for some reason would not be an option what plain schema of files would you use? Would shelve work? There are some systems for storing key-value pairs in files. Underneath shelve is some primitive database, dbm, gdbm or bsddb. bsddb is deprecated and was removed from Python 3.x. dbm has some classic problems. gdbm is an improved version of dbm. None of these handle access from multiple processes, or crash recovery. We're looking at 1979 technology here. SQLite works right when accessed from multiple processes. SQLite is the entry-level database technology for Python today. It handles the hard cases, like undoing transactions after a crash and locking against multiple accesses. Lookup performance is good; simultaneous update by multiple processes, though, is not so good. When you have a web site that has many processes hitting the same database, it's time to move up to MySQL or Postgres. There's a lot of interest in non-SQL databases for very large distributed systems. You worry about this if you're Facebook or Google, or are running a big game server farm. SQLite isn't exactly no SQL. I've used the bsddb and gdbm modules quite a bit. I've found that bsddb tables tend to get corrupted (whether used from CPython or C), EG when a filesystem fills up. I quite like the gdbm module though, and have been using it in my current project. If you find that converting your database keys and values to/from strings is expensive, you could check out http://stromberg.dnsalias.org/~dstromberg/cachedb.html which is a caching wrapper around gdbm and other single-table database interfaces supporting the same API. As far as multiple processes, IINM, gdbm supports a single writer and multiple readers. -- http://mail.python.org/mailman/listinfo/python-list
Collision of rotated rectangles without pygame
Hello, I am looking for a Python library for 2D collision checks of rotated rectangles. Currently, I have found vizier 0.5b that is based on pygame. Since I do not want to add a pygame dependency to my app, I replaced the pygame.rect.Rect by a wxPython wx.Rect (see code below). However, collision checks do not work correctly, i. e. identical rects are not found to be colliding: $ python Python 2.6.6 (r266:84292, Nov 28 2010, 18:42:58) [GCC 4.4.5] on linux2 Type help, copyright, credits or license for more information. import xrect r=xrect.RotoRect(10,10,30,20,angle=34) s=xrect.RotoRect(10,10,30,20,angle=34) r.rotocollide(s) False Is my replacement of the rectangle object wrong or is vizier not working correctly with pygame as well? Do you know of any other pure Python library for rotated rectangle collision checks? Cheers Martin from __future__ import division import math import wx ## cos_table = dict([(deg, math.cos(math.radians(deg))) for deg in xrange(360)]) sin_table = dict([(deg, math.sin(math.radians(deg))) for deg in xrange(360)]) class RotoRect(wx.Rect): def __init__(self, *a, **kw): self.deg = kw.pop('angle') wx.Rect.__init__(self, *a, **kw) # pygame rect compatibility for wx.Rect def get_center(self): return self.centerx, self.centery def set_center(self, center): self.centerx, self.centery = center def get_centerx(self): return self.x + self.width / 2 def set_centerx(self, centerx): self.SetX(centerx - self.width / 2) def get_centery(self): return self.y + self.height / 2 def set_centery(self, centery): self.SetY(centery - self.height / 2) def get_topleft(self): return self.GetTopLeft() def set_topleft(self, p): self.SetTopLeft(p) def get_topright(self): return self.GetTopRight() def set_topright(self, p): self.SetTopRight(p) center = property(get_center, set_center) centerx = property(get_centerx, set_centerx) centery = property(get_centery, set_centery) topleft = property(get_topleft, set_topleft) topright = property(get_topright, set_topright) # Now for the vizier code def rotate(self, point, origin = 0): Returns coords of point p rotated self.theta radians with the rectangle around its center if not origin: origin = self.center p_x = point[0] p_y = point[1] o_x = origin[0] o_y = origin[1] costheta = cos_table[self.deg] sintheta = sin_table[self.deg] return ((o_x + costheta * (p_x - o_x)) - (sintheta * (p_y - o_y)), (o_y + sintheta * (p_x - o_x)) + (costheta * (p_y - o_y))) def rotoxt(self, a, b): Returns the y extremity xt of rect between self.rect a_x = a[0] a_y = a[1] b_x = b[0] b_y = b[1] #calculate difference between self.left and b_x dxl = self.left - b_x #calculate difference between self.right and b_x dxr = self.right - b_x #if b_x isn't between self.left and self.right if (dxl * dxr) 0: #if dxl 1, b_x is on the right if (dxl 0): #xt = (m * dxr) + b_y xt = b_y - (-a_y)) / (b_x - (-a_x))) * dxr) + b_y) else: #else b_x is on the left #xt = (m * dxl) + b_y xt = b_y - a_y) / (b_x - a_x)) * dxl) + b_y) return xt else: #else b_x is between self.left and self.right, and xt = b_y return b_y def rotocollide(self, rect): Check for collision between self.rect and rect #initialize collision to False col = False #transforming the plane to set rect's center to the origin transplane = rect.center #set rect's center to the origin rect.center = (0, 0) #transform self.rect's center by the transplane amount self.center = (self.centerx - transplane[0], self.centery - transplane[1]) #transforming the plane to set self.rect's theta to 0 transdeg = self.deg
Re: Collision of rotated rectangles without pygame
On Sun, 5 Dec 2010 23:49:36 +0100 Martin Manns mma...@gmx.net wrote: Is my replacement of the rectangle object wrong or is vizier not working correctly with pygame as well? Answering my first question: Vizier works O.K. with pygame. I am unsure what I did wrong in the rect replacement though. Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparison with False - something I don't understand
On 05/12/2010 21:01, Martin v. Loewis wrote: result = myfunction (vars) if not result: # error condition Now above I first realized that the function can also return an empty list under some conditions and so changed it to If your function returns a list when successful, it should not return False in the error case. Instead, it should return None (indicating that there is no list). Then the condition changes to result = myfunction() if result is None: # error condition Using None for no result available is very common in Python. Using False for the same purpose (i.e. returning either a list or False) is not. If you return False from a function, the only other possible result should be True. As an example, the re module uses both two approaches. If you ask it to compile a regex: rgx = re.compile(regex) it either returns a PatternObject (if the regex is valid) or raises an exception (if the regex isn't valid). If you ask it to search a string: rgx.search(string) it returns either a MatchObject (if the match is successful) or None (if the match isn't successful). -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I get the email address of the person who clicked the link in the email?
On Dec 5, 10:15 am, Zeynel azeyn...@gmail.com wrote: I am working with Google App Engine python version. The app sends an email to the user with a link to a page to upload an image as an avatar. It would be nice to have the email so that I can associate the avatar with that email. How can I do this? Thank you. One approach would be to assign a unique identifier to the email address, then include that identifier as a parameter in the link that allows for image uploading: http://your.site.tld/avatar/upload/unique_id (for eg) Then the upload process can get the ID from the path and identify the email address with which the image is associated. -- http://mail.python.org/mailman/listinfo/python-list
PEP8 compliance and exception messages ?
Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) ... and assuming a certain amount of indenting you're going to break that guideline. However there's a way around that ! You can do this ... raise fooMod.fooException(\ Some message \ which is quite long) ... but the trouble is when that Exception is raised the message is displayed as : Some message which is quite long I'm aware that a foolish consistency is the hobgoblin of something or the other so maybe I should just let the PEP8 verifier complain but otherwise does anyone have any ideas for how to get around this ? Thanks richard -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
On Sun, Dec 5, 2010 at 7:40 PM, shearichard shearich...@gmail.com wrote: Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) ... and assuming a certain amount of indenting you're going to break that guideline. However there's a way around that ! You can do this ... raise fooMod.fooException(\ Some message \ which is quite long) ... but the trouble is when that Exception is raised the message is displayed as : Some message which is quite long I'm aware that a foolish consistency is the hobgoblin of something or the other so maybe I should just let the PEP8 verifier complain but otherwise does anyone have any ideas for how to get around this ? Use implicit string literal concatenation: raise fooMod.fooException( Some message which is quite long) #) # you could also put the closing paren here instead Alternatively, you could disregard PEP 8 on this point on the grounds that the 79/80 characters per line limit is outdated. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
On 06/12/2010 03:40, shearichard wrote: Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) ... and assuming a certain amount of indenting you're going to break that guideline. However there's a way around that ! You can do this ... raise fooMod.fooException(\ Some message \ which is quite long) ... but the trouble is when that Exception is raised the message is displayed as : Some message which is quite long I'm aware that a foolish consistency is the hobgoblin of something or the other so maybe I should just let the PEP8 verifier complain but otherwise does anyone have any ideas for how to get around this ? You can use implied string concatenation: abc def 'abcdef' so: raise fooMod.fooException( Some message which is quite long) -- http://mail.python.org/mailman/listinfo/python-list
Wanted: slow regexes
I'm looking for examples of regexes which are slow (especially those which seem never to finish) but whose results are known. I already have those reported in the bug tracker, but further ones will be welcome. This is for testing additional modifications to the new regex implementation (available on PyPI). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3 encoding question: Read a filename from stdin, subsequently open that filename
Ultimately I switched to reading the filenames from file descriptor 0 using os.read(); this gave back bytes in 3.x, strings of single-byte characters in 2.x - which are similar enough for my purposes, and eliminated the filesystem encoding(s) question nicely. I rewrote readline0 (http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/readline0/trunk/?root=svn) for 2.x and 3.x to facilitate reading null-terminated strings from stdin. It's in better shape now anyway - more OOP than functional, and with a bunch of unit tests. The module now works on CPython 2.x, CPython 3.x and PyPy 1.4 from the same code. On Mon, Nov 29, 2010 at 9:26 PM, Dan Stromberg drsali...@gmail.com wrote: I've got a couple of programs that read filenames from stdin, and then open those files and do things with them. These programs sort of do the *ix xargs thing, without requiring xargs. In Python 2, these work well. Irrespective of how filenames are encoded, things are opened OK, because it's all just a stream of single byte characters. In Python 3, I'm finding that I have encoding issues with characters with their high bit set. Things are fine with strictly ASCII filenames. With high-bit-set characters, even if I change stdin's encoding with: import io STDIN = io.open(sys.stdin.fileno(), 'r', encoding='ISO-8859-1') ...even with that, when I read a filename from stdin with a single-character Spanish n~, the program cannot open that filename because the n~ is apparently internally converted to two bytes, but remains one byte in the filesystem. I decided to try ISO-8859-1 with Python 3, because I have a Java program that encountered a similar problem until I used en_US.ISO-8859-1 in an environment variable to set the JVM's encoding for stdin. Python 2 shows the n~ as 0xf1 in an os.listdir('.'). Python 3 with an encoding of ISO-8859-1 wants it to be 0xc3 followed by 0xb1. Does anyone know what I need to do to read filenames from stdin with Python 3.1 and subsequently open them, when some of those filenames include characters with their high bit set? TIA! -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
shearichard shearich...@gmail.com writes: Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) PEP 8 also says those names are poorly chosen. Better: raise foomod.FooException(Some message which is quite long) raise fooMod.fooException(\ Some message \ which is quite long) Take advantage of the parsing of string literals and parenthesis: raise foomod.FooException( Some message which is quite long) and for the sake of my eyes, avoid camelCase. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
On Sun, 5 Dec 2010 19:52:54 -0800 Chris Rebert c...@rebertia.com wrote: On Sun, Dec 5, 2010 at 7:40 PM, shearichard shearich...@gmail.com wrote: Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) ... and assuming a certain amount of indenting you're going to break that guideline. [etc.] Use implicit string literal concatenation: [...] But isn't explicit string literal concatenation better than implicit string literal concatenation? ... sorry ... On a more serious note: Alternatively, you could disregard PEP 8 on this point on the grounds that the 79/80 characters per line limit is outdated. Maybe, but it's not outmoded. /W -- To reach me via email, replace INVALID with the country code of my home country. But if you spam me, I'll be one sour Kraut. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
On 2010-12-06, Andreas Waldenburger use...@geekmail.invalid wrote: On Sun, 5 Dec 2010 19:52:54 -0800 Chris Rebert c...@rebertia.com wrote: On Sun, Dec 5, 2010 at 7:40 PM, shearichard shearich...@gmail.com wrote: Hi - PEP8 says lines should not exceed 79 characters in length ( http://www.python.org/dev/peps/pep-0008/ ). So if you've got some code that looks like this : raise fooMod.fooException(Some message which is quite long) ... and assuming a certain amount of indenting you're going to break that guideline. [etc.] Use implicit string literal concatenation: [...] But isn't explicit string literal concatenation better than implicit string literal concatenation? So add the +, it really doesn't change it much. Alternatively, you could disregard PEP 8 on this point on the grounds that the 79/80 characters per line limit is outdated. Maybe, but it's not outmoded. I would say that it is not even outdated. Just because you happen to enjoy longer lines doesn't mean that everybody does. Not all progammers have 20/10 vision and even those who have hardware to handled it don't necessarily like having a single piece of code take up their entire display just to be readable. Many of us like the extra ability that wider screen technology gives us to actually be able to view more of the file at once by splitting the display into a couple of columns. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 compliance and exception messages ?
On Mon, 06 Dec 2010 06:15:06 +, Tim Harig wrote: But isn't explicit string literal concatenation better than implicit string literal concatenation? So add the +, it really doesn't change it much. Perhaps not *much*, but it *may* change it a bit. Implicit concatenation of literals is promised to be handled by the compiler, at compile time: from dis import dis dis(compile(s = 'hello' 'world', , single)) 1 0 LOAD_CONST 0 ('helloworld') 3 STORE_NAME 0 (s) 6 LOAD_CONST 1 (None) 9 RETURN_VALUE This holds all the way back to Python 1.5 and probably older. But explicit concatenation may occur at run-time, depending on the implementation and the presence or absence of a keyhole optimizer. E.g. in Python 2.4: dis(compile(s = 'hello' + 'world', , single)) 1 0 LOAD_CONST 0 ('hello') 3 LOAD_CONST 1 ('world') 6 BINARY_ADD 7 STORE_NAME 0 (s) 10 LOAD_CONST 2 (None) 13 RETURN_VALUE A small difference, but a real one. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: class attribute confusion
On 12/3/2010 11:58 PM, Steven D'Aprano wrote: Right. If you define a *class* attribute, it lives in the class, not the instance, and so all instances share the same value. Unless, of course, an instance binds the same name in its namespace, in which case it will (usually) mask the class attribute for that instance. 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: Which non SQL Database ?
On 12/5/2010 12:59 AM, CM wrote: SQlite itself is around 300 kilobytes. That's negligible. It is also already in Python, so you'd have to purposefully exclude it in creating your executable to save those 300 kb and thus the 1/13th of a second additional time it would take average (3.9 MB/s) users to download your app if it were included. Just as a matter of interest where do you get the information that the average user has a 3.9 MB/s path to the Internet? 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
[issue10628] Typos in 3.2 what’s new
Georg Brandl ge...@python.org added the comment: Applied rest in r87083. -- nosy: +georg.brandl resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10628 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10626] test_concurrent_futures implicitly installs a logging handler on import
Nick Coghlan ncogh...@gmail.com added the comment: This is unrelated to issue 10517 (based on Dave Malcolm's initial investigation, that looks like it may be a genuine problem in multiprocessing) Instead, this relates to a problem in concurrent.futures where it installs a logging *handler* as a side effect of import. IMO, this is itself a bug in the concurrent.futures package - the standard library shouldn't be installing logging handlers implicitly, but only when explicitly asked to do so, or when absolutely necessary (multiprocessing is an example of a package that walks this line appropriately). The reason the test_pydoc, test_logging, test_concurrent_futures sequence causes an error is as follows: 1. test_pydoc walks the entire package hierarchy when testing its ability to generate the HTML for the search page. 2. this implicitly imports concurrent.futures, since it is implemented as a package that imports names from submodules in __init__.py 3. this means the c.f handler is already registered in logging when test_logging is run 4. as test_logging assumes it has full control over the logging state, the c.f handler is not left in the same state as it started in 5. test_concurrent_futures then fails, as it assumes the state of the handler has not changed since it was created as a side-effect of the package import Quite a trip down the rabbit hole to figure that one out :) Handing back to Brian to fix the underlying problem (i.e. the implicit installation of the logging handler by concurrent.futures). Georg FYI as to why the py3k buildbots will sometimes go red if the randomised execution happens to run these 3 tests in this particular order (and my apologies for checking in the regrtest.py changes during the release freeze). -- assignee: ncoghlan - bquinlan keywords: +buildbot nosy: +georg.brandl title: test_concurrent_futures failure - test_concurrent_futures implicitly installs a logging handler on import ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10626 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10629] Arbitrary precision
New submission from Bill McEachen billyma...@excite.com: from this link [http://en.wikipedia.org/wiki/PARI/GP#Usage_examples], I wanted to contrast arbitrary precision with the other pgm I use, Pari/GP. I tried the xample there which was: 123456! + 0. Now, behavior seems the same without the +0. for both. However, while Pari returns the answer shown on link quickly, Python after a delay returned an error, related to float conversion. Here is the progression from a smaller number to the problem: math.factorial(12) +0. 479001600.0 math.factorial(123) +0. 1.214630436702533e+205 math.factorial(1234) +0. Traceback (most recent call last): File stdin, line 1, in module OverflowError: long int too large to convert to float -- components: Regular Expressions messages: 123414 nosy: billymac00 priority: normal severity: normal status: open title: Arbitrary precision type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10629 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10576] Add a progress callback to gcmodule
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Here is a third patch. The callback now gets two argument, phase and info. I've added documentation and unittests. -- Added file: http://bugs.python.org/file19946/gccallback3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Boštjan Mejak bostjan.me...@gmail.com added the comment: I'm troubled with one little letter: L.copy() - list -- a shallow copy of L); should be L.copy() - list -- shallow copy of L); without the letter 'a', because other sentences also don't say L.__sizeof__() -- *A* size of L in memory, in bytes); Please fix this. -- Added file: http://bugs.python.org/file19947/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___I#39;m troubled with one little letter:divspan class=Apple-style-span style=font-family: #39;Times New Roman#39;; font-size: medium; pre style=word-wrap: break-word; white-space: pre-wrap; quot;L.copy() -gt; list -- a shallow copy of Lquot;); should be/pre pre style=word-wrap: break-word; white-space: pre-wrap; span class=Apple-style-span style=font-family: #39;Times New Roman#39;; white-space: normal; pre style=word-wrap: break-word; white-space: pre-wrap; quot;L.copy() -gt; list -- shallow copy of Lquot;); without the letter #39;a#39;, because other sentences also don#39;t say quot;L.__sizeof__() -- *A* size of L in memory, in bytesquot;);/prepre style=word-wrap: break-word; white-space: pre-wrap; Please fix this./pre/span/pre/span/div ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Boštjan Mejak bostjan.me...@gmail.com added the comment: Can you please help me find the definition of the copy() method of dict in the Python sources? I want to see how that method is defined and compare the definition to the one in Eli's patch. -- Added file: http://bugs.python.org/file19948/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___Can you please help me find the definition of the copy() method of dict in the Python sources? I want to see how that method is defined and compare the definition to the one in Eli#39;s patch. ___ 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
Steven Bethard steven.beth...@gmail.com added the comment: The workaround in TestImportStar is fine. The test is really just meant to make sure that __all__ contains all the current API methods, and the _ checks were the easiest way at the time to check that. -- ___ 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
[issue10626] test_concurrent_futures implicitly installs a logging handler on import
Georg Brandl ge...@python.org added the comment: What a nice mess :) Raising priority so that this doesn't get overlooked. -- priority: normal - deferred blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10626 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1294232] Error in metaclass search order
Daniel Urban urban.dani...@gmail.com added the comment: What also worries me is the difference between the class statement and the type() function. I think the reason of this is that the class statement uses the __build_class__ builtin function. This function determines the metaclass to use (by getting the metaclass of the first base class), and calls it. When one directly calls type, one doesn't call the metaclass (though type.__new__ will later call the real metaclass). An example: class M_A(type): ... def __new__(mcls, name, bases, ns): ... print('M_A.__new__', mcls, name, bases) ... return super().__new__(mcls, name, bases, ns) ... class M_B(M_A): ... def __new__(mcls, name, bases, ns): ... print('M_B.__new__', mcls, name, bases) ... return super().__new__(mcls, name, bases, ns) ... class A(metaclass=M_A): pass ... M_A.__new__ class '__main__.M_A' A () class B(metaclass=M_B): pass ... M_B.__new__ class '__main__.M_B' B () M_A.__new__ class '__main__.M_B' B () class C(A, B): pass ... M_A.__new__ class '__main__.M_A' C (class '__main__.A', class '__main__.B') M_B.__new__ class '__main__.M_B' C (class '__main__.A', class '__main__.B') M_A.__new__ class '__main__.M_B' C (class '__main__.A', class '__main__.B') Above __build_class__ calls M_A (because that is the metaclass of the first base class, A). Then M_A calls type.__new__ with super(), then type.__new__ searches the real metaclass, M_B, and calls its __new__. Then M_B.__new__ calls again M_A.__new__. D = type('D', (A, B), {}) M_B.__new__ class '__main__.M_B' D (class '__main__.A', class '__main__.B') M_A.__new__ class '__main__.M_B' D (class '__main__.A', class '__main__.B') Above type.__call__ directly calls type.__new__, which determines the real metaclass, M_B, and calls it (which then class M_A): class C2(B, A): pass ... M_B.__new__ class '__main__.M_B' C2 (class '__main__.B', class '__main__.A') M_A.__new__ class '__main__.M_B' C2 (class '__main__.B', class '__main__.A') If we reverse the order of the base classes of C (as above for C2), __build_class__ will use M_B as the metaclass. D2 = M_B('D', (A, B), {}) M_B.__new__ class '__main__.M_B' D (class '__main__.A', class '__main__.B') M_A.__new__ class '__main__.M_B' D (class '__main__.A', class '__main__.B') And of course, if we call directly the real metaclass, M_B (as above), we get the same result. I used the expression real metaclass with the meaning the __class__ of the class we are currently creating: C.__class__ class '__main__.M_B' C2.__class__ class '__main__.M_B' D.__class__ class '__main__.M_B' D2.__class__ class '__main__.M_B' Summary: the problem seems to be, that __build_class__ doesn't call the real metaclass, but the metaclass of the first base. (Note: I think this is approximately consistent with the documentation: Otherwise, if there is at least one base class, its metaclass is used. But I don't know, if this is the desired behaviour.) This behaviour of __build_class__ can result in problems. For example, if the two metaclasses define __prepare__. In some cases __build_class__ won't call the real metaclass' __prepare__, but the other's: class M_A(type): ... def __new__(mcls, name, bases, ns): ... print('M_A.__new__', mcls, name, bases) ... return super().__new__(mcls, name, bases, ns) ... @classmethod ... def __prepare__(mcls, name, bases): ... print('M_A.__prepare__', mcls, name, bases) ... return {} ... class M_B(M_A): ... def __new__(mcls, name, bases, ns): ... print('M_B.__new__', mcls, name, bases, ns) ... return super().__new__(mcls, name, bases, ns) ... @classmethod ... def __prepare__(mcls, name, bases): ... print('M_B.__prepare__', mcls, name, bases) ... return {'M_B_was_here': True} ... The __prepare__ method of the two metaclass differs, M_B leaves a 'M_B_was_here' name in the namespace. class A(metaclass=M_A): pass ... M_A.__prepare__ class '__main__.M_A' A () M_A.__new__ class '__main__.M_A' A () class B(metaclass=M_B): pass ... M_B.__prepare__ class '__main__.M_B' B () M_B.__new__ class '__main__.M_B' B () {'M_B_was_here': True, '__module__': '__main__'} M_A.__new__ class '__main__.M_B' B () class C(A, B): pass ... M_A.__prepare__ class '__main__.M_A' C (class '__main__.A', class '__main__.B') M_A.__new__ class '__main__.M_A' C (class '__main__.A', class '__main__.B') M_B.__new__ class '__main__.M_B' C (class '__main__.A', class '__main__.B') {'__module__': '__main__'} M_A.__new__ class '__main__.M_B' C (class '__main__.A', class '__main__.B') 'M_B_was_here' in C.__dict__ False __build_class__ calls M_A.__prepare__, so the new class won't have a 'M_B_was_here' attribute (though its __class__ is M_B). class C2(B, A): pass ... M_B.__prepare__ class '__main__.M_B' C2 (class '__main__.B', class '__main__.A')
[issue10292] tarinfo should use relative symlinks
Lars Gustäbel l...@gustaebel.de added the comment: Okay, this bug has been fixed in the 2.7 series. Python 2.6 is now in security-fix-only mode which means that there will not be a fix for it. Therefore, I close this issue. -- resolution: - fixed status: open - closed versions: +Python 2.6 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10292 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10629] Arbitrary precision
Georg Brandl ge...@python.org added the comment: Note that while Python's long type gives you unlimited-size integers, the float type doesn't make such promises: it is just a double-precision float. As such, math.factorial(1234) cannot be interpreted; it would simply be positive infinity. -- components: +Interpreter Core -Regular Expressions nosy: +georg.brandl, mark.dickinson resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10629 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10629] Arbitrary precision
Mark Dickinson dicki...@gmail.com added the comment: Right; this is expected behaviour. The error you're seeing comes from the implicit conversion of 1234! from long to float. -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10629 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10576] Add a progress callback to gcmodule
Changes by Antoine Pitrou pit...@free.fr: -- stage: - patch review versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5587] vars() no longer has a useful __repr__
Daniel Urban urban.dani...@gmail.com added the comment: Based on David Stanek's patch I've made a patch against the current py3k branch. The only difference is, that dict_proxy.__repr__ instead of simply returning the repr of the dict, returns approximately dict_proxy({!r}).format(self.dict). -- nosy: +durban Added file: http://bugs.python.org/file19949/issue5587.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5587 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5587] vars() no longer has a useful __repr__
Ezio Melotti ezio.melo...@gmail.com added the comment: Thanks for the patch! Can you include also a test that verifies that the repr is printed correctly? (You can take a look at #7310 if you want to see a possible approach.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5587 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5587] vars() no longer has a useful __repr__
Daniel Urban urban.dani...@gmail.com added the comment: Thanks for the patch! Can you include also a test that verifies that the repr is printed correctly? Sure. Where should I put the test? I didn't found any dict_proxy tests, except in test_descr.py (# Classes don't allow __dict__ assignment and have readonly dicts). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5587 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Changes by Mark Dickinson dicki...@gmail.com: Removed file: http://bugs.python.org/file19947/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Changes by Mark Dickinson dicki...@gmail.com: Removed file: http://bugs.python.org/file19948/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10630] dict_proxy.keys() / values() / items() are lists
New submission from Daniel Urban urban.dani...@gmail.com: The keys, values and items methods of dict_proxy return a list, while dict.keys, etc. return dictionary views (dict_keys, etc.). dict_proxy is used as the __dict__ attribute of classes. This is documented at http://docs.python.org/dev/py3k/reference/datamodel.html under Custom classes as Special attributes: ... __dict__ is the dictionary containing the class’s namespace ... While __dict__ is not actually dict, it probably should behave like a dict as close as possible. For example set operations work for dict.keys(), but not for dict_proxy.keys(). -- components: Interpreter Core messages: 123427 nosy: durban priority: normal severity: normal status: open title: dict_proxy.keys() / values() / items() are lists type: behavior versions: Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10630 ___ ___ 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
New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Is this intended behavior? Creating zipfile.ZipFile with relative path and changing current directory, relative path is resolved from new directory not from the directory object was created. F:\py3k Python 3.2a4+ (py3k, Dec 3 2010, 22:11:05) [MSC v.1200 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import zipfile [67577 refs] zip = zipfile.ZipFile(non-ascii-cp932.zip, r) [68999 refs] import os [69001 refs] os.mkdir(temp) [69001 refs] os.chdir(temp) [69001 refs] zip.extractall() Traceback (most recent call last): File stdin, line 1, in module File e:\python-dev\py3k\lib\zipfile.py, line 992, in extractall self.extract(zipinfo, path, pwd) File e:\python-dev\py3k\lib\zipfile.py, line 980, in extract return self._extract_member(member, path, pwd) File e:\python-dev\py3k\lib\zipfile.py, line 1023, in _extract_member source = self.open(member, pwd=pwd) File e:\python-dev\py3k\lib\zipfile.py, line 901, in open zef_file = io.open(self.filename, 'rb') IOError: [Errno 2] No such file or directory: 'non-ascii-cp932.zip' [69128 refs] -- messages: 123428 nosy: ocean-city priority: normal severity: normal status: open title: ZipFile and current directory change type: behavior ___ 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
[issue9101] reference json format in file formats chapter
Changes by Éric Araujo mer...@netwok.org: -- status: closed - open versions: -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9101 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6490] os.popen documentation in 2.6 is probably wrong
Éric Araujo mer...@netwok.org added the comment: I will refresh the patch, update it to recommend use as a context manager, and submit the patch here for review before committing. It’s too late for 2.6, though. Benjamin, I hope you won’t mind me taking the assignment from you. -- assignee: benjamin.peterson - eric.araujo nosy: +eric.araujo versions: +Python 3.1 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6490 ___ ___ 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
Antoine Pitrou pit...@free.fr added the comment: I don't know, but I wouldn't call it a bug either. In general it's not recommended to change the current directory except at the very beginning of your application. -- nosy: +pitrou ___ 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
[issue10516] Add list.clear() and list.copy()
Terry J. Reedy tjre...@udel.edu added the comment: Objects/dictobject.c -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10626] test_concurrent_futures implicitly installs a logging handler on import
Brian Quinlan br...@sweetapp.com added the comment: I've attached a patch that removes the code that installs a handler to the futures logger. I'm not sure if this is the correct approach though - it means that impossible errors will only be reported to the user through a message like no handler installed for logger. Maybe it is OK because this logging really shouldn't happen. Thoughts? -- keywords: +patch Added file: http://bugs.python.org/file19950/logging.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10626 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8194] Incompatible API change in xmlrpclib.Transport.parse_response() of Python 2.7 and 3.2
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8194 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10630] dict_proxy.keys() / values() / items() are lists
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10630 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5587] vars() no longer has a useful __repr__
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5587 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10632] multiprocessing gene
New submission from Brian Quinlan br...@sweetapp.com: multiprocessing generates fatal error Invalid thread state for this thread in PyThreadState_Swap This seems to happen on RHEL 5 and Centos 5.5 Here is the minimal repro: import multiprocessing.managers mpp = multiprocessing.Pool(4) sm = multiprocessing.managers.SyncManager() sm.start() See http://bugs.python.org/issue10517 for more details -- assignee: jnoller components: Library (Lib) messages: 123433 nosy: bquinlan, jnoller priority: high severity: normal status: open title: multiprocessing gene type: crash versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10632 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10517] test_concurrent_futures crashes with Fatal Python error: Invalid thread state for this thread
Brian Quinlan br...@sweetapp.com added the comment: I've filed a new bug (http://bugs.python.org/issue10632) against multiprocessing and this bug dependent on it. In the meantime, I can't repro this on ubuntu 10.04 LTS so I'm going to install Centos and give that a go. -- dependencies: +multiprocessing gene ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...
Martin v. Löwis mar...@v.loewis.de added the comment: As per http://mail.python.org/pipermail/python-dev/2010-December/106374.html I think this checkin should be reverted, as it's breaking the language moratorium. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...
Georg Brandl ge...@python.org added the comment: I leave this to MAL, on whose behalf I finished this to be in time for beta. -- assignee: - lemburg ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10632] multiprocessing generates a fatal error
Changes by Brian Quinlan br...@sweetapp.com: -- title: multiprocessing gene - multiprocessing generates a fatal error ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10632 ___ ___ 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: More formally: it's unspecified. I'd like to propose this general principle: If you pass a relative path to some library that gets stored in the library, it's unspecified whether the cwd is consider at the point of passing the path or at the point of using it in some operation. Applications that want to be cwd-agnostic must always use abspath. The only exceptions are operations where there is some explicit open() operation that is documented to interpret the path name; for these, it is clear that the cwd is considered inside the open(). -- nosy: +loewis ___ 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
[issue8910] Write a text file explaining why Lib/test/data exists
Éric Araujo mer...@netwok.org added the comment: Temporarily reopening so that Martin can decide whether he wants to add Lib/test/data/README to msi.py -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8910] Write a text file explaining why Lib/test/data exists
Martin v. Löwis mar...@v.loewis.de added the comment: All README files are automatically packages, and so is this one. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8910 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10633] string.format() Unexpected output with numeric '#' prefix and 0 width
New submission from Alex Leone acle...@gmail.com: When using the '#' to prefix a numeric argument in format() with a '0x' or others, the 0-width padding takes into account the '0x' characters. This is unexpected - the 0-width should NOT take into account the prefix. Current Behavior: {0:#02x}.format(10) '0xa' Expected Output: {0:#02x}.format(10) '0x0a' (note that the '0a' is two characters long, as it should be) -- components: Library (Lib) messages: 123441 nosy: Alex.Leone priority: normal severity: normal status: open title: string.format() Unexpected output with numeric '#' prefix and 0 width type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10633 ___ ___ 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
New submission from Eric Pruitt eric.pru...@gmail.com: If the current time zone changes on Windows, time.localtime will continue to return results that reflect the time zone the system used when the module was imported. My current work around is to use GetLocalTime from kernel32 with ctypes. Windows does not have a tzset() equivalent as it does in Linux, but it seems like modifying time.localtime to use GetLocalTime on Windows systems could make up for this shortcoming. -- components: Windows messages: 123442 nosy: eric.pruitt priority: normal severity: normal status: open title: Windows timezone changes not reflected by time.localtime type: behavior versions: Python 2.5, Python 2.6 ___ 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
[issue10588] imp.find_module raises unexpected SyntaxError
Changes by Éric Araujo mer...@netwok.org: -- nosy: +brett.cannon, eric.araujo, ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10588 ___ ___ 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 Brian Curtin cur...@acm.org: -- components: +Library (Lib) stage: - unit test needed versions: +Python 2.7, Python 3.1, Python 3.2 -Python 2.5, Python 2.6 ___ 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
[issue10633] string.format() Unexpected output with numeric '#' prefix and 0 width
Eric Smith e...@trueblade.com added the comment: I disagree that your expected output is how it should behave. I believe it's more likely that the user wants the entire field width specified. In addition, compatibility with %-formatting would dictate that we keep the current behavior. '%#02x' % 10 '0xa' -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10633 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10635] Calling subprocess.Popen with preexec_fn=signal.pause blocks forever
New submission from joseph.h.garvin joseph.h.gar...@gmail.com: The following code will cause the interpreter to hang: import subprocess import signal subprocess.Popen(/bin/echo, preexec_fn=signal.pause) Replace /bin/echo with any valid program on your box, it's just the simplest Linux example. It's expected for signal.pause to block, but the documentation for Popen says that preexec_fn will be run in the /child/ process, so it shouldn't cause the interpreter running this code to block. I'm going to guess Popen is using signals for some reason internally and signal.pause interferes with it. It's probably worth making sure that signals related functions work with preexec_fn in general. -- components: Library (Lib) messages: 123444 nosy: joseph.h.garvin priority: normal severity: normal status: open title: Calling subprocess.Popen with preexec_fn=signal.pause blocks forever type: behavior versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10635 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10636] subprocess module has race condition with SIGCHLD handlers
New submission from joseph.h.garvin joseph.h.gar...@gmail.com: The following code will result in a traceback 99% of the time, though it may take two runs (sometimes the first run won't trigger it, I think due to the changing in timing from genrating the .pyc file). It spawns an instance of /bin/echo, chosen because it's a very quick to finish program. Any program that executes faster than subprocess.Popen can return will work as a substitute though: import signal import subprocess to_launch = None def sig_chld_handler(signum, frame): global to_launch # Crashes here. # 'NoneType' object has no attribute 'poll' to_launch.poll() print to_launch.returncode signal.signal(signal.SIGCHLD, sig_chld_handler) to_launch = subprocess.Popen(/bin/echo) And the traceback: Traceback (most recent call last): File /tmp/sigchld.py, line 15, in module to_launch = subprocess.Popen(/bin/echo) File /usr/lib/python2.6/subprocess.py, line 623, in __init__ errread, errwrite) File /usr/lib/python2.6/subprocess.py, line 1130, in _execute_child data = _eintr_retry_call(os.read, errpipe_read, 1048576) File /usr/lib/python2.6/subprocess.py, line 455, in _eintr_retry_call return func(*args) File /tmp/sigchld.py, line 9, in sig_chld_handler to_launch.poll() AttributeError: 'NoneType' object has no attribute 'poll' I believe the problem is that the process completes before Popen can return, which means the assignment of to_launch hasn't happened yet, so it's not defined when we get into sig_chld_handler. I tried to work around this issue by setting preexec_fn to signal.pause and sending the child process a signal after the assignment, but then ran into another bug: http://bugs.python.org/issue10635 If when it caught SIGCHLD python pushed an event onto its internal event loop to execute the handler, I think that would make sure it's deferred until after the assignment. There might be other consequences of that, but I'm not familiar with the interpreter internals. Alternatively it could be fixed with an API change -- let Popen return an object before it actually launches the process, and have a separate start() method. -- components: Library (Lib) messages: 123445 nosy: joseph.h.garvin priority: normal severity: normal status: open title: subprocess module has race condition with SIGCHLD handlers versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10636 ___ ___ 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
Martin v. Löwis mar...@v.loewis.de added the comment: This is not a bug in Python, but in the Microsoft CRT. Rewriting Python to not use the CRT anymore for this is non-trivial, in particular as the semantics of environment variables (TZ) needs to be considered. -- nosy: +loewis ___ 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
[issue10636] subprocess module has race condition with SIGCHLD handlers
Martin v. Löwis mar...@v.loewis.de added the comment: If when it caught SIGCHLD python pushed an event onto its internal event loop to execute the handler, I think that would make sure it's deferred until after the assignment. This is not a reasonable request. How long would you want to postpone this? Suppose somebody writes def foo(): local_to_launch = subprocess.Popen(/bin/echo) return local_to_launch local_to_launch = foo() then deferring the signal until after the assignment would not help, so the semantics of your proposed change are fuzzy. There might be other consequences of that, but I'm not familiar with the interpreter internals. Alternatively it could be fixed with an API change -- let Popen return an object before it actually launches the process, and have a separate start() method. The right approach is to use sigblock/sigsetmask before creating the process, and then again after creating it. Unfortunately, these aren't exposed from the signal module. -- nosy: +loewis title: subprocess module has race condition with SIGCHLD handlers - subprocess module has race condition with SIGCHLD handlers ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10636] subprocess module has race condition with SIGCHLD handlers
joseph.h.garvin joseph.h.gar...@gmail.com added the comment: Sorry I wasn't trying to make a request, just suggesting one potential 'fix' (I agree that it isn't really though) to make things more intutive. Unless the app is delayed from launching until after the assignment finishes though I think a workaround is required. When it's deferred until after the assignment you at least have the ability to get it stored into a global. When it's not deferred I think you're required to something like disable SIGCHLD like you say, spawn the child, enable, and then manually poll each of the subprocess popen objects you've opened before to see if they died while the signal was down. I realize now this isn't really a bug. Principle of least surprise is probably too much to hope for with signals anyway. Feel free to close unless you want to leave it open as a bug to get sigblock/sigsetmask in. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10636 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10633] string.format() Unexpected output with numeric '#' prefix and 0 width
R. David Murray rdmur...@bitdance.com added the comment: Eric, I'm assuming you just forgot to close this. On the other hand, if you wanted a +1 from another dev, you've got it :) Besides the considerations you mentioned, changing this would be a significant backward incompatibility, and is therefore pretty much ruled out at this point, no matter what anyone might want. -- nosy: +r.david.murray resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10633 ___ ___ 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
R. David Murray rdmur...@bitdance.com 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. -- nosy: +r.david.murray ___ 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
[issue10626] test_concurrent_futures implicitly installs a logging handler on import
Nick Coghlan ncogh...@gmail.com added the comment: For 3.2, writing such errors directly to stderr would be fine (we already do that in other places via PyErr_WriteUnraisable) The test could then be modified to use test.support.captured_output to temporarily replace stderr and look at the output. The problem of avoiding interfering with application level handlers while having unraisable errors visible by default is probably the biggest reason past attempts to get the standard library using the logging module internally haven't gained much traction :P -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10626 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Very sorry, I created the bug calling CloseHandle twice in Modules/posixmodule.c. I think this should be fixed before beta1 released. Can I commit it? -- components: None files: posixmodule.diff keywords: needs review, patch messages: 123452 nosy: georg.brandl, ocean-city priority: release blocker severity: normal stage: commit review status: open title: Calling CloseHandle twice (Modules/posixmodule.c) versions: Python 3.2 Added file: http://bugs.python.org/file19951/posixmodule.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10516] Add list.clear() and list.copy()
Eli Bendersky eli...@gmail.com added the comment: Boštjan, a shallow copy: I took this directly from the documentation of dicts, which says: D.copy() - a shallow copy of D) As I mentioned in an earlier message, the doc-strings of list and dict methods are inconsistent in more than one way, so I'm going to leave this decision to the committer. I'll be happy to help with fixes too. Re your other question, in the Python source root, dictionaries are mostly implemented in Objects/dictobject.c - there's an array called mapp_methods that lists the functions used to implement relevant methods. For copy() it lists: {copy,(PyCFunction)dict_copy, METH_NOARGS, So you need dict_copy. Note that it's just a wrapper (of another wrapper, by the way) bit it's a good place to start. Arm yourself with an editor or IDE with some code-searching capabilities. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10482] subprocess and deadlock avoidance
Nick Coghlan ncogh...@gmail.com added the comment: The general idea is sound. My work colleagues have certainly had to implement their own reader/writer thread equivalents to keep subprocess from blocking. It makes sense to provide more robust public support for such techniques in process itself. -- nosy: +ncoghlan versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10482 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Martin v. Löwis mar...@v.loewis.de added the comment: Very sorry, I created the bug calling CloseHandle twice in Modules/posixmodule.c. I think this should be fixed before beta1 released. Can I commit it? Even if you commit it now, it won't get into beta1: the Windows binaries for that are already built. -- nosy: +loewis title: Calling CloseHandle twice (Modules/posixmodule.c) - Calling CloseHandle twice (Modules/posixmodule.c) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Georg Brandl ge...@python.org added the comment: What is the result of calling it twice? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Martin v. Löwis mar...@v.loewis.de added the comment: The second CloseHandle call will fail. As we are not checking the CloseHandle result, this has no further consequences, AFAICT. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Martin v. Löwis mar...@v.loewis.de added the comment: quick followup: there is a chance that this closes the wrong file due to race conditions, in case a different thread opens a file in-between that gets the same handle. Due to the GIL, this is unlikely -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10635] Calling subprocess.Popen with preexec_fn=signal.pause blocks forever
Georg Brandl ge...@python.org added the comment: After forking, the parent waits for the child's exec call to determine if it succeeds. Otherwise, you wouldn't get an exception in the parent when you do Popen('/bin/ech') or somesuch. -- nosy: +georg.brandl resolution: - invalid status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10635 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Georg Brandl ge...@python.org added the comment: OK, I would say this is an acceptable bug in a beta release. Will fix it after the release is done. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Well, I'm not sure. I didn't realize it while running python_d.exe. I just realized it while re-reading source code. MSDN says, (http://msdn.microsoft.com/en-us/library/ms724211%28VS.85%29.aspx) If the application is running under a debugger, the function will throw an exception if it receives either a handle value that is not valid or a pseudo-handle value. This can happen if you close a handle twice, (snip) So if someone run python_d.exe in debugger, maybe he/she can see exception. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10637] Calling CloseHandle twice (Modules/posixmodule.c)
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: -- Removed message: http://bugs.python.org/msg123461 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10637 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com