ANN: pypi-grep, grep a local file of PyPI info
An example first: pypi-grep 'pyqt' -- # day status packagename version homepage summary 2009-06-07 3 pydee 0.4.11 http://code.google.com/p/pydee/ Pydee development environment and its PyQt4-based IDE tools: ... 2009-06-05 4 Sandbox 0.9.5 http://www.qtrac.eu/sandbox.html A PyQt4-based alternative to IDLE ... pypi-grep is just a file with one long line per PyPI package, and a trivial bash script, basically egrep -i `newest pypi-grepfile*`. Why ? Grepping a local file is very fast and very simple, for old Unix guys and simple searches: what's XYZ ? hg clone http://bitbucket.org/denisb/pypi-grep/ should get pypi-grep and pypi-grepfile-2009-06-08 or the like; move them to a directory in your PATH. Notes: * the pypi-grepfile has only one version per package, the newest; multiline summaries are folded to one long line * pypi-grep -h lists the few options * the data comes from http://pypi.python.org/pypi xmlrpc, but beware: some packages in list_packages have no package_releases or no releasedata, and a few releasedatas timeout (timeout_xmlrpclib); what you see is All you get. * PyPI package names may contain blanks, even non-ascii * updates ? dunno, ask me -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Jython 2.5.0 Release Candidate 4 is out!
On behalf of the Jython development team, I'm pleased to announce that Jython 2.5rc4 is available for download: http://downloads.sourceforge.net/jython/jython_installer-2.5rc4.jar See http://www.jython.org/Project/installation.html for installation instructions. This is the fourth and probably final release candidate of the 2.5.0 version of Jython. If no major bugs are found in rc4, we will relabel it as 2.5.0 final. With this version, all of the regression tests that we follow on Windows now pass. Please try this out and report any bugs that you find: http://bugs.jython.org -Frank -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: unladen swallow: python and llvm
On 8 Jun., 00:31, bearophileh...@lycos.com wrote: ShedSkin (SS) is a beast almost totally different from CPython, SS compiles an implicitly static subset of Python to C++. So it breaks most real Python programs, and it doesn't use the Python std lib (it rebuilds one in C++ or compiled Python), and so on. SS may be useful for people that don't want to mess with the intricacies of Cython (ex-Pyrex) and its tricky reference count, to create compiled python extensions. Don't understand your Cython compliant. The only tricky part of Cython is the doublethink regarding Python types and C types. I attempted once to write a ShedSkin like code transformer from Python to Cython based on type recordings but never found the time for this because I have to work on EasyExtend on all fronts at the same time. Maybe next year or when Unladen Swallow becomes a success - never. The advantage of this approach over ShedSkin was that every valid Cython program is also a Python extension module, so one can advance the translator in small increments and still make continuous progress on the execution speed front. -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
On Sun, 2009-06-07 at 16:40 -0600, Brian wrote: On Fri, Jun 5, 2009 at 3:29 AM, Nick Craig-Wood n...@craig-wood.com wrote: It is an interesting idea for a number of reasons, the main one as far as I'm concerned is that it is more of a port of CPython to a new architecture than a complete re-invention of python (like PyPy / IronPython / jython) so stands a chance of being merged back into CPython. Blatant fanboyism. PyPy also has a chance of being merged back into Python trunk. How? I believe that unladen swallow has already had many of it's optimisations back-ported to CPython, but I can't see how backporting a python interpreter written in python into C is going to be as easy as merging from Unladen swallow, which is (until the llvm part) a branch of CPython. Personally, I think that PyPy is a much better interpreter from a theoretical point of view, and opens up massive possibilities for writing interpreters in general. Unladen Swallow on the other hand is something we can use _now_ - on real work, on real servers. It's a more interesting engineering project, and something that shouldn't require re-writing of existing python code. Tim W -- http://mail.python.org/mailman/listinfo/python-list
Re: how to transfer my utf8 code saved in a file to gbk code
Thank you Mark, that works. Firstly using 'string-escape' to decode the content is the key point,so I can get the Chinese characters now. Regards, -higer -- http://mail.python.org/mailman/listinfo/python-list
Re: Making the case for repeat
On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: We factor code to eliminate redundancy, but that is not always a good idea with an API. The goal for code factoring is to minimize redundancy. The goal for API design is having simple parts that are easily learned and can be readily combined (i.e. the notion of an iterator algebra). Wonderfully said! That has articulated something which I only recently came to appreciate, but couldn't put into words. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Making the case for repeat
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: We factor code to eliminate redundancy, but that is not always a good idea with an API. The goal for code factoring is to minimize redundancy. The goal for API design is having simple parts that are easily learned and can be readily combined (i.e. the notion of an iterator algebra). Wonderfully said! That has articulated something which I only recently came to appreciate, but couldn't put into words. As originally defined by Martin Fowler, re-factoring always means the external behaviour is unchanged URL:http://refactoring.com/. So, there's no such thing as a re-factoring that changes the API. Anything that changes an external attribute of the code is a different kind of transformation, not a re-factoring. -- \ “Better not take a dog on the space shuttle, because if he | `\ sticks his head out when you're coming home his face might burn | _o__)up.” —Jack Handey | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: multi-core software
By the way, there is a series of articles about concurrency on ACM Queue which may be interesting for those participating in or just following this discussion: http://queue.acm.org/listing.cfm?item_topic=Concurrencyqc_type=theme_listfilter=Concurrencypage_title=Concurrency Here is one introductory paragraph from one of the articles: Parallel programming poses many new challenges to the developer, one of which is synchronizing concurrent access to shared memory by multiple threads. Programmers have traditionally used locks for synchronization, but lock-based synchronization has well-known pitfalls. Simplistic coarse-grained locking does not scale well, while more sophisticated fine-grained locking risks introducing deadlocks and data races. Furthermore, scalable libraries written using fine-grained locks cannot be easily composed in a way that retains scalability and avoids deadlock and data races. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Making the case for repeat
On Jun 8, 9:30 am, Ben Finney ben+pyt...@benfinney.id.au wrote: [...] As originally defined by Martin Fowler, re-factoring always means the external behaviour is unchanged URL:http://refactoring.com/. So, there's no such thing as a re-factoring that changes the API. Anything that changes an external attribute of the code is a different kind of transformation, not a re-factoring. ... and Steven was not calling the two things by the same name. He, and Raymond, were distinguishing between refactoring, and API design. That was their point, I think. Jon N -- http://mail.python.org/mailman/listinfo/python-list
Re: Making the case for repeat
On Mon, 08 Jun 2009 18:30:37 +1000, Ben Finney wrote: Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Sun, 07 Jun 2009 16:46:23 -0700, Raymond Hettinger wrote: We factor code to eliminate redundancy, but that is not always a good idea with an API. The goal for code factoring is to minimize redundancy. The goal for API design is having simple parts that are easily learned and can be readily combined (i.e. the notion of an iterator algebra). Wonderfully said! That has articulated something which I only recently came to appreciate, but couldn't put into words. As originally defined by Martin Fowler, re-factoring always means the external behaviour is unchanged URL:http://refactoring.com/. So, there's no such thing as a re-factoring that changes the API. Anything that changes an external attribute of the code is a different kind of transformation, not a re-factoring. Possibly a *factoring*, without the re-, just like Raymond said. Also, keep in mind that when creating a new API, you have no existing API to re-factor. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Making the case for repeat
Possibly a *factoring*, without the re-, just like Raymond said. Also, keep in mind that when creating a new API, you have no existing API to re-factor. Exactly. I think this has come up before, but I can't remember the answers; any suggestions for pointer to examples of very well-designed APIs, and maybe some background as to how the design was achieved? Thanks jon N -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
Kay Schluehr: Don't understand your Cython compliant. The only tricky part of Cython is the doublethink regarding Python types and C types. I attempted once to write a ShedSkin like code transformer from Python to Cython based on type recordings but never found the time for this because I have to work on EasyExtend on all fronts at the same time. I have tried to create a certain data structure with a recent version of Pyrex on Windows, and I have wasted lot of time looking for missing reference count updates that didn't happen, or memory that didn't get freed. The C code produced by ShedSkin is a bit hairy but it's 50 times more readable than the C jungle produced by Pyrex, where I have lost lot of time looking for the missing reference counts, etc. In the end I have used D with Pyd to write an extension in a very quick way. For me writing D code is much simpler than writing Pyrex code. Never used Pyrex ever since. I'm sure lot of people like Cython, but I prefer a more transparent language, that doesn't hide me how it works inside. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
On Jun 7, 6:13 pm, Paul Rubin http://phr...@nospam.invalid wrote: Aaron Brady castiro...@gmail.com writes: url+= { '/': '' }.get( url[ -1 ], '/' ) Shorter is always better. url = url.rstrip('/') + '/' I was joking. Sheesh. -- http://mail.python.org/mailman/listinfo/python-list
urllib2.URLError: urlopen error unknown url type: 'http error using twill with python
Hi I wonder if someone could point me in the right direction. I used the following code to access gmail but I got a urllib2.URLError: urlopen error unknown url type: 'http error when I ran it. I have included the Traceback import twill, string, os b=twill.commands.get_browser() b.set_agent_string(Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14) b.clear_cookies() b.go('http://www.gmail.com') f=b.get_form(1) b.showforms() f['Email']= email f['Passwd'] =password b.clicked(f, f) b.submit() When I run the code I get: Traceback (most recent call last): File stdin, line 1, in ? File /home/mdevine/qa/aqa/mfe/site-packages/twill/browser.py, line 115, in go self._journey('open', u) File /home/mdevine/qa/aqa/mfe/site-packages/twill/browser.py, line 540, in _journey r = func(*args, **kwargs) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 156, in open return self._mech_open(url, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 182, in _mech_open response = UserAgentBase.open(self, request, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 191, in open response = meth(req, response) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py, line 573, in http_response response = self.parent.error( File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 208, in error result = apply(self._call_chain, args) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py, line 129, in http_error_302 return self.parent.open(new) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 156, in open return self._mech_open(url, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 182, in _mech_open response = UserAgentBase.open(self, request, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 191, in open response = meth(req, response) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py, line 573, in http_response response = self.parent.error( File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 208, in error result = apply(self._call_chain, args) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py, line 129, in http_error_302 return self.parent.open(new) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 156, in open return self._mech_open(url, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 182, in _mech_open response = UserAgentBase.open(self, request, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 191, in open response = meth(req, response) File /home/mdevine/qa/aqa/mfe/site-packages/twill/utils.py, line 455, in http_response refresh, msg, hdrs) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 208, in error result = apply(self._call_chain, args) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_http.py, line 129, in http_error_302 return self.parent.open(new) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 156, in open return self._mech_open(url, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_mechanize.py, line 182, in _mech_open response = UserAgentBase.open(self, request, data) File /home/mdevine/qa/aqa/mfe/site-packages/twill/other_packages/mechanize/_opener.py, line 180, in open response = urlopen(self, req, data) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 381, in _open 'unknown_open', req) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /opt/ams/mdevine/lib/python2.4/urllib2.py, line 1053, in unknown_open raise URLError('unknown url type: %s' % type) urllib2.URLError: urlopen error unknown url type: 'http Thanks M -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint naming conventions?
Hi David, David Stanek wrote: It is my understanding that it does check for PEP8 names. Even if it doesn't it is really easy to change. If you run 'pylint --generate-rcfile' (i think) it will output the configuration that it is using. You can then save this off and customize it. Thanks, I'll see if I can customize it this way. I looked at it once briefly. I'll try to come up with a nice short code example in the next few days to demonstrate what I think the problem is and post it, thanks for the suggestion. If you didn't have an example handy what prompted you to start this thread? :-) I have had number of examples, but they are rather long, so I think it will be better if I can provide a short example with the (rather lengthy pylint) output that shows the problem. I thought lots of people are using pylint and I would hear one way or the other about the name checks (ie people agreeing or telling me I'm way off :) .. in which case perhaps my recollection/reading of PEP 8 is not accurate. Esmail -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint naming conventions?
Ben Finney wrote: My understanding of Esmail's original message was that, like many of us on first running ‘pylint’ against an existing code base, the output is astonishingly verbose and tedious to read. By the above I presume he's being a good forum member and trying to find a minimal example that shows the problem clearly :-) Yes, that is my intention .. because the code I was checking was rather long, combined with the long pylint output it would make for a rather big posting. I'm going to go back and re-read PEP 8 and see if I perhaps don't recall the right guidelines since no one else here seems to have had the same observation. Esmail -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2.URLError: urlopen error unknown url type: 'http error using twill with python
On Mon, 08 Jun 2009 12:14:18 +0100, Mark Devine wrote: Hi I wonder if someone could point me in the right direction. I used the following code to access gmail but I got a urllib2.URLError: urlopen error unknown url type: 'http error when I ran it. I have included the Traceback import twill, string, os b=twill.commands.get_browser() b.set_agent_string(Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14) b.clear_cookies() b.go('http://www.gmail.com') f=b.get_form(1) b.showforms() f['Email']= email f['Passwd'] =password b.clicked(f, f) b.submit() My bet is that the above is not the actual code you have run. I bet that the offending line is actually something like the following: b.go('http://www.gmail.com;) Note that there is a single character difference. Consider the last two lines of the traceback: raise URLError('unknown url type: %s' % type) urllib2.URLError: urlopen error unknown url type: 'http It seems to be saying that the url type is 'http -- note the leading single quote. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: 403 error for python webpage
2009/6/7 Daniel danwgr...@gmail.com I created a page with a .py extension but the browser does not like it. Here is what I did: I edited httpd.conf file and added the line: AddHandler cgi-script .cgi .py Then I stopped and restarted apache. Next I created a hello world file as on this page: http://deron.meranda.us/python/webserving/helloworld.html I stored the file in htdocs and then went to the corresponding http://127.0.0.1/python/testhw.py in my browser. But the browser gives a 403 error. I am running from internet explorer on windows xp. -- http://mail.python.org/mailman/listinfo/python-list This sounds like an setup problem for Apache + CGI. You should study the Apache logs. Don't know their location in WIN32, in Linux there are some files named error_log and also access_log. Typically, Apache writes the reason for error messages there. BR, Roland -- http://mail.python.org/mailman/listinfo/python-list
Re: Python preprosessor
R. David Murray wrote: Tuomas Vesterinen tuomas.vesteri...@iki.fi wrote: I am developing a Python application as a Python2.x and Python3.0 version. A common code base would make the work easier. So I thought to try a preprosessor. GNU cpp handles this kind of code correct: test_cpp.py #ifdef python2 print u'foo', u'bar' #endif #ifdef python3 print('foo', 'bar') #endif end code results: cpp -E -Dpython2 test_cpp.py ... print u'foo', u'bar' Any other suggestions? There's a Google Summer of Code project to create a 3to2 processor. That would let you maintain the code in 3.x, and have it automatically translated on demand so that it will run under 2.x (where x goes back to at least 5, I think, but I'm not sure). Of course, it isn't finished yet, so it won't do you any good right at the moment :( -- R. David Murray http://www.bitdance.com IT ConsultingSystem AdministrationPython Programming I found also a ready made py3to2-tool (test/develop/integrate python 3.0 code natively under robust, software-rich python 2.5 environment) at: http://code.activestate.com/recipes/574436/ It seems so complicated that I don't dare to try before some more experienced people has commented it. TV -- http://mail.python.org/mailman/listinfo/python-list
Re: Python preprosessor
Roger Binns wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tuomas Vesterinen wrote: I am intensively using 2to3.py. So I have 2 codebase: one in py2 and the other in py3. The expectation would be that you only maintain the py2 code and automatically generate the py3 code on demand using 2to3. It is possible to have the same code run under both versions, but not recommended. As an example I do this for the APSW test suite, mostly because the test code deliberately explores various corner cases that 2to3 could not convert (nor should it try!). Here is how I do the whole Unicode thing: if py3: # defined earlier UPREFIX= else: UPREFIX=u def u(x): # use with raw strings return eval(UPREFIX+'''+x+''') # Example of use u(r\N${BLACK STAR}\u234) You can pull similar stunts for bytes (I use buffers in py2), long ints (needing L suffix in some py2 versions), the next() builtin from py3, exec syntax differences etc. You can see more details in the first 120 lines of http://code.google.com/p/apsw/source/browse/apsw/trunk/tests.py Roger -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkosTxEACgkQmOOfHg372QS4rQCgl1ymNME2kdHTBUoc7/f2e+W6 cbMAmwf7mArr7hVA8k/US53JE59ChnIt =pQ92 -END PGP SIGNATURE- You have interesting solutions. TV -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
2009/6/8 Aaron Brady castiro...@gmail.com On Jun 7, 6:13 pm, Paul Rubin http://phr...@nospam.invalid wrote: Aaron Brady castiro...@gmail.com writes: url+= { '/': '' }.get( url[ -1 ], '/' ) Shorter is always better. url = url.rstrip('/') + '/' I was joking. Sheesh. -- http://mail.python.org/mailman/listinfo/python-list my two cents: a solution based on regex: the pattern replaces all slashes at the end of the string with a single one. The * usage matches also the empty group of slashes (example s2) print s1 a/ print s2 re.sub('[/]*$','/', s1) 'a/' re.sub('[/]*$','/', s2) '/' -Roland -- http://mail.python.org/mailman/listinfo/python-list
Re: spammers on pypi
On Jun 5, 1:39 pm, joep josef.p...@gmail.com wrote: Is there a way to ban spammers from pypi? Can you provide some examples? It's possible that we can apply SpamBayes to PyPI submissions in much the same way that we apply it in other non- mail areas. Thx, Skip Montanaro -- http://mail.python.org/mailman/listinfo/python-list
Wrapping LabVIEW and DAQmx Libraries for Python
All, I've started wrapping the DAQmx and other LabVIEW libraries for python using ctypes. I really like doing some things in python and other in LabVIEW, so I'd like to have the same functionality available for both. I've hosted the tiniest bit of code (mostly just proof of concept) on github. Let me know if anyone else would be interested in this. I'd love some help hashing it out. - Ken http://github.com/erdosmiller/pydaqmx/tree/master -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
bearophile I'm sure lot of people like Cython, but I prefer a more bearophile transparent language, that doesn't hide me how it works bearophile inside. Why not just write extension modules in C then? -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ America's vaunted free press notwithstanding, story ideas that expose the unseemly side of actual or potential advertisers tend to fall by the wayside. Not quite sure why. -- Jim Thornton -- http://mail.python.org/mailman/listinfo/python-list
Re: interval arithmetic libraries
On Jun 6, 8:15 am, srepmub mark.duf...@gmail.com wrote: Hi all, I'm looking for libraries that allow one to calculate with sets of (date) intervals. So for example, I'd like to be able to calculate the overlap between two sets of intervals, the union etc. Preferrably, this works with datetime objects, is written in pure Python, and has reasonably good (algorithmic) performance. The neatest library I've found so far is this one: http://members.cox.net/apoco/interval/ From an API standpoint, it looks rather nice, but the performance could be better (for example, calculating an overlap now involves looping quadratically over both interval sets), and it doesn't work fully with datetime objects (Inf doesn't work). Thanks for any pointers, Mark Dufour. (author of Shedskin, an experimental (restricted-)Python-to-C++ compiler,http://shedskin.googlecode.com) For some pointers look at this thread where I posted a similar question: http://groups.google.com/group/comp.lang.python/browse_frm/thread/1a1d2ed9d05d11d0/56684b795fc527cc#56684b795fc527cc I am surprised that libraries to do that are not more common. I guess everybody rolls his own. -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
On 8 Jun, 12:13, bearophileh...@lycos.com wrote: The C code produced by ShedSkin is a bit hairy but it's 50 times more readable than the C jungle produced by Pyrex, where I have lost lot of time looking for the missing reference counts, etc. The C++ code produced by Shed Skin can actually provide an explicit, yet accurate summary of the implicit type semantics present in a program, in the sense that appropriate parameterisations of template classes may be chosen for the C++ program in order to model the data structures used in the original program. The analysis required to achieve this is actually rather difficult, and it's understandable that in languages like OCaml that are widely associated with type inference, one is encouraged (if not required) to describe one's types in advance. People who claim (or imply) that Shed Skin has removed all the dynamicity from Python need to look at how much work the tool still needs to do even with all the restrictions imposed on input programs. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: multi-core software
rossb...@mpi-sws.org wrote: On Jun 8, 6:28 am, Ken T. nowh...@home.com wrote: Let's not forget Elite for the 6502 exploiting predictable performance in order to switch graphics modes partway down the vsync! That actually didn't require predictable timing. You could tell the video chip to send you an interrupt when it got to a given scan line. I used this myself. I don't know what Elite did, but I know for sure that it was a common trick on the Atari ST to switch color palettes or graphics mode at a fixed point *in each single scan line* to get more colors, or display graphics on the screen borders. That required synchronous programming, i.e. counting clock cycles of machine instructions such that for every point in the program you knew exactly where the electron ray would be. The Atari ST had an M68000 with exactly 8 MHz, which made this possible. There were no caches in those times, and clock cycles were entirely predictable. The usual trick for these machines was an exact multiple of the NTSC color clock, which was approx 3.58 MHz. The 8-bit atari video games and home computers all used this technique, as did the C-64/128. 68000-based machines (such as the ST and the Amiga) could not only exploit that synchrony, they could also (this was the days before memory wall) exploit the fact that a 680x0 typically accessed memory only once every 4 clock cycles to do DMA from the same memory when the CPU wasn't using it. High display resolutions would lock the processor out of RAM except during blanking intervals. (Talk about contention and hot spots.) Figuring out how to reuse resources most effectively was pretty much the same as the register-allocation problem for compilers, and was sometimes solved using the same kinds of graph-coloring algorithms... -- http://mail.python.org/mailman/listinfo/python-list
10 Easy Steps to Speed Up Your Computer - Without Upgrading
It seems that the longer you own your computer, the slower it gets! A lot of people will keep their computer until it gets so slow that they feel they need a newer, faster model. Some feel like the reason it is getting slower is because it is getting older, when that is just not the case. Your computer should run just as fast as the day you brought it home if you follow these 10 Easy Steps to Speed Up Your Computer. 1. Empty the Temp directory regularly. After a short while, the temp directory fills up with hundreds of temp files that always get scanned over when Windows starts up and when programs launch. This slows everything down immensely. Rule of thumb for Temp Files: If you dont have any programs open (and nothing minimized in the bar below), then you shouldnt have ANY temp files in your temp directory. If you do, delete them. To delete Temp files, make sure NO programs are open, and a. In Windows 95, 98 or Me, go to C:WindowsTemp and delete everything inside the Temp folder. b. In Windows 2000 or XP, it is a little trickier. First, make sure that you can see hidden folders. Double-click My Computer. Click on the Tools pull-down menu, and then on Folder Options. Click on the View tab. Scroll down and click on Show Hidden Files and Folders. Click Ok. Now you can go to the C:Documents and SettingsAdministratorLocal SettingsTemp folder. Delete everything here. 2. Empty the Temporary Internet Files regularly. To empty Temporary Internet Files, go to your Control Panel and double-click the Internet Options icon. Choose to Delete Cookies, and to Delete Files. This will clear all of your Temporary Internet Files. 3. Check your hard disks for problems. a. For Windows 95, 98, or Me, double-click My Computer. Right-click the C-drive and click on Properties. Click on the Tools tab and choose to check the computer for problems. If you choose to do a Thorough Scan, this will do the hardware check for physical disk damage or sector damage. Choose to fix any errors it finds. b. For Windows 2000 and XP, double-click My Computer. Right-click the C-drive and click Properties. Click on the Tools tab and choose to check the computer for problems. Click on Check Now. You will then have two check boxes. The top option is for the file check, and the second option is for the hardware (physical disk) check. Check either one, or both. At least check the top one. Hit ok, and reboot. This may take some time, but let it run. 4. An even more thorough disk check, would be to use a 3rd party utility. One of my favorites is TuneUp Utilities 2004. It does cost $39.99, but they do offer a FREE download trial of 15 days. This program does a really good job of fixing software and physical hard drive problems. It also tunes up your system for increased speed, and streamlines your operating system for peak performance. Download it HERE... http://www.lapeertechgroup.com/downloads.asp 5. Or, you can do a few of the performance tweaks yourself, if you have Windows XP. By default, EVERYTHING is turned on in Windows XP. It isnt very streamlined for performance, but rather for appearance. You can turn off a few of the unnecessary features, and Windows will still work just fine, and maybe a little faster. To do this, right-click on My Computer and click on Properties. Click on the Advanced tab. Under the Performance section, click on the Settings button. On the Visual Effects tab, you will see a list of check boxes. By default, these are all on. You really dont need any of them for Windows to run. Go through the check boxes one by one, and determine which ones you can and cant live without. 6. Turn off Active Desktop. Active Desktop turns your desktop into a web page, and allows you to have things like a real-time calendar, and up-to-the-minute weather or stocks. These are nice, but really slow down your computer. And even if you dont use Active Desktop for anything, just having it active can cause a performance decrease. Turn it off. a. In Windows 95, 98 and Me, right-click on the desktop and in the pop- up menu, choose Active Desktop. Inside that option, uncheck Active Desktop. If there is no check next to it, then it isnt on. Dont choose it. Instead, just click the desktop again to get out of the menu. b. In Windows 2000, right-click on the desktop and in the pop-up menu, choose Active Desktop. Inside that option, uncheck Show Web Content. Again, if there is no check next to it, then it is not on. Do not check it. c. In Windows XP, right-click on the desktop and in the pop-up menu, choose Properties. On the Desktop tab, choose Customize Desktop. Now, on the Web tab, make sure that there are no websites chosen here. If there arent any, then Active Desktop is not on. Cancel and go back to the desktop. 7. Install and run a good AntiVirus program to keep out viruses that can take over your system. One of my favorites is AVG. It is not only a really good AntiVirus program, but it is also FREE! If you dont have any AntiVirus
Career Track: Computer Programmer
Roles and Responsibilities : The primary role of a Computer Programmer is to write programs according to the instructions determined primarily by computer software engineers and systems analysts. In a nutshell, Computer Programmers are the ones that take the completed designs and convert them into the instructions that the computer can actually follow. The instructions are coded into a programming language. In some cases, programmers are also expected to know platform specific languages used in database programming. Many programmers at the enterprise level are also expected to know platform-specific languages used in database programming. Responsibilities include updating; repairing, modifying and expanding existing programs as well as running tests to authenticate that the program will produce the desired outcome. Applications Programmers are the ones that actually write programs to handle very specific jobs, revise existing software or customize generic applications while Systems Programmers write programs to maintain and control computer systems software such as operating systems, database and/or networked systems. In some smaller organizations, the programmers may also be responsible for systems analysis and the actual programming. In many cases, however, technology is replacing the need to write basic code which doesn't bode well for those considering entering the field. According to the U.S. Department of Labor, however, the demand for programmers with strong object-oriented programming capabilities and technical specialization in areas such as client/server programming, wireless applications, multimedia technology, and graphic user interface (GUI) should arise from the expansion of intranets, extranets, and Internet applications. Programmers also will be needed to create and maintain expert systems and embed these technologies in more products. Finally, growing emphasis on cyber-security will lead to increased demand for programmers who are familiar with digital security issues and skilled in using appropriate security technology. Advancement Opportunities : The advancement opportunities for computer Programmers are many and usually start with a promotion to a Lead Programmer. A Lead Programmer position will more than likely include supervisory duties. System programming is usually the next career step for Computer Programmers who have completed systems software courses. Programmer Analysts and Systems Analysts are also logical steps. Many programmers are also finding that independent contracting and consulting gives them the freedom to pick and choose their projects. Advancement Opportunities : The advancement opportunities for computer Programmers are many and usually start with a promotion to a Lead Programmer. A Lead Programmer position will more than likely include supervisory duties. System programming is usually the next career step for Computer Programmers who have completed systems software courses. Programmer Analysts and Systems Analysts are also logical steps. Many programmers are also finding that independent contracting and consulting gives them the freedom to pick and choose their projects. Educational Requirements : Although required skills and training will vary dependent upon the position and industry in which you're working, the demand for skill sets is even more driven by technological changes. In some positions, graduate degrees may be required. While traditional language knowledge is still important, C++ and Java are the programming languages of choice. GUI and systems programming skills are also sought after. In addition, general business skills will be an asset in any organization. Systems programmers usually need a 4-year degree in computer science and extensive knowledge of a variety of operating systems. They are usually also expected to be proficient in database systems such as DB2, Sybase and/or Oracle. Salary Potential : (As reported by the U.S. Dept. of Labor) Position Salary Range (2003) Median Average Earnings $60.290 Starting salary for graduates with B.A. in Computer Programming $45,558 Salary range for Applications Development Programmers $51,500 - $80,500 Salary range for Software Developers $55,000 - $87,750 Salary range for Mainframe Programmers $53,250 - $68,750 for more information about programming and computers visit http://tips-made-easy.info/computer -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
Aaron Brady wrote: Shorter is always better. url+= { '/': '' }.get( url[ -1 ], '/' ) Why bother with spaces or 3 letter-wide token, check this :o) : x+={'/':''}.get(x[-1],'/') Apart from joking, the following proposed solution is by **far** the one I prefer if not url.endswith('/'): url += '/' Maybe not the shorter, but the most concise and clear to me. Jean-Michel -- http://mail.python.org/mailman/listinfo/python-list
is there python image lib that does imagemagick?
is there a python image library that does pretty much what imagemagick does? all i need is for converting png/jpg, and scaling images. No need other fancy things imagemagick does. i know there's a python wrapper for imagemagick, but i need independent ones that doesn't require shell calls. Basically i have a python script that works in os x that process a dir of html files and generate thumbnails. I'm porting to Windows and wish to get rid of imagemagick dependence. Thanks. Xah ∑ http://xahlee.org/ ☄ -- http://mail.python.org/mailman/listinfo/python-list
Re: The pysync library - Looking for the code, but all download links are broken
Thanks for the help. I will let the community know as soon as I have salvaged a working copy. Cheers //Jan Persson On 7 Juni, 23:06, Søren - Peng - Pedersen pengmeis...@gmail.com wrote: I think what you are looking for can be found at: http://www.google.com/codesearch/p?hl=en#RncWxgazS6A/pysync-2.24/test... orhttp://shortlink.dk/58664133 I am not affiliated with the project in any way, and I can't find a way to download the entire thing in one go. So if you do salvage a working copy please let me (and the rest of the community) know. //Søren - Peng - Pedersen -- http://mail.python.org/mailman/listinfo/python-list
Re: GD Library
On 2009-06-08, Xah Lee xah...@gmail.com wrote: is there a python image library that does pretty much what imagemagick does? GD library has a Python binding: http://www.libgd.org/Main_Page -- http://mail.python.org/mailman/listinfo/python-list
Re: is there python image lib that does imagemagick?
On Mon, 08 Jun 2009 08:13:37 -0700, Xah Lee wrote: is there a python image library that does pretty much what imagemagick does? Python Imaging Library (PIL). http://pypi.python.org/pypi/PIL/1.1.6 -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL Python Imaging Library
On 2009-06-08, Xah Lee xah...@gmail.com wrote: is there a python image library that does pretty much what imagemagick does? http://www.pythonware.com/products/pil/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Get the class name
Kless wrote: Is there any way of to get the class name to avoid to have that write it? --- class Foo: super(Foo, self) --- * Using Py 2.6.2 The question does not make sense: to have WHAT write WHAT, and the code is wrong: the call to super fails But even so, perhaps this will answer your question class Foo: ... pass ... print Foo.__name__ Foo c = Foo print c.__name__ Foo ob = Foo() print ob.__class__.__name__ Foo Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
Jean-Michel Pichavant wrote: Aaron Brady wrote: Shorter is always better. url+= { '/': '' }.get( url[ -1 ], '/' ) Why bother with spaces or 3 letter-wide token, check this :o) : x+={'/':''}.get(x[-1],'/') Even shorter: x+='/'*(x[-1]!='/') Apart from joking, the following proposed solution is by **far** the one I prefer if not url.endswith('/'): url += '/' Maybe not the shorter, but the most concise and clear to me. Definitely. -- http://mail.python.org/mailman/listinfo/python-list
problems while using pexpect: pexcept.TIMEOUT always
I have been trying to use pexpect and I am failing with pexpect.TIMEOUT for all my attempts. In order to troubleshoot, I decided to go with simplest possible one. Here is my ssh to localhost: [21:29:14 senthil]$ssh localhost -l senthil sent...@localhost's password: sent...@ubuntu:~$ And here is my pexpect script: http://paste.pocoo.org/show/121788/ And the output I get is: True None None Traceback (most recent call last): File 4.py, line 17, in module print child.read() File /usr/local/lib/python2.6/site-packages/pexpect.py, line 858, in read self.expect (self.delimiter) # delimiter default is EOF File /usr/local/lib/python2.6/site-packages/pexpect.py, line 1311, in expect return self.expect_list(compiled_pattern_list, timeout, searchwindowsize) File /usr/local/lib/python2.6/site-packages/pexpect.py, line 1325, in expect_list return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize) File /usr/local/lib/python2.6/site-packages/pexpect.py, line 1409, in expect_loop raise TIMEOUT (str(e) + '\n' + str(self)) pexpect.TIMEOUT: Timeout exceeded in read_nonblocking(). Complete Traceback is here: http://paste.pocoo.org/show/121790/ Can someone help me what I am doing wrong here? Why is not working for such a simple thing as ssh to my localhost.? I am getting the same problem while trying to login to remote host also. Thanks, Senthil -- http://mail.python.org/mailman/listinfo/python-list
Extract value and average
I come 'naked', which is unusual and unfair. However, I find it difficult to give a correct start. The files consist, among other things, of a huge number of blocks of the type NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS =89.4 Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905 BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS= 19047.1551 EELEC = -218354.9960 EHBOND = 0. RESTRAINT = 3.7793 EAMBER (non-restraint) = -176251.1698 EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME =669299.5681 Density= 0.9896 Ewald error estimate: 0.8252E-05 (in attachment what surely is a correct reproduction of columns) I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. Thanks for giving a possible attack francesco pietra NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS =89.4 Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905 BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS= 19047.1551 EELEC = -218354.9960 EHBOND = 0. RESTRAINT = 3.7793 EAMBER (non-restraint) = -176251.1698 EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME =669299.5681 Density= 0.9896 Ewald error estimate: 0.8252E-05 -- http://mail.python.org/mailman/listinfo/python-list
Re: pyc-files contains absolute paths, is this a bug ?
Stef Mientki wrote: hello, AFAIK I read that pyc files can be transferred to other systems. I finally got a windows executable working through py2exe, but still have some troubles, moving the directory around. I use Python 2.5.2. I use py2exe to make a distro I can unpack the distro, on a clean computer, anywhere where I like, and it runs fine. Now when I've run it once, I move the subdirectory to another location, at it doesn't run. Looking with a hex editor into some pyc-files, I see absolute paths to the old directory. It is normal, because they refer to the location of the source-files, which are needed for stacktraces (or at least something like that) But execution itself is independent from this. Is this normal, or am I doing something completely wrong ? Dunno anything about py2exe, but it sure sounds a bit awkward what you do - changing locations of files after installation is calling for trouble in lots of software. But I might not have understood what you actually did - and doesn't run isn't helping much in that regard. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
Francesco Pietra wrote: I come 'naked', which is unusual and unfair. However, I find it difficult to give a correct start. The files consist, among other things, of a huge number of blocks of the type NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS =89.4 Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905 BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS= 19047.1551 EELEC = -218354.9960 EHBOND = 0. RESTRAINT = 3.7793 EAMBER (non-restraint) = -176251.1698 EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME =669299.5681 Density= 0.9896 Ewald error estimate: 0.8252E-05 (in attachment what surely is a correct reproduction of columns) I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. Thanks for giving a possible attack The first thing that comes to mind is a regular expression to extract the DIHED values from the file contents, something like: pattern = re.compile(r'DIHED\s+=\s+(\d+\.\d+)') -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
On Mon, 08 Jun 2009 18:13:50 +0200, Francesco Pietra wrote: I come 'naked', which is unusual and unfair. ??? However, I find it difficult to give a correct start. The files consist, among other things, of a huge number of blocks of the type NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS = 89.4 Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905 BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS= 19047.1551 EELEC = -218354.9960 EHBOND = 0. RESTRAINT = 3.7793 EAMBER (non-restraint) = -176251.1698 EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME =669299.5681 Density= 0.9896 Ewald error estimate: 0.8252E-05 (in attachment what surely is a correct reproduction of columns) I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. Thanks for giving a possible attack Assuming no DIHED value will ever be split over two lines: data = open(filename) values = [] for line in data: if line and line.strip(): # ignore blanks words = line.strip().split() try: i = words.index(DIHED) except IndexError: continue values.append(float(words[i+2])) mean = sum(values)/len(values) should do the job. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. To just pull the DIHED values, you can use this: import re find_dihed_re = re.compile(r'\bDIHED\s*=\s*([.-e\d]+)', re.I) total = count = 0 for line in file('file.txt'): m = find_dihed_re.search(line) if m: str_value = m.group(1) try: f = float(str_value) total += f count += 1 except: print Not a float: %s % str_value print Total:, total print Count:, count if count: print Average:, total/count If you want a general parser for the file, it takes a bit more work. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
Steven D'Aprano wrote: On Mon, 08 Jun 2009 18:13:50 +0200, Francesco Pietra wrote: I come 'naked', which is unusual and unfair. ??? However, I find it difficult to give a correct start. The files consist, among other things, of a huge number of blocks of the type NSTEP = 1000 TIME(PS) = 152.000 TEMP(K) = 298.54 PRESS = 89.4 Etot = -134965.2123 EKtot = 41282.1781 EPtot = -176247.3905 BOND = 1771.7644 ANGLE = 6893.3003 DIHED = 4660.1650 1-4 NB = 1931.6071 1-4 EEL = 7799.8343 VDWAALS= 19047.1551 EELEC = -218354.9960 EHBOND = 0. RESTRAINT = 3.7793 EAMBER (non-restraint) = -176251.1698 EKCMT = 16048.2253 VIRIAL = 14755.8154 VOLUME =669299.5681 Density= 0.9896 Ewald error estimate: 0.8252E-05 (in attachment what surely is a correct reproduction of columns) I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. Thanks for giving a possible attack Assuming no DIHED value will ever be split over two lines: data = open(filename) values = [] for line in data: if line and line.strip(): # ignore blanks words = line.strip().split() try: i = words.index(DIHED) except IndexError: continue values.append(float(words[i+2])) mean = sum(values)/len(values) should do the job. str.index raises ValueError, not IndexError. Anyway, your code could be shortened slightly: data = open(filename) values = [] for line in data: words = line.split() try: i = words.index(DIHED) values.append(float(words[i + 2])) except ValueError: pass mean = sum(values) / len(values) -- http://mail.python.org/mailman/listinfo/python-list
Re: Odd closure issue for generators
On Thu, Jun 4, 2009 at 7:42 PM, Scott David Danielsscott.dani...@acm.org wrote: Brian Quinlan wrote: This is from Python built from the py3k branch: c = (lambda : i for i in range(11, 16)) for q in c: ... print(q()) ... 11 12 13 14 15 # This is expected c = (lambda : i for i in range(11, 16)) d = list(c) for q in d: ... print(q()) ... 15 15 15 15 15 # I was very surprised You are entitled to be surprised. Then figure out what is going on. Hint: it is the moral equivalent of what is happening here: c = [] for i in range(11, 16): c.append(lambda: i) i = 'Surprise!' print([f() for f in c]) ['Surprise!', 'Surprise!', 'Surprise!', 'Surprise!', 'Surprise!'] i = 0 print([f() for f in c]) [0, 0, 0, 0, 0] The body of your lambda is an un-evaluated expression with a reference, not an expression evaluated at the time of loading c. TO get what you expected, try this: c = [] for i in range(11, 16): c.append(lambda i=i: i) i = 'Surprise!' print([f() for f in c]) [11, 12, 13, 14, 15] When you evaluate a lambda expression, the default args are evaluated, but the expression inside the lambda body is not. When you apply that evaluated lambda expression, the expression inside the lambda body is is evaluated and returned. Getting around this can be pretty easy: c = (lambda i=i: i for i in range(11, 16)) for q in (list(c)): print(q()) -- David blog: http://www.traceback.org twitter: http://twitter.com/dstanek -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
On Mon, 08 Jun 2009 17:29:12 +0100, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Mon, 08 Jun 2009 18:13:50 +0200, Francesco Pietra wrote: I come 'naked', which is unusual and unfair. ??? Yeah, I had to go and scrub my brain out :-) Assuming no DIHED value will ever be split over two lines: data = open(filename) values = [] for line in data: if line and line.strip(): # ignore blanks words = line.strip().split() try: i = words.index(DIHED) except IndexError: Should be ValueError, not IndexError. continue values.append(float(words[i+2])) mean = sum(values)/len(values) should do the job. You don't need the second strip(), words = line.split() should be sufficient. (And we're back to the 'naked' bit again...) -- Rhodri James *-* Wildebeeste Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
problems while using pexpect: pexcept.TIMEOUT always
Phoe6 orsent...@gmail.com wrote: I have been trying to use pexpect and I am failing with pexpect.TIMEOUT for all my attempts. In order to troubleshoot, I decided to go with simplest possible one. [...] Can someone help me what I am doing wrong here? Why is not working for such a simple thing as ssh to my localhost.? I would suggest using the 'setlog' method of child to get more debugging information from pexpect. I've found that the best way to diagnose the source of a timeout. -- R. David Murray http://www.bitdance.com IT ConsultingSystem AdministrationPython Programming -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
Steven D'Aprano wrote: ... Assuming no DIHED value will ever be split over two lines: data = open(filename) values = [] for line in data: if line and line.strip(): # ignore blanks words = line.strip().split() words = line.split() # does the same as above try: i = words.index(DIHED) except IndexError: continue values.append(float(words[i+2])) mean = sum(values)/len(values) Or similarly (with error checks): values = [] with open('/imports/file.txt') as data: for line in data: parts = line.split(' DIHED ') # assume spaces around DIHED if len(parts) 1: if len(parts) 2: # make sure only one DIHED found raise ValueError('Line has DIHED twice: %s' % line) # break the post-DIHED part into '=', value, rest words = parts[1].split(None, 2) values.append(float(tokens[1])) mean = sum(values) / len(values) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: pylint naming conventions?
Esmail ebo...@hotmail.com wrote: Ben Finney wrote: My understanding of Esmail's original message was that, like many of us on first running ‘pylint’ against an existing code base, the output is astonishingly verbose and tedious to read. By the above I presume he's being a good forum member and trying to find a minimal example that shows the problem clearly :-) Yes, that is my intention .. because the code I was checking was rather long, combined with the long pylint output it would make for a rather big posting. I'm going to go back and re-read PEP 8 and see if I perhaps don't recall the right guidelines since no one else here seems to have had the same observation. Well, I for one looked at that long pylint output when I first tried it, and switched to another tool :) (pyflakes...but I don't think it does PEP 8) -- R. David Murray http://www.bitdance.com IT ConsultingSystem AdministrationPython Programming -- http://mail.python.org/mailman/listinfo/python-list
Re: problems while using pexpect: pexcept.TIMEOUT always
On Jun 8, 10:19 pm, R. David Murray rdmur...@bitdance.com wrote: I would suggest using the 'setlog' method of child to get more debugging information from pexpect. I've found that the best way to diagnose the source of a timeout. setlog method seems to be deprecated and 'not allowed' too as the help says. But, I just figured out with help from another forum (bangpypers) that I was not closing the ssh session. so doing child.sendline('logout') and then doing child.read() in my script worked out. Thanks, Senthil -- http://mail.python.org/mailman/listinfo/python-list
Am I doing this the python way? (list of lists + file io)
Horace Blegg tkjthing...@gmail.com wrote: So, Example: I'll read in a CSV file (just one, for now.) and store it into a list. Sometime later, I'll get another CSV file, almost identical/related to the first. However, a few values might have changed, and there might be a few new lines (entries) or maybe a few less. I would want to compare the CSV file I have in my list (in memory) to new CSV file (which I would probably read into a temporary list). I would then want to track and log the differences between the two files. After I've figured out what's changed, I would either update the original CSV file with the new CSV's information, or completely discard the original and replace it with the new one (whichever involves less work). Basically, lots of iterating through each entry of each CSV file and comparing to other information (either hard coded or variable). So, to reiterate, are lists what I want to use? Should I be using something else? (even if that 'something else' only really comes into play when storing and operating on LOTS of data, I would still love to hear about it!) Given your description, I don't see any reason to prefer any alternate data structure. 1000 small CSV files should fit in a modern computer's memory with no problem...and if it does become an issue, worry about it then. One thought, though: you might want to create a list subclass to hold your data, so that you can put useful-to-you methods on the subclass... -- R. David Murray http://www.bitdance.com IT ConsultingSystem AdministrationPython Programming -- http://mail.python.org/mailman/listinfo/python-list
Re: multi-core software
Piet van Oostrum wrote: By the way, there is a series of articles about concurrency on ACM Queue which may be interesting for those participating in or just following this discussion: http://queue.acm.org/listing.cfm?item_topic=Concurrencyqc_type=theme_listfilter=Concurrencypage_title=Concurrency Here is one introductory paragraph from one of the articles: Parallel programming poses many new challenges to the developer, one of which is synchronizing concurrent access to shared memory by multiple threads. Programmers have traditionally used locks for synchronization, but lock-based synchronization has well-known pitfalls. Simplistic coarse-grained locking does not scale well, while more sophisticated fine-grained locking risks introducing deadlocks and data races. Furthermore, scalable libraries written using fine-grained locks cannot be easily composed in a way that retains scalability and avoids deadlock and data races. Is that the one about transactional memory? -- http://mail.python.org/mailman/listinfo/python-list
error: an integer is required
I execute my code in linux environment. My code is: from os import * def insert_text_file(self, strng): t=open(elements_file.txt, a) t.write(strng) t.close() I'm getting this error: type 'exception.TypeError': an integer is required Where is the mistake? Help me, please!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Extract value and average
Tim Chase wrote: I would like to extract values corresponding to variable DIHED (here 4660.1650) and getting also the mean value from all DIHED. To just pull the DIHED values, you can use this: import re find_dihed_re = re.compile(r'\bDIHED\s*=\s*([.-e\d]+)', re.I) total = count = 0 for line in file('file.txt'): m = find_dihed_re.search(line) if m: str_value = m.group(1) try: f = float(str_value) total += f count += 1 except: print Not a float: %s % str_value print Total:, total print Count:, count if count: print Average:, total/count If you want a general parser for the file, it takes a bit more work. Just because I was a little bored: import re pair_re = re.compile(r'\b([^=:]+)\s*[=:]\s*([-.e\d]+)', re.I) def builder(fname='file.txt'): thing = {} for line in file(fname): if not line.strip(): continue line = line.upper() if 'NSTEP' in line: # 1 # it's a new thing # 1 if thing: # 1 yield thing # 1 thing = {}# 1 thing.update(dict( (k.strip(), float(v)) for k,v in pair_re.findall(line) )) #if 'EWALD' in line: # 2 # # it's a new thing # 2 # if thing: # 2 #yield thing # 2 #thing = {}# 2 if thing: yield thing # average the various values to demo total = count = 0 for thing in builder(): total += thing.get('DIHED', 0) count += 1 print Total:, total print Count:, count if count: print Average:, total/count This makes a more generic parser (comment/uncomment the corresponding # 1 or # 2 code based on whether a new block is found by a first line containing NSTEP or a last line containing EWALD). This yields a dictionary for each item in the input file. You can pull out whichever value(s) you want to manipulate. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Is it possible to disable readline in the interactive interpreter?
I run Python on Windows. I have the (pure Python) pyreadline package installed for (occasional) use by IPython. However, when I use the normal Python interactive prompt, the mere fact that the readline module exists means that it gets used. Is there a way of disabling this? (Preferably by default, rather than on a per-session basis). I don't want to get into usability arguments, but the standard Windows command line history and editing is fine for me, and consistency with other apps is more important in this case than configurability (or any other benefits of readline). And yes, the default behaviour of readline *is* different, in small but irritating ways. Paul. -- http://mail.python.org/mailman/listinfo/python-list
Re: error: an integer is required
madigre...@yahoo.gr wrote: I execute my code in linux environment. My code is: from os import * def insert_text_file(self, strng): t=open(elements_file.txt, a) t.write(strng) t.close() I'm getting this error: type 'exception.TypeError': an integer is required Where is the mistake? Help me, please!! The os module has a function called 'open'. When you imported all of the os module you hid the builtin 'open' with the one in the os module. Wildcarded imports are generally not recommended for this reason. Just use import os and then prefix with os. wherever it's needed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to disable readline in the interactive interpreter?
Paul Moore wrote: I run Python on Windows. I have the (pure Python) pyreadline package installed for (occasional) use by IPython. However, when I use the normal Python interactive prompt, the mere fact that the readline module exists means that it gets used. I used to get round this by installing pyreadline within the iPython package, so it only appeared to exist from that app's POV. TJG -- http://mail.python.org/mailman/listinfo/python-list
MD5 hash of object
Hi, in hashlib the hash methods have as parameters just string, i want to know how can i digest an object to get a md5 hash of them. Thankz Luiz -- http://mail.python.org/mailman/listinfo/python-list
Re: error: an integer is required
madigre...@yahoo.gr wrote: I execute my code in linux environment. My code is: from os import * def insert_text_file(self, strng): t=open(elements_file.txt, a) t.write(strng) t.close() I'm getting this error: type 'exception.TypeError': an integer is required Where is the mistake? Help me, please!! Tell us the Python version and give the *full* traceback message, not just the last line. I am pretty sure you also left out an important part of the code you executed to get that message. tjr -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it possible to disable readline in the interactive interpreter?
On Jun 8, 7:31 pm, Tim Golden m...@timgolden.me.uk wrote: Paul Moore wrote: I run Python on Windows. I have the (pure Python) pyreadline package installed for (occasional) use by IPython. However, when I use the normal Python interactive prompt, the mere fact that the readline module exists means that it gets used. I used to get round this by installing pyreadline within the iPython package, so it only appeared to exist from that app's POV. Interesting approach - I hadn't thought of that. I might give that a try. Nevertheless, if it isn't possible to disable readline, I may just raise a bug report as well... Paul. -- http://mail.python.org/mailman/listinfo/python-list
Re: spammers on pypi
On 2009-06-08 07:44, Skip Montanaro wrote: On Jun 5, 1:39 pm, joepjosef.p...@gmail.com wrote: Is there a way to ban spammers from pypi? Can you provide some examples? It's possible that we can apply SpamBayes to PyPI submissions in much the same way that we apply it in other non- mail areas. I suspect he might talking about all of the 1.0.1 releases of projects on June 5th from v y p e r l o g i x . c o m or p y p i . i n f o (obfuscated to avoid helping them out). Most of them appear to be removed, now. These chuckleheads even have a blog post complaining about it. I can collect a list from my Cheeseshop RSS history if you like. I don't think a SpamBayes approach will work for this particular guy. It's not like completely fake metadata was uploaded with links to spam sites. There actually is Python code for some of them. Maybe even some that is marginally useful. But only marginally (Linked Lists for Python? Really?). All of the code appears to use their proprietary, unreleased package. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
s...@pobox.com: Why not just write extension modules in C then? In the past I have used some C for that purpose, but have you tried the D language (used from Python with Pyd)? It's way better, especially if you for example use libs similar to itertools functions, etc :-) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Am I doing this the python way? (list of lists + file io)
R. David Murray: Given your description, I don't see any reason to prefer any alternate data structure. 1000 small CSV files should fit in a modern computer's memory with no problem...and if it does become an issue, worry about it then. The OP can also try the diff command that can be found implemented both on Linux and Windows. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: spammers on pypi
On 2009-06-08 14:32, Jesse Noller wrote: On Mon, Jun 8, 2009 at 3:14 PM, Robert Kernrobert.k...@gmail.com wrote: On 2009-06-08 07:44, Skip Montanaro wrote: On Jun 5, 1:39 pm, joepjosef.p...@gmail.comwrote: Is there a way to ban spammers from pypi? Can you provide some examples? It's possible that we can apply SpamBayes to PyPI submissions in much the same way that we apply it in other non- mail areas. I suspect he might talking about all of the 1.0.1 releases of projects on June 5th from v y p e r l o g i x . c o m or p y p i . i n f o (obfuscated to avoid helping them out). Most of them appear to be removed, now. These chuckleheads even have a blog post complaining about it. I can collect a list from my Cheeseshop RSS history if you like. I don't think a SpamBayes approach will work for this particular guy. It's not like completely fake metadata was uploaded with links to spam sites. There actually is Python code for some of them. Maybe even some that is marginally useful. But only marginally (Linked Lists for Python? Really?). All of the code appears to use their proprietary, unreleased package. None of the code was useful, and I swear it all seemed like one giant ruse to bump google rankings for his pay-for-play sites and downloads. It was all just series of URLs back linking to his crap-sites. Come now! I'm sure pyLotto has some measurable (but tiny!) amount of expected value to it. :-) The main point is that the code isn't gibberish. It might even do what it claims to do if one had the dependencies. Only a human examining it could determine that the code was actually useless and part of a spam-like campaign. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: MD5 hash of object
On Mon, Jun 8, 2009 at 11:43 AM, lczancanellalczancane...@gmail.com wrote: Hi, in hashlib the hash methods have as parameters just string, i want to know how can i digest an object to get a md5 hash of them. Hashes are only defined to operate on bytestrings. Since Python is a high-level language and doesn't permit you to view the internal binary representation of objects, you're going to have to properly convert the object to a bytestring first, a process called serialization. The `pickle` and `json` serialization modules are included in the standard library. These modules can convert objects to bytestrings and back again. Once you've done the bytestring conversion, just run the hash method on the bytestring. Be careful when serializing dictionaries and sets though, because they are arbitrarily ordered, so two dictionaries containing the same items and which compare equal may have a different internal ordering, thus different serializations, and thus different hashes. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrapping LabVIEW and DAQmx Libraries for Python
hi Ketteth, I was waiting for someone, making these available. The hardware modules of NI are very good, and they have a huge range of DAQ cards, even relative cheap ones. We use USB 6009 and 9162 container a lot ( now in Delphi, because the lack of Python drivers :-( I took a biref look at your code, but couldn't find any continous sampling routines. Are you plan to create them ? cheers, Stef xkenneth wrote: All, I've started wrapping the DAQmx and other LabVIEW libraries for python using ctypes. I really like doing some things in python and other in LabVIEW, so I'd like to have the same functionality available for both. I've hosted the tiniest bit of code (mostly just proof of concept) on github. Let me know if anyone else would be interested in this. I'd love some help hashing it out. - Ken http://github.com/erdosmiller/pydaqmx/tree/master -- http://mail.python.org/mailman/listinfo/python-list
Re: is there python image lib that does imagemagick?
Hi! On Windows, you can drive (manage?) ImageMagick from Python, via COM. See: http://www.imagemagick.org/script/api.php#com+ @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
On Jun 8, 9:50 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Aaron Brady wrote: Shorter is always better. url+= { '/': '' }.get( url[ -1 ], '/' ) Why bother with spaces or 3 letter-wide token, check this :o) : x+={'/':''}.get(x[-1],'/') Apart from joking, the following proposed solution is by **far** the one I prefer if not url.endswith('/'): url += '/' Maybe not the shorter, but the most concise and clear to me. Why won't Python permit: url.endswith( '/' ) or url.append( '/' ) ? Should it? Do we find it just as concise and clear? Does it outweigh the priority of the immutability of strings? It works on lists, for example. A sole mutating operation could create a highly and finely tempered compromise with immutability. Would it be 'append'? I like Scott's and MRAB's idea for slicing, not indexing, the last character. The most literal translation of the original natural language is: #ensure that the url ends with a '/' ensure( url, string.endswith, '/' ) (Is it not?) But the parameters aren't sufficient to define 'ensure' generally, and it won't be able to mutate 'url' regardless. -- http://mail.python.org/mailman/listinfo/python-list
Re: Get the class name
On Jun 8, 11:33 am, Gary Herron gher...@islandtraining.com wrote: Kless wrote: Is there any way of to get the class name to avoid to have that write it? --- class Foo: super(Foo, self) --- * Using Py 2.6.2 The question does not make sense: to have WHAT write WHAT, and the code is wrong: the call to super fails But even so, perhaps this will answer your question class Foo: ... pass ... print Foo.__name__ Foo c = Foo print c.__name__ Foo ob = Foo() print ob.__class__.__name__ Foo Gary Herron I think the OP wants to call super without having to explicitly name the type. If you use the self.__class__ approach in that scenario, you can enter into a recursion loop with further inheritance. class T(object): I'm a standard class def f(self): print function class S(T): I call super using self.__class__ def f(self): super(self.__class__, self).f() class J(S): I don't know about S' odd call. j = J() j.f() # --- Bombs -- http://mail.python.org/mailman/listinfo/python-list
Re: pythoncom and writing file summary info on Windows
mattleftb...@gmail.com wrote: Hello, I was trying to put together a script that would write things like the Author and Title metadata fields of a file under Windows. I got the win32 extensions installed and found a few things that look like they should work, though I'm not getting the result I would expect. Hopefully someone has worked through this area and can point me in the right direction. FWIW, this works for me: code import os, sys from win32com.shell import shell, shellcon import pythoncom from win32com import storagecon filepath = sys.argv[1] pidl, flags = shell.SHILCreateFromPath (os.path.abspath (filepath), 0) property_set_storage = shell.SHGetDesktopFolder ().BindToStorage ( pidl, None, pythoncom.IID_IPropertySetStorage ) summary_info = property_set_storage.Open ( pythoncom.FMTID_SummaryInformation, storagecon.STGM_READWRITE | storagecon.STGM_SHARE_EXCLUSIVE ) summary_info.WriteMultiple ([storagecon.PIDSI_TITLE], [BLAHBLAH2]) /code BUT... you need to be aware that working with files -- typically media files such as JPEGs etc. -- can play strange tricks with this info as they implement their own property handlers to provide extra file-specific info. On my system, for example, altho' the Summary tab offers Title and Author and I can fill them in an Apply, nothing happens. They're not there when I come back, and likewise the code above won't affect them. Maybe this is what you're seeing. TJG -- http://mail.python.org/mailman/listinfo/python-list
preferring [] or () in list of error codes?
Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). context: these are database errors and e is database exception, so there's probably been zillions of instructions and io's handling that already. Many TIA! Mark -- Mark Harrison Pixar Animation Studios -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Mon, Jun 8, 2009 at 2:36 PM, m...@pixar.com wrote: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). I like to use tuples / () if the sequence literal is ultimately static. Purely because in my mind that just makes it a little more clear-- a list is mutable, so I use it when it should be or may be mutated; if it never would, I use a tuple. It just seems clearer to me that way. But a tuple also takes up a little space in memory, so it's a bit more efficient that way. I have absolutely no idea if reading / checking for contents in a list vs tuple has any performance difference, but would suspect it'd be tiny (and probably irrelevant in a small case like that), but still. --S -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
m...@pixar.com wrote: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). context: these are database errors and e is database exception, so there's probably been zillions of instructions and io's handling that already. I lightly prefer the (a, b, c) -- you do put spaces after the comma, don't you? A tuple can be kept as a constant, but it requires (not very heavy) program analysis to determine that the list need not be constructed each time the statement is executed. In addition, a tuple is allocated as a single block, while a list is a pair of allocations. The cost is tiny, however, and your sense of aesthetics is part of your code. So unless you only very slightly prefer brackets, if I were you I'd go with the list form. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
mh at pixar.com writes: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): From the viewpoint of relative execution speed, in the above case if it matters at all it matters only on Python 2.4 AFAICT: | L=lambda x:x in[25401,25402,25408]; T=lambda x:x in(25401,25402,25408);import dis;dis.dis(L);dis.dis(T) 1 0 LOAD_FAST0 (x) 3 LOAD_CONST 1 (25401) 6 LOAD_CONST 2 (25402) 9 LOAD_CONST 3 (25408) 12 BUILD_LIST 3 15 COMPARE_OP 6 (in) 18 RETURN_VALUE 1 0 LOAD_FAST0 (x) 3 LOAD_CONST 4 ((25401, 25402, 25408)) 6 COMPARE_OP 6 (in) 9 RETURN_VALUE Earlier versions build the list or tuple at run time (as for the list above); later versions detect that the list can't be mutated and generate the same code for both the list and tuple. However there are limits to the analysis that can be performed e.g. if the list is passed to a function, pursuit halts at the county line: [Python 2.6.2] | F=lambda y,z:y in z;L=lambda x:F(x,[25401,25402,25408]); T=lambda x:F(x,(25401,25402,25408));import dis;dis.dis(L);dis.dis(T) 1 0 LOAD_GLOBAL 0 (F) 3 LOAD_FAST0 (x) 6 LOAD_CONST 0 (25401) 9 LOAD_CONST 1 (25402) 12 LOAD_CONST 2 (25408) 15 BUILD_LIST 3 18 CALL_FUNCTION2 21 RETURN_VALUE 1 0 LOAD_GLOBAL 0 (F) 3 LOAD_FAST0 (x) 6 LOAD_CONST 3 ((25401, 25402, 25408)) 9 CALL_FUNCTION2 12 RETURN_VALUE So in general anywhere I had a list constant I'd make it a tuple -- I'm not aware of any way that performance gets worse by doing that, and it can get better. Background: I'm supporting packages that run on 2.1 to 2.6 in one case and 2.4 to 2.6 in the other; every little unobtrusive tweak helps :-) HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
m...@pixar.com writes: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). Use a list when the semantic meaning of an item doesn't depend on all the other items: it's “only” a collection of values. Your list of message codes is a good example: if a value appears at index 3, that doesn't make it mean something different from the same value appearing at index 2. Use a tuple when the semantic meaning of the items are bound together, and it makes more sense to speak of all the items as a single structured value. The classic examples are point coordinates and timestamps: rather than a collection of values, it makes more sense to think of each coordinate set or timestamp as a single complex value. The value 7 appearing at index 2 would have a completely different meaning from the value 7 appearing at index 3. James Tauber explains this at URL:http://jtauber.com/blog/2006/04/15/python_tuples_are_not_just_constant_lists/. -- \ “Pinky, are you pondering what I'm pondering?” “Well, I think | `\ so, Brain, but pantyhose are so uncomfortable in the | _o__) summertime.” —_Pinky and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: can it be shorter?
On Mon, 08 Jun 2009 12:57:58 -0700, Aaron Brady wrote: Why won't Python permit: url.endswith( '/' ) or url.append( '/' ) ? Because: (1) Strings are immutable, so that won't work. (2) Even if it did, you're programming by side-effect, which is bad style often leading to bugs, and so should be avoided. Should it? Heavens no! It's bad enough that similar expressions are allowed for lists. Just because they're allowed, doesn't mean we should use them! Do we find it just as concise and clear? No. It *looks* like a boolean expression which is produced then thrown away uselessly. If not for append() on lists having a side-effect, I'd call it an expensive no-op. Does it outweigh the priority of the immutability of strings? Certainly not. Special cases aren't special enough to break the rules. Strings have nice consistent behaviour. You're suggesting making their behaviour inconsistent. It works on lists, for example. A sole mutating operation could create a highly and finely tempered compromise with immutability. You're not thinking it through. You can't say strings are immutable, except for append, which mutates them. If you allow *one* mutable operation, then the type is mutable, full stop. Would it be 'append'? I like Scott's and MRAB's idea for slicing, not indexing, the last character. The most literal translation of the original natural language is: #ensure that the url ends with a '/' ensure( url, string.endswith, '/' ) (Is it not?) But the parameters aren't sufficient to define 'ensure' generally, and it won't be able to mutate 'url' regardless. This suggestion appears to be a pie-in-the-sky impractical suggestion. It requires a function ensure() with close to human intelligence to do what I mean. As such, I can't take it seriously. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Network Simulator
Hello everyone. I plan on starting to write a network simulator on python for testing a modified version of TCP. I am wondering if a python network simulator exists? Also, if anyone tried using simpy for doing a simulation. Thank you -- http://mail.python.org/mailman/listinfo/python-list
networking simulator on python
Hello everyone. I plan on starting to write a network simulator on python for testing a modified version of TCP. I am wondering if a python network simulator exists? Also, if anyone tried using simpy for doing a simulation. Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Jun 8, 4:43 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: m...@pixar.com writes: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): I'm currently using [], but only coz I think it's prettier than (). Use a list when the semantic meaning of an item doesn't depend on all the other items: it's “only” a collection of values. Your list of message codes is a good example: if a value appears at index 3, that doesn't make it mean something different from the same value appearing at index 2. Use a tuple when the semantic meaning of the items are bound together, and it makes more sense to speak of all the items as a single structured value. If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. I don't think it's very important, however, to stick to rules like that for objects that don't live for more than a single line of code. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Pyrex and refcounts (Re: unladen swallow: python and llvm)
bearophileh...@lycos.com wrote: I have tried to create a certain data structure with a recent version of Pyrex on Windows, and I have wasted lot of time looking for missing reference count updates that didn't happen, or memory that didn't get freed. Can you elaborate on those problems? The only way you should be able to get reference count errors in Pyrex code is if you're casting between Python and non-Python types. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: networking simulator on python
On Jun 8, 7:18 pm, Ala shaib...@ymail.com wrote: Hello everyone. I plan on starting to write a network simulator on python for testing a modified version of TCP. I am wondering if a python network simulator exists? Also, if anyone tried using simpy for doing a simulation. Thank you There was an article on just this topic in the April issue of Python Magazine. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
Carl Banks pavlovevide...@gmail.com writes: If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. Yes, a set would be best for this specific situation. I don't think it's very important, however, to stick to rules like that for objects that don't live for more than a single line of code. It's important to the extent that it's important to express one's *meaning*. Program code should be written primarily as a means of communicating with other programmers, and only incidentally for the computer to execute. -- \“Laurie got offended that I used the word ‘puke’. But to me, | `\ that's what her dinner tasted like.” —Jack Handey | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: unladen swallow: python and llvm
bearophileh...@lycos.com wrote: s...@pobox.com: Why not just write extension modules in C then? In the past I have used some C for that purpose, but have you tried the D language (used from Python with Pyd)? It's way better, especially if you for example use libs similar to itertools functions, etc :-) Bye, bearophile Is Pyd maintained? I'm interested, but was scared away when I noticed that it had not been updated for some time. (I haven't looked recently). -- http://mail.python.org/mailman/listinfo/python-list
Any idea of stopping the execution of PyRun_File()
Hi,All I have an embedded python application. which is a MFC app with Python interpreter embedded. In the App, I have a separate thread to execute a Python script (using the PyRun_File), but if the user want to stop the executing script, how should I do? A possible way is terminate the thread of executing the scripts by TerminateThread(). but TerminateThread() is unsafe and not recommended. guys, could you guide me on this? B.R. Harry -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Jun 8, 6:02 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Carl Banks pavlovevide...@gmail.com writes: If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. Yes, a set would be best for this specific situation. I don't think it's very important, however, to stick to rules like that for objects that don't live for more than a single line of code. It's important to the extent that it's important to express one's *meaning*. Program code should be written primarily as a means of communicating with other programmers, and only incidentally for the computer to execute. Which is precisely why isn't not very important for an object that exists for one line. No programmer is ever going to be confused about the meaning of this: if a in (1,2,3): Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: multi-core software
On Jun 8, 6:28 am, Ken T. nowh...@home.com wrote: Let's not forget Elite for the 6502 exploiting predictable performance in order to switch graphics modes partway down the vsync! That actually didn't require predictable timing. You could tell the video chip to send you an interrupt when it got to a given scan line. I used this myself. I don't know what Elite did, but I know for sure that it was a common trick on the Atari ST to switch color palettes or graphics mode at a fixed point *in each single scan line* to get more colors, or display graphics on the screen borders. That required synchronous programming, i.e. counting clock cycles of machine instructions such that for every point in the program you knew exactly where the electron ray would be. The Atari ST had an M68000 with exactly 8 MHz, which made this possible. There were no caches in those times, and clock cycles were entirely predictable. -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Jun 8, 7:37 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jun 8, 4:43 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: m...@pixar.com writes: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. As the length of the list increases, the increased speeds of looking something up makes using a set makes more sense. But what's the best way to express this? Here are a few more comparisons (using Python 3.0)... S=lambda x:x in set((25401,25402,25408)) dis(S) 1 0 LOAD_FAST0 (x) 3 LOAD_GLOBAL 0 (set) 6 LOAD_CONST 3 ((25401, 25402, 25408)) 9 CALL_FUNCTION1 12 COMPARE_OP 6 (in) 15 RETURN_VALUE S=lambda x:x in{25401,25402,25408} dis(S) 1 0 LOAD_FAST0 (x) 3 LOAD_CONST 0 (25401) 6 LOAD_CONST 1 (25402) 9 LOAD_CONST 2 (25408) 12 BUILD_SET3 15 COMPARE_OP 6 (in) 18 RETURN_VALUE S=lambda x:x in{(25401,25402,25408)} dis(S) 1 0 LOAD_FAST0 (x) 3 LOAD_CONST 3 ((25401, 25402, 25408)) 6 BUILD_SET1 9 COMPARE_OP 6 (in) 12 RETURN_VALUE I conclude that using constructors is generally a bad idea, since the compiler doesn't know if you're calling the builtin or something with an overloaded name. I presume that the compiler will eventually optimize the second example to match the last, but both of them use the BUILD_SET opcode. I expect that this can be expensive for long lists, so I don't think that it's a good idea to use set constants inside loops. Instead it should be assigned to a global or class variable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyrex and refcounts (Re: unladen swallow: python and llvm)
Greg: Can you elaborate on those problems? I can't, I am sorry, I don't remember the details anymore. Feel free to ignore what I have written about Pyrex, lot of people appreciate it, so it must be good enough, even if I was not smart/ expert enough to use it well. I have even failed in using it on Windows for several days, so probably I am/was quite ignorant. I use Python also because it's handy. For programmers being lazy is sometimes a quality :-) - This part is almost OT, I hope it will be tolerated. Neal Becker: Is Pyd maintained? I'm interested, but was scared away when I noticed that it had not been updated for some time. (I haven't looked recently). I think Pyd works (with no or small changes) with a D1 compiler like DMD, but you have to use the Phobos Standard library, that is worse than Tango. If you have problems with Pyd you will probably find people willing to help you on the D IRC channel. The problem is that the D language isn't used by lot of people, and most libraries are developed by few university students that stop mantaining the libraries once they find a job. So most D libraries are almost abandoned. There is just not enough people in the D community. And some people don't like to develop new libs because the D2 language (currently in Alpha still) makes D1 look like a dead end. On the other hand this is also a good thing, because D1 language has stopped evolving, so you are often able to compile even old code. Using Pyd is quite easy, but D1 language is not as simple as Python, despite being three times simpler than C++ :-) The good thing is that it's not difficult to adapt C code to D, it's almost a mechanical translation (probably a tool simpler than 2to3 can be enough to perform such translation of C to D, but of course no one has written such thing). Another problem with Pyd is that it may have scalability problems, that is it may have problems if you want to wrap hundreds of classes and functions. So before using it for real projects it's better to test it well. I have no idea if D will ever have some true success, even if it's nice. The hystory of Informatics is full of thousands of nice dead languages. In the meantime I'll keep using it and writing libs, etc. I have seen than several Python-lovers like D. The new LDC compiler allows D1 code to be most times about as fast as C++. This is more than enough. At the moment it seems that D is appreciated by people that write video games. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: spammers on pypi
Robert I don't think a SpamBayes approach will work for this particular Robert guy. It's not like completely fake metadata was uploaded with Robert links to spam sites. There actually is Python code for some of Robert them. Maybe even some that is marginally useful. But only Robert marginally (Linked Lists for Python? Really?). All of the code Robert appears to use their proprietary, unreleased package. You might be surprised how well SpamBayes could single out this guy's stuff as spam. In his form submission he has to provide some references to his site. Those URLs (or at least fragments of them like domain names) or product references (seems everything has vyper in it) would probably become very spammy clues. I'll contact the PyPI software folks. I've used SpamBayes for similar sorts of things (like RoundUp). Somebody even built a SpamBayes for YouTube browser extension: http://userscripts.org/scripts/show/13839 Skip -- http://mail.python.org/mailman/listinfo/python-list
Unbound Method Error
Hi, i am brand new in Python, so sorry if this question is too basic, but i have tried a lot and dont have success... I have the following code... class Funcoes: def CifradorDeCesar(mensagem, chave, funcao): mensagem_encriptada='' if funcao == 1: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)+chave) if byte.isupper() and ord(byte_encriptado) 90: byte_encriptado=chr(ord(byte_encriptado)-26) if byte.islower() and ord(byte_encriptado) 122: byte_encriptado=chr(ord(byte_encriptado)-26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado else: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)-chave) if byte.isupper() and ord(byte_encriptado) 65: byte_encriptado=chr(ord(byte_encriptado)+26) if byte.islower() and ord(byte_encriptado) 97: byte_encriptado=chr(ord(byte_encriptado)+26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado return mensagem_encriptada class MC(Funcoes, type): def __init__(cls, clsname, bases, ns): def addtrace(f): def t(self, *args, **kwargs): for att in self.__crypt__: atribcripto = getattr(self, att) atribdescripto = Funcoes.CifradorDeCesar (atribcripto, 3, 2) setattr(self, att, atribdescripto) ret = f(self, *args, **kwargs) for att in self.__crypt__: atribdescripto = getattr(self, att) atribcripto = Funcoes.CifradorDeCesar (atribdescripto, 3, 1) setattr(self, att, atribcripto) # aqui seta __signature__ vazio, assina e atribui __signature__ return ret return t from types import FunctionType for name,obj in ns.items(): if type(obj) == FunctionType: setattr(cls, name, addtrace(ns[name])) class C(): __metaclass__ = MC __crypt__ = [_a, _b] _a = 1 _b = 2 def add(self, a, b): _a = a _b = b return a+b then i call i = C() i.add(2,2) and the error: File C:\Users\Junior\Desktop\Python\T2.py, line 37, in t atribdescripto = Funcoes.CifradorDeCesar(atribcripto, 3, 2) TypeError: unbound method CifradorDeCesar() must be called with Funcoes instance as first argument (got int instance instead) -- http://mail.python.org/mailman/listinfo/python-list
Re: Unbound Method Error
On Mon, Jun 8, 2009 at 7:23 PM, lczancanellalczancane...@gmail.com wrote: Hi, i am brand new in Python, so sorry if this question is too basic, but i have tried a lot and dont have success... I have the following code... class Funcoes: def CifradorDeCesar(mensagem, chave, funcao): mensagem_encriptada='' if funcao == 1: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)+chave) if byte.isupper() and ord(byte_encriptado) 90: byte_encriptado=chr(ord(byte_encriptado)-26) if byte.islower() and ord(byte_encriptado) 122: byte_encriptado=chr(ord(byte_encriptado)-26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado else: for byte in mensagem: if byte.isalpha(): byte_encriptado=chr(ord(byte)-chave) if byte.isupper() and ord(byte_encriptado) 65: byte_encriptado=chr(ord(byte_encriptado)+26) if byte.islower() and ord(byte_encriptado) 97: byte_encriptado=chr(ord(byte_encriptado)+26) else: byte_encriptado=byte mensagem_encriptada+=byte_encriptado return mensagem_encriptada class MC(Funcoes, type): def __init__(cls, clsname, bases, ns): def addtrace(f): def t(self, *args, **kwargs): for att in self.__crypt__: atribcripto = getattr(self, att) atribdescripto = Funcoes.CifradorDeCesar (atribcripto, 3, 2) setattr(self, att, atribdescripto) ret = f(self, *args, **kwargs) for att in self.__crypt__: atribdescripto = getattr(self, att) atribcripto = Funcoes.CifradorDeCesar (atribdescripto, 3, 1) setattr(self, att, atribcripto) # aqui seta __signature__ vazio, assina e atribui __signature__ return ret return t from types import FunctionType for name,obj in ns.items(): if type(obj) == FunctionType: setattr(cls, name, addtrace(ns[name])) class C(): __metaclass__ = MC __crypt__ = [_a, _b] _a = 1 _b = 2 def add(self, a, b): _a = a _b = b return a+b then i call i = C() i.add(2,2) and the error: File C:\Users\Junior\Desktop\Python\T2.py, line 37, in t atribdescripto = Funcoes.CifradorDeCesar(atribcripto, 3, 2) TypeError: unbound method CifradorDeCesar() must be called with Funcoes instance as first argument (got int instance instead) `CifradorDeCesar` is an instance method of the class `Funcoes`, and thus can only be used on instances of the class, *NOT the class itself*. Since it appears to be just a normal function (as suggested by the name of the class and the fact that it lacks `self` as its first parameter), you should scrap the class entirely and just define `CifradorDeCesar` in the toplevel body of the module. Unlike Java, it is *not* good Python style to unnecessarily cram functions into classes. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Jun 8, 2009, at 9:28 PM, Carl Banks wrote: On Jun 8, 6:02 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Carl Banks pavlovevide...@gmail.com writes: If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. Yes, a set would be best for this specific situation. I don't think it's very important, however, to stick to rules like that for objects that don't live for more than a single line of code. It's important to the extent that it's important to express one's *meaning*. Program code should be written primarily as a means of communicating with other programmers, and only incidentally for the computer to execute. Which is precisely why isn't not very important for an object that exists for one line. No programmer is ever going to be confused about the meaning of this: if a in (1,2,3): Actually, I might be -- I think of a tuple first as a single thing, as opposed to a list or map, which I see first as a collection of other things. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Mon, Jun 8, 2009 at 6:57 PM, samwysesamw...@gmail.com wrote: On Jun 8, 7:37 pm, Carl Banks pavlovevide...@gmail.com wrote: On Jun 8, 4:43 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: m...@pixar.com writes: Is there any reason to prefer one or the other of these statements? if e.message.code in [25401,25402,25408]: if e.message.code in (25401,25402,25408): If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. As the length of the list increases, the increased speeds of looking something up makes using a set makes more sense. But what's the best way to express this? Here are a few more comparisons (using Python 3.0)... S=lambda x:x in set((25401,25402,25408)) dis(S) 1 0 LOAD_FAST 0 (x) 3 LOAD_GLOBAL 0 (set) 6 LOAD_CONST 3 ((25401, 25402, 25408)) 9 CALL_FUNCTION 1 12 COMPARE_OP 6 (in) 15 RETURN_VALUE S=lambda x:x in{25401,25402,25408} dis(S) 1 0 LOAD_FAST 0 (x) 3 LOAD_CONST 0 (25401) 6 LOAD_CONST 1 (25402) 9 LOAD_CONST 2 (25408) 12 BUILD_SET 3 15 COMPARE_OP 6 (in) 18 RETURN_VALUE S=lambda x:x in{(25401,25402,25408)} dis(S) 1 0 LOAD_FAST 0 (x) 3 LOAD_CONST 3 ((25401, 25402, 25408)) 6 BUILD_SET 1 9 COMPARE_OP 6 (in) 12 RETURN_VALUE I conclude that using constructors is generally a bad idea, since the compiler doesn't know if you're calling the builtin or something with an overloaded name. I presume that the compiler will eventually optimize the second example to match the last, but both of them use the BUILD_SET opcode. I expect that this can be expensive for long Erm, unless I misunderstand you somehow, the second example will and should *never* match the last. The set {25401,25402,25408}, containing 3 integer elements, is quite distinct from the set {(25401,25402,25408)}, containing one element and that element is a tuple. set(X) != {X}; set([X]) = {X} Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On Tue, 09 Jun 2009 11:02:54 +1000, Ben Finney wrote: Carl Banks pavlovevide...@gmail.com writes: If you want to go strictly by the book, I would say he ought to be using a set since his collection of numbers has no meaningful order nor does it make sense to list any item twice. Yes, a set would be best for this specific situation. I don't think it's very important, however, to stick to rules like that for objects that don't live for more than a single line of code. It's important to the extent that it's important to express one's *meaning*. Program code should be written primarily as a means of communicating with other programmers, and only incidentally for the computer to execute. But practicality beats purity -- there are many scenarios where we make compromises in our meaning in order to get correct, efficient code. E.g. we use floats, despite them being a poor substitute for the abstract Real numbers we mean. In addition, using a tuple or a list in this context: if e.message.code in (25401,25402,25408): is so idiomatic, that using a set in it's place would be distracting. Rather that efficiently communicating the programmer's intention, it would raise in my mind the question that's strange, why are they using a set there instead of a tuple?. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: MD5 hash of object
On Jun 8, 3:47 pm, Chris Rebert c...@rebertia.com wrote: On Mon, Jun 8, 2009 at 11:43 AM, lczancanellalczancane...@gmail.com wrote: Hi, in hashlib the hash methods have as parameters just string, i want to know how can i digest an object to get a md5 hash of them. Hashes are only defined to operate on bytestrings. Since Python is a high-level language and doesn't permit you to view the internal binary representation of objects, you're going to have to properly convert the object to a bytestring first, a process called serialization. The `pickle` and `json` serialization modules are included in the standard library. These modules can convert objects to bytestrings and back again. Once you've done the bytestring conversion, just run the hash method on the bytestring. Be careful when serializing dictionaries and sets though, because they are arbitrarily ordered, so two dictionaries containing the same items and which compare equal may have a different internal ordering, thus different serializations, and thus different hashes. Cheers, Chris --http://blog.rebertia.com I'd think that using the hash of the pickled representation of an object might be problematic, no? The pickle protocol handles object graphs in a way that allows it to preserve references back to identical objects. Consider the following (contrived) example: import pickle from hashlib import md5 class Value(object): def __init__(self, v): self._v = v class P1(object): def __init__(self, name): self.name = Value(name) self.other_name = self.name class P2(object): def __init__(self, name): self.name = Value(name) self.other_name = Value(name) h1 = md5(pickle.dumps(P1('sabres'))).hexdigest() h2 = md5(pickle.dumps(P2('sabres'))).hexdigest() print h1 == h2 False Just something to be aware of. Depending on what you're trying to accomplish, it may make sense to simply define a method which generates a byte string representation of your object's state and just return the hash of that value. Thanks, -Jeff mcjeff.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
Steven D'Aprano ste...@remove.this.cybersource.com.au writes: In addition, using a tuple or a list in this context: if e.message.code in (25401,25402,25408): is so idiomatic, that using a set in it's place would be distracting. I think a list in that context is fine, and that's the idiom I see far more often than a tuple. Rather that efficiently communicating the programmer's intention, it would raise in my mind the question that's strange, why are they using a set there instead of a tuple?. The fact that literal set syntax is a relative newcomer is the primary reason for that, I'd wager. -- \ “If you are unable to leave your room, expose yourself in the | `\window.” —instructions in case of fire, hotel, Finland | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: preferring [] or () in list of error codes?
On 6/8/2009 8:43 PM Ben Finney said... Steven D'Aprano ste...@remove.this.cybersource.com.au writes: In addition, using a tuple or a list in this context: if e.message.code in (25401,25402,25408): is so idiomatic, that using a set in it's place would be distracting. I think a list in that context is fine, and that's the idiom I see far more often than a tuple. Rather that efficiently communicating the programmer's intention, it would raise in my mind the question that's strange, why are they using a set there instead of a tuple?. The fact that literal set syntax is a relative newcomer is the primary reason for that, I'd wager. Well, no. It really is more, that's odd... why use set? Emile -- http://mail.python.org/mailman/listinfo/python-list
multi-thread python interpreaters and c++ program
hi, all I am ruuning a c++ program (boost python) , which create many python interpreaters and each run a python script with use multi-thread (threading). when the c++ main program exit, I want to shut down python interpreaters, but it crashed. I have googled a lot but cant get any clue. here is my code, your suggestion will be greatly appreciated. c++ : / test multi interpreaters ***/ #include Python.h #include boost/python.hpp #include boost/bind.hpp #include string #include windows.h using namespace boost::python; static const char* strs[3]={ m1,m2,m3 }; static void xxx(const char* abc){ fprintf(stderr, this is xxx %s\n, abc); } PyThreadState* testPy(int i){ char buf[128]; PyThreadState* ts = Py_NewInterpreter(); object main_namespace = import(__main__).attr(__dict__); main_namespace[xxx]= xxx; main_namespace[aaa]= i+1; main_namespace[strs]= strs[i]; sprintf(buf, execfile('pyinter/%d.py'),i+1); if(!PyRun_SimpleString(buf)){ return ts; }else return 0; } int main(int argc, char** argv){ PyThreadState *ts[3]; Py_InitializeEx(0); PyEval_InitThreads(); for(int i=0 ; i 3; i++){ ts[i]= testPy(i); if(! ts[i] ){ printf(run %d error\n,i); } else { printf(run %d ok\n,i); } } PyEval_ReleaseLock(); /// release the lock, interpreaters run Sleep(3500); for(int i=0; i 3; i++){ if(! ts[i])continue; printf(delete %d , i); PyEval_AcquireThread(ts[i]); Py_Finalize();///shut down interpreaters ,crash here PyEval_ReleaseLock(); Sleep(10); printf( ok\n); } Sleep(1500); printf(exit...\n); } each interpreater uses the same python script: class MyTimer(object): def __init__(self, interval, function, args=[], kwargs={}): self.interval = interval self.function = function self.args = args self.kwargs = kwargs def start(self): self.stop() import threading self._timer = threading.Timer(self.interval, self._run) self._timer.setDaemon(True) self._timer.start() ### start a python thread, keep running def restart(self): self.start() def stop(self): if self.__dict__.has_key(_timer): self._timer.cancel() del self._timer def _run(self): try: self.function(strs) except: pass self.restart() abc= MyTimer(aaa,xxx); abc.start(); -- http://mail.python.org/mailman/listinfo/python-list
[issue6235] \d missing from effects of re.ASCII flag
Georg Brandl ge...@python.org added the comment: Thanks, fixed in r73285. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6235 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2947] subprocess (Replacing popen) - add a warning / hint
Georg Brandl ge...@python.org added the comment: Patch looks good, except for strange code indentation in the replaced example. -- assignee: georg.brandl - r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2947 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com