Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99918

Subclassing tuple and introspection

From "Joseph L. Casale" <jcasale@activenetwerx.com>
Newsgroups comp.lang.python
Subject Subclassing tuple and introspection
Date 2015-12-02 23:32 +0000
Message-ID <mailman.148.1449099313.14615.python-list@python.org> (permalink)

Show all headers | View raw


I need to return a collection of various types, since python doesn't
have the terse facility of extension methods like C#, subclassing tuple
and adding a method seems like a terse way to accommodate this.

However, if the method returns one element of the collection, how can
one enable introspection for users of IDE's that the resulting reference
is of type A, and therefor has A's fields?

For example:
col = (Class(..), Class(...))
item = col[0]

Introspection will now enumerate item as an instance of Class, providing
its fields. The subclass of tuple breaks this. 

Is there a better way to do this?

Thanks,
jlc

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Subclassing tuple and introspection "Joseph L. Casale" <jcasale@activenetwerx.com> - 2015-12-02 23:32 +0000

csiph-web