[Tutor] references to containing objects

2008-06-22 Thread John Gunderman
I am looking for a way to tell a object the properties of its containing object. For example, I have an object foo, of class Bar, which I have stored in a dict in the object I want to access. Basically: container_object.contained_object["foo"].action() What I want is for the object "foo" to be ab

Re: [Tutor] endless processing through for loop

2008-06-22 Thread John Fouhy
On 23/06/2008, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > I have a program with 2 for loops like this (in pseudocode): > > fw = open(newLine.txt, 'w') > for i in xrange(0, 700,000, 1): > read a file fname from folder > for line in open(fname, 'r'): > do some simple string processi

Re: [Tutor] endless processing through for loop

2008-06-22 Thread Dinesh B Vadhia
There is no thrashing of disk as I have > 2gb RAM and I'm not keeping the file contents in memory. One line is read at a time, some simple string processing and then writing out the modified line. From: Kent Johnson Sent: Sunday, June 22, 2008 5:39 PM To: Dinesh B Vadhia Cc: tutor@python.or

Re: [Tutor] endless processing through for loop

2008-06-22 Thread Kent Johnson
On Sun, Jun 22, 2008 at 8:13 PM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > That's it. Very simple but after i reaches about 550,000 the program begins > to crawl. As an example, the loops to 550,000 takes about an hour. From > 550,000 to 580,000 takes an additional 4 hours. > > Any ideas abou

Re: [Tutor] endless processing through for loop

2008-06-22 Thread Alan Gauld
"Dinesh B Vadhia" <[EMAIL PROTECTED]> wrote fw = open(newLine.txt, 'w') for i in xrange(0, 700,000, 1): read a file fname from folder for line in open(fname, 'r'): do some simple string processing on line fw.write(newline) fw.close() From 550,000 to 580,000 takes an addi

[Tutor] endless processing through for loop

2008-06-22 Thread Dinesh B Vadhia
I have a program with 2 for loops like this (in pseudocode): fw = open(newLine.txt, 'w') for i in xrange(0, 700,000, 1): read a file fname from folder for line in open(fname, 'r'): do some simple string processing on line fw.write(newline) fw.close() That's it. Very simpl

Re: [Tutor] dollarize.py

2008-06-22 Thread Martin Walsh
Jordan Greenberg wrote: > def addcommas(s): # assumes type(s)==str > b=[] > l=len(s) > for i,v in enumerate(s): > i+=1 # easier to understand w/ 1-based indexing, i think. > b.append(v) > > if (l-i)%3==0 and not i==l: > b.append(',') > return ''.

Re: [Tutor] Is this the right way to create a

2008-06-22 Thread Kent Johnson
On Sun, Jun 22, 2008 at 3:50 PM, Zameer Manji <[EMAIL PROTECTED]> wrote: > I'm quite new to OOP, so forgive me if I am missing something obvious. > When you say that the User class should have a UserProfile as an > attribute, would it look something like this? > > from lastfmapi import UserProfile

[Tutor] A SAPI Module With Pitch and Create

2008-06-22 Thread FT
Hi! I have reduced down and added a few features into the SAPI 5 speech module I have created. You can now save and read wav files. The test module tests most of the features I have in it at the moment. I added the ability inside the Create method to set all the voice parameters. Yo

Re: [Tutor] Is this the right way to create a

2008-06-22 Thread Zameer Manji
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Kent Johnson wrote: > A User class that has a UserProfile as an attribute, and accessors for > Neighbors, etc, sounds good to me. You may want an Artist class, > probably not a Top Artists class. The User.getTopArtists() method > would access the web

[Tutor] [Fwd: Re: From Newbie]

2008-06-22 Thread Marilyn Davis
On Sun, June 22, 2008 7:55 am, [EMAIL PROTECTED] wrote: > hi Danny, > > > As far as i am aware you must declare your variable first, something like > a=0 That's a good thought. But he did initialize his variable. The '!' and the '=' in '!=' are all smashed together without spaces. So: > whil

Re: [Tutor] From Newbie

2008-06-22 Thread paul
hi Danny,As far as i am aware you must declare your variable first, something like a=0The same would go for shope that helpspaulOn Sun Jun 22 10:45 , Danny Laya sent:Hi ! I have learned wiki tutor for non-programmer and I found some hill that stopping me. InĀ  Non-Programmer's Tutorial for Python/C

Re: [Tutor] From Newbie

2008-06-22 Thread Danny Laya
Few... Thanks all, i have found the wrong, i miss some space between != and 0. Thank's for the help. I really apreciate it ! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] From Newbie

2008-06-22 Thread bhaaluu
On Sun, Jun 22, 2008 at 6:45 AM, Danny Laya <[EMAIL PROTECTED]> wrote: > Hi ! I have learned wiki tutor for non-programmer and I found some hill that > stopping me. In Non-Programmer's Tutorial for Python/Count to 10, wiki ask > me to write this code : > > a = 1 > s = 0 > print 'Enter Numbers to a

Re: [Tutor] From Newbie

2008-06-22 Thread broek
But when i write while a != 0: and then i press enter, python terminal tell me : while a ! = 0: File "", line 1 while a ! = 0: ^ SyntaxError: invalid syntax Can you find my mistake, guys ? Sorry to bother you, I try to Hi, Python's trying to give you a hint: while

[Tutor] From Newbie

2008-06-22 Thread Danny Laya
Hi ! I have learned wiki tutor for non-programmer and I found some hill that stopping me. In Non-Programmer's Tutorial for Python/Count to 10, wiki ask me to write this code : a = 1 s = 0 print 'Enter Numbers to add to the sum.' print 'Enter 0 to quit.' while a != 0: print 'Current Sum:', s

Re: [Tutor] Is this the right way to create a

2008-06-22 Thread Kent Johnson
On Sun, Jun 22, 2008 at 12:00 AM, Zameer Manji <[EMAIL PROTECTED]> wrote: > I'm trying to create a library for the Last.fm webservice[1] and the > first thing I created was a class for the Profile Information.[2] Is > this the proper way of creating it? Is this useful to another programmer? > > imp

Re: [Tutor] Is this the right way to create a

2008-06-22 Thread Kent Johnson
On Sun, Jun 22, 2008 at 4:03 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > Web services are usually procedural in nature so that you don't > need to create classes at all. So to provbide maximum flexibility > you might be better just creating a module that exposes the > services as functions. The us

Re: [Tutor] Is this the right way to create a

2008-06-22 Thread Alan Gauld
"Zameer Manji" <[EMAIL PROTECTED]> wrote Also, how do I then begin to approach the whole API ? Do I create a User class the inherits from the UserProfile class and other classes for their Neighbours', Top Artists, etc ? I don;t know enough about the underlying service to answer that but...

Re: [Tutor] Tkinter on OS X

2008-06-22 Thread Alan Gauld
"Kent Johnson" <[EMAIL PROTECTED]> wrote I'm pretty sure that page is out-of-date, Tkinter does not require X11, it is integrated with Aqua. This is true, as a recent posting confirmed re the limitations of colouring buttons under Aqua. But... Tkinter has a reputation as quick and ugly. Th