Re: print problem

2008-06-16 Thread Gabriel Genellina
En Tue, 17 Jun 2008 03:15:11 -0300, pirata <[EMAIL PROTECTED]> escribió: > I was trying to print a dot on console every second to indicates > running process, so I wrote, for example: > > for i in xrange(10): > print ".", > time.sleep(1) > > Idealy, a dot will be printed out each second. B

Re: How to catch StopIteration?

2008-06-16 Thread Chris
On Jun 17, 8:43 am, Chris <[EMAIL PROTECTED]> wrote: > On Jun 17, 5:50 am, [EMAIL PROTECTED] wrote: > > > > > I'm writing to see calcuration process. > > And so, I can't catch StopIteration... > > > What is mistake? > > > def collatz(n): > >   r=[] > >   while n>1: > >     r.append(n) > >     n = 3

Re: How to catch StopIteration?

2008-06-16 Thread Chris
On Jun 17, 5:50 am, [EMAIL PROTECTED] wrote: > I'm writing to see calcuration process. > And so, I can't catch StopIteration... > > What is mistake? > > def collatz(n): >   r=[] >   while n>1: >     r.append(n) >     n = 3*n+1 if n%2 else n/2 >     yield r > > for i, x in enumerate(collatz(13)): >

Re: Buffer size when receiving data through a socket?

2008-06-16 Thread Gabriel Genellina
En Mon, 16 Jun 2008 21:21:35 -0300, John Salerno <[EMAIL PROTECTED]> escribió: > I wrote some pretty basic socket programming again, but I'm still confused > about what's happening with the buffer_size variable. Here are the server and > client programs: > > -- > > from socket import

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Paul McGuire
On Jun 17, 12:28 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > My guess is that the two main memory allocate/deallocate cases are 1) > > appending a new item to the end, and 2) GC'ing the entire data > > structure.  I would optimize these 2 at the expense of all others. > > Does that include

print problem

2008-06-16 Thread pirata
I was trying to print a dot on console every second to indicates running process, so I wrote, for example: for i in xrange(10): print ".", time.sleep(1) Idealy, a dot will be printed out each second. But there is nothing print out until after 10 seconds, all 10 dots come out together. I

Re: How to catch StopIteration?

2008-06-16 Thread Lie
On Jun 17, 12:36 pm, Lie <[EMAIL PROTECTED]> wrote: > On Jun 17, 10:50 am, [EMAIL PROTECTED] wrote: > > > > > I'm writing to see calcuration process. > > And so, I can't catch StopIteration... > > > What is mistake? > (snip) > > In a for-loop, StopIteration is caught by the for-loop for your > conv

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Gabriel Genellina
En Mon, 16 Jun 2008 07:34:06 -0300, Bart Kastermans <[EMAIL PROTECTED]> escribió: > Summary: can't verify big O claim, how to properly time this? > > This is interesting. I had never attempted to verify a big O > statement > before, and decided that it would be worth trying. So I wrote some > c

Pattern Matching Over Python Lists

2008-06-16 Thread Chris
Is anyone aware of any prior work done with searching or matching a pattern over nested Python lists? I have this problem where I have a list like: [1, 2, [1, 2, [1, 7], 9, 9], 10] and I'd like to search for the pattern [1, 2, ANY] so that is returns: [1, 2, [1, 2, [6, 7], 9, 9], 10] [1, 2, [6,

Re: 2Q's: How to autocreate instance of class;How to check for membership in a class

2008-06-16 Thread George Sakkis
On Jun 16, 9:16 pm, asdf <[EMAIL PROTECTED]> wrote: > So I'm writing a script which will create several instances of User() > class. I want each instance to be named after the login name > of a user. I don't know beforehand how many users the script will > have to create or how they are named. Rig

Re: How to catch StopIteration?

