Re: [Tutor] objects becoming pointers

2009-07-16 Thread Dave Angel
chris Hynes wrote: That's just it, you won't know in advance what names the user will type in. Maybe I mean to say dynamically create pointers. For instance, In the morning, I might be working with data regarding methanol and do several iterations and save those iterations in separate arrays wi

Re: [Tutor] objects becoming pointers

2009-07-16 Thread chris Hynes
need to. Thanks for your help. > To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Thu, 16 Jul 2009 19:25:51 +0100 > Subject: Re: [Tutor] objects becoming pointers > > > "chris Hynes" wrote > > > I want the user to input a name, say "Chris

Re: [Tutor] objects becoming pointers

2009-07-16 Thread Alan Gauld
"chris Hynes" wrote I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) so that when I type: print Chris This is a common misapprehension by beginners. But let me ask you something. Since you will be writing your

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Kent Johnson
> chris Hynes wrote: >> >> Ah, there you go, that's what I want to do, dynamically create variable >> names. Then I could interactively create as many arrays as I want to, say >> Chris1, Chris2, Chris3 and each of these would be different array with >> different results. >> >> But based on what you

Re: [Tutor] objects becoming pointers

2009-07-15 Thread bob gailer
Please always reply-all so a copy goes to the list. chris Hynes wrote: Ah, there you go, that's what I want to do, dynamically create variable names. Then I could interactively create as many arrays as I want to, say Chris1, Chris2, Chris3 and each of these would be different array with differ

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Kent Johnson
On Wed, Jul 15, 2009 at 11:19 AM, chris Hynes wrote: > I guess I have to start somewhere to ask > > I want the user to input a name, say "Chris". I know I can use the code: > > name=raw_input() > > I now want: > > "Chris"=zeros((3,3)) > > so that when I type: > > print Chris > > the ret

Re: [Tutor] objects becoming pointers

2009-07-15 Thread vince spicer
not sure exactly why you would want to that, but you could assign attributes to a class EX: class storage: pass >> store = Storage() >> name=raw_input() >> setattr(store, name, zeros(3,3)) >> print store.Chris On Wed, Jul 15, 2009 at 9:19 AM, chris Hynes wrote: > I guess I have to sta

Re: [Tutor] objects becoming pointers

2009-07-15 Thread bob gailer
chris Hynes wrote: I guess I have to start somewhere to ask I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) This is a FAQ. In Python one is discouraged from dynamically creating variable names. Preferred

Re: [Tutor] objects becoming pointers

2009-07-15 Thread Rich Lovely
2009/7/15 chris Hynes : > I guess I have to start somewhere to ask > > I want the user to input a name, say "Chris". I know I can use the code: > > name=raw_input() > > I now want: > > "Chris"=zeros((3,3)) > > so that when I type: > > print Chris > > the return will be an array of zero'

[Tutor] objects becoming pointers

2009-07-15 Thread chris Hynes
I guess I have to start somewhere to ask I want the user to input a name, say "Chris". I know I can use the code: name=raw_input() I now want: "Chris"=zeros((3,3)) so that when I type: print Chris the return will be an array of zero's 3x3 So that I can understand this deeper, I