Re: RegExp performance?

2007-02-25 Thread John Machin
On Feb 26, 2:01 pm, Kirk Sluder <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Christian Sonne <[EMAIL PROTECTED]> wrote: > > > Thanks to all of you for your replies - they have been most helpful, and > > my program is now running at a reasonable pace... > > > I ended up using r"\

Re: Nested Parameter Definitions

2007-02-25 Thread bearophileHUGS
Virgil Dupras: > Without the call example, I would have > had a hard time to try to figure out what these extra brackets are > for. For this reason, I think that an explicit unpack is more > readable, and thus better. I can't agree. Bye, bearophile -- http://mail.python.org/mailman/listinfo/py

Re: Rational numbers

2007-02-25 Thread Gabriel Genellina
En Sat, 24 Feb 2007 01:42:00 -0300, Martin Manns <[EMAIL PROTECTED]> escribió: > On Fri, 23 Feb 2007 20:20:12 -0300 > "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > >> mx.Number.Rational is horribly broken. They break this rule: >> a==b => hash(a)==hash(b) >> so they can'b be used as dictionary

Re: Help on Dict

2007-02-25 Thread Steven D'Aprano
On Mon, 26 Feb 2007 07:15:43 +0200, Hendrik van Rooyen wrote: > "James Stroud" <[EMAIL PROTECTED]> wrote: > > >> Clement wrote: >> > Can any body tell how Dict is implemented in python... plz tell what >> > datastructure that uses >> > >> >> I think it uses a dict. > > "Groan

help regarding python and jsp

2007-02-25 Thread chandrapsg
Hi, i am working with jsp .. i wanna help regarding how to import or how to call python modules to jsp if a piece of code is availabe will be very helpful for me chandra -- http://mail.python.org/mailman/listinfo/python-list

help regarding python and jsp

2007-02-25 Thread chandrapsg
Hi, i am working with jsp .. i wanna help regarding how to import or how to call python modules to jsp if a piece of code is availabe will be very helpful for me chandra -- http://mail.python.org/mailman/listinfo/python-list

Re: Weakref problem: no way to get original object from proxy object?

2007-02-25 Thread John Nagle
Gabriel Genellina wrote: > En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <[EMAIL PROTECTED]> > escribió: > >> Is there some way to get a strong ref to the original object back >> from a weakref proxy object? I can't find any Python function to do >> this. >> ".ref()" doesn't work on prox

Re: Nested Parameter Definitions

2007-02-25 Thread Hendrik van Rooyen
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > On Feb 25, 6:00 pm, "Paddy" <[EMAIL PROTECTED]> wrote: > > I blogged on finding a new-to-me feature of Python, in that you are > > allowed to nnest parameter definitions: > > > > >>> def x ((p0, p1), p2): > > > > ... return p0,p1,p2 > > ...>>> x

Re: Help on object scope?

2007-02-25 Thread Hendrik van Rooyen
"hg" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > > Hello everybody, > > > > I have a (hopefully) simple question about scoping in python. I have a > > program written as a package, with two files of interest. The two > > files are /p.py and /lib/q.py Make a third file for all th

Re: Help on Dict

2007-02-25 Thread Hendrik van Rooyen
"James Stroud" <[EMAIL PROTECTED]> wrote: > Clement wrote: > > Can any body tell how Dict is implemented in python... plz tell what > > datastructure that uses > > > > I think it uses a dict. "Groan!" - this answer is like Microsoft documentation - while technically correct,

Jobs: Lisp and Python programmers wanted in the LA area

2007-02-25 Thread Tech HR
http://www.smartcharter.com/jobs.html Smart Charter Inc. is a dynamic new startup company aiming to revolutionize the purchase and sale of private aviation services. If you are ready for a challenging ground-floor opportunity with significant upside potential you've come to the right place. We

Re: RegExp performance?

2007-02-25 Thread Kirk Sluder
In article <[EMAIL PROTECTED]>, Christian Sonne <[EMAIL PROTECTED]> wrote: > Thanks to all of you for your replies - they have been most helpful, and > my program is now running at a reasonable pace... > > > I ended up using r"\b\d{9}[0-9X]\b" which seems to do the trick - if it > turns out t

