[Tutor] objects becoming pointers

Rich Lovely roadierich at googlemail.com
Wed Jul 15 17:33:00 CEST 2009


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.


More information about the Tutor mailing list