Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Fri, 07 Mar 2008 20:57:32 -0800, dave_mikesell wrote: >> x = get_stuff(store) # Get the stuff what was brought at the store. > > Perfect example of an unnecessary comment. The variable and function > names are commentary enough. "x" is a terrible name. What does it mean? Nothing. There's on

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-08 Thread castironpi
On Mar 7, 7:46 pm, DBak <[EMAIL PROTECTED]> wrote: > > > > >  However I can't do this, because, of course, the name Tree isn't > > > > >  available at the time that the classes _MT and _Node are defined, so > > > > >  _MT and _Node can't inherit from Tree. > > > > > Not only is the name not defined

Re: Timed execution in eval

2008-03-08 Thread castironpi
On Mar 7, 9:43 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 7, 11:12 am, [EMAIL PROTECTED] wrote: > > > I have various bits of code I want to interpret and run at runtime in > > eval ... > > Check out these two recipes: > > - Using signals:http://aspn.activestate.com/ASPN/Cookbook/Python/R

Re: help on file storage for split multi part download

2008-03-08 Thread coolman . guron
On Mar 7, 2:14 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 07 Mar 2008 04:16:42 -0200, <[EMAIL PROTECTED]> escribi�: > > > > > On Mar 7, 1:38 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > >> En Thu, 06 Mar 2008 14:34:27 -0200, <[EMAIL PROTECTED]> escribi�: > > >> > storage c

Re: distutils - Is is possible to install without the .py extensions

2008-03-08 Thread Jari Aalto
* Fri 2008-03-07 Robert Kern <[EMAIL PROTECTED]> gmane.comp.python.general * Message-Id: [EMAIL PROTECTED] setup(name='program', >> ... scripts = ['program,py'], ) that the the result is: /usr/bin/program instead of: /us

Re: islice ==> [::]

2008-03-08 Thread bearophileHUGS
George Sakkis: > I had posted some time ago an OO wrapper of itertools; slice notation > for islice was one > motivation:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/498272 I think I did see that, but later I forgot of it. It looks nice. Thank you, bearophile -- http://mail.python.org

Re: Timed execution in eval

2008-03-08 Thread Guilherme Polo
2008/3/7, Steven D'Aprano <[EMAIL PROTECTED]>: > On Fri, 07 Mar 2008 08:12:38 -0800, alex.pedwysocki wrote: > > > I have various bits of code I want to interpret and run at runtime in > > eval ... > > > I hope that code doesn't contain any data coming from an untrusted user. > > > > > I want to

parralel downloads

2008-03-08 Thread John Deas
Hi, I would like to write a python script that will download a list of files (mainly mp3s) from Internet. For this, I thought to use urllib, with urlopen("myUrl").read() and then writing the resulting string to a file my problem is that I would like to download several files at the time. As I ha

Writing Memory to File

2008-03-08 Thread Stefan Wagner
Hi, I'm trying to do some memory analyzing stuff, i wrote me a small .c so far to dump the memory to a file for later analysis, the analyzing part itself is python code. I wonder if any of you has an idea how to dump the whole memory in Linux/Windows from python ? Using the .c for this somehow doe

Re: Want - but cannot get - a nested class to inherit from outer class

2008-03-08 Thread marek . rocki
Everybody has already explained why this doesn't work and a possible "solution" using metaclasses was suggested. I tried to implement it, ended up with monkey-patching __bases__, which is certainly an abomination (will it be possible in python 3.0?) but seems to do the trick. class _InheritFromOut

Re: DOM parsing not working!

2008-03-08 Thread rbossy
Quoting Mike D <[EMAIL PROTECTED]>: > Hello, I've spent the morning trying to parse a simple xml file and have the > following: > import sys > from xml.dom import minidom > > doc=minidom.parse('topstories.xml') > > items = doc.getElementsByTagName("item") > text='' > for i in items: > t = i.fi

