discover: automatic test discovery for unittest
The discover module is a backport of the automatic test discovery from python-trunk (what will become Python 2.7 3.2) to work with Python 2.4 or more recent (including Python 3.0). Test discovery allows you to run all the unittest based tests (or just a subset of them) in your project without you having to write your own test collection or running machinery. Once installed, test discovery can be invoked with ``python -m discover``. I've tested the discover module with Python 2.4 and 3.0. The discover module also implements the ``load_tests`` protocol which allows you to customize test loading from modules and packages. Test discovery and ``load_tests`` are implemented in the ``DiscoveringTestLoader`` which can be used from your own test framework. * discover module on PyPI http://pypi.python.org/pypi/discover discover can be installed with pip or easy_install. After installing switch the current directory to the top level directory of your project and run:: python -m discover python discover.py This will discover all tests (with certain restrictions) from the current directory. The discover module has several options to control its behavior (full usage options are displayed with ``python -m discover -h``):: Usage: discover.py [options] Options: -v, --verboseVerbose output -s directory Directory to start discovery ('.' default) -p pattern Pattern to match test files ('test*.py' default) -t directory Top level directory of project (default to start directory) For test discovery all test modules must be importable from the top level directory of the project. For example to use a different pattern for matching test modules run:: python -m discover -p '*test.py' (Remember to put quotes around the test pattern or shells like bash will do shell expansion rather than passing the pattern through to discover.) Test discovery is implemented in ``discover.DiscoveringTestLoader.discover``. As well as using discover as a command line script you can import ``DiscoveringTestLoader``, which is a subclass of ``unittest.TestLoader``, and use it in your test framework. This method finds and returns all test modules from the specified start directory, recursing into subdirectories to find them. Only test files that match *pattern* will be loaded. (Using shell style pattern matching.) All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level directory must be specified separately. The ``load_tests`` protocol allows test modules and packages to customize how they are loaded. This is implemented in ``discover.DiscoveringTestLoader.loadTestsFromModule``. If a test module defines a ``load_tests`` function then tests are loaded from the module by calling ``load_tests`` with three arguments: `loader`, `standard_tests`, `None`. If a test package name (directory with `__init__.py`) matches the pattern then the package will be checked for a ``load_tests`` function. If this exists then it will be called with *loader*, *tests*, *pattern*. If ``load_tests`` exists then discovery does *not* recurse into the package, ``load_tests`` is responsible for loading all tests in the package. The pattern is deliberately not stored as a loader attribute so that packages can continue discovery themselves. *top_level_dir* is stored so ``load_tests`` does not need to pass this argument in to ``loader.discover()``. discover.py is maintained in a google code project (where bugs and feature requests should be posted): http://code.google.com/p/unittest-ext/ The latest development version of discover.py can be found at: http://code.google.com/p/unittest-ext/source/browse/trunk/discover.py Michael Foord -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: W3C HTML batch Validator in Python
what is it -- A simple script calling the W3C HTML Validator in batch mode. Adapted from Perl version. changes since the last full release --- - BUGFIX: checks for Valid or Invalid adapted to changes of W3C HTML Validator HTML (the check is really naive!) - BUGFIX: fixed saving of reports - improvement of output - added valid and invalid example HTML download download validate-1.7 - 090620 from http://cthedot.de/batchvalidator/ tested on Python 2.6.2 only but should work on other versions as it is really simple... Included is a (modified) httplib_multipart.py script (originally from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306) to be able to POST fields and files to an HTTP host as multipart/form-data. any comment appreciated... thanks, Christof -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Python-URL! - weekly Python news and links (Jun 20)
QOTW: ... open recursion with abstraction is supported in OOP but it requires elaborate and rather tedious boilerplate in FP ... - Martin Odersky http://www.nabble.com/Re%3A--scala--usefulness-of-OOP-p23273389.html How to write a method that may act both as an instance method and as a class method: http://groups.google.com/group/comp.lang.python/browse_thread/thread/41e3606af55598e8/ How to check the Python version? http://groups.google.com/group/comp.lang.python/browse_thread/thread/105dd4686e7985e1/ Exceptions alter the normal lifetime of some objects: http://groups.google.com/group/comp.lang.python/browse_thread/thread/7f9056711e3e313c Are exit() and sys.exit() the same thing? http://groups.google.com/group/comp.lang.python/browse_thread/thread/72b318b07030a048/ Exotic logics http://groups.google.com/group/comp.lang.python/browse_thread/thread/75d688efdac05526/ A compilation of good books in Computer Science/Software Engineering: http://groups.google.com/group/comp.lang.python/browse_thread/thread/952facdd398772/ itertools.intersect is missing? http://groups.google.com/group/comp.lang.python/browse_thread/thread/4772d9ff82a90a6c/ From Perl to Python: Lexical (private) scope: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2b2536c28cd32888/ Multiple sequence subscripts: http://groups.google.com/group/comp.lang.python/browse_thread/thread/61c1d89d988a2cac/ None, vacuous truth, denotational semantics, and other philosophical aspects of emptyness: http://groups.google.com/group/comp.lang.python/browse_thread/thread/3c5397f9b6726b7a/ Walking a directory containing many many files: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ff3905b80de43588/ How to get the total size of a local hard disk in a cross-platform way :) http://groups.google.com/group/comp.lang.python/msg/c6c09fa6b3b62f84 Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiasts: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/group/comp.lang.python.announce/topics Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html The Python Package Index catalogues packages. http://www.python.org/pypi/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donations/ The Summary of Python Tracker Issues is an automatically generated report summarizing new bugs, closed ones, and patch submissions. http://search.gmane.org/?author=status%40bugs.python.orggroup=gmane.comp.python.develsort=date Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://code.activestate.com/recipes/langs/python/ Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available, see: http://www.python.org/channews.rdf For more, see:
Python class gotcha with scope?
I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. class foo: ... r = {} ... def setn(self, n): ... self.r[f] = n ... a = foo() a.setn(4) b = foo() b.r {'f': 4} thanks, billy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python class gotcha with scope?
On Jun 21, 2:32 pm, billy billy.cha...@gmail.com wrote: I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. class foo: ... r = {} ... def setn(self, n): ... self.r[f] = n ... a = foo() a.setn(4) b = foo() b.r {'f': 4} thanks, billy class Foo: def __init__(self): self.r = {} def setn(self,n): self.r['f'] = n a = Foo() a.setn(3) a.r {'f': 3} b = Foo() b.r {} -- http://mail.python.org/mailman/listinfo/python-list
Re: Python class gotcha with scope?
On Jun 21, 2:38 pm, Vincent pho...@gmail.com wrote: On Jun 21, 2:32 pm, billy billy.cha...@gmail.com wrote: I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. class foo: ... r = {} ... def setn(self, n): ... self.r[f] = n ... a = foo() a.setn(4) b = foo() b.r {'f': 4} thanks, billy class Foo: def __init__(self): self.r = {} def setn(self,n): self.r['f'] = n a = Foo() a.setn(3) a.r {'f': 3} b = Foo() b.r {} you defined r as class-level variable. and i defined r as instance-level variable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python class gotcha with scope?
On Jun 20, 11:32 pm, billy billy.cha...@gmail.com wrote: I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. class foo: ... r = {} ... def setn(self, n): ... self.r[f] = n ... a = foo() a.setn(4) b = foo() b.r {'f': 4} r is a class attribute, that is, it is attacted to the class itself. Look at what happens when you enter foo.r at the interactive prompt: foo.r {'f': 4} You want an instance attribute, a value attached to the instance of the class. You create those in the __init__ method: class foo: def __init__(self): self.r = {} def setn(self,n): self.r[n] = n Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python class gotcha with scope?
great, thanks for the quick responses :) On Jun 21, 2:41 am, Carl Banks pavlovevide...@gmail.com wrote: On Jun 20, 11:32 pm, billy billy.cha...@gmail.com wrote: I don't quite understand why this happens. Why doesn't b have its own version of r? If r was just an int instead of a dict, then it would. class foo: ... r = {} ... def setn(self, n): ... self.r[f] = n ... a = foo() a.setn(4) b = foo() b.r {'f': 4} r is a class attribute, that is, it is attacted to the class itself. Look at what happens when you enter foo.r at the interactive prompt: foo.r {'f': 4} You want an instance attribute, a value attached to the instance of the class. You create those in the __init__ method: class foo: def __init__(self): self.r = {} def setn(self,n): self.r[n] = n Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Look, guys, here's the thing: In the company I work at we decided to rewrite our MRP system in Python. I was one of the main proponents of it since it's nicely cross platform and allows for quite rapid application development. The language and it's built in functions are simply great. The opposition was quite strong, especially since the owner cheered for it - .net. So, recently I started writing a part of this new system in Python. A report generator to be exact. Let's not go into existing offerings, they are insufficient for our needs. First I started on a few tests. I wanted to know how the reporting engine will behave if I do this or that. One of the first tests was, naturally, threading. The reporting engine itself will have separate, semi-independent parts that can be threaded well, so I wanted to test that. The rest you know if you read the two threads I started on this group. Now, the core of the new application is designed so that it can be clustered so it's no problem if we just start multiple instances on one server, say one for each available core. The other day, a coworker of mine said something like: what?!? you've been using Python for two days already and you already say it's got a major fault? I kinda aggreed with him, especially since this particular coworker programmed strictly in Python for the last 6 months (and I haven't due to other current affairs). There was no way my puny testing could reveal such a major drawback. As it turns out, I was right. I have programmed enough threading to have tried enough variations which all reveal the GIL. Which I later confirmed through searching on the web. My purpose with developing the reporting engine in Python was twofold: learn Python as I go and create a native solution which will work out- of-the-box for all systems we decide to support. Making the thing open source while I'm at it was a side-bonus. However: Since the testing revealed this, shall we say problem, I am tempted to just use plain old C++ again. Furthermore, I was also not quite content with the speed of arithmetic processing of the python engine. I created some simple aggregating objects that only performed two additions per pass. Calling them 200K times took 4 seconds. This is another reason why I'm beginning to think C++ might be a better alternative. I must admit, had the GIL issue not popped up, I'd just take the threading benefits and forget about it. But both things together, I'm thinking I need to rethink my strategy again. I may at some point decide that learning cross platform programming is worth a shot and just write a Python plugin for the code I write. The final effect will be pretty much the same, only faster. Perhaps I will even manage to get close to Crystal Reports speed, though I highly doubt that. But in the end, my Python skill will suffer. I still have an entire application (production support) to develop in it. Thanks for all the information and please don't flame each other. I already get the picture that GIL is a hot subject. -- http://mail.python.org/mailman/listinfo/python-list
Re: File Syncing
On Jun 20, 11:21 am, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message b2c37939-f921-4ea5- b0d7-586b1b332...@t10g2000vbg.googlegroups.com, dads wrote: What would I have to learn to be able to sync the text files on each server? How big is the text file? If it's small, why not have your script read it directly from a master server every time it runs, instead of having a local copy. Yeah the text files will never get bigger than a 100k. I don't think they have a master server but i'll check. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: walking a directory with very many files
Lawrence D'Oliveiro wrote: Ok, now pipe ls to less, take three days to browse through all the filenames to locate the file you want to see. Sounds like you're approaching the issue with a GUI-centric mentality, which is completely hopeless at dealing with this sort of situation. Piping the output of ls to less is a GUI-centric mentality? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: File Syncing
In message b2c37939-f921-4ea5- b0d7-586b1b332...@t10g2000vbg.googlegroups.com, dads wrote: What would I have to learn to be able to sync the text files on each server? How big is the text file? If it's small, why not have your script read it directly from a master server every time it runs, instead of having a local copy. -- http://mail.python.org/mailman/listinfo/python-list
a evaluation of Google-code-prettify
For those of you interested in the Google tech of syntax coloring source code in html on the fly using javascript, i've spent few hours for a evaluation. See: • Google-code-prettify Examples http://xahlee.org/js/google-code-prettify/index.html Xah ∑ http://xahlee.org/ ☄ -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
On 21 juin, 03:27, Jure Erznožnik jure.erznoz...@gmail.com wrote: Add: Carl, Olivier co. - You guys know exactly what I wanted. Others: Going back to C++ isn't what I had in mind when I started initial testing for my project. Do you think multiprocessing can help you seriously ? Can you benefit from multiple cpu ? did you try to enhance your code with numpy ? Olivier (installed a backported multiprocessing on his 2.5.1 Python, but need installation of Xcode first) -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie queue question
On Jun 21, 9:43 am, Чеширский Кот p.ela...@gmail.com wrote: 1. say me dbf files count? 2. why dbf ? It was just a test. It was the most compatible format I could get between Python and the business application I work with without using SQL servers and such. Otherwise it's of no consequence. The final application will have a separate input engine that will support multiple databases as input. Jure -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
On Jun 21, 9:32 am, OdarR olivier.da...@gmail.com wrote: Do you think multiprocessing can help you seriously ? Can you benefit from multiple cpu ? did you try to enhance your code with numpy ? Olivier (installed a backported multiprocessing on his 2.5.1 Python, but need installation of Xcode first) Multithreading / multiprocessing can help me with my problem. As you know, database reading is typically I/O bound so it helps to put it in a separate thread. I might not even notice the GIL if I used SQL access in the first place. As it is, DBFPY is pretty CPU intensive since it's a pure Python DBF implementation. To continue: the second major stage (summary calculations) is completely CPU bound. Using numpy might or might not help with it. Those are simple calculations, mostly additions. I try not to put the entire database in arrays to save memory and so I mostly just add counters where I can. Soe functions simply require arrays, but they are more rare, so I guess I'm safe with that. You wouldn't believe how complex some reports can be. Threading + memory saving is a must and even so, I'll probably have to implement some sort of serialization later on, so that the stuff can run on more memory constrained devices. The third major stage, rendering engine, is again mostly CPU bound, but at the same time it's I/O bound as well when outputting the result. All three major parts are more or less independent from each other and can run simultaneously, just with a bit of a delay. I can perform calculations while waiting for the next record and I can also start rendering immediately after I have all the data for the first group available. I may use multiprocessing, but I believe it introduces more communication overhead than threads and am so reluctant to go there. Threads were perfect, other stuff wasn't. To make things worse, no particular extension / fork / branch helps me here. So if I wanted to just do the stuff in Python, I'd have to move to Jthon or IronPython and hope cPython eventually improves in this area. I do actually need cPython since the other two aren't supported on all platforms my company intends to support. The main issue I currently have with GIL is that execution time is worse when I use threading. Had it been the same, I wouldn't worry too much about it. Waiting for a permenent solution would be much easier then... -- http://mail.python.org/mailman/listinfo/python-list
Re: raw_input with a pre-compiled data
On Sat, Jun 20, 2009 at 6:38 PM, Chris Rebertc...@rebertia.com wrote: On Sat, Jun 20, 2009 at 7:17 AM, Lucaluca...@gmail.com wrote: Hi all. I need to use a function like the raw_input to read data from user command line, but I really like to pre-compile the choice and I'm not able to do this. There is some other function/module I can use? I wanna to pre-compile the raw_input input line with the current working path. What does pre-compile mean in this context? It's not clear at all, so I can't even understand your question. I'm really sorry to all that replied... In fact I literally traduced a concept from italian and the term precompiled was not so clear... What I mean is this: I wanna that raw_input (or other modules) ask to the user the data, but some data inserted is already present, to the user can cancel it with the BACKSPACE key. Examples below (the _ is the initial cursor position). raw_input(Insert the directory to work: ) Insert the directory to work: _ What I need is: XXX_raw_input(Insert the directory to work: , default=/home/john/) Insert the directory to work: /home/john_ In the second example a user can cancel the text /home/john. I hope this time is more clear, sorry again. -- -- luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Developing GUI applications
Grant Ito grant_...@shaw.ca wrote: Hi everyone. I'm looking to find out what people are using for an open source wysiwyg GUI developer. I'm running both Linux and Windows but prefer to do my development in Linux. I've got the most experience with Tkinter but am willing to look at wxPython and Tix as well. Thus far I've looked into PAGE and SpecTcl. The version of PAGE I've downloaded doesn't quite look like the online manual so I'm wondering about that. SpecTcl seems cool but I can't locate SpecPython by either Erik Brunel or Richard Colley, and the SpecTix page is down as well, as is the GUIBuilder page. All the sites I've looked at seem to date back to somewhere between 2002 and 2006. Any help would be much appreciated. Have a long, hard look at Boa Constructor. It is a RAD based on wx. It actually works as advertised. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: os.read in non blocking mode of os.open : resource busy error
On Wed, Jun 17, 2009 at 7:18 PM, kshama nagarajkshama.naga...@gmail.com wrote: Dear all, I am using os.open to open a tun/tap device and then read data from it. I also need to do some other tasks apart from reading from this device. So i wish to have the read non blocking. I am opening the device in non-block mode using os.O_NONBLOCK . But, if i do this, i get an error when i call the os.read a follows: File ./tunnel_more1.py, line 305, in main_loop payload = os.read(self.tun_fd,64) OSError: [Errno 11] Resource temporarily unavailable From the glibc documentation of read: `EAGAIN' Normally, when no input is immediately available, `read' waits for some input. But if the `O_NONBLOCK' flag is set for the file (*note File Status Flags::), `read' returns immediately without reading any data, and reports this error. And from ipython: In [1]: import errno In [2]: print errno.EAGAIN 11 That's your error 11. I am running my application with GNU Radio on Ubuntu. Can some one tell me, what is the error? What are the ways to use non blocking read? thanks all for your time and attention. -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Kay Schluehr k...@fiber-space.de wrote: This implies that people stay defensive concerning concurrency ( like me right now ) and do not embrace it like e.g. Erlang does. Sometimes there is a radical change in the way we design applications and a language is the appropriate medium to express it succinctly. Concurrency is one example, writing GUIs and event driven programs in a declarative style ( Flex, WPF, JavaFX ) is another one. In particular the latter group shows that new skills are adopted rather quickly. I don't see that a concurrency oriented language has really peaked though yet. I think that this is because (like your link has shown) the problem is really not trivial, and also because the model that can bring sanity to the party (independent threads/processes that communicate with queued messages) is seen as inefficient at small scale. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: waling a directory with very many files
On Jun 15, 2:35 am, tom f...@thefsb.org wrote: i can traverse adirectoryusing os.listdir() or os.walk(). but if adirectoryhas a very large number of files, these methods produce very large objects talking a lot of memory. in other languages one can avoid generating such an object by walking adirectoryas a liked list. for example, in c, perl or php one can use opendir() and then repeatedly readdir() until getting to the end of the file list. it seems this could be more efficient in some applications. is there a way to do this in python? i'm relatively new to the language. i looked through the documentation and tried googling but came up empty. I might be a little late with my comment here. David Beazley in his PyCon'2008 presentation Generator Tricks For Systems Programmers had this very elegant example of handling an unlimited numbers of files: import os, fnmatch def gen_find(filepat,top): gen_find(filepat,top) - find matching files in directory tree, start searching from top expects: a file pattern as string, and a directory path as string yields: a sequence of filenames (including paths) for path, dirlist, filelist in os.walk(top): for name in fnmatch.filter(filelist,filepat): yield os.path.join(path,name) for file in gen_find('*.py', '/'): print file -- http://mail.python.org/mailman/listinfo/python-list
Re: waling a directory with very many files
rkl wrote: I might be a little late with my comment here. David Beazley in his PyCon'2008 presentation Generator Tricks For Systems Programmers had this very elegant example of handling an unlimited numbers of files: David Beazley's generator stuff is definitely worth recommending on. I think the issue here is that: anything which ultimately uses os.listdir (and os.walk does) is bound by the fact that it will create a long list of every file before handing it back. Certainly there are techniques (someone posted a ctypes wrapper for opendir; I recommended FindFirst/NextFile on Windows) which could be applied, but those are all outside the stdlib. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: raw_input with a pre-compiled data
Luca wrote: On Sat, Jun 20, 2009 at 6:38 PM, Chris Rebertc...@rebertia.com wrote: On Sat, Jun 20, 2009 at 7:17 AM, Lucaluca...@gmail.com wrote: Hi all. I need to use a function like the raw_input to read data from user command line, but I really like to pre-compile the choice and I'm not able to do this. There is some other function/module I can use? I wanna to pre-compile the raw_input input line with the current working path. What does pre-compile mean in this context? It's not clear at all, so I can't even understand your question. I'm really sorry to all that replied... In fact I literally traduced a With traduced you stumbled upon another false friend ;) http://it.wikipedia.org/wiki/Falso_amico concept from italian and the term precompiled was not so clear... What I mean is this: I wanna that raw_input (or other modules) ask to the user the data, but some data inserted is already present, to the user can cancel it with the BACKSPACE key. Examples below (the _ is the initial cursor position). raw_input(Insert the directory to work: ) Insert the directory to work: _ What I need is: XXX_raw_input(Insert the directory to work: , default=/home/john/) Insert the directory to work: /home/john_ In the second example a user can cancel the text /home/john. I hope this time is more clear, sorry again. import readline def input_default(prompt, default): def startup_hook(): readline.insert_text(default) readline.set_startup_hook(startup_hook) try: return raw_input(prompt) finally: readline.set_startup_hook(None) print input_default(directory? , default=/home/john) The cmd module may also be worth having a look. Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Christian Heimes wrote: Hard computations gain more speed from carefully crafted C or Fortran code that utilizes features like the L1 and L2 CPU cache, SIMD etc. or parallelized algorithms. If you start sharing values between multiple cores you have a serious problem. Oh, and use NumPy for the job ;) [...] It *is* a well known limitation of Python. All the nice 'n shiny syntax and features are coming with a cost. Python is a powerful language and good tool for lots of stuff. But Python is and will never become the übertool that solves every problem perfectly. At some point you need a different tool to get the raw power of your machine. C (and perhaps Fortran) are the weapons of choice for number crunching. Well, and there's always Cython to the rescue when you need it. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Jure Erznožnik wrote: On Jun 20, 1:36 am, a...@pythoncraft.com (Aahz) wrote: You should put up or shut up -- I've certainly seen multi-core speedup with threaded software, so show us your benchmarks! -- Sorry, no intent to offend anyone here. Flame wars are not my thing. I have shown my benchmarks. See first post and click on the link. That's the reason I started this discussion. All I'm saying is that you can get threading benefit, but only if the threading in question is implemented in C plugin. I have yet to see pure Python code which does take advantage of multiple cores. From what I read about GIL, this is simply impossible by design. Well, CPython is written in C. So running Python code in CPython will necessarily run C code (whatever plugin means in your post above). If that C code frees the GIL or not depends on the parts of CPython or external packages that you use. And there are many parts that free the GIL and will thus benefit (sometimes heavily) from threading and multiple-cores, and there are also many parts that do not free the GIL and will therefore not (or likely not) benefit from multiple-cores. Claiming that pure Python code does not free the GIL in the context of CPython when you define pure Python code as code that does not depend on C code is plain flawed. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Jesse Noller wrote: Sorry, you're incorrect. I/O Bound threads do in fact, take advantage of multiple cores. I don't know whether anyone else brought this up, but it looks like Python has problems with even this form of threading http://www.dabeaz.com/python/GIL.pdf It's certainly a very interesting read if you're interested in this subject. -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list
MemoryError c/vcompiler.h:745: Fatal Python error (Psycopg2)
Hi, I have a program that uses a lot of resources: memory and cpu but it never returned this error before with other loads: MemoryError c/vcompiler.h:745: Fatal Python error: psyco cannot recover from the error above Aborted The last time I checked physical RAM while the script was running, it was used in about 75% and there is no reason (based in other runs of the program) for it to surpass 80% (maximum). $ python -V Python 2.5.2 Pyscopg2 is version 2.0.8 I use Linux, Kernel 2.6.24.5-smp #2 SMP with a Core2 CPU T5500 @ 1.66GHz and 3GB of RAM I could not find this error. What does this mean? Is this a bug of Python? of Psycopg2? Luis -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance and forward references (prototypes)
On 21 Jun., 01:54, Dave Angel da...@ieee.org wrote: LorenzoDiGregoriowrote: On Jun 20, 8:43 pm, Dave Angel da...@ieee.org wrote: LorenzoDiGregoriowrote: Hi, I'm wondering what would be the preferred way to solve the following forward reference problem: --- class BaseA(object): def __init__(self): return class DebugA(BaseA): def __init__(self): return # here I would have a prototype of class A which is the same as class BaseA class B(object): def __init__(self): self.obj =() return if __name__ =__main__: # class A(BaseA): # Uncomment this for using BaseA objects # pass class A(DebugA): # Uncomment this for using DebugA objects pass --- I can figure out some ways to fix this but none seems satisfying. Either they are too specific or too cumbersome. A runtime redefinition of class A does not seem to work either. What would be the most pythonesque solution other than sorting out the class order? Best Regards, Lorenzo You haven't shown us any problem. class B works fine with a forward reference to A. Now if you were trying to subclass A before defining it, that'd be a problem. Or if you were trying to make an instance of B before defining A. Better put some code together with enough meat to actually show a symptom. And tell us what sys.version says. I'm testing with 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)], running on Win XP.- Hide quoted text - - Show quoted text - Thank you for your help: I'm working on a rather large source, but I think I have isolated the problem now. This listing generates an error: --- class BaseA(object): def __init__(self): return class DebugA(BaseA): def __init__(self): return class B(object): def __init__(self,test=A()): self.obj =() return if __name__ =__main__: # class A(BaseA): # Uncomment this for using BaseA objects # pass class A(DebugA): # Uncomment this for using DebugA objects pass --- The error happens because Python apparently evaluates the named arguments before running the script. I think I have read something about this some (long) time ago but I can't find it anymore. Suggestions? BTW, my Python version is 2.6.1 (with latest PyDev). Thx! Lorenzo This error is caused because a default argument uses class A. Default arguments of class methods are evaluated during the definition of the class, and not later when the class is instantiated. Thus the problem. To work around that specific problem, you may want to use the following: class B(object): def __init__(self,test=None): if test==None: test = A() self.obj =() return This is actually different than what you had, since what you had would have used the same A() object for all instances of B that didn't supply their own test() parameter. Maybe that's what you wanted, and maybe not, but default arguments set to mutable values are frequently a bug. But I'm wondering if you're just looking for problems. Why not put the commented switch early in the file, and test for it wherever you need to use it? import x, y, z _debug = False #_debug = True then as soon as BaseA and DebugA are defined, do the following: if _debug: class A(DebugA): pass else: class A(BaseA) pass- Zitierten Text ausblenden - - Zitierten Text anzeigen - I had also thought of using None (or whatever else) as a marker but I was curious to find out whether there are better ways to supply an object with standard values as a default argument. In this sense, I was looking for problems ;-) Of course the observation that def is an instruction and no declaration changes the situation: I would not have a new object being constructed for every instantiation with no optional argument, because __init__ gets executed on the instantiation but test=A() gets executed on reading 'def'. At this point I think there is no other way than using a marker as suggested above multiple times, if I want to supply a new object with default values for non-passed arguments. Anybody with a better idea? -- http://mail.python.org/mailman/listinfo/python-list
Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. Examples are the postings by Dennis Lee Bieber wlfr...@ix.netcom.com that I am replying to (but I break the thread on purpose). For example the posting with Message-ID: mailman.1883.1245538633.8015.python-l...@python.org references: 77e831100906192220y5536d9d2oe5ca2dcc59084...@mail.gmail.com which is not present on my news server. I have been wondering why these disappear, and I noticed the following in the Dennis Lee Bieber posting: On Sat, 20 Jun 2009 11:48:21 -0600, Vincent Davis vinc...@vincentdavis.net declaimed the following in gmane.comp.python.general: So apparently some of these come through gmane.comp.python.general. So my question is: would this be the cause of these disappearing postings? Are postings on gmane.comp.python.general not relayed to comp.lang.python? Are they relayed to the python mailing list? I find it quite disturbing that sometimes only half of a discussion is visible. -- 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: Rich comparison methods don't work in sets?
Hi, everyone. OK, I got it now! The value of the hash is not decisive, as __eq__ will still be called when the hashes match. It's like a filter, for performance reasons. It's really nice, I just tried it and it worked. Thank you very, very much!! Cheers, - Gustavo. -- http://mail.python.org/mailman/listinfo/python-list
Re: MemoryError c/vcompiler.h:745: Fatal Python error (Psycopg2)
Luis P. Mendes wrote: Hi, I have a program that uses a lot of resources: memory and cpu but it never returned this error before with other loads: MemoryError c/vcompiler.h:745: Fatal Python error: psyco cannot recover from the error above Aborted The last time I checked physical RAM while the script was running, it was used in about 75% and there is no reason (based in other runs of the program) for it to surpass 80% (maximum). $ python -V Python 2.5.2 Pyscopg2 is version 2.0.8 I use Linux, Kernel 2.6.24.5-smp #2 SMP with a Core2 CPU T5500 @ 1.66GHz and 3GB of RAM I could not find this error. What does this mean? Is this a bug of Python? of Psycopg2? Luis Have you tried running without psyco? Psyco increases memory usage quite significantly. If it runs well without psyco, you can try looking at your code and selectively psyco parts that need the speed boost the most. -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance and forward references (prototypes)
Lorenzo Di Gregorio wrote: I had also thought of using None (or whatever else) as a marker but I was curious to find out whether there are better ways to supply an object with standard values as a default argument. In this sense, I was looking for problems ;-) Of course the observation that def is an instruction and no declaration changes the situation: I would not have a new object being constructed for every instantiation with no optional argument, because __init__ gets executed on the instantiation but test=A() gets executed on reading 'def'. At this point I think there is no other way than using a marker as suggested above multiple times, if I want to supply a new object with default values for non-passed arguments. Using None as default for mutable default argument is the common idiom for the problem you're having. -- http://mail.python.org/mailman/listinfo/python-list
Re: MemoryError c/vcompiler.h:745: Fatal Python error (Psycopg2)
Sun, 21 Jun 2009 13:04:59 +, Lie Ryan escreveu: Luis P. Mendes wrote: Hi, I have a program that uses a lot of resources: memory and cpu but it never returned this error before with other loads: MemoryError c/vcompiler.h:745: Fatal Python error: psyco cannot recover from the error above Aborted The last time I checked physical RAM while the script was running, it was used in about 75% and there is no reason (based in other runs of the program) for it to surpass 80% (maximum). $ python -V Python 2.5.2 Pyscopg2 is version 2.0.8 I use Linux, Kernel 2.6.24.5-smp #2 SMP with a Core2 CPU T5500 @ 1.66GHz and 3GB of RAM I could not find this error. What does this mean? Is this a bug of Python? of Psycopg2? Luis Have you tried running without psyco? Psyco increases memory usage quite significantly. If it runs well without psyco, you can try looking at your code and selectively psyco parts that need the speed boost the most. I really need Psyco (use version 1.6 - forgot to mention earlier) to speed up the code. The part that consumes more memory is the one that needs Psyco the most. Luis -- http://mail.python.org/mailman/listinfo/python-list
question about c++ and python
Dear Sirs; I'm a PhD student,i have a question i wish if you can help me really.I'm working in Linux ubuntu 8.10,i have a c++ file which i need to connect this file to a python file and run it,i wish really if u can send me the method that can help me to do this and really I'm very thankful. best regards -- http://mail.python.org/mailman/listinfo/python-list
Re: class or instance method
Hi, class class_or_instance(object): def __init__(self, fn): ... This works a treat, thank-you. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: MemoryError c/vcompiler.h:745: Fatal Python error (Psycopg2)
Luis P. Mendes wrote: Sun, 21 Jun 2009 13:04:59 +, Lie Ryan escreveu: Have you tried running without psyco? Psyco increases memory usage quite significantly. If it runs well without psyco, you can try looking at your code and selectively psyco parts that need the speed boost the most. I really need Psyco (use version 1.6 - forgot to mention earlier) to speed up the code. The part that consumes more memory is the one that needs Psyco the most. Yeah, but try running without psyco first and see if the problem is really caused by psyco. If it still produces an error, then we can rule out psyco as the root cause of the problem. Selective psyco-ing can reduce the amount of memory psyco uses and may just be slightly slower than full boosting (and sometimes it may actually become faster in memory constrained situation as less swapping is needed). -- http://mail.python.org/mailman/listinfo/python-list
Re: question about c++ and python
Issa Kamar schrieb: Dear Sirs; I'm a PhD student,i have a question i wish if you can help me really.I'm working in Linux ubuntu 8.10,i have a c++ file which i need to connect this file to a python file and run it,i wish really if u can send me the method that can help me to do this and really I'm very thankful. If you send me money, I will send you the code. Otherwise, I suggest you start googling a bit and find out how to map C++-classes to Python. There is an abundance of information on that topic out there. Popular options include SWIG, Boost::Python and SIP, the latter I can only recommend from personal experience. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: KeyboardInterrupt eats my error and then won't be caught
On Jun 20, 2009, at 10:21 PM, greg wrote: Philip Semanchuk wrote: Best of all, PyErr_CheckSignals() doesn't interfere with a Python- level signal handler if one is set. Ah, I hadn't realised that you were doing this in C code, and I was trying to think of a Python-level solution. For C code, the solution you give sounds like a good one. My only misgiving is that the user might expect to get a KeyboardInterrupt in response to Ctrl-C, so it might be better to just let it propagate instead of turning it into a different exception. I completely agree. The simple solution (for me) is to handle all return codes of EINTR the same way which is to raise posix_ipc.Error with the message The wait was interrupted by a signal. But that loses information. KeyboardInterrupt is very specific while posix_ipc.Error is generic and even parsing the message doesn't tell much more. When my C code sees EINTR, I will probably raise KeyboardError when I see that and add a specific posix_ipc.SignalError to raise in other EINTR circumstances. Thanks, Philip -- http://mail.python.org/mailman/listinfo/python-list
python needs a tutorial for install and setup on a Mac
I am running python on a mac and when I was getting going it was difficult to setup information. Specifically how modify bash_profile, how pythonpath works and how to set it up. how to switch between python versions. How/where to install modules if you have multiple installed versions. I am thinking about this from perspective of a new pythoner (is there a word for a person who programs in python). I think many new pythoners may be like me and don't mess with the underling UNIX on a mac. My question/suggestion is that there be a nice tutorial for this. I am wiling to contribute much but I am still somewhat new to python and may need help with some details. Also where should this be posted, how do I post it. Do other think there is a need? Any willing to help? But of course I may have missed a great tutorial out there if so I think It needs to be easier to findor I need to learn how to look. Thanks Vincent -- http://mail.python.org/mailman/listinfo/python-list
docs error for PyBuffer_FillInfo?
I'm trying to wrap a C++-lib with SIP need to return a buffer-object from one method. I'm on python2.6 (OS X, but that doesn't matter I guess), and http://docs.python.org/c-api/buffer.html#Py_buffer gives a signature like this: int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int readonly, int infoflags)¶ However, the abstract.h of the Python-installation has this: PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, Py_ssize_t len, int readonly, int flags); And obviously enough, compiling my wrapper fails because there is an argument missing. So, I'm in need for a guide on how to use PyBuffer_FillInfo properly - all I've got is a void* and a total size of the buffer. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
In article 90303b55-8686-4d56-b89c-01e31d0a6...@l8g2000vbp.googlegroups.com, =?windows-1252?Q?Jure_Erzno=9Enik?= jure.erznoz...@gmail.com wrote: So, recently I started writing a part of this new system in Python. A report generator to be exact. Let's not go into existing offerings, they are insufficient for our needs. First I started on a few tests. I wanted to know how the reporting engine will behave if I do this or that. One of the first tests was, naturally, threading. The reporting engine itself will have separate, semi-independent parts that can be threaded well, so I wanted to test that. This is not something that I would expect Python threads to provide a performance boost for. I would expect that if it were a GUI app, it would improve responsiveness, properly designed. If performance were a goal, I would start by profiling it under a single-threaded design and see where the hotspots were, then either choose one of several options for improving performance or go multi-process. Note that I'm generally one of the Python thread boosters (unlike some people who claim that Python threads are worthless), but I also never claim that Python threads are good for CPU-intensive operations (which report generation is), *except* for making GUI applications more responsive. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ as long as we like the same operating system, things are cool. --piranha -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
In article h1l6m3$3f...@gemini.csx.cam.ac.uk, Jeremy Sanders jeremy+complangpyt...@jeremysanders.net wrote: Jesse Noller wrote: Sorry, you're incorrect. I/O Bound threads do in fact, take advantage of multiple cores. I don't know whether anyone else brought this up, but it looks like Python has problems with even this form of threading http://www.dabeaz.com/python/GIL.pdf Most of us have already seen this. It's a good point, but IME writing multi-threaded apps for multi-core machines, I think one should be careful to avoid reading too much into it. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ as long as we like the same operating system, things are cool. --piranha -- http://mail.python.org/mailman/listinfo/python-list
urllib2 urlopen takes too much time
I have encountered a performance problem using suds, which was traced down to _socket.recv. I am calling some web services and each of them uses about 0.2 sec and 99% of this time is spent on urllib2.urlopen, while the rest of the call is finished in milliseconds. Because of this, my web app works really slow, especially when it must do many ws calls. I could of course decrease the number of calls and do a lot of caching (which would be quite perilous and I wouldn't like to delve into this), but it seems as treating symptoms, rather than the illness itself. The machine I am connecting to through ws is in the same building, the connection should be really fast and mostly it is - except for using suds. Is it possible, that I could done something wrong and it hangs on this socket for too long? Have anyone encountered similar problems? Oh, and we did some profiling using also other tool written in C#, that also uses those web services and it worked much faster, so it doesn't seem to be connection problem. -- Filip Gruszczyński -- http://mail.python.org/mailman/listinfo/python-list
Re: generator expression works in shell, NameError in script
On Jun 18, 11:28 pm, greg g...@cosc.canterbury.ac.nz wrote: nn wrote: This is certainly an odd one. This code works fine under 2.6 but fails in Python 3.1. class x: ... lst=[2] ... gen=[lst.index(e) for e in lst] In 3.x it was decided that the loop variables in a list comprehension should be local, and not leak into the surrounding scope. This was implemented by making the list comprehension into a nested function. Unfortunately this leads to the same unintuitive behaviour as a genexp when used in a class scope. -- I don't get this - the only local loop variable is e, not lst. And lst is used twice in the generator expression, which is being complained about? It would generally be the case that a nested function would have access to its enclosing scope. In any case, even if/when the current behavior is explained or rationalized, it certainly appears un-intuitive, and that is another level of error! :-) -- http://mail.python.org/mailman/listinfo/python-list
urllib2 content-type headers
I have a little application that wants to send data to a Google API. This API requires an HTTP header to be set as follows: Authorization: GoogleLogin auth=[value of auth token goes here] Unfortunately, I'm getting nothing but 400 Bad Requests. I suspect this is due to an unfeature of urllib2. Notably, although you can use urllib2.Request's add_header method to append a header, the documentation (http://docs.python.org/library/urllib2.html) says that: remember that a few standard headers (Content-Length, Content-Type and Host) are added when the Request is passed to urlopen() (or OpenerDirector.open()). And: Note that there cannot be more than one header with the same name, and later calls will overwrite previous calls in case the key collides. To put it another way, you cannot rely on Content-Type being correct because whatever you set it to explicitly, urllib2 will silently change it to something else which may be wrong, and there is no way to stop it. What happened to explicit is better than implicit? -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 content-type headers
On Jun 21, 2009, at 12:01 PM, TYR wrote: I have a little application that wants to send data to a Google API. This API requires an HTTP header to be set as follows: Authorization: GoogleLogin auth=[value of auth token goes here] Unfortunately, I'm getting nothing but 400 Bad Requests. I suspect this is due to an unfeature of urllib2. Notably, although you can use urllib2.Request's add_header method to append a header, the documentation (http://docs.python.org/library/urllib2.html) says that: remember that a few standard headers (Content-Length, Content-Type and Host) are added when the Request is passed to urlopen() (or OpenerDirector.open()). And: Note that there cannot be more than one header with the same name, and later calls will overwrite previous calls in case the key collides. To put it another way, you cannot rely on Content-Type being correct because whatever you set it to explicitly, urllib2 will silently change it to something else which may be wrong, and there is no way to stop it. What happened to explicit is better than implicit? Hi TYR, I'm confused, are you having a problem with the Content-Type or Authorization headers? Some suggestions -- - Try sending the request to a server you control so you can see what it is actually receiving. Maybe urllib2 isn't overwriting your header at all, but you're sending (e.g.) a misconfigured auth token. - Use a protocol sniffer like Wireshark to see what's going out over the wire - Urrlib2 automates some things for you (like building headers), but as with all automated magic sometimes it's not what you want. The httplib module offers finer control over HTTP conversations. You might want to use httplib to debug this problem even if you find you don't need it in your final solution. good luck Philip -- http://mail.python.org/mailman/listinfo/python-list
Re: docs error for PyBuffer_FillInfo?
Diez B. Roggisch wrote: And obviously enough, compiling my wrapper fails because there is an argument missing. So, I'm in need for a guide on how to use PyBuffer_FillInfo properly - all I've got is a void* and a total size of the buffer. The second argument points to the (optional) object for that you are creating the view. The code in Object/stringobject.c is a good example: static int string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags) { return PyBuffer_FillInfo(view, (PyObject*)self, (void *)self-ob_sval, Py_SIZE(self), 1, flags); } Christian -- http://mail.python.org/mailman/listinfo/python-list
os.system vs subprocess
I get different behavior with os.system and subprocess (no surprise there I guess), but I was hoping for some clarification, namely why. If I type this directly into the command window: java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml mapoutput.txt mapoutput.txt stores the output: Command line mode: input file=censettings.xml 1358 files will be created in C:\Documents and Settings\Nate\Desktop \freqanalysis\tilefiles\CENSUS1-tiles 1358 tiles created out of 1358 in 16 seconds If I execute said command with subprocess, the output is not written to mapoutput.txt - the output just appears in the command window. If I execute said command with os.system, the output is written to mapoutput.txt like I expected. In reality all I want to do is access the first two lines of the above output before the process finishes, something which I haven't been able to manage with subprocess so far. I saw that somehow I might be able to use os.read(), but this is my first attempt at working with pipes/processes, so I'm a little overwhelmed. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Status of Python threading support (GIL removal)?
Hendrik van Rooyen m...@microcorp.co.za writes: I think that this is because (like your link has shown) the problem is really not trivial, and also because the model that can bring sanity to the party (independent threads/processes that communicate with queued messages) is seen as inefficient at small scale. That style works pretty well in Python and other languages. The main gripe about it for Python is the subject of this thread, i.e. the GIL. -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system vs subprocess
On Sun, Jun 21, 2009 at 10:12 AM, Natewalton.nathan...@gmail.com wrote: I get different behavior with os.system and subprocess (no surprise there I guess), but I was hoping for some clarification, namely why. If I type this directly into the command window: java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml mapoutput.txt mapoutput.txt stores the output: Command line mode: input file=censettings.xml 1358 files will be created in C:\Documents and Settings\Nate\Desktop \freqanalysis\tilefiles\CENSUS1-tiles 1358 tiles created out of 1358 in 16 seconds If I execute said command with subprocess, the output is not written to mapoutput.txt - the output just appears in the command window. Show us the subprocess version of you code. People tend to not get the parameters quite right if they're not familiar with the library. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
On Sun, Jun 21, 2009 at 5:25 AM, Piet van Oostrump...@cs.uu.nl wrote: I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. Examples are the postings by Dennis Lee Bieber wlfr...@ix.netcom.com that I am replying to (but I As addressed in an earlier thread, Mr. Bieber chooses to set a Usenet header (X-Noarchive) in his postings that suppresses their permanent archiving (and often the archiving of replies to his posts). I would direct you to the thread, but it looks like it wasn't archived. :P Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: raw_input with a pre-compiled data
Peter Otten wrote: Luca wrote: On Sat, Jun 20, 2009 at 6:38 PM, Chris Rebertc...@rebertia.com wrote: On Sat, Jun 20, 2009 at 7:17 AM, Lucaluca...@gmail.com wrote: Hi all. I need to use a function like the raw_input to read data from user command line, but I really like to pre-compile the choice and I'm not able to do this. There is some other function/module I can use? I wanna to pre-compile the raw_input input line with the current working path. What does pre-compile mean in this context? It's not clear at all, so I can't even understand your question. I'm really sorry to all that replied... In fact I literally traduced a With traduced you stumbled upon another false friend ;) http://it.wikipedia.org/wiki/Falso_amico concept from italian and the term precompiled was not so clear... What I mean is this: I wanna that raw_input (or other modules) ask to the user the data, but some data inserted is already present, to the user can cancel it with the BACKSPACE key. Examples below (the _ is the initial cursor position). raw_input(Insert the directory to work: ) Insert the directory to work: _ What I need is: XXX_raw_input(Insert the directory to work: , default=/home/john/) Insert the directory to work: /home/john_ In the second example a user can cancel the text /home/john. I hope this time is more clear, sorry again. import readline def input_default(prompt, default): def startup_hook(): readline.insert_text(default) readline.set_startup_hook(startup_hook) try: return raw_input(prompt) finally: readline.set_startup_hook(None) print input_default(directory? , default=/home/john) The cmd module may also be worth having a look. Peter The readline module is specific to Unix implementations. I don't know what OS the OP was using. -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts
Chris Rebert c...@rebertia.com (CR) wrote: CR On Sun, Jun 21, 2009 at 5:25 AM, Piet van Oostrump...@cs.uu.nl wrote: I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. Examples are the postings by Dennis Lee Bieber wlfr...@ix.netcom.com that I am replying to (but I CR As addressed in an earlier thread, Mr. Bieber chooses to set a Usenet CR header (X-Noarchive) in his postings that suppresses their permanent CR archiving (and often the archiving of replies to his posts). CR I would direct you to the thread, but it looks like it wasn't archived. :P Actually, I do see Mr. Bieber's posts, but not the ones he replies to. And I am not talking about the archives but about the regular NNTP server, although the retention period somewhere along the path could be so low that posts disappear before they reach us. Anyway, as I saw gmane mentioned in the replies I wondered if that would have something to do with the problem. -- 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: os.system vs subprocess
On Jun 21, 2:12 pm, Chris Rebert c...@rebertia.com wrote: On Sun, Jun 21, 2009 at 10:12 AM, Natewalton.nathan...@gmail.com wrote: I get different behavior with os.system and subprocess (no surprise there I guess), but I was hoping for some clarification, namely why. If I type this directly into the command window: java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml mapoutput.txt mapoutput.txt stores the output: Command line mode: input file=censettings.xml 1358 files will be created in C:\Documents and Settings\Nate\Desktop \freqanalysis\tilefiles\CENSUS1-tiles 1358 tiles created out of 1358 in 16 seconds If I execute said command with subprocess, the output is not written to mapoutput.txt - the output just appears in the command window. Show us the subprocess version of you code. People tend to not get the parameters quite right if they're not familiar with the library. Cheers, Chris --http://blog.rebertia.com- Hide quoted text - - Show quoted text - Here it is: gmapcreator = subprocess.Popen(java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 content-type headers
On Jun 21, 2009, at 12:01 PM, TYR wrote: Unfortunately, I'm getting nothing but 400 Bad Requests. I suspect this is due to an unfeature of urllib2. Notably, although you can use urllib2.Request's add_header method to append a header, the documentation (http://docs.python.org/library/urllib2.html) says that: remember that a few standard headers (Content-Length, Content-Type and Host) are added when the Request is passed to urlopen() (or OpenerDirector.open()). And: Note that there cannot be more than one header with the same name, and later calls will overwrite previous calls in case the key collides. To put it another way, you cannot rely on Content-Type being correct because whatever you set it to explicitly, urllib2 will silently change it to something else which may be wrong, and there is no way to stop it. What happened to explicit is better than implicit? Those headers are added (by AbstractHTTPHandler.do_request_) only if they are missing. -Miles -- http://mail.python.org/mailman/listinfo/python-list
Re: generator expression works in shell, NameError in script
On Jun 19, 2009, at 8:45 AM, Bruno Desthuilliers wrote: class Foo(object): ... bar = ['a', 'b', 'c'] ... baaz = list((b, b) for b in bar) but it indeed looks like using bar.index *in a generator expression* fails (at least in 2.5.2) : class Foo(object): ... bar = ['a', 'b', 'c'] ... baaz = list((bar.index(b), b) for b in bar) ... Traceback (most recent call last): File stdin, line 1, in module File stdin, line 3, in Foo File stdin, line 3, in genexpr NameError: global name 'bar' is not defined The reason that the first one works but the second fails is clearer if you translate each generator expression to the approximately equivalent generator function: class Foo(object): bar = ['a', 'b', 'c'] def _gen(_0): for b in _0: yield (b, b) baaz = list(_gen(iter(bar)) # PEP 227: the name bindings that occur in the class block # are not visible to enclosed functions class Foo(object): bar = ['a', 'b', 'c'] def _gen(_0): for b in _0: yield (bar.index(b), b) baaz = list(_gen(iter(bar)) -Miles -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system vs subprocess
Nate wrote: gmapcreator = subprocess.Popen(java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Try this: gmapcreator = subprocess.Popen( [java, -Xms128M, -Xmx512M, -jar, gmapcreator.jar, -dfile=censettings.xml], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = gmapcreator.communicate(stdin input) The subprocess doesn't use the shell so you have to apply the command as a list of strings. Do you really need stdin, stdout and stderr as pipes? If you aren't carefully with the API your program can block. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I replace this for loop with a join?
On Mon, 2009-04-13 at 17:03 +0200, WP wrote: Hello, I have dictionary {1:astring, 2:anotherstring, etc} I now want to print: Press 1 for astring Press 2 for anotherstring etc I could do it like this: dict = {1:'astring', 2:'anotherstring'} for key in dict.keys(): print 'Press %i for %s' % (key, dict[key]) Press 1 for astring Press 2 for anotherstring but can I use a join instead? Thanks for any replies! - WP In addition to the comments already made, this code will be quite broken if there is ever a need to localize your package in another language. -- http://mail.python.org/mailman/listinfo/python-list
Re: docs error for PyBuffer_FillInfo?
Christian Heimes schrieb: Diez B. Roggisch wrote: And obviously enough, compiling my wrapper fails because there is an argument missing. So, I'm in need for a guide on how to use PyBuffer_FillInfo properly - all I've got is a void* and a total size of the buffer. The second argument points to the (optional) object for that you are creating the view. The code in Object/stringobject.c is a good example: static int string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags) { return PyBuffer_FillInfo(view, (PyObject*)self, (void *)self-ob_sval, Py_SIZE(self), 1, flags); } But doesn't this mean the docs are faulty? Shall I report a bug? And I have to say that the docs are anything but clear to me. As I said, I've got a method void *lock(readonly=True) as part of a C++-library. So, all I've got is a void-pointer and a length (through another method). But I'm unsure about how to allocate the view - just with malloc? What about reference-counting, do I have to increment it? A self-contained example in the docs would be great. Any pointers? Thanks, Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
Piet van Oostrum wrote: I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. Examples are the postings by Dennis Lee Bieber wlfr...@ix.netcom.com that I am replying to (but I break the thread on purpose). For example the posting with Message-ID: mailman.1883.1245538633.8015.python-l...@python.org references: 77e831100906192220y5536d9d2oe5ca2dcc59084...@mail.gmail.com which is not present on my news server. I have been wondering why these disappear, and I noticed the following in the Dennis Lee Bieber posting: On Sat, 20 Jun 2009 11:48:21 -0600, Vincent Davis vinc...@vincentdavis.net declaimed the following in gmane.comp.python.general: So apparently some of these come through gmane.comp.python.general. I am posting and reading thru gmane and generally see no problem. Sometimes I do see replies before the posting being replied. Sometimes certain posts get 'echoed' about week after the original posting date. If a reply gets echoed, but not the original, and one missed both originally, that can look weird. tjr So my question is: would this be the cause of these disappearing postings? Are postings on gmane.comp.python.general not relayed to comp.lang.python? Are they relayed to the python mailing list? I find it quite disturbing that sometimes only half of a discussion is visible. -- http://mail.python.org/mailman/listinfo/python-list
GNUstep and Python
Has anyone used GNUstep? In addition to Objective-C, there are Java and Ruby bindings. Has anyone created a Python binding to GNUstep? -- http://mail.python.org/mailman/listinfo/python-list
RE: RE: Good books in computer science?
-From: Bob Martin [mailto:bob.mar...@excite.com] -.Sent: Thursday, 18 June 2009 6:07 p.m. -Subject: Re: RE: Good books in computer science? -in 117815 20090617 221804 Phil Runciman ph...@aspexconsulting.co.nz wrote: -Because it reminds me of when things went badly wrong. IBM360, Von Neumann = -architecture, no hardware stacks ... - -IMHO Burroughs and ICL had better approaches to OS design back then but had= -less resources to develop their ideas.=20 - -However, mainly this period marked a transition from the excitement and dis= -covery phase of computing to commercial power plays and take-overs. The bes= -t ideas in a field tend to get lost in the melee of competition. Early comp= -uters were rooted in academia and there was a lot of cross fertilisation of= -ideas and approaches. IMHO commerce affected layers of the stack where it = -had no useful contribution to make. Vertical integration warred against sou= -nd architecture. - -The book has an important message and I recommend that people read it. The = -book is to me, and possibly only me, an icon representing when things went = -wrong. -Well, it's an opinion, but certainly not one I would agree with! -AFAIAC the IBM 360 got everything right, which is why the instruction set is still -going strong 45 years later (I've used it for every one of those 45 years). Yes, I was afraid someone would use that sort of argument. Sadly, having the best instruction set does not lead to commercial success. If it did then Interdata would still be with us. They used IBM360 instructions. How many instruction sets have you used? I have used at least 9.(I nearly missed the DG Nova). KDF9 had the best set for general computing that I had the privilege of using but that is not to say it was the best. The Burroughs B series or PDP11 may have been better... and doubtless there are many more candidates. What I can say is that for scientific/engineering calculations the RPN of KDF9 was Great because assembler was no harder than using algol60 for the calculations part of the problems I worked on. Oh yes, I even used assembler on the IBM360 series. It was a 360/50. The experience Did impact on the force of my observations! FWIW I learned it using the training material For the ICL System 4 which was superior to IBM's. The ICL System 4 was not a success... despite its instruction set. ;-) -AFAIAC the IBM 360 got everything right How many known bugs did the OS end up with? I know it hit 50,000+ and counting. LOL Suffice to say we are on a journey and Python is part of the scenery. Phil -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance and forward references (prototypes)
Lorenzo Di Gregorio wrote: On 21 Jun., 01:54, Dave Angel da...@ieee.org wrote: ... class B(object): def __init__(self,test=None): if test==None: test = A() self.obj =() return ... I had also thought of using None (or whatever else) as a marker but I was curious to find out whether there are better ways to supply an object with standard values as a default argument. In this sense, I was looking for problems ;-) Of course the observation that def is an instruction and no declaration changes the situation: I would not have a new object being constructed for every instantiation with no optional argument, because __init__ gets executed on the instantiation but test=A() gets executed on reading 'def' If what you are worrying about is having a single default object, you could do something like this: class B(object): _default = None def __init__(self, test=None): if test is None: test = self._default if test is None: B._default = test = A() ... --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: GNUstep and Python
Paul Watson schrieb: Has anyone used GNUstep? In addition to Objective-C, there are Java and Ruby bindings. Has anyone created a Python binding to GNUstep? There is the pyobjc-binding for OSX, maybe that's suitable for GNUStep. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: class or instance method
Hrvoje Niksic wrote: ... class class_or_instance(object): def __init__(self, fn): self.fn = fn def __get__(self, obj, cls): if obj is not None: return lambda *args, **kwds: self.fn(obj, *args, **kwds) else: return lambda *args, **kwds: self.fn(cls, *args, **kwds) ... Just to polish a bit: import functools class ClassOrInstance(object): def __init__(self, fn): self._function = fn self._wrapper = functools.wraps(fn) def __get__(self, obj, cls): return self._wrapper(functools.partial(self._function, cls if obj is None else obj)) --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: class or instance method
On Jun 21, 2009, at 5:23 PM, Scott David Daniels wrote: Hrvoje Niksic wrote: ... class class_or_instance(object): def __init__(self, fn): self.fn = fn def __get__(self, obj, cls): if obj is not None: return lambda *args, **kwds: self.fn(obj, *args, **kwds) else: return lambda *args, **kwds: self.fn(cls, *args, **kwds) ... Just to polish a bit: import functools class ClassOrInstance(object): def __init__(self, fn): self._function = fn self._wrapper = functools.wraps(fn) def __get__(self, obj, cls): return self._wrapper(functools.partial(self._function, cls if obj is None else obj)) from types import MethodType class ClassOrInstance(object): def __init__(self, func): self._func = func def __get__(self, obj, cls): return MethodType(self._func, cls if obj is None else obj, cls) -Miles -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I replace this for loop with a join?
Paul Watson paul.hermeneu...@gmail.com writes: On Mon, 2009-04-13 at 17:03 +0200, WP wrote: dict = {1:'astring', 2:'anotherstring'} for key in dict.keys(): print 'Press %i for %s' % (key, dict[key]) In addition to the comments already made, this code will be quite broken if there is ever a need to localize your package in another language. How is this code especially broken? AFAICT, it merely needs the strings marked for translation, which is the best i18n situation any regular program can hope for anyway. -- \ “Crime is contagious… if the government becomes a lawbreaker, | `\ it breeds contempt for the law.” —Justice Louis Brandeis | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system vs subprocess
On Jun 21, 3:49 pm, Christian Heimes li...@cheimes.de wrote: Nate wrote: gmapcreator = subprocess.Popen(java -Xms128M -Xmx512M -jar gmapcreator.jar -dfile=censettings.xml, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) Try this: gmapcreator = subprocess.Popen( [java, -Xms128M, -Xmx512M, -jar, gmapcreator.jar, -dfile=censettings.xml], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = gmapcreator.communicate(stdin input) The subprocess doesn't use the shell so you have to apply the command as a list of strings. Do you really need stdin, stdout and stderr as pipes? If you aren't carefully with the API your program can block. Christian Christian, Thanks for your response. Related to this talk about shells, maybe you could point me towards a resource where I could read about how windows commands are processed w/w/o shells? I guess I assumed all subprocess commands were intepreted by the same thing, cmd.exe., or perhaps the shell. I guess this also ties in with me wondering what the whole subprocess Popen instantiation encompassed (the __init__ of the subprocess.Popen class?). I don't think I need stdin, stdout, stderr as pipes, I just was faced with several options for how to capture these things and I chose subprocess.PIPE. I could also os.pipe my own pipes, or create a file descriptor in one of a couple of ways, right? I'm just unclear on which method is preferable for me. All I want to do is pull the first 2 lines from the output before gmapcreator.jar finishes. The first 2 lines of output are always the same except a few numbers. -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
Piet van Oostrum wrote: I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. I see the same problem. I suspect it's because of over-vigorous spam filtering from Usenet providers. Some even block everything from anyone using Google Groups. It's quite frustrating, to have perfectly valid Python-related posts go missing while dozens of posts offering to sell well-known brands of shoes and watches are delivered. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system vs subprocess
Nate wrote: Thanks for your response. Related to this talk about shells, maybe you could point me towards a resource where I could read about how windows commands are processed w/w/o shells? I guess I assumed all subprocess commands were intepreted by the same thing, cmd.exe., or perhaps the shell. The subprocess module never uses the shell unless you tell it so. On Unix the modules uses fork() the exec*() familiy to create a new process. On Windows it's the CreateProcess() api. If you want to read about the Windows stuff then have fun at http://msdn.microsoft.com/ ;) I guess this also ties in with me wondering what the whole subprocess Popen instantiation encompassed (the __init__ of the subprocess.Popen class?). It does *a lot* of stuff. The subprocess module tries very hard to create an easy to use interface that abstracts all OS specific traps very well. Most of the subprocess module is written in Python but that doesn't mean it's easy to understand. Have fun again! I don't think I need stdin, stdout, stderr as pipes, I just was faced with several options for how to capture these things and I chose subprocess.PIPE. I could also os.pipe my own pipes, or create a file descriptor in one of a couple of ways, right? I'm just unclear on which method is preferable for me. All I want to do is pull the first 2 lines from the output before gmapcreator.jar finishes. The first 2 lines of output are always the same except a few numbers. os.pipe() are suffering from the same issue as subprocess.PIPE. In fact the PIPE constant tells subprocess to use OS specific pipes. If you don't read from all pipes simultaneously one pipe may get filled up to its buffer limit and both programs block. As long as you use just one PIPE or the communicate() method then nothing can get wrong. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamically associate radio buttons with droplists
In article f28e2bcc-3b51-4d43-81e7-9a7810040...@o36g2000vbi.googlegroups.com, Leo Brugud sakradevanamin...@gmail.com wrote: Not being very familiar with python, nor with cgi/http, I intend to have 3 of buttons in a webpage, each of them is associate with a file (so I have 3 files, too) What I would like to have is, when users choose a button, the droplist update automatically to load the contents of the associated file. Can someone educate me the approach of this? Are you trying to do this without requiring the user to click the submit button? If yes, you need to learn JavaScript (although I think there are web frameworks that will auto-generate the JavaScript, you need to know JavaScript in order to do debugging). -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ as long as we like the same operating system, things are cool. --piranha -- http://mail.python.org/mailman/listinfo/python-list
pyinstaller
Newbie here using Python 2.6.2 on MS WinXP Pro SP3. I'm trying create an frozen exec and was able to generate and exe file. python D:\pyinstaller-1.3\Makespec.py -F myprog.py python D:\pyinstaller-1.3\Build.py myprog.spec --paths=D: \pyinstaller-1.3;D:\PROJECTS\pyproject but when I ran myprog.exe i get this: Traceback (most recent call last): File string, line 2, in module File D:\pyinstaller-1.3\iu.py, line 312, in importHook mod = _self_doimport(nm, ctx, fqname) File D:\pyinstaller-1.3\iu.py, line 398, in doimport exec co in mod.__dict__ File D:\PROJECTS\python.paging.system.client \buildpaging_system_client\out1.p yz/MySQLdb, line 19, in module File D:\pyinstaller-1.3\iu.py, line 312, in importHook mod = _self_doimport(nm, ctx, fqname) File D:\pyinstaller-1.3\iu.py, line 382, in doimport mod = director.getmod(nm) File D:\pyinstaller-1.3\iu.py, line 215, in getmod mod = owner.getmod(nm) File D:\pyinstaller-1.3\iu.py, line 77, in getmod mod = imp.load_module(nm, fp, attempt, (ext, mode, typ)) ImportError: _mysql: init failed ~~~ I have to source files namely: myprog.py mp3.py This is the content of spec file: a = Analysis([os.path.join(HOMEPATH,'support\\_mountzlib.py'), os.path.join(HOMEPATH,'support\\useUnicode.py'), 'myprog.py'], pathex=['D:\\PROJECTS\\pyproject']) pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, a.binaries, name='myprog.exe', debug=False, strip=False, upx=False, console=True ) Please help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
Dennis Lee Bieber wrote: unless one is reading from a server that interprets X-no-archive to mean delete before reading. Can't be too careful with security. Destroy it, memorize it and then read it! -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: pyinstaller
Renamed the project directory. from ... File D:\PROJECTS\python.paging.system.client \buildpaging_system_client\out1.p ... to ... File D:\PROJECTS\pyproject \buildpyproject\out1.p ... -- http://mail.python.org/mailman/listinfo/python-list
Re: generator expression works in shell, NameError in script
guthrie wrote: -- I don't get this - the only local loop variable is e, not lst. Yes, but the whole list comprehension gets put into a nested function, including the part that evaluates lst. (It's not strictly *necessary* to do that, but that's the way it happens to be implemented at the moment.) It would generally be the case that a nested function would have access to its enclosing scope. Usually, but class namespaces are a special case -- they're not considered to be enclosing scopes, even though textually they're written that way. it certainly appears un-intuitive It is, but it's hard to see what could be done to improve the situation without introducing worse problems. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: pyinstaller
Imported files in myprog.py: import MySQLdb import os # works on Windows or Linux, also Vista import os.path import time import mp3 ~~~ Content of mp3.py: # -*- coding: utf-8 -*- #Michel Claveau import time from ctypes import windll, c_buffer class mci: def __init__(self): self.w32mci = windll.winmm.mciSendStringA self.w32mcierror = windll.winmm.mciGetErrorStringA def send(self,commande): buffer = c_buffer(255) errorcode = self.w32mci(str(commande),buffer,254,0) if errorcode: return errorcode, self.get_error(errorcode) else: return errorcode,buffer.value def get_error(self,error): error = int(error) buffer = c_buffer(255) self.w32mcierror(error,buffer,254) return buffer.value def directsend(self, txt): (err,buf)=self.send(txt) if err != 0: print'Error',str(err),'sur',txt,':',buf return (err,buf) ### def play(mp3file): xmci=mci() xmci.directsend('open ' + mp3file + ' alias toto') xmci.directsend('set toto time format milliseconds') err,buf=xmci.directsend('status toto length ') #print 'Duree du fichier : ',buf,' millisecondes' soundlength = int(buf) / 1000 err,buf=xmci.directsend('play toto from 0 to '+str(buf)) #time.sleep(int(buf)/1000) time.sleep(soundlength + 1) xmci.directsend('close toto') -- http://mail.python.org/mailman/listinfo/python-list
Re: pyinstaller
Content of warnmyprog.txt: W: no module named posix (conditional import by os) W: no module named optik.__all__ (top-level import by optparse) W: no module named readline (delayed, conditional import by cmd) W: no module named readline (delayed import by pdb) W: no module named pwd (delayed, conditional import by posixpath) W: no module named org (top-level import by pickle) W: no module named ctypes.windll (top-level import by mp3) W: no module named ctypes.c_buffer (top-level import by mp3) W: no module named posix (delayed, conditional import by iu) W: no module named fcntl (conditional import by subprocess) W: no module named org (top-level import by copy) W: no module named _emx_link (conditional import by os) W: no module named optik.__version__ (top-level import by optparse) W: no module named fcntl (top-level import by tempfile) W: __all__ is built strangely at line 0 - collections (C:\Python26\lib \collections.pyc) W: delayed exec statement detected at line 0 - collections (C: \Python26\lib\collections.pyc) W: delayed conditional __import__ hack detected at line 0 - doctest (C: \Python26\lib\doctest.pyc) W: delayed exec statement detected at line 0 - doctest (C: \Python26\lib\doctest.pyc) W: delayed conditional __import__ hack detected at line 0 - doctest (C: \Python26\lib\doctest.pyc) W: delayed __import__ hack detected at line 0 - encodings (C: \Python26\lib\encodings\__init__.pyc) W: __all__ is built strangely at line 0 - optparse (D: \pyinstaller-1.3\optparse.pyc) W: delayed __import__ hack detected at line 0 - ctypes (C: \Python26\lib\ctypes\__init__.pyc) W: delayed __import__ hack detected at line 0 - ctypes (C: \Python26\lib\ctypes\__init__.pyc) W: __all__ is built strangely at line 0 - dis (C:\Python26\lib \dis.pyc) W: delayed eval hack detected at line 0 - os (C:\Python26\lib\os.pyc) W: __all__ is built strangely at line 0 - __future__ (C:\Python26\lib \__future__.pyc) W: delayed conditional __import__ hack detected at line 0 - unittest (C:\Python26\lib\unittest.pyc) W: delayed conditional __import__ hack detected at line 0 - unittest (C:\Python26\lib\unittest.pyc) W: __all__ is built strangely at line 0 - tokenize (C:\Python26\lib \tokenize.pyc) W: delayed exec statement detected at line 0 - bdb (C:\Python26\lib \bdb.pyc) W: delayed eval hack detected at line 0 - bdb (C:\Python26\lib \bdb.pyc) W: delayed eval hack detected at line 0 - bdb (C:\Python26\lib \bdb.pyc) W: delayed __import__ hack detected at line 0 - pickle (C: \Python26\lib\pickle.pyc) W: delayed __import__ hack detected at line 0 - pickle (C: \Python26\lib\pickle.pyc) W: delayed conditional exec statement detected at line 0 - iu (D: \pyinstaller-1.3\iu.pyc) W: delayed conditional exec statement detected at line 0 - iu (D: \pyinstaller-1.3\iu.pyc) W: delayed eval hack detected at line 0 - gettext (C:\Python26\lib \gettext.pyc) W: delayed __import__ hack detected at line 0 - optik.option_parser (D:\pyinstaller-1.3\optik\option_parser.pyc) W: delayed conditional eval hack detected at line 0 - warnings (C: \Python26\lib\warnings.pyc) W: delayed conditional __import__ hack detected at line 0 - warnings (C:\Python26\lib\warnings.pyc) W: __all__ is built strangely at line 0 - optik (D: \pyinstaller-1.3\optik\__init__.pyc) W: delayed exec statement detected at line 0 - pdb (C:\Python26\lib \pdb.pyc) W: delayed conditional eval hack detected at line 0 - pdb (C: \Python26\lib\pdb.pyc) W: delayed eval hack detected at line 0 - pdb (C:\Python26\lib \pdb.pyc) W: delayed conditional eval hack detected at line 0 - pdb (C: \Python26\lib\pdb.pyc) W: delayed eval hack detected at line 0 - pdb (C:\Python26\lib \pdb.pyc) -- http://mail.python.org/mailman/listinfo/python-list
Re: os.system vs subprocess
In message mailman.1925.1245613790.8015.python-l...@python.org, Christian Heimes wrote: The subprocess doesn't use the shell ... It can if you tell it to. -- http://mail.python.org/mailman/listinfo/python-list
RE: RE: Good books in computer science?
In message mailman.1928.1245616909.8015.python-l...@python.org, Phil Runciman wrote: What I can say is that for scientific/engineering calculations the RPN of KDF9 was Great because assembler was no harder than using algol60 for the calculations part of the problems I worked on. Unfortunately, we had to learn the hard way that machine instruction sets must be designed for efficiency of execution, not ease of use by humans. Stack-based architectures, for all their charm, cannot match register-based ones in this regard. -- http://mail.python.org/mailman/listinfo/python-list
Re: Meta question: disappearing posts (was Re: calculating a self.value, self.randomnum = normalvariate(x, y))
In article m21vpddb9y.fsf...@cs.uu.nl, Piet van Oostrum p...@cs.uu.nl wrote: I notice that I see several postings on news:comp.lang.python that are replies to other postings that I don't see. As stated previously, my suspicion is that at least some is caused by a problem with MIME messages and the mail-news gateway on python.org. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ as long as we like the same operating system, things are cool. --piranha -- http://mail.python.org/mailman/listinfo/python-list
Re: File Syncing
dads wayne.dads.b...@gmail.com wrote: On Jun 20, 11:21 am, Lawrence D'Oliveiro l...@geek- central.gen.new_zealand wrote: In message b2c37939-f921-4ea5- b0d7-586b1b332...@t10g2000vbg.googlegroups.com, dads wrote: What would I have to learn to be able to sync the text files on each server? How big is the text file? If it's small, why not have your script read it directly from a master server every time it runs, instead of having a local copy. Yeah the text files will never get bigger than a 100k. I don't think they have a master server but i'll check. Thanks He's suggesting that you just PICK one and make that the master server. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Idioms and Anti-Idioms Question
I have a question about the Using Backslash to Continue Statements in the howto Idioms and Anti-Idioms in Python (http://docs.python.org/howto/doanddont.html#using-backslash-to-continue-statements) It says: ...if the code was: value = foo.bar()['first'][0]*baz.quux(1, 2)[5:9] \ + calculate_number(10, 20)*forbulate(500, 360) then it would just be subtly wrong. What is subtly wrong about this piece of code? I can't see any bugs and can't think of subtle gotchas (e.g. the '\' is removed or the lines become separated, because in both cases an IndentationError would be raised). Cheers, Ben -- http://mail.python.org/mailman/listinfo/python-list
Re: Good books in computer science?
On Sun, Jun 14, 2009 at 06:42:50PM EDT, Lawrence D'Oliveiro wrote: In message mailman.1558.1245010564.8015.python-l...@python.org, Chris Jones wrote: Vivaldi vs. Mozart And the latter especially had definitely mastered his editor. Just think of the sheer volume of the coding he managed during his short life. Not many bugs either… I thought Vivaldi did more. The style of music was such that they could virtually sketch it out in shorthand, and leave it to the copyists to expand to proper notation for the musicians to play. I imagine that it was also the job of copyists to fix the typos. 100 years before Frederick W. Taylor was born..? Vivaldi ran a school for musically-minded young women, I heard, so his alumni may have pitched in. Mozart on the other hand, pretty much must have spent his days coding. It has been estimated that the fastest copyist would need years to manually reproduce the sum total of his manuscripts. Mind you, that's only stuff I read years ago, and even though I looked around a bit, I have no evidence to corroborate. In other words, high productivity was a direct consequence of adoption of a cookie-cutter style. It looks like we pretty much agree. You make it sound like it was Vivaldi who invented Pacbase. :-) Maybe I'm nitpicking, but the one thing I don't understand is how you practice programming. The term makes obvious sense when you're talking about your golf swing, acquiring competitive driving skills, playing tetris.. But programming..?? CJ -- http://mail.python.org/mailman/listinfo/python-list
Re: Idioms and Anti-Idioms Question
On Mon, 22 Jun 2009 00:14:50 -0400, Ben Charrow wrote: I have a question about the Using Backslash to Continue Statements in the howto Idioms and Anti-Idioms in Python (http://docs.python.org/howto/doanddont.html#using-backslash-to- continue-statements) It says: ...if the code was: value = foo.bar()['first'][0]*baz.quux(1, 2)[5:9] \ + calculate_number(10, 20)*forbulate(500, 360) then it would just be subtly wrong. What is subtly wrong about this piece of code? I can't see any bugs and can't think of subtle gotchas (e.g. the '\' is removed or the lines become separated, because in both cases an IndentationError would be raised). As examples go, it's pretty lousy because you can't just copy and paste it into an interpreter session and see for yourself. However, with some helper objects: def forbulate(*args): return [1] def calculate_number(*args): return 2 class K: pass foo = K() foo.bar = lambda: {'first': [1, 2, 3]} baz = K() baz.quux = lambda *args: [3]*10 value = foo.bar()['first'][0]*baz.quux(1, 2)[5:9] \ + calculate_number(10, 20)*forbulate(500, 360) I can run the example. I confirm that it works without a space after the line continuation character. Using Python 2.5, if I put a space after the backslash I get SyntaxError: unexpected character after line continuation character followed by IndentationError: unexpected indent So I don't understand the claim that the code is subtly wrong either. It looks to me like it's obviously wrong. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
[issue6317] winsound.PlaySound doesn't accept non-unicode string
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Added file: http://bugs.python.org/file14326/py3k_winsound.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6317] winsound.PlaySound doesn't accept non-unicode string
Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp: Removed file: http://bugs.python.org/file14325/py3k_winsound.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6318] HTMLParser Attributes Containing Javascript
New submission from Eric e.rykwal...@gmail.com: The line: n.feed('a onclick=alert(\\test\\)test/a') is not matched by the regular expressions for attributes. -- components: Library (Lib) messages: 89555 nosy: ericryk severity: normal status: open title: HTMLParser Attributes Containing Javascript versions: Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6318 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6318] HTMLParser Attributes Containing Escaped Quotes
Eric e.rykwal...@gmail.com added the comment: More specifically, the attributes cannot contain escaped quotes of the same kind that the attribute value is wrapped in. -- title: HTMLParser Attributes Containing Javascript - HTMLParser Attributes Containing Escaped Quotes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6318 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6317] winsound.PlaySound doesn't accept non-unicode string
Martin v. Löwis mar...@v.loewis.de added the comment: Even for 3k, I would defer this patch after the 3.1 release, as it is an incompatible change (requiring a Unicode string where a byte string was acceptable before). -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6317] winsound.PlaySound doesn't accept non-unicode string
Changes by Martin v. Löwis mar...@v.loewis.de: -- priority: release blocker - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6318] HTMLParser Attributes Containing Escaped Quotes
Georg Brandl ge...@python.org added the comment: That snippet is not valid HTML. The attribute string is not a JS string, so quotes in it must be escaped with 'quot;', not '\'. -- nosy: +georg.brandl resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6318 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4856] Remove checks for win NT
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: Here is an updated patch with Py_GetFileAttributesEx[AW] removal. I propose to commit this to trunk, and merge it to py3k after 3.1 will be released. -- Added file: http://bugs.python.org/file14327/remove_w9x_code.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4856 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6266] cElementTree.iterparse ElementTree.iterparse return differently encoded strings
Fredrik Lundh fred...@effbot.org added the comment: It should definitely give what's intended (either a Unicode string, or, if the content is plain ASCII, an 8-bit string). What did you get instead? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6266 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6317] winsound.PlaySound doesn't accept non-unicode string
Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment: I agree. By the way, I created the patch for trunk experimentally. -- Added file: http://bugs.python.org/file14328/py2x_winsound.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6317 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5450] test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped
Guilherme Polo ggp...@gmail.com added the comment: Finally I'm looking into this again. So, for now, I decided to only move the tk load tests to Lib/lib-tk/test/test_tkinter under a new module named test_loadtk. Lib/test/test_tcl remains almost the same, except it no longer it contain those tests related to tk loading. Patch attached. May I reassign it to me David ? -- Added file: http://bugs.python.org/file14329/moving_loadtktests.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5450] test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped
R. David Murray rdmur...@bitdance.com added the comment: On Sun, 21 Jun 2009 at 14:57, Guilherme Polo wrote: Patch attached. May I reassign it to me David ? Absolutely. -- title: test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped - test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6266] cElementTree.iterparse ElementTree.iterparse return differently encoded strings
nlopes shelika.v...@gmail.com added the comment: I got pure gibberish output, but I know why. It was a compilation gone wrong. To get the output as ElementTree, I think instead of parcel = Py_BuildValue(sN, (prefix) ? prefix : , makestring(uri)); it should be parcel = Py_BuildValue(sN, (prefix) ? prefix : , PyUnicode_AsUnicode(makestring(uri), strlen(uri))); Else it will not be the expected result. Or am I overseeing something? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6266 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5450] test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped
Guilherme Polo ggp...@gmail.com added the comment: Running tk tests through both Lib/test/test_tk.py and Lib/test/regrtest.py show the desired behaviour (from what I understood from your description and from what I tested). It has been committed now, r73495 (trunk). Should 2.6 and 3.0 really receive this patch ? I've removed them from the list in this issue, please add back if it is really needed. -- assignee: r.david.murray - gpolo versions: -Python 2.6, Python 3.0, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5450] test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped
R. David Murray rdmur...@bitdance.com added the comment: No, I don't see any reason to bother backporting. From my understanding we're not backporting anything to 3.0 at this point anyway. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5450] test_tcl testLoadTk fails if DISPLAY defined but connect fails, instead of being skipped
Guilherme Polo ggp...@gmail.com added the comment: Fine, closing then. Committed as r73497 on py3k. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5450 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com