[Python-ideas] breaking out of module execution

Jim Jewett jimjjewett at gmail.com
Thu Apr 26 22:30:32 CEST 2012


On Wed, Apr 25, 2012 at 11:31 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Matt Joiner wrote:
>>
>> If not use_simple_api:
>>    class C:

> More like:
>
>  class C:
>    def basic_method(self):
>      pass
>    if not use_simple_gui:
>      def advanced_method(self, this, that):
>        pass


He may have been thinking of a replacement idiom

    class C:
        ...

    if system_has_propertyX():
        class C(C):
            # Extend the Base class, but keep the name...


-jJ



More information about the Python-ideas mailing list