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
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
"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
> 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
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
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
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
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
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'
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
10 matches
Mail list logo