[Tutor] Functions and Variable Names
bob smith
bobsmith327@hotmail.com
Mon Feb 24 16:50:11 2003
I'm back with another question about functions and variable names.
Okay, if I have separate functions, I know I can pass a value between them
with the same variable name. But is that considered poor programming? Will
it make things unclear? Here’s an trivial example of what I mean:
def f1(score):
print "Your score of %d has been recorded." %score
def f2(score):
if score > 80:
print "Great job!"
else:
print "Keep trying."
f1(score)
def main():
score = 90
f2(score)
main()
"score" is the prefect name for what I'm representing, but should I have
different names for this value in each function? This would seem odd to me,
but I'm trying to learn the best way to program in Python.
Thanks.
Bob
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail