Python

Moderators: None (Apply to moderate this forum)
Number of threads: 473
Number of posts: 1165

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
passing variables between functions Posted by rul on 21 Feb 2004 at 10:43 PM
how do i pass variables from one function to another in python?
Report
Re: passing variables between functions Posted by infidel on 23 Feb 2004 at 8:10 AM
: how do i pass variables from one function to another in python?

Same way you passed them to the first function.

def func1(x, y):
    return func2(x, y, 1, 2)

def func2(a, b, c, d):
    return a + b + c + d

print func1(8, 9)



infidel

$ select * from users where clue > 0
no rows returned


Report
Re: passing variables between functions Posted by egrove on 16 Dec 2012 at 9:11 PM
def function(x, y):
total = x + y
return total

def main():
a = 5
b = 10
total = function(a,b)
print a, b, total

main()

By doing this you can pass args from main to a function and can get back any value by returning from that function.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.