classification
Title: There is no 'seq' type
Type: Stage:
Components: Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, tom66
Priority: normal Keywords:

Created on 2009-12-30 18:44 by tom66, last changed 2009-12-30 18:46 by benjamin.peterson. This issue is now closed.

Messages (2)
msg97050 - (view) Author: Thomas Oldbury (tom66) Date: 2009-12-30 18:44
I find myself often writing the following code:

   if isinstance(var, (tuple, list, basestring)):

to determine if a var is indexable and iterable. 

It would be simpler if there were a 'seq' type which is subclassed into 
mutableseq and immutableseq (or something like that). Tuples and strings 
would be children of immutableseq. Lists would be children of 
mutableseq. Then I can do:

   if isinstance(var, seq):

Or to determine if I can edit values I can:

   if isinstance(var, mutableseq):

Actually this should probably not be a bug, maybe a PEP... or something.

This is the only thing I can presently think I would really like to 
correct in Python, because so far Python is the best language I've ever 
had the pleasure to write programs for. Thanks to everyone involved. :)
msg97052 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-12-30 18:46
Take a swing by the abc module.
History
Date User Action Args
2009-12-30 18:46:50benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg97052

resolution: out of date
2009-12-30 18:44:08tom66create