Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "Joseph L. Casale" Newsgroups: comp.lang.python Subject: Subclassing tuple and introspection Date: Wed, 2 Dec 2015 23:32:31 +0000 Lines: 19 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de iOo8B/hIMkwKI9CZ3UXJLQjpJJ8Ey/0tFHpyXCQLbICw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'resulting': 0.04; 'subclass': 0.09; 'tuple': 0.09; 'example:': 0.10; 'python': 0.10; 'col': 0.16; 'received:172.18.0': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subclassing': 0.16; 'terse': 0.16; 'element': 0.18; 'extension': 0.20; 'to:name:python- list@python.org': 0.20; 'accommodate': 0.22; 'class,': 0.22; 'subject:skip:i 10': 0.22; 'seems': 0.23; 'thanks,': 0.24; "doesn't": 0.26; 'this.': 0.28; 'facility': 0.33; 'this?': 0.34; 'instance': 0.35; 'item': 0.35; 'there': 0.36; 'to:addr:python- list': 0.36; 'method': 0.37; 'to:addr:python.org': 0.40; 'collection': 0.60; 'providing': 0.62; 'collection,': 0.84 X-Authority-Analysis: v=2.1 cv=AMkI9oPf c=1 sm=1 tr=0 a=g3mLq75WYuDrh3Lt0JSDww==:117 a=g3mLq75WYuDrh3Lt0JSDww==:17 a=QC7fh9NfAAAA:8 a=P90J6pEA2ccA:10 a=8nJEP1OIZ-IA:10 a=wUQvQvOEmiQA:10 a=maoh1wntLzP2gJjIU5gA:9 a=wPNLvfGTeEIA:10 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.activenetwerx.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED, T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.0 Thread-Topic: Subclassing tuple and introspection Thread-Index: AQHRLVkERwHpQKKW4EiOavIzwUIB8Q== Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.4] X-CMAE-Envelope: MS4wfIKb4kXtGYIMJZunSXvsbJJvOvEdkseBS3BcvEu+VNHi/rcS2eoeyeS/n9BVuhRcmiqHsovYuBpXOQIpS86pmgUItcerT11oR1/iHrgcvkPVOOZJOjOK vSDXULp39KZpjwBmuUxHWEGkgLQl3uaKeQv+JvHLHzzKVgHlMqpSxOpqIdlpTQEq9MMbkJS+LANt1A== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99918 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 =3D (Class(..), Class(...)) item =3D col[0] Introspection will now enumerate item as an instance of Class, providing its fields. The subclass of tuple breaks this.=20 Is there a better way to do this? Thanks, jlc