List of given type
Mike C. Fletcher
mcfletch at rogers.com
Mon Mar 31 20:55:47 EST 2003
More information about the Python-list mailing list
Mon Mar 31 20:55:47 EST 2003
- Previous message (by thread): List of given type
- Next message (by thread): A default in the __init__ is like a class variable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Creating type-restricted lists is useful when creating self-assembling or largely automatically-assembled software. The system can catch attempts to assign objects of the wrong type, reason about how to coerce an assigned value to the right type, etceteras. Similarly, the GUI system can use introspection to present constructors to create appropriate values for the list/collection. For pointers on how to declare something like this: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/wxpypropdist/properties/basictypes/rlist.py?rev=HEAD&content-type=text/vnd.viewcvs-markup is a base-class which allows you to call a method on each addition to a list, where you can then do the type-checking necessary to support type-restriction. While: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/wxpypropdist/properties/basictypes/list_types.py?rev=HEAD&content-type=text/vnd.viewcvs-markup is the actual implementation of "list-of-X" for the basictypes/basicproperty packages. However, I'm guessing that the original poster may have been doing some premature optimisation, thinking that they needed such things when really the restrictions aren't necessary. Unless you're dealing with automatically assembling software, the type-specifications aren't really that useful for Python code. Enjoy, Mike John Machin wrote: >Zaur Shibzoukhov <szport at fromru.com> wrote in message news:<mailman.1049055286.13086.python-list at python.org>... > > > >>I need standard list of objects with a given type: >>list of int, list of float, list of list, list of dict, list of string, ... - list of any type. >> >> >> > >A silly question: WHY??? > > _______________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://members.rogers.com/mcfletch/
- Previous message (by thread): List of given type
- Next message (by thread): A default in the __init__ is like a class variable?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list