go-python / go-python/gpython

Support inheriting Go objects in Python and overriding methods/attributes?

Đang mở
#247 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
1k
Fork
105
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I am exploring gpython to embed Python scripting in a Go project. I have the following question regarding object interoperability:

- Is it possible to define a Python class that inherits from a Go object exposed to gpython?
- Can such a Python subclass override methods or add new attributes on top of the Go object?

For example, in Python I would like to do something like:
```python
# Hypothetical example
class PyVacation(MyGoVacation):
def new_method(self):
return "Python override"

@property
def new_attr(self):
return "Python attribute"
```

Currently, I am able to expose Go objects to gpython and call Go methods, but I am unsure if inheritance is supported.

Could you clarify whether this is possible, and if not, are there recommended workarounds (e.g., composition or monkey-patching) to extend Go objects in Python?

Thank you for your help!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.