title: __enter__ , __exit__ , with block is not working
body: <p>When I try to execute this code , it returns this error </p>
  
  <pre><code>Traceback (most recent call last):
    File "with.py", line 13, in &lt;module&gt;
      with A as a:
  AttributeError: __enter__"
  </code></pre>
  
  <p>I searched and found that this error occurs when I haven't define <code>__enter__</code> or <code>__exit__</code>  methods. but I defined both, and still getting this error</p>
  
  <pre><code>class A:
      def __enter__(self):
          self.t='printing from enter variable t'
          return self.t
  
      def fun(self):
          print("inside fun")
          print(self.t)
  
      def __exit__(self, exception_type, exception_value, traceback):
          print("exiting.........")
          print(exception_type, exception_value, traceback)
  
  with A as a:
      a.fun()
  </code></pre>