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

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: '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

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

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

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

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: > >

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 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

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: 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: 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: 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: 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: 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: 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

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: 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

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: 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 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

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 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

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 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

DIGITAL TV

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

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

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

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

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

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

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: 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: 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: 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: 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: 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: 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

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: 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

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

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: 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

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: 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: 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: 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

<    1   2