Re: os.chdir

2008-03-08 Thread rbossy
Quoting Maryam Saeedi <[EMAIL PROTECTED]>: > I have a problem using os.chdir on linux. What should I do if I want to > change to root directory? The below does not work: > > os.chdir("~/dir1") It is not mentioned in the documentation but I'm pretty sure os.dir() doesn't do tilde expansion since t

Re: os.chdir

2008-03-08 Thread Martin v. Löwis
>> os.chdir("~/dir1") > > It is not mentioned in the documentation but I'm pretty sure os.dir() doesn't > do > tilde expansion since this is usually performed by a shell. > > You should use instead: > > os.chdir(os.join(os.environ['HOME'], 'dir1')) Or os.chdir(os.path.expanduser("~/dir1")) R

List as FIFO in for loop

2008-03-08 Thread malkarouri
Hi everyone, I have an algorithm in which I need to use a loop over a queue on which I push values within the loop, sort of: while not(q.empty()): x = q.get() #process x to get zero or more y's #for each y: q.put(y) The easiest thing I can do is use a list as a queue and a normal

Re: os.chdir

2008-03-08 Thread rbossy
Quoting "Martin v. Löwis" <[EMAIL PROTECTED]>: > >> os.chdir("~/dir1") > > > > It is not mentioned in the documentation but I'm pretty sure os.dir() > doesn't do > > tilde expansion since this is usually performed by a shell. > > > > You should use instead: > > > > os.chdir(os.join(os.environ['HOM

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 2:38 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 20:57:32 -0800, dave_mikesell wrote: > >> x = get_stuff(store) # Get the stuff what was brought at the store. > > > Perfect example of an unnecessary comment. The variable and function > > names

Re: for-else

2008-03-08 Thread egbert
The idea of the if-else is: . depending on some condition either do this or do something else, . don't do them both. If you approach a loop-else with this same idea, you get: . depending on the loop conditions either do the loop, . or do something else, but not both. However the loop-else r

Re: List as FIFO in for loop

2008-03-08 Thread Roel Schroeven
malkarouri schreef: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): > x = q.get() > #process x to get zero or more y's > #for each y: > q.put(y) > > The easiest thing I

extract multiple ranges from a list

2008-03-08 Thread pi . arctan
Hi guys, One of my many project involves working with YUV-files, where I need to reduce the vertical resolution with a factor of two, i.e. remove every other scan line. Today I'm using two for-loops in the fashion shown below y = [] for i in range(0, width*height, width*2): for j in range(0,w

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> The function name also doesn't explain anything. How was the stuff got? >> Was it paid for, or stolen, or picked up on consignment, or what? Compare >> the above line with: >> >> x = get_stuff(store) # Steal stuff from the store. >> >

Re: Can't get items out of a set?

2008-03-08 Thread Alan Isaac
Cruxic wrote: > people = set( [Person(1, 'Joe'), Person(2, 'Sue')] ) > ... > p = people.get_equivalent(2) #method doesn't exist as far as I know > print p.name #prints Sue def get_equivalent(test, container): for p in container: if p == test: return p hth, Alan Isaac

Re: extract multiple ranges from a list

2008-03-08 Thread Paul Hankin
On Mar 8, 3:28 pm, [EMAIL PROTECTED] wrote: > Hi guys, > > One of my many project involves working with YUV-files, where I need > to reduce > the vertical resolution with a factor of two, i.e. remove every other > scan line. > Today I'm using two for-loops in the fashion shown below > > y = [] > fo

wholesale and retail nike sports shoes,nike shox,air maxss,dunks

2008-03-08 Thread 333
our website: http://www.FASHION4BIZ.com our MSN:[EMAIL PROTECTED] our EMAIL:[EMAIL PROTECTED] paypal accept,wholesale and retail accept,dropship accept sale new Nike Sneakers,Air Jordan Sneakers,AIR FORCE 1S,Nike Dunks SB, Bape Sta from nike outlets and factory stores, also Nike wholesale - Jord

Re: List as FIFO in for loop

2008-03-08 Thread duncan smith
malkarouri wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): > x = q.get() > #process x to get zero or more y's > #for each y: > q.put(y) > > The easiest thing I ca

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 3:20 pm, Roel Schroeven <[EMAIL PROTECTED]> wrote: > malkarouri schreef: > > > > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.empty()): > >     x = q.get() > >     #process x to g

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 3:52 pm, duncan smith <[EMAIL PROTECTED]> wrote: > malkarouri wrote: > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.empty()): > >     x = q.get() > >     #process x to get zero or

