Guido van Rossum wrote:
> (3) I think a better patch is to use str(word)[:n] instead of word[:n].
Mmh, I'm not so sure that's a good idea, as it leads to this:
In [1]: class f: pass
...:
In [2]: a=f()
In [3]: a.__dict__[1] = 8
In [4]: a.x = 0
In [5]: a.<TAB HIT HERE>
a.1 a.x
In [5]: a.1
------------------------------------------------------------
File "<console>", line 1
a.1
^
SyntaxError: invalid syntax
In general, foo.x named attribute access is only valid for strings to begin with
(what about unicode in there?). Instead, this is what I've actually
implemented in ipython:
words = [w for w in dir(object) if isinstance(w, basestring)]
That does allow unicode, I'm not sure if that's a good thing to do.
Cheers,
f
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com