[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Re: list comprehesnion in variable doesnt work
From: |
feldmaus |
Subject: |
[Discuss-gnuradio] Re: list comprehesnion in variable doesnt work |
Date: |
Sat, 30 May 2009 20:59:12 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Eric Blossom <eb <at> comsec.com> writes:
>
> On Sat, May 30, 2009 at 10:55:50AM +0000, feldmaus wrote:
> > Hi All again,
> >
> > list comprehension doesnt work in variables, for example:
> > [print(i) for i in range(3)]
>
> "print" is a statement, not a function.
>
> I'd probably use:
>
> for i in range(3): print i
>
> > or
> > variable_2 = file('../../../tabs.dat','w')
> > ([variable_2.write(str(i)) for i in [1,2]] is True) &\
> > (variable_2.close() is True)
> > doesnt work.
>
> ([v2.write(str(i)) for i in [1,2]] is True) and v2.close() is True
>
> will of course always be False, since [None, None] is not True
>
> It looks like you are trying to abuse list comprehensions for some kind
> of control flow short cut. I think of them as an equivalent to the
> "map" builtin, a higher-order function.
>
> You may want to consider "map" and "reduce" in combination.
>
Thanks for your answer,
i tried to save some infos, because i can not send a string to the file sink.
However i tried to save to a file AND close this in the next step.
But this doesn't work. I still tried the map function, but doesnt got it
to work. And at least i tried to set up 3 variables in grc to
1.)define a file descriptor
2.)write to the file something
3.)and close the file
the last point doesnt work. I dont know why.
If i insert the close() function manually it works. :-)
But not with grc.
I think there is a problem with the sequence grc set up the variables.
However it doesnt work.
regards markus