2008-06-16 Thread Lie
On Jun 17, 10:50 am, [EMAIL PROTECTED] wrote: > I'm writing to see calcuration process. > And so, I can't catch StopIteration... > > What is mistake? > > def collatz(n): >   r=[] >   while n>1: >     r.append(n) >     n = 3*n+1 if n%2 else n/2 >     yield r > > for i, x in enumerate(collatz(13)): >

Re: Python GC does not work as it should be

2008-06-16 Thread Martin v. Löwis
> Yes I did my job, i had mention it before. but an application would not > consist mine only, it could be incorporate your c extension module(s), and > others, means problem could be from my side, yours, or others. Though > forcing to reset the state would not mean fixing the real problem, but

Re: string.Template.delimiter cannot be overriden?

2008-06-16 Thread kretik
Raymond Hettinger wrote: On Jun 16, 9:53 pm, kretik <[EMAIL PROTECTED]> wrote: I've been trying to coax this class to use something other than the default '$' but it seems setting it to something else has no discernible effect. Is it necessary to inherit from the class to do this? Yes, subclas

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Martin v. Löwis
> My guess is that the two main memory allocate/deallocate cases are 1) > appending a new item to the end, and 2) GC'ing the entire data > structure. I would optimize these 2 at the expense of all others. Does that include dictionary lookups? Regards, Martin -- http://mail.python.org/mailman/lis

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Martin v. Löwis
>> For this API, I think it's important to make some performance guarantees. > > I may appreciate them for all Python collections :-) See http://wiki.python.org/moin/TimeComplexity >> It seems fairly difficult to make byindex O(1), and >> simultaneously also make insertion/deletion better than

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread Lie
On Jun 17, 11:07 am, "Leo Jay" <[EMAIL PROTECTED]> wrote: > On Tue, Jun 17, 2008 at 11:29 AM, pirata <[EMAIL PROTECTED]> wrote: > > I'm a bit confusing about whether "is not" equivelent to "!=" > > > if a != b: > >  ... > > > if a is not b: > >  ... > > > What's the difference between "is not" and

Re: string.Template.delimiter cannot be overriden?

2008-06-16 Thread Raymond Hettinger
On Jun 16, 9:53 pm, kretik <[EMAIL PROTECTED]> wrote: > I've been trying to coax this class to use something other than the > default '$' but it seems setting it to something else has no discernible > effect. Is it necessary to inherit from the class to do this? Yes, subclassing is the intended wa

string.Template.delimiter cannot be overriden?

2008-06-16 Thread kretik
I've been trying to coax this class to use something other than the default '$' but it seems setting it to something else has no discernible effect. Is it necessary to inherit from the class to do this? I've only been using Python for a couple of weeks so I'm not sure what the best approach is

read the message

2008-06-16 Thread msvelu
Please sent your country nature picture in need it. plz ya -- http://mail.python.org/mailman/listinfo/python-list

Re: NoneType Error

2008-06-16 Thread Gabriel Genellina
En Mon, 16 Jun 2008 06:29:09 -0300, Bruno Desthuilliers <[EMAIL PROTECTED]> escribió: > Gabriel Genellina a écrit : > >> It appears that you want to catch all exceptions, just use Exception for >> that: >> try: >>... >> except Exception: >>... > > Hem... That's definitively *not* an a go

Re: Python GC does not work as it should be

2008-06-16 Thread Jaimy Azle
Jean-Paul Calderone wrote: > > There's plenty of things other than that one static variable that can get > messed up in this scenario. The access violation could easily come along > with random memory corruption. Fixing just the GC to handle this doesn't > mean your program will be able to keep

DIGITAL TV

2008-06-16 Thread PREETHI
DIGITAL TVhttp://digitaltvtech.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread Leo Jay
On Tue, Jun 17, 2008 at 11:29 AM, pirata <[EMAIL PROTECTED]> wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: > ... > > if a is not b: > ... > > > What's the difference between "is not" and "!=" or they are the same thing? The 'is' is used to test do they poi

Re: How to catch StopIteration?

2008-06-16 Thread John Salerno
[EMAIL PROTECTED] wrote: for i, x in enumerate(collatz(13)): try: last = x[:i+1] print x[:i+1] except StopIteration: print last.appnd(1) My guess would be because StopIteration is raised when control returns to the for loop and sees that it has nothing else left. At that point

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread John Salerno
John Salerno wrote: == and != test to see if the *value* of two variables are the same. Let me just clarify this. It might seem like a picky point, but I think it's pretty important when learning Python. I don't really mean the value of the variables themselves, I mean the values that the

How to catch StopIteration?

2008-06-16 Thread ccy56781
I'm writing to see calcuration process. And so, I can't catch StopIteration... What is mistake? def collatz(n): r=[] while n>1: r.append(n) n = 3*n+1 if n%2 else n/2 yield r for i, x in enumerate(collatz(13)): try: last = x[:i+1] print x[:i+1] except StopIteration:

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread Dan Bishop
On Jun 16, 10:29 pm, pirata <[EMAIL PROTECTED]> wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: >   ... > > if a is not b: >   ... > > What's the difference between "is not" and "!=" or they are the same thing? "is not" is the logical negation of the "is" oper

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread Erik Max Francis
pirata wrote: I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? The `==` operator tests equality. The `is` operator tests identity. If you don't specifically inte

Re: Does '!=' equivelent to 'is not'

2008-06-16 Thread John Salerno
pirata wrote: I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? No, they are not the same thing. == and != test to see if the *value* of two variables are the same.

Re: Simple and safe evaluator

2008-06-16 Thread bvdp
[EMAIL PROTECTED] wrote: On Jun 17, 8:02 am, bvdp <[EMAIL PROTECTED]> wrote: Thanks. That was easy :) The change to the _ast version is left as an exercise to the reader ;) And I have absolutely no idea on how to do this. I can't even find the _ast import file on my system. I'm assuming that

Does '!=' equivelent to 'is not'

2008-06-16 Thread pirata
I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Paul McGuire
On Jun 16, 5:24 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > >     ``odict.byindex(index)`` > > >         Index-based lookup is supported by ``byindex()`` which returns > >         the key/value pair for an index, that is, the "position" of a > >         key in the ordered dict.  0 is the fir

Re: Iterate creating variables?

