A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2005-August/055455.html below:

[Python-Dev] SWIG and rlcompleter

[Python-Dev] SWIG and rlcompleter [Python-Dev] SWIG and rlcompleterFernando Perez fperez.net at gmail.com
Tue Aug 16 19:17:04 CEST 2005
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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4