[Tutor] what does %25f mean?

2005-10-24 Thread Shi Mu
what does %25f mean? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] what does %25f mean?

2005-10-24 Thread Pujo Aji
it will reserve the 25 space for your number. example:     print '%25.2f' % (1.222,)   It will use 25 space and 2 digit of your 1.222result is: 1.22   cheers, pujo  On 10/24/05, Shi Mu <[EMAIL PROTECTED]> wrote: what does %25f mean?_

[Tutor] dictionary

2005-10-24 Thread Shi Mu
I typed: landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} and when i checked landUse, I found it become: {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} why the order is changed? ___ Tutor maillist - Tutor@python.org http://mail.python

Re: [Tutor] dictionary

2005-10-24 Thread Pujo Aji
you work with dictionary. In dictionary you work with the key to get your value. You don't care about how python arrange the key. your key here are: 'res', 'com', 'ind', and  'other' when you want to get your value you just type: landUse['res'] this you will get 1 landUse['ind'] this you will get 3

Re: [Tutor] dictionary

2005-10-24 Thread Jan Erik Moström
Shi Mu <[EMAIL PROTECTED]> 2005-10-24 09:13: > why the order is changed? By definition a dictionary has no order. jem -- Jan Erik Moström, www.mostrom.pp.se ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinf

Re: [Tutor] dictionary

2005-10-24 Thread Sean Perry
Shi Mu wrote: > I typed: > landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} > and when i checked landUse, I found it become: > {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} > why the order is changed? the docs warn you about this. A dictionary stores its values based on the ke

Re: [Tutor] Modify to Print All Results After Sort

2005-10-24 Thread Alan
Dear Python's Gurus I have this nice over-my-head scripts 1. It loads two files (daifmaster.txt and sahihmaster.txt) HELP ONE Please I NEED to print these unified two sorted files as one = call it dsmaster.txt 2. It load file (Kanzmaster.txt) and sort it HELP TWO Please I need to print this sor

[Tutor] string

2005-10-24 Thread Shi Mu
what does the following sentence mean? does it mean i can not use double-quoted string? SyntaxError: EOL while scanning single-quoted string ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] string

2005-10-24 Thread Pujo Aji
please show us the code   cheers, pujo  On 10/24/05, Shi Mu <[EMAIL PROTECTED]> wrote: what does the following sentence mean? does it mean i can not usedouble-quoted string?SyntaxError: EOL while scanning single-quoted string ___Tutor maillist  -  Tut

[Tutor] neat join

2005-10-24 Thread Vincent Gulinao
is there any simple syntax for joining strings such that if any (or all) of the params is white space or None, it won't be included in the resulting string? e.g. str1, str2, str3 = "foo", "bar", None, if delimiter is " " would result to "foo bar"; str1, str2 = None, None would result to None. TIA

Re: [Tutor] neat join

2005-10-24 Thread Kent Johnson
Vincent Gulinao wrote: > is there any simple syntax for joining strings such that if any (or all) > of the params is white space or None, it won't be included in the > resulting string? > > e.g. str1, str2, str3 = "foo", "bar", None, if delimiter is " " would > result to "foo bar"; str1, str2 =

[Tutor] about FIND

2005-10-24 Thread Shi Mu
I got confused by the following information from the help for "FIND": find(s, *args) find(s, sub [,start [,end]]) -> in what does *args mean (especially the '*')? also, in the sub, why put a comma before start? what does 'in' mean? ___ Tutor maillist

Re: [Tutor] Modify to Print All Results After Sort (Alan) Or Self Inflected - When runs in MS active python the output is no good

2005-10-24 Thread Alan
I did this and it worked 1. However will be nice to print output into filenames without me using > 2. Another problem: when run in Linux the output is OK BUT when runs in windows active python the output is no good # modify1: PRINT THE ABOVE CALL IT SORTEDkanz.TXT I commented the last lines in th

[Tutor] about \

2005-10-24 Thread Shi Mu
Is there any difference if I remove the '/' from the following statement? intMatrix2 = [[1,1,2,4,1,7,1,7,6,9],\ [1,2,5,3,9,1,1,1,9,1],\ [0,0,5,1,1,1,9,7,7,7]] print intMatrix2 I removed one '\' and it still works. So what is the use of '\'?

Re: [Tutor] about \

2005-10-24 Thread Kent Johnson
Please don't duplicate post to python-tutor and comp.lang.python. You are getting two sets of answers to all your questions which wastes the time of those kind enough to reply. Thanks, Kent Shi Mu wrote: > Is there any difference if I remove the '/' > from the following statement? > intMatrix2

