How to call built in function 'open' from inside object that has 'open' method?
Jp Calderone
exarkun at intarweb.us
Wed Apr 30 11:47:50 EDT 2003
On Wed, Apr 30, 2003 at 10:43:52AM -0400, Aahz wrote:
> 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.)
The builtin open is called.
There would be a problem with this class, though:
class C:
def open(self, name):
...
f = open('foo')
Jp
--
Seduced, shaggy Samson snored.
She scissored short. Sorely shorn,
Soon shackled slave, Samson sighed,
Silently scheming,
Sightlessly seeking
Some savage, spectacular suicide.
-- Stanislaw Lem, "Cyberiad"
--
up 41 days, 11:04, 5 users, load average: 0.14, 0.11, 0.03
More information about the Python-list
mailing list