On 11/8/21 4:45 AM, Victor Stinner wrote:
> Is it implement "like" ascii(obj).encode("ascii") but with minor
> changes? What changes?
It works like `str()`, but you get ascii-encoded bytes (or an exception if
that's not possible).
The difference with the built-in ascii is the absence of extra
[Ethan Furman ]
> When is an empty container contained by a non-empty container?
That depends on how the non-empty container's type defines
__contains__. The "stringish" types (str, byte, bytearray) work _very_
differently from others (list, set, tuple) in this respect.
t in x
for the latter
On Mon, Nov 8, 2021 at 1:43 PM Ethan Furman wrote:
> When is an empty container contained by a non-empty container?
>
> For example:
>
> {} in {1:'a', 'b':2} <-- TypeError because of hashability
>
(You accidentally wrote a square close bracket, but I know you meant a
curly close brace. :-}
On 08Nov2021 23:32, MRAB wrote:
>On 2021-11-08 22:10, Cameron Simpson wrote:
>>>{} in {1:'a', 'b':2] <-- TypeError because of hashability
>>>set() in {1, 2, 'a', 'b'} <-- ditto
>>>[] in ['a', 'b', 1, 2] <-- False
>>
>>Right. Also, the members are not dicts or sets, respectively.
>>
>More
When is an empty container contained by a non-empty container?
For example:
{} in {1:'a', 'b':2] <-- TypeError because of hashability
set() in {1, 2, 'a', 'b'} <-- ditto
[] in ['a', 'b', 1, 2] <-- False
'' in 'a1b2' <-- True
SomeFlag.nothing in SomeFlag.something <-- ???
On 2021-11-09 00:27, Cameron Simpson wrote:
On 08Nov2021 23:32, MRAB wrote:
>On 2021-11-08 22:10, Cameron Simpson wrote:
>>>{} in {1:'a', 'b':2] <-- TypeError because of hashability
>>>set() in {1, 2, 'a', 'b'} <-- ditto
>>>[] in ['a', 'b', 1, 2] <-- False
>>
>>Right. Also, the members are
Note: I know you understand all this, I'm not "explaining" how things
work below, I'm explaining how/why I think about how these work.
On 08Nov2021 13:43, Ethan Furman wrote:
>When is an empty container contained by a non-empty container?
[...]
>For example:
>
>{} in {1:'a', 'b':2] <--
On Mon, Nov 08, 2021 at 01:43:03PM -0800, Ethan Furman wrote:
> When is an empty container contained by a non-empty container?
[...]
> SomeFlag.nothing in SomeFlag.something <-- ???
I don't think that consistency with other containers is particularly
relevant here. More useful is consistency
On 2021-11-08 22:10, Cameron Simpson wrote:
Note: I know you understand all this, I'm not "explaining" how things
work below, I'm explaining how/why I think about how these work.
On 08Nov2021 13:43, Ethan Furman wrote:
When is an empty container contained by a non-empty container?
[...]
For
Let's use a concrete example: `re.RegexFlag`
```
Help on function match in module re:
match(pattern, string, flags=0)
Try to apply the pattern at the start of the string, returning
a Match object, or None if no match was found.
```
In use we have:
result = re.match('present',
On 08/11/2021 21:43, Ethan Furman wrote:
When is an empty container contained by a non-empty container?
For example:
These examples are not at all analogous. `a in b` has different
meanings for different classes of b.
{} in {1:'a', 'b':2] <-- TypeError because of hashability
`x in aDict`
On Mon, Nov 8, 2021 at 7:26 PM Ethan Furman wrote:
> Let's use a concrete example: `re.RegexFlag`
>
> ```
> Help on function match in module re:
>
> match(pattern, string, flags=0)
> Try to apply the pattern at the start of the string, returning
> a Match object, or None if no match
I think he's confusing the fact that empty is a subset of every set
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message
Something to keep in mind as these discussions continue: Enums are already
unusual in several ways:
- the class itself is iterable
- the class itself supports containment checks of its enum members
- the enum members are created, and guaranteed singletons, during class creation
- the enum
The ascii() constructor is not well specified by the PEP. There are
only a few examples. I don't understand how it's supposed by be
implemented. Would you mind to elaborate its specification?
Is it implement "like" ascii(obj).encode("ascii") but with minor
changes? What changes?
Victor
What's New in Python 3.10 lists other suggestions and enhanced error messages:
https://docs.python.org/dev/whatsnew/3.10.html#better-error-messages
Victor
On Fri, Oct 29, 2021 at 7:22 PM Steven D'Aprano wrote:
>
> I was using Python 3.10 and got this NameError when I mistyped a name:
>
>
16 matches
Mail list logo