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
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,
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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
Please, why isn't a set permitted as the second argument to isinstance?
--
http://mail.python.org/mailman/listinfo/python-list
23 matches
Mail list logo