On Thu, 20 Jan 2005 15:41:43 +0100 (CET), [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > > Today's Topics: > > 1. Re: Class introspection and dynamically determining function > arguments (Diez B. Roggisch) > 2. Re: xml parsing escape characters (Luis P. Mendes) > 3. Problem in importing MySQLdb (Gurpreet Sachdeva) > 4. Re: Problem in importing MySQLdb (deelan) > 5. Re: mod_python friendly isps in europe (Daniel Bowett) > 6. Re: xml parsing escape characters (Kent Johnson) > 7. Re: Zen of Python (Steve Holden) > 8. Re: Freezing a mutable (was Re: lambda) (Antoon Pardon) > 9. Re: iteritems() and enumerate() (Steve Holden) > 10. Re: ElementTree cannot parse UTF-8 Unicode? (Erik Bethke) > 11. Re: ElementTree cannot parse UTF-8 Unicode? (Fredrik Lundh) > > > > ---------- Forwarded message ---------- > From: "Diez B. Roggisch" <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 13:50:37 +0100 > Subject: Re: Class introspection and dynamically determining function > arguments > Nick Coghlan wrote: > > > > If this only has to work for classes created for the purpose (rather than > > for an arbitrary class): > > > > Certainly a step into the direction I meant - but still missing type > declarations. And that's what at least I'd like to see - as otherwise you > don't know what kind of editing widget to use for a property. > -- > Regards, > > Diez B. Roggisch > > > > ---------- Forwarded message ---------- > From: "Luis P. Mendes" <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 13:05:59 +0000 > Subject: Re: xml parsing escape characters > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > this is the xml document: > > <?xml version="1.0" encoding="utf-8"?> > <string xmlns="http://www......"><DataSet> > ~ <Order> > ~ <Customer>439</Customer> > (... others ...) > ~ </Order> > </DataSet></string> > > When I do: > > print xmldoc.toxml() > > it prints: > <?xml version="1.0" ?> > <string xmlns="http://www..."><DataSet> > ~ <Order> > ~ <Customer>439</Customer> > > ~ </Order> > </DataSet></string> > > __________________________________________________________ > with: stringNode = xmldoc.childNodes[0] > print stringNode.toxml() > I get: > <string xmlns="http://www......."><DataSet> > ~ <Order> > ~ <Customer>439</Customer> > > ~ </Order> > </DataSet></string> > ______________________________________________________________________ > > with: DataSetNode = stringNode.childNodes[0] > print DataSetNode.toxml() > > I get: > > <DataSet> > ~ <Order> > ~ <Customer>439</Customer> > > ~ </Order> > </DataSet> > _______________________________________________________________- > > so far so good, but when I issue the command: > > print DataSetNode.childNodes[0] > > I get: > IndexError: tuple index out of range > > Why the error, and why does it return a tuple? > Why doesn't it return: > <Order> > <Customer>439</Customer> > > </Order> > ?? > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.4 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFB76y3Hn4UHCY8rB8RAvQsAKCFD/hps8ybQli8HAs3iSCvRjwqjACfS/12 > 5gctpB91S5cy299e/TVLGQk= > =XR2a > -----END PGP SIGNATURE----- > > > > ---------- Forwarded message ---------- > From: Gurpreet Sachdeva <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 18:53:06 +0530 > Subject: Problem in importing MySQLdb > I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2) > > When I try to import MySQldb > > I get: > Python 2.2.2 (#1, Feb 24 2003, 19:13:11) > [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import MySQLdb > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/lib/python2.2/site-packages/MySQLdb/__init__.py", line 27, in ? > import _mysql > ImportError: /usr/lib/libmysqlclient.so.10: symbol errno, version > GLIBC_2.0 not defined in file libc.so.6 with link time reference > > Is there any problem in library files?? Do I need to install anything > I have installed MySQL-shared-3.23.54a-1.i386.rpm, > MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm, > MySQL-server-5.0.2-0.i386.rpm > > Please help, > Garry > > > > ---------- Forwarded message ---------- > From: deelan <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 14:43:01 +0100 > Subject: Re: Problem in importing MySQLdb > Gurpreet Sachdeva wrote: > > I am using Mysql version 5.0.2-alpha on RedHat 9.0 (python2.2) > > > > When I try to import MySQldb > > i' not completely sure mysqldb works with mysql 5.0 and its > bundled client libraries. > > to be more precise: > > '' MySQL-5.0 and newer are not currently supported, > but might work.'' > > from: > <http://sourceforge.net/project/shownotes.php?release_id=293608> > > > Is there any problem in library files?? Do I need to install anything > > I have installed MySQL-shared-3.23.54a-1.i386.rpm, > > MySQL-devel-5.0.2-0.i386.rpm, MySQL-client-5.0.2-0.i386.rpm, > > MySQL-server-5.0.2-0.i386.rpm > > are u sure you have compiled mysqldb against 5.0 > client libs? > > you may want to post on the mysqldb forum of ask > for help there: > > <http://sourceforge.net/forum/forum.php?forum_id=70461> > > HTH, > deelan > > -- > @prefix foaf: <http://xmlns.com/foaf/0.1/> . > <#me> a foaf:Person ; foaf:nick "deelan" ; > foaf:weblog <http://blog.deelan.com/> . > > > > ---------- Forwarded message ---------- > From: Daniel Bowett <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 08:48:37 +0000 > Subject: Re: mod_python friendly isps in europe > [EMAIL PROTECTED] wrote: > > Hello everybody > > > > I'm thinking about improving my web site scripts > > and would like to use Python instead of PHP/Perl. > > > > Does anyone know of mod_python friendly ISPs in > > europe? With prices around 10â ? > > > > Thanks in advance, > > Paulo > > > > I would doubt you will find any commercial python ISP's out there. If > you do could you post them here? > > > > ---------- Forwarded message ---------- > From: Kent Johnson <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 09:01:01 -0500 > Subject: Re: xml parsing escape characters > Luis P. Mendes wrote: > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > this is the xml document: > > > > <?xml version="1.0" encoding="utf-8"?> > > <string xmlns="http://www......"><DataSet> > > ~ <Order> > > ~ <Customer>439</Customer> > > (... others ...) > > ~ </Order> > > </DataSet></string> > > This is an XML document containing a single tag, <string>, whose content is > text containing > entity-escaped XML. > > This is *not* an XML document containing tags <DataSet>, <Order>, <Customer>, > etc. > > All the behaviour you are seeing is a consequence of this. You need to > unescape the contents of the > <string> tag to be able to treat it as structured XML. > > Kent > > > > ---------- Forwarded message ---------- > From: Steve Holden <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 09:04:00 -0500 > Subject: Re: Zen of Python > Paul Rubin wrote: > > > Tim Peters <[EMAIL PROTECTED]> writes: > > > >>>Huh? [1,2,[3,4,5],[6,[[[[7]],8]]]] is a perfectly valid Python list. > >> > >>You're claiming not to know any relevant difference between Python > >>lists and Lisp lists? Heh. > > > > > > Python doesn't provide syntactic sugar for [1,[2,[3,[4,[]]]]] if > > that's what you mean. In Lisp you'd say (1 2 3 4). It's still > > a perfectly valid list in Python. Python by convention uses > > multi-element arrays instead of lists of conses. > > > But how, in Lisp, would you transliterate the Python list [1, 2, 3, 4]? > Clearly the Python list *is* different, and the tradeoff was to obtain > speed of random access, presumably (I wasn't taking an interest in > Python in its early days) anticipating that non-recursive algorithms > would be the norm. > > > >>>And you can break out of a containing loop from a nested loop > >>>with try/raise. > >> > >>Heh heh. Yes, you can. I've never seen a real Python program that > >>did, but there's nothing to stop you. > > > > > I do that on a fairly routine basis. I won't say "often", but it's a > > standard technique that finds a use now and then. > > > Well, I blush to say I have done that (once, if my memory serves me > correctly), but it was an ugly program, and I did eventually refactor > the code so that the loops were in separate scopes, which made it much > cleaner. > > [...] > > > > There's a technique in numerical analysis called Richardson > > extrapolation, where you compute an integral by [...] > > Wow. Anyone who feels the need to explain numerical analysis techniques > to Tim Peters is wasting keystrokes big-time. Anyway, Richardson > extrapolation is merely one of many successive approximation techniques, > which is what you are talking about, no? > > > > > I see the same thing happening in Python. It's going through > > successively better approximations to get closer to a limit. Python > > has it harder than some other languages, because it tries to serve the > > needs of both throwaway scripts and large-scale development projects. > > The result is that feature after feature starts out with an > > implementation sufficient for small scripts, and then edges towards > > the needs of large-scale projects. But it's often predictable at the > > beginning what the final destination is going to be. So once we can > > see where it's going, why not proceed to the finish line immediately > > instead of bothering with the intermediate steps? > > Perhaps because we don't all have your psychic powers? > > regards > Steve > -- > Steve Holden http://www.holdenweb.com/ > Python Web Programming http://pydish.holdenweb.com/ > Holden Web LLC +1 703 861 4237 +1 800 494 3119 > > > > ---------- Forwarded message ---------- > From: Antoon Pardon <[EMAIL PROTECTED]> > To: python-list@python.org > Date: 20 Jan 2005 14:07:57 GMT > Subject: Re: Freezing a mutable (was Re: lambda) > Op 2005-01-20, Nick Coghlan schreef <[EMAIL PROTECTED]>: > > Antoon Pardon wrote: > >> I missed that you would use it with the idiom: dct[x.frozen()] > > > > The list itself isn't hashable with this approach, so you don't have much > > choice. I wasn't particularly clear about that point, though. > > > >> I have two problems with this approach. > >> > >> 1) It doesn't work when you get your keys via the keys/items > >> methods. > > > > True - the frozen object has no link back to the original object. That > > could be > > added though (by returning a tuple subtype with the extra attribute) > > > >> 2) This is rather minor, but a user could still unfreeze > >> untimely > > > > True - doing that is less likely than mutating a hashable list though :) > > > > I'm just noting this as a way to avoid copying data more than once when > > storing > > immutable copies of mutable data in a dictionary. You're quite right that > > there > > isn't a really clean idiom for doing that in Python (aside from moving to a > > different data structure that works natively as a dict key, naturally). > > The problem here is IMO is the, we are all consenting adults (which we > are not but I wont start on this now), approach. > > I have been thinking a bit in your freeze direction, but more thorough. > The idea i had was that freeze would replace all mutating methods > with methods that would throw an exception. a thaw method would inverse > the proces. It would then be the responsibilty of the dictionary to > freeze an object on entry and thaw it when removed. However this > wouldn't work with ordinary python objects, since there is no easy way > to have readonly or private variables. > > -- > Antoon Pardon > > > > ---------- Forwarded message ---------- > From: Steve Holden <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 09:07:39 -0500 > Subject: Re: iteritems() and enumerate() > Xah Lee wrote: > > > Python has iteritems() and enumerate() to be used in for loops. > > > > can anyone tell me what these are by themselves, if anything? > > > > are they just for idiom? > > No, anyone can use them, not just idioms like you. > > regards > Steve > -- > Steve Holden http://www.holdenweb.com/ > Python Web Programming http://pydish.holdenweb.com/ > Holden Web LLC +1 703 861 4237 +1 800 494 3119 > > > > ---------- Forwarded message ---------- > From: "Erik Bethke" <[EMAIL PROTECTED]> > To: python-list@python.org > Date: 20 Jan 2005 06:20:46 -0800 > Subject: Re: ElementTree cannot parse UTF-8 Unicode? > There is something wrong with the physical file... I d/l a trial > version of XML Spy home edition and built an equivalent of the korean > test file, and tried it and it got past the element tree error and now > I am stuck with the wxEditCtrl error. > > To build the xml file in the first place I had code that looked like > this: > > d=wxFileDialog( self, message="Choose a file", > defaultDir=os.getcwd(), defaultFile="", wildcard="*.xml", style=wx.SAVE > | wxOVERWRITE_PROMPT | wx.CHANGE_DIR) > if d.ShowModal() == wx.ID_OK: > # This returns a Python list of files that were selected. > paths = d.GetPaths() > layout = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n' > L1Word = self.t1.GetValue() > L2Word = 'undefined' > > layout += '<Vocab>\n' > layout += ' <Word L1=\'' + L1Word + '\'></Word>\n' > layout += '</Vocab>' > open( paths[0], 'w' ).write(layout) > d.Destroy() > > So apprantly there is something wrong with physically constructing the > file in this manner? > > Thank you, > -Erik > > > > ---------- Forwarded message ---------- > From: "Fredrik Lundh" <[EMAIL PROTECTED]> > To: python-list@python.org > Date: Thu, 20 Jan 2005 15:40:35 +0100 > Subject: Re: ElementTree cannot parse UTF-8 Unicode? > Erik Bethke wrote: > > > layout += '<Vocab>\n' > > layout += ' <Word L1=\'' + L1Word + '\'></Word>\n' > > what does "print repr(L1Word)" print (that is, what does wxPython return?). > it should be a Unicode string, but that would give you an error when you write > it out: > > >>> f = open("file.txt", "w") > >>> f.write(u'\uc5b4\ub155\ud558\uc138\uc694!') > Traceback (most recent call last): > File "<stdin>", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode characters > in position 0-4: ordinal not in range(128) > > have you hacked the default encoding in site/sitecustomize? > > what happens if you replace the L1Word term with L1Word.encode("utf-8") > > can you post the repr() (either of what's in your file or of the thing, > whatever > it is, that wxPython returns...) > > </F> > > > -- > http://mail.python.org/mailman/listinfo/python-list > >
-- Atte, Eduardo HenrÃquez A. 9-6975236 -- http://mail.python.org/mailman/listinfo/python-list