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


Groups > comp.lang.python > #99918 > unrolled thread

Subclassing tuple and introspection

Started by"Joseph L. Casale" <jcasale@activenetwerx.com>
First post2015-12-02 23:32 +0000
Last post2015-12-02 23:32 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#99918 — Subclassing tuple and introspection

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2015-12-02 23:32 +0000
SubjectSubclassing tuple and introspection
Message-ID<mailman.148.1449099313.14615.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web