Skip to content

Some thoughts about this example #11

@unkcpz

Description

@unkcpz

@dataclass
class Apple:
name: str
def grow() -> List[Apple]:
apples = [Apple("a"),
Apple("b")]
for b in apples:
print(f"Apple: {b.name}")

I personally like this example very much, after 1 year of rust I would write my python code in this way. But for a python programmer or from other OOP, I believe they will be struggle about this. I believe 9 of 10 python programmer will come up with a Tree class and inherit it to get a AppleTree and make grow a method of Tree. Life sucks..

You may have good idea how to present it, looking forward to hear it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions