can't find python2.4 source code
I make program in c++ embedding python2.4 in windows, I need the python24_d.lib to link with the debug version of my program, but i can't find the source code to build python24_d.lib on the internet, I even can't find python24_d.lib/python24_d.dll on the internet. Does the python24 source code released? -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find python2.4 source code
Donnie Leen <[EMAIL PROTECTED]> wrote: >I make program in c++ embedding python2.4 in windows, I need the > python24_d.lib to link with the debug version of my program, but i can't > find the source code to build python24_d.lib on the internet, I even can't > find python24_d.lib/python24_d.dll on the internet. > Does the python24 source code released? http://www.python.org/2.4/ look for "Download the release" and the links to Python-2.4.tgz or Python-2.4.tar.bz2. -- http://mail.python.org/mailman/listinfo/python-list
PyQt on MAC OS X
Hi, I'm trying to get PyQt up and running under Mac OS X 10.2.8, but can't get past configuring sip. I installed fink's qt3-3.2.3-2 and restarted my shells to get qt3's environment variables QTDIR and QMAKESPEC. I downloaded sip-4.1 from http://www.river-bank.demon.co.uk, unpacked it, ran python configure.py and got this error: Error: /sw/share/qt3/mkspecs/darwin-g++/qmake.conf: macro 'QMAKE_LIBDIR/$(TARGET1)' is not defined. Any ideas? Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: New versions breaking extensions, etc.
Jive wrote: Well, ain't that enough to gag a maggot? I was aware that DLL's don't really link dynamically. I was not aware that the crt dll file name was hard-coded into the linker. But I looked on the link line and, sure enough, that particular dll was not listed among the others. It's not hard-coded in the linker, but hard-coded in the import library. So if you link with msvcrt.lib (which might not be the precise name of the import library - I cannot look up the precise name right now), msvcrt.lib will in turn refer to msvcr71.dll. In addition, through #pragma comment(lib, foo.lib), the Microsoft C *header* files force references to import libraries into the object files, so that the import libraries don't even appear on the linker line - instead, the linker gets additional command line options from the object files; use dumpbin to find out what those are. On the plus side, I believe that the name of the import library for the CRT was always the same (msvcrt.lib), so different versions of that file refer to different actual CRTs (msvcrt.dll, msvcrt40.dll, msvcr70.dll, msvcr71.dll). So just replacing your msvcrt.lib file of VC6 with the VC71 one might be enough - but then, perhaps there also where changes to the header files which you need to get. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: why no python setup.py uninstall?
Installing new versions of modules over old versions has often caused me problems. Particularly py3exe recently. Admittedly 'uninstalling' the old version was as simple as deleting the folder from 'site-packages'. Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Brian Beck wrote: Dimitri Tcaciuc wrote: While I'm not absolutely positive, it looks like Python still doesn't have any official mascot or logo. Hence, here's something I came up with yesterday. Its by no means a final version, but rather just a draft to show an idea. Here's a link to png file. http://www.sfu.ca/~dtcaciuc/art/pymascot.png Nice work! I admit it's just too tempting not to design around snake imagery for Python. Here are a couple of images/logos (quite a bit different from a mascot) I've been working on... http://exogen.cwru.edu/python.png http://exogen.cwru.edu/python2.png If anyone can think of a way to break free of the reptile-oriented thought process but maintain clear, symbolic imagery, I'd love to see more suggestions or renditions! Since the word 'Python' would bring -some- sort of snake associations, I thought of combining snake and Monty Python symbolic, like making a snake wind around a giant foot, or adding long mustache and an english hat to a snake or something in that manner, or even put a snake into a holy grail heh. But then again, I'm not sure if there'll be no copyright issues. -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling PIL for Python 2.4
Fuzzyman schrieb: I'll post this to the image-sig as well, but the audience is a bit wider here. Sorry, can't help you on the rest (which seems to be rather MS and compiler specific), but in general: cross-posting is not a good idea. Read any of the many copies of the Netiquette on this topic. In short, submitting a cross-post reads as: you haven't actually thought about your problem but want to bug as many people as possible with it. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Perl
Christos TZOTZIOY Georgiou wrote: Both languages cover all of your requirements. So read as much documentation needed to write some simple programs as examples doing similar tasks to the one you want in *both* languages. Test them that they work. Then forget about your problems. Go to an island. Dream. Relax. Come back without explanations six months later, and if they take you back in the same company, read *both* of your example programs. You'll know then which language to select (I would select the language of the island natives, but that's another story :) That's unfair! That approach leads to Python every time! Oh wait, that was the purpose.. :) -- Timo Virkkala -- http://mail.python.org/mailman/listinfo/python-list
Re: GUIs: wxPython vs. Tkinter (and others)
[EMAIL PROTECTED] wrote: Hi, I had very bad experience with Tkinter when using input servers(for CJK languages like scim, xcin...) on Linux (doesn't work), so you might consider this. Eh? I use (not frequently, I admit...) kinput2 with canna and wnn servers with Tkinter on Linux and it works quite smoothly. Can you describe what happens to you exactly? -- - Eric Brunel - PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Christian Ergh wrote: flag = true for char in data: if 127 < ord(char) < 128: flag = false if flag: try: data = data.encode('latin-1') except: pass A little OT, but (assuming I got your indentation right[1]) this kind of loop is exactly what the else clause of a for-loop is for: for char in data: if 127 < ord(char) < 128: break else: try: data = data.encode('latin-1') except: pass Only saves you one line of code, but you don't have to keep track of a 'flag' variable. Generally, I find that when I want to set a 'flag' variable, I can usually do it with a for/else instead. Steve [1] Messed up indentation happens in a lot of clients if you have tabs in your code. If you can replace tabs with spaces before posting, this usually solves the problem. -- http://mail.python.org/mailman/listinfo/python-list
Re: while 1 vs while True
Dan Bishop wrote: Out of pure curiousity, Why wasn't 'While True' optimized also? Probably has something to do with "True" and "False" not being constants. Yup. Even 'None' only just became a constant in 2.4. I don't know if 'True' and 'False' are in line for similar treatment (there are obvious backwards compatibility issues in doing so). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Compiling PIL for Python 2.4
I'll post this to the image-sig as well, but the audience is a bit wider here. I've just upgraded to Python 2.4. I've installed the free microsoft optimising compiler and hacked distutils to use it - following the instructiosn from http://www.vrplumber.com/programming/mstoolkit/ . It works great and I've built a windows installer for PyCrypto 2.0. I'm attempting to compile PIL for python 2.4. The build instructions for windows say : If you're using Python 2.0 or later, you can use the setup.py script to build the library. The following commands should do the trick: $ python setup.py build $ python setup.py install You may need to tweak the setup.py file somewhat in order to make it find certain external libraries; see comments in the file for details. Right - so you actually need to *get* the zlib and jpeg libraries, which I've done. I've not yet got the right header/include files for Tkinter, but it should work without them (just not build those files). Except it bombs out : C:\compile\Imaging-1.1.4\PIL>cd /D C:\compile\Imaging-1.1.4 C:\compile\Imaging-1.1.4>setup.py build *** Cannot find Tcl/Tk headers and library files. *** To build the Tkinter interface, set the TCLROOT *** variable in the setup.py file. running build running build_py running build_ext building '_imaging' extension C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:libImaging / LIBPATH:jpeg-6b /LIBPATH:zlib /LIBPATH:C:\Python24\libs /LIBPATH:C:\Python24\PCBuild Imaging.lib jpeg.lib zlib.lib kernel32.lib user32.lib gdi32.lib /EXPORT:init_imaging build\temp.win32-2.4\Release\_imaging.obj build\temp.win32 -2.4\Release\decode.obj build\temp.win32-2.4\Release\encode.obj build\temp.win32-2.4\Release\map.obj build\temp.wi n32-2.4\Release\display.obj build\temp.win32-2.4\Release\outline.obj build\temp.win32-2.4\Release\path.obj /OUT:bu ild\lib.win32-2.4\_imaging.pyd /IMPLIB:build\temp.win32-2.4\Release\_imaging.lib LINK : fatal error LNK1181: cannot open input file 'Imaging.lib' error: command '"C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe"' failed with exit status 1181 C:\compile\Imaging-1.1.4> _imaging.obj is being created - but not linked. I can't find an Imaging.lib file anywhere. Anyone got any clues for me ? Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Steven Bethard wrote: > Christian Ergh wrote: >> flag = true >> for char in data: >> if 127 < ord(char) < 128: >> flag = false >> if flag: >> try: >> data = data.encode('latin-1') >> except: >> pass > > A little OT, but (assuming I got your indentation right[1]) this kind of > loop is exactly what the else clause of a for-loop is for: > > for char in data: > if 127 < ord(char) < 128: > break > else: > try: > data = data.encode('latin-1') > except: > pass > > Only saves you one line of code, but you don't have to keep track of a > 'flag' variable. Generally, I find that when I want to set a 'flag' > variable, I can usually do it with a for/else instead. > > Steve > > [1] Messed up indentation happens in a lot of clients if you have tabs > in your code. If you can replace tabs with spaces before posting, this > usually solves the problem. Even more off-topic: >>> for char in data: ... if 127 < ord(char) < 128: ... break ... >>> print char 127.5 :-) Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Martin v. Löwis wrote: Dylan wrote: Things I have tried include encode()/decode() This should work. If you somehow manage to guess the encoding, e.g. guess it as cp1252, then htmlstring.decode("cp1252").encode("us-ascii", "xmlcharrefreplace") will give you a file that contains only ASCII characters, and character references for everything else. Now, how should you guess the encoding? Here is a strategy: 1. use the encoding that was sent through the HTTP header. Be absolutely certain to not ignore this encoding. 2. use the encoding in the XML declaration (if any). 3. use the encoding in the http-equiv meta element (if any) 4. use UTF-8 5. use Latin-1, and check that there are no characters in the range(128,160) 6. use cp1252 7. use Latin-1 In the order from 1 to 6, check whether you manage to decode the input. Notice that in step 5, you will definitely get successful decoding; consider this a failure if you have get any control characters (from range(128, 160)); then try in step 7 latin-1 again. When you find the first encoding that decodes correctly, encode it with ascii and xmlcharrefreplace, and you won't need to worry about the encoding, anymore. Regards, Martin Something like this? Chris import urllib2 url = 'www.someurl.com' f = urllib2.urlopen(url) data = f.read() # if it is not in the pagecode, how do i get the encoding of the page? pageencoding = ??? xmlencoding = 'whatever i parsed out of the file' htmlmetaencoding = 'whatever i parsed out of the metatag' f.close() try: data = data.decode(pageencoding) except: try: data = data.decode(xmlencoding) except: try: data = data.decode(htmlmetaencoding) except: try: data = data.encode('UTF-8') except: flag = true for char in data: if 127 < ord(char) < 128: flag = false if flag: try: data = data.encode('latin-1') except: pass try: data = data.encode('cp1252') except: pass try: data = data.encode('latin-1') except: pass: data = data.encode("ascii", "xmlcharrefreplace") -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
> Since the word 'Python' would bring -some- sort of snake associations, > I > thought of combining snake and Monty Python symbolic, like making a > snake wind around a giant foot, or adding long mustache and an english > hat to a snake or something in that manner, or even put a snake into a > holy grail heh. > > But then again, I'm not sure if there'll be no copyright issues. But surely only you and I and the other Pythonistas will recognize a Norwegian Blue when we see one. Might be hard to get away from the snake, as was noted, its a level or two easier mental association than MP. Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead off to is ide, grinningly wit a char-grin? es not dead! Eric Pederson ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling PIL for Python 2.4
Hmmm... disagree. Not eevryone who has experience of compilation (even compiling PIL) will be on the sig. The sifg is probably the 'right' place - but my experience is that a lot of htem are very low traffic. This is also a topic of general interest to many pythoners. See the number of questions regarding configuring distutils recently. Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling PIL for Python 2.4
Hi ! Fredrik Lundh did what is necessary. PIL for P 2.4 is at : http://effbot.org/downloads/#PIL Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Peter Otten wrote: Steven Bethard wrote: Christian Ergh wrote: flag = true for char in data: if 127 < ord(char) < 128: flag = false if flag: try: data = data.encode('latin-1') except: pass A little OT, but (assuming I got your indentation right[1]) this kind of loop is exactly what the else clause of a for-loop is for: for char in data: if 127 < ord(char) < 128: break else: try: data = data.encode('latin-1') except: pass Only saves you one line of code, but you don't have to keep track of a 'flag' variable. Generally, I find that when I want to set a 'flag' variable, I can usually do it with a for/else instead. Steve [1] Messed up indentation happens in a lot of clients if you have tabs in your code. If you can replace tabs with spaces before posting, this usually solves the problem. Even more off-topic: for char in data: ... if 127 < ord(char) < 128: ... break ... print char 127.5 :-) Peter Well yes, that happens when doing a quick hack and not reviewing it, 128 has to be 160 of course... -- http://mail.python.org/mailman/listinfo/python-list
Re: Renaming __getattribute__ (PEP?)
Henry 'Pi' James wrote: This whole issue seems so obvious and trivial to me that I've in fact expected it to be resolved by itself Obvious - arguable Trivial - I think so too, but probably not in the way you mean The obviousness is arguable because the differences between __getattr__ and __getattribute__ are genuinely subtle and changing the name of the latter won't alter that. A single attribute access may actually pass through both methods at different points in the process. (It could be said that the similarity in names is actually advantageous, as it corresponds to the similarity in function) Python makes it fairly easy to override attribute access, but it can't eliminate the basic complexity of the idea - if you want to override builtin behaviour, it's necessary to understand what the builtin behaviour *is* first. On the triviality aspect, the amount of work involved in changing the name far exceeds any slight aesthetic improvement from a new name. And that's without even getting into the issues of backwards compatibility. I'd prefer to see the developers making speed improvements or adding to the standard library, rather than working on changing the names of special methods. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Once more, indention should be correct now, and the 128 is gone too. So, something like this? Chris import urllib2 url = 'www.someurl.com' f = urllib2.urlopen(url) data = f.read() # if it is not in the pagecode, how do i get the encoding of the page? pageencoding = '???' xmlencoding = 'whatever i parsed out of the file' htmlmetaencoding = 'whatever i parsed out of the metatag' f.close() try: data = data.decode(pageencoding) except: try: data = data.decode(xmlencoding) except: try: data = data.decode(htmlmetaencoding) except: try: data = data.encode('UTF-8') except: flag = true for char in data: if 127 < ord(char) < 160: flag = false if flag: try: data = data.encode('latin-1') except: pass try: data = data.encode('cp1252') except: pass try: data = data.encode('latin-1') except: pass data = data.encode("ascii", "xmlcharrefreplace") -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling PIL for Python 2.4
Blimey - there's a lot of typos in my last post... ugh Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Compiling PIL for Python 2.4
Great - and thanks for the info it was interesting messing around with the compiler but I'm not goign to do it for the heck of it !! Thanks Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
ANN: PyCrypto 2.0 Binary Installer
Because of export restrictions, Andrew is unable to offer prebuilt binary versions of his excellent PyCrypto module. I've built a windows installer for Python 2.4 Actually download it here http://www.voidspace.org.uk/atlantibots/pythonutils.html#crypto Visit PyCrypto Homepage - http://www.amk.ca/python/code/crypto.html I was able to build the binary by installing microsofts free optimising compiler - VC Toolkit - and hacking distutils to use it. I followed the excellent instructions at http://www.vrplumber.com/programming/mstoolkit/ Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Well the most well known Flying Circus snake related sketch is probably the one eyed trouser snake one, which is er-, probably less than a good idea for a logo. The Snake with some sort of Monty Python themeing is probably the best idea, but drawing a snake + large foot/16 ton weight/holy grail/norweigan blue might be a bit tricky when you have to make small sized icons, which is why the current snake is so handy. I guess someone should watch the intro to flying circus, and/or the animations from some of the movies for inspiration. But on that note, how about a python + rose combo? Eric Pederson wrote: Since the word 'Python' would bring -some- sort of snake associations, I thought of combining snake and Monty Python symbolic, like making a snake wind around a giant foot, or adding long mustache and an english hat to a snake or something in that manner, or even put a snake into a holy grail heh. But then again, I'm not sure if there'll be no copyright issues. But surely only you and I and the other Pythonistas will recognize a Norwegian Blue when we see one. Might be hard to get away from the snake, as was noted, its a level or two easier mental association than MP. Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead off to is ide, grinningly wit a char-grin? es not dead! Eric Pederson ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
- snip - def get_encoded(st, encodings): "Returns an encoding that doesn't fail" for encoding in encodings: try: st_encoded = st.decode(encoding) return st_encoded, encoding except UnicodeError: pass -snip- This works fine, but after this you have three possible encodings (or even more, looking at the data in the net you'll see a lot of encodings...)- what we need is just one for all. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find python2.4 source code
I had tried already, the doesn't contain the sourcecode. In python2.3.3, the release pakage contained sourcecode is Python-2.3.3.tar. "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Donnie Leen <[EMAIL PROTECTED]> wrote: > > >I make program in c++ embedding python2.4 in windows, I need the > > python24_d.lib to link with the debug version of my program, but i can't > > find the source code to build python24_d.lib on the internet, I even can't > > find python24_d.lib/python24_d.dll on the internet. > > Does the python24 source code released? > > http://www.python.org/2.4/ > > look for "Download the release" and the links to Python-2.4.tgz or > Python-2.4.tar.bz2. > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 338: Executing modules inside packages with '-m'
Fredrik Lundh wrote: I'd say that for a typical user, $ python -m foo.bar arg is a marginal improvement over $ python -c "import foo.bar" arg This doesn't work. Any code protected by "if __name__ == '__main__':" won't run in this context (since 'foo.bar' is being imported as a module, not run as a script). Even 'python -c "from foo.bar import _main; _main()" arg' isn't quite right, since sys.argv[0] will be wrong (it will say '-c', instead of giving the module's filename). There's also the problem that there is no standard idiom for _main() functions. compared to $ bar arg This is true, but it has its own problems, mainly in the area of namespace conflicts on the packaging side: 1. Namespace conflicts between different Python versions 2. Namespace conflicts between different Python packages 3. Namespace conflicts between Python packages and other programs 4. Additional overhead to create an installed module that is usable as a script a. Add a shebang line for *nix style systems b. Think about how to deal with the previous 3 points c. Update the installer to copy the file to the right place with a good name d. Realise you're screwed on Windows, since you can't control the file associations and the script will always run with the default interpreter. An extended -m, on the other hand deals with all those problems automatically: python -m foo.bar arg # Default interpreter, foo's bar python -m bar.bar arg # Default interpreter, bar's bar python24 -m foo.bar arg # Force Python 2.4, foo's bar python24 -m bar.bar arg # Force Python 2.4, bar's bar bar arg # Unrelated application called bar Points 1, 3 & 4 were the justification for adding the current version of -m to Python 2.4 (obviously, point 2 didn't apply, since the current version doesn't work for modules insides packages). Specifically, it makes it trivial to get hold of the right version of pdb and profile for the interpreter you're working with. For usability, you can hide all of the above behind a menu item or desktop shortcut. However, the major target of the feature is Python developers rather than the end-users of applications built using Python. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt on MAC OS X
> Hi, > > I'm trying to get PyQt up and running under Mac OS X 10.2.8, but > can't get past configuring sip. > > I installed fink's qt3-3.2.3-2 and restarted my shells to get > qt3's environment variables QTDIR and QMAKESPEC. > > I downloaded sip-4.1 from > http://www.river-bank.demon.co.uk, > unpacked it, ran > > python configure.py > > and got this error: > > Error: /sw/share/qt3/mkspecs/darwin-g++/qmake.conf: macro > 'QMAKE_LIBDIR/$(TARGET1)' is not defined. > > > Any ideas? The Fink version of Qt isn't officially supported (the native version is), although there is a user contributed README.Fink (either with SIP or PyQt, can't remember which). Phil -- http://mail.python.org/mailman/listinfo/python-list
urllib2 and Set-Cookie with "302 Moved temporarily"
It seems that urrlib2 default redirection does not allow me to handle Cookies. Service I'm trying seems to use IP switcher and session id's with cookies. After successful login it changes session id (PD-H_SESSION-ID) in 302 Moved temporarily. Urllib2 is so clever that it handles redirection but with wrong cookies. Some hookings? Just own version from source. What is the most lazy way to handle this. Older urllib? Eino - HTTP/1.x 302 Moved Temporarily Set-Cookie: BIGipServerWWW511_HTTP_Pool=1829440010.20480.; expires=Mon, 13-Dec-2004 11:55:59 GMT; path=/ Set-Cookie: PD-H-SESSION-ID=4_w5sBH4QGJ+UqZ0nfWTduFl4yYQj8WToCPG3PO-NPo9sAAslb; Path=/ Set-Cookie: PD-H-SESSION-ID=4_w5sBH4QGJ+UqZ0nfWTduFl4yYQj8WToCPG3PO-NPo9sAAslb; Path=/ Date: Mon, 13 Dec 2004 11:25:59 GMT Message-Id: c365e552-4cf9-11d9-ab36-0a0a0b61aa77 Cache-Control: no-cache Pragma: no-cache Connection: close Location: https://xxx/yyy/xxx/RepresentationApp Content-Type: text/html -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
"houbahop Thank you everyone, but I still not understand why such a comon feature like passing parameters byref that is present in most serious programming languages is not possible in a clean way,here in python. I have the habit to never use globals as far as possible and this involve that my main function is passing some parameters by reference to subs to allow them to modify the vars. Python could be said to pass everything by reference. You are getting caught more by the difference between mutable and immutable types, than by the distinction between 'pass by reference' and 'pass by value' that other languages have (Python actually uses a blend of the two ideas - you get references passed in, but it you use assignment on your arguments, the caller is not affected). Items which are immutable can't be modified *at all* (not just in subroutines). The only thing you can do is take the name that references them and make them point to something else. Items which are mutable can be both modified and made to point to something else. A list is mutable: .>>>L = L1 = [1, 2, 3] .>>>L is L1 True .>>>L += [4] .>>>L is L1 # Modification leaves us referencing the same thing True .>>> print L, L1 [1, 2, 3, 4] [1, 2, 3, 4] .>>> L = [] .>>> L is L1 # Assignment gives a reference to a different thing False .>>> print L, L1 [] [1, 2, 3, 4] A string is not: .>>>S = S1 = "123" .>>>S is S1 True .>>>S += "4" # Even modification gives a reference to a different thing .>>>S is S1 False .>>>print S, S1 "1234", "123" I would be sad to break my structured programming scheme because a lack of feature. As you work with Python, you'll find a lot of the heavy lifting is done with mutable types (particularly list and dict). For these, modification within a function is quite straightforward (just modify the argument directly - e.g. by adding items to a list or dictionary). Immutable types (e.g. strings, numbers, tuples) are generally returned directly from functions, rather than returned as 'output parameters'. The ability to return multiple values easily (via "return a, b, c" & "x, y, z = myfunc()" generally eliminates the need for 'by reference' output parameters as used by C, C++, Java and the like. Regards, Nick. P.S. If you *really*, *really*, *really* want to fake output parameters, just wrap them in a list: def myfunc(outputparam): # Do something outputparam[0] = result x = []# Like declaring x as a pointer to something myfunc(x) # The function fills the 'pointer' x = x[0] # We dereference our 'pointer' There's generally a better way, though (which way that is depends greatly on the context). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0
> duane> I'm looking for a stand alone email program which is not > duane> browser based. I simply want to write, send and receive > duane> email without accessing the internet. Is Python 3.0 that > duane> kind of program? I'd appreciate your response. > I'm a little confused by your request to send and receive email > without accessing the internet, since email generally travels over the > internet. Do you only want to handle email over an internal network? > Or did you mean that you wanted to do this without accessing an > internet browser such as Internet Explorer? I'm guessing the latter. I think he wants something more along the lines of Outlook/Thunderbird... -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Would a parrot on it's back be better? adil On Mon, 13 Dec 2004, Alex Stapleton wrote: > Well the most well known Flying Circus snake related sketch is probably > the one eyed trouser snake one, which is er-, probably less than a good > idea for a logo. The Snake with some sort of Monty Python themeing is > probably the best idea, but drawing a snake + large foot/16 ton > weight/holy grail/norweigan blue might be a bit tricky when you have to > make small sized icons, which is why the current snake is so handy. I > guess someone should watch the intro to flying circus, and/or the > animations from some of the movies for inspiration. > > But on that note, how about a python + rose combo? > > Eric Pederson wrote: > > > > > >>Since the word 'Python' would bring -some- sort of snake associations, > >>I > >>thought of combining snake and Monty Python symbolic, like making a > >>snake wind around a giant foot, or adding long mustache and an english > >>hat to a snake or something in that manner, or even put a snake into a > >>holy grail heh. > >> > >>But then again, I'm not sure if there'll be no copyright issues. > > > > > > > > But surely only you and I and the other Pythonistas will recognize a > > Norwegian Blue when we see one. > > > > > > Might be hard to get away from the snake, as was noted, its a level or two > > easier mental association than MP. > > > > > > Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake > > ead off to is ide, grinningly wit a char-grin? > > > > > > > > es not dead! > > > > > > > > > > Eric Pederson > > ::: > > domainNot="@something.com" > > domainIs=domainNot.replace("s","z") > > ePrefix="".join([chr(ord(x)+1) for x in "do"]) > > mailMeAt=ePrefix+domainIs > > ::: > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL for Windows for Python 2.4
Fuzzyman wrote: Steve Holden wrote: Fuzzyman wrote: If you're determined enough there are instructions here : http://www.vrplumber.com/programming/mstoolkit/ These will get you the Visual Studio 7 tools (free releases of) and tell you how to configure distutils to use it. Hefty downloads though, do not attempt this without broadband ! Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html Wow! I already installed the oolkit Compiler, and now it seems I need to install 646MB of SDK. Make that "you have to be *really, really* determined". Think I might wait a bit longer. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 Hello Steve, I've just completed following the instructions at http://www.vrplumber.com/programming/mstoolkit/ It's really not too bad. The download is 400meg - which unpacks to about a 650meg isntall... but is you're hard drive that full ? Once done it works fine No, it's not that my hard drive is full (I have 22 GB spare on the current 60BG drive, and can add another 60 GB if I need (though that would be another 1lb to have to lug around :-). It's the unreliability of the download process. I have now tried the installation four times, and each time it's stalled during the download of a component. Maybe it's just the times I've been trying, but it's driving me nuts. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: thread/queue bug
Op 2004-12-12, Tim Peters schreef <[EMAIL PROTECTED]>: > > I think you'd have to ask Brett (who did most of the work on > dummy_thread and dummy_threading). It doesn't really matter, though: > it's a general truth that starting a thread as a side effect of > importing is a recipe for deadlock, and hacking specific methods and > functions to avoid imports just moves the problem around. It's not a > goal that anything in the standard Python library cater to bad thread > practice here (the bad thread practice being, again, starting a thread > as a side effect of importing). I don't see why starting a thread as a side effect of importing is bad thread practice. Sure python doesn't cater for it, but IMO that seems to be python failing. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
re: usage of __import__ across two files
Thanks Diez, Obvious when you put it that way... -- http://mail.python.org/mailman/listinfo/python-list
Why are tuples immutable?
Yo. Why can't we __setitem__ for tuples? The way I see it is that if we enable __setitem__ for tuples there doesn't seem to be any performance penalty if the users don't use it (aka, python performance independent of tuple mutability). On the other hand, right now we have to use a list if we want to __setitem__ on a sequence. If we could use tuples in the cases where we want to modify items but not modify the length of the sequence, programs could be considerably faster. Yes? Enlighten me. G. -- http://mail.python.org/mailman/listinfo/python-list
Another RegEx Question...
Hello NG, I'm quite new to Python and I don't know if this is a FAQ (I can't find it) or an obvious question. I'm using the RE module in python, and I would like to be able to contruct something like the Window$ "Find Files Or Folders" engine. As the Window$ users know, you can filter the file names using the character "*", as: myfilen* (Will find a file named myfilenames) *yf*nam*(Will find a file named myfilenames) I have tried something like: import re mystring = "*yf*nam*" mystring.replace("*","\w+") php = re.compile(mystring + "\w+") But it does not work... Is there a way to let the user of my application use the "*" character and to do a Regular Expression search inside a Python code? Thank you for every suggestion. Andrea. -- Message for the recipient only, if received in error, please notify the sender and read http://www.eni.it/disclaimer/ -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find python2.4 source code
Donnie Leen wrote: I had tried already, the doesn't contain the sourcecode. In python2.3.3, the release pakage contained sourcecode is Python-2.3.3.tar. Rhubarb. All you had to do was follow Fredrik's instructions. Since they didn't appear to be explicit enough for you, search in the page he names for the string """All others should download either Python-2.4.tgz or Python-2.4.tar.bz2, the source archive.""". The filenames are links to two different versions of the source. regards Steve "Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Donnie Leen <[EMAIL PROTECTED]> wrote: I make program in c++ embedding python2.4 in windows, I need the python24_d.lib to link with the debug version of my program, but i can't find the source code to build python24_d.lib on the internet, I even can't find python24_d.lib/python24_d.dll on the internet. Does the python24 source code released? http://www.python.org/2.4/ look for "Download the release" and the links to Python-2.4.tgz or Python-2.4.tar.bz2. -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
How can i send 8-bit data or binary data with pyserial?
hi, I want to transfer 0 bit and 1 bit in order with pyserial.But pyserial only send string data. Can anyone help me? Sorry about my english.. _ Depolama alani sikintisindan kurtulun - hemen Hotmail'e üye olun! http://odeme.hotmail.com.tr -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Luis M. Gonzalez wrote: Hey Dimitri, I completely agree with you in that Python needs once for all a cool logo. I like your design very much, but I have a few thoughts about it: 1) I think that Python's logo should reflect its power. Vorpal Bunny. Now, *that's* power. If we use a mascot as its image, we would be giving the wrong idea: that Python is a "toy" language, instead of a very good alternative to other mainstream languages. 2) We should also bear in mind Guido's oppinion about using a snake for identifying Python. I've been googling for this today. So, what exactly is Guido's opinion on snake logos? 3) And finally, we should consider it very seriously. Image is not everything, but it is very important for "marketing" a product. I'm sure that if Java didn't have a cool name and a cool logo, it wouldn't have been that succesfull. I don't mean to sound like I'm rejecting your idea. I really like it alot, and it is an excellent mascot. It's just that I wouldn't use a mascot... I'd rather use a more "killer" image. There's not much more of a "killer" than a Vorpal Bunny. Those things are vicious. Something that reflects power and excellence. I see some similarities between Vorpal Bunnies and Python (the language): - Pleasing to the eye - Deceptively powerful - Gets the job done - and then some What do you think? Vorpal Bunny. Because every other logo lacks the power of a rodential killer. 0.5-wink-ly y'rs, Jeremy Jones -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
The problem with parrots is that Perl 6's engine is called Parrot. Although I suppose the image of a dead Parrot/snake eating a parrot etc could be a "good" one in some peoples minds. But i'm not sure Perl people are really the sort that you wan't to make enemies of, they are deadly with custard pies. It's a bit immature to insult another language like that anyway, not thats the idea you where going for of course. Adil Hasan wrote: Would a parrot on it's back be better? adil On Mon, 13 Dec 2004, Alex Stapleton wrote: Well the most well known Flying Circus snake related sketch is probably the one eyed trouser snake one, which is er-, probably less than a good idea for a logo. The Snake with some sort of Monty Python themeing is probably the best idea, but drawing a snake + large foot/16 ton weight/holy grail/norweigan blue might be a bit tricky when you have to make small sized icons, which is why the current snake is so handy. I guess someone should watch the intro to flying circus, and/or the animations from some of the movies for inspiration. But on that note, how about a python + rose combo? Eric Pederson wrote: Since the word 'Python' would bring -some- sort of snake associations, I thought of combining snake and Monty Python symbolic, like making a snake wind around a giant foot, or adding long mustache and an english hat to a snake or something in that manner, or even put a snake into a holy grail heh. But then again, I'm not sure if there'll be no copyright issues. But surely only you and I and the other Pythonistas will recognize a Norwegian Blue when we see one. Might be hard to get away from the snake, as was noted, its a level or two easier mental association than MP. Logo? Maybe a Norweigian Blue on is back, one fut in e air, wit a snake ead off to is ide, grinningly wit a char-grin? es not dead! Eric Pederson ::: domainNot="@something.com" domainIs=domainNot.replace("s","z") ePrefix="".join([chr(ord(x)+1) for x in "do"]) mailMeAt=ePrefix+domainIs ::: -- http://mail.python.org/mailman/listinfo/python-list
Re: How can i send 8-bit data or binary data with pyserial?
Hi ! 1 byte is 8 bits. If you want to manage bits, one by one, you can rewrite a protocol, and replace pyserial. Have a good day -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list
(no subject)
Some addresses were rejected by the MDA fetchmail forwards to. Reporting-MTA: dns; localhost Final-Recipient: rfc822; [EMAIL PROTECTED] Last-Attempt-Date: Mon, 13 Dec 2004 18:41:26 +0530 (IST) Action: failed Status: 3.0.0 Diagnostic-Code: [EMAIL PROTECTED]: 550 <[EMAIL PROTECTED]>... User unknown Delivered-To: alumnux-alumnux:[EMAIL PROTECTED] X-Envelope-To: [EMAIL PROTECTED] Received: (qmail 85964 invoked from network); 9 Dec 2004 09:02:23 - Received: from ppp124-190.pppcal.vsnl.net.in (HELO alumnux.com) (203.197.124.190) by sowilu.pair.com with SMTP; 9 Dec 2004 09:02:23 - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Mail Delivery (failure [EMAIL PROTECTED]) Date: Thu, 9 Dec 2004 14:30:34 +0530 MIME-Version: 1.0 Content-Type: multipart/related; type="multipart/alternative"; boundary="=_NextPart_000_001B_01C0CA80.6B015D10" X-Priority: 3 X-MSMail-Priority: Normal X-Spam-Filtered: 0631cd96faabc64bd1deb3fa09f65716 X-Spam-Status: No, hits=1.8 required=4.0 tests=MISSING_MIMEOLE,MIME_MISSING_BOUNDARY,BAYES_00,HTML_MESSAGE,NO_REAL_NAME,PRIORITY_NO_NAME,MIME_SUSPECT_NAME,HTML_RELAYING_FRAME X-Spam-Flag: NO X-Spam-Level: * Status: O -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL for Windows for Python 2.4
That's odd - it worked fully *both* times I've done it. I did the *full* doenload though and downloaded the 13 CAB files individually and did a local install. Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
jfj wrote: Yo. Why can't we __setitem__ for tuples? The way I see it is that if we enable __setitem__ for tuples there doesn't seem to be any performance penalty if the users don't use it (aka, python performance independent of tuple mutability). On the other hand, right now we have to use a list if we want to __setitem__ on a sequence. If we could use tuples in the cases where we want to modify items but not modify the length of the sequence, programs could be considerably faster. Yes? Enlighten me. G. Well, the best answer may be "tuples are immutable because otherwise there wouldn't be an immutable sequence type". There have been many discussions on this topic (not that I'm blaming you for being unaware of them), and normally when someone raises this topic there's a flurry of nbew justifications for the existing behavior. The bottom line seems to be that Guido wanted something that corresponds to a mathematical tuple, which is an ordered collection of items of (potentially) different types. Of course there's nothing much to stop you using lists instead of tuples, except the rare piece of code that insists on one or the other. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: Tibia 0.1 DOM-based website editor
The example that Robert posted is protected with http BASIC authentication (judging by the popup anyway). Part of the Jalopy toolkit is `Login Tools` that implements a CGI Login framework that can be plugged into any CGI with the addition of as little as 2 lines of code. It includes optional user sign up, user accoutn editing and account administration. This is due for it's first public release into the wild any day now. (All done, docs done, just needs me to finish the Jalopy docs). You can see it in action at the Jalopy demo. (Which doesn't really address your question to RObert I guess - sorry - didn't think it was too OT) Regards, Fuzzy http://www.voidspace.org.uk/atlantibots/pythonutils.html -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL for Windows for Python 2.4
Fuzzyman wrote: That's odd - it worked fully *both* times I've done it. I did the *full* doenload though and downloaded the 13 CAB files individually and did a local install. I made the mistake of trying to use the Microsoft installer, which is frankly a load of crap. As I write it's now canceling a fifth installation attempt, as it have been for the last twenty minutes. Bah. regards Steve -- http://www.holdenweb.com http://pydish.holdenweb.com Holden Web LLC +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: How can i send 8-bit data or binary data with pyserial?
"ouz as" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I want to transfer 0 bit and 1 bit in order with pyserial.But pyserial only > send string data. string _is_ the type one would normally use in Python for 8-bit encoded data. If you are a Unicode purist, that's perhaps all you would use it for. If you have a list [11, 22, 33] of bytes to send, you can write: buffer = [chr(i) for i in [11, 22, 33]] Or possibly, use the struct or array module. Either way, the problem you have to solve is converting the format you have to/from an appropriate string. We lack the detail to suggest the best solution to that. -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find python2.4 source code
Donnie Leen wrote: I make program in c++ embedding python2.4 in windows, I need the python24_d.lib to link with the debug version of my program, but i can't find the source code to build python24_d.lib on the internet, I even can't find python24_d.lib/python24_d.dll on the internet. Does the python24 source code released? http://sourceforge.net/projects/python/ Which is linked from www.python.org However, as Fredrik said, the source tarballs are available on the release page for 2.4 (and yes, they do contain the source code). Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: How can i send 8-bit data or binary data with pyserial?
> I want to transfer 0 bit and 1 bit in order with pyserial.But pyserial > only send string data. Convert your data to numbers and use module struct to create strings out of it. Apart from that: You can only send chunks of bits as configured in your serial settings - e.g. 8N1 means that you will have to send 8 Bits in a row. I personally never used anything else, but it might be possible to alter that setting to lets say 7N1 or even lower numeber - but I doubt that this will work down to 1N1. If you give us more details on your actual problem, we migh be able to give better answers. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Dylan wrote: Here's what I'm trying to do: - scrape some html content from various sources The issue I'm running to: - some of the sources have incorrectly encoded characters... for example, cp1252 curly quotes that were likely the result of the author copying and pasting content from Word Finally: For me this works, all inside my own class, and the module has a logger, for reuse you would need to fix this stuff... Im am updating a postgreSQL Database, in case someone wonders about the __setattr__, and my class inherits from SQLObject. def doDecode(self, st): "Returns an encoding that doesn't fail" for encoding in encodings: try: stEncoded = st.decode(encoding) return stEncoded except UnicodeError: pass def setAttribute(self, name, data): import HTMLFilter data = self.doDecode(data) try: data = data.encode('ascii', "xmlcharrefreplace") except: log.warn('new method did not fit') try: if '' in data: data = HTMLFilter.HTMLDecode(data) except UnicodeDecodeError: log.debug('HTML decoding failed!!!') try: data = data.encode('utf-8') except: log.warn('new utf 8 method did not fit') try: self.__setattr__(name, data) except: log.debug('1. try failed: ') log.warning(type(data)) log.debug(data) log.warning('Some unicode error while updating') -- http://mail.python.org/mailman/listinfo/python-list
Re: character encoding conversion
Forgot a part... You need the encoding list: encodings = [ 'utf-8', 'latin-1', 'ascii', 'cp1252', ] Christian Ergh wrote: Dylan wrote: Here's what I'm trying to do: - scrape some html content from various sources The issue I'm running to: - some of the sources have incorrectly encoded characters... for example, cp1252 curly quotes that were likely the result of the author copying and pasting content from Word Finally: For me this works, all inside my own class, and the module has a logger, for reuse you would need to fix this stuff... Im am updating a postgreSQL Database, in case someone wonders about the __setattr__, and my class inherits from SQLObject. def doDecode(self, st): "Returns an encoding that doesn't fail" for encoding in encodings: try: stEncoded = st.decode(encoding) return stEncoded except UnicodeError: pass def setAttribute(self, name, data): import HTMLFilter data = self.doDecode(data) try: data = data.encode('ascii', "xmlcharrefreplace") except: log.warn('new method did not fit') try: if '' in data: data = HTMLFilter.HTMLDecode(data) except UnicodeDecodeError: log.debug('HTML decoding failed!!!') try: data = data.encode('utf-8') except: log.warn('new utf 8 method did not fit') try: self.__setattr__(name, data) except: log.debug('1. try failed: ') log.warning(type(data)) log.debug(data) log.warning('Some unicode error while updating') -- http://mail.python.org/mailman/listinfo/python-list
Re: predict directory write permission under windows?
On Mon, 13 Dec 2004 22:14:03 +0800, rumours say that Qiangning Hong <[EMAIL PROTECTED]> might have written: >I want to know if I can write files into a directory before I actually >perferm the write behavor. I found os.access(path, os.W_OK) but it uses >real uid/gid to check instead of euid/egid so it doesn't fit my problem. I didn't even know that the notion of effective uid/gid existed on windows. Unless that's a "service" from the Run as a different user service, but I wouldn't know. >I don't know how to get euid/egid under windows so I cannot use the mode >infomation returned by os.stat(). >Anybody give me a hint? I won't be very helpful, but Python is mostly built around the philosophy of asking forgiveness instead of permission (the opposite of "look before you leap", which is what you want). There are other typical arguments (what if permissions change between your check and the actual write? what if the directory disappears before writing? etc) which you might think they do not apply to you, but they most probably do. In case you want that to update some form of UI where the user should know in advance, well, create a dummy file in the directory (and instantly delete it) and report success or failure. However, if you insist on knowing something that could be false, pywin32 might offer more functions to check for permissions. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
save an opengl canvas (wxPython)
Hi, I've a drawing made in an OpenGL canvas. I want to save it to a file (preferibly PostScript format). Somebody knows how to do it? TIA Zunbeltz -- Zunbeltz Izaola Azkona| wmbizazz at lg dot ehu dotes Materia Kondentsatuaren Fisika Saila | Zientzia eta Teknologia Fakultatea| Phone: 34946015326 Euskal Herriko Unibertsitatea | PK 644| Fax: 34 944648500 48080 Bilbo (SPAIN) | -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3.0
On Sun, 12 Dec 2004 21:44:02 -0600, rumours say that John Hunter <[EMAIL PROTECTED]> might have written: >I'm a little confused by your request to send and receive email >without accessing the internet, since email generally travels over the >internet. Do you only want to handle email over an internal network? >Or did you mean that you wanted to do this without accessing an >internet browser such as Internet Explorer? I'm guessing the latter. I guess he doesn't want the email *originating* application to access the internet; rather to use some local MAPI object-model which then takes care to forward messages over the local network or whatever the setup is. -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: predict directory write permission under windows?
My method isn't elegant, but I use tempfile to create a tempfile in the directory (inside a try block). If it works, closing the file makes it go away. Larry Bates Syscon, Inc. Qiangning Hong wrote: I want to know if I can write files into a directory before I actually perferm the write behavor. I found os.access(path, os.W_OK) but it uses real uid/gid to check instead of euid/egid so it doesn't fit my problem. I don't know how to get euid/egid under windows so I cannot use the mode infomation returned by os.stat(). Anybody give me a hint? -- http://mail.python.org/mailman/listinfo/python-list
Re: thread/queue bug
[Antoon Pardon] > I don't see why starting a thread as a side effect of importing is > bad thread practice. Sure python doesn't cater for it, but IMO > that seems to be python failing. Obviously, it's bad practice in Python because it can lead to deadlocks in Python. It's nearly tautological. Import is an executable statement in Python, not, e.g., as in many other languages, a declaration directed at the system linker. With that power comes opportunities to shoot yourself, although they're generally easy to avoid. Come up with a practical design that doesn't have this limitation, and then perhaps your characterization of the current design as "a failing" would be both credible and constructive. Apart from that, ya, I do think it would *uisually* be poor practice to start a thread as a side effect of importing anyway. It's too mysterious, and IME has caused trouble even when it didn't lead to deadlocks. The fundamental purpose of import in Python is to add useful names to the importer's namespace, and users of a module generally think of it as doing no more than that. Note that the OP's example had a module that, upon the first attempt to import it, ran an infinite loop (even if it hadn't deadlocked), and it's clearly severe abuse of import's purpose.to write a module M such that "import M" *never* returns. Indeed, that's the other half of how deadlock occurs: not only that the imported module spawn a thread as a side effect of importing, but also that the imported module refuse to allow the import to complete. The current design actually supports spawning all the threads you like as a side effect of importing, provided you ensure also that the import ompletes. The easiest way to avoid trouble remains not to spawn threads as a side effect of importing to begin with, although a programmer determined to demonstrate their bad taste can easily enough make it work. -- http://mail.python.org/mailman/listinfo/python-list
Re: A problem with list
<[EMAIL PROTECTED]> wrote: >but when I have Mylist in a file and I read it from the file it does >not work as I expect. ># >import string >ff=open('C:\\Robotp\\MyFile.txt','r') # read MyList from a file >MyList=ff.read() >for i in MyList: >print i >### >I will get >[ >' >a >b >c >' >, >' >d >e >f >' >] > >where my MyFile.txt looks like this: >['abc','def'] The problem is that read() just reads in characters of text and stores them in a string. It doesn't *execute* that text as if it were a program. You want to do one of two things. The first, which requires no changes to your file, would be to eval the text you read. For example: >>> s = "['foo', 'bar']" >>> s "['foo', 'bar']" >>> type (s) s is a string containing the printed representation of a list. You turn that into a real list by passing the string to eval() >>> l = eval (s) >>> l ['foo', 'bar'] >>> type (l) Alternatively (and probably the direction you want to be looking), is to alter your file a little and import it. Make your file look like: x = ['abc', 'def'] Assuming the filename is "foo.py", you can do "import foo" and your file will be read AND EXECUTED, and a module will be created with the same name as the basename of the file. The variable x will be a variable inside that module: >>> import foo >>> foo.x ['abc', 'def'] -- http://mail.python.org/mailman/listinfo/python-list
RE: A problem with list
Title: RE: A problem with list [EMAIL PROTECTED] #- where my MyFile.txt looks like this: #- ['abc','def'] The issue is that in the file you don't have a list, you have text, and there is the difference in the behaviour. >>> l = ['abc','def'] >>> for x in l: print x abc def >>> s = "['abc','def']" >>> for x in s: print x [ ' a b c ' , ' d e f ' ] >>> . Facundo -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
I thought there was probably already an official mascot. There's a little green snake with his tongue hanging out on the left of the URL when you visit www.python.org. I see it in my Safari browser on Mac OS X and in Firefox, but not in Internet Exploder. I thought that I had seen a large picture somewhere, but can't find it now. I don't know if he has an official name, but I've been calling him Monty. Monty, the Python; not to be confused with Monty Python of course ;) Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: A problem with list
[EMAIL PROTECTED] wrote: The following code ## import string MyList=['abc','def'] for i in MyList: print i ### works as I expect that is I get abc def but when I have Mylist in a file and I read it from the file it does not work as I expect. # import string ff=open('C:\\Robotp\\MyFile.txt','r') # read MyList from a file MyList=ff.read() for i in MyList: print i ### I will get [ ' a b c ' , ' d e f ' ] where my MyFile.txt looks like this: ['abc','def'] Where is a problem? Thanks for help Lad That's quite simple. Your file contain a string, not a list You must use eval(your_list_as_string). >>> f = open('/tmp/list') >>> f.seek(0) >>> s = f.read() >>> s "['adc','def']\n" >>> l = eval(s) >>> l ['adc', 'def'] >>> for i in l: ... print i ... adc def gawel -- http://mail.python.org/mailman/listinfo/python-list
RE: uptime for Win XP?
[Peter Hansen] | | Richie Hindle wrote: | > [Greg] | > | import win32api | print "Uptime:", win32api.GetTickCount(), "Milliseconds" | > | > Note that in the unlikely event of your Windows machine being up for | > longer than 2^32 ms (about 49 days), GetTickCount() will | wrap back to | > zero. | | The real solution, in spite of the dozen alternatives we've | now produced, seems to be to use the win32pdh library | to access the "System"-> "System Up Time" value. To add my twopence-ha'penny worth in, the recommended WMI technique is (apparently) to use the Win32_OperatingSystem.LastBootUpTime value: import wmi for i in wmi.WMI ().Win32_OperatingSystem (): print i.LastBootUpTime The time format is 20041202112313 with some -- apparently unused -- sub-seconds, so you'd have to faff about a bit with the numbers, but it is at least usable. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are tuples immutable?
"jfj" wrote: > Why can't we __setitem__ for tuples? http://www.python.org/doc/faq/general.html#why-are-there-separate-tuple-and-list-data-types > The way I see it is that if we enable __setitem__ for tuples there > doesn't seem to be any performance penalty if the users don't use it > (aka, python performance independent of tuple mutability). how would you implement a dictionary where the keys could change, without any performance penalty compared to the current implementation? > On the other hand, right now we have to use a list if we want to > __setitem__ on a sequence. If we could use tuples in the cases where > we want to modify items but not modify the length of the sequence, > programs could be considerably faster. really? in what way are tuples faster than lists? have you noticed that "a[i]" is actually faster if "a" is a list? (especially in 2.2 and earlier). -- http://mail.python.org/mailman/listinfo/python-list
Performance (pystone) of python 2.4 lower then python 2.3 ???
Hi, Just installed Python 2.4 on a machine (RH8.0 Linux) that also has python 2.3 and python 2.2 installed. The latter came with the linux distribution, the other are compiled from source tarballs. Comparing them gives the following unexpected result: [EMAIL PROTECTED] test]$ /usr/bin/python pystone.py Pystone(1.1) time for 5 passes = 1.86 This machine benchmarks at 26881.7 pystones/second [EMAIL PROTECTED] test]$ /usr/local/bin/python2.3 pystone.py Pystone(1.1) time for 5 passes = 1.22 This machine benchmarks at 40983.6 pystones/second This is ok, a 52% speed increase, but: [EMAIL PROTECTED] test]$ /usr/local/bin/python2.4 pystone.py Pystone(1.1) time for 5 passes = 1.31 This machine benchmarks at 38167.9 pystones/second A 7% speed DECREASE??? According to the documentation it should be a 5% increase? The machine is a 3.0 GHz Xeon box. Both python 2.3 and 2.4 where configure without any options. Anyone who understands what is going on? Regards, Lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for "syntax error": ++i, --i
Hmm, i never liked the i++ syntax, because there is a value asignment behind it and it does not show - except the case you are already used to it. >>> i = 1 >>> i +=1 >>> i 2 I like this one better, because you see the assignment at once, it is easy to read and inuitive usability is given - in my opinion. Chris Petr Prikryl wrote: Hi, Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". Current situation: try... (Python 2.4 (#60, ...)) i = 1 i 1 i++ File "", line 1 i++ ^ SyntaxError: invalid syntax ++i 1 --i 1 Reason for how ++i and --i behaves in Python is that it is probably treated as (-(-i)) and (+(+i)) respectively. Rationale: My guess is that many Python users do use other languages at the same time. The C-family languages do use the prefix increment and decrement operators. When used in Python no warning appears -- the code simply does not work as expected. In the same time, there is probably no reason to use the increment and decrement prefix operators. On the other hand, the newcommer or the programmer that "types ++i automatically because of brain synapses say he/she should..." is not warned until something does not work. Con: The situation must be recognized by the parser (i.e. someone have to implement it). Pro: No runtime overhead except of the detection of the situation. As Python is a good candidate to be used as the language for teaching, the "syntax error" would be the pedagogical plus. Personal experience: Many things in Python work intuitively. My C++ experience "forced me" to use ++i as described above. I use iteration more these days and I know about the ++i problem invisibility in Python. But I had to learn by mistake. The ++i behaviour is not intuitive for me. Your opinion? -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt on MAC OS X
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've assembled a binary installer for the native version of PyQt. See http://www.wordtech-software.com/pyqt-mac.html I built it on Panther. Not sure if it will work on Jaguar, but you're welcome to give it a try. Michael McGarry wrote: | Hi, | | I'm trying to get PyQt up and running under Mac OS X 10.2.8, but | can't get past configuring sip. | | I installed fink's qt3-3.2.3-2 and restarted my shells to get | qt3's environment variables QTDIR and QMAKESPEC. | | I downloaded sip-4.1 from | http://www.river-bank.demon.co.uk, | unpacked it, ran | | python configure.py | | and got this error: | | Error: /sw/share/qt3/mkspecs/darwin-g++/qmake.conf: macro | 'QMAKE_LIBDIR/$(TARGET1)' is not defined. | | | Any ideas? | | Michael - -- Cheers, Kevin Walzer, PhD WordTech Software--Open Source Applications and Packages for OS X http://www.wordtech-software.com http://www.smallbizmac.com http://www.kevin-walzer.com mailto:[EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBvb9CJmdQs+6YVcoRAsv2AJ4rkwZ2kO8kPcBKoZ5h1F8vEof+lwCeNO8n rK8yurwPQaJFH8yK6PlbOtg= =0LQg -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 338: Executing modules inside packages with '-m'
Nick Coghlan wrote: >> $ python -c "import foo.bar" arg > > This doesn't work. Any code protected by "if __name__ == '__main__':" won't > run in this context > (since 'foo.bar' is being imported as a module, not run as a script). I appreciate that you're taking the time to teach me about Python, but I can assure you that it's not really needed. as for the rest of your arguments, I have to assume that you were joking. (or that you have no experience whatsoever of distribution of Python programs in Unix and Windows environments). -- http://mail.python.org/mailman/listinfo/python-list
anybody know how to use python to communicate with UART?
I want to use python to communicate with UART port in my PC, how can I achieve this? any modules need to be installed? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Another RegEx Question...
Hello Andrea, > I'm quite new to Python and I don't know if this is a FAQ (I > can't find it) or an obvious question. I'm using the RE module > in python, and I would like to be able to contruct something > like the Window$ "Find Files Or Folders" engine. As the Window$ > users know, you can filter the file names using the character > "*", as: [...] You're looking for the fnmatch module. > import re > mystring = "*yf*nam*" > mystring.replace("*","\w+") > php = re.compile(mystring + "\w+") > > But it does not work... >>> re.compile("*yf*nam*".replace("*", ".*")+"$").match("myfilename") <_sre.SRE_Match object at 0xb7ab3b10> > Is there a way to let the user of my application use the "*" character and > to do a Regular Expression search inside a Python code? >>> import fnmatch >>> fnmatch.fnmatch("myfilename", "*yf*nam*") True >>> fnmatch.translate("*") '.*$' >>> fnmatch.translate("?yf*nam?") '.yf.*nam.$' -- Gustavo Niemeyer http://niemeyer.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Another RegEx Question...
<[EMAIL PROTECTED]> wrote: > I'm quite new to Python and I don't know if this is a FAQ (I can't > find it) or an obvious question. I'm using the RE module in python, and I > would like to be able to contruct something like the Window$ "Find Files Or > Folders" engine. As the Window$ users know, you can filter the file names > using the character "*", as: > > myfilen* (Will find a file named myfilenames) > *yf*nam*(Will find a file named myfilenames) in Unix lingo, that's known as a "glob" pattern. it's not really a regular expression. if you insist on using regular expressions, you can use the fnmatch.translate function to convert from pattern to expression: >>> import fnmatch >>> fnmatch.translate("myfilen*") 'myfilen.*$' >>> fnmatch.translate("*yf*nam*") '.*yf.*nam.*$' or you can use fnmatch.filter() to find matching names in a list: >>> fnmatch.filter(["hello.txt", "bye.txt", "spam.egg"], "*.txt") ['hello.txt', 'bye.txt'] but it's likely that what you really want is the "glob" module, which looks for files matching a given pattern: >>> import glob >>> glob.glob("*.txt") ['key.txt', 'some_document.txt'] more info here: http://docs.python.org/lib/module-glob.html http://docs.python.org/lib/module-fnmatch.html -- http://mail.python.org/mailman/listinfo/python-list
Suggestion for "syntax error": ++i, --i
Hi, Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". Current situation: try... (Python 2.4 (#60, ...)) >>> i = 1 >>> i 1 >>> i++ File "", line 1 i++ ^ SyntaxError: invalid syntax >>> ++i 1 >>> --i 1 >>> Reason for how ++i and --i behaves in Python is that it is probably treated as (-(-i)) and (+(+i)) respectively. Rationale: My guess is that many Python users do use other languages at the same time. The C-family languages do use the prefix increment and decrement operators. When used in Python no warning appears -- the code simply does not work as expected. In the same time, there is probably no reason to use the increment and decrement prefix operators. On the other hand, the newcommer or the programmer that "types ++i automatically because of brain synapses say he/she should..." is not warned until something does not work. Con: The situation must be recognized by the parser (i.e. someone have to implement it). Pro: No runtime overhead except of the detection of the situation. As Python is a good candidate to be used as the language for teaching, the "syntax error" would be the pedagogical plus. Personal experience: Many things in Python work intuitively. My C++ experience "forced me" to use ++i as described above. I use iteration more these days and I know about the ++i problem invisibility in Python. But I had to learn by mistake. The ++i behaviour is not intuitive for me. Your opinion? -- Petr Prikryl (prikrylp at skil dot cz) -- http://mail.python.org/mailman/listinfo/python-list
RE: Tibia 0.1 DOM-based website editor
Richie Hindle wrote: > [Robert] > > Tibia is an in-browser editor for web pages. It allows you > to quickly > > and easily modify the content of your web pages. It allows you to > > directly view, edit, and save files on your webserver. > > Very impressive! I ran into a couple of difficulties but > otherwise it's a great tool. Thanks! We're starting to use it already in-house. > I had to hard-code a username - does it require you to use HTTP > authentication before it will work? If so, it would be good if you > mentioned that in the documentation. Currently, it requires you to use *some* form of authentication. I'm working on a way to get around that for intranet deployers who don't care (but _should_, but hey, it's their loss). If you set up your own site, you also need to have somebody in the Admin group if you want to get any editing done. > It also erased my HTML file when I tried to save my changes. > 8-) I'll try to track that one down if I get the chance. Sorry about that. Tibia switches between three modes: web, upload, and server. The initial release had an ugly pattern where you would open a webpage, switch to server mode (without realizing it) by clicking the "server" flyout button and then hit save--and get nothing saved because you thought you were still in "web mode". I changed the events a bit in recent releases so that doesn't happen anymore; you only change to server mode when you actually load a file from the server. Numerous other buglets fixed over the weekend. Thanks for the feedback, all! Robert Brewer MIS Amor Ministries [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: anybody know how to use python to communicate with UART?
Arnold wrote: I want to use python to communicate with UART port in my PC, how can I achieve this? any modules need to be installed? Thanks pyserial is the usual solution. See http://pyserial.sourceforge.net/ regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: urllib2 and Set-Cookie with "302 Moved temporarily"
"Eino Mäkitalo" <[EMAIL PROTECTED]> wrote: > It seems that urrlib2 default redirection does not allow me to handle > Cookies. Service I'm trying seems to use IP switcher and session id's with > cookies. After > successful login it changes session id (PD-H_SESSION-ID) in 302 Moved > temporarily. and adds a new cookie. > Urllib2 is so clever that it handles redirection but with wrong cookies. with the old cookies, that is. that's stupid. here's an ugly hack for the old urllib that looks for set-cookie headers in redirects, and adds corresponding cookie headers to the new request: import urllib class my_url_opener(urllib.FancyURLopener): def http_error_302(self, *args): headers = args[4] # print headers # <-- uncomment to see the headers cookie = headers.get("set-cookie") if cookie: # this is ugly self.addheaders.append(("Cookie", cookie.split(";")[0])) return urllib.FancyURLopener.http_error_302(self, *args) myurlopen = my_url_opener().open myurlopen("http://www.google.com";) -- http://mail.python.org/mailman/listinfo/python-list
Re: anybody know how to use python to communicate with UART?
Have you tried pyserial ? Regards, Fuzzy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Not that my opinion is worth anything in these matters, but I like the upper-left example at http://exogen.cwru.edu/python.png the best (out of the samples I've seen thus far). I don't like the "gear" shape, and I think adding a coil or circle around the "head" detracts somewhat from the look. I like the clean, sharp lines - seems very metaphorical for the language. My only critique would be that it appears (to me) much like a clan insignia from Battletech. Not that such is a bad thing, mind you. I think people are a little over-anxious regarding copyright infringement. I think a snake around a holy grail would be a fine logo, "the holy grail of programming languages" seems appropriate to me. There's no way that MPFC can have rights over all possible combinations of "Python" and "Holy Grail". Chill out, people. -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
Nick Coghlan wrote: > Python could be said to pass everything by reference. You are getting caught > more by the > difference between mutable and immutable types, than by the distinction > between 'pass by > reference' and 'pass by value' that other languages have (Python actually > uses a blend of the two > ideas - you get references passed in, but it you use assignment on your > arguments, the caller is > not affected). to avoid confusing people who (think they) know exactly what "call by value" and "call by reference" means, the preferred term is "call by object". for some background, see http://mail.python.org/pipermail/python-list/2003-May/163312.html (in earlier literature, Python's model is often called "call by sharing". this model is in fact closer to "call by value" than "call by reference", at least if you stick to the usual definitions) -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
thanks, very usefull answer. > Immutable types (e.g. strings, numbers, tuples) are generally returned > directly from functions, rather than returned as 'output parameters'. The > ability to return multiple values easily (via "return a, b, c" & "x, y, z > = myfunc()" generally eliminates the need for 'by reference' output > parameters as used by C, C++, Java and the like. > P.S. If you *really*, *really*, *really* want to fake output parameters, > just wrap them in a list: return multiple values is ok, I usualy use a function only to return one value, for exemple : value=IsSomething(), returning true, to include that in an if statement : if (isSomething(blabla) ) ... but It's not a problem to change that habit. and as I have read somewhere about python : "Explicit is better than implicit" Dominique. "Nick Coghlan" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] > "houbahop > Thank you everyone, but I still not understand why such a comon feature >> like passing parameters byref that is present in most serious programming >> languages is not possible in a clean way,here in python. >> >> I have the habit to never use globals as far as possible and this involve >> that my main function is passing some parameters by reference to subs to >> allow them to modify the vars. > > Python could be said to pass everything by reference. You are getting > caught more by the difference between mutable and immutable types, than by > the distinction between 'pass by reference' and 'pass by value' that other > languages have (Python actually uses a blend of the two ideas - you get > references passed in, but it you use assignment on your arguments, the > caller is not affected). > > Items which are immutable can't be modified *at all* (not just in > subroutines). The only thing you can do is take the name that references > them and make them point to something else. Items which are mutable can be > both modified and made to point to something else. > > A list is mutable: > > .>>>L = L1 = [1, 2, 3] > .>>>L is L1 > True > .>>>L += [4] > .>>>L is L1 # Modification leaves us referencing the same thing > True > .>>> print L, L1 > [1, 2, 3, 4] [1, 2, 3, 4] > .>>> L = [] > .>>> L is L1 # Assignment gives a reference to a different thing > False > .>>> print L, L1 > [] [1, 2, 3, 4] > > A string is not: > > .>>>S = S1 = "123" > .>>>S is S1 > True > .>>>S += "4" # Even modification gives a reference to a different thing > .>>>S is S1 > False > .>>>print S, S1 > "1234", "123" > >> I would be sad to break my structured programming scheme because a lack >> of feature. > > As you work with Python, you'll find a lot of the heavy lifting is done > with mutable types (particularly list and dict). For these, modification > within a function is quite straightforward (just modify the argument > directly - e.g. by adding items to a list or dictionary). > > Immutable types (e.g. strings, numbers, tuples) are generally returned > directly from functions, rather than returned as 'output parameters'. The > ability to return multiple values easily (via "return a, b, c" & "x, y, z > = myfunc()" generally eliminates the need for 'by reference' output > parameters as used by C, C++, Java and the like. > > Regards, > Nick. > > P.S. If you *really*, *really*, *really* want to fake output parameters, > just wrap them in a list: > > def myfunc(outputparam): > # Do something > outputparam[0] = result > > x = []# Like declaring x as a pointer to something > myfunc(x) # The function fills the 'pointer' > x = x[0] # We dereference our 'pointer' > > There's generally a better way, though (which way that is depends greatly > on the context). > > Cheers, > Nick. > > -- > Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia > --- > http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: from vb6 to Python
Martijn Faassen wrote: > Unfortunately this is currently not near production use, and whether > Microsoft is funding > IronPython development is up in the air: http://www.microsoft.com/careers/search/details.aspx?JobID=6391a54a-bfd7-4384-b18f-cecb0acf86e0 (too bad it's in seattle) -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL for Windows for Python 2.4
Steve Holden wrote: Fuzzyman wrote: That's odd - it worked fully *both* times I've done it. I did the *full* doenload though and downloaded the 13 CAB files individually and did a local install. I made the mistake of trying to use the Microsoft installer, which is frankly a load of crap. As I write it's now canceling a fifth installation attempt, as it have been for the last twenty minutes. Bah. As a further follow-up, I have now managed to install the Egenix base package from source (even building my own Windows installer: neat!), so it looks like I'm there - thanks for encouraging me to persist, I did eventually manage to install by downloading the installer files and running them locally. regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list
Re: jython and concatenation of strings
Jan Gregor wrote: Hello I found that price of += operator on string is too high in jython. For example 5000 such operations took 90 seconds (i generated html copy of table with 1000 rows and 5 columns). Generation of row data into separate string and joining after lead to time 13 seconds !!! What's alternative way to do that ? (similiar parts of my code are terribbly slow and such simple solution as above didn't help). I don't use Jython, but are you not able to do something like: string_list = [] for ... in ...: ... string_list.append(...) ... string = ''.join(string_list) This is the usual Python idiom and is usually faster than the += idiom. Note too that +ing strings in Java also has this problem -- hence StringBuffer or whatever it's called. Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for "syntax error": ++i, --i
Christian Ergh schrieb: Ah, ok, i misunderstood you. Well, to mark it as a syntax error sounds good, and at the Moment I would not know a case where this conflicts with a implementation. target = 'a=' sign = '-' operand = '-2' exec(target+sign+operand) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: make uninstall?
Christopher J. Bottaro wrote: >I installed Python-2.3.4 from source... > configure && make && make install > > Now I want to remove it, but make uninstall doesn't work. How do I > uninstall it? $ python >>> import sys >>> sys.executable '/usr/somewhere/bin/python' >>> sys.prefix '/usr/somewhere' >>> sys.version[:3] '2.3' >>> ^D $ rm /usr/somewhere/bin/python $ rm -rf /usr/somewhere/lib/python2.3 $ rm -rf /usr/somewhere/include/python2.3 -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for "syntax error": ++i, --i
Petr Prikryl wrote: Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". My guess is that the impact of it would be nil. This is python, there are no prefix or postfix operators. That is very easy to remember. Just because one might get burned by it when learning python it cannot become a recurring problem that needs fixing. Istvan. -- http://mail.python.org/mailman/listinfo/python-list
Re: uptime for Win XP?
[Peter Hanson] > The real solution, in spite of the dozen alternatives we've > now produced, seems to be to use the win32pdh library > to access the "System"-> "System Up Time" value. It > claims to return an 8-byte value, which likely doesn't > wrap quite so soon. (And yes, remarkably, with the advent > of Windows XP Pro it is now possible to keep a Windows > machine running for longer than 49 days, even if it's > used as a development machine. Well, for Python development, > anyway. ;-) > > For the life of me, however, I can't figure out how to do it. Here's how. :-) = import win32pdh query = win32pdh.OpenQuery() counter = win32pdh.AddCounter(query, r"\System\System Up Time") win32pdh.CollectQueryData(query) (bizzare_int, val) = win32pdh.GetFormattedCounterValue(counter, \ win32pdh.PDH_FMT_LONG) print "Uptime: %s secs" % (val,) == Writting this script was harder than I initially thought due to a lack of documentation for win32all. And I still don't know what that bizzare_int value stands for (an error/status code?). Well, the registry interface to counters is definitely easier to use, but not available to Python at the moment :-( -- http://mail.python.org/mailman/listinfo/python-list
Re: make uninstall?
So Python installs one file and two dirs (containing files/dirs). If I delete all three of those, it will delete all installed modules as well, right? I mean, when I installed cx_Oracle, it only installed files in $PYTHONDIR/lib/python2.3 and $PYTHONDIR/include/python2.3 right? Thanks for the help. Fredrik Lundh wrote: > Christopher J. Bottaro wrote: > >>I installed Python-2.3.4 from source... >> configure && make && make install >> >> Now I want to remove it, but make uninstall doesn't work. How do I >> uninstall it? > > $ python import sys sys.executable > '/usr/somewhere/bin/python' sys.prefix > '/usr/somewhere' sys.version[:3] > '2.3' ^D > > $ rm /usr/somewhere/bin/python > $ rm -rf /usr/somewhere/lib/python2.3 > $ rm -rf /usr/somewhere/include/python2.3 > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Python Bounties (other than Shuttleworth)?
Hi, We are trying to build a Database of all Open Source Bounties, Call for Tenders (projects), and Grants. Other than the Bounties provided by Mark Shuttleworth is anyone available of any on other sites? Here is a link to our DB: http://www.opensourcexperts.com/bountylist.html Cheers, Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for "syntax error": ++i, --i
On Mon, 13 Dec 2004 16:42:28 +0100, rumours say that "Petr Prikryl" <[EMAIL PROTECTED]> might have written: >Summary: In my opinion, the C-like prefix >increment and decrement operators (++i and --i) >should be marked as "syntax error". [snip of lots of explanations] I am +0 on this. However, I can imagine no *non-obscure* reasons[1] for someone to use ++ and -- as prefixes or postfixes[2], so I think that it's possible to modify the lexer or grammar (ain't sure) to make ++ and -- without any spaces in-between be a valid operator somehow throwing a SyntaxError. I have been bitten by this in the beginning[3], but OTOH it didn't last long. I am on the plus side of 0 just because of a couple of lines of the python Zen: Errors should never pass silently. (although it's only a logical error) In the face of ambiguity, refuse the temptation to guess. my 2e-2 euros [1] including overloaded operators and side-effects [2] "p++ - x" is valid python even if "p++" is not [3] at least Javascript and [ng]awk accept these operators -- TZOTZIOY, I speak England very best. "Be strict when sending and tolerant when receiving." (from RFC1958) I really should keep that in mind when talking with people, actually... -- http://mail.python.org/mailman/listinfo/python-list
Re: Fun with Outlook and MAPI
At the risk of beating a dead horse, but you really should consider using SMTP instead if you are really going to be sending a lot of messages. The problem is that doesn't work in more complicated configurations such as when authentication and/or SSL have to happen, not to mention the issue of configuring servers and ports, that users have already configured in their mail clients. Additionally when you use MAPI, messages that you send also end up in your sent items folder. (I also have not had any issue sending lots of messages using MAPI). Ultimately the utility of vanilla of pure SMTP will depend on customer requirements and how simple the configuration is. That pretty much sums it up. Also, since everything is done over IMAP with Outlook, I don't really have access to an SMTP server. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Read a gzip file from inside a tar file
if I change fileText = fileLike.read() to fileText = fileLike.readLines(). It works for a while before it gets killed of out of memory. These are huge files. My goal is to analyze the content of the gzip file in the tar file without having to un gzip. If that is possible. -- http://mail.python.org/mailman/listinfo/python-list
Re: Qt String Question
Phil Thompson wrote: >> Michael McGarry wrote: >>> Hi, >>> >>> How do I convert from a qt.QString to a Python string? >>> >>> Michael >> Apparently the ascii() method of QString does this. (I answered my own >> question). > > Or use the str() builtin. > > Phil unicode() is even better because QString might contain non-ASCII characters. Detlev -- Detlev Offenbach [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie questions
On Mon, 2004-12-13 at 11:30, houbahop --> > thanks, very usefull answer. > > > > Immutable types (e.g. strings, numbers, tuples) are generally returned > > directly from functions, rather than returned as 'output parameters'. The > > ability to return multiple values easily (via "return a, b, c" & "x, y, z > > = myfunc()" generally eliminates the need for 'by reference' output > > parameters as used by C, C++, Java and the like. > > P.S. If you *really*, *really*, *really* want to fake output parameters, > > just wrap them in a list: > > return multiple values is ok, I usualy use a function only to return one > value, for exemple : value=IsSomething(), returning true, to include that in > an if statement : if (isSomething(blabla) ) ... but It's not a problem to > change that habit. and as I have read somewhere about python : "Explicit is > better than implicit" > > Dominique. I think your interpretation of the the "explicit vs. implicit" quote might be confusing in this case. Certainly: x = 0 def a(): something = 1 somethingelse = 2 global x x = something return somethingelse y = a() print x,y To say "we are explicitly setting X" in a is wrong. We are returning 1 and 2. We return 2 explicitly. We return 1 by side effect. If we want to explicitly return both, then: def a(): something = 1 somethingelse = 2 return something,somethingelse x,y = a() This makes the code clear and easy to understand. Navré je ne pas répondre en français. - Adam DePrince -- http://mail.python.org/mailman/listinfo/python-list
Re: uptime for Win XP?
Andrey Ivanov wrote: [Peter Hanson] For the life of me, however, I can't figure out how to do it. Here's how. :-) = import win32pdh query = win32pdh.OpenQuery() counter = win32pdh.AddCounter(query, r"\System\System Up Time") Argh! A _leading backslash_ !! :-( (Thanks. :-) -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: Fun with Outlook and MAPI
There is actually a workaround. You're using Simple MAPI which has a nice easy interface. The confirmation dialogs are only for Simple MAPI. Using Extended MAPI can work around the problem but its a lot more tricky. See the initial discussion here: http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646 This code has now been included in pywin32 somehow but I can't remember where and its late. Should also be a cookbook entry. Maybe Google can help :-) Okay, here's the results. The good news is that the code sent the mail without any popup's. The bad news is that the sent e-mail stays in the outbox instead of the sent folder. Any suggestions? Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance (pystone) of python 2.4 lower then python 2.3 ???
Lucas Hofman wrote: Anyone who understands what is going on? It is difficult to measure a speedup that might be well within your measurement error. Run the same pystone benchmark repeatedly and see what variation you get. Istvan. -- http://mail.python.org/mailman/listinfo/python-list
looking for blocking on read of a real file (not socket or pipe)
Hello, I'm seeking a read method that will block until new data is available. Is there such a python function that does that? Thanks, Steven Howe -- http://mail.python.org/mailman/listinfo/python-list
Re: how do I "peek" into the next line?
Jeffrey Maitland writes: [EMAIL PROTECTED] writes: Hi, suppose I am reading lines from a file or stdin. I want to just "peek" in to the next line, and if it starts with a special character I want to break out of a for loop, other wise I want to do readline(). Is there a way to do this? for example: while 1: line=stdin.peek_nextline() if not line: break if line[0]=="|": break: else: x=stdin.nextline() # do something with x thanks -- http://mail.python.org/mailman/listinfo/python-list Well what you can do is read the line regardless into a testing variable. here is some sample code (writting this off the topof my head so syntax might be off some) import re file = open("test.txt", 'r') variablestr = '' #this would be your object.. in my example using a string for the file data file.seek(0,2) eof = file.tell() #what this is the position of the end of the file. file.seek(0,0) while file.tell() != eof: testline = file.readline() if re.match("#", testline) == True: break else: variablestr += testline file.close() now if I was concerned with being at the beging of the testline that it read in what you can do is in the if is something like: file.seek((file.tell() - len(testline)), 0) and that will move you back to the beginging of that line which is where the readline from the previous call left you before the "peek". hope that helps some.. Jeff -- http://mail.python.org/mailman/listinfo/python-list I noticed something in my code. re.match("#", testline) == True isn't possible it would be more like. re.match("#", testline) != None -- http://mail.python.org/mailman/listinfo/python-list
Re: Python vs. Perl
Michael McGarry wrote: I intend to use a scripting language for GUI development and front end code for my simulations in C. I want a language that can support SQL, Sockets, File I/O, and shell interaction. In my experience, Python is definitely much more suitable than Perl for the first four areas mentioned in the last sentence. For the last area, I'm not sure, but Python's capabilities in this area are also quite good. For GUI development and front end, Python most likely has better facilities than Perl, but still leaves a lot to be desired (after getting a taste of Delphi 3rd party VCL components, all other RAD environments pale in comparison). -- http://mail.python.org/mailman/listinfo/python-list
building extension modules under 2.4 / cygwin
For the first time, I am trying to compile a matplotlib installer for win32 / python2.4 under cygwin. I tested this earlier with one of the pre-release candidates and had no troubles. But when I compile with python2.4, I get the following error when I try and import my extension code the procedure entry point _ctype could not be located in the dynamic link libary msvcr71.dll This DLL resides in C:\Windows\System32 on my system If I edit the distutils/cygwincompiler.py file and remove the line that add this lib elif msc_ver == '1310': # MSVC 7.1 #self.dll_libraries = ['msvcr71'] self.dll_libraries = [] My code compiles, links and runs fine, at least in initial tests Any reason I shouldn't be doing this? JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: Python mascot proposal
Steven Bethard <[EMAIL PROTECTED]> writes: > Brian Beck wrote: > > http://exogen.cwru.edu/python2.png > > Oooh, I like this one. Very cool! > Its visually stunning. But under Windows gears show up in the DLL and batch file icons. Lenard Lindstrom <[EMAIL PROTECTED]> -- http://mail.python.org/mailman/listinfo/python-list