Movatterモバイル変換
[0]ホーム
Class Variable Question
Robert Johnsonrjohnson 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 namingthe new variable?Like:ClassObject.var1=5Would this create a variable "var1" inside the class even though the creatorof 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 iscreated rather than flagging the error? Is there a way to prevent this sousers cannot add variables? It seems to me that the user could justoverride a class with unrelated data.Thanks in advance,Robert Johnson
More information about the Python-listmailing list
[8]ページ先頭