Re: comparing two lists, ndiff performance

2008-01-30 Thread Gabriel Genellina
On 29 ene, 22:47, Zbigniew Braniecki <[EMAIL PROTECTED]> wrote: > The new one is of course much better and cleaner (the old one is > bloated), but I'm wondering if there is a faster way to compare two > lists and find out what was added, what was removed, what was changed. > I can simply iterate t

Re: Module/package hierarchy and its separation from file structure

2008-01-30 Thread Steven D'Aprano
On Tue, 29 Jan 2008 13:44:33 -0600, Robert Kern wrote: > Carl Banks wrote: >> On Jan 29, 7:48 am, Peter Schuller <[EMAIL PROTECTED]> wrote: You can also put, in animal/__init__.py: from monkey import Monkey and now you can refer to it as org.lib.animal.Monkey, but keep the imp

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Hrvoje Niksic
Paul Rubin writes: > Quadratic time!! Yowch!! Back to the future: > > def rocket_science(xs): >for x in xs: > if x != 99: > yield x > > a[:] = list(rocket_science(a)) I call "useless use of list"! a[:] = rocket_science(a) :-) -- http://mail.python

Re: find nearest time in datetime list

2008-01-30 Thread Boris Borcic
washakie wrote: > Hello, > > I have a list of datetime objects: DTlist, I have another single datetime > object: dt, ... I need to find the nearest DTlist[i] to the dt is > there a simple way to do this? There isn't necessarily an exact match... > > Thanks! > .john > min(DTlist,key=lambd

Anyone Know Unicode? Help!

2008-01-30 Thread Victor Subervi
Hi; Second post on this. Googling shows many others with same problem, but no answers! Help! New to unicode. Got this error: Traceback (most recent call last): File "", line 1, in File "", line 29, in tagWords File "/usr/local/lib/python2.5/codecs.py", line 303, in write data, consumed

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Neil Cerutti
On 30 Jan 2008 05:20:49 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Neil Cerutti" <[EMAIL PROTECTED]> writes: > > Or one can put on his bellbottoms, horn-rimmed glasses, and wear a mullet: > > > > i = 0 > > while i < len(a): > > if a[i] == 99: > > del a[i] > > else: > >

Re: comparing two lists, ndiff performance

2008-01-30 Thread Zbigniew Braniecki
[EMAIL PROTECTED] wrote: > Zbigniew Braniecki: >> Is there a way to speed it up? Any easier way? Faster method? > > This problem is a bit messy. Maybe it's better to sidestep the > problem, and not use a list, and create an object that wraps the list, > so it always keeps an updated record of what

Re: Removing Pubic Hair Methods

2008-01-30 Thread Sion Arrowsmith
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >On Tue, 29 Jan 2008 11:48:38 -0800, Tobiah wrote: >> class genital: >> def pubic_hair(self): >> pass >> def remove(self): >> del(self.pubic_hair) >I think `pubic_hair` is an attribute instead of a method. > >O

Re: Unicode literals to latin-1

2008-01-30 Thread Gabriel Genellina
On 30 ene, 07:54, <[EMAIL PROTECTED]> wrote: > On 30. januar 2008 10:48, Marc 'BlackJack' Rintsch wrote: > > >On Wed, 30 Jan 2008 09:57:55 +0100, David.Reksten wrote: > > >> How can I convert a string read from a database containing unicode > >> literals, such as "Fr\u00f8ya" to the latin-1 equival

Re: comparing two lists, ndiff performance

2008-01-30 Thread bearophileHUGS
Zbigniew Braniecki: > Is there a way to speed it up? Any easier way? Faster method? This problem is a bit messy. Maybe it's better to sidestep the problem, and not use a list, and create an object that wraps the list, so it always keeps an updated record of what changes are done... but you have to

Re: Removing hidden files and folders with python ...

