[Tutor] nested functions
Cameron Stoner
wolf_binary@hotmail.com
Tue, 9 Apr 2002 16:06:38 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0005_01C1DFE0.87E0A780
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all,
Is it a good or bad idea to call functions with in functions? What =
could you do to not have functions calling functions? I have given an =
example of this bellow.
def splitter(sentence):
import string
list =3D string.split(sentence, sep=3D" ")
return list
# Encrypt sentences
def encryptsent(sentence):
list =3D splitter(sentence) # list is the list of the
# the words in the sentence
count_of_sent =3D len(list)
count =3D count_of_sent - 1 # -1 of count_of_sent to account for =
slicing
# initialize variables
x =3D 0
list_sentence =3D []
=20
while x <=3D count: # x is the counter of each word to be processed
word =3D list[x]
word_encrypted =3D encrypting(word) # encrypt word
=20
quashed_word =3D flow(word_encrypted) # mash character encryption
# together
list_sentence.append(quashed_word)
=20
x =3D x + 1
message =3D flow(list_sentence)
=20
return message
Thanks,
Cameron Stoner
------=_NextPart_000_0005_01C1DFE0.87E0A780
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2713.1100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Is it a good or bad idea to call =
functions with in=20
functions? What could you do to not have functions calling =
functions? I=20
have given an example of this bellow.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>def splitter(sentence):<BR> import =
string<BR> list =3D string.split(sentence, sep=3D" =
")<BR> return=20
list</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2># Encrypt sentences<BR>def=20
encryptsent(sentence):<BR> list =3D splitter(sentence) # list is =
the list of=20
the<BR> # the words in the=20
sentence<BR> count_of_sent =3D len(list)<BR> count =3D =
count_of_sent - 1 #=20
-1 of count_of_sent to account for slicing<BR> # initialize=20
variables<BR> x =3D 0<BR> list_sentence =3D =
[]<BR> <BR> while x=20
<=3D count: # x is the counter of each word to be =
processed<BR> word=20
=3D list[x]<BR> word_encrypted =3D encrypting(word) # encrypt =
word<BR> <BR> quashed_word =3D =
flow(word_encrypted) # mash=20
character =
encryption<BR> #=20
together<BR> list_sentence.append(quashed_word)<BR>  =
;<BR> x=20
=3D x + 1<BR> message =3D =
flow(list_sentence)<BR> <BR> return=20
message</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Cameron Stoner</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV> </DIV></BODY></HTML>
------=_NextPart_000_0005_01C1DFE0.87E0A780--