I am writing a Python shell class for the C # API, accessed through Pythonnet. Since I want to extend the API with my own methods, I decided to wrap it using the compositional approach indicated here :
The C # API makes heavy use of the properties that I want to simulate in my Python code. The following minimal example shows my current approach for an example of a C # Surface class with two width and height properties:
class MySurface:
def __init__(api_surface):
self.api_surface = api_surface
@property
def width(self):
return self.api_surface.width
@width.setter
def width(self, value):
self.api_surface.width = value
@property
def height(self):
return self.api_surface.height
@height.setter
def height(self, value):
self.api_surface.height = value
, 50 . , ..
, , - , . factory . !
: python, . {hit tab} surface.width surface.height. getattr, .