On Feb 21, 9:13 pm, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Feb 21, 8:04 pm, Benjamin <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Feb 17, 6:18 am, Terry Jones <[EMAIL PROTECTED]> wrote:
>
> > > Hi Arnaud & Benjamin
>
> > > Here's a version that's a bit more general. It handles keys whose values
>
On Feb 21, 8:04 pm, Benjamin <[EMAIL PROTECTED]> wrote:
> On Feb 17, 6:18 am, Terry Jones <[EMAIL PROTECTED]> wrote:
>
> > Hi Arnaud & Benjamin
>
> > Here's a version that's a bit more general. It handles keys whose values
> > are empty dicts (assigning None to the value in the result), and also di
On Feb 17, 6:18 am, Terry Jones <[EMAIL PROTECTED]> wrote:
> Hi Arnaud & Benjamin
>
> Here's a version that's a bit more general. It handles keys whose values
> are empty dicts (assigning None to the value in the result), and also dict
> keys that are not strings (see the test data below). It's als
Duncan Booth wrote:
> In this particular case I think the lambda does contribute to the
> obfuscation. Yes, they are single expressions, but only because that
> have been contorted to become single expressions. The first two return
> generators, so if you don't force them into a lambda you can wr
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> # Untested
> def flattendict(d):
> def gen(L):
> return (x for M in exp(L) for x in rec(M))
> def exp(L):
> return (L+list(kv) for kv in L.pop().iteritems())
> def rec(M):
> return gen(M) if isinstance(M[-1],dict) els
Arnaud Delobelle wrote:
> On Feb 18, 10:22 pm, Steven D'Aprano <[EMAIL PROTECTED]
> cybersource.com.au> wrote:
> [...]
>> The problem with lambdas comes from people trying to hammer multi-
>> expression functions into a single-expression lambda, hence obfuscating
>> the algorithm. That's no differe
On Feb 18, 10:22 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
[...]
> The problem with lambdas comes from people trying to hammer multi-
> expression functions into a single-expression lambda, hence obfuscating
> the algorithm. That's no different from people who obfuscate mult
On Mon, 18 Feb 2008 14:03:20 +, Duncan Booth wrote:
> Why, why, why, why are you using lambda here? It only makes the code
> harder to read (and it is bad enough without that). A lambda which is
> assigned directly to a variable is a bad code smell.
Oh come on. I don't get this allergy to lam
Duncan Booth wrote:
> Boris Borcic <[EMAIL PROTECTED]> wrote:
>
>> It is more elementary in the mathematician's sense, and therefore
>> preferable all other things being equal, imo. I've tried to split
>> 'gen' but I can't say the result is so much better.
>>
>> def flattendict(d) :
>>gen
Boris Borcic <[EMAIL PROTECTED]> wrote:
> It is more elementary in the mathematician's sense, and therefore
> preferable all other things being equal, imo. I've tried to split
> 'gen' but I can't say the result is so much better.
>
> def flattendict(d) :
>gen = lambda L : (x for M in exp(
Arnaud Delobelle wrote:
> On Feb 17, 4:03 pm, Boris Borcic <[EMAIL PROTECTED]> wrote:
>> George Sakkis wrote:
>>> On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
BTW, I keep using the idiom itertools.chain(*iterable). I guess that
during function calls *iterable gets expa
On Feb 17, 4:03 pm, Boris Borcic <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
> > On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> >> BTW, I keep using the idiom itertools.chain(*iterable). I guess that
> >> during function calls *iterable gets expanded to a tuple. Wouldn'
> "Arnaud" == Arnaud Delobelle <[EMAIL PROTECTED]> writes:
Arnaud> BTW, I keep using the idiom itertools.chain(*iterable). I guess
Arnaud> that during function calls *iterable gets expanded to a tuple.
Arnaud> Wouldn't it be nice to have an equivalent one-argument function
Arnaud> that takes
George Sakkis wrote:
> On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
>> BTW, I keep using the idiom itertools.chain(*iterable). I guess that
>> during function calls *iterable gets expanded to a tuple. Wouldn't it
>> be nice to have an equivalent one-argument function that ta
On Feb 17, 7:51 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> BTW, I keep using the idiom itertools.chain(*iterable). I guess that
> during function calls *iterable gets expanded to a tuple. Wouldn't it
> be nice to have an equivalent one-argument function that takes an
> iterable of iterabl
On Feb 17, 12:18 pm, Terry Jones <[EMAIL PROTECTED]> wrote:
> Hi Arnaud & Benjamin
>
> Here's a version that's a bit more general. It handles keys whose values
> are empty dicts (assigning None to the value in the result), and also dict
> keys that are not strings (see the test data below). It's al
Hi Arnaud & Benjamin
Here's a version that's a bit more general. It handles keys whose values
are empty dicts (assigning None to the value in the result), and also dict
keys that are not strings (see the test data below). It's also less
recursive as it only calls itself on values that are dicts.
Arnaud Delobelle wrote:
>
> In Python you can do anything, even
...pass the Turing test with a one-liner. Back after 9/11, when US patriotism
was the rage, Python knew how to answer correctly the query
filter(lambda W : W not in 'ILLITERATE','BULLSHIT')
And Python 3.0 slated for next August o
On Feb 17, 3:56 am, Benjamin <[EMAIL PROTECTED]> wrote:
> How would I go about "flattening" a dict with many nested dicts
> within? The dicts might look like this:
> {"mays" : {"eggs" : "spam"},
> "jam" : {"soda" : {"love" : "dump"}},
> "lamba" : 23}
>
> I'd like it to put "/" inbetween the dicts t
Benjamin wrote:
> How would I go about "flattening" a dict with many nested dicts
> within? The dicts might look like this:
> {"mays" : {"eggs" : "spam"},
> "jam" : {"soda" : {"love" : "dump"}},
> "lamba" : 23
> }
> I'd like it to put "/" inbetween the dicts to make it a one
> dimensional dict and
20 matches
Mail list logo