On 30 November 2016 at 02:14, Stephen J. Turnbull
wrote:
> How about:
>
> class Blog:
> pass
>
> blog = get_blog_for_date(someday)
>
> logn = log(blog.size)
>
> NameError: Python doesn't recognize the function "log". Did you
> mean "Blog"?
>
> Wouldn't
>
> NameErro
It would be nice to have a supported way to add defaults to namedtuple, so
the slightly hacky solution here does not have to be
used: http://stackoverflow.com/a/18348004/2570866
Jelte
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.p
On 29/11/2016 20:09, Terry Reedy wrote:
On 11/29/2016 11:32 AM, Rob Cliffe wrote:
On 29/11/2016 04:58, victor rajewski wrote:
Traceback (most recent call last):
File "foo.py", line 2, in
l[10]=14
IndexError: list assignment index out of range
A better message might be:
You tried
On 30 November 2016 at 19:05, Paul Moore wrote:
> On 30 November 2016 at 02:14, Stephen J. Turnbull
> wrote:
>> Wouldn't
>>
>> NameError: Python doesn't recognize the name "log". Perhaps
>> you need to import the "math" module?
>
> ... and of course up until this example, I'd assumed you
Hello,
While I think this should not be "on by default", I don't see the harm in
being able to opt-in to this behavior.
I also figured spending a few minutes attempting to write this would be fun:
https://gist.github.com/veloutin/2ec3e5246651f5de78442516d8e24fc1
François: sorry about the double
On 11/30/2016 02:32 AM, Jelte Fennema wrote:
It would be nice to have a supported way to add defaults to namedtuple,
so the slightly hacky solution here does not have to be used:
http://stackoverflow.com/a/18348004/2570866
Actually, the solution right below it is better [1]:
--> from collec
On Wed, Nov 30, 2016 at 7:09 AM, Ethan Furman wrote:
> On 11/30/2016 02:32 AM, Jelte Fennema wrote:
>
> It would be nice to have a supported way to add defaults to namedtuple,
>> so the slightly hacky solution here does not have to be used:
>> http://stackoverflow.com/a/18348004/2570866
>>
>
>
On Tue, 29 Nov 2016 at 12:32 MRAB wrote:
> On 2016-11-29 19:45, Brendan Barnwell wrote:
> > On 2016-11-29 09:43, Brett Cannon wrote:
> >> One way to make this cheap is to have a reasonable default message and
> >> use attributes on the exceptions trigger the use of the default message.
> >> Nearl
Currently these functions fail if the supplied object has no len().
There are algorithms for this task that can work on any finite iterator
(for example, files as a stream of lines), and the functions could fall
back to these if there is no len().
___
Pyt
On 30 November 2016 at 13:09, Ethan Furman wrote:
> But even more readable than that is using the NamedTuple class from my aenum
> [3] library (and on SO as [3]):
>
> --> from aenum import NamedTuple
> --> class Node(NamedTuple):
> --> val = 0
> --> left = 1, 'previous Node', None
> -->
On 2016-11-30 17:25, Random832 wrote:
Currently these functions fail if the supplied object has no len().
There are algorithms for this task that can work on any finite iterator
(for example, files as a stream of lines), and the functions could fall
back to these if there is no len().
I like th
This was also brought up back in April:
https://mail.python.org/pipermail//python-ideas/2016-April/039707.html
It got a few replies from Guido
(https://mail.python.org/pipermail//python-ideas/2016-April/039713.html
for one of them).
It seems the idea got dropped due to problems with making it pro
On Wed, Nov 30, 2016 at 11:52 AM, Chris Kaynor wrote:
> There are also issues with how it should behave on iterables that
> cannot be re-iterated (eg, random.choice will consume the iterator,
> and could only be called once safely).
I meant to include a sample in my previous e-mail:
Consider tha
On 2016-11-30 17:57, Chris Kaynor wrote:
On Wed, Nov 30, 2016 at 11:52 AM, Chris Kaynor wrote:
There are also issues with how it should behave on iterables that
cannot be re-iterated (eg, random.choice will consume the iterator,
and could only be called once safely).
I meant to include a samp
Is the goal to allow them to consume a finite generator of *unknown* length
(requires reservoir sampling
https://en.wikipedia.org/wiki/Reservoir_sampling with N random calls,
which seemed to be the rub before?) or just consume a generator with known
length that's not indexable (a rare beast?). Con
On Wed, Nov 30, 2016 at 12:21 PM, Bernardo Sulzbach
wrote:
> On 2016-11-30 17:57, Chris Kaynor wrote:
>>
>> On Wed, Nov 30, 2016 at 11:52 AM, Chris Kaynor
>> wrote:
>>>
>>> There are also issues with how it should behave on iterables that
>>> cannot be re-iterated (eg, random.choice will consume
On 2016-11-30 19:11, Chris Kaynor wrote:
All that said, I would not be opposed to Python including a
random.reservoir_choice (probably not the best name) function *in
addition* to random.choice. The algorithm has its uses, but enough
drawbacks and gotchas that it likely is not a good candidate f
On Wed, Nov 30, 2016 at 11:57:46AM -0800, Chris Kaynor wrote:
> Consider that this code will not produce the "correct" results (for a
> reasonable definition of correct):
>
> a = (i for i in range(100)) # Pretend this does something more
> interesting, and isn't a trivial generator - maybe a file
18 matches
Mail list logo