2008-06-16 Thread Mark Tolonen
"Hyuga" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Jun 13, 11:34 am, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: Friday, June 13, 2008 11:11 AM

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Maric Michaud
Le Tuesday 17 June 2008 05:10:57 Maric Michaud, vous avez écrit : > The class complextiy problem is actually solved by : > > inst_with_alg1 = MyClassUsingStrategies((algo1_strategy,), > (algo1_strategy,)) inst_with_alg1_alg2 = MyClassUsingStrategies( >                                              

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Maric Michaud
Le Monday 16 June 2008 20:35:22 George Sakkis, vous avez écrit : > On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > > George Sakkis wrote: > > > I have a situation where one class can be customized with several > > > orthogonal options. Currently this is implemented with (multiple)

Re: Context manager for files vs garbage collection

2008-06-16 Thread Benjamin
On Jun 16, 8:24 am, Bruno Desthuilliers wrote: > > IIRC (please someone correct me if I'm wrong), proper release of file > resources as soon as the file object gets out of scope is not garanteed > in the language spec and is implementation dependant. Right. Resources are freed in CPython right af

Re: Simple and safe evaluator

2008-06-16 Thread sweeneym
On Jun 17, 8:02 am, bvdp <[EMAIL PROTECTED]> wrote: > Thanks. That was easy :) > > > The change to the _ast version is left as an exercise to the reader ;) > > And I have absolutely no idea on how to do this. I can't even find the > _ast import file on my system. I'm assuming that the _ast definit

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread David
takayuki wrote: Paul, Thank you for the informative reply. Yes, I created the indent problem when manually copying the original script when I posted. (I'm using an old laptop to study python and posting here using the desktop.) Your examples really helped. Last night I played with using a fo

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread John Salerno
takayuki wrote: I'm early on in my python adventure so I'm not there yet on the strip command nuances.I'm reading "How to think like a python programmer" first. It's great. Then "Learning python". I've read parts of Dive into Python and will work through it fully when I'm a little farther

2Q's: How to autocreate instance of class;How to check for membership in a class

2008-06-16 Thread asdf
So I'm writing a script which will create several instances of User() class. I want each instance to be named after the login name of a user. I don't know beforehand how many users the script will have to create or how they are named. Right now I've created a dictionary of usernames as keys and obj

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread takayuki
On Jun 17, 6:34 am, Thomas Hill <[EMAIL PROTECTED]> wrote: > On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote: > > > def hasnolet(avoid): > > fin = open('animals.txt') > > for line in fin: > > word = line.strip() > > for letter in avoid: > >

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread takayuki
Paul, Thank you for the informative reply. Yes, I created the indent problem when manually copying the original script when I posted. (I'm using an old laptop to study python and posting here using the desktop.) Your examples really helped. Last night I played with using a for loop instead of

FYA: visualizing repository commits

2008-06-16 Thread wesley chun
have you guys seen this on Slashdot yet? (i did a quick search in the archives and haven't seen any posts yet so hopefully this isn't a duplicate msg!) http://developers.slashdot.org/developers/08/06/16/1855209.shtml this video is a visualization of the commits to the source base (and made by who

Buffer size when receiving data through a socket?

2008-06-16 Thread John Salerno
I wrote some pretty basic socket programming again, but I'm still confused about what's happening with the buffer_size variable. Here are the server and client programs: -- from socket import * host = '' port = 51567 address = (host, port) buffer_size = 1024 server_socket = socket

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Terry Reedy
Cédric Lucantis wrote: I don't see any string method to do that >>> 'abcde'.translate(str.maketrans('','','bcd')) 'ae' I do not claim this to be better than all the other methods, but this pair can also translate while deleting, which others cannot. -- http://mail.python.org/mailman/listin

UnicodeDecodeError: 'ascii' codec can't decode byte

2008-06-16 Thread Gilles Ganault
Hello It seems like I have Unicode data in a CSV file but Python is using a different code page, so isn't happy when I'm trying to read and put this data into an SQLite database with APSW: sql = "INSERT INTO mytable (col1,col2) VALUES (?,?)" cursor.executemany(sql, records("test.

Re: We are all consenting adults here

2008-06-16 Thread Aahz
In article <[EMAIL PROTECTED]>, David Hughes <[EMAIL PROTECTED]> wrote: > >Who coined this originally? AFAICT, none other than Guido. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "as long as we like the same operating system, things are cool." --piranha -- http

Re: Please explain Python "__whatever__" construct.

2008-06-16 Thread Matimus
When and why would I ever use > "__main__" or the many other "__whatever__" constructs? You don't generally use those names directly, they are 'magic'. The __add__ example is a good one. When you do `"hello " + "world"` behind the scenes python is actually calling "hello ".__add__("world"). There

Re: sqlite3 and Python 2.5.1

2008-06-16 Thread Robert Hancock
On Jun 16, 5:15 pm, Gerhard Häring <[EMAIL PROTECTED]> wrote: > milan_sanremo wrote: > > I have sqlite installed, but when I try to importsqlite3I receive: > > > Python 2.5.1 (r251:54863, Nov 3 2007, 02:54:36) [C] on sunos5 > > Type "help", "copyright", "credits" or "license" for more information.

Re: Please explain Python "__whatever__" construct.

2008-06-16 Thread s0suk3
On Jun 16, 4:56 pm, [EMAIL PROTECTED] wrote: > After a couple of weeks studying Python, I already have a few useful > scripts, including one that downloads 1500 Yahoo stock quotes in 6 > seconds. However, many things are puzzling to me. I keep on seeing > things like "__main__" in scripts. A more

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread bearophileHUGS
Martin v. L.: > For this API, I think it's important to make some performance guarantees. I may appreciate them for all Python collections :-) > It seems fairly difficult to make byindex O(1), and > simultaneously also make insertion/deletion better than O(n). It may be possible to make both of

Re: Please explain Python "__whatever__" construct.

2008-06-16 Thread Benjamin Kaplan
On Mon, Jun 16, 2008 at 5:56 PM, <[EMAIL PROTECTED]> wrote: > After a couple of weeks studying Python, I already have a few useful > scripts, including one that downloads 1500 Yahoo stock quotes in 6 > seconds. However, many things are puzzling to me. I keep on seeing > things like "__main__" in s

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread Martin v. Löwis
> ``odict.byindex(index)`` > > Index-based lookup is supported by ``byindex()`` which returns > the key/value pair for an index, that is, the "position" of a > key in the ordered dict. 0 is the first key/value pair, -1 > the last. > > >>> d.byindex(2)

Re: Please explain Python "__whatever__" construct.

2008-06-16 Thread Jason Scheirer
On Jun 16, 2:56 pm, [EMAIL PROTECTED] wrote: > After a couple of weeks studying Python, I already have a few useful > scripts, including one that downloads 1500 Yahoo stock quotes in 6 > seconds. However, many things are puzzling to me. I keep on seeing > things like "__main__" in scripts.  A more

Re: Simple and safe evaluator

2008-06-16 Thread bvdp
George Sakkis wrote: On Jun 16, 4:47 pm, bvdp <[EMAIL PROTECTED]> wrote: 2. I thought I'd be happy with * / + -, etc. Of course now I want to add a few more funcs like int() and sin(). How would I do that? For the builtin eval, just populate the globals dict with the names you want to make av

Please explain Python "__whatever__" construct.

2008-06-16 Thread bsagert
After a couple of weeks studying Python, I already have a few useful scripts, including one that downloads 1500 Yahoo stock quotes in 6 seconds. However, many things are puzzling to me. I keep on seeing things like "__main__" in scripts. A more obscure example would be "__add__" used in string con

Re: How to request data from a lazily-created tree structure ?

2008-06-16 Thread méchoui
On Jun 16, 11:16 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > méchoui schrieb: > > > > > Problem: > > > - You have tree structure (XML-like) that you don't want to create > > 100% in memory, because it just takes too long (for instance, you need > > a http request to request the information

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread Thomas Hill
On Jun 16, 2:34 pm, Thomas Hill <[EMAIL PROTECTED]> wrote: > On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote: > > > def hasnolet(avoid): > > fin = open('animals.txt') > > for line in fin: > > word = line.strip() > > for letter in avoid: > >

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread Thomas Hill
On Jun 15, 6:23 pm, takayuki <[EMAIL PROTECTED]> wrote: > def hasnolet(avoid): > fin = open('animals.txt') > for line in fin: > word = line.strip() > for letter in avoid: > if letter in word: > b

Re: sorted or .sort() ?

2008-06-16 Thread Nick Craig-Wood
Ben Finney <[EMAIL PROTECTED]> wrote: > Peter Bengtsson <[EMAIL PROTECTED]> writes: > > > My poor understanding is that the difference between `sorted(somelist, > > key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one > > returns a new list and the other sorts in-place. > > Yes. >

Re: Simple and safe evaluator

2008-06-16 Thread George Sakkis
On Jun 16, 4:47 pm, bvdp <[EMAIL PROTECTED]> wrote: > 2. I thought I'd be happy with * / + -, etc. Of course now I want to add > a few more funcs like int() and sin(). How would I do that? For the builtin eval, just populate the globals dict with the names you want to make available: import math

Re: How to request data from a lazily-created tree structure ?

2008-06-16 Thread Diez B. Roggisch
méchoui schrieb: Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from a slow distant site). - But you want to be able to request data from it, such has "gi

Re: sqlite3 and Python 2.5.1

2008-06-16 Thread Gerhard Häring
milan_sanremo wrote: > I have sqlite installed, but when I try to import sqlite3 I receive: > > Python 2.5.1 (r251:54863, Nov 3 2007, 02:54:36) [C] on sunos5 > Type "help", "copyright", "credits" or "license" for more information. import sqlite3 > Traceback (most recent call last): > File

Re: 32 bit or 64 bit?

2008-06-16 Thread [EMAIL PROTECTED]
On Jun 16, 12:57 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jun 15, 11:30 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > > > [EMAIL PROTECTED] wrote: > > > I have a physical system set up in which a body is supposed to > > > accelerate and to get very close to lightspeed, while

Re: Simple and safe evaluator

2008-06-16 Thread bvdp
Okay guys. I have the _ast based safe eval installed and working in my program. It appears to be working just fine. Thanks for the help. Now, a few more questions: 1. I see that _ast is a 2.5 module?? So, for folks using my code with <2.5 I could do something like this: # I've got some imp

Re: newbie question: for loop within for loop confusion

2008-06-16 Thread MRAB
On Jun 16, 7:17 am, Paul Hankin <[EMAIL PROTECTED]> wrote: > On Jun 16, 2:35 pm, takayuki <[EMAIL PROTECTED]> wrote: > > > > > def hasnolet2(avoid): > > fin = open('animals.txt') > > for line in fin: > > word = line.strip() > > > length = len(avoid) > >

Re: numpy: handling float('NaN') different in XP vs. Linux

2008-06-16 Thread Robert Kern
John [H2O] wrote: Dan Bishop wrote: Python just uses the atof() function from the underlying C library. Some of them handle NaN's, and some of them don't. As a work around, how would I write this in list comprehension form: newlist=[] for i in range(len(v[1])):

Good cross-host IPC?

2008-06-16 Thread Kirk Strauser
We've been using NetWorkSpaces (http://www.ddj.com/web-development/21971) for IPC on programs running on several different machines. Since it uses a central, shared server for storing values, you don't have to write socket code in your various programs to pass data back and forth. For example

vmware job vacancy!

2008-06-16 Thread Mr Shore
A veteran engineer from VMWare Inc., Jeffrey, is being featured on jobirn.com on Monday Jun 16, from 9am to 5pm (PST.) He will chat with applicants who are interested in job openings in VMWare. He will identify qualified candidates and directly submit qualified candidates' resumes to hiring manager

How to request data from a lazily-created tree structure ?

2008-06-16 Thread méchoui
Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from a slow distant site). - But you want to be able to request data from it, such has "give me all nodes tha

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Ian Kelly
On Mon, Jun 16, 2008 at 12:07 PM, Alex Elder <[EMAIL PROTECTED]> wrote: > I found this article useful when dealing with strings in Python: > >http://www.skymind.com/~ocrow/python_string/ > > It may help squeeze some more time out of your code. 8-) Things seem to have changed since then. I

Re: py2exe 0.6.8 released

2008-06-16 Thread Robert
Being new on on Python (but otherwise experienced programmer this message triggered me to do the install. It looks like a nice way to do a comprehensive check of your system. When running one of the py2exe samples, located in C:\Python25\Lib\site-packages\py2exe\samples\singlefile\gui I got the

President Bush Meets Pope Before Heading to Paris

2008-06-16 Thread vaticans.org
U.S. President George Bush has met with Pope Benedict at the Vatican, as he continues his week-long European trip. After his talks with the pontiff, Mr. Bush was traveling to Paris, France, where he is to give a speech later Friday on the strong relationship between the U.S. and Europe. U.S. Nati

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Jean-Paul Calderone
On Mon, 16 Jun 2008 11:30:19 -0600, Ian Kelly <[EMAIL PROTECTED]> wrote: On Mon, Jun 16, 2008 at 11:09 AM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: It will depend what version of Python you're using and the *exact* details of the code in question. An optimization was introduced where, if

Re: Configuration files

2008-06-16 Thread Robert
Does ConfigParser allow writing configuration changes also? "Dennis Lee Bieber" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] > On Sat, 14 Jun 2008 21:27:19 +0200, "Robert" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > What is the most Pythonic way to ma

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread [EMAIL PROTECTED]
On 16 juin, 10:37, Armin Ronacher <[EMAIL PROTECTED]> wrote: > Abstract > > > This PEP proposes an ordered dictionary as a new data structure for > the ``collections`` module, called "odict" in this PEP for short. The > proposed API incorporates the experiences gained from working with >

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread George Sakkis
On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > I have a situation where one class can be customized with several > > orthogonal options. Currently this is implemented with (multiple) > > inheritance but this leads to combinatorial explosion of subclasses

Re: sqlite3 and Python 2.5.1

2008-06-16 Thread Lie
On Jun 17, 12:59 am, milan_sanremo <[EMAIL PROTECTED]> wrote: > I have sqlite installed, but when I try to import sqlite3 I receive: > > Python 2.5.1 (r251:54863, Nov  3 2007, 02:54:36) [C] on sunos5 > Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 > > Tra

Re: numpy: handling float('NaN') different in XP vs. Linux

2008-06-16 Thread John [H2O]
Dan Bishop wrote: > > > > Python just uses the atof() function from the underlying C library. > Some of them handle NaN's, and some of them don't. > > As a work around, how would I write this in list comprehension form: newlist=[] for i in range(len(v[1])): t

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Alex Elder
I found this article useful when dealing with strings in Python: http://www.skymind.com/~ocrow/python_string/ It may help squeeze some more time out of your code. 8-) Alex. -- http://mail.python.org/mailman/listinfo/python-list

sqlite3 and Python 2.5.1

2008-06-16 Thread milan_sanremo
I have sqlite installed, but when I try to import sqlite3 I receive: Python 2.5.1 (r251:54863, Nov 3 2007, 02:54:36) [C] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 Traceback (most recent call last): File "", line 1, in ImportError: No mo

Re: bpython - fancy Python shell

2008-06-16 Thread Sebastian "lunar" Wiesner
Wolfgang Grafen <[EMAIL PROTECTED]>: > I couldn't get it work on Solaris (modified some lines for Python2.3). If solaris doesn't have a readline library, you might try to compile gnu readline, and recompile python (also a chance to get the current version 2.5) > One reason was that I had to down

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Gerard flanagan
George Sakkis wrote: I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of subclasses as more orthogonal features are added. Naturally, the decorator pattern [1]

Re: sorted or .sort() ?

2008-06-16 Thread Raymond Hettinger
On Jun 16, 5:11 am, Peter Bengtsson <[EMAIL PROTECTED]> wrote: > My poor understanding is that the difference between `sorted(somelist, > key=lambda x:...)` and `somelist.sort(lambda x,y...)` is that one > returns a new list and the other sorts in-place. > > Does that mean that .sort() is more effi

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Ian Kelly
On Mon, Jun 16, 2008 at 11:09 AM, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > It will depend what version of Python you're using and the *exact* details > of the code in question. An optimization was introduced where, if the > string being concatenated to is not referred to anywhere else, it

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Raymond Hettinger
On Jun 16, 10:09 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Ethan Furman wrote: > > The strip() method of strings works from both ends towards the middle. > > Is there a simple, built-in way to remove several characters from a > > string no matter their location? (besides .replace() ;) > >>> iden

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Peter Otten
Ethan Furman wrote: > The strip() method of strings works from both ends towards the middle. > Is there a simple, built-in way to remove several characters from a > string no matter their location? (besides .replace() ;) >>> identity = "".join(map(chr, range(256))) >>> 'www.example.com'.translate

Python-URL! - weekly Python news and links (Jun 16)

2008-06-16 Thread Gabriel Genellina
QOTW: "The problem [with C++] is, I never feel like I'm programing the *problem*, I always feel like I'm programming the *language*." - Roy Smith Alternatives to the Decimal type: http://groups.google.com/group/comp.lang.python/browse_thread/thread/9cd6dae725268afb/ How

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Jean-Paul Calderone
On Mon, 16 Jun 2008 10:41:05 -0600, Ian Kelly <[EMAIL PROTECTED]> wrote: On Mon, Jun 16, 2008 at 4:34 AM, Bart Kastermans <[EMAIL PROTECTED]> wrote: This is interesting. I had never attempted to verify a big O statement before, and decided that it would be worth trying. So I wrote some code to

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Maric Michaud
Le Monday 16 June 2008 18:58:06 Ethan Furman, vous avez écrit : > The strip() method of strings works from both ends towards the middle. > Is there a simple, built-in way to remove several characters from a > string no matter their location? (besides .replace() ;) > > For example: > .strip --> 'www

Re: PEP 372 -- Adding an ordered directory to collections

2008-06-16 Thread ivarnelispam
I'm very happy to see this PEP. I have needed to use ordered dictionaries many times, and this has always felt to me like a surprising omission from Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: String Concatenation O(n^2) (was: Re: Explaining Implementing a Binary Search Tree.)

2008-06-16 Thread Ian Kelly
On Mon, Jun 16, 2008 at 4:34 AM, Bart Kastermans <[EMAIL PROTECTED]> wrote: > This is interesting. I had never attempted to verify a big O > statement > before, and decided that it would be worth trying. So I wrote some > code to > collect data, and I can't find that it goes quadratic. I have th

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Larry Bates
Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --> 'www.example.com'.strip('cmowz.') 'example'

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Cédric Lucantis
Hi, > Greetings. > > The strip() method of strings works from both ends towards the middle. > Is there a simple, built-in way to remove several characters from a > string no matter their location? (besides .replace() ;) > > For example: > .strip --> 'www.example.com'.strip('cmowz.') > 'example' >

Re: 'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Calvin Spealman
On Jun 16, 2008, at 12:58 PM, Ethan Furman wrote: Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --> 'www.exampl

Re: py2exe 0.6.8 released

2008-06-16 Thread Larry Bates
Jimmy Retzlaff wrote: py2exe 0.6.8 released = py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll C

'string'.strip(chars)-like function that removes from the middle?

2008-06-16 Thread Ethan Furman
Greetings. The strip() method of strings works from both ends towards the middle. Is there a simple, built-in way to remove several characters from a string no matter their location? (besides .replace() ;) For example: .strip --> 'www.example.com'.strip('cmowz.') 'example' .??? --> --- 'www.ex

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Diez B. Roggisch
> Ok, I see how this would work (and it's trivial to make it cache the > generated classes for future use) but I guess I was looking for a more > "mainstream" approach, something that even a primitive statically > typed language could run :) Even in Python though, I think of Runtime > Type Generati

### hai, make money very simple on internet. earn at home very easily .........###

2008-06-16 Thread jeeno
Hello friends & guys, I want to tell you about great site I found. They pay me to read e- mail, visit sign in the web sites and much more. earn easily without investment. It's free to join and easy to sign up! CLICK THIS LINK TO VISIT: http://www.ippomails.net/pages/index.php?refid=veeramani http

sexe day

2008-06-16 Thread suresh
u want the all sexye flimes ues this u want me see this *** *** http;//lesbiangroupsexy.blogspot.com/ -- http://mail.python.org/mailman/lis

  1   2   >