Wing IDE 4.1.5 released
Hi, Wingware has released version 4.1.5 of Wing IDE, an integrated development environment designed specifically for the Python programming language. Wing IDE is a cross-platform Python IDE that provides a professional code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aware auto-editing, a powerful graphical debugger, version control, unit testing, search, and many other features. **Changes** Recent changes include: * Add Show in Explorer/Finder and Copy File Path to editor tab context menu * Include special and inherited methods names in the auto-completer * Option to sort unit tests by source order * Item in Options menu of Search in Files to copy results to clipboard * Print and Select All in the debug I/O context menu * Project property to override the Strip Trailing White Space preference * Improved auto-editing with repeated press of : * Auto-wrap auto-entered invocations * Added support for debugging QThreads in PySide and PyQt4 * Option to auto-show Debug I/O tool on first output in each debug run * Added support for Python 3.3 alpha1 * Emacs mode Alt-{ and Alt-} * Improved Python turbo completion mode * Several VI mode improvements * About 50 other bug fixes and minor improvements Complete change log: http://wingware.com/pub/wingide/4.1.5/CHANGELOG.txt **New Features in Version 4** Version 4 adds the following new major features: * Refactoring -- Rename/move symbols, extract to function/method, and introduce variable * Find Uses -- Find all points of use of a symbol * Auto-Editing -- Reduce typing by auto-entering expected code * Diff/Merge -- Graphical file and repository comparison and merge * Django Support -- Debug Django templates, run Django unit tests, and more * matplotlib Support -- Maintains live-updating plots in shell and debugger * Simplified Licensing -- Includes all OSes and adds Support+Upgrades subscriptions Details on licensing changes: http://wingware.com/news/2011-02-16 **About Wing IDE** Wing IDE is an integrated development environment designed specifically for the Python programming language. It provides powerful editing, testing, and debugging features that help reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE can be used to develop Python code for web, GUI, and embedded scripting applications. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free simplified version designed for teaching beginning programming courses with Python. Version 4.0 of Wing IDE Professional includes the following major features: * Professional quality code editor with vi, emacs, and other keyboard personalities * Code intelligence for Python: Auto-completion, call tips, find uses, goto-definition, error indicators, refactoring, context-aware auto-editing, smart indent and rewrapping, and source navigation * Advanced multi-threaded debugger with graphical UI, command line interaction, conditional breakpoints, data value tooltips over code, watch tool, and externally launched and remote debugging * Powerful search and replace options including keyboard driven and graphical UIs, multi-file, wild card, and regular expression search and replace * Version control integration for Subversion, CVS, Bazaar, git, Mercurial, and Perforce * Integrated unit testing with unittest, nose, and doctest frameworks * Django support: Debugs Django templates, provides project setup tools, and runs Django unit tests * Many other features including project manager, bookmarks, code snippets, diff/merge tool, OS command integration, indentation manager, PyLint integration, and perspectives * Extremely configurable and may be extended with Python scripts * Extensive product documentation and How-Tos for Django, matplotlib, Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks Please refer to http://wingware.com/wingide/featuresfor a detailed listing of features by product level. System requirements are Windows 2000 or later, OS X 10.3.9or later (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Wing IDE supports Python versions 2.0.x through 3.2.x and Stackless Python. For more information, see the http://wingware.com/ **Downloads** Wing IDE Professional and Wing IDE Personal are commercial software and require a license to run. A free trial can be obtained directly from the product when launched. Wing IDE Pro -- Full-featured product: http://wingware.com/downloads/wingide/4.1 Wing IDE Personal -- A simplified IDE: http://wingware.com/downloads/wingide-personal/4.1 Wing IDE 101 -- For teaching with Python: http://wingware.com/downloads/wingide-101/4.1 **Purchasing and Upgrading** Wing 4.x requires an upgrade for Wing IDE 2.x and 3.x users at a cost of
[Windows] drag-and-drop onto .py file in modern versions?
Hello all, Back when I had 2.6.x installed, I used to be able to drag a file onto a .py file in order to open it with that script (rather, pass the name of the file as `sys.argv[1]`). I did nothing special to make this work, as far as I can recall; it was something that the installer set up automatically. I am running Windows Vista. Now that I have uninstalled 2.6.x, and have 2.7.2 and 3.2.2 installed, this behaviour no longer works. The .py file is apparently not recognized by Vista as a valid drop target; it does not highlight, and when I release the mouse, the dragged file is simply moved to / reordered within the containing folder. I was able to find a registry hack that is supposed to re-enable this behaviour: http://mindlesstechnology.wordpress.com/2008/03/29/make-python-scripts-droppable-in-windows/ However, I tried this and it had no effect whatsoever. Is there any way I can get the drag-and-drop behaviour back? Was it deliberately disabled for some reason? It was exceptionally convenient for several of my scripts, and now I have to make .bat wrappers for each one to get the same convenience. Aside: when I double-click a .py file, what determines which Python will run it? Is it a matter of which appears first in the PATH, or do I have to set something else in the registry? Will a shebang line override the default on Windows? If so, how do I write a shebang line for a Windows path - just #!C:/Windows/Python32? -- ~Zahlman {: -- http://mail.python.org/mailman/listinfo/python-list
Re: functions which take functions
Kiuhnm kiuhnm03.4t.yahoo.it wrote: That won't do. A good example is when you pass a function to re.sub, for instance. This is an odd request. I often pass functions to functions in order to simulate a C switch statement, such as in a language translator: commands = { 'add': doAdd, 'subtract' : doSubtract, 'multiply' : doMultiply, 'divide' : doDivide } nextCommand = parseCommandLine( line ) invokeCommand( commands[NextCommand] ) -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem connecting to SMTP/IMAP server using SSL
Hi Michael, Thanks again for your reply. I've tried using SMTP with TLS. And again it works with the VPN turned on but it still won't work with the VPN turned off. For some reason I don't understand, it simply won't instantiate the SMTP/SMTP_SSL/IMAP4/IMAP4_SSL objects at all and will hang forever if the VPN is turned off. I'm really at loss there :) Julien On Apr 2, 2012, at 6:57 PM, Michael Hrivnak wrote: Your phone may be using TLS on the normal IMAP port (143). Or, are you sure your phone is using IMAP and not active sync? Michael On Mon, Apr 2, 2012 at 6:25 PM, Julien jpha...@gmail.com wrote: Hi Michael, Thanks for your reply. I did try port 993. I know that port generally works for me, as I can access the Gmail IMAP/SMTP server using SSL. It also works for that other Exchange server but only when the VPN is turned on. Somehow my iPhone works fine without a VPN, as long as it uses SSL. So I'm really unsure why I can't achieve the same thing from my laptop using imaplib.IMAP4_SSL() without the VPN turned on. Thank you, Julien On Apr 2, 3:10 pm, Michael Hrivnak mhriv...@hrivnak.org wrote: That method uses the default port 993. Can you connect to that port at all from your computer? For example, try using a telnet client. Michael On Sat, Mar 31, 2012 at 1:39 AM, Julien jpha...@gmail.com wrote: Hi, I'm able to connect to an Exchange server via SMTP and IMAP from my iPhone using SSL and without using a VPN. So I would expect to be able to do the same from my computer using Python. However, the following hangs and times out on my computer when I'm not connected to the VPN: import imaplib imap = imaplib.IMAP4_SSL(my.server.address) If I am connected to the VPN, then it works fine. Do you know why it won't work with SSL and without the VPN? Am I missing something? Thanks a lot, Julien -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list smime.p7s Description: S/MIME cryptographic signature -- http://mail.python.org/mailman/listinfo/python-list
Re: [Windows] drag-and-drop onto .py file in modern versions?
On Thu, Apr 12, 2012 at 4:02 PM, Karl Knechtel zahl...@gmail.com wrote: Aside: when I double-click a .py file, what determines which Python will run it? Is it a matter of which appears first in the PATH, or do I have to set something else in the registry? Will a shebang line override the default on Windows? If so, how do I write a shebang line for a Windows path - just #!C:/Windows/Python32? Apologies - I can't answer your main question, and am just picking up the aside. The file-type association (which is really a file-extension association) determines the path to the executable. If that's specified without a full path, then it'll be the first one in PATH, but usually the association is given as an absolute filespec. I don't have a Vista handy, but in XP, bring up any folder, Options|Folder Options, File Types, and scroll down to PY. (For some obscure reason, on this particular computer of mine the association is with a Python that was installed with GNU Lilypond. Weird!) You may need to use the Advanced button to see the full path. As to writing a shebang, there's no way to do that directly. But in theory you could associate .py files with a little script that reads the first line and figures out which interpreter to invoke it in. For extra coolness points, write that script in portable Python that can be run on any of the interpreters you have installed - then you don't have to care! :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list
Is it possible develop applications in python for android and which IDE could you recommend me (Eclipse, ...)???
Hello all, I would like to know if it's possible develop android applications with python, making the apk package, etc. I don't want program from an android device only want to make programs for android from my PC. If it's possible which IDE could you recommend me? Thanks for your help Regards -- http://mail.python.org/mailman/listinfo/python-list
Sockets accept() in child processes
Hi, I'm writing a multiprocess server with Python 3.2 and the multiprocessing module. Here is my current implementation : - Main process: select() on a list of server sockets (different ips of the host, ssl or not, etc) - Children process : When they get a signal (in fact, a message in a pipe), they will accept() the server socket The problem is that after select() returns, I can accept() in the main process, but in a children process I got a EAGAIN error. The sockets are non-blocking. It seems that accept() can only be called in the same process that the one which selected(). This is a problem because I wanted to decide which process I should ask to take the connection to do some basic load-balacing based on current number of connected client in each process. Could someone help me or propose other implementations ? Thank you, -- http://mail.python.org/mailman/listinfo/python-list
is this foolish?
I've found myself using a Python gotcha as a feature. I've got a budding mail filter program which keeps rule state in a little class instance. Slightly paraphrased: class RuleState(object): def __init__(self, M, maildb_path, maildirs={}): [...] self.maildirs = maildirs The maildirs property is a cache of Maildir objects mapped by their pathname to avoid opening Maildirs every time they're mentioned. I create a new RuleState every time I file a message, and of course I want to share the cache between instances. Normally we look on the Python default parameter value as a gotcha which causes the unwary to reuse a single object across the board, causing unwanted persistence of state. But here I actually think this is a sane way to make an anonymous single shared state object for the maildirs cache, absent the caller's intent to use their own. I can think of a few potential downsides, but on the whole this is going to do exactly what I want in this case. Would experienced users please mock me? -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ Real Daleks don't climb stairs Real Daleks level the building. - Adrian Tritschler, ajft@ajft_sun.cs.adfa.oz.au -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On Thu, Apr 12, 2012 at 7:35 PM, Cameron Simpson c...@zip.com.au wrote: I've found myself using a Python gotcha as a feature. I've got a budding mail filter program which keeps rule state in a little class instance. Slightly paraphrased: class RuleState(object): def __init__(self, M, maildb_path, maildirs={}): [...] self.maildirs = maildirs Would experienced users please mock me? Well, no mocking; the same technique on a non-method function is a pretty normal way of maintaining state. But wouldn't it be simpler to use a class variable? class RuleState(object): maildirs = {} def __init__(self, M, maildb_path): Then just use self.maildirs everywhere, never assign to it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On 12Apr2012 19:43, Chris Angelico ros...@gmail.com wrote: | On Thu, Apr 12, 2012 at 7:35 PM, Cameron Simpson c...@zip.com.au wrote: | I've found myself using a Python gotcha as a feature. | I've got a budding mail filter program which keeps rule state in a | little class instance. Slightly paraphrased: | | class RuleState(object): | def __init__(self, M, maildb_path, maildirs={}): | [...] | self.maildirs = maildirs | | Would experienced users please mock me? | | Well, no mocking; the same technique on a non-method function is a | pretty normal way of maintaining state. I hadn't realised it was a common approach. | But wouldn't it be simpler to use a class variable? Yes. Yes it would. | class RuleState(object): | maildirs = {} | def __init__(self, M, maildb_path): | Then just use self.maildirs everywhere, never assign to it. Thanks. It makes the shared state far more obvious, too. Cheers, -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ Life IS pain, highness... anyone who tries to tell you different is trying to sell you something. - Wesley, The_Princess_Bride -- http://mail.python.org/mailman/listinfo/python-list
Error in MD5 checksums of the 2.7.3 release page.
Hello, There is an error in the MD5 checksums section of the following page: http://python.org/download/releases/2.7.3/ Python-3.1.5.tgz, Python-3.1.5.tar.bz2 and Python-3.1.5.tar.xz are listed instead of: Python-2.7.3.tgz, Python-2.7.3.tar.bz2 and Python-2.7.3.tar.xz Best, -- Jérémy Bethmont -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On 12/04/2012 10:35, Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. Have a look at Peter Inglesby's lightning talk from a recent London Python Dojo: http://inglesp.github.com/2012/03/24/mutable-default-arguments.html TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On Thu, Apr 12, 2012 at 7:15 AM, Tim Golden m...@timgolden.me.uk wrote: On 12/04/2012 10:35, Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. Have a look at Peter Inglesby's lightning talk from a recent London Python Dojo: http://inglesp.github.com/2012/03/24/mutable-default-arguments.html That's interesting, but you can get the same effect with a function attribute, if you really don't want to write a class... that way also protects you against accidentally passing something in to override the default. (Incidentally: I feel that the lambda x = x: ... idiom to avoid multiple closures sharing state is an ugly hack, for the same reason.) -- ~Zahlman {: -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem connecting to SMTP/IMAP server using SSL
Am 12.04.2012 08:56, schrieb Julien Phalip: Hi Michael, Thanks again for your reply. I've tried using SMTP with TLS. And again it works with the VPN turned on but it still won't work with the VPN turned off. For some reason I don't understand, it simply won't instantiate the SMTP/SMTP_SSL/IMAP4/IMAP4_SSL objects at all and will hang forever if the VPN is turned off. Are you trying to connect to an Exchange server? Several Exchange mobile clients aren't using IMAP and SMTP but EAS over HTTPS. I have the same setup at work. The SMTP port is blocked unless I'm at the office or using VPN. In your case the connection hangs forever because your office's firewall drops the network packages instead of sending a reject package. The client keeps on trying since you haven't configured a timeout. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. I've got a budding mail filter program which keeps rule state in a little class instance. Slightly paraphrased: class RuleState(object): def __init__(self, M, maildb_path, maildirs={}): [...] self.maildirs = maildirs The maildirs property is a cache of Maildir objects mapped by their pathname to avoid opening Maildirs every time they're mentioned. I create a new RuleState every time I file a message, and of course I want to share the cache between instances. Normally we look on the Python default parameter value as a gotcha which causes the unwary to reuse a single object across the board, causing unwanted persistence of state. But here I actually think this is a sane way to make an anonymous single shared state object for the maildirs cache, absent the caller's intent to use their own. I can think of a few potential downsides, but on the whole this is going to do exactly what I want in this case. Would experienced users please mock me? Instance attributes are not meant to be shared among all instances. Assigning a persistant object over instances to an instance attribute is perverting your design. Remember that experienced programmers will automaticcaly trigger a warning in their mind when reading your mutable maildirs. They 'll lose time to realize that it was intended. Since there is much more standard ways to do this (class attribute for instance), you should not use that form. Cleverness is the step mother of obfuscation. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On 04/12/2012 10:35 AM, Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. I've got a budding mail filter program which keeps rule state in a little class instance. Slightly paraphrased: class RuleState(object): def __init__(self, M, maildb_path, maildirs={}): [...] self.maildirs = maildirs The maildirs property is a cache of Maildir objects mapped by their pathname to avoid opening Maildirs every time they're mentioned. I create a new RuleState every time I file a message, and of course I want to share the cache between instances. Normally we look on the Python default parameter value as a gotcha which causes the unwary to reuse a single object across the board, causing unwanted persistence of state. But here I actually think this is a sane way to make an anonymous single shared state object for the maildirs cache, absent the caller's intent to use their own. I can think of a few potential downsides, but on the whole this is going to do exactly what I want in this case. Would experienced users please mock me? You could probably just make this caching more explicit using a decorator. The good thing about that is that you could even change the behaviour of your caching without touching the code that uses it for example. -- http://mail.python.org/mailman/listinfo/python-list
Coping with risk of decision - modeling of scenarios of parameters of the model in python
Hello, I work with energy planning on municipal level. I have an energy supply deterministic model for municipal customer. Now I want to coping with uncertainty and risk of decision choosing one energy supply option for implementing in real. Some parameters of my deterministic model (energy prices and energy demands) are uncertainty in future. I want to coping with uncertainty by using: (1) scenario analysis, (2) stochastic simulation, and (3) on the end of my research stochastic optimization. I want to calculate VaR and CVaR of any modeling decision. For this parameters (which are uncertainty) I have historical data (last 15 years) and I want use this data for forecasting/modeling scenarios for energy carriers prices (gas, electricity, LPG, coal, etc.) in future 15 year. I am looking for methodology of creating scenarios of parameters of the model (ex-post… ex-ante, ???) for this decision problem. Can you suggest any paper/book/example about: - scenario analysis in pyhon - stochastic simulation in pyhon - coping with uncertenises and risk in python (VaR, CVaR)? Thanks in advance for any help. John -- http://mail.python.org/mailman/listinfo/python-list
Re: [Windows] drag-and-drop onto .py file in modern versions?
On 12/04/2012 08:00, Chris Angelico wrote: On Thu, Apr 12, 2012 at 4:02 PM, Karl Knechtelzahl...@gmail.com wrote: Aside: when I double-click a .py file, what determines which Python will run it? Is it a matter of which appears first in the PATH, or do I have to set something else in the registry? Will a shebang line override the default on Windows? If so, how do I write a shebang line for a Windows path - just #!C:/Windows/Python32? Apologies - I can't answer your main question, and am just picking up the aside. The file-type association (which is really a file-extension association) determines the path to the executable. If that's specified without a full path, then it'll be the first one in PATH, but usually the association is given as an absolute filespec. I don't have a Vista handy, but in XP, bring up any folder, Options|Folder Options, File Types, and scroll down to PY. (For some obscure reason, on this particular computer of mine the association is with a Python that was installed with GNU Lilypond. Weird!) You may need to use the Advanced button to see the full path. As to writing a shebang, there's no way to do that directly. But in theory you could associate .py files with a little script that reads the first line and figures out which interpreter to invoke it in. For extra coolness points, write that script in portable Python that can be run on any of the interpreters you have installed - then you don't have to care! :) Chris Angelico For the record please see http://www.python.org/dev/peps/pep-0397/ Python launcher for Windows which discusses shebang lines. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On Thursday, April 12, 2012 10:40:47 AM Tim Golden did opine: On 12/04/2012 10:35, Cameron Simpson wrote: I've found myself using a Python gotcha as a feature. Tim: your setup of using the CC: line for every thing with a blank To: line is landing your posts in my spam folder. Do you have a specific reason for not using a To: line? I am not inclined to change my filer rules because that particular rule catches a lot of the incoming spam. Have a look at Peter Inglesby's lightning talk from a recent London Python Dojo: http://inglesp.github.com/2012/03/24/mutable-default-arguments.html TJG Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) My web page: http://coyoteden.dyndns-free.com:85/gene He who invents adages for others to peruse takes along rowboat when going on cruise. -- http://mail.python.org/mailman/listinfo/python-list
Re: functions which take functions
On 4/11/2012 16:01, Antti J Ylikoski wrote: On 9.4.2012 21:57, Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? Thank you. Kiuhnm A function to numerically integrate another function comes as follows: [...] Thank you. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: functions which take functions
On 4/12/2012 8:07, Tim Roberts wrote: Kiuhnmkiuhnm03.4t.yahoo.it wrote: That won't do. A good example is when you pass a function to re.sub, for instance. This is an odd request. All shall be revealed :) I often pass functions to functions in order to simulate a C switch statement, such as in a language translator: commands = { 'add': doAdd, 'subtract' : doSubtract, 'multiply' : doMultiply, 'divide' : doDivide } nextCommand = parseCommandLine( line ) invokeCommand( commands[NextCommand] ) I like that very much. Thank you. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Zipping a dictionary whose values are lists
I using Python 3.2 and have a dictionary d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} whose values are lists I would like to zip into a list of tuples. If I explicitly write: list(zip([1,2], [1,2,3], [1,2,3,4]) [(1, 1, 1), (2, 2, 2)] I get exactly what I want. On the other hand, I have tried list(zip(d)) [(0,), (1,), (2,)] list(zip(d.values())) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(d[i] for i in d)) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(*d)) Traceback (most recent call last): File pyshell#48, line 1, in module list(zip(*d)) TypeError: zip argument #1 must support iteration and nothing quite works. What am I doing wrong? Sincerely Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list
Re: Zipping a dictionary whose values are lists
zip(*d.values()) On 12 April 2012 20:28, tkp...@gmail.com wrote: I using Python 3.2 and have a dictionary d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} whose values are lists I would like to zip into a list of tuples. If I explicitly write: list(zip([1,2], [1,2,3], [1,2,3,4]) [(1, 1, 1), (2, 2, 2)] I get exactly what I want. On the other hand, I have tried list(zip(d)) [(0,), (1,), (2,)] list(zip(d.values())) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(d[i] for i in d)) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(*d)) Traceback (most recent call last): File pyshell#48, line 1, in module list(zip(*d)) TypeError: zip argument #1 must support iteration and nothing quite works. What am I doing wrong? Sincerely Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list -- С уважением, Аносов Павел -- http://mail.python.org/mailman/listinfo/python-list
Re: Zipping a dictionary whose values are lists
On 4/12/2012 18:28, tkp...@gmail.com wrote: I using Python 3.2 and have a dictionary d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} whose values are lists I would like to zip into a list of tuples. If I explicitly write: list(zip([1,2], [1,2,3], [1,2,3,4]) [(1, 1, 1), (2, 2, 2)] I get exactly what I want. On the other hand, I have tried list(zip(d)) [(0,), (1,), (2,)] list(zip(d.values())) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] Almost. Since d.values() = [[1,2], [1,2,3], [1,2,3,4]], you need to use list(zip(*d.values())) which is equivalent to list(zip([1,2], [1,2,3], [1,2,3,4])) Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: Zipping a dictionary whose values are lists
tkp...@gmail.com wrote: I using Python 3.2 and have a dictionary d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} whose values are lists I would like to zip into a list of tuples. If I explicitly write: list(zip([1,2], [1,2,3], [1,2,3,4]) [(1, 1, 1), (2, 2, 2)] I get exactly what I want. On the other hand, I have tried list(zip(d)) [(0,), (1,), (2,)] list(zip(d.values())) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(d[i] for i in d)) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(*d)) Traceback (most recent call last): File pyshell#48, line 1, in module list(zip(*d)) TypeError: zip argument #1 must support iteration and nothing quite works. What am I doing wrong? You have all the building blocks ;) d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} list(zip(*d.values())) [(1, 1, 1), (2, 2, 2)] The order of the values is undefined, so you may want to sort the lists by key first: list(zip(*[v for k, v in sorted(d.items())])) [(1, 1, 1), (2, 2, 2)] Well, I guess it doesn't really matter for that example... -- http://mail.python.org/mailman/listinfo/python-list
Re: Zipping a dictionary whose values are lists
On Thu, 12 Apr 2012 09:28:03 -0700 (PDT) tkp...@gmail.com wrote: I using Python 3.2 and have a dictionary d = {0:[1,2], 1:[1,2,3], 2:[1,2,3,4]} whose values are lists I would like to zip into a list of tuples. If I explicitly write: list(zip([1,2], [1,2,3], [1,2,3,4]) [(1, 1, 1), (2, 2, 2)] I get exactly what I want. On the other hand, I have tried list(zip(d)) [(0,), (1,), (2,)] list(zip(d.values())) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(d[i] for i in d)) [([1, 2],), ([1, 2, 3],), ([1, 2, 3, 4],)] list(zip(*d)) Traceback (most recent call last): File pyshell#48, line 1, in module list(zip(*d)) TypeError: zip argument #1 must support iteration and nothing quite works. What am I doing wrong? Try this: list(zip(*d.values())) d.values() is a list, but zip wants the individual values as separate arguments. HTH, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible develop applications in python for android and which IDE could you recommend me (Eclipse, ...)???
http://code.google.com/p/android-scripting/ However, I've not used it, and I'm told it requires a stub for each new android method exposed to python. I find it a little regrettable that they didn't start frp, jython or pypy for jvm instead of cpython, to avoid all the stubbing. On Thu, Apr 12, 2012 at 1:21 AM, sisifus pyt...@borja.fagorederlan.eswrote: Hello all, I would like to know if it's possible develop android applications with python, making the apk package, etc. I don't want program from an android device only want to make programs for android from my PC. If it's possible which IDE could you recommend me? Thanks for your help Regards -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets accept() in child processes
I wonder if this'll do what you need: https://trac.calendarserver.org/browser/CalendarServer/trunk/twext/python/sendfd.py On Thu, Apr 12, 2012 at 2:31 AM, Thibaut DIRLIK merwin@gmail.comwrote: Hi, I'm writing a multiprocess server with Python 3.2 and the multiprocessing module. Here is my current implementation : - Main process: select() on a list of server sockets (different ips of the host, ssl or not, etc) - Children process : When they get a signal (in fact, a message in a pipe), they will accept() the server socket The problem is that after select() returns, I can accept() in the main process, but in a children process I got a EAGAIN error. The sockets are non-blocking. It seems that accept() can only be called in the same process that the one which selected(). This is a problem because I wanted to decide which process I should ask to take the connection to do some basic load-balacing based on current number of connected client in each process. Could someone help me or propose other implementations ? Thank you, -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem connecting to SMTP/IMAP server using SSL
Are you quite sure that your iPhone isn't using some sort of VPN? On my Android phone, I need a VPN client to access my work mail, but I install it once and forget about it; it doesn't require me to enter my password more than once. On Fri, Mar 30, 2012 at 10:39 PM, Julien jpha...@gmail.com wrote: Hi, I'm able to connect to an Exchange server via SMTP and IMAP from my iPhone using SSL and without using a VPN. So I would expect to be able to do the same from my computer using Python. However, the following hangs and times out on my computer when I'm not connected to the VPN: import imaplib imap = imaplib.IMAP4_SSL(my.server.address) If I am connected to the VPN, then it works fine. Do you know why it won't work with SSL and without the VPN? Am I missing something? Thanks a lot, Julien -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: functions which take functions
On 4/9/12 20:57 , Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? I don't use it daily but the first argument of list.sort, i.e. the compare function springs to mind. Jan Kuiken -- http://mail.python.org/mailman/listinfo/python-list
Re: python module development workflow
On 4/11/2012 1:04 PM, Miki Tebeka wrote: Could any expert suggest an authoritative and complete guide for developing python modules? Thanks! I'd start with http://docs.python.org/distutils/index.html Make sure that python setup.py build python setup.py install works. Don't use the rotten egg distribution system. (http://packages.python.org/distribute/easy_install.html) John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem connecting to SMTP/IMAP server using SSL
Maybe it's a matter of two different protocols, one requiring a VPN, one not. You could perhaps try a sniffer to check that out. Where to place the sniffer could be complicated though. On Fri, Mar 30, 2012 at 10:39 PM, Julien jpha...@gmail.com wrote: Hi, I'm able to connect to an Exchange server via SMTP and IMAP from my iPhone using SSL and without using a VPN. So I would expect to be able to do the same from my computer using Python. However, the following hangs and times out on my computer when I'm not connected to the VPN: import imaplib imap = imaplib.IMAP4_SSL(my.server.address) If I am connected to the VPN, then it works fine. Do you know why it won't work with SSL and without the VPN? Am I missing something? Thanks a lot, Julien -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Deep merge two dicts?
Is there a simple way to deep merge two dicts? I'm looking for Perl's Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets accept() in child processes
Le 12/04/2012 19:10, Dan Stromberg a écrit : I wonder if this'll do what you need: https://trac.calendarserver.org/browser/CalendarServer/trunk/twext/python/sendfd.py The problem is that this is Linux-only solution, and I would like to keep a multi-platform compatibility. There are other ways to do this : use a Lock and do the select() directly in the children processes, but I can't control which process will get the lock, and it's totally possible that only 2 processes on 8 will accept connections alternatively. -- http://mail.python.org/mailman/listinfo/python-list
Re: Deep merge two dicts?
On 4/12/2012 10:41 AM, Roy Smith wrote: Is there a simple way to deep merge two dicts? I'm looking for Perl's Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) in Python. def dmerge(a, b) : for k in a : v = a[k] if isinstance(v, dict) and k in b: dmerge(v, b[k]) a.update(b) -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing and Array problems
I am not subscribed to these lists but I do check them occasionally and will check them more frequently looking for a response. I am getting a pickling error that I do not understand. It seems the shared arrays that I create cannot be pickled. Makes the multiprocessing.Array fairly useless if it cannot be pickled. Hence, I am guessing that I am doing something wrong and would like some help spotting it. This is basically a cut and paste from the examples in the documentation: import ctypes import multiprocessing def subproc (a, i): print (From subprocess + str(i)) print (a[:]) return if __name__ == __main__: nproc = 3 print (\nBuilding the array for the second computation.) b = multiprocessing.Array (ctypes.c_double, nproc*nproc, lock=False) print (\nSending the task across to see what happens.) pool = multiprocessing.Pool(nproc) for i in range(nproc): pool.apply_async (subproc, kwds={'a':b, 'i':i}) pool.close() pool.join() pass Whether I run it on 2.6, 2.7, or 3.2 I get the same error. Exception in thread Thread-1: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File /usr/lib/python2.6/threading.py, line 484, in run self.__target(*self.__args, **self.__kwargs) File /usr/lib/python2.6/multiprocessing/pool.py, line 225, in _handle_tasks put(task) PicklingError: Can't pickle class 'multiprocessing.sharedctypes.c_double_Array_9': attribute lookup multiprocessing.sharedctypes.c_double_Array_9 failed Anyone want to take a stab as to why this error message is being generated? Again I have tried python 2.6.7, 2.7.2+, and 3.2.2. Thanks for any and all help in advance. -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing and Array problems
Here is an update. def subproc (i): print (From subprocess + str(i)) print (b[:]) return if __name__ == __main__: nproc = 3 print (\nBuilding the array for the second computation.) b = multiprocessing.Array (ctypes.c_double, nproc*nproc, lock=False) print (\nSending the task across to see what happens.) pool = multiprocessing.Pool(nproc) for i in range(nproc): pool.apply_async (subproc, kwds={'i':i}) pool.close() pool.join() pass Does work. It is not what I need though. I need to be able to pass b as an argument. The reason is that I create some of these in a loop and they are not in a global space nor are they know prior to creating the pool. On Thu, 2012-04-12 at 11:15 -0700, Al Niessner wrote: I am not subscribed to these lists but I do check them occasionally and will check them more frequently looking for a response. I am getting a pickling error that I do not understand. It seems the shared arrays that I create cannot be pickled. Makes the multiprocessing.Array fairly useless if it cannot be pickled. Hence, I am guessing that I am doing something wrong and would like some help spotting it. This is basically a cut and paste from the examples in the documentation: import ctypes import multiprocessing def subproc (a, i): print (From subprocess + str(i)) print (a[:]) return if __name__ == __main__: nproc = 3 print (\nBuilding the array for the second computation.) b = multiprocessing.Array (ctypes.c_double, nproc*nproc, lock=False) print (\nSending the task across to see what happens.) pool = multiprocessing.Pool(nproc) for i in range(nproc): pool.apply_async (subproc, kwds={'a':b, 'i':i}) pool.close() pool.join() pass Whether I run it on 2.6, 2.7, or 3.2 I get the same error. Exception in thread Thread-1: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File /usr/lib/python2.6/threading.py, line 484, in run self.__target(*self.__args, **self.__kwargs) File /usr/lib/python2.6/multiprocessing/pool.py, line 225, in _handle_tasks put(task) PicklingError: Can't pickle class 'multiprocessing.sharedctypes.c_double_Array_9': attribute lookup multiprocessing.sharedctypes.c_double_Array_9 failed Anyone want to take a stab as to why this error message is being generated? Again I have tried python 2.6.7, 2.7.2+, and 3.2.2. Thanks for any and all help in advance. -- Al Niessner I have never found the companion that was so companionable as solitude. - From Walden by Henry David Thoreau The universe is indifferent, and life is brutal; however, it is man's choice of behavior that makes them malevolent rather than benevolent. Some will fall in love with life and drink it from a fountain That is pouring like an avalanche coming down the mountain. - From the song Pepper by the Butthole Surfers -- http://mail.python.org/mailman/listinfo/python-list
Re: Deep merge two dicts?
On Thu, Apr 12, 2012 at 11:59 AM, John Nagle na...@animats.com wrote: On 4/12/2012 10:41 AM, Roy Smith wrote: Is there a simple way to deep merge two dicts? I'm looking for Perl's Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) in Python. def dmerge(a, b) : for k in a : v = a[k] if isinstance(v, dict) and k in b: dmerge(v, b[k]) a.update(b) That doesn't work. After b[k] is recursively merged into a[k], the call a.update(b) copies b[k] into a[k], discarding the merged dict. Try this: def dmerge(a, b): for k, v in b.items(): if isinstance(v, dict) and k in a: dmerge(a[k], v) else: a[k] = v Hash::Merge also does a lot more than this, but I'm not sure exactly which functionality the OP is looking for. -- http://mail.python.org/mailman/listinfo/python-list
Re: Error in MD5 checksums of the 2.7.3 release page.
On 4/12/2012 6:11 AM, Jérémy Bethmont wrote: There is an error in the MD5 checksums section of the following page: http://python.org/download/releases/2.7.3/ Python-3.1.5.tgz, Python-3.1.5.tar.bz2 and Python-3.1.5.tar.xz are listed instead of: Python-2.7.3.tgz, Python-2.7.3.tar.bz2 and Python-2.7.3.tar.xz verified and forwarded to pydev list for correction. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing and Array problems
On 12/04/2012 19:30, Al Niessner wrote: Here is an update. def subproc (i): print (From subprocess + str(i)) print (b[:]) return if __name__ == __main__: nproc = 3 print (\nBuilding the array for the second computation.) b = multiprocessing.Array (ctypes.c_double, nproc*nproc, lock=False) print (\nSending the task across to see what happens.) pool = multiprocessing.Pool(nproc) for i in range(nproc): pool.apply_async (subproc, kwds={'i':i}) pool.close() pool.join() pass Does work. It is not what I need though. I need to be able to pass b as an argument. The reason is that I create some of these in a loop and they are not in a global space nor are they know prior to creating the pool. Doing this works: processes = [] for i in range(nproc): processes.append(multiprocessing.Process(target=subproc, kwargs={'a':b, 'i':i})) for p in processes: p.start() for p in processes: p.join() On Thu, 2012-04-12 at 11:15 -0700, Al Niessner wrote: I am not subscribed to these lists but I do check them occasionally and will check them more frequently looking for a response. I am getting a pickling error that I do not understand. It seems the shared arrays that I create cannot be pickled. Makes the multiprocessing.Array fairly useless if it cannot be pickled. Hence, I am guessing that I am doing something wrong and would like some help spotting it. This is basically a cut and paste from the examples in the documentation: import ctypes import multiprocessing def subproc (a, i): print (From subprocess + str(i)) print (a[:]) return if __name__ == __main__: nproc = 3 print (\nBuilding the array for the second computation.) b = multiprocessing.Array (ctypes.c_double, nproc*nproc, lock=False) print (\nSending the task across to see what happens.) pool = multiprocessing.Pool(nproc) for i in range(nproc): pool.apply_async (subproc, kwds={'a':b, 'i':i}) pool.close() pool.join() pass Whether I run it on 2.6, 2.7, or 3.2 I get the same error. Exception in thread Thread-1: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File /usr/lib/python2.6/threading.py, line 484, in run self.__target(*self.__args, **self.__kwargs) File /usr/lib/python2.6/multiprocessing/pool.py, line 225, in _handle_tasks put(task) PicklingError: Can't pickleclass 'multiprocessing.sharedctypes.c_double_Array_9': attribute lookup multiprocessing.sharedctypes.c_double_Array_9 failed Anyone want to take a stab as to why this error message is being generated? Again I have tried python 2.6.7, 2.7.2+, and 3.2.2. Thanks for any and all help in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Sockets accept() in child processes
On Thu, Apr 12, 2012 at 10:48 AM, Merwin merwin@gmail.com wrote: Le 12/04/2012 19:10, Dan Stromberg a écrit : I wonder if this'll do what you need: https://trac.calendarserver.**org/browser/CalendarServer/** trunk/twext/python/sendfd.pyhttps://trac.calendarserver.org/browser/CalendarServer/trunk/twext/python/sendfd.py The problem is that this is Linux-only solution, and I would like to keep a multi-platform compatibility. I suspect it's actually pretty multiplatform, with one likely exception: Windows. But the code itself is from Apple, and I first learned of the technique in Unix's heyday. There are other ways to do this : use a Lock and do the select() directly in the children processes, but I can't control which process will get the lock, and it's totally possible that only 2 processes on 8 will accept connections alternatively. If you have all your children bind using SO_REUSEADDR, and then have the parent process pass a go ahead message to an available child, you might get what you desire. The unavailable child would then pass a I'm available again message back to the parent when ready for another piece of work. The children probably should also be able to send a I'm done with the socket message to the parent as well, so the parent doesn't ask two children to use the socket at the same time. This is kind of weird, but it seems to satisfy your requirement. I believe SO_REUSEADDR is even more cross-platform than passing a filedescriptor. Better still, don't have the children interact with the main socket; just let them get a complete message describing a piece of work from the parent. This isn't as likely to run into OS idiosyncrasies. -- http://mail.python.org/mailman/listinfo/python-list
Re: older woman and young guy
http://porn-extreme.2304310.n4.nabble.com/ http://porn-extreme.2304310.n4.nabble.com/ -- View this message in context: http://python.6.n6.nabble.com/AMPUTEE-INCEST-MIDGET-2012-tp4708963p4864079.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why does this hang sometimes?
Possibly. I wonder what the difference(s) is(are)? On Sat, Apr 7, 2012 at 5:54 PM, Jason Friedman ja...@powerpull.net wrote: I am just playing around with threading and subprocess and found that the following program will hang up and never terminate every now and again. import threading import subprocess import time def targ(): p = subprocess.Popen([/bin/sleep, 2]) while p.poll() is None: time.sleep(1) t1 = threading.Thread(target=targ) t2 = threading.Thread(target=targ) t1.start() t2.start() t1.join() t2.join() I found this bug, and while it sounds similar it seems that it was closed during python 2.5 (I'm using 2.7.2): http://bugs.python.org/issue1404925 I can confirm hanging on my installation of 2.7.2. I also ran this code 100 times on 3.2.2 without experiencing a hang. Is version 3.x a possibility for you? -- http://mail.python.org/mailman/listinfo/python-list
GNTP not connecting
hey folks seems GNTP doesn't work for me. the growl app itself works cool import gntp.notifier gntp.notifier.mini(message) - Traceback (most recent call last): File stdin, line 1, in module File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gntp/notifier.py, line 48, in mini result = growl.register() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gntp/notifier.py, line 128, in register return self._send('register', register) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gntp/notifier.py, line 221, in _send s.connect((self.hostname, self.port)) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py, line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 61] Connection refused thanks m. -- Milosh Zorica http://www.linkedin.com/in/miloshzorica phone: +44 20 8144 5294 +1 206 350 9734 e-mail: miloshzor...@gmail.com skype: milosh.zorica -- http://mail.python.org/mailman/listinfo/python-list
Re: GNTP not connecting
On Fri, Apr 13, 2012 at 7:32 AM, milosh zorica miloshzor...@gmail.com wrote: s.connect((self.hostname, self.port)) socket.error: [Errno 61] Connection refused This is saying that the computer at that hostname is running, but no program is listening on that port. Maybe you have the host/port wrong, or maybe something needs to be running on that computer. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Deep merge two dicts?
On 4/12/2012 19:59, John Nagle wrote: On 4/12/2012 10:41 AM, Roy Smith wrote: Is there a simple way to deep merge two dicts? I'm looking for Perl's Hash::Merge (http://search.cpan.org/~dmuey/Hash-Merge-0.12/Merge.pm) in Python. def dmerge(a, b) : for k in a : v = a[k] if isinstance(v, dict) and k in b: dmerge(v, b[k]) a.update(b) There are a few problems with that code: 1) you don't make sure that b[k] is a dict so a={'a':{'b':1}}; b={'a':1} make it crash. 2) the last update overwrites nested updates, but this could be the intended behavior. For instance, with the 'a' and 'b' above, the result would be {'a':1} Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: GNTP not connecting
On Fri, Apr 13, 2012 at 7:44 AM, milosh zorica miloshzor...@gmail.com wrote: yes but what? everything else works cool and i can connect via socket from python On Thu, Apr 12, 2012 at 6:38 PM, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 13, 2012 at 7:32 AM, milosh zorica miloshzor...@gmail.com wrote: s.connect((self.hostname, self.port)) socket.error: [Errno 61] Connection refused This is saying that the computer at that hostname is running, but no program is listening on that port. Maybe you have the host/port wrong, or maybe something needs to be running on that computer. ChrisA -- http://mail.python.org/mailman/listinfo/python-list I'm hoping you meant for that reply to be on-list, and am myself replying on-list. You can connect to that (host,port) using Python? In that case, check that the right host/port is being used by growl - possibly there's a parameter you need to check. I can't help any further though, as I have no experience with growl. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: GNTP not connecting
thanks On Thu, Apr 12, 2012 at 7:30 PM, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 13, 2012 at 7:44 AM, milosh zorica miloshzor...@gmail.com wrote: yes but what? everything else works cool and i can connect via socket from python On Thu, Apr 12, 2012 at 6:38 PM, Chris Angelico ros...@gmail.com wrote: On Fri, Apr 13, 2012 at 7:32 AM, milosh zorica miloshzor...@gmail.com wrote: s.connect((self.hostname, self.port)) socket.error: [Errno 61] Connection refused This is saying that the computer at that hostname is running, but no program is listening on that port. Maybe you have the host/port wrong, or maybe something needs to be running on that computer. ChrisA -- http://mail.python.org/mailman/listinfo/python-list I'm hoping you meant for that reply to be on-list, and am myself replying on-list. You can connect to that (host,port) using Python? In that case, check that the right host/port is being used by growl - possibly there's a parameter you need to check. I can't help any further though, as I have no experience with growl. ChrisA -- http://mail.python.org/mailman/listinfo/python-list -- Milosh Zorica http://www.linkedin.com/in/miloshzorica phone: +44 20 8144 5294 +1 206 350 9734 e-mail: miloshzor...@gmail.com skype: milosh.zorica -- http://mail.python.org/mailman/listinfo/python-list
Re: is this foolish?
On 12Apr2012 10:44, gene heskett ghesk...@wdtv.com wrote: | On Thursday, April 12, 2012 10:40:47 AM Tim Golden did opine: | On 12/04/2012 10:35, Cameron Simpson wrote: | I've found myself using a Python gotcha as a feature. | | Tim: your setup of using the CC: line for every thing with a blank To: | line is landing your posts in my spam folder. Do you have a specific | reason for not using a To: line? | | I am not inclined to change my filer rules because that particular rule | catches a lot of the incoming spam. This should probably be offline, but can you outline your rule? Almost all my rules match on either to or cc happily and I don't know of a spam pattern that would benefit from treating them differently. -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ The laws of thermodynamics state that you can't win, you can't break even, and you can't even quit the game. Most human institutions are based on the belief that you can break one of the three laws -- capitalism assumes you can win, socialism assumes you can break even, and religion assumes you can quit the game. -- http://mail.python.org/mailman/listinfo/python-list
remainder of dividing by zero
Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate or by definition answer as to why this should not be so? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: functions which take functions
On 4/12/2012 19:29, Jan Kuiken wrote: On 4/9/12 20:57 , Kiuhnm wrote: Do you have some real or realistic (but easy and self-contained) examples when you had to define a (multi-statement) function and pass it to another function? I don't use it daily but the first argument of list.sort, i.e. the compare function springs to mind. Yes, I guess there are times when a lambda is not enough and one needs to define a real function. Thanks. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: remainder of dividing by zero
On 4/12/2012 6:34 PM, Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate or by definition answer as to why this should not be so? 0 = M % N N no solution for N == 0 m // n, m % n = divmod(m, n), which is to say, divmod is the fundamental recursively defined operation and // and % are each one of the components with the other ignored. m % n = divmod(m, n)[1] and divmod is not defined for n == 0 def divmod(m, n): # m, n not negative q, r = 0, m while m = n: q, r = q+1, r-n return q, r Of course, given m, n in base n representation, the way you learned to do it in school is faster. In binary, it is even easier because each digit is 0 or 1 so no guessing needed as with base 10. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: remainder of dividing by zero
On 12/04/2012 23:34, Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate or by definition answer as to why this should not be so? If x 0, 0 = 5 % x x. At the limit of x == 0, you get 0 = 5 % 0 0. At that point, an exception is probably a good idea! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Mouse LED Control in Python
How can I make a battery powered http://www.ledstrips8.com/led-light-bars-c-38.html led strip 12v with 3 way switches? My goal is to make a long line of grouped LEDs that is battery powered and can be turned on or off from 2 different locations. I'm trying to make a lighting system that doesn't make me have to turn on several individual lamps as I find them along my path. I will be making a line with 8 http://www.ledstrips8.com/ waterproof led strip light (lamp being a cluster of 6 LEDs), but I have no idea as to how to go about making the line. How should I set up the circuit to have all of them retain their brightness? I need a battery that is rechargeable, so I am making one on cheapbatterypacks.com. What size battery will I need to make (voltage and mAh) to power this setup? LEDs are RL5-W18030 at http://www.ledstrips8.com/flexible-led-strip-lighting-c-32.html blue led strip I know I need a 3 way switch to turn them on and off with 2 switches, but I'm not sure how to wire them into the circuit. Any advice? I don't have a lot of experience with electronics, so some explanations would be greatly appreciated. Thanks for you help! -- View this message in context: http://python.6.n6.nabble.com/Mouse-LED-Control-in-Python-tp1035960p4874673.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: python module development workflow
On Apr 11, 8:38 pm, Peng Yu pengyu...@gmail.com wrote: On Apr 11, 10:25 am, John Gordon gor...@panix.com wrote: In 2900f481-fbe9-4da3-a7ca-5485d1ceb...@m13g2000yqc.googlegroups.com Peng Yu pengyu...@gmail.com writes: It is confusing to me what the best workflow is for python module development. There is setup.py, egg. Also, pip, easy_install. It's unclear what you are asking. How to develop your own modules? How to package and distribute your own modules once they're finished? I'm asking these two questions. You need to ask these two questions separately. For the first you'll get good answers here if you can be more specific. The second is a good question which will not get useful answers because python's package and distribute system(s) are in a flux. In all fairness this is so for most languages which have as bad messes in this domain. eg Haskell's cabal http://cdsmith.wordpress.com/2011/01/16/haskells-own-dll-hell/ http://ivanmiljenovic.wordpress.com/2010/03/15/repeat-after-me-cabal-is-not-a-package-manager/ -- http://mail.python.org/mailman/listinfo/python-list
[issue14532] multiprocessing module performs a time-dependent hmac comparison
STINNER Victor victor.stin...@gmail.com added the comment: +def time_independent_equals(a, b): +if len(a) != len(b): +return False This is not time independent. Is it an issue? +if type(a[0]) is int: It's better to write isinstance(a, bytes). You should raise a TypeError if a is not a bytes or str. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Otto Kekäläinen o...@seravo.fi added the comment: As a note to comments msg60038-msg60040, for anybody like me who ended up here after Googling around on how to do wordwrap in Python: The function textwrap in Python is for single strings/paragraphs only, and it does not work as wordwrap normally works in text editors or other programming languages (eg. Wordwrap in Python). If you want to do wordwrap or a block of text, run something like this: new_msg = lines = msg.split(\n) for line in lines: if len(line) 75: w = textwrap.TextWrapper(width=75, break_long_words=False) line = '\n'.join(w.wrap(line)) new_msg += line + \n An use case example for this would be, if you have a email message and you want to apply word wrapping to it, so that no line would be over 78 characters. -- nosy: +otto ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Otto Kekäläinen o...@seravo.fi added the comment: In previous comment: (eg. Wordwrap in Python) - (wordwrap() in PHP) Some examples of how this function works on text blocks: Original text: -- *Maksaako riippuvuus yksittäisestä ohjelmistoyritykstä Helsingille vuosittain 3,4 miljoonaa euroa?* Helsingin kaupungin raportti OpenOffice-pilottihankkeesta tuottaa kaupunkilaisille enemmän kysymyksiä kuin vastauksia. Kaupunki kokeili avoimen lähdekoodin hyötyohjelmistopakettia kaupunginvaltuuston jäsenten kannettavissa tietokoneissa kymmenen kuukauden ajan vuonna 2011. Ohjelmistopaketti sai käyttäjiltä laajan hyväksynnän. Kokeilun päätyttyä kaupunki tuotti pilotista raportin, jonka mukaan OpenOfficen käyttöönotto koko virkamieskunnalle tulisi hyvin kalliiksi. Kaupungin raportti väittää, että maksaisi 3,4 miljoonaa euroa vuodessa käyttää OpenOfficea. Luku vaikuttaa yllättävän isolta ja raportti ei selosta, miten lukuun on päädytty, sanoo Otto Kekäläinen, Euroopan vapaiden ohjelmien säätiö (Free Software Foundation Europe, FSFE), Suomen paikalliskoordinaattori. Ilman tarkkoja tietoja, luku vaikuttaa perusteettomalta. Ilmeisesti Helsingin hallinto ei raporttia laatiessaan edes ollut yhteydessä yleisiin OpenOffice-palveluiden tarjoajiin tiedustellaakseen hintoja. -- Applying msg.message_body = textwrap.fill(msg.message_body_unwrapped, 75) -- *Maksaako riippuvuus yksittäisestä ohjelmistoyritykstä Helsingille vuosittain 3,4 miljoonaa euroa?* Helsingin kaupungin raportti OpenOffice- pilottihankkeesta tuottaa kaupunkilaisille enemmän kysymyksiä kuin vastauksia. Kaupunki kokeili avoimen lähdekoodin hyötyohjelmistopakettia kaupunginvaltuuston jäsenten kannettavissa tietokoneissa kymmenen kuukauden ajan vuonna 2011. Ohjelmistopaketti sai käyttäjiltä laajan hyväksynnän. Kokeilun päätyttyä kaupunki tuotti pilotista raportin, jonka mukaan OpenOfficen käyttöönotto koko virkamieskunnalle tulisi hyvin kalliiksi. Kaupungin raportti väittää, että maksaisi 3,4 miljoonaa euroa vuodessa käyttää OpenOfficea. Luku vaikuttaa yllättävän isolta ja raportti ei selosta, miten lukuun on päädytty, sanoo Otto Kekäläinen, Euroopan vapaiden ohjelmien säätiö (Free Software Foundation Europe, FSFE), Suomen paikalliskoordinaattori. Ilman tarkkoja tietoja, luku vaikuttaa perusteettomalta. Ilmeisesti Helsingin hallinto ei raporttia laatiessaan edes ollut yhteydessä yleisiin OpenOffice-palveluiden tarjoajiin tiedustellaakseen hintoja. -- Applying msg.message_body = textwrap.fill(msg.message_body_unwrapped, 75, break_long_words=False, replace_whitespace=False) -- *Maksaako riippuvuus yksittäisestä ohjelmistoyritykstä Helsingille vuosittain 3,4 miljoonaa euroa?* Helsingin kaupungin raportti OpenOffice- pilottihankkeesta tuottaa kaupunkilaisille enemmän kysymyksiä kuin vastauksia. Kaupunki kokeili avoimen lähdekoodin hyötyohjelmistopakettia kaupunginvaltuuston jäsenten kannettavissa tietokoneissa kymmenen kuukauden ajan vuonna 2011. Ohjelmistopaketti sai käyttäjiltä laajan hyväksynnän. Kokeilun päätyttyä kaupunki tuotti pilotista raportin, jonka mukaan OpenOfficen käyttöönotto koko virkamieskunnalle tulisi hyvin kalliiksi. Kaupungin raportti väittää, että maksaisi 3,4 miljoonaa euroa vuodessa käyttää OpenOfficea. Luku vaikuttaa yllättävän isolta ja raportti ei selosta, miten lukuun on päädytty, sanoo Otto Kekäläinen, Euroopan vapaiden ohjelmien säätiö (Free Software Foundation Europe, FSFE), Suomen paikalliskoordinaattori. Ilman tarkkoja tietoja, luku vaikuttaa perusteettomalta. Ilmeisesti Helsingin hallinto ei raporttia laatiessaan edes ollut yhteydessä yleisiin OpenOffice-palveluiden tarjoajiin tiedustellaakseen hintoja. -- In case this bug report form wraps the text, you can also view the it at pastebin: http://pastebin.com/y6icAJC6 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Gregory P. Smith g...@krypto.org added the comment: Your three step approach makes sense... But it _is_ still technically a new API though in that the UTF8BOM placeholder for LogRecord's is being introduced. What would the behavior be when run on an older version without support for that placeholder be? I'm okay with adding this but wouldn't be surprised if release managers are not. But I personally have no need for syslog logging from Python so it'd be better to have someone who needs this to work properly chime in. Perhaps just fixing it nicely in 3.3 is sufficient while documenting the misbehavior as a known issue for 2.7 and 3.2. -- nosy: +gregory.p.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Georg Brandl ge...@python.org added the comment: ISTM that meta / is neither valid HTML nor valid XHTML. -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14559] (2.7.3 Regression) PC\8.0 directory can no longer be used to build on windows
New submission from Mitchell Blank Jr m-pyt...@bodyfour.com: In the diff between 2.7.2 and 2.7.3, we see: --- Python-2.7.2/PCbuild/pythoncore.vcproj 2011-06-11 08:46:27.0 -0700 +++ Python-2.7.3/PCbuild/pythoncore.vcproj 2012-04-09 16:07:35.0 -0700 @@ -1835,6 +1835,10 @@ /File File + RelativePath=..\Python\random.c + + /File + File RelativePath=..\Python\structmember.c /File ...however there isn't any similar change to PC\VS8.0\pythoncore.vcproj , PC\VS7.1\pythoncore.vcproj, nor PC\VC6\pythoncore.dsp I don't know if any of those are deprecated, but the VS8.0 .vcproj's definitely worked in 2.7.2. In 2.7.3 the missing random.obj file causes python27.dll to fail to link and everything goes downhill from there. Hand-applying the same change to the PC\VS8.0 directory fixed the problem for me. -- components: Build messages: 158110 nosy: mitchblank priority: normal severity: normal status: open title: (2.7.3 Regression) PC\8.0 directory can no longer be used to build on windows type: compile error versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14559 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14554] test module: correction
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file25187/correction.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14554 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Ezio Melotti ezio.melo...@gmail.com added the comment: Here's a patch. -- keywords: +patch stage: test needed - patch review Added file: http://bugs.python.org/file25188/issue14538.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12537] mailbox's _become_message is very fragile
David Lam d...@dlam.me added the comment: Wow, cool! Thanks for the update. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12537 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14548] garbage collection just after multiprocessing's fork causes exceptions
Charles-François Natali neolo...@free.fr added the comment: That's a problem indeed. Perhaps we need a global fork lock shared between subprocess and multiprocessing? I did an atfork patch which included a (recursive) fork lock. See http://bugs.python.org/review/6721/show The patch included changes to multiprocessing and subprocess. (Being able to acquire the lock when doing fd manipulation is quite useful. For instance, the creation of Process.sentinel currently has a race which can mean than another process inherits the write end of the pipe. That would cause Process.join() to wait till both processes terminate.) Indeed, I had a look and it looked good. I just had a couple minor comments, I'll try to get back to this later today, or by the end of the week. Actually, for Finalizers I think it would be easier to just record and check the pid. I'd prefer this too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14548 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14560] urllib2 cannot make POST with utf-8 content
New submission from Андрей Р lans...@gmail.com: Issue can be found only in 2.7, in 2.6.6 it works System: Linux strix 3.2.14-1-ARCH x86_64 Python information: Python 2.7.2 (default, Jan 31 2012, 13:19:49) [GCC 4.6.2 20120120 (prerelease)] on linux2 Snippet to reproduce error: # -*- encoding: utf-8 -*- import urllib2 request = urllib2.Request('http://google.com', u'Контент', {'Content-Type': 'text/plain; charset=utf-8'}) urllib2.urlopen(request).read() Stacktrace: Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/urllib2.py, line 126, in urlopen return _opener.open(url, data, timeout) File /usr/lib/python2.7/urllib2.py, line 394, in open response = self._open(req, data) File /usr/lib/python2.7/urllib2.py, line 412, in _open '_open', req) File /usr/lib/python2.7/urllib2.py, line 372, in _call_chain result = func(*args) File /usr/lib/python2.7/urllib2.py, line 1199, in http_open return self.do_open(httplib.HTTPConnection, req) File /usr/lib/python2.7/urllib2.py, line 1168, in do_open h.request(req.get_method(), req.get_selector(), req.data, headers) File /usr/lib/python2.7/httplib.py, line 955, in request self._send_request(method, url, body, headers) File /usr/lib/python2.7/httplib.py, line 989, in _send_request self.endheaders(body) File /usr/lib/python2.7/httplib.py, line 951, in endheaders self._send_output(message_body) File /usr/lib/python2.7/httplib.py, line 815, in _send_output self.send(message_body) File /usr/lib/python2.7/httplib.py, line 787, in send self.sock.sendall(data) File /usr/lib/python2.7/socket.py, line 224, in meth return getattr(self._sock,name)(*args) -- components: Unicode messages: 158114 nosy: ezio.melotti, Андрей.Р priority: normal severity: normal status: open title: urllib2 cannot make POST with utf-8 content versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14560] urllib2 cannot make POST with utf-8 content
Андрей Р lans...@gmail.com added the comment: # -*- encoding: utf-8 -*- import urllib2 request = urllib2.Request('http://google.com', u'Контент'.encode(utf-8), {'Content-Type': 'text/plain; charset=utf-8'}) urllib2.urlopen(request).read() -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14560] urllib2 cannot make POST with utf-8 content
Changes by Андрей Р lans...@gmail.com: -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14560] urllib2 cannot make POST with utf-8 content
Андрей Р lans...@gmail.com added the comment: Sorry. My fault -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14452] SysLogHandler sends invalid messages when using unicode
Vinay Sajip vinay_sa...@yahoo.co.uk added the comment: What would the behavior be when run on an older version without support for that placeholder be? Then it would fail when the format string contained e.g. %(UTF8BOM)s and there was no corresponding attribute in the LogRecord - but that's true of any feature which is introduced in newer Pythons. I get that it would be unexpected in a point release, and that's why I've posted about this on c.l.py (no feedback from there so far). I'm okay with adding this but wouldn't be surprised if release managers are not. Hence the post to python-dev, but no release manager has expressed an opinion yet. Perhaps just fixing it nicely in 3.3 is sufficient while documenting the misbehavior as a known issue for 2.7 and 3.2. This is doable at a user level, except for the fact that the BOM insertion is currently unconditional. If I just remove the BOM insertion in 2.7 and 3.2, then I don't need to do the UTF8BOM placeholder thing in the stdlib; I could just add a cookbook recipe telling users how to do it. I am thinking about a different solution for 3.3 anyway, i.e. adding one or more overridable methods to SysLogHandler. Since no one has objected on c.l.py about the proposed change (which implied that if there were no objections, the change would happen) Marko may be right that not many people are affected, or care. I'll wait a little while longer, and if no objections are forthcoming I'll remove the BOM insertion in 2.7 and 3.2, add a cookbook recipe for those who need a BOM and leave it at that for those versions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14452 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9377] socket, PEP 383: Mishandling of non-ASCII bytes in host/domain names
Nick spaun2002mob...@gmail.com added the comment: I faced with the issue on my own PC. For a Russian version of WinOS default PC name is ИВАН-ПК (C8 C2 C0 CD 2D CF CA in hex) and it returns from gethostbyaddr (CRT) exactly in this form (encoded with system locale cp1251 not UTF8). So when the function PyUnicode_FromString is called, it expects that argument is utf8 encoded string and throws and error. A lot of 3rd party modules use gethostbyaddr or getfqdn (which uses gethostbyaddr) and I can't just use function that returns names as bytes. Surrogate names are also not acceptable because the name mentioned above becomes -?? -- nosy: +spaun2002 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14561] python-2.7.2-r3 suffers test failure at test_mhlib
New submission from Ian Delaney del...@iinet.com.au: Testing test suite of pyth-2.7. Re-running failed tests in verbose mode Re-running test 'test_mhlib' in verbose mode test_basic (test.test_mhlib.MhlibTests) ... ok test_listfolders (test.test_mhlib.MhlibTests) ... FAIL It seems to be pinned down to this one line in test that failed. ok, it comes down to this. From test_mhlib.py def test_listfolders(self): mh = getMH() eq = self.assertEqual #tfolders.sort()\\ Line 184 #eq(folders, tfolders) \\ Line 185 Commenting them out removes the source of error. The lines that trips up include at least 185, 189, 193. The 'folders' are not equal. Bug filed in gentoo bugzilla; Bug 387967; 21-10-2011. The build log from that bug in Comment 2 https://bugs.gentoo.org/attachment.cgi?id=290409 -- components: Tests messages: 158119 nosy: idella5 priority: normal severity: normal status: open title: python-2.7.2-r3 suffers test failure at test_mhlib type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14561 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14560] urllib2 cannot make POST with utf-8 content
Changes by Senthil Kumaran sent...@uthcode.com: -- nosy: +orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14557] HP-UX libraries not included
Charles-François Natali neolo...@free.fr added the comment: Hello Adi, Thanks for your patch. Just a detail: if platform == 'hp-ux11': lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] Wouldn't it be more robust as: if platform.startswith('hp-ux'): lib_dirs += ['/usr/lib/hpux64', '/usr/lib/hpux32'] So that it works with older and (potenttially) future HP-UX releases? -- nosy: +neologix stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14557 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14557] HP-UX libraries not included
Adi Roiban a...@roiban.ro added the comment: Hi, startswith('hp-ux') should also work as in real world it should be synonym with hp-ux11 ... see my reasoning below I used 'hp-ux11' since this was the system I have access to and can test and I was not brave enought to assume that the patch will work on future or past version. According to wikipedia HP-UX 11.00 was relesed in 1997... and I see a trend to change the minor version number . Latest is 11.31 released in 2007... HPUX 10 is from 1995 and I am not sure if Python will work at all on such a system. As a side node, i think that HPUX will slowly die and we will not see an HP-UX 12. Cheers, Adi -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14557 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14412] Sqlite Integer Fields
Mendez goatsofmen...@users.sourceforge.net added the comment: I've tested the released 2.7.3 and this works fine so there must just have been some oddity with the packaging of sqlite in rc2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14412 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14412] Sqlite Integer Fields
Benjamin Peterson benja...@python.org added the comment: Great! -- resolution: - out of date status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14412 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14562] urllib2 maybe blocks too long
New submission from Anrs Hu anders.x...@gmail.com: If HTTP URL response's Transfer-Encoding is 'Chunked', then the urllib2.urlopen(URL).readline() will block until there're enough 8192 bytes, even though the first chunk is just a line. Every chunks should be processed as soon as posible, so the readline() behavior should read a line and return immediately, rather than read 8K data to buffer and look up a line from the buffer. -- components: Library (Lib) messages: 158124 nosy: Anrs.Hu priority: normal severity: normal status: open title: urllib2 maybe blocks too long type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14562] urllib2 maybe blocks too long
Senthil Kumaran sent...@uthcode.com added the comment: I am trying to this test this to determine the fault. -- assignee: - orsenthil nosy: +orsenthil versions: +Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14562 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14556] telnetlib Telnet.expect fails with timeout=0
R. David Murray rdmur...@bitdance.com added the comment: Ah, so there are actually two timeouts of interest. One is time out if there is no more data for X seconds, and the other is time out if there is no match for X seconds. It used to do the former, now it does the latter. I think you get the former by calling socket.settimeout() and then using a blocking call for the expect. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14556 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14563] Segmentation fault on ctypes.Structure subclass with byte string field names
New submission from aliles aaron.i...@gmail.com: Python 3.2 will exit with a segmentation fault if a byte string is used as a field name in a subclass of ctypes.Structure. Python 3.2.2 (default, Dec 18 2011, 18:56:20) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin Type help, copyright, credits or license for more information. import ctypes class Point(ctypes.Structure): ... _fields_ = ((b'x', ctypes.c_int), (b'y', ctypes.c_int)) ... Segmentation fault: 11 This also occurs if None or an int is used as the field name. I would expect that a TypeError exception would be raised if an attempt is made to use an invalid type for the field name. -- components: ctypes files: segfault.py messages: 158127 nosy: aliles priority: normal severity: normal status: open title: Segmentation fault on ctypes.Structure subclass with byte string field names type: crash versions: Python 3.2 Added file: http://bugs.python.org/file25189/segfault.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14563 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14399] zipfile and creat/update comment
Serhiy Storchaka storch...@gmail.com added the comment: Thank you, the TypeError test helped me find the error. Here is the corrected patch. For 2.7 it was necessary to turn the ZipFile in the new-style class. -- Added file: http://bugs.python.org/file25190/fix_zipfile_comment_4.patch Added file: http://bugs.python.org/file25191/fix_zipfile_comment_4-2.7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14399 ___diff -r bd353f12c007 Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py Wed Apr 11 20:15:10 2012 -0400 +++ b/Lib/test/test_zipfile.py Thu Apr 12 10:44:42 2012 +0300 @@ -970,6 +970,30 @@ with zipfile.ZipFile(TESTFN, mode=r) as zipfr: self.assertEqual(zipfr.comment, comment2) +def test_unicode_comment(self): +def setcomment(zipf, comment): +zipf.comment = comment +with zipfile.ZipFile(TESTFN, w, zipfile.ZIP_STORED) as zipf: +zipf.writestr(foo.txt, O, for a Muse of Fire!) +self.assertRaises(TypeError, setcomment, zipf, + this is a comment) + +def test_change_comment_in_empty_archive(self): +with zipfile.ZipFile(TESTFN, a, zipfile.ZIP_STORED) as zipf: +self.assertFalse(zipf.filelist) +zipf.comment = bthis is a comment +with zipfile.ZipFile(TESTFN, r) as zipf: +self.assertEqual(zipf.comment, bthis is a comment) + +def test_change_comment_in_nonempty_archive(self): +with zipfile.ZipFile(TESTFN, w, zipfile.ZIP_STORED) as zipf: +zipf.writestr(foo.txt, O, for a Muse of Fire!) +with zipfile.ZipFile(TESTFN, a, zipfile.ZIP_STORED) as zipf: +self.assertTrue(zipf.filelist) +zipf.comment = bthis is a comment +with zipfile.ZipFile(TESTFN, r) as zipf: +self.assertEqual(zipf.comment, bthis is a comment) + def check_testzip_with_bad_crc(self, compression): Tests that files with bad CRCs return their name from testzip. zipdata = self.zips_with_bad_crc[compression] diff -r bd353f12c007 Lib/zipfile.py --- a/Lib/zipfile.pyWed Apr 11 20:15:10 2012 -0400 +++ b/Lib/zipfile.pyThu Apr 12 10:44:42 2012 +0300 @@ -698,7 +698,7 @@ self.compression = compression # Method of compression self.mode = key = mode.replace('b', '')[0] self.pwd = None -self.comment = b'' +self._comment = b'' # Check if we were passed a file-like object if isinstance(file, str): @@ -774,7 +774,7 @@ print(endrec) size_cd = endrec[_ECD_SIZE] # bytes in central directory offset_cd = endrec[_ECD_OFFSET] # offset of central directory -self.comment = endrec[_ECD_COMMENT] # archive comment +self._comment = endrec[_ECD_COMMENT] # archive comment # concat is zero, unless zip was concatenated to another file concat = endrec[_ECD_LOCATION] - size_cd - offset_cd @@ -886,6 +886,24 @@ else: self.pwd = None +@property +def comment(self): +The comment text associated with the ZIP file. +return self._comment + +@comment.setter +def comment(self, comment): +if not isinstance(comment, bytes): +raise TypeError(comment: expected bytes, got %s % type(comment)) +# check for valid comment length +if len(comment) = ZIP_MAX_COMMENT: +if self.debug: +print('Archive comment is too long; truncating to %d bytes' +% ZIP_MAX_COMMENT) +comment = comment[:ZIP_MAX_COMMENT] +self._comment = comment +self._didModify = True + def read(self, name, pwd=None): Return file bytes (as a string) for name. with self.open(name, r, pwd) as fp: @@ -1287,18 +1305,11 @@ centDirSize = min(centDirSize, 0x) centDirOffset = min(centDirOffset, 0x) -# check for valid comment length -if len(self.comment) = ZIP_MAX_COMMENT: -if self.debug 0: -msg = 'Archive comment is too long; truncating to %d bytes' \ - % ZIP_MAX_COMMENT -self.comment = self.comment[:ZIP_MAX_COMMENT] - endrec = struct.pack(structEndArchive, stringEndArchive, 0, 0, centDirCount, centDirCount, - centDirSize, centDirOffset, len(self.comment)) + centDirSize, centDirOffset, len(self._comment)) self.fp.write(endrec) -self.fp.write(self.comment) +self.fp.write(self._comment) self.fp.flush() if not self._filePassed: diff -r d60ef141e090 Lib/test/test_zipfile.py --- a/Lib/test/test_zipfile.py Wed Apr
[issue14532] multiprocessing module performs a time-dependent hmac comparison
Jon Oberheide j...@oberheide.org added the comment: This is not time independent. Is it an issue? You're correct, the length check does leak the length of the expected digest as a performance enhancement (otherwise, your comparison runtime is bounded by the length of the attackers input). Generally, exposing the length and thereby potentially the underlying cryptographic hash function (eg. 20 bytes - hmac-sha1) is not considered a security risk for this type of scenario, whereas leaking key material certainly is. I considered including this nuance in the documentation and probably should. It's better to write isinstance(a, bytes). You should raise a TypeError if a is not a bytes or str. Ack, thanks. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Jim Jewett jimjjew...@gmail.com added the comment: -1 on that particular patch. tagname / (with only whitespace between / and ) strikes me as obviously intending to close the tag, and a reasonably common error. I can't think of any reason to support nested meta tags while not supporting sloppy self-closing tags. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14532] multiprocessing module performs a time-dependent hmac comparison
Antoine Pitrou pit...@free.fr added the comment: You could rewrite: result |= x ^ y as: result |= (x != y) Of course, this assumes that the != operator is constant-time for 1-element strings. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Jim Jewett jimjjew...@gmail.com added the comment: This issue is also marked for (bugfix-only) 2.7 and 3.2. Unless there is a specification somewhere (or at least an editor's draft), I can't really see any particular parse as a bugfix. Was the goal just to make the parse finish, as opposed to stopping part way through the text? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14532] multiprocessing module performs a time-dependent hmac comparison
Jon Oberheide j...@oberheide.org added the comment: You could rewrite: result |= x ^ y as: result |= (x != y) You could, but it's best not to introduce any conditional branching based if at all possible. For reference, see: http://rdist.root.org/2009/05/28/timing-attack-in-google-keyczar-library/#comment-5783 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14532] multiprocessing module performs a time-dependent hmac comparison
sbt shibt...@gmail.com added the comment: Why not just def time_independent_equals(a, b): return len(a) == len(b) and sum(x != y for x, y in zip(a, b)) == 0 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14532 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Changes by Jesús Cea Avión j...@jcea.es: Removed file: http://bugs.python.org/file24281/5458412752d5.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Changes by Jesús Cea Avión j...@jcea.es: Removed file: http://bugs.python.org/file24283/f86bb02fd8f4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Changes by Jesús Cea Avión j...@jcea.es: Added file: http://bugs.python.org/file25192/aa2dcffa267f.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Changes by Jesús Cea Avión j...@jcea.es: Added file: http://bugs.python.org/file25193/1e4d2c51b2d9.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1859] textwrap doesn't linebreak on \n
Serhiy Storchaka storch...@gmail.com added the comment: Cooking recipe for Otto: def wrap_paragraphs(text, width=70, **kwargs): return [line for para in text.splitlines() for line in textwrap.wrap(para, width, **kwargs)] -- nosy: +storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1859 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14399] zipfile and creat/update comment
R. David Murray rdmur...@bitdance.com added the comment: Thanks. We've had trouble in the past with a conversion to new style class breaking people's code. People are less likely to be subclassing ZipFile, though, so it is probably OK. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14399 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Jesús Cea Avión j...@jcea.es added the comment: Published diff from stock 2.7.3. Cleanups and simplifications. Marc, could you possible compile under MacOS X both 2.7 and 3.3 branches, both in 32 and 64 bits?. The tags are: dtrace-issue13405 - 3.3a2+ dtrace-issue13405_2.7 - 2.7.3 Let me know how is going. Please, document your build environment. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1065986] Fix pydoc crashing on unicode strings
Tom Bachmann e_mc...@web.de added the comment: Hello, [this is my first bug report, so I'm sorry if I'm not adhering to some conventions] in what versions of python is this supposed to be fixed? Consider: % python Python 2.7.2+ (default, Nov 30 2011, 19:22:03) [GCC 4.6.2] on linux2 Type help, copyright, credits or license for more information. from pydoc import pager from locale import getpreferredencoding expr = u'\u211a' pager(expr) # error pager(expr.encode(getdefaultencoding())) # works The error is: Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/pydoc.py, line 1318, in pager pager(text) File /usr/lib/python2.7/pydoc.py, line 1332, in lambda return lambda text: pipepager(text, os.environ['PAGER']) File /usr/lib/python2.7/pydoc.py, line 1359, in pipepager pipe.write(text) UnicodeEncodeError: 'ascii' codec can't encode character u'\u211a' in position 0: ordinal not in range(128) Best, Tom -- nosy: +ness ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1065986 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6717] Some problem with recursion handling
Changes by Philippe Devalkeneer phil.le.bienheur...@gmail.com: -- nosy: +flupke ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6717 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13405] Add DTrace probes
Jesús Cea Avión j...@jcea.es added the comment: PHP 5.4.0 added DTRACE support: http://fr2.php.net/ChangeLog-5.php The python window for 3.3 closes mid june. Let's do not miss it this time :-). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13405 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14538] HTMLParser: parsing error
Serhiy Storchaka storch...@gmail.com added the comment: To be consistent, this patch should remove the references to http://www.w3.org/TR/html5/tokenization.html#tag-open-state and http://www.w3.org/TR/html5/tokenization.html#tag-open-state as irrelevant. -- nosy: +storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14538 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1065986] Fix pydoc crashing on unicode strings
R. David Murray rdmur...@bitdance.com added the comment: It is fixed in Python3. Apparently Raymond was wrong about it having been fixed earlier (or perhaps he was referring to the unicode being removed from the pydoc __credits__ string). -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1065986 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com