Re: Newbie: where's the new python gone?
I have several installations on my windows, so I use c:\python27_64\python.exe module_file.py or c:\python26\python.exe module_file.py in the command line. Not to show that this shouldn't be a discussion, but usually it's searching. Here's search term a link, and some python docs: install python windows command line or click: https://www.google.com/search?q=install+python+windows+command+lineie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-ahere's and one of the better results: http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any difference between print 3 and print '3' in Python ?
On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote i...@feete.org wrote: On 09/09/12 14:23, iMath wrote: 在 2012年3月26日星期一UTC+8下午7时45分26秒,**iMath写道: I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ? thx everyone Here's a future import though I used,so I can use the planned 3 with a 2x python version in the command line interpreter: Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\davidc:\python26\python.exe Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. exit() C:\Users\davidc:\python27_64\python.exe Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type help, copyright, credits or license for more information. import __future__ x = 3 y = '3' print(x) 3 print(y) 3 type(x) type 'int' type(y) type 'str' z = '%i' % (3) type(z) type 'str' In other words type(value), and find out the difference. -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: where's the new python gone?
On 10/09/2012 07:10, Dwight Hutto wrote: I have several installations on my windows, so I use c:\python27_64\python.exe module_file.py or c:\python26\python.exe module_file.py in the command line. Not to show that this shouldn't be a discussion, but usually it's searching. Here's search term a link, and some python docs: install python windows command line or click: https://www.google.com/search?q=install+python+windows+command+lineie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-ahere's and one of the better results: http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows Why have you posted this seeing that the OP stated that they're on Mac OS X? The windows faq is outdated wrt PEP397. An up to date version is available here http://docs.python.org/dev/using/windows.html -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any difference between print 3 and print '3' in Python ?
On Sun, Sep 9, 2012 at 11:33 PM, Dwight Hutto dwightdhu...@gmail.com wrote: On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote i...@feete.org wrote: On 09/09/12 14:23, iMath wrote: 在 2012年3月26日星期一UTC+8下午7时45分26秒,iMath写道: I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ? thx everyone Here's a future import though I used,so I can use the planned 3 with a 2x python version in the command line interpreter: Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\davidc:\python26\python.exe Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. exit() C:\Users\davidc:\python27_64\python.exe Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type help, copyright, credits or license for more information. import __future__ x = 3 y = '3' print(x) 3 print(y) 3 type(x) type 'int' type(y) type 'str' z = '%i' % (3) type(z) type 'str' In other words type(value), and find out the difference. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com Somewhat OT, but __future__ doesn't work like that. You have to import the specific features you want to use. Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. print 3 3 import __future__ print 3 3 from __future__ import print_function print 3 File stdin, line 1 print 3 ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: where's the new python gone?
On Sun, Sep 9, 2012 at 11:10 PM, Dwight Hutto dwightdhu...@gmail.com wrote: I have several installations on my windows, so I use c:\python27_64\python.exe module_file.py or c:\python26\python.exe module_file.py in the command line. Not to show that this shouldn't be a discussion, but usually it's searching. Here's search term a link, and some python docs: install python windows command line or click: https://www.google.com/search?q=install+python+windows+command+lineie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-ahere's and one of the better results: http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com The problem is related to Python on Mac, not on Windows. As was stated in the original post. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any difference between print 3 and print '3' in Python ?
On 9/10/2012 2:33 AM, Dwight Hutto wrote: On Sun, Sep 9, 2012 at 10:41 AM, Ian Foote i...@feete.org mailto:i...@feete.org wrote: On 09/09/12 14:23, iMath wrote: 在 2012年3月26日星期一UTC+8下午7时45分26秒,__iMath写道: I know the print statement produces the same result when both of these two instructions are executed ,I just want to know Is there any difference between print 3 and print '3' in Python ? thx everyone Here's a future import though I used,so I can use the planned 3 with a 2x python version in the command line interpreter: Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\davidc:\python26\python.exe Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. exit() C:\Users\davidc:\python27_64\python.exe Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type help, copyright, credits or license for more information. import __future__ x = 3 y = '3' print(x) 3 print(y) 3 type(x) type 'int' type(y) type 'str' z = '%i' % (3) type(z) type 'str' In other words type(value), and find out the difference. print(x) prints str(x), which is meant to be a 'friendly' representation. To see a difference, print(repr(3)) 3 print(repr('3')) '3' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner Q: What does the double underscore __ mean?
The very first few steps, are help(any_module), and google. Try looking at this first then, the google search term I used(or any you might come up with_ : double underscore python 2.7 yielding: https://isearch.avg.com/search?q=double+underscore+python+2.7sap=kulang=enmid=376c19fb27d247d0a284cd3c4e3199e1-2a42c7757f8323a601da41ed11055b4506e772ffcid={f9f3e522-d7d6-4f0d-bfa5-e8ef583d0ff7}v=12.2.0.5ds=ft011d=8%2F29%2F2012+7%3A54%3A48+AMpr=sasnd=hdr and usually any question you've wanted to ask, has already been asked, and answered, but if you can't find it, you're in the right place. -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
Gelonida N gelon...@gmail.com wrote: On 09/07/2012 06:06 AM, Steven D'Aprano wrote: On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: Also of some interest is the best case: O(1) for unequal strings (they differ at the first character) and O(N) for equal strings. The worst case is O(N) or N characters the average case is O(1) or two characters. For denial of service attacks or systems, that are NEVER allowed to fail the worst case is important. For most other cases the average complexity counts. However I still wonder for how many applications the complexity of string comparisons would be the limiting factor. and of course if you ever do find an application where that worst case matters there's an easy way round it: just call intern() on all the strings when they are created. For the comparison to be the limiting factor you have to be doing a lot of comparisons on the same string (otherwise creating the string would be the limiting factor), so at the expense of a single dictionary insertion when the string is created you can get guaranteed O(1) on all the comparisons. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Call for Papers: ACCU 2013 conference
ACCU invites you to propose a session for its leading software development conference. The conference will be held in Bristol, England, from the 9th to the 13th April inclusive. Our opening keynote speakers will be Eben Upton, Mr Raspberry Pi. To propose a session please email the following information to confere...@accu.org * Title (a working title if necessary) * Type (tutorial, case-study, workshop, etc.) * Duration (45/90 min) * Speaker name(s) * Speaker biography (max 150 words) * Description (approx 250 words) We have a long tradition of high quality sessions covering many aspects of software development, from programming languages (e.g., Java, C#, Python, Erlang, Haskell, Ruby, Groovy, C, C++, etc.), and technologies (libraries, frameworks, databases, etc.) to subjects about the wider development environment such as testing, architecture and design, development process, analysis, patterns, project management, and softer aspects such as team building, communication and leadership. Sessions are usually tutorial-based, presentations of case studies, or interactive workshops, but we are always open to novel formats. Most sessions are 90 minutes. To encourage less experienced speakers to speak without the pressure of filling a full 90 minutes, we reserve a number of shorter 45 minute sessions. Speakers running one or more full 90 minute sessions receive a special conference package including free attendance, and assistance with their travel and accommodation costs. Speakers filling a 45 minute slot qualify for free conference attendance on the day of their session. For more information about location, travel, fees, accommodation, restaurants, etc, please see http://www.cvent.com/events/save-the-date-/event-summary-8539404013564465b7aba6a2ce241323.aspx The conference has always benefited from the strength of its programme. Please help us make 2013 another successful event. Thank you Jon Jagger (ACCU conference chair) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to run python2.6 module with absolute imports stand alone
Gelonida N wrote: On 09/08/2012 02:13 AM, Mark Lawrence wrote: [snip] I hope this helps http://stackoverflow.com/questions/3616952/how-to-properly-use-relative-or-absolute-imports-in-python-modules It seems the safest bet seems to be to not use relative imports. That's what I figured as well. I may have been misusing relative imports, but I never found the solution for my problems. Absolute imports just solved everything. I think this is the way to go for anyone who does not want to spend too much brain on their import directives. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: AttributeError: 'list' object has no attribute 'lower'
Token Type wrote: In fact, I'm guessing that's your problem. I think you're ending up with a list of lists of strings, when you think you're getting a list of strings. Thanks. You guess right. It turns out that lemma_list is a list of list, as I tested in the previous post. I often noticed people around me that are not that familiar with python are dismissing the error stack so quickly ; they probably knows the machine is trying to communicate with them but they don't seem to understand the message. Error stacks may be difficult to read at first glance but you can solve a lot of problems just by reading it. So next time you see 'X' has no attribute 'Y', you'll know that you've accessed an attribute/method of an object that does not exist, either you made a typo in the attribute name, or you object is not actually what you think it is. Advice : if you have so time, install ipython and execute your scripts in an ipython shell with the %pdb faeture on. This will automatically call the debugger upon unhandled exceptions and you'll be able to inspect your objects live from the prompt. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Standard Asynchronous Python
The responses have certainly highlighted some errors in emphasis in my approach. * My idea is to propose a design PEP. (Steven, Dennis) I'm not at *all* suggesting including uthreads in the standard library. It's a toy implementation I used to develop my ideas. I think of this as a much smaller idea in the same vein as the DBAPI (PEP 249): a common set of expectations that allows portability. * I'd like to set aside the issue of threads vs. event-driven programming. There are legitimate reasons to do both, and the healthy ecosystem of frameworks for the latter indicates at least some people are interested. My idea is to introduce a tiny bit of coherence across those frameworks. * (Bryan) The Fibonacci example is a simple example of, among other things, a CPU-bound, recursive task -- something that many async frameworks don't handle fairly right now. I will add some text to call that out explicitly. * Regarding generators vs. coroutines (Bryan), I use the terms generator and generator function in the PEP carefully, as that's what the syntactic and runtime concepts are called in Python. I will include a paragraph distinguishing the two. I will need to take up the details of the idea with the developers of the async frameworks themselves, and get some agreement before actually proposing the PEP. However, among this group I'm interested to know whether this is an appropriate use of a design PEP. That's why I posted my old and flawed PEP text, rather than re-drafting first. Thanks for the responses so far! Dustin -- http://mail.python.org/mailman/listinfo/python-list
Compile python code into a dll
Hi, I have Python code that I would like to compile into a dll (I have to deliver a C/C++ callable dll and I don't want to reimpelement the Python code in C/C++). It's not for extending Python but I want to call the Python functions and classes from C/C++. It's more like extending C/C++ with Python. I would be very appreciative for any help. Thank you in advance Regards Rolf -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile python code into a dll
On Monday, 10 September 2012 17:45:11 UTC+5:30, Rolf Wester wrote: Hi, I have Python code that I would like to compile into a dll (I have to deliver a C/C++ callable dll and I don't want to reimpelement the Python code in C/C++). It's not for extending Python but I want to call the Python functions and classes from C/C++. It's more like extending C/C++ with Python. I would be very appreciative for any help. Thank you in advance Regards Rolf http://docs.python.org/extending/embedding.html is the official docs for this thing Embedding is similar to extending. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile python code into a dll
I have Python code that I would like to compile into a dll (I have to See http://docs.python.org/extending/embedding.html. You can pack your code in a zip file and load it from the DLL entry point (something like what py2exe does). See also the Freeze tool - http://wiki.python.org/moin/Freeze. HTH, -- Miki (http://pythonwise.blogspot.com/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Standard Asynchronous Python
On Mon, 10 Sep 2012 07:36:11 -0400, Dustin J. Mitchell wrote: The responses have certainly highlighted some errors in emphasis in my approach. * My idea is to propose a design PEP. (Steven, Dennis) I'm not at *all* suggesting including uthreads in the standard library. It's a toy implementation I used to develop my ideas. I think of this as a much smaller idea in the same vein as the DBAPI (PEP 249): a common set of expectations that allows portability. Okay, point taken, I misunderstood your proposal. But my point still stands: since nobody except (possibly) you has used your uthreads library, what gives you confidence that the API you suggest is any good? Not just good, but good enough to impose that API on every other async framework in the standard library and possibly beyond it? If you have a good answer to that question, then it might be appropriate to propose such an API. (For what it's worth, consensus among the major async frameworks that your approach was a good idea would be a pretty good answer to that question.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
SAP MM Cupertino, CA
Hi, This is Girish, - IT Recruiter from SancroSoft USA Inc. Please respond with updated resume in MS-Word .doc Format with the following details to gir...@sancrosoftusa.com Full Name : Location : Contact Number : Email : Availability : Visa Status : SAP MM Location : Cupertino, CA Duration: 3+ Months Job Description: • Candidate should possess excellent functional knowledge in SAP MM for about 4-5 yrs and have 2 years of implementation or Production support experience • Should be strong in Procure to pay cycle covering the critical aspects of Purchasing, Inventory Management Invoice Verification. • Should be able to understand the client business process so as to map the requirements in SAP using standard solution methodology. • Should be able to conduct Business workshops to drive the project implementation using SAP standard implementation methodologies. • Should be strong in Special processes which include Consignment process, Subcontracting process Batch Management. • Should be comfortable in handling and preparation of Functional Specifications and to work with developer to achieve RICEF objects. • Should have cross functional expertise and should be strong in integrating the system with other modules which includes SD, WM FI. • Should have worked and exposed to EDI Integration techniques along with Idoc monitoring process. • Should be an excellent team player good team builder. • Should demonstrate excellent communication skills. Thanks Regards, Girish IT Recruiter. The power of focus SancroSoft USA INC 4944 Sunrise Blvd, Suite B-4 || Fair Oaks, CA 95628 Phone : 916-671-5584|| Fax: 916-200-0305 E-Mail : gir...@sancrosoftusa.com|| www.sancrosoftusa.com Stay Connected: The information contained in this email message is intended only for the personal and confidential use of the recipient(s) named above. The message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by email and delete the original message. -- http://mail.python.org/mailman/listinfo/python-list
Re: Standard Asynchronous Python
On 2012-09-10, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 9 Sep 2012 20:07:51 -0400, Dustin J. Mitchell dus...@v.igoro.us declaimed the following in gmane.comp.python.general: My proposal met with near-silence, and I didn't pursue it. Instead, I did what any self-respecting hacker would do - I wrote up a framework, uthreads [4], that implemented my idea. This was initially a simple trampoline scheduler, but I eventually refactored it to run atop Twisted, since that's what I use. To my knowledge, it's never been used. So for your small attempt to hide an event-driven dispatcher, one has to load a massive event-driven library. Some years ago I tried to make sense of Twisted and failed badly. Maybe it makes sense to those raised on UNIX style select() (where practically anything that involved data transfer over some sort of channel could be tested -- but doesn't work as such on Windows where only network sockets can be used, file i/o needs to use a different call), I think the idea behind the PEP is to facilitate modularisation of event driven frameworks into dispatchers and libraries that are suitable for running within dispatchers. When you say a 'massive-event driven library' I guess you mean something liek Twisted. I don't have much experience with Twisted but having looked at it a bit my impression is that it is so large because it includes many components that are not essential for every user. I guess that the reason for keeping those components in Twisted rather than as separate projects is not so much because every user needs them but because many of them are implemented in a way that makes them not much use outside of Twisted. The idea that Dustin is proposing is that in the same way that a library might declare a subset of its API to be thread-safe, and so usable with threading frameworks, a library could expose a PEP-XXX compliant interface for use with a PEP-XXX compliant dispatcher. If implemented that should facilitate the creation of minimal dispatchers and minimal standard components that can run within those dispatchers. This would mean that it wouldn't be necessary to make massive event-driven libraries but rather smaller interchangeable libraries. For example, it might facilitate the creation of a Windows-specific dispatcher that would be able to use the best underlying Windows APIs while also benefitting from any PEP-XXX compliant libraries that would work with any other dispatcher. As I get to work on the PEP, I'd like to hear any initial reactions to the idea. I don't have much experience with the event-driven frameworks but having made a couple of simple scripts using gevent/Twisted my experience is that learning to use these frameworks is hard, largely because of the number of framework- specific concepts that are needed to make simple examples work. I would expect that giving each framework a relatively standardised interface would make them much easier to learn. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Mon, 10 Sep 2012 08:59:37 +, Duncan Booth wrote: Gelonida N gelon...@gmail.com wrote: On 09/07/2012 06:06 AM, Steven D'Aprano wrote: On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: Also of some interest is the best case: O(1) for unequal strings (they differ at the first character) and O(N) for equal strings. The worst case is O(N) or N characters the average case is O(1) or two characters. For denial of service attacks or systems, that are NEVER allowed to fail the worst case is important. For most other cases the average complexity counts. However I still wonder for how many applications the complexity of string comparisons would be the limiting factor. and of course if you ever do find an application where that worst case matters there's an easy way round it: just call intern() on all the strings when they are created. There are other good reasons for interning strings, but speeding up astring == bstring is not one of them. [steve@ando ~]$ python -m timeit -s s = 'abc'*10 -s \ t = s[:-1] + 'x' s == t 1000 loops, best of 3: 910 usec per loop [steve@ando ~]$ python -m timeit -s s = 'abc'*10 -s \ t = s[:-1] + 'x' -s intern(s); intern(t) s == t 1000 loops, best of 3: 914 usec per loop No significant difference. To state the bleedin' obvious, the computational effort required to *compare two strings* pre-supposes that those strings already exist, and is *completely independent* of the complexity of creating the strings. For the comparison to be the limiting factor you have to be doing a lot of comparisons Correct. on the same string (otherwise creating the string would be the limiting factor), Not necessarily. Look, it's really hard to come up with a realistic, non-contrived example where string comparisons are a significant bottleneck in a non-toy application. So let me first off say that *nearly always* you're not going to care whether s == t looks at all N characters or just the first 2 (or 20, or 100). This argument is rather academic (the best sort of argument!). Until you start getting up into truly huge strings, we're arguing about how many angels can dance on a CPU cache. But for the record, in principle string comparisons *could* be the bottleneck. Example: you have 1 strings, which are each created once and stored in a list. Then you iterate over the list, comparing every string against every other string. And due to some weird vagary of the data, the strings are nearly all equal. (Why would you do this? I don't know, maybe it's a programmers' challenge found on the Internet, make up your own scenario...) Total number of strings created: 1. Total number of strings compared: 1. The overhead of creating the strings is trivial compared to the overhead of comparing them, and since each string is only created once anyway, interning them is just a waste of time. so at the expense of a single dictionary insertion when the string is created you can get guaranteed O(1) on all the comparisons. What interning buys you is that s == t is an O(1) pointer compare if they are equal. But if s and t differ in the last character, __eq__ will still inspect every character. There is no way to tell Python all strings are interned, if s is not t then s != t as well. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: where's the new python gone?
On Sep 9, 2012, at 10:28 AM, BobAalsma overhaalsgang_24_...@me.com wrote: I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version. However, when typing python in Terminal, I get Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) . So: (1) I can't seem to find where the new software has gone and (2) can't seem to find how to point to this new versoin. I've searched Python.org and with Google but :( [I'm on Mac OS X 10.7.4] Please help. -- http://mail.python.org/mailman/listinfo/python-list Bob, I'm coming into this late, but it doesn't appear that you've gotten a satisfactory answer yet. Let's take it one step at a time. First, if none of the hints you've received earlier have gotten you going. Maybe the thing is to resort to a bigger hammer. In a terminal window: $sudo find / -name Python -printreturn This will search the entire file system for all the files named Python and will ask for your admin password so it can search in directories owned by root. (It may also generate quite a bit of output, so you might want to capture it in a file.) In any case, this will take several minutes and while it is running, you can be checking a couple of other things. OS X doesn't use a .bashrc file by default (you can make it do so if you want, but that's extra work right now). It uses .login and then .profile to set up your python path _if_ you've used the installer from python.org. So, look to see if you have a .profile in your ~ directory. If so, then you're using (or have used at some point in the past) an installer from python.org. It should have an entry that looks something like the following: # Setting PATH for Python 2.7 # The orginal version is saved in .profile.pysave PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH} export PATH Note the distinction between this path and the one from Apple. The python that ships from Apple is in /System/Library/Frameworks… Do NOT touch the one from Apple. Apple uses it for some of its housekeeping operations and you want it to stay just as Apple installed it. When you finally find the Python 2.7 in the output from the find command, you can edit your .login (if you don't have a .profile) or edit .profile if you do. Good luck, Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 2012-09-10, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Mon, 10 Sep 2012 08:59:37 +, Duncan Booth wrote: Gelonida N gelon...@gmail.com wrote: so at the expense of a single dictionary insertion when the string is created you can get guaranteed O(1) on all the comparisons. What interning buys you is that s == t is an O(1) pointer compare if they are equal. But if s and t differ in the last character, __eq__ will still inspect every character. There is no way to tell Python all strings are interned, if s is not t then s != t as well. I thought that if *both* strings were interned then a pointer comparison could decide if they were unequal without needing to check the characters. Have I misunderstood how intern() works? Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Tue, Sep 11, 2012 at 12:06 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 2012-09-10, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What interning buys you is that s == t is an O(1) pointer compare if they are equal. But if s and t differ in the last character, __eq__ will still inspect every character. There is no way to tell Python all strings are interned, if s is not t then s != t as well. I thought that if *both* strings were interned then a pointer comparison could decide if they were unequal without needing to check the characters. Have I misunderstood how intern() works? In a language where _all_ strings are guaranteed to be interned (such as Lua, I think), you do indeed gain this. Pointer inequality implies string inequality. But when interning is optional (as in Python), you cannot depend on that, unless there's some way of recognizing interned strings. Of course, that may indeed be the case; a simple bit flag this string has been interned would suffice, and if both strings are interned AND their pointers differ, THEN you can be sure the strings differ. I have no idea whether or not CPython version X.Y.Z does this. The value of such an optimization really depends on how likely strings are to be interned; for instance, if the compiler automatically interns all the names of builtins, this could be quite beneficial. Otherwise, probably not; most Python scripts don't bother interning anything. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 2012-09-10, Chris Angelico ros...@gmail.com wrote: On Tue, Sep 11, 2012 at 12:06 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 2012-09-10, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What interning buys you is that s == t is an O(1) pointer compare if they are equal. But if s and t differ in the last character, __eq__ will still inspect every character. There is no way to tell Python all strings are interned, if s is not t then s != t as well. I thought that if *both* strings were interned then a pointer comparison could decide if they were unequal without needing to check the characters. Have I misunderstood how intern() works? In a language where _all_ strings are guaranteed to be interned (such as Lua, I think), you do indeed gain this. Pointer inequality implies string inequality. But when interning is optional (as in Python), you cannot depend on that, unless there's some way of recognizing interned strings. Of course, that may indeed be the case; a simple bit flag this string has been interned would suffice, and if both strings are interned AND their pointers differ, THEN you can be sure the strings differ. I have no idea whether or not CPython version X.Y.Z does this. The value of such an optimization really depends on how likely strings are to be interned; for instance, if the compiler automatically interns all the names of builtins, this could be quite beneficial. Otherwise, probably not; most Python scripts don't bother interning anything. I haven't looked at the source but my understanding was precisely that there is an intern() bit and that not only the builtins module but all the literals in any byte-compiled module are interned. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 2012-09-10, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 2012-09-10, Chris Angelico ros...@gmail.com wrote: On Tue, Sep 11, 2012 at 12:06 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 2012-09-10, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: What interning buys you is that s == t is an O(1) pointer compare if they are equal. But if s and t differ in the last character, __eq__ will still inspect every character. There is no way to tell Python all strings are interned, if s is not t then s != t as well. I thought that if *both* strings were interned then a pointer comparison could decide if they were unequal without needing to check the characters. Have I misunderstood how intern() works? In a language where _all_ strings are guaranteed to be interned (such as Lua, I think), you do indeed gain this. Pointer inequality implies string inequality. But when interning is optional (as in Python), you cannot depend on that, unless there's some way of recognizing interned strings. Of course, that may indeed be the case; a simple bit flag this string has been interned would suffice, and if both strings are interned AND their pointers differ, THEN you can be sure the strings differ. I have no idea whether or not CPython version X.Y.Z does this. The value of such an optimization really depends on how likely strings are to be interned; for instance, if the compiler automatically interns all the names of builtins, this could be quite beneficial. Otherwise, probably not; most Python scripts don't bother interning anything. I haven't looked at the source but my understanding was precisely that there is an intern() bit and that not only the builtins module but all the literals in any byte-compiled module are interned. s/literals/identifiers/ You can see the interned flag in the PyUnicodeObject struct here: http://hg.python.org/cpython/file/3ffd6ad93fe4/Include/unicodeobject.h#l303 Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Tue, Sep 11, 2012 at 12:43 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote: On 2012-09-10, Oscar Benjamin oscar.j.benja...@gmail.com wrote: I haven't looked at the source but my understanding was precisely that there is an intern() bit and that not only the builtins module but all the literals in any byte-compiled module are interned. s/literals/identifiers/ You can see the interned flag in the PyUnicodeObject struct here: http://hg.python.org/cpython/file/3ffd6ad93fe4/Include/unicodeobject.h#l303 Ah, yep, so that's there. In that case, it's possible to have that optimization. However, I may be misreading this, but it seems the only Unicode comparison function is a rich compare, which is unable to take advantage of a known difference: http://hg.python.org/cpython/file/b48ef168d8c5/Objects/unicodeobject.c#l6114 Different pointers prove the strings differ, but don't tell you which is to be sorted earlier. You could use this if you roll your own comparison in C; or, if you already know the strings are interned, you can use 'is' / 'is not'. But that seems to be the extent of it. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
PYODBC Print Cursor Output Question
I think there's a simple answer but displaying my ignorance here. I'm using Python 2.7.3 IDLW with pydoc 3x I think I've connected to my SQL Server 2005 and my SQL is good. How do I display the actual data returned from my fetch? Been searching for several hours but no joy... Thanks. Jamie === cursor.execute(select * from project) row = cursor.fetchone() if row: print row pyodbc.Cursor object at 0x0167D678 I'd like to actually see SQL output here?) -- http://mail.python.org/mailman/listinfo/python-list
Re: SAP MM Cupertino, CA
On Monday, 10 September 2012 18:51:10 UTC+5:30, Suresh Kumar wrote: Hi, This is Girish, - IT Recruiter from SancroSoft USA Inc. Please respond with updated resume in MS-Word .doc Format with the following details to gir...@sancrosoftusa.com Full Name : Location : Contact Number : Email : Availability : Visa Status : SAP MM Location : Cupertino, CA Duration: 3+ Months Job Description: • Candidate should possess excellent functional knowledge in SAP MM for about 4-5 yrs and have 2 years of implementation or Production support experience • Should be strong in Procure to pay cycle covering the critical aspects of Purchasing, Inventory Management Invoice Verification. • Should be able to understand the client business process so as to map the requirements in SAP using standard solution methodology. • Should be able to conduct Business workshops to drive the project implementation using SAP standard implementation methodologies. • Should be strong in Special processes which include Consignment process, Subcontracting process Batch Management. • Should be comfortable in handling and preparation of Functional Specifications and to work with developer to achieve RICEF objects. • Should have cross functional expertise and should be strong in integrating the system with other modules which includes SD, WM FI. • Should have worked and exposed to EDI Integration techniques along with Idoc monitoring process. • Should be an excellent team player good team builder. • Should demonstrate excellent communication skills. Thanks Regards, Girish IT Recruiter. The power of focus SancroSoft USA INC 4944 Sunrise Blvd, Suite B-4 || Fair Oaks, CA 95628 Phone : 916-671-5584|| Fax: 916-200-0305 E-Mail : gir...@sancrosoftusa.com|| www.sancrosoftusa.com Stay Connected: The information contained in this email message is intended only for the personal and confidential use of the recipient(s) named above. The message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by email and delete the original message. Marking this as abusive in Google Groups - this seems like spam. Please explain what does this have to do with Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: where's the new python gone?
On 10/09/12 15:04:24, William R. Wing (Bill Wing) wrote: On Sep 9, 2012, at 10:28 AM, BobAalsma overhaalsgang_24_...@me.com wrote: I think I've installed Python 2.7.3 according to the instructions in the README, and now want to use that version. However, when typing python in Terminal, I get Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32) . So: (1) I can't seem to find where the new software has gone and (2) can't seem to find how to point to this new versoin. I've searched Python.org and with Google but :( [I'm on Mac OS X 10.7.4] Please help. -- http://mail.python.org/mailman/listinfo/python-list Bob, I'm coming into this late, but it doesn't appear that you've gotten a satisfactory answer yet. Let's take it one step at a time. First, if none of the hints you've received earlier have gotten you going. Maybe the thing is to resort to a bigger hammer. In a terminal window: $sudo find / -name Python -printreturn This will search the entire file system for all the files named Python Trouble is, the file you're looking for is named python and this command is case-sensitive. So the command you need would be: sudo find / -name python -print and will ask for your admin password so it can search in directories owned by root. The file you're looking for is in a directory that you can read with more mundane permissions, so you might want to leave off the sudo prefix. If you do, you'll get some message about permission problems. (It may also generate quite a bit of output, so you might want to capture it in a file.) For example: find / -name python /tmp/pythons.txt 2 /dev/null The 2/dev/null bit throws away warnings about permission problems and the like. Alternatively, you can cut down the output like so: find / -name python -print | grep bin/python That will only report pythons found in directories named bin. On my laptop, that cuts the output down to: /Library/Frameworks/Python.framework/Versions/2.7/bin/python /opt/local/bin/python /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python /usr/bin/python /usr/local/bin/python Those are all valid python interpreters, or wrappers for same. In any case, this will take several minutes and while it is running, you can be checking a couple of other things. OS X doesn't use a .bashrc file by default (you can make it do so if you want, but that's extra work right now). It uses .login and then .profile to set up your python path _if_ you've used the installer from python.org. I doubt it. What files are used, depends on which shell you use. Bash uses .profile; the C shell uses .login and .cshrc. I don't think there is a shell that can read both .login and .profile since .login typically uses C shell syntax and .profile uses Bourne shell syntax. If you're not sure which shell you have, type echo $SHELL at the shell prompt. So, look to see if you have a .profile in your ~ directory. If so, then you're using (or have used at some point in the past) an installer from python.org. It should have an entry that looks something like the following: # Setting PATH for Python 2.7 # The original version is saved in .profile.pysave PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH} export PATH Note the distinction between this path and the one from Apple. The python that ships from Apple is in /System/Library/Frameworks… Do NOT touch the one from Apple. Apple uses it for some of its housekeeping operations and you want it to stay just as Apple installed it. +1 When you finally find the Python 2.7 in the output from the find command, you can edit your .login (if you don't have a .profile) or edit .profile if you do. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: Compile python code into a dll
On 9/10/2012 8:15 AM, Rolf Wester wrote: I have Python code that I would like to compile into a dll (I have to deliver a C/C++ callable dll and I don't want to reimpelement the Python code in C/C++). It's not for extending Python but I want to call the Python functions and classes from C/C++. It's more like extending C/C++ with Python. I would be very appreciative for any help. Cython compiles CPython to C which can be compiled by and c/c++ compiler. I believe it can do the above. This makes Cython the ideal language for wrapping external C libraries, embedding CPython into existing applications, . I think the latter is what you want to do. http:cython.org -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 04/09/2012 03:54, Roy Smith wrote: Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of comparing every character. I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. But, if it turns out that for real-life situations, the ends of strings have more entropy than the beginnings, the odds are you'll discover that they're unequal quicker by starting at the end. From the rest of the thread, it looks like in most situations it won't make much difference as typically very few characters need to be compared if they are unequal. However, if you were in a situation with many strings which were almost equal, the most general way to improve the situation might be store a hash of the string along with the string, i.e. store (hash(x), x) and then compare equality of this tuple. Almost all of the time, if the strings are unequal the hash will be unequal. Or, as someone else suggested, use interned versions of the strings. This is basically the same solution but even better. In this case, your startup costs will be higher (creating the strings) but your comparisons will always be instant. Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: PYODBC Print Cursor Output Question
On 10/09/2012 15:55, james simpson wrote: I think there's a simple answer but displaying my ignorance here. I'm using Python 2.7.3 IDLW with pydoc 3x I think I've connected to my SQL Server 2005 and my SQL is good. How do I display the actual data returned from my fetch? Been searching for several hours but no joy... Thanks. Jamie === cursor.execute(select * from project) row = cursor.fetchone() if row: print row pyodbc.Cursor object at 0x0167D678 I'd like to actually see SQL output here?) Try this: results = cursor.execute(select * from project) row = results.fetchone() print row -- http://mail.python.org/mailman/listinfo/python-list
Re: Standard Asynchronous Python
On 9/10/2012 7:36 AM, Dustin J. Mitchell wrote: The responses have certainly highlighted some errors in emphasis in my approach. * My idea is to propose a design PEP. (Steven, Dennis) I'm not at *all* suggesting including uthreads in the standard library. It's a toy implementation I used to develop my ideas. I think of this as a much smaller idea in the same vein as the DBAPI (PEP 249): a common set of expectations that allows portability. That has been very successful. * I'd like to set aside the issue of threads vs. event-driven programming. There are legitimate reasons to do both, and the healthy ecosystem of frameworks for the latter indicates at least some people are interested. My idea is to introduce a tiny bit of coherence across those frameworks. I think many developers recognize that some improvment in coherence would be a good idea. I occasionally read that *someone* is working on common event loop approach, though it has not materialized yet. I will need to take up the details of the idea with the developers of the async frameworks themselves, and get some agreement before actually proposing the PEP. However, among this group I'm interested to know whether this is an appropriate use of a design PEP. I think so. That's why I posted my old and flawed PEP text, rather than re-drafting first. I think you should do a bit of editing now, even if not a full redraft. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: SAP MM Cupertino, CA
On 9/10/2012 7:58 AM Ramchandra Apte said... On Monday, 10 September 2012 18:51:10 UTC+5:30, Suresh Kumar wrote: SNIP delete the original message. Marking this as abusive in Google Groups - this seems like spam. Please explain what does this have to do with Python. Please learn to trim -- your reposting of the entire 'abusive' post is in and of itself abusive. Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 2012-09-10, Dan Goodman dg.gm...@thesamovar.net wrote: On 04/09/2012 03:54, Roy Smith wrote: Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of comparing every character. I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. But, if it turns out that for real-life situations, the ends of strings have more entropy than the beginnings, the odds are you'll discover that they're unequal quicker by starting at the end. From the rest of the thread, it looks like in most situations it won't make much difference as typically very few characters need to be compared if they are unequal. However, if you were in a situation with many strings which were almost equal, the most general way to improve the situation might be store a hash of the string along with the string, i.e. store (hash(x), x) and then compare equality of this tuple. Almost all of the time, if the strings are unequal the hash will be unequal. Or, as someone else suggested, use interned versions of the strings. This is basically the same solution but even better. In this case, your startup costs will be higher (creating the strings) but your comparisons will always be instant. Computing the hash always requires iterating over all characters in the string so is best case O(N) where string comparison is best case (and often average case) O(1). Also, so far as I know the hash value once computed is stored on the string object itself [1] and used for subsequent string comparisons so there's no need for you to do that in your code. Oscar [1] http://hg.python.org/cpython/file/71d94e79b0c3/Include/unicodeobject.h#l293 -- http://mail.python.org/mailman/listinfo/python-list
How to timeout a recv() on an ssl connection?
I can't figure out how to timeout a recv() on an SSLSocket -- I'm using Python 2.6 nad 2.7. Here's what I've got so far (it needs to work on either a plain or SSL socket): s.settimeout(timeout) try: b = ord(s.recv(1)) except socket.timeout: return None except ssl.SSLError as e: if e.message == 'The read operation timed out': return None else: raise finally: s.settimeout(None) It works fine on normal sockets. With an SSLSocket, it works the first time it's called with timeout set to something other than None (it times out properly). Subsequence reads with timeout set to None work, but then the second time it's called with a non-None timeout, it hangs for several minutes, and then the recv() returns an empty string. -- Grant Edwards grant.b.edwardsYow! This PORCUPINE knows at his ZIPCODE ... And he has gmail.comVISA!! -- http://mail.python.org/mailman/listinfo/python-list
how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py
In Python 2.7.2 on Windows 7, os.walk() uses isdir(), which comes from os.path, which really comes from ntpath.py, which really comes from genericpath.py I want os.walk() to use a modified isdir() on my Windows 7. Not knowing any better, it seems to me like ntpath.py would be a good place to intercept. When os.py does import ntpath as path, how can I get python to process my customized ntpath.py instead of Lib/ntpath.py ? Thanks for any comments. John BTW, here's my mod to ntpath.py: $ diff ntpath.py.standard ntpath.py 14c14,19 from genericpath import * --- from genericpath import * def isdir(s): return genericpath.isdir('?\\' + abspath(s + '\\')) def isfile(s): return genericpath.isfile('?\\' + abspath(s + '\\')) Why? Because the genericpath implementation relies on os.stat() which uses Windows API function that presumes or enforces some naming conventions like doesn't end with a space or a period. But the NTFS actually supports such filenames and dirnames, and some sw (like cygwin) lets users make files dirs without restricting. So, cygwin users like me may have file 'voo...\\doo' which os.walk() cannot ordinarily walk. That is, the isdir('voo...') returns false because the underlying os.stat is assessing 'voo' instead of 'voo...' . The workaround is to pass os.stat a fullpathname that is prefixed with r'\\?\' so the Windows API recognizes that you do NOT want the name filtered. Better said by Microsoft: For file I/O, the \\?\ prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 10/09/2012 18:33, Oscar Benjamin wrote: Computing the hash always requires iterating over all characters in the string so is best case O(N) where string comparison is best case (and often average case) O(1). Yep, but you already have O(N) costs just creating the strings in the first place, so it's absorbed into that. It's only worth doing if you do many comparisons. Also, so far as I know the hash value once computed is stored on the string object itself [1] and used for subsequent string comparisons so there's no need for you to do that in your code. Cool, Python is very clever as always! :) Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: How to timeout a recv() on an ssl connection?
On 2012-09-10, Grant Edwards invalid@invalid.invalid wrote: I can't figure out how to timeout a recv() on an SSLSocket -- I'm using Python 2.6 nad 2.7. Here's what I've got so far (it needs to work on either a plain or SSL socket): s.settimeout(timeout) try: b = ord(s.recv(1)) except socket.timeout: return None except ssl.SSLError as e: if e.message == 'The read operation timed out': return None else: raise finally: s.settimeout(None) It works fine on normal sockets. With an SSLSocket, it works the first time it's called with timeout set to something other than None (it times out properly). Subsequence reads with timeout set to None work, but then the second time it's called with a non-None timeout, it hangs for several minutes, and then the recv() returns an empty string. Doh! Never mind. The above code does appear to be working correctly. I had a different bug that was misleading me... -- Grant Edwards grant.b.edwardsYow! What GOOD is a at CARDBOARD suitcase ANYWAY? gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 10/09/2012 18:07, Dan Goodman wrote: On 04/09/2012 03:54, Roy Smith wrote: Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of comparing every character. I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. But, if it turns out that for real-life situations, the ends of strings have more entropy than the beginnings, the odds are you'll discover that they're unequal quicker by starting at the end. From the rest of the thread, it looks like in most situations it won't make much difference as typically very few characters need to be compared if they are unequal. However, if you were in a situation with many strings which were almost equal, the most general way to improve the situation might be store a hash of the string along with the string, i.e. store (hash(x), x) and then compare equality of this tuple. Almost all of the time, if the strings are unequal the hash will be unequal. Or, as someone else suggested, use interned versions of the strings. This is basically the same solution but even better. In this case, your startup costs will be higher (creating the strings) but your comparisons will always be instant. Just had another thought about this. Although it's unlikely to be necessary in practice since (a) it's rarely necessary at all, and (b) when it is, hashing and optionally interning seems like the better approach, I had another idea that would be more general. Rather than starting from the beginning or the end, why not do something like: check the first and last character, then the len/2 character, then the len/4, then 3*len/4, then len/8, 3*len/8, etc. You'd need to be a bit clever about making sure you hit every character but I'm sure someone's already got an efficient algorithm for this. You could probably even make this cache efficient by working on cache line length blocks. Almost certainly entirely unnecessary, but I like the original question and it's a nice theoretical problem. Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: pyQT performance?
Le 10/09/12 19:24, jayden.s...@gmail.com a écrit : Anybody has the experience of the performance of the program developed by pyQT? Is it much slower than the one made by QT, such as (20%)? For my experience, 20% is really surestimated. I'm developping only with PyQt and essentially in the imaging domain (viewing, transformation) and I've never seen a difference of processing speed with the same applications written in C++. Qt + Python, a very good association. -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager -- http://mail.python.org/mailman/listinfo/python-list
Wing IDE 4.1.8 released
Hi, Wingware has released version 4.1.8 of Wing IDE, our integrated development environment designed specifically for the Python programming language. Wing IDE provides a professional quality 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. For details see http://wingware.com/ This minor release includes: Added How-Tos for The Foundry's NUKE/NUKEX and IDA Python Track file operations in Project at the revision control level Accept glob style wildcards for Filter in Search in Files Support analysis of extension modules within zip archives Fix searching of documentation Several VI mode files Several auto-editing and auto-completion fixes Fix excessive memory use by the Perforce integration Copy existing window's tool layout when creating new windows Less confusing auto-save recovery About 35 other bug fixes and minor improvements For a complete change log see http://wingware.com/pub/wingide/4.1.8/CHANGELOG.txt Free trial: http://wingware.com/wingide/trial Downloads: http://wingware.com/downloads Feature matrix: http://wingware.com/wingide/features More information: http://wingware.com/ Sales: http://wingware.com/store/purchase Upgrades: https://wingware.com/store/upgrade Questions? Don't hesitate to email us at sa...@wingware.com. Thanks, -- Stephan Deibel Wingware | Python IDE Advancing Software Development www.wingware.com -- http://mail.python.org/mailman/listinfo/python-list
Re: pyQT performance?
On Monday, September 10, 2012 2:06:59 PM UTC-4, Vincent Vande Vyvre wrote: Le 10/09/12 19:24, jayden.s...@gmail.com a écrit : Anybody has the experience of the performance of the program developed by pyQT? Is it much slower than the one made by QT, such as (20%)? For my experience, 20% is really surestimated. I'm developping only with PyQt and essentially in the imaging domain (viewing, transformation) and I've never seen a difference of processing speed with the same applications written in C++. Qt + Python, a very good association. -- Vincent V.V. Oqapy https://launchpad.net/oqapy . Qarte https://launchpad.net/qarte . PaQager https://launchpad.net/paqager Have you ever used py2exe? After converting the python codes to executable, does it save the time of interpreting the script language? Thank a lot! -- http://mail.python.org/mailman/listinfo/python-list
Re: pyQT performance?
On 09/10/2012 07:29 PM, jayden.s...@gmail.com wrote Have you ever used py2exe? After converting the python codes to executable, does it save the time of interpreting the script language? Thank a lot! Py2exe normally never speeds up anything, simply because it doesn't convert to executable, but simply package everything together, so I haven't tried in this particular case but it shouldn't make a difference.. -- http://mail.python.org/mailman/listinfo/python-list
Numpy combine channels
I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy combine channels
On Monday, September 10, 2012 3:39:11 PM UTC-4, Wanderer wrote: I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? Thanks I figured it out. numpy.sum(array, axis=1). -- http://mail.python.org/mailman/listinfo/python-list
RE: Numpy combine channels
I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? You may be over-thinking this, and numpy might not be necessary. A simple solution would be just a quick list comprehension: stereo_array = [[1, 1], [1, 2], [2, 3]] mono_array = [l+r for (l, r) in stereo_array] Thanks, Nick Cash -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy combine channels
On 10/09/2012 20:39, Wanderer wrote: I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? import numpy numpy.array([[1,1],[1,2],[2,3]], dtype=i) array([[1, 1], [1, 2], [2, 3]]) a[:, 0] array([1, 1, 2]) a[:, 1] array([1, 2, 3]) a[:, 0] + a[:, 1] array([2, 3, 5]) But should they be added together to make mono? Suppose, for example, that both channels have a maximum value. Their sum would be _twice_ the maximum. Therefore, I think that it should probably be the average. (a[:, 0] + a[:, 1]) / 2 array([1, 1, 2]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy combine channels
On Monday, September 10, 2012 4:12:40 PM UTC-4, MRAB wrote: On 10/09/2012 20:39, Wanderer wrote: I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? import numpy numpy.array([[1,1],[1,2],[2,3]], dtype=i) array([[1, 1], [1, 2], [2, 3]]) a[:, 0] array([1, 1, 2]) a[:, 1] array([1, 2, 3]) a[:, 0] + a[:, 1] array([2, 3, 5]) But should they be added together to make mono? Suppose, for example, that both channels have a maximum value. Their sum would be _twice_ the maximum. Therefore, I think that it should probably be the average. (a[:, 0] + a[:, 1]) / 2 array([1, 1, 2]) I'm decoding morse code. So it's CV dots and dashes. -- http://mail.python.org/mailman/listinfo/python-list
Re: set and dict iteration
Paul Rubin於 2012年8月17日星期五UTC+8上午9時01分39秒寫道: Ian Kelly ian.g.ke...@gmail.com writes: With regard to key insertion and deletion while iterating over a dict or set, though, there is just no good reason to be doing that (especially as the result is very implementation-specific), and I wouldn't mind a more complete low-level check against it as long as it's not too expensive (which is not clearly the case with the current suggestion at all). One possible approach is to freeze the dictionary against modification while any iterator is open on it. You could keep a count of active iterators in the dict structure, adjusting it whenever an iterator is created or closed/destroyed. If there is only one iterator of a frozen dictionary, then nothing is saved. But if there are manny iterators based on the same frozen dictionary, this approach saves a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy combine channels
On Monday, September 10, 2012 4:14:18 PM UTC-4, Wanderer wrote: On Monday, September 10, 2012 4:12:40 PM UTC-4, MRAB wrote: On 10/09/2012 20:39, Wanderer wrote: I have an array generated by audiolab of left and right stereo channels. It looks like [[1,1],[1,2],[2,3]]. I would like to combine the left and right channels to get an array [2,3,5]. Is there a numpy command to do that? import numpy numpy.array([[1,1],[1,2],[2,3]], dtype=i) array([[1, 1], [1, 2], [2, 3]]) a[:, 0] array([1, 1, 2]) a[:, 1] array([1, 2, 3]) a[:, 0] + a[:, 1] array([2, 3, 5]) But should they be added together to make mono? Suppose, for example, that both channels have a maximum value. Their sum would be _twice_ the maximum. Therefore, I think that it should probably be the average. (a[:, 0] + a[:, 1]) / 2 array([1, 1, 2]) I'm decoding morse code. So it's CV dots and dashes. In case anyone is interested, here is the full code. # morsecode.py import numpy as np from scikits.audiolab import wavread from scipy.signal import decimate from pylab import plot from pylab import show import os def movingaverage(interval, window_size): window = np.ones(int(window_size)) / float(window_size) return np.convolve(interval, window, 'same') def wav2morse(resultDir, filename): Convert a wave file to morse code resultDir: directory for wave file and results filename: wave file name data, _fs, _enc = wavread(resultDir + '\\' + filename) data = np.sum(data, axis=1) data = np.fabs(data) data = movingaverage(data, 100) data = decimate(data, 2) highcount = 0 lowcount = 0 fileBase, _fileExt = os.path.splitext(filename) f = open(resultDir + '\\' + fileBase + '.txt', 'w') for d in data: if d 0.3: if lowcount 3000: f.write(' ') lowcount = 0 highcount += 1 else: if highcount 3000: f.write('-') elif highcount 1000: f.write('.') highcount = 0 lowcount += 1 f.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py
On Mon, 10 Sep 2012 10:25:29 -0700, ruck wrote: In Python 2.7.2 on Windows 7, os.walk() uses isdir(), which comes from os.path, which really comes from ntpath.py, which really comes from genericpath.py I want os.walk() to use a modified isdir() on my Windows 7. Not knowing any better, it seems to me like ntpath.py would be a good place to intercept. When os.py does import ntpath as path, how can I get python to process my customized ntpath.py instead of Lib/ntpath.py ? import os os.path.isdir = my_isdir ought to do it. This general technique is called monkey-patching. The Ruby community is addicted to it. Everybody else -- and a goodly number of the more sensible Ruby crowd -- consider it a risky, dirty hack that 99 times out of 100 will lead to blindness, moral degeneracy and subtle, hard-to-fix bugs. They are right to be suspicious of it. As a general rule, monkey-patching is not for production code. You have been warned. http://www.codinghorror.com/blog/2008/07/monkeypatching-for-humans.html [...] Why? Because the genericpath implementation relies on os.stat() which uses Windows API function that presumes or enforces some naming conventions like doesn't end with a space or a period. But the NTFS actually supports such filenames and dirnames, and some sw (like cygwin) lets users make files dirs without restricting. So, cygwin users like me may have file 'voo...\\doo' which os.walk() cannot ordinarily walk. That is, the isdir('voo...') returns false because the underlying os.stat is assessing 'voo' instead of 'voo...' . Please consider submitting a patch that adds support for cygwin paths to the standard library. You'll need to target 3.4 though, 2.7 is now a maintenance release with no new features allowed. The workaround is to pass os.stat a fullpathname that is prefixed with r'\\?\' so the Windows API recognizes that you do NOT want the name filtered. Better said by Microsoft: For file I/O, the \\?\ prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. That's not so much a workaround as the officially supported API for dealing with the situation you are in. Why don't you just prepend a '?' to paths like they tell you to? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
python CAD libraries?
Are there any python CAD libraries that can (1) build simple 3D primitives solids such as spheres, cylinders and so on (2) perform bool operations on 3D solids (3) better if it has some transformations such has scaling, sweeping, and lofting Please recommend some good ones for me? Thanks a lot!! -- http://mail.python.org/mailman/listinfo/python-list
Re: python CAD libraries?
On 09/10/2012 02:10 PM, Jayden wrote: Are there any python CAD libraries that can (1) build simple 3D primitives solids such as spheres, cylinders and so on (2) perform bool operations on 3D solids (3) better if it has some transformations such has scaling, sweeping, and lofting Please recommend some good ones for me? Thanks a lot!! Try PythonCAD: http://sourceforge.net/projects/pythoncad/ (Google would have been faster. :-) ) Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing ISO date/time strings - where did the parser go?
On Sun, 09 Sep 2012 13:14:30 +0100, Roy Smith r...@panix.com wrote: In article mailman.323.1346961101.27098.python-l...@python.org, Thomas Jollans t...@jollybox.de wrote: The ISO date/time format is dead simple and well-defined. Well defined, perhaps. But nobody who has read the standard could call it dead simple. ISO-8601-2004(E) is 40 pages long. A short standard, then :-) -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: python CAD libraries?
On Monday, September 10, 2012 5:30:08 PM UTC-4, Gary Herron wrote: On 09/10/2012 02:10 PM, Jayden wrote: Are there any python CAD libraries that can (1) build simple 3D primitives solids such as spheres, cylinders and so on (2) perform bool operations on 3D solids (3) better if it has some transformations such has scaling, sweeping, and lofting Please recommend some good ones for me? Thanks a lot!! Try PythonCAD: http://sourceforge.net/projects/pythoncad/ (Google would have been faster. :-) ) Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 Thank you. But this is for 2D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 2012-09-10, Dan Goodman dg.gm...@thesamovar.net wrote: On 10/09/2012 18:07, Dan Goodman wrote: On 04/09/2012 03:54, Roy Smith wrote: Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of comparing every character. I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. But, if it turns out that for real-life situations, the ends of strings have more entropy than the beginnings, the odds are you'll discover that they're unequal quicker by starting at the end. From the rest of the thread, it looks like in most situations it won't make much difference as typically very few characters need to be compared if they are unequal. However, if you were in a situation with many strings which were almost equal, the most general way to improve the situation might be store a hash of the string along with the string, i.e. store (hash(x), x) and then compare equality of this tuple. Almost all of the time, if the strings are unequal the hash will be unequal. Or, as someone else suggested, use interned versions of the strings. This is basically the same solution but even better. In this case, your startup costs will be higher (creating the strings) but your comparisons will always be instant. Just had another thought about this. Although it's unlikely to be necessary in practice since (a) it's rarely necessary at all, and (b) when it is, hashing and optionally interning seems like the better approach, I had another idea that would be more general. Rather than starting from the beginning or the end, why not do something like: check the first and last character, then the len/2 character, then the len/4, then 3*len/4, then len/8, 3*len/8, etc. You'd need to be a bit clever about making sure you hit every character but I'm sure someone's already got an efficient algorithm for this. You could probably even make this cache efficient by working on cache line length blocks. Almost certainly entirely unnecessary, but I like the original question and it's a nice theoretical problem. It's not totally theoretical in the sense that the reasoning applies to all sequence comparisons. If you needed to compare lists of objects where the comparison of each pair of elements was an expensive operation then you would want to think carefully about what order you used. Also in general you can't hash/intern all sequences. If I was going to change the order of comparisons for all strings then I would use a random order. This is essentially how dict gets away with claiming to have O(1) lookup. There are sequences of inputs that can cause every possible hash collision to occur but because the hash function acts as a kind of randomisation filter the pathological sequences are very unlikely to occur unless someone is going out of their way. The clever way that Python 3.3 prevents someone from even doing this on purpose is just to introduce additional per-process randomisation. The difference between dict lookup and string comparison is that string comparison always compares the characters in the same order and it corresponds to the natural ordering of the data. This means that some pefectly natural use cases like comparing file-paths can have close to worst case behaviour. If string/sequence comparison occurs in a random order then there can be no use case where the likely strings would induce close to worst case behaviour unless you really are just comparing lots of almost identical sequences. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie: where's the new python gone?
On Sep 10, 2012, at 11:17 AM, Bob Aalsma overhaalsgang_24_...@me.com wrote: Well, Bill, better late than never - thanks for stepping in. You are right, my problems are not yet solved ;) As Hans pointed out, you are looking for python, not Python (the frameworks are named Python, the executable is python). Sorry about that. To eliminate the output from TimeMachine (assuming it is using an external drive or a TimeCapsule), add one more option to the find command: $ sudo find -x / -name python -print (or follow his directions for piping to a file). The -x option prevents find from descending into a volume with a different device number from the one you started on. -Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py
On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: On Mon, 10 Sep 2012 10:25:29 -0700, ruck wrote: In Python 2.7.2 on Windows 7, os.walk() uses isdir(), which comes from os.path, which really comes from ntpath.py, which really comes from genericpath.py I want os.walk() to use a modified isdir() on my Windows 7. Not knowing any better, it seems to me like ntpath.py would be a good place to intercept. When os.py does import ntpath as path, how can I get python to process my customized ntpath.py instead of Lib/ntpath.py ? import os os.path.isdir = my_isdir ought to do it. This general technique is called monkey-patching. The Ruby community is addicted to it. Everybody else -- and a goodly number of the more sensible Ruby crowd -- consider it a risky, dirty hack that 99 times out of 100 will lead to blindness, moral degeneracy and subtle, hard-to-fix bugs. They are right to be suspicious of it. As a general rule, monkey-patching is not for production code. You have been warned. http://www.codinghorror.com/blog/2008/07/monkeypatching-for-humans.html [...] Why? Because the genericpath implementation relies on os.stat() which uses Windows API function that presumes or enforces some naming conventions like doesn't end with a space or a period. But the NTFS actually supports such filenames and dirnames, and some sw (like cygwin) lets users make files dirs without restricting. So, cygwin users like me may have file 'voo...\\doo' which os.walk() cannot ordinarily walk. That is, the isdir('voo...') returns false because the underlying os.stat is assessing 'voo' instead of 'voo...' . Please consider submitting a patch that adds support for cygwin paths to the standard library. You'll need to target 3.4 though, 2.7 is now a maintenance release with no new features allowed. The workaround is to pass os.stat a fullpathname that is prefixed with r'\\?\' so the Windows API recognizes that you do NOT want the name filtered. Better said by Microsoft: For file I/O, the \\?\ prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. That's not so much a workaround as the officially supported API for dealing with the situation you are in. Why don't you just prepend a '?' to paths like they tell you to? -- Steven Steven says: That's not so much a workaround as the officially supported API for dealing with the situation you are in. Why don't you just prepend a '?' to paths like they tell you to? Good idea, but the first thing os.walk() does is a listdir(), and os.listdir() does not like the r'\\?\' prefix. In other words, os.walk(r'\\?\C:Users\john\Desktop\sandbox\goo') does not work. Also, your recipe worked for me -- I'm walking 'goo' which contains 'voo.../doo' import os import genericpath def my_isdir(s): return genericpath.isdir('?\\' + os.path.abspath(s + '\\')) print 'os.walk(\'goo\') with standard isdir()' for root, dirs, files in os.walk('goo'): print root, dirs, files print 'os.walk(\'goo\') with modified isdir()' os.path.isdir = my_isdir for root, dirs, files in os.walk('goo'): print root, dirs, files yields os.walk('goo') with standard isdir() goo [] ['voo...'] os.walk('goo') with modified isdir() goo ['voo...'] [] goo\voo... [] ['doo'] About monkeypatching, generally -- thanks for the pointer to that discussion. That sounded like a lot of wisdom and lessons learned being shared. About me suggesting a patch -- I'll sleep on that :) Thanks Steven! John -- http://mail.python.org/mailman/listinfo/python-list
delay on windows when processing Pygame events
Greetings, I am writing a simple game for visually impaired in pygame. I use this construction: while running == True: for event in pygame.event.get(): if event.type == blahblahblah, #processing various events blahblahblah, contiuing the code after events are analysed I am looking mainly for keyboard events. I notice a quite nonnegligible lag when running this under Windows XP, when compared to the same code on Ubuntu 12.04. Python and pygame version should be the same: Python 2.7.3 pygame 1.9.1 Can anyone please help me? Thank you, Vojta -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing ISO date/time strings - where did the parser go?
On Tue, Sep 11, 2012 at 7:46 AM, Rhodri James rho...@wildebst.demon.co.uk wrote: On Sun, 09 Sep 2012 13:14:30 +0100, Roy Smith r...@panix.com wrote: In article mailman.323.1346961101.27098.python-l...@python.org, Thomas Jollans t...@jollybox.de wrote: The ISO date/time format is dead simple and well-defined. Well defined, perhaps. But nobody who has read the standard could call it dead simple. ISO-8601-2004(E) is 40 pages long. A short standard, then :-) What is it that takes up forty pages? RFC 2822 describes a date/time stamp in about two pages. In fact, the whole RFC describes the Internet Message Format in not much more than 40 pages. Is ISO-language just bloated? *boggle* ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: delay on windows when processing Pygame events
On 10 September 2012 23:25, Vojtěch Polášek krec...@gmail.com wrote: while running == True: for event in pygame.event.get(): if event.type == blahblahblah, #processing various events blahblahblah, contiuing the code after events are analysed I am looking mainly for keyboard events. I notice a quite nonnegligible lag when running this under Windows XP, when compared to the same code on Ubuntu 12.04. I do not have WinXP available, but if you want the best help from this board you should post the *exact* code that you are running. I don't think anyone has ever complained of code lasting a page or so (although any more and it becomes a bit of a chore :P). It does help. How are you sure that it is pygame.event.get() that is lagging? Have you tried while True: for e in pygame.event.get(): pass * or even while True: pygame.event.get()*? If you have not, would it not be something else? How are you measuring the lag and what type is it (late signals? program freezes?)? *Obviously you need to add code that tells you whether it's on time, but I'm not sure how you're doing that currently. I'm not saying this to be harsh and if I could I would look further into the question, but I am trying to ask what I would probably need to know if I did have a Windows installation. Or it could be a known bug. Eh. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing ISO date/time strings - where did the parser go?
In article mailman.473.1347317852.27098.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: On Tue, Sep 11, 2012 at 7:46 AM, Rhodri James rho...@wildebst.demon.co.uk wrote: On Sun, 09 Sep 2012 13:14:30 +0100, Roy Smith r...@panix.com wrote: In article mailman.323.1346961101.27098.python-l...@python.org, Thomas Jollans t...@jollybox.de wrote: The ISO date/time format is dead simple and well-defined. Well defined, perhaps. But nobody who has read the standard could call it dead simple. ISO-8601-2004(E) is 40 pages long. A short standard, then :-) What is it that takes up forty pages? RFC 2822 describes a date/time stamp in about two pages. In fact, the whole RFC describes the Internet Message Format in not much more than 40 pages. Is ISO-language just bloated? *boggle* You can find a copy at http://dotat.at/tmp/ISO_8601-2004_E.pdf -- http://mail.python.org/mailman/listinfo/python-list
a python license problem?
Python is under GPL compatible. If I develop a python code, convert it to executable and distribute the executable as a commercial software. May I need to make my source code open? If python is under GPL, is the answer different? Thanks a lot!! -- http://mail.python.org/mailman/listinfo/python-list
Re: a python license problem?
On Mon, Sep 10, 2012 at 7:58 PM, Jayden jayden.s...@gmail.com wrote: Python is under GPL compatible. If I develop a python code, convert it to executable and distribute the executable as a commercial software. May I need to make my source code open? If python is under GPL, is the answer different? Thanks a lot!! -- http://mail.python.org/mailman/listinfo/python-list GPL compatible is not a license. It's a quality of the license. Python's license is compatible with the GPL, which means that you can use Python in software licensed under the GPL Python's license (which is available at http://docs.python.org/license.html ) does not require Python code to be open source, nor does it prohibit commercial use. And even if Python was under the GPL, you would still be able to release your own programs without opening the source. You just wouldn't be able to modify Python without releasing your changes. That's how the userland in Mac OS X is still closed-source despite being compiled with GCC. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py
On Mon, 10 Sep 2012 15:22:05 -0700, ruck wrote: On Monday, September 10, 2012 1:16:13 PM UTC-7, Steven D'Aprano wrote: [...] That's not so much a workaround as the officially supported API for dealing with the situation you are in. Why don't you just prepend a '?' to paths like they tell you to? Good idea, but the first thing os.walk() does is a listdir(), and os.listdir() does not like the r'\\?\' prefix. In other words, os.walk(r'\\?\C:Users\john\Desktop\sandbox\goo') does not work. Now that sounds like a bug to me. If Microsoft officially support leading ? in file names, then so should Python on Windows. Also, your recipe worked for me -- I'm walking 'goo' which contains 'voo.../doo' Good for you. (Sorry, that comes across as more condescending than it is intended as.) Monkey-patching often gets used for quick scripts and tiny pieces of code because it works. Just beware that if you extend that technique to larger bodies of code, say when using a large framework, or multiple libraries, your experience may not be quite so good. Especially if *they* are monkey-patching too, as some very large frameworks sometimes do. (Or so I am lead to believe.) The point is not that monkey-patching is dangerous and should never be used, but that it is risky and should be used with caution. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
submit jobs on multi-core
Dear all, I have a python script in which I have a list of files to input one by one and for each file I get a number as an output. I used for loop to submit the file to script. My script uses one file at a time and returns the output. My computers has 8 cores. Is there any way that I could submit 8 jobs at a time and get all the output faster ? In other words, how can I modify my script so that I could submit 8 jobs together on 8 different processors ? I am bit new to this stuff, please suggest me some directions. Thank you. -- Joshi -- http://mail.python.org/mailman/listinfo/python-list
Re: submit jobs on multi-core
On 2012-09-11 06:16, Dhananjay wrote: Dear all, I have a python script in which I have a list of files to input one by one and for each file I get a number as an output. I used for loop to submit the file to script. My script uses one file at a time and returns the output. My computers has 8 cores. Is there any way that I could submit 8 jobs at a time and get all the output faster ? In other words, how can I modify my script so that I could submit 8 jobs together on 8 different processors ? I am bit new to this stuff, please suggest me some directions. You should first look at the multiprocessing module. It is part of the standard library. http://docs.python.org/library/multiprocessing.html -- http://mail.python.org/mailman/listinfo/python-list
[issue15890] lib2to3 pickles created with wrong permissions
Tomi Pieviläinen added the comment: Tomi, do you find a different behavior in 3.2? No, the behaviour is the same in 2.6-3.2: no compiled files have permissions for other than root, and all non-compiled files do (because install is run with -m 644). What made me report this bug was that 3.3rc1 does not have this behaviour: while the pickles had a bad timestamp, the permissions were just fine, so I assumed that someone had changed the this intentionally. Also this hasn't been a problem in Python2.x. I can install 2.6.8 and 2.7.3 from source without fixing any permissions, and still have a working Python installation. 3.2.3 requires chmoding the lib2to3 pickles, but no other compiled files need to be touched (it seems that they aren't really needed). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15890 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12947] doctest directive examples in library/doctest.html lack the flags
Chris Jerdonek added the comment: I discovered this today as well while reading the doctest documentation. One thing that I never noticed before (and that doesn't seem to be reflected in the comments above) is that many of the code snippet rectangles in the doctest documentation have a small rectangle in the upper-right corner with the text . If you click on one of these small rectangles, most of the text inside the code snippet rectangle disappears. I haven't confirmed this, but I suspect that it is the code snippets with a doctest directive that have this clickable corner. Is this a feature? What is it for? :) -- nosy: +cjerdonek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15898] OSX TTY bug
Ned Deily added the comment: Sorry, all I can tell you is that, for me, your test produces an empty string as output with either Python 2.7 or 3.3 and, if I remove the time.sleep() call or remove the os.close(slave), testing or btesting is output. I'm not sure what you believe the problem to be or what behavior you expect; you're covering a lot of ground here and much of it is very close to the OS. You are going to need to be a lot more specific than OSX TTY bug. You should describe exactly what failing behavior you observe with what component of Python, 2. how to reproduce it, and 3. exactly what behavior you expect of that component, and 4. if possible, the results of testing on another supported platform. Otherwise, it will be very difficult to help. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15676] mmap: add empty file check prior to offset check
Charles-François Natali added the comment: You forgot to add an entry in Misc/ACKS. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15676 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15888] ipaddress doctest examples have some errors
Chris Jerdonek added the comment: Attaching patch. The doctests for these three files now all pass (using a newer version of the patch I uploaded to issue 15629). -- keywords: +patch Added file: http://bugs.python.org/file27161/issue-15888-1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15888 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15898] OSX TTY bug
Martin v. Löwis added the comment: If you want to analyse this further, please provide dtruss -f output of the script. Most likely, this is a glitch in the operating system, but not a bug in Python. Unless you can provide more details, or a patch, we are likely to close this issue as works for me. -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15629] Add to regrtest the ability to run Lib and Doc doctests
Chris Jerdonek added the comment: I am attaching an updated version of the patch for feedback. The latest version of the patch I developed and used in the real-world example of fixing both the module and documentation file doctests for the ipaddress module (and its HOWTO) in issue 15888. The patch includes the following additional features: (1) the user is warned if a user-selected test file contains no tests (2) tests to run can be specified using one or more globs (e.g. fdoc:howto*) (3) the doc directory can be specified relatively (e.g. --docdir Doc) (4) passing --docall adds all doctests to the test run selection (5) passing --docunsafe runs doctests for all selected tests, whether or not the test files are marked doctest safe The patch also includes usage documentation towards the beginning. -- Added file: http://bugs.python.org/file27162/issue-15629-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15629 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15726] PyState_FindModule false length-comparison fix
Antoine Pitrou added the comment: Oops, sorry, that was a mistake. -- resolution: invalid - fixed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15726 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15899] howto/unicode.rst doctest corrections
New submission from Chris Jerdonek: This issue is to fix Doc/howto/unicode.rst so that its doctests pass when using the doctest module. Patch forthcoming. -- assignee: docs@python components: Documentation keywords: easy messages: 170167 nosy: cjerdonek, docs@python priority: normal severity: normal status: open title: howto/unicode.rst doctest corrections versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15899] howto/unicode.rst doctest corrections
Chris Jerdonek added the comment: Attaching patch for the default branch. -- keywords: +patch stage: - patch review Added file: http://bugs.python.org/file27163/issue-15899-1.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15899 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15896] Sporadic EINVAL in nonblocking pipe os.read when forked child fails on Mac OS
Changes by Denis Bilenko denis.bile...@gmail.com: -- nosy: +Denis.Bilenko ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15896 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15895] PyRun_SimpleFileExFlags() can leak a FILE pointer
Christian Heimes added the comment: No, that's not possible. 'fp' is part of the argument to PyRun_SimpleFileExFlags() and never NULL. We need some way to distinguish a externally provided fp from a self-opened fp and fclose(fp) in the latter case. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15895 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15873] datetime cannot parse ISO 8601 dates and times
Changes by Matej Cepl mc...@redhat.com: -- nosy: +mcepl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15900] Memory leak in PyUnicode_TranslateCharmap()
New submission from Christian Heimes: Objects/unicodeobject.c:PyUnicode_TranslateCharmap() leaks a reference to the variable unicode. PyUnicode_Translate() is also implemented around the helper function _PyUnicode_TranslateCharmap() but it properly decrefs the reference to the first argument. PyUnicode_Translate() also has an obsolete onError goto label. The patch fixes the leak and simplifies PyUnicode_Translate(). CID 719686 -- components: Interpreter Core files: translate_leak.patch keywords: 3.3regression, patch messages: 170170 nosy: christian.heimes priority: normal severity: normal status: open title: Memory leak in PyUnicode_TranslateCharmap() type: resource usage versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file27164/translate_leak.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15900 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15901] multiprocessing sharedctypes Array don't accept strings
New submission from Simon R: I've simply tested the example reported in the py3k documentation, and it don't works. See the site: http://docs.python.org/py3k/library/multiprocessing.html?highlight=multiprocessing#module-multiprocessing.sharedctypes The program exit with this error: python sha.py Traceback (most recent call last): File sha.py, line 21, in module s = Array('c', 'hello world', lock=lock) File /usr/lib/python3.2/multiprocessing/sharedctypes.py, line 112, in Array obj = RawArray(typecode_or_type, size_or_initializer) File /usr/lib/python3.2/multiprocessing/sharedctypes.py, line 89, in RawArray result.__init__(*size_or_initializer) TypeError: one character string expected Observe that the following code works correctly with python2! I'm using python 3.2.3 and gcc 4.7.1 under ArchLinx Te code is: http://docs.python.org/py3k/library/multiprocessing.html?highlight=multiprocessing#module-multiprocessing.sharedctypes from multiprocessing import Process, Lock from multiprocessing.sharedctypes import Value, Array from ctypes import Structure, c_double class Point(Structure): _fields_ = [('x', c_double), ('y', c_double)] def modify(n, x, s, A): n.value **= 2 x.value **= 2 s.value = s.value.upper() for a in A: a.x **= 2 a.y **= 2 if __name__ == '__main__': lock = Lock() n = Value('i', 7) x = Value(c_double, 1.0/3.0, lock=False) s = Array('c', 'hello world', lock=lock) A = Array(Point, [(1.875,-6.25), (-5.75,2.0), (2.375,9.5)], lock=lock) p = Process(target=modify, args=(n, x, s, A)) p.start() p.join() print((n.value)) print((x.value)) print((s.value)) print([(a.x, a.y) for a in A]) -- components: ctypes messages: 170171 nosy: bred priority: normal severity: normal status: open title: multiprocessing sharedctypes Array don't accept strings type: crash versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15901] multiprocessing sharedctypes Array don't accept strings
Richard Oudkerk added the comment: The documentation needs updating for Python 3 so that a byte string is used. So the line becomes s = Array('c', b'hello world', lock=lock) -- nosy: +sbt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15901] multiprocessing sharedctypes Array don't accept strings
Changes by Simon simone.r...@bluewin.ch: -- assignee: - docs@python components: +Documentation -ctypes nosy: +docs@python type: crash - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15828] imp.load_module doesn't support C_EXTENSION type
Paul Moore added the comment: The applied fix appears to have a regression - the file argument is not allowed to be None. The pywin32 post-install script calls imp.load_module for a C extension with file=None, so presumably this worked in earlier versions. The regression breaks the postinstall script for pywin32, meaning that the start menu shortcuts do not get installed. I do not know if it has any more serious consequences for pywin32. -- nosy: +pmoore ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15828 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15828] imp.load_module doesn't support C_EXTENSION type
Tim Golden added the comment: Paul, are you using the hg tip of pywin32? pywin32_postintall.py was patched a couple of months ago to use imp.load_dynamic (essentially to work around this issue). -- nosy: +tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15828 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15828] imp.load_module doesn't support C_EXTENSION type
Paul Moore added the comment: On 10 September 2012 11:47, Tim Golden rep...@bugs.python.org wrote: Tim Golden added the comment: Paul, are you using the hg tip of pywin32? pywin32_postintall.py was patched a couple of months ago to use imp.load_dynamic (essentially to work around this issue). No, this is the 217 release. Looks like they may need a new release then... Paul -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15828 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15828] imp.load_module doesn't support C_EXTENSION type
Nick Coghlan added the comment: Paul, could you please report that issue/question separately? If it's a regression, it's likely in the importlib migration in general and was hidden by this bug rather than being introduced by the fix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15828 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7358] cStringIO not 64-bit safe
Gilles Louppe added the comment: Hi, Any solution regarding that issue? We are currently encountering the exact same bug when pickling too large objects. Best, Gilles -- nosy: +Gilles.Louppe ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7358 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15902] imp.load_module won't accept None for the file argument for a C extension
New submission from Paul Moore: imp.load_module appears to have a regression - the file argument is not allowed to be None when loading a C_EXTENSION. The pywin32 post-install script for version 217 calls imp.load_module for a C extension with file=None, so presumably this worked in earlier versions. Note that apparently pywin32 tip no longer calls load_module in this way, and load_module is marked as deprecated in the documentation, so it is not clear if this issue actually needs fixing. See #15828 for some background. -- components: Library (Lib) keywords: 3.3regression messages: 170178 nosy: brett.cannon, georg.brandl, ncoghlan, pmoore priority: normal severity: normal status: open title: imp.load_module won't accept None for the file argument for a C extension type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15902 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15828] imp.load_module doesn't support C_EXTENSION type
Paul Moore added the comment: Logged as #15902. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15828 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15873] datetime cannot parse ISO 8601 dates and times
Roy Smith added the comment: I've started collecting some test cases. I'll keep adding to the collection. I'm going to start trolling ISO 8601:2004(E) for more. Let me know if there are other sources I should be considering. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15873] datetime cannot parse ISO 8601 dates and times
Roy Smith added the comment: Ooops, clicked the wrong button. -- Added file: http://bugs.python.org/file27165/test-cases.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15873 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15901] multiprocessing sharedctypes Array don't accept strings
Roundup Robot added the comment: New changeset ddb406904be1 by Richard Oudkerk in branch '3.2': Issue #15901: Change example to use byte string instead of string http://hg.python.org/cpython/rev/ddb406904be1 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15901] multiprocessing sharedctypes Array don't accept strings
Changes by Richard Oudkerk shibt...@gmail.com: -- resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15901 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15903] Make rawiobase_read() read directly to bytes object
New submission from Richard Oudkerk: Currently rawiobase_read() reads to a bytearray object and then copies the data to a bytes object. There is a TODO comment saying that the bytes object should be created directly. The attached patch does that. -- files: iobase_read.patch keywords: patch messages: 170183 nosy: sbt priority: normal severity: normal status: open title: Make rawiobase_read() read directly to bytes object Added file: http://bugs.python.org/file27166/iobase_read.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15903 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12947] doctest directive examples in library/doctest.html lack the flags
Ezio Melotti added the comment: Is this a feature? What is it for? :) The is added to every example that contains an interactive session to hide the '' and '...' prompts and the output and make the code copy/pastable, and it's not specific to doctests. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15902] imp.load_module won't accept None for the file argument for a C extension
Brett Cannon added the comment: How can you load a C extension without a file path? Are C extensions being inappropriately flagged as built-in modules on Windows? What does imp.find_module() return for the module being checked? I need more debugging info on what imp.find_module() and imp.load_module() returns in 3.2 and 3.3 before I can make a call on where the actual breakage is. -- status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15902 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15902] imp.load_module won't accept None for the file argument for a C extension
Paul Moore added the comment: It's the open file object argument, not the path. I assume that if you supplied None, the code opened the file for you. -- status: pending - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15902 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15881] multiprocessing 'NoneType' object is not callable
Richard Oudkerk added the comment: I see the same error on Windows (when pressing ^C), but on Linux I get Error in sys.exitfunc: Traceback (most recent call last): File /usr/lib/python2.7/atexit.py, line 28, in _run_exitfuncs import traceback File /usr/lib/python2.7/traceback.py, line 3, in module import linecache File /usr/lib/python2.7/linecache.py, line 9, in module import os File /usr/lib/python2.7/os.py, line 119, in module sys.modules['os.path'] = path AttributeError: 'module' object has no attribute 'modules' This also suggests that module teardown has begun before/while sys.exitfunc is running. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15881 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com