Any comments? My draft of a new PEP.

Courageous jkraska1 at san.rr.com
Sat Aug 18 14:42:41 EDT 2001


>> static ... Would rather gouge my eyes out.

>Maybe 'static' would be used for something totally different, like to tell
>the interpreter that dynamism is not needed in a certain context.

>def static f(): pass
>f.attribute = 1 # Error: 'f' declared immutable by keyword 'static'.


I've heard that Perl uses the keyword "strict" for this. If I
implemented it, I'd explore the following ideas:

When a function is declared "strict," local variables must be
declared. Misspellings would not automatically create a local
variable.

When a class is declared "strict," assignments to attributes
on an object instance would throw an exception unless first the
class had that attribute. A strict class automatically propagates
the strict attribute to all of the methods on the class and its
instances.

When a module is declared "strict," module level attributes
may not be assigned unless first declared. module-level "strict"
automatically propagates strictness to all functions defined
in the module.

I'm not sure that I _would_ do any of these things, mind you,
except fiddle with them and see how they work out in practice. :)

C//




More information about the Python-list mailing list