instantiate a class with a variable

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Mar 27 22:13:33 EST 2006


Ben Finney <bignose+hates-spam at benfinney.id.au> writes:

>     >>> class Foo:
>     ...     pass
>     ...
>     >>> foo_name = 'foo'

Dang. As Cameron Laird points out, this should be

    >>> foo_name = 'Foo'

each time.

Moral of the story: if the example already works, and then you cut and
paste into the message compose window, and then notice that it could
be clearer and edit it some more...

... always test the example code you're *actually* presenting, after
all edits.

-- 
 \     "You know what would make a good story? Something about a clown |
  `\    who makes people happy, but inside he's real sad. Also, he has |
_o__)                                severe diarrhea."  -- Jack Handey |
Ben Finney




More information about the Python-list mailing list