Re: Can't get items out of a set?

2008-03-08 Thread Cruxic
On Mar 7, 11:20 am, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Cruxic] > > > Is it possible to get an object out of a set() given another object > > that has the same hash code and equality (__hash__() and __eq__() > > return the same)? > > Yes, but it requires an indirect > approach.http://a

Re: Can't get items out of a set?

2008-03-08 Thread Cruxic
On Mar 8, 7:32 am, Alan Isaac <[EMAIL PROTECTED]> wrote: > Cruxic wrote: > > people = set( [Person(1, 'Joe'), Person(2, 'Sue')] ) > > ... > > p = people.get_equivalent(2) #method doesn't exist as far as I know > > print p.name #prints Sue > > def get_equivalent(test, container): > > for p in co

Re: parralel downloads

2008-03-08 Thread poof65
For your problem you have to use threads. You can have more information here. http://artfulcode.nfshost.com/files/multi-threading-in-python.html On Sat, Mar 8, 2008 at 1:11 PM, John Deas <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to write a python script that will download a list of > f

Re: extract multiple ranges from a list

2008-03-08 Thread Peter Otten
[EMAIL PROTECTED] wrote: > One of my many project involves working with YUV-files, where I need > to reduce > the vertical resolution with a factor of two, i.e. remove every other > scan line. > Today I'm using two for-loops in the fashion shown below > > y = [] > for i in range(0, width*height,

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
On Mar 7, 11:23 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: > > Sorry to come in so late in this discussion. Although it is correct to > > say that many real numbers that have an exact decimal representation > > can

Re: List as FIFO in for loop

2008-03-08 Thread Martin v. Löwis
> Still, why avoid changing loop variable? Does python treat looping > over a list differently from looping over an iterator, where it > doesn't know if the iterator future changes while loop running? Take a look at Objects/listobject.c:listiterobject. It contains an it_index, which is the index i

Re: parralel downloads

2008-03-08 Thread Gary Herron
poof65 wrote: > For your problem you have to use threads. > Not at all true. Thread provide one way to solve this, but another is the select function. For this simple case, select() may (or may not) be easier to write. Pseudo-code would look something like this: openSockets = list of soc

SQL problem in python

2008-03-08 Thread aiwarrior
class db: def __init__(self): #constructor conn = sqlite3.connect(":memory:") conn.isolation_level = None self.cursor = conn.cursor() self.cursor.execute("CREATE TABLE database (album,filepath)") def add_entry(self, eone , etwo): #Add entry to database

Re: Converting a string to the most probable type

2008-03-08 Thread Lie
On Mar 8, 12:19 am, rockingred <[EMAIL PROTECTED]> wrote: > Dates can be a pain.  I wrote my own date program, simply because > there are so many different ways to write a date: > > Mar 8, 2008 > March 8th, 08 > 03/08/08 > 03-08-2008 > > And so on and so forth.  The tricky bit is how to tell the di

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
On Mar 8, 11:34 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > following, which arises from Python arbitrarily stripping trailing > zeros from the result returned by the C library functions: Correction: on closer examination it's not Python doing the stripping of trailing zeros; it's the C librar

Re: SQL problem in python

