python leading and trailing underscores in user defined functions
<p>How can i used the rt function, as i understand leading &amp; trailing underscores <code>__and__()</code> is available for native python objects or you wan't to customize behavior in specific situations. how can the user take advantages of it . For ex: in the below code can i use this function at all,</p>

<pre><code>class A(object):
  def __rt__(self,r):
      return "Yes special functions"


a=A()
print dir(a)
print a.rt('1') # AttributeError: 'A' object has no attribute 'rt'
</code></pre>

<p>But</p>

<pre><code>class Room(object):



  def __init__(self):
     self.people = []

  def add(self, person):
     self.people.append(person)

   def __len__(self):
     return len(self.people)



room = Room()
room.add("Igor")
print len(room) #prints 1
</code></pre>

<p>Because there are builtin methods that you can overriden and then you can use them, ex <code>__len__</code> -> <code>len()</code>, <code>__str__</code> -> <code>str()</code> and etc.</p>

<p>Here is the <a href="https://docs.python.org/3/reference/datamodel.html#basic-customization" rel="nofollow">list of these functions</a></p>

<blockquote>
  <p>The following methods can be defined to customize the meaning of attribute access (use of, assignment to, or deletion of x.name) for class instances.</p>
</blockquote>

python