On Sat, 2005-03-05 at 00:00 -0700, Dave Benjamin wrote:
> On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote:
> > Is there a better, more FP style, more Pythonic way to
> > write this:
> >
> > def compute_vectors(samples, dset):
> > vectors = {}
> > for d in dset:
> > vectors[d] =
On Fri, 2005-03-04 at 08:36 -0800, gf gf wrote:
> Is there a better, more FP style, more Pythonic way to
> write this:
>
> def compute_vectors(samples, dset):
> vectors = {}
> for d in dset:
> vectors[d] = [sample.get_val(d) for sample in
> samples]
> return vectors
Michael Hoffman wrote:
Steve Holden wrote:
return dict([(d, sample.getval(d)) for d in dset for sample in samples])
That won't do what the original code does. This sets dict[d] to
samples[-1].getval(d) instead of [sample.getval(d) for sample in samples].
My bad, I didn;t look closely enbough to se
Steve Holden wrote:
return dict([(d, sample.getval(d)) for d in dset for sample in samples])
That won't do what the original code does. This sets dict[d] to
samples[-1].getval(d) instead of [sample.getval(d) for sample in samples].
--
Michael Hoffman
--
http://mail.python.org/mailman/listinfo/pytho
On Fri, 4 Mar 2005 08:36:49 -0800 (PST), gf gf
<[EMAIL PROTECTED]> wrote:
> Is there a better, more FP style, more Pythonic way to
> write this:
>
> def compute_vectors(samples, dset):
> vectors = {}
> for d in dset:
> vectors[d] = [sample.get_val(d) for sample in
>
gf gf wrote:
Is there a better, more FP style, more Pythonic way to
write this:
def compute_vectors(samples, dset):
vectors = {}
for d in dset:
vectors[d] = [sample.get_val(d) for sample in
samples]
return vectors
Namely, I'd like to get rid of the initilizat
gf gf wrote:
Is there a better, more FP style, more Pythonic way to
write this:
def compute_vectors(samples, dset):
vectors = {}
for d in dset:
vectors[d] = [sample.get_val(d) for sample in
samples]
return vectors
Namely, I'd like to get rid of the initilizat
Is there a better, more FP style, more Pythonic way to
write this:
def compute_vectors(samples, dset):
vectors = {}
for d in dset:
vectors[d] = [sample.get_val(d) for sample in
samples]
return vectors
Namely, I'd like to get rid of the initilization
(vector