2008-03-08 Thread Carsten Haese
On Sat, 2008-03-08 at 08:57 -0800, aiwarrior wrote: > def get_value( self, column ): > self.cursor.execute( "SELECT (?) FROM database", column ) > for n in self.cursor: > print n > > When i run it the get_value() returns 'filepath' instead of the > columns. But if

Re: SQL problem in python

2008-03-08 Thread Peter Otten
aiwarrior wrote: > When i run it the get_value() returns 'filepath' instead of the > columns. But if i dont use any variable and make the expression static > all goes on as its supposed to. What am i doing wrong? > self.cursor.execute( "SELECT (?) FROM database", column ) In this case yo

Re: Converting a string to the most probable type

2008-03-08 Thread Lie
On Mar 8, 8:34 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 16:13:04 -0800, Paul Rubin wrote: > > Pierre Quentel <[EMAIL PROTECTED]> writes: > >> I would like to know if there is a module that converts a string to a > >> value of the "most probable type" >

Re: SQL problem in python

2008-03-08 Thread aiwarrior
Thanks a lot. In the Python documentation, the sqlite module documentation doesn't mention that special rule. I really thought that every variable to be included in a query had to use that special method. Again thanks a lot -- http://mail.python.org/mailman/listinfo/python-list

Re: Intelligent Date & Time parsing

2008-03-08 Thread castironpi
On Mar 7, 9:23 pm, [EMAIL PROTECTED] wrote: > I figured I might as well share the code I ended up using, in case > anyone else wants an easy way to get strings to, for instance, SQL- > storable datetimes. > > [EMAIL PROTECTED]:~$ cat test.py > #!/usr/bin/python > from datetime import datetime > imp

Re: tcp

2008-03-08 Thread Dan Stromberg
On Sun, 02 Mar 2008 23:05:27 -0500, Roy Smith wrote: > In article > <[EMAIL PROTECTED]>, > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > >> On 2 mar, 17:21, [EMAIL PROTECTED] wrote: >> >> > This worked: >> > >> > import socket >> > from time import time >> > >> > for i in range( 20 ): >> >    

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 9:31 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> The function name also doesn't explain anything. How was the stuff got? > >> Was it paid for, or stolen, or picked up on consignment, or what? Compare > >> the above line

Re: Regarding coding style

2008-03-08 Thread Lie
Personally I preferred a code that has chosen good names but have little or no comments compared to codes that makes bad names and have twenty pages of comments to read and understand what it's about. Personally, I think comments should be made as short and as concise as possible and codes should t

Help xxx.py Program Recognition problem

2008-03-08 Thread crashbangboom
Hi... I was using Python 2.4 and installed 2.5...I copied all my .py files from the Python24\ root directory to the Python25\ root directory...when I try to run them by double clicking I get: "X.py is not a valid Win32 application"... Also, the files do not appear to be associated with python

Re: What is a class?

2008-03-08 Thread castironpi
On Mar 7, 6:16 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Thu, 06 Mar 2008 08:40:47 -0800, castironpi wrote: > > you > > could say exec( open( 'modA.py' ).read() ) ==> import modA > > Yes, you could say that, but you'd be wrong. Please test your code before > making such

Re: Intelligent Date & Time parsing

2008-03-08 Thread Tim Chase
> I am a GNU newbie. (I know C &o.) Can you point me to a > place to find the source for 'date'? It's part of the GNU Coreutils: http://ftp.gnu.org/gnu/coreutils/ Within the file, you're likely interested in lib/getdate.* It helps if you have a working knowledge of Yacc. -tkc -- http://ma

Re: Difference between 'function' and 'method'