2008-01-30 Thread Gabriel Genellina
On 30 ene, 06:21, Konrad Mühler <[EMAIL PROTECTED]> wrote: > I try to delete a whole directory-tree using shutil.rmtree(...) > But there are always the hidden files and folders (e.g. from the svn > .svn) left. > > How can I delete -all- files and folders (also the hidden) with python? I assume yo

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Arnaud Delobelle
On Jan 30, 11:57 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > n = len(a) > for i, x in enumerate(a): >     if x == 99: del a[i-n] Oops. That can't work. Don't know what I was thinking here. I probably did had one mental refactoring too many... -- Arnaud -- http://mail.python.org/mailman/

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Paul Rubin
"Neil Cerutti" <[EMAIL PROTECTED]> writes: > Or one can put on his bellbottoms, horn-rimmed glasses, and wear a mullet: > > i = 0 > while i < len(a): > if a[i] == 99: > del a[i] > else: > i += 1 Quadratic time!! Yowch!! Back to the future: def rocket_science(xs): for x in xs:

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread bearophileHUGS
If you don't want to reinvent the wheel all the time you can use this one: def inplacefilter(pred, alist): """inplacefilter(pred, alist): filters the given list like filter(), but works inplace, minimizing the used memory. It returns None. >>> pr = lambda x: x > 2 >>> l = [] >

Re: refcount

2008-01-30 Thread Sion Arrowsmith
Benjamin <[EMAIL PROTECTED]> wrote: >> [ help(sys.getrefcount) says: ] >> [ ... ] The count returned is generally >> one higher than you might expect, because it includes the (temporary) >> reference as an argument to getrefcount(). >Are there any cases when it wouldn't? When the temporary refer

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Neil Cerutti
On Jan 30, 2008 6:57 AM, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Or one could use the trick of counting from the right (untested): > > n = len(a) > for i, x in enumerate(a): > if x == 99: del a[i-n] Or one can put on his bellbottoms, horn-rimmed glasses, and wear a mullet: i = 0 while i

Re: HI all

2008-01-30 Thread Gabriel Genellina
On 30 ene, 09:26, [EMAIL PROTECTED] wrote: > I am shravan tiwari, i want to know that how i'll run any python > file(*.py) on command prompt r python GUI. > i tried this > > python test.py > > but i have got error, syntax error. so can i get the solution. This is the right way to run it. If you g

Re: Problem with Tkinter scrollbar callback

2008-01-30 Thread Ivan Van Laningham
HI All-- We've decided that this represents a bug in the tcl/tk library, and there's no workaround. I switched to + and - buttons, which are not as nice aesthetically but work correctly on both Windows & Linux. Thanks to everyone for their help. Metta, Ivan On Jan 29, 2008 11:03 AM, Ivan Van La

Re: Removing Pubic Hair Methods

2008-01-30 Thread Marc 'BlackJack' Rintsch
On Tue, 29 Jan 2008 11:48:38 -0800, Tobiah wrote: > class genital: > > def pubic_hair(self): > pass > > def remove(self): > del(self.pubic_hair) I think `pubic_hair` is an attribute instead of a method. Oh, and ``del`` is a statement and not a function.

Re: Python noob SOS (any [former?] Perlheads out there?)

2008-01-30 Thread kj
In <[EMAIL PROTECTED]> Wildemar Wildenburger <[EMAIL PROTECTED]> writes: >kj wrote: >> Is there any good reading (to ease the transition) for Perl >> programmers trying to learn Python? >> >www.diveintopython.org Thanks. Not for Perl programmers specifically, but it looks useful all the same.

Tkinter - incremental input ?

2008-01-30 Thread Helmut Jarausch
Hi, I don't want to reinvent the wheel but I cannot find it so far. Many editors have a so-called incremental search feature. As you type characters, elements of a set of strings which fit so far are displayed or at least, the first one of these is displayed. Now I want to do something similar i

Re: Python noob SOS (any [former?] Perlheads out there?)

2008-01-30 Thread kj
In <[EMAIL PROTECTED]> "Reedick, Andrew" <[EMAIL PROTECTED]> writes: >> Be that as it may, the activation barrier to using Python for my >> scripting remains too high. >>=20 >> I'd written a Perl module to facilitate the writing of scripts. >> It contained all my boilerplate code for parsing and v

Re: Removing Pubic Hair Methods

2008-01-30 Thread Tobiah
class genital: def pubic_hair(self): pass def remove(self): del(self.pubic_hair) "Removing pubic hair methods" [EMAIL PROTECTED] wrote: > Shaving is the most common removing pubic hair method. However, it is > not the only one. > > After you ha

Re: Trying to understand Python web-development

