ANN: SfePy 2009.3 released
I am pleased to announce release 2009.3 of SfePy. Description --- SfePy (simple finite elements in Python) is a software, distributed under the BSD license, for solving systems of coupled partial differential equations by the finite element method. The code is based on NumPy and SciPy packages. Mailing lists, issue tracking, git repository: http://sfepy.org Home page: http://sfepy.kme.zcu.cz Highlights of this release -- Finally, SfePy has a basic support for Windows installation via numpy distutils: - still very experimental! - the tests will not finish if umfpack is not installed, as the default direct solver in scipy cannot handle some problems (see recent sfepy-devel mailing list discussions). Major improvements -- - new scripts: - cylindergen.py: cylindrical mesh generator - updated scripts: - postproc.py: - quite usable now for fast first glance at the results - plots point, cell data of all kinds (scalar, vector, tensor) - Viewer is much more configurable - probe.py: - can probe selected quantities only - isfepy: - Viewer is much more configurable - new tests and terms Applications - phononic materials: - plotting improved - caching of eigen-problem solution and Christoffel acoustic tensor - schroedinger.py: - choose and call DFT solver via solver interface People who contributed to this release: Vladimir Lukes. For more information on this release, see http://sfepy.googlecode.com/svn/web/releases/2009.3_RELEASE_NOTES.txt Best regards, Robert Cimrman -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: ignore special characters in python regex
On Jul 21, 3:02 pm, Astan Chee astan.c...@al.com.au wrote: Hi, I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? It would help if you were to say (1) what ignore ... characters means -- pretend they don't exist? (2) what are special chararacters -- non-alphanumeric? (3) what treat them like normal strings means (4) how you expect these special characters to be (a) ignored and (b) treated like normal strings /at the same time/. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: any suggestions to synchronize typed text and speech ?
On Jul 19, 4:15 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I'm using Scintilla as a wxPython widget with great pleasure. I now have an application where I want to make notes during a conversation, but also want to record the speech during that conversation. I'm using Scintilla as a wxPython widget for editing and PyAudio for the speech recording, until so far everything works fine. Here the problem part: I need to synchronize the typed text with the sound during playback. So if I click somewhere in the sound recording, the line of text, typed that moment should be highlighted. And vise versa, if the cursor in the text is moved and some special key is pressed, the sound starting 10 or 20seconds earlier should be playbacked. I though of adding bookmarks (because these are fixed in the text), and keep a list of bookmarks and sound pointers. This idea should work, but there are only 31 bookmarks. Any other suggestions ? thanks, Stef Mientki Stef, it occurs to me now that you might be useful to look at Transana: http://www.transana.org/ From their site: Transana is software for professional researchers who want to analyze digital video or audio data. Transana lets you analyze and manage your data in very sophisticated ways. Transcribe it, identify analytically interesting clips, assign keywords to clips, arrange and rearrange clips, create complex collections of interrelated clips, explore relationships between applied keywords, and share your analysis with colleagues. It is written in Python, uses Scintilla, and is open source (GPL): http://www.transana.org/developers/index.htm Che -- http://mail.python.org/mailman/listinfo/python-list
Re: comments? storing a function in an object
On Mon, 20 Jul 2009 21:53:59 -0400, Esmail wrote: In general I would agree with you, but in my specific case I want so store some additional meta-data with each function, such as the valid range for input values, where the max or minimum are located, the name/source for the function etc. I am creating list of functions for use in testing optimization code, so it seems best to store this data along with the function I am going to optimize in order to verify the results for a given range (for instance). You can set attributes on functions, so if your class is just storing this data, rather than altering the behavior of the function, you may be able to just use a function: def f(x, y): x * y return x * y f.arguments_max = [1000, 255] A function also already knows how many arguments it takes, which you can access as f.func_code.co_argcount -- http://mail.python.org/mailman/listinfo/python-list
python function for retrieving key and encryption
M2Crypto package not showing the 'recipient_public_key.pem' file at linux terminal .how do i get/connect with recipient public key. exactly i need to check how can i open this file through linux commands. import M2Crypto def encrypt(): recip = M2Crypto.RSA.load_pub_key(open ('recipient_public_key.pem','rb').read()) print recip; plaintext = whatever i need to encrypt msg = recip.public_encrypt (plaintext,RSA.pkcs1_padding) print msg; after calling the function its not giving any output and even any error i also tried as 'Will' said pk = open('public_key.pem','rb').read() print pk; rsa = M2Crypto.RSA.load_pub_key(pk) whats the mistake i am not getting .will somebody help me out. is something wrong in opening 'recipient_public_key.pem'. is M2Crypto contain this file inbuilt .from where this file taking public key of the recipient i'. what this file contain and how it will work .should i need to create such a file for my purpose.if it is then how can i create this and how it will retrieve the key,where i recognize my recipient to get his public key .is something like database at server. please give me a quick response.. looking for your answer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why aren't OrderedDicts comparable with etc?
On Mon, Jul 20, 2009 at 10:00 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Mon, 20 Jul 2009 09:34:24 +, Sion Arrowsmith wrote: Terry Reedy tjre...@udel.edu wrote: Sion Arrowsmith wrote: Jack Diederich jackd...@gmail.com wrote: It isn't an OrderedDict thing, it is a comparison thing. Two regular dicts also raise an error if you try to LT them. Python 2.5.2 d1 = dict((str(i), i) for i in range (10)) d2 = dict((str(i), i) for i in range (20)) d1 d2 True Try reversing the definitions of d1 and d2. The dicts are probably being compared by id (address), which is the 2.x CPython default. Like this? d1 = dict((str(i), i) for i in range (20)) d2 = dict((str(i), i) for i in range (10)) d1 d2 False id(d1) id(d2) True I didn't know that comparison for anything other than equality defaulted to using id. That really is rather broken, and I'm glad 3.0 fixed it. I don't think comparisons other than equality use id. That would be rather insane. If anyone can demonstrate such comparisons in a built-in or standard library class, I'd like to see it. For the record, dicts have been comparable with and since at least Python 1.5: $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam {1: 'a', 2: 'b'} {2: 'b', 3: 'a'} 1 Reading the docs: http://docs.python.org/library/stdtypes.html#comparisons http://docs.python.org/library/stdtypes.html#mapping-types-dict I can only suggest that dicts compare in an arbitrary but consistent fashion. I should have specified 3.x but since we were talking about OrderedDicts (only in 3.1) I didn't say it explicitly. Earlier versions of python were very permissive with comparisons -- it was rare that any cmp() raised an error and the ultimate fallback was on the object's id. This is one of the non-backwards compatible changes in 3k. Now comparing two of the same thing that don't have an obvious ordering is an error. Is a dict greater than if it has a larger size? if its max key is larger? what does max key mean when the keys aren't even comparable?. Comparing things that aren't extremely similar is an error now also. -Jack -- http://mail.python.org/mailman/listinfo/python-list
Re: comments? storing a function in an object
En Mon, 20 Jul 2009 22:53:59 -0300, Esmail ebo...@hotmail.com escribió: Gabriel Genellina wrote: If you follow the above suggestions, you'll see that your Function class becomes almost useless: a normal function already IS an object, so you don't have to wrap it inside ANOTHER object unless you need very special features. Hello Gabriel, In general I would agree with you, but in my specific case I want so store some additional meta-data with each function, such as the valid range for input values, where the max or minimum are located, the name/source for the function etc. I am creating list of functions for use in testing optimization code, so it seems best to store this data along with the function I am going to optimize in order to verify the results for a given range (for instance). You can store all meta-data in the function itself: py def triangle(b, h): ... area of triangle: b*h/2 ... return b*h/2 ... py triangle.foo = some value py triangle.foo 'some value' Python already knows some properties: py triangle.func_code.co_argcount 2 py triangle.func_doc 'area of triangle: b*h/2' py triangle.__doc__ 'area of triangle: b*h/2' You may use this variant of Carl Banks proposal - this is a factory function that returns new function objects: def inline_function_factory(name, args, expr): ns = {} exec '''def %s(%s): %r return %s''' % ( name, args, expr, expr) in ns function = ns[name] return function py sqr = inline_function_factory(square, x, x*x) py sqr(3) 9 py sqr.__doc__ 'x*x' py sqr function square at 0x00B46770 Wrapping a function object isn't necesarily bad, but perhaps you're doing things more complicated than should be. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: ignore special characters in python regex
I think the re.escape did the trick. to answer your questions: By ignore i meant instead of using non-alphanumeric characters that have special significance in regular expression (e.g. [|\]) and treat them as normal strings (i.e preceded by \), but since I don't know all the characters in regular expression that have special significance, I don't know which ones to add a '\' infront of. Thanks anyway John Machin wrote: On Jul 21, 3:02 pm, Astan Chee astan.c...@al.com.au wrote: Hi, I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? It would help if you were to say (1) what ignore ... characters means -- pretend they don't exist? (2) what are special chararacters -- non-alphanumeric? (3) what treat them like normal strings means (4) how you expect these special characters to be (a) ignored and (b) treated like normal strings /at the same time/. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On 21 Jul., 06:57, Frank Buss f...@frank-buss.de wrote: Scott Burson wrote: Have you looked at ECL? http://ecls.sourceforge.net/ I've used it only a little, so I can't vouch for its stability, but it fits the threading and license requirements (well, some corporate lawyers have trouble with the LGPL, but I think it's usable). I didn't tried it myself, but looks like it is not very stable: http://www.mail-archive.com/application-buil...@lispniks.com/msg01069.html I'm not sure if it is fair to post a reference to a single post by someone without context and without having used ECL. If there are stability problems, people can report to the ECL mailing list. The maintainers are very active. Frank, I have seen you constructive and posting code a year ago. What happened? Several messages of yours I've seen here are now going in the direction of been mostly useless. I thought you could do better. If you are no longer interested in Lisp with no first hand usage, why not switch to comp.lang.misc or some other random place? -- http://mail.python.org/mailman/listinfo/python-list
Re: Mutable Strings - Any libraries that offer this?
casebash schrieb: Hi, I have searched this list and found out that Python doesn't have a mutable string class (it had an inefficient one, but this was removed in 3.0). Are there any libraries outside the core that offer this? Hi, you could use a list of characters. It would not be difficult to implement this as a class with all fancy methods like startswith() ... Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de -- http://mail.python.org/mailman/listinfo/python-list
PIL for OSX 64bit
Hi, I have a problem with Python and the Python Image Library to get it work on OSX 64 bit. Maybe anyone can help me? I started Python in 64 bit mode and called Image.open(...).load() and got: ImportError: The _imaging C module is not installed Yes, it seems PIL is not available in 64 bit on my system, but I can't compile it in any way. Is there a tutorial or something like that which explains how I can compile it in 64 bit? I found a workaround where I added this function to the setup.py OrigExtension = Extension def Extension(*args, **kwargs): extra_args = ['-arch', 'x86_64'] kwargs['extra_compile_args'] = extra_args + kwargs.get ('extra_compile_args', []) kwargs['extra_link_args'] = extra_args + kwargs.get('extra_link_args', []) return OrigExtension(*args, **kwargs) without success. Can anyone help me? Thanks... Cheers, Googler -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a Python Service under the LocalService or NetworkService Account
On Jul 20, 5:25 pm, David Adamo Jr. dtgead...@yahoo.com wrote: On Jul 20, 5:14 pm, Tim Golden m...@timgolden.me.uk wrote: mistersexy wrote: On Jul 20, 3:03 pm, Tim Golden m...@timgolden.me.uk wrote: mistersexy wrote: I am trying to create a Windows service in Python using pywin32. I do not want this service to run under a user account. I want this service to be able to run as a LocalService, NetworkService and the like. How do I specify this using the win32 library? Thanks, everyone. When you install the service, using the HandleCommandLine option, specify --username= and --password options. TJG That's exactly my point. I do not want to have to specify username and password options. For instance, when creating a Windows Service in .NET, it is possible to specify that the service should run using the LocalService or NetworkService account. Doing this, you would not need to specify username and password options. Is there a way to achieve this in Python? Sorry, I misread: I mentally removed the not in your 'I do not want this service to run under a user account' and reinserted it further on! By default, the service will run as LocalSystem: you only specify a username to override that default. The value in Username is passed straight through to the CreateService Win32 API, and the docs for that: http://msdn.microsoft.com/en-us/library/ms682450%28VS.85%29.aspx say: lpServiceStartName [in, optional] The name of the account under which the service should run. If the service type is SERVICE_WIN32_OWN_PROCESS, use an account name in the form DomainName\UserName. The service process will be logged on as this user. If the account belongs to the built-in domain, you can specify .\UserName. If this parameter is NULL, CreateService uses the LocalSystem account. If the service type specifies SERVICE_INTERACTIVE_PROCESS, the service must run in the LocalSystem account. If this parameter is NT AUTHORITY\LocalService, CreateService uses the LocalService account. If the parameter is NT AUTHORITY\NetworkService, CreateService uses the NetworkService account. A shared process can run as any user. If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the system uses to load the device driver. Specify NULL if the driver is to use a default object name created by the I/O system. A service can be configured to use a managed account or a virtual account. If the service is configured to use a managed service account, the name is the managed service account name. If the service is configured to use a virtual account, specify the name as NT SERVICE\ServiceName. For more information about managed service accounts and virtual accounts, see the Service Accounts Step-by-Step Guide. Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP/2000: Managed service accounts and virtual accounts are not supported until Windows 7 and Windows Server 2008 R2. So, although I haven't tried it, it looks as though you can pass LocalService or NetworkService and so on if you want to override the default LocalSystem but don't want to specify a username/password. TJG I'll try this stuff. Thanks a million...I'll let everyone know how it goes. I'm finding it hard to install my Python service. When I try to install the service, this is what I get: Error Installing Service: Access is Denied. (5) Event with a correct username and password (I think). Also, inheriting from the win32serviceutil.Framework class, I do not see a way to explicitly specify the serviceType. I know some of the parameters such as the startupType can be specified when installing the service in the command line, but how are these things specified in the service code when inheriting from win32serviceutil.Framework (especially the serviceType). Does this mean I would have to code my service from scratch without using win32serviceutil.Framework? Basically, I still can't install my service using a NetworkService or LocalSystem Account because it still requires me to specify a username and password. Following Tim Golden's advice, I'm trying to specify the service type in order to determine what account to run the service under. Please help! -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
On Monday 20 July 2009 21:26:07 Phillip B Oldham wrote: On Jul 20, 6:08 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: The main reason why you need both lists and tuples is that because a tuple of immutable objects is itself immutable you can use it as a dictionary key. Really? That sounds interesting, although I can't think of any real- world cases where you'd use something like that. simplest is something like a point in the cartesian plane with an associated attribute like colour. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 20-07-2009, srepmub wrote: Nice timings, can you please show me the Python, Java and C code versions? I may do more tests. Of course, the codes are here : http://hg.flibuste.net/libre/games/cheval Like you'll see, i tried to use exactly the same code for each langage. also, which shedskin options did you use? did you use -bw, to disable bounds and wrap-around checking? this can make quite a difference for code that does a lot of indexing. if the code uses random numbers, then -r can also make a big difference, to use C rand(), instead of Python compatible random numbers. and which C++ compiler flags did you use? the default -O2, or something like -O3 -fomit-frame-pointer -msse2..? I used the default, shedksin cheval.py; make shedskin 0.2 With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8) Let me know if you find better. -- William Dodé - http://flibuste.net Informaticien Indépendant -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 20-07-2009, Bearophile wrote: Skip Montanaro: I read just enough French to know that avec means with, but I don't understand the difference between avec malloc *int and avec []. Can you explain please? Maybe it's the time difference between using a Python list from Cython and using a C array allocated with a malloc from Cython. yes, it's this -- William Dodé - http://flibuste.net Informaticien Indépendant -- http://mail.python.org/mailman/listinfo/python-list
Re: Mutable Strings - Any libraries that offer this?
John Machin sjmac...@lexicon.net writes: OK, I'll bite: where does the Python 3.x bytearray type I wasn't previously aware of it, thanks for bringing it to my attention URL:http://docs.python.org/3.1/library/stdtypes.html#bytes-methods. fit into your taxonomy? At first glance it appears to be mutable and have a fair swag of functionality. Yes. I'd classify it as a mutable array of bytes :-) but, as such, not to be used as a text string. -- \“Science doesn't work by vote and it doesn't work by | `\authority.” —Richard Dawkins, _Big Mistake_ (The Guardian, | _o__) 2006-12-27) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Mutable Strings - Any libraries that offer this?
Steven D'Aprano st...@remove-this-cybersource.com.au writes: On Mon, 20 Jul 2009 21:08:22 +1000, Ben Finney wrote: A mutable string would not (AFAICT) be usefully implementable as a subclass of the built-in string types. So even if such a type existed, it would not be useable with all the functionality that works with strings. If applications ignore duck-typing and do isinstance(value, str), it's arguably the application and not the value that is broken. Agreed, I wouldn't advise that. My point was rather meant to imply that subclassing the built-in (immutable) string types was the best way to usefully get all their functionality, rather than re-implementing most of it. -- \ “I went to a restaurant that serves ‘breakfast at any time’. So | `\I ordered French Toast during the Renaissance.” —Steven Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: missing 'xor' Boolean operator
On Jul 20, 11:34 pm, Ethan Furman et...@stoneleaf.us wrote: Dr. Phillip M. Feldman wrote: Suppose that 'xor' returns the value that is true when only one value is true, and False otherwise. This definition of xor doesn't have the standard associative property, that is, (a xor b) xor c will not necessarily equal a xor (b xor c) To see that this is the case, let a= 1, b= 2, and c= 3. (a xor b) xor c yields 3, while a xor (b xor c) yields 1. So, I'd prefer an xor operator that simply returns True or False. Phillip You are, of course, free to write your version however it makes sense to you and your team. :) Since the 'and' and 'or' already return objects (and objects evaluate to true or false), then 'xor' should behave likewise, IMO. I expect that would be the case if it were ever added to the language. I'm not so sure. Did you ever wonder why the any() and all() functions introduced in 2.5 return a boolean rather than returning one of their arguments? (I did, and I'm still not sure what the answer is.) Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On Jul 21, 6:57 am, Frank Buss f...@frank-buss.de wrote: Scott Burson wrote: Have you looked atECL? http://ecls.sourceforge.net/ I've used it only a little, so I can't vouch for its stability, but it fits the threading and license requirements (well, some corporate lawyers have trouble with the LGPL, but I think it's usable). I didn't tried it myself, but looks like it is not very stable: http://www.mail-archive.com/application-buil...@lispniks.com/msg01069... ECL suffers from fast development problems if this is what you mean. People are advised to stay with certain releases and we announce when some ports are broken due to progress along certain lines. For instance, if I find that the generational garbage collector is needed for Linux, FreeBSD, OpenBSD and OS X, and it works, I do not mind dropping temporarily the mingw port until the garbage collector library catches up. People who wanted to stay with mingw produced a branch (see Samium's posts) with the old garbage collector. Now this is not so dramatic. ECL now has a release cycle of ONE MONTH. If you find that this month's release does not work on your platform (and this is normally explicit in the announcement), then do not upgrade and wait one or two months until the problem is solved. OTOH, people only seem to notice problems when their petty platform is temporarily broken, but nobody seems to notice the overall stability and portability of the platform. See the list http://ecls.sourceforge.net/logs.html which will soon expand including Solaris and regular builds on Windows using the free Microsoft compiler. And once the ARM computer I have been gifted by a happy arrives, then Debian-ARM as well. Juanjo -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On Jul 19, 8:31 pm, Frank Buss f...@frank-buss.de wrote: Python is not that bad. Unlike Lisp, there is much less undefined behavior, there is one free unique implementation on the 3 major platforms Linux, Windows and MacOS X, which is stable, support multithreading and has a default GUI library binding, which is difficult to find for Lisp (e.g. I don't know of a free modern and stable Lisp implemenation with mulithreading support for Windows, with a licence with which you can use it in closed source commercial programs, like you can do with Python). Many problems in the Lispbuilder mailing list are related to problems due to different operating systems and Lisp implementations. Frank Buss, f...@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de Someone should mention Clozure CL - http://trac.clozure.com/openmcl As you can see there is os x, freebsd, linux, solaris and windows port and all of them use native threads (python still use green threads ?) and development is pretty alive, they did planty of developing last year[s], ccl licence permits you to deliver closed source programs ... CCL is promising bright feature to CL since looks like the insist of building stable implementation across most arch in use today -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a Python Service under the LocalService or NetworkService Account
sightseer wrote: knip Error Installing Service: Access is Denied. (5) knip Are you trying to do this on windows vista? -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' -- http://mail.python.org/mailman/listinfo/python-list
Re: ignore special characters in python regex
En Tue, 21 Jul 2009 02:02:57 -0300, Astan Chee astan.c...@al.com.au escribió: I'm reading text from a file (per line) and I want to do a regex using these lines but I want the regex to ignore any special characters and treat them like normal strings. Is there a regex function that can do this? Here is what I have so far: fp = open('file.txt','r') notes = fp.readlines() fp.close() strin = this is what I want for note in notes: if re.search(r+ str(note) + ,strin): print Found + str(note) + in + strin You don't even need a regex for that. py fragil in supercalifragilisticexpialidocious True Note that: r+ str(note) + is the same as: str(note) which in turn is the same as: note Remember that each line keeps its '\n' final! for note in notes: if note.rstrip('\n') in strin: print Found %s in %s % (note, strin) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
Hrvoje Niksic hnik...@xemacs.org wrote: Chris Rebert c...@rebertia.com writes: x = [2,1,3] print sorted(x)[0] DB 3 What kind of Python produces that? Assuming you're referring to the latter example, it was added in version 2.4 If you meant the former example, I think that's purely pseudo-Python. sorted([2, 1, 3])[0] evaluates to 1, not 3. I guess you can tell I broke my unbreakable rule to never post untested code without labelling it as such. :-) -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: How to import pydoc and then use it?
Albert Hopkins wrote: On Mon, 2009-07-20 at 13:38 -0700, mrstevegross wrote: I know how to use pydoc from the command line. However, because of complicated environmental setup, it would be preferable to run it within a python script as a native API call. That is, my python runner looks a bit like this: import pydoc pydoc.generate_html_docs_for(someFile) However, it's not clear to me from the pydoc documentation which function calls I need to use to make this behavior work. Any ideas? Did you try 'pydoc pydoc'? ;) import pydoc htmldoc = pydoc.HTMLDoc() htmldoc_for_pydoc = htmldoc(pydoc) print htmldoc_for_pydoc By the way, just in case the OP didn't know, there is the epydoc module (google it) which is doing basically the same things than pydoc, but with a much better look and feel to my opinion. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8) Let me know if you find better. thanks. now I'm wondering how fast does the C version become with these flags..? :-) mark. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Mark Dufour mark.duf...@gmail.com wrote: I have just released version 0.2 of Shed Skin, an experimental (restricted) Python-to-C++ compiler (http://shedskin.googlecode.com). It comes with 7 new example programs (for a total of 40 example programs, at over 12,000 lines) and several important improvements/bug fixes. See http://code.google.com/p/shedskin/wiki/ReleaseNotes for the full changelog. Cool! I tried it on a program I wrote to solve a puzzle (Rush Hour). (Actually it solves the meta-puzzle - trying to make the hardest possible Rush Hour puzzle.) After a bit of twiddling (remove psyco and profiling) I got it to start compiling, but unfortunately it compiled for about an hour (in iterative type analysis..) used up 600 MB of RAM printing an '*' every 10 minutes or so then gave an error message and gave up. Unfortunately I shut the window by accident, but the error message was something about not being able to resolve types I think with a list of 20 or so unresolved types. Can you give a hint as to how I debug this? I presume my program has some instances of non static types which is causing the problem, but it is going to be a very long debugging session if it takes me an hour each cycle ;-) The program is about 700 lines of python (excluding comments). Thanks Nick -- Nick Craig-Wood n...@craig-wood.com -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
On 21-07-2009, srepmub wrote: With -bw and -O3 -fomit-frame-pointer -msse2 i have 5.5s (instead of 8) Let me know if you find better. thanks. now I'm wondering how fast does the C version become with these flags..? :-) I don't see any difference... -- William Dodé - http://flibuste.net Informaticien Indépendant -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a Python Service under the LocalService or NetworkService Account
On Jul 21, 10:40 am, Martin P. Hellwig martin.hell...@dcuktec.org wrote: sightseer wrote: knip Error Installing Service: Access is Denied. (5) knip Are you trying to do this on windows vista? -- MPHhttp://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' Yeah, I was trying to do it on Vista. Someone has just helped me out. I had to deactivate User Account Control on Windows Vista...and now everything is rosy. Thanks guys. -- http://mail.python.org/mailman/listinfo/python-list
Re: JavaScript toolkits (was Re: ANN: Porcupine Web Application Server 0.6 is released!)
On 20 Jul, 18:00, a...@pythoncraft.com (Aahz) wrote: Out of curiosity, are there any JavaScript toolkits that generate code that degrades gracefully when JavaScript is disabled? You mean Web toolkits which use JavaScript, I presume. I have written (and use myself) a toolkit/framework called XSLForms (part of the XSLTools distribution) which supports in-page updates (AJAX, effectively) that degrade to vanilla whole-page requests if JavaScript is switched off: http://www.boddie.org.uk/python/XSLTools.html I've been meaning to have a few example applications running on that site to illustrate the point. Some people complain that by constraining the JavaScript functionality to merely enhance vanilla HTML/HTTP functionality, one is not using the full potential of the medium, but having used sites whose JavaScript has failed, thus preventing the use of those sites almost completely, I think that stacking AJAX-like stuff on top of normal stuff helps the majority of developers offer an accessible solution. Paul -- http://mail.python.org/mailman/listinfo/python-list
Particle research opens door for new technology
Big uses for small particles will be explored at the annual Particle Technology Research Centre Conference at The University of Western Ontario July 9 and 10.more link http://0nanotechnology0.blogspot.com/ -- http://mail.python.org/mailman/listinfo/python-list
RE: Auto-generate GUI from a database table structure
Gabriel, Thanks for pointing this out. It does not look like it supports Oracle at this time, which is one of my requirements, but that is based on doing a quick read of the wiki. I will dig in further and see. Perhaps it supports ODBC which would be an acceptable work-around. Thanks again, Craig -Original Message- From: python-list-bounces+craig1.boyd=citi@python.org [mailto:python-list-bounces+craig1.boyd=citi@python.org] On Behalf Of Gabriel Genellina Sent: Monday, July 20, 2009 4:40 PM To: python-list@python.org Subject: Re: Auto-generate GUI from a database table structure En Mon, 20 Jul 2009 12:09:47 -0300, Boyd, Craig1 craig1.b...@citi.com escribió: I am trying to write a couple screens to update three or four database tables on Oracle 10g and I was wondering if there was a way to automatically generate some kind of GUI shell based on the tables that I could then fill in with the logic / functionality I need. I've never actually used it, but the DABO project seems to provide what you want: http://dabodev.com/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Multiple versions of python
Hi, I have installed 2 versions of python on my Windows XP computer - I originally had 3.0.1, but then found that the MySQL module only supported 2.*, so I've now installed that. I have found that if I change the Windows Environment Variable path, then I can change the version of python called when I type 'python' into a command line. However, I'd like to be able to choose which version I use. I know that if I change C:\Python26\python.exe to C:\Python26\python2.exe and C:\Python30\python.exe to C: \Python26\python3.exe, then typing 'python2' or 'python3' will invoke the correct interpreter. However, is it safe just to rename the executable files? Is there a more elegant way to achieve the same task? Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list
Regular expression
Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') with code def readline(self): self.line = self.file_in.readline().rstrip() if (len(self.line)) : return True else : return False while (self.readline()): words = self.pattern_main.findall(self.line) This handles text file like // remark PL_OFF PARK FS MA 52.8806 , 18.0914 SS AD_W PL_ON C 52.3955 , -16.1511 , -90. It handles file correctly with two exceptions 1) omits ',' in the a output 2) omits minus sign in the numbers... Would anyone recommend me what to change regular expression to add thesee two think to the output,please? Thank you for any help. I look forward hearing form you Yours faithfully Peter Fodrek -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
On Jul 20, 12:27 pm, Phillip B Oldham phillip.old...@gmail.com wrote: [snip] We understand that lists are mutable and tuples are not, but we're a little lost as to why the two were kept separate from the start. They both perform a very similar job as far as we can tell. My guess is that it was probably for optimization reasons long ago. I've never heard a *good* reason why Python needs both. -- http://mail.python.org/mailman/listinfo/python-list
Re: Mutable Strings - Any libraries that offer this?
Steven D'Aprano wrote: On Mon, 20 Jul 2009 21:08:22 +1000, Ben Finney wrote: What is it you're trying to do that makes you search for a mutable string type? It's likely that a better approach can be found. When dealing with very large strings, it is wasteful to have to duplicate the entire string just to mutate a single character. However, when dealing with very large strings, it's arguably better to use the rope data structure instead. The general problem is that whether strings are mutable or not is an early language design decision, and few languages provide both. Mutable strings need lots of data copying to be safe passing args to unknown functions; immutable strings need lots of copying for ncremental changes. The rope is a great idea for some cases. I'd argue Python works better with immutable strings, because Python is too slow at per-character operations to be running up and down strings a character at a time, changing here and there. So it becomes more natural to deal with strings as chunks to pass around, and it is nice not to have to copy the strings when doing that passing around. --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple versions of python
ChrisW wrote: Hi, I have installed 2 versions of python on my Windows XP computer - I originally had 3.0.1, but then found that the MySQL module only supported 2.*, so I've now installed that. I have found that if I change the Windows Environment Variable path, then I can change the version of python called when I type 'python' into a command line. However, I'd like to be able to choose which version I use. I know that if I change C:\Python26\python.exe to C:\Python26\python2.exe and C:\Python30\python.exe to C: \Python26\python3.exe, then typing 'python2' or 'python3' will invoke the correct interpreter. However, is it safe just to rename the executable files? Is there a more elegant way to achieve the same task? I wouldn't rename them. You can, of course, copy them (so you have two executables), or you can pick a somedir on your path (I made a directory C:\cmds that I add to my path, but tastes vary). C: copy con somedir\py25.cmd C:\Python25\python\python.exe %* ^Z C: copy con somedir\py31.cmd C:\Python31\python\python.exe %* ^Z I'd use the two-digit form, as that is where interface changes happen; trying code with py24, py25, py26 can be convenient. By the way, install Python 3.1 rather than 3.0; think of 3.0 as the alpha of the 3.X branches (it will get no love at all now that 3.1 is out). --Scott David Daniels scott.dani...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On 2009-07-21 05:37:27 -0400, milanj mil...@gmail.com said: Someone should mention Clozure CL - http://trac.clozure.com/openmcl As you can see there is os x, freebsd, linux, solaris and windows port and all of them use native threads (python still use green threads ?) and development is pretty alive, they did planty of developing last year[s], ccl licence permits you to deliver closed source programs ... CCL is promising bright feature to CL since looks like the insist of building stable implementation across most arch in use today Hear, hear! -- Raffael Cavallaro -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple versions of python
ChrisW wrote: Hi, I have installed 2 versions of python on my Windows XP computer - I originally had 3.0.1, but then found that the MySQL module only supported 2.*, so I've now installed that. I have found that if I change the Windows Environment Variable path, then I can change the version of python called when I type 'python' into a command line. However, I'd like to be able to choose which version I use. I know that if I change C:\Python26\python.exe to C:\Python26\python2.exe and C:\Python30\python.exe to C: \Python26\python3.exe, then typing 'python2' or 'python3' will invoke the correct interpreter. However, is it safe just to rename the executable files? Is there a more elegant way to achieve the same task? Thanks, Chris The elegant way is to have a batch directory on your PATH ( I use m:\t\bat ) and put your *.bat files there. I do NOT put any python installations on the PATH. For example, I have a batch file called: m:\t\bat\python26.bat c:\progfiles\python26\python.exe %* The %* syntax means pass all arguments through to the program. Once it all works, you can add an @ in front of the c: in order to suppress echoing the command. At that point, it'll look and work the same way as what you did, but without modifying anything in the install directory.(You may want python26.bat, pythonw26.bat, python31.bat and pythonw31.bat) The other thing you may want to do in a batch file is to change the file associations so that you can run the .py file directly, without typing python or pythonw in front of it. The relevant Windows commands are: assoc and ftype And on a related note, you may want to edit the PATHEXT environment variable, to add .PY and .PYW -- http://mail.python.org/mailman/listinfo/python-list
Workflow Libraries (DB vs Code)
Hi, I need to write some simple workflows with web interface. For the web stuff I will use django, but I am not sure how to do the workflow part. Here are ideas: Do it myself. I don't think it will be difficult, I did things like this before. But they were not reusable. Use spiff Workflow library http://code.google.com/p/spiff-workflow/ Use goflow for django (port of OpenFlow of Zope). It does not look like a active project. Has anyone worked with spiff, goflow or other workflow software? What do you like and dislike? Somehow I like it the way goflow does it: The process definitions are stored in the database. But on the other hand I prefer to have things like this in a SVN-Repository. Creating the workflow definitions will be done by python programmers. I don't need a GUI to build them. There are many languages to define processes (BPML, XPDL, BPEL or YAWL). But I prefer python. Feedback welcome, Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de -- http://mail.python.org/mailman/listinfo/python-list
Re: invoke method on many instances
On Jul 20, 3:29 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sat, 18 Jul 2009 12:31:46 -0300, Alan G Isaac alan.is...@gmail.com escribió: On Fri, 17 Jul 2009 05:19:50 +, Alan G Isaac wrote: def apply2(itr, methodname, *args, **kwargs): f = operator.methodcaller(methodname, *args, **kwargs) for item in itr: f(item) On 7/17/2009 3:45 AM Steven D'Aprano apparently wrote: for obj in objects: getattr(obj, methodname)(*args, **kwargs) Are there any obvious considerations in choosing between those two? The operator.methodcaller version is faster in my tests for large collections, but slightly slower when you have very few elements. code import operator import timeit class X: def method(self, x, y, **kw): pass def apply1(itr, methodname, *args, **kwargs): for item in itr: getattr(item, methodname)(*args, **kwargs) def apply2(itr, methodname, *args, **kwargs): f = operator.methodcaller(methodname, *args, **kwargs) for item in itr: f(item) L=[X() for _ in range(3000)] apply1(L,'method', 1, 2, foo=3) apply2(L,'method', 1, 2, foo=3) timeit.timeit(setup=from __main__ import apply1,apply2,L, stmt=apply1(L,'method', 1, 2, foo=3), number=1000) timeit.timeit(setup=from __main__ import apply1,apply2,L, stmt=apply2(L,'method', 1, 2, foo=3), number=1000) /code -- Gabriel Genellina If your instances are all of the same class you can pass in the method directly like so: def apply3(iterator, method, *args, **kwargs): for item in iterator: method(item, *args, **kwargs) class X: def method(self, x, y, **kw): pass items = [X() for _ in range(10)] apply3(items, X.method, 1, 2, foo=3) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: tough-to-explain Python
On Mon, Jul 20, 2009 at 9:54 PM, Paul Rubinhttp://phr...@nospam.invalid wrote: Simon Forman sajmik...@gmail.com writes: But I'm glad it's there to study, these are wheels I don't have to invent for myself. http://dwheeler.com/essays/high-assurance-floss.html might be an interesting place to start. OO la la! Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On Jul 19, 7:33 pm, fft1976 fft1...@gmail.com wrote: On Jul 19, 9:55 am, Frank Buss f...@frank-buss.de wrote: E.g. the number system: In many Lisp implementations (/ 2 3) results in the fractional object 2/3. In Python 2.6 2 / 3 results in 0. Looks like with Python 3.1 they have fixed it, now it returns 0.66, which will result in lots of fun for porting applications written for Python = 2.6. How do you explain that something as inferior as Python beat Lisp in the market place despite starting 40 years later. Worse is better? Bobi http://www.linkedin.com/in/slobodanblazeski -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Nick Craig-Wood: Can you give a hint as to how I debug this? I presume my program has some instances of non static types which is causing the problem, but it is going to be a very long debugging session if it takes me an hour each cycle ;-) The program is about 700 lines of python (excluding comments). You can show us the Python (SSPython) code, and we can try to find the problem. Sometimes there's no simple ways to solve such problems. Generally for not very large progrograms if SS doesn't compile in about a minute or so then it's gone in infinite loop (there's a compilation flag that avoids some infinite loops, try it). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
Hendrik van Rooyen hend...@microcorp.co.za (HvR) wrote: HvR On Monday 20 July 2009 21:26:07 Phillip B Oldham wrote: On Jul 20, 6:08 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: The main reason why you need both lists and tuples is that because a tuple of immutable objects is itself immutable you can use it as a dictionary key. Really? That sounds interesting, although I can't think of any real- world cases where you'd use something like that. HvR simplest is something like a point in the cartesian plane with HvR an associated attribute like colour. There are numerous other examples. Anytime you need a key that is not a single object but composed of more than one: Name + birthday Street + number + City Student + Course etc. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
William Dode': http://hg.flibuste.net/libre/games/cheval Like you'll see, i tried to use exactly the same code for each langage. It's a cute solver. Few more versions of mine: #1, a Psyco version of mine: http://codepad.org/9m5rf7kX #2, unrolled Psyco version: http://codepad.org/gKFLu34M #3, a quick D (D1) version: http://codepad.org/Tk9FL7Xk Timings (no printing), seconds, best of 3: #1: 4.79 #2: 3.67 #3: 1.10 Your Psyco version: 13.37 Your C version, compiled with GCC 4.3.2, -s -O3 -fomit-frame-pointer: 3.79 I have timed the whole running time of the programs, with an external timer, so my timings include the start of the PythonVM and the final cleanup of the GC. Please, feel free to time my code again, so we can compare with your other timings (Java, etc) better. I have used Psyco 1.6 final and Python 2.6.2 on a Core2 CPU at 2 GHz. To compile the D1 code you can use the free DMD compiler for D1, I have used version 1.042, www.digitalmars.com/d/download.html ). In such benchmarks it's often better to start from the fastest low level code (written in an imperative language as C/D/C++, or a version in a functional language like Clean or OCaML) and then use it to create higher level versions (in Python, etc). This offers you a baseline timing, and usually the small differences of the higher level code compared to the original C/Clean code don't invalidate the test. I have changed only small things in the program, as you can see the Psyco program #2 is faster than your C code :-) If you learn how to use it well, Psyco1.6 can often lead to very good performance. But lot of people don't know how to use Psyco well (I too am ignorant: I don't know how to profile Python programs yet). Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
Piet van Oostrum wrote: Hendrik van Rooyen hend...@microcorp.co.za (HvR) wrote: HvR On Monday 20 July 2009 21:26:07 Phillip B Oldham wrote: On Jul 20, 6:08 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: The main reason why you need both lists and tuples is that because a tuple of immutable objects is itself immutable you can use it as a dictionary key. Really? That sounds interesting, although I can't think of any real- world cases where you'd use something like that. HvR simplest is something like a point in the cartesian plane with HvR an associated attribute like colour. There are numerous other examples. Anytime you need a key that is not a single object but composed of more than one: Name + birthday Street + number + City Student + Course etc. Compound keys (like what's listed above) can also be used for sorting lists of dictionaries using DSU style sorting. Something I believe (and I could be wrong) won't work with mutable types like lists. --David -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
Peter Fodrek wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') [snip] It handles file correctly with two exceptions 1) omits ',' in the a output 2) omits minus sign in the numbers... Would anyone recommend me what to change regular expression to add thesee two think to the output,please? self.pattern_main = re.compile(r'(\s+|,|-?\w\+?\d*(?:\.\d*)?|\w#\d+|\(.*?\)|#\d+=\+?\d*(?:\.\d*)?)') -- http://mail.python.org/mailman/listinfo/python-list
Re: missing 'xor' Boolean operator
Mark Dickinson wrote: On Jul 20, 11:34 pm, Ethan Furman et...@stoneleaf.us wrote: Dr. Phillip M. Feldman wrote: Suppose that 'xor' returns the value that is true when only one value is true, and False otherwise. This definition of xor doesn't have the standard associative property, that is, (a xor b) xor c will not necessarily equal a xor (b xor c) To see that this is the case, let a= 1, b= 2, and c= 3. (a xor b) xor c yields 3, while a xor (b xor c) yields 1. So, I'd prefer an xor operator that simply returns True or False. Phillip You are, of course, free to write your version however it makes sense to you and your team. :) Since the 'and' and 'or' already return objects (and objects evaluate to true or false), then 'xor' should behave likewise, IMO. I expect that would be the case if it were ever added to the language. I'm not so sure. Did you ever wonder why the any() and all() functions introduced in 2.5 return a boolean rather than returning one of their arguments? (I did, and I'm still not sure what the answer is.) Mark Very good question -- I likewise do not know the answer. I will only observe that any() and all() are functions, while 'and' and 'or' are not. If one wanted the object-returning behavior one could string together 'or's or 'and's instead. ~Ethan~ -- Thinking out loud here -- YMMV. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
David Smith d...@cornell.edu (DS) wrote: DS Piet van Oostrum wrote: Hendrik van Rooyen hend...@microcorp.co.za (HvR) wrote: HvR On Monday 20 July 2009 21:26:07 Phillip B Oldham wrote: On Jul 20, 6:08 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: The main reason why you need both lists and tuples is that because a tuple of immutable objects is itself immutable you can use it as a dictionary key. Really? That sounds interesting, although I can't think of any real- world cases where you'd use something like that. HvR simplest is something like a point in the cartesian plane with HvR an associated attribute like colour. There are numerous other examples. Anytime you need a key that is not a single object but composed of more than one: Name + birthday Street + number + City Student + Course etc. DS Compound keys (like what's listed above) can also be used for sorting DS lists of dictionaries using DSU style sorting. Something I believe (and DS I could be wrong) won't work with mutable types like lists. For sorting there is no problem with mutable arrays as long as you don't mutate them during the sorting process (for example in the comparison routine). Doing that would be extremely perverse. And there is no enforcement of that. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') Always use raw strings (r...) when you're working with regular expressions. *Always*. It may happen that you don't need them, as in this case, because Python fails to throw an exception when it meets unknown escape sequences in string literals, but when you do need them you will spend hours before realising it. Also, whoever wrote this regular expression should be taken out and slapped with a wet fish, for it is abominable and unlikely to look much like what you actually want. with code def readline(self): self.line = self.file_in.readline().rstrip() if (len(self.line)) : return True else : return False while (self.readline()): words = self.pattern_main.findall(self.line) Um. Yes. Well. This handles text file like // remark PL_OFF PARK FS MA 52.8806 , 18.0914 SS AD_W PL_ON C 52.3955 , -16.1511 , -90. It handles file correctly with two exceptions 1) omits ',' in the a output You don't do any output, so it's hard to correct that! 2) omits minus sign in the numbers... Would anyone recommend me what to change regular expression to add thesee two think to the output,please? It would help considerably if you explained what it handles file correctly means, since the regular expresion makes little sense with the input you give. What are you trying to extract from the input, and what do you think you are getting at the moment? -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: Multiple versions of python
On 21 July, 15:19, Dave Angel da...@dejaviewphoto.com wrote: ChrisW wrote: Hi, I have installed 2 versions of python on my Windows XP computer - I originally had 3.0.1, but then found that the MySQL module only supported 2.*, so I've now installed that. I have found that if I change the Windows Environment Variable path, then I can change the version of python called when I type 'python' into a command line. However, I'd like to be able to choose which version I use. I know that if I change C:\Python26\python.exe to C:\Python26\python2.exe and C:\Python30\python.exe to C: \Python26\python3.exe, then typing 'python2' or 'python3' will invoke the correct interpreter. However, is it safe just to rename the executable files? Is there a more elegant way to achieve the same task? Thanks, Chris The elegant way is to have a batch directory on your PATH ( I use m:\t\bat ) and put your *.bat files there. I do NOT put any python installations on the PATH. For example, I have a batch file called: m:\t\bat\python26.bat c:\progfiles\python26\python.exe %* The %* syntax means pass all arguments through to the program. Once it all works, you can add an @ in front of the c: in order to suppress echoing the command. At that point, it'll look and work the same way as what you did, but without modifying anything in the install directory. (You may want python26.bat, pythonw26.bat, python31.bat and pythonw31.bat) The other thing you may want to do in a batch file is to change the file associations so that you can run the .py file directly, without typing python or pythonw in front of it. The relevant Windows commands are: assoc and ftype And on a related note, you may want to edit the PATHEXT environment variable, to add .PY and .PYW Thanks for this - this way made a bit more sense to me. I've now got C:\commands with the 4 .bat files in, and C:\commands in my path. It all seems to work :) I think I've missed the point of the @ though - it doesn't seem to make any difference.. I'm also a bit confused with the associations - since I've got python 2.6 and 3.1, surely the command I type (python26 or python31) is the only way to force a script to be run using a specific interpreter at runtime without having to change the .bat file every time I want to run a script using 3.1 instead of 2.6? -- http://mail.python.org/mailman/listinfo/python-list
Re: Workflow Libraries (DB vs Code)
Thomas Guettler wrote: Hi, I need to write some simple workflows with web interface. For the web stuff I will use django, but I am not sure how to do the workflow part. Did you consider using OpenERP? It comes with a web-frontend (TG1.0.8-based), but also offers a XMLRPC-server to connect to, so using it from within django shouldn't be any difficult. Workflow-definitions are stored in the DB, and can be generated visually, not sure if they have to though. I'm not very familiar with the system myself, but the EuroPython presentation was truly impressive. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: python function for retrieving key and encryption
jayshree jayshree06c...@gmail.com (j) wrote: j M2Crypto package not showing the 'recipient_public_key.pem' file at j linux terminal .how do i get/connect with recipient public key. j exactly i need to check how can i open this file through linux j commands. j import M2Crypto def encrypt(): recip = M2Crypto.RSA.load_pub_key(open j ('recipient_public_key.pem','rb').read()) print recip; plaintext = j whatever i need to encrypt msg = recip.public_encrypt j (plaintext,RSA.pkcs1_padding) print msg; j after calling the function its not giving any output and even any j error j i also tried as 'Will' said j pk = open('public_key.pem','rb').read() print pk; rsa = j M2Crypto.RSA.load_pub_key(pk) j whats the mistake i am not getting .will somebody help me out. j is something wrong in opening 'recipient_public_key.pem'. is M2Crypto j contain this file inbuilt .from where this file taking public key of j the recipient i'. what this file contain and how it will work .should j i need to create such a file for my purpose.if it is then how can i j create this and how it will retrieve the key,where i recognize my j recipient to get his public key .is something like database at server. j please give me a quick response.. j looking for your answer. Please: 1. Type your python code with newlines and proper indentation. 2. Show the error messages that your code gives when you run it. 3. Use proper capital letters at the beginning of your sentences. 4. Don't fire so many questions in rapid succession. The recipient_public_key.pem file is the public key of the recipient which means the person that is going to receive the encrypted message. You should get it from the recipient him/herself or from some key store where s/he has deposited it. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL for OSX 64bit
In article e0564f03-f736-4d0f-8c50-e1bce0eb5...@r2g2000yqm.googlegroups.com, moerchendiser2k3 googler.1.webmas...@spamgourmet.com wrote: I have a problem with Python and the Python Image Library to get it work on OSX 64 bit. Maybe anyone can help me? I started Python in 64 bit mode and called Image.open(...).load() and got: ImportError: The _imaging C module is not installed [...] It's hard to know what your problem is without more information. One potential stumbling block: PIL has dependencies on other open-source libraries, such as libjpeg and freetype. You'll need to have 64-bit versions of them available when building and when running, as well. There are a number of ways to do that. The simplest might be to download pre-built frameworks containing those libraries from here: http://www.kyngchaos.com/software:frameworks There are also build scripts there for building your own versions from scratch. -- Ned Deily, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
21.7.2009 v 16:50, MRAB: Peter Fodrek wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d +|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') [snip] It handles file correctly with two exceptions 1) omits ',' in the a output 2) omits minus sign in the numbers... Would anyone recommend me what to change regular expression to add thesee two think to the output,please? self.pattern_main = re.compile(r'(\s+|,|-?\w\+?\d*(?:\.\d*)?|\w#\d+|\ (.*?\)|#\d+=\+?\d*(?:\.\d*)?)') Thank you I will try yesterday... Peter -- http://mail.python.org/mailman/listinfo/python-list
Issue combining gzip and subprocess
Hi there, We tried to gzip the output of a shell command, but this results in a strange error: the resulting file seems to be the concatenation of the plaintext file with the zipped content. For example: f = gzip.open(filename, 'w') subprocess.check_call(['ls','-la'], stdout=f) f.close() Using a normal file works as expected, but a GzipFile results in a file containing what looks like the unzipped data, followed by the zipped data. I suspect this may have something to do with limitations of GzipFile such as it not implementing truncate(). Does anyone have an explanation / can you suggest a nice solution for doing what we are trying to do? Regards - Iwan -- http://mail.python.org/mailman/listinfo/python-list
Re: any suggestions to synchronize typed text and speech ?
hi Marcus, That sounds like a very specialized type of thing, Well from an application point of view, with the current netbooks, this looks like a perfect tool for any conversation or meeting. which only the few people with experience with wxPython, PyAudio, and Scintilla could help you with... I was afraid of that too, so I dropped the question in several places, and the writer of Scintilla himself came with the perfect answer. cheers,Stef But you might try having a dictionary with notes and associated times, or just give each note a four-digit ID number at the beginning of it when it's entered and use that in the dictionary (to keep keys shorter). Or you could just do a little hack and increase the number of bookmarks allowed (seeing as source is available) :p Marcus Glad you got a good answer from somebody. Sounds like an interesting project. About when would this be headed for a release? Could you post a link to a googlecode or sourceforge project or something so I can follow and/or help with development? For the moment it's just an idea, so no line of code yet. I first like to tackle all the problems, at least to the level I think I can handle them. So first solve the next problem, before I start coding: automatic synchronization (file uploading and deleting) between EEE-pc and desktop PC over bluetooth. And another problem, as my customers are physicians, both the text and audio need to be stored encrypted. cheers, Stef Marcus -- http://mail.python.org/mailman/listinfo/python-list
Re: Help understanding the decisions *behind* python?
On Jul 20, 12:27 pm, Phillip B Oldham phillip.old...@gmail.com wrote: My colleagues and I have been working with python for around 6 months now, and while we love a lot of what python has done for us and what it enables us to do some of the decisions behind such certain data-types and their related methods baffle us slightly (when compared to the decisions made in other, similarly powerful languages). Specifically the differences between lists and tuples have us confused and have caused many discussions in the office. We understand that lists are mutable and tuples are not, but we're a little lost as to why the two were kept separate from the start. They both perform a very similar job as far as we can tell. Consider the following: x = [2,1,3] x.sort() print x [1, 2, 3] Now, if the sort operations were unable to affect the original structure of the list (as in JavaScript) you'd effectively have a tuple which you could add/remove from, and the example above would look more like: x = [2,1,3] print x.sort() [1, 2, 3] print x [2,1,3] This make a lot more sense to us, and follows the convention from other languages. It would also mean chaining methods to manipulate lists would be easier: x = [2,1,3] print x.sort()[0] 3 (As others have already pointed out this would print 1, not 3.) print x [2,1,3] We often find we need to do manipulations like the above without changing the order of the original list, and languages like JS allow this. We can't work out how to do this in python though, other than duplicating the list, sorting, reversing, then discarding. In this case you can use: x = [2,1,3] print min(x) 1 (There's also a max() function.) We're not looking to start any arguments or religious wars and we're not asking that python be changed into something its not. We'd simply like to understand the decision behind the lists and tuple structures. We feel that in not getting the difference between the two types we may be missing out on using these data structures to their full potential. One way to think about tuples (as distinct from lists) is as a short- hand version of Pascal's 'record' type, or C's 'struct' (with the caveats that the fields are not named, only indexed, and the types of the fields are implied by use, not explicitly declared.) (FWIW: http://en.wikipedia.org/wiki/Record_(computer_science) ) Broadly speaking, lists are useful for things like stacks and queues, and sorting, while tuples are useful for aggregating heterogeneous data into coherent units, and you can hash them (provided their contents are also hashable.) HTH, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
Rainer Joswig wrote: I'm not sure if it is fair to post a reference to a single post by someone without context and without having used ECL. If there are stability problems, people can report to the ECL mailing list. The maintainers are very active. This was just one example. Another one: http://www.mail-archive.com/application-buil...@lispniks.com/msg01024.html Luke and Elliott are no beginners, so it is at least difficult to use ECL: On Windows it doesn't work with MinGW and on MacOS X there was at least one case were it freezed. But as I have written, I didn't tried it myself, so this is only some second hand experience. Maybe it is all wrong setups in combination with Lispbuilder and ECL itself is stable, I don't know. But I know that it is much easier to get a full featured running Python system on Windows, MacOS X and Linux, so this is something where Lisp distributions could be improved. -- Frank Buss, f...@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de -- http://mail.python.org/mailman/listinfo/python-list
Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops
Ville Vainio wrote: Has anyone implementing something like what the subject line indicates? The idea: To run functions that execute a series of system commands without blocking the ui, *and* without adding state machine logic. At some level, there's going to be state machine logic. You need interlocking so that the user can't initiate simultaneous conflicting background operations from the GUI. The usual solution is to run the background operations in another thread, and have them put events on a queue read by the GUI task. You also have to work out how to cancel background operations, if they're going to be as big as a make. Here's the very first application which did this sort of thing, running commands in multiple threads without blocking the user interface thread. This is from 1972. http://www.fourmilab.ch/documents/univac/fang/ And yes, it did properly interlock everything it was doing in the background. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Issue combining gzip and subprocess
Iwan Vosloo i...@reahl.org (IV) wrote: IV Hi there, IV We tried to gzip the output of a shell command, but this results in a IV strange error: the resulting file seems to be the concatenation of the IV plaintext file with the zipped content. IV For example: IV f = gzip.open(filename, 'w') IV subprocess.check_call(['ls','-la'], stdout=f) IV f.close() IV Using a normal file works as expected, but a GzipFile results in a file IV containing what looks like the unzipped data, followed by the zipped IV data. IV I suspect this may have something to do with limitations of GzipFile IV such as it not implementing truncate(). IV Does anyone have an explanation / can you suggest a nice solution for IV doing what we are trying to do? stdout (and the others) must be None, PIPE or a real file object or file descriptor, not a file like object. In your case the solution would be to use PIPE, and then read the output and write in to the GzipFile yourself. f = gzip.open(filename, 'w') proc = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE) while True: line = proc.stdout.readline() if not line: break f.write(line) f.close() -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
Re: win32api install problem
MCIPERF wrote: On Jul 20, 9:57 am, Tim Golden m...@timgolden.me.uk wrote: Gerry wrote: I'm running Python 2.6 under XP. I've installed Windows 32 extensions for Python 2.6 version 1.4 (pywin32-214.win32-py2.6.exe). But If I try to import win32api, I get: File C:\python_projects\euler\driveletters.py, line 1, in module import win32api ImportError: DLL load failed: The specified module could not be found. Used to be you'd get this error if you installed as a non-admin user. Don't know if that's still an issue. Possibility? TJG Not a possibility (afaict) -- I am an administrator, according to the control panel. Not too many ideas, then, I'm afraid. Apart from the obvious -- uninstall and try again -- how about running Python with the -vv option: python -vv to get more information about what it's trying to get, and/or running sysinternal's Process Explorer at the same time to spot the DLL Dependencies. I have seen a (not too similar) problem when running TortoiseHg and the pywin32 extensions, since the shell import's TortoiseHg's version of various pywin32 DLLs before I try to import them myself for some other purpose, and the two versions clashed dramatically (crashed Explorer hard, I seem to remember). Just in case that rings any bells.. TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
Rhodri James wrote: On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: Dear conference! I have third party regular expression self.pattern_main = re.compile('(\s+|\w(?:[+])?\d*(?:\.\d*)?|\w\#\d+|\(.*?\)| \#\d+\=(?:[+])?\d*(?:\.\d*)?)') Also, whoever wrote this regular expression should be taken out and slapped with a wet fish, for it is abominable and unlikely to look much like what you actually want. Here, take that fish and please, hit really hard ! ** ;'-. `;-._) '---.._ `-.__.-' `'.__ /_.-'-._ _, ^ ---) ` `'--/_.'`` JM ** -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On 2009-07-19 19:31:36 +0100, Frank Buss f...@frank-buss.de said: (e.g. I don't know of a free modern and stable Lisp implemenation with mulithreading support for Windows, with a licence with which you can use it in closed source commercial programs, like you can do with Python). Openmcl seems reasonably stable to me, is LLGPL-licensed, and runs on these platforms and Solaris x86. It's kind of tragic, of course, that this kind of parasitic behaviour (will not consider a commercial product to use in your commercial system) has now become so common. -- http://mail.python.org/mailman/listinfo/python-list
Re: clean way prepend an element to a numpy array
On 2009-07-20 22:56, bdb112 wrote: If I want to add an element at the beginning of an array, it seems like I must make a list, insert in place, then make an array again. the_array = numpy.concatenate([new_value, the_array]) You will want to ask numpy questions on the numpy mailing list. http://www.scipy.org/Mailing_Lists -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Regular expression
On Tue, 21 Jul 2009 17:12:53 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: 21.7.2009 v 17:39, Rhodri James: On Tue, 21 Jul 2009 14:30:47 +0100, Peter Fodrek peter.fod...@stuba.sk wrote: [snipped for space] This handles text file like // remark PL_OFF PARK FS MA 52.8806 , 18.0914 SS AD_W PL_ON C 52.3955 , -16.1511 , -90. It handles file correctly with two exceptions 1) omits ',' in the a output You don't do any output, so it's hard to correct that! for line C 52.3955 , -16.1511 , -90. it returns (as I remember) ('C', ' ', '52.3955', ' ', ' ', ' 16.1511', ' ', ' ','90.0') I was to get (number and positions of empty strings are not related to me. I can add, remove then as you wish) ('C', ' ', '52.3955', ' ', ' ,', ' -16.1511', ' ', ' ,','-90.0') If whitespace isn't an issue and the format really is as simple as your example, you don't need the full power of a regular expression here. split() would do the trick: words = self.line.split() will return what you want for that example. It will produce different (but more consistent) results than the regular expression for other lines, though: for example, MA 52.8806 , 18.0914 when put through the regular expression (if fixed for commas) would give you ('M', 'A', ' ', '52.8806', ' ', ',', ' ', '18.0914') as against ['MA', '52.8806', ',', '18.0914'] I use eval call in python to do format conversion, so just parsing is problem float() might be better than eval(), if you know for sure that you are expecting floats. -- Rhodri James *-* Wildebeest Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list
Re: are user defined classes hashable?
On Jul 20, 10:53 pm, a...@pythoncraft.com (Aahz) wrote: In article 373d6c69-6965-4a88-bdd2-8028ef850...@k6g2000yqn.googlegroups.com, Hyuga hyugaricd...@gmail.com wrote: Regardless, Nicolas's example can be applied to the class too: class Foo(object): pass hash(Foo) 11443104 id(Foo) 11443104 class objects are just objects of type 'type'. Not quite. They certainly default that way, but changing the metaclass changes a class's type:: class M(type): pass class C(object): pass class C2(object): __metaclass__ = M print type(C) print type(C2) Well, okay, you got me there. But the OP wasn't asking about classes with different metaclasses. And besides, type(type(C2)) is still type ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
Nick Craig-Wood wrote: I tried it on a program I wrote to solve a puzzle (Rush Hour). (Actually it solves the meta-puzzle - trying to make the hardest possible Rush Hour puzzle.) After a bit of twiddling (remove psyco and profiling) I got it to start compiling, but unfortunately it compiled for about an hour (in iterative type analysis..) used up 600 MB of RAM printing an '*' every 10 minutes or so then gave an error message and gave up. Unfortunately I shut the window by accident, but the error message was something about not being able to resolve types I think with a list of 20 or so unresolved types. Can you give a hint as to how I debug this? I presume my program has some instances of non static types which is causing the problem, but it is going to be a very long debugging session if it takes me an hour each cycle ;-) The program is about 700 lines of python (excluding comments). Split it into pieces and compile each separately. Recurse. tjr -- http://mail.python.org/mailman/listinfo/python-list
setuptools question.
I have a python program and when I install this program from the module home directory using setup.py everything works fine. But easy_install fails with the following error, because I am trying to install some start up shell scripts into /etc/init.d The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. Is there a way to use easy_install to install the start scripts into / etc/init.d. If not, what is the best way to install these scripts. Thanks -fred- -- http://mail.python.org/mailman/listinfo/python-list
Re: Pep 342 (val = yield MyGenerator(foo)), synchronous os.system() that doesn't block gui event loops
Ville Vainio wrote: Has anyone implementing something like what the subject line indicates? Your subject line is so long that it is cut off even on my wide screen. Better to repeat the question in the body. -- http://mail.python.org/mailman/listinfo/python-list
Re: Running a Python Service under the LocalService or NetworkService Account
David Adamo Jr. wrote: On Jul 21, 10:40 am, Martin P. Hellwig martin.hell...@dcuktec.org wrote: sightseer wrote: knip Error Installing Service: Access is Denied. (5) knip Are you trying to do this on windows vista? -- MPHhttp://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' Yeah, I was trying to do it on Vista. Someone has just helped me out. I had to deactivate User Account Control on Windows Vista...and now everything is rosy. Thanks guys. No need to deactivate it, just right click on the command shell program and say run as administrator, than you can install the service via the command line. -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' -- http://mail.python.org/mailman/listinfo/python-list
List insertion cost
Hello, I would like to know how much it costs to insert an element into a list using this operation: a[2:2] = [ 1 ] i. e, what is the complexity of the operation above (given that len(a) = n)? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: List insertion cost
On Tue, Jul 21, 2009 at 2:21 PM, Lucas P Melo lukepada...@gmail.com wrote: I would like to know how much it costs to insert an element into a list using this operation: a[2:2] = [ 1 ] i. e, what is the complexity of the operation above (given that len(a) = n)? O(n) If you want O(log n), you can use the blist extension type from http://pypi.python.org/pypi/blist/ -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC http://stutzbachenterprises.com -- http://mail.python.org/mailman/listinfo/python-list
Pyserial and pyQt
I have used pyserial in the past but this is my first experience with pyQt. I am using the Python xy package for windows current but might move to linux. I have a small device that is outputting a basic text string. I want to be able to read this string(from the comm port) and update a text box and eventually a graph in pyQt. I can't find any documentation or tutorials on how to do this. If anyone can point me in the right direction or give me some tips I would be grateful. Thanks, Seth -- http://mail.python.org/mailman/listinfo/python-list
Re: List insertion cost
On 2009-07-21 14:21, Lucas P Melo wrote: Hello, I would like to know how much it costs to insert an element into a list using this operation: a[2:2] = [ 1 ] i. e, what is the complexity of the operation above (given that len(a) = n)? O(n). Python lists are contiguous arrays in memory, and everything after the insertion point needs to be moved. Raymond Hettinger has a good talk about the implementation of Python lists and other container objects. http://www.youtube.com/watch?v=hYUsssClE94 http://www.pycon.it/static/stuff/slides/core-python-containers-under-hood.ppt -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: List insertion cost
Robert Kern wrote: O(n). Python lists are contiguous arrays in memory, and everything after the insertion point needs to be moved. Raymond Hettinger has a good talk about the implementation of Python lists and other container objects. http://www.youtube.com/watch?v=hYUsssClE94 http://www.pycon.it/static/stuff/slides/core-python-containers-under-hood.ppt Thanks. :) -- http://mail.python.org/mailman/listinfo/python-list
Changing the private variables content
Hi. I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have. Maybe some example. A class with private method and private variable: class Secret(object): # def __init__(self): self._number = 1 # def _secret(self): print self._number def showit(self): print Secret number is:\n self._secret() sec = Secret() sec.showit() Secret number is: 1 sec._number 1 sec._number = 2 sec._number 2 sec._number += 3 sec._number 5 As You can see, i made class with private method and private variable inside __init__ constructor. I've changed also the variable value, but outside class. I've got problem with changing some variable value _inside__my_ class, which i'm writing. I've searched over google, some tuts with topics about operations on private variables, but didn't found anything - only how to make them, but no how to assign new objects/override them with new content (and other advanced and helpful options). If someone could help me, it would be great. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 -- http://mail.python.org/mailman/listinfo/python-list
Balanced binary tree implementation
Hello, I would like to use a balanced binary tree implementation (preferably within some API). Any hints about where I could find it? I am looking for something that implements insertion, deletion, search and a special search that returns the lesser element bigger than a given key [1]. A nice possibility would be an extensible API that allows me to inherit its classes and to add operations myself. Thanks in advance. [1] Ex: 1 2 3 4 5 6 are elements of the bbt. If I use this operation given 4 as the parameter, the value returned would be 5. -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
On 21 July, 22:00, davidj411 davidj...@gmail.com wrote: I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 I assume month, day and year are actually being output and that you've removed it from your post. Err, what else do you expect to happen if you're doing this recursively? -- http://mail.python.org/mailman/listinfo/python-list
Re: Changing the private variables content
Ryniek90 wrote: Hi. I'm writing some class, and decided to use inside private method and some private variables. While with method i haven't got any problem's with variables i have. Maybe some example. A class with private method and private variable: class Secret(object): # def __init__(self): self._number = 1 # def _secret(self): print self._number def showit(self): print Secret number is:\n self._secret() sec = Secret() sec.showit() Secret number is: 1 sec._number 1 sec._number = 2 sec._number 2 sec._number += 3 sec._number 5 As You can see, i made class with private method and private variable inside __init__ constructor. I've changed also the variable value, but outside class. I've got problem with changing some variable value _inside__my_ class, which i'm writing. Not sure this is what you are asking, but a method (which is how I interpret _inside__my_ class) changes the value by normal assignment like this: class Secret(object): ... def SetNumber(self,value): self._number = value Is that what you were asking? Gary Herron I've searched over google, some tuts with topics about operations on private variables, but didn't found anything - only how to make them, but no how to assign new objects/override them with new content (and other advanced and helpful options). If someone could help me, it would be great. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
On Jul 21, 5:00 pm, davidj411 davidj...@gmail.com wrote: I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 Your output doesn't match your format string: In [1]: import time In [2]: print time.strftime('%m-%d-%Y %H:%m:%S') 07-21-2009 17:07:16 There's no way to tell why your output times seem to repeat without seeing the code that surrounds your print time.strftime('%m-%d-%Y %H: %m:%S') line. -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
davidj411 davidj...@gmail.com (d) wrote: d I am using a recursive function to print the time and a few other d things on each pass. ( the function calculates size of file that is d being transferred and if not 100 % copied, it waits 20 secs and checks d again). d i would expect the time to be correct anytime it is used: d --code below -- d print time.strftime('%m-%d-%Y %H:%m:%S') d --code above -- d here is an example of what i am seeing: d 16:07:16 d 16:07:36 d 16:07:56 d 16:07:16 d 16:07:36 d 16:07:56 d 16:07:16 d 16:07:36 d 16:07:56 You probably meant: print time.strftime('%m-%d-%Y %H:%M:%S') -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list
doted filenames in import statements
Hi fellows, I'd like to use the dynamic __import__ statement. It works pretty well with non dotted names, but I cannot figure how to make it work with dotted file paths. example: file = /home/dsp/test.py test = __import__(file) works like a charm file = /home/dsp/4.6.0.0/test.py test = __import__(file) = no module name blalalal found. Any suggestion ? I tried multiple escape technics without any success. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
On 21 July, 22:38, Piet van Oostrum p...@cs.uu.nl wrote: davidj411 davidj...@gmail.com (d) wrote: d I am using a recursive function to print the time and a few other d things on each pass. ( the function calculates size of file that is d being transferred and if not 100 % copied, it waits 20 secs and checks d again). d i would expect the time to be correct anytime it is used: d --code below -- d print time.strftime('%m-%d-%Y %H:%m:%S') d --code above -- d here is an example of what i am seeing: d 16:07:16 d 16:07:36 d 16:07:56 d 16:07:16 d 16:07:36 d 16:07:56 d 16:07:16 d 16:07:36 d 16:07:56 You probably meant: print time.strftime('%m-%d-%Y %H:%M:%S') -- Piet van Oostrum p...@cs.uu.nl URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org Good spot! -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
On Jul 21, 5:29 pm, Simon Forman sajmik...@gmail.com wrote: On Jul 21, 5:00 pm, davidj411 davidj...@gmail.com wrote: I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 Your output doesn't match your format string: In [1]: import time In [2]: print time.strftime('%m-%d-%Y %H:%m:%S') 07-21-2009 17:07:16 There's no way to tell why your output times seem to repeat without seeing the code that surrounds your print time.strftime('%m-%d-%Y %H: %m:%S') line. sorry, yes, i did manually filter the output. here is the function: def log_out(msg,servername='std.out'): print msg open(log_dir + '\\' + servername + .log,'a').write(servername + - + time.strftime('%m-%d-%Y %H:%M:%S') + + msg+'\n') on each pass, it should output the newer time (whether recursive or not, right) ? -- http://mail.python.org/mailman/listinfo/python-list
Re: doted filenames in import statements
On Tue, Jul 21, 2009 at 2:42 PM, Jean-Michel Pichavantjeanmic...@sequans.com wrote: Hi fellows, I'd like to use the dynamic __import__ statement. It works pretty well with non dotted names, but I cannot figure how to make it work with dotted file paths. example: file = /home/dsp/test.py test = __import__(file) works like a charm file = /home/dsp/4.6.0.0/test.py test = __import__(file) = no module name blalalal found. Any suggestion ? I tried multiple escape technics without any success. You want the imp.load_module() function: http://docs.python.org/library/imp.html#imp.load_module __import__() only operates on module/package names. I'm not sure how you even got it to work with a filename... Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
davidj411 wrote: On Jul 21, 5:29 pm, Simon Forman sajmik...@gmail.com wrote: On Jul 21, 5:00 pm, davidj411 davidj...@gmail.com wrote: I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 Your output doesn't match your format string: In [1]: import time In [2]: print time.strftime('%m-%d-%Y %H:%m:%S') 07-21-2009 17:07:16 There's no way to tell why your output times seem to repeat without seeing the code that surrounds your print time.strftime('%m-%d-%Y %H: %m:%S') line. sorry, yes, i did manually filter the output. here is the function: def log_out(msg,servername='std.out'): print msg open(log_dir + '\\' + servername + .log,'a').write(servername + - + time.strftime('%m-%d-%Y %H:%M:%S') + + msg+'\n') on each pass, it should output the newer time (whether recursive or not, right) ? Maybe it does, but you were outputting the month (07) instead of the minutes; the seconds were changing. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial and pyQt
On Tuesday 21 July 2009 21:37, Seth wrote: I have used pyserial in the past but this is my first experience with pyQt. I am using the Python xy package for windows current but might move to linux. I have a small device that is outputting a basic text string. I want to be able to read this string(from the comm port) and update a text box and eventually a graph in pyQt. I can't find any documentation or tutorials on how to do this. If anyone can point me in the right direction or give me some tips I would be grateful. It seems that someone has already asked a similar question on Stack Overflow, though perhaps you should start with a simpler solution and look at more advanced ones later: http://stackoverflow.com/questions/771988/pyqt4-and-pyserial One starting point is this list of tutorials on the PyQt and PyKDE Wiki: http://www.diotavelli.net/PyQtWiki/Tutorials Later, when you want to draw graphs, you might find PyQwt useful: http://pyqwt.sourceforge.net/ You may already be aware that there's also a mailing list for PyQt and PyKDE: http://www.riverbankcomputing.com/pipermail/pyqt/ Another way to get answers to questions is to join the #pyqt IRC channel at freenode.net: irc://irc.freenode.net/ David -- http://mail.python.org/mailman/listinfo/python-list
Re: setuptools question.
On Tue, 21 Jul 2009 11:12:01 -0700, Fred C f...@bsdhost.net wrote: I have a python program and when I install this program from the module home directory using setup.py everything works fine. But easy_install fails with the following error, because I am trying to install some start up shell scripts into /etc/init.d The package setup script has attempted to modify files on your system that are not within the EasyInstall build area, and has been aborted. Is there a way to use easy_install to install the start scripts into / etc/init.d. If not, what is the best way to install these scripts. What package is it? what platform ? -- http://mail.python.org/mailman/listinfo/python-list
Re: time.strftime('%m-%d-%Y %H:%m:%S') to log is out of order
On Jul 21, 5:53 pm, davidj411 davidj...@gmail.com wrote: On Jul 21, 5:29 pm, Simon Forman sajmik...@gmail.com wrote: On Jul 21, 5:00 pm, davidj411 davidj...@gmail.com wrote: I am using a recursive function to print the time and a few other things on each pass. ( the function calculates size of file that is being transferred and if not 100 % copied, it waits 20 secs and checks again). i would expect the time to be correct anytime it is used: --code below -- print time.strftime('%m-%d-%Y %H:%m:%S') --code above -- here is an example of what i am seeing: 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 16:07:16 16:07:36 16:07:56 Your output doesn't match your format string: In [1]: import time In [2]: print time.strftime('%m-%d-%Y %H:%m:%S') 07-21-2009 17:07:16 There's no way to tell why your output times seem to repeat without seeing the code that surrounds your print time.strftime('%m-%d-%Y %H: %m:%S') line. sorry, yes, i did manually filter the output. here is the function: def log_out(msg,servername='std.out'): print msg open(log_dir + '\\' + servername + .log,'a').write(servername + - + time.strftime('%m-%d-%Y %H:%M:%S') + + msg+'\n') on each pass, it should output the newer time (whether recursive or not, right) ? Well, as Piet van Oostrum pointed out, your problem in the first code you posted was that you used '%m' rather than '%M' for the minutes. (Good eye Van Oostrum!) But now in this function you seem to have the correct '%M' field. Are you still having the same output after changing that? In any event, here's a rewritten version of that function that's a little cleaner, FWIW. from os.path import join from time import strftime format = '%m-%d-%Y %H:%M:%S' def log_out(msg, servername='std.out'): print msg msg = %s - %s %s\n % (servername, strftime(format), msg) log_file = open(join(log_dir, servername + .log), 'a') try: log_file.write(msg) finally: log_file.close() But why not just use the logging module? -- http://mail.python.org/mailman/listinfo/python-list
Fast reading and unpacking of binary data (struct module)
Hi, I have a Python newbie question about reading data from a binary file. I have an huge binary file from an external program. I want to read and process the data in this file in a reasonable time. It turns out that the reading of the data itself and the processing do not need most of the time. However, when using the read(bytes) method Python returns a string representing the binary information in hex. This string I have to cast/translate into a number (in my case a signed short). For this I am using the method struct.unpack from the struct module. This unpacking part of the program takes by far the most time. Is there a way to speed this up or to do it the unpacking more cleverly than with the struct module? Thanks in advance. With kind regards, Daniel -- http://mail.python.org/mailman/listinfo/python-list
trouble with minidom
Hello I'm trying to read an xml file using minidome. The xml looks like: rootNode project namemyProj/name path/here//path /project /rootNode My code looks like so: from xml.dom.minidom import parse dom = parse(myfile.xml) for node in dom.getElementsByTagName(project'): print('name: %s, path: %s \n') % (node.childNodes[0].nodeValue, node.childNodes[1]) Unfortunately, it returns 'nodeValue as none. I'm trying to read the value out of the node fir example name: myProj. I haven't found much help in the documentation. Can someone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast reading and unpacking of binary data (struct module)
En Tue, 21 Jul 2009 21:00:13 -0300, Daniel Platz mail.to.daniel.pl...@googlemail.com escribió: I have an huge binary file from an external program. I want to read and process the data in this file in a reasonable time. It turns out that the reading of the data itself and the processing do not need most of the time. However, when using the read(bytes) method Python returns a string representing the binary information in hex. This string I have to cast/translate into a number (in my case a signed short). For this I am using the method struct.unpack from the struct module. This unpacking part of the program takes by far the most time. Is there a way to speed this up or to do it the unpacking more cleverly than with the struct module? Try creating a Struct object with your format and use its unpack() method. http://docs.python.org/library/struct.html#struct-objects If your format consists of just integers, probably an array is more efficient: http://docs.python.org/library/array.html#array.array.fromfile -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: tough-to-explain Python
Simon Forman wrote: My understanding (so far) is that you (hope to) /derive/ correct code using formal logic, rather than writing code and then proving its soundness. But to the extent you can rigorously formalise it, all you've done is create Yet Another Programming Language. Which is fine, if you can come up with one that works at a high enough level in some domain that you can see just by looking that the program will do what you want. However, I suspect that you can't improve much on what we've already got without restricting the domain of applicability of the language. Otherwise, you just shift the intellectual bottleneck from writing a correct program to writing correct specifications. In the realm of programming language design, it's been said that you can't eliminate complexity, all you can do is push it around from one place to another. I suspect something similar applies to the difficulty of writing programs. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Mutable Strings - Any libraries that offer this?
Ben Finney wrote: My point was rather meant to imply that subclassing the built-in (immutable) string types was the best way to usefully get all their functionality However, it would be difficult to do that without changing all C code that deals with strings, including that in extension modules. That's because the existing string type stores the characters in the string object itself. A mutable variant would have to contain a pointer to a resizable memory block, and therefore couldn't be used as a drop-in replacement by existing C code that expects a string. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Python
do you have any materials about Python? can you show me the link of Python or some books? thanks a lots! -- Regard! Khanh -- http://mail.python.org/mailman/listinfo/python-list
Re: trouble with minidom
En Tue, 21 Jul 2009 21:08:57 -0300, Ronn Ross ronn.r...@gmail.com escribió: Hello I'm trying to read an xml file using minidome. The xml looks like: rootNode project namemyProj/name path/here//path /project /rootNode My code looks like so: from xml.dom.minidom import parse dom = parse(myfile.xml) for node in dom.getElementsByTagName(project'): print('name: %s, path: %s \n') % (node.childNodes[0].nodeValue, node.childNodes[1]) Unfortunately, it returns 'nodeValue as none. I'm trying to read the value out of the node fir example name: myProj. I haven't found much help in the documentation. Can someone point me in the right direction? Unless you have a specific reason to use the DOM interface (like having a masochistic mind), working with ElementTree usually is a lot easier: py import xml.etree.ElementTree as ET py xml = rootNode ... project ...namemyProj/name ...path/here//path ... /project ... /rootNode py doc = ET.fromstring(xml) py for project in doc.findall('project'): ... for child in project.getchildren(): ... print child.tag, child.text ... name myProj path /here/ -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Shed Skin 0.2, an experimental (restricted) Python-to-C++ compiler
William Dode wrote: I just tested it with a litle game, to find the places of horse on a board 5x5. The result is : cython avec malloc *int 18s Posting benchmark times for Pyrex or Cython is pretty meaningless without showing the exact code that was used, since times can vary enormously depending on how much you C-ify things. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
SMTPlib and SMTPd Performance Issues
Hi, I just wanted mention a few workarounds I've come up with for the Python SMTP modules in regards to performance. Before I started, I was getting about 15MB/s while sending e-mail from smtplib to smptd over a local connection. (i.e. both client/server running on the same machine). After the following changes, I'm seeing around*220+MB/s * (increase of 14x) The source can be found here: http://svn.python.org/view/python/trunk/Lib/smtplib.py?view=markup http://svn.python.org/view/python/trunk/Lib/smtpd.py?view=markup When sending e-mail through *smtpdlib*, the following method is called. def quotedata(data): Quote data for email. Double leading '.', and change Unix newline '\\n', or Mac '\\r' into Internet CRLF end-of-line. return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)) As you can see there are two regular expressions parsing the data. If you know that your message is formatted correctly to start with, then this step is unnecessary. When receiving e-mail through *smtpd*, the SMTPChannel class inherits from * asynchat.async_chat*. The default recv buffer size for asynchat is 4K. This can be too much overhead for high data throughput. The buffer size can be increased with this code: import asynchat asynchat.async_chat.ac_in_buffer_size = 1024*128 asynchat.async_chat.ac_out_buffer_size = 1024*128 The *smtpd.SMTP* class prcoesses data through the *smtpd.SMTPChannel* class. There are a lot of debug statements in the module, like so: print DEBUGSTREAM, 'Data:', repr(line) By default, DEBUGSTREAM is a no-op, but that that doesn't prevent repr(line) from being called. When variable, line, contains a large email (multiple megabytes), this debug step will really kill performance. Secondly, the method *found_terminator* will also perform expensive strings ops on the e-mail. Maybe its not possible to disable this step, in all cases, but for testing performance, you can override the method like so: class QuickSMTPChannel( smtpd.SMTPChannel, object): def found_terminator(self): if (self._SMTPChannel__state == self.COMMAND or self._SMTPChannel__state != self.DATA): super(QuickSMTPChannel,self).found_terminator() else: data = smtpd.EMPTYSTRING.join(self._SMTPChannel__line) self._SMTPChannel__line = [] status = self._SMTPChannel__server.process_message( self._SMTPChannel__peer, self._SMTPChannel__mailfrom, self._SMTPChannel__rcpttos, data) self._SMTPChannel__rcpttos = [] self._SMTPChannel__mailfrom = None self._SMTPChannel__state = self.COMMAND self.set_terminator('\r\n') if not status: self.push('250 Ok') else: self.push(status Thanks, - Casey -- http://mail.python.org/mailman/listinfo/python-list