Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is 'self' optional ?
#5
Quote:that 'self' doesn't need to be in the parameters is a symptom of self being redundant, but seems the python dev team don't want to accept this !


explicit is better Wink
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>> 
Quote:a.) My point that when a function is called, self is not put in the parameter list, but it does appear in the function definition. This is dumb, and will take some getting used to.
I must of just used python for so long i dont even think about it. I (personally) consider self in the class definition to be the switch, to say i want this to be an instance method. Its an easy identifier for methods in a class to determine which is a class/instance method. And when calling it from an instance, not needed it because it is obviously an the instance method. 


If you think its redundant to put self in the parameters, then it would be even more redundant to put self in the call.
Recommended Tutorials:
Reply


Messages In This Thread
is 'self' optional ? - by meems - Nov-25-2016, 08:33 PM
RE: is 'self' optional ? - by metulburr - Nov-25-2016, 09:36 PM
RE: is 'self' optional ? - by Ofnuts - Nov-25-2016, 09:39 PM
RE: is 'self' optional ? - by meems - Nov-26-2016, 12:45 AM
RE: is 'self' optional ? - by metulburr - Nov-26-2016, 02:13 AM
RE: is 'self' optional ? - by nilamo - Dec-06-2016, 08:11 PM
RE: is 'self' optional ? - by metulburr - Dec-06-2016, 08:53 PM
RE: is 'self' optional ? - by nilamo - Dec-06-2016, 10:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  using mutable in function defintion as optional paramter akbarza 8 524 Apr-27-2024, 09:59 PM
Last Post: snippsat
  Trouble making an argument optional linuxnoob 2 2,953 Aug-31-2018, 01:52 AM
Last Post: linuxnoob

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020