[SIP] How to hide helper functions?
Phil Thompson
phil at riverbankcomputing.com
Sat Jul 2 10:55:15 BST 2022
On 02/07/2022 10:30, Weitian Leung wrote:
> No because the Python Foo.get_Count() will only raise an exception.
> Not exactly, because the interface is created by another interface,
> get_Count() can be called normally.
>
> Is it due to python property need to call the C++ method explicitly?
Python properties have an explicit getter. They don't go through the MRO
to find the getter and so wouldn't find a non-abstract reimplementation
of get_Count().
Phil
> ________________________________
> From: Phil Thompson <phil at riverbankcomputing.com>
> Sent: Saturday, July 2, 2022 4:34 PM
> To: Weitian Leung <Just_Fancy at live.com>
> Cc: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
> Subject: Re: [SIP] How to hide helper functions?
>
> On 02/07/2022 09:09, Weitian Leung wrote:
>> I have such situation that want to hide the handwritten functions, for
>> example
>> struct Foo /Abstract/
>> {
>> HRESULT get_Count(long *count /Out/) = 0;
>> long getCount();
>> %MethodCode
>> long count = 0;
>> sipCpp->get_Count(&count);
>> sipRes = count;
>> %End
>> %Property(name=Count, get=getCount)
>> };
>> the getCount is not the original interface method, I just want to make
>> the get_Count be a property, so write one helper function and use the
>> %Property directive.
>> But I don't want the user see or call the getCount method directly,
>> only the get_Count or Count property is acceptable.
>>
>> It is possible do that?
>
> No.
>
>> Or is any other way to expose get_Count as a property?
>
> No because the Python Foo.get_Count() will only raise an exception.
>
> Phil
More information about the PyQt
mailing list