Colon expected error
<p>I have a simple problem.</p>

<pre><code>class MyObj:
   ...
   def get_file_name(self):
    return "myfile.txt" 

some_obj = MyObj()

# Error: Colon expected
with open some_obj.get_file_name() as f:
  print("dealing with file ...")
  # do something on f
</code></pre>

<p><code>MyObj</code> class has a method called <code>get_file_name(self)</code>, which returns a string of file name.</p>

<p>In the code of opening the file, I got compiler error <strong>Colon expected</strong>. I don't see where/why colon needed. Please help me why I got this error?</p>