On Monday, January 20, 2014 4:32:40 PM UTC+5:30, Piet van Oostrum wrote:
> "Rhodri James" writes:
> > On Sat, 18 Jan 2014 16:00:45 -, Jussi Piitulainen wrote:
> [...]
> >> I would write that on three lines anyway, properly indented:
> >> [ somefunc(mn,day,wd,name)
> >> for (then, name)
"Rhodri James" writes:
> On Sat, 18 Jan 2014 16:00:45 -, Jussi Piitulainen
> wrote:
[...]
>> I would write that on three lines anyway, properly indented:
>>
>> [ somefunc(mn,day,wd,name)
>> for (then, name) in mylist
>> let (_,mn,dy,_,_,_,wd,_,_) = localtime(then) ]
>>
>> It coul
On Sat, 18 Jan 2014 16:00:45 -, Jussi Piitulainen
wrote:
Rustom Mody writes:
On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote:
> What would a list-comp with `let` or `where` look like? Would it
> win the beauty contest against the loop?
For me this is neat
[somefu
John Allsup writes:
> Hi,
>
> I'd agree with the advice that it's not the best idea: readability sucks
> here, but consider the following:
>
>
> import time
>
> def somefunc(a,b,c,d): # dummy function
> return "{} - {} - {} : {}".format(a,b,c,d)
> l = [(time.time(),"name {}".format(n)) for n
Hi,
I'd agree with the advice that it's not the best idea: readability sucks
here, but consider the following:
import time
def somefunc(a,b,c,d): # dummy function
return "{} - {} - {} : {}".format(a,b,c,d)
l = [(time.time(),"name {}".format(n)) for n in range(100)] # dummy data
# the li
Alain Ketterlin writes:
> Piet van Oostrum writes:
> [...]
>> Python misses a 'where' or 'let'-like construction as in Haskell.
>
> "let x = v in e" really is (lambda x:e)(v)
>
You are right, but it is a lot less readable IMHO.
--
Piet van Oostrum
WWW: http://pietvanoostrum.com/
PGP key: [8DAE
Rustom Mody writes:
> On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote:
>
> > What would a list-comp with `let` or `where` look like? Would it
> > win the beauty contest against the loop?
>
> For me this is neat
>
> [somefunc(mn,day,wd,name) for (then, name) in mylist let
>
On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote:
> Options I can think of:
> You could do it in two steps...
> time_name_pairs = ((localtime(then), name) for then, name in mylist)
> labels = [somefunc(t.tm_mon, t.tm_mday, t.tm_wday, name)
> for t, name in time_na
Piet van Oostrum writes:
[...]
> I could define a auxiliary function like:
>
> def auxfunc(then, name):
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> return somefunc(mn, day, wd, name)
>
> and then use
> [auxfunc(then, name) for then, name in mylist]
[...]
> labels = [somefunc(mn,
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 2014-01-17, 23:19 GMT, you wrote:
> But defining the auxfunc takes away the elegance of a list
> comprehension.
Au contraire! Remember, that brevity is the sister of talent.
I would definitively vote for
labels = [make_label(then, name) f
Rustom Mody writes:
> On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote:
[...]
>
>> Python misses a 'where' or 'let'-like construction as in Haskell.
>
> +1
> Yes Ive often been bitten by the lack of a 'comprehension-let'
If it used only in a comprehension as in my exampl
Piet van Oostrum wrote:
> Hi,
>
> I am looking for an elegant way to write the following code as a list
> comprehension:
>
> labels = []
> for then, name in mylist:
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> labels.append(somefunc(mn, day, wd, name))
>
> So mylist is a list of t
On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote:
> Hi,
> I am looking for an elegant way to write the following code as a list
> comprehension:
> labels = []
> for then, name in mylist:
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> labels.append(somefunc(mn,
On Fri, Jan 17, 2014 at 3:19 PM, Piet van Oostrum wrote:
> Hi,
>
> I am looking for an elegant way to write the following code as a list
> comprehension:
>
> labels = []
> for then, name in mylist:
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> labels.append(somefunc(mn, day, wd, name)
Hi,
I am looking for an elegant way to write the following code as a list
comprehension:
labels = []
for then, name in mylist:
_, mn, dy, _, _, _, wd, _, _ = localtime(then)
labels.append(somefunc(mn, day, wd, name))
So mylist is a list of tuples, the first member of the tuple is a time
15 matches
Mail list logo