A newbie doubt on methods/functions calling

Peter Otten __peter__ at web.de
Thu Oct 6 13:30:04 EDT 2016


mr.puneet.goyal at gmail.com wrote:

> Hi
> 
> I just started learning python. Is there any way to call functions in
> different way ?
> 
> Rather calling obj.function(arg1, arg2) I would like to call like below
> 
> "obj function arg1 arg2"

How would the machine reading the above know that you didn't mean

obj(function, arg1, arg2)

or

obj.function.arg1(arg2)

?
 
> this function is part of a class.
> 
> class myClass:
>     def function(arg1, arg2):
>          # do something
> 
> Is it possible to do in python ? May be not directly but using some other
> methods.

No, that would be a different language, and if someone were to implement it 
this would make you a newbie in two languages -- hardly an improvement ;)




More information about the Python-list mailing list