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


Groups > comp.lang.python > #21567 > unrolled thread

Re: concatenate function

Started byJames Elford <fil.oracle@gmail.com>
First post2012-03-13 15:54 +0000
Last post2012-03-13 15:54 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#21567 — Re: concatenate function

FromJames Elford <fil.oracle@gmail.com>
Date2012-03-13 15:54 +0000
SubjectRe: concatenate function
Message-ID<mailman.616.1331654064.3037.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web