[ANN] Karrigell-3.0.4 released
Hi, A new version of the web framework Karrigell has been released. The main changes are : - more robust session management in multi-threaded and multi-process environments - Unicode management in HTMLTags - Unicode management and error reports in Karrigell Templates - more of MySQL : can be used for users database ; improved online management ; blog application - use of the WhizzyWig Javascript library for blog applications - make script caching and HTTP caching optional - the alias keys can be regular expressions for a more flexible url resolution - bug fix for default host configuration and for cookie expiry date Home page : http://karrigell.sourceforge.net Downloads : http://sourceforge.net/project/showfiles.php?group_id=67940 Group : http://groups.google.com/group/karrigell Cheers, Pierre -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
First Lalita release: 0.1.1
Python Argentina is pleased to announce the 0.1.1 release of Lalita. https://edge.launchpad.net/lalita/trunk/pre-alpha-1 Lalita is yet another IRC bot, one where new functionality is simple to create by just adding easy-to-write plugins. This is a pre-alpha release, our first release, but the delivered product is quite robust: we're using it in production since almost a year ago. Lalita is written with some goals in mind: - Twisted! (we don't like threads) - Pluggable: easy to implement new functionalities - Have fun: yes, it's Python As is said before, it's really easy to add new functionality (just copy the example plugin and touch a couple of lines), but Lalita itself has a lot of plugins already included, among which stand out: - freenode: Executes all the authentication dialog on the Freenode servers (this plugin does not offer functionality to the end user, but allows Lalita to connect to Freenode using a registered user). - misc: Implements a very simple functionality: answers pong to the user after receiving a ping. - url: Collects all the URLs that are said in the different channels, allowing then to search through them. - seen: Implements two commands: last and seen. The former tells what is the last said by an user, and the later tells when an user was seen last time (sometimes they match, sometimes don't). For further information, the project page is: https://edge.launchpad.net/lalita Regards, -- .Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
IMDbPY 4.5
IMDbPY 4.5 is available (tgz, rpm, exe) from: http://imdbpy.sourceforge.net/ IMDbPY is a Python package useful to retrieve and manage the data of the IMDb movie database about movies, people, characters and companies. In this release, important fixes to access the remote data and some improvements to the local database. Platform-independent and written in pure Python (and few C lines), IMDbPY can retrieve data from both the IMDb's web server and a local copy of the whole database. IMDbPY package can be very easily used by programmers and developers to provide access to the IMDb's data to their programs. Some simple example scripts are included in the package; other IMDbPY-based programs are available from the home page. -- Davide Alberani albera...@libero.it [GPG KeyID: 0x465BFD47] http://www.mimante.net/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: stripping fields from xml file into a csv
Hal Styli, 27.02.2010 21:50: I have a sed solution to the problems below but would like to rewrite in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you want in a standard compliant way, and they can deal with all sorts of XML formatting and encoding, for example. I need to strip out some data from a quirky xml file into a csv: from something like this . cust=dick product=eggs ... quantity=12 cust=tom product=milk ... quantity=2 ... cust=harry product=bread ... quantity=1 ... cust=tom product=eggs ... quantity=6 ... . cust=dick product=eggs ... quantity=6 As others have noted, this doesn't tell much about your XML. A more complete example would be helpful. to this dick,eggs,12 tom,milk,2 harry,bread,1 tom,eggs,6 dick,eggs,6 I am new to python and xml and it would be great to see some slick ways of achieving the above by using python's XML capabilities to parse the original file or python's regex to achive what I did using sed. It's funny how often people still think that SAX is a good way to solve XML problems. Here's an untested solution that uses xml.etree.ElementTree: from xml.etree import ElementTree as ET csv_field_order = ['cust', 'product', 'quantity'] clean_up_used_elements = None for event, element in ET.iterparse(thefile.xml, events=['start']): # you may want to select a specific element.tag here # format and print the CSV line to the standard output print(','.join(element.attrib.get(title, '') for title in csv_field_order)) # safe some memory (in case the XML file is very large) if clean_up_used_elements is None: # this assigns the clear() method of the root (first) element clean_up_used_elements = element.clear clean_up_used_elements() You can strip everything dealing with 'clean_up_used_elements' (basically the last section) if your XML file is small enough to fit into memory (a couple of MB is usually fine). Stefan -- http://mail.python.org/mailman/listinfo/python-list
Paper Presentation Topics
Paper Presentation Topics. Our database posses huge collection of topics for paper presentations in all areas. Check all our paper presentation topics at http://pptcontent.blogspot.com/ Topics for Paper Presentation : Paper presentation topics for ece. Paper presentation topics for cse. Paper presentation topics for eee. Paper presentation topics for it. Paper presentation topics for mba. Paper presentation topics for mechanical engineering. Paper presentation topics for civil engineering. Paper presentation topics for eee. Our sample list list of paper presentation topics in all area branches : Hot Topics : Lunar Solar Power,Speech Recognition,Bullet Proof Vests,Nano Robos,Diamond Search,Brain Controlled Car -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
On Sat, 27 Feb 2010 19:37:50 -0800, staticd wrote: Amusing how long those Python toes can be. In several replies I have noticed (often clueless) opinions on Perl. When do people learn that a language is just a tool to do a job? When do people learn that language makes a difference? I used to be a Perl programmer; these days, you'd have to triple my not-small salary to get me to even think about programming in Perl. dude, you nailed it. many times, if not _always_, the correct output is important. the method used to produce the output is irrelevant. Oh really? Then by that logic, you would consider that these two functions are both equally good. Forget readability, forget maintainability, forget efficiency, we have no reason for preferring one over the other since the method is irrelevant. def greet1(name): Print 'Hello name' for any name. print Hello, name def greet2(name): Print 'Hello name' for any name. count = 0 for i in range(0, (Hello, name).__len__(), 1): word = (Hello, name).__getitem__(i) for i in range(0, word[:].__len__(), 1): c = word.__getitem__(i) import sys import string empty = '' maketrans = getattr.__call__(string, 'maketrans') chars = maketrans.__call__(empty, empty) stdout = getattr.__call__(sys, 'stdout') write = getattr.__call__(stdout, 'write') write.__call__(c) count = count.__add__(1) import operator eq = getattr.__call__(operator, 'eq') ne = getattr.__call__(operator, 'ne') if eq.__call__(count, 2): pass elif not ne.__call__(count, 2): continue write.__call__(chr.__call__(32)) write.__call__(chr.__call__(10)) return None There ought to be some kind of competition for the least efficient solution to programming problems-ly y'rs, -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: help with Python installation
On Feb 28, 12:51 am, gujax rjngrj2...@gmail.com wrote: I agree with you. I have a CD of Xubuntu. I tried booting up with the CD and was impressed. I noticed few problems with screen resolution, window size etc. Though it may be worth working out any niggling problems to switch to Linux, I don't think you should feel pressured to switch if you are comfortable with Win ME on that particular machine. And no, I am not at all attached to Win, though wouldn't say the same for my computer. It sounds like you could have switched to Linux and resolved any configuration problems in the two years you've been trying to install Python. ;) But that said, I have used older versions of Python without any trouble on Win ME. In fact, I still have a Win ME machine running 2.5.2. According to the docs, you have to have Microsoft Installer 2.0 (freely downloadable from Microsoft if necessary) to use the 2.5 MSI distribution: http://www.python.org/download/releases/2.5.4/ If for whatever reason you can't or don't want to do this, 2.3 still has an EXE distribution: http://www.python.org/download/releases/2.3.5/ John -- http://mail.python.org/mailman/listinfo/python-list
Re: Is this secure?
a...@pythoncraft.com (Aahz) writes: Are you sure? I haven't done a lot of research, but my impression was that Windows didn't have anything built in. I don't know much about the windows but there is the CAPI and then there is all the TCPA (i.e. DRM) stuff. Maybe it can be used somehow. -- http://mail.python.org/mailman/listinfo/python-list
getting rpy2 from repository
Hi all, I have Enthought Python 4.3 installed on my OS X 10.5. When I do $ easy_install rpy2 Searching for rpy2 No matching release version found. Searching for latest development version. Reading http://www.enthought.com/repo/epd/eggs/MacOSX/10.4_x86/ Please enter credentials to access this repository: User Name: Is there a way to point to the original (non-Enthought) repository, or is there a better way? Thanks very much in advance! Stephen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
Steven D'Aprano, 28.02.2010 09:48: There ought to be some kind of competition for the least efficient solution to programming problems That wouldn't be very interesting. You could just write a code generator that spits out tons of garbage code including a line that solves the problem, and then let it execute the code afterwards. That beast would always win. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: scope of generators, class variables, resulting in global na
...and really means this... class C: x = 1 def f(self,y): return T.x + y I don't understand what T is. Did you mean C? Yes, I meant C. Thanks. If so, you are wrong. self.x is not the same as class.x due to inheritance rules. Consider one example: example snipped see thread/ Thanks for the nice example. Sorry for my loose language. By really means, what I really meant was that the most appropriate construct should be the one referring to the class variable explicitly. I would consider it inelegant (at least) to use an instance variable with the same name as a class variable. 1. Has this been discussed before? Yes. 1. What would this suggestion break? Nearly all existing code using classes, which is nearly everything. Is it that common to have code containing a class variable with the same name as a global variable? Are there other use cases that would break? 2. What are the advantages of making the scope of class variables different? Maybe is it just a historical trait? See the discussion in the PEP for introducing nested scopes in the first place: http://www.python.org/dev/peps/pep-0227/ Thanks. That is really useful. I just read the PEP. I find this paragraph very helpful: An alternative would have been to allow name binding in class scope to behave exactly like name binding in function scope. This rule would allow class attributes to be referenced either via attribute reference or simple name. This option was ruled out because it would have been inconsistent with all other forms of class and instance attribute access, which always use attribute references. Code that used simple names would have been obscure. The point about all other access use cases requiring attribute references is a really good one. If a language requires self.f() to access the member f of class C, which happens to be a function, then self.x or C.x should also be required to access attribute x. And no one would be crazy enough to ask to have that fixed. @Steven: Are there other snippets from the PEP you were pointing to specifically? Cheers, Leo. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
On 02/28/10 11:05, Stefan Behnel wrote: Steven D'Aprano, 28.02.2010 09:48: There ought to be some kind of competition for the least efficient solution to programming problems That wouldn't be very interesting. You could just write a code generator that spits out tons of garbage code including a line that solves the problem, and then let it execute the code afterwards. That beast would always win. Stefan Well that would be an obvious rule that garbage code that does not contribute to the end result (ie can be taken out without affecting the end result) would not be allowed. Enforcing the rule is another beast though, but I would leave that to the competition. Though the idea of a code generator is solid, but instead of generating garbage, produces a virtual machine that implements a generator that produces a virtual machine, etc. etc. -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
Hello, 2010/2/28 Stefan Behnel stefan...@behnel.de Hal Styli, 27.02.2010 21:50: I have a sed solution to the problems below but would like to rewrite in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you want in a standard compliant way, and they can deal with all sorts of XML formatting and encoding, for example. I need to strip out some data from a quirky xml file into a csv: from something like this . cust=dick product=eggs ... quantity=12 cust=tom product=milk ... quantity=2 ... cust=harry product=bread ... quantity=1 ... cust=tom product=eggs ... quantity=6 ... . cust=dick product=eggs ... quantity=6 As others have noted, this doesn't tell much about your XML. A more complete example would be helpful. to this dick,eggs,12 tom,milk,2 harry,bread,1 tom,eggs,6 dick,eggs,6 I am new to python and xml and it would be great to see some slick ways of achieving the above by using python's XML capabilities to parse the original file or python's regex to achive what I did using sed. another solution in this case could be to use an XSLT stylesheet. That way the input processing is defined in an XSLT stylesheet. The stylesheet is test.xsl and the insput data test.xml. The following Python code the applies the stylesheet on the input data and puts the output into foo. Python code: #!/usr/bin/python import sys import libxml2 import libxslt styledoc = libxml2.parseFile(test.xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile(test.xml) result = style.applyStylesheet(doc, None) style.saveResultToFilename(foo, result, 0) BR, Roland *Example run in Linux:* rol...@komputer:~/Desktop/XML/XSLT$ ./xslt_test.py rol...@komputer:~/Desktop/XML/XSLT$ cat foo john,eggs,12 cindy,bread,1 larry,tea bags,100 john,butter,1 derek,chicken,2 derek,milk,2 * The test.xsl stylesheet:* ?xml version=1.0 encoding=UTF-8? xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xmlns:fo=http://www.w3.org/1999/XSL/Format; version=1.0 !-- text output because we want to have an CSV file -- xsl:output method=text/ !-- remove all whitespace coming with input XML -- xsl:strip-space elements=*/ !-- matches any order element and extracts the customer,productquantity attributes -- xsl:template match=order xsl:value-of select=@customer/ xsl:text,/xsl:text xsl:value-of select=@product/ xsl:text,/xsl:text xsl:value-of select=@quantity/ xsl:text /xsl:text /xsl:template /xsl:stylesheet -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
Roland Mueller, 28.02.2010 13:01: The stylesheet is test.xsl and the insput data test.xml. The following Python code the applies the stylesheet on the input data and puts the output into foo. Python code: #!/usr/bin/python import sys import libxml2 import libxslt styledoc = libxml2.parseFile(test.xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile(test.xml) result = style.applyStylesheet(doc, None) style.saveResultToFilename(foo, result, 0) BR, Roland *Example run in Linux:* rol...@komputer:~/Desktop/XML/XSLT$ ./xslt_test.py Note that the shorthand for the above is $ xsltproc test.xsl test.xml foo Stefan -- http://mail.python.org/mailman/listinfo/python-list
Method / Functions - What are the differences?
Out of curiosity I tried this and it actually worked as expected: class T(object): x=[] foo=x.append def f(self): return self.x t=T() t.f() [] T.foo(1) t.f() [1] At first I thought hehe, always fun to play around with python. Might be useful sometimes - but then It really confused me what I did. I mean: f is what we call a method, right? But was is foo? It is not a method and not a classmethod as it accepts no self and no cls. So that leaves staticmethod? OK, fair, as x is static here anyway this reflects what it does. But then consider this: class T(object): def __init__(self): self.x=[] self.foo=self.x.append def f(self): return self.x y=T() y.x [] y.foo(1) y.x [1] a=T() a.x [] a.foo(2) a.x [2] Note that all I did was moving the list and foo into the instance. Still no self and no cls, but also no static behaviour any more. So is foo just nothing of the above and really only a class/instance attribute which happens to be callable? Perhaps this all does not matter, but now I am really confused about the terminology. So: what makes a method a method? And of what type? Regards, Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with floats and calculations
In article mailman.2549.1266184509.28905.python-l...@python.org, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 14 Feb 2010 10:33:54 +0100, Karsten Goen karsten.g...@googlemail.com declaimed the following in gmane.comp.python.general: Maybe anyone can help me with this problem, I don't want to generate for every possible user input a single formula. And also it should be possible for a computer, my calculator at home does the same and is much smaller and slower. Most ALL calculators that I've encountered use packed BCD internally for numeric data. That is -- two decimal digits (0-9) and a few special codes (mantissa sign, exponent sign, decimal point location, and exponent start). A lot of them (though strangely not HP) included guard digits -- they would display, say, 8 significant digits for results, but kept 10 digits internally, so that rounding errors wouldn't accumulate as rapidly. M$ Excel/Access/VisualBasic money data type What is displayed has no influence on rounding errors. Calculator vendors prevent puzzlement by non-knowledgeable users by having guard digits. HP apparently deals with professional users, so I think it not strange at all. carries four decimal places, on the assumption that only two are significant, and the last two are guards. Most ALL computers are using IEEE floating point (and the exceptions are still a binary floating point, not a decimal representation). The practice, which /used to be/ taught, is that one does not compare floating numbers for equality, but rather one compares the difference between floating numbers to be less than some epsilon value; epsilon chosen depending upon the significance needed. Rather than comparing a = b one uses abs(a - b) epsilon Since Decimal() also has infinite series values (1.0/3.0), an epsilon comparison may also be called for. Not may be. -- Wulfraed Dennis Lee Bieber KD6MOG Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. alb...@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
2010/2/28 Stefan Behnel stefan...@behnel.de Roland Mueller, 28.02.2010 13:01: The stylesheet is test.xsl and the insput data test.xml. The following Python code the applies the stylesheet on the input data and puts the output into foo. Python code: #!/usr/bin/python import sys import libxml2 import libxslt styledoc = libxml2.parseFile(test.xsl) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile(test.xml) result = style.applyStylesheet(doc, None) style.saveResultToFilename(foo, result, 0) BR, Roland *Example run in Linux:* rol...@komputer:~/Desktop/XML/XSLT$ ./xslt_test.py Note that the shorthand for the above is $ xsltproc test.xsl test.xml foo yes, that's true, and probably the best way to use XML stylesheets in Linux. However, this is a Python ML, and so I was sending the Python example. The original poster does not necessarily use Linux, and I do not know about Windos tools in that regard. BR, Roland Stefan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Sat, 27 Feb 2010 11:27:04 -0600, John Bokma wrote: When do people learn that a language is just a tool to do a job? When do people learn that there are different sorts of tools? A professional wouldn't use a screwdriver when they need a hammer. [...] Languages are not just nebulous interchangeable tools, they're tools A hammer is just a tool to do a job. Doesn't mean one must or should use a hammer to paint a wall. for a particular job with particular strengths and weaknesses, and depending on what strengths you value and what weaknesses you dislike, some tools simply are better than other tools for certain tasks. In short, we agree. -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
Re: Method / Functions - What are the differences?
* Michael Rudolf: Out of curiosity I tried this and it actually worked as expected: class T(object): x=[] foo=x.append def f(self): return self.x t=T() t.f() [] T.foo(1) t.f() [1] At first I thought hehe, always fun to play around with python. Might be useful sometimes - but then It really confused me what I did. I mean: f is what we call a method, right? But was is foo? foo is (refers to) an object that supports call notation and that forwards calls somewhere else, in this case to append on a list. You might call it (descriptive) a call forwarder, or (C# or general terminology) a delegate, or (Python 2.x) a bound method. example Hello.upper built-in method upper of str object at 0x00BA16E0 f = Hello.upper f built-in method upper of str object at 0x00BA16E0 f() 'HELLO' f.__self__ 'Hello' f.__call__ method-wrapper '__call__' of builtin_function_or_method object at 0x00BDD170 print( f.__doc__ ) S.upper() - str Return a copy of S converted to uppercase. _ /example A common use for delegates is as command handlers in a GUI application, and in general for event notifications. Cheers hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Method / Functions - What are the differences?
Michael Rudolf wrote in news:hmdo3m$28...@news.urz.uni-heidelberg.de in comp.lang.python: Note that all I did was moving the list and foo into the instance. Still no self and no cls, but also no static behaviour any more. Yes in the first case foo was an attribute of the class, and in the second an attribute of aon instance of the class. In both cases it was a bound method, something similar too: lambda item : T.x.append( item ) -- http://mail.python.org/mailman/listinfo/python-list
cpan for python?
Is there something like cpan for python? I like python's syntax, but I use perl because of cpan and the tremendous modules that it has. -- http://mail.python.org/mailman/listinfo/python-list
Re: cpan for python?
On Feb 28, 2010, at 9:28 AM, Someone Something wrote: Is there something like cpan for python? I like python's syntax, but I use perl because of cpan and the tremendous modules that it has. -- Please search the mailing list archives. This subject has been discussed to absolute death. Draw your own conclusions about what is currently and may, in the future, be available. S -- http://mail.python.org/mailman/listinfo/python-list
Printing the arguments of an attribute in a class
I have a class that is a wrapper: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print 'Trace: ', attrname #print arguments to attrname, how? return getattr(self.wrapped, attrname) I can run it this way: x = wrapper([1,2,3]) x.append(4) Trace: append x.wrapped [1, 2, 3, 4] I am able to capture the attribute name to x (that is, append). However, I do not know how to capture and print all of its arguments (in this case number 4). How should I proceed? Thank you -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the arguments of an attribute in a class
* vsoler: I have a class that is a wrapper: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print 'Trace: ', attrname #print arguments to attrname, how? return getattr(self.wrapped, attrname) I can run it this way: x = wrapper([1,2,3]) x.append(4) Trace: append x.wrapped [1, 2, 3, 4] I am able to capture the attribute name to x (that is, append). However, I do not know how to capture and print all of its arguments (in this case number 4). How should I proceed? If your goal is just learning then in your __getattr__ you might return a wrapper for the attribute instead of the attribute itself. Equip the wrapper with a __call__ method if it is a method. And equip it with other special methods as appropriate. I can imagine that that approach will lead to some practical problems, but it may be great for learning. If your goal is tracing, then I suggest looking at the trace module. If your goal is something else purely practical, like intercepting method calls to do arbitrary things (logging, marshaling, whatever) then I suspect that it might getspretty complicated, hairy. For specific method calls you might just use subclassing, but for doing this in general, parameterized, you'd need to about the same kinds of things as the trace module does. So I guess then one idea might be to look at the source code of that module. But if that's what you intend to do, then best check first if there is an existing solution. ParcPlace did this thing for a number of languages and introduced a special term for it, I can't recall but something like cross-whatever mumbo jumbo concerns plus one single catchy name. There might be an existing Python implementation. Cheers hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the arguments of an attribute in a class
On Feb 28, 4:00 pm, Alf P. Steinbach al...@start.no wrote: * vsoler: I have a class that is a wrapper: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print 'Trace: ', attrname #print arguments to attrname, how? return getattr(self.wrapped, attrname) I can run it this way: x = wrapper([1,2,3]) x.append(4) Trace: append x.wrapped [1, 2, 3, 4] I am able to capture the attribute name to x (that is, append). However, I do not know how to capture and print all of its arguments (in this case number 4). How should I proceed? If your goal is just learning then in your __getattr__ you might return a wrapper for the attribute instead of the attribute itself. Equip the wrapper with a __call__ method if it is a method. And equip it with other special methods as appropriate. I can imagine that that approach will lead to some practical problems, but it may be great for learning. If your goal is tracing, then I suggest looking at the trace module. If your goal is something else purely practical, like intercepting method calls to do arbitrary things (logging, marshaling, whatever) then I suspect that it might getspretty complicated, hairy. For specific method calls you might just use subclassing, but for doing this in general, parameterized, you'd need to about the same kinds of things as the trace module does. So I guess then one idea might be to look at the source code of that module. But if that's what you intend to do, then best check first if there is an existing solution. ParcPlace did this thing for a number of languages and introduced a special term for it, I can't recall but something like cross-whatever mumbo jumbo concerns plus one single catchy name. There might be an existing Python implementation. Cheers hth., - Alf Alf, My goal is just learning. In the code provided in the post I just can't think of a method to see, capture or use the parameters. I am going to study the __call__ method and see if I can figure out how I can capture the parameters. Thank you Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: cpan for python?
Is there something like cpan for python? I like python's syntax, but I use perl because of cpan and the tremendous modules that it has. It's called PyPI or Cheese Shop: http://pypi.python.org/pypi OFF Is it only me or others also mentally read C-SPAN when somebody writes CPAN? /OFF Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: Challenge: escape from the pysandbox
Le samedi 27 février 2010 18:37:22, Daniel Fetchinson a écrit : It's google's hosting solution called app engine, for python web applications: http://code.google.com/appengine/docs/python/gettingstarted/ I guess they also have some kind of a sandbox if they let people run python on their machines, I'm not sure if it's open source though. Yes, Google AppEngine has its Python sandbox and the source code is available online. I don't know the license. I found 7 vulnerabilities in 1 hour :-) I contacted Google security team. To answer to your question How is [AppEngine] different from your project?: * pysanbox has an import whitelist, whereas AppEngine has an import blacklist (subprocess, socket, ... builtin modules are replaced by safe versions). Import a Python module written in C is forbidden. * Import a module in AppEngine imports all symbols, whereas pysandbox uses also a symbol whitelist. * AppEngine doesn't have proxies, all objects are modifiable (eg. sys.path) There are other differences, but I prefer to wait for the answer from Google before telling you more :) AppEngine sandbox and pysandbox projects are very close: most protections are based on blacklists, whereas RestrictedPython is only based on whitelists. -- Victor Stinner http://www.haypocalc.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
On Feb 28, 12:05 am, Stefan Behnel stefan...@behnel.de wrote: Hal Styli, 27.02.2010 21:50: I have a sed solution to the problems below but would like to rewrite in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you want in a standard compliant way, and they can deal with all sorts of XML formatting and encoding, for example. I need to strip out some data from a quirky xml file into a csv: from something like this . cust=dick product=eggs ... quantity=12 cust=tom product=milk ... quantity=2 ... cust=harry product=bread ... quantity=1 ... cust=tom product=eggs ... quantity=6 ... . cust=dick product=eggs ... quantity=6 As others have noted, this doesn't tell much about your XML. A more complete example would be helpful. to this dick,eggs,12 tom,milk,2 harry,bread,1 tom,eggs,6 dick,eggs,6 I am new to python and xml and it would be great to see some slick ways of achieving the above by using python's XML capabilities to parse the original file or python's regex to achive what I did using sed. It's funny how often people still think that SAX is a good way to solve XML problems. Here's an untested solution that uses xml.etree.ElementTree: from xml.etree import ElementTree as ET csv_field_order = ['cust', 'product', 'quantity'] clean_up_used_elements = None for event, element in ET.iterparse(thefile.xml, events=['start']): # you may want to select a specific element.tag here # format and print the CSV line to the standard output print(','.join(element.attrib.get(title, '') for title in csv_field_order)) # safe some memory (in case the XML file is very large) if clean_up_used_elements is None: # this assigns the clear() method of the root (first) element clean_up_used_elements = element.clear clean_up_used_elements() You can strip everything dealing with 'clean_up_used_elements' (basically the last section) if your XML file is small enough to fit into memory (a couple of MB is usually fine). Stefan This solution is so beautiful and elegant. Thank you. Now I am off to learn ElementTree. By the way, Stefan, I am using Python 2.6. Do you know the differences between ElementTree and cElementTree? -- http://mail.python.org/mailman/listinfo/python-list
Re: Docstrings considered too complicated
Gregory Ewing wrote: Mel wrote: You could think of it as a not bad use of the design principle Clear The Simple Stuff Out Of The Way First. Destinations are commonly a lot simpler than sources Calculations for immediate values could be just about anything. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: Method / Functions - What are the differences?
Am 28.02.2010 15:08, schrieb Alf P. Steinbach: Hello.upper built-in method upper of str object at 0x00BA16E0 f = Hello.upper f built-in method upper of str object at 0x00BA16E0 f() 'HELLO' f.__self__ 'Hello' Holy hand grenade. You have no Idea how enlightened I feel right now :D Thank you, bound method was the term I forgot and your example... ...totally revealed the internals behind this to me. Especially the last line I quoted. I mean, I always knew *that* this works, but I never knew *why*. Regards, Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Printing the arguments of an attribute in a class
vsoler vicente.so...@gmail.com writes: I have a class that is a wrapper: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print 'Trace: ', attrname #print arguments to attrname, how? return getattr(self.wrapped, attrname) I can run it this way: x = wrapper([1,2,3]) x.append(4) Trace: append x.wrapped [1, 2, 3, 4] I am able to capture the attribute name to x (that is, append). However, I do not know how to capture and print all of its arguments (in this case number 4). How should I proceed? Thank you You could do something like this: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print '** get attribute: ', self.wrapped, attrname return wrapper(getattr(self.wrapped, attrname)) def __call__(self, *args, **kwargs): print '** call with args: ', self.wrapped, args, kwargs return wrapper(self.wrapped(*args, **kwargs)) x = wrapper([1,2,3]) x.append(4) I haven't thought about it too much though. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Challenge: escape from the pysandbox
In article mailman.330.1267292249.4577.python-l...@python.org, Daniel Fetchinson fetchin...@googlemail.com wrote: I guess they also have some kind of a sandbox if they let people run python on their machines, I'm not sure if it's open source though. Thing is, I'm sure that Google uses a critical backstop to any Python-based sandbox: something like a chroot jail. The Python sandbox is mostly there to inform you about what you can and can't do; the real security is provided by the OS. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Many customs in this life persist because they ease friction and promote productivity as a result of universal agreement, and whether they are precisely the optimal choices is much less important. --Henry Spencer -- http://mail.python.org/mailman/listinfo/python-list
Py2exe - Bad File Descriptor
I have a Python script, which is a Windows Service, that I created an EXE of via py2exe. As part of the program, it calls some external binaries, one of which restarts the computer. When I'm logged in, this works fine. However, if I log out, the service stops and logs the following error in the Event Log: type 'exceptions.IOError':(9, 'Bad file descriptor') Anyone have an idea what could be causing this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Updates about Tk
rantingrick ha scritto: On Feb 27, 11:11 am, Kevin Walzer k...@codebykevin.com wrote: (...snip...) Kevin Walzer Code by Kevinhttp://www.codebykevin.com Great post Kevin! The only thing i would like to add are my two favorite references for learning Tkinter. They are not geared around the new ttk stuff, but still 95% relevant to any Tkinter-ing http://effbot.org/tkinterbook/ http://infohost.nmt.edu/tcc/help/pubs/tkinter/ Thanks @All you guys for the explanations and links! Regards -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
Hai Vu, 28.02.2010 17:41: By the way, Stefan, I am using Python 2.6. Do you know the differences between ElementTree and cElementTree? Use cElementTree, it's implemented in C and a lot faster and more memory friendly. http://effbot.org/zone/celementtree.htm#benchmarks http://codespeak.net/lxml/performance.html Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Upgrading Py2exe App
In article mailman.201.1267054217.4577.python-l...@python.org, Ryan Kelly r...@rfk.id.au wrote: On Wed, 2010-02-24 at 15:05 -0800, Aahz wrote: In article mailman.2807.1266614926.28905.python-l...@python.org, Ryan Kelly r...@rfk.id.au wrote: Yes. The idea of having a bootstrapping exe is that actual application code can be swapped out without having to overwrite the executable file. As long as you don't change python versions, this allows updates to be safe against system crashes, even on platforms without atomic file replacement. So the frozen app does this in a background thread: Esky(sys.executable,http://my.updates.com;).auto_update() And it hits the given url, grabs the latest zipfile, downloads and unpacks and atomically places it into the application directory. Et viola, your app is at the latest version. How does this work with a running app? What if the app is a service? The changes will only take effect the next time the app is started - currently there's no support for hot upgrading a running app. From my POV, hot upgrading is less important than solid restart capabilities, particularly for services. Performing tasks like modifying the DB schema is also important (not the actual capability, but hooks for it). E.g., the next time the app starts, it should know that it's been upgraded. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Many customs in this life persist because they ease friction and promote productivity as a result of universal agreement, and whether they are precisely the optimal choices is much less important. --Henry Spencer -- http://mail.python.org/mailman/listinfo/python-list
[ANNC] pynguin-0.1 (python-based turtle graphics application)
pynguin is a python-based turtle graphics application. It combines an editor, interactive interpreter, and graphics display area. It is meant to be an easy environment for introducing some programming concepts to beginning programmers. http://pynguin.googlecode.com/ This is the initial release, with many optimizations and finer details yet to come. Please check it out and let me know what you think. pynguin is tested with Python 2.6.4 and uses PyQt (4.6) for its GUI elements. pynguin is released under GPLv3. Changes in pynguin-0.1: - initial public release _ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969 -- http://mail.python.org/mailman/listinfo/python-list
PyQt4.7 and PyQwt5.2.0
I installed the latest PyQt (4.7-1), then PyQwt 5.2.0, which was built with PyQt4.5.4. This line import PyQt4.Qwt5 as Qwt fails to load the DLL. Could this be the result of not using PyQt4 4.5.4? -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe - Bad File Descriptor
On Feb 28, 3:48 pm, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On Sun, 28 Feb 2010 10:35:23 -0800 (PST), T misceveryth...@gmail.com declaimed the following in gmane.comp.python.general: I have a Python script, which is a Windows Service, that I created an EXE of via py2exe. As part of the program, it calls some external binaries, one of which restarts the computer. When I'm logged in, this works fine. However, if I log out, the service stops and logs the following error in the Event Log: type 'exceptions.IOError':(9, 'Bad file descriptor') Anyone have an idea what could be causing this? Without code, one must play psychic... And I haven't dusted off the Tarot cards, I Ching coins, and Crystal balls is some time (No, I don't have a ouija board)... Could it be you have a mapped drive that gets disconnected when you log off? Is the service being started as part of your login? Does it attempt to write to a console? -- Wulfraed Dennis Lee Bieber KD6MOG wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Sorry for the lack of code - yes, it does try to write to the console. From what I'm finding, this error may be due to the fact that there is no console to write to when I'm logged off. However, I would like to be able to print to screen if I run the EXE in debug mode (i.e. myservice.exe debug). Do you know of any way around this? Also, I need to get the output generated from an external EXE - will subprocess.Popen cause problems if I use stdout=PIPE? Thanks for your help! -- http://mail.python.org/mailman/listinfo/python-list
Earn Money Online without Investment
Earn Money Online without Investment Now anyone can earn money online with out any investment by using some genuine websites. The detailed information of some of the genuine everseen good earnings website information are presented clealy for free at http://earnmoneyonline-without-investment.blogspot.com/2010/02/earn-money-with-e-mail-marketing-how-it.html Earn Money Online with out Inevstment Overview : | Home | | E-mail Marketing | | Home Job Opportunities | | Contact | | Disclaimer | | Sitemap | Earn Money By : | Reading E-mails | | Clicking Ads | | Chatting Friends | | Surfing Internet | | Filling Forms | | Taking Surveys | -- http://mail.python.org/mailman/listinfo/python-list
Re: Docstrings considered too complicated
In article 4b889e3d$0$27844$c3e8...@news.astraweb.com, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 26 Feb 2010 21:51:17 -0600, Tim Daneliuk wrote: The only possible exception to this I can think of is when there is some non-obvious side-effect (i.e. language and/or hardware is misfeatured): mov A,B; Moving A into B also will also arm ; the nuclear warhead if the CPU is ; hotter than 110C I had an embedded device that did *just that*, but only on Tuesdays. Thus explaining why some people never can get the hang of Tuesdays. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Many customs in this life persist because they ease friction and promote productivity as a result of universal agreement, and whether they are precisely the optimal choices is much less important. --Henry Spencer -- http://mail.python.org/mailman/listinfo/python-list
Re: help with Python installation
On Feb 27, 10:14 pm, Arnaud Delobelle arno...@googlemail.com wrote: On 28 Feb, 01:48, gujax rjngrj2...@gmail.com wrote: Hi, I have been trying to install python on my Win ME system for over two years - gave up for a while and now I am back with a resolve to solve the problem. I tried all versions of python but having installation problems for all. Installation does not proceed and I get a message saying dll required for installation could not be run. I do not even know what to do next. I also tried Activepython. It installs but when I try to open it from Start-Programs-ActivePython 2.6, I get an error window saying - upgrade windows. Is there no solution at all to installing python on WinME. I have checked registry several times online and have sought professional help but so far no success. Thanks, I will appreciate any help gujax The docs (*) say that Python 2.5 is still compatible with Windows 9X and ME, but that support for these platform was dropped at 2.6. So you should be able to install and run Python 2.5. (*)http://docs.python.org/using/windows.html#installing-python -- Arnaud Hi, Yes indeed, Python 2.5 worked and so did numpy and scipy for this version. Thanks to all for your inputs. There are now issues with plotting - graph plotting using pylab does not work nor does the Tck- Tk, but for now I am satisfied. Hopefully I will plod my way through. I should have read the documentation properly to realize that Win ME is not supported for later versions, Thanks again Gujax -- http://mail.python.org/mailman/listinfo/python-list
Re: Challenge: escape from the pysandbox
I guess they also have some kind of a sandbox if they let people run python on their machines, I'm not sure if it's open source though. Thing is, I'm sure that Google uses a critical backstop to any Python-based sandbox: something like a chroot jail. The Python sandbox is mostly there to inform you about what you can and can't do; the real security is provided by the OS. I see, makes perfect sense. This then raises the question whether it's important to have a 100% fool proof python sandbox without help from the OS, or this goal is not only too ambitious but also not really a useful one. One aspect might be that one might want to have a platform independent way of sandboxing, perhaps. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: Quoting quotes
OK, now I see the point. I was mistaken because I was supposing that every quote strictly _inside_ the string have to match another quote od the same type. Thanks to all for yours responses. -- http://mail.python.org/mailman/listinfo/python-list
Re: Use eval() safely?
Gregory Ewing wrote: I posted a demonstration of this earlier in this thread. As you wrote, your example does not work when using eval() like in my original post with second and third parameter to eval(): import math eval([c for c in (0).__class__.__bases__[0].__subclasses__() if c.__name__ == 'file'][0]('/myfile', 'w'), { __builtins__: None }, { abs: abs, sin: math.sin }) Traceback (most recent call last): File stdin, line 1, in module File string, line 1, in module IOError: file() constructor not accessible in restricted mode (Same result with Python 2.4, 2.5, and 2.6.) While I believe, that eval() is not save, I have yet to see an example for exploiting it. Leaving out the second and third parameter just proves, that one shouldn't omit them :~) Thanks in advance for any black hat example! P.S. Please Cc me, thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: cpan for python?
On Sun, 28 Feb 2010 17:27:22 +0100, Daniel Fetchinson wrote: OFF Is it only me or others also mentally read C-SPAN when somebody writes CPAN? /OFF No, it's not just you. This is the first time I've realised it wasn't C-SPAN. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python dos2unix one liner
On Sun, 28 Feb 2010 12:05:12 +0100, Stefan Behnel wrote: Steven D'Aprano, 28.02.2010 09:48: There ought to be some kind of competition for the least efficient solution to programming problems That wouldn't be very interesting. You could just write a code generator that spits out tons of garbage code including a line that solves the problem, and then let it execute the code afterwards. That beast would always win. Obfuscated code competitions could do the same: insert your simple, straight-forward, completely unobfuscated algorithm somewhere in the middle of 15 GB of garbage code. Who would even find it? But they don't, because human judges decide the winner, not some silly rule of the most lines of code wins. In any case, I wasn't serious. It would be a bit of fun, if you like that sort of thing, and you might even learn a few things (I never knew that ints don't have an __eq__ method), but I can't see it taking off. I prefer to use my powers for inefficiency to be sarcastic to strangers on Usenet. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
On 28 Feb, 19:20, Stefan Behnel stefan...@behnel.de wrote: Hai Vu, 28.02.2010 17:41: By the way, Stefan, I am using Python 2.6. Do you know the differences between ElementTree and cElementTree? Use cElementTree, it's implemented in C and a lot faster and more memory friendly. http://effbot.org/zone/celementtree.htm#benchmarkshttp://codespeak.net/lxml/performance.html Stefan Thanks for the responses so far, most enlightening. Stefan, I was happy to see such concise code. Your python worked with only very minor modifications. Hai's test xml data *without* the first and last line is close enough to the data I am using: order customer=john product=eggs quantity=12 / order customer=cindy product=bread quantity=1 / order customer=larry product=tea bags quantity=100 / order customer=john product=butter quantity=1 / order product=chicken quantity=2 customer=derek / ... quirky. I get a large file given to me in this format. I believe it is created by something like: grep 'customer=' *.xml, where there are a large number of xml files. I had to edit the data to include the first and last lines, orders and /orders, to get the python code to work. It's not an arduous task(!), but can you recommend a way to get it to work without manually editing the data? One other thing, what's the Roland Mueller post above about (I'm viewing htis in google groups)? What would the test.xsl file look like? Thanks again Hal. -- http://mail.python.org/mailman/listinfo/python-list
Starting Python from the terminal with no welcome message
Hi, Does exist some option I could send to the python interpreter during an interactive session in order to avoid the printing of the introductory message just above the top prompt ? In my case, the welcome message is the following : Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type help, copyright, credits or license for more information. gdb has such an option (the so-called quiet option). Compare this : $ gdb GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i486-linux-gnu. (gdb) with that $ gdb -q (gdb) -- http://mail.python.org/mailman/listinfo/python-list
Multiple console windows for a single program?
Hello, I'm wanting to write a program with multiple objects, each in a thread. Both will be doing output (with the print statement) almost constantly, so I'd like to be able to separate their outputs. What I want to do is have a separate window for each. Is my only option to make my own console windows using TK or something? Thanks in advance, Blake B -- http://mail.python.org/mailman/listinfo/python-list
Re: Starting Python from the terminal with no welcome message
On Sun, Feb 28, 2010 at 5:23 PM, candide cand...@free.invalid wrote: Hi, Does exist some option I could send to the python interpreter during an interactive session in order to avoid the printing of the introductory message just above the top prompt ? In my case, the welcome message is the following : Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type help, copyright, credits or license for more information. gdb has such an option (the so-called quiet option). Compare this : $ gdb GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i486-linux-gnu. (gdb) with that $ gdb -q (gdb) -- http://mail.python.org/mailman/listinfo/python-list good idea, could be very useful. I don't think I recall seeing that option in python. +1 -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list
Sample code usable Tkinter listbox
In case Someone Else(TM) may need this. This code is just how it currently looks, what I needed for my code, so it's not a full-fledged or even tested class. But it works. code language=Py3 import tkinter as t import tkinter.simpledialog import tkinter.messagebox t.askstring = tkinter.simpledialog.askstring t.warningbox= tkinter.messagebox.showwarning class UsableListbox( t.Frame ): def __init__( self, parent_widget ): t.Frame.__init__( self, parent_widget ) scrollbar = t.Scrollbar( self, orient = vertical ) self.lb = t.Listbox( self, yscrollcommand = scrollbar.set ) scrollbar.config( command = self.lb.yview ) scrollbar.pack( side = right, fill = y ) self.lb.pack( side = left, fill = both, expand = 1 ) def current_index( self ): indices = self.lb.curselection() assert( len( indices ) = 1 ) # TODO: about multi-selection. return None if len( indices ) == 0 else int( indices[0] ) def current( self ): #return self.lb.get( active ) # Incorrect with mousing i = self.current_index() return if i is None else self.lb.get( i ) def append( self, item ): return self.lb.insert( end, item ) def add_selection_event_handler( self, handler ): An event handler takes one argument, a Tkinter Event return self.lb.bind( ListboxSelect, handler ) /code Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple console windows for a single program?
On Sun, Feb 28, 2010 at 5:27 PM, Blake B bl...@randomresources.com wrote: Hello, I'm wanting to write a program with multiple objects, each in a thread. Both will be doing output (with the print statement) almost constantly, so I'd like to be able to separate their outputs. What I want to do is have a separate window for each. Is my only option to make my own console windows using TK or something? Thanks in advance, Blake B -- http://mail.python.org/mailman/listinfo/python-list you can also use python-vte -Alex Goretoy -- http://mail.python.org/mailman/listinfo/python-list
Re: Starting Python from the terminal with no welcome message
candide wrote: Does exist some option I could send to the python interpreter during an interactive session in order to avoid the printing of the introductory message just above the top prompt ? In my case, the welcome message is the following : Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type help, copyright, credits or license for more information. I asked a similar question a while back: http://www.opensubscriber.com/message/python-list@python.org/4611139.html (strangely, I couldn't find that in the mail.python.org archives via google) If you don't want to monkey with the prompts (like I did in that thread), you can just use bash$ python -ic to get a python shell without the banner. That said, it _would_ be a nice addition to have a -quiet startup option that behaves like many other apps do. But with it being just a few extra characters on the command-line, I don't expect it will happen. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Draft PEP on RSON configuration file format
All: Finding .ini configuration files too limiting, JSON and XML to hard to manually edit, and YAML too complex to parse quickly, I have started work on a new configuration file parser. I call the new format RSON (for Readable Serial Object Notation), and it is designed to be a superset of JSON. I would love for it to be considered valuable enough to be a part of the standard library, but even if that does not come to pass, I would be very interested in feedback to help me polish the specification, and then possibly help for implementation and testing. The documentation is in rst PEP form, at: http://rson.googlecode.com/svn/trunk/doc/draftpep.txt Thanks and best regards, Pat -- http://mail.python.org/mailman/listinfo/python-list
Re: Draft PEP on RSON configuration file format
Patrick Maupin pmau...@gmail.com writes: I have started work on a new configuration file parser The documentation is in rst PEP form, at:... N not another... there are too many already. :-( -1 -- http://mail.python.org/mailman/listinfo/python-list
Re: Sample code usable Tkinter listbox
On Feb 28, 6:30 pm, Alf P. Steinbach al...@start.no wrote: In case Someone Else(TM) may need this. This code is just how it currently looks, what I needed for my code, so it's not a full-fledged or even tested class. Thanks for sharing Alf, Thats works fine as-is but what about inheriting from tk.Listbox directly and having the container frame as an attribute? I prefer this API because I hate to write the laborious megawidget.mainwidget.methodX() when i could instead write megawidget.methodX(). What is your opinion on this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Draft PEP on RSON configuration file format
On Sun, 28 Feb 2010 20:09:30 -0600, Patrick Maupin wrote: All: Finding .ini configuration files too limiting, JSON and XML to hard to manually edit, and YAML too complex to parse quickly, I have started work on a new configuration file parser. I call the new format RSON (for Readable Serial Object Notation), and it is designed to be a superset of JSON. Wait a minute... if JSON is too hard to edit, and RSON is a *superset* of JSON, that means by definition every JSON file is also a valid RSON file. Since JSON is too hard to manually edit, so is RSON. I would love for it to be considered valuable enough to be a part of the standard library, Come back when you actually have MANY users other than yourself using this is real-world projects. Until then, it is too early to even consider adding it the std library. Python comes with batteries included, but not experimental batteries that aren't even built yet, let alone proven that they work. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Sample code usable Tkinter listbox
* rantingrick: On Feb 28, 6:30 pm, Alf P. Steinbach al...@start.no wrote: In case Someone Else(TM) may need this. This code is just how it currently looks, what I needed for my code, so it's not a full-fledged or even tested class. Thanks for sharing Alf, Thats works fine as-is but what about inheriting from tk.Listbox directly and having the container frame as an attribute? I prefer this API because I hate to write the laborious megawidget.mainwidget.methodX() when i could instead write megawidget.methodX(). What is your opinion on this? Well the frame contains a listbox and scrollbar. And with the frame as attribute the object that you have a direct reference to would then not be the complete thing on screen, with respect to sizing and placement and such. I generally don't like widgets that present stuff outside their bounding box. I guess that could be fixed up somehow by overriding this and that, but I find it simpler to just make the enclosing widget the widget that one has a reference to. And in a way it's also good that it's more laborious to directly access the tkinter listbox stuff, because what I discovered so far is that much of it requires work arounds and fixups, i.e. that it should be wrapped in higher level methods. I had to add some more such functionality after I posted that code. So, current (this is untested except that it works for what I'm using it for!): code language=Py3 class UsableListbox( t.Frame ): def __init__( self, parent_widget ): t.Frame.__init__( self, parent_widget ) scrollbar = t.Scrollbar( self, orient = vertical ) self.lb = t.Listbox( self, exportselection = 0, yscrollcommand = scrollbar.set ) scrollbar.config( command = self.lb.yview ) scrollbar.pack( side = right, fill = y ) self.lb.pack( side = left, fill = both, expand = 1 ) def current_index( self ): indices = self.lb.curselection() assert( len( indices ) = 1 ) # TODO: about multi-selection. return None if len( indices ) == 0 else int( indices[0] ) def current( self ): #return self.lb.get( active ) # Incorrect with mousing i = self.current_index() return if i is None else self.lb.get( i ) def item_count( self ): return self.lb.size() def clear( self ): self.lb.delete( 0, end ) def append( self, item ): return self.lb.insert( end, item ) def select_item( self, i ): assert( 0 = i self.item_count() ) self.lb.selection_set( i ) def add_selection_event_handler( self, handler ): An event handler takes one argument, a Tkinter Event return self.lb.bind( ListboxSelect, handler ) /code Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: Draft PEP on RSON configuration file format
Patrick Maupin wrote: All: Finding .ini configuration files too limiting, JSON and XML to hard to manually edit, and YAML too complex to parse quickly, I have started work on a new configuration file parser. You're not supposed to edit those formats manually. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Draft PEP on RSON configuration file format
On Sun, Feb 28, 2010 at 10:39 PM, John Nagle na...@animats.com wrote: Patrick Maupin wrote: All: Finding .ini configuration files too limiting, JSON and XML to hard to manually edit, and YAML too complex to parse quickly, I have started work on a new configuration file parser. You're not supposed to edit those formats manually. Huh? True for XML /perhaps/, but for the others I quite disagree. Perhaps you could explain your reasoning? Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Sample code usable Tkinter listbox
On Feb 28, 9:57 pm, Alf P. Steinbach al...@start.no wrote: * rantingrick: I just hate overriding all the paths to each listbox method. How about just overideing the Listboxe's geomerty methods once an your done? #-- start script --# import Tkinter as tk from Tkconstants import * import tkMessageBox as MB class ScrolledList(tk.Listbox): def __init__(self, master, **kw): self.frame = tk.Frame(master) self.frame.rowconfigure(0, weight=1) self.frame.columnconfigure(0, weight=1) self.hbar = tk.Scrollbar(self.frame, orient=HORIZONTAL) self.block = tk.Frame(self.frame, width=18, height=18) self.block.grid(row=1, column=1) self.vbar = tk.Scrollbar(self.frame, orient=VERTICAL) kw.setdefault('activestyle', 'none') kw.setdefault('highlightthickness', 0) if 'pack' in kw.keys() and kw.pop('pack') == 1: self.frame.pack(fill=BOTH, expand=1) tk.Listbox.__init__(self, self.frame, **kw) self.grid(row=0, column=0, sticky=N+S+E+W) self.hbar.configure(command=self.xview) self.vbar.configure(command=self.yview) self.config( yscrollcommand=self.vbar.set, xscrollcommand=self.hbar.set ) self.hbar.grid(row=1, column=0, sticky=W+E) self.vbar.grid(row=0, column=1, sticky=N+S) self.pack = lambda **kw: self.frame.pack(**kw) self.grid = lambda **kw: self.frame.grid(**kw) self.place = lambda **kw: self.frame.place(**kw) self.pack_config = lambda **kw: self.frame.pack_config(**kw) self.grid_config = lambda **kw: self.frame.grid_config(**kw) self.place_config = lambda **kw: self.frame.place_config(**kw) self.pack_configure = lambda **kw: self.frame.pack_config(**kw) self.grid_configure = lambda **kw: self.frame.grid_config(**kw) self.place_configure = lambda **kw: self.frame.place_config(**kw) def gets(self): return self.get(0, END) def sets(self, arg): self.delete(0, END) try: arg = arg.strip('\n').splitlines() except AttributeError: pass if hasattr(arg, '__getitem__'): for item in arg: self.insert(END, str(item)) else: raise TypeError(Scrolledlist.sets() requires a string of iterable of strings) if __name__ == '__main__': root = tk.Tk() listbox = ScrolledList(root, width=50, height=5, fg='green', selectmode='Extended', pack=1) #listbox.sets(1.25) #listbox.sets('1\n2\n3\n4\n5\n\n\n') listbox.sets(range(100)) root.mainloop() #-- end script --# -- http://mail.python.org/mailman/listinfo/python-list
Re: stripping fields from xml file into a csv
Hal Styli, 01.03.2010 00:15: Stefan, I was happy to see such concise code. Your python worked with only very minor modifications. Hai's test xml data *without* the first and last line is close enough to the data I am using: order customer=john product=eggs quantity=12 / order customer=cindy product=bread quantity=1 / order customer=larry product=tea bags quantity=100 / order customer=john product=butter quantity=1 / order product=chicken quantity=2 customer=derek / ... quirky. I get a large file given to me in this format. I believe it is created by something like: grep 'customer=' *.xml, where there are a large number of xml files. Try to get this fixed at the source. Exporting non-XML that looks like XML is not a good idea in general, and it means that everyone who wants to read the data has to adapt, instead of fixing the source once and for all. I had to edit the data to include the first and last lines, orders and /orders, to get the python code to work. It's not an arduous task(!), but can you recommend a way to get it to work without manually editing the data? Iff this cannot be fixed at the source, you can write a file-like wrapper around a file that simply returns the boundary tags before and after reading from the file itself. All you need is a .read(n) method, see the documentation of the file type. One other thing, what's the Roland Mueller post above about (I'm viewing htis in google groups)? What would the test.xsl file look like? This is the XSLT script he posted: ?xml version=1.0 encoding=UTF-8? xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform; xmlns:fo=http://www.w3.org/1999/XSL/Format; version=1.0 !-- text output because we want to have an CSV file -- xsl:output method=text/ !-- remove all whitespace coming with input XML -- xsl:strip-space elements=*/ !-- matches any order element and extracts the customer,productquantity attributes -- xsl:template match=order xsl:value-of select=@customer/ xsl:text,/xsl:text xsl:value-of select=@product/ xsl:text,/xsl:text xsl:value-of select=@quantity/ xsl:text /xsl:text /xsl:template /xsl:stylesheet Stefan -- http://mail.python.org/mailman/listinfo/python-list
[issue7242] Forking in a thread raises RuntimeError
Gregory P. Smith g...@krypto.org added the comment: Using issue7242-gps01.diff on release26-maint and a freshly downloaded opensolaris 2009-06 VM test_thread, test_threading and test_subprocess all pass for me both before -and- after the patch. Nor does the original thread_test.py cause the problem for me (meaning I'm unable to reproduce the problem in this VM in the first place so... someone else needs to) Regardless, I altered patch_2 a bit in that diff to do what I though _PyImport_ReInitLock() should really do. I also added the thread_unittest testcase to that diff. % uname -a SunOS opensolaris-vm 5.11 snv 111b i86pc i386 i86pc Solaris Can someone who could reproduce the problem in the first place please test that patch. The logic change makes sense to me. I don't know why test_threading.ThreadJoinOnShutdown.test_3_join_in_forked_from_thread would be changing behavior for you. -- components: +Extension Modules -Library (Lib) priority: normal - high Added file: http://bugs.python.org/file16395/issue7242-gps01.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7242 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7232] Support of 'with' statement fo TarFile class
Lars Gustäbel l...@gustaebel.de added the comment: Another version of the patch (issue7232.6.diff) that checks if the TarFile object is still open in the __enter__() method (plus a test for that). I removed the docstrings as Eric suggested. This is common practice in the standard library. -- Added file: http://bugs.python.org/file16396/issue7232.6.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8029] bug in 2to3 dealing with print FOO, followed by sys.stdout.write('')
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8029 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7242] Forking in a thread raises RuntimeError
Greg Jednaszewski jednaszew...@gmail.com added the comment: The problem only seems to appear on Solaris 9 and earlier. I'll try to test the updated patch tonight or tomorrow and let you know what I find. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7242 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True
R. David Murray rdmur...@bitdance.com added the comment: Because the shell argument provides important functionality. Or are you suggesting that passing a list implies shell=False and passing a string implies shell=True? That is a possibility, but I think it would not be a good idea, because people will 'accidentally' get shell=True (which, you will note is *not* the default), which is less secure. It is much better, IMO, to make people ask explicitly for the less-safe behavior. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True
Eric Smith e...@trueblade.com added the comment: I think the better design is to have 2 distinct APIs: Popen_shell and Popen_exec. I'm not wild about the name Popen_exec, suggestions welcome. Neither of these would accept a shell parameter. For starters these could be convenience APIs that just call Popen with the correct shell= value, and check the type of args. We could ultimately deprecate Popen itself. I don't see a use case where you programmatically compute the value of shell: it's always known as a function of how you're building up args. And even if such a rare case exists, you could select between the two APIs to call. Whether at this point we can make this change is another issue, of course. I'm just trying to get at the best design. But if it's done over a number of releases I think it's doable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True
Brian Curtin cur...@acm.org added the comment: That seems reasonable. We already have subprocess.call, the thin wrapper around Popen. Maybe add this as subprocess.call_shell and call_exec? -- nosy: +brian.curtin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7839] Popen should raise ValueError if pass a string when shell=False or a list when shell=True
R. David Murray rdmur...@bitdance.com added the comment: Hmm. I liked Eric's idea, and it would be easier to get in, but 'call' is actually an argument against it. It would mean that in addition to PopenExec and PopenShell we'd need call_exec and call_shell, and check_call_exec and check_call_shell. Proliferating interfaces to handle a boolean parameter doesn't seem minimalist. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7839 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7232] Support of 'with' statement fo TarFile class
Meador Inge mead...@gmail.com added the comment: This is common practice in the standard library. This doesn't necessarily mean it is a correct practice :-). All kidding aside, I think the assumption that the standard documentation on '__enter__' and '__exit__' is sufficient is a bad one. With respect to how the 'tarfile' versions of these methods behave, that documentation is not that helpful. In particular, the special behavior of an 'IOError' potentially being thrown from '__enter__' and the fact that '__exit__' does not swallow the exception. These special behaviors should be documented either in a docstring or the library documentation. I think this is important, but I may be being a bit pedantic. Also, the last change to 'test_context_manager_exception' has a bug. If the call to 'tarfile.open' throws an exception, then the call to 'self.assertRaises' will swallow it. This will cause an undefined variable reference to 'tar' in 'self.assertTrue(tar.closed, ...)'. I attached another update that fixes this problem. -- Added file: http://bugs.python.org/file16398/issue7232.7.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7242] Forking in a thread raises RuntimeError
Gregory P. Smith g...@krypto.org added the comment: If you have a chance tonight that'd be awesome. I'd love to get this in before 2.6.5rc1 (being cut tomorrow) but as its platform specific (and a pretty-old platform at that) its not worth holding up the release. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7242 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8030] documentation bugs and improvements
New submission from Christopher the Magnificent ultimate.mac.fana...@gmail.com: Help for list looks like this: help(list) class list(object) | list() - new list | list(sequence) - new list initialized from sequence's items | Help for dict looks like this: help(dict) class dict(object) | dict() - new empty dictionary. | dict(mapping) - new dictionary initialized from a mapping object's | (key, value) pairs. | dict(seq) - new dictionary initialized as if via: | d = {} | for k, v in seq: | d[k] = v | dict(**kwargs) - new dictionary initialized with the name=value pairs | in the keyword argument list. For example: dict(one=1, two=2) | As suggested by the documentation above -- and proven by verification: a = [1, 2, 3]# a new list b = list(a) a is a True a == b True a is b False a is list(a) False a = {'do': 1, 'rey': 2, 'mi': 3}# a new dict b = dict(a) a is a True a == b True a is b False a is dict(a) False -- we can clearly see that list(x) and dict(x) ALWAYS return a new, unique object. What about set? help(set) class set(object) | set(iterable) -- set object | | Build an unordered collection of unique elements. | help(set) simply reports that set(x) returns a set object. For all we know, this could mean creating a new object only if coercion is necessary; that sounds plausible enough, and people could easily write code dependent on that assumption that would introduce VERY subtle bugs! Experimentation shows however that, like list and dict, set always returns a new, unique object: a = {1, 2, 3} b = set(a) a is a True a == b True a is b False a is set(a) False Yipes! CONFUSION!!! How about we fix the documentation for set so that it matches that of list and dict, including disclosure of its always-create-new-object behavior? We can also make the returns arrow have one hyphen instead of two for consistency with most other Python documentation. Let's replace this line: X set(iterable) -- set object with this line: √ set(iterable) - new set object so that our help(set) documentation ends up looking like this: class set(object) | set(iterable) - new set object | | Build an unordered collection of unique elements. | While we're at it, I'd recommend changing the help for list and dict so that instead of saying list(sequence), dict(seq), and for k, v in seq: -- which, besides being inconsistent in use of abbreviation, also use the older paradigm of sequences instead of iterables -- we instead say list(iterable), dict(iterable), and for k, v in iterable:, giving us (X's by altered lines): help(list) class list(object) | list() - new list X| list(iterable) - new list initialized from sequence's items | help(dict) class dict(object) | dict() - new empty dictionary. | dict(mapping) - new dictionary initialized from a mapping object's | (key, value) pairs. X| dict(iterable) - new dictionary initialized as if via: | d = {} X| for k, v in iterable: | d[k] = v | dict(**kwargs) - new dictionary initialized with the name=value pairs | in the keyword argument list. For example: dict(one=1, two=2) | Making these changes from seq/sequence to iterable will serve to eliminate confusion as to whether set objects are usable in list and dict constructors -- for example, like this: x = {('spam', 'icky'), ... ('balony', 'stomachable'), ... ('beef', 'palatable'), ... ('turkey', 'yummy')} dict(x) {'turkey': 'yummy', 'balony': 'stomachable', 'beef': 'palatable', 'spam': 'icky'} Python's clear and helpful online documentation is one of my most favorite features of the language, and I'm not alone in feeling this way, so we should make it the very best resource that we can! Python rules!! -- assignee: georg.brandl components: Documentation messages: 100212 nosy: christopherthemagnificent, georg.brandl severity: normal status: open title: documentation bugs and improvements versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8030 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7481] Failing to start a thread leaves zombie thread in initial state
Gregory P. Smith g...@krypto.org added the comment: fixed in trunk r78517 and release26-maint r78518. still needs merging into py3k and release31-maint -- resolution: - accepted ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7481 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7232] Support of 'with' statement fo TarFile class
Lars Gustäbel l...@gustaebel.de added the comment: IMO it is okay for __enter__() and __exit__() not to have docstrings. I cannot see what's so special about the behaviour of __enter__() and __exit__(). __enter__() raises IOError only if the TarFile object has been already closed. This is exactly the behaviour I would expect, because it is the same every other TarFile method does when the object has been closed. IOW, using a closed TarFile as a context manager is the programmer's mistake, and I don't feel the need to document that case. The fact that __exit__() only closes the TarFile object and does not swallow exceptions is what everyone expects from a file object. It is the only logical thing to do, no need to document that either. The test_context_manager_exception() test is fine. If the call to tarfile.open() really raises an exception then something is so terribly wrong and probably all of the testsuite's 200 tests will fail anyway. We can safely assume here that this will work, no need to double-check. However, I have changed the docs again to be a bit more specific. -- Added file: http://bugs.python.org/file16400/issue7232.8.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7232 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7481] Failing to start a thread leaves zombie thread in initial state
Gregory P. Smith g...@krypto.org added the comment: r78519 r78520 for py3k and 3.1. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7481 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5802] The security descriptors of python binaries in Windows are not strict enough
Hong Chen cn.hongc...@gmail.com added the comment: Sorry for the delay, it's been a busy month. I just tried python 3.1 If installed under c:\program files, the access control list would be correct, only system administrator accounts get the modify privilege. The default installation is to c:\python31, in which the access control list has the issue that unprivileged users can modify it. I guess a possible remedy to this is that after installation, the setup program can just remove authenticated users from the access control list, or at least remove the modify privilege from the corresponding entry. Thanks, Hong On Mon, Feb 8, 2010 at 7:23 AM, Brian Curtin rep...@bugs.python.org wrote: Brian Curtin cur...@acm.org added the comment: Is the situation any different if you install Python to C:\Program Files? This seems to be at least part of the reason IronPython installs to C:\Program Files, which was discussed on the IronPython list [1] a few months ago. [1] http://lists.ironpython.com/pipermail/users-ironpython.com/2009-October/011345.html -- nosy: +brian.curtin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5802 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5802 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7245] better Ctrl-C support in pdb (program can be resumed) (issue216067)
Gregory P. Smith g...@krypto.org added the comment: Reviewers: gregory.p.smith, Benjamin, ilya.sandler, Message: Also, can you take a look at how the pdb unittests work and see if you can come up with a way to unittest the KeyboardInterrupt behavior? Particular for the 4 scenarios you outlined in your prior comments in the bug (those all make sense to me). http://codereview.appspot.com/216067/diff/2001/2002 File Lib/pdb.py (right): http://codereview.appspot.com/216067/diff/2001/2002#newcode63 Lib/pdb.py:63: def sigint_handler(self, signum, frame): Please move this below the __init__ definition. It makes classes odd to read when __init__ isn't the first method defined when people are looking for the constructor to see how to use it. http://codereview.appspot.com/216067/diff/2001/2002#newcode64 Lib/pdb.py:64: if self.allow_kbdint: Initialize self.allow_kdbint in __init__ so that a SIGINT coming in before _cmdloop has run doesn't cause an AttributeError. http://codereview.appspot.com/216067/diff/2001/2002#newcode215 Lib/pdb.py:215: # keyboard interrupts allow for an easy way to interrupt to cancel the current command http://codereview.appspot.com/216067/diff/2001/2002#newcode356 Lib/pdb.py:356: #it appears that that when pdb is reading input from a pipe Space after the # please. Also, could you add a comment in here describing what the effect of this code is? It looks like you catch KeyboardInterrupt here and remove the particular interrupted command from the list of commands to run at the current breakpoint but I may be misreading things as I haven't spent much time in pdb.py. Please review this at http://codereview.appspot.com/216067/show Affected files: M Lib/pdb.py Index: Lib/pdb.py === --- Lib/pdb.py (revision 78520) +++ Lib/pdb.py (working copy) @@ -13,8 +13,10 @@ import re import pprint import traceback +import signal + class Restart(Exception): Causes a debugger to be restarted for the debugged python program. pass @@ -58,6 +60,13 @@ class Pdb(bdb.Bdb, cmd.Cmd): +def sigint_handler(self, signum, frame): +if self.allow_kbdint: +raise KeyboardInterrupt() +print self.stdout, \nProgram interrupted. (Use 'cont' to resume). +self.set_step() +self.set_trace(frame) + def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None): bdb.Bdb.__init__(self, skip=skip) cmd.Cmd.__init__(self, completekey, stdin, stdout) @@ -72,6 +81,7 @@ import readline except ImportError: pass +signal.signal(signal.SIGINT, self.sigint_handler) # Read $HOME/.pdbrc and ./.pdbrc self.rcLines = [] @@ -176,7 +186,7 @@ if not self.commands_silent[currentbp]: self.print_stack_entry(self.stack[self.curindex]) if self.commands_doprompt[currentbp]: -self.cmdloop() +self._cmdloop() self.forget() return return 1 @@ -199,11 +209,22 @@ self.interaction(frame, exc_traceback) # General interaction function +def _cmdloop(self): +while 1: +try: +# keyboard interrupts allow for an easy way to interrupt +# cancel current command +self.allow_kbdint = True +self.cmdloop() +self.allow_kbdint = False +break +except KeyboardInterrupt: +print self.stdout, '--KeyboardInterrupt--' def interaction(self, frame, traceback): self.setup(frame, traceback) self.print_stack_entry(self.stack[self.curindex]) -self.cmdloop() +self._cmdloop() self.forget() def displayhook(self, obj): @@ -329,9 +350,18 @@ prompt_back = self.prompt self.prompt = '(com) ' self.commands_defining = True -self.cmdloop() -self.commands_defining = False -self.prompt = prompt_back +try: +self.cmdloop() +except (KeyboardInterrupt, IOError): +#it appears that that when pdb is reading input from a pipe +# we may get IOErrors, rather than KeyboardInterrupt +self.commands.pop(bnum) # remove this cmd list +self.commands_doprompt.pop(bnum) +self.commands_silent.pop(bnum) +raise KeyboardInterrupt() +finally: +self.commands_defining = False +self.prompt = prompt_back def do_break(self, arg, temporary = 0): # break [ ([filename:]lineno | function) [, condition] ] -- title: better Ctrl-C support in pdb (program can be resumed) - better Ctrl-C support in pdb (program can be resumed) (issue216067) ___ Python tracker rep...@bugs.python.org
[issue7832] assertSameElements([0, 1, 1], [0, 0, 1]) does not fail
Gregory P. Smith g...@krypto.org added the comment: fwiw - The documentation was updated in trunk, py3k and release31-maint to mention this behavior of assertSameElements. Assigning to Michael for a decision on whether or not to add to the API. python-unittest-backport has since been supplanted by Michael's http://pypi.python.org/pypi/unittest2/. -- assignee: gregory.p.smith - michael.foord priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7832 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8031] Can't get f2py to work at all
New submission from Peter Jones pjon...@hughes.net: I am user 11943. OS is Windows Vista Ultimate. I have followed the instructions on how to use f2py and get this error when I try it (is this a known bug? It appears that there is bug in f2py): C:\Python26\Scriptspython f2py.py Traceback (most recent call last): File f2py.py, line 3, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in module import crackfortran File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586 as=b['args'] ^ SyntaxError: invalid syntax I have also tried the example to create a fortran module for python and get this error: C:\Python26\Scriptspython f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m cep cep.for Traceback (most recent call last): File f2py.py, line 3, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in module import crackfortran File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586 as=b['args'] ^ SyntaxError: invalid syntax Additionally I use the Lahey/Fujitsu 95 compiler. Do I just replace the gnu95 with lahey? Also Is the msvrc71.dll file the correct one to use? I use MSVC VS 2009, which uses msvc90.dll. Should I use it instead? -- files: unnamed messages: 100225 nosy: PeterJones severity: normal status: open title: Can't get f2py to work at all Added file: http://bugs.python.org/file16402/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN HTMLHEAD META content=text/html; charset=iso-8859-1 http-equiv=Content-Type META name=GENERATOR content=MSHTML 8.00.6001.18882 STYLE/STYLE /HEAD BODY bgColor=#ff DIVFONT size=2 face=ArialI am user 11943.nbsp;OS is Windows Vista Ultimate.nbsp;I have followed the instructions on how to use f2py and get this error when I try it (is this a known bug? It appears that there is bug in f2py):/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=ArialC:\Python26\Scriptsgt;python f2py.pyBRTraceback (most recent call last):BRnbsp; File f2py.py, line 3, in lt;modulegt;BRnbsp;nbsp;nbsp; import f2py2eBRnbsp; File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in lt;modulegt;BRnbsp;nbsp;nbsp; import f2py2eBRnbsp; File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in lt;modulegt;BRnbsp;nbsp;nbsp; import crackfortranBRnbsp; File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586BRnbsp;nbsp;nbsp; as=b['args']BRnbsp;nbsp;nbsp;nbsp; ^BRSyntaxError: invalid syntax/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=ArialI have also tried the example to create a fortran module for python and get this error:/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=ArialC:\Python26\Scriptsgt;python f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m cep cep.for/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=ArialTraceback (most recent call last):BRnbsp; File f2py.py, line 3, in lt;modulegt;BRnbsp;nbsp;nbsp; import f2py2eBRnbsp; File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in lt;modulegt;BRnbsp;nbsp;nbsp; import f2py2eBRnbsp; File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in lt;modulegt;BRnbsp;nbsp;nbsp; import crackfortranBRnbsp; File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586BRnbsp;nbsp;nbsp; as=b['args']BRnbsp;nbsp;nbsp;nbsp; ^BRSyntaxError: invalid syntax/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV DIVFONT size=2 face=ArialAdditionally I use the Lahey/Fujitsu 95 compiler. Do I just replace the gnu95 with lahey? /FONT/DIV DIVFONT size=2 face=ArialAlso Is the msvrc71.dll file the correct one to use? I use MSVC VS 2009, which uses msvc90.dll. Should I use it instead?/FONT/DIV DIVFONT size=2 face=Arial/FONTnbsp;/DIV/BODY/HTML ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8032] Add gdb7 hooks to make it easier to debug Python
New submission from Dave Malcolm dmalc...@redhat.com: gdb 7 can be extended with Python code, allowing the writing of domain-specific pretty-printers and commands. I've been working on gdb 7 hooks to make it easier to debug python itself, as mentioned here: https://fedoraproject.org/wiki/Features/EasierPythonDebugging I'm attaching a patch for merger with trunk. My hope is to be the maintainer of this work, although I do not yet have SVN commit rights (see http://mail.python.org/pipermail/python-committers/2010-February/000711.html ) The code is fully compatible with the existing Misc/gdbinit macros - you can freely use both as needed. = Two versions of Python = This code is intended to run inside gdb. There are potentially two Python versions involved here: that of the inferior process (the one being debugged), and that of the debugger. As I understand things, gdb only supports embedding Python 2 at the moment. This code is thus targeting that version of Python. So far, I've attempted to keep this code so that it will run when the inferior process is either Python 2 or Python 3. I could vary this code in the py3k branch if desired. The code would then track the inferior process version of Python, so that code to debug Python 3 would live in the py3k branch. That code would still be written for Python 2, though. = Makefile changes = The Makefile installs the gdb hooks to -gdb.py relative to the built python (even if you're not using them), which some may find irritating. It needs to do this for the test_gdb.py selftest to work (and for the gdb hooks to be usable if you're actually using them to debug your build of Python). Should I write a gdb configuration test to check for the availability of gdb built with python? I've added the file to .hgignore and .bzrignore. IIRC, a similar thing can be done to the SVN metadata (I don't think this is expressable as a patch, though). Alternatively, I could wire up the gdb tests to load the file from its location in the source tree. However, I intend for this code to be installed to a location alongside the build Python, so that it can be automatically detected and used by gdb. Typically this means copying it to the path of the ELF file with a -gdb.py file. In my RPM builds I add an extra copy, locating it relative to the location of the stripped DWARF data (e.g. /usr/lib/debug/usr/lib64/libpython26.so.1.0-gdb.py) = Selftests = The selftest runs whatever version of gdb is in the path, which then invokes the built version of python, running simple print commands and verifying that gdb is corrrectly representing the results in backtraces (even in the face of corrupt data). I haven't fully tested the error cases yet (e.g. for when gdb is not installed). The tests take about 14 seconds to run on my box: [da...@brick trunk-gdb]$ time ./python Lib/test/regrtest.py -v -s test_gdb The CWD is now /tmp/test_python_19369 test_gdb test_NULL_ob_type (test.test_gdb.DebuggerTests) ... ok test_NULL_ptr (test.test_gdb.DebuggerTests) Ensure that a NULL PyObject* is handled gracefully ... ok test_classic_class (test.test_gdb.DebuggerTests) ... ok test_corrupt_ob_type (test.test_gdb.DebuggerTests) ... ok test_corrupt_tp_flags (test.test_gdb.DebuggerTests) ... ok test_corrupt_tp_name (test.test_gdb.DebuggerTests) ... ok test_dicts (test.test_gdb.DebuggerTests) ... ok test_getting_backtrace (test.test_gdb.DebuggerTests) ... ok test_int (test.test_gdb.DebuggerTests) ... ok test_lists (test.test_gdb.DebuggerTests) ... ok test_long (test.test_gdb.DebuggerTests) ... ok test_modern_class (test.test_gdb.DebuggerTests) ... ok test_singletons (test.test_gdb.DebuggerTests) ... ok test_strings (test.test_gdb.DebuggerTests) ... ok test_subclassing_list (test.test_gdb.DebuggerTests) ... ok test_subclassing_tuple (test.test_gdb.DebuggerTests) This should exercise the negative tp_dictoffset code in the ... ok test_tuples (test.test_gdb.DebuggerTests) ... ok test_unicode (test.test_gdb.DebuggerTests) ... ok -- Ran 18 tests in 13.233s OK 1 test OK. [36833 refs] real0m13.599s user0m11.771s sys 0m1.384s = Platform support = I don't have access to anything other than Linux, so I've no idea how well this stuff works on other platforms. My testing so far has been on Fedora, though I've heard of successful usage of this on Debian. = Legal stuff = Earlier versions of this code were licensed under the LGPL 2.1 I'm relicensing the code to be under the same license as Python itself, assuming that's legally OK. Do I need to state that in the file header, or is that redundant? I'm in the process of doing the PSF Contributor Agreement paperwork (as an individual); waiting to get my hands on a fax machine. My employer, Red Hat, has agreed for me to retain copyright on all contributions I make to Python. -- components: Demos and Tools messages: 100226 nosy:
[issue8032] Add gdb7 hooks to make it easier to debug Python
Changes by Dave Malcolm dmalc...@redhat.com: -- keywords: +patch Added file: http://bugs.python.org/file16403/add-gdb7-python-hooks-to-trunk.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8032 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8031] Can't get f2py to work at all
Benjamin Peterson benja...@python.org added the comment: This is a 3rd party package problem. Please ask the maintainers of it. -- nosy: +benjamin.peterson resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8031] Can't get f2py to work at all
Peter Jones pjon...@hughes.net added the comment: I would like to recall this bug report. What happend was I went to the f2py web site and dowloaded the latest version and installed it over Pythoh x,y. So I uninstalled P x,y and resinstalled and the f2py works OK now. Some one should make it more clear in the documentation to not do what I did. Peter. - Original Message - From: Peter Jones rep...@bugs.python.org To: pjon...@hughes.net Sent: Sunday, February 28, 2010 2:45 PM Subject: [issue8031] Can't get f2py to work at all New submission from Peter Jones pjon...@hughes.net: I am user 11943. OS is Windows Vista Ultimate. I have followed the instructions on how to use f2py and get this error when I try it (is this a known bug? It appears that there is bug in f2py): C:\Python26\Scriptspython f2py.py Traceback (most recent call last): File f2py.py, line 3, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in module import crackfortran File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586 as=b['args'] ^ SyntaxError: invalid syntax I have also tried the example to create a fortran module for python and get this error: C:\Python26\Scriptspython f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m cep cep.for Traceback (most recent call last): File f2py.py, line 3, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\__init__.py, line 10, in module import f2py2e File C:\Python26\lib\site-packages\f2py2e\f2py2e.py, line 26, in module import crackfortran File C:\Python26\lib\site-packages\f2py2e\crackfortran.py, line 1586 as=b['args'] ^ SyntaxError: invalid syntax Additionally I use the Lahey/Fujitsu 95 compiler. Do I just replace the gnu95 with lahey? Also Is the msvrc71.dll file the correct one to use? I use MSVC VS 2009, which uses msvc90.dll. Should I use it instead? -- files: unnamed messages: 100225 nosy: PeterJones severity: normal status: open title: Can't get f2py to work at all Added file: http://bugs.python.org/file16402/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7242] Forking in a thread raises RuntimeError
Greg Jednaszewski jednaszew...@gmail.com added the comment: I tested the updated patch, and the new unit test passes on my Sol 8 sparc, but the test_threading test still hangs on my system. However, given that the test is skipped on several platforms and it does work on more relevant versions of Solaris, it's probably OK. It's possible that an OS bug is causing that particular hang. Plus, the original patch fixed the 'real world' scenario I was running into, so I'd like to see it get into the release candidate if you're OK with it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7242 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6560] socket sendmsg(), recvmsg() methods
David Watson bai...@users.sourceforge.net added the comment: Thanks for your interest! I'm actually still working on the patch I posted, docs and a test suite, and I'll post something soon. Yes, you could just use b.join() with sendmsg() (and get slightly annoyed because it doesn't accept buffers ;) ). I made sendmsg() take multiple buffers because that's the way the system call works, but also to match recvmsg_into(), which gives you the convenience of being able to receive part of the message into a bytearray and part into an array.array(i), say, if that's how the data is formatted. As you might know, gather-write with sendmsg() can give a performance benefit by letting the kernel assemble the message while copying the data from userspace rather than having userspace copy the data once to form the message and then having the kernel copy it again when the system call is made. I suppose with Python you just need a larger message to see the benefit :) Since it can read from buffers, though, socket.sendmsg() can pull a large chunk of data straight out of an mmap object, say, and attach headers from a bytes object without the mmapped data being touched by Python at all (or even entering userspace, in this case). The patch is for 3.x, BTW - y* is valid there (and does take a buffer). As for a good reference, I haven't personally seen one. There's POSIX and RFC 3542, but they don't provide a huge amount of detail. Perhaps the (updated) W. Richard Stevens networking books? I've got the Stevens/Rago second edition of Advanced Programming in the Unix Environment, which discusses FD and credential passing with sendmsg/recvmsg, but not very well (it misuses CMSG_LEN, for one thing). The networking books were updated by different people though, so perhaps they do better. The question of whether to use CMSG_NXTHDR() to step to the next header when constructing the buffer for sendmsg() is a bit murky, in particular. I've assumed that this is the way to do it since the examples in RFC 3542 (and most of the code I've seen generally) use CMSG_FIRSTHDR() to get the initial pointer, but I've found that glibc's CMSG_NXTHDR() can (wrongly, I think) return NULL if the buffer hasn't been zero-filled beforehand (this causes segfaults with the patch I initially posted). @Wim: Yes, the rfc3542 module from that package looks as if it would be usable with these patches - although it's Python 2-only, GPL-only and looks unmaintained. Those kind of ancillary data constructors will actually be needed to make full portable use of sendmsg() and recvmsg() for things like IPv6, SCTP, Linux's socket error queues, etc. The same goes for data for the existing get/setsockopt() methods, in fact - the present suggestion to use the struct module is pretty inadequate when there are typedefs involved and implementations might add and reorder fields, etc. The objects in that package seem a bit overcomplicated, though, messing about with setter methods instead of just subclassing bytes and having different constructors to create the object from individual arguments or received bytes (say, ucred(1, 2, 3) or ucred.from_bytes(...)). Maybe the problem of testing patches well has been putting people off so far? Really exercising the system's CMSG_*HDR() macros in particular isn't entirely straightforward. I suppose there's also a reluctance to write tests while still uncertain about how to present the interface - that's another reason why I went for the most general multiple-buffer form of sendmsg()! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6560 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3892] bsddb: test01_basic_replication fails sometimes
Gregory P. Smith g...@krypto.org added the comment: r.david.murray - sounds like a good idea. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3892 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8033] sqlite: broken long integer handling for arguments to user-defined functions
New submission from Fred Fettinger fetti...@gmail.com: Handling of long integers is broken for arguments to sqlite functions created with the create_function api. Integers passed to a sqlite function are always converted to int instead of long, which produces an incorrect value for integers outside the range of a int32 on a 32 bit machine. These failures cannot be reproduced on a 64 bit machine, since sizeof(long) == sizeof(long long). I attached a program that demonstrates the failure. This program reports failures on a 32 bit machine, and all tests pass on a 64 bit machine. -- components: Library (Lib) files: sqlite_long_test.py messages: 100235 nosy: BinaryMan32 severity: normal status: open title: sqlite: broken long integer handling for arguments to user-defined functions type: behavior versions: Python 2.6 Added file: http://bugs.python.org/file16404/sqlite_long_test.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8033 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8033] sqlite: broken long integer handling for arguments to user-defined functions
Fred Fettinger fetti...@gmail.com added the comment: I've never really looked at the python source before, but this is my best guess at the problem: For the standard SELECT query: In Modules/_sqlite/cursor.c, _pysqlite_fetch_one_row() has this code: PY_LONG_LONG intval; ... } else if (coltype == SQLITE_INTEGER) { intval = sqlite3_column_int64(self-statement-st, i); if (intval INT32_MIN || intval INT32_MAX) { converted = PyLong_FromLongLong(intval); } else { converted = PyInt_FromLong((long)intval); } } For user-defined function arguments: In Modules/_sqlite/connection.c, _pysqlite_build_py_params() has this code: PY_LONG_LONG val_int; ... case SQLITE_INTEGER: val_int = sqlite3_value_int64(cur_value); cur_py_value = PyInt_FromLong((long)val_int); break; A select query can return long integers from C to python but a user-defined function argument cannot. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8033 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6729] Add support for ssize_t
Ryan Coyner rcoy...@gmail.com added the comment: You don't want to do c_size_t = c_void_p because that will prevent type checking. We want c_size_t to be integers; setting it to c_void_p will accept other values. The lines that define c_size_t are doing a sizeof check to determine how many bits the CPU supports, and c_size_t should represent unsigned integers [1]. On a 16-bit machine: c_size_t = c_uint On a 32-bit machine: c_size_t = c_ulong On a 64-bit machine: c_size_t = c_ulonglong Now, ssize_t is like size_t, except that it is signed [2]. So if I am not mistaken, all we have to do is: if sizeof(c_uint) == sizeof(c_void_p): c_size_t = c_uint c_ssize_t = c_int elif sizeof(c_ulong) == sizeof(c_void_p): c_size_t = c_ulong c_ssize_t = c_long elif sizeof(c_ulonglong) == sizeof(c_void_p): c_size_t = c_ulonglong c_ssize_t = c_longlong Patch attached with documentation and unit test. [1] - http://www.gnu.org/software/libc/manual/html_node/Important-Data-Types.html [2] - http://www.gnu.org/software/libc/manual/html_node/I_002fO-Primitives.html -- keywords: +patch nosy: +rcoyner Added file: http://bugs.python.org/file16405/issue6729.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6729 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8031] Can't get f2py to work at all
Éric Araujo mer...@netwok.org added the comment: Hello This is indeed a problem with f2py. Please tell its maintaines that they can’t name an object “as” since it’s a reserved keyword in Python 2.6 and higher. Testing with 2.5 (previous stable version, released in 2006) would have shown it: http://www.python.org/doc/2.5/whatsnew/pep-343.html points to http://www.python.org/dev/peps/pep-0343/ which tells in “Transition Plan”: “In Python 2.5, the new syntax will only be recognized if a future statement is present: from __future__ import with_statement This will make both 'with' and 'as' keywords. Without the future statement, using 'with' or 'as' as an identifier will cause a Warning to be issued to stderr. In Python 2.6, the new syntax will always be recognized; 'with' and 'as' are always keywords.” So we’ll close here, since it is a normal, documented behavior. The f2py people have to fix their code. Regards -- nosy: +merwok ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8031] Can't get f2py to work at all
Éric Araujo mer...@netwok.org added the comment: While I’m thinking about this, is there a way to make the syntax error traceback more informative, i.e. adding “'{}' is a reserved keyword” in such cases? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8031 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7849] Improve test_support.check_warnings()
Antoine Pitrou pit...@free.fr added the comment: lazy sounds like a bad name for that parameter. It makes me think of lazy evaluation, not error checking. There's also the problem that check_py3k_warnings() will check all DeprecationWarnings, not only py3k-specific ones. We need a Py3kDeprecationWarning subclass. Besides, there doesn't seem to be any point accepting positional arguments in check_py3k_warnings(). If you want a custom filter, just use check_warnings() instead. -- nosy: +benjamin.peterson, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7849 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8032] Add gdb7 hooks to make it easier to debug Python
Changes by Gregory P. Smith g...@krypto.org: -- nosy: +gregory.p.smith priority: - normal ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8032 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6926] socket module missing IPPROTO_IPV6, IPPROTO_IPV4
Gregory P. Smith g...@krypto.org added the comment: In PC/pyconfig.h we #define Py_WINVER to _WIN32_WINNT_WIN2K (0x500) for 32bit builds. I think we should update this to _WIN32_WINNT_WINXP (0x501) for all builds, not just 64bit. Assigning to loewis as he does our windows release builds so likely knows what the ramifications of this would be. -- assignee: - loewis nosy: +gregory.p.smith, loewis priority: - high versions: +Python 3.2 -Python 2.5, Python 2.6, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6926 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6926] socket module missing IPPROTO_IPV6, IPPROTO_IPV4
Martin v. Löwis mar...@v.loewis.de added the comment: Bumping the API level to XP might mean that we stop supporting Windows 2000; I'm not sure whether we agreed to that yet. I'd be curious to find out why the constants were defined in Python 2.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6926 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6926] socket module missing IPPROTO_IPV6, IPPROTO_IPV4
Gregory P. Smith g...@krypto.org added the comment: extended support for windows 2000 server ends in a few months, mainstream support ended 5 years ago: http://support.microsoft.com/lifecycle/?LN=en-usx=8y=9p1=7274 That, IMNSHO, implies that python 2.7 and 3.2 should not bother supporting win2k. Regardless, I'd imagine we can look the particular constants in question up and hard code the values when the header files don't define them for us (that is also the obvious workaround for anyone needing them in code today). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6926 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com