ANN: Resolver One 1.8 released
We're proud to announce that we've just released version 1.8 of Resolver One. This version switches to IronPython 2.6, which gives us support for Python 2.6 syntax along with some serious performance improvements. Resolver One is a Windows-based spreadsheet that integrates Python deeply into its recalculation loop, making the models you build more reliable and more maintainable. In version 1.8, we've worked hard on improving performance above and beyond the gains we got from IronPython 2.6, and we've also added a number of new statistical functions, along with various minor bugfixes and smaller enhancements. You can read more about Resolver One here: http://www.resolversystems.com/products/resolver-one/ We have a 31-day free trial version, so if you would like to take a look, you can download it from our website: http://www.resolversystems.com/download/ If you want to use Resolver One in an Open Source project, we offer free licenses for that: http://www.resolversystems.com/opensource/ Best regards, Giles -- Giles Thomas giles.tho...@resolversystems.com +44 (0) 20 7253 6372 17a Clerkenwell Road, London EC1M 5RD, UK VAT No.: GB 893 5643 79 Registered in England and Wales as company number 5467329. Registered address: 843 Finchley Road, London NW11 8NA, UK -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
ANN: mpmath 0.14 released
Hi all, Version 0.14 of mpmath is now available on the website: http://code.google.com/p/mpmath/ It can also be downloaded from the Python Package Index: http://pypi.python.org/pypi/mpmath/0.14 Mpmath is a pure-Python library for arbitrary-precision floating-point arithmetic that implements an extensive set of mathematical functions. It can be used as a standalone library or via SymPy ( http://code.google.com/p/sympy/), and is also available as a standard component of Sage (http://sagemath.org/). For a list of new features, see the blog post and changelog: http://fredrik-j.blogspot.com/2010/02/mpmath-014-released.html http://mpmath.googlecode.com/svn/tags/0.14/CHANGES For a brief summary, the new features in 0.14 include support for using a Cython-based backend soon to be added to Sage (giving a large speedup of mpmath in Sage); support for 3D plotting; fast low-precision functions (using Python's builtin float/complex types); an implementation of the Riemann-Siegel expansion for the Riemann zeta function; many improvements to evaluation of hypergeometric functions; miscellaneous new special functions; matrix functions; and several bugfixes and optimizations. Extensive documentation is available at: http://mpmath.googlecode.com/svn/trunk/doc/build/index.html (or equivalently) http://mpmath.googlecode.com/svn/tags/0.14/doc/build/index.html Bug reports and other comments are welcome on the issue tracker at http://code.google.com/p/mpmath/issues/list or the mpmath mailing list: http://groups.google.com/group/mpmath Enjoy, and extra thanks to Juan Arias de Reyna, Vinzent Steinberg, Jorn Baayen and Chris Smith who contributed to this version. Fredrik Johansson -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[RELEASED] Python 2.7 alpha 3
On behalf of the Python development team, I'm cheerful to announce the third alpha release of Python 2.7. Python 2.7 is scheduled (by Guido and Python-dev) to be the last major version in the 2.x series. Though more major releases have not been absolutely ruled out, it's likely that the 2.7 release will an extended period of maintenance for the 2.x series. 2.7 includes many features that were first released in Python 3.1. The faster io module, the new nested with statement syntax, improved float repr, set literals, dictionary views, and the memoryview object have been backported from 3.1. Other features include an ordered dictionary implementation, unittests improvements, a new sysconfig module, and support for ttk Tile in Tkinter. For a more extensive list of changes in 2.7, see http://doc.python.org/dev/whatsnew/2.7.html or Misc/NEWS in the Python distribution. To download Python 2.7 visit: http://www.python.org/download/releases/2.7/ Please note that this is a development release, intended as a preview of new features for the community, and is thus not suitable for production use. The 2.7 documentation can be found at: http://docs.python.org/2.7 Please consider trying Python 2.7 with your code and reporting any bugs you may notice to: http://bugs.python.org Enjoy! -- Benjamin Peterson 2.7 Release Manager benjamin at python.org (on behalf of the entire python-dev team and 2.7's contributors) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: execute sqlite3 dot commands in python
On Feb 5, 3:19 pm, Steve Holden st...@holdenweb.com wrote: gintare statkute wrote: Does anybody know if it possible to execute sqlite3 dot commands in python? dovanotas:/pages/links# python Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type help, copyright, credits or license for more information. import sqlite3 sqlite3 .help Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'help' the same with other commands: .databases .tables http://www.sqlite.org/sqlite.html No. Well actually you can, sort of. For instance: os.system('sqlite3 :memory: .help') Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt4 designer custom properties - combo box style
On Feb 4, 2:59 pm, David Boddie da...@boddie.org.uk wrote: On Tuesday 02 February 2010 22:25, Andrew wrote: I am creating custom widgets for the PyQt4 Designer. I can create custom properties, but I'm looking for how to create a custom property that has a combo box drop down. I've seen them in the example widgets and tried following them, but they are using pre-defined items to populate their property, so it's not a very clear example of how to get the combo box property to work. Can you explain a bit more about what you have seen and what you are trying to do. Are you trying to create a property that is treated specially by Designer or do you want to get the data for the combo box from somewhere else? I'm attempting to create a drop down property for a custom widget I'm creating. So when in designer and you scroll down to the custom properties, under the regular widget properties, one of them would be a drop down menu. The data to populate it will be coming from our API and currently is a list of string-items. Yes, it would be treated specially by Designer, since it's the only place it would be seen. In the PyQt4\examples\designer folder, it carries a number of custom widgets that will load into designer. The datetimeedit widget creates a custom drop down menu property. The plugin pulls its information from the QtCore libraries and from the QCalander Widget. Though I am unable to find a better example or even explanation of how it's actually creating that drop down menu. Is there any other examples or help for this kind of setup? Have you seen this article? http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html No, I haven't, thanks. That might step in the right direction. I can't run it right now, so I'm not sure if it is putting a spinbox as it's property or just the value from the spin box. David Andrew -- http://mail.python.org/mailman/listinfo/python-list
Re: method names nounVerb or verbNoun
On Feb 5, 3:36 pm, Chris Rebert c...@rebertia.com wrote: On Fri, Feb 5, 2010 at 2:45 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: For instance, if getting or setting the voltage is an expensive operation, you don't want to fool the user into thinking it is a cheap attribute access. I strongly disagree with this rationale as it violates the Uniform Access Principle (http://en.wikipedia.org/wiki/Uniform_access_principle). Though I concede Python's builtins don't adhere to the UAP. And I strongly disagree with the Uniform Access Principle. I want my accesses to an object to be explicitly data-like or method-like, even if Based on the Wikipedia page, Meyer's main reason behind UAP seems to be to minimize the need to break interfaces: the UAP is a means to an end. Python achieves that end without the conforming to UAP, therefore it doesn't need it, and there's no reason to adhere to it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: C:\Python25\Lib\IDLELIB\idle.pyw won't start
Gabriel, Thanks for your hints. I take them up one by one: Gabriel Genellina wrote: En Fri, 05 Feb 2010 10:23:57 -0300, Anthra Norell anthra.nor...@bluewin.ch escribió: I upgraded from 2.4 to 2.5 and am unable to start an 2.5 idle window. The OS is Windows ME. The download of 2.5 finished with a warning saying that 2.5 was the highest version for Windows 9* Any tips? I'd suggest a couple more tests. Open the Python interpreter and execute: py from idlelib import idle This *should* launch IDLE, or raise an error... import idle Traceback (most recent call last): File stdin, line 1, in module File C:/PYTHON25/Lib/IDLELIB\idle.pyw, line 6, in module import PyShell File C:\Python25\Lib\idlelib\PyShell.py, line 3, in module ImportError: No module named os import os Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named os If nothing happens, exit the process and open another one, and execute: py import Tkinter import Tkinter Traceback (most recent call last): File stdin, line 1, in module File C:\PYTHON25\lib\lib-tk\Tkinter.py, line 37, in module import FixTk # Attempt to configure Tcl/Tk without requiring PATH File C:\PYTHON25\lib\lib-tk\FixTk.py, line 1, in module import sys, os ImportError: No module named os py root = Tkinter.Tk() py root.mainloop() An empty window should appear. If not, I'd say something is wrong with the Tcl/Tk libraries. For the time being 2.4 works fine. I'd much prefer 2.5, though, because it includes the image library (PIL), whereas 2.4 cannot even use it. PIL has an impressive compatibility record - it works with *any* Python version from 1.5.2 up. You should be able to use PIL with 2.4 without problems. Another good hint to a side issue: I should download PIL for P2.4. I guess it wasn't available back then and so I continued doing images with P2.2. The real issue seems to be a missing module os. C:\PYTHON25\LIBdir os.* Volume in drive C is PKBACK# 001 Volume Serial Number is 07D1-0103 Directory of C:\PYTHON25\Lib OS PY 25,211 08-03-06 9:27a OS.PY OS PYC24,430 06-05-08 6:45p OS.PYC 2 file(s) 49,641 bytes 0 dir(s)2,635.30 MB free Here we are! Somehow the name got upper-cased! There's a whole bunch (131) of upper-cased names in the Lib I shall install the whole thing from scratch. That should take care if it. Thank you very much. Frederic (Looking forward to Linux!) -- http://mail.python.org/mailman/listinfo/python-list
Re: how to run part of my python code as root
sjdevn...@yahoo.com wrote: On Feb 4, 2:05 pm, Tomas Pelka tompe...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hey, is there possibility how to run part of my code (function for example) as superuser. Or only way how to do this is create a wrapper and run is with Popen through sudo (but I have to configure sudo to run whole python as root). thank you for excellent explanation. In decreasing order of desirability: 1. Find a way to not need root access (e.g. grant another user or group access to whatever resource you're trying to access). 2. Isolate the stuff that needs root access into a small helper program that does strict validation of all input (including arguments, environment, etc); when needed, run that process under sudo or similar. I thing this approach is the best for me. But how to connect two separated processes, one running with root privileges and second without superuser privileges? Is was thinking about Queues from multiprocessing, didn't you know if it is a good choice? 2a. Have some sort of well-verified helper daemon that has access to the resource you need and mediates use of that resource. 3. Run the process as root, using seteuid() to switch between user and root privs. The entire program must be heavily verified and do strict validation of all inputs. Any attacker who gets control over the process can easily switch to root privs and do damage. This is generally a bad idea. -- Tom Key fingerprint = 06C0 23C6 9EB7 0761 9807 65F4 7F6F 7EAB 496B 28AA -- http://mail.python.org/mailman/listinfo/python-list
Doctests and decorated methods don't get along
It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): Emulate built-in staticmethod descriptor. def __init__(self, f): self.f = f def __get__(self, obj, objtype=None): return self.f class Test(object): def method1(self): Doc string print 'x' x @staticmethod def method2(): Doc string print 'y' y @MyStaticMethod def method3(): Doc string print '***' # This test should fail. z if __name__ == '__main__': import doctest doctest.testmod(verbose=True) # == and here is the output using Python 2.6.4: [st...@sylar python]$ python2.6 test_doctests.py Trying: print 'x' Expecting: x ok Trying: print 'y' Expecting: y ok 5 items had no tests: __main__ __main__.MyStaticMethod __main__.MyStaticMethod.__get__ __main__.MyStaticMethod.__init__ __main__.Test 2 items passed all tests: 1 tests in __main__.Test.method1 1 tests in __main__.Test.method2 2 tests in 7 items. 2 passed and 0 failed. Test passed. It doesn't even see method3, let alone run the tests. This looks like bug to me. Have I missed anything? Any work arounds? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make a SimpleXMLRPCServer abort at CTRL-C under windows
Hi Gabriel, Gabriel Genellina wrote: En Fri, 05 Feb 2010 20:03:51 -0300, News123 news...@free.fr escribió: I'm using an XMLRPC server under Windows. What I wonder is how I could create a server, that can be killed with CTRL-C The server aborts easily with CTRL-BREAK but not with CTRL-C (under Windows) If I press CTRL-C it will only abort when the next RPC call occurs. It seems it is blocking in the select() call in the handle_request() function. Python 2.6 and up behaves exactly as you want. On previous versions you may use this:] I', using python 2.6.4 nd neither on Win-XP nor on Win-7 I'm capable to abort with CTR-C ? On Linux however I can use CTRL-C . class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): ... your methods ... if not hasattr(SimpleXMLRPCServer.SimpleXMLRPCServer, 'shutdown'): # pre 2.6 quit = False def serve_forever(self): while not self.quit: self.handle_request() def shutdown(self): self.quit = True def server_bind(self): self.socket.settimeout(1.0) SimpleXMLRPCServer.SimpleXMLRPCServer.server_bind(self) I tried something similiar, but without setting the socket timeout. I'll try it now with. N -- http://mail.python.org/mailman/listinfo/python-list
Re: Nim game being created, no GUI used... Need tips...
On Fri, 05 Feb 2010 21:54:48 -0600, Jordan Uchima wrote: Hello Jordan, You could try something like this (not tested, and maybe I don't quite get the rules): Nim game. In response to question on c.l.p. # Start with pot of thirteen pieces and two players. # Each player takes 1 - 4 pieces each turn. # Player who takes the last piece loses. # Declare constants. NUMBER_OF_PLAYERS = 2 TOTAL_PIECES_AT_START = 13 # Declare functions. def rules(): Print the rules of the game. print 'Some rules' def get_players(): Get the names of the players. # Let's put the player's names in a list. players = [] # Looping like this saves us repeating lines of code for each player. for player in range(NUMBER_OF_PLAYERS): name = raw_input(Hello Player %d, what is your name?\n % player) players.append(player) return players def take_turn(player): Handle a player's turn. # Turn logic goes here. # Left as an exercise :) the_remaining_number_of_pieces_after_this_turn = 1 return the_remaining_number_of_pieces_after_this_turn def main(): Run the game. # Display the rules by calling rules function. rules() # Get the players by calling the get_players function. players = get_players() # Set up the game. remaining_pieces = TOTAL_PIECES_AT_START playing = True # Main loop - let's play! while playing: # Take turns. for player in players: remaining_pieces = take_turn(player) # Check if this player has lost. if remaining_pieces == 0: # Player has taken last piece. print 'Sorry %s, you have lost.' % player # Break out of the loop playing = False break # Automatically run main function if we're run as a script. if __name__ == '__main__': main() # End. The while loop in the main function runs the game until a winner (or loser in this case) is declared. The for loop within the while loop handles the alternation of turns. Have a look at the python tutorial at http://docs.python.org/tutorial/index.html for more on while and for statements. Use functions to break up the code into related sections. Check out the tutorial material for functions too. This skeleton should give you a starting structure for your program. Have fun :) Kev -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception class documentation
If you browse the Python source tree, you should be able to find it. http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045view=markup On Fri, Feb 5, 2010 at 7:27 PM, Charles Yeomans char...@declaresub.com wrote: On Feb 5, 2010, at 2:13 PM, Gerald Britton wrote: On Fri, Feb 5, 2010 at 12:55 PM, Charles Yeomans char...@declaresub.com wrote: I am so far unable to find the information I want about the Exception class. Information like the signature of __init__ seems to be unavailable. Any suggestions where I might find such information? Though not documented, some silly tests indicate that it will accept pretty much anything: Exception(1,2,4,54) Exception(1, 2, 4, 54) Exception(*range(10)) Exception(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) Exception(*range(50)) Exception(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49) Exception('a','b','c','d','e') Exception('a', 'b', 'c', 'd', 'e') Exception(Exception(1)) Exception(Exception(1,),) I had also tried such tests. If you pass a single argument msg, it is assigned to the message property, and the args property is set to (msg,). If you pass more than one argument, the tuple of arguments is assigned to the args property, and nothing is assigned to the message property. I was hoping to at least find source code that provides a definitive answer. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list
Re: C:\Python25\Lib\IDLELIB\idle.pyw won't start
Gabriel, After reinstalling the whole package things are shaping up. It still doesn't work but it fails more to the point of your suggestions. I update the responses to your questions: Anthra Norell wrote: Gabriel, Thanks for your hints. I take them up one by one: Gabriel Genellina wrote: En Fri, 05 Feb 2010 10:23:57 -0300, Anthra Norell anthra.nor...@bluewin.ch escribió: I upgraded from 2.4 to 2.5 and am unable to start an 2.5 idle window. The OS is Windows ME. The download of 2.5 finished with a warning saying that 2.5 was the highest version for Windows 9* Any tips? I'd suggest a couple more tests. Open the Python interpreter and execute: py from idlelib import idle This *should* launch IDLE, or raise an error... import idle Traceback (most recent call last): File stdin, line 1, in module File C:/PYTHON25/lib/IDLELIB\idle.py, line 19, in module PyShell.main() File C:\Python25\Lib\idlelib\PyShell.py, line 1390, in main root = Tk(className=Idle) File C:\PYTHON25\lib\lib-tk\Tkinter.py, line 1647, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, want objects, useTk, sync, use) _tkinter.TclError: Can't find a usable init.tcl in the following directories: C:/PYTHON25/lib/tcl8.4 C:/lib/tcl8.4 C:/library Checking for the whereabouts of the tcl8.4 directory I find it in C:/PYTHON25/TCL together with a few more plus some files. C:\PYTHON25\TCLdir Volume in drive C is PKBACK# 001 Volume Serial Number is 07D1-0103 Directory of C:\PYTHON25\TCL . DIR11-25-08 4:09p . .. DIR11-25-08 4:09p .. TCL84LIB 191,802 03-27-06 4:23p tcl84.lib TCLSTU~1 LIB 2,264 03-27-06 4:23p tclstub84.lib DDE1 2 DIR11-25-08 4:09p DDE1.2 REG1 1 DIR11-25-08 4:09p REG1.1 TCL8 4 DIR11-25-08 4:09p TCL8.4 TK8 4 DIR11-25-08 4:09p TK8.4 TK84 LIB 167,288 03-27-06 4:44p tk84.lib TKSTUB84 LIB 2,988 03-27-06 4:43p tkstub84.lib TIX8 4 DIR02-06-10 1:09p tix8.4 4 file(s)364,342 bytes 7 dir(s)2,569.25 MB free This is the way the installer fixed it. The thing to do seems to be to move the tcl8.4 dirctory to the lib directory. Before I start upsetting things, perhaps you would know whether the whole TCL subtree should move. Frederic -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
Hello, this is Jeff Cameron, the organizer of the Google AI Challenge. I'm glad to see all this interest in our humble little contest. I wish you all the best of luck, and encourage everyone to try their hand at writing an AI for Tron! www.ai-contest.com Someone please dumb the Tron ROM from the MAME32 project and use it as baseline answer. :) -- @~@ Might, Courage, Vision, SINCERITY. / v \ Simplicity is Beauty! May the Force and Farce be with you! /( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7 ^ ^ 21:42:01 up 7 days 5:48 2 users load average: 0.00 0.02 0.00 不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa -- http://mail.python.org/mailman/listinfo/python-list
ANN: Resolver One 1.8 released
We're proud to announce that we've just released version 1.8 of Resolver One. This version switches to IronPython 2.6, which gives us support for Python 2.6 syntax along with some serious performance improvements. Resolver One is a Windows-based spreadsheet that integrates Python deeply into its recalculation loop, making the models you build more reliable and more maintainable. In version 1.8, we've worked hard on improving performance above and beyond the gains we got from IronPython 2.6, and we've also added a number of new statistical functions, along with various minor bugfixes and smaller enhancements. You can read more about Resolver One here: http://www.resolversystems.com/products/resolver-one/ We have a 31-day free trial version, so if you would like to take a look, you can download it from our website: http://www.resolversystems.com/download/ If you want to use Resolver One in an Open Source project, we offer free licenses for that: http://www.resolversystems.com/opensource/ Best regards, Giles -- Giles Thomas giles.tho...@resolversystems.com +44 (0) 20 7253 6372 17a Clerkenwell Road, London EC1M 5RD, UK VAT No.: GB 893 5643 79 Registered in England and Wales as company number 5467329. Registered address: 843 Finchley Road, London NW11 8NA, UK -- http://mail.python.org/mailman/listinfo/python-list
ANN: PyGUI 2.2
PyGUI 2.2 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Highlights of this version: - TextEditor component with tabs, scrolling and word wrap - Classes for laying out components in rows, colums and grids - Printing support What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Calendar GUI
On Feb 6, 12:59 am, Michael Torrie torr...@gmail.com wrote: Gabriel wrote: On Fri, Feb 5, 2010 at 9:08 PM, William Gaggioli wgaggi...@gmail.com wrote: I'm working on setting up some software for a Peruvian non-profit to help them organize their incoming volunteers. One of the features I'd like to add is acalendar-like view of the different volunteers arrival dates and staying time, with potentially some other info through some double-click action. Rather than writing acalendarguimyself, is there some open-source calendarprogram you guys could recommend that I could plug into? It has to be run locally, as the internet isn't so reliable down here, but other than that something simple and clean is ideal. I wrote a gtkguifor googlecalendar. Maybe you can adapt it to your needs. http://code.google.com/p/googlecalendar-gtk/ Would this work without an internet connection? The original poster stated that internet isn't so reliable, hence the need for a local solution. The functionality of Google calendar would be perfect, but it needs to be run locally. -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception class documentation
On Feb 6, 2010, at 8:09 AM, Gerald Britton wrote: If you browse the Python source tree, you should be able to find it. http://svn.python.org/view/python/trunk/Objects/exceptions.c?revision=77045view=markup Perfect (even if I have to read C). Thanks. Charles Yeomans -- http://mail.python.org/mailman/listinfo/python-list
[RELEASED] Python 2.7 alpha 3
On behalf of the Python development team, I'm cheerful to announce the third alpha release of Python 2.7. Python 2.7 is scheduled (by Guido and Python-dev) to be the last major version in the 2.x series. Though more major releases have not been absolutely ruled out, it's likely that the 2.7 release will an extended period of maintenance for the 2.x series. 2.7 includes many features that were first released in Python 3.1. The faster io module, the new nested with statement syntax, improved float repr, set literals, dictionary views, and the memoryview object have been backported from 3.1. Other features include an ordered dictionary implementation, unittests improvements, a new sysconfig module, and support for ttk Tile in Tkinter. For a more extensive list of changes in 2.7, see http://doc.python.org/dev/whatsnew/2.7.html or Misc/NEWS in the Python distribution. To download Python 2.7 visit: http://www.python.org/download/releases/2.7/ Please note that this is a development release, intended as a preview of new features for the community, and is thus not suitable for production use. The 2.7 documentation can be found at: http://docs.python.org/2.7 Please consider trying Python 2.7 with your code and reporting any bugs you may notice to: http://bugs.python.org Enjoy! -- Benjamin Peterson 2.7 Release Manager benjamin at python.org (on behalf of the entire python-dev team and 2.7's contributors) -- http://mail.python.org/mailman/listinfo/python-list
determining which value is the first to appear five times in a list?
I'm working on a naive K-nearest-neighbors selection criteria for an optical character recognition problem. After I build my training set, I test each new image against against the trained feature vectors and record the scores as follows: match_vals = [(match_val_1, identifier_a), (match_val_2, identifier_b) ] and so on.. then I sort the list so the smallest match_val's appear first (indictating a strong match, so I may end up with something like this: [(match_val_291, identifier_b), (match_val_23, identifier_b), (match_val_22, identifer_k) ] Now, what I would like to do is step through this list and find the identifier which appears first a K number of times. Naively, I could make a dict and iterate through the list AND the dict at the same time and keep a tally, breaking when the criteria is met. such as: def getnn(match_vals): tallies = defaultdict(lambda: 0) for match_val, ident in match_vals: tallies[ident] += 1 for ident, tally in tallies.iteritems(): if tally == 5: return ident I would think there is a better way to do this. Any ideas? Cheers! Chris -- http://mail.python.org/mailman/listinfo/python-list
how to fix bugs (python)
I am interested in fixing bugs in python. Are there entry-level bugs in python which makes me familiarize with the process just like gnome have gnome-love ? Just a small start-up guidance will be a big favour as I have never fixed any. Thanks, ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: determining which value is the first to appear five times in a list?
On 2/6/2010 1:24 PM, Chris Colbert wrote: I'm working on a naive K-nearest-neighbors selection criteria for an optical character recognition problem. After I build my training set, I test each new image against against the trained feature vectors and record the scores as follows: match_vals = [(match_val_1, identifier_a), (match_val_2, identifier_b) ] and so on.. then I sort the list so the smallest match_val's appear first (indictating a strong match, so I may end up with something like this: [(match_val_291, identifier_b), (match_val_23, identifier_b), (match_val_22, identifer_k) ] Now, what I would like to do is step through this list and find the identifier which appears first a K number of times. Naively, I could make a dict and iterate through the list AND the dict at the same time and keep a tally, breaking when the criteria is met. such as: def getnn(match_vals): tallies = defaultdict(lambda: 0) for match_val, ident in match_vals: tallies[ident] += 1 for ident, tally in tallies.iteritems(): if tally == 5: return ident I would think there is a better way to do this. Any ideas? You only need to check that the incremented tally is 5, which is to say, that the about-to-be-incremented tally is 4. t = tallies[ident] if t 4: tallies[ident] = t+1 else: return ident -- http://mail.python.org/mailman/listinfo/python-list
Re: python admin abuse complaint
Xah Lee wrote: For anyone reading this thread and interested in my opinions, i have written many essays related to this and netiquette. Many of which detail other similar incidences that i personally experienced, such as freenode's irc ban in #emacs channel. If you are interested, they can be found on my website, search for “ban xah lee”. Xah, Often (in the past) most of your posts have come across as complaints or ones pointing out problems or comparisons of the negative sort. Your overall negative tone is just one of the reasons you get labeled a troll. I suggest you try to be less confrontational and more positive. Use your expertise and intelligence to help others but don't be offended if they don't agree with you. There's more than one way to do almost everything and sometimes the best way for a person to do it is the way that person is able to grasp it. Regards, Ron -- http://mail.python.org/mailman/listinfo/python-list
Re: Doctests and decorated methods don't get along
On 2/6/2010 6:48 AM, Steven D'Aprano wrote: class MyStaticMethod(object): Emulate built-in staticmethod descriptor. def __init__(self, f): self.f = f def __get__(self, obj, objtype=None): return self.f How about using a function, instead of a class, to implement the decorator: import functools def MyStaticMethod(f): @functools.wraps(f) def _wrapper(*args, **kwargs): return f(*args, **kwargs) return _wrapper For me, this produces the hoped-for doctest failure in __main__.Test.method3. I tried making the class-based implementation work by using functools.wraps(), but I couldn't manage it. Also, doesn't the decorator protocol want the class to implement a __call__() method, not a __get__() method? Or am I getting hung up (not the first time) at the nexus of the descriptor and decorator protocols? -John -- http://mail.python.org/mailman/listinfo/python-list
intolerant HTML parser
I generate some HTML and I want to include in my unit tests a check for syntax. So I am looking for a program that will complain at any syntax irregularities. I am familiar with Beautiful Soup (use it all the time) but it is intended to cope with bad syntax. I just tried feeding HTMLParser.HTMLParser some HTML containing 'pabb/p/b' and it didn't complain. That is, this: h=HTMLParser.HTMLParser() try: h.feed('pabb/p/b') h.close() print I expect not to see this line except Exception, err: print exception:,str(err) gives me I expect not to see this line. Am I using that routine incorrectly? Is there a natural Python choice for this job? Thanks, Jim -- http://mail.python.org/mailman/listinfo/python-list
Re: determining which value is the first to appear five times in a list?
On Sat, Feb 06, 2010 at 13:24 -0500, Chris Colbert wrote: [(match_val_291, identifier_b), (match_val_23, identifier_b), (match_val_22, identifer_k) ] Now, what I would like to do is step through this list and find the identifier which appears first a K number of times. I think you can use the itertools.groupby(L, lambda el: el[1]) to group elements in your *sorted* list L by the value el[1] (i.e. the identifier) and then iterate through these groups until you find the desired number of instances grouped by the same identifier. Let me exemplify this: from itertools import groupby instances = [(1, 'b'), (2, 'b'), (3, 'a'), (4, 'c'), (5, 'c'), (6, 'c'), (7, 'd')] k = 3 grouped_by_identifier = groupby(instances, lambda el: el[1]) grouped_by_identifier = ((identifier, list(group)) for identifier, group in grouped_by_identifier) k_instances = (group for identifier, group in grouped_by_identifier if len(group) == k) next(k_instances) [(4, 'c'), (5, 'c'), (6, 'c')] next(k_instances) Traceback (most recent call last): File input, line 1, in module StopIteration There are certainly millions of ways to do this and most of them will be better than my proposal here, but you might like this approach. Another approach would use itertools.takewhile() or itertools.ifilter() ... Just have a look :-) yours sincerely -- .''`. Wolodja Wentlandwentl...@cl.uni-heidelberg.de : :' : `. `'` 4096R/CAF14EFC `- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Re: intolerant HTML parser
Jim wrote: I generate some HTML and I want to include in my unit tests a check for syntax. So I am looking for a program that will complain at any syntax irregularities. I am familiar with Beautiful Soup (use it all the time) but it is intended to cope with bad syntax. I just tried feeding HTMLParser.HTMLParser some HTML containing 'pabb/p/b' and it didn't complain. Try HTML5lib. http://code.google.com/p/html5lib/downloads/list The syntax for HTML5 has well-defined notions of correct, fixable, and unparseable. For example, the common but incorrect form of HTML comments, - comment - is understood. HTML5lib is slow, though. Sometimes very slow. It's really a reference implementation of the spec. There's code like this: #Should speed up this check somehow (e.g. move the set to a constant) if ((0x0001 = charAsInt = 0x0008) or (0x000E = charAsInt = 0x001F) or (0x007F = charAsInt = 0x009F) or (0xFDD0 = charAsInt = 0xFDEF) or charAsInt in frozenset([0x000B, 0xFFFE, 0x, 0x1FFFE, 0x1, 0x2FFFE, 0x2, 0x3FFFE, 0x3, 0x4FFFE, 0x4, 0x5FFFE, 0x5, 0x6FFFE, 0x6, 0x7FFFE, 0x7, 0x8FFFE, 0x8, 0x9FFFE, 0x9, 0xAFFFE, 0xA, 0xBFFFE, 0xB, 0xCFFFE, 0xC, 0xDFFFE, 0xD, 0xEFFFE, 0xE, 0xE, 0xF, 0x10FFFE, 0x10])): self.tokenQueue.append({type: tokenTypes[ParseError], data: illegal-codepoint-for-numeric-entity, datavars: {charAsInt: charAsInt}}) Every time through the loop (once per character), they build that frozen set again. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Doctests and decorated methods don't get along
On 2/6/2010 6:48 AM, Steven D'Aprano wrote: It seems that doctest doesn't discover or execute doctests in methods which have been decorated. Here is my test file: # == class MyStaticMethod(object): Emulate built-in staticmethod descriptor. def __init__(self, f): self.f = f def __get__(self, obj, objtype=None): return self.f class Test(object): def method1(self): Doc string print 'x' x @staticmethod def method2(): Doc string print 'y' y @MyStaticMethod def method3(): Doc string print '***' # This test should fail. z if __name__ == '__main__': import doctest doctest.testmod(verbose=True) # == and here is the output using Python 2.6.4: [st...@sylar python]$ python2.6 test_doctests.py Trying: print 'x' Expecting: x ok Trying: print 'y' Expecting: y ok 5 items had no tests: __main__ __main__.MyStaticMethod __main__.MyStaticMethod.__get__ __main__.MyStaticMethod.__init__ __main__.Test 2 items passed all tests: 1 tests in __main__.Test.method1 1 tests in __main__.Test.method2 2 tests in 7 items. 2 passed and 0 failed. Test passed. It doesn't even see method3, let alone run the tests. Method3 is wrapped as an instance of MyStaticMethod and doctest does not see that as function. Even if it did, you would might have to copy the docstring (self.__doc__ = f.__doc__) to have the test run. Note the following: (3.1) Test.method3 function method3 at 0x00F5F7C8 Test.__dict__['method3'] __main__.MyStaticMethod object at 0x00F5CDF0 Test.__dict__['method2'] staticmethod object at 0x00F5C290 Doctest has to scan the dict, so it does not see the attribute-lookup result. This looks like bug to me. Have I missed anything? I would call it a limitation as I do not see the doc as promising otherwise. I believe doctest predates the descripter protocol, at least in its current form, so it may not be completely descriptor-aware. You certainly could file a feature request for improved recognition and subsequent calling of __get__. An initial patch would improve chances of action. Any workarounds? Perhaps look at the doctest source to see why staticmethod instances are recognized as functions. If doctest directly special-cases their recognition, then use the standard nested function approach for decorators, making sure to copy the doc string. Look at functools.wraps. If doctest recognizes them by some characteristic that you have not emulated, try to improve that. Terry Jan Reedy Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: intolerant HTML parser
Thank you, John. I did not find that by looking around; I must not have used the right words. The speed of the unit tests are not critical so this seems like the solution for me. Jim -- http://mail.python.org/mailman/listinfo/python-list
How to print all expressions that match a regular expression
Hi, I am a fresh man with python. I know there is regular expressions in Python. What I need is that given a particular regular expression, output all the matches. For example, given “[1|2|3]{2}” as the regular expression, the program should output all 9 matches, i.e., 11 12 13 21 22 23 31 32 33. Is there any well-written routine in Python or third-party program to do this? If there isn't, could somebody make some suggestions on how to write it myself? Thanks. Zhuo -- http://mail.python.org/mailman/listinfo/python-list
Re: determining which value is the first to appear five times in a list?
On 2/6/2010 2:09 PM, Wolodja Wentland wrote: On Sat, Feb 06, 2010 at 13:24 -0500, Chris Colbert wrote: [(match_val_291, identifier_b), (match_val_23, identifier_b), (match_val_22, identifer_k) ] Now, what I would like to do is step through this list and find the identifier which appears first a K number of times. I think you can use the itertools.groupby(L, lambda el: el[1]) to group elements in your *sorted* list L by the value el[1] (i.e. the identifier) and then iterate through these groups until you find the desired number of instances grouped by the same identifier. This will generally not return the same result. It depends on whether OP wants *any* item appearing at least 5 times or whether the order is significant and the OP literally wants the first. Sorting the entire list may also take a *lot* longer. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: how to fix bugs (python)
On 2/6/2010 1:54 PM, Shashwat Anand wrote: I am interested in fixing bugs in python. Are there entry-level bugs in python which makes me familiarize with the process just like gnome have gnome-love ? Just a small start-up guidance will be a big favour as I have never fixed any. Go to python.org/dev/ and look at various pages there. The item tracker is at bugs.python.org Some items are marked easy. Many items have patches that need review. Help is needed both with Python code (modules) and C code (core and modules) depending on your abilities and interest. I would start with looking at current items on the tracker. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: how to fix bugs (python)
Thanks Terry. I am looking on it. :) On Sun, Feb 7, 2010 at 1:19 AM, Terry Reedy tjre...@udel.edu wrote: On 2/6/2010 1:54 PM, Shashwat Anand wrote: I am interested in fixing bugs in python. Are there entry-level bugs in python which makes me familiarize with the process just like gnome have gnome-love ? Just a small start-up guidance will be a big favour as I have never fixed any. Go to python.org/dev/ and look at various pages there. The item tracker is at bugs.python.org Some items are marked easy. Many items have patches that need review. Help is needed both with Python code (modules) and C code (core and modules) depending on your abilities and interest. I would start with looking at current items on the tracker. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Subclassing datetime.date
Hi all, I recently attempted to subclass the datetime.date object resulting in horror and confusion, before submitting to a has-a relationship. That's all fine and dandy, but out of curiosity I'd like to know what I'm missing. I was attempting to allow more flexible instancing of an object, like so: import datetime class MyDate(datetime.date): def __init__(self,*args,**kw): if len(kw) + len(args) 1: self.construct(*args,**kw) def construct(self,d,m=None,y=None,**kw): today = datetime.date.today() if m is None: m = today.month if y is None: y = today.year datetime.date.__init__(self,y,m,d,**kw) However, it wasn't having the desired effect. Indeed, I could still only instance it with 3 variables lest I get errors, and when I did call it with 3 variables it didn't reflect the order change I had implemented. Indeed, the properties were already set before it even got to the construct method. Is there some kind of built in I'm missing here? Thanks all, Will -- http://mail.python.org/mailman/listinfo/python-list
Re: determining which value is the first to appear five times in a list?
On Sat, Feb 06, 2010 at 14:42 -0500, Terry Reedy wrote: On 2/6/2010 2:09 PM, Wolodja Wentland wrote: I think you can use the itertools.groupby(L, lambda el: el[1]) to group elements in your *sorted* list L by the value el[1] (i.e. the identifier) and then iterate through these groups until you find the desired number of instances grouped by the same identifier. This will generally not return the same result. It depends on whether OP wants *any* item appearing at least 5 times or whether the order is significant and the OP literally wants the first. Order is preserved by itertools.groupby - Have a look: instances = [(1, 'b'), (2, 'b'), (3, 'a'), (4, 'c'), (5, 'c'), (6, 'c'), (7, 'b'), (8, 'b')] grouped_by_identifier = groupby(instances, lambda el: el[1]) grouped_by_identifier = ((identifier, list(group)) for identifier, group in grouped_by_identifier) k_instances = (group for identifier, group in grouped_by_identifier if len(group) == 2) for group in k_instances: ... print group ... [(1, 'b'), (2, 'b')] [(7, 'b'), (8, 'b')] So the first element yielded by the k_instances generator will be the first group of elements from the original list whose identifier appears exactly k times in a row. Sorting the entire list may also take a *lot* longer. Than what? Am I missing something? Is the *sorted* the culprit? If yes - Just forget it as it is not relevant. -- .''`. Wolodja Wentlandwentl...@cl.uni-heidelberg.de : :' : `. `'` 4096R/CAF14EFC `- 081C B7CD FF04 2BA9 94EA 36B2 8B7F 7D30 CAF1 4EFC signature.asc Description: Digital signature -- http://mail.python.org/mailman/listinfo/python-list
Google AI Challenge at U of Waterloo
Contest runs from 4 February to 26 February 2010. You may choose a programming language, such as Java, C++, Python, Ruby or Haskell. See details at http://csclub.uwaterloo.ca/contest/problem_description.php Bonne Chance! Mentifex -- http://www.scn.org/~mentifex/mindforth.txt -- http://mail.python.org/mailman/listinfo/python-list
How Uninstall MatPlotLib?
See Subject. -- http://mail.python.org/mailman/listinfo/python-list
Need installer recommendation
Hi, I could use a recommendation on a free installer for use by an unsophisticated programmer, that would be me, for some simple programs which are a bit more than Hello World, but only a little. Basically reading text files and processing the results. Nothing fancy. I am using PY2EXE to create the distribution. In doing the Google, and from past posting here, I see that most recommendations are for inno and nsis. I expect that either would do what I want. Is one a better choice for someone to learn enough to do basic stuff without getting bogged down in details which are not immediately important? -- Alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Building a multiline string
lallous lall...@lgwm.org wrote: Now should I be using method 2 or 3 in production code? Also Method1a: # Method1a x = (line1 + # can use comments! line2+ line3) Use Method1a or Method3 as you prefer: either of these generates a single string constant. Method2 is dumb. -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
Sweet, something to keep my brain busy for the next couple of weeks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
Forthminder wrote: ... Ignore. Well-known nut. See http://www.nothingisreal.com/mentifex_faq.html; John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
On Feb 5, 11:18 pm, Man-wai Chang to The Door (24000bps) toylet.toy...@gmail.com wrote: On 06-Feb-10 08:02, Forthminder wrote: Contest runs from 4 February to 26 February 2010. http://csclub.uwaterloo.ca/contest/problem_description.php Bonne Chance! It's definitely *not* exactly a programming challenge, but algorithm challenge. A programming (only) challenge should only require the players to write codes to implement an algorithm. This one requires both algorithm design programming. -- �...@~@ Might, Courage, Vision, SINCERITY. / v \ Simplicity is Beauty! May the Force and Farce be with you! /( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7 ^ ^ 12:16:01 up 6 days 20:22 2 users load average: 0.45 0.26 0.09 不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA):http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa Hello, this is Jeff Cameron, the organizer of the Google AI Challenge. I'm glad to see all this interest in our humble little contest. I wish you all the best of luck, and encourage everyone to try their hand at writing an AI for Tron! www.ai-contest.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
Man-wai Chang to The Door (24000bps) toylet.toy...@gmail.com writes: It's definitely *not* exactly a programming challenge, but algorithm challenge. A programming (only) challenge should only require the players to write codes to implement an algorithm. Eh? Just about every interesting programming challenge is mostly about algorithm selection. Try some Project Euler for example. -- http://mail.python.org/mailman/listinfo/python-list
Re: Google AI Challenge at U of Waterloo
Eh? Just about every interesting programming challenge is mostly about algorithm selection. Try some Project Euler for example. Everyone back then has abused the programming word to meant doing everything (algorithms (system analysis design), data structures, coding, testing, documentation, auditing, ) at cheap salaries+benefits and tight schedules! -- @~@ Might, Courage, Vision, SINCERITY. / v \ Simplicity is Beauty! May the Force and Farce be with you! /( _ )\ (x86_64 Ubuntu 9.10) Linux 2.6.32.7 ^ ^ 21:40:01 up 7 days 5:46 2 users load average: 0.00 0.04 0.01 不借貸! 不詐騙! 不援交! 不打交! 不打劫! 不自殺! 請考慮綜援 (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing command line argument to program from within IDLE?
Yes, that is what I was trying to do. I need to puzzle a bit on the solution, being a newbie. Thanks! -- Alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing command line argument to program from within IDLE?
Terry, CLICK, the light just came on. Knowing that it is writable, I can look at the length to determine whether there are any arguments. If not, I can switch to interactive input within the program, and input the values that way. A few easy extra lines. Whatever works. Thanks!! -- Alan -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing parameters in URL
Am 04.02.10 01:42, schrieb John Bokma: Diez B. Roggischde...@nospam.web.de writes: Am 03.02.10 19:11, schrieb John Bokma: Alan Harris-Reida...@baselinedata.co.uk writes: I have a web-page where each row in a grid has edit/delete buttons to enable the user to maintain a selected record on another page. The buttons are in the form of a link with href='/item_edit?id=123', but this string appears in the URL and gives clues as to how to bypass the correct sequence of events, and could be risky if they entered the URL directly (especially when it comes to deleting records). You should *never* use a GET request to do actions like deleting records. You already are aware of it being risky, so don't do this. You should use GET for getting information, and POST for modifying information. You should *never* say never, because there might be situations where exceptions from rules are valid. This is one such cases. Making this a post means that you need to resort to javascript to populate submit a hidden HTML-form. Just for the sake of a POST. Make each edit/delete button a submit button and optionally style it. *slap* Yep, you are right, no JS needed. I should have thought about that. Also, your claim of it being more risky is simply nonsense. GET is a tiny bit more prone to tinkering by the average user. But calling this less risky is promoting security by obscurity, at most. Maybe you should think about what happens if someone posts: img src=http://example.com/item_delete?id=123; to a popular forum... And the difference to posting from urrlib2 import open from urllib import encode open(http://example.com/item_delete;, data=encode([(id, 123)])) to that same public hacker forum is exactly what? If your webapp happens to allow item_delete to be called without authentication authorization, then *that's* your problem. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing parameters in URL
Diez B. Roggisch a écrit : Am 03.02.10 19:11, schrieb John Bokma: Alan Harris-Reida...@baselinedata.co.uk writes: I have a web-page where each row in a grid has edit/delete buttons to enable the user to maintain a selected record on another page. The buttons are in the form of a link with href='/item_edit?id=123', but this string appears in the URL and gives clues as to how to bypass the correct sequence of events, and could be risky if they entered the URL directly (especially when it comes to deleting records). You should *never* use a GET request to do actions like deleting records. You already are aware of it being risky, so don't do this. You should use GET for getting information, and POST for modifying information. You should *never* say never, because there might be situations where exceptions from rules are valid. This is one such cases. Oh yes ? Making this a post means that you need to resort to javascript to populate submit a hidden HTML-form. I beg your pardon This is total nonsense. Hopefully you don't need any js to emit a post request from a browser ! The only thing you need to do is to use a form and submit input instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing parameters in URL
Bruno Desthuilliers a écrit : Diez B. Roggisch a écrit : (snip) Making this a post means that you need to resort to javascript to populate submit a hidden HTML-form. I beg your pardon This is total nonsense. Sorry, posted too fast, John alredy adressed this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Stephen -- Bruce?
On Feb 4, 5:13 pm, Alf P. Steinbach al...@start.no wrote: What's this about all the Stephen'ses here? Shouldn't it be Bruce? Of course. We just call everyone Stephen to avoid confusion. - Alf (wondering) -- http://mail.python.org/mailman/listinfo/python-list
Re: Your beloved python features
Terry Reedy tjre...@udel.edu wrote in message news:mailman.1929.1265328905.28905.python-l...@python.org... Iterators, and in particular, generators. A killer feature. Terry Jan Reedy Neither unique to Python. And then're the other killer features superfluous :s and rigid formatting! -- http://mail.python.org/mailman/listinfo/python-list
Re: Your beloved python features
apeach a écrit : I love intuitive type recognition. no need to 'DIM everything AS Integer' etc.! not to mention the ever hilarious (that is, when you don't have to maintain it) typical Java idiom: EveryThing theEveryThing = new EveryThing(); -- http://mail.python.org/mailman/listinfo/python-list
Re: list.extend([]) Question
Gerald Britton a écrit : I think it's because when you do ['a'].extend([]) or whatever, the result is whatever the method extend returns. But extend has no return value It does : it returns None. -- http://mail.python.org/mailman/listinfo/python-list
Stephen -- Bruce?
What's this about all the Stephen'ses here? Shouldn't it be Bruce? - Alf (wondering) -- http://mail.python.org/mailman/listinfo/python-list
optparse print_help question
Is there a way to use the optparser parser.print_help() so that it ONLY prints out the options, and NOT the usage? thanks -- http://mail.python.org/mailman/listinfo/python-list
TABS in the CPython C source code
Just trying to delve into the CPython source code. Pleasant surprise: while e.g. the gcc compiler is written in KR C (1975 style C), CPython seems to be written in almost modern C (1989 and on). But, hey, TABS used for indenting, combined haphazardly and randomly with SPACES used for indenting, in the same source files... The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. Or perhaps modern Visual Studio has default tab size 8, it wouldn't surprise me (the best version was the MSVC 6.0 Developer Studio, since then that IDE has only gone downhill being re-based on the Office Assistant inspired for dummies IDE that Microsoft had for web designers). Anyways, I would suggest converting all those tabs to spaces, as e.g. the Boost library project does -- no tabs allowed. That's much more platform-independent. :-) Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt4 designer custom properties - combo box style
On Saturday 06 February 2010 10:32, Andrew wrote: I'm attempting to create a drop down property for a custom widget I'm creating. So when in designer and you scroll down to the custom properties, under the regular widget properties, one of them would be a drop down menu. The data to populate it will be coming from our API and currently is a list of string-items. Yes, it would be treated specially by Designer, since it's the only place it would be seen. Right. The drop down menus in the property editor usually contain values defined for C++ enums which have been declared to Qt's meta-object system when a C++ library or plugin is compiled. I'm not sure that PyQt can expose lists of Python values in the same way. An example of this is the alignment property in QLineEdit. In the PyQt4\examples\designer folder, it carries a number of custom widgets that will load into designer. The datetimeedit widget creates a custom drop down menu property. The plugin pulls its information from the QtCore libraries and from the QCalander Widget. Though I am unable to find a better example or even explanation of how it's actually creating that drop down menu. Each of the individual properties are just single values, aren't they, not collections of values? Have you seen this article? http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html No, I haven't, thanks. That might step in the right direction. I can't run it right now, so I'm not sure if it is putting a spinbox as it's property or just the value from the spin box. The value from each spin box is turned into a property, so there are latitude and longitude properties, though each of these only holds a double precision floating point number. It sounds like you want to be able to select from a list of values, or possibly change the values themselves. If it turns out you can't add a property to Qt Designer in the way you want, you can still add a custom editor to the widget so that users can open a context menu and select an item to configure it. This is similar to the way you can open a dialog to edit the text inside QTextEdit widgets. The article I referred to also covers this: http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html#makingamenu David -- http://mail.python.org/mailman/listinfo/python-list
Re: Last M digits of expression A^N
mukesh tiwari wrote: Hello everyone. I am kind of new to python so pardon me if i sound stupid. I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking mod of expression. Is there any other way to do this in python more faster than log N. How do you arrive at log N as the performance number? def power(A,N,M): ret=1 while(N): if(N%2!=0):ret=(ret*A)%M A=(A*A)%M N=N//2 return ret -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
On Feb 6, 9:31 pm, Alf P. Steinbach al...@start.no wrote: Just trying to delve into the CPython source code. Pleasant surprise: while e.g. the gcc compiler is written in KR C (1975 style C), CPython seems to be written in almost modern C (1989 and on). But, hey, TABS used for indenting, combined haphazardly and randomly with SPACES used for indenting, in the same source files... The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. Or perhaps modern Visual Studio has default tab size 8, it wouldn't surprise me (the best version was the MSVC 6.0 Developer Studio, since then that IDE has only gone downhill being re-based on the Office Assistant inspired for dummies IDE that Microsoft had for web designers). Anyways, I would suggest converting all those tabs to spaces, as e.g. the Boost library project does -- no tabs allowed. That's much more platform-independent. :-) Cheers, - Alf So what's stopping you from doing this yourself? -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
* Andrej Mitrovic: On Feb 6, 9:31 pm, Alf P. Steinbach al...@start.no wrote: Just trying to delve into the CPython source code. Pleasant surprise: while e.g. the gcc compiler is written in KR C (1975 style C), CPython seems to be written in almost modern C (1989 and on). But, hey, TABS used for indenting, combined haphazardly and randomly with SPACES used for indenting, in the same source files... The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. Or perhaps modern Visual Studio has default tab size 8, it wouldn't surprise me (the best version was the MSVC 6.0 Developer Studio, since then that IDE has only gone downhill being re-based on the Office Assistant inspired for dummies IDE that Microsoft had for web designers). Anyways, I would suggest converting all those tabs to spaces, as e.g. the Boost library project does -- no tabs allowed. That's much more platform-independent. :-) Cheers, - Alf So what's stopping you from doing this yourself? Depends what this you're referring to. If by this you mean, automatically converting tabs to spaces on checking out a newer version of a CPython source file, nothing in particular stops anyone from doing that. But it's needless work, and it results in false positive changes when checking in something. That's why e.g. Boost standardizes on spaces. If by this you mean, changing the coding guidelines (if such exist) for the CPython project, well I'm not involved, so the best I can do is to float the idea and point to existing practice in other projects, which I've now done. :-) Cheers hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
Alf P. Steinbach: The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. I'm concluding that the CPython programmers configure their Visual Studio's to *nix convention. Most of the core developers use Unix. Anyways, I would suggest converting all those tabs to spaces, as e.g. the Boost library project does -- no tabs allowed. This would damage the usefulness of source control histories (svn annotate) as all of the converted lines would show this recent cosmetic change rather than the previous change which is likely to be a substantive modification. Neil -- http://mail.python.org/mailman/listinfo/python-list
Re: Subclassing datetime.date
Sir Wilhelm the Sturdy wgaggi...@gmail.com writes: F Hi all, I recently attempted to subclass the datetime.date object resulting in horror and confusion, before submitting to a has-a relationship. That's all fine and dandy, but out of curiosity I'd like to know what I'm missing. I was attempting to allow more flexible instancing of an object, like so: import datetime class MyDate(datetime.date): def __init__(self,*args,**kw): if len(kw) + len(args) 1: self.construct(*args,**kw) def construct(self,d,m=None,y=None,**kw): today = datetime.date.today() if m is None: m = today.month if y is None: y = today.year datetime.date.__init__(self,y,m,d,**kw) However, it wasn't having the desired effect. Indeed, I could still only instance it with 3 variables lest I get errors, and when I did call it with 3 variables it didn't reflect the order change I had implemented. Indeed, the properties were already set before it even got to the construct method. __init__ is *not* the construction method, __new__ is (at least with new style classes) Is there some kind of built in I'm missing here? I guess __new__ but I am quite the newbie. -- 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: TABS in the CPython C source code
Alf P. Steinbach al...@start.no writes: Just trying to delve into the CPython source code. Pleasant surprise: while e.g. the gcc compiler is written in KR C (1975 style C), CPython seems to be written in almost modern C (1989 and on). But, hey, TABS used for indenting, combined haphazardly and randomly with SPACES used for indenting, in the same source files... The size-8 tabs look really bad in an editor configured with tab size 4, as is common in Windows. Then you are either used a broken editor or a misconfigured editor. I've used TextPad for ages, and it can be configured to hard tab 8 (might even be the default [1]). [1] With Perl coding I configured it to indent 4 spaces, hard tab 4 spaces and convert hard tabs to 4 spaces while saving, so no surprises. -- John Bokma j3b Hacking Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl Python Development -- http://mail.python.org/mailman/listinfo/python-list
how to add pydoc strings to 'Data and other attributes'
I'm having some problems with pydoc and I was not very sucessful in googling. (probably missng one key word) Is there soemthing like a documentation of pydoc (execpt pydocs output of pydoc, which doesn't seem to answer my question ) I can add docstrings to - the file head - to a class - to a class function - to a property but I don't know how document a class attribute (like 'name' ) in my example below Does anybody know how to doc it? # file starts here # # # This appears in the python documentation # # __author__ = 'News123' # this will also be part of pydoc general blabla will not be part of pydoc class MyClass(object): This class can be doc-ed name = 3 ### I don't know how to document this def get_f(self): the function get_f is here return 3 f = property(get_f,doc=this property is also documented) # file ends here thanks for any help N -- http://mail.python.org/mailman/listinfo/python-list
Re: Code snippet: dualmethod descriptor
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Thu, 04 Feb 2010 00:09:02 -0300, Gabriel Genellina wrote: En Sat, 30 Jan 2010 03:06:18 -0300, Steven D'Aprano st...@remove-this-cybersource.com.au escribió: class dualmethod(object): [...] Seems useful! Perhaps a better place to post it would be http://code.activestate.com/recipes/langs/python/, at least it's easier to search. Thank you for the encouragement. The recipe is now posted: http://code.activestate.com/recipes/577030/ Oddly, in Python 3 you can achieve something a bit similar very simply: class A: ... def foo(self=None): ... return Instance if self else Class ... A.foo() 'Class' a = A() a.foo() 'Instance' It works in python 3 because unbound methods are plain functions. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
Gabriel Genellina gagsl-...@yahoo.com.ar writes: En Fri, 05 Feb 2010 19:22:39 -0300, bartc ba...@freeuk.com escribió: Steve Holden st...@holdenweb.com wrote in message news:mailman.1998.1265399766.28905.python-l...@python.org... Arnaud Delobelle wrote: Robert Kern robert.k...@gmail.com writes: I prefer Guido's formulation (which, naturally, I can't find a direct quote for right now): if you expect that a boolean argument is only going to take *literal* True or False, then it should be split into ^^^ two functions. So rather than three boolean arguments, would you have eight functions? If there's genuinely a need for that functionality, yes. So you want a function such as drawtext(s, bold=true, italic=false, underline=true) to be split into: drawtext(s) drawtextb(s) drawtexti(s) drawtextu(s) drawtextbi(s) drawtextbu(s) drawtextiu(s) drawtextbiu(s) Note the *literal* part. If you (the programmer) is likely to know the parameter value when writing the code, then the function is actually two separate functions. Thanks, I understand what Steve Holden meant now. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
In article ee2cfd35-3171-4ee7-ad3a-cf117e552...@r24g2000yqd.googlegroups.com, hzh...@gmail.com hzh...@gmail.com wrote: Hi, I am a fresh man with python. I know there is regular expressions in Python. What I need is that given a particular regular expression, output all the matches. For example, given ³[1|2|3]{2}² as the regular expression, the program should output all 9 matches, i.e., 11 12 13 21 22 23 31 32 33. Is there any well-written routine in Python or third-party program to do this? If there isn't, could somebody make some suggestions on how to write it myself? Thanks. Zhuo Please enumerate all the strings which match .*. Use additional sheets of paper if needed. -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
Neil Hodgson nyamatongwe+thunder at gmail.com writes: This would damage the usefulness of source control histories (svn annotate) as all of the converted lines would show this recent cosmetic change rather than the previous change which is likely to be a substantive modification. That's not completely true given svn diff -x -w. -- http://mail.python.org/mailman/listinfo/python-list
Re: Last M digits of expression A^N
Yes, it can be done. Have a look at : http://en.wikipedia.org/wiki/Modular_exponentiation The algorithm is also mentioned in CLRS.I tried writing my own modular-exponentiation code following CLRS but observed that python pow() function is much more efficient. Have a look at this problem : https://www.spoj.pl/problems/LASTDIG/ as you can see ( https://www.spoj.pl/status/LASTDIG,l0nwlf/ )my first solution used algorithm hard-coded from CLRS which took 0.04 sec however using pow() function directly improved the efficiency to 0.0 So I would suggest to go for pow() unless you intend to learn modular exponentiation algorithm for which hand-coding is a must. here are my solutions : first one (hand-coded): 1. def pow(a, b): 2. if( not b): 3.return 1 4. if( b 1 ): 5.return ( pow( a, b - 1 ) * a ) % 10 6. 7. tmp = pow( a, b / 2 ) 8. return ( tmp * tmp ) % 10; 9. 10. for i in xrange(input()): 11. a,b = [ int(x) for x in raw_input().split(' ')] 12. print( pow( a % 10, b ) ) second one (pow()): 1. for i in range(int(raw_input())): 2. a,b = [int(x) for x in raw_input().split()] 3. print pow (a,b,10) 4. HTH ~l0nwlf On Sun, Feb 7, 2010 at 2:32 AM, monkeys paw u...@example.net wrote: mukesh tiwari wrote: Hello everyone. I am kind of new to python so pardon me if i sound stupid. I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking mod of expression. Is there any other way to do this in python more faster than log N. How do you arrive at log N as the performance number? def power(A,N,M): ret=1 while(N): if(N%2!=0):ret=(ret*A)%M A=(A*A)%M N=N//2 return ret -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
Alf P. Steinbach alfps at start.no writes: Anyways, I would suggest converting all those tabs to spaces This has been discussed to death of Python-dev. We use spaces for all new files and tabs for historical reasons in old files. Mixed ones should be converted one way or the other. That's much more platform-independent. -- http://mail.python.org/mailman/listinfo/python-list
Re: Last M digits of expression A^N
a nice exercise to do can be this problem : http://www.codechef.com/MARCH09/problems/A4/ , it deals with both cases, first and last k digits and can be performed within O(log n) On Sun, Feb 7, 2010 at 3:58 AM, Shashwat Anand anand.shash...@gmail.comwrote: Yes, it can be done. Have a look at : http://en.wikipedia.org/wiki/Modular_exponentiation The algorithm is also mentioned in CLRS.I tried writing my own modular-exponentiation code following CLRS but observed that python pow() function is much more efficient. Have a look at this problem : https://www.spoj.pl/problems/LASTDIG/ as you can see ( https://www.spoj.pl/status/LASTDIG,l0nwlf/ )my first solution used algorithm hard-coded from CLRS which took 0.04 sec however using pow() function directly improved the efficiency to 0.0 So I would suggest to go for pow() unless you intend to learn modular exponentiation algorithm for which hand-coding is a must. here are my solutions : first one (hand-coded): 1. def pow(a, b): 2. if( not b): 3. return 1 4. if( b 1 ): 5. return ( pow( a, b - 1 ) * a ) % 10 6. 7. tmp = pow( a, b / 2 ) 8. return ( tmp * tmp ) % 10; 9. 10. for i in xrange(input()): 11. a,b = [ int(x) for x in raw_input().split(' ')] 12. print( pow( a % 10, b ) ) second one (pow()): 1. for i in range(int(raw_input())): 2. a,b = [int(x) for x in raw_input().split()] 3. print pow (a,b,10) 4. HTH ~l0nwlf On Sun, Feb 7, 2010 at 2:32 AM, monkeys paw u...@example.net wrote: mukesh tiwari wrote: Hello everyone. I am kind of new to python so pardon me if i sound stupid. I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking mod of expression. Is there any other way to do this in python more faster than log N. How do you arrive at log N as the performance number? def power(A,N,M): ret=1 while(N): if(N%2!=0):ret=(ret*A)%M A=(A*A)%M N=N//2 return ret -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: determining which value is the first to appear five times in a list?
On 2/6/2010 3:25 PM, Wolodja Wentland wrote: On Sat, Feb 06, 2010 at 14:42 -0500, Terry Reedy wrote: On 2/6/2010 2:09 PM, Wolodja Wentland wrote: I think you can use the itertools.groupby(L, lambda el: el[1]) to group elements in your *sorted* list L by the value el[1] (i.e. the identifier) and then iterate through these groups until you find the desired number of instances grouped by the same identifier. This will generally not return the same result. It depends on whether OP wants *any* item appearing at least 5 times or whether the order is significant and the OP literally wants the first. Order is preserved by itertools.groupby - Have a look: Sorting does not. instances = [(1, 'b'), (2, 'b'), (3, 'a'), (4, 'c'), (5, 'c'), (6, 'c'), (7, 'b'), (8, 'b')] grouped_by_identifier = groupby(instances, lambda el: el[1]) grouped_by_identifier = ((identifier, list(group)) for identifier, group in grouped_by_identifier) k_instances = (group for identifier, group in grouped_by_identifier if len(group) == 2) for group in k_instances: ... print group ... [(1, 'b'), (2, 'b')] [(7, 'b'), (8, 'b')] So the first element yielded by the k_instances generator will be the first group of elements from the original list whose identifier appears exactly k times in a row. Sorting the entire list may also take a *lot* longer. Than what? Than linearly scanning for the first 5x item, as in my corrected version of the original code. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
Roy Smith r...@panix.com writes: hzh...@gmail.com hzh...@gmail.com wrote: What I need is that given a particular regular expression, output all the matches. […] Please enumerate all the strings which match .*. Use additional sheets of paper if needed. +1 QOTW -- \ “Are you pondering what I'm pondering?” “I think so, ... Brain, | `\but how can we get seven dwarves to shave their legs?” —_Pinky | _o__) and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
new.instancemethod __iter__
Hello all When I create an Object and set its __iter__ method from outside s = Sequence #one of my own classes s.__iter__ = new.instancemethod(f,s,Sequence) I get different results, depending on whether I call for x in y.__iter__(): print x or for x in y: print x The first case does what I expected, i.e. it iterates over whatever f() yields. In the second case nothing is printed. I have the impression that it still calls the original __iter__() method (the one defined at the class level). Why is that so? How can I replace the __iter__() method so it does what I want. The reason I want to do such things is I need to implement operations similar to what itertools do. However I want my own classes and the operations are only similar to itertools, but differ in significant details. -- http://mail.python.org/mailman/listinfo/python-list
Re: Last M digits of expression A^N
monkeys paw wrote: div class=moz-text-flowed style=font-family: -moz-fixedmukesh tiwari wrote: Hello everyone. I am kind of new to python so pardon me if i sound stupid. I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking mod of expression. Is there any other way to do this in python more faster than log N. How do you arrive at log N as the performance number? def power(A,N,M): ret=1 while(N): if(N%2!=0):ret=(ret*A)%M A=(A*A)%M N=N//2 return ret Because the N= N/2 operation in the loop means that the number of loops is equal to the number of bits in N, or the log-base-2 of N. DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Doctests and decorated methods don't get along
On Sat, 06 Feb 2010 14:00:28 -0500, John Posner wrote: On 2/6/2010 6:48 AM, Steven D'Aprano wrote: class MyStaticMethod(object): Emulate built-in staticmethod descriptor. def __init__(self, f): self.f = f def __get__(self, obj, objtype=None): return self.f How about using a function, instead of a class, to implement the decorator: I've had problems with function decorators and doctest in the past. If I remember the problem correctly, functools.wraps changing the __module__ of the wrapped function, making it look like it came from the functool module, and so doctest would not run the tests. But it seems that has been fixed in 2.6: I can confirm your version works as expected. Nevertheless, I think it is a limitation of doctest that it doesn't see methods using the descriptor protocol. Even if I could work around my immediate issue by using a function decorator (and I don't think I can) I'd still want to fix this problem. I tried making the class-based implementation work by using functools.wraps(), but I couldn't manage it. Me neither. I think the problem is that the doctest.DocTestFinder class doesn't find descriptor-based methods. It special cases staticmethod, classmethod and property. Also, doesn't the decorator protocol want the class to implement a __call__() method, not a __get__() method? Or am I getting hung up (not the first time) at the nexus of the descriptor and decorator protocols? In this case, I'm actually using a descriptor as the decorator. The descriptor is called at attribute lookup, before the method is called. __get__ returns a function, which has a __call__ method, and it should all just work. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: TABS in the CPython C source code
Le Sat, 06 Feb 2010 22:26:55 +, Benjamin Peterson a écrit : Neil Hodgson nyamatongwe+thunder at gmail.com writes: This would damage the usefulness of source control histories (svn annotate) as all of the converted lines would show this recent cosmetic change rather than the previous change which is likely to be a substantive modification. That's not completely true given svn diff -x -w. That's even less true given we aren't ashamed to make other kinds of cosmetic changes when desired, even though it also damages the usefulness of source control histories ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: new.instancemethod __iter__
On Sat, 06 Feb 2010 23:53:53 +0100, Martin Drautzburg wrote: Hello all When I create an Object and set its __iter__ method from outside s = Sequence #one of my own classes s.__iter__ = new.instancemethod(f,s,Sequence) I'm confused as to why you are aliasing your class before changing it. The above just makes s an alternative name for Sequence. Did you mean this? s = Sequence() # make an instance of the class I get different results, depending on whether I call for x in y.__iter__(): print x What's y? Where does it come from? Is y supposed to be an instance of Sequence? or for x in y: print x The first case does what I expected, i.e. it iterates over whatever f() yields. In the second case nothing is printed. I have the impression that it still calls the original __iter__() method (the one defined at the class level). Yes, that's almost certainly what is happening. As an optimization, Python bypasses the instance for special methods __NAME__. Why is that so? How can I replace the __iter__() method so it does what I want. The best solution is, find another way to do what you want. The clunky solution is to use delegation to wrap your class, and have the outer class re-direct calls to special methods to the instance first. The reason I want to do such things is I need to implement operations similar to what itertools do. However I want my own classes and the operations are only similar to itertools, but differ in significant details. I don't understand this. If you want iterator operations similar to itertools, why does this mean you need to replace anything? Just create your own iterators. Or use pre-processing and post-processing to get what you want. Can you show an example of what you would like to happen? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: merge stdin, stdout?
On Feb 5, 11:10 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Fri, 05 Feb 2010 17:39:07 -0300, jonny lowe jonny.lowe.12...@gmail.com escribió: On Feb 4, 8:20 pm, exar...@twistedmatrix.com wrote: On 01:56 am, jonny.lowe.12...@gmail.com wrote: What I want is to have an easy way tomergeinput.txt and thestdout so that output.txt look like: Enter a number: 42 You entered 42. Here, the first 42 is of course from input.txt. It sounds like you might be looking forscript(1)? $ script -c ./y input.txt output.txt Script started, file is output.txt gimme x:you entered hello Script done, file is output.txt Try moving the redirection out of the command: $ script -c ./y output.txt input.txt -- Gabriel Genellina- Hide quoted text - - Show quoted text - The result is the same as before. I've tested in fedora11. -jon -- http://mail.python.org/mailman/listinfo/python-list
Re: Last M digits of expression A^N
On Feb 5, 8:14 pm, mukesh tiwari mukeshtiwari.ii...@gmail.com wrote: I have to find out the last M digits of expression.One thing i can do is (A**N)%M but my A and N are too large (10^100) and M is less than 10^5. The other approach was repeated squaring and taking mod of expression. Is there any other way to do this in python more faster than log N. By the way, given that your M is fairly tiny compared with A and N, a little bit of elementary number theory (e.g., Euler's theorem) could save you a lot of time here. For example, pow(a, n, 10**5) is equivalent to pow(a, 5 + (n - 5) % 4, 10**5) for any n = 5. Not sure if this is the kind of thing you're looking for. -- Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: new.instancemethod __iter__
Martin Drautzburg wrote: The first case does what I expected, i.e. it iterates over whatever f() yields. In the second case nothing is printed. I have the impression that it still calls the original __iter__() method (the one defined at the class level). Why is that so? How can I replace the __iter__() method so it does what I want. Virtually all __magic__ methods are looked up on the type, not the instance. So obj.__iter__() translates into type(obj).__iter__(obj). If you *really* need to overwrite __iter__ on your instance rather than defining it on your class, you need to proxy the method call: class MyObject(object): def __iter__(self): return self.myiter() obj = MyObject() obj.myiter = myiter That should do the trick. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Doctests and decorated methods don't get along
On Sat, 06 Feb 2010 14:39:00 -0500, Terry Reedy wrote: On 2/6/2010 6:48 AM, Steven D'Aprano wrote: It seems that doctest doesn't discover or execute doctests in methods which have been decorated. [...] Doctest has to scan the dict, so it does not see the attribute-lookup result. Ahaha, now we're getting somewhere. If I do this: import inspect import test_doctests method3 = test_doctests.Test.__dict__['method3'] inspect.isfunction(method3) False inspect.ismethod(method3) False But: inspect.ismethoddescriptor(method3) True which is what I want to see. Presumably doctest.DocTestFinder needs a patch to call methoddescriptor's __get__ method. (BTW, classmethod, staticmethod and property are all special-cased by DocTestFinder.) -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. Zhuo On Feb 6, 5:23 pm, Roy Smith r...@panix.com wrote: In article ee2cfd35-3171-4ee7-ad3a-cf117e552...@r24g2000yqd.googlegroups.com, hzh...@gmail.com hzh...@gmail.com wrote: Hi, I am a fresh man with python. I know there is regular expressions in Python. What I need is that given a particular regular expression, output all the matches. For example, given ³[1|2|3]{2}² as the regular expression, the program should output all 9 matches, i.e., 11 12 13 21 22 23 31 32 33. Is there any well-written routine in Python or third-party program to do this? If there isn't, could somebody make some suggestions on how to write it myself? Thanks. Zhuo Please enumerate all the strings which match .*. Use additional sheets of paper if needed. -- http://mail.python.org/mailman/listinfo/python-list
sshd in python for windows 7
Hi, I wondered which modules would be best to perform following task: A user uses a standard ssh (e.g. putty or openssh) client and performs an ssh to a windows host The windows host would run a python script acting as ssh server. Instead of controlling a shell the user would directly have access to stdin/stdout/stderr of another python script. Another option would of course be to install a non python sshd for windows. The only ssh server for windows, that I know is however a little heavy as it is openssh under cygwin (and I only used it on XP hosts.) I'm still not sure, whether python as sshd is a good choice or whether any other sshd would be better. bye N -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make a SimpleXMLRPCServer abort at CTRL-C under windows
Hi Gabriel, Gabriel Genellina wrote: En Fri, 05 Feb 2010 20:03:51 -0300, News123 news...@free.fr escribió: I'm using an XMLRPC server under Windows. What I wonder is how I could create a server, that can be killed with CTRL-C The server aborts easily with CTRL-BREAK but not with CTRL-C (under Windows) If I press CTRL-C it will only abort when the next RPC call occurs. It seems it is blocking in the select() call in the handle_request() function. Python 2.6 and up behaves exactly as you want. On previous versions you may use this: class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): ... your methods ... if not hasattr(SimpleXMLRPCServer.SimpleXMLRPCServer, 'shutdown'): # pre 2.6 quit = False def serve_forever(self): while not self.quit: self.handle_request() def shutdown(self): self.quit = True def server_bind(self): self.socket.settimeout(1.0) SimpleXMLRPCServer.SimpleXMLRPCServer.server_bind(self) Overloading server_bind() with your version solved my problem. thanks again N -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. How do you expect to tell the ones that can be enumerated apart from those that can't be? Regular expressions are programs in a regex programming language. What you are asking for is the same as saying: Is there a program that can enumerate every possible set of data that is usable as valid input for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. (Note, however, it isn't necessary to solve the Halting Problem for *all* cases in order to have a useful Endless Loop Detector program.) Why do you think you need this? Seems to me you're starting on an extraordinarily difficult job. I hope the benefit is equally extraordinary. [Aside: Python regexes aren't Turing Complete. I'm not sure about Perl regexes. Either way, this might actually be less difficult than the Halting Problem, as in amazingly difficult rather than impossible.] -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: xmlrcp - how to marshall objects
Adam Tauno Williams wrote: On Fri, 2010-02-05 at 18:24 +0100, Jean-Michel Pichavant wrote: Jean-Michel Pichavant wrote: Deos anyone knows where to find an code sample describing how to implement the interface to marshall one object into XMLRPC compliant structures ? I googled without any success, and what google does not find does not exist. Let say I have this very simple class: class Point: def __init__(self, x, y): self.x = x self.y = y I've looked into xmlrpc code, I see 2 options: 1/ override the Marshaller class of client and server 2/ looks like the lib is supporting a WRAPPER list system, it uses to Marshall Datetime Binary object. Can it be possible to add its own class (could require to emplement the 'encode' method) I sense I will spend much more time than required unless someone is pointing me in the right direction. I realized I gave a poor example, actually the Point object is marshable (marshallable ? like to invent new words), xmlrpc will try to marshall using __dict__ if possible. import os class Point: def __init__(self, x, y): self.x = x self.y = y self.notMarshallable = os This example doesn't make any sense. Why would you set a variable equal to an important module in a class named Point? What is it you are actually trying to accomplish? If you are trying to create an object publishing environment then maybe something like - rpc = xmlrpclib.loads(payload, use_datetime=True) method = rpc[1].split('.') classname = method[0] methodname = method[1] parameters = rpc[0] classclass = eval(classname) handler = classclass() call = getattr(handler, method_name) result = apply(call, parameters) result = xmlrpclib.dumps(tuple([result]), methodresponse=True) Obviously add copious amounts of exception handling and a security model. I just took the first non marshallable object that came to my mind. So yes that makes no sense but it was an example. I'll try to sitck to what I'm really trying to do. I have 2 classes, defined on server side class Pool: def foo(): return 42 class Stream: def __init__(self, pool): @param pool: the pool the stream belongs so. self._pool = pool I won't need any more detail I think for my example. Now If I want to return a stream, sending it to the client, I can't because xmlrpclib won't be able to marshall _pool. What I need is the sever being able to marshall a Stream. I would like to overide the marshall method of that stream, so that instead of raising an error because self._pool is not marshallable, it sends an int instead identifying the pool on the server side. class Pool: instances = {} when marshalling a stream: id = some_unique_generated_int() Pool.instances[id] = self._pool self._pool = id # an int will be gracefully marshalled by the defaut marshaller # call here the default marshaller Then, when unmarshalling, the server can reassign the _pool reference using the id provided by the client. I hope I am being clear. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Doctests and decorated methods don't get along
On Sat, 06 Feb 2010 14:39:00 -0500, Terry Reedy wrote: On 2/6/2010 6:48 AM, Steven D'Aprano wrote: It seems that doctest doesn't discover or execute doctests in methods which have been decorated [by method descriptors]. [...] This looks like bug to me. Have I missed anything? I would call it a limitation as I do not see the doc as promising otherwise. I believe doctest predates the descripter protocol, at least in its current form, so it may not be completely descriptor-aware. You certainly could file a feature request for improved recognition and subsequent calling of __get__. An initial patch would improve chances of action. I have found an existing report for this issue: http://bugs.python.org/issue4037 The original poster's suggested fix was on the right track, but not complete. I've added a patch which works according to my tests. Since this report is currently unassigned, is there a protocol for raising its profile and having somebody check my patch for inclusion? Should I just send an email to python-dev? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
* Steven D'Aprano: On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. How do you expect to tell the ones that can be enumerated apart from those that can't be? Regular expressions are programs in a regex programming language. What you are asking for is the same as saying: Is there a program that can enumerate every possible set of data that is usable as valid input for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing match after match after match, on request. To use that /expression/, it seems that Theory is yet again up against Hard Reality. In such a contest where something doesn't quite /match/, is the Map, the Terrain, or perhaps the Interpretation of how the Map applies to Terrain, at fault? (Note, however, it isn't necessary to solve the Halting Problem for *all* cases in order to have a useful Endless Loop Detector program.) Why do you think you need this? Seems to me you're starting on an extraordinarily difficult job. I hope the benefit is equally extraordinary. Depending on the application there may be more efficient ways than applying a general purpose regexp matcher. Don't know about modern *nix but in the old days there were different greps for different purposes, egrep, fgrep, whatever. Aside: the only article by Niklaus Wirth that I can remember reading was about how to transform algorithms to more efficient ones by exploiting the invariants, and one of his examples was simple text searching, where you can advance the pattern a number of characters depending on the current non-matching character. [Aside: Python regexes aren't Turing Complete. I'm not sure about Perl regexes. Either way, this might actually be less difficult than the Halting Problem, as in amazingly difficult rather than impossible.] Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list
max / min / smallest float value on Python 2.5
Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party modules just for this purpose. e.g. For the smallest positive float I'm using, import platform if platform.architecture()[0].startswith('64'): TINY = 2.2250738585072014e-308 else: TINY = 1.1754943508222875e-38 where I've extracted the values for TINY from numpy in IDLE, float(numpy.finfo(numpy.float32).tiny) 1.1754943508222875e-38 float(numpy.finfo(numpy.float64).tiny) 2.2250738585072014e-308 I'm not 100% sure how reliable this will be across platforms. Any ideas about the cleanest, reliable way of uncovering this type of information? (I can always invoke numpy, or use Python 2.6, on my home machine and hardcode the retrieved values, but I need the code to run on 2.5 without 3rd part dependencies.) Cheers. Duncan -- http://mail.python.org/mailman/listinfo/python-list
Re: Your beloved python features
Bruno Desthuilliers wrote: apeach a écrit : I love intuitive type recognition. no need to 'DIM everything AS Integer' etc.! not to mention the ever hilarious (that is, when you don't have to maintain it) typical Java idiom: EveryThing theEveryThing = new EveryThing(); http://www.artima.com/weblogs/viewpost.jsp?thread=42242 regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS:http://holdenweb.eventbrite.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: xmlrpc slow in windows 7 if hostnames are used
News123 wrote: Hi JM, Jean-Michel Pichavant wrote: import socket # server server = SimpleXMLRPCServer((socket.gethostname(), 5000), logRequests=False, allow_none=True) # client xmlrpclib.ServerProxy(http://%s.yourdomain.com:%s; % (socket.gethostname(), 5000)) Well This was exactly my question. for virtual web servers I cannot just use the IP-address. some XMLRPC servers do need the histname within the HTTP-POST request. a valid IP address would make it if I just replaced the hostname with the IP addres, then certain servers would not be accessable. I had to use the IP-address for connecteing why not using the host names? , but to pass the hostname in the HTTP-POST request. I wondered how to convince puthon's SimpleXMLRPCServer (or any other standard python xmlrpc server), such, that I can obtain above mentioned goal. bye N I'm puzzled. Unless my english is failing me, everything would be solved using hostnames if I follow you. Why don't you do that ? I am no network/IP guru, but it sounds very weird to have requests rejected when using IP addresses. Are you sure your host names are resolved with the same IPM address you are using ? JM -- http://mail.python.org/mailman/listinfo/python-list
Re: max / min / smallest float value on Python 2.5
On Sun, Feb 7, 2010 at 6:22 AM, duncan smith buzz...@urubu.freeserve.co.ukwrote: Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party modules just for this purpose. e.g. For the smallest positive float I'm using, import platform if platform.architecture()[0].startswith('64'): TINY = 2.2250738585072014e-308 else: TINY = 1.1754943508222875e-38 The above code is executed on OSX (snow leopard - 64 bit) without any issue. Your implementation seems fine to me. where I've extracted the values for TINY from numpy in IDLE, float(numpy.finfo(numpy.float32).tiny) 1.1754943508222875e-38 float(numpy.finfo(numpy.float64).tiny) 2.2250738585072014e-308 I'm not 100% sure how reliable this will be across platforms. Any ideas about the cleanest, reliable way of uncovering this type of information? (I can always invoke numpy, or use Python 2.6, on my home machine and hardcode the retrieved values, but I need the code to run on 2.5 without 3rd part dependencies.) Cheers. Duncan -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: max / min / smallest float value on Python 2.5
On Sat, Feb 6, 2010 at 7:52 PM, duncan smith buzz...@urubu.freeserve.co.uk wrote: Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party modules just for this purpose. e.g. For the smallest positive float I'm using, import platform if platform.architecture()[0].startswith('64'): TINY = 2.2250738585072014e-308 else: TINY = 1.1754943508222875e-38 where I've extracted the values for TINY from numpy in IDLE, float(numpy.finfo(numpy.float32).tiny) 1.1754943508222875e-38 float(numpy.finfo(numpy.float64).tiny) 2.2250738585072014e-308 I'm not 100% sure how reliable this will be across platforms. Any ideas about the cleanest, reliable way of uncovering this type of information? (I can always invoke numpy, or use Python 2.6, on my home machine and hardcode the retrieved values, but I need the code to run on 2.5 without 3rd part dependencies.) Cheers. Duncan import platform platform.architecture() ('32bit', '') tiny = 2.22e-308 tiny 2.2201e-308 float32 vs. float64 has nothing to do with a 32-bit vs. a 64-bit platform. It's single precision floating-point (C float) vs. double-precision floating point (C double). It's used in numpy because numpy optimizes everything like crazy. Python always uses doubles. import numpy numpy.double type 'numpy.float64' -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Your beloved python features
Steve Holden st...@holdenweb.com writes: EveryThing theEveryThing = new EveryThing(); http://www.artima.com/weblogs/viewpost.jsp?thread=42242 Pretty cool! I see your blog post criticizing Java's lack of type inference, and then immediately adjacent to the post there's a banner ad for a book called Programming in Scala. I think I am getting a mixed message ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
On Sun, 07 Feb 2010 01:51:19 +0100, Alf P. Steinbach wrote: Regular expressions are programs in a regex programming language. What you are asking for is the same as saying: Is there a program that can enumerate every possible set of data that is usable as valid input for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing match after match after match, on request. I think you have completely misunderstood what I'm saying. I'm not saying that you can't *run* a regular expression against text and generate output. That truly would be a stupid thing to say, because I clearly can do this: import re mo = re.search(p.rr.t, ... Some text containing parrots as well as other things) mo.group() 'parrot' As you point out, it's not hard to embed a regex interpreter inside a text editor or other application, or to call an external library. What is difficult, and potentially impossible, is to take an arbitrary regular expression such as p.rr.t (the program in the regex language) and generate every possible data (parrot, pbrrat, ...) that would give a match when applied to that regular expression. Now, in this case, my example is very simple, and it would be easy to enumerate every possible data: there's only 65025 of them, limiting to the extended ASCII range excluding NUL (1-255). But for an arbitrary regex, it won't be that easy. Often it will be unbounded: the example of enumerating every string that matches .* has already been given. The second problem is, generating the data which gives the output you want is potentially very, very, difficult, potentially as difficult as finding collisions in cryptographic hash functions: Given the function hashlib.sha256, enumerate all the possible inputs that give the hexadecimal result 0a2591aaf3340ad92faecbc5908e74d04b51ee5d2deee78f089f1607570e2e91. This too is unbounded, but you'll have your work cut out just to find *one* match, let alone an infinite number of them. (In this specific example, your best bet is to try a crib: knowing what newsgroup this is, and knowing what I've written in the past, the message is predictable for being totally unexpected. And yes, that's a hint. A shiny penny for the first person to guess what it is.) I'm suggesting that, in general, there's no way to tell in advance which regexes will be easy and which will be hard, and even when they are easy, the enumeration will often be infinite. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Dreaming of new generation IDE
Arnaud Delobelle arno...@googlemail.com wrote in message news:m28wb6ypfs@googlemail.com... Gabriel Genellina gagsl-...@yahoo.com.ar writes: En Fri, 05 Feb 2010 19:22:39 -0300, bartc ba...@freeuk.com escribió: Steve Holden st...@holdenweb.com wrote in message news:mailman.1998.1265399766.28905.python-l...@python.org... Arnaud Delobelle wrote: Robert Kern robert.k...@gmail.com writes: I prefer Guido's formulation (which, naturally, I can't find a direct quote for right now): if you expect that a boolean argument is only going to take *literal* True or False, then it should be split into ^^^ two functions. So rather than three boolean arguments, would you have eight functions? If there's genuinely a need for that functionality, yes. So you want a function such as drawtext(s, bold=true, italic=false, underline=true) to be split into: drawtext(s) drawtextb(s) drawtexti(s) drawtextu(s) drawtextbi(s) drawtextbu(s) drawtextiu(s) drawtextbiu(s) Note the *literal* part. If you (the programmer) is likely to know the parameter value when writing the code, then the function is actually two separate functions. Thanks, I understand what Steve Holden meant now. I've just noticed that 'literal' part. But I think I still disagree. For a real-world example, it means instead of having a room with a light-switch in it, if I *know* I want the light on or off, I should have two rooms: one with the light permanently on, and one with it permanently off, and just walk into the right one. -- Bartc -- http://mail.python.org/mailman/listinfo/python-list
Re: Calendar GUI
Michael Torrie wrote: Gabriel wrote: On Fri, Feb 5, 2010 at 9:08 PM, William Gaggioli wgaggi...@gmail.com wrote: I'm working on setting up some software for a Peruvian non-profit to help them organize their incoming volunteers. One of the features I'd like to add is a calendar-like view of the different volunteers arrival dates and staying time, with potentially some other info through some double-click action. Rather than writing a calendar gui myself, is there some open-source calendar program you guys could recommend that I could plug into? It has to be run locally, as the internet isn't so reliable down here, but other than that something simple and clean is ideal. I wrote a gtk gui for google calendar. Maybe you can adapt it to your needs. http://code.google.com/p/googlecalendar-gtk/ Would this work without an internet connection? The original poster stated that internet isn't so reliable, hence the need for a local solution. How about zimbra ? http://www.zimbra.com/products/calendar-collaboration.html Ok, that's heavy stuff, but it's free, open source and widely used. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to print all expressions that match a regular expression
Alf P. Steinbach wrote: * Steven D'Aprano: On Sat, 06 Feb 2010 16:05:15 -0800, hzh...@gmail.com wrote: Thanks for your reply. So there isn't such a routine just because some of the regular expressions cannot be enumerated. However, some of them can be enumerated. I guess I have to write a function myself. How do you expect to tell the ones that can be enumerated apart from those that can't be? Regular expressions are programs in a regex programming language. What you are asking for is the same as saying: Is there a program that can enumerate every possible set of data that is usable as valid input for a given program? This, in turn, is equivalent to the Halting Problem -- if you can solve one, you can solve the other. You might like to google on the Halting Problem before you spend too much time on this. Hm, well, text editors /regularly/ do repeated regular expression searches, producing match after match after match, on request. [snip] I'm not sure you understood what the OP was requesting: a way of generating the strings which would match a given regex. -- http://mail.python.org/mailman/listinfo/python-list
Re: max / min / smallest float value on Python 2.5
duncan smith wrote: Hello, I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually). I don't want to add a dependence on 3rd party modules just for this purpose. e.g. For the smallest positive float I'm using, import platform if platform.architecture()[0].startswith('64'): TINY = 2.2250738585072014e-308 else: TINY = 1.1754943508222875e-38 where I've extracted the values for TINY from numpy in IDLE, float(numpy.finfo(numpy.float32).tiny) 1.1754943508222875e-38 float(numpy.finfo(numpy.float64).tiny) 2.2250738585072014e-308 You are confusing a 32 / 64bit build with 32 / 64bit floats. Python's float type is build upon C's double precision float type on both 32 and 64 bit builds. The simple precision 32bit float type isn't used. The DBL_MIN and DBL_MAX values are equal on all platforms that have full IEEE 754 float point support. The radix may be different, though. Christian -- http://mail.python.org/mailman/listinfo/python-list