Re: [Python-Dev] SWIG and rlcompleter

2005-08-18 Thread M.-A. Lemburg
James Y Knight wrote: > On Aug 17, 2005, at 2:55 PM, Timothy Fitz wrote: > > >>On 8/16/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: >> >> >>>-0 The behavior of dir() already a bit magical. Python is much >>>simpler >>>to comprehend if we have direct relationships like dir() and vars() >>>

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread James Y Knight
On Aug 17, 2005, at 2:55 PM, Timothy Fitz wrote: > On 8/16/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >> -0 The behavior of dir() already a bit magical. Python is much >> simpler >> to comprehend if we have direct relationships like dir() and vars() >> corresponding as closely as poss

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Guido van Rossum
[me] > > A more useful relationship is > > > > name in dir(x) <==> getattr(x, name) is valid [Raymond] > That would be a useful invariant. Well, the <== part can't really be guaranteed due to the existence of __getattr__ overriding (and all bets are off if __getattribute__ is overridden!), b

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Raymond Hettinger
> > [Timothy Fitz] > > > It seems to > > > me that those who want dir to reflect __dict__ should just use > > > __dict__ in the first place. > > [Raymond] > > The dir() builtin does quite a bit more than obj.__dict__.keys(). > > Well that's the whole point, right? Perhaps. I wasn't taking a po

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Guido van Rossum
> [Timothy Fitz] > > It seems to > > me that those who want dir to reflect __dict__ should just use > > __dict__ in the first place. [Raymond] > The dir() builtin does quite a bit more than obj.__dict__.keys(). Well that's the whole point, right? We shouldn't conflate the two. I don't see this as

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Raymond Hettinger
[Timothy Fitz] > It seems to > me that those who want dir to reflect __dict__ should just use > __dict__ in the first place. The dir() builtin does quite a bit more than obj.__dict__.keys(). >>> class A(list): x = 1 >>> dir(A) ['__add__', '__class__', '__contains__', '__delattr__', '__d

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Guido van Rossum
On 8/17/05, Timothy Fitz <[EMAIL PROTECTED]> wrote: > On 8/16/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > -0 The behavior of dir() already a bit magical. Python is much simpler > > to comprehend if we have direct relationships like dir() and vars() > > corresponding as closely as possibl

Re: [Python-Dev] SWIG and rlcompleter

2005-08-17 Thread Timothy Fitz
On 8/16/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > -0 The behavior of dir() already a bit magical. Python is much simpler > to comprehend if we have direct relationships like dir() and vars() > corresponding as closely as possible to the object's dictionary. If > someone injects non-stri

Re: [Python-Dev] SWIG and rlcompleter

2005-08-16 Thread Raymond Hettinger
[Michael Hudson] > I wonder if dir() should strip non-strings? -0 The behavior of dir() already a bit magical. Python is much simpler to comprehend if we have direct relationships like dir() and vars() corresponding as closely as possible to the object's dictionary. If someone injects non-strin

Re: [Python-Dev] SWIG and rlcompleter

2005-08-16 Thread Fernando Perez
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. a.1 a.x In [5]: a.1 -

Re: [Python-Dev] SWIG and rlcompleter

2005-08-16 Thread Fernando Perez
Michael Hudson wrote: > [EMAIL PROTECTED] writes: > >> You don't need something like a buggy SWIG to put non-strings in dir(). >> > class C: pass >> ... > C.__dict__[3] = "bad wolf" > dir(C) >> [3, '__doc__', '__module__'] >> >> This is likely to happen "legitimately", for instance in

Re: [Python-Dev] SWIG and rlcompleter

2005-08-16 Thread Michael Hudson
[EMAIL PROTECTED] writes: > You don't need something like a buggy SWIG to put non-strings in dir(). > class C: pass > ... C.__dict__[3] = "bad wolf" dir(C) > [3, '__doc__', '__module__'] > > This is likely to happen "legitimately", for instance in a class that allows > x.y and x['y'

Re: [Python-Dev] SWIG and rlcompleter

2005-08-15 Thread jepler
You don't need something like a buggy SWIG to put non-strings in dir(). >>> class C: pass ... >>> C.__dict__[3] = "bad wolf" >>> dir(C) [3, '__doc__', '__module__'] This is likely to happen "legitimately", for instance in a class that allows x.y and x['y'] to mean the same thing. (if the user ass

Re: [Python-Dev] SWIG and rlcompleter

2005-08-15 Thread Fernando Perez
Guido van Rossum wrote: > (1) Please use the SF patch manager. > > (2) Please don't propose adding more bare "except:" clauses to the > standard library. > > (3) I think a better patch is to use str(word)[:n] instead of word[:n]. Sorry to jump in, but this same patch was proposed for ipython, a

Re: [Python-Dev] SWIG and rlcompleter

2005-08-15 Thread Guido van Rossum
(1) Please use the SF patch manager. (2) Please don't propose adding more bare "except:" clauses to the standard library. (3) I think a better patch is to use str(word)[:n] instead of word[:n]. On 8/14/05, Michael Krasnyk <[EMAIL PROTECTED]> wrote: > Hello all, > > Recently I've found that rlco