2008-03-08 Thread castironpi
On Mar 7, 1:34 pm, [EMAIL PROTECTED] wrote: > On Mar 7, 6:44 am, Sion Arrowsmith <[EMAIL PROTECTED]> > wrote: > > > Gabriel Genellina <[EMAIL PROTECTED]> wrote: > > >En Thu, 06 Mar 2008 23:46:43 -0200, <[EMAIL PROTECTED]> escribi�: > > >> [ ... ] > > >You may look at the SimpleXMLRPCServer class

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 5, 2:16 am, Bruno Desthuilliers wrote: > [EMAIL PROTECTED] a écrit : > (snip) > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > as finding a computer that's "paired" with multiple users, each of who > > are "paired" with multiple computers, without maintaining

Re: Converting a string to the most probable type

2008-03-08 Thread Pierre Quentel
> >>> def convert(x): > >         if '.' in x: >                 try: return float(x) >                 except ValueError: return x >         else: >                 try: return int(x) >                 except: return x > > >>> convert('123') > 123 > >>> convert('123.99') > 123.98 > >>>

Re: multiplication of lists of strings

2008-03-08 Thread castironpi
On Mar 8, 12:04 pm, [EMAIL PROTECTED] wrote: > On Mar 5, 2:16 am, Bruno Desthuilliers > [EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] a écrit : > > (snip) > > > > That reminds me:  Is there a generic 'relation' pattern/recipie, such > > > as finding a computer that's "paired" with multiple users

Re: List as FIFO in for loop

2008-03-08 Thread rockingred
On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): >     x = q.get() >     #process x to get zero or more y's >     #for each y: >    

del class with recursive list

2008-03-08 Thread duccio
Hello! Will someone have time to tell me why this code don't work as I expect? And what should I do to make the "del n" delete all the lower nodes? Thanks! class Node: def __init__(self): self.childs=[] def appendNode(self, n): self.childs.append(n) def __del__(s

Re: SQL problem in python

2008-03-08 Thread Carsten Haese
On Sat, 2008-03-08 at 10:11 -0800, Dennis Lee Bieber wrote: > On Sat, 8 Mar 2008 09:28:23 -0800 (PST), aiwarrior > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > Thanks a lot. > > In the Python documentation, the sqlite module documentation doesn't > > mention that special

Re: del class with recursive list

2008-03-08 Thread Peter Otten
duccio wrote: > Will someone have time to tell me why this code don't work as I expect? > And what should I do to make the "del n" delete all the lower nodes? > Thanks! > > class Node: > def __init__(self): > self.childs=[] > def appendNode(self, n): > self.childs.appe

Image Libraries

2008-03-08 Thread PB
I have been using PIL for generating images, however it does not easily support operations with transparency etc. I tried to install aggdraw but it wouldn't compile. Ideally I'd like something open source so I can adapt it, hopefully mostly written in python rather than C. Is there any other dec

Re: Can't get items out of a set?

2008-03-08 Thread Raymond Hettinger
> > > Is it possible to get an object out of a set() given another object > > > that has the same hash code and equality (__hash__() and __eq__() > > > return the same)? > > > Yes, but it requires an indirect > > approach.http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/499299 > > > Raymond

Re: Converting a string to the most probable type

2008-03-08 Thread castironpi
On Mar 8, 12:05 pm, Pierre Quentel <[EMAIL PROTECTED]> wrote: > > >>> def convert(x): > > >         if '.' in x: > >                 try: return float(x) > >                 except ValueError: return x > >         else: > >                 try: return int(x) > >                 except: return x > >

Intra-Package References

2008-03-08 Thread xkenneth
Does your python module have to exist in the path in order for intra- package references to work? Regards, Kenneth Miller -- http://mail.python.org/mailman/listinfo/python-list

Re: Python CGI & Webpage with an Image

2008-03-08 Thread rodmc
> Is the cgi script in the same directory? The user's browser looks > for the jpg relative to the URL it used to get the page, which in > the case of the CGI script is the path to the script, not the > path to the html file. No the CGI script is in a different folder, I could move everything to

