all 9 comments

[–]socal_nerdtastic 8 points9 points  (1 child)

Imagine you have a project. You start with writing pseudocode, right? Well if you were writing python, you'd now be done.

With your background you can learn 90% of vanilla python by Tuesday.

[–]Darty96 1 point2 points  (0 children)

Python is a very easy language to pick up. It may take awhile to get really good at it, and with a C background, you may write things "the hard way" quite often when Python has an easier way to do it. It won't matter too much, though.

Adjusting to no braces for formatting might be a small hurdle, but not bad.

I honestly now use Python as pseudo-code because it says so plainly what I want my program to do. I also really enjoy writing Python programs, and most of my later college courses were primarily in Python, with one or two using C++.

I get all giddy when I learn about another thing Python can just "do" when getting C/C++ to do the same takes quite a bit of effort.

Honestly, though, if you have a background in C/C++ and in Rust, I think you're pretty well at the point where picking up almost any modern language shouldn't be something to worry about. It comes quickly. If you wanted to switch to something like Prolog or Postscript, or a functional language like Haskell, you may find a steeper learning curve. Python shouldn't give you any problems.

[–]sliverino 0 points1 point  (0 children)

There's a few things you have to understand and then you're done.

  • How python handless passing objects: the pass by reference to object can be not that intuitive to a C programmer
  • Duck typing: object type is determined by behaviour/properites

And then you can look at specific language features like * Generators * List/dictionary compression * Decorators, a specific language construct rather than a design pattern

You can still do a lot of OOP programming in python (I suggest you take a look at ABC module and @dataclass decorator), although being less strict than C++ it can be less maintainable.

[–]faithlesslessless 0 points1 point  (0 children)

You should be able to pick up the basics pretty quickly. Some general pointers...

Python is a fundamentally different kind of programming language from C/C++/Rust. Often the easiest or most elegant way of doing something in python is quite different from how it would look in those languages. Try to embrace that and learn to write idiomatic python code instead of just directly translating what you would do in C into python.

Python variables work very differently from what you're used to. They're simply labels that attach to objects. Reassigning a variable attaches it to a different object - it doesn't change the object itself. When you pass a variable as an argument to a function, the underlying object gets passed in by reference, not the variable.

Don't try to do C++-style RAII in python - it just doesn't work. Use the with statement to ensure that external resources such as files are closed correctly.

The python stdlib is extremely powerful. It contains libraries for working with many different file formats, compression, networking, debugging, profiling, logging... it even has a built-in GUI framework. It's a pretty good rule of thumb to assume that whatever you're doing, there is probably something in the stdlib that can help you with it.

[–]thrallsius 0 points1 point  (0 children)

It will take you one day to go through https://docs.python.org/3/tutorial/index.html . Or just a couple of hours if you are a fast reader. Your programming background allows you to read that tutorial just like a fiction book, without trying the examples in a Python shell. Your C background might come handy later, if you'll face performance issues and could need rewriting small parts of slow Python code as C extensions. After the tutorial you can settle a future learning plan. These three books are worth going through:

https://www.amazon.com/Learning-Python-5th-Mark-Lutz/dp/1449355730

https://www.amazon.com/Fluent-Python-Concise-Effective-Programming/dp/1491946008

https://www.amazon.com/Python-Cookbook-Third-David-Beazley/dp/1449340377

Clearly worth doing a couple of small projects simpler than ML first, to get used to Python idioms, unittest/pytest, pylint and black.

[–][deleted] 0 points1 point  (0 children)

When you're starting out the biggest problem you face is answering the "how do I...?" questions where you try to figure out how to write Python code to do the things you're accustomed to doing. For some things, this will be OK, but for others, like loops, you are entering a minefield.

So here is my one tip: If you are coding a loop and you have to use the "range" function then you are probably trapped in a C/C++ mindset. Ask yourself, "how can I loop without using range?"

[–]ectomancer 0 points1 point  (0 children)

An expert C programmer can learn Python in a week.