Bizarre error from help()

Roy Smith roy at panix.com
Wed Aug 10 05:25:16 CEST 2005


Roy Smith <roy at panix.com> wrote:
> No, that works fine. But, now I can't even reproduce the error I reported 
> earlier (when I try, I get the help message as expected).  And, yes, that 
> was with a brand new interpreter session.  Strange.

I got it now!  Oh, this is funny.

I've got a directory where I keep all sorts of little snippets of python 
code for testing.  When I start up python in that directory, I get the 
error I reported.  It turns out, I've got a file called "string.py" in it, 
with the contents:

----------------------------
Roy-Smiths-Computer:play$ cat string.py
#!/usr/bin/env python

class myString (str):
    def __init__ (self, value):
        self.value = value

    def plural (self):
        if self.value[-1] in "sz":
            return self.value + "es";
        else:
            return self.value + "s";

foo = myString("foo")
bar = myString("bar")
baz = myString("baz")

print foo.plural(), bar.plural(), baz.plural()
print foo.capitalize()
----------------------------

something in the help system must be doing an "import string".



More information about the Python-list mailing list