Re: [Tutor] Regarding python function arguments

2013-06-11 Thread Asokan Pichai
On Tue, Jun 11, 2013 at 2:24 PM, Arijit Ukil arijit.u...@tcs.com wrote:

 i am writing following python function:

 def my_func (arg1, arg2, arg3):


 however, I am not always going to pass all the arguments. sometimes only
 arg1 is passed, sometimes arg1 and arg2 are passed; sometimes arg1, arg2,
 arg3 are passed.
 How can i manage this?


Look at keyword arguments:
http://docs.python.org/release/1.5.1p1/tut/keywordArgs.html


BTW, don't you think that the signature attached by your organization is
rather
unsuitable for this list. For example, do I need an explicit disclaimer
from you
that you are not sharing company confidential information, if you post
a solution?

Asokan Pichai

Expecting the world to treat you fairly because you are a good person is a
little like expecting the bull to not attack you because you are a
vegetarian
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Regarding python function arguments

2013-06-11 Thread Todd Matsumoto
One way you can do that is by using default arguments.

def my_func (arg1=False, arg2=False, arg3=False):
# Check the arguments.


On Tue, Jun 11, 2013 at 10:54 AM, Arijit Ukil arijit.u...@tcs.com wrote:

 i am writing following python function:

 def my_func (arg1, arg2, arg3):

 however, I am not always going to pass all the arguments. sometimes only
 arg1 is passed, sometimes arg1 and arg2 are passed; sometimes arg1, arg2,
 arg3 are passed.
 How can i manage this?

 Regards,
 Arijit Ukil
 Tata Consultancy Services
 Mailto: arijit.u...@tcs.com
 Website: http://www.tcs.com
 
 Experience certainty.IT Services
Business Solutions
Consulting
 

 =-=-=
 Notice: The information contained in this e-mail
 message and/or attachments to it may contain
 confidential or privileged information. If you are
 not the intended recipient, any dissemination, use,
 review, distribution, printing or copying of the
 information contained in this e-mail message
 and/or attachments to it are strictly prohibited. If
 you have received this communication in error,
 please notify us by reply e-mail or telephone and
 immediately and permanently delete the message
 and any attachments. Thank you


 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 http://mail.python.org/mailman/listinfo/tutor




-- 
Todd Matsumoto
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor