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


Groups > comp.lang.python > #26433

Re: Calling Values

From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Newsgroups comp.lang.python
Subject Re: Calling Values
Date 2012-08-03 14:32 +0200
Message-ID <p0tse9-3tp.ln1@satorlaser.homedns.org> (permalink)
References <8bdc29d5-fa88-4ead-a4a1-135d708eeb57@googlegroups.com>

Show all headers | View raw


Am 03.08.2012 13:49, schrieb Subhabrata:
> I am trying to call the values of one function in the
 > another function in the following way:
>
> def func1():
> 	num1=10
> 	num2=20
> 	print "The Second Number is:",num2
> 	return
>
> def func2():
> 	num3=num1+num2
> 	num4=num3+num1
> 	print "New Number One is:",num3
> 	print "New Number Two is:",num4
> 	return
>
> I am preferring not to use argument passing or using class?

You could make those variables global, see the "global" statement in the 
documentation of the language. However: I don't think that is a good 
idea and it will make your program more confusing to read than 
necessary, but go ahead and make that experience yourself. ;)

If you want, you can post your code here when done so that others might 
give you hints how to do things easier and cleaner, like e.g. putting 
spaces around operators and using four spaces indention (See PEP 8) or 
dropping the implied return from functions that return nothing. Apart 
from that, the above code is too short and with too little info what 
it's supposed to achieve, I can't really give you better advise.

Good luck!

Uli

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Calling Values Subhabrata <subhabangalore@gmail.com> - 2012-08-03 04:49 -0700
  Re: Calling Values Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-03 13:07 +0100
  Re: Calling Values Nobody <nobody@nowhere.com> - 2012-08-03 13:44 +0100
  Re: Calling Values Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-03 14:32 +0200
  Re: Calling Values subhabangalore@gmail.com - 2012-08-03 07:38 -0700
    RE: Calling Values "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-08-03 15:30 +0000
    Re: Calling Values Ethan Furman <ethan@stoneleaf.us> - 2012-08-03 08:37 -0700
  Re: Calling Values Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-03 16:24 +0000
  Re: Calling Values Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-03 13:20 -0400
    Re: Calling Values subhabangalore@gmail.com - 2012-08-03 11:23 -0700
    Re: Calling Values subhabangalore@gmail.com - 2012-08-03 11:23 -0700
  Re: Calling Values alex23 <wuwei23@gmail.com> - 2012-08-05 19:56 -0700

csiph-web