instantiate a class with a variable

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Mar 28 05:13:33 CEST 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