How to call built in function 'open' from inside object that has 'open' method?

Aahz aahz at pythoncraft.com
Wed Apr 30 16:43:52 CEST 2003


In article <mailman.1051711257.436.python-list at python.org>,
Fredrik Lundh <fredrik at pythonware.com> wrote:
>"vadim" <vf at interna.ru> wrote:
>>
>> I am new to Python and do not know the answer to very simple how to
>> 'open' from inside another object that has 'open' method. I know that
>> in C++ I should use following syntax ::open.
>>
>> More details on reasons. I have met this problem trying to write a
>> simple script use ActiveScripting inside IE.  I am trying "file =
>> open(...) but because context window object has 'open' method that
>> just opens window it is called first.
>
>Unless you're typing "file = self.open(...)", the class you're in has
>nothing to do with it.

Not quite true; what happens with

    class C:
        def open(self, name):
            f = open(name)

(Which is how I interpreted vadim, possibly incorrectly.)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"In many ways, it's a dull language, borrowing solid old concepts from
many other languages & styles:  boring syntax, unsurprising semantics,
few automatic coercions, etc etc.  But that's one of the things I like
about it."  --Tim Peters on Python, 16 Sep 93




More information about the Python-list mailing list