ANN: PyPM Index - build notification by author; import data
Hi, There are, now, a couple more features to the previously announced PyPM Index that I think would be of interest if you are a developer of Python packages on PyPI. 1. an RSS feed for each author that shows the recently failing builds (eg: to identify bugs in releases) 2. The import feature shows if multiple packages provide the same import (eg: site-packages/tests) ... and, map packages to imports and vice-versa. See the import conflicts section for interesting set of cases. For more details, see my blog post: http://www.activestate.com/blog/2010/11/python-pypm-index-author-build-notification-imports-recipes-integration -- Sridhar Ratnakumar Python Developer ActiveState, The Dynamic Language Experts http://www.activestate.com/ On 11/10/2010 5:08 PM, Sridhar Ratnakumar wrote: Hi, I'd like to announce the availability of PyPM Index - frontend to browse/search Python packages available in the PyPM repository: http://code.activestate.com/pypm/ The site also has some nifty features that, I think, may be of use to package authors: 1. Author pages 2. Build RSS notification (released with a setup.py bug?) 3. Dependency information For more details, see this blog post: http://www.activestate.com/blog/2010/11/pypm-index-python-developers -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN] PythonWebkit bindings for WebkitDFB
WebkitDFB is an experimental port to allow the webkit web browser engine to use DirectFB (http://directfb.org). It is lightning-quick to start up (no large widget set to load), yet has the potential to provide full HTML5 functionality. The PythonWebkit project, http://www.gnu.org/software/pythonwebkit brings 300+ DOM objects and 2,000+ fully W3C-compliant python-based DOM functions to webkit, making python effectively a peer of javascript (doc.body.style, getElementsByTagName, appendChild, setTimeout, XMLHttpRequest, onclick etc.) These two projects have been brought together in the same source repository. If startup time and CPU usage is important (as it is on embedded systems) then please do consider helping with WebkitDFB by funding its ongoing development and/or helping Denis out. If startup time and CPU usage and _python_ are important... :) in this rather short announcement, it's easy to miss the significance: yes, webkit the web browser engine, directfb the direct framebuffer engine, and python the utterly cool and beautiful programming language have been combined into the same package and sentence. more information at http://www.gnu.org/software/pythonwebkit. l. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[ANN] PythonWebkit bindings for WebkitDFB
WebkitDFB is an experimental port to allow the webkit web browser engine to use DirectFB (http://directfb.org). It is lightning-quick to start up (no large widget set to load), yet has the potential to provide full HTML5 functionality. The PythonWebkit project, http://www.gnu.org/software/pythonwebkit brings 300+ DOM objects and 2,000+ fully W3C-compliant python-based DOM functions to webkit, making python effectively a peer of javascript (doc.body.style, getElementsByTagName, appendChild, setTimeout, XMLHttpRequest, onclick etc.) These two projects have been brought together in the same source repository. If startup time and CPU usage is important (as it is on embedded systems) then please do consider helping with WebkitDFB by funding its ongoing development and/or helping Denis out. If startup time and CPU usage and _python_ are important... :) in this rather short announcement, it's easy to miss the significance: yes, webkit the web browser engine, directfb the direct framebuffer engine, and python the utterly cool and beautiful programming language have been combined into the same package and sentence. more information at http://www.gnu.org/software/pythonwebkit. l. -- http://mail.python.org/mailman/listinfo/python-list
Re: building a web interface
This is really great. I wish I could come up with some creative new ways to say thank you, but... thank you :-) Shel On Nov 21, 6:10 pm, Martin Gregorie mar...@address-in-sig.invalid wrote: On Sun, 21 Nov 2010 15:40:10 -0800, Shel wrote: I am confused about multiple simultaneous users, which I would like to be able to accommodate. On the db side, I have a structure to store data for each user, and know a bit about selectively locking data, although I have not implemented that yet, so will see what happens. I realise what I wrote last night wasn't all that clear. Terms: 'transaction' and 'session'. A web server 'transaction' consists of a request from a user that results in a page being sent to the user. That's it. It is an isolated action that does not depend in the web server knowing anything about the user because all the information it needs to decide which page to send was supplied when the user sent in the URL of the page. Now if the user clicks on a link on that page, his browser sends the URL in the link to the server, which in turn fishes out another page and sends it back to the user. As far as the server is concerned, there is no connection whatever between the two requests: either or both URLs could have been copied from a piece of paper for all it knows or cares. There is no concept of context or a session involved. A 'session' involves context. Think of what happens when you login to a computer. That starts a login session that has context: the computer now knows who you are and provides context by connecting you to your login directory and opening some work space which is used to remember which directory you're in, what commands you issued (so you can look at the history), etc. The session and its context persists until you log out. In what you're intending to do, a user will start a session by starting to use your program and that session will last until the user disconnects from the session. All the web server knows is that instead of finding a page on disk some place it passes your user's request to your program and sends its output, in the form of a web page, back to the user. It does this each time it receives a request from the user because all the user's requests contain the same URL - that of your program. The server does this without knowing there is such a thing as a session or that there is any context belonging to the user. The upshot is that your program has to keep track of all the active sessions and maintain context for each active session. It also needs a way to recognise and get rid of dead sessions because sessions don't always end cleanly: the line may go down or the user may forget he was using your program and turn his PC off. For instance, if the session context has a timestamp, you might delete it after, say, 20 hours of inactivity, or when the user logs on again. If the data is sensitive, you might also force a new logon after 10 minutes of inactivity. The database is as good a place as any for keeping session and context data - if its well structured the context may well form a single (large) row on one table, but you do need a unique key for it. That could even be the login name provided you're able to include it in every page you send to the user and can guarantee that the browser will send it back as part of the next request. A hidden field on the page will do this automatically. The basic program cycle will be: - receive a request - read the context for the session - use data in the request to carry out the requested action - write the updated context back to the database - create the output page and send it to the user though of course you need additional dialogue to deal with both valid and invalid logons and logoffs. I don't really get how multiple users work in terms of pretty much everything else, like if the Python code is running on the server, then... well, I just don't know. Hopefully the above made it a bit clearer. Maybe I should try to get it running for multiple discrete users first, and then think about simultaneous users, or is that a bad way to go about things? Or maybe it will start to make more sense when I get into building the interface? Any info/suggestions are very welcome. For bare desktop development I would split the program into three parts: 1) the program itself, written to run a single transaction each time its called. Inputs would be the bits of the users message it needs to act on and the current session context record. 2) a testing harness that accepts user input from the console, sends output back to the console and maintains a single session context record in memory: IOW it runs your program in single user mode. 3)the web server interface which retrieves the session context record, passes it and the input to your program and, after that has run, saves the session context record and passes the output to the web server for
Re: building a web interface
Howdy! I'm mildly biased, being the author of the framework, but I can highly recommend WebCore for rapid prototyping of web applications; it has templating via numerous template engines, excellent JSON (AJAJ) support, and support for database back-ends via SQLAlchemy. It also has session support baked-in via a project called Beaker. Documentation is fairly complete, and I can be found camping in the #webcore IRC channel on irc.freenode.net at strange hours. If you can write a class, you can have a fully operational web application in a single file of ~8 lines or so. (Or you can create a complete easy-installable Python package with multiple modules.) For information, see: http://www.web-core.org/ As an interactive-fiction example: class RootController(web.core.Controller): def index(self): This returns a template that uses JavaScript to call execute(). The JavaScript adds the result of execute() to the display. session = db.Session().save() return './templates/main.html', dict(session=session.id) def execute(self, session, statement): Load our session and pass the input off to our interactive fiction library of choice. Return the result if all went well. session = db.Session.get(session) try: result = myiflib.execute(session, statement) except myiflib.ParseError: return 'json:', dict(status=failure, message=Error...) return 'json:', dict(status=success, message=result) — Alice. -- http://mail.python.org/mailman/listinfo/python-list
what a cheap rule
Sometimes the golden rule in Python of explicit is better than implicit is so cheap that it can be thrown away for the trouble of typing an empty tuple. Today when I am explaining that in Python 3, there are two ways to raise exceptions: raise Exception raise Exception() and that the first one is the same as the second one, as Python will add the missing pair of parenthesis. I felt their pain as they gasped. Before that, I have already explained to them this piece of code: try: raise SomeException() except SomeException: print('Got an exception here') by saying that the except-clause will match anything that belong to the SomeException class. Without knowing this secrete piece of information (that a pair of parenthesis is automatically provided), the following code would be hard to understand: try: raise SomeException except SomeException: print('Got an exception here') because the class object SomeException is not an instance of itself, so a not-so-crooked coder will not consider a match here. So, the explicit is better than implicit rule is thrown out of the window so cheaply, that it literally worth less than an empty tuple! Regards, Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: Pypi (Cheeseshop) Score - derivation of ?
Occurrence of search term weighted by field (name, summary, keywords, description, author, maintainer) I thought PyPI used to offer a 'kwality' score for packages, based on the presence of installers, doc files, tests etc. Does anyone know what happened to that? There was indeed a kwalitee computation (cheesecake); it is unmaintained. It is a urban myth that this had any impact on search results. It never did. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
AIX 5.3 - Enabling Shared Library Support Vs Extensions
All, When I configure python to enable shared libraries, none of the extensions are getting built during the make step due to this error. building 'cStringIO' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I. -IInclude -I./Include -I/opt/freeware/include -I/opt/freeware/include/readline -I/opt/freeware/include/ncurses -I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include -I/u01/home/apli/wm/GDD/Python-2.6.6 -c /u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.c -o build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o -L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so *collect2: library libpython2.6 not found* building 'cPickle' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I. -IInclude -I./Include -I/opt/freeware/include -I/opt/freeware/include/readline -I/opt/freeware/include/ncurses -I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include -I/u01/home/apli/wm/GDD/Python-2.6.6 -c /u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.c -o build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cPickle.o -L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cPickle.so *collect2: library libpython2.6 not found* This is on AIX 5.3, GCC 4.2, Python 2.6.6 I can confirm that there is a libpython2.6.a file in the top level directory from where I am doing the configure/make etc Here are the options supplied to the configure command ./configure --enable-shared --disable-ipv6 --with-gcc=gcc CPPFLAGS=-I /opt/freeware/include -I /opt/freeware/include/readline -I /opt/freeware/include/ncurses Please guide me in getting past this error. Thanks for your help on this. Regards, Anurag -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'
--- On Thu, 11/25/10, Phlip phlip2...@gmail.com wrote: From: Phlip phlip2...@gmail.com Subject: a regexp riddle: re.search(r' To: python-list@python.org Date: Thursday, November 25, 2010, 8:46 AM HypoNt: I need to turn a human-readable list into a list(): print re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c').groups() That currently returns ('c',). I'm trying to match any word \w+ followed by a comma, or a final word preceded by and. The match returns 'a, bbb, and c', but the groups return ('bbb', 'c'). What do I type for .groups() to also get the 'a'? First of all, the 'bbb' coresponds to the first capturing group and 'c' the second. But 'a' is forgotten be cause it was the first match of the first group, but there is a second match 'bbb'. Generally, a capturing group only remembers the last match. It also seems that your re may match this: 'and c', which does not seem to be your intention. So it may be more intuitively written as: r'(?:(\w+), )+and (\w+)' I'm not sure how to get it done in one step, but it would be easy to first get the whole match, then process it with: re.findall(r'(\w+)(?:,|$)', the_whole_match) cheers, Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Processing file with lists.
I have a text file , having fields delimited by ; in the first line and all the way down is the data taken for those fields . Say FAMILY NAME;SPECIES/SUBSPECIES;GENUS NAME;SUBGENUS NAME;SPECIES NAME;SUBSPECIES NAME;AUTHORSHIP Acrididae;Acanthacris ruficornis (Fabricius, 1787);Acanthacris;;ruficornis;;(Fabricius, 1787) Acrididae;Acrida bicolor (Thunberg, 1815);Acrida;;bicolor;;(Thunberg, 1815) Acrididae;Acrida oxycephala (Pallas, 1771);Acrida;;oxycephala;; (Pallas, 1771) Acrididae;Acrida turrita (Linnaeus, 1758);Acrida;;turrita;;(Linnaeus, 1758) I want to know how could I process this file using ' lists ' , that could answer questions like . How many ? , Who did .. ? etc. I am a newbie , and would appreciate your help -- http://mail.python.org/mailman/listinfo/python-list
Re: Processing file with lists.
You describe a two-part problem. The first, loading the data, is easily accomplished with the Python CSV module: http://docs.python.org/library/csv.html e.g.: reader = csv.reader(open('filename', 'rb'), delimiter=';', quotechar=None) In the above example, you can iterate over 'reader' in a for loop to read out each row. The values will be returned in a list. You could also use a DictReader to make the data more naturally accessible using name=value pairs. I want to know how could I process this file using ' lists ' , that could answer questions like . How many ? , Who did .. ? etc. This isn't very clear, but if your dataset is small ( 1000 rows or so) you can fairly quickly read the data into RAM then run through the data with loops designed to pull out certain data, though it seems your data would need additional processing. (The authorship information should be split into two separate columns, for example.) An alternative would be to load the data into a relational database like MySQL or even SQLite (which offers in-memory databases), or an object database such as MongoDB which supports advanced querying using map/reduce. You'd have to examine the documentation on these different systems to see which would best fit your use case. I prefer Mongo as it is very easy to get data into and out of, supports SQL-like queries, and map/reduce is extremely powerful. — Alice. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
Accepting input from a human is frought with dangers and edge cases. ;) Some time ago I wrote a regular expression generator that creates regexen that can parse arbitrarily delimited text, supports quoting (to avoid accidentally separating two elements that should be treated as one), and works in both directions (text-native). The code that generates the regex is heavily commented: https://github.com/pulp/marrow.util/blob/master/marrow/util/convert.py#L123-234 You should be able to use this as-is and simply handle the optional 'and' on the last element yourself. You can even create an instance of the class with the options you want then get the generated regular expression by running print(parser.pattern). Note that I have friends who use 'and' multiple times when describing lists of things. :P — Alice. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
Now that I think about it, and can be stripped using a callback function as the 'normalize' argument to my KeywordProcessor class: def normalize(value): value = value.strip() if value.startswith(and): value = value[3:] return value parser = KeywordProcessor(',', normalize=normalize, result=list) — Alice. -- http://mail.python.org/mailman/listinfo/python-list
Re: AIX 5.3 - Enabling Shared Library Support Vs Extensions
Anurag Chourasia anurag.choura...@gmail.com wrote: When I configure python to enable shared libraries, none of the extensions are getting built during the make step due to this error. building 'cStringIO' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -I/u01/home/apli/wm/GDD/Python-2.6.6/./Include -I. -IInclude -I./Include -I/opt/freeware/include -I/opt/freeware/include/readline -I/opt/freeware/include/ncurses -I/usr/local/include -I/u01/home/apli/wm/GDD/Python-2.6.6/Include -I/u01/home/apli/wm/GDD/Python-2.6.6 -c /u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.c -o build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o ./Modules/ld_so_aix gcc -pthread -bI:Modules/python.exp build/temp.aix-5.3-2.6/u01/home/apli/wm/GDD/Python-2.6.6/Modules/cStringIO.o -L/usr/local/lib *-lpython2.6* -o build/lib.aix-5.3-2.6/cStringIO.so Try these flags: -L. -L/usr/local/lib If this solves the problem and the issue is also present in Python-2.7, you should report a bug at http://bugs.python.org/ . Stefan Krah -- http://mail.python.org/mailman/listinfo/python-list
tilted text in the turtle module
First of all, I'd like to express my deep gratidute to the author of this module, it is such a fun module to work with and to teach python as a first programming language. Secondly, I would like to request a feature if it is not too hard to achieve. Currently, you can only write texts horizontally, no matter what is the current orientation of the turtle pen. I wonder if it is possible to write text in any direction when we control the heading of the turtle? For example, the following code would write a vertically oriented text: setheading(90) #turtle facing up write(vertical text!) Thanks a lot! Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On Oct 13, 9:09 pm, namekuseijin namekusei...@gmail.com wrote: On 11 out, 08:49, Oleg Parashchenko ole...@gmail.com wrote: Hello, I'd like to try the idea that Scheme can be considered as a new portable assembler. We could code something in Scheme and then compile it to PHP or Python or Java or whatever. Any suggestions and pointers to existing and related work are welcome. Thanks! My current approach is to take an existing Scheme implementation and hijack into its backend. At this moment Scheme code is converted to some representation with a minimal set of bytecodes, and it should be quite easy to compile this representation to a target language. After some research, the main candidates are Gambit, Chicken and CPSCM: http://uucode.com/blog/2010/09/28/r5rs-scheme-as-a-virtual-machine-i/... If there is an interest in this work, I could publish progress reports. -- Oleg Parashchenko o...@http://uucode.com/http://uucode.com/blog/ XML, TeX, Python, Mac, Chess it may be assembler, too bad scheme libs are scattered around written in far too many different flavors of assembler... It warms my heart though to realize that Scheme's usual small size and footprint has allowed for many quality implementations targetting many different backends, be it x86 assembly, C, javascript or .NET. Take python and you have a slow c bytecode interpreter and a slow bytecode .NET compiler. Take haskell and its so friggin' huge and complex that its got its very own scary monolithic gcc. When you think of it, Scheme is the one true high-level language with many quality perfomant backends -- CL has a few scary compilers for native code, but not one to java, .NET or javascript that I know of... Take R5RS Scheme and you get a language which doesn't allow you to get things done. Scheme is as far from Assembly as one language can be. Assembly exists to get things done, R5RS Scheme does not even allows you load native libraries of the underlying operating-system, does it? It's easy to stay small and clean when you don't have to dirty your hands with such crap as real-world applications development. -- http://mail.python.org/mailman/listinfo/python-list
the buggy regex in Python
I know many experts will say I don't have understanding...but let me pay this up front as my tuition. Here are some puzzling results I have got (I am using Python 3, I suppose similar results for python 2). When I do the following, I got an exception: re.findall('(d*)*', 'adb') re.findall('((d)*)*', 'adb') When I do this, I am fine but the result is wrong: re.findall('((.d.)*)*', 'adb') [('', 'adb'), ('', '')] Why is it wrong? The first mactch of groups: ('', 'adb') indicates the outer group ((.d.)*) captured the empty string, while the inner group (.d.) captured 'adb', so the outer group must have captured the empty string at the end of the provided string 'adb'. Once we have matched the final empty string '', there should be no more matches, but we got another match ('', '')!!! So, findall matched the empty string in the end of the string twice!!! Isn't this a bug? Yingjie -- http://mail.python.org/mailman/listinfo/python-list
do something every n seconds
Hello, how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Santiago -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? The simplest method is executing time.sleep(n) within an infinite while loop. There are more elegant solutions: using coroutine frameworks, threaded task schedulers, etc. — Alice. -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
Santiago Caracol santiago.cara...@gmail.com writes: how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Don't do it that way if you can help it. Use inotify or the equivalent instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
Windows or UNIX ? Am Do, 25.11.2010, 13:38 schrieb Santiago Caracol: Hello, how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Santiago -- http://mail.python.org/mailman/listinfo/python-list -- MfG, Stefan Sonnenberg-Carstens IT Architect -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
On Thu, 2010-11-25 at 04:38 -0800, Santiago Caracol wrote: how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Use the Python Advanced Scheduler in your application - it is a great little module. Then you've solved every 'scheduler' issue your application will ever have. http://packages.python.org/APScheduler/ -- Adam Tauno Williams awill...@whitemice.org LPIC-1, Novell CLA http://www.whitemiceconsulting.com OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
Phlip, I'm trying to match any word \w+ followed by a comma, or a final word preceded by and. Here's a non-regex solution that handles multi-word values and multiple instances of 'and' (as pointed out by Alice). The posted code could be simplified via list comprehension - I chose the more verbose method to illustrate the logic. def to_list( text ): text = text.replace( ' and ', ',' ) output = list() for item in text.split( ',' ): if item: output.append( item.strip() ) return output test = 'cat, dog, big fish, goat and puppy and horse' print to_list( test ) Outputs: ['cat', 'dog', 'big fish', 'goat', 'puppy', 'horse'] Malcolm -- http://mail.python.org/mailman/listinfo/python-list
regexp matching end of line or comma
Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? JM -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
On 11/25/2010 3:12 AM, Yingjie Lan wrote: Sometimes the golden rule in Python of explicit is better than implicit is so cheap that it can be thrown away for the trouble of typing an empty tuple. I'm not sure that there *are* any golden rules. The Zen of Python is intended to be guidelines, not rigid rules intended to constrain your behavior but advice to help you write better code. Today when I am explaining that in Python 3, there are two ways to raise exceptions: raise Exception raise Exception() and that the first one is the same as the second one, as Python will add the missing pair of parenthesis. In fact this is noting to do with Python 3 - the same is true of Python 2, so this isn't new: Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01) [GCC 4.3.4 20090804 (release) 1] on cygwin Type help, copyright, credits or license for more information. raise KeyError Traceback (most recent call last): File stdin, line 1, in module KeyError raise KeyError(Here is the message) Traceback (most recent call last): File stdin, line 1, in module KeyError: 'Here is the message' I felt their pain as they gasped. Before that, I have already explained to them this piece of code: try: raise SomeException() except SomeException: print('Got an exception here') by saying that the except-clause will match anything that belong to the SomeException class. Or any of its subclasses ... Without knowing this secrete piece of information (that a pair of parenthesis is automatically provided), the following code would be hard to understand: try: raise SomeException except SomeException: print('Got an exception here') because the class object SomeException is not an instance of itself, so a not-so-crooked coder will not consider a match here. It's a matter of understanding correctly how the interpreter operates (and the interactive interpreter session is the ideal place to investigate this). The 2.7 documentation for the raise statement says (and this is not new): If the first object is an instance, the type of the exception is the class of the instance, the instance itself is the value, and the second object must be None. If the first object is a class, it becomes the type of the exception. The second object is used to determine the exception value: If it is an instance of the class, the instance becomes the exception value. If the second object is a tuple, it is used as the argument list for the class constructor; if it is None, an empty argument list is used, and any other object is treated as a single argument to the constructor. The instance so created by calling the constructor is used as the exception value. So the interpreter doesn't really automatically provide a pair of parentheses, but examines the exception object and instantiates it if it is a class. So, the explicit is better than implicit rule is thrown out of the window so cheaply, that it literally worth less than an empty tuple! Surely an exaggeration. In fact current best practice (which you should inform yourself of as best you can to help you in your teaching work - so you are to be congratulated for bringing this question to the list) is to always use explicit calls, with arguments specifying a tailored message. Regards, Yingjie regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
On 11/25/2010 5:06 AM, Yingjie Lan wrote: First of all, I'd like to express my deep gratidute to the author of this module, it is such a fun module to work with and to teach python as a first programming language. Secondly, I would like to request a feature if it is not too hard to achieve. Currently, you can only write texts horizontally, no matter what is the current orientation of the turtle pen. I wonder if it is possible to write text in any direction when we control the heading of the turtle? For example, the following code would write a vertically oriented text: setheading(90) #turtle facing up write(vertical text!) Thanks a lot! Yingjie: This sounds like a good idea. To request a feature you should create an account (if you do not already have one) on bugs.python.org and create a new issue (assuming a search reveals that there is not already such an issue). You may find if you look at the module's code that you can imagine how to make the change. If not, the request will wait until some maintainer sees it and has time. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
On 11/25/2010 6:38 AM, Santiago Caracol wrote: Hello, how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Look at the sched library, which was written to take care of requirements like this. Use time.sleep() as your delay function and time.time() as your time function. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
On 11/24/2010 10:46 PM, Phlip wrote: HypoNt: I need to turn a human-readable list into a list(): print re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c').groups() That currently returns ('c',). I'm trying to match any word \w+ followed by a comma, or a final word preceded by and. The match returns 'a, bbb, and c', but the groups return ('bbb', 'c'). What do I type for .groups() to also get the 'a'? Please go easy on me (and no RTFM!), because I have only been using regular expressions for about 20 years... A kind of lazy way just uses a pattern for the separators to fuel a call to re.split(). I assume that and and , are both acceptable in any position: The best I've been able to do so far (due to split's annoying habit of including the matches of any groups in the pattern I have to throw away every second element) is: re.split(\s*(,|and)?\s*, 'whatever a, bbb, and c')[::2] ['whatever', 'a', 'bbb', '', 'c'] That empty string is because of the , and which isn't recognise as a single delimiter. A parsing package might give you better results. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite date fields
On 25/11/2010 00:45, Alan Harris-Reid wrote: Hi, I am having design problems with date storage/retrieval using Python and SQLite. I understand that a SQLite date column stores dates as text in ISO format (ie. '2010-05-25'). So when I display a British date (eg. on a web-page) I convert the date using datetime.datetime.strptime(mydate,'%Y-%m-%d').strftime('%d/%m/%Y'). However, when it comes to writing-back data to the table, SQLite is very forgiving and is quite happy to store '25/06/2003' in a date field, but this is not ideal because a) I could be left with a mixture of date formats in the same column, b) SQLite's date functions only work with ISO format. Therefore I need to convert the date string back to ISO format before committing, but then I would need a generic function which checks data about to be written in all date fields and converts to ISO if necessary. That sounds a bit tedious to me, but maybe it is inevitable. Are there simpler solutions? Would it be easier to change the date field to a 10-character field and store 'dd/mm/' throughout the table? This way no conversion is required when reading or writing from the table, and I could use datetime() functions if I needed to perform any date-arithmetic. How have other developers overcome this problem? Any help would be appreciated. For the record, I am using SQLite3 with Python 3.1. Even when storing a date as text, I always prefer to use ISO format because it makes sorting by date easier and there's less chance of confusion over UK vs US date format. -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On 2010-11-24 16:19:49 -0500, toby said: And furthermore, he has cooties. Once again, not all ad hominem arguments are ad hominem fallacies. Financial conflict of interest is a prime example of a perfectly valid ad hominem argument. People who parse patterns but not semantics are apt to fall into the error of believing that ad hominem automatically means logically invalid. This is not the case. warmest regards, Ralph -- Raffael Cavallaro -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
Try this: '(?Psomething\S+)(,|$)' On Thu, Nov 25, 2010 at 9:40 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? JM -- http://mail.python.org/mailman/listinfo/python-list -- http://www.afroblend.com African news as it happens. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? Within a character set '$' is a literal '$' and not end-of-string, just as '\b' is '\x08' and not word-boundary. Use a lookahead instead: re.match('(?Psomething\S+)(?=,|$)', ex1) _sre.SRE_Match object at 0x01719FA0 re.match('(?Psomething\S+)(?=,|$)', ex2) _sre.SRE_Match object at 0x016937E0 -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On 25 nov, 09:23, Elena egarr...@gmail.com wrote: On Oct 13, 9:09 pm, namekuseijin namekusei...@gmail.com wrote: On 11 out, 08:49, Oleg Parashchenko ole...@gmail.com wrote: Hello, I'd like to try the idea that Scheme can be considered as a new portable assembler. We could code something in Scheme and then compile it to PHP or Python or Java or whatever. Any suggestions and pointers to existing and related work are welcome. Thanks! My current approach is to take an existing Scheme implementation and hijack into its backend. At this moment Scheme code is converted to some representation with a minimal set of bytecodes, and it should be quite easy to compile this representation to a target language. After some research, the main candidates are Gambit, Chicken and CPSCM: http://uucode.com/blog/2010/09/28/r5rs-scheme-as-a-virtual-machine-i/... If there is an interest in this work, I could publish progress reports. -- Oleg Parashchenko o...@http://uucode.com/http://uucode.com/blog/ XML, TeX, Python, Mac, Chess it may be assembler, too bad scheme libs are scattered around written in far too many different flavors of assembler... It warms my heart though to realize that Scheme's usual small size and footprint has allowed for many quality implementations targetting many different backends, be it x86 assembly, C, javascript or .NET. Take python and you have a slow c bytecode interpreter and a slow bytecode .NET compiler. Take haskell and its so friggin' huge and complex that its got its very own scary monolithic gcc. When you think of it, Scheme is the one true high-level language with many quality perfomant backends -- CL has a few scary compilers for native code, but not one to java, .NET or javascript that I know of... Take R5RS Scheme and you get a language which doesn't allow you to get things done. Scheme is as far from Assembly as one language can be. Assembly exists to get things done, R5RS Scheme does not even allows you load native libraries of the underlying operating-system, does it? It's easy to stay small and clean when you don't have to dirty your hands with such crap as real-world applications development.- Ocultar texto das mensagens anteriores - assembly in the sense that it's what other languages could compile to. Like many are targetting javascript, the de facto assembly of the web... In any case, the original poster was advocating the opposite: to code in Scheme and compile it to more common backends, such as PHP or javascript... I misunderstood his point. But the flamewars that followed were far more entertaining anyway... :) -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
On 25/11/2010 04:46, Phlip wrote: HypoNt: I need to turn a human-readable list into a list(): print re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c').groups() That currently returns ('c',). I'm trying to match any word \w+ followed by a comma, or a final word preceded by and. The match returns 'a, bbb, and c', but the groups return ('bbb', 'c'). What do I type for .groups() to also get the 'a'? Please go easy on me (and no RTFM!), because I have only been using regular expressions for about 20 years... Try re.findall: re.findall(r'(\w+), |and (\w+)', 'whatever a, bbb, and c') [('a', ''), ('bbb', ''), ('', 'c')] You can get a list of strings like this: [x or y for x, y in re.findall(r'(\w+), |and (\w+)', 'whatever a, bbb, and c')] ['a', 'bbb', 'c'] -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
--- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: Sometimes the golden rule in Python of explicit is better than implicit is so cheap that it can be thrown away for the trouble of typing an empty tuple. I'm not sure that there *are* any golden rules. The Zen of Python is intended to be guidelines, not rigid rules intended to constrain your behavior but advice to help you write better code. Surely an exaggeration. In fact current best practice (which you should inform yourself of as best you can to help you in your teaching work - so you are to be congratulated for bringing this question to the list) is to always use explicit calls, with arguments specifying a tailored message. regards Steve A very cogent message -- the end echos the start. :) I must say that I learned from you a new angle to think about this issue. On the other hand, I still feel that when allowing both ways colliding into the simpleness and bueaty of the language, we should consider to make a decision. Sure, this introduced quite a lot of complexity when the doc has to give a very long explanation of what is happening in order to justify it. As I am thinking about it, it seems two conflicting intuition of code comprehension are at work here: Intuition #1: as if you raise an exception type, and then match that type. It seems that no instances are involved here (Intuitively). See an example code here: try: raise KeyError except KeyError: pass Intuition #2: you raise an exception instance, and then match an instance by its type. See an example code here: try: raise KeyError() except KeyError as ke: pass Those two comprehensions are not compatible, and thus the one that promotes correct understanding should be encouraged, while the other should be discouraged, and maybe even be made iliegal. Regards, Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
MRAB wrote: On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? Within a character set '$' is a literal '$' and not end-of-string, just as '\b' is '\x08' and not word-boundary. Use a lookahead instead: re.match('(?Psomething\S+)(?=,|$)', ex1) _sre.SRE_Match object at 0x01719FA0 re.match('(?Psomething\S+)(?=,|$)', ex2) _sre.SRE_Match object at 0x016937E0 thanks, it works that way. By the way I don't get the difference between non capturing parentesis (?:) and lookahead parenthesis (?=): re.match('(?Psomething\S+)(?:,|$)', ex2).groups() ('sumthin',) re.match('(?Psomething\S+)(?=,|$)', ex2).groups() ('sumthin',) JM -- http://mail.python.org/mailman/listinfo/python-list
Re: the buggy regex in Python
On 25/11/2010 11:32, Yingjie Lan wrote: I know many experts will say I don't have understanding...but let me pay this up front as my tuition. Here are some puzzling results I have got (I am using Python 3, I suppose similar results for python 2). When I do the following, I got an exception: re.findall('(d*)*', 'adb') re.findall('((d)*)*', 'adb') A repeated repeat can cause problems if what is repeated can match an empty string. The re module tries to protect itself by forbidding such a regex. The regex module (available from PyPI) accepts that regex and returns a result. When I do this, I am fine but the result is wrong: re.findall('((.d.)*)*', 'adb') [('', 'adb'), ('', '')] Why is it wrong? The first mactch of groups: ('', 'adb') indicates the outer group ((.d.)*) captured the empty string, while the inner group (.d.) captured 'adb', so the outer group must have captured the empty string at the end of the provided string 'adb'. Once we have matched the final empty string '', there should be no more matches, but we got another match ('', '')!!! So, findall matched the empty string in the end of the string twice!!! re.findall performs multiple searches, each starting where the previous one finished. The first match started at the start of the string and finished at its end. The second match started at that point (the end of the string) and found another match, ending at the end of the string. It tried to match a third time, but that failed because it would have matched an empty string again (it's not allowed to return 2 contiguous empty strings). Isn't this a bug? No, but it can be confusing at times! :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: the buggy regex in Python
--- On Thu, 11/25/10, MRAB pyt...@mrabarnett.plus.com wrote: re.findall performs multiple searches, each starting where the previous one finished. The first match started at the start of the string and finished at its end. The second match started at that point (the end of the string) and found another match, ending at the end of the string. It tried to match a third time, but that failed because it would have matched an empty string again (it's not allowed to return 2 contiguous empty strings). Isn't this a bug? No, but it can be confusing at times! :-) -- But the last empty string is matched twice -- so it is an overlapping. But findall is supposed not to return overlapping matches. So I think this does not live up to the documentation -- thus I still consider it a bug. Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com writes: On 2010-11-24 16:19:49 -0500, toby said: And furthermore, he has cooties. Once again, not all ad hominem arguments are ad hominem fallacies. Financial conflict of interest is a prime example of a perfectly valid ad hominem argument. It has limited validity. People are way more complicated than the simplistic follow your own selfish egoistic interests to the letter without taking prisoners model of human behavior that seems (unfortunately) so prevalent nowadays. People who parse patterns but not semantics are apt to fall into the error of believing that ad hominem automatically means logically invalid. This is not the case. In the realm of pure logic, ad hominems are logically invalid, period. However, if the question cannot be resolved by its own merits, simple logic has little to say, and you may include additional information in a sort-of Bayesian fashion. Saying that a conflict of interest means that nothing this person says makes any sense at all is in a way an admission that the subject of discussion is not very amenable to rational argument. -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
On 25/11/2010 16:26, Jean-Michel Pichavant wrote: MRAB wrote: On 25/11/2010 14:40, Jean-Michel Pichavant wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? Within a character set '$' is a literal '$' and not end-of-string, just as '\b' is '\x08' and not word-boundary. Use a lookahead instead: re.match('(?Psomething\S+)(?=,|$)', ex1) _sre.SRE_Match object at 0x01719FA0 re.match('(?Psomething\S+)(?=,|$)', ex2) _sre.SRE_Match object at 0x016937E0 thanks, it works that way. By the way I don't get the difference between non capturing parentesis (?:) and lookahead parenthesis (?=): re.match('(?Psomething\S+)(?:,|$)', ex2).groups() ('sumthin',) re.match('(?Psomething\S+)(?=,|$)', ex2).groups() ('sumthin',) A non-capturing parenthesis 'consumes' characters; a lookahead parenthesis doesn't, so another part of the regex can match it again. I suppose that in this instance it doesn't matter! -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
--- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: From: Steve Holden st...@holdenweb.com Subject: Re: tilted text in the turtle module To: python-list@python.org Date: Thursday, November 25, 2010, 7:00 PM On 11/25/2010 5:06 AM, Yingjie Lan wrote: This sounds like a good idea. To request a feature you should create an account (if you do not already have one) on bugs.python.org and create a new issue (assuming a search reveals that there is not already such an issue). Thanks I just did that. You may find if you look at the module's code that you can imagine how to make the change. If not, the request will wait until some maintainer sees it and has time. I don't know much about tkinter, not sure if I can contribute. And even if I made a patch, then how to publish it? Regards, Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: the buggy regex in Python
On 25/11/2010 16:44, Yingjie Lan wrote: --- On Thu, 11/25/10, MRABpyt...@mrabarnett.plus.com wrote: re.findall performs multiple searches, each starting where the previous one finished. The first match started at the start of the string and finished at its end. The second match started at that point (the end of the string) and found another match, ending at the end of the string. It tried to match a third time, but that failed because it would have matched an empty string again (it's not allowed to return 2 contiguous empty strings). Isn't this a bug? No, but it can be confusing at times! :-) -- But the last empty string is matched twice -- so it is an overlapping. But findall is supposed not to return overlapping matches. So I think this does not live up to the documentation -- thus I still consider it a bug. Look at the spans: for m in re.finditer('((.d.)*)*', 'adb'): print(m.span()) (0, 3) (3, 3) There's an non-empty match followed by an empty match. -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
On 11/25/2010 10:15 AM, Yingjie Lan wrote: As I am thinking about it, it seems two conflicting intuition of code comprehension are at work here: Intuition #1: as if you raise an exception type, and then match that type. It seems that no instances are involved here (Intuitively). See an example code here: try: raise KeyError except KeyError: pass Intuition #2: you raise an exception instance, and then match an instance by its type. See an example code here: try: raise KeyError() except KeyError as ke: pass Those two comprehensions are not compatible, and thus the one that promotes correct understanding should be encouraged, while the other should be discouraged, and maybe even be made iliegal. I prefer to treat those two cases as unified, by observing that if what is raised in an exception class than an instance is created by calling it with no arguments. So matching is always by the instance's type - it's just that the instance creation can be implicit. I agree with you that explicit is better. Most of the syntactic variation you dislike is to allow existing code to continue to work. Some of it is removed in Python 3, when backwards compatibility could be ignored. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
while True: time.sleep(10) print('hello python!') HTH, KM On Thu, Nov 25, 2010 at 8:35 PM, Steve Holden st...@holdenweb.com wrote: On 11/25/2010 6:38 AM, Santiago Caracol wrote Hello, how can I do something (e.g. check if new files are in the working directory) every n seconds in Python? Look at the sched library, which was written to take care of requirements like this. Use time.sleep() as your delay function and time.time() as your time function. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
On 11/25/2010 10:49 AM, Yingjie Lan wrote: --- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: From: Steve Holden st...@holdenweb.com Subject: Re: tilted text in the turtle module To: python-list@python.org Date: Thursday, November 25, 2010, 7:00 PM On 11/25/2010 5:06 AM, Yingjie Lan wrote: This sounds like a good idea. To request a feature you should create an account (if you do not already have one) on bugs.python.org and create a new issue (assuming a search reveals that there is not already such an issue). Thanks I just did that. You may find if you look at the module's code that you can imagine how to make the change. If not, the request will wait until some maintainer sees it and has time. I don't know much about tkinter, not sure if I can contribute. And even if I made a patch, then how to publish it? Once you have a patch, attach it to the issue as a file and try and get it reviewed by a developer for incorporation into a future release. Note that no Python 2.8 release is planned, so you would best concentrate your effort on the 3.x series. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: regexp matching end of line or comma
On Nov 25, 8:40 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Hy guys, I'm struggling matching patterns ending with a comma ',' or an end of line '$'. import re ex1 = 'sumthin,' ex2 = 'sumthin' m1 = re.match('(?Psomething\S+),', ex1) m2 = re.match('(?Psomething\S+)$', ex2) m3 = re.match('(?Psomething\S+)[,$]', ex1) m4 = re.match('(?Psomething\S+)[,$]', ex2) print m1, m2 print m3 print m4 _sre.SRE_Match object at 0x8834de0 _sre.SRE_Match object at 0x8834e20 _sre.SRE_Match object at 0x8834e60 None My problem is that m4 is None while I'd like it to match ex2. Any clue ? JM From the Regular Expression Syntax documentation: Special characters are not active inside sets. For example, [akm$] will match any of the characters 'a', 'k', 'm', or '$'; so in m4, [,$] matches a comma or a literal dollar sign. -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite date fields
However, when it comes to writing-back data to the table, SQLite is very forgiving and is quite happy to store '25/06/2003' in a date field, but this is not ideal because a) I could be left with a mixture of date formats in the same column, b) SQLite's date functions only work with ISO format. Therefore I need to convert the date string back to ISO format before committing, but then I would need a generic function which checks data about to be written in all date fields and converts to ISO if necessary. That sounds a bit tedious to me, but maybe it is inevitable. It doesn't strike me as particularly tedious if it is just the line: datetime.datetime.strptime(mydate,'%Y-%m-%d').strftime('%d/%m/%Y') Are there simpler solutions? Would it be easier to change the date field to a 10-character field and store 'dd/mm/' throughout the table? This way no conversion is required when reading or writing from the table, and I could use datetime() functions if I needed to perform any date-arithmetic. Maybe I've misunderstood, but wouldn't you have to do the conversion to display the date anyway? It seems to me like, whichever approach you take, you will have to do a conversion. For that reason, isn't it better to leave the date fields in ISO so that you can take advantage of SQLite's date functions? Che How have other developers overcome this problem? Any help would be appreciated. For the record, I am using SQLite3 with Python 3.1. Alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Scheme as a virtual machine?
On 25 nov, 14:30, m_mom...@yahoo.com (Mario S. Mommer) wrote: Raffael Cavallaro raffaelcavall...@pas.despam.s.il.vous.plait.mac.com writes: On 2010-11-24 16:19:49 -0500, toby said: And furthermore, he has cooties. Once again, not all ad hominem arguments are ad hominem fallacies. Financial conflict of interest is a prime example of a perfectly valid ad hominem argument. It has limited validity. People are way more complicated than the simplistic follow your own selfish egoistic interests to the letter without taking prisoners model of human behavior that seems (unfortunately) so prevalent nowadays. People who parse patterns but not semantics are apt to fall into the error of believing that ad hominem automatically means logically invalid. This is not the case. In the realm of pure logic, ad hominems are logically invalid, period. However, if the question cannot be resolved by its own merits, simple logic has little to say, and you may include additional information in a sort-of Bayesian fashion. Saying that a conflict of interest means that nothing this person says makes any sense at all is in a way an admission that the subject of discussion is not very amenable to rational argument. I have to say I'm always amazed how ad hominens can generate quite strong responses to the point of making a lot of new faces (or mail accounts) suddenly appear... ;) -- http://mail.python.org/mailman/listinfo/python-list
Automatic Distutils generator
Hi Folks I am trying run Distutils setup inside a script. The Docs dont tell me much and I cant find any examples. This script will generate shared libraries recursive to all files in a dir. - import os import sys from distutils.core import setup as d from distutils.extension import Extension from Cython.Distutils import build_ext fileList = [] rootdir = sys.argv[1] fileType = '.pyx' for root, subFolders, files in os.walk(rootdir): for file in files: if file[-4:] == fileType: fileList.append(os.path.join(root,file)) # But Here I want automatic Distutils generator # I want replace manual entry like this: # python setup.py build_ext --inplace d.setup(name = str(file) + '_Cython', ext_modules=[ Extension(file[:-4], [file]) ], cmdclass = {'build_ext': build_ext}) d.run_setup() print 'Files convert: \n' print fileList Who can help me fix it? Best Regards Mario -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
Accepting input from a human is fraught with dangers and edge cases. Here's a non-regex solution Thanks all for playing! And as usual I forgot a critical detail: I'm writing a matcher for a Morelia /viridis/ Scenario step, so the matcher must be a single regexp. http://c2.com/cgi/wiki?MoreliaViridis I'm avoiding the current situation, where Morelia pulls out (.*), and the step handler manually splits that up with: flags = re.split(r', (?:and )?', flags) That means I already had a brute-force version. A regexp version is always better because, especially in Morelia, it validates input. (.*) is less specific than (\w+). So if the step says: Alice has crypto keys apple, barley, and flax Then the step handler could say (if this worked): def step_user_has_crypto_keys_(self, user, *keys): r'(\w+) has crypto keys (?:(\w+), )+and (\w+)' # assert that user with those keys here That does not work because a capturing group only remembers the last match. This would appear to be an irritating 'feature' in Regexp. The total match is 'apple, barley, and flax', but the stored groups behave as if each () were a slot, so (\w+)+ would not store more than one group. Unless there's a Regexp workaround to mean arbitrary number of slots for each (), then I /might/ go with this: got = re.findall(r'(?:(\w+), )?(?:(\w+), )?(?:(\w+), )?(?:(\w+), )? (?:(\w+), and )?(\w+)$', 'whatever a, bbb, and c') print got # [('a', '', '', '', 'bbb', 'c')] The trick is to simply paste in a high number of (?:(\w+), )? segments, assuming that nobody should plug in too many. Behavior Driven Development scenarios should be readable and not run-on. (Morelia has a table feature for when you actually need lots of arguments.) Next question: Does re.search() return a match object that I can get ('a', '', '', '', 'bbb', 'c') out of? The calls to groups() and such always return this crazy ('a', 2, 'bbb', 'c') thing that would disturb my user-programmers. -- Phlip -- http://mail.python.org/mailman/listinfo/python-list
Re: building a web interface
Will take a look after stuffing myself with turkey today (am in the US, where we give thanks by eating everything in sight). Thanks, Alice. Wait, did I just say thanks? Must go eat pie. On Nov 25, 12:36 am, Alice Bevan–McGregor al...@gothcandy.com wrote: Howdy! I'm mildly biased, being the author of the framework, but I can highly recommend WebCore for rapid prototyping of web applications; it has templating via numerous template engines, excellent JSON (AJAJ) support, and support for database back-ends via SQLAlchemy. It also has session support baked-in via a project called Beaker. Documentation is fairly complete, and I can be found camping in the #webcore IRC channel on irc.freenode.net at strange hours. If you can write a class, you can have a fully operational web application in a single file of ~8 lines or so. (Or you can create a complete easy-installable Python package with multiple modules.) For information, see:http://www.web-core.org/ As an interactive-fiction example: class RootController(web.core.Controller): def index(self): This returns a template that uses JavaScript to call execute(). The JavaScript adds the result of execute() to the display. session = db.Session().save() return './templates/main.html', dict(session=session.id) def execute(self, session, statement): Load our session and pass the input off to our interactive fiction library of choice. Return the result if all went well. session = db.Session.get(session) try: result = myiflib.execute(session, statement) except myiflib.ParseError: return 'json:', dict(status=failure, message=Error...) return 'json:', dict(status=success, message=result) — Alice. -- http://mail.python.org/mailman/listinfo/python-list
Re: a regexp riddle: re.search(r'(?:(\w+), |and (\w+))+', 'whatever a, bbb, and c') =? ('a', 'bbb', 'c')
On 25/11/2010 19:57, Phlip wrote: Accepting input from a human is fraught with dangers and edge cases. Here's a non-regex solution Thanks all for playing! And as usual I forgot a critical detail: I'm writing a matcher for a Morelia /viridis/ Scenario step, so the matcher must be a single regexp. http://c2.com/cgi/wiki?MoreliaViridis I'm avoiding the current situation, where Morelia pulls out (.*), and the step handler manually splits that up with: flags = re.split(r', (?:and )?', flags) That means I already had a brute-force version. A regexp version is always better because, especially in Morelia, it validates input. (.*) is less specific than (\w+). So if the step says: Alice has crypto keys apple, barley, and flax Then the step handler could say (if this worked): def step_user_has_crypto_keys_(self, user, *keys): r'(\w+) has crypto keys (?:(\w+), )+and (\w+)' # assert that user with those keys here [snip] You could do: def step_user_has_crypto_keys_(self, user, keys): r'(\w+) has crypto keys ((?:\w+, )+and \w+)' to validate and capture, and then split the keys string. -- http://mail.python.org/mailman/listinfo/python-list
Re: a story of a top expert of Mathematica: Robby Villegas
On Nov 25, 2:10 am, Xah Lee xah...@gmail.com wrote: On Nov 24, 2:02 pm, Xah Lee xah...@gmail.com wrote: just learned that one of my best friend, one of world's top expert of the Mathematica language, died, last month. • 〈Robby Villegas Died (1968-2010)〉http://xahlee.org/math/Robby_Villegas.html so, apparantly, he killed himself. not lisp related, but i thought it is interetsing to many here, becuase Robby is very interested in computer languages, and share with many of us being ubberly socially inept and frustrated. (he's not a emacs users. Occationally uses vi. I think he's main editor is NEdit (if he hasn't changed since 1990s). Yes he's a linux user. Became a Redhat linux user as his main machine in late 1990s. You could find many of his writings in comp.soft-sys.math.mathematica, but i believ they all dates in the mid 1990s. He's a extremely keep-to-himself guy.) He's also the first computer programer that i got to know in real meat space, who hates Windows and Microsoft. --- Robby's Goodbye Notes Apparantly, Robby killed himself. There's this memorial page posted by Robby's friends on his site at: Source. Reading it, i came across several Wolfram employees i remember having met, some i recognize as Robby's good friends. In it, there's this post, apparantly Robby's goodbye note. Robby via Christina Szabo Says: October 7th, 2010 at 9:54 pm Robby wanted to “give some explanation to people in general” and asked me to post this, which he wrote. -Christina Subject: the end is important in all things Robby Villegas October 2 at 7:17am Depression, and even more so, physical exhaustion, continues to claim more and more of my life, to render a larger percentage of each day either unusable, or a sloggin, dragging fight to keep myself upright just to get through the basics of my day. On top of fatigue, a few years ago I began to develop a tendency toward anxiety, which gradually became more frequent and of faster onset, throwing a specter of borderline panic attacks over many of my activities. Eventually, I was taking partial doses of my prescription sleep medication *preemptively* before simple activities like skating class, meeting friends at a bar, going to a theater, or spending an evening studying at a cafe. The sleep and exhaustion problems that forced me to suddenly quit working in January 2007 have gradually worsened, and I have run out of means at this point. More important than financial means, though: the ratio of quality of life to pained struggling has passed a threshold. Eventually, I’ll forget what it even felt like to be happy, the memories of what I was will fade further, I won’t be able to appreciate any of the good parts of life, and I’ll be bitter, not even a shadow of my self. This must not happen. For many years, I have felt that some day I’d have to make that call that it’s time to go; that most of the good stuff was past, and the proportion of hope and new joy to the pain and effort that goes into rallying would fall too low I want to go out while I can still reflect on the good things, and go out really feeling and believing “I lived.” Worse than the death of the body is the death of pieces of the self while still alive, and the memories that provide conviction that there was a lot worth being here for, while it lasted. In retrospect, I probably should have made this call last winter, or at the very latest, early summer, given that the last few months have had a marked dulling effect on me. But, two decades of fighting depression, rallying through many dozens of life-hating and self- hating episodes ranging from bad patches to truly close calls, and being thankful I did each time I got a “new lease on life” that was followed by more of the worthwhile stuff of life … two decades of that makes it *intensely* difficult to make that final call. Albeit more weary and dull than I’ve ever been, I am thankful that there’s enough left of me to look back (even with difficulty) and appreciate all the good people, activities, and interests that made My Life worth living during that time. So it is perhaps not too late to exit while there’s a reasonable amount left of Me. Yours in truth, Robby “R. Scott” Not sure what to say. Robby has told me in around 2004 to 2005, our last big exchange, that he has serious insomnia problems. But i don't recall any serious depression. Actually, i remember now he has told me that he had depression episodes, which i did too, and we chatted our experiences. But i recall it's all past tense, and this chat was in 1995. (depression is hard to define) But i didn't know it was getting to the point of killing himself, but again, for certain type of persons who are not emotionally responsive (i.e. cold, lone, type, who hide their emotions or unable to express it), it
Re: inverse of a matrix with Fraction entries
Daniel Fetchinson fetchin...@googlemail.com writes: I wouldn't do it that way. Let M be your matrix. Work out the LCM l of the denominators, and multiply the matrix by that to make it an integer matrix N = l M. Then work out the determinant d of that integer matrix. Next, the big step: use Gaussian elimination to find a matrix A (the `adjugate matrix') such that A N = d I. This should be doable entirely using integer arithmetic, and I think without needing any divisions. Finally, we have l A M = d I, so (l/d A) M = I and l/d A is the inverse you seek. Does that make sense? Absolutely! But there is nothing wrong with working out the inverse directly using fractions.Fraction arithmetic, I'd think. It'll work, certainly; but the Fraction implementation will have to do a buttload of GCD computations that it wouldn't need to do if you worked with plain integers. And GCDs are relatively hard, as arithmetical computations go: the usual algorithms require either a number of divisions (which are themselves rather costly) or a bitwise traversal of one of the operands. A million entries seems nontrivial for a matrix, and Gaussian elimination has cubic running time if I remember rightly; I suspect that the transformations I describe would reduce the running time by a fair amount. Of course, I might be drastically underestimating the performance of modern hardware -- I often do -- so this may not be especially relevant. Anyway, the possibility's there. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list
Re: inverse of a matrix with Fraction entries
I wouldn't do it that way. Let M be your matrix. Work out the LCM l of the denominators, and multiply the matrix by that to make it an integer matrix N = l M. Then work out the determinant d of that integer matrix. Next, the big step: use Gaussian elimination to find a matrix A (the `adjugate matrix') such that A N = d I. This should be doable entirely using integer arithmetic, and I think without needing any divisions. Finally, we have l A M = d I, so (l/d A) M = I and l/d A is the inverse you seek. Does that make sense? Absolutely! But there is nothing wrong with working out the inverse directly using fractions.Fraction arithmetic, I'd think. It'll work, certainly; but the Fraction implementation will have to do a buttload of GCD computations that it wouldn't need to do if you worked with plain integers. And GCDs are relatively hard, as arithmetical computations go: the usual algorithms require either a number of divisions (which are themselves rather costly) or a bitwise traversal of one of the operands. A million entries seems nontrivial for a matrix, and Gaussian elimination has cubic running time if I remember rightly; I suspect that the transformations I describe would reduce the running time by a fair amount. Of course, I might be drastically underestimating the performance of modern hardware -- I often do -- so this may not be especially relevant. Anyway, the possibility's there. Okay, I see your point and I completely agree. Surely it will be faster to do it with integers, will give it a shot. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
On Nov 24, 9:16 pm, Alice Bevan–McGregor al...@gothcandy.com wrote: On 2010-11-24 12:08:04 -0800, Raymond Hettinger said: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. The SocketServer module (http://docs.python.org/library/socketserver.html) uses cooperative multiple inheritance to implement threading / async using a ThreadingMixIn class and multi-processing using a ForkingMixIn class, which may not be as complicated a use case as you are looking for. It is a great example of a style of using mixins, but isn't actually an example of Python's cooperative multiple inheritance. The code doesn't use super() and doesn't have a diamond problem. It's hard to write a best practices document for super() when the doesn't appear to be any practice at all :-) Raymond -- http://mail.python.org/mailman/listinfo/python-list
Newbie subprocess question
I'm starting various application using subprocess.Popen without any problem. The problem is with application inside Program Files. It looks like subprocess is stopping the application string after Program. I tried puting the programe name inside double quote like 'Program File*...'. No luck. How can I start a app inside this folder ? Thanks -- Hugo Léveillé TD Compositing, Vision Globale hu...@fastmail.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
On 11/25/2010 4:40 PM, Raymond Hettinger wrote: It's hard to write a best practices document for super() when the doesn't appear to be any practice at all :-) Sounds like the Python community have voted with their feet. I seem to remember that Alex Martelli's Python in a Nutshell contains a very thorough description of the new-style class system with an example showing the resolution of the diamond pattern. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
In article 89b6d53f-dcdc-4442-957f-1f4d29115...@n32g2000pre.googlegroups.com, Raymond Hettinger pyt...@rcn.com wrote: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. My previous job used this rather heavily, but I can't provide you with code. I suspect we weren't the only people, but I have no clue how to locate samples. Were you searching code.google.com or something else? -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Look, it's your affair if you want to play with five people, but don't go calling it doubles. --John Cleese anticipates Usenet -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie subprocess question
On 2010-11-25, Hugo Léveillé hu...@fastmail.net wrote: I'm starting various application using subprocess.Popen without any problem. The problem is with application inside Program Files. It looks like subprocess is stopping the application string after Program. I tried puting the programe name inside double quote like 'Program File*...'. No luck. Not sure you you are having issues. subprocess.Popen(C:\\Program Files\\Vim\\vim73\\gvim.exe) -- http://mail.python.org/mailman/listinfo/python-list
MediaTags - exporting m4a, id3, exiv, etc as JSON (YAML)
I'm sponsoring the development of cross-platform (C/C++) utilities for extracting a variety of media meta-data as JSON, including stream checksums and stream meta-data. git://github.com/coolaj86/mtags.git I'd like to get support for developing this, and I'm interested in the opinions of others who would use these tools. http://pledgie.com/campaigns/14039 The m4atags utility is now complete. Here's an example of the usage / output: http://coolaj86.info/articles/example-of-verbose-output-from-mediatags.html AJ ONeal -- http://mail.python.org/mailman/listinfo/python-list
Re: Arrays
I have an exercise im working on. I have an array of strings, and I would like to take each peace of the array and assign it to a new array so I can iterate over each of those pieces and replace the sting I want then put it back together. I hope that is not too confusing. This is how im trying to solve the problem. I have a program that takes in integers and it prints out the integers in bigger ones made up of asterisks. Im supposed to alter the program so so that instead of asterisks it prints them in bigger ones made up of the number itself. I am given arrays built to look like the numbers, already. - Reply message - From: Stefan Behnel stefan...@behnel.de Date: Wed, Nov 24, 2010 2:18 am Subject: Arrays To: python-list@python.org Garland Fulton, 24.11.2010 06:55: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? Python has lists and tuples as basic data structures. Tuples are completely immutable, lists are completely mutable. If you want a container that has a fixed size but allows changing items, use a list and avoid calling .append() and .remove() to change items in favour of direct item assignments. If you want a completely mutable container, use a list and use it as you see fit. If you want a stack, a list will do. If you want a queue, a deque is a better option. In any case, if you tell us more about what you actually want to do, we can give better suggestions. Stefan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
MediaTags - exporting m4a, id3, exiv, etc as JSON
I'm sponsoring the development of cross-platform (C/C++) utilities for extracting a variety of media meta-data as JSON, including stream checksums and stream meta-data. git://github.com/coolaj86/mtags.git I'd like to get support for developing this, and I'm interested in the opinions of others who would use these tools. http://pledgie.com/campaigns/14039 The m4atags utility is now complete. Here's an example of the usage / output: http://coolaj86.info/articles/example-of-verbose-output-from-mediatags.html AJ ONeal -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
Raymond Hettinger pyt...@rcn.com writes: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. I'd mention the SocketServer library, except I'm not sure what you mean by cooperative, so I don't know if that counts. The few times I've tried to use multiple inheritance, I think it wasn't the right idea for what I was doing. It turns into a big mess quite easily. The classic example though is a window system, where you have a window class, and a scroll bar class, and a drop-down menu class, etc. and if you want a window with a scroll bar and a drop-down menu, you inherit from all three of those classes. They each have to support (e.g.) a redraw operation, so automatic method combination figures out what to call. I''ve mostly seen this stuff in connection with Lisp. If you look at a CLOS manual you can probably find examples. There are also some examples in the old CADR manual, using the MIT Flavors system which predated CLOS. That manual is online now: http://common-lisp.net/project/bknr/static/lmman/frontpage.html The object system is documented in this chapter: http://common-lisp.net/project/bknr/static/lmman/flavor.xml The paragraph about defwrapper gives a clear view into the machinery. -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
On 11/24/2010 12:08 PM, Raymond Hettinger wrote: I'm writing-up more guidance on how to use super() and would like to point at some real-world Python examples of cooperative multiple inheritance. Google searches take me to old papers for C++ and Eiffel, but that don't seem to be relevant to most Python programmers (i.e. a WalkingMenu example where a submenu is both a Entry in a Menu and a Menu itself). Another published example is in a graphic library where some widgets inherit GraphicalFeature methods such as location, size and NestingGroupingFeatures such as finding parents, siblings, and children. I don't find either of those examples compelling because there is no particular reason that they would have to have overlapping method names. So far, the only situation I can find where method names necessarily overlap is for the basics like __init__(), close(), flush(), and save() where multiple parents need to have their own initialization and finalization. If you guys know of good examples, I would appreciate a link or a recap. Multiple inheritance in Python is basically what fell out of CPython's internals, not a design. It's one of those areas where order of execution matters, and that wasn't well worked out. Allowing classes to form a directed acyclic graph isn't very useful. It just fell out of the semantics of a naive interpreter. Read C3 method resolution order: http://www.python.org/download/releases/2.3/mro/ which is what you have to understand to use the awful cases properly. Originally, the semantics were just wrong. Now the awful cases have well-defined semantics, but aren't very useful. Part of the problem is the notion that if a base class is duplicated in the hierarchy, there's only one copy. So if you inherit from two classes, both of which inherit from dict, there will be only one dict at the bottom. (I think.) This probably won't do what the authors of any of the classes involved expected. The author of the class which does the multiple inheritance might not even be aware that there's a clash further up in the hierarchy. This is one of those areas where all the code looks right locally, but it's wrong globally. Best practice for this is don't do it. Some name clashes ought to simply be detected as errors, rather than being given such complex semantics. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
On 11/25/2010 4:12 AM, Yingjie Lan wrote: Sometimes the golden rule in Python of explicit is better than implicit is so cheap that it can be thrown away for the trouble of typing an empty tuple. Today when I am explaining that in Python 3, there are two ways to raise exceptions: raise Exception raise Exception() I agree with you that this is annoying. I think it is a holdover from the past. In Python 1/2, raise 'some string' also works, but that was disallowed in Py 3. A lot of things were cleaned up in Py 3, but not everything. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
--- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: And even if I made a patch, then how to publish it? Once you have a patch, attach it to the issue as a file and try and get it reviewed by a developer for incorporation into a future release. Note that no Python 2.8 release is planned, so you would best concentrate your effort on the 3.x series. I see. I suppose one could post a message somewhere to get the attention? Thanks for the pointer. Regards, Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: the buggy regex in Python
--- On Thu, 11/25/10, MRAB pyt...@mrabarnett.plus.com wrote: Look at the spans: for m in re.finditer('((.d.)*)*', 'adb'): print(m.span()) (0, 3) (3, 3) There's an non-empty match followed by an empty match. If you read my first post, it should be apparent that that the empty string in the end of the string is used twice -- thus an overlap. Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
On 11/25/2010 5:58 PM, Yingjie Lan wrote: --- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: And even if I made a patch, then how to publish it? Once you have a patch, attach it to the issue as a file and try and get it reviewed by a developer for incorporation into a future release. Note that no Python 2.8 release is planned, so you would best concentrate your effort on the 3.x series. I see. I suppose one could post a message somewhere to get the attention? Thanks for the pointer. One would normally make a post on the python-dev list to get the attention of developers. If you want to *guarantee* that your issue gets attention then you can review five existing issues and advance them a little to help the development team. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie subprocess question
On 25/11/2010 22:56, Hugo Léveillé wrote: I'm starting various application using subprocess.Popen without any problem. The problem is with application inside Program Files. It looks like subprocess is stopping the application string after Program. I tried puting the programe name inside double quote like 'Program File*...'. No luck. How can I start a app inside this folder ? Try passing the application path and its arguments (if any) as a list like this: subprocess.Popen([app_path, arg1, arg2]) -- http://mail.python.org/mailman/listinfo/python-list
Re: tilted text in the turtle module
--- On Fri, 11/26/10, Steve Holden st...@holdenweb.com wrote: From: Steve Holden st...@holdenweb.com Subject: Re: tilted text in the turtle module To: python-list@python.org Date: Friday, November 26, 2010, 4:16 AM On 11/25/2010 5:58 PM, Yingjie Lan wrote: --- On Thu, 11/25/10, Steve Holden st...@holdenweb.com wrote: And even if I made a patch, then how to publish it? Once you have a patch, attach it to the issue as a file and try and get it reviewed by a developer for incorporation into a future release. Note that no Python 2.8 release is planned, so you would best concentrate your effort on the 3.x series. I see. I suppose one could post a message somewhere to get the attention? Thanks for the pointer. One would normally make a post on the python-dev list to get the attention of developers. If you want to *guarantee* that your issue gets attention then you can review five existing issues and advance them a little to help the development team. Sound advices. Many thanks! Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
On Thu, 25 Nov 2010 08:15:21 -0800, Yingjie Lan wrote: Intuition #1: as if you raise an exception type, and then match that type. It seems that no instances are involved here (Intuitively). Your intuition is not my intuition, nor does it match what Python actually does. You can only go so far on *guessing* what a programming statement does, sometimes you need to actually read the Fine Manual. See an example code here: try: raise KeyError except KeyError: pass As the documentation states, this creates an instance of KeyError. raise evaluates the first expression as the exception object. It must be either a subclass or an instance of BaseException. If it is a class, the exception instance will be obtained when needed by instantiating the class with no arguments. http://docs.python.org/py3k/reference/simple_stmts.html#the-raise-statement So there is no semantic difference between raise KeyError and raise KeyError(). Why should there be? What practical difference would you expect? If you do this: try: raise KeyError except KeyError as ke: print(ke) you will see that the value caught is an instance, not the class. Intuition #2: you raise an exception instance, and then match an instance by its type. See an example code here: try: raise KeyError() except KeyError as ke: pass Your intuition is wrong. Exceptions aren't matched by type, they are *always* matched by an isinstance() check, and that includes subclasses. try: raise KeyError # with or without parentheses makes no difference ... except Exception as e: print(type(e)) ... class 'KeyError' Those two comprehensions are not compatible, and thus the one that promotes correct understanding should be encouraged, while the other should be discouraged, and maybe even be made iliegal. You seem to have misunderstood both forms of the raise statement. Should we make exceptions illegal because you can't correctly guess what they do? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
John Nagle na...@animats.com writes: Multiple inheritance in Python is basically what fell out of CPython's internals, not a design. It's one of those areas where order of execution matters, and that wasn't well worked out. I'm not sure about the history, but this doesn't sound right to me. Allowing classes to form a directed acyclic graph isn't very useful. This is simply wrong. It just fell out of the semantics of a naive interpreter. No: there's some essential work needed to make it happen. Originally, the semantics were just wrong. Agreed. Now the awful cases have well-defined semantics, but aren't very useful. Disagree strongly. I think linearization is the only coherent approach to multiple inheritance, and the C3 linearization seems to have almost all of the necessary properties. I'm not quite sure what you mean by `awful' here: the old Python linearization rules were wrong even for very simple graphs (they failed to respect the superclass ordering properly). The CLOS, Dylan and C3 linearizations agree on most commonly occurring class graphs, including many graphs for which the old Python orderings disagreed; the exceptions are where CLOS or Dylan failed to be monotonic or to obey the extended precedence graph. The semantics are extremely useful in the hands of a careful designer. Part of the problem is the notion that if a base class is duplicated in the hierarchy, there's only one copy. This is a problem? No! Duplicating superclass state (as is done in C++ and, I believe, Eiffel) is incoherent. So if you inherit from two classes, both of which inherit from dict, there will be only one dict at the bottom. (I think.) Yes. You end up (probably) with an enhanced dictionary which supports both protocols. This happens frequently, and is very useful. This probably won't do what the authors of any of the classes involved expected. The author of the class which does the multiple inheritance might not even be aware that there's a clash further up in the hierarchy. This is one of those areas where all the code looks right locally, but it's wrong globally. This is only likely if there's a misdesign -- probably using inheritance where containership is required. Best practice for this is don't do it. Some name clashes ought to simply be detected as errors, rather than being given such complex semantics. It sounds like you've been scarred by experiences with C++'s dementedly inadequate object system, with its bizarre `repeated inheritance' rules and hopelessly primitive manual (static!) method combination -- possibly even to the extent of believing that they're in some way `right' or `necessary'. I'm sorry. You have my pity. Python's object system is different, and doesn't have those problems. You probably need a viewpoint shift to be able to think about it properly, but that won't happen if you continue to cling to the idea that C++'s approach is anything like a model of how to do it right. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list
Re: what a cheap rule
--- On Fri, 11/26/10, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: From: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info Subject: Re: what a cheap rule To: python-list@python.org Date: Friday, November 26, 2010, 5:10 AM On Thu, 25 Nov 2010 08:15:21 -0800, Yingjie Lan wrote: You seem to have misunderstood both forms of the raise statement. Should we make exceptions illegal because you can't correctly guess what they do? Though what you said about Python is right, I think somehow you missed my point a bit. Ideally, the language could be so 'natural' that it means what meets the eyes. Yingjie -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
On Thu, 25 Nov 2010 15:38:36 -0800, John Nagle wrote: Part of the problem is the notion that if a base class is duplicated in the hierarchy, there's only one copy. Why is that a problem? I would expect it to be a problem if it showed up twice. So if you inherit from two classes, both of which inherit from dict, there will be only one dict at the bottom. (I think.) This probably won't do what the authors of any of the classes involved expected. The author of the class which does the multiple inheritance might not even be aware that there's a clash further up in the hierarchy. This is one of those areas where all the code looks right locally, but it's wrong globally. Why do you assume it is wrong? The whole point of the complex semantics that you are complaining about is to ensure that multiple inheritance does the right thing, rather than the wrong thing. You simply can't safely inherit from arbitrary classes without understanding them. This is equally true for single and multiple inheritance, but in multiple inheritance there are more places for things to go wrong. That is simply because the semantics of inherit from classes A and B are more complex than the semantics of inherit from class A. The problem is that people expect multiple inheritance to just work mechanically, without giving any thought to the process. That it does often just work is a credit to the complex semantics that you are complaining about, but this lulls people into a false sense of security and makes it more surprising when it doesn't work. Best practice for this is don't do it. Some name clashes ought to simply be detected as errors, rather than being given such complex semantics. If that's the case, you would have to prohibit ALL multiple inheritance from new-style classes, because all new-style classes inherit from object. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
On Nov 25, 3:38 pm, John Nagle na...@animats.com wrote: Multiple inheritance in Python is basically what fell out of CPython's internals, not a design. Sorry to disagree. That is historically inaccurate. Guido designed super() on purpose. He took his cues from Putting Metaclasses to Work by Ira Forman and Scott Danforth. The method resolution order was based on yet another paper which showed the defects in the two earlier designs for multiple inheritance. It may not be great, but it sure wasn't an accident. Best practice for this is don't do it. Some name clashes ought to simply be detected as errors, rather than being given such complex semantics. That may well be true. If a coder has enough control over the classes to be make sure they use super() in a way that supports cooperative multiple inheritance, then they have enough control to just rename the methods to prevent name diamond shaped name clashes. OTOH, sometimes you don't have control over the names if they are magic methods or standard names like close(), save(), flush(), __init__(), etc. Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Needed: Real-world examples for Python's Cooperative Multiple Inheritance
[Paul Rubin] I'd mention the SocketServer library, except I'm not sure what you mean by cooperative, so I don't know if that counts. Cooperative multiple inheritance is a specific problem when there is a diamond diagram with the same method name needing to be called on multiple paths and each name should only be called exactly once. http://www.python.org/download/releases/2.2.3/descrintro/#cooperation Raymond -- http://mail.python.org/mailman/listinfo/python-list
Preciseinfo collections updated http://preciseinfo.org
All preciseinfo.org collections are updated. (Java, Javascript, C++ VC ATL STL, MFC VC, Python, Php) About collections: -- Collections include two types of information: 1) Code examples (guaranteed to have articles with code on the subject of selected chapter, guaranteed to be relevant to that topic with 90% certainty) 2) Expert articles Contain articles by writers with above average competence level. Internal search engine: --- All collections may be searched with a very powerfule internal search engine. It supports all standard search engine operations, including OR and a literal match (if you include multiple search words surrounded by quote chars ()). Also, phrase search is fully supported. Synonyms are supported. Except in programming languages synonyms are not that straightforward issue. Do not underestimate the power of INTERNAL search engine. It is a very powerful search engine. It will allow you to drill down the issue to the most precise degree. You can search on some language (Java, MFC, C++, etc.) Or you can search on a single chapter from some language. Or, you can search on ALL the languages and ALL the chapters. If and when you perform a search from some article, the default search condition is to search the chapter that article belongs to. But the search result box will show you what was found and will give you an option to change the scope of search. That is, to select some specific chapter from some collection, or to select ALL the chapters in that collection. If you click on Index link in the navbar, you will be shown the list of articles in that chapter. If you perform a search from the search box in the chapter index, the default search scope is to search that chapter. It is best to search using the internal search engine vs. standard search engines, such as Google. Because Google only has a small part of the collections indexed for whatever reason. But the internal search engine has every single article available in the collection indexed. So you have the full scoop. Enjoy. -- http://mail.python.org/mailman/listinfo/python-list
Parsing markup.
I'm attempting to parse some basic tagged markup. The output of the TinyMCE editor returns a string that looks something like this; pThis is a paragraph with bbold/b and iitalic/i elements in it/ppIt can be made up of multiple lines separated by pagagraph tags./p I'm trying to render the paragraph into a bit mapped image. I need to parse it out into the various paragraph and bold/italic pieces. I'm not sure the best way to approach it. Elementree and lxml seem to want a full formatted page, not a small segment like this one. When I tried to feed a line similar to the above to lxml I got an error; XMLSyntaxError: Extra content at the end of the document. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing markup.
On 26/11/2010 03:28, Joe Goldthwaite wrote: I’m attempting to parse some basic tagged markup. The output of the TinyMCE editor returns a string that looks something like this; pThis is a paragraph with bbold/b and iitalic/i elements in it/ppIt can be made up of multiple lines separated by pagagraph tags./p I’m trying to render the paragraph into a bit mapped image. I need to parse it out into the various paragraph and bold/italic pieces. I’m not sure the best way to approach it. Elementree and lxml seem to want a full formatted page, not a small segment like this one. When I tried to feed a line similar to the above to lxml I got an error; “XMLSyntaxError: Extra content at the end of the document”. I'd probably use a regex: import re text = pThis is a paragraph with bbold/b and iitalic/i elements in it/ppIt can be made up of multiple lines separated by pagagraph tags./p re.findall(r/?\w+|[^]+, text) ['p', 'This is a paragraph with ', 'b', 'bold', '/b', ' and ', 'i', 'italic', '/i', ' elements in it', '/p', 'p', 'It can be made up of multiple lines separated by pagagraph tags.', '/p'] -- http://mail.python.org/mailman/listinfo/python-list
Re: Pypi (Cheeseshop) Score - derivation of ?
Martin v. Loewis mar...@v.loewis.de wrote: There was indeed a kwalitee computation (cheesecake); it is unmaintained. Ah yes, I couldn't remember the particular mispelling the project used :) -- http://mail.python.org/mailman/listinfo/python-list
class in c subclasses python classes, called in python
I'm looking to create an application that uses c++ and python together. Currently my application is all python. But need to obfuscate some of the code. I am wanting to have c++ code so I can handle encryption with it and other tasks. But first I need it to subclass some python class objects. One task that I need to do is create a class in c++ that subclasses 3 python classes and calls the base class constructor as super would call in python. I need this in c++. How can I do this please? class ABC(a,b,c): def __init__(self, *args, **kwargs): super(ABC, self).__init__(*args, **kwargs) What I would like to know is how would I create a class in C or C++ that would: 1. create a class that subclasses 2 or more python classes 2. initializes the subclassed classes by calling the contructors like python's super would 3. import the class in python and call this class constructor with ABC(*args, **kwargs) is there a way to do this? Thanks in advance :) Thank you, -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie subprocess question
On 01/-10/-28163 02:59 PM, Hugo Léveillé wrote: I'm starting various application using subprocess.Popen without any problem. The problem is with application inside Program Files. It looks like subprocess is stopping the application string after Program. I tried puting the programe name inside double quote like 'Program File*...'. No luck. How can I start a app inside this folder ? Thanks How about you show us exactly what you are doing, and just what you mean by no luck ? You also should tell us what version of Python you're running, and mention that you're on Windows (presumably, but not necessarily). Perhaps you're using shell=True, perhaps you have an executable in the root directory called c:\program.exe, Perhaps you're passing arguments, but not putting them in separate list items. Who knows? DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing markup.
Hello, 2010/11/26 Joe Goldthwaite j...@goldthwaites.com: I’m attempting to parse some basic tagged markup. Elementree and lxml seem to want a full formatted page, not a small segment like this one. BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/) could help in the parsing: from BeautifulSoup import BeautifulSoup as Soup s = Soup(text) print s.prettify() p This is a paragraph with b bold /b and i italic /i elements in it /p p It can be made up of multiple lines separated by pagagraph tags. /p s.findAll('b') [bbold/b] s.findAll('i') [iitalic/i] s.findAll('p') [pThis is a paragraph with bbold/b and iitalic/i elements in it/p, pIt can be made up of multiple lines separated by pagagraph tags./p] Best regards, Javier -- http://mail.python.org/mailman/listinfo/python-list
Re: Matlab equivalent syntax in Python
Akand Islam sohel...@gmail.com wrote: Can anyone please suggest me what will be the good way to use matlab equivalent of profile clear, profile on, profile off, profile resume and profile viewer in Python? Python has a number of ways of measuring elapsed time, including the timeit module and the trace module. There's nothing that will display the results in a pretty graph, so the answer depends on what you are after. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite date fields
Alan Harris-Reid a...@baselinedata.co.uk wrote: I am having design problems with date storage/retrieval using Python and SQLite. I understand that a SQLite date column stores dates as text in ISO format (ie. '2010-05-25'). Only if you store it that way. So when I display a British date (eg. on a web-page) I convert the date using datetime.datetime.strptime(mydate,'%Y-%m-%d').strftime('%d/%m/%Y'). However, when it comes to writing-back data to the table, SQLite is very forgiving and is quite happy to store '25/06/2003' in a date field, SQLite is essentially typeless. ALL fields are stored as strings, with no interpretation. You can store whatever you want in any column. The column types are basically there to remind YOU how to handle the data. How have other developers overcome this problem? By converting. SQLite's flexibility is cool, but it means you have to be smart about how you store the data. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
[issue1508475] transparent gzip compression in urllib
Senthil Kumaran orsent...@gmail.com added the comment: The transparent gzip Content-Encoding support should be done at the http.client level code. Before adding this feature, a question needs to be sorted out. If we support the transparent gzip and wrap the file pointer to a GzipFile filepointer, should reset the Content-Length value? What if a user of urllib is relying on the Content-Length of response to do something further? I observed that google-chrome returns the uncompressed output (which is correct for a browser), but has the Content-Length set the compressed output length. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1508475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1508475] transparent gzip compression in urllib
Senthil Kumaran orsent...@gmail.com added the comment: Patch for py3k. -- stage: unit test needed - patch review Added file: http://bugs.python.org/file19811/issue1508475.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1508475 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10399] AST Optimization: inlining of function calls
Armin Rigo ar...@users.sourceforge.net added the comment: But this seems to me like a contrived example: how often in real code do people pass around these builtins, rather than calling them directly? From experience developing PyPy, every argument that goes this theoretically breaks obscure code, but who writes it in that way? is inherently broken: there *is* code out there that uses any and all Python strangenesses. The only trade-offs you can make is in how much existing code you are going to break -- or make absolutely sure that you don't change semantics in any case. -- nosy: +arigo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10399 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10518] Bring back callable()
Łukasz Langa luk...@langa.pl added the comment: I was originally surprised to find that callable() was gone. I pointed it out at Europython and got a very informative explanation from Brett. The isinstance(obj, collections.Callable) was introduced and it works well. I'm with Ezio here. I'm -1 for callable(), +0 for iscallable() (there should be preferably one obvious way to do it and using isinstance() seems to be that way at this point). -- nosy: +brett.cannon, lukasz.langa ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10122] Documentation typo fix and a side question
Senthil Kumaran orsent...@gmail.com added the comment: Boštjan, it is fixed. The change will reflect when the docs get served from the updated version. Also, Georg will take care of merging it to other branches. -- nosy: +orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10122 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10526] Minor typo in What's New in Python 2.7
New submission from Petter Remen petter.re...@gmail.com: There's a word missing in section PEP 372: Adding an Ordered Dictionary to collections The ConfigParser module uses them by default, meaning that configuration files can now read, modified, and then written [...] should be now be read. -- assignee: d...@python components: Documentation messages: 122347 nosy: Petter.Remen, d...@python priority: normal severity: normal status: open title: Minor typo in What's New in Python 2.7 versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10512] regrtest ResourceWarning - unclosed sockets and files
Nadeem Vawda nadeem.va...@gmail.com added the comment: test_cgi causes a strange filehandle leak that only causes a warning when regrtest terminates, and for some reason doesn't show up if you run just test_cgi by itself. I've attached a patch that closes the filehandle. -- nosy: +lukasz.langa Added file: http://bugs.python.org/file19812/resourcewarning-fixes-3.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10512 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10527] multiprocessing.Pipe problem: handle out of range in select()
New submission from Gergely Kálmán kalman.gerg...@duodecad.hu: Hello, I have a code that uses multiprocessing.Pipe to communicate with subprocesses. Spawning 500 subprocesses this way works like a charm, but when spawning about 600 of them the pipe ends raise the exception: handle out of range in select(). I realized that this is because of the FD_SETSIZE limit. To address the situation I quickly hacked together a patch that uses poll() instead of select(), which solves the problem for me. I don't know the reason why select() was chosen for this task (maybe because of windows) but wouldn't it be better to use polling where possible? I've attached the tester. Beware, running it may use up all memory in your system, so be careful! Gergely Kalman -- components: Library (Lib) files: tester.py messages: 122349 nosy: synapse priority: normal severity: normal status: open title: multiprocessing.Pipe problem: handle out of range in select() type: feature request versions: Python 3.2 Added file: http://bugs.python.org/file19813/tester.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10527] multiprocessing.Pipe problem: handle out of range in select()
Gergely Kálmán kalman.gerg...@duodecad.hu added the comment: And this is the patch that I wrote. It applies to python 3.2. Hope this helps Gergely Kalman -- keywords: +patch Added file: http://bugs.python.org/file19814/multiproc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10527 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5800] make wsgiref.headers.Headers accept empty constructor
Éric Araujo mer...@netwok.org added the comment: LGTM. -- assignee: - pje ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5800 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10362] AttributeError: addinfourl instance has no attribute 'tell'
Senthil Kumaran orsent...@gmail.com added the comment: If you want to quickly solve this, do like this: import urllib import tarfile tarfile.open(urllib.urlretrieve('http://plugins.supybot-fr.tk/GoodFrench.tar')[0], mode='r:') # Works The problem is tarfile is expecting a file-object with a tell method for seeking, whereas urllib2 returns a file-like object, which does have a tell method. It seems to not have because, the underlying socket._fileobject is not exposing one (for whatever reason). Let me try to figure out reason for fixing/closing this bug. (BTW, http module is relying on .tell() of the socket._fileobject too and I wonder it did not get noticed earlier because the has not taken that path yet? Strange!) -- assignee: - orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10362 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9509] argparse FileType raises ugly exception for missing file
SilentGhost michael.mischurow+...@gmail.com added the comment: Ammended akira's patch for Lib/test/test_argparse.py to include suggested in review changes: with statement, import statement -- Added file: http://bugs.python.org/file19815/test_argparse.py.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9509 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10524] Patch to add Pardus to supported dists in platform
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo, lemburg type: - feature request versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10497] Incorrect use of gettext in argparse
Éric Araujo mer...@netwok.org added the comment: A bit of rationale behind the patch. You probably know that the gettext/_ functions serves two roles: Identifying the strings to translate, and retrieving the translation from a catalog. At strings extraction time, the string in the line msg = _('unknown parser %r (choices: %s)' % tup) will be found by xgettext (just checked), so the .pot and .po files will include it. So far, so good. At runtime however, the gettext function will get unknown parser 'parserr' (choices: ('some', 'tuple')) as argument, which isn’t in the translation catalogs. Doing the string interpolation after the gettext call (my patch) avoids this problem. I will write a test for those two strings. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10497 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com