declaration of variables?
A. Lloyd Flanagan
alloydflanagan at attbi.com
Tue Feb 25 17:39:40 EST 2003
More information about the Python-list mailing list
Tue Feb 25 17:39:40 EST 2003
- Previous message (by thread): declaration of variables?
- Next message (by thread): declaration of variables?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jp Calderone <exarkun at intarweb.us> wrote in message news:<mailman.1045424456.19402.python-list at python.org>... > I'd think it was obvious. Right now, I can bind any name any time I like > . > With declarations, any time I wanted a new variable, I'd have to type an > extra keyword somewhere. Any time I decided I didn't need a variable any > more, I'd have to go find where it was declared and remove it. If you think > this isn't a significant hurdle, I recommend you go read some of the larger > C projects out there. In many of them, you'll find all kinds of accrued > variable cruft - variables people declared, used, and then discarded, but > failed to remove the declarations. This reduces program readability, and > would presumably slow down program execution in Python as well. > I agree, but I think we're missing another feature of not requiring declaration. One class can add attributes to another class. This is useful in all sorts of situations, because you can add behavior to class instances without caring what class the instance belongs to. Want to add a unique ID to a collection of various objects? for x in some_collection: x.unique_id = getUniqueId() How you'd preserve the capabilities of augmentation and metaclass programming while requiring variable declaration, I don't know. Incidentally, that's why I dislike __slots__. It may have some uses, but it means there are a lot of useful things you can't do to objects of that class.
- Previous message (by thread): declaration of variables?
- Next message (by thread): declaration of variables?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list