[Tutor] manipulating list of lists

2005-10-24 Thread Vincent Gulinao
I have a list of lists of constant width (2 rows). I need to: 1. delete sub-lists with None element 2. sort it by any sub-list index say: [ ['c','d'], ['g',None], ['a','b',], ['e','f'] if sorted using 2nd index: [ ['a','b'], ['c','d'], ['e','f'] ] (same result for 1st index for this example) TIA

Re: [Tutor] : Threads?

2005-10-24 Thread Hugo González Monteverde
I have done scripts for decompressing MP3 in the past. I normally follow a fork() exec() subprocess scheme, and this helps me gain about 30% improvement. I'm not an expert, but I have read that CPU time will be better used by several processes than for just one, and while one process is waiting

Re: [Tutor] Time - sum/difference

2005-10-24 Thread Hugo González Monteverde
What I usually do is convert them all to UNIX epoch and then substact the values in seconds: >>> import time >>> early = time.time() >>> sleep(5) >>> time.sleep(5) >>> late = time.time() >>> print late - early 5.7889997959 >>> Jonas Melian wrote: > I would get the local time of a country

Re: [Tutor] : Threads?

2005-10-24 Thread Kent Johnson
Hugo González Monteverde wrote: > I have done scripts for decompressing MP3 in the past. I normally follow > a fork() exec() subprocess scheme, and this helps me gain about 30% > improvement. I'm not an expert, but I have read that CPU time will be > better used by several processes than for jus

Re: [Tutor] about \

2005-10-24 Thread Hugo González Monteverde
Hi, The '\' character is used to break lines and ask the interpreter to treat them as a single line, but Python is smart enough to allow breaking lines inside parenthesis and braces...so: NOT WORKING: >>> a, e, i, o, u = 1, 2, Traceback (most recent call last): File "", line 1, in ? ValueE

Re: [Tutor] Time - sum/difference

2005-10-24 Thread Jonas Melian
Anyway, I found a library for working with time zones http://pytz.sourceforge.net/ Hugo González Monteverde wrote: > What I usually do is convert them all to UNIX epoch and then substact > the values in seconds: > > >>> import time > >>> early = time.time() > >>> sleep(5) > >>> time.sleep(5) > >

Re: [Tutor] define vars by iteration

2005-10-24 Thread Luke Jordan
Thanks for this insight into classes. It often takes me a few days to absorb and respond because my job limits the time I can give to programming. But thanks again for taking the time to respond in a meaningful way.   I guess I could say that you changed my world when it comes to programming (sorr

[Tutor] help

2005-10-24 Thread Shi Mu
I got confused by the following information from the help for "FIND": find(s, *args) find(s, sub [,start [,end]]) -> in what does *args mean (especially the '*')? also, in the sub, why put a comma before start? what does 'in' mean? ___ Tutor maillis

Re: [Tutor] what does %25f mean?

2005-10-24 Thread Danny Yoo
On Mon, 24 Oct 2005, Shi Mu wrote: > what does %25f mean? Hi Shi Mu, Without more context, I'd have to guess that this looks like a format string. Here's more information about them: http://www.python.org/doc/lib/typesseq-strings.html But can you show us where you saw this "%25f" thing

[Tutor] problem with class overloading (maybe it's just me)

2005-10-24 Thread Matt Richardson
Hi all, I've started the wxPython tutorials and have hit a problem already. When run from IDLE or by calling the script from the command line with [EMAIL PROTECTED]:~/wxpy$ python helloWorld.py the script works fine, generating a small text editor. Making the file executable and including the

Re: [Tutor] dictionary

2005-10-24 Thread Danny Yoo
> > I typed: > > landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} > > and when i checked landUse, I found it become: > > {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} > > why the order is changed? > > the docs warn you about this. Hi Shi, By the way, here's a post from a lon

Re: [Tutor] problem with class overloading (maybe it's just me)

2005-10-24 Thread Danny Yoo
> this one fails: > [EMAIL PROTECTED]:~/wxpy$ cat helloWorld.py > > #!/usr/bin/python Hi Matt, Ah, good for showing that cat command: it gave enough hints that we can tell what's going on. Take out the leading empty space in your file; it's interfering with the magic line '#!/usr/bin/python'.

Re: [Tutor] help

2005-10-24 Thread Michael Janssen
On 10/24/05, Shi Mu <[EMAIL PROTECTED]> wrote: > I got confused by the following information from the help for "FIND": > find(s, *args) > find(s, sub [,start [,end]]) -> in Hello Shi Mu, this is the help for the function find in the string module, which is slightly out of date. Better you use

Re: [Tutor] problem with class overloading (maybe it's just me)

2005-10-24 Thread Matt Richardson
Danny Yoo wrote: > Hope this helps! Helped a lot. Shows that syntax errors aren't always visible (like whitespace) and that I should know better than to attempt anything before having at least one cup of coffee. Thanks! Matt -- Matt Richardson IT Consultant College of Arts and Letters CSU S

[Tutor] py in a nut

2005-10-24 Thread carl.badgley
Hope this is not too off topic: I noticed that the Python in a Nutshell book is version 2.2 and a few years old.  Does anyone know if there are plans to bring out a new edition anytime soon?  I checked the O'reilly page and didnt find anything, also googled it. If anyone knows anything let me know.

Re: [Tutor] Help(!) with OOP/Composition from "Learning Python"

2005-10-24 Thread CPIM Ronin
I've been reading about composition vs inheritance, and went back to "Learning Python" to look at something I found very confusing a year ago. Turns out I still find it very confusing :) Try this example ecology simulation by Kirby Urner: http://mail.python.org/pipermail/edu-sig/2000-April/000

Re: [Tutor] py in a nut

2005-10-24 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hope this is not too off topic: > I noticed that the Python in a Nutshell book is version 2.2 and a few > years old. Does anyone know if there are plans to bring out a new > edition anytime soon? I checked the O'reilly page and didnt find > anything, also googled it.

Re: [Tutor] dictionary

2005-10-24 Thread Alan Gauld
> A dictionary stores its values based on the keys. Internally Python > sorts the keys to make the lookup meet performance expectations. > > You can not expect a dictionary to return keys in the other you added > them. If you want that, store the items as tuples in a list. Or you can sort the k

Re: [Tutor] string

2005-10-24 Thread Alan Gauld
> what does the following sentence mean? does it mean i can not use > double-quoted string? > SyntaxError: EOL while scanning single-quoted string No, it means you didn't correctly terminate the string with a matching quote. The error is slightly ambiguous, the word 'single' here means there is o

Re: [Tutor] about FIND

2005-10-24 Thread Alan Gauld
> find(s, sub [,start [,end]]) -> in > > what does *args mean (especially the '*')? *args means that a variable number of arguments can be provided. The exact nature of those being described in the next line. So: find =(s,sub) find(s,sub,start) find(s,sub,start,stop) are all valid > also, in t

Re: [Tutor] about \

2005-10-24 Thread Alan Gauld
> Is there any difference if I remove the '/' You mean the '\' I assume? In this case no difference whatsoever because Python will keep on looking for the matching closing ']' > intMatrix2 = [[1,1,2,4,1,7,1,7,6,9],\ > [1,2,5,3,9,1,1,1,9,1],\ > [0,0,5,1,1,1,9,7,7,7]] >

Re: [Tutor] Time - sum/difference

2005-10-24 Thread Alan Gauld
> Anyway, I found a library for working with time zones > http://pytz.sourceforge.net/ Thanks for pointing this one out, it looks good. As someone who once commisioned a research paper on Time Zones and programming I must say this looks like one of the most complete timezone sites around. Howeve

Re: [Tutor] py in a nut

2005-10-24 Thread Alan Gauld
> I noticed that the Python in a Nutshell book is version 2.2 and a few > years > old. Does anyone know if there are plans to bring out a new edition Disclaimer: I know nothing of O'Reilly or Alex Martelli's plans! But from experience of my own book it takes a good year to 18 months to do a full

Re: [Tutor] pytunes (Was __slots__, struct, etc.)

2005-10-24 Thread John Fouhy
For all of them --- not guaranteed that you'll be able to achieve the optimum.. My solution is basically a greedy algorithm: Make a list of (artist, tracks) pairs, and sort descending by len(tracks). Then iteratively: 1. Take the next track from the first artist on the list. 2. Move that artist

[Tutor] Tkinter Data Passing Problem

2005-10-24 Thread mdcooper
Hi, I am having some trouble with tkinter. I am creating a filled set of entry boxes so that a user can adjust certain data if desired. I would prefer that the box containing these data be separate from the main GUI. The problem is that when I specify that the frame be part of root the data a

Re: [Tutor] Tkinter Data Passing Problem

2005-10-24 Thread John Fouhy
On 25/10/05, mdcooper <[EMAIL PROTECTED]> wrote: > The problem is that when I specify that the frame be part of root the data > appears in the entry boxes (using textvariable = StringVar()) but if a second > Tk() root is specified, the entry boxes appear, but there is no data. I cannot > figure out

[Tutor] testing for modules?

2005-10-24 Thread Ed Hotchkiss
i have a generic script that is using several modules on windows and linux boxes. i need to have the scripts test if a module is installed, and then if not - then to install the module. can anyone give me a headsup on how to test for a module, returning something to indicate whether or not it is in

Re: [Tutor] Tkinter Data Passing Problem

2005-10-24 Thread Alan Gauld
> The problem is that when I specify that the frame be part of root the data > appears in the entry boxes (using textvariable = StringVar()) but if a > second > Tk() root is specified, the entry boxes appear, but there is no data. I > cannot > figure out why. Create your new dialog as a child of

Re: [Tutor] testing for modules?

2005-10-24 Thread Kent Johnson
Ed Hotchkiss wrote: > i have a generic script that is using several modules on windows and > linux boxes. i need to have the scripts test if a module is installed, > and then if not - then to install the module. can anyone give me a > headsup on how to test for a module, returning something to i

Re: [Tutor] testing for modules?

2005-10-24 Thread Bill Burns
Ed Hotchkiss wrote: > i have a generic script that is using several modules on windows and > linux boxes. i need to have the scripts test if a module is installed, > and then if not - then to install the module. can anyone give me a > headsup on how to test for a module, returning something to i

Re: [Tutor] : Threads?

2005-10-24 Thread Orri Ganel
Not sure what IIUC stands for, but I am, indeed, running windows. XP Home Edition, in fact, with Python 2.4.2 finalOn 10/24/05, Kent Johnson < [EMAIL PROTECTED]> wrote:Hugo González Monteverde wrote:> I have done scripts for decompressing MP3 in the past. I normally follow > a fork() exec() subproc

Re: [Tutor] : Threads?

2005-10-24 Thread Kent Johnson
Orri Ganel wrote: > Not sure what IIUC stands for, but I am, indeed, running windows. XP > Home Edition, in fact, with Python 2.4.2 final If I Understand Correctly http://www.acronymfinder.com/ is helpful here. Kent ___ Tutor maillist - Tutor@python

Re: [Tutor] hand-holding for web development

2005-10-24 Thread Jay Loden
Sorry, didn't see your reply until now... the directory section can go either in your main apache config file (in my case, /etc/httpd/conf/httpd.conf ) OR in a separate file in the conf.d directory. In my case, I have a python.conf file in /etc/httpd/conf.d/ that contains the following: LoadM

Re: [Tutor] manipulating list of lists

2005-10-24 Thread Brian van den Broek
Vincent Gulinao said unto the world upon 2005-10-24 09:29: > I have a list of lists of constant width (2 rows). I need to: > 1. delete sub-lists with None element > 2. sort it by any sub-list index > > say: [ ['c','d'], ['g',None], ['a','b',], ['e','f'] > if sorted using 2nd index: [ ['a','b'], ['

Re: [Tutor] manipulating list of lists

2005-10-24 Thread John Fouhy
On 25/10/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > To sort by the second item, try > > >>> def sort_by_second(sequence): > decorated = [(x[1], x) for x in sequence] > decorated.sort() > return [x[1] for x in decorated] With python2.4, you can use the key= argume

Re: [Tutor] manipulating list of lists

2005-10-24 Thread John Fouhy
On 25/10/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > To sort by the second item, try > > >>> def sort_by_second(sequence): > decorated = [(x[1], x) for x in sequence] > decorated.sort() > return [x[1] for x in decorated] With python2.4, you can use the key= argume

Re: [Tutor] manipulating list of lists

2005-10-24 Thread Brian van den Broek
John Fouhy said unto the world upon 2005-10-24 22:18: > On 25/10/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > >>To sort by the second item, try >> >> >>> def sort_by_second(sequence): >>decorated = [(x[1], x) for x in sequence] >>decorated.sort() >>return [x[1] for

[Tutor] Matrix

2005-10-24 Thread Shi Mu
I can not understand the use of "cell in row" for two times in the code: # convert the matrix to a 1D list matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] items = [cell for row in matrix for cell in row] print items ___ Tutor maillist - Tutor@python.o