Re: Weakref problem: no way to get original object from proxy object?

2007-02-25 Thread Gabriel Genellina
En Sun, 25 Feb 2007 19:07:38 -0300, John Nagle <[EMAIL PROTECTED]> escribió: > Is there some way to get a strong ref to the original object back > from a weakref proxy object? I can't find any Python function to do > this. > ".ref()" doesn't work on proxy objects. Add a method to the ori

Re: modifying a list while iterating through

2007-02-25 Thread attn . steven . kuo
On Feb 25, 5:12 pm, [EMAIL PROTECTED] wrote: > consider the following working loop where Packet is a subclass of > list, with Packet.insert(index, iterable) inserting each item in > iterable into Packet at consecutive indexes starting at index. > > i=0 > while(i if packet[i:i+5]==Pa

Re: modifying a list while iterating through

2007-02-25 Thread George Sakkis
On Feb 25, 8:12 pm, [EMAIL PROTECTED] wrote: > consider the following working loop where Packet is a subclass of > list, with Packet.insert(index, iterable) inserting each item in > iterable into Packet at consecutive indexes starting at index. > > i=0 > while(i if packet[i:i+5]==Pa

Re: getting terminal display size?

2007-02-25 Thread Grant Edwards
On 2007-02-26, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-02-26, jeff <[EMAIL PROTECTED]> wrote: > >> I looked around a lot on the internet and couldn't find out how to do >> this, how do I get the sizer (in rows and columns) of the view? > > You use the TIOCGWINSZ ioctl() call on the tty d

Re: getting terminal display size?

2007-02-25 Thread Grant Edwards
On 2007-02-26, jeff <[EMAIL PROTECTED]> wrote: > I looked around a lot on the internet and couldn't find out how to do > this, how do I get the sizer (in rows and columns) of the view? You use the TIOCGWINSZ ioctl() call on the tty device in question. import termios, fcntl, struct, sys s =

Re: getting terminal display size?

2007-02-25 Thread Jean-Paul Calderone
On 25 Feb 2007 16:53:17 -0800, jeff <[EMAIL PROTECTED]> wrote: >I looked around a lot on the internet and couldn't find out how to do >this, how do I get the sizer (in rows and columns) of the view? > Assuming you're talking about something vaguely *NIXy, you want something like what's being done

Re: convert strings to utf-8

2007-02-25 Thread John Nagle
Diez B. Roggisch wrote: > Niclas schrieb: > >> Thank you! >> >> solved it with this: >> unicode( data.decode('latin_1') ) > > > The unicode around this is superfluous. Worse, it's an error. utf-8 needs to go into a stream of 8-bit bytes, not a Unicode string.

Re: Nested Parameter Definitions

2007-02-25 Thread Gabriel Genellina
En Sun, 25 Feb 2007 15:00:31 -0300, Paddy <[EMAIL PROTECTED]> escribió: def x ((p0, p1), p2): > ... return p0,p1,p2 The first time I saw it used was in Zope, a long time ago. And I like it. Of course it only has any sense if you expect the tuple (p0,p1) to exist *before* the functi

Re: finding out the precision of floats

2007-02-25 Thread Robert Kern
Dennis Lee Bieber wrote: > On 25 Feb 2007 05:31:11 -0800, "John Machin" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> Evidently not; here's some documentation we both need(ed) to read: >> >> http://docs.python.org/tut/node16.html >> """ >> Almost all machines today (Novem

modifying a list while iterating through

2007-02-25 Thread dustin . getz
consider the following working loop where Packet is a subclass of list, with Packet.insert(index, iterable) inserting each item in iterable into Packet at consecutive indexes starting at index. i=0 while(ihttp://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2007-02-25 Thread Steven D'Aprano
On Sun, 25 Feb 2007 16:57:25 -0800, jeff wrote: print {}.update.__doc__ That's a long way to spell "help({}.update)" :-) -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2007-02-25 Thread Steven D'Aprano
On Sun, 25 Feb 2007 18:49:56 -0600, S.Mohideen wrote: asd={} asd={1:2,3:4,4:5} You don't need to initialise asd to an empty dict. print asd > {1: 2, 3: 4, 4: 5} > asd.has_key(3) > True asd.update() print asd > {1: 2, 3: 4, 4: 5} You're not updating it with anythi

Re: newbie question

2007-02-25 Thread jeff
On Feb 25, 7:49 pm, "S.Mohideen" <[EMAIL PROTECTED]> wrote: >... > > what does asd.update() signifies. What is the use of it. Any comments would > help to understand it. > > Thanks > Mohideen >>> print {}.update.__doc__ D.update(E, **F) -> None. Update D from E and F: for k in E: D[k] = E[k] (if

getting terminal display size?

2007-02-25 Thread jeff
I looked around a lot on the internet and couldn't find out how to do this, how do I get the sizer (in rows and columns) of the view? -- http://mail.python.org/mailman/listinfo/python-list

newbie question

2007-02-25 Thread S.Mohideen
>>> asd={} >>> asd={1:2,3:4,4:5} >>> print asd {1: 2, 3: 4, 4: 5} >>> asd.has_key(3) True >>> asd.update() >>> print asd {1: 2, 3: 4, 4: 5} >>> what does asd.update() signifies. What is the use of it. Any comments would help to understand it. Thanks Mohideen -- http://mail.python.org/mailman

Re: Nested Parameter Definitions

2007-02-25 Thread Steven D'Aprano
On Sun, 25 Feb 2007 11:06:03 -0800, Virgil Dupras wrote: > On Feb 25, 1:00 pm, "Paddy" <[EMAIL PROTECTED]> wrote: >> I blogged on finding a new-to-me feature of Python, in that you are >> allowed to nnest parameter definitions: >> >> >>> def x ((p0, p1), p2): >> >> ... return p0,p1,p2 [snip]

Re: Nested Parameter Definitions

2007-02-25 Thread Steven D'Aprano
On Sun, 25 Feb 2007 10:00:31 -0800, Paddy wrote: > I wondered if those of you with some Python experience new of nested > parameters and don't use them; or just forgot/don't know it is > possible? I learnt about this some time ago. I don't often use it, although it makes sense to write this: def

Re: Referencing Items in a List of Tuples

2007-02-25 Thread rshepard
On 2007-02-25, Jussi Salmela <[EMAIL PROTECTED]> wrote: > I'm nitpicking, but the OP has a list of tuples: > ec = [ item[2:] for item in mainlist if item[:2] == ('eco','con') ] Jussi, An excellent nit to pick. Thank you, Rich -- http://mail.python.org/mailman/listinfo/python-list

Re: Referencing Items in a List of Tuples

2007-02-25 Thread rshepard
On 2007-02-25, Paddy <[EMAIL PROTECTED]> wrote: > You might also use list comprehensions to accumulate the values you > need: > > ec = [ item[2:] for item in mainlist if item[:2] == ['eco','con'] ] Thank you, Paddy. That's the syntax I couldn't work out myself. Rich -- http://mail.python.or

Working with C object of python object (pycairo,ctypes)

2007-02-25 Thread AngelBlaZe
Can you access the c object of a python object directly? Can this be done in ctypes or directly throught python functions without reverting to forking the python module? scanario: I have pyctx object that i get in python like this: pyctx = cairo.Context(surface) defined in the python extension t

Re: Rational numbers

2007-02-25 Thread Fernando Perez
[EMAIL PROTECTED] wrote: > gmpy itself is or should be pretty trivial to build on any platform > (and I'll always happily accept any fixes that make it better on any > specific platform, since it's easy to make them conditional so they'll > apply to that platform only), but the underlying GMP is

RE: BeautifulSoup modified to use weak refs and avoid circular links.

2007-02-25 Thread Delaney, Timothy (Tim)
John Nagle wrote: > "weakref.proxy()" probably should work that way. > Weakref proxies are supposed to be transparent, but they're not > quite transparent enough. Submit a patch to SourceForge. Please don't use tabs in email/usenet postings - use 4-space indents. "return" is not a function, a

Re: Help on object scope?

2007-02-25 Thread Diez B. Roggisch
> > Thank you for the advice, but that seems a bit unwieldy. My code will > have about 10 of these global objects, all of which interact with > eachother. It seems silly to have to pass 10 parameters around to each > instance I work with. I hope there is a smarter way to do it, or > perhaps someon

Re: Help on object scope?

2007-02-25 Thread Ben Finney
[EMAIL PROTECTED] writes: > My code will have about 10 of these global objects, all of which > interact with eachother. It seems silly to have to pass 10 > parameters around to each instance I work with. Yes. A better solution would be to put them inside a module, and import that module. Then the

Re: convert strings to utf-8

2007-02-25 Thread Diez B. Roggisch
Niclas schrieb: > Thank you! > > solved it with this: > unicode( data.decode('latin_1') ) The unicode around this is superfluous. Either do unicode(bytestring, encoding) or bytestring.decode(encoding) > and when I write it to the file... > f = codecs.open(path, encoding='utf-8', mod

Weakref problem: no way to get original object from proxy object?

2007-02-25 Thread John Nagle
Is there some way to get a strong ref to the original object back from a weakref proxy object? I can't find any Python function to do this. ".ref()" doesn't work on proxy objects. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Help on object scope?

2007-02-25 Thread bmaron2
On Feb 25, 9:37 am, hg <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hello everybody, > > > I have a (hopefully) simple question about scoping in python. I have a > > program written as a package, with two files of interest. The two > > files are /p.py and /lib/q.py > > > My file p.py l

Re: convert strings to utf-8

2007-02-25 Thread Niclas
Thank you! solved it with this: unicode( data.decode('latin_1') ) and when I write it to the file... f = codecs.open(path, encoding='utf-8', mode='w+') f.write(self.__rssDoc.toxml()) Diez B. Roggisch skrev: > Niclas schrieb: >> Hi >> >> I'm having trouble to work with the spec

ANN: pynakotheka v1.1.0

2007-02-25 Thread Iñigo Serna
Hi there, I'm pleased to announce a new release of Pynakotheka. Pynakotheka is a simple GPL-licensed python script which generates static HTML photo albums to be added to web sites or to be burnt into CDs. It includes some templates and it's easy to create more. It depends on python, Mako Templa

Re: Help on object scope?

2007-02-25 Thread hg
[EMAIL PROTECTED] wrote: > Hello everybody, > > I have a (hopefully) simple question about scoping in python. I have a > program written as a package, with two files of interest. The two > files are /p.py and /lib/q.py > > My file p.py looks like this: > > --- > > from lib import q > > def ma

Help on object scope?

2007-02-25 Thread bmaron2
Hello everybody, I have a (hopefully) simple question about scoping in python. I have a program written as a package, with two files of interest. The two files are /p.py and /lib/q.py My file p.py looks like this: --- from lib import q def main(): global r r = q.object1() s = q.object2()

Re: How to build Hierarchies of dict's? (Prototypes in Python?)

2007-02-25 Thread Toby
Charles D Hixson wrote: > I want to access the values via instances of the class, so your D().a > approach isn't suitable. More like: "t = D(); t[a]" Well, D() is an instance of D, so D().a is the same as t = D(); t.a In fact the various "a" attributes I'm accessing are class attributes of th

Re: Nested Parameter Definitions

2007-02-25 Thread Paddy
On Feb 25, 7:06 pm, "Virgil Dupras" <[EMAIL PROTECTED]> wrote: > On Feb 25, 1:00 pm, "Paddy" <[EMAIL PROTECTED]> wrote: > > > > > I blogged on finding a new-to-me feature of Python, in that you are > > allowed to nnest parameter definitions: > > > >>> def x ((p0, p1), p2): > > > ... return p0,p

BeautifulSoup modified to use weak refs and avoid circular links.

2007-02-25 Thread John Nagle
John Nagle wrote: > Are weak refs slower than strong refs? I've been considering making the > "parent" links in BeautifulSoup into weak refs, so the trees will release > immediately when they're no longer needed. In general, all links back > towards the root of a tree should be weak refs; this

Re: Referencing Items in a List of Tuples

2007-02-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > While working with lists of tuples is probably very common, none of my > five Python books or a Google search tell me how to refer to specific items > in each tuple. t = "a", "b", "c" assert t[0] == "a" assert t[1] == "b" assert t[2] == "c" > I find references to

Re: Help on Dict

2007-02-25 Thread Daniel Nogradi
> Can any body tell how Dict is implemented in python... plz tell what > datastructure that uses Please see http://svn.python.org/view/python/trunk/Objects/dictnotes.txt?rev=53782&view=markup for general notes and http://svn.python.org/view/python/trunk/Objects/dictobject.c?rev=

Re: Question about idiomatic use of _ and private stuff.

2007-02-25 Thread Bruno Desthuilliers
Troy Melhase a écrit : >> Why do people sometimes use one leading underscore? > > > Many folks like to use the single leading underscore to emphasize that > the attribute isn't part of the normal way to use the class or > instance. > > It's bad style in my opinion, but I'm probably in the minori

Re: Referencing Items in a List of Tuples

2007-02-25 Thread Paddy
On Feb 25, 5:44 pm, Jussi Salmela <[EMAIL PROTECTED]> wrote: > Paddy kirjoitti: > > > > > On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote: > >> While working with lists of tuples is probably very common, none of my > >> five Python books or a Google search tell me how to refer to specific items > >>

Re: Question about idiomatic use of _ and private stuff.

2007-02-25 Thread Bruno Desthuilliers
Steven W. Orr a écrit : > I understand that two leading underscores in a class attribute make the > attribute private. Nope. It doesn't make it "private", it mangles the attribute name with the class name (ie : Bar.__mangled will become Bar._Bar__mangled everywhere except inside Bar). This is

Re: Nested Parameter Definitions

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 6:00 pm, "Paddy" <[EMAIL PROTECTED]> wrote: > I blogged on finding a new-to-me feature of Python, in that you are > allowed to nnest parameter definitions: > > >>> def x ((p0, p1), p2): > > ... return p0,p1,p2 > ...>>> x(('Does', 'this'), 'work') > > ('Does', 'this', 'work') Reminds

Re: Help on Dict

2007-02-25 Thread James Stroud
Clement wrote: > Can any body tell how Dict is implemented in python... plz tell what > datastructure that uses > I think it uses a dict. James -- http://mail.python.org/mailman/listinfo/python-list

Re: Who has not attended these free tutorial courses ?

2007-02-25 Thread *
Is it true that all the above-listed "tutorials" offer undergraduate credit at Islam University? -- http://mail.python.org/mailman/listinfo/python-list

Re: finding out the precision of floats

2007-02-25 Thread Robert Kern
John Machin wrote: > Evidently not; here's some documentation we both need(ed) to read: > > http://docs.python.org/tut/node16.html > """ > Almost all machines today (November 2000) use IEEE-754 floating point > arithmetic, and almost all platforms map Python floats to IEEE-754 > "double precision

Re: Rational numbers

2007-02-25 Thread aleaxit
On Feb 24, 12:25 am, Toby A Inkster <[EMAIL PROTECTED]> wrote: > aleaxit wrote: > > If anybody who has easy access to Microsoft's MSVC++.NET (and is willing > > to try building GMP 4.2 with/for it), or a PPC Mac with XCode installed > > (possibly with MacOSX 10.3...) > > I'm writing this message on

Re: Nested Parameter Definitions

2007-02-25 Thread Virgil Dupras
On Feb 25, 1:00 pm, "Paddy" <[EMAIL PROTECTED]> wrote: > I blogged on finding a new-to-me feature of Python, in that you are > allowed to nnest parameter definitions: > > >>> def x ((p0, p1), p2): > > ... return p0,p1,p2 > ...>>> x(('Does', 'this'), 'work') > > ('Does', 'this', 'work') > > > >

Re: How to build Hierarchies of dict's? (Prototypes in Python?)

2007-02-25 Thread Charles D Hixson
Toby wrote: > Charles D Hixson wrote: > >> a class whose sub-classes automatically have unique class variables of >> a determined form such that I can do a hierarchical search through them >> > > Something like this? > (scroll down to see the results) > > > # --- begin --- > > class AttrS

Re: RegExp performance?

2007-02-25 Thread Christian Sonne
John Machin wrote: > On Feb 25, 7:21 pm, Christian Sonne <[EMAIL PROTECTED]> wrote: >> Long story short, I'm trying to find all ISBN-10 numbers in a multiline >> string (approximately 10 pages of a normal book), and as far as I can >> tell, the *correct* thing to match would be this: >> ".*\D*(\d{1

Re: convert strings to utf-8

2007-02-25 Thread Martin v. Löwis
Niclas schrieb: > I'm having trouble to work with the special charcters in swedish (Å Ä Ö > å ä ö). The script is parsing and extracting information from a webpage. > This works fine and I get all the data correctly. The information is > then added to a rss file (using xml.dom.minidom.Document() to

Re: Referencing Items in a List of Tuples

2007-02-25 Thread rshepard
On 2007-02-25, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > Item is ALREADY the "current" tuple... > > for tpl in mainlist: > if tpl[0] == "eco" and tpl[1] == "con": > ec.Append(tpl[2:]) #presuming ec is NOT a list, as Append() >

Nested Parameter Definitions

2007-02-25 Thread Paddy
I blogged on finding a new-to-me feature of Python, in that you are allowed to nnest parameter definitions: >>> def x ((p0, p1), p2): ... return p0,p1,p2 ... >>> x(('Does', 'this'), 'work') ('Does', 'this', 'work') >>> Ruben commented that there was a poll on this features continued existence

Help on Dict

2007-02-25 Thread Clement
Can any body tell how Dict is implemented in python... plz tell what datastructure that uses -- http://mail.python.org/mailman/listinfo/python-list

Re: Referencing Items in a List of Tuples

2007-02-25 Thread Jussi Salmela
Paddy kirjoitti: > On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote: >> While working with lists of tuples is probably very common, none of my >> five Python books or a Google search tell me how to refer to specific items >> in each tuple. I find references to sorting a list of tuples, but not >> extr

Re: Find the first element that meets the condition

2007-02-25 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I have a list and I want to find the first element that meets a > condition. I do not want to use 'filter', because I want to come out > of the iteration as soon as the first element is found. > I have implemented it this way, may be, there should b

Re: Referencing Items in a List of Tuples

2007-02-25 Thread Paddy
On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote: > While working with lists of tuples is probably very common, none of my > five Python books or a Google search tell me how to refer to specific items > in each tuple. I find references to sorting a list of tuples, but not > extracting tuples based on

Re: Are weak refs slower than strong refs?

2007-02-25 Thread Duncan Booth
John Nagle <[EMAIL PROTECTED]> wrote: > Are weak refs slower than strong refs? I've been considering > making the "parent" links in BeautifulSoup into weak refs, so the > trees will release immediately when they're no longer needed. In > general, all links back towards the root of a tree should

Re: timeout in urllib.open()

2007-02-25 Thread John J. Lee
[EMAIL PROTECTED] writes: > >> I believe this can only be set globally: > >> > >> import socket > >> socket.setdefaulttimeout(seconds) > > Stefan> Uuuh this is no solution for me, because the website-checking > Stefan> tool is part of a very very big application running i

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 3:59 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On 25 Feb 2007 06:11:02 -0800, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > > > Moreover the reason I got interested in this is because I am creating > > a Dec class (decimal numbers) > > Are you familiar with Python's Decimal > librar

Re: Are weak refs slower than strong refs?

2007-02-25 Thread shredwheat
On Feb 24, 10:17 pm, John Nagle <[EMAIL PROTECTED]> wrote: >Are weak refs slower than strong refs? I've been considering making the > "parent" links in BeautifulSoup into weak refs, so the trees will release > immediately when they're no longer needed. In general, all links back > towards the

Re: finding out the precision of floats

2007-02-25 Thread Jerry Hill
On 25 Feb 2007 06:11:02 -0800, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Moreover the reason I got interested in this is because I am creating > a Dec class (decimal numbers) Are you familiar with Python's Decimal library? http://docs.python.org/lib/module-decimal.html -- Jerry -- http://ma

Re: convert strings to utf-8

2007-02-25 Thread Diez B. Roggisch
Niclas schrieb: > Hi > > I'm having trouble to work with the special charcters in swedish (Å Ä Ö > å ä ö). The script is parsing and extracting information from a webpage. > This works fine and I get all the data correctly. The information is > then added to a rss file (using xml.dom.minidom.Do

Re: Endianness conversion

2007-02-25 Thread Dan Sommers
On Sat, 24 Feb 2007 17:27:12 +, Toby wrote: > Dan Sommers wrote: >> You could try the struct module. If your input comes in fixed sized >> chunks, just call struct.unpack and struct.pack once per chunk. > > Thanks, but it was a bit awkward to use for big chunks. def swapper( bytestring ):

convert strings to utf-8

2007-02-25 Thread Niclas
Hi I'm having trouble to work with the special charcters in swedish (Å Ä Ö å ä ö). The script is parsing and extracting information from a webpage. This works fine and I get all the data correctly. The information is then added to a rss file (using xml.dom.minidom.Document() to create the file

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 1:31 pm, "John Machin" <[EMAIL PROTECTED]> wrote: > On Feb 25, 11:06 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> > wrote: [...] > Evidently not; here's some documentation we both need(ed) to read: > > http://docs.python.org/tut/node16.html Thanks for this link > I'm very curious to know

Re: finding out the precision of floats

2007-02-25 Thread John Machin
On Feb 25, 11:06 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > On Feb 25, 11:20 am, "John Machin" <[EMAIL PROTECTED]> wrote: > [...] > > > I'm a little puzzled: > > > You don't seem to want a function that will tell you the actual number > > of significant decimal digits in a particular numbe

Re: HTML Parsing

2007-02-25 Thread Stefan Behnel
John Machin wrote: > One can even use ElementTree, if the HTML is well-formed. See below. > However if it is as ill-formed as the sample (4th "td" element not > closed; I've omitted it below), then the OP would be better off > sticking with Beautiful Soup :-) Or (as we were talking about the best

Re: CSV(???)

2007-02-25 Thread skip
David> Is there a csvlib out there somewhere? ... David> ...Believe it or not I'm _still_ using python 1.5.7 You might see if someone has written a pure Python version of the csv module for use in PyPy. Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: How to build Hierarchies of dict's? (Prototypes in Python?)

2007-02-25 Thread Toby
Charles D Hixson wrote: > a class whose sub-classes automatically have unique class variables of > a determined form such that I can do a hierarchical search through them Something like this? (scroll down to see the results) # --- begin --- class AttrSearch(object): @classmethod def getcl

Re: Python 3.0 unfit for serious work?

2007-02-25 Thread skip
Jeff> My post was entitled "Python 3.0 unfit for serious work", you just Jeff> indicated that the Linux distros will agree with me, in order to Jeff> be taken seriously, the distros will have to include 2.x python Jeff> for a very long time. If 3.0 and 2.x have any serious degree

Re: finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
On Feb 25, 11:20 am, "John Machin" <[EMAIL PROTECTED]> wrote: [...] > I'm a little puzzled: > > You don't seem to want a function that will tell you the actual number > of significant decimal digits in a particular number e.g. > > nsig(12300.0) -> 3 > nsig(0.00123400) -> 4 > etc > > You appear to b

Re: timeout in urllib.open()

2007-02-25 Thread skip
>> I believe this can only be set globally: >> >> import socket >> socket.setdefaulttimeout(seconds) Stefan> Uuuh this is no solution for me, because the website-checking Stefan> tool is part of a very very big application running in an Stefan> application server, so g

Re: finding out the precision of floats

2007-02-25 Thread John Machin
On Feb 25, 9:57 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > Hi all, > > I want to know the precision (number of significant digits) of a float > in a platform-independent manner. I have scoured through the docs but > I can't find anything about it! > > At the moment I use this terrible sub

Re: Is there any way to automatically create a transcript of an interactive Python session?

2007-02-25 Thread skip
Jonathan> Some languages, such as Scheme, permit you to make a Jonathan> transcript of an interactive console session. Is there a way Jonathan> to do that in Python? If you decide not to use IPython for some reason, you should be able to easily whip something up based on the command h

finding out the precision of floats

2007-02-25 Thread Arnaud Delobelle
Hi all, I want to know the precision (number of significant digits) of a float in a platform-independent manner. I have scoured through the docs but I can't find anything about it! At the moment I use this terrible substitute: FLOAT_PREC = repr(1.0/3).count('3') How can I do this properly or w

Re: RegExp performance?

2007-02-25 Thread John Machin
On Feb 25, 7:21 pm, Christian Sonne <[EMAIL PROTECTED]> wrote: > Long story short, I'm trying to find all ISBN-10 numbers in a multiline > string (approximately 10 pages of a normal book), and as far as I can > tell, the *correct* thing to match would be this: > ".*\D*(\d{10}|\d{9}X)\D*.*" All of

Re: Find the first element that meets the condition

2007-02-25 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I have a list and I want to find the first element that meets a > condition. I do not want to use 'filter', because I want to come out > of the iteration as soon as the first element is found. > I have implemented it this way, may be, there should be a built in > hiding

Re: Find the first element that meets the condition

2007-02-25 Thread Troy Melhase
> I have implemented it this way, may be, there should be a built in > hiding somewhere in the standard libraries? the itertools module might have what you're after. something similar to your example: >>> import itertools >>> r = iter(range(100)) >>> n = itertools.dropwhile(lambda x:x<=13, r) >>

Find the first element that meets the condition

2007-02-25 Thread [EMAIL PROTECTED]
Hi, I have a list and I want to find the first element that meets a condition. I do not want to use 'filter', because I want to come out of the iteration as soon as the first element is found. I have implemented it this way, may be, there should be a built in hiding somewhere in the standard librar

Re: RegExp performance?

2007-02-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Christian Sonne wrote: > Long story short, I'm trying to find all ISBN-10 numbers in a multiline > string (approximately 10 pages of a normal book), and as far as I can > tell, the *correct* thing to match would be this: > ".*\D*(\d{10}|\d{9}X)\D*.*" > > (it should be no

Re: select which lib for iNet?

2007-02-25 Thread Gabriel Genellina
En Sun, 25 Feb 2007 06:12:32 -0300, Marco <[EMAIL PROTECTED]> escribió: > I wanta know why (Py)Qt has its own lib on socket/ sql/ openGL,etc ? > Is the lib better than standard lib? See http://www.commandprompt.com/community/pyqt/x3738 In short, because Qt already had them, and some callbacks or

Re: RegExp performance?

2007-02-25 Thread Gabriel Genellina
En Sun, 25 Feb 2007 05:21:49 -0300, Christian Sonne <[EMAIL PROTECTED]> escribió: > Long story short, I'm trying to find all ISBN-10 numbers in a multiline > string (approximately 10 pages of a normal book), and as far as I can > tell, the *correct* thing to match would be this: > ".*\D*(\d{10}|

Re: select which lib for iNet?

2007-02-25 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Marco wrote: > I wanta know why (Py)Qt has its own lib on socket/ sql/ openGL,etc ? That's simply because Qt has these libraries. If you are programming in C++ this has the advantage that the application is platform independent if you write against the Qt APIs. As Python

select which lib for iNet?

2007-02-25 Thread Marco
Hello everyone, I wanta know why (Py)Qt has its own lib on socket/ sql/ openGL,etc ? Is the lib better than standard lib? Thank you! -- LinuX Power -- http://mail.python.org/mailman/listinfo/python-list

RegExp performance?

2007-02-25 Thread Christian Sonne
Long story short, I'm trying to find all ISBN-10 numbers in a multiline string (approximately 10 pages of a normal book), and as far as I can tell, the *correct* thing to match would be this: ".*\D*(\d{10}|\d{9}X)\D*.*" (it should be noted that I've removed all '-'s in the string, because they

*** ISRAELI TERRORISTS BLEW UP INDIAN TRAIN ***

2007-02-25 Thread thermate2
Eye opener research http://www.apfn.org/apfn/WTC_STF.htm -- http://mail.python.org/mailman/listinfo/python-list