[Tutor] objects becoming pointers

Kent Johnson kent37 at tds.net
Wed Jul 15 17:44:30 CEST 2009


On Wed, Jul 15, 2009 at 11: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

The usual way to solve this is to use a dictionary:
name = raw_input()
values = dict()
values[name] = zeros((3, 3))
print values[name]

Kent


More information about the Tutor mailing list