Re: Python 3 isinstance

2009-01-16 Thread Duncan Booth
Steven D'Aprano wrote: > On Fri, 16 Jan 2009 09:58:53 +, Duncan Booth wrote: > >> That still leaves the question whether anyone has ever actually taken >> advantage of this feature. You can do isinstance(x, (IntType, >> LongType, StringTypes)) but I didn't even know that StringTypes >> exist

Re: Python 3 isinstance

2009-01-16 Thread Steven D'Aprano
On Fri, 16 Jan 2009 09:58:53 +, Duncan Booth wrote: > That still leaves the question whether anyone has ever actually taken > advantage of this feature. You can do isinstance(x, (IntType, LongType, > StringTypes)) but I didn't even know that StringTypes existed until a > couple of moments ago,

Re: Python 3 isinstance

2009-01-16 Thread Duncan Booth
Carl Banks wrote: > On Jan 15, 1:08 pm, Duncan Booth wrote: >> Carl Banks wrote: >> > I don't see what the big deal is.  Right now isinstance accepts a >> > typ > e >> > or a tuple of types.  The code could be changed to allow a type, or >> > any iterable the returns types (wherein every items

Re: Python 3 isinstance

2009-01-15 Thread Rhamphoryncus
On Jan 14, 3:14 pm, "Lambert, David W (S&T)" wrote: > Please, why isn't a set permitted as the second argument to isinstance? The real problem is it would be misleading. isinstance(a, myset) suggests implementation like type(a) in myset, but it's really any (isinstance(a, t) for t in myset). If

Re: Python 3 isinstance

2009-01-15 Thread Carl Banks
On Jan 15, 1:08 pm, Duncan Booth wrote: > Carl Banks wrote: > > I don't see what the big deal is.  Right now isinstance accepts a type > > or a tuple of types.  The code could be changed to allow a type, or > > any iterable the returns types (wherein every items of the sequence is > > required to

Re: Python 3 isinstance

2009-01-15 Thread John Machin
On Jan 16, 4:28 am, "Lambert, David W (S&T)" wrote: > Although isinstance predates sets, the python history I recall is that > allowing tuples as second argument to isinstance happened at about the > same time as set type was builtin. isinstance 2nd arg as tuple of type info: 2.2 sets module: 2.3

Re: Python 3 isinstance

2009-01-15 Thread Terry Reedy
Duncan Booth wrote: Terry Reedy wrote: Lambert, David W (S&T) wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. I agree. However, isinst

Re: Python 3 isinstance

2009-01-15 Thread Duncan Booth
Carl Banks wrote: > I don't see what the big deal is. Right now isinstance accepts a type > or a tuple of types. The code could be changed to allow a type, or > any iterable the returns types (wherein every items of the sequence is > required to be a type). What's messy about that? No, it isn

Re: Python 3 isinstance

2009-01-15 Thread Carl Banks
On Jan 15, 3:35 am, Duncan Booth wrote: > Terry Reedy wrote: > > Lambert, David W (S&T) wrote: > >> Overly terse.  I do mean that this is illegal: > > >> isinstance(s, {str, bytes}) > > >> tuples have order, immutability, and the possibility of repeat items. > > >> A set is most reasonable in a m

Re: Python 3 isinstance

2009-01-15 Thread
Although isinstance predates sets, the python history I recall is that allowing tuples as second argument to isinstance happened at about the same time as set type was builtin. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 isinstance

2009-01-15 Thread MRAB
Lambert, David W (S&T) wrote: > I have use case, needn't be dynamic, and it's not hard to enclose set as > tuple. But I also write (for example) > > __all__ = 'this that other'.split() > string_list = 'evenOneWord'.split() > > instead of > > __all__ = 'this','that','imTiredOfMistypingCommasAndQuo

Re: Python 3 isinstance

2009-01-15 Thread
I have use case, needn't be dynamic, and it's not hard to enclose set as tuple. But I also write (for example) __all__ = 'this that other'.split() string_list = 'evenOneWord'.split() instead of __all__ = 'this','that','imTiredOfMistypingCommasAndQuotes' if not isinstance(o,set_of_handled_type

Re: Python 3 isinstance

2009-01-15 Thread MRAB
Lambert, David W (S&T) wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. You could say the same about s.startswith(("a", "b")). It might be

Re: Python 3 isinstance

2009-01-15 Thread Duncan Booth
Terry Reedy wrote: > Lambert, David W (S&T) wrote: >> Overly terse. I do mean that this is illegal: >> >> isinstance(s, {str, bytes}) >> >> tuples have order, immutability, and the possibility of repeat items. >> >> A set is most reasonable in a mathematical sense. > > I agree. However, isi

Re: Python 3 isinstance

2009-01-14 Thread Steven D'Aprano
On Wed, 14 Jan 2009 22:03:37 -0500, Lambert, David W (S&T) wrote: > Overly terse. I do mean that this is illegal: > > isinstance(s, {str, bytes}) *shrug* Just change the {} to () and it will work fine. Or do this: isinstance(s, tuple({str, bytes})) > tuples have order, immutability, and t

Re: Python 3 isinstance

2009-01-14 Thread Terry Reedy
Lambert, David W (S&T) wrote: Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. I agree. However, isinstance predates set. Hence the status quo.

Re: Python 3 isinstance

2009-01-14 Thread John Machin
On Jan 15, 2:03 pm, "Lambert, David W (S&T)" wrote: > Overly terse. I do mean that this is illegal: > > isinstance(s, {str, bytes}) > > tuples have order, immutability, and the possibility of repeat items. In the anticipated/usual use case (the type/class names are hard- coded): * order is a ver

Re: Python 3 isinstance

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 1:03 PM, Lambert, David W (S&T) wrote: > Overly terse. I do mean that this is illegal: > > isinstance(s, {str, bytes}) > > tuples have order, immutability, and the possibility of repeat items. > > A set is most reasonable in a mathematical sense. What's wrong with: >>> a

Re: Python 3 isinstance

2009-01-14 Thread
Overly terse. I do mean that this is illegal: isinstance(s, {str, bytes}) tuples have order, immutability, and the possibility of repeat items. A set is most reasonable in a mathematical sense. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3 isinstance

2009-01-14 Thread Carl Banks
On Jan 14, 4:14 pm, "Lambert, David W (S&T)" wrote: > Please, why isn't a set permitted as the second argument to isinstance? The Python development team might be open to adding it if you were to submit a patch. The use case is fairly obvious. I doubt any of them would respond to a wishlist req

Re: Python 3 isinstance

2009-01-14 Thread MRAB
Lambert, David W (S&T) wrote: Please, why isn't a set permitted as the second argument to isinstance? Do you mean set as a class ("isinstance(s, set)", which is valid) or a set of classes ("isinstance(s, set([str, bytes])", which isn't valid)? -- http://mail.python.org/mailman/listinfo/python-l

Re: Python 3 isinstance

2009-01-14 Thread James Mills
On Thu, Jan 15, 2009 at 8:14 AM, Lambert, David W (S&T) wrote: > Please, why isn't a set permitted as the second argument to isinstance? Care to show us a code sample ? We're not psychic you know... cheers James -- http://mail.python.org/mailman/listinfo/python-list

Python 3 isinstance

2009-01-14 Thread
Please, why isn't a set permitted as the second argument to isinstance? -- http://mail.python.org/mailman/listinfo/python-list