Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21567

Re: concatenate function

Date 2012-03-13 15:54 +0000
From James Elford <fil.oracle@gmail.com>
Subject Re: concatenate function
References <1331649332216-4574176.post@n6.nabble.com>
Newsgroups comp.lang.python
Message-ID <mailman.616.1331654064.3037.python-list@python.org> (permalink)

Show all headers | View raw


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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: concatenate function James Elford <fil.oracle@gmail.com> - 2012-03-13 15:54 +0000

csiph-web