Re: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Does one side of this hold that there are no -good- comments? I wouldn't say there are _no_ good comments, but I would say that 90+% of the comments I've seen in my lifetime were bad. Most of them were bad to the extent that anybody ne

identifying and parsing string in text file

2008-03-08 Thread [EMAIL PROTECTED]
I have a large file that has many lines like this, SITE I would like to identify the line by the tag (300a,0014) and then grab the name (DoseReferenceStructureType) and value (SITE). I would like to create a file that would have the structure, DoseReferenceStructureType = Site ...

Re: SQL problem in python

2008-03-08 Thread petr . jakes . tpc
Maybe you should try SQLObject :-) from sqlobject import * from sqlobject.sqlbuilder import Select #from sqlobject.sqlbuilder import * from datetime import datetime # === sqlite == #connection = connectionForURI('sqlite:///dev/shm/ourdata.db') connection = conne

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

Re: identifying and parsing string in text file

2008-03-08 Thread Bernard
Hey Brian, It seems the text you are trying to parse is similar to XML/HTML. So I'd use BeautifulSoup[1] if I were you :) here's a sample code for your scraping case: from BeautifulSoup import BeautifulSoup # assume the s variable has your text s = "whatever xml or html here" # turn it into a

Re: identifying and parsing string in text file

2008-03-08 Thread Nemesis
[EMAIL PROTECTED] wrote: > I have a large file that has many lines like this, > > name="DoseReferenceStructureType">SITE > > I would like to identify the line by the tag (300a,0014) and then grab > the name (DoseReferenceStructureType) and value (SITE). > > I would like to create a file that woul

SV: Regarding coding style

2008-03-08 Thread K Viltersten
> What I really can't stand are the > pointy-haired comment blocks at the > beginnings of C/C++ functions that do > things like tell you the name and return > type of the function and list the names > and types of the parameters. Gee, thanks. > I never could have figured that out from > looki

Adjust a canvas as the window is resized

