[PyKDE] a few issues

Phil Thompson phil at riverbankcomputing.co.uk
Tue Aug 9 09:43:06 BST 2005


> On Mon, 8 Aug 2005 21:07:43 +0100
> Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
>
>> On Monday 08 August 2005 7:14 pm, Gerard Vermeulen wrote:
>> > On Mon, 8 Aug 2005 18:50:27 +0100
>> >
>> > Phil Thompson <phil at riverbankcomputing.co.uk> wrote:
>> > > On Friday 29 July 2005 6:16 am, Gerard Vermeulen wrote:
>> > > > (1) (public) member data of class Foo does not show up in
>> dir(Foo).
>> > > >     This trips up tools like PyChecker and the standard library
>> module
>> > > >     inspect.py
>> > >
>> > > Works for me. Do you have an example .sip file in case I'm
>> > > misunderstanding what you mean?
>> >
>> > Sorry, I was not clear enough: public data shows up in instances but
>> not
>> > in classes:
>> >
>> > %Module v 0
>> >
>> > class C
>> > {
>> > %TypeHeaderCode
>> > class C
>> > {
>> > public:
>> >     void alwaysVisible() {};
>> >     int hiddenInClassButVisibleInInstance;
>> > };
>> > %End
>> >
>> > public:
>> >     void alwaysVisible();
>> >     int hiddenInClassButVisibleInInstance;
>> > };
>> >
>> >
>> > And now:
>> >
>> > [packer at titan data]$ python
>> > Python 2.4 (#2, Feb 12 2005, 00:29:46)
>> > [GCC 3.4.3 (Mandrakelinux 10.2 3.4.3-3mdk)] on linux2
>> > Type "help", "copyright", "credits" or "license" for more information.
>> >
>> > >>> from v import *
>> > >>> dir(C)
>> >
>> > ['__class__', '__delattr__', '__doc__', '__getattribute__',
>> '__hash__',
>> > '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
>> > '__repr__', '__setattr__', '__str__', '__weakref__', 'alwaysVisible']
>> >
>> > >>> c = C()
>> > >>> dir(c)
>> >
>> > ['__class__', '__delattr__', '__doc__', '__getattribute__',
>> '__hash__',
>> > '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
>> > '__repr__', '__setattr__', '__str__', '__weakref__', 'alwaysVisible',
>> > 'hiddenInClassButVisibleInInstance']
>>
>> But an instance variable doesn't make any sense in that context. What
>> object
>> would you expect C.__dict__['hiddenInClassButVisibleInInstance'] to be?
>>
>
> Something similar as file.__dict__['softspace']:
>
>>>> dir(file)
> ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__',
> '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__',
> '__repr__', '__setattr__', '__str__', 'close', 'closed', 'encoding',
> 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read',
> 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell',
> 'truncate', 'write', 'writelines', 'xreadlines']
>>>> file.__dict__['seek']
> <method 'seek' of 'file' objects>
>>>> file.__dict__['softspace']
> <member 'softspace' of 'file' objects>

softspace is implemented as a class member - wrapped C++ instance
variables can't be implmented in the same way. If they were implemented as
Python properties then it might work as you expect - I'll have a look at
this when I get the chance.

Phil




More information about the PyQt mailing list