2008-01-30 Thread Paul Boddie
On 29 Jan, 18:11, walterbyrd <[EMAIL PROTECTED]> wrote: > I don't know much php either, but running a php app seems straight > forward enough. I think that this (the ease of PHP application deployment) is one of the things that keeps Python framework developers up at night, regardless of whether t

Re: find nearest time in datetime list

2008-01-30 Thread Tim Chase
> I have a list of datetime objects: DTlist, I have another single datetime > object: dt, ... I need to find the nearest DTlist[i] to the dt is > there a simple way to do this? There isn't necessarily an exact match... import datetime dates = [datetime.datetime(2007,m, 1) for m in range(1,1

Re: find nearest time in datetime list

2008-01-30 Thread Tim Golden
washakie wrote: > Hello, > > I have a list of datetime objects: DTlist, I have another single datetime > object: dt, ... I need to find the nearest DTlist[i] to the dt is > there a simple way to do this? There isn't necessarily an exact match... import datetime dates = [datetime.date (20

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Arnaud Delobelle
On Jan 29, 10:59 pm, Paul Hankin <[EMAIL PROTECTED]> wrote: > If I really had to modify it in place (and the condition wasn't really > x == 99), how about: > bad_indices = [i for i, x in enumerate(a) if x == 99] > for bad_index in reversed(bad_indices): >     del a[bad_index] Or one could use the

find nearest time in datetime list

2008-01-30 Thread washakie
Hello, I have a list of datetime objects: DTlist, I have another single datetime object: dt, ... I need to find the nearest DTlist[i] to the dt is there a simple way to do this? There isn't necessarily an exact match... Thanks! .john -- View this message in context: http://www.nabble.

HI all

2008-01-30 Thread tiwarishravan
I am shravan tiwari, i want to know that how i'll run any python file(*.py) on command prompt r python GUI. i tried this python test.py but i have got error, syntax error. so can i get the solution. -- http://mail.python.org/mailman/listinfo/python-list

Re: Implementation of IBuyable or Interface?

2008-01-30 Thread Marcelo de Moraes Serpa
Hi Gabriel, thanks for the reply. It's hard to tell just with that description. If you have to distinguish > between a Product and a Service, specially if you have to do things with > one that aren't done with the other (so they have a different set of > methods), I'd say they should be different

Re: help using python on Vista

2008-01-30 Thread James Matthews
You need to go into folder options which is in the control panel and there under the view tab click Show hidden files and folders On Jan 30, 2008 9:36 AM, Safe Alattar <[EMAIL PROTECTED]> wrote: > I have no issues using python on XP. However on Vista I cant get the > python gui (IDLE) to open! >

SV: Unicode literals to latin-1

2008-01-30 Thread David.Reksten
On 30. januar 2008 10:48, Marc 'BlackJack' Rintsch wrote: >On Wed, 30 Jan 2008 09:57:55 +0100, David.Reksten wrote: > >> How can I convert a string read from a database containing unicode >> literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? >> >> I have tried variations around >>

Re: Unicode literals to latin-1

2008-01-30 Thread Marc 'BlackJack' Rintsch
On Wed, 30 Jan 2008 09:57:55 +0100, David.Reksten wrote: > How can I convert a string read from a database containing unicode > literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? > > I have tried variations around > "Fr\u00f8ya".decode('latin-1') > but to no avail. In [388]: 'F

SV: Unicode literals to latin-1

2008-01-30 Thread David.Reksten
On 30. januar 2008 10:21, Berteun Damman wrote: >On Wed, 30 Jan 2008 09:57:55 +0100, <[EMAIL PROTECTED]> ><[EMAIL PROTECTED]> wrote: >> How can I convert a string read from a database containing unicode >> literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? >> >> I have tried vari

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Paul Rubin
Santiago Romero <[EMAIL PROTECTED]> writes: > In a = [1, 2, 3, 3, 3, 4, 3, 3, 2, 3], the filter solution will > efectively remove all items with value == 3 while li.remove(3) will > only remove the first ocurrence. Hmm, interesting, I didn't realize that (shoulda checked the docs). Thanks! --

Re: Module/package hierarchy and its separation from file structure

2008-01-30 Thread Peter Schuller
>> The problem is that we are now back to the identity problem. The class >> won't actually *BE* org.lib.animal.Monkey. > > The usage is the same; it works in all cases once you redefine > __module__. Who cares what it really is? The cases I listed were just examples. My point was that I wanted i

Re: Unicode literals to latin-1

2008-01-30 Thread Piet van Oostrum
> <[EMAIL PROTECTED]> (DR) wrote: >DR> How can I convert a string read from a database containing unicode >literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? >DR> I have tried variations around >DR> "Fr\u00f8ya".decode('latin-1') >DR> but to no avail. You have to use encode

Re: Unicode literals to latin-1

2008-01-30 Thread Berteun Damman
On Wed, 30 Jan 2008 09:57:55 +0100, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > How can I convert a string read from a database containing unicode > literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? > > I have tried variations around > "Fr\u00f8ya".decode('latin-1') > but

Re: Appropriate use of Property()

2008-01-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Property() can be used to rid ourselves of the extra effort of using > two different methods (getAttrib() setAttrib()) for access of an > attribute without giving direct access to the attribute, NB : properties are for computed attributes, not to "avoid giving direct

Re: Web Interface Recommendations

2008-01-30 Thread Bruno Desthuilliers
PurpleServerMonkey a écrit : (snip) > Out of the major frameworks is there one that stands out as being > particularly well suited for what I'm trying to do? > > Django and CherryPy are on the short list so I'll give them a detailed > look although Pylons does sound rather interesting as well. I

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread cokofreedom
On Jan 30, 9:50 am, Santiago Romero <[EMAIL PROTECTED]> wrote: > On 30 ene, 08:09, Paul Rubin wrote: > > > Santiago Romero <[EMAIL PROTECTED]> writes: > > > > > >>> li = [1,2,3,4,5] > > > > >>> filter(lambda x: x != 3, li) > > > > [1, 2, 4, 5] > > > > I haven't measure

Unicode literals to latin-1

2008-01-30 Thread David.Reksten
How can I convert a string read from a database containing unicode literals, such as "Fr\u00f8ya" to the latin-1 equivalent, "Frøya"? I have tried variations around "Fr\u00f8ya".decode('latin-1') but to no avail. .david -- http://mail.python.org/mailman/listinfo/python-list

Re: Removal of element from list while traversing causes the next element to be skipped

2008-01-30 Thread Santiago Romero
On 30 ene, 08:09, Paul Rubin wrote: > Santiago Romero <[EMAIL PROTECTED]> writes: > > > > >>> li = [1,2,3,4,5] > > > >>> filter(lambda x: x != 3, li) > > > [1, 2, 4, 5] > > > I haven't measured it, but this should be the fast solution in all > > the thread ... > > li.re

help using python on Vista

2008-01-30 Thread Safe Alattar
I have no issues using python on XP. However on Vista I cant get the python gui (IDLE) to open! I did some research and found out that I need to unhide .idlerc but I cannot find any hidden files by that name whatsoever. Please help me. Im fairly new to python but I want to get this going. User fri

Form to mail script

2008-01-30 Thread Joe Demeny
I am looking for a python web form to mail script for a public web site - could you recommend one? -- Joe Demeny -- http://mail.python.org/mailman/listinfo/python-list

Removing hidden files and folders with python ...

2008-01-30 Thread Konrad Mühler
Hi, I try to delete a whole directory-tree using shutil.rmtree(...) But there are always the hidden files and folders (e.g. from the svn .svn) left. How can I delete -all- files and folders (also the hidden) with python? Many Thanks Konrad -- http://mail.python.org/mailman/listinfo/python-list

Re: starting programs from python script on windows

2008-01-30 Thread Piet van Oostrum
> Benedict Verheyen <[EMAIL PROTECTED]> (BV) wrote: >BV> Hi, >BV> i want to automate starting programs on my windows machine and i want >BV> to do it with windows. >BV> This is a sample script: >BV> from subprocess import Popen, PIPE >BV> import time >BV> print " Starting app 1" >BV> time.sl

Re: Appropriate use of Property()

2008-01-30 Thread Asun Friere
On Jan 30, 5:03 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > On 29 ene, 23:17, [EMAIL PROTECTED] wrote: > > > Property() can be used to rid ourselves of the extra effort of using > > two different methods (getAttrib() setAttrib()) for access of an > > attribute without giving direct access to

<    1   2