python-graph-1.2.0 released
python-graph release 1.2.0 http://code.google.com/p/python-graph/ python-graph is a library for working with graphs in Python. This software provides a suitable data structure for representing graphs and a whole set of important algorithms. The code is appropriately documented and API reference is generated automatically by epydoc. Comments, bug reports or suggestions are welcome. Provided features and algorithms: * Support for directed, undirected, weighted and non-weighted graphs * Support for hypergraphs * Canonical operations * XML import and export * DOT-Language output (for usage with Graphviz) * Random graph generation * Accessibility (transitive closure) * Breadth-first search * Cut-vertex and cut-edge identification * Depth-first search * Identification of connected components * Minimum spanning tree (Prim's algorithm) * Mutual-accessibility (strongly connected components) * Shortest path (Dijkstra's algorithm) * Topological sorting signature.asc Description: This is a digitally signed message part -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python training in Cheminformatics
Python training in Cheminformatics Andrew Dalke is offering a course in Python programming for cheminformatics in Leipzig, Germany on 6-7 October and in the San Francisco Bay Area in early December. Early registration for the Leipzig course ends 12 September. For full details see http://dalkescientific.com/training/ or contact Andrew directly at [EMAIL PROTECTED] . The courses are designed for working computational chemists with some programming experience who want to be more effective at the software aspect of the field. The course is hands-on, with examples directly drawn from common needs in cheminformatics research. Some of the topics covered are: - an overview of the Python language - plotting with matplotlib - OpenEye's OEChem - parsing CSV, SMILES and SD files - substructure matching with SMARTS - generating and searching fingerprints - scripting PyMol - calling command-line programs like InChI - web scraping servers like PubChem - working with Excel Andrew Dalke [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
GPCE'08 Second Call for Participation -- NEWS --
* NEWS * * Early registration for OOPSLA and GPCE'08 has been * * extended until Septermber 15 * http://gpce08.gpce.org Seventh International Conference on Generative Programming and Component Engineering (GPCE'08) Nashville, Tennessee (co-located with OOPSLA 2008) *** CALL FOR PARTICIPATION *** GPCE 2008 will be co-located with OOPSLA, in Nashville, Tennessee. The GPCE technical program will take place on Oct. 19-20, before the OOPSLA technical program begins. Other GPCE events (workshops and tutorials) will run in parallel with OOPSLA events on Oct 21-23. GPCE'08 is sponsored by ACM SIGPLAN, in cooperation with ACM SIGSOFT. GPCE'08 proceedings published by ACM Press. For full conference program and the latest news, check the GPCE'08 web site (http://gpce08.gpce.org). REGISTRATION Registration for GPCE'08 is handled through the OOPSLA registration page (http://www.regmaster.com/conf/oopsla2008.html). Early registration deadline has been moved to Septermber 15. If registering for OOPSLA as well, the GPCE surcharge is just $200! If registering for GPCE alone, the charge is $375 for ACM members. *** TECHNICAL PROGRAM Sunday, October 19 8:50-9:00 Welcome 9:00-10:00 Keynote Session Chair: Julia Lawall * Emerging Challenges for Large Scale Systems Integration Dr. Andrew Fano (Accenture) 10:30-12:00 Technical papers 1 Session Chair: Julia Lawall * Code Generation to Support Static and Dynamic Composition of Software Product Lines Marko Rosenmueller, Norbert Siegmund, Sven Apel and Gunter Saake. * Efficient Compilation Techniques for Large Scale Feature Models Marcilio Mendonca, Andrzej Wasowski, Krzysztof Czarnecki and Don Cowan. * On the Modularity of Feature Interactions Chang Hwan Peter Kim, Christian Kaestner and Don Batory. 13:30-15:00 Technical papers 2 Session Chair: Jaakko Jarvi * Using Simple Mathematics as a Modeling Language Don Batory. * From Generic to Specific: Off-line Optimization for General Constraint Solver Ye Zhang, Torben Amtoft and Flemming Nielson. * Generating Incremental Implementations of Object-Set Queries Tom Rothamel and Yanhong A. Liu. 15:30-17:00 Technical papers 3 Session Chair: Aniruddha Gokhale * Integrating Semantics and Compilation Peter Gottschling and Andrew Lumsdaine. * Generating Customized Verifiers for Automatically Generated Code Ewen Denney and Bernd Fischer. * Property Models: From Incidental Algorithms to Reusable Components Jaakko Jarvi, Mat Marcus, Sean Parent, John Freeman and Jacob Smith. 17:00-17:30 PC chair's report Monday, October 20 9:00-10:00 Keynote Session Chair: William Cook * Fundamentalist Functional Programming Erik Meijer (Microsoft) 10:30-12:00 Technical papers 4 Session Chair: William Cook * Feature Featherweight Java: A Calculus for Feature-Oriented Programming and Stepwise Refinement Sven Apel, Christian Kastner and Christian Lengauer. * Lightweight Dependent Classes Tetsuo Kamina and Tetsuo Tamai. * Typing Communicating Component Assemblages Michael Lienhardt, Vivien Quema, Alan Schmitt and Jean-Bernard Stefani. 14:00-15:00 Technical papers 5 Session Chair: David Abrahams * Polymorphic Embedding of DSLs Christian Hofer, Klaus Ostermann, Tillmann Rendel and Adriaan Moors. * Pantaxou: a Domain-Specific Language for Developing Safe Coordination Services Julien Mercadal, Nicolas Palix, Charles Consel and Julia Lawall. 15:30-17:00 Technical papers 6 Session Chair: Mark Grechanik * Program Refactoring using Functional Aspects Sven Apel, Christian Kastner and Don Batory. * Rigorous and Practical Refactoring-Based Framework Upgrade Ilie Savga, Michael Rudolf, Sebastian Gotz and Uwe Assmann. * An abstraction for reusable MDD components Vinay Kulkarni and Sreedhar Reddy.-- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: dynamic allocation file buffer
Steven D'Aprano wrote: You've created a solution to a problem which (probably) only affects a very small number of people, at least judging by your use-cases. Who has a 4GB XML file Getting 4GB XML files from, say, logging processes or databases that can render their output as XML is not that uncommon. They're usually record-oriented, and are intended to be processed as streams. And given the right tools, doing that is no harder than doing the same to a 4GB text file. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing a session and reload() problem (with repro error)
En Wed, 10 Sep 2008 00:56:43 -0300, Rafe [EMAIL PROTECTED] escribió: On Sep 9, 11:03 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Mon, 08 Sep 2008 05:37:24 -0300,Rafe[EMAIL PROTECTED] escribió: ... This dependency between modules, applied to all modules in your project, defines a dependency graph. In some cases, one can define a partial ordering of its nodes, such that no module depends on any other module *after* it (it may depend only on modules *before* it). Look for topological sort. Doing that in the generic case is not easy. If you *know* your dependencies, reload the modules in the right order by hand. ... I was hoping there would be a way to just wipe out the module cache and let it get rebuilt by executing my code (since I'm not using reload as part of my program, but rather, to test it in an environment where I cannot restart the Python session). Ok, I think the following sequence *might* work: - replace the __import__ and reload builtins with a custom callable object. This way you can hook into any import attempt. The object should keep a list of already reloaded modules. When a module is imported: if it is already in the list, just delegate to the original __import__; if it is not in the list, locate the module in sys.modules and reload it. - iterate over sys.modules and reload the desired modules, as you did in your previous attempt. - restore the original __import__ function. This way, you effectively transform any import statement into a recursive reload (for the first time); subsequent imports of the same module behave as usual. This may work for you, or perhaps not, or it may screw all your running environment up, or even cause the next global thermonuclear war... (I hope not!) Note: some modules don't work well with reload(). A common case: global mutable values, like a list of objects which starts empty: my_list = [] To make it more reload friendly, use this: try: my_list except NameError: my_list = [] (this way the list will keep its previous values). The example below shows how to hook into the import mechanism - it just prints the module being imported. Implementing the functionality outlined above is left as an exercise to the reader :) py class ImportHook(object): ... _orig_import = None ... # ... def __call__(self, name, globals={}, locals={}, fromlist=[], level=-1): ... if fromlist: ... print - from %s import %s % (name, ','.join(fromlist)) ... else: ... print - import %s % name ... return self._orig_import(name, globals, locals, fromlist, level) ... # ... def hook(self): ... import __builtin__ ... self._orig_import = __builtin__.__import__ ... __builtin__.__import__ = self ... # ... def unhook(self): ... assert self._orig_import is not None, unhook called with no previous hook ... import __builtin__ ... __builtin__.__import__ = self._orig_import ... del self._orig_import ... # ... # support the with statement ... def __enter__(self): ... self.hook() ... return self ... # ... def __exit__(self, type, value, tb): ... self.unhook() ... py py ih = ImportHook() py ih.hook() py import htmllib - import htmllib - import sgmllib - import markupbase - import re - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import re - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - import sre_parse - from formatter import AS_IS - import sys - from htmlentitydefs import entitydefs py reload(htmllib) - import sgmllib - from formatter import AS_IS - from htmlentitydefs import entitydefs module 'htmllib' from 'C:\apps\Python25\lib\htmllib.pyc' py ih.unhook() - import __builtin__ py import htmllib py I have been keeping a diagram of my module inheritance to make sure it is as clean as possible, so I could just right a list of reloads as you suggest. However, one of the sub-packages is designed to allow users to add more modules. Because these get dynamically imported, a guess I could add an argument to the reload function to allow a user to give the 'add-on' module they are working on... so much work just to get a clean environment... Separate of my program, I was really hoping to write a generic reload tool for anyone developing in the same application as I am. I just don't see a way to trace import dependencies in systems which include dynamic imports. Any ideas? You may adapt the example above. Good luck! -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython ms-dos black window popping up in background
icarus top-posted: one more question... ...deserves a separate thread. how do I create a pythonw standalone executable that works on w32, linux, mac, etc..? Either it is Python, then it is portable but no executable, or it is an executable, then it is standalone but not portable. I'm afraid what you are asking for is not possible. Other than that, others told you how to easily get a standalone executable. Uli [ 35 lines of uselessly quoted content removed ] -- Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-RPC filter
On 9 Set, 17:55, Diez B. Roggisch [EMAIL PROTECTED] wrote: I would go for a slightly different approach: make your server have a dispatch-method that delegates the calls to the underlying actual implementation. But *before* that happens, extract the information as above, and either - prepend it to the argument list - stuff it into threadlocal variables, and only access these if needed in your implementation. Diez Are you suggesting me to overwrite the _dispatch(self, method, params) method of SimpleXMLRPCDispatcher? I thought to this possibility, but it only accepts method and params as arguments, so, as far as I know, I have no way to get the user and host address to append. Perhaps I've misunderstood your suggestion... in that case can you post a short example? Thank you very much! Luigi -- http://mail.python.org/mailman/listinfo/python-list
Re: Deflate with urllib2...
En Tue, 09 Sep 2008 16:38:54 -0300, Sam [EMAIL PROTECTED] escribió: I'm using urllib2 and accepting gzip and deflate. It turns out that almost every site returns either normal text or gzip. But I finally found one that returns deflate. Here's how I un-gzip: compressedstream = StringIO.StringIO(data) gzipper = gzip.GzipFile(fileobj=compressedstream) data = gzipper.read() Un-gzipping works great! Here's how I un-deflate (inflate??) data = zlib.decompress(data) Un-deflating doesn't work. I get zlib.error: Error -3 while decompressing data: incorrect header check I'm using python 2.5.2. Can someone tell me exactly how to handle deflated web pages? zlib.decompress should work - can you provide a site that uses deflate to test? -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
I want to use a C++ library from Python
Hello, I have a C++ library compiled as Windows DLL's. It consists of 32 .h and 1 .lib and 1 .dll files. I don't have the source code. How can I create a Python module from these files? // Anders -- English is not my first, or second, language so anything strange, or insulting, is due to the translation. Please correct me so I may improve my English! -- http://mail.python.org/mailman/listinfo/python-list
Re: I want to use a C++ library from Python
Anders Eriksson schrieb: Hello, I have a C++ library compiled as Windows DLL's. It consists of 32 .h and 1 .lib and 1 .dll files. I don't have the source code. How can I create a Python module from these files? Did you bother googling? http://www.google.de/search?q=python+c%2B%2Bie=utf-8oe=utf-8 Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: XML-RPC filter
On Sep 9, 8:53 am, Luigi [EMAIL PROTECTED] wrote: Dear all, I'm writing an XML-RPC server which should be able to modify the incoming request before dispatching it. In particular I wand to added two fixed parameters to the method called: one is the client host address, and the other is the user name provided as for Basic Authentication (http://[EMAIL PROTECTED]). To do this, at the present I've overwritten the do_POST method of SimpleXMLRPCRequestHandler, including at a certain point this code: data = ''.join(L) params, method = xmlrpclib.loads(data) user = unknown if self.headers.has_key('Authorization'): # handle Basic authentication (enctype, encstr) = self.headers.get('Authorization').split() user, password = base64.standard_b64decode(encstr).split(':') params = list(params) params.append(self.address_string()) params.append(user) params = tuple(params) data = xmlrpclib.dumps(params, methodname=method) (I slightly modified it to make it more readable at mail level) It works, but I don't really like it because it completely overwrites the do_POST method that in the future Python releases is going to change (I verified it). Do you know a better way to do this? Thanks in advance. Luigi I actually wrote a wsgi module for almost this -exact- use case (having to prepend a user/password to the method calls). The simple rpc server and dispatchers didn't give me enough control over the behavior, so I had to reimplement all the logic surround the loads/ dumps calls, and eventually that just turned into the bulk of the whole SimpleXMLRPCServer module. There's a lot of tight coupling in the _dispatch method, so you'll have to override, monkey patch, or reimplement it. -- http://mail.python.org/mailman/listinfo/python-list
Re: I want to use a C++ library from Python
On 10 sep, 10:00, Diez B. Roggisch [EMAIL PROTECTED] wrote: Anders Eriksson schrieb: Hello, I have a C++ library compiled as Windows DLL's. It consists of 32 .h and 1 .lib and 1 .dll files. I don't have the source code. How can I create a Python module from these files? Did you bother googling? http://www.google.de/search?q=python+c%2B%2Bie=utf-8oe=utf-8 Diez You may want google python dll as well. Good luck. -- http://mail.python.org/mailman/listinfo/python-list
which of these 2 quicksorts is faster?
qsort can handle bigger lists it seems, making less recursive calls before finishing(quicksort blows the stack when sorting range(100,-1000,-1). qsort does more work though right? is there a way to speed up that? is the built-in sort not defined recursively? def quicksort(lista): if len(lista) != 0: return quicksort([x for x in lista[1:] if x lista[0]]) + [lista[0]] + \ quicksort([x for x in lista[1:] if x = lista[0]]) else: return [] def qsort(lista): l = len(lista) if len(lista) != 0: return qsort([x for x in lista[:l/2]+lista[l/2+1:] if x lista[l/2]]) + \ [lista[l/2]] + \ qsort([x for x in lista[:l/2]+lista[l/2+1:] if x = lista[l/2]]) else: return [] -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamic allocation file buffer
On Wed, 10 Sep 2008 09:26:20 +0200, Fredrik Lundh wrote: Steven D'Aprano wrote: You've created a solution to a problem which (probably) only affects a very small number of people, at least judging by your use-cases. Who has a 4GB XML file Getting 4GB XML files from, say, logging processes or databases that can render their output as XML is not that uncommon. They're usually record-oriented, and are intended to be processed as streams. And given the right tools, doing that is no harder than doing the same to a 4GB text file. Fair enough, that's a good point. But would you expect random access to a 4GB XML file? If I've understood what Castironpi is trying for, his primary use case was for people wanting exactly that. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: which of these 2 quicksorts is faster?
process wrote: qsort can handle bigger lists it seems, making less recursive calls before finishing(quicksort blows the stack when sorting range(100,-1000,-1). qsort does more work though right? is there a way to speed up that? is the built-in sort not defined recursively? what makes you think you can write a better sort than the built-in algorithm by typing in some toy quick-sort implementations from a sorting for dummies article? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Curious: 2134 2004-10-06 08:55:20Z fredrik
On Fri, 5 Sep 2008 04:13:28 +0100 Akathorn Greyhat [EMAIL PROTECTED] wrote: I've already fix it, but I don't know what the hell does this line means: # $Id: __init__.py 2134 2004-10-06 08:55:20Z fredrik $ It seens curious, isn't it? http://ximbiot.com/cvs/wiki/CVS--Concurrent%20Versions%20System%20v1.12.12.1%3A%20Keyword%20substitution -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: max(), sum(), next()
Quoting Mensanator [EMAIL PROTECTED]: Actualy, I already get the behaviour I want. sum([1,None]) throws an exception. I don't see why sum([]) doesn't throw an exception also If you take a start value and add to it every element of a list, should the process fail if the list is empty? If you don't add anything to the start value, you should get back the start value. Python's sum is defined as sum(sequence, start=0). If sum were to throw an exception with sum([]), it should also throw it with sum([], start=0), wich makes no sense. -- Luis Zarrabeitia Facultad de Matemática y Computación, UH http://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list
Web shopping carts
Hey People, I am wondering if there are any OS shopping cart application written in python? Regards, Luke Hamilton Solutions Architect RPM Solutions Pty. Ltd. Mobile: 0430 223 558 [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Long lines [was Re: __builtins__ magic behavior]
En Sun, 07 Sep 2008 19:30:07 -0300, Steven D'Aprano [EMAIL PROTECTED] escribió: Gabriel, could I please ask you to configure your news-reader software or editor to limit the length of each line of your posts to 70 characters wide, as per the common standard for email and Usenet? Your lines are significantly longer than that, including one single line which is 325 characters wide. That forces a lot of backwards and forwards scrolling to read your posts. Fixed, thanks for pointing it out. Opera wraps long lines automatically so I didn't notice the problem myself. I can't remember when, or why, I altered the setting (if *I* altered it at all!) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: List of modules available for import inside Python?
A quick fix is to replace line 1854 in pydoc.py (ModuleScanner.run) with this one: for importer, modname, ispkg in pkgutil.walk_packages(onerror=lambda name:None): (the onerror argument makes it to ignore all errors) well not all, for example GLUT: Fatal Error in summon: could not open display: :0.0 So to refine the question: how can I list all modules that might be importable on my system, without actually importing them all ? (How about a pydoc2 that's well thought out, doesn't crash ... let me ask more knowledgable people, what's a good small help system as model ? ) cheers -- denis -- http://mail.python.org/mailman/listinfo/python-list
Re: which of these 2 quicksorts is faster?
On Sep 10, 12:29 pm, Fredrik Lundh [EMAIL PROTECTED] wrote: process wrote: qsort can handle bigger lists it seems, making less recursive calls before finishing(quicksort blows the stack when sorting range(100,-1000,-1). qsort does more work though right? is there a way to speed up that? is the built-in sort not defined recursively? what makes you think you can write a better sort than the built-in algorithm by typing in some toy quick-sort implementations from a sorting for dummies article? /F Where did I write that I was trying to do that? I am merely trying to learn. Get some social skills dude. -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching subprocess stdout stream
On Sep 8, 8:37 am, Thomas Jansson [EMAIL PROTECTED] wrote: Dear all I have tkinkter based frontend to a Fortran based program. I use subprocess to launch the fortran program as a child process and I wish to see the output of the fortran program as it is created in the console. The fortran program can take up to 20 minuttes to finish and at the moment the I will first see any output after the fortran program is done. How make my function write the output of the process as it comes? def runprogram(Icommand, Ijobfile, Ioutput): if os.name == posix: os.system(pythonpath+/bin/+Icommand+ +Ijobfile+ | tee +Ioutput) elif os.name == nt: import subprocess ofile = open(Ioutput, 'w') p = subprocess.Popen([os.path.join(pythonpath, bin, Icommand + '.exe')], stdin=open(Ijobfile, rb),bufsize=1024,shell=False, stdout=subprocess.PIPE) while p.poll() is None: #Check if child process has terminated. o = p.stdout.readline() ofile.writelines(o) print o, ofile.close Kind regards Thomas Jansson import threading, Queue, subprocess class iCommand(threading.Thread): def __init__ (self, iCommand, iJobFile, queue): threading.Thread.__init__(self) self.iCommand = iCommand self.queue = queue self.iJobFile = iJobFile def run(self): p = subprocess.Popen([os.path.join(C:/Python25, bin, self.iCommand + '.exe')], stdin=open(self.iJobFile, rb),bufsize=1024,shell=False, stdout=subprocess.PIPE) while p.poll() == None: q.put(p.stdout.readline()) command = FOO jobFile = =FAH aQueue = Queue.Queue() fo = open(C:/temp/foo.out, 'w') aThread = iCommand(command, jobFile, aQueue) aThread.start() while aThread.isAlive() or not aQueue.empty(): l = aQueue.get().rstrip() fo.write(l) print l fo.close() A bit of fun for a sleepless night... ~Sean -- http://mail.python.org/mailman/listinfo/python-list
Re: which of these 2 quicksorts is faster?
On Wed, 10 Sep 2008 03:17:30 -0700, process wrote: qsort can handle bigger lists it seems, making less recursive calls before finishing(quicksort blows the stack when sorting range(100,-1000,-1). It just seems so because that `range()` list is the worst case for `quicksort()` but not for `qsort()`. If you feed `qsort()` a list constructed to always leave one recursive call with the empty list, it will reach the recursion limit too. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: which of these 2 quicksorts is faster?
Fredrik Lundh wrote: what makes you think you can write a better sort than the built-in algorithm by typing in some toy quick-sort implementations from a sorting for dummies article? Anybody who can FULLY understand Tim's text at http://svn.python.org/projects/python/branches/release25-maint/Objects/listsort.txt can write a better sorting algorithm ... *scnr* :] Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching subprocess stdout stream
Sean DiZazzo wrote: while aThread.isAlive() or not aQueue.empty(): l = aQueue.get().rstrip() fo.write(l) print l fo.close() A bit of fun for a sleepless night... and unless you add a call to time.sleep somewhere in that loop, you'll keep your CPU up all night as well... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: which of these 2 quicksorts is faster?
Fredrik Lundh wrote: what makes you think you can write a better sort than the built-in algorithm by typing in some toy quick-sort implementations from a sorting for dummies article? Anybody who can FULLY understand Tim's text at http://svn.python.org/projects/python/branches/release25-maint/Objects/listsort.txt can write a better sorting algorithm ... *scnr* :] Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: List of modules available for import inside Python?
[EMAIL PROTECTED] wrote: how can I list all modules that might be importable on my system, without actually importing them all ? I'm pretty sure I mentioned a way to do that back when this thread was opened. let's see, yes, here it is: ... there's a helper script in the 2.5 source code kit that locates all existing standard modules: http://svn.python.org/projects/python/tags/r252/Doc/tools/listmodules.py to get all modules, remove the for-loop that follows after the comment get rid of site packages. also see: http://effbot.org/zone/listmodules-cgi.htm ... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython ms-dos black window popping up in background
On Tue, 9 Sep 2008 14:35:13 -0700 (PDT), icarus [EMAIL PROTECTED] wrote: Oh ok. Thanks. In windows xp I just renamed the file extension to .pyw That did it. one more question... how do I create a pythonw standalone executable that works on w32, linux, mac, etc..? I have noticed that when applications are written in Python with the GUI created by PyGTK, it seems that to install the application on each slightly different version of unix is a fairly major task - although the creators of PyGTK proudly say that the code will run anywhere, it definitely will not install anywhere - the code will only run on a slightly different system after a massive and major rewrite of the install for that target system. Horrible installs are a chronic problem GUI programs driven by interpreted languages Installing visual basic programs that worked on one Windows machine to work on a very slightly different windows machine was also a nightmare. I have not attempted to create installable wxPython windows, but generally, run anywhere will bite you. Still looking for a good solution to run anywhere. -- -- We have the right to defend ourselves and our property, because of the kind of animals that we are. True law derives from this right, not from the arbitrary power of the omnipotent state. http://www.jim.com/ James A. Donald -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
Luke Hamilton wrote: Hey People, I am wondering if there are any OS shopping cart application written in python? Yes there are. HTH Tino smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
ImportError: No module named zipextimporter on py2exe when { compressed: 0 }
Hi, I'm trying to compile using py2exe, and am getting the following: $ python_win Setup.py py2exe running py2exe creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build\bdist.win32 creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build\bdist.win32\winexe creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build\bdist.win32\winexe\collect-2.5 creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build\bdist.win32\winexe\bundle-2.5 creating c:\Documents and Settings\rbarak\rbarak_devel\dpm09\build\bdist.win32\winexe\temp *** searching for required modules *** Traceback (most recent call last): File Setup.py, line 96, in module windows = [test_wx] File C:\Python25\lib\distutils\core.py, line 151, in setup dist.run_commands() File C:\Python25\lib\distutils\dist.py, line 974, in run_commands self.run_command(cmd) File C:\Python25\lib\distutils\dist.py, line 994, in run_command cmd_obj.run() File c:\Python25\lib\site-packages\py2exe\build_exe.py, line 228, in run self._run() File c:\Python25\lib\site-packages\py2exe\build_exe.py, line 281, in _run self.find_needed_modules(mf, required_files, required_modules) File c:\Python25\lib\site-packages\py2exe\build_exe.py, line 1202, in find_needed_modules mf.import_hook(mod) File c:\Python25\lib\site-packages\py2exe\mf.py, line 716, in import_hook return Base.import_hook(self,name,caller,fromlist,level) File c:\Python25\lib\site-packages\py2exe\mf.py, line 136, in import_hook q, tail = self.find_head_package(parent, name) File c:\Python25\lib\site-packages\py2exe\mf.py, line 204, in find_head_package raise ImportError, No module named + qname ImportError: No module named zipextimporter My Setup.py (produced by GUI2Exe) is attached. Note that I set compressed to 0 in Setup.py (options = {py2exe: {compressed: 0), but it does not help. Any ideas ? Bye, Ron. Setup.py Description: Setup.py -- http://mail.python.org/mailman/listinfo/python-list
Re: I want to use a C++ library from Python
kaer wrote: On 10 sep, 10:00, Diez B. Roggisch [EMAIL PROTECTED] wrote: Anders Eriksson schrieb: Hello, I have a C++ library compiled as Windows DLL's. It consists of 32 .h and 1 .lib and 1 .dll files. I don't have the source code. How can I create a Python module from these files? Did you bother googling? http://www.google.de/search?q=python+c%2B%2Bie=utf-8oe=utf-8 Diez You may want google python dll as well. Good luck. Which actually isn't really helpful, as a DLL itself says nothing about what language was used to create it - and sending the OP to e.g. ctypes makes no sense at all in the face of C++. Whereas the first link for python c++ is Boost::Python, a C++-wrapper to make C++-code accessible from Python. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: List of modules available for import inside Python?
On Sep 10, 1:45 pm, Fredrik Lundh [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: how can I list all modules that might be importable on my system, without actually importing them all ? I'm pretty sure I mentioned a way to do that back when this thread was opened. let's see, yes, here it is: ... there's a helper script in the 2.5 source code kit that locates all existing standard modules: http://svn.python.org/projects/python/tags/r252/Doc/tools/listmodules.py to get all modules, remove the for-loop that follows after the comment get rid of site packages. I have just tried the following on my Ubuntu box with the system Python: ~$ python /usr/lib/python2.5/doc/tools/listmodules.py /usr/lib/python2.5/doc/tools/listmodules.py:99: DeprecationWarning: the rgbimg module is deprecated __import__(m) ** (process:24863): WARNING **: AT_SPI_REGISTRY was not started at session startup. ** (process:24863): WARNING **: Could not locate registry location: /usr/lib/xulrunner-1.9.0.1/libxpcom.so before 3 /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot register existing type `GtkSourceStyleScheme' __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: g_type_set_qdata: assertion `node != NULL' failed __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot register existing type `GtkSourceBuffer' __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: g_type_get_qdata: assertion `node != NULL' failed __import__(m) Segmentation fault Interesting, isn't it? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
Thanks... Do you happen to have anymore details? From: Tino Wildenhain [EMAIL PROTECTED] Date: Wed, 10 Sep 2008 06:52:40 -0500 To: Luke Hamilton [EMAIL PROTECTED] Cc: python-list@python.org python-list@python.org Subject: Re: Web shopping carts Luke Hamilton wrote: Hey People, I am wondering if there are any OS shopping cart application written in python? Yes there are. HTH Tino -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching subprocess stdout stream
On Sep 8, 5:37 pm, Thomas Jansson [EMAIL PROTECTED] wrote: Dear all I have tkinkter based frontend to a Fortran based program. I use subprocess to launch the fortran program as a child process and I wish to see the output of the fortran program as it is created in the console. The fortran program can take up to 20 minuttes to finish and at the moment the I will first see any output after the fortran program is done. How make my function write the output of the process as it comes? Sometimes very low technology solutions may be enough. For instance on Unix you could call os.system on something like that: xterm -e the-fortran-executable|less Make sure the Fortran executable output is unbuffered. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: List of modules available for import inside Python?
Michele Simionato wrote: I have just tried the following on my Ubuntu box with the system Python: ~$ python /usr/lib/python2.5/doc/tools/listmodules.py /usr/lib/python2.5/doc/tools/listmodules.py:99: DeprecationWarning: the rgbimg module is deprecated __import__(m) ** (process:24863): WARNING **: AT_SPI_REGISTRY was not started at session startup. ** (process:24863): WARNING **: Could not locate registry location: /usr/lib/xulrunner-1.9.0.1/libxpcom.so before 3 /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot register existing type `GtkSourceStyleScheme' __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: g_type_set_qdata: assertion `node != NULL' failed __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: cannot register existing type `GtkSourceBuffer' __import__(m) /usr/lib/python2.5/doc/tools/listmodules.py:99: Warning: g_type_get_qdata: assertion `node != NULL' failed __import__(m) Segmentation fault Interesting, isn't it? it does indeed import modules found in the path if they appear to be Python C extensions. why Ubuntu puts badly written C modules in their default Python path is more than I can tell... /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
Luke Hamilton wrote: Do you happen to have anymore details? Google says Results 1 - 10 of about 869,000 for python shopping cart. http://www.google.com/search?q=python+shopping+cart Checking the first few pages might give you something that fits your requirements (whatever they are). If you don't know what your requirements are, I suggest using something built on top of an established Python web framework, e.g. http://www.satchmoproject.com/ /F -- http://mail.python.org/mailman/listinfo/python-list
Re: I want to use a C++ library from Python
Diez B. Roggisch wrote: Which actually isn't really helpful, as a DLL itself says nothing about what language was used to create it - and sending the OP to e.g. ctypes makes no sense at all in the face of C++. The library - or more precisely the calling convention of the library - is related to the solution. On Windows a dll might be a container for a .NET assembly and C++ code can (theoretically) be compiled to .NET, too. Whereas the first link for python c++ is Boost::Python, a C++-wrapper to make C++-code accessible from Python. C++ bindings can be created with SIP, SWIG, Boost or hand written code. Multiple sites claim that SIP generates the fastest code. Christian -- http://mail.python.org/mailman/listinfo/python-list
Adding further report options to unittest.py
Hi all. I would like to change the way test reports are generated, in a Zope environment. I'm playing with TextTestReport, TextTestRunner. Since things are getting to complicated, I'm afraid I'm following a non-pythonic way. Specifically, I would like to have an output like: package.subpackage.test_module.TestCase 0.1 where 0.1 is the time spent into doing the test. In a previous attempt, I made the tests print the number of the test executed, so that I would have the following output: 1 package.subpackage.test_module.TestCase however, to do this, I had to put things in the following way: class PAFlowTestRunner(TextTestRunner): def _makeResult(self): return PAFlowTextResult(self.stream, self.descriptions, self.verbosity) class PAFlowTextResult(_TextTestResult): def startTest(self, test): self.stream.write(%s % self.testsRun) _TextTestResult.startTest(self, test) now, of course, this is ugly, because I'm using _TextTestResult, which I'm not supposed to know, and I'm changing behaviour by subclassing, which is not exactly what I would like to do. What is the pythonic way to accomplish this? Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Python extension, where am I going wrong
All, I am trying to create an extension module and keep getting an error, /usr/local/lib/python2.5/site-packages/mytest.so: undefined symbol: PyInitModule thanks in advance, *Here is my source code and setup.py information: */* mytest.c */ #include Python.h #include unistd.h #include stdlib.h #include sys/types.h static PyObject *ErrorObject; static char isEven__doc__[] = Method to determine if number is odd or even\n; static PyObject *isEven(PyObject *self, PyObject *args){ int inputValue; int returnValue; if (!PyArg_ParseTuple(args, i, inputValue)){ PyErr_SetString(PyExc_ValueError, Argument parsing Error); return NULL; } if ( 0 == inputValue%2 ){ returnValue = 1; } else { returnValue = 0; } return Py_BuildValue(i, returnValue); } static char getFactorial__doc__[] = This module takes a number as a parameter \ and returns the factorial of that number\n; static PyObject *getFactorial(PyObject *self, PyObject *args){ int inputValue; int resultValue; if (!PyArg_ParseTuple(args, i, inputValue)){ PyErr_SetString(PyExc_ValueError, Argument parsing error); return NULL; } resultValue = factorialHelper(inputValue); return PyInt_FromLong(resultValue); } int factorialHelper(int factor){ if (factor = 0){ return 0; } if (factor == 1){ return 1; } return factor*factorialHelper(factor-1); } static struct PyMethodDef mytest_methods[] = { {isEven, isEven, METH_VARARGS, Determine odd/even of a number}, {getFactorial, getFactorial, METH_VARARGS, Calc the factorial value of a number}, {NULL, NULL, 0, NULL} }; void initmytest(){ PyObject *m, *d; m = PyInitModule(mytest, mytest_methods); d = PyModule_GetDict(m); ErrorObject = PyBuildValue(s, mytest module error); PyDict_SetItemString(d, Error, ErrorObject); if (PyErr_Occurred()) Py_FatalError(Can't initialize module mytest!); } *My setup.py code:* #!/usr/bin/env python from distutils.core import setup, Extension setup(name=mytest, version=1.0, ext_modules=[Extension(mytest, [mytest.c])]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding further report options to unittest.py
Marco Bizzarri wrote: Hi all. I would like to change the way test reports are generated, in a Zope environment. I'm playing with TextTestReport, TextTestRunner. Since things are getting to complicated, I'm afraid I'm following a non-pythonic way. Specifically, I would like to have an output like: package.subpackage.test_module.TestCase 0.1 where 0.1 is the time spent into doing the test. In a previous attempt, I made the tests print the number of the test executed, so that I would have the following output: 1 package.subpackage.test_module.TestCase however, to do this, I had to put things in the following way: class PAFlowTestRunner(TextTestRunner): def _makeResult(self): return PAFlowTextResult(self.stream, self.descriptions, self.verbosity) class PAFlowTextResult(_TextTestResult): def startTest(self, test): self.stream.write(%s % self.testsRun) _TextTestResult.startTest(self, test) now, of course, this is ugly, because I'm using _TextTestResult, which I'm not supposed to know, and I'm changing behaviour by subclassing, which is not exactly what I would like to do. What is the pythonic way to accomplish this? Have you looked at nosetests? Nose is a test-discovery running-framework based upon unittest-module (but you can also only test simple functions, very handy) And it has a very powerful plugin-mechanism, that allows you to implement cleanly what you want. For each test, you get a start/end-method called in your plugin that you can use to gather the information you need, e.g. start/stop-times. For example, I've created an enhanced reporting plugin that lists all tests run (not only those failed or error'ed), and adding time-measuring per-test is on my list of todos. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: universal unicode font for reportlab
Ross Ridge wrote: Terry Reedy [EMAIL PROTECTED] wrote: Sorry, I posted the wrong name. Ariel Unicode MS is the one that seems pretty complete. ... From the MS, I would guess that is a Windows font too ;-). It's made by Microsoft, but it's not a standard Windows font. I think it comes with Microsoft Office. I need to use HTML anyway. I realized that universal unicode fonts are above 5MB in size. The report would be a 10KB PDF, but I need to embed the font before I can send it to anyone. Since some reports needs to be sent in emails, I need to use something else. I cannot be sending 10MB emails for one page reports. I ended up implementing the reports in HTML. I'm assuming that the user's browser is capable of displaying any characters needed. Now there is another problem: how to print an HTML without page header/footer information, from a browser? But that is another problem and probably has nothing to do with Python. Thanks for your help anyway. Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
Hi, Luke Hamilton wrote: Thanks... Do you happen to have anymore details? Yes well... you guess it was supposed to be a funny comment but would you happen to have anymore details on your requirements as well? Your simple question was just asking for making fun of it. (Other than that please see the answer given by Fredrik) Ah, btw, I'd check the the other posts of long term members if you see something in the appearance different to yours :-) (not related to your question itself) Cheers Tino ... Luke Hamilton wrote: Hey People, I am wondering if there are any OS shopping cart application written in python? Yes there are. HTH Tino smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: Python extension, where am I going wrong
John Vines (CISD/HPCD) wrote: I am trying to create an extension module and keep getting an error, /usr/local/lib/python2.5/site-packages/mytest.so: undefined symbol: PyInitModule it's spelled Py_InitModule, not PyInitModule. /F -- http://mail.python.org/mailman/listinfo/python-list
PHP's str_replace ?
In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
From: Tino Wildenhain [EMAIL PROTECTED] Date: Wed, 10 Sep 2008 08:40:42 -0500 To: Luke Hamilton [EMAIL PROTECTED] Cc: python-list@python.org python-list@python.org Subject: Re: Web shopping carts Hi, Luke Hamilton wrote: Thanks... Do you happen to have anymore details? Yes well... you guess it was supposed to be a funny comment but would you happen to have anymore details on your requirements as well? Your simple question was just asking for making fun of it. It was actually meant to be a pretty general question. I was really trying to get a feel for what was out there, so I can then to start to have a look at there capabilities. (Other than that please see the answer given by Fredrik) And unfortunately Google hasn't been much help... Ah, btw, I'd check the the other posts of long term members if you see something in the appearance different to yours :-) (not related to your question itself) Cheers Tino ... Luke Hamilton wrote: Hey People, I am wondering if there are any OS shopping cart application written in python? Yes there are. HTH Tino -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
On 10.09.2008, Anjanesh Lekshminarayanan [EMAIL PROTECTED] wroted: In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? The .translate() method of strings? import string mystr = This is just a test transtable = string.maketrans(aeiouy,--) mystr.translate(transtable) 'Th-s -s j-st - t-st' GS -- Grzegorz Staniak gstaniak _at_ wp [dot] pl Nocturnal Infiltration and Accurate Killing -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
Anjanesh Lekshminarayanan (10.09.2008 15:50): In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? What about something like this: import re new_str = re.sub('([aeiou])-', r'\1', str) Matthias -- http://mail.python.org/mailman/listinfo/python-list
[Fwd: Re: Python extension, where am I going wrong]
Yes spelling things correctly does help, got it thanks for the help. ---BeginMessage--- John Vines (CISD/HPCD) wrote: I am trying to create an extension module and keep getting an error, /usr/local/lib/python2.5/site-packages/mytest.so: undefined symbol: PyInitModule it's spelled Py_InitModule, not PyInitModule. /F -- http://mail.python.org/mailman/listinfo/python-list ---End Message--- begin:vcard fn:John Vines n:Vines;John org:Advanced Computing and Computational Sciences Division;Army Research Laboratory adr;dom:;;Building 394, Room 231;Aberdeen Proving Ground;MD;21005 email;internet:[EMAIL PROTECTED] title:Scientific Visualization Team Leader (A) tel;work:410-278-9150 / 410-278-1643 url:http://www.arl.hpc.mil/SciVis/ version:2.1 end:vcard -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
Matthias Huening (10.09.2008 16:07): Anjanesh Lekshminarayanan (10.09.2008 15:50): In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? What about something like this: import re new_str = re.sub('([aeiou])-', r'\1', str) Sorry - I misinterpreted your question. Try this instead: import re new_str = re.sub('[aeiou]', '-', str) matthias -- http://mail.python.org/mailman/listinfo/python-list
Alternatives to traditional RDBMS
Hi all, Are there any known alternatives to the traditional RDBMS (MySQL, PostgreSQL, SQLite, Oracle, etc0 / I know of 3 written in Python: * buzhug * kirbybase * PyDbLite buzhug - Although buzhug has a group membership size of ~60 or so it has not seen any activity in some time - and any activity that exists is slow and far and in-between. That said, buzhug is has a nice OO/Pythonic design and is quite nice to use. I have been working in improving it and have fixed issues I've come across in a branch of the original buzhug code that I now maintain. I fear the author of buzhug has lost interest and gone elsewhere to tinker with (better) other things ? kirbybase A nice small (also pure) python OO database. Developed quite some time ago, not actively worked on, but works really well.. PyDbLite -- Also developed quite some time ago, similar to both kirbybase and buzhug. Are there any others out there ? Is anyone working on something ? I would like to continue my work on buzhug... I have so: * Fixed several bugs * Implemented a WSGI middleware layer I'd like to refactor a lot of it's code and make better use of more recent features of python as buzhug was written quite some time ago. I think it's protocol could be vastly improved as well - as pickling things doesn't always work so well... In addition, I think buzhug could do with some caching features to speed database operations up (they're already pretty fast). cheers James -- -- -- Problems are solved by method -- http://mail.python.org/mailman/listinfo/python-list
Re: Web shopping carts
Luke Hamilton wrote: And unfortunately Google hasn't been much help... You've got to be very careful if you don't know where you're going, because you might not get there. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-URL! - weekly Python news and links (Sep 9)
Gabriel Genellina [EMAIL PROTECTED] writes: QOTW: So why am I supposed to care about SOAP again? Oh yes, the wizards I can use to generate 'web service end-points' from programming language code. My years in the SOAP trenches just makes me laugh myself half to death at that notion: I would probably have been twice as productive if every time I reached for a SOAP toolkit I instead just coded straight XML in HTTP. And this represents experience with Python, Java and C WS tools. - Uche Ogbuji It looks as if that Large Hadron Collider is having ill effects already. A week has been stretched into 6 years. ;-) http://lists.xml.org/archives/xml-dev/200302/msg00259.html -- Pete Forman-./\.- Disclaimer: This post is originated WesternGeco -./\.- by myself and does not represent [EMAIL PROTECTED]-./\.- the opinion of Schlumberger or http://petef.22web.net -./\.- WesternGeco. -- http://mail.python.org/mailman/listinfo/python-list
Re: universal unicode font for reportlab
Laszlo Nagy [EMAIL PROTECTED] wrote: I need to use HTML anyway. I realized that universal unicode fonts are above 5MB in size. The report would be a 10KB PDF, but I need to embed the font before I can send it to anyone. Since some reports needs to be sent in emails, I need to use something else. I cannot be sending 10MB emails for one page reports. I thought that usually when you embed a font in a PDF only the glyphs which are actually used in the document get embedded. Unfortunately a quick test with reportlab seems to show that it doesn't do that optimisation: it looks as though it just embeds the entire font. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Accessing __slots__ from C
Hi, I'd like to be able to access an attribute of a particular Python object as fast as possible from some C code. I wondered if using __slots__ to store the attribute would allow me to do this in a faster way. The reason I'd like to do this is because I need to access the attribute inside a loop within some C code, and I find that the attribute lookup using the 'PyObject_GetAttrString' call is far slower than any of the subsequent calculations I perform in C. Using the 'PyObject_GetAttrString' function to get the attribute, I find it is slightly faster when the attribute is a slot than when it isn't, but that the attribute lookup remains the performance-limiting factor. Additionally, if I instead build a list of the attributes first and pass that to the C code, using the 'PyList_GetItem' function to access each item, the performance improves significantly. I'd rather be able to access the information from C, instead of building the list externally. As far as I can tell, nothing is documented about accessing __slot__ members in a special way from C, but perhaps someone knows how to do it anyway? To be more specific, below is an example of what I'm talking about. I use SciPy's weave to inline C code, but I assume that doesn't make any difference to my problem. Thanks for any suggestions, Chris class MyObject(object): __slots__ = ['attr_one'] def __init__(self,attr_one=1.0): self.attr_one = attr_one import weave def test_loop(myobjects): rows,cols = len(myobjects),len(myobjects[0]) code = for (int r=0; rrows; ++r) { PyObject *myobjects_row = PyList_GetItem(myobjects,r); for (int l=0; lcols; ++l) { PyObject *myobject = PyList_GetItem(myobjects_row,l); // any faster way when attr_one is a slot? PyObject *attr_one_obj=PyObject_GetAttrString(myobject,attr_one); // more computations involving attr_one; just print for now... double attr_one = PyFloat_AsDouble(attr_one_obj); printf(%f\\n,attr_one); } } weave.inline(code,['myobjects','rows','cols'],local_dict=locals(),verbose=1) test_list = [[MyObject(0.0),MyObject(1.0)],[MyObject(2.0),MyObject(3.0)]] test_loop(test_list) -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternatives to traditional RDBMS
James Mills wrote: ... Are there any others out there ? Is anyone working on something ? I would like to continue my work on buzhug... I have so: * Fixed several bugs * Implemented a WSGI middleware layer I'd like to refactor a lot of it's code and make better use of more recent features of python as buzhug was written quite some time ago. I think it's protocol could be vastly improved as well - as pickling things doesn't always work so well... In addition, I think buzhug could do with some caching features to speed database operations up (they're already pretty fast). Looks as you didn't mention ZODB yet. As it is actively developed, it is maybe something you could consider. Regards Tino smime.p7s Description: S/MIME Cryptographic Signature -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
On 10.09.2008, Anjanesh Lekshminarayanan [EMAIL PROTECTED] wroted: In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? The .translate() method of strings? import string mystr = This is just a test transtable = string.maketrans(aeiouy,--) mystr.translate(transtable) 'Th-s -s j-st - t-st' GS -- Grzegorz Staniak gstaniak _at_ wp [dot] pl Nocturnal Infiltration and Accurate Killing -- http://mail.python.org/mailman/listinfo/python-list
Refcount problem in ceval.c
I have a problem with my debug Python 2.5.2 executable with Py_REF_DEBUG and Py_TRACE_REFS set. With one of my scripts I get: ... Fatal Python error: Python/ceval.c:947 object at 0x2aa3f4d840 has negative ref count -2604246222170760230 Program received signal SIGABRT, Aborted. [Switching to Thread 182905044128 (LWP 2595)] 0x002a95dde479 in raise () from /lib64/tls/libc.so.6 (gdb) p ((PyObject*)0x2aa3f4d840)-ob_type $1 = (struct _typeobject *) 0xdbdbdbdbdbdbdbdb (gdb) p ((PyObject*)0x2aa3f4d840)-ob_refcnt $2 = -2604246222170760230 (gdb) p ((PyObject*)0x2aa3f4d840)-_ob_next $3 = (struct _object *) 0xdbdbdbdbdbdbdbdb (gdb) p ((PyObject*)0x2aa3f4d840)-_ob_prev $4 = (struct _object *) 0xdbdbdbdbdbdbdbdb (gdb) Is there any common reason to for such a strange object on the command stack, or is it more likely that any of my extension modules is causing havoc? Kind regards Berthold -- __ Address: G / \ L Germanischer Lloyd phone: +49-40-36149-7374 -++- Vorsetzen 35 P.O.Box 111606 fax : +49-40-36149-7320 \__/ D-20459 HamburgD-20416 Hamburg -- http://mail.python.org/mailman/listinfo/python-list
dict slice in python (translating perl to python)
Hi, Let's take following perl code snippet: %myhash=( one = 1, two = 2, three = 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # -- line of interest print $v1\n$v2\n$v2\n; How do I translate the second line in a similiar compact way to python? Below is what I tried. I'm just interested in something more compact. mydict={ 'one' : 1, 'two' : 2, 'three' : 3 } # first idea, but still a little too much to type [v1,v2,v3] = [ mydict[k] for k in ['one','two','two']] # for long lists lazier typing,but more computational intensive # as split will probably be performed at runtime and not compilation time [v1,v2,v3] = [ mydict[k] for k in 'one two two'.split()] print %s\n%s\n%s %(v1,v2,v3) thanks for any ideas -- http://mail.python.org/mailman/listinfo/python-list
Re: Refcount problem in ceval.c
Berthold Höllmann wrote: Is there any common reason to for such a strange object on the command stack, or is it more likely that any of my extension modules is causing havoc? It's very likely that your extension has a reference counting bug. It looks like you are either missing a Py_INCREF or you have a Py_DECREF too much. Newly freed memory is filled with 0xDB (see Objects/obmalloc.c DEADBYTE). Wild guess: Are you using PyModule_AddObject with a PyTypeObject w/o Py_INCREF()ing the type object first? Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Accessing __slots__ from C
Chris wrote: Hi, I'd like to be able to access an attribute of a particular Python object as fast as possible from some C code. I wondered if using __slots__ to store the attribute would allow me to do this in a faster way. The reason I'd like to do this is because I need to access the attribute inside a loop within some C code, and I find that the attribute lookup using the 'PyObject_GetAttrString' call is far slower than any of the subsequent calculations I perform in C. That's correct. You can use slots to increase the performance but it doesn't work like you think. If you need it *really* fast than write a C Extension, store the data in a C struct and access the data via PyMemberDef. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternatives to traditional RDBMS
James Mills wrote: Hi all, Are there any known alternatives to the traditional RDBMS (MySQL, PostgreSQL, SQLite, Oracle, etc0 / I know of 3 written in Python: * buzhug * kirbybase * PyDbLite ZODB. Without any problems usable without ZOPE, clusterable, ACID-conform and so forth. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: dict slice in python (translating perl to python)
On Wed, 10 Sep 2008 08:28:43 -0700 (PDT), hofer wrote: Hi, Let's take following perl code snippet: %myhash=( one = 1, two = 2, three = 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # -- line of interest print $v1\n$v2\n$v2\n; What about: myhash={'one':1, 'two':2, 'three':3} map(myhash.get, ['one', 'two', 'two']) [1, 2, 2] or, to make it more similar to perl's qw() thing: map(myhash.get, 'one two two'.split()) [1, 2, 2] ...but I think that using explicit list is more pythonic. Isn't it? ;) -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list
Re: dict slice in python (translating perl to python)
On 10 Sep, 16:28, hofer [EMAIL PROTECTED] wrote: Hi, Let's take following perl code snippet: %myhash=( one = 1 , two = 2 , three = 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # -- line of interest print $v1\n$v2\n$v2\n; How do I translate the second line in a similiar compact way to python? Below is what I tried. I'm just interested in something more compact. mydict={ 'one' : 1 , 'two' : 2 , 'three' : 3 } # first idea, but still a little too much to type [v1,v2,v3] = [ mydict[k] for k in ['one','two','two']] # for long lists lazier typing,but more computational intensive # as split will probably be performed at runtime and not compilation time [v1,v2,v3] = [ mydict[k] for k in 'one two two'.split()] print %s\n%s\n%s %(v1,v2,v3) thanks for any ideas Another option [note I'm not stating it's preferred, but it would appear to be closer to some syntax that you'd prefer to use] from operator import itemgetter x = { 'one' : 1, 'two' : 2, 'three' : 3 } itemgetter('one', 'one', 'two')(x) (1, 1, 2) hth Jon. -- http://mail.python.org/mailman/listinfo/python-list
md5 differences
Hi there! I'm trying to match the results of an md5 checksum done in a tcsh shell. I keep getting different results and can't find anything on google... here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(hello).hexdigest() '5d41402abc4b2a76b9719d911017c592' How do I get the same results? thanks Arno -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
Matthias Huening wrote: Matthias Huening (10.09.2008 16:07): Anjanesh Lekshminarayanan (10.09.2008 15:50): In PHP, if I do str_replace(array('a', 'e', 'i', 'o', 'u'), '-', $str) it'll replace all vowels with a hyphen in string $str. Is there some equivalent in Python ? What about something like this: import re new_str = re.sub('([aeiou])-', r'\1', str) Sorry - I misinterpreted your question. Try this instead: import re new_str = re.sub('[aeiou]', '-', str) Wow - this is neat. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
Python wrote: I'm trying to match the results of an md5 checksum done in a tcsh shell. I keep getting different results and can't find anything on google... here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(hello).hexdigest() '5d41402abc4b2a76b9719d911017c592' import md5 md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' /F -- http://mail.python.org/mailman/listinfo/python-list
Re: universal unicode font for reportlab
Duncan Booth [EMAIL PROTECTED] wrote: I thought that usually when you embed a font in a PDF only the glyphs which are actually used in the document get embedded. Unfortunately a quick test with reportlab seems to show that it doesn't do that optimisation: it looks as though it just embeds the entire font. Yah, PDF files normally only contain an embedded subset of the fonts used. It might possible to use Ghostscript's ps2pdf command (which can take a PDF file as input) to strip out the unused glyphs from the embedded fonts. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] [EMAIL PROTECTED] -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
Python [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 How do I get the same results? Checksum the same string. md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' -- http://mail.python.org/mailman/listinfo/python-list
Re: dict slice in python (translating perl to python)
for a long list, you could try: result = [mydict[k] for k in mydict] or [mydict[k] for k in mydict.keys()] or [mydict[k] for k in mydict.iterkeys()] this won't give you the same order as your code though, if you want them sorted you can use the sorted function: [mydict[k] for k in sorted(x)] (or sorted(x.etc)) hofer wrote: Hi, Let's take following perl code snippet: %myhash=( one = 1, two = 2, three = 3 ); ($v1,$v2,$v3) = @myhash{qw(one two two)}; # -- line of interest print $v1\n$v2\n$v2\n; How do I translate the second line in a similiar compact way to python? Below is what I tried. I'm just interested in something more compact. mydict={ 'one' : 1, 'two' : 2, 'three' : 3 } # first idea, but still a little too much to type [v1,v2,v3] = [ mydict[k] for k in ['one','two','two']] # for long lists lazier typing,but more computational intensive # as split will probably be performed at runtime and not compilation time [v1,v2,v3] = [ mydict[k] for k in 'one two two'.split()] print %s\n%s\n%s %(v1,v2,v3) thanks for any ideas -- http://mail.python.org/mailman/listinfo/python-list
Generator functions and user interfaces
I'm trying to implement an interactive graph visualisation tool using matplotlib. I want to use a spring layout, where nodes repulse each other and edges act as springs to pull connected nodes together. Usually, this algorithm runs through a number of iterations of attraction/repulsion to allow the nodes to converge to suitable positions. However, rather than running all these iterations to lay out the graph and then rendering it, I want to animate the graph as it is springing into place, and then allow the user to drag nodes around and have the graph redraw on the fly. My idea for doing this was to use a generator function, where I yield the position of the nodes after each iteration and then call draw() on the position yielded. Does this seem like a sensible approach? The problem is that the node positions that are being operated on by the generator function may be altered by user input - dragging the nodes - and I'm not sure if this will break the way that the new positions are yielded. How do I use a generator function that might stop (when the nodes stop moving) but then need to restart again (once the user moves the nodes)? I'm quite an experienced Python programmer but I've never taken the trouble to get my head around generator functions, so any guidance welcome! Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On Wed, 10 Sep 2008 18:25:19 +0200 Python [EMAIL PROTECTED] wrote: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 [...] md5.new(hello).hexdigest() '5d41402abc4b2a76b9719d911017c592' How do I get the same results? Send the same thing. md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: crack registration codes for pogo games
your site won't come upDo you have the crack for operation mania on pogo.com?-- http://mail.python.org/mailman/listinfo/python-list
Re: dict slice in python (translating perl to python)
B wrote: for a long list, you could try: result = [mydict[k] for k in mydict] or [mydict[k] for k in mydict.keys()] or [mydict[k] for k in mydict.iterkeys()] and the point of doing that instead of calling mydict.values() is what? /F -- http://mail.python.org/mailman/listinfo/python-list
Presenting calculation results
Hello! I would like to present the results of the calculations on the web using Python and Apache. Currently I have java console applications that generate text files with results. Can somebody point me in the right direction from where to start? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: dict slice in python (translating perl to python)
Fredrik Lundh wrote: B wrote: for a long list, you could try: result = [mydict[k] for k in mydict] or [mydict[k] for k in mydict.keys()] or [mydict[k] for k in mydict.iterkeys()] and the point of doing that instead of calling mydict.values() is what? /F It's more fun? Or if you want to sort by keys. -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 10 sep 2008, at 18:34, Fredrik Lundh wrote: Python wrote: I'm trying to match the results of an md5 checksum done in a tcsh shell. I keep getting different results and can't find anything on google... here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(hello).hexdigest() '5d41402abc4b2a76b9719d911017c592' import md5 md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' /F oooh... thanks :) -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 10 sep 2008, at 18:30, Richard Brodie wrote: Python [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 How do I get the same results? Checksum the same string. md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' hmm and this then: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' even echo -n hello | md5 doesn't return the same number gr Arno -- http://mail.python.org/mailman/listinfo/python-list
Reading binary data
I've been trying to tackle this all morning, and so far I've been completely unsuccessful. I have a binary file that I have the structure to, and I'd like to read it into Python. It's not a particularly complicated file. For instance: signature char[3] GDE version uint32 2 attr_count uint32 { attr_id uint32 attr_val_lenuint32 attr_valchar[attr_val_len] } ... repeated attr_count times ... However, I can't find a way to bring it into Python. This is my code -- which I know is definitely wrong, but I had to start somewhere: import struct file = open(test.gde, rb) output = file.read(3) print output version = struct.unpack(I, file.read(4))[0] print version attr_count = struct.unpack(I, file.read(4))[0] while attr_count: print --- file.seek(4, 1) counter = int(struct.unpack(I, file.read(4))[0]) print file.read(counter) attr_count -= 1 file.close() Of course, this doesn't work at all. It produces: GDE 2 --- é --- ê Å I'm completely at a loss. If anyone could show me the correct way to do this (or at least point me in the right direction), I'd be extremely grateful. -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On Wed, 10 Sep 2008 19:12:28 +0200 Python [EMAIL PROTECTED] wrote: hmm and this then: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' You're going to smack yourself on the head over this one. :-) md5.new(open(/Volumes/data/Arno/test.txt).read()).hexdigest() -- D'Arcy J.M. Cain [EMAIL PROTECTED] | Democracy is three wolves http://www.druid.net/darcy/| and a sheep voting on +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Presenting calculation results
On Wed, Sep 10, 2008 at 6:46 PM, Vedran [EMAIL PROTECTED] wrote: Hello! I would like to present the results of the calculations on the web using Python and Apache. Currently I have java console applications that generate text files with results. Can somebody point me in the right direction from where to start? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list http://www.modpython.org/ Regards Marco -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: PHP's str_replace ?
Anjanesh Lekshminarayanan wrote: import re new_str = re.sub('[aeiou]', '-', str) Wow - this is neat. Thanks But probably slower and definitely harder to understand. For simple problems the str methods are usually faster than a regular expression. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: wxpython ms-dos black window popping up in background
On Sep 10, 6:48 am, James A. Donald [EMAIL PROTECTED] wrote: On Tue, 9 Sep 2008 14:35:13 -0700 (PDT), icarus [EMAIL PROTECTED] wrote: Oh ok. Thanks. In windows xp I just renamed the file extension to .pyw That did it. one more question... how do I create a pythonw standalone executable that works on w32, linux, mac, etc..? I have noticed that when applications are written in Python with the GUI created by PyGTK, it seems that to install the application on each slightly different version of unix is a fairly major task - although the creators of PyGTK proudly say that the code will run anywhere, it definitely will not install anywhere - the code will only run on a slightly different system after a massive and major rewrite of the install for that target system. Horrible installs are a chronic problem GUI programs driven by interpreted languages Installing visual basic programs that worked on one Windows machine to work on a very slightly different windows machine was also a nightmare. I have not attempted to create installable wxPython windows, but generally, run anywhere will bite you. Still looking for a good solution to run anywhere. -- -- We have the right to defend ourselves and our property, because of the kind of animals that we are. True law derives from this right, not from the arbitrary power of the omnipotent state. http://www.jim.com/ James A. Donald I haven't had much trouble getting wxPython applications to run in Windows XP and Ubuntu Hardy Heron. Of course, my GUIs aren't extremely complex, but I did make use of Hammond's PyWin32 package and had to wrap those in Platform aware conditional statements. Plus wx was pretty easy to install in Ubuntu, so that was cool. I can't really comment on other toolkits though. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading binary data
On 10 Sep, 18:14, Aaron Scott [EMAIL PROTECTED] wrote: I've been trying to tackle this all morning, and so far I've been completely unsuccessful. I have a binary file that I have the structure to, and I'd like to read it into Python. It's not a particularly complicated file. For instance: signature char[3] GDE version uint32 2 attr_count uint32 { attr_id uint32 attr_val_len uint32 attr_val char[attr_val_len] } ... repeated attr_count times ... However, I can't find a way to bring it into Python. This is my code -- which I know is definitely wrong, but I had to start somewhere: import struct file = open(test.gde, rb) output = file.read(3) print output version = struct.unpack(I, file.read(4))[0] print version attr_count = struct.unpack(I, file.read(4))[0] while attr_count: print --- file.seek(4, 1) counter = int(struct.unpack(I, file.read(4))[0]) print file.read(counter) attr_count -= 1 file.close() Of course, this doesn't work at all. It produces: GDE 2 --- é --- ê Å I'm completely at a loss. If anyone could show me the correct way to do this (or at least point me in the right direction), I'd be extremely grateful. What if we view the data as having an 11 byte header: signature, version, attr_count = struct.unpack('3cII', yourfile.read(11)) Then for the list of attr's: for idx in xrange(attr_count): attr_id, attr_val_len = struct.unpack('II', yourfile.read(8)) attr_val = yourfile.read(attr_val_len) hth, or gives you a pointer anyway Jon. -- http://mail.python.org/mailman/listinfo/python-list
Re: Generator functions and user interfaces
[EMAIL PROTECTED] a écrit : I'm trying to implement an interactive graph visualisation tool using matplotlib. I want to use a spring layout, where nodes repulse each other and edges act as springs to pull connected nodes together. Usually, this algorithm runs through a number of iterations of attraction/repulsion to allow the nodes to converge to suitable positions. However, rather than running all these iterations to lay out the graph and then rendering it, I want to animate the graph as it is springing into place, and then allow the user to drag nodes around and have the graph redraw on the fly. My idea for doing this was to use a generator function, where I yield the position of the nodes after each iteration and then call draw() on the position yielded. Does this seem like a sensible approach? I don't have much experience with this kind of algorithms, but AFAICT, it seems sensible to me, yes. But don't take me on words... The problem is that the node positions that are being operated on by the generator function may be altered by user input - dragging the nodes - and I'm not sure if this will break the way that the new positions are yielded. How do I use a generator function that might stop (when the nodes stop moving) but then need to restart again (once the user moves the nodes)? Starting with Python 2.5, there's a way to pass values back to generators: http://docs.python.org/whatsnew/pep-342.html Now, not having played much with these new features so far, I'm afraid I can't help more, nor even be strictly positive about this being what you need. Any generator guru around ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding further report options to unittest.py
On Wed, Sep 10, 2008 at 3:25 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote: Marco Bizzarri wrote: Hi all. I would like to change the way test reports are generated, in a Zope environment. Have you looked at nosetests? Nose is a test-discovery running-framework based upon unittest-module (but you can also only test simple functions, very handy) Nope; next time I will make a google search before posting ;) And it has a very powerful plugin-mechanism, that allows you to implement cleanly what you want. For each test, you get a start/end-method called in your plugin that you can use to gather the information you need, e.g. start/stop-times. I gave it a look; it is nice and it seems powerful; I just wonder if I need to put my hands on all my tests to do what I want to do... but I'm sure this can be sorted in the documentation. For example, I've created an enhanced reporting plugin that lists all tests run (not only those failed or error'ed), and adding time-measuring per-test is on my list of todos. Looks like there is a new tool I need to learn... ah, nice times when all you needed was an hammer and a screwdriver... ;) Thanks for the suggestion, Diez, I'll read it. Diez -- Marco Bizzarri http://notenotturne.blogspot.com/ http://iliveinpisa.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
File operations
Hello folks, I am using Python-2.5.2 on fedora 9 sulphur -2.6.25-14.fc9.i686.I am creating a temporary file , in which data is written by another program and then i am using that temporary file to do my computations.I am new to linux and i am facing two issues homedir = os.path.expanduser('~') temp = tempfile.NamedTemporaryFile( suffix='_suffix',prefix='prefix_',dir= homedir) temp.close() tn = temp.name print tn Issue1 - when i am logged in as root then everything works fine except that the file is created in the current working directory (/usr/Python-2.5.2) and not in the directory supplied as the dir='directory' parameter.i have tried dir='/tmp' as well.i don't know how to fix this issue and why the file is not getting created in the specified directory. Issue2 - when i am logged in as user ie any other user than root then i get this error sh: prefix_u92XQJ_suffix: Permission denied also , i cannot find the find in either the current working directory nor in the dir='directory'.so i cant check the permission by using ls -l prefix_u92XQJ_suffix Please help me understand this issue and eventually fix it. Thanks Aditya -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' Works for me: import md5 f = open('test.txt').read() md5.new(f).hexdigest() 'd8e8fca2dc0f896fd7cb4cb0031ba249' IOW, don't pass the path to the file to md5.new, but the contents of this file. The strange thing is that md5.new(/Volumes/data/Arno/test.txt).hexdigest() returns '8dd66a1592e2a8c3ab160822fb237f4d' on my machine. -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 2008-09-10, Python [EMAIL PROTECTED] wrote: On 10 sep 2008, at 18:30, Richard Brodie wrote: Python [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] here's an example: [EMAIL PROTECTED]:~% echo hello | md5 b1946ac92492d2347c6235b4d2611184 How do I get the same results? Checksum the same string. md5.new(hello\n).hexdigest() 'b1946ac92492d2347c6235b4d2611184' hmm and this then: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 [EMAIL PROTECTED]:~% python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type help, copyright, credits or license for more information. import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' That's the digest of the string /Volumes/data/Arno/test.txt. It's not supposed to match the digest of the string test\n. md5.new(open(test.txt).read()).hexdigest() 'd8e8fca2dc0f896fd7cb4cb0031ba249' $ md5sum test.txt d8e8fca2dc0f896fd7cb4cb0031ba249 test.txt $ echo test | md5sum d8e8fca2dc0f896fd7cb4cb0031ba249 - md5.new(test\n).hexdigest() 'd8e8fca2dc0f896fd7cb4cb0031ba249' even echo -n hello | md5 doesn't return the same number Not the same as _what_? md5.new(test).hexdigest() '098f6bcd4621d373cade4e832627b4f6' $ echo -n test | md5sum 098f6bcd4621d373cade4e832627b4f6 - -- Grant Edwards grante Yow! One FISHWICH coming at up!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 2008-09-10, Wojtek Walczak [EMAIL PROTECTED] wrote: On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' Works for me: import md5 f = open('test.txt').read() md5.new(f).hexdigest() 'd8e8fca2dc0f896fd7cb4cb0031ba249' IOW, don't pass the path to the file to md5.new, but the contents of this file. The strange thing is that md5.new(/Volumes/data/Arno/test.txt).hexdigest() returns '8dd66a1592e2a8c3ab160822fb237f4d' on my machine. Same here. -- Grant Edwards grante Yow! What PROGRAM are they at watching? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Alternatives to traditional RDBMS
Are there any known alternatives to the traditional RDBMS (MySQL, PostgreSQL, SQLite, Oracle, etc0 / I know of 3 written in Python: * buzhug * kirbybase * PyDbLite ZODB. Without any problems usable without ZOPE, clusterable, ACID-conform and so forth. There is also dejavu: http://www.aminus.net/dejavu -- Psss, psss, put it down! - http://www.cafepress.com/putitdown -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading binary data
On 10 Sep, 18:33, Jon Clements [EMAIL PROTECTED] wrote: On 10 Sep, 18:14, Aaron Scott [EMAIL PROTECTED] wrote: I've been trying to tackle this all morning, and so far I've been completely unsuccessful. I have a binary file that I have the structure to, and I'd like to read it into Python. It's not a particularly complicated file. For instance: signature char[3] GDE version uint32 2 attr_count uint32 { attr_id uint32 attr_val_len uint32 attr_val char[attr_val_len] } ... repeated attr_count times ... However, I can't find a way to bring it into Python. This is my code -- which I know is definitely wrong, but I had to start somewhere: import struct file = open(test.gde, rb) output = file.read(3) print output version = struct.unpack(I, file.read(4))[0] print version attr_count = struct.unpack(I, file.read(4))[0] while attr_count: print --- file.seek(4, 1) counter = int(struct.unpack(I, file.read(4))[0]) print file.read(counter) attr_count -= 1 file.close() Of course, this doesn't work at all. It produces: GDE 2 --- é --- ê Å I'm completely at a loss. If anyone could show me the correct way to do this (or at least point me in the right direction), I'd be extremely grateful. What if we view the data as having an 11 byte header: signature, version, attr_count = struct.unpack('3cII', yourfile.read(11)) Then for the list of attr's: for idx in xrange(attr_count): attr_id, attr_val_len = struct.unpack('II', yourfile.read(8)) attr_val = yourfile.read(attr_val_len) hth, or gives you a pointer anyway Jon. CORRECTION: '3cII' should be '3sII'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading binary data
signature, version, attr_count = struct.unpack('3cII', yourfile.read(11)) This line is giving me an error: Traceback (most recent call last): File test.py, line 19, in module signature, version, attr_count = struct.unpack('3cII', file.read(12)) ValueError: too many values to unpack -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On Wed, 10 Sep 2008 12:39:24 -0500, Grant Edwards wrote: The strange thing is that md5.new(/Volumes/data/Arno/test.txt).hexdigest() returns '8dd66a1592e2a8c3ab160822fb237f4d' on my machine. Same here. I guess it will be the same for vast majority of us ;-) The question is why is it '90364ed45b452d43378629c20543a81d' for the OP? :-) -- Regards, Wojtek Walczak, http://tosh.pl/gminick/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading binary data
CORRECTION: '3cII' should be '3sII'. Even with the correction, I'm still getting the error. -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 2008-09-10, Wojtek Walczak [EMAIL PROTECTED] wrote: On Wed, 10 Sep 2008 12:39:24 -0500, Grant Edwards wrote: The strange thing is that md5.new(/Volumes/data/Arno/test.txt).hexdigest() returns '8dd66a1592e2a8c3ab160822fb237f4d' on my machine. Same here. I guess it will be the same for vast majority of us ;-) The question is why is it '90364ed45b452d43378629c20543a81d' for the OP? :-) The smart money is betting on because the OP goofed when he was cutting/pasting stuff from his terminal window into his posting. -- Grant Edwards grante Yow! Were these parsnips at CORRECTLY MARINATED in visi.comTACO SAUCE? -- http://mail.python.org/mailman/listinfo/python-list
Re: max(), sum(), next()
On Sep 7, 3:38 pm, Luis Zarrabeitia [EMAIL PROTECTED] wrote: Quoting Mensanator [EMAIL PROTECTED]: Actualy, I already get the behaviour I want. sum([1,None]) throws an exception. I don't see why sum([]) doesn't throw an exception also If you take a start value and add to it every element of a list, should the process fail if the list is empty? No. If you don't add anything to the start value, you should get back the start value. Agree. Python's sum is defined as sum(sequence, start=0). That's the issue. If sum were to throw an exception with sum([]), it should also throw it with sum([], start=0), wich makes no sense. Given that definition, yes. But is the definition correct in ALL cases? Are there situations where the sum of an empty list should NOT be 0? Of course there are. Can sum() handle those cases? No, it can't, I have to write my own definition if I want that behaviour. There's no reason why sum([]) and sum([],0) have to mean the same thing at the exclusion of a perfectly valid alternative definition. But that's the way it is, so I have to live with it. But that's not conceeding that I'm wrong. -- Luis Zarrabeitia Facultad de Matemática y Computación, UHhttp://profesores.matcom.uh.cu/~kyrie -- http://mail.python.org/mailman/listinfo/python-list
removing text string
I need to remove text string from the list of the numbers mentioned below: 080829-7_A 070529-5_c 080824-7_O 070405_6_p The output will be : 080829-7 070529-5 080824-7 070405-6 Any idea is highly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
subprocess.Popen hangs at times?
When making calls of the form Popen(cmd, shell=True, stdout=subprocess.PIPE), we've been getting occasional, predictable hangs. Will Popen accumulate a certain amount of stdout and then block until its read? We don't want to use threads, so just want to read the entire stdout after the subprocess has finished. Thanks, Ken -- http://mail.python.org/mailman/listinfo/python-list
Re: md5 differences
On 10 sep 2008, at 19:39, Grant Edwards wrote: On 2008-09-10, Wojtek Walczak [EMAIL PROTECTED] wrote: On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote: [EMAIL PROTECTED]:~% echo test test.txt [EMAIL PROTECTED]:~% md5 test.txt MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb0031ba249 import md5 md5.new(/Volumes/data/Arno/test.txt).hexdigest() '90364ed45b452d43378629c20543a81d' Works for me: import md5 f = open('test.txt').read() md5.new(f).hexdigest() 'd8e8fca2dc0f896fd7cb4cb0031ba249' IOW, don't pass the path to the file to md5.new, but the contents of this file. The strange thing is that md5.new(/Volumes/data/Arno/test.txt).hexdigest() returns '8dd66a1592e2a8c3ab160822fb237f4d' on my machine. Same here. -- Grant Edwards grante Yow! What PROGRAM are they thanks everyone for helping me out! cheers Arno -- http://mail.python.org/mailman/listinfo/python-list
Gateway to python-list is generating bounce messages.
Could whoever is responsible for the gateway that is grabbing my postings off of Usenet and e-mailing them out please fix the headers in the mail messages so that I don't get the bounce messages? While you're at it, might as well fix it for everybody else too. ;) Its a bit rude to send out mass e-mail messages with headers faked up so that the bounce messages go to somebody else. -- Grant Edwards grante Yow! As President I have at to go vacuum my coin visi.comcollection! -- http://mail.python.org/mailman/listinfo/python-list