While confusion with optional arguments is somewhat unfortunate, the name came
from an already established convention. A lot of languages have exactly the
same concept, varying between names like Optional, Option, and Maybe. I don't
think coming up with a Python-specific name for the same thing
I actually initially was going to suggest a `strict` flag get added, but I
figured that would be impractical. I was mostly concerned about classes that
mimic file objects, because (obviously) their read methods wouldn't include a
`strict` flag and you couldn't pass such objects to functions
The code I'm currently working on involves parsing binary data. If I ask for,
say, 4 bytes, it's because I actually need 4 bytes and if the file doesn't have
4 bytes for me, it's malformed. Because `f.read(4)` can silently return less
than 4 bytes and I don't want to have to explicitly double
If you don't like:
while True:
...
if whatever:
break
One thing I've seen people do is:
condition = True
while condition:
...
condition = whatever
You can use it if you really hate `while True` loops with `break`.
___
I'm not sure what you're proposing. What should its `__name__` be set to?
If you have a value you want its `__name__` to be, you can just set it yourself.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to
As I said before, the "1,2,3" in `f(1,2,3)` has a very different meaning than
the "1,2,3" in `d[1,2,3]`. One is a (comma-separated) list of expressions, and
one is a single expression, a tuple.
`*(1,2,3)` does not evaluate to the tuple `(1,2,3)`, so I don't think expecting
it to do so in the
> One reason MRAB points to. The `*keys` syntax is more-or-less equivalent to
> "substitute a tuple" in other Python contexts; you are proposing to give it a
> completely different meaning. This would be confusing and inconsistent.
I disagree that it is a completely different meaning. If the
No, definitely not. d[1,2,3] and d[1][2][3] are not the same thing. The latter
is what I am talking about.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
Given code like this:
```
d = {1: {2: {3: 4}}}
print(d[1][2][3])
d[1][2][3] = None
print(d)
```
It should be possible to rewrite it using a starred expression, like this:
```
d = {1: {2: {3: 4}}}
keys= 1,2,3
print(d[*keys])
d[*keys] = None
print(d)
```
Hopefully it's clear from that example
Sorry for the duplicate message. I realized two seconds after I sent it, that I
only replied to you and not the group.
I didn't see the `consume` recipe until after I posted, or I probably would've
mentioned it. What I want would have to be done in C, because `it_index` (as
`listiterobject`
str_iterator, bytes_iterator, range_iterator, list_iterator, and tuple_iterator
(and probably others) should have a method that is capable of efficiently
advancing the iterator, instead of having to call next repeatedly.
I suggest adding an itertools.advance function which dispatches to a
11 matches
Mail list logo