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


Groups > comp.lang.python > #21567

Re: concatenate function

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fil.oracle@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.019
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'function,': 0.07; 'python': 0.08; '[0,': 0.09; 'context:': 0.09; 'def': 0.13; '[2,': 0.16; 'clues': 0.16; 'mean,': 0.16; 'nabble.com.': 0.16; 'subject:function': 0.16; 'url:nabble': 0.16; 'wrote:': 0.18; 'archive': 0.21; 'header:In-Reply-To:1': 0.22; 'runs': 0.23; 'object,': 0.24; 'messages.': 0.25; 'code': 0.26; 'function': 0.27; 'tried': 0.27; 'depends': 0.28; 'second': 0.28; 'example': 0.29; 'message-id:@gmail.com': 0.31; "i've": 0.32; 'list': 0.32; 'header:User-Agent:1': 0.33; 'object': 0.33; 'appreciated.': 0.34; 'causing': 0.34; 'calling': 0.34; 'another.': 0.34; 'shorter': 0.34; 'to:addr:python-list': 0.35; 'something': 0.35; 'apply': 0.35; 'url:python': 0.35; 'received:209.85.214': 0.36; 'list,': 0.36; 'run': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'another': 0.37; 'received:209.85': 0.38; 'could': 0.38; 'think': 0.38; 'third': 0.38; 'url:org': 0.39; 'goes': 0.39; 'mailing': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'view': 0.61; 'talking': 0.62; 'results': 0.64; 'here': 0.64; 'here:': 0.67; '<<<': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=g7A8sMSbq970hKOVoH7ZQUEK4ZpAQdOqgP0r+Il3uUI=; b=aENDAAw3v0bVcR2rppQxmZZU5O82WiltlxGi+7dLznQUgjB7bz266RMTHADForGsZc d6DA43UzJN+x1BOShOMWcR2bz7rfZSLuYt/kArzm2SbrgnN0MDhPj91vmDceC0oJ+Uzk 6trb6HxFnmJCjUfASvgud60kzTWSwuusuPAp6PeCoLvPVEbfdW+rCfPRZMX/TYnw92Ey 3zKYMVl3EkDZXKxae/ZWm8xXw3V+wkw6piHapyyazoJI45e13F26KRTp0zpF5Igtx29b /Priz6cYXSfhJiLdN1TjEHzEPhAHSvMhDPikwQGzWo/xusN+260vrSBkwiewlgRCyHFg pOkA==
Date Tue, 13 Mar 2012 15:54:20 +0000
From James Elford <fil.oracle@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: concatenate function
References <1331649332216-4574176.post@n6.nabble.com>
In-Reply-To <1331649332216-4574176.post@n6.nabble.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.616.1331654064.3037.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1331654064 news.xs4all.nl 6878 [2001:888:2000:d::a6]:54425
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21567

Show key headers only | 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