A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/108624.html below:

Class Variable Question

Class Variable Question Class Variable QuestionRobert Johnson rjohnson at exotic-eo.com
Mon Apr 9 10:33:24 EDT 2001
I am new to Python and I just read something that I thought was peculiar.
Is it true that a user can add to the variables of a class just by naming
the new variable?

Like:

ClassObject.var1=5

Would this create a variable "var1" inside the class even though the creator
of the class never intended it to be there (there was no var1 originally)?
If I mistype the variable in my code, a new variable inside the class is
created rather than flagging the error?  Is there a way to prevent this so
users cannot add variables?  It seems to me that the user could just
override a class with unrelated data.

Thanks in advance,

Robert Johnson



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4