Re: iterating initalizations

2008-12-23 Thread D'Arcy J.M. Cain
On Mon, 22 Dec 2008 22:32:17 -0500 Aaron Stepp stepp.aa...@gmail.com wrote: Instead of writing a long list of initializations like so: A = [ ] B = [ ] ... Y = [ ] Z = [ ] I'd like to save space by more elegantly turning this into a loop. If Well, if all you want is a loop: for

Re: iterating initalizations

2008-12-23 Thread Steve Holden
D'Arcy J.M. Cain wrote: On Mon, 22 Dec 2008 22:32:17 -0500 Aaron Stepp stepp.aa...@gmail.com wrote: Instead of writing a long list of initializations like so: A = [ ] B = [ ] ... Y = [ ] Z = [ ] I'd like to save space by more elegantly turning this into a loop. If Well, if all you

Re: iterating initalizations

2008-12-23 Thread Aaron Stepp
import random from rtcmix import * from chimes_source import * # Chime.play() from rhythmblock import * # rhythmBlock.rhythmTwist() and rhythmBlock.printStuff() from pitchblock import * # pitchBlock.pitchTwist() and pitchBlock.printStuff() from lenEval import * #greaterThan.sovler()

Re: iterating initalizations

2008-12-23 Thread D'Arcy J.M. Cain
On Tue, 23 Dec 2008 10:20:59 -0500 Steve Holden st...@holdenweb.com wrote: D'Arcy J.M. Cain wrote: Well, if all you want is a loop: for v in vars: locals()[v] = [] Note that this isn't guaranteed to work. While locals() will return a dict containing the names and values

Re: iterating initalizations

2008-12-23 Thread Steve Holden
D'Arcy J.M. Cain wrote: On Tue, 23 Dec 2008 10:20:59 -0500 Steve Holden st...@holdenweb.com wrote: D'Arcy J.M. Cain wrote: Well, if all you want is a loop: for v in vars: locals()[v] = [] Note that this isn't guaranteed to work. While locals() will return a dict containing

Re: iterating initalizations

2008-12-23 Thread Rhodri James
On Tue, 23 Dec 2008 15:39:52 -, Aaron Stepp stepp.aa...@gmail.com wrote: import random from rtcmix import * from chimes_source import * # Chime.play() from rhythmblock import * # rhythmBlock.rhythmTwist() and rhythmBlock.printStuff() from pitchblock import * # pitchBlock.pitchTwist()

iterating initalizations

2008-12-22 Thread Aaron Stepp
Hi all: I'm new to python and trying to save time and code by iterating through list initializations as well as the assignments. I have the following code: import random from rtcmix import * from chimes_source import * from rhythmblock import * from pitchblock import * indexrand =

Re: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 2:22 PM, Aaron Stepp stepp.aa...@gmail.com wrote: Hi all: I'm new to python and trying to save time and code by iterating through list initializations as well as the assignments. I have the following code: import random from rtcmix import * from chimes_source

Re: iterating initalizations

2008-12-22 Thread bearophileHUGS
Chris Rebert: It likely goes without saying, but you ought to read the fine tutorial as well. I also suggest to fix the messed up indentations. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: iterating initalizations

2008-12-22 Thread r
I can't check you code because i don't have these modules but here is the code with proper indention import random from rtcmix import * from chimes_source import * from rhythmblock import * from pitchblock import * indexrand = random.Random() indexrand.seed(2) rhythm = rhythmBlock() pitch =

Re: iterating initalizations

2008-12-22 Thread r
I can't check you code because i don't have these modules but here is the code with proper indention import random from rtcmix import * from chimes_source import * from rhythmblock import * from pitchblock import * indexrand = random.Random() indexrand.seed(2) rhythm = rhythmBlock() pitch =

Re: iterating initalizations

2008-12-22 Thread Aaron Stepp
On Dec 22, 2008, at 10:15 PM, r wrote: I can't check you code because i don't have these modules but here is the code with proper indention import random from rtcmix import * from chimes_source import * from rhythmblock import * from pitchblock import * indexrand = random.Random()

Re: iterating initalizations

2008-12-22 Thread r
class test(): def __init__(self, name): self.name = 'My name is %d' %name l = [] for name in range(10): l.append(test(name)) l [__main__.test instance at 0x02852E18, __main__.test instance at 0x02852C38, __main__.test instance at 0x028528A0, __main__.test

Re: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp stepp.aa...@gmail.com wrote: snip Thanks for the help so far, I think I'm starting to get a hang of the syntax. I think I need to state my goal more clearly. Instead of writing a long list of initializations like so: A = [ ] B = [ ] ... Y =

Re: iterating initalizations

2008-12-22 Thread Aaron Stepp
On Dec 22, 2008, at 10:43 PM, Chris Rebert wrote: On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp stepp.aa...@gmail.com wrote: snip Thanks for the help so far, I think I'm starting to get a hang of the syntax. I think I need to state my goal more clearly. Instead of writing a long list of

Re: iterating initalizations

2008-12-22 Thread Rhodri James
On Tue, 23 Dec 2008 03:52:35 -, Aaron Stepp stepp.aa...@gmail.com wrote: Simply put, I just need enough arrays to hold a list of pitches/rhythms. Then I'll have each list member returned to an instrument defined in another module. One array can hold a list of pitches/rhythms. I'm

Re: iterating initalizations

2008-12-22 Thread Chris Rebert
On Mon, Dec 22, 2008 at 7:52 PM, Aaron Stepp stepp.aa...@gmail.com wrote: On Dec 22, 2008, at 10:43 PM, Chris Rebert wrote: On Mon, Dec 22, 2008 at 7:32 PM, Aaron Stepp stepp.aa...@gmail.com wrote: snip Thanks for the help so far, I think I'm starting to get a hang of the syntax. I