[Tutor] objects becoming pointers

chris Hynes cjhynes36 at hotmail.com
Thu Jul 16 20:58:21 CEST 2009

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 with some type of methanol basename (I guess I could just save everything in a huge multidimensional array but it helps me to compartmentalize in to separate smaller arrays by name), later that afternoon I might we doing some formaldehyde calculations so I want those arrays to have some kind of aldehyde name associated with it. I could recall an earlier methanol array that was created. 

I could go back in to my code and change names. Or I thought I could just leave my program running and just keep on typing in new names as I need them, kind of like giving birth to as many arrays with whatever names as I see fit.

Several people have suggested I use dictionary function, and I'll probably do that. Hmmm, is it possible to concantenate a raw_input on to a pointer?

Oh well, in the end I think I'm just going to create a mutidimensional array and just access sub parts of it as I need to. Thanks for your help.

> To: tutor at python.org
> From: alan.gauld at btinternet.com
> Date: Thu, 16 Jul 2009 19:25:51 +0100
> Subject: Re: [Tutor] objects becoming pointers
> "chris Hynes" <cjhynes36 at hotmail.com> 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 
> program code, including the 
> print Chris 
> line, how will you know in advance what names your userrs are 
> going to input?
> I think you will find it easier to create a dictiobnary of user names 
> with their associated values:
> name = raw_input()
> names[name] = value
> name = raw_input("Which name was it?")
> print names[name]
> or even:
> for name in names:
>    print names[name]
> HTH,
> -- 
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Windows Live™ SkyDrive™: Get 25 GB of free online storage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090716/efea7249/attachment.htm>

More information about the Tutor mailing list