티스토리 뷰
728x90
class MyClass(object):
def __init__(self):
print "never called in this case"
def __new__(cls):
return 42
obj = MyClass()
print obj
https://stackoverflow.com/questions/2491819/how-to-return-a-value-from-init-in-python
How to return a value from __init__ in Python?
I have a class with an __init__ function. How can I return an integer value from this function when an object is created? I wrote a program, where __init__ does command line parsing and I need t...
stackoverflow.com
728x90
'공부' 카테고리의 다른 글
[Git 에러] Fatal: 정방향이 불가능하므로, 중지합니다. (0) | 2022.05.08 |
---|---|
[Airflow] dag, execution_date, template_fields & self.{value} logging (0) | 2022.05.07 |
[Python] __new__ return constructor (0) | 2022.05.07 |
[K8s] Ingress (0) | 2022.05.07 |
[Airflow] kafka producer flush() not working (solution: instanciate object in execute) (0) | 2022.05.07 |
[docker-compose] `docker-compose -f docker-compose.yml up` (0) | 2022.05.07 |
댓글