On Thu, 24 Sep 2015 04:54 pm, Ben Finney wrote:
> Steven D'Aprano writes:
>
>> On Thursday 24 September 2015 16:16, Paul Rubin wrote:
>>
>> > Steven D'Aprano writes:
>> >> for k, v in mydict.items():
>> >> del(k)
>>
>> […] The obvious intent is to iterate over the *values* of the
>> diction
On Fri, 25 Sep 2015 06:46 am, Ned Batchelder wrote:
> On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano
> wrote:
>> What are your favorite not-wrong-just-weird Python moments?
>
> I've seen this a number of times:
>
> dict_of_values.update({'key': some_value})
>
> why not
On Fri, 25 Sep 2015 02:54 am, Todd wrote:
> Using list indexing with booleans in place of a ternary operator.
>
> a = False
> b = [var2, var1][a]
>
> Instead of:
>
> b = var1 if a else var2
Ah, you youngsters... :-)
Using a bool to index into a list used to be the standard idiom, before the
Mark Lawrence writes:
> On 24/09/2015 07:02, Steven D'Aprano wrote:
>> I was looking at an in-house code base today, and the author seems to have a
>> rather idiosyncratic approach to Python. For example:
>>
>> for k, v in mydict.items():
>> del(k)
>> ...
>>
>> instead of the more obvio
On 24/09/2015 07:02, Steven D'Aprano wrote:
I was looking at an in-house code base today, and the author seems to have a
rather idiosyncratic approach to Python. For example:
for k, v in mydict.items():
del(k)
...
instead of the more obvious
for v in mydict.values():
...
What a
On Wednesday, September 23, 2015 at 11:02:38 PM UTC-7, Steven D'Aprano wrote:
> I was looking at an in-house code base today, and the author seems to have a
> rather idiosyncratic approach to Python. For example:
>
>
> for k, v in mydict.items():
> del(k)
> ...
>
>
> instead of the mo
On Fri, Sep 25, 2015 at 7:08 AM, Laura Creighton wrote:
> In a message of Thu, 24 Sep 2015 13:46:27 -0700, Ned Batchelder writes:
>>On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano wrote:
>>> What are your favorite not-wrong-just-weird Python moments?
>>
>>I've seen this a numb
In a message of Thu, 24 Sep 2015 13:46:27 -0700, Ned Batchelder writes:
>On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano wrote:
>> What are your favorite not-wrong-just-weird Python moments?
>
>I've seen this a number of times:
>
>dict_of_values.update({'key': some_value})
On Thursday, September 24, 2015 at 2:02:38 AM UTC-4, Steven D'Aprano wrote:
> What are your favorite not-wrong-just-weird Python moments?
I've seen this a number of times:
dict_of_values.update({'key': some_value})
why not:
dict_of_values['key'] = some_value
I've considered writing a P
On 24/09/2015 18:50, Laurent Pointal wrote:
wxjmfa...@gmail.com wrote:
Le jeudi 24 septembre 2015 08:02:38 UTC+2, Steven D'Aprano a écrit :
What are your favorite not-wrong-just-weird Python moments?
Showing how to make Python 3.5.0 crash by
just using an "é", U+00E9.
Would you like to
On Sep 24, 2015 18:59, "Chris Angelico" wrote:
>
> On Fri, Sep 25, 2015 at 2:54 AM, Todd wrote:
> > Using list indexing with booleans in place of a ternary operator.
> >
> > a = False
> > b = [var2, var1][a]
> >
> > Instead of:
> >
> > b = var1 if a else var2
>
> Be careful - these are not semant
On Thu, Sep 24, 2015 at 12:04 PM, jmp wrote:
> I'm not an expert but I think this "return by value thing" is only for C++.
> In vintage C, you can only return something that fits within a register.
If that was true at one time, it was before ANSI C.
$ cat test.c
#include
struct foo {
int a;
On 09/24/2015 04:26 PM, Ian Kelly wrote:
On Thu, Sep 24, 2015 at 8:07 AM, jmp wrote:
result = getResult()
For the later, the original weird form come from a C habit to allocate
returned structures within the caller and provide a pointer to it so the
function can fill the data in, otherwise the
wxjmfa...@gmail.com wrote:
> Le jeudi 24 septembre 2015 08:02:38 UTC+2, Steven D'Aprano a écrit :
>>
>>
>> What are your favorite not-wrong-just-weird Python moments?
>>
>>
> Showing how to make Python 3.5.0 crash by
> just using an "é", U+00E9.
Like this ?
Python 3.5.0 (default, Sep 24 201
On Fri, Sep 25, 2015 at 2:54 AM, Todd wrote:
> Using list indexing with booleans in place of a ternary operator.
>
> a = False
> b = [var2, var1][a]
>
> Instead of:
>
> b = var1 if a else var2
Be careful - these are not semantically identical. The first one
evaluates both var1 and var2, while the
Using list indexing with booleans in place of a ternary operator.
a = False
b = [var2, var1][a]
Instead of:
b = var1 if a else var2
On Sep 24, 2015 8:06 AM, "Steven D'Aprano" <
steve+comp.lang.pyt...@pearwood.info> wrote:
> I was looking at an in-house code base today, and the author seems to h
On Thu, Sep 24, 2015 at 8:07 AM, jmp wrote:
> result = getResult()
>
> For the later, the original weird form come from a C habit to allocate
> returned structures within the caller and provide a pointer to it so the
> function can fill the data in, otherwise the structure is lost as the stack
> i
On 09/24/2015 02:50 PM, paul.hermeneu...@gmail.com wrote:
> A lot of our in base weird python comes from heavily C-wired people:
>
> The classic
> for i in range(len(alist)):
> print alist[i]
>
> with its twin brother
>
> i=0
> while i < len(alist):
> print alist[i]
> i += 1
>
On 24/09/2015 13:50, paul.hermeneu...@gmail.com wrote:
> A lot of our in base weird python comes from heavily C-wired people:
>
> The classic
> for i in range(len(alist)):
> print alist[i]
>
> with its twin brother
>
> i=0
> while i < len(alist):
> print alist[i]
> i += 1
>
>
> A lot of our in base weird python comes from heavily C-wired people:
>
> The classic
> for i in range(len(alist)):
> print alist[i]
>
> with its twin brother
>
> i=0
> while i < len(alist):
> print alist[i]
> i += 1
>
> And the even more annoying
>
> result = Result()
> getResult(result)
>
On 09/24/2015 08:02 AM, Steven D'Aprano wrote:
I was looking at an in-house code base today, and the author seems to have a
rather idiosyncratic approach to Python. For example:
for k, v in mydict.items():
del(k)
...
instead of the more obvious
for v in mydict.values():
...
On 9/24/2015 2:35 AM, Steven D'Aprano wrote:
On Thursday 24 September 2015 16:16, Paul Rubin wrote:
Steven D'Aprano writes:
for k, v in mydict.items():
del(k)
That looks wrong: it's deleting k from what?
The local namespace.
py> k = 23
py> print k
23
py> del k
py> print k
Traceback
Steven D'Aprano writes:
> On Thursday 24 September 2015 16:16, Paul Rubin wrote:
>
> > Steven D'Aprano writes:
> >> for k, v in mydict.items():
> >> del(k)
>
> […] The obvious intent is to iterate over the *values* of the
> dictionary, but the coder didn't know about values, so he iterated
>
On Thursday 24 September 2015 16:16, Paul Rubin wrote:
> Steven D'Aprano writes:
>> for k, v in mydict.items():
>> del(k)
>
> That looks wrong: it's deleting k from what?
The local namespace.
py> k = 23
py> print k
23
py> del k
py> print k
Traceback (most recent call last):
File "", line
Steven D'Aprano writes:
> for k, v in mydict.items():
> del(k)
That looks wrong: it's deleting k from what?
> instead of the more obvious
> for v in mydict.values():
> ...
Maybe you mean
while mydict:
k, v = mydict.popitem()
...
--
https://mail.python.org/mailman/list
I was looking at an in-house code base today, and the author seems to have a
rather idiosyncratic approach to Python. For example:
for k, v in mydict.items():
del(k)
...
instead of the more obvious
for v in mydict.values():
...
What are your favorite not-wrong-just-weird Pyth
26 matches
Mail list logo