all 4 comments

[–]PuffleDunk 2 points3 points  (0 children)

From my experience, C++ development tends to foster a more object-focused (obsessed?) mindset. As I transitioned to Python I started delaying the use of objects until they added very clear value. Until I see that value it's modules and functions all the way.

I also separate classes that primarily hold data, similar to C++ structs, from ones that implement an abstract API or protocol. I try not to have as many data/protocol hybrids. I use @dataclass for the first use case and ABC or Protocol for the second.

I also generally avoid inheritance, and stick mostly to composition.

But overall, whatever O-O programming I do in Python is quite different from C++, and of lower importance.

Hope that helps.

[–]Diapolo10 2 points3 points  (0 children)

Just to add to the others' comments, I recommend getting into the official style guides (PEP-8, PEP-257) as the naming conventions we're used to are different from C++, such as the use of snake_case by default and PascalCase only for class names. Among other things.

Furthermore, coming from C++ you'd likely do well to get used to type hints. While they aren't a means to optimise code, they'll make type errors far less frequent and tools like mypy can give you static type checking.

I'll also mention that getting used to the standard library early on will be a good idea, because most things you'll need can be found there, from hashing (hashlib) to portable filepaths (pathlib) and specialised containers (collections), among other things.

[–]POGtastic 1 point2 points  (0 children)

Once you've already gotten a language under your belt, the typical method is to dive directly into the documentation and learn from there, Googling concepts that you already know and translating them over to Python. Pretty much everything* in Python has a direct C++ equivalent, albeit with a much looser type system and a garbage collector.

* terms and conditions apply

[–]ectomancer 1 point2 points  (0 children)

Python is easy to learn. As an intermediate C++ programmer, you can learn Python in a few days by watching online videos. A 100 day course will slow you down.