[Tutor] Fwd: The why
roadierich at googlemail.com
Thu Jul 16 04:34:48 CEST 2009
---------- Forwarded message ----------
From: chris Hynes <cjhynes36 at hotmail.com>
Subject: The why
To: roadierich at googlemail.com
Well, I'm trying to create an interactive program, let's say I'm
running the program, I ask the user to give the array a name, I then
do some computations and store the results in that array. While I'm
still running the program I might decide to create several more arrays
of the same type/dimension with names of my choosing same types of
computation. When I'm done, I might have several arrays created, all
with different names that I have given them. In the ipython mode I
could call up any of these arrays off and on again as I want to
visually compare them to each other.
I mean I guess what I could do is go back to my code, name the array
Chris, let a calculation use x=2, save, run the program, go back in to
the code, edit it so that the array is named Bob along with changing
x=3, save, run the program a second time. When I'm done I'll now have
two arrays, one named Chris the other Bob with different results
because I changed some other input paramenters.
I just now thought of maybe making one huge array, storing all the
results of x=2 and use a conditional satement like if x=2, then name
was Chris. But it would be so much easier if I could type print Chris
or print Bob and it woulds spit out what those arrays were.
> From: roadierich at googlemail.com
> Date: Wed, 15 Jul 2009 16:33:00 +0100
> Subject: Re: [Tutor] objects becoming pointers
> To: cjhynes36 at hotmail.com
> CC: tutor at python.org
> 2009/7/15 chris Hynes <cjhynes36 at hotmail.com>:
> > 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 know that "name" is just a pointer
> > to the object "Chris". I don't want to just change the pointer to something
> > else, like "zeros((3,3))" but I want to make "Chris" become the pointer or
> > the name of the pointer. At least that's what I think I want.
> > ________________________________
> > Windows Live™ SkyDrive™: Get 25 GB of free online storage. Get it on your
> > BlackBerry or iPhone.
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> Sorry if I've sent this twice...
> Why would you want to do that?
> The closest you can get to that is using exec, but exec is usually
> considered a code smell. I'd say you're trying to do the wrong thing.
> Rich "Roadie Rich" Lovely
> There are 10 types of people in the world: those who know binary,
> those who do not, and those who are off by one.
Windows Live™: Keep your life in sync. Check it out.
Rich "Roadie Rich" Lovely
There are 10 types of people in the world: those who know binary,
those who do not, and those who are off by one.
More information about the Tutor