Leipzig Python User Group - Meeting, August 16, 2006, 8:00pm
= Leipzig Python User Group = Next Meeting Wednesday, August 16, 2006 --- We will meet on August 16 at 8:00 pm at the training center of Python Academy in Leipzig, Germany (http://www.python-academy.com/center/find.html). Our regular meeting time, the second Tuesday of the month, would be August 8. We postpone to next week because the meeting location is not available at this regular date. Stefan Schwarzer will present his Python module ftputil. Food and soft drinks are provided. Please send a short confirmation mail to [EMAIL PROTECTED], so we can prepare appropriately. Everybody who uses Python, plans to do so or is interested in learning more about the language is encouraged to participate. While the meeting language will be mainly German, English speakers are very welcome. We will provide English interpretation if needed. Current information about the meetings can always be found at http://www.python-academy.com/user-group/index.html = Leipzig Python User Group = Stammtisch am 16.08.2006 - Wir treffen uns am 16.08.2006 um 20:00 Uhr wieder im im Schulungszentrum der Python Academy in Leipzig (http://www.python-academy.de/Schulungszentrum/anfahrt.html). Am planmäßigen zweiten Dienstag im Monat, dem 8.August, steht unser Treffpunkt nicht zur Verfügung, so dass wir das Treffen auf nächste Woche verschieben. Stefan Schwarzer stellt sein Python-Modul ftputil vor. Für das leibliche Wohl wird gesorgt. Wir bitten um kurze Anmeldung per e-mail an: [EMAIL PROTECTED] An den Treffen der Python Anwendergruppe kann jeder teilnehmen, der Interesse an Python hat, die Sprache bereits nutzt oder nutzen möchte. Die Arbeitssprachen des Treffens ist Deutsch. Englisch sprechende Python-Enthusiasten sind trotzdem herzlich eingeladen. Wir übersetzen gern. Aktuelle Informationen zu den Treffen sind immer unter http://www.python-academy.de/User-Group/index.html zu finden. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
No August Fredericksburg ZPUG
The Fredericksburg, VA ZPUG will be taking a break this month: no August 9 meeting. Thanks Gary -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Static Variables in Python?
Cameron Laird wrote: In article [EMAIL PROTECTED], Paddy [EMAIL PROTECTED] wrote: . [substantial thread with many serious alternatives] . . You can do things with function attributes def foo(x): foo.static += x return foo.static foo.static = 0 . . . My favorite variation is this: def accumulator(x): # On first execution, the attribute is not yet known. # This technique allows use of accumulator() as a # function without the consumer having to initialize # it. if not static in dir(accumulator): accumulator.static = 0 accumulator.static += x return accumulator.static print accumulator(3) print accumulator(5) Thanks Cameron, I'll accumulate this in my toolbox. - pad. -- http://mail.python.org/mailman/listinfo/python-list
import help
Hi all, How do i import a module that has an hypen/dash (-) in its name ? I get a SytaxError exception Cheers -- http://mail.python.org/mailman/listinfo/python-list
Re: import help
placid wrote: Hi all, How do i import a module that has an hypen/dash (-) in its name ? I get a SytaxError exception Cheers You can't do that directly. However, the internals of the import mechanism are available to the programmer through a module named imp. It allows you to import a file whose name is specified in a string -- that should work for you. Gary Herron -- http://mail.python.org/mailman/listinfo/python-list
Re: import help
placid wrote: Hi all, How do i import a module that has an hypen/dash (-) in its name ? I get a SytaxError exception You can use function __import__. print open(-test.py).read() def fun2(): return Hello from -test ! import -test File stdin, line 1 import -test ^ SyntaxError: invalid syntax __import__(-test, globals(), locals(), []) module '-test' from '-test.pyc' But here is another problem: -test.fun2() Traceback (most recent call last): File stdin, line 1, in ? NameError: name 'test' is not defined import sys sys.modules[-test].fun2() 'Hello from -test !' Regards, Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Import module with non-standard file name
Patrick Maupin [EMAIL PROTECTED] writes: Ben Finney wrote: Question: I have Python modules named without '.py' as the extension, and I'd like to be able to import them. How can I do that? This is a piece of cake in Python. from types import ModuleType x = ModuleType('myModName') data = open('myfilename').read() exec data in x.__dict__ Your output here... This won't save a .pyc, but as your message later explains, this is for unittesting, so this could probably be considered a feature for this usage. Very nice. Okay, my unit testing scaffold module now has a new function: def make_module_from_file(module_name, file_name): Make a new module object from the code in specified file from types import ModuleType module = ModuleType(module_name) module_file = open(file_name, 'r') exec module_file in module.__dict__ return module The unit test now just imports that functionality, and then makes the module object via that function: import scaffold module_name = 'frobnicate_foo' module_file_under_test = os.path.join(scaffold.code_dir, 'frobnicate-foo') frobnicate_foo = scaffold.make_module_from_file( module_name, module_file_under_test) The rest of the unit test then has 'frobnicate_foo' as a module to test. It's working fine. Does anyone foresee any problems with doing it this way? -- \ Injustice is relatively easy to bear; what stings is justice. | `\ -- Henry L. Mencken | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: singleton decorator
[EMAIL PROTECTED] wrote: Andre Meyer: What is the preferred pythonic way of implementing singleton elegantly? Maybe to just use a module. Bye, bearophile Here is some sample code for both singleton classes and named classes that I use: class Singleton(type): This class will allow only one instance of a type regardless of the initialization arguments. def __init__(self, *args, **kwargs): This is done when the class is defined. type.__init__(self, *args, **kwargs) self._instance = None def __call__(self, *args, **kwargs): This is called when the class is instantiated. if not self._instance : self._instance = type.__call__(self,*args,**kwargs) return self._instance class namedSingleton(type): This class will allow a different singleton per initialization argument list. This implementation does not take into account variations in the keyword args. def __init__(self, *args, **kwargs): This is executed when the class is first defined. type.__init__(self, *args, **kwargs) self._instances = {} def __call__(self, *args, **kwargs): This is called when the class is instantiated. if not args in self._instances: self._instances[args] = type.__call__(self, *args,**kwargs ) return self._instances[args] -- http://mail.python.org/mailman/listinfo/python-list
urllib and urllib2, with proxies
hello all, I just maybe hit a bug in both urllib and urllib2, actually urllib doesn't support proxy authentication, and if you setup the http_proxy env var to http_proxy=http://user:[EMAIL PROTECTED]:port/ and https_proxy=$http_proxy i get a traceback : Traceback (most recent call last): File test_urllib.py, line 2, in ? urllib.urlopen(https://sf.net/;) File /usr/lib/python2.4/urllib.py, line 82, in urlopen return opener.open(url) File /usr/lib/python2.4/urllib.py, line 190, in open return getattr(self, name)(url) File /usr/lib/python2.4/urllib.py, line 313, in open_http h.endheaders() File /usr/lib/python2.4/httplib.py, line 798, in endheaders self._send_output() File /usr/lib/python2.4/httplib.py, line 679, in _send_output self.send(msg) File /usr/lib/python2.4/httplib.py, line 646, in send self.connect() File /usr/lib/python2.4/httplib.py, line 614, in connect socket.SOCK_STREAM): IOError: [Errno socket error] (-2, 'Name or service not known') now with urllib2, it goes beyond that and connect and authenticate to the proxy, however, instead of using CONNECT with https, it simply does a GET, which result in a error 501 with a squid proxy: Traceback (most recent call last): File test_urllib.py, line 2, in ? urllib2.urlopen(https://sf.net/;) File /usr/lib/python2.4/urllib2.py, line 130, in urlopen return _opener.open(url, data) File /usr/lib/python2.4/urllib2.py, line 358, in open response = self._open(req, data) File /usr/lib/python2.4/urllib2.py, line 376, in _open '_open', req) File /usr/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /usr/lib/python2.4/urllib2.py, line 573, in lambda lambda r, proxy=url, type=type, meth=self.proxy_open: \ File /usr/lib/python2.4/urllib2.py, line 597, in proxy_open return self.parent.open(req) File /usr/lib/python2.4/urllib2.py, line 364, in open response = meth(req, response) File /usr/lib/python2.4/urllib2.py, line 471, in http_response response = self.parent.error( File /usr/lib/python2.4/urllib2.py, line 402, in error return self._call_chain(*args) File /usr/lib/python2.4/urllib2.py, line 337, in _call_chain result = func(*args) File /usr/lib/python2.4/urllib2.py, line 480, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 501: Not Implemented this is with python-2.4.3 thank you for your help -- Ali Sabil -- http://mail.python.org/mailman/listinfo/python-list
Re: Ann: SE 2.2b
Anthra Norell wrote: If you go to http://www.python.org/pypi. you see it about in the middle of the recently updated packages. It's blue, so you can click it and you're there. The update page shows only the twenty most recent updates. So they drop out at the bottom rather fast. If it's gone by the time you check, type SE into the search template in the upper right corner. Thanks, but I know how to use the Cheese Shop. Last time I looked, there was no file available for download. Now it is. Georg -- http://mail.python.org/mailman/listinfo/python-list
=?utf-8?Q?Re:_Leipzig_Python_User_Group_=2D_Meeting, _August_16, _2006, _8:00pm?=
I'll be out of the office until approximately August 20th. If you have any questions, please email [EMAIL PROTECTED] -- David Wahler -- http://mail.python.org/mailman/listinfo/python-list
Re: Class attributes, instances and metaclass __getattribute__
Pedro Werneck wrote: When I access a class attribute, on a class with a custom metaclass with a __getattribute__ method, the method is used when acessing some attribute directly with the class object, but not when you do it from the instance. code type='prompt' class M(type): ... def __getattribute__(cls, attr): ... print cls, attr ... return type.__getattribute__(cls, attr) ... class C(object): ... __metaclass__ = M ... C.x = 'foo' C.x class '__main__.C' x 'foo' o = C() o.x 'foo' /code Someone at freenode #python channel involved with python-dev sprint suggested it might be a bug, worth mentioning... to me it seems like a decision to avoid some problems with method and descriptors creation, since someone using metaclasses and custom __getattribute__ at the same time is asking for trouble, but... I googled for it and tried to find something on the list but, nothing. From the source it seems like a generic wrapper is used. What's the real case here ? Regards, -- Pedro Werneck To me, it seems consistent. As said in http://www-128.ibm.com/developerworks/linux/library/l-pymeta2/ The availability of metaclass attributes is not transitive; in other words, the attributes of a metaclass are available to its instances, but not to the instances of the instances. Just this is the main difference between metaclasses and superclasses. Since this happens for real attributes, it looks natural that the same should happen for 'virtual' attributes implemented via '__getattr__' or '__getattribute__'. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Looking for an intellisense with good help IDE for Python
Hi, I would like an IDE that shows me all methods and functions I can call on a particular data item. For instance, iter() can be called on any sequence, but it is not a method. Nonetheless, I would like for something to show me every thing that I can call on a particular data item. This includes % after a string. I would also like browseable help with good examples on whatever methods and functions and operators it pops up. Thanks, Terrence -- http://mail.python.org/mailman/listinfo/python-list
Re: access abook addressbook with curses
On 2006-08-08, Fabian Braennstroem [EMAIL PROTECTED] wrote: Hi Ben, * Ben C [EMAIL PROTECTED] wrote: On 2006-08-06, Fabian Braennstroem [EMAIL PROTECTED] wrote: Hi Ben, * Ben C [EMAIL PROTECTED] wrote: On 2006-08-05, Fabian Braennstroem [EMAIL PROTECTED] wrote: Hi, I want to get access to my abook address file with python. Does anyone have some python lines to achive this using curses? If not, maybe anybody has small python program doing it with a gui!? You can just parse the abook addressbook with the ConfigParser, try this: import os from ConfigParser import * abook = ConfigParser() abook.read(os.environ[HOME] + /.abook/addressbook) for s in abook.sections(): print abook.items(s) Thanks! I found a different example too: import ConfigParser import string config = ConfigParser.ConfigParser() config.read(/home/fab/.abook/addressbook) # print summary print for number in [2,200]: print string.upper(config.get(str(number), email)) print string.upper(config.get(str(number), name)) print string.upper(config.get(str(number), city)) print string.upper(config.get(str(number), address)) but the problem seems to be that abook does not write every field, so I get an exception when there is a field missing: Traceback (most recent call last): File configparser-example-1.py, line 13, in ? print string.upper(config.get(str(number), city)) File /usr/lib/python2.4/ConfigParser.py, line 520, in get raise NoOptionError(option, section) ConfigParser.NoOptionError: No option 'city' in section: '2' Section 2 looks like: [2] name=Andrs Gzi [EMAIL PROTECTED] nick=oz Is there a workaround? You can construct the parser with a dictionary of defaults: config = ConfigParser.ConfigParser({city : unknown, zip : unknown}) that kind of thing. Or catch the exceptions. Or use config.options(2) to see what options exist in section 2 before you try to read them. Thanks! I will try it out! Looking at the bigger picture here, though, I may be giving you the wrong advice. Mutt just invokes abook to get the addresses I think, that's why you put set query_command=abook --mutt-query '%s' So you could do the same (if what you're trying to do is write a mutt clone in Python): import subprocess name = Andrs subprocess.Popen(abook --mutt-query + name, stdout=subprocess.PIPE, shell=True).communicate()[0] The difference is that this leverages abook to do the search, not just to store the data, which is a logical approach. On the other hand, this way, you require that abook is installed on the machine, which is no good if the object of the exercise is a portable Python-only solution. -- http://mail.python.org/mailman/listinfo/python-list
variable creation
Hei all, im trying to create a list of variables for further use: Els = raw_input(Are there any further elements you would like to include? if so type the element, eg, Pd. If not type No: ) if Els != 'No': el = Els in pt while el == 1 and Els != 'Next': elements = [] elements.insert(-1, Els) Els = raw_input(Which further element would you like to include, eg, Pd, if not type Next: ) el = Els in pt while el == 0 and Els != 'Next': Els = raw_input(This is not an element in the periodic table, please try again, eg Pd, If you dont wish to include any more, type Next: ) if el == 1: elements.insert(-1, Els) while el == 0: Els = raw_input(This is not an element in the periodic table, please try again, eg Pd. If you dont wish to include any more, type Next: ) print elements this works to a certain extent but gets stuck on some loop. Im a beginner and am not sure where im going wrong. here is a portion of the dictionary containing typical elements: pt = {'H': 1.00794, 'He': 4.002602, 'Li': 6.941, 'Be': 9.012182, 'B': 10.811} Ali -- Dr. Alistair King Research Chemist, Laboratory of Organic Chemistry, Department of Chemistry, Faculty of Science P.O. Box 55 (A.I. Virtasen aukio 1) FIN-00014 University of Helsinki Tel. +358 9 191 50429, Mobile +358 (0)50 5279446 Fax +358 9 191 50366 -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
Op 8-aug-2006, om 1:49 heeft Ben Finney het volgende geschreven: As others have pointed out, these people really do exist, and they each believe their preconception -- that significant whitespace is intrinsically wrong -- is valid, and automatically makes Python a lesser language. Well, I most certainly disagree with that, of course, but you gotta admit that there's something really charming about running an auto- formatting script on a large piece of C code, turning it from an unreadable mess into a beautifully indented and organized document. I actually sometimes intentionally programmed ugly code so that I could do that. I kind of miss it. :) Michiel -- http://mail.python.org/mailman/listinfo/python-list
Dr. Dobb's Python-URL! - weekly Python news and links (Aug 8)
QOTW: being able to cook an egg - Guido Van Rossum in response to the question, What do you think is the most important skill every programmer should posses? I am asking for your forgiveness - an open letter to Guido by someone who took the D in BDFL too literally. Parsing a Grammar. Several solid tools are suggested. http://groups.google.com/group/comp.lang.python/browse_thread/thread/ea9736e13bd20fe2 Alex Martelli was awarded the Frank Willison award at OSCON. Can I define one class across multiple files? Yes, but the need does have a code smell... http://groups.google.com/group/comp.lang.python/browse_thread/thread/4633283e851f6d9e Broken decorator example in a PEP -- it's a decorated class! Here are work arounds (python 2.6 cometh, never fear!) http://groups.google.com/group/comp.lang.python/browse_thread/thread/930e574102c9ac03 Releases of Note Revision 51087. It isn't prime. It isn't the product of two cubes. It is python2.5 beta3. http://www.python.org/download/releases/2.5/ http://www.python.org/dev/peps/pep-0356/ mod_python 3.2.10 released. http://groups.google.com/group/comp.lang.python/browse_thread/thread/2694ccef2bee274b functional 0.7 released. Functional toolkit for python. http://groups.google.com/group/comp.lang.python/browse_thread/thread/136c70074e0b5357 Clever Harold released. py_web_frameworks += 1 http://blog.melhase.net/articles/2006/08/02/clever-harold-the-shocking-first-exclusive Upcoming Community Events SciPy - Scientific Python Conference Aug 17-18 (Pasadena, CA) http://www.scipy.org/SciPy2006/ Open Source Developers Conference Dec 5-8 (Melbourne, Australia) http://www.osdc.com.au/ Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. For far, FAR more Python reading than any one mind should absorb, much of it quite interesting, several pages index much of the universe of Pybloggers. http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog http://www.planetpython.org/ http://mechanicalcat.net/pyblagg.html comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard, Tim Lesher, and Tony Meyer continue the marvelous tradition early borne by Andrew Kuchling, Michael Hudson and Brett Cannon of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/python/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes.
beginner questions on embedding/extending python with C++
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. One example is that a user can write a python script like: player = Player() game.loadPlayer(player) player.moveTo(location) To configure the game environment. I am trying to figure out how to make this happen. I only have the vague idea that this concerns embedding/extending python with C++, but after reading Python Doc, SWIG, BOOST.Python, I am still not sure how to architecture it. Since the main program is still going to be the C++ application, I guess we need to embedding the python scripts in the C++ code. So at initialization stage, the python script needs to be loaded into the C++ code. And this code can be simple, like player = Player() game.loadPlayer(player) But for this to work, the python code needs to know the Player class, is it right? Does that mean I need to build a python wrapper class for Player and import Player in the python code? But because this application is built on top of a game engine, Player class inherits many classes from there, I cannot possibly wrapping them all, right? Also, some global objects are probably needed in this code of adding players, how can the python code access them? I know I probably don't have a grasp of basics here, please kindly enlighten me! Btw, if you can point me to any source code of non-trivial projects utilizing SWIG/Boost.Python, that would be very helpful. I found the examples on the tutorials are far too simple. Thank you very much, Qun -- http://mail.python.org/mailman/listinfo/python-list
Re: class variables
On 7/31/06, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Colin J. Williams wrote: Andre Meyer wrote: Hi all I am trying to understand the magic of Python's class variables and tried the following code (see below). Just out of curiosity, I tried to define a property that provides access to a seemingly instance variable which is in fact a class variable. [...] I'm afraid there are too much problems with indentation in the posted code to give any serious answer. So, here we go again (plain formatting). The following code shows two versions of using class variables. The first one uses the __class__ attribute directly and works. The second one tries to hide the __class__ attibute with the help of a property, which does not work, because an assignment in the instance replaces the property with the assigned value. Any idea how the second version could be fixed with either a property and/or a decorator? thanks for your help André class Value(object): def __init__(self, i): self.i = i def work(self): return 'done', self.i print; print *** Case A ***; print class ClassA(object): v = None def __init__(self, value): print '-', self.v self.__class__.v = Value(value) print '+', self.__class__.v @classmethod def value1(self): print self.v.work() return self.v def value2(self): print self.__class__.v.work() return self.__class__.v va1 = ClassA(1) va2 = ClassA(2) print va1.value1() print va1.value2() print va1.v print va1.__class__.v print va1.v.work() print *** Case B ***; print class ClassB(object): def __set_v(self, v): self.__class__.__v = v def __get_v(self): return self.__class__.__v def __del_v(self): del self.__class__.__v #v = property(__get_v, __set_v, __del_v, 'make class variable') v = None def __init__(self, value): self.v = property(self.__get_v, self.__set_v, self.__del_v, 'make class variable') print '-', self.v self.v = Value(value) print '+', self.v @classmethod def value1(self): print self.v.work() return self.v def value2(self): print self.v.work() return self.v vb1 = ClassB(1) vb2 = ClassB(2) print vb1.value2() print vb1.v print vb1.__class__.v print vb1.v.work() -- http://mail.python.org/mailman/listinfo/python-list
Newbie - How to iterate list or scalar ?
I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same variables. My problem is how to iterate it, whether it's a a list or not. I can't simply throw it into the for...in loop -- if the scalar variable were to be a string (which is considered to be atomic in my application) then Python sees this string as iterable and iterates over the characters in it! versionsNeeded = pluginVersionNeeded if isinstance( versionsNeeded, list): versionsToTest = versionsNeeded else: versionsToTest = [ versionsNeeded ] for versionNeeded in versionsToTest: pass Thanks for any advice -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner questions on embedding/extending python with C++
Since the main program is still going to be the C++ application, I guess we need to embedding the python scripts in the C++ code. So at initialization stage, the python script needs to be loaded into the C++ code. And this code can be simple, like player = Player() game.loadPlayer(player) But for this to work, the python code needs to know the Player class, is it right? Does that mean I need to build a python wrapper class for Player and import Player in the python code? But because this application is built on top of a game engine, Player class inherits many classes from there, I cannot possibly wrapping them all, right? Also, some global objects are probably needed in this code of adding players, how can the python code access them? You should look into SIP besides the tools you already mentioned - IMHO it is the best choice for wrapping C++. And yes, you need to wrap classes - but only those that are of interest for you! So if you need Player, wrap Player. No need to wrap it's base-classes, unless you want these for other purposes, too. And for global objects I'd create functions which return these. I suggest you try and download a project that uses one of the possible toolkits for wrapping - the most prominent user of SIP is of course PyQt. Go and have a look at the source, how things are done. There aresome tutorials I think, google should help you on that. HTH Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
Andy Dingley [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same variables. The obvious question would be, is there a good reason why you don't change the API to always require a list? Then you can just write: myFunction( [scalarParameter] ) when you have only one variable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
Andy Dingley wrote: I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same variables. My problem is how to iterate it, whether it's a a list or not. I can't simply throw it into the for...in loop -- if the scalar variable were to be a string (which is considered to be atomic in my application) then Python sees this string as iterable and iterates over the characters in it! versionsNeeded = pluginVersionNeeded if isinstance( versionsNeeded, list): versionsToTest = versionsNeeded else: versionsToTest = [ versionsNeeded ] for versionNeeded in versionsToTest: pass Use a function. def listify(v): if not isinstance(v, list): return [v] return v versionsToTest = listify(versionsNeeded) Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Resource temporarily unavailable launching idle under cygwin
Juan C., On Mon, Aug 07, 2006 at 11:47:33AM -0700, jcmendez wrote: Hello everyone. Trying to run idle from a cygwin session on Win2k (yuk, but I must) I'm getting the following error message. [snip] $ idle 23367 [main] python2.4 1668 C:\cygwin\bin\python2.4.exe: *** fatal error - C:\cygwin\bin\python2.4.exe: *** unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x1889) != 0x18D2 You need to rebase your system: http://www.google.com/search?hl=enq=cygwin+python+%22unable+to+remap%22 Jason -- PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-list
Re: singleton decorator
Andre Meyer wrote: While looking for an elegant implementation of the singleton design pattern I came across the decorator as described in PEP318 http://www.python.org/dev/peps/pep-0318/. Unfortunately, the following does not work, because decorators only work on functions or methods, but not on classes. def singleton(cls): instances = {} def getinstance(): if cls not in instances: instances[cls] = cls() return instances[cls] return getinstance @singleton class MyClass: ... Am I missing something here? What is the preferred pythonic way of implementing singleton elegantly? You can always use the syntax the decorator replaces: class MyClass: ... MyClass = singleton(MyClass) But there are better ways, and maybe you don't even need a singleton. See the Python Cookbook. Georg -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
Andy Dingley wrote: I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same variables. My problem is how to iterate it, whether it's a a list or not. I can't simply throw it into the for...in loop -- if the scalar variable were to be a string (which is considered to be atomic in my application) then Python sees this string as iterable and iterates over the characters in it! Yes, this is a common gotcha. Problem is that, as someone here noticed sometimes ago, what should be a scalar and what should be an iterable is often application or context dependent... And according to the context, string being iterable can be either a royal PITA or the RightThing(tm). versionsNeeded = pluginVersionNeeded if isinstance( versionsNeeded, list): versionsToTest = versionsNeeded else: versionsToTest = [ versionsNeeded ] for versionNeeded in versionsToTest: pass OT Too much names essentially refering to the same thing IMHO... this could be simplified to: if not isinstance(pluginVersionNeeded, list): pluginVersionNeeded = [pluginVersionNeeded] for versionNeeded in pluginVersionNeeded: pass /OT The second problem here is that, given the above (I mean in your original snippet) use of versionsToTest, there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). AS far as I'm concerned, I'd rather either: 1/ test versionsToTest against basestring (which is the parent class for both strings and unicode) and turn it into a list if needed if isinstance( pluginVersionsNeeded, basestring): pluginVersionsNeeded = [pluginVersionsNeeded] for versionNeeded in pluginVersionsNeeded: pass The problem is that it limits 'scalars' to strings (and unicodes), and will fail with say ints or floats etc... This could be handled with a tuple of 'to-be-considered-as-scalar' types: scalars = (basestring, int, float) if isinstance( pluginVersionsNeeded, scalars): pluginVersionsNeeded = [pluginVersionsNeeded] for versionNeeded in pluginVersionsNeeded: pass 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables except strings...): if not hasattr(pluginVersionsNeeded, '__iter__'): pluginVersionsNeeded = [pluginVersionsNeeded] for versionNeeded in pluginVersionsNeeded: pass It's probably the most general scheme, but won't work if you intend to consider tuples as scalars since tuples have the __iter__ attribute. Also, if this is a common pattern in your module, you perhaps want to abstract this out (example for both of the above solutions): 1/ def enumerateVersion(versions, scalars=(basestring, int, float)): if isinstance(versions, scalars): yield versions raise StopIteration # not required but clearer IMHO else: for version in versions: yield version NB : the default arg 'scalars' let you customize what is to be considered as a scalar... 2/ def enumerateVersion(versions): if hasattr(versions, '__iter__'): for version in versions: yield version raise StopIteration # not required but clearer IMHO else: yield versions and in the calling code: ... for versionNeeded in enumerateVersions(pluginVersionNeeded): do_whatever_with(versionNeeeded) ... HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner questions on embedding/extending python with C++
On 8 Aug 2006 02:28:31 -0700, Qun Cao [EMAIL PROTECTED] wrote: Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. As for me, Boost.Python is the way to go. Fortunately you are not the first one, and I hope not the last one :-) : http://language-binding.net/pyplusplus/quotes.html#who-is-using-pyplusplus 1. Python-OGRE * http://lakin.weckers.net/index_ogre_python.html * http://tinyurl.com/mvj8d 2. http://cgkit.sourceforge.net/ - contains Python bindings for Maya C++ SDK 3. PyOpenSG - https://realityforge.vrsource.org/view/PyOpenSG/WebHome The goal of PyOpenSG is to provide python bindings for the OpenSG scene graph. Since the main program is still going to be the C++ application, I guess we need to embedding the python scripts in the C++ code. Boost.Python is the only tool that provides complete functionality( extending and embedding ). Also I think cgkit is dealing with the problem too. But for this to work, the python code needs to know the Player class, is it right? Right. Does that mean I need to build a python wrapper class for Player and import Player in the python code? But because this application is built on top of a game engine, Player class inherits many classes from there, I cannot possibly wrapping them all, right? It depends on how much functionality you want to export. Also, some global objects are probably needed in this code of adding players, how can the python code access them? Boost.Python provides the functionality you need. Btw, if you can point me to any source code of non-trivial projects utilizing SWIG/Boost.Python, that would be very helpful. I found the examples on the tutorials are far too simple. Those are tutorials, they should be simple, right :-) ? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
infidel wrote: Where are they-who-hate-us-for-our-whitespace? You may find some on comp.lang.ruby... -- http://mail.python.org/mailman/listinfo/python-list
''Get free calling cards now ''
''Get free calling cards now '' Hi Friends, I found a great site to call anywhere in the World for free! What we have to do is just signup and earn freecalling cards. After signingup with Globalfreecalling you can findout lot of very simple and easy offers (Just Contact Information Required).Some Offers may Required only E-Mail and Zip Code Only. Just complete the Offers and get Free calling Cards. signup with below link:: http://ww3.6URL.com/0P8U Hurry Up Friends ! -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
John Salerno wrote: I like using Python for everything, and if I don't need to learn the bash 'language', then I won't just yet. And like vim, Ipython works on both windows and ubuntu. rd -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
infidel wrote: Where are they-who-hate-us-for-our-whitespace? Are they really that stupid/petty? Are they really out there at all? They almost sound like a mythical caste of tasteless heathens that we have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe. Some of it may be a reaction from old-timers who remember FORTRAN, where (if memory serves), code had to start in column 16 and code continutations had to be an asterik in column 72 (it's been many years since I've done any work in FORTRAN, but you get the idea) Or it may be a reaction from Assembler, which is also quite column-centric (is Assembler still taught in schools??). But most likely, it's different. It's easier to complain about things than to actually check them out. Recently I had a friend tell me that they absolutely hated a certain tv personality/author. When I asked if they had ever watched the person or read one of their books, they said Why should I? I hate them!!. I think the same attitude comes into play with computer languages. One more thing. I have many friends that love to program Perl. Without bashing the language, I find it ironic when they say There's more than one way to do it but inisit that I should be using Perl while they quote Python as There's only one way to do it though (most) Python coders I know are fairly comforatble dealing with multiple languages. --greg -- http://mail.python.org/mailman/listinfo/python-list
Newbie
Hi, I am new to python. I wanted to know how can i debug a python program. Is there a gdb equivalent? -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
pranav wrote: Hi, I am new to python. I wanted to know how can i debug a python program. Is there a gdb equivalent? pdb, a standard module. I use it like this: def some_method_I_want_to_debug(): import pdb pdb.set_trace() # more code to come But that is only one way of using it - read the docs. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for an intellisense with good help IDE for Python
I dont know if it will meet all your needs but SPE (Stani's Python Editor) is quite cool - has code completion. http://pythonide.stani.be metaperl wrote: Hi, I would like an IDE that shows me all methods and functions I can call on a particular data item. For instance, iter() can be called on any sequence, but it is not a method. Nonetheless, I would like for something to show me every thing that I can call on a particular data item. This includes % after a string. I would also like browseable help with good examples on whatever methods and functions and operators it pops up. Thanks, Terrence -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie
Diez B. Roggisch wrote: pranav wrote: Hi, I am new to python. I wanted to know how can i debug a python program. Is there a gdb equivalent? pdb, a standard module. I use it like this: def some_method_I_want_to_debug(): import pdb pdb.set_trace() # more code to come But that is only one way of using it - read the docs. Diez Thanks -- http://mail.python.org/mailman/listinfo/python-list
class return another instance
Hello All, Here is simplified version of what Im trying to do: IDs = {} class ID: def __init__(self, id): if id in IDs: self = IDs[id] else: IDs[id] = self foo = ID(1) bar = ID(2) copy = ID(1) print foo: + str(foo) + with ID of 1 print bar: + str(bar) + with ID of 2 print copy: + str(copy) + should be a copy of foo print IDs: + str(IDs) What Im after is if you call the class ID it checks to is if the id is in the dictionary IDs if so then use that class instance else put self into the dictionary as a new key-value, so if you try and create it again it will use that instance Also I know its easy enough to do copy = foo but I would like the class to determine this for me any ideas? There has got to be a way to replace self with another instance or return something from the init statement Heres what it returns: foo: __main__.ID instance at 0x01DE6CB0 with ID of 1 bar: __main__.ID instance at 0x01DE6CD8 with ID of 2 copy: __main__.ID instance at 0x01DE6D00 should be a copy of foo IDs: {1: __main__.ID instance at 0x01DE6CB0, 2: __main__.ID instance at 0x01DE6CD8} What I would expect/want: foo: __main__.ID instance at 0x01DE6CB0 with ID of 1 bar: __main__.ID instance at 0x01DE6CD8 with ID of 2 copy: __main__.ID instance at *0x01DE6CB0* should be a copy of foo IDs: {1: __main__.ID instance at 0x01DE6CB0, 2: __main__.ID instance at 0x01DE6CD8} Any help would be great. Cheers, Keith -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner questions on embedding/extending python with C++
Qun Cao wrote: Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python interface is providing a convenient scripting toolkit for the application. As well as this group/list, you may find some useful help at the Gamedev.net Scripting Languages and Game Modifications forum: http://www.gamedev.net/community/forums/forum.asp?forum_id=41 Many people there have mixed Python and C++ code in the context of game applications and may have some good answers to your questions. After deciding how to expose C++ classes and functions to Python, the main problem you'll face, assuming you need the functionality, is how to yield control between Python and C++ when a Python action is long-running yet requires the C++ engine to be polled (eg. to handle input, AI, graphics, etc). Previous threads there will give you some hints on all these matters. -- Ben Sizer -- http://mail.python.org/mailman/listinfo/python-list
Re: Class attributes, instances and metaclass __getattribute__
Hi On 8 Aug 2006 00:10:39 -0700 Michele Simionato [EMAIL PROTECTED] wrote: To me, it seems consistent. As said in http://www-128.ibm.com/developerworks/linux/library/l-pymeta2/ The availability of metaclass attributes is not transitive; in other words, the attributes of a metaclass are available to its instances, but not to the instances of the instances. Just this is the main difference between metaclasses and superclasses. Well... I'm not talking about metaclass attributes... that's perfectly consistent, agreed. I'm saying that when the class implements a custom __getattribute__, when you try to access the instance attributes from itself, it uses it. But if the class is a metaclass, instances of its instances have acess to the attribute anyway, but don't use the custom __getattribute__ you implemented. Like the example I mentioned on the previous mail, or (I think in this case it's more obvious): class N(type): ... def __getattribute__(cls, attr): ... print 'using N.__getattribute for %s'%(attr) ... return type.__getattribute__(cls, attr) ... class M(type): ... __metaclass__ = N ... class C(object): ... __metaclass__ = M ... M.x = 'foo' M.x using N.__getattribute for x 'foo' C.x 'foo' So, in both cases I have access to the class attribute; but in one case it's using the bound M.__getattribute__ implemented at the base metaclass, but not in the other. It was supposed to use it after the bound 'C.__getattribute__' raises AttributeError as expected, but it doesn't... It's inconsistent, but seems a reasonable decision to me since someone can easily mess with descriptors doing with this... but, someone else involved with Python dev I talked about thinks it may be a bug. And, I'm curious anyway... is it possible to customize attribute access in this case in any other way ? What really happens here ? From the typeobject.c source code, seems like when the metaclass implements __getattribute__, it uses type.__getattribute__ in this case, but I'm not sure. Since this happens for real attributes, it looks natural that the same should happen for 'virtual' attributes implemented via '__getattr__' or '__getattribute__'. Well... as I think it's clear now, the case you mentioned is not exactly what I'm talking about, but it's good you mentioned about 'virtual' attributes, because in this case we have another problem, it's inconsistent too and there's no reason for it... class M(type): ... def __getattr__(cls, attr): ... if attr == 'x': ... return 'foo' ... class C(object): ... __metaclass__ = M ... C.y = 'bar' C.x 'foo' C.y 'bar' o = C() o.x ... AttributeError: 'C' object has no attribute 'x' o.y 'bar' So... both 'x' and 'y' are class attributes, but 'x' is a virtual attribute implemented with M.__getattr__. From the instance I have access to 'y' but not to 'x'. Regards, -- Pedro Werneck -- http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Aug 8)
I'll be out of the office until approximately August 20th. If you have any questions, please email [EMAIL PROTECTED] -- David Wahler -- http://mail.python.org/mailman/listinfo/python-list
Re: Resource temporarily unavailable launching idle under cygwin
The rebase process worked. Thanks, Jason. The other previously posted solution of uninstalling and reinstalling Python did not. On 8/8/06, Jason Tishler [EMAIL PROTECTED] wrote: Juan C.,On Mon, Aug 07, 2006 at 11:47:33AM -0700, jcmendez wrote: Hello everyone.Trying to run idle from a cygwin session on Win2k (yuk, but I must)I'm getting the following error message. [snip] $ idle 23367 [main] python2.4 1668 C:\cygwin\bin\python2.4.exe: *** fatal error - C:\cygwin\bin\python2.4.exe: *** unable to remap C:\cygwin\bin\tk84.dll to same address as parent(0x1889) != 0x18D2You need to rebase your system: http://www.google.com/search?hl=enq=cygwin+python+%22unable+to+remap%22 Jason--PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key serversFingerprint: 7A73 1405 7F2B E669 C19D8784 1AFD E4CC ECF4 8EF6 -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for an intellisense with good help IDE for Python
On 8 Aug 2006 00:36:30 -0700, metaperl [EMAIL PROTECTED] wrote: Hi,I would like an IDE that shows me all methods and functions I can callon a particular data item. For instance, iter() can be called on anysequence, but it is not a method.Nonetheless, I would like for something to show me every thing that I can call on a particular data item.This includes % after a string.I would also like browseable help with good examples on whatevermethods and functions and operators it pops up.Thanks,Terrence Have you checked pydev: http://pydev.sf.net Cheers, Fabio -- http://mail.python.org/mailman/listinfo/python-list
Re: class return another instance
Keith [EMAIL PROTECTED] wrote: Any help would be great. Cheers, Keith Do you absolutely need the functionality to be in the __init__ method, or does something like the following work: IDs={} class ID: pass def factory(ident): if ident in IDs: instance=IDs[ident] else: instance=ID() IDs[ident]=instance return instance g=factory(1) h=factory(2) i=factory(1) g,h,i (__main__.ID instance at 0x00A45FD0, __main__.ID instance at 0x00A4B918, __main__.ID instance at 0x00A45FD0) max -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
[EMAIL PROTECTED] wrote: John Aside from the normal commands you can use, I was wondering if John it's possible to use Python from the terminal instead of the John normal bash commands (e.g. print instead of echo). Take a look at ipython http://ipython.scipy.org/. It's not precisely what you've asked for, but it provides some features that help integrate Python with the shell environment. Skip Can you use IPython to do normal bash things, like installing, etc.? -- http://mail.python.org/mailman/listinfo/python-list
Re: Class attributes, instances and metaclass __getattribute__
Pedro Werneck wrote: Hi [snip] Well... I'm not talking about metaclass attributes... that's perfectly consistent, agreed. I'm saying that when the class implements a custom __getattribute__, when you try to access the instance attributes from itself, it uses it. But if the class is a metaclass, instances of its instances have acess to the attribute anyway, but don't use the custom __getattribute__ you implemented. Attribute lookup for instances of a class never calls metaclass' __getattribute__() method. This method is called only when you access attributes directly on the class. [snip] And, I'm curious anyway... is it possible to customize attribute access in this case in any other way ? What really happens here ? There are two distinct methods involved in your example; attribute lookup for classes is controled by metaclass' __getattribute__() method, while instance attribute lookup is controled by class' __getattribute__() method. They are basicaly the same, but they never use ``type(obj).attr`` to access the class' attributes. The code for these methods would look something like this in Python: class Object(object): Emulates object's and type's behaviour in attribute lookup. def __getattribute__(self, name): cls = type(self) # you normally access this as self.__dict__ try: dict_descriptor = cls.__dict__['__dict__'] except KeyError: # uses __slots__ without dict mydict = {} else: mydict = dict_descriptor.__get__(self, cls) # Can't use cls.name because we would get descriptors # (methods and similar) that are provided by class' # metaclass and are not meant to be accessible from # instances. classdicts = [c.__dict__ for c in cls.__mro__] # We have to look in class attributes first, since it can # be a data descriptor, in which case we have to ignore # the value in the instance's dict. for d in classdicts: if name in d: classattr = d[name] break else: # None of the classes provides this attribute; perform # the normal lookup in instance's dict. try: return mydict[name] except KeyError: # Finally if everything else failed, look for the # __getattr__ hook. for d in classdicts: if '__getattr__' in d: return d['__getattr__'](self, name) msg = %r object has no attribute %r raise AttributeError(msg % (cls.__name__, name)) # Check if class' attribute is a descriptor. if hasattr(classattr, '__get__'): # If it is a non-data descriptor, then the value in # instance's dict takes precedence if not hasattr(classattr, '__set__') and name in mydict: return mydict[name] return classattr.__get__(self, cls) # Finally, look into instance's dict. return mydict.get(name, classattr) As you can see, it completely avoids calling metaclass' __getattribute__() method. If it wouldn't do that, then the metaclass' attributes would 'leak' to instances of its classes. For example, __name__, __mro__ and mro() are some of the descriptors provided by type to every class, but they are not accesible through instances of these classes, and shouldn't be, otherwise they could mask some errors in user's code. Ziga -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
One of the most stupid language-definition decisions that most people have come across is the Makefile format. snippage/ Hope that goes some way to explaining one possible reason why rational people can consistently react in horror to the issue. Ah, thanks for that. This peek into history makes the irrational fear of significant whitespace seem a little less irrational. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to make python socket server work with the app.MainLoop() in wxpython?
Dennis: Thanks for your message. Let me try the double-buffer-operation. Ouyang Dennis Lee Bieber wrote: On 1 Aug 2006 01:10:18 -0700, zxo102 [EMAIL PROTECTED] declaimed the following in comp.lang.python: I just wrote the code following the example you provided. The image location can be controlled with the data from socket client. But only one thing confuse me. When the image keeps moving to a new location, the image at a old location is not deleted and is left behind in the frame. Do you know what is going on with it? The location of image is processed in def OnResult(self,event): and is initialized in def __init__(self, parent, id): of class MainFrame ( See the code attached). Off hand, it is doing just what the code says it should. Each time you update position, you are COPYING a SMALL rectangle (the moved image) into the larger frame... Only the pixels corresponding to the small rectangle are changed -- anything that was already in the frame stays there. You might want to double-buffer the operations... For each move: clear an unseen frame-sized buffer compute the new location of the moved image blit the moved image into the unseen buffer blit the full unseen buffer to the viewed frame (not to a portion of the frame, but replace the entire frame contents) The double-buffer is to avoid annoying the viewer with the flash of clearing out the view frame before drawing the new image -- WulfraedDennis Lee Bieber KD6MOG [EMAIL PROTECTED] [EMAIL PROTECTED] HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: [EMAIL PROTECTED]) HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
All societies demonise outsiders to some extent. It's an unfortunate human (and animal) trait. Which is why I questioned it. So just block your ears when the propaganda vans with the loud-speakers on top drive past your dwelling :-) Funny how using python makes me feel like a member of some kind of rebellion against the empire. Where I work it's all VB, VB.NET, and ASP.NET. I've been the lone voice in the wilderness for so long that I've become an inside joke. I actually have a certificate that says Most likely to re-write the system in Python. *sigh* -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows vs. Linux
Duncan Booth wrote: [CUT] C:\cd /Documents and settings The system cannot find the path specified. C:\cd /DDocuments and settings C:\Documents and Settings that's because the cd /D is interpreted as change drive and directory so I imagine it enables some kind of command extension but anyway you're right: m$ CMD is weird bye, PiErre -- http://mail.python.org/mailman/listinfo/python-list
fundamental issue with unittest
I have added a unit test to some of my code, following closely the examples in the python docs and python in a nutshell. However, when I try calling unittest.main(), I get the following:-- Ran 0 tests in 0.000sOK---exceptions.SystemExit Traceback (most recent call last)/Users/chris/ipython console /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/PyMC/MCMC.py in runtest() 2916 2917 2918 def runtest(): 2919 # Run unit tests- 2920 unittest.main () global unittest.main = class 'unittest.TestProgram'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/unittest.py in __init__(self=unittest.TestProgram object at 0x10e1970, module='__main__', defaultTest=None, argv=['/usr/local/bin/ipython'], testRunner=None, testLoader= unittest.TestLoader object at 0x5ff870) 757 self.progName = os.path.basename(argv[0]) 758 self.parseArgs(argv)-- 759 self.runTests() self.runTests = bound method TestProgram.runTests of unittest.TestProgram object at 0x10e1970 760 761 def usageExit(self, msg=None):/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/unittest.py in runTests(self= unittest.TestProgram object at 0x10e1970) 795 self.testRunner = TextTestRunner(verbosity=self.verbosity) 796 result = self.testRunner.run(self.test)-- 797 sys.exit(not result.wasSuccessful()) global sys.exit = built-in function exit result.wasSuccessful = bound method _TextTestResult.wasSuccessful of unittest._TextTestResult run=0 errors=0 failures=0 798 799 main = TestProgramSystemExit: FalseType exit or quit to exit IPython (%Exit or %Quit do so unconditionally).My unit testing code is here:class MCMCTest(unittest.TestCase ): def testCoalMiningDisasters(self): Run coal mining disasters example sampler print 'Running coal mining disasters test case ...' # Create an instance of the sampler self.sampler = DisasterSampler() # Specify the nimber of iterations to execute iterations = 1 thin = 2 burn = 5000 chains = 2 # Run MCMC simulation for i in range(chains): self.failUnless(self.sampler.sample(iterations, burn=burn, thin=thin, plot=True)) # Run convergence diagnostics self.sampler.convergence() # Plot autocorrelation self.sampler.autocorrelation() # Goodness of fit self.failIf(any(self.sampler.goodness(iterations/10)['overall'] 0.05))def runtest(): # Run unit tests unittest.main()I appear to be subclassing appropriately, and the only method begins with test, so I do not see the problem. Can anyone help me out? Thanks,C.-- Chris Fonnesbeck + Atlanta, GA + http://trichech.us -- http://mail.python.org/mailman/listinfo/python-list
Re: variable creation
Alistair King wrote: Hei all, im trying to create a list of variables for further use: [snip] this works to a certain extent but gets stuck on some loop. Im a beginner and am not sure where im going wrong. You are trying to do too much in one function. Split those loops up into a few little ones and the program will work... or if it doesn't, you'll know exactly where the problem is. def get_element(pt): Return None or a single element from the periodic table while 1: el = raw_input(Which element would you like to include? ) if not el: #blank answer return if el in pt: return pt[el] print This element is not in the periodic table, please try again def get_elements(pt): elements = [] while 1: el = get_element(pt) if not el: break elements.append(el) return elements See how using two separate functions makes it easy to test? In [10]:print get_element(pt) Which element would you like to include? X This element is not in the periodic table, please try again Which element would you like to include? H 1.00794001 In [11]:print get_elements(pt) Which element would you like to include? Z This element is not in the periodic table, please try again Which element would you like to include? Li Which element would you like to include? B Which element would you like to include? H Which element would you like to include? [6.9408, 10.811, 1.00794001] Now, since the information for a single element consists of more than just a single number, you'll probably want to make a class for them. Once you have an object for every element, you can add them to a class for the periodic table. -- - Justin -- http://mail.python.org/mailman/listinfo/python-list
Missing MSVCR71.dll
Hi, I am trying to get my application into debug. I am using VS2005 with some Python code in it. Works fine in release build, but I do need to go to dubug. I have ActivePython 2.4.3.12. It says it is missing MSVCR71D.dll, I think that is an older .dll, maybe it should be an 8 for VS2005. MSVCR71D.dll is not even on my system. I have seen a similar posting a while back. Suggestion was to download the dll but I believe that could be incompatiable with VS2005. Any help would be appreciated. Thanks Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: variable creation
Hi, I'm not sure if this is exactly what you had in mind but what about something like this: elements = [] Els = pt = {'H': 1.00794, 'He': 4.002602, 'Li': 6.941, 'Be': 9.012182, 'B':10.811} while Els != 'No': Els = raw_input(Are there any further elements you would like to include? if so type the element, eg, Pd. If not type No:) if pt.has_key(Els): elements.append({Els:pt[Els]}) print elements Alistair King wrote: Hei all, im trying to create a list of variables for further use: Els = raw_input(Are there any further elements you would like to include? if so type the element, eg, Pd. If not type No: ) if Els != 'No': el = Els in pt while el == 1 and Els != 'Next': elements = [] elements.insert(-1, Els) Els = raw_input(Which further element would you like to include, eg, Pd, if not type Next: ) el = Els in pt while el == 0 and Els != 'Next': Els = raw_input(This is not an element in the periodic table, please try again, eg Pd, If you dont wish to include any more, type Next: ) if el == 1: elements.insert(-1, Els) while el == 0: Els = raw_input(This is not an element in the periodic table, please try again, eg Pd. If you dont wish to include any more, type Next: ) print elements this works to a certain extent but gets stuck on some loop. Im a beginner and am not sure where im going wrong. here is a portion of the dictionary containing typical elements: pt = {'H': 1.00794, 'He': 4.002602, 'Li': 6.941, 'Be': 9.012182, 'B': 10.811} Ali -- Dr. Alistair King Research Chemist, Laboratory of Organic Chemistry, Department of Chemistry, Faculty of Science P.O. Box 55 (A.I. Virtasen aukio 1) FIN-00014 University of Helsinki Tel. +358 9 191 50429, Mobile +358 (0)50 5279446 Fax +358 9 191 50366 -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
Am Mon, 07 Aug 2006 14:43:04 -0700 schrieb infidel: Where are they-who-hate-us-for-our-whitespace? Are they really that stupid/petty? Are they really out there at all? They almost sound like a mythical caste of tasteless heathens that we have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe. I like python, but sometimes i don't like that python allows spaces and tabs. It would be easier if you had less choice and must use four spaces. That's one small argument against the current whitespace syntax in python. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Dallas One wire tempreture measurement.
a previous thread http://mail.python.org/pipermail/python-list/2002-June/107616.html discussed this issue, and Dave Moor kindly pointed to his solution. However this is no longer a current link, does anyone know if there is a currently available solution? -- http://mail.python.org/mailman/listinfo/python-list
Tkinter module not found
Hey, Even though I freshly installed Tcl and Tk, python still seem to have problems accessing Tkinter module. Here is what says when I do import Tkinter == Traceback (most recent call last): File stdin, line 1, in ? ImportError: No module named Tkinter == Any ideas how to fix this problem? (Gentoo distribution) Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Info on continuations?
vasudevram wrote: Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Saw a few URLs which had some info, some of which I understood. But like I said, personal viewpoints are good to have. Thanks Vasudev Could you be a little more specific on what you're looking for? Continuations are a big can of worms. In general, some of the historical uses of continuations are better represented as classes in python. Generators provide some limited functionality as well, and will be able to send info both ways in python 2.5 to enable limited co-routines. Stackless python allows you to *really* suspend the stack at a given time and do a bunch of crazy stuff, but doesn't currently support 'full continuations'. -- http://mail.python.org/mailman/listinfo/python-list
Re: Info on continuations?
[EMAIL PROTECTED] wrote: vasudevram wrote: Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Could you be a little more specific on what you're looking for? Continuations are a big can of worms. Thanks for the reply. Can't really be more specific, since I don't know enough. The question and the interest was exploratory in nature - as part of wanting to learn more about some dynamic / advanced features of Python. Will Google more and read the docs ... Vasudev -- http://mail.python.org/mailman/listinfo/python-list
Accessing Yahoo Mail withtout POP
Is there a way to access yahoo mail via its web interface? If so, can someone give some pointers? -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
Shuaib wrote: Hey, Even though I freshly installed Tcl and Tk, python still seem to have problems accessing Tkinter module. Here is what says when I do import Tkinter == Traceback (most recent call last): File stdin, line 1, in ? ImportError: No module named Tkinter == Any ideas how to fix this problem? (Gentoo distribution) Thanks. The cause of this is usually that you are using a different version of Python than the one you installed Tkinter into, but being a Linux newbie I have yet to discover how to redirect the 'python' command to invoke the newer version of Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
John Salerno [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all. I just installed Ubuntu and I'm learning how to use the bash shell. Aside from the normal commands you can use, I was wondering if it's possible to use Python from the terminal instead of the normal bash commands (e.g. print instead of echo). My main reason for asking is that I like using Python for everything, and if I don't need to learn the bash 'language', then I won't just yet. The answer is yes and you are getting excellent tips from others. I am just validating your experience by saying that coming from Python is a barrier to my learning BASH. The more I work with Linux/BASH, the more I see how I might have used BASH to script something I have already done in Python. But the question that always comes up is why bother with BASH at all ;-) And with Python available everywhere, I've just reconsiled to pick up my BASH by osmosis and concentrate on (much!) cleaner scripting with Python. Thomas Bartkus -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
[EMAIL PROTECTED] wrote: infidel wrote: Where are they-who-hate-us-for-our-whitespace? Are they really that stupid/petty? Are they really out there at all? They almost sound like a mythical caste of tasteless heathens that we have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe. Some of it may be a reaction from old-timers who remember FORTRAN, where (if memory serves), code had to start in column 16 and code continutations had to be an asterik in column 72 (it's been many years since I've done any work in FORTRAN, but you get the idea) Column 7 was the start, 6 the one for continuation; 1-5 and 73-80 were ignored by the compiler and could be used for numbering, grouping c. Been many years in my case, too, but as I was a mainly-Fortran guru for several years in my career, it's hard to forget;-). Or it may be a reaction from Assembler, which is also quite column-centric (is Assembler still taught in schools??). I never used a column-centric Assembler: even the first assemblers I used, in the '70s (6502, Z80, a mini called HP1000, VAX/VMS when it was just out, BAL/370, ...) were all column-indifferent. The HP1000 did not even have a punched-card reader: it used punched _tape_ instead (quite a popular device then, as it came with teletypes typically used as consoles), so keeping track of columns would have a royal mess:-). I'm pretty sure you're still _able_ to take SOME Assembler-based course in most universities, but you need to strive pretty hard for the purpose... it's definitely not in the default curriculum, even for EEs, much less CSs. Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: Info on continuations?
On 8 Aug 2006 08:07:02 -0700, [EMAIL PROTECTED] wrote: vasudevram wrote: Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Saw a few URLs which had some info, some of which I understood. But like I said, personal viewpoints are good to have. Thanks Vasudev Could you be a little more specific on what you're looking for? Continuations are a big can of worms. In general, some of the historical uses of continuations are better represented as classes in python. Generators provide some limited functionality as well, and will be able to send info both ways in python 2.5 to enable limited co-routines. Stackless python allows you Coroutines can switch out of stacks deeper than one frame. Generators cannot, even in Python 2.5. You seem to be partially aware of this, given your comments below, but have suffered some of the confusion PEP 342's naming seems intended to generate. Python doesn't have continuations or coroutines at all. It has generators, and calling them anything else (even limited coroutines - depending on what limited means (which no one really knows), Python 2.4 already had these - the ability to pass information into a generator is not new, only the syntax by which to do it is) can't help but lead to misunderstandings. to *really* suspend the stack at a given time and do a bunch of crazy stuff, but doesn't currently support 'full continuations'. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Accessing Yahoo Mail withtout POP
T [EMAIL PROTECTED] writes: Is there a way to access yahoo mail via its web interface? If so, can someone give some pointers? This works for me: http://www.ypopsemail.com/ -- Dieter Deyke mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Vs lbh pna ernq guvf, lbh unir jnl gbb zhpu gvzr. -- http://mail.python.org/mailman/listinfo/python-list
Urllib2/Pycurl/HTTP Speeds?
For the Program I Am Making I Make Multiple HTTP Request to My Server. I found that using urllib2 it was pretty slow, when I activated the program and tested it it would hang from 2secs-5secs since I am doing it multiple times I wanted to speed it up by using pycurl. But I got the samething. Here is my code: import urllib import os.path import cookielib import pycurl import StringIO class GoToPage: #HTTPHeaders = {'User-agent' : self.browser, 'Accept-Language: en-us' : 'en-us', 'Accept-Encoding' : 'deflate'} FireFox_15 = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6 IE7_B2 = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322) Opera_85 = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 8.51 IE6 = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1) Mozilla_17 = Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040404 def __init__(self, myName): self.browser = self.FireFox_15 self.lastPage = self.cookies = self.name = myName self.wrapper = pycurl.Curl() #self.wrapper.setopt(pycurl.AUTOREFERER, 0) self.wrapper.setopt(pycurl.COOKIEFILE, self.name) #self.cookieJar = cookielib.LWPCookieJar() #if self.cookieJar != None: #if os.path.isfile(self.name): #self.cookieJar.load(self.name) #self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar)) #urllib2.install_opener(self.opener) return #end Function def buildHeaders(self, browser, referer=): if referer != : buildHeaders = ['User-agent: ' + self.browser, 'Accept-Language: en-us', 'Accept-Encoding: gzip,compress;q=0.9,deflate;q=0', 'Referer:' + referer] else: buildHeaders = ['User-agent: ' + self.browser, 'Accept-Language: en-us', 'Accept-Encoding: gzip,compress;q=0.9,deflate;q=0'] return buildHeaders def saveCookies(self, cookies): fileHandle = open (self.name, 'w') fileHandle.write (cookies) fileHandle.close() def GetPage(self, URL, referer=): theHeaders = self.buildHeaders(self.browser, referer) returnVal = StringIO.StringIO() self.wrapper.setopt(pycurl.URL, URL) self.wrapper.setopt(pycurl.HTTPHEADER, theHeaders) self.wrapper.setopt(pycurl.WRITEFUNCTION, returnVal.write) self.wrapper.perform() self.wrapper.close() #self.saveCookies(self.wrapper.getinfo(pycurl.COOKIELIST)) #self.cookieJar.save(self.name) return returnVal.getvalue() def PostPage(self, URL, data, referer=): timer = wx.StopWatch() theHeaders = self.buildHeaders(self.browser, referer) print timer.Time() timer.Start(0) returnVal = StringIO.StringIO() self.wrapper.setopt(pycurl.URL, URL) self.wrapper.setopt(pycurl.POSTFIELDS, data) self.wrapper.setopt(pycurl.HTTPHEADER, theHeaders) self.wrapper.setopt(pycurl.WRITEFUNCTION, returnVal.write) print str(timer.Time()) + ' before perform' timer.Start(0) self.wrapper.perform() print str(timer.Time()) + ' after perform' self.wrapper.close() #self.saveCookies(self.wrapper.getinfo(pycurl.COOKIELIST)) #self.cookieJar.save(self.name) return returnVal.getvalue() The Urlib2 source is lost, and there are timer functions in there. I call it like this import GoToPage newHTTP = GoToPage.GoToPage(name) -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing MSVCR71.dll
This dll is shipped with VS.NET2003, you can copy one from others, maybe it'll work. missdeer 2006-08-08 发件人: Hoop 发送时间: 2006-08-0822:50:22 收件人: python-list@python.org 抄送: 主题: Missing MSVCR71.dll Hi, Iamtryingtogetmyapplicationintodebug.IamusingVS2005with somePythoncodeinit.Worksfineinreleasebuild,butIdoneedto gotodubug.IhaveActivePython2.4.3.12.Itsaysitismissing MSVCR71D.dll,Ithinkthatisanolder.dll,maybeitshouldbean8 forVS2005.MSVCR71D.dllisnotevenonmysystem. Ihaveseenasimilarpostingawhileback.Suggestionwastodownload thedllbutIbelievethatcouldbeincompatiablewithVS2005. Anyhelpwouldbeappreciated. Thanks Jeff -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Info on continuations?
vasudevram wrote: Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Python does not have (full) continuations. If you want to understand continuations, you need a language that supports them. For instance this is a recent reference for continuations in Scheme: http://www-128.ibm.com/developerworks/linux/library/l-advflow.html?ca=dgr-lnxw02FlowControl Ruby should have support for continuations too, but I am quite ignorant about the Ruby literature. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
In article [EMAIL PROTECTED], infidel [EMAIL PROTECTED] wrote: Where are they-who-hate-us-for-our-whitespace? Are they really that stupid/petty? Are they really out there at all? They almost sound like a mythical caste of tasteless heathens that we have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe. When I put on my Python evangelist hat, I do get complaints about that regularly. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Brian W. Kernighan -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
The cause of this is usually that you are using a different version of Python than the one you installed Tkinter into, but being a Linux newbie I have yet to discover how to redirect the 'python' command to invoke the newer version of Python. The OS looks for the first 'python' it finds in its path. In Linux (or other *nix OSes), you can use bash which python and it will reply with which python it's pointing to. You can then change into that directory (usually /usr/bin) and get back a listing of various pythons. On my Debian linux distro at home, I get something back that looks like bash which python /usr/bin/python bash cd /usr/bin bash ls -lsF python* | grep -o python.* python - python2.3* python2.3* python2.4* You *should* be able to just relink the python link to the new version of python: bash ln -sf /usr/bin/python2.4 /usr/bin/python I don't know if this will cause other problems down the line for packages that expect the system default. Alternatively, at least on my system, you can force your choice by explicity running python2.3 or python2.4 instead of just python. You can determine your path via bash echo $PATH along which your shell will search for an executable. Win32 has a similar executable search path c:\ echo %PATH% but doesn't have something as handy as the which command to do the hunting for you. HTH, -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
Thomas Bartkus wrote: I am just validating your experience by saying that coming from Python is a barrier to my learning BASH. The more I work with Linux/BASH, the more I see how I might have used BASH to script something I have already done in Python. But the question that always comes up is why bother with BASH at all ;-) And with Python available everywhere, I've just reconsiled to pick up my BASH by osmosis and concentrate on (much!) cleaner scripting with Python. Glad to know I'm not alone! But I'm certainly much happier using Python than bash anyway. All I really want to learn as far as the shell is concerned are the 'natural' things you can do, such as directory/file manipulation, installing programs, etc. I don't have much of a need to learn the actual programming parts of the bash language, especially when I can do the same with Python, which is so much cooler. :) -- http://mail.python.org/mailman/listinfo/python-list
binary conversion issues
I'm using python's struct and binascii modules to write some values from my parser to binary floats. This works great for all of my binary files except one. For some reason this file is saving to 836 (stated by my command shell) bytes instead of 832 like it should. It sounds like an issue with whatever's writing that particular file out but I've checked it 100 times. Also python can read in the 836 byte file, find it has a size of 832 bytes and convert back each value perfectly. However, when I read in the file in C++ it finds a file of size 836 and in the middle of the data starts spitting out junk. Has anyone run into an issue like this or have an idea of what it could be? -- http://mail.python.org/mailman/listinfo/python-list
Re: do people really complain about significant whitespace?
Thomas Guettler wrote: I like python, but sometimes i don't like that python allows spaces and tabs. It would be easier if you had less choice and must use four spaces. That's the nice thing about Python. It doesn't care about indentation distance, it just wants some and consistent. I like the idea that humans see the whitespace as significant anyway, so document the fact and use it (I presume this came from Occam). What I don't like so much is that the _ends_ of blocks are less visually obvious. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
Tim Chase wrote: The cause of this is usually that you are using a different version of Python than the one you installed Tkinter into, but being a Linux newbie I have yet to discover how to redirect the 'python' command to invoke the newer version of Python. The OS looks for the first 'python' it finds in its path. In Linux (or other *nix OSes), you can use bash which python A very helpful command to know! I'll have to wait til I get home to play on Linux though. Then I can try these things you suggested. I'm suddenly very bored here at work using Windows. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
I've just reconsiled to pick up my BASH by osmosis and concentrate on (much!) cleaner scripting with Python. John I don't have much of a need to learn the actual programming parts John of the bash language, ... As long as you promise never, ever, ever to try programming in csh... Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
Hey again, I am using the latest python available on my system (2.4). So I don't think that's the problem. Any more ideas? Do I need to install Tkinter as a seperate module/package? As I said, I've already installed Tcl/Tk, though. Thanks for your time. Tim Chase wrote: The cause of this is usually that you are using a different version of Python than the one you installed Tkinter into, but being a Linux newbie I have yet to discover how to redirect the 'python' command to invoke the newer version of Python. The OS looks for the first 'python' it finds in its path. In Linux (or other *nix OSes), you can use bash which python and it will reply with which python it's pointing to. You can then change into that directory (usually /usr/bin) and get back a listing of various pythons. On my Debian linux distro at home, I get something back that looks like bash which python /usr/bin/python bash cd /usr/bin bash ls -lsF python* | grep -o python.* python - python2.3* python2.3* python2.4* You *should* be able to just relink the python link to the new version of python: bash ln -sf /usr/bin/python2.4 /usr/bin/python I don't know if this will cause other problems down the line for packages that expect the system default. Alternatively, at least on my system, you can force your choice by explicity running python2.3 or python2.4 instead of just python. You can determine your path via bash echo $PATH along which your shell will search for an executable. Win32 has a similar executable search path c:\ echo %PATH% but doesn't have something as handy as the which command to do the hunting for you. HTH, -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
John Salerno schrieb: Tim Chase wrote: The cause of this is usually that you are using a different version of Python than the one you installed Tkinter into, but being a Linux newbie I have yet to discover how to redirect the 'python' command to invoke the newer version of Python. The OS looks for the first 'python' it finds in its path. In Linux (or other *nix OSes), you can use bash which python A very helpful command to know! I'll have to wait til I get home to play on Linux though. Then I can try these things you suggested. I'm suddenly very bored here at work using Windows. :) Well, we have python, haven't we? Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. c:\which python c:\util\python.EXE c:\which which c:\util\which.PY c:\type \util\which.py import os, string, sys PATH = os.environ[PATH] PATHEXT = os.environ[PATHEXT] all = 0 if sys.argv[1] == -a: del sys.argv[1] all = 1 arg = sys.argv[1] base, ext = os.path.splitext (arg) for path in string.split (PATH, ';'): if not ext: for extension in string.split(PATHEXT, ';'): if os.path.isfile(path + '\\' + arg + extension): print path + '\\' + arg + extension if not all: sys.exit (0) else: if os.path.isfile (path + '\\' + arg): print path + '\\' + arg if not all: sys.exit (0) c:\ There may be better variants of which out there... Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
Shuaib wrote: Hey again, I am using the latest python available on my system (2.4). So I don't think that's the problem. Any more ideas? Do I need to install Tkinter as a seperate module/package? As I said, I've already installed Tcl/Tk, though. Hmm, yes, I think tkinter is separate from Tk, so you might try doing a search for it in your repositories and see if something comes up that you don't have installed yet. -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
[EMAIL PROTECTED] wrote: I've just reconsiled to pick up my BASH by osmosis and concentrate on (much!) cleaner scripting with Python. John I don't have much of a need to learn the actual programming parts John of the bash language, ... As long as you promise never, ever, ever to try programming in csh... Skip Heh heh, Python all the way! -- http://mail.python.org/mailman/listinfo/python-list
Re: binary conversion issues
godavemon wrote: I'm using python's struct and binascii modules to write some values from my parser to binary floats. This works great for all of my binary files except one. For some reason this file is saving to 836 (stated by my command shell) bytes instead of 832 like it should. It sounds like an issue with whatever's writing that particular file out but I've checked it 100 times. Also python can read in the 836 byte file, find it has a size of 832 bytes and convert back each value perfectly. However, when I read in the file in C++ it finds a file of size 836 and in the middle of the data starts spitting out junk. Has anyone run into an issue like this or have an idea of what it could be? Not enough information. Code and data samples would help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter module not found
Thomas Heller wrote: c:\which python c:\util\python.EXE which didn't work for me on the command prompt...is it native to it? -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
John Salerno wrote: [EMAIL PROTECTED] wrote: John Aside from the normal commands you can use, I was wondering if John it's possible to use Python from the terminal instead of the John normal bash commands (e.g. print instead of echo). Take a look at ipython http://ipython.scipy.org/. It's not precisely what you've asked for, but it provides some features that help integrate Python with the shell environment. Skip Can you use IPython to do normal bash things, like installing, etc.? normal bash things? :-) Yes, most commands can be run by putting an '!' before them. If you ever need to run something that for some reason doesn't work with this, you can always run !bash and do it in bash. :-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
Bruno Desthuilliers wrote: there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables except strings...): strings don't have __iter__ ?!?! I'm never going to get my head round this language 8-( I can understand strings and tuples being iterable, if you take a sufficiently first-class view of things, but why shouldn't everything that is iterable support the function that makes iteration work? -- http://mail.python.org/mailman/listinfo/python-list
Newbie question: what's with self?
This is probably a really basic question, but anyway ... I'm new to both Python and OO programming. From looking at a number of code examples, the word self is used a lot when referring to classes. As such, what does self mean and/or do? I've read things that say it's a naming convention, but no-one has really spelt it out (in idiot form!) in a way I can understand. Any help you can provide would be great: at the moment, when code doesn't work as expected, I'm randomly sprinkling selfs in all over the place to see if that helps, but without much of an idea of what it really achieves. Thanks in advance!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Class attributes, instances and metaclass __getattribute__
On 8 Aug 2006 07:24:54 -0700 Ziga Seilnacht [EMAIL PROTECTED] wrote: [snip] Well... I'm not talking about metaclass attributes... that's perfectly consistent, agreed. I'm saying that when the class implements a custom __getattribute__, when you try to access the instance attributes from itself, it uses it. But if the class is a metaclass, instances of its instances have acess to the attribute anyway, but don't use the custom __getattribute__ you implemented. Attribute lookup for instances of a class never calls metaclass' __getattribute__() method. This method is called only when you access attributes directly on the class. Well... thanks for the answer. As I said on the first mail, I noticed this when I was explaining descriptors and methods to someone else... I implemented a pure-python Method class to show him exactly how it works. But, since their __get__ call is available at the class too, my first thought was that it was implemented at the metaclass __getattribute__, and when an instance tries to get a class attribute it would fail on its own __getattribute__, use the bound method at its class and make the call. After implementing a test metaclass I noticed it doesn't work this way, and even if it's a bit inconsistent (especially in the case of 'virtual' attributes), it seemed to me the reasonable thing to do, exactly for what you mentioned on your code... someone could easily break a lot of stuff doing it the wrong way, instead if not using __dict__. I mailed the list because someone else thought it might be a bug and I was in doubt... now it's clear it was the right thing to do. Regards, -- Pedro Werneck -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing MSVCR71.dll
The windows distribution of python was compiled with Visual Studio 7.1, so you need the 7.1 runtime libraries on your computer to run python. I haven't tried compiling an app with VS2005, but I don't see why they would be incompatible. I've compiled a python app using VS 7.0 and it worked fine. -Farshid -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: what's with self?
donkeyboy wrote: This is probably a really basic question, but anyway ... I'm new to both Python and OO programming. From looking at a number of code examples, the word self is used a lot when referring to classes. As such, what does self mean and/or do? I've read things that say it's a naming convention, but no-one has really spelt it out (in idiot form!) in a way I can understand. Any help you can provide would be great: at the moment, when code doesn't work as expected, I'm randomly sprinkling selfs in all over the place to see if that helps, but without much of an idea of what it really achieves. Thanks in advance!! Hi, Take a look at the following FAQ on the python homepage: http://www.python.org/infogami-faq/general/why-must-self-be-used-explicitly-in-method-definitions-and-calls/ -Farshid -- http://mail.python.org/mailman/listinfo/python-list
Unicode/utf-8 data in SQL Server
I'm working with a MS SQL Server database created by a program from a fine US company who seems to have gotten run over by the Unicode truck. In their infinite wisdom they've decided to store Unicode data directly in regular varchar fields, utf-8 encoded! (on the bright side, it is properly utf-8 encoded). One of our customers then wants to use a csv file created from a report to import in Excel and is getting an attitude when the text shows up all garbled (which I can understand...) One method that works is to use Python to pull down the result set from the database, accumulate the entire result text as a big unicode string (while decode('utf-8') all text fields in the process) separating each field with a tab, before encode('utf-16') the result string and writing it to a file opened in binary mode. This ensures that the file gets a bom, that it's in a format (utf-16) that Excel can import, and hopefully tabs are less common than commas in the source data :-( The csv module doesn't support Unicode. The customer is of the firm belief that our national characters (æøå) are part of ascii, presumably because they're single-byte-encoded in iso-8859-1. He has no understanding for the issues (either by choice or experience) so there is no purpose to trying to explain the differences... Be that as it may, he might be satisfied with a csv file in that (iso-8859-1) encoding since the local version of Excel can import it transparently (with significant behind-the-scenes magic I believe...?) The Python script mentioned above has to be run on the server, since it doesn't accept remote connections, I'm of course the only one with access, and I'd like to remove myself from the loop. I've looked at creating a view on the database that would cast or convert the data, but all I've run into are vague references to StrConv, which seems to be a VB function. Giving the customer a macro that he could run in Excel after importing the data would probably be ok as well, so I also tried creating an Excel VB macro using the StrConv function, but (a) it isn't entirely clear to me that this function can do this, and (b) the third argument to the function is an LCID, a Locale ID, which is numeric and not defined anywhere I can find it... Anyone have any advice? tia, -- bjorn -- http://mail.python.org/mailman/listinfo/python-list
Re: binary conversion issues
On 2006-08-08, godavemon [EMAIL PROTECTED] wrote: I'm using python's struct and binascii modules to write some values from my parser to binary floats. This works great for all of my binary files except one. For some reason this file is saving to 836 (stated by my command shell) bytes instead of 832 like it should. I'm just making a wild-ass guess since you didn't provide any sample code or data, but it sounds like cr/lf translation problem to me. Make sure you open the files in binary mode using the b flag. -- Grant Edwards grante Yow! Is this BIKINI at BEACH? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: what's with self?
donkeyboy wrote: This is probably a really basic question, but anyway ... I'm new to both Python and OO programming. From looking at a number of code examples, the word self is used a lot when referring to classes. As such, what does self mean and/or do? I've read things that say it's a naming convention, but no-one has really spelt it out (in idiot form!) in a way I can understand. Any help you can provide would be great: at the moment, when code doesn't work as expected, I'm randomly sprinkling selfs in all over the place to see if that helps, but without much of an idea of what it really achieves. Thanks in advance!! When you write a class, it works sort of like a template for creating instances of that class. The instances have variables (as attributes) and use the methods (functions with the 'self' parameter) you define in the class to manipulate the variables. class foo: def __init__(self, value=0): self.value = value def get(self): return self.value def add(self, n): self.value += n f = foo() # magically calls the __init__ method # Call some methods on the instance. print f.get() f.add(23) print f.get() # Access the instance attribute directly. print f.value f.value -= 23 print f.value # The above code prints: 0 23 23 0 Notice how, when you call f.get() and f.add(23), you don't pass in the 'self' parameter? That's because when you call a method (get, add) on an instance (f) of a class (foo), the python interpreter fills in the 'self' parameter for you as the instance itself. (itSELF, get it?) Put another way, inside the method, self == f. If you were to create another instance, g = foo(), and call the methods on/with it, g.get(), then self == g. Use can even use the class and pass in the instance yourself, foo.get(f) and foo.add(f, 23), but there's almost never a reason to do that. I hope this helps. (BTW, don't randomly sprinkle things in your code. Programming ain't like cooking. You can't just add a dash of 'self's and a sprinkle of 'if..then..'s. :-) You should know what you are doing and why. If not, read and ask questions. Computers are deterministic machines that do exactly what you tell them to. If you tell them to do random things you'll get random results, and if *you* don't even understand your code then it's quite likely no one will and all you'll have is pointless junk. (And if there's one thing I've learned reading and posting to c.l.p in the last couple of months, it's that there's *plenty* of pointless junk around already.) One exception to don't sprinkle things would be print statements, but even there, don't sprinkle randomly...) :-) Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list
Re: using python at the bash shell?
Simon Forman wrote: normal bash things? :-) forgive my ignorance, i just installed linux on saturday! :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Accessing Yahoo Mail withtout POP
At Tuesday 8/8/2006 12:39, Dieter Deyke wrote: Is there a way to access yahoo mail via its web interface? If so, can someone give some pointers? www.freepops.org Very generic almost-anything-to-pop3, but it's not written in Python, uses LUA instead. Gabriel Genellina Softlab SRL __ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: what's with self?
donkeyboy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This is probably a really basic question, but anyway ... I'm new to both Python and OO programming. From looking at a number of code examples, the word self is used a lot when referring to classes. As such, what does self mean and/or do? I've read things that say it's a naming convention, but no-one has really spelt it out (in idiot form!) in a way I can understand. Any help you can provide would be great: at the moment, when code doesn't work as expected, I'm randomly sprinkling selfs in all over the place to see if that helps, but without much of an idea of what it really achieves. Thanks in advance!! To put it simply, a class needs a way to know which instance (of itself!) to operate on. If you have a class str (and Python has that built in!), then there will be many instances of class str in a typical program. The parameter self refers to the particular string the class method is being called to operate upon. If you have a method upper() that convert everything to uppercase, your class definition would need the self parameter in order to know which particular string to convert. Thomas Bartkus -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie question: what's with self?
donkeyboy wrote: but no-one has really spelt it out Go to: http://www.freenetpages.co.uk/hp/alan.gauld/ Look down the left-hand frames page until you see Advanced Topics | Object Oriented Programming Then find What is self? Good luck rd -- http://mail.python.org/mailman/listinfo/python-list
ImportError: math.so: undefined symbol PyFPE_jbuf
Hello! I'm trying to install the web application written with Python, and have the trouble with module math.so: # lwp-request http://localhost/site/code/edit.py Mod_python error: PythonHandler edit::handler Traceback (most recent call last): File /usr/local/lib/python2.3/site-packages/mod_python/apache.py, line 181, in Dispatch module = import_module(module_name, _req) File /usr/local/lib/python2.3/site-packages/mod_python/apache.py, line 335, in import_module module = imp.load_module(mname, f, p, d) File /usr/local/apache/htdocs/site/code/edit.py, line 6, in ? from PPA.HTTP.CGI import Adapter File /usr/local/lib/python2.3/site-packages/PPA/HTTP/CGI.py, line 3, in ? import Base File /usr/local/lib/python2.3/site-packages/PPA/HTTP/Base.py, line 102, in ? class Response: File /usr/local/lib/python2.3/site-packages/PPA/HTTP/Base.py, line 104, in Response from Errors import statusCodes File /usr/local/lib/python2.3/site-packages/PPA/HTTP/Errors.py, line 3, in ? import cgi File /usr/lib/python2.3/cgi.py, line 40, in ? import mimetools File /usr/lib/python2.3/mimetools.py, line 6, in ? import tempfile File /usr/lib/python2.3/tempfile.py, line 33, in ? from random import Random as _Random File /usr/lib/python2.3/random.py, line 42, in ? from math import log as _log, exp as _exp, pi as _pi, e as _e ImportError: /usr/lib/python2.3/lib-dynload/math.so: undefined symbol: PyFPE_jbuf I read similar topic at http://mail.python.org/pipermail/python-list/2006-July/349940.html but did not find the solution :( Of cource I'm using apache 1.3.33, mod_python 2.7.11, ppa, qps, mx modules, but I thing that the problem is in the Python 2.3.5. Any ideas? -- http://mail.python.org/mailman/listinfo/python-list
String.digits help!!!
Hi All Hope u all might have come across the string deprecation thought of in Python 3.0. For example : string.lower(str) needs to be some thing like str.lower(). Can some one help me out whether such a change in the common python would require string.digits to be changed. If yes wat would be ur suggestions Thanks for ur inputs Anoop -- http://mail.python.org/mailman/listinfo/python-list
Re: Missing MSVCR71.dll
Hi Farshid, Yes, you are correct. I downloaded the dll and was able to run a debug build. Jeff Farshid Lashkari wrote: The windows distribution of python was compiled with Visual Studio 7.1, so you need the 7.1 runtime libraries on your computer to run python. I haven't tried compiling an app with VS2005, but I don't see why they would be incompatible. I've compiled a python app using VS 7.0 and it worked fine. -Farshid -- http://mail.python.org/mailman/listinfo/python-list
Re: Info on continuations?
Michele Simionato wrote: vasudevram wrote: Hi, I am Googling and will do more, found some stuff, but interested to get viewpoints of list members on: Continuations in Python. Thanks to all who replied. Vasudev -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting previous file name
Thank you everyone. It worked. Here is the BETA 0.9 :) import os, time, sys from stat import * def findfile(path): file_list = [] for f in os.listdir(path): filename = os.path.join(path, f) if not os.path.isfile(filename): print *** Not a file:, repr(filename) continue create_date_secs = os.stat(filename)[ST_CTIME] create_date = time.strftime(%Y%m%d%H%M%S, time.localtime(create_date_secs)) file_list.append((create_date, filename)) file_list.sort() print file_list[-2] return file_list[-2] if __name__ == '__main__': path = r'\\rad-db02-ny\c$\backup\rad_oltp' create_date, prev_file = findfile(path) print Previous back file is: , prev_file, , create_date Now I am going to read this file and manupulate stuff with DB so I am going to work on ODBC connection using python.. interesting stuff. Thank you all, hj Hitesh wrote: Hi, I have a small script here that goes to inside dir and sorts the file by create date. I can return the create date but I don't know how to find the name of that file... I need file that is not latest but was created before the last file. Any hints... I am newbiw python dude and still trying to figure out lot of 'stuff'.. import os, time, sys from stat import * def walktree(path): test1 = [] for f in os.listdir(path): filename = os.path.join(path, f) create_date_sces = os.stat(filename)[ST_CTIME] create_date = time.strftime(%Y%m%d%H%M%S, time.localtime(create_date_sces)) print create_date, . , f test1.append(create_date) test1.sort() print test1 return test1[-2] if __name__ == '__main__': path = 'srv12\\c$\\backup\\my_folder\\' prev_file = walktree(path) print Previous back file is , prev_file Thank you, hj -- http://mail.python.org/mailman/listinfo/python-list
Re: Python open a named pipe == hanging?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Alex Martelli) wrote: Donn Cave [EMAIL PROTECTED] wrote: ... I believe your problem is that, by the time you open the pipe for read, it has already been closed by its writer. Hmmm, no: the problem is, he never opens the pipe for write, because the open blocks (will not proceed until somebody opens the fifo for reading, which in turn won't happen here because the open blocks). Try: a = open('my_fifo', 'w') b = os.popen('cat my_fifo') a.write ... a.close() c = b.read() this STILL doesn't work, since the very first statement blocks. (I've also removed the 'r+' mode in favor of 'w', since opening a FIFO for reading AND writing produces undefined behavior, at least in all Unix versions and variants I'm familiar with). But it does work. I edited that excerpt only to complete missing parts, and ran it on MacOS X and GNU Linux. import os f = '/tmp/r' try: os.unlink(f) except: pass You forgot to add os.mkfifo(f) here -- so you're writing and reading a perfectly ordinary file... of course *that* gives no problems!-) Of course you're right about that, and with that fixed we see that you're right, the open blocks. In order to avoid that, you have to open r+, which after all is what the original post proposed to do. os.mkfifo(f) a = open(f, 'r+') a.write('chunks\n') b = os.popen('cat %s' % f) a.close() c = b.readline() print repr(c) And again, if the close() moves up before the cat, there's no data - the read end has to open before the write end closes. But I cheated when I replaced read() with readline(). The read end (cat) doesn't detect the end of file, when there are two processes involved. On NetBSD, when the child process closes the write descriptor, that operation doesn't entirely succeed and the file descriptor is left in a `no more information' state. On Linux, one doesn't see that, but the result is the same. In any case, a stream that can't have an end is not going to be very satisfactory. [I don't know why I get tangled up in these named pipe problems, when I know better myself than to use them!] Donn Cave, [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
ANN: xtopdf: PDF creation / conversion toolkit: alpha release of v1.3
Hi group, ANN: xtopdf: PDF creation / conversion toolkit: alpha release of v1.3 This is actually a somewhat preliminary announcement, but may be of interest to developers / users who know Python and/or have earlier checked out my xtopdf PDF creation / conversion toolkit ( http://sourceforge.net/projects/xtopdf): I've released (via my own web site, not yet properly packaged/documented and put on the SourceForge site, that will be done in some days), the next version of xtopdf: v1.3. This version adds support for conversion of CSV, TDV (Tab Delimited Values) and XLS (limited support) to PDF. v1.3 also adds some GUI tools written using wxPython (v1.0 had only command-line tools and a library for developers). Users/developers will need to install wxPython and properly configure it to work with their Python installation before they can use these GUI tools. This is fairly straightforward on Windows using the .MSI or .EXE (can't remember which it is right now) installer for wxPython, but on Linux, you'll need to know how to handle the tools that are used to build packages from source code, i.e. make, configure, etc. Also, wxPython is a medium-sized package - it took around an hour or two to fully build on my reasonably fast PC. So be patient (get yourself a coffee or two, or do something else in another Linux console / window while wxPython builds :-) Those who know even basic Python should be able to install and run both xtopdf v1.0 and the new stuff in v1.3, at least for the command-line tools (the programs are quite simple). Main SourceForge site for xtopdf v1.0: http://sourceforge.net/projects/xtopdf URL for xtopdf v1.3 on my web site: http://www.dancingbison.com/xtopdf-1.3.zip URL for xtopdf v1.0 on my web site: http://www.dancingbison.com/xtopdf-1.0.tar.gz wxPython site: http://wxpython.org xtopdf requires both Python and the open source version of the ReportLab toolkit. ReportLab site: http://www.reportlab.org xtopdf was developed using ReportLab v1.17, should work with all v1.x, may or may not work (not tested yet) with v2.x. More details (for Windows) are available in a guide here: http://itext.ugent.be/library/question.php?id=41 I'd appreciate any feedback, about bugs (v1.3 is tested but not a lot yet, that will be done in next some days), or how / what for anyone is using it. Apart from the proper packaging/documenting and upload to SourceForge (and my web site), I shall be writing and posting more about how to use it, etc. in the coming days. Enjoy, and Thanks Vasudev === Vasudev Ram Software consulting and training http://www.dancingbison.com === -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie - How to iterate list or scalar ?
Andy Dingley wrote: Bruno Desthuilliers wrote: there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables except strings...): strings don't have __iter__ ?!?! No. Should they ?-) I'm never going to get my head round this language 8-( Hmmm While simple to get started with, Python is *not* a 'simple' language. There's a price to pay for it's flexibility, and this price is named complexity. While one doesn't necessary needs to deal with it, this complexity shows as soon as you start to dig deeper into advanced features. FWIW, if I judge on source code I've seen so far, the canonical way to distinguish a string from another sequence type or iterable is still to use isinstance(obj, basestring), and I don't know if I should have mentionned the hasattr(obj, '__iter__') hack at all. I can understand strings and tuples being iterable, if you take a sufficiently first-class view of things, but why shouldn't everything that is iterable support the function that makes iteration work? Actually, __iter__ is not needed to allow for loops on an object if the object defines __getitem__ so that it supports numeric indexing: class MySequence(object): def __init__(self): self._data = range(3) def __getitem__(self, key): return self._data[key] m = MySequence() for x in m: print x ... 0 1 2 FWIW, the iterator protocol appeared with Python 2.2. Before this version, the above solution was the only one that allowed iteration over a container type. Now if you wonder why string, unicode and buffer don't have __iter__ while other sequence types have it, ask your favourite Python guru (and please keep me informed !-). Fact is that Python is not exactly a newborn language (first release was around 1990 IIRC), and it has greatly evolved over the year. The BDFL being very conservative, great cares have been taken to ensure compatibility with older versions - with the side effect that there are lots of stuff that now looks like warts or inconsistencies. The 3K release is supposed to be the big cleanup, but until then, we'll have to live with all the compat stuff. HTH -- http://mail.python.org/mailman/listinfo/python-list