[Tutor] objects becoming pointers

Dave Angel davea at ieee.org
Fri Jul 17 04:24:04 CEST 2009


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 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.
>   
>
What language are you planning to write this in?  Python doesn't have 
pointers.  And variables created in one run of the program are not 
visible next time it runs.  And it doesn't have arrays, nor 
multidimensional anything.  Nor "dictionary functions."

Who is the user?  Is it the same person writing the code, and you just 
refer to yourself in the 3rd person?  Once your code is running, and 
getting names, it's a bit late to be entering print statements into your 
code.  Are you perhaps running this whole thing from the interpreter prompt?

A dictionary is a data structure, like a list is.  Each item in a 
dictionary has a key and a value.  Certainly dictionary values may be 
lists, and keys can be strings like "methanol" or "Chris".




More information about the Tutor mailing list