[Tutor] objects becoming pointers
vince spicer
vinces1979 at gmail.com
Wed Jul 15 17:44:19 CEST 2009
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 <cjhynes36 at hotmail.com> 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 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.<http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_SD_25GB_062009>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090715/f7b18170/attachment-0001.htm>
More information about the Tutor
mailing list