2008-03-08 Thread K Viltersten
Do i need to set a callback to a canvas in order to "listen" to the root window being resized in order to make it adjust its contents? If so, how? If not, how do i make the canvas draw a line from one corner to an other? from Tkinter import * class Demo(Frame): def __init__(self, master =

Re: Regarding coding style

2008-03-08 Thread castironpi
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-03-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Does one side of this hold that there are no -good- comments? > > I wouldn't say there are _no_ good comments, but I would say > that 90+% of the comments I've seen in my

Re: for-else

2008-03-08 Thread castironpi
> The idea of the if-else is: > .  depending on some condition either do this or do something else, > .  don't do them both. yes = the loop completed. 'else' isn't rechecking a piece of the loop, it's checking the loop. Does it test successfully--- not the loop condition, the loop? What is 'if a

Re: Can't get items out of a set?

2008-03-08 Thread castironpi
> something something equivalence class. > The intern() builtin uses this approach: > >    interned = {} >    def intern(s): >         if s in interned: >             return interned[s] >         interned[s] = s >         return s If you've seen it before, and have the old one, return the old one

Re: List as FIFO in for loop

2008-03-08 Thread castironpi
> Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an implementation that would > crash, erase your hard disk, or set you

Re: distutils - Is is possible to install without the .py extensions

2008-03-08 Thread Robert Kern
Jari Aalto wrote: > * Fri 2008-03-07 Robert Kern <[EMAIL PROTECTED]> gmane.comp.python.general > * Message-Id: [EMAIL PROTECTED] > > setup(name='program', >>> ... > scripts = ['program,py'], > ) > that the the result is: > > /usr/bin/program > >>

Re: for-else

2008-03-08 Thread Terry Reedy
"egbert" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | However the loop-else really works more like this: | . try to do the loop; | . if it starts but is interrupted by a break, | . then do something else as well. This is NOT how loop-else works for Python. If you want to do s

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 1:31 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: LOL. Thanks for the laughs. I share your frustration. -- http://mail.python.org/mailman/listinfo/python-list

Re: Regarding coding style

2008-03-08 Thread dave_mikesell
On Mar 8, 2:27 pm, [EMAIL PROTECTED] wrote: > Good comments are better than bad names. > Good names are better than bad comments. If you're taking the time to write good comments, why not just fix the bad names? The compiler/interpreter can never, ever catch bad comments. -- http://mail.python

Re: SV: Regarding coding style

2008-03-08 Thread Grant Edwards
On 2008-03-08, K Viltersten <[EMAIL PROTECTED]> wrote: >> What I really can't stand are the pointy-haired comment blocks >> at the beginnings of C/C++ functions that do things like tell >> you the name and return type of the function and list the >> names and types of the parameters. Gee, thanks.

Re: identifying and parsing string in text file

2008-03-08 Thread Paul McGuire
On Mar 8, 2:02 pm, Nemesis <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I have a large file that has many lines like this, > > > > name="DoseReferenceStructureType">SITE > > > I would like to identify the line by the tag (300a,0014) and then grab > > the name (DoseReferenceStructureTy

off topic: 2 videos on source control and open source development

2008-03-08 Thread Aaron Watters
I just wanted to send out links to 2 informative videos regarding open source and change control systems. The first is Linus Torvalds on git and how it contrasts with subversion and other approaches (where he says some nice things about Mercurial, btw). http://www.youtube.com/watch?v=4XpnKHJAok8

Parse specific text in email body to CSV file

2008-03-08 Thread dpw . asdf
I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to incorporate into a database or CSV file. I want to search the email for specific text. The emails ba

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 4:44 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: ... > Notice that the language specification *deliberately* does not > distinguish between deletion of earlier and later items, but > makes modification of the sequence undefined behavior to allow > alternative implementations. E.g. an

Re: extract multiple ranges from a list

2008-03-08 Thread pi . arctan
On 8 Mar, 17:32, Peter Otten <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > One of my many project involves working with YUV-files, where I need > > to reduce > > the vertical resolution with a factor of two, i.e. remove every other > > scan line. > > Today I'm using two for-loops in the

Fwd: [PyQt] Popen + poll & pid

2008-03-08 Thread Kevin
Hi, I sent the question below to the wrong list. I was wondering if someone here could help? Kevin Sent from my iPhone Begin forwarded message: From: Kevin <[EMAIL PROTECTED]> Date: March 8, 2008 11:53:39 AM PST To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> Subject: [PyQt] Popen + poll & pid

Re: List as FIFO in for loop

2008-03-08 Thread malkarouri
On Mar 8, 6:24 pm, rockingred <[EMAIL PROTECTED]> wrote: > I think it's a bad practice to get into.  Did you intend to do the > "process" step again over the added variables?  If not I would set a > new variable, based on your awful naming convention, let's call it z. > Then use z.append(y) within

Re: List as FIFO in for loop

2008-03-08 Thread Carl Banks
On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I have an algorithm in which I need to use a loop over a queue on > which I push values within the loop, sort of: > > while not(q.empty()): > x = q.get() > #process x to get zero or more y's > #for each y: >

SV: SV: Regarding coding style

2008-03-08 Thread K Viltersten
> If you can't/don't look at the source file, > then comments aren't going to help (except > in the case of something like docstrings in > Python). I strongly disagree. Now, perhaps we're talking about different things, here? Usually, in the header file (C++), there won't be any source code, e

Re: SV: Quit-command not quiting

2008-03-08 Thread Gabriel Genellina
En Fri, 07 Mar 2008 13:56:45 -0200, K Viltersten <[EMAIL PROTECTED]> escribi�: >>> The window itself vanishes if i click the >>> cross in the upper-right corner but pressing >>> the quit-button only makes it "pressed". >>> Then, the program freezes. >> >> How did you run it? From inside IDLE? ID

Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Alasdair
I need to apply the ceiling function to arbitrary sized (long) integers. However, division automatically returns the type of its operands, so that, for example: math.ceil(7/4) returns 1. I can use float, as in: math.ceil(7/float(4)), except that for very large integers float causes an unacceptabl

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Paul Rubin
Alasdair <[EMAIL PROTECTED]> writes: > What is the best way of finding a ceiling of a quotient of arbitrary sized > integers? ceiling(a/b) = (a+b-1)//b -- http://mail.python.org/mailman/listinfo/python-list

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Robert Kern
Alasdair wrote: > I need to apply the ceiling function to arbitrary sized (long) integers. > However, division automatically returns the type of its operands, so that, > for example: math.ceil(7/4) returns 1. I can use float, as in: > math.ceil(7/float(4)), except that for very large integers flo

Re: SV: SV: Regarding coding style

2008-03-08 Thread Ben C
On 2008-03-08, K Viltersten <[EMAIL PROTECTED]> wrote: >> If you can't/don't look at the source file, >> then comments aren't going to help (except >> in the case of something like docstrings in >> Python). > > I strongly disagree. Now, perhaps we're > talking about different things, here? > Us

Re: float / rounding question

2008-03-08 Thread Roel Schroeven
Mark Dickinson schreef: > On Mar 7, 11:23 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: >>> Sorry to come in so late in this discussion. Although it is correct to >>> say that many real numbers that have an exact d

Green's Function

2008-03-08 Thread olusina eric
Hi All, I am new to Python and trying to solve the Hamiltonian of a linear chair of atoms using green’s function. Does anyone know any pre-existing library functions and literature that could be helpful? Thanks EOF - Looking for last minute shopp

Re: List as FIFO in for loop

2008-03-08 Thread Paul Hankin
On Mar 8, 10:42 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Mar 8, 9:43 am, malkarouri <[EMAIL PROTECTED]> wrote: > > > Hi everyone, > > > I have an algorithm in which I need to use a loop over a queue on > > which I push values within the loop, sort of: > > > while not(q.empty()): > >     x = q

Re: What is a class?

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 09:52:41 -0800, castironpi wrote: > On Mar 7, 6:16 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Thu, 06 Mar 2008 08:40:47 -0800, castironpi wrote: >> > you >> > could say exec( open( 'modA.py' ).read() ) ==> import modA >> >> Yes, you could say that

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 19:31:47 +, Grant Edwards wrote: > I'm also a bit baffled by people who put a comment at the top of every > file that tells you what the filename is. [snip rant] You've never printed out a source file on pieces of dead tree to read on the train on the way home, or in bed

Re: SV: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 21:21:48 +0100, K Viltersten wrote: > Coming from C++/Java camp i can't help noticing that in most cases, when > i'm using a class written by somebody else, i don't want to see his/her > code. I only want to know WHAT the function does (is intended to be > doing, at least). >

SV: SV: Quit-command not quiting

2008-03-08 Thread K Viltersten
"Gabriel Genellina" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > En Fri, 07 Mar 2008 13:56:45 -0200, K Viltersten <[EMAIL PROTECTED]> > escribi�: > The window itself vanishes if i click the cross in the upper-right corner but pressing the quit-button only makes

Re: Regarding coding style

2008-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2008 13:40:56 -0800, dave_mikesell wrote: > On Mar 8, 2:27 pm, [EMAIL PROTECTED] wrote: > >> Good comments are better than bad names. Good names are better than bad >> comments. > > If you're taking the time to write good comments, why not just fix the > bad names? The compiler/i

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
On Mar 8, 6:26 pm, Paul Rubin wrote: > Alasdair <[EMAIL PROTECTED]> writes: > > What is the best way of finding a ceiling of a quotient of arbitrary sized > > integers? > > ceiling(a/b) = (a+b-1)//b I prefer: ceiling(a/b) = -(-a)//b which also works if a and b are some

  1   2   >