A newbie doubt on methods/functions calling

BartC bc at freeuk.com
Thu Oct 6 19:48:03 EDT 2016


On 06/10/2016 18:06, 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"

As has been pointed out, it's difficult to tell whether a space should 
mean a "." or "(". Or, as is also possible, "=" or "+" or any other kind 
of operator.

But even sticking only with "." and "(", then something like:

   a b c d e f g

could be interpreted in a myriad different ways. Python requires that 
this is determined at 'compile' time, but information about what each 
name is (class, instance, function, attribute etc), which might help 
resolve the ambiguity, isn't available until run-time.

> 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.

It would be hard without extra clues, or extra restrictions on what is 
possible. But even if a translator could figure out what is what, a 
human reader will have trouble.

What's the problem with typing "." and "(" anyway; keyboard problems? 
(If so then keep away from languages such as C and C++ because they have 
a /lot/ more punctuation!) Or used to a language that doesn't require 
(,) around function arguments?

-- 
Bartc



More information about the Python-list mailing list