Re: display VARCHAR(mysql) and special chars in html
Jonas Meurer wrote: hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8 hyphens, german umlauts, etc. i could write a function to parse the comment and substitute special chars with the relevant html code, but maybe this already exists in some module? if not, it'll be hard work, as i've to consider many special chars, and at least iso-8859-1* and utf-8 as charmaps. bye jonas If I understand you correctly, just put meta http-equiv=CONTENT-TYPE content=text/html; charset=utf-8 somewhere in the head-section of you HTML-Page. HTH, Wolfram -- http://mail.python.org/mailman/listinfo/python-list
Re: UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux Windows XP
Serge Orlov [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Paul Boddie wrote: Anyone who has needed to expose filesystems created by Linux distributions before the UTF-8 big push to later distributions can attest to the fact that the see no evil brass monkey is wearing a T-shirt with UTF-8 written on it. Unfortunately the monkey is painted in the air with a stick, so not everyone can see it. Python can't. Given a random linux system how can you tell if the monkey has pushed it already or not? That's a good question. See this article for an example of the frustration caused: http://groups.google.no/groups?selm=b1npav%24cci%241%40slb6.atl.mindspring.netoutput=gplain Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: a wrapper to invoke functions using argument
[EMAIL PROTECTED] wrote: Hi, support I have a library of function, called mylib.py, in which there are 2 functions 'f1' and 'f2' (1 arguments in either one); Now I want to write a wrapper that will invoke f1 or f2 using the command line argument. So for example, I want to write a function call.py and invoke it as python call.py f1 arg1 So this is straight forward, but I don't know how to evaluate a function. any help would be much appreciate it. les There is a FAQ about this: http://www.python.org/doc/faq/programming.html#how-do-i-use-strings-to-call-functions-methods -- Soraia: http://www.soraia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: which parser to use
[EMAIL PROTECTED] wrote: I'm building something that requires parsing a rather complex language. I'd like to do the whole application, including the lex/parse phase, in Python (for development/debug speed), and only move parts of it to a compiled language if execution speed absolutely dictates. So, what i'm looking for in a Python parser is: 1) reliability (don't want to debug a parser) 1) flexibility (i do a lot of refactoring) 2) E/BNF friendliness (working from a spec) 3) speed (moderate speed will do; glacial won't) Does anyone have any familiarity with some of the several Python parsers out there? Any pointers to comparisons (as opposed to surveys) of _several_ of the Python parsers would be much appereciated. (I've seen the YAPPS/Spark comparison.) If none of the Python parsers really fit the bill, any thoughts on ANTLR, Spirit, etc? Thanks in advance, E Depending on just *how* complex your EBNF is, pyparsing may be suitable. It has been used for Verilog, DOT, TeX, and agent language parsing. Pyparsing is a combinator, in which you assemble the grammar using expression objects such as Literal, Word, OneOrMore, etc., all in pure Python code - no separate lex/yacc syntax, or code generation/synchronization steps. It *may* be somewhat slow for your purposes, but I find the grammars to be readable and easily maintained and extended. Download pyparsing at http://pyparsing.sourceforge.net. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: exercise: partition a list by equivalence
I started to collect i believe the 4 or so solutions by different people... but seems it's gonna take some an hour or more... So far the only other one i've run and find alright is Reinhold Birkenfeld's original. Others worth noting i'm aware of is David Epsteinn, improved versions from Reinhold Birkenfeld, the one using graphs by bearophile ... since many of you have already collected and tested these... i wonder if anyone'd be interested to put together all the (working) code in a single message? (or even a webpage.) thanks. Xah [EMAIL PROTECTED] http://xahlee.org/PageTwo_dir/more.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Dealing with config files what's the options
Hello Tom, Tom Willis wrote: How are the expert pythoneers dealing with config files? Is there anything similair to .net's config files or java's .properties? I'm not familiar with those config file formats - but ConfigObj certainly makes handling config files easy. It uses the ini type layout - which you're not so fond of, although it aloows lists for values as well. from configobj import ConfigObj config = ConfigObj(filename) value1 = config['section 1']['value 1'] See http://www.voidspace.org.uk/python/configobj.html I'm interested in suggestions as to ways to take it forward. I've just added unicode support (still experimental - wait for the next release) and an interface for validation. Adding nested sections using indentation will probably be the next major feature. (as well as preserving user formatting when writing back files) Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml A quick search on google didn't return anything that looked useful, and I almost would expect to see some module that would be for dealing with config information. I can think of at least one way to do it, but I'm sure there are shortcomings I can't see yet, and I'd rather use something someone smarter than me has written. I see in the logging module that there's stuff to handle configs but seems kind of odd to have to import logging to get your config information Any ideas? have I used the word config enough in this message? :) -- Thomas G. Willis http://paperbackmusic.net -- http://mail.python.org/mailman/listinfo/python-list
Re: Mixing Txinter and Pygame
On Wed, 23 Feb 2005 10:23:09 +1300, Tim Knauf [EMAIL PROTECTED] wrote: [snip] (When I'm starting on a language feature, though, I usually find I learn a lot more from worked examples than from straight command information. You may be interested in Tkinter best kept secret: the example scripts in the Demo/tkinter sub-directory of the Python source installation. It mainly covers the basics, but may be quite helpful when you start. HTH - eric - -- http://mail.python.org/mailman/listinfo/python-list
Re: display VARCHAR(mysql) and special chars in html
Wolfram Kraus [EMAIL PROTECTED] wrote: Jonas Meurer wrote: hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8 hyphens, german umlauts, etc. i could write a function to parse the comment and substitute special chars with the relevant html code, but maybe this already exists in some module? if not, it'll be hard work, as i've to consider many special chars, and at least iso-8859-1* and utf-8 as charmaps. bye jonas If I understand you correctly, just put meta http-equiv=CONTENT-TYPE content=text/html; charset=utf-8 somewhere in the head-section of you HTML-Page. ... and make sure the deault charset of your HTTP server is *OFF* (or UTF-8), since it overrides the per-page setting (most unfortunate). -- --- | Radovan Garabk http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__garabik @ kassiopeia.juls.savba.sk | --- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
I guess print is using the __repr__ (or __str__ ?) methods of lsit - which you will need to override as well. Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
wax is a nice layer on top of wx - it maintains cross-platform-ability and is easier to learn ! See http://zephyrfalcon.org Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating Button arrays with different commands using Tkinter
Thanks Frederik. I knew it was not binding the way I intended to, but just had no idea why or how to make it do so... thanks for the quick lambda lesson :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
Tkinter! Ease* Well-documented? Easy to Learn? Functionality * Can I get it to do what I need it to do? Looks *** Does it look good? Well, beauty is after all in the eye of the beholder. Anything I can get to work on either platform with minimum effort and quick writing looks good to me :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
Fuzzyman wrote: I guess print is using the __repr__ (or __str__ ?) methods of lsit - which you will need to override as well. Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml Thank you but the problem is that I have to express my intention in duplicate places -- __iter__(along with next), __str__, __eq__ and so on. p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. -- http://mail.python.org/mailman/listinfo/python-list
Working FTP server based on Twisted framework.
Hi call, Does anybody know, if there is any opensource, working FTP server implementation based on Twisted framework? Greetings -- http://mail.python.org/mailman/listinfo/python-list
Re: display VARCHAR(mysql) and special chars in html
Jonas Meurer wrote: (...) i've changed my plans, and now will transform the comments to html before saving them in mysql. this way, the comment never contains special chars except they weren't filtered out when safed in mysql. do any filters exist, to transform plain text to html? otherwise i might use third-party products, as text2html. what do you think? as you may known mysql 4.1 offers utf-8 support. il would be wise to keep everything as utf-8: db, html generation and finally serve, with correct HTTP headers, pages encoded as utf-8. to do this you might have to fiddle with mysql settings and make sure that issuing a: show varibles; almost all of these settings: character_set_clientlatin1 character_set_connectionlatin1 character_set_database latin1 character_set_results latin1 character_set_serverlatin1 character_set_systemutf8 use utf-8 (as you can see my copy of mysql does not), otherwise i think bad things will occur. if you prefer to filter out weird characters and encode as html # entities textile[1] does the job just fine, you can specify input and output encoding. cheers, deelan. [1] http://dealmeida.net/en/Projects/PyTextile/ -- @prefix foaf: http://xmlns.com/foaf/0.1/ . #me a foaf:Person ; foaf:nick deelan ; foaf:weblog http://blog.deelan.com/ . -- http://mail.python.org/mailman/listinfo/python-list
assert 0, foo vs. assert(0, foo)
Hi, Python 2.3.3 (#1, Feb 5 2005, 16:22:10) [GCC 3.3.3 (SuSE Linux)] on linux2 assert 0, foo Traceback (most recent call last): File stdin, line 1, in ? AssertionError: foo assert(0, foo) If you use parenthesis for the assert statement, it never raises an exception. Up to now I raised strings, but since this is deprecated, I switched to use the second argument for the assert statement. Is it possible to change future python versions, that assert accept parenthesis? Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: how can I make this script shorter?
Good idea about hashing part of the file before comparing entire files. It will make the script longer but the speed increase will most likely make it worth it. Lowell Christos TZOTZIOY Georgiou wrote: On Tue, 22 Feb 2005 00:34:39 -0800, rumours say that Lowell Kirsh [EMAIL PROTECTED] might have written: I have a script which I use to find all duplicates of files within a given directory and all its subdirectories. It seems like it's longer than it needs to be but I can't figure out how to shorten it. Perhaps there are some python features or libraries I'm not taking advantage of. The way it works is that it puts references to all the files in a dictionary with file size being the key. The dictionary can hold multiple values per key. Then it looks at each key and all the associated files (which are the same size). Then it uses filecmp to see if they are actually byte-for-byte copies. It's not 100% complete but it's pretty close. I can't advise on code length; my dupefind.py script is 361 lines, but the algorithm is slightly more complex to speed things up (and it also optionally hardlinks identical files on POSIX and NTFS filesystems). If in your case there are lots of files of several MiB each, that often match on size, you could avoid lots of comparisons if you did match based on some hash (md5 or sha). You could also compare first on the hash of the first few kiB (I check 8 kiB) to see if you need to read the whole file or not. So: for every file: if other files exist with the same size: calculate hash for first few kiB if file has same initial hash with other files: calculate full hash return all files with same full hash Something like that. -- http://mail.python.org/mailman/listinfo/python-list
Re: how can I make this script shorter?
Thanks for the advice. There are definitely some performance issues I hadn't thought of before. I guess it's time to go lengthen, not shorten, the script. Lowell John Machin wrote: Lowell Kirsh wrote: I have a script which I use to find all duplicates of files within a given directory and all its subdirectories. It seems like it's longer than it needs to be but I can't figure out how to shorten it. Perhaps there are some python features or libraries I'm not taking advantage of. The way it works is that it puts references to all the files in a dictionary with file size being the key. The dictionary can hold multiple values per key. Then it looks at each key and all the associated files (which are the same size). Then it uses filecmp to see if they are actually byte-for-byte copies. It's not 100% complete but it's pretty close. Lowell To answer the question in the message subject: 1,$d And that's not just the completely po-faced literal answer that the question was begging for: why write something when it's already been done? Try searching this newsgroup; there was a discussion on this very topic only a week ago, during which the effbot provided the URL of an existing python file duplicate detector. There seems to be a discussion every so often ... However if you persist in DIY, read the discussions in this newsgroup, search the net (people have implemented this functionality in other languages); think about some general principles -- like should you use a hash (e.g. SHA-n where n is a suitably large number). If there are N files all of the same size, you have two options (a) do O(N**2) file comparisons or (b) do N hash calcs followed by O(N**2) hash comparisons; then deciding on your need/whim/costs-of-false-negatives/positives you can stop there or you can do the file comparisons on the ones which match on hashes. You do however need to consider that calculating the hash involves reading the whole file, whereas comparing two files can stop when a difference is detected. Also, do you understand and are you happy with using the (default) shallow option of filecmp.cmp()? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with minidom and special chars in HTML
Jarek Zgoda wrote: Horst Gutmann napisa(a): I currently have quite a big problem with minidom and special chars (for example uuml;) in HTML. Let's say I have following input file: -- ?xml version=1.0? !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; HTML4 is not an XML application. Even if minidom will fetch this DTD and be able to parse character entities, it may not be able to parse the document. Any idea how I could solve this problem? Don't use minidom or convert HTML4 to XHTML and change declaration of doctype. This was just a bad example :-) I get the same problem with XHTML in the doctype. The funny thing here IMO is, that the special chars are simply removed. No warning, no nothing :-( MfG, Horst -- http://mail.python.org/mailman/listinfo/python-list
Re: assert 0, foo vs. assert(0, foo)
Thomas Guettler [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Python 2.3.3 (#1, Feb 5 2005, 16:22:10) [GCC 3.3.3 (SuSE Linux)] on linux2 assert 0, foo Assert that 0 is true. If that fails, raise AssertionError(foo). Traceback (most recent call last): File stdin, line 1, in ? AssertionError: foo assert(0, foo) Assert that the tuple (0, foo) is true. Non-empty tuples are always true. If you use parenthesis for the assert statement, it never raises an exception. Up to now I raised strings, but since this is deprecated, I switched to use the second argument for the assert statement. Is it possible to change future python versions, that assert accept parenthesis? As shown above, it does, but it doesn't do quite what you expected. For further enlightenment, try the following and think through why each one gives the results it does: assert (), 'spam' assert [], 'eggs' assert {}, 'spam and eggs' assert (0,), 'spam, spam, and eggs' assert (0, foo), 'spam, spam, eggs, and spam' assert 0, foo, 'shrubbery' The last will give a syntax error. Can you spot why? Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Attaching to a Python Interpreter a la Tcl
Hello, Some long time ago, I used to use Tcl/Tk. I had an tcl embedded into my app. The coolest thing was however, I was able to attach to the interpreter (built in to my app) via a tcl shell in which I could type in regular tcl code which would be interpreted by the interpreter of my application. Naturally, it was possible to call tcl functions of my applications. Some kind of rapid RPC. Is this also possible with python ? Thanks, -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
[EMAIL PROTECTED] wrote: p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. Reversed is an iterator - it does NOT copy the list. In other words, reversed already does pretty much what you want. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh schrieb: +00: googled for the mingw home page +00: found the mingw download page +02: finally figured out what to download +03: noticed that my usual SF site only offered 1K/s; aborted download +07: finished downloading the mingw kit from another SF site +17: finished installing +18: added \mingw\bin to the path +18: typed python setup.py install --compiler=mingw32 +18: got a linker error; googled for help +19: copied python24.dll to \mingw\lib +20: finished building the sample library (cElementTree); all tests pass Impressive. How did you record the minutes? ;) I'd like to know wether this is a single observation or true for most if not all your MinGW builds? I used Borland's C++ Compiler (free and commercial) and had frequently to tweak .def files and the source to make it work. I also had to transform the python dll with COFF2OMF because the library interfaces of python.dll and the Borland binaries were different. If your MinGW experience described above is typical then I'll get a stop watch and give it a try ;) -- --- 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: Attaching to a Python Interpreter a la Tcl
DE wrote: Hello, Some long time ago, I used to use Tcl/Tk. I had an tcl embedded into my app. The coolest thing was however, I was able to attach to the interpreter (built in to my app) via a tcl shell in which I could type in regular tcl code which would be interpreted by the interpreter of my application. Naturally, it was possible to call tcl functions of my applications. Some kind of rapid RPC. Is this also possible with python ? Thanks, I think you are talking about the tk send command which allows for communicating with a known app. I don't believe python comes with such a facility without some coding, but it has been implemented in various ways using sockets etc etc. I seem to remember that modern idle uses an rpc technique for debugging. There are several python projects which address interprocess communication pyro http://pyro.sourceforge.net/ is a good example. -- Robin Becker -- http://mail.python.org/mailman/listinfo/python-list
Re: Making pygopherd working with Mac OS X
Sorry, can anyone tell me whether the complete.org mailing list is still alive or not? I believe I tried subscribing but nothing came back :) Been a while since I looked at getting pygopherd going, but it appeared to be a non-trivial task.. Anyone with the time to look at it might be interested :) -- mattabat Cameron Kaiser wrote: [EMAIL PROTECTED] (mattabat) writes: I attempted to use pygopherd 2.0.9 work with MacPython 2.3 under Mac OS X 10.3.7 but I'm afraid I hit a brick wall trying to make it run. Does anyone know how to make this work? I obtained pygopherd from gopher://gopher.quux.org/1/devel/gopher/pygopherd - or for the gopher client deprived, from http://gopher.quux.org:70/devel/gopher/pygopherd Has anyone managed to get pygopherd running with MacPython? You might subscribe to the complete.org mailing list; John Goerzen reads there. See gopher://gopher.quux.org/0/Software/Gopher/Mailing%20List.txt -- Cameron Kaiser * [EMAIL PROTECTED] * posting with a Commodore 128 personal page: http://www.armory.com/%7Espectre/ ** Computer Workshops: games, productivity software and more for C64/128! ** ** http://www.armory.com/%7Espectre/cwi/ ** -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
[EMAIL PROTECTED] wrote: Fuzzyman wrote: I guess print is using the __repr__ (or __str__ ?) methods of lsit - which you will need to override as well. Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml Thank you but the problem is that I have to express my intention in duplicate places -- __iter__(along with next), __str__, __eq__ and so on. If you are sublassing the built in types I guess you will have to change all methods that have changed.. an alternative wuld be to not subclass object and override __getattr__ : class rev_wrap: def __init__(self,l): self.l=l def __getitem__(self,i): return self.l[-i-1] def __getattr__(self, attr): return getattr(self.l, attr) Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. -- http://mail.python.org/mailman/listinfo/python-list
Re: On eval and its substitution of globals
Paddy wrote: Hi, I got tripped up on the way eval works with respect to modules and so wrote a test. It seems that a function carries around knowledge of the globals() present when it was defined. (The .func_globals attribute)? When evaluated using eval(...) the embedded globals can be overridden with the one passed through the eval(...) call If however you create a new function that calls the first then eval's global argument is only substituted in the outer call! TEST: = def f1(): return A B ... def z(): return f1() ... eval(f1.func_code,dict(A=1,B=2)) True eval(z.func_code,dict(A=1,B=2, f1=f1)) Traceback (most recent call last): File stdin, line 1, in ? File stdin, line 1, in z File stdin, line 1, in f1 NameError: global name 'A' is not defined ENDTEST === Is there a way to do a deep substitution of the globals? A workaround is to implement z() using eval() again, this forces f1() to use the same globals passed to z(): def z(): return eval(f1.func_code) ... eval(z.func_code,dict(A=1,B=2, f1=f1)) True Kent I should add that f1 is given as-is. I can modify z, and f1 is just one of many functions given and function z is some boolean function of the fn's Thanks, Pad. -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
[EMAIL PROTECTED] wrote: p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. reversed() returns an iterator so list size shouldn't be an issue. What problem are you actually trying to solve? Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Attaching to a Python Interpreter a la Tcl
Do you mean making the interpreter available from within a Python app ? There are various ways of doing that - you can see the SPE editor which uses pycrust as one example. http://spe.pycs.net You could also embed IPython for a good interface to the interpreter. http://ipython.scipy.net Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(obj, errors='foo') raises TypeError - bug?
Steven Bethard wrote: Mike Brown wrote: class C: ... def __str__(self): ... return 'asdf\xff' ... o = C() unicode(o, errors='replace') Traceback (most recent call last): File stdin, line 1, in ? TypeError: coercing to Unicode: need string or buffer, instance found [snip] What am I doing wrong? Is this a bug in Python? No, this is documented behavior[1]: unicode([object[, encoding [, errors]]]) ... For objects which provide a __unicode__() method, it will call this method without arguments to create a Unicode string. For all other objects, the 8-bit string version or representation is requested and then converted to a Unicode string using the codec for the default encoding in 'strict' mode. Note that the documentation basically says that it will call str() on your object, and then convert it in 'strict' mode. You should either define __unicode__ or call str() manually on the object. Not a bug, I guess, since it is documented, but it seems a bit bizarre that the encoding and errors parameters are ignored when object does not have a __unicode__ method. Kent STeVe [1] http://docs.python.org/lib/built-in-funcs.html -- http://mail.python.org/mailman/listinfo/python-list
How new Check 21 legislation is affecting you...
Good Afternoon! Recenty intrdocuced legislation requires business and home users to print personal and business checks with security blank check stock and magnetic ink. Please find qualified suppliers at Google by clicking on the followingl link. http://www.google.com/search?sourceid=navclientie=UTF-8rls=GGLC,GGLC:1969-53,GGLC:enq=blank+check+paper%2C+magnetic+ink+for+inkjets Thank you very much. Cathleen Baer Marketing Relationship Representative Globalzon Consulting Group -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
Kent Johnson wrote: [EMAIL PROTECTED] wrote: p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. reversed() returns an iterator so list size shouldn't be an issue. What problem are you actually trying to solve? Kent Oh, you are right. Actually, it's more complicated than simple reversion. The list order should be somewhat twisted and the list is big. For example, [1,2,3,4,5,6,7,8,9,10] -- [10,9,8,7,6,1,2,3,4,5] so __getitem__(self,i) = __getitem__(self,-i-1) if ilen(size)/2, otherwise __getitem__(self,i-len(size)/2) I'd like to have TwistedList class that takes in an original list and pretends as if it is twisted actually. However, I have to have duplicate codes here and there to make it act like a list, say assert twisted_list == [10,9,...] and for each in twisted_list and etc. -- http://mail.python.org/mailman/listinfo/python-list
File/Directory hacks - is there a better way to do this?
I had a software package screw up a directory tree by placing all the files in a directory of the same name. So I wound up with: Root file1.txt (dir) file1.txt (file) file2.txt (dir) file2.txt (file) Annoying. So I wrote the following script, which fixed the problem by renaming and copying the file up to the root directory, removing the intermediate directory, and finally restoring the orginal file name. Is there a better (faster, or fewer lines of code, or more 'python-esque') way to do? In particular, I know the latest versions of python includes iterators, generators, and decorators...but I haven't had a chance to really read about them, or understand how to use them properly. So I'd love to hear if the new tools could've solved this simpler/faster. Thanks! -- #!/user/bin/env python import os, os.path, shutil top = 'c:\$user' class fixdirectories: def __init__(self, top): self.top = top def walk(self): for root, dirs, files in os.walk(self.top, topdown=False): rootdir, roottail = os.path.split(root) for name in files: if name.lower() == roottail: oldname = os.path.join(root, name) tmpname = os.path.join(rootdir, PRE- + name) newname = os.path.join(rootdir, name) shutil.move(oldname, tmpname) try: os.rmdir(root) print removing: + rootdir shutil.move(tmpname, newname) except: print Could not remove: + root if __name__ == __main__: f = fixdirectories(top) f.walk() -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie help for mod_python
Am Mittwoch, 23. Februar 2005 00:29 schrieb Brian Beck: Jochen Kaechelin wrote: I run debian sid and apache2 with libapache2-mod-python2.3 and I added these lines Directory /var/www AddHandler mod_python .py PythonDebug On /Directory in a virtualhost container. Were those the only lines you added? You also should have actually loaded the module somewhere by adding something resembling: LoadModule python_module modules/mod_python.so Thats done by debian during installation: Module Name: mod_python.c Content handlers: yes -- Gugsch Du: http://gissmoh.de -- http://mail.python.org/mailman/listinfo/python-list
Fonts and PIL
Hello- I'm running Python 2.3 on a windows box and would like to use PIL to superimpose text over an existing pgn image. I have no problem getting the text on the image but can not figure out how to manage fonts. How to set the font style and size. From reading the archives I surmise that I want to work with *.pil files. I've searched my box for the font files but did not find them. I've googled for information on pil font files and it appears to be involved with Zope. So, can any of you honcho-level types help me out? How can I set font size and style in my PIL application? Thanks again! --greg -- Greg Lindstrom 501 975.4859 Computer Programmer [EMAIL PROTECTED] NovaSys Health Little Rock, Arkansas We are the music makers, and we are the dreamers of dreams. W.W. -- http://mail.python.org/mailman/listinfo/python-list
Re: Attaching to a Python Interpreter a la Tcl
fuzzyman == Fuzzyman [EMAIL PROTECTED] writes: fuzzyman Do you mean making the interpreter available from within fuzzyman a Python app ? There are various ways of doing that - fuzzyman you can see the SPE editor which uses pycrust as one fuzzyman example. http://spe.pycs.net I believe he means embedding he interpreter in his app, then accessing the interpreter from another process - so you could change and view global vars of the running process from the interpreter, for example. This basically means redirecting i/o of the interpreter to a socket to which you connect via, say, telnet. There are libs that do such a thing, I even remember trying one out myself, but I couldn't find it quickly enough from google. -- Ville Vainio http://tinyurl.com/2prnb -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Markus Wankus wrote: George Sakkis wrote: Ilias Lazaridis [EMAIL PROTECTED] wrote in message [...] The Essence is this one, as stated before: [huge copy paste of previous post] The Essence is irrelevant. - - - All your thread are belong to us. - - - For great justice! ;o) [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Sizers VS window size
Brian Victor [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]... Deltones wrote: However, if I add this part from the tutorial, I get a much smaller window. Why is there an interference with the result I want when adding the sizer code? [snip] self.sizer.Fit(self) As noted in the the docs for Fit(): Tell the sizer to resize the window to match the sizer's minimal size. Take this call out and the size should be as you expect. Thanks Brian, that was it. I admit I'm having quite a lot of fun learning the Python/wxPython combo, but man is there a lot of concepts to grasp! Denis -- http://mail.python.org/mailman/listinfo/python-list
kill a process in XP
Hi. From my Python-program I spawn a new process. When using P_NOWAIT spawnl returns the pid but in windows it returns a process handle. Later I want to kill this process. How can I do this when I only have the process handle? -tores- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
On 2005-02-23, Ilias Lazaridis [EMAIL PROTECTED] wrote: The Essence is this one, as stated before: [huge copy paste of previous post] The Essence is irrelevant. - All your thread are belong to us. - For great justice! ;o) [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 Um, you realize that nobody in this thread takes you the least bit seriously and people are just poking you with a stick to watch you jump? -- Grant Edwards grante Yow! An INK-LING? Sure -- at TAKE one!! Did you BUY any visi.comCOMMUNIST UNIFORMS?? -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
Thomas Guettler wrote: Am Tue, 22 Feb 2005 20:09:50 -0800 schrieb Raghul: Which of the UI I can used for my program that I can use both in windows and in Linux. Several. Tkinter and wxPython are good choices -- they run on the three major platforms: Linux/unix, Windows, and Mac OS X. I like pygtk. It should be portable to windows, but I have not tried this yet. Up to now I only used it under linux. I believe this may be a reasonable choice as well. Another choice is PyQt, which has a great simple model and definition, but has, I believe, licensing issues if you intend to deliver a product to many PCs. Is it possible for me to use Wxpython for my program so that it can run on both the windows and linux machine? It is, indeed, possible (and often easy) to have the same program run well on both platforms. Will it be platform independent? You can write portable programs (if you test across platforms). The only truly portable programs in any language are abstract. Once you start dealing with I/O and the real world, you inevitably have to face issues one circumstance at a time. Both Tkinter and wxPython spend a lot of effort in reducing the work you have to do. Don't fool yourself with a manager-friendly slogan; programs must be tested to work. Any I/O heavy (or threaded, or ) application running on two platforms will take more work than on a single platform. Python and wxPython or Tkinter, for example, _allow_ you to write portable programs, but they don't _guarantee_ it. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Selective HTML doc generation
Hi. I'm looking for a documentation generation tool (such as pydoc, epydoc, happydoc, etc.) that will allow me to filter what it includes in it's output. I only want the reader to know about classes and methods in my package if if the classes have docstrings. I've got a large package that is used by relatively non-technical users (and yet they write Python!) that documents the public API with docstrings. I don't want to clutter their view of the world with links to the package's internal classes and documentation that covers things like __special__ methods. Anybody know of anything that let's you do it? I realise I may end up doing some hacking here but don't want to repeat work unnecessarily. Cheers, Graham -- http://mail.python.org/mailman/listinfo/python-list
Re: assert 0, foo vs. assert(0, foo)
Thomas Guettler wrote: Hi, Python 2.3.3 (#1, Feb 5 2005, 16:22:10) [GCC 3.3.3 (SuSE Linux)] on linux2 assert 0, foo Traceback (most recent call last): File stdin, line 1, in ? AssertionError: foo assert(0, foo) If you use parenthesis for the assert statement, it never raises an exception. Up to now I raised strings, but since this is deprecated, I switched to use the second argument for the assert statement. Is it possible to change future python versions, that assert accept parenthesis? You are confusing assert with raise. assert test, text behaves like: if __debug__ and test: raise AssertionError, text As far as raise goes, where you have been writing: raise some complaint you could simply use: raise ValueError, some complaint or: raise ValueError(some complaint) --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
A Question about SQLBuilder
Hi, We are going to make an database application integrated development environment with python, zope and cmf. I am searching for an sql builder class for generating sql sentences. This class must run over different sql relational databases. But i want to use zope database adapters for db connections. I dont want to manage connections in the python code. There is a class SQLBuilder seems to be suitable for us at this project. But i cant find enough document about SQLBuilder. There is a short one on the sqlobject.org website, but its quite poor. Have you ever heard about this class and is there anyone knows other documents about this class. If someone would help me about using this class over Zope with zope database adapters (like ZPsycopgDA, ZMySQLDA, etc) i will be very gladfull. Kind Regards, -- Evrim zelik Anka Information Technologies RD Co. Manager of Internet Technologies Web : http://www.ankabt.com/ Gsm : +90 555 474 84 52 Phone : +90 212 276 19 69 # 134 -- http://mail.python.org/mailman/listinfo/python-list
running a shell command from a python program
Hi, I'm a newbie, so please be gentle :-) How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and do stuff with the contents of that list. I started with a BASH script actually, until I realized I really needed better data structures :-) Is popen the answer? Also, where online would I get access to good sample code that I could peruse? I'm running 2.2.3 on Linux, and going strictly by online doc so far. Thanks! S C -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Grant Edwards wrote: [...] Um, you realize that nobody in this thread takes you the least bit seriously and people are just poking you with a stick to watch you jump? jump: [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: running a shell command from a python program
Am Wed, 23 Feb 2005 07:00:31 -0800 schrieb Sandman: Hi, I'm a newbie, so please be gentle :-) How would I run a shell command in Python? [cut] Is popen the answer? Also, where online would I get access to good sample code that I could peruse? Yes, popen is the answer. I recommend popen4 because it avoids deadlocks if there is output on stdout and stderr. Example: stdout, stdin = popen2.popen4(tidy -q -errors '%s' % htmlfile) HTH, Thomas -- Thomas Güttler, http://www.thomas-guettler.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: running a shell command from a python program
Doh, use the search Luke: http://www.wellho.net/forum/Programming-in-Python-and-Ruby/Running-shell-commands-from-Python.html Seems like popen is the way to go. S -- http://mail.python.org/mailman/listinfo/python-list
Socks-4 Client Example in Twisted
I am looking for examples on how to write a Socks-4 client example using the Twisted framework. Has anybody attempted this or aware of examples? Thanks, Daniel -- http://mail.python.org/mailman/listinfo/python-list
[OT] [Job] Open Python/Zope/Plone Positions in Ireland
Propylon is looking to recruit people with Python or Zope experience for several projects that we are involved in. We are seeking candidates with varying amount of experience in Python and all who are interested in learning in Python are encouraged to apply for the positions. Experience with Zope or Plone is an advantage but not necessary. For more information on Propylon, please visit http://www.propylon.com . All positions would be in our Irish office in Dublin. All candidates would have to be eligible to work in the EU and have the appropriate visas, etc. If you or anyone you know is interested, please forward a CV, preferably in the OpenOffice.org or RTF format to both [EMAIL PROTECTED] and [EMAIL PROTECTED] Regards, -- Darragh Sherwin PWB Implementations Manager http://www.propylon.com/ solutions/parliament/index.html +353-1-4927456 +353-87-1204654 -- http://mail.python.org/mailman/listinfo/python-list
Re: running a shell command from a python program
Sandman wrote: How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and do stuff with the contents of that list. There's a Python Cookbook example that should fit nicely with what you're trying to do here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296 -- Leif Biberg Kristensen -- http://mail.python.org/mailman/listinfo/python-list
print and str subclass with tab in value
I ran into this strange behavior when noticing some missing spaces in some debugging output. It seems that somewhere in the print processing, there is special handling for string contents that isn't affected by changing how a string is represented when printed (overriding __str__). For example, given a class like: class mystr(str): def __new__(cls, value): return str.__new__(cls, value) def __str__(self): return 'Test' you get the following behavior x = strtest.mystr('foo') print x,1 Test 1 print repr(x),1 'foo' 1 x = strtest.mystr('foo\t') print x,1 Test1 print repr(x),1 'foo\t' 1 Note the lack of a space if the string value ends in a tab, even if that tab has nothing to do with the printed representation of a string. It looks like it's part of basic string output since with a plain old string literal the tab gets output (I've replaced the literal tab with [TAB] in the output below) but no following string. x = 'testing\t' print x,1 testing[TAB]1 x = str('testing\t') print x,1 testing[TAB]1 so I'm guessing it's part of some optimization of tab handling in print output, although a quick perusal of the Python source didn't have anything jump out at me. It seems to me that this is probably a buglet since I would expect print and its softspace handling to depend on what was actually written and not internal values - has anyone else ever run into this. -- David -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
Yeah.. Tkinter is nice. Wzx is just as easy though, but scales better because it's built on wx. Regards, Fuzzy http://www.voidsapce.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list
Can somebody help compiling 'mssqldb.pyd' for Python24 [win]?
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html Unfortunately the binary for Python-2.4 isn't available yet and I'd hate to step back to a previous version. I'm glad I managed to set up my XP machine to being able to compile extensions using the VC++ toolkit which freely availbale from MS. See my posting Step by step: Compiling extensions with MS Visual C++ Toolkit 2003 in this group. The problem is that compiling stops with an error in this case. Two additional header files are needed: sqlfront.h and sqldb.h. They can be downloaded as file 'Ptk_I386.exe' here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q186893#kb2 The problem I have in compiling is: [...] c:\Python24-extra-modules\MSSQL-0.09\sqlfront.h(312) : error C2373: 'LPCBYTE' : redefinition; different type modifiers c:\Programme\Microsoft Platform SDK for Windows XP SP2\Include\WinSCard.h(43) : see declaration of 'LPCBYTE' error: command 'c:\programme\Microsoft Visual C++ Toolkit 2003\bin\cl.exe' failed with exit status 2 Currently I'm not C-Guru enough to find out what's wrong. I'm hoping somebody else succeeds in compiling and can provide compiled module. I think the object-craft.com.au staff would gladly accept the binary as well, as they don't have the appropriate environment right now. Thanks in advance mb - Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Fonts and PIL
Greg Lindstrom wrote: I'm running Python 2.3 on a windows box and would like to use PIL to superimpose text over an existing pgn image. I have no problem getting the text on the image but can not figure out how to manage fonts. How to set the font style and size. From reading the archives I surmise that I want to work with *.pil files. I've searched my box for the font files but did not find them. I've googled for information on pil font files and it appears to be involved with Zope. So, can any of you honcho-level types help me out? How can I set font size and style in my PIL application? Pick a nice .ttf file and load it with ImageFont.truetype(). /ug -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(obj, errors='foo') raises TypeError - bug?
Kent Johnson wrote: Steven Bethard wrote: No, this is documented behavior[1]: unicode([object[, encoding [, errors]]]) ... For objects which provide a __unicode__() method, it will call this method without arguments to create a Unicode string. For all other objects, the 8-bit string version or representation is requested and then converted to a Unicode string using the codec for the default encoding in 'strict' mode. Note that the documentation basically says that it will call str() on your object, and then convert it in 'strict' mode. You should either define __unicode__ or call str() manually on the object. Not a bug, I guess, since it is documented, but it seems a bit bizarre that the encoding and errors parameters are ignored when object does not have a __unicode__ method. Yeah, I agree it's weird. I suspect if someone supplied a patch for this behavior it would be accepted -- I don't think this should break backwards compatibility (much). STeVe -- http://mail.python.org/mailman/listinfo/python-list
Vexira ALERT [your mail: Hi]
* * * * * * * * * * * * * * * Vexira ALERT * * * * * * * * * * * * * * * This version of Vexira MailArmor is licensed and full featured. Vexira has detected the following in a mail from your address: Worm/NetSky.Z worm The mail was not delivered. Your computer may be infected with a virus! Please visit Central Command at http://www.centralcommand.com and obtain a copy of Vexira AntiVirus now. Mail-Info: --8-- From: python-list@python.org To: [EMAIL PROTECTED] Date: Wed, 23 Feb 2005 17:32:58 +0100 Subject: Hi --8-- -- Vexira AntiVirus for Linux, OpenBSD, FreeBSD Virus Protection for the Real World (TM). Central Command http://www.centralcommand.com -- http://mail.python.org/mailman/listinfo/python-list
Re: MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?)
Colombes == Colombes [EMAIL PROTECTED] writes: ColombesNow I only need to figure out how to install the Colombes correct Numeric module(s). I'm making progress, Colombes almost have my home laptop fully capable with the Colombes MatLab-like (PyLab) graphs, plots. You can get either Numeric or numarray from http://sourceforge.net/projects/numpy. matplotlib works transparently with either (and provides a unified interface to both), but if you choose numarray you need to change the numerix variable to numarray in your matplotlib configuration file, which is described at http://matplotlib.sf.net/.matplotlibrc Good luck! JDH -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] exercise: partition a list by equivalence
Please consider my submission also (Python 2.3-compatible). -- Paul McGuire .import sets . .input = [[1, 2], [3, 4], [2, 3], [4, 5]] .input = [[1, 2], [3, 4], [4, 5]] .input = [[1, 2],[2,1], [3, 4], [4, 5],[2,2],[2,3],[6,6]] . .def merge(pairings): .ret = [] .for a,b in pairings: .s1 = None .s2 = None .for s in ret: .if a in s or b in s: .if s1 is None: .s1 = s .else: .s2 = s .break .else: .for s in ret: .if a in s: .s.add(b) .break .elif b in s: .s.add(a) .break .else: .ret.append(sets.Set([a,b])) .continue .ret.remove(s1) .ret.remove(s2) .ret.append(s1.union(s2)) . .return [list(s) for s in ret] . .print merge(input) -- http://mail.python.org/mailman/listinfo/python-list
Pythoncard - Mistake in walkthrough?
Hi all, I'm just getting into Python/wxPython/Pythoncard and I'm trying the tutorial from this page: http://pythoncard.sourceforge.net/walkthrough1.html Is it me who's totally dense or there's some sort of confusion with this tutorial? Here's what is said in the tutorial: Open the file starter1.py in your Python-aware editor of choice. The Python script is, as you'd expect, brief and to the point. Here's the important part to focus on: def on_menuFileExit_select(self, event): pass But here's the starter1.py code: #!/usr/bin/python from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() As you can see, the on_menu line is not in the starter1.py original script, so I guessed that it should be a part of the Minimal class. Then the tutorial ask me to replace the on_menu pass line with: result = dialog.alertDialog(self, 'It works!', 'Showing Off') but when you run the script, it runs, but clicking on Exit does not display any dialog box. I did change the import line to include dialog. Is there something I'm not seeing here or there is really a mistake with the walkthrough? Thanks Denis -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Ilias Lazaridis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grant Edwards wrote: [...] Um, you realize that nobody in this thread takes you the least bit seriously and people are just poking you with a stick to watch you jump? jump: [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 Lol, this guy is hopeless :-) George -- http://mail.python.org/mailman/listinfo/python-list
Re: kill a process in XP
Tor Erik Sønvisen wrote: From my Python-program I spawn a new process. When using P_NOWAIT spawnl returns the pid but in windows it returns a process handle. Later I want to kill this process. How can I do this when I only have the process handle? Try ctypes - if it's really a Windows handle, then this should work: from ctypes import * windll.kernel32.TerminateProcess(h, 0) # or whatever return code you want -Dave -- http://mail.python.org/mailman/listinfo/python-list
PyEphem on Win32 -- 2nd try
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 A second request for help... Has anyone run the PyEphem ephemeris application under WinXP? http://rhodesmill.org/brandon/projects/pyephem.html I have compiled it with Visual Studio 6 and it crashes Python with a simple import ephem ephem.date('1994/7/16') Identical code works fine under Linux. I suspect that the problem has to do with a parser built into the c shell for the c code that the app wraps around. However, I am not good enough at c to spot the error. I am running ActivePython 2.3.5 Build 236 on a WinXP SP2 system with Visual Studio 6 patched to sp6. I would appreciate either help from a c guru who knows how to wrap python around c or a pointer to another list where experts might reside. - --- Cheers, David Flory -BEGIN PGP SIGNATURE- Version: PGP 8.1 iQA/AwUBQhy551e2/rcN3lp8EQIu2gCfRyDmSCtiP4uB2qKMtIvjcOOsNUkAn1FD rir+BKqfDqZ0P+lKcwfgdQPu =5+at -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
In message [EMAIL PROTECTED], George Sakkis [EMAIL PROTECTED] writes Ilias Lazaridis [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Grant Edwards wrote: [...] Um, you realize that nobody in this thread takes you the least bit seriously and people are just poking you with a stick to watch you jump? jump: [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 Lol, this guy is hopeless :-) Who's Guido? -- Stephen Kellett Object Media Limitedhttp://www.objmedia.demon.co.uk RSI Information:http://www.objmedia.demon.co.uk/rsi.html -- http://mail.python.org/mailman/listinfo/python-list
Arrow-keys bug.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi there. I'm making a talker's base in python and i'm with a serious bug in it. Everytime a client connects to the talker and presses for ex. the arrow key lets say twice, the following characters appears in it's screen: [[A[[A, if he presses enter to send that characters to all the users in the talker, the user's screen will go up two lines, and the input line will be there, replacing older text, instead of being where it should, in the bottom of the screen; this also works for the down key and for home, end, etc. Does anyone here knows how I can strip those keys? Thanks in advance. - -- Cumprimentos, Daniel Alexandre ( [EMAIL PROTECTED] ) Chave pblica PGP: http://student.dei.uc.pt/~dfcruz/pubring.html -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCHMAEL3+DjgQV3LgRApyBAJ9iPL428OkF1vHwTu61F6zQIz0SeQCg03D+ NAp+hY/10+IPUQa0T1fGjGY= =ooz8 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Stephen Kellett wrote: [...] Who's Guido? Guido is the one, who should care by time about the status of the python-community. - I've send an addition CC of this message to the python-foundation, which will hopefully take some steps to improve the build-system. [EVALUATION] - E02 - Support for MinGW Open Source Compiler Essence: http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 - Thank's for every bit of contribution, which has made this thread an worthfull insight into the python-community. . -- http://lazaridis.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comm. between Python and PHP
Hello Python is perfectly capable of generating HTML. You don't have to demean yourself by working in PHP. Thanks for the tip about using Python instead of PHP to generate web pages. I may follow it. Nils Emil -- My reply-address is valid. www.bios-flash.dk Min svar-adresse er gyldig. Redning af døde BIOS'er -- http://mail.python.org/mailman/listinfo/python-list
Re: Comm. between Python and PHP
Hello Sorry for not being too exact in my request! If the data you want to pass is structured then you might consider XML-RPC which is a cross platform way of passing structured data XML-RPC looks like something very suitable for my needs. It seems Python handles the remote procedure calls very easily (almost like local functions). It also works quite well in PHP. I didn't recompile anything but downloaded Keith Devens XML-RPC Library (500 lines code). With this I can call RPC-functions almost as easily as with Python. It took me just about an hour to get it working... Thanks everybody! Nils Emil P. Larsen -- My reply-address is valid. www.bios-flash.dk Min svar-adresse er gyldig. Redning af døde BIOS'er -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
On Wed, Feb 23, 2005 at 01:03:56AM -0600, Kenneth Pronovici wrote: [snip] Today, I accidentally ran across a directory containing three normal files (with ASCII filenames) and one file with a two-character unicode filename. My code, which was doing something like this: for entry in os.listdir(path): # path is type 'unicode' entrypath = os.path.join(path, entry) suddenly started blowing up with the dreaded unicode error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1: ordinal not in range(128) Sorry to reply to my own note, but after sleeping on it, I think I've come up with a reasonable solution. Now that I've dug further and my eyes are less bleery, everything seems to work as long as I only pass in simple strings to the filesystem functions. I think that I can solve my problem by just converting any unicode strings from configuration into utf-8 simple strings using encode(). Using this solution, all of my existing regression tests still pass, and my code seems to make it past the unusual directory. [u'README.strange-name', '\xe2\x99\xaa\xe2\x99\xac', u'utflist.long.gz', u'utflist.cp437.gz', u'utflist.short.gz'] Note that in this second result, element [1] is not a unicode string while the other three elements are. I'm still confused as to why this happens, but since I work around it, I guess I don't care so much. Thanks, KEN -- Kenneth J. Pronovici [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: Selective HTML doc generation
Graham said unto the world upon 2005-02-23 09:42: Hi. I'm looking for a documentation generation tool (such as pydoc, epydoc, happydoc, etc.) that will allow me to filter what it includes in it's output. I only want the reader to know about classes and methods in my package if if the classes have docstrings. I've got a large package that is used by relatively non-technical users (and yet they write Python!) that documents the public API with docstrings. I don't want to clutter their view of the world with links to the package's internal classes and documentation that covers things like __special__ methods. Anybody know of anything that let's you do it? I realise I may end up doing some hacking here but don't want to repeat work unnecessarily. Cheers, Graham Hi Graham, Warning I'm not at all an expert /Warning OK, that out of the way: I recently wanted pydoc to display information about my methods whose names started with one or more underscores, so that I could see in the docs for the objects in my first bigger than small project. I managed with a small change to the visiblename function of pydoc.py. It looks to me that this is also the place where you'd want to put in code to filter for only treating objects with docstrings. *How* to do that is something I've not read enough of pydoc.py to speak to. Omitting special methods is easy, though. The code says: # Private names are hidden, but special names are displayed. if name.startswith('__') and name.endswith('__'): return 1 So, just change the 1 to a 0. (The `private' logic is a few lines down.) Easy :-) Hope that is at least of some help. Best, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt and Python 2.4 - also WinXP LnF?
Simon John - Feb 10, 11:51 am: I've just read the Qt4 GPL for Windows will only support gcc (and maybe MinGW) anyway, not BCC or VisualC++ (or it's free equivalents), so it looks like it would be a daunting task to actually build PyQt Why? I think that it is fair. Why a Free Software developer should buy VC++ licenses to build free Qt? It is nonsense. gcc works under Windows, and that is enough. I guess a lot of this licensing crap will change when Qt4 GPL is actually released, but it's still looking like commercial Qt is the only easy way to go, and the Trolls are just making a difficult GPL version to shut people up! What is the matter with you? When Qt is released GPL for Windows, with the support from Trolltech, if they do not give you a .exe version of Qt, then someone should compile it. There is no need to compile it every time. I think Trolltech is right. If can afford Windows and VisualStudio, you can also afford Qt. Or maybe you are a pirate. -- http://mail.python.org/mailman/listinfo/python-list
Re: Style guide for subclassing built-in types?
[EMAIL PROTECTED] wrote: Kent Johnson wrote: [EMAIL PROTECTED] wrote: p.s. the reason I'm not sticking to reversed or even reverse : suppose the size of the list is huge. reversed() returns an iterator so list size shouldn't be an issue. What problem are you actually trying to solve? Kent Oh, you are right. Actually, it's more complicated than simple reversion. The list order should be somewhat twisted and the list is big. For example, [1,2,3,4,5,6,7,8,9,10] -- [10,9,8,7,6,1,2,3,4,5] so __getitem__(self,i) = __getitem__(self,-i-1) if ilen(size)/2, otherwise __getitem__(self,i-len(size)/2) I'd like to have TwistedList class that takes in an original list and pretends as if it is twisted actually. However, I have to have duplicate codes here and there to make it act like a list, say assert twisted_list == [10,9,...] and for each in twisted_list and etc. If you want a twisted 'view' of an existing list, then a wrapper makes most sense. If, however, you only need the twisted version, why not simply override list.__init__ (and extend, append etc... as required): class rev_list(list): ...def __init__(self, iterable): ...list.__init__(self, iterable[::-1]) ... l = rev_list([1,2,3]) l [3, 2, 1] Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt and Python 2.4 - also WinXP LnF?
Simon John - Feb 13, 4:24 pm: After building with MSVC6 (Python 2.3.5 and 2.4 versions) I've noticed that the ToolTips don't seem to work in the GPL version. Free (GPL) Qt3 port to Windows is not complete. They indeed need help to conclude their job. And as Trolltech is not going to release Qt3 under GPL, to encorage people using Qt4, this work of porting is not useless. MSVC6 is about twice as fast to build as MinGW I think it is because they use precompiled headers. But I prefer to wait rather than using MSVC. -- http://mail.python.org/mailman/listinfo/python-list
Re: running a shell command from a python program
In Python 2.4, use the new subprocess module for this. It subsume the popen* methods. Hi, I'm a newbie, so please be gentle :-) How would I run a shell command in Python? Here is what I want to do: I want to run a shell command that outputs some stuff, save it into a list and do stuff with the contents of that list. I started with a BASH script actually, until I realized I really needed better data structures :-) Is popen the answer? Also, where online would I get access to good sample code that I could peruse? I'm running 2.2.3 on Linux, and going strictly by online doc so far. Thanks! S C -- http://mail.python.org/mailman/listinfo/python-list
Re: PyEphem on Win32 -- 2nd try
A quick look at the site, and following the link to the XEphem site reveals that the Windows port of XEphem uses Cygwin. AFAIK, that's not compatible with the usual CPython implementation. Again, AFAIK, you'll either have to use a Python port compiled under Cygwin, or you'll have to find a Windows port compiled with VS 6 or higher. Someone who knows more about those issues will have to take it from here. John Roth [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 A second request for help... Has anyone run the PyEphem ephemeris application under WinXP? http://rhodesmill.org/brandon/projects/pyephem.html I have compiled it with Visual Studio 6 and it crashes Python with a simple import ephem ephem.date('1994/7/16') Identical code works fine under Linux. I suspect that the problem has to do with a parser built into the c shell for the c code that the app wraps around. However, I am not good enough at c to spot the error. I am running ActivePython 2.3.5 Build 236 on a WinXP SP2 system with Visual Studio 6 patched to sp6. I would appreciate either help from a c guru who knows how to wrap python around c or a pointer to another list where experts might reside. - --- Cheers, David Flory -BEGIN PGP SIGNATURE- Version: PGP 8.1 iQA/AwUBQhy551e2/rcN3lp8EQIu2gCfRyDmSCtiP4uB2qKMtIvjcOOsNUkAn1FD rir+BKqfDqZ0P+lKcwfgdQPu =5+at -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Don't understand global variables between modules
Fredrik Lundh [EMAIL PROTECTED] wrote: because running a script isn't the same thing as importing it. try adding print __name__ lines before your other print statements so you can see who's printing what. Is there more than one global space? in this case, there are more module namespaces than you think. this page might help (especially the Using Modules as Scripts section): http://effbot.org/zone/import-confusion.htm Thanks for your answer, and also thanks for effbot. Lots of good tips. Bart -- http://mail.python.org/mailman/listinfo/python-list
Re: user interface for python
Scott David Daniels [EMAIL PROTECTED] writes: Thomas Guettler wrote: You can write portable programs (if you test across platforms). The only truly portable programs in any language are abstract. Once you start dealing with I/O and the real world, you inevitably have to face issues one circumstance at a time. Both Tkinter and wxPython spend a lot of effort in reducing the work you have to do. Don't fool yourself with a manager-friendly slogan; programs must be tested to work. Any I/O heavy (or threaded, or ) application running on two platforms will take more work than on a single platform. Python and wxPython or Tkinter, for example, _allow_ you to write portable programs, but they don't _guarantee_ it. There are no portable programs, only ported programs. -- John Gilmore (?) mike -- Mike Meyer [EMAIL PROTECTED] http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list
select + ssl
Hello, I don't have the same behaviour with two codes who are quite the same, one using SSL, the other not. I tested the programs with stunnel and telnet , respectively. Here are the first code : #!/usr/bin/python from select import select import socket if __name__ == '__main__': s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 6001)) s.listen(5) ready_read = {} ready_send = {} ready_read[s] = s while True: rs, ws, _ = select(ready_read.keys(), ready_send.keys(), [], 2) print '.' for r in rs: if r == s: (cli, addr) = s.accept() ready_send[cli] = cli ready_read[cli] = cli else: ret = r.recv(1000) print 'ret =', ret for w in ws: w.send('you have to give up') The client receive the 'you have to give up' sentence every two seconds. The second code is : #!/usr/bin/python from select import select import socket from OpenSSL import SSL import os def verify_cb(): return ok if __name__ == '__main__': dir = '' ctx = SSL.Context(SSL.SSLv23_METHOD) ctx.set_options(SSL.OP_NO_SSLv2) ctx.set_verify(SSL.VERIFY_NONE, verify_cb) ctx.use_privatekey_file (os.path.join(dir, 'server.pkey')) ctx.use_certificate_file(os.path.join(dir, 'server.cert')) ctx.load_verify_locations(os.path.join(dir, 'CA.cert')) s = SSL.Connection(ctx, socket.socket(socket.AF_INET, socket.SOCK_STREAM)) #s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', 6000)) s.listen(5) s.setblocking(0) ready_read = {} ready_send = {} ready_read[s] = s while True: rs, ws, _ = select(ready_read.keys(), ready_send.keys(), [], 2) print '.' for r in rs: if r == s: (cli, addr) = s.accept() ready_send[cli] = cli ready_read[cli] = cli else: ret = r.recv(1000) print 'ret =', ret for w in ws: w.send('you have to give up') The server blocks on recv here. In both case I don't send anything with the client. (Perhaps stunnel send something that I don't see ?) Why does the server block ? Kototama -- http://mail.python.org/mailman/listinfo/python-list
Re: On eval and its substitution of globals
Thanks Kent for your reply. I had to do as you suggest but I was thinking either it was a kludge, and there should be a 'deep' substitution of globals, or that there was a good reason for it to work as it does and some magician would tell me. Oh, the third reason could be that it was first implimented that way and no-one has submitted a patch of course. Could someone clue me in? Ta, Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Ilias Lazaridis [EMAIL PROTECTED] writes: Guido is the one, who should care by time about the status of the python-community. That one crashed my parser. Thank's for every bit of contribution, which has made this thread an worthfull insight into the python-community. To really get a sense of the Python community (at least the Usenet branch), you should see how it responds to typical questions and requests for help. The response you received is not really typical, because your attitude has been atypical. Just sayin', Nick -- # sigmask || 0.2 || 20030107 || public domain || feed this to a python print reduce(lambda x,y:x+chr(ord(y)-1),' Ojdl!Wbshjti!=obwAcboefstobudi/psh?') -- http://mail.python.org/mailman/listinfo/python-list
Re: assert 0, foo vs. assert(0, foo)
Thomas Guettler wrote: Is it possible to change future python versions, that assert accept parenthesis? It's possible, but extremely unlikely that it will ever happen. assert is not a function, but a statement (like print). Statements don't use parentheses; when you use parentheses, it considers that a tuple. For example, if you try this with print: print (hello,world) you see that in prints out a tuple value, rather than treating hello and world as arguments. Same thing with assert. -- CARL BANKS -- http://mail.python.org/mailman/listinfo/python-list
Re: Dealing with config files what's the options
Tom Willis [EMAIL PROTECTED] writes: How are the expert pythoneers dealing with config files? You could use the cPickle module if you don't mind your config files being unreadable by humans. There is also the shlex module for more powerful config file needs: http://docs.python.org/lib/module-shlex.html While I'm replying to you, would you mind if I take the opportunity to ask you to stop top-posting? Thanks, Phil -- http://mail.python.org/mailman/listinfo/python-list
Communication between JAVA and python
Hello How can I transfert information between a JAVA application and a python script application. I can't use jython because, I must use python interpreter.I think to socket or semaphore, but can I use it on Windows plateform ? thanks a lot jack -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with minidom and special chars in HTML
Horst Gutmann napisa(a): Don't use minidom or convert HTML4 to XHTML and change declaration of doctype. This was just a bad example :-) I get the same problem with XHTML in the doctype. The funny thing here IMO is, that the special chars are simply removed. No warning, no nothing :-( As Fredrik pointed out, it's minidom that cann't fetch DTD from remote location. Download this DTD file to your local machine (it lies at exactly this URI), try changing PUBLIC identifier to SYSTEM and give local path to this file. -- Jarek Zgoda http://jpa.berlios.de/ | http://www.zgodowie.org/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythoncard - Mistake in walkthrough?
As stated in the on-line WalkThrough, the information there was written for an older version of the program. Deltones [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I'm just getting into Python/wxPython/Pythoncard and I'm trying the tutorial from this page: http://pythoncard.sourceforge.net/walkthrough1.html Is it me who's totally dense or there's some sort of confusion with this tutorial? Here's what is said in the tutorial: Open the file starter1.py in your Python-aware editor of choice. The Python script is, as you'd expect, brief and to the point. Here's the important part to focus on: def on_menuFileExit_select(self, event): pass But here's the starter1.py code: #!/usr/bin/python from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() As you can see, the on_menu line is not in the starter1.py original script, so I guessed that it should be a part of the Minimal class. Then the tutorial ask me to replace the on_menu pass line with: result = dialog.alertDialog(self, 'It works!', 'Showing Off') but when you run the script, it runs, but clicking on Exit does not display any dialog box. I did change the import line to include dialog. Is there something I'm not seeing here or there is really a mistake with the walkthrough? Thanks Denis -- http://mail.python.org/mailman/listinfo/python-list
Yahoo! Auto Response
Hi - This is the vacation program; I'm working for my owner, Ben. The account to which you have sent your mail is going to be discontinued at at the end of July (Yahoo's mail service has deteriorated well past abysmal into nightmarishly bad, and the trend shows no sign of stopping). Please update your information for Ben; his new email address is at the callahans.org domain under the username of ben (it is not shown as a complete address in order to foil stupid spambots; use it as [EMAIL PROTECTED].) Sorry about any inconvenience, and have a nice day. Original Message: X-YahooFilteredBulk: 61.1.74.98 Authentication-Results: mta106.mail.mud.yahoo.com from=python.org; domainkeys=neutral (no sig) X-Originating-IP: [61.1.74.98] Return-Path: python-list@python.org Received: from 61.1.74.98 (EHLO yahoo.com) (61.1.74.98) by mta106.mail.mud.yahoo.com with SMTP; Wed, 23 Feb 2005 12:25:29 -0800 From: python-list@python.org To: [EMAIL PROTECTED] Subject: Re: Message Error Date: Thu, 24 Feb 2005 01:55:13 +0530 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary==_NextPart_000_0016=_NextPart_000_0016 X-Priority: 3 X-MSMail-Priority: Normal This is a multi-part message in MIME format. --=_NextPart_000_0016=_NextPart_000_0016 Content-Type: text/plain; charset=Windows-1252 Content-Transfer-Encoding: 7bit For further details see the attachment. +++ Attachment: No Virus found +++ Kaspersky AntiVi _ DO YOU YAHOO!? Get your free @yahoo.com address at http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list
Re: On eval and its substitution of globals
Paddy wrote: I had to do as you suggest but I was thinking either it was a kludge, and there should be a 'deep' substitution of globals, or that there was a good reason for it to work as it does and some magician would tell me. If there was deep substitution of globals, how would functions imported from different modules behave? Consider this: --- foo.py --- from bar import func data = 24 print func() print eval('func()', globals(), locals()) --- bar.py --- data = 42 def func(): return data If globals were deeply substituted when using eval, the program would presumably print 42\n24, which would be far from intuitive. If you limit the deep substitution to functions in the same module, you're creating a confusing special case. -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(obj, errors='foo') raises TypeError - bug?
Steven Bethard wrote: Yeah, I agree it's weird. I suspect if someone supplied a patch for this behavior it would be accepted -- I don't think this should break backwards compatibility (much). Notice that the right thing to do would be to pass encoding and errors to __unicode__. If the string object needs to be told what encoding it is in, why not any other other object as well? Unfortunately, this apparently was overlooked, and now it is too late to change it (or else the existing __unicode__ methods would all break if they suddenly get an encoding argument). As for using encoding and errors on the result of str() conversion of the object: how can the caller know what encoding the result of str() is in, reasonably? It seems more correct to assume that the str() result in in the system default encoding. If you can follow so far(*): if it is the right thing to ignore the encoding argument for the case that the object was str() converted, why should the errors argument not be ignored? It is inconsistent to ignore one parameter to the decoding but not the other. Regards, Martin (*) I admit that the reasoning for ignoring the encoding is somewhat flawed. There are some types (e.g. numbers) where str() always uses the system encoding (i.e. ASCII - actually, it always uses ASCII, no matter what the system encoding is). There may be types where the encoding of the str() result is not ASCII, and the caller happens to know what it is, but I'm not aware of any such type. -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
Kenneth Pronovici wrote: I think that I can solve my problem by just converting any unicode strings from configuration into utf-8 simple strings using encode(). Using this solution, all of my existing regression tests still pass, and my code seems to make it past the unusual directory. See my other post. UTF-8 might be the wrong choice: the path might be encoded as, say, ISO-8859-1 on disk, in which case an UTF-8-encoded path would not be found. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
Kenneth Pronovici wrote: 1) Why LC_ALL has any effect on the os.listdir() result? The operating system (POSIX) does not have the inherent notion that file names are character strings. Instead, in POSIX, file names are primarily byte strings. There are some bytes which are interpreted as characters (e.g. '\x2e', which is '.', or '\x2f', which is '/'), but apart from that, most OS layers think these are just bytes. Now, most *people* think that file names are character strings. To interpret a file name as a character string, you need to know what the encoding is to interpret the file names (which are byte strings) as character strings. There is, unfortunately, no operating system API to carry the notion of a file system encoding. By convention, the locale settings should be used to establish this encoding, in particular the LC_CTYPE facet of the locale. This is defined in the environment variables LC_CTYPE, LC_ALL, and LANG (searched in this order). 2) Why only 3 of the 4 files come back as unicode strings? If LANG is not set, the C locale is assumed, which uses ASCII as its file system encoding. In this locale, '\xe2\x99\xaa\xe2\x99\xac' is not a valid file name (atleast it cannot be interpreted as characters, and hence not be converted to Unicode). Now, your Python script has requested that all file names *should* be returned as character (ie. Unicode) strings, but Python cannot comply, since there is no way to find out what this byte string means, in terms of characters. So we have three options: 1. skip this string, only return the ones that can be converted to Unicode. Give the user the impression the file does not exist. 2. return the string as a byte string 3. refuse to listdir altogether, raising an exception (i.e. return nothing) Python has chosen alternative 2, allowing the application to implement 1 or 3 on top of that if it wants to (or come up with other strategies, such as user feedback). 3) The proper general way to deal with this situation? You can chose option 1 or 3; you could tell the user about it, and then ignore the file, you could try to guess the encoding (UTF-8 would be a reasonable guess). My goal is to build generalized code that consistently works with all kinds of filenames. Then it is best to drop the notion that file names are character strings (because some file names aren't). You do so by converting your path variable into a byte string. To do that, you could try path = path.encode(sys.getfilesystemencoding()) This should work in most cases; Python will try to determine the file system encoding from the environment, and try to encode the file. Notice, however: - on some systems, getfilesystemencoding may return None, if the encoding could not be determined. Fall back to sys.getdefaultencoding in this case. - depending on where you got path from, this may raise a UnicodeError, if the user has entered a path name which cannot be encoding in the file system encoding (the user may well believe that she has such a file on disk). So your code would read try: path = path.encode(sys.getfilesystemencoding() or sys.getdefaultencoding()) except UnicodeError: print sys.stderr, Invalid path name, repr(path) sys.exit(1) Ultimately, all I'm trying to do is copy some files around. I'd really prefer to find a programmatic way to make this work that was independent of the user's configured locale, if possible. As long as you manage to get a byte string from the path entered, all should be fine. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Python and Ajax technology collaboration
Interesting GUI developments, it seems. Anyone developed a Ajax application using Python? Very curious thx (Ajax stands for: XHTML and CSS; dynamic display and interaction using the Document Object Model; data interchange and manipulation using XML and XSLT; asynchronous data retrieval using XMLHttpRequest; and JavaScript binding everything together ie Google has used these technologies to build Gmail, Google Maps etc. more info: http://www.adaptivepath.com/publications/essays/archives/000385.php) -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
Martin v. Löwis wrote: My goal is to build generalized code that consistently works with all kinds of filenames. Then it is best to drop the notion that file names are character strings (because some file names aren't). You do so by converting your path variable into a byte string. To do that, you could try path = path.encode(sys.getfilesystemencoding()) Shouldn't os.path.join do that? If you pass a unicode string and a byte string it currently tries to convert bytes to characters but it makes more sense to convert the unicode string to bytes and return two byte strings concatenated. Serge. -- http://mail.python.org/mailman/listinfo/python-list
msnp group chats
I'm currently using the msnp.py module in a project. We are trying to implement a group chats feature. Has anyone had any success in doing this or know how to do this? We have it doing single chats, but we can't figure out how MSN is adding the multiple invites. Any help would be greatly appreciated! -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
Serge Orlov wrote: Shouldn't os.path.join do that? If you pass a unicode string and a byte string it currently tries to convert bytes to characters but it makes more sense to convert the unicode string to bytes and return two byte strings concatenated. Sounds reasonable. OTOH, this would be the only (one of a very few?) occasion where Python combines byte+unicode = byte. Furthermore, it might be that the conversion of the Unicode string to a file name fails as well. That said, I still think it is a good idea, so contributions are welcome. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Ajax technology collaboration
It was discussed in the last Bay Area Python Interest Group meeting. Thursday, February 10, 2005 Agenda: Developing Responsive GUI Applications Using HTML and HTTP Speakers: Donovan Preston http://www.baypiggies.net/ The author has a component LivePage for this. You may find it from http://nevow.com/. Similar idea from the Javascript stuff but very Python centric. Interesting GUI developments, it seems. Anyone developed a Ajax application using Python? Very curious thx (Ajax stands for: XHTML and CSS; dynamic display and interaction using the Document Object Model; data interchange and manipulation using XML and XSLT; asynchronous data retrieval using XMLHttpRequest; and JavaScript binding everything together ie Google has used these technologies to build Gmail, Google Maps etc. more info: http://www.adaptivepath.com/publications/essays/archives/000385.php) -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
In message [EMAIL PROTECTED], Ilias Lazaridis [EMAIL PROTECTED] writes Stephen Kellett wrote: [...] Who's Guido? Guido is the one, who should care by time about the status of the python-community. Who is care by time? -- Stephen Kellett Object Media Limitedhttp://www.objmedia.demon.co.uk RSI Information:http://www.objmedia.demon.co.uk/rsi.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Ajax technology collaboration
John Willems wrote: Interesting GUI developments, it seems. Anyone developed a Ajax application using Python? Very curious thx (Ajax stands for: XHTML and CSS; dynamic display and interaction using the Document Object Model; data interchange and manipulation using XML and XSLT; asynchronous data retrieval using XMLHttpRequest; and JavaScript binding everything together We're using it in a couple of projects with Zope as the backend and it works really well - the web applications are way more responsive now (I'm hoping someone with lots of Zope knowledge will redo the ZMI itself using this approach). -Dave -- http://mail.python.org/mailman/listinfo/python-list
Re: unicode(obj, errors='foo') raises TypeError - bug?
Martin v. Lwis wrote: Steven Bethard wrote: Yeah, I agree it's weird. I suspect if someone supplied a patch for this behavior it would be accepted -- I don't think this should break backwards compatibility (much). Notice that the right thing to do would be to pass encoding and errors to __unicode__. If the string object needs to be told what encoding it is in, why not any other other object as well? Unfortunately, this apparently was overlooked, and now it is too late to change it (or else the existing __unicode__ methods would all break if they suddenly get an encoding argument). Could this be handled with a try / except in unicode()? Something like this: class A: ... def u(self): # __unicode__ with no args ... print 'A.u()' ... class B: ... def u(self, enc, err): # __unicode__ with two args ... print 'B.u()', enc, err ... def convert(obj, enc='ascii', err='strict'): # unicode() function delegates to u() ... try: ... obj.u(enc, err) ... except TypeError: ... obj.u() ... convert(a) A.u() convert(a, 'utf-8', 'replace') A.u() convert(b) B.u() ascii strict convert(b, 'utf-8', 'replace') B.u() utf-8 replace As for using encoding and errors on the result of str() conversion of the object: how can the caller know what encoding the result of str() is in, reasonably? The same way that the caller will know the encoding of a byte string, or of the result of str(some_object) - in my experience, usually by careful detective work on the source of the string or object followed by attempts to better understand and control the encoding used throughout the application. It seems more correct to assume that the str() result in in the system default encoding. To assume that in absence of any guidance, sure, that is consistent. But to ignore the guidance the programmer attempts to provide? One thing that hasn't been pointed out in this thread yet is that the OP could just define __unicode__() on his class to do what he wants... Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Dealing with config files what's the options
On Wed, 23 Feb 2005 20:15:47 +, Phil Jackson [EMAIL PROTECTED] wrote: Tom Willis [EMAIL PROTECTED] writes: How are the expert pythoneers dealing with config files? You could use the cPickle module if you don't mind your config files being unreadable by humans. There is also the shlex module for more powerful config file needs: http://docs.python.org/lib/module-shlex.html While I'm replying to you, would you mind if I take the opportunity to ask you to stop top-posting? Thanks, Phil -- http://mail.python.org/mailman/listinfo/python-list sigh I guess. It's just so inconvenient in gmail. But anything for you. I'll try to try. :) Thanks for the info. -- Thomas G. Willis http://paperbackmusic.net -- http://mail.python.org/mailman/listinfo/python-list
Re: LC_ALL and os.listdir()
On Wed, Feb 23, 2005 at 10:07:19PM +0100, Martin v. Löwis wrote: So we have three options: 1. skip this string, only return the ones that can be converted to Unicode. Give the user the impression the file does not exist. 2. return the string as a byte string 3. refuse to listdir altogether, raising an exception (i.e. return nothing) Python has chosen alternative 2, allowing the application to implement 1 or 3 on top of that if it wants to (or come up with other strategies, such as user feedback). Understood. This appears to be the most flexible solution among the three. 3) The proper general way to deal with this situation? You can chose option 1 or 3; you could tell the user about it, and then ignore the file, you could try to guess the encoding (UTF-8 would be a reasonable guess). Ok. My goal is to build generalized code that consistently works with all kinds of filenames. Then it is best to drop the notion that file names are character strings (because some file names aren't). You do so by converting your path variable into a byte string. To do that, you could try [snip] So your code would read try: path = path.encode(sys.getfilesystemencoding() or sys.getdefaultencoding()) except UnicodeError: print sys.stderr, Invalid path name, repr(path) sys.exit(1) This makes sense to me. I'll work on implementing it that way. Thanks for the in-depth explanation! KEN -- Kenneth J. Pronovici [EMAIL PROTECTED] Personal Homepage: http://www.skyjammer.com/~pronovic/ They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. - Benjamin Franklin, Historical Review of Pennsylvania, 1759 -- http://mail.python.org/mailman/listinfo/python-list