concatenate function

James Elford fil.oracle at gmail.com
Tue Mar 13 16:54:20 CET 2012


On 13/03/12 14:35, ferreirafm wrote:
> Hi List,
> I've coded three functions that I would like to concatenate. I mean, run
> them one after another. The third function depends on the results of the
> second function, which depends on the results of the first one. When I call
> one function after another, python runs them at the same time causing
> obvious errors messages. I've tried to call one of them from inside another
> but no way. Any clues are appreciated.


> Complete code goes here: 
> http://ompldr.org/vZDB4OQ

Do you think you could provide a much shorter example to illustrate what
you need? In general, when you want to run one function on the result of
another, you can do something like:

<<< def increment_all(l);
...	return [i+1 for i in l]

<<< increment_all(increment_all(range(3))
[2, 3, 4]

Here we apply the function increment_all to the result of the function
increment_all.

If you are talking about the "results" of each function in terms of it
mutating an object, and then the next function mutating the same object
in a (possibly) different way, then calling the functions in order will
do what you want.

l = [0, 3, 5, 2]
l.append(10)		# [0, 3, 5, 2, 10]
l.sort()		# [0, 2, 3, 5, 10]
l.append(3)		# [0, 2, 3, 5, 10, 3]

James

> 
> 
> 
> --
> View this message in context: http://python.6.n6.nabble.com/concatenate-function-tp4574176p4574176.html
> Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list