Ethan Furman stoneleaf.us> writes:
>
>
> No. The reply from MRAB explains this.
>
> ~Ethan~
>
Thanks, you're right!
I was confusing statemens with declarations.
--
http://mail.python.org/mailman/listinfo/python-list
Jose H. Martinez gmail.com> writes:
>
>
> You should define the function first and then call it.
>
>
> def something(i): return i
>
>
> a = something(5)
>
>
> If you want a reference to the function somewhere else you can do this:
>
I know that. That was what I meant by "changing t
I'm puzzled with the following example, which is intended to be a part of a
module, say "tst.py":
a = something(5)
def something(i):
return i
When I try:
->>> import tst
The interpreter cries out:
Traceback (most recent call last):
File "", line 1, in
File "tst.py", line 11
>From a sequence of numbers, I'm trying to get a list that does something to
>even
numbers but leaves untouched the odd ones, say:
[0,1,2,3,4,...] ==> [100,1,102,3,104,...]
I know that this can be done with an auxiliary function, as follows:
->>> def filter(n):
... if (n%2 == 0):
...
J. Cliff Dyer sdf.lonestar.org> writes:
>
> readlines() reads all the lines from the filehandle, but the filehandle
> hasn't signalled that it is done writing lines, so fo is waiting until
> fi is complete. You either need to keep reading one line at a time, and
> manually release control when
MRAB mrabarnett.plus.com> writes:
>
> I believe it's waiting for the end of the input, i.e. for the pipe to
> close.
>
> Have you tried calling fo.readline() 3 times instead?
>
yeah! It worked!...
A question remains: what is then the purpose of fo.readlines(...)?
Thanks,
--Sergio
--
htt
I'm trying to call an external process to filter some of my data, i.e., I'm
trying to pass some information to the called process, and have this
information
back transformed. I started testing with the linux 'cat' command, in this way:
->>> import subprocess as sp
->>> p = sp.Popen(["cat"],std
I want to use the sign function. When I use it in in-line mode works pretty
well:
: sign(-20)
: -1
However, I wrote the following code in a file, say, pp.py
def tst(x):
s = sign(x)
return(s)
Then I tried to import into my session:
: from pp import *
When I try to use tst, thi