Learning Python

Started by Laura Hunt, Sat 30/05/2020 09:21:20

Previous topic - Next topic

Laura Hunt

Hi everybody.

I'm thinking of dipping my toes in the fantabulous world of Python, but there are so many online tutorials, courses, introductions and books out there that I'm overwhelmed by choice and don't even know where to start.

Could anybody recommend a good starting point? I'm a very hands-on learner, so I would definitely prefer tutorials that give you stuff to do with what you've learned.

In case this helps, I would like to focus eventually (when and if I achieve certain proficiency) on QA testing automation. I guess this is not really relevant right now that I'm just starting off, but maybe it can help determine what I should focus on the most.

Thanks in advance! :)

EDIT: Couple more questions: Python 2 or 3? And which IDE would be best to start with?

Blondbraid

Well, I found this nice video on Pythons for beginners;


Khris

Python 2 has officially reached EOL, so I'd definitely go for 3.

As for the IDE, a light-weight one is Visual Studio Code (which is awesome for programming in general).
Dedicated Python support is provided by PyCharm, which has a free community edition.

Codecademy has a free online Python course, unfortunately it's for Python 2. If you're fine with the switch from "print a" to "print(a)" later, check it out.

morganw

Quote from: Khris on Sat 30/05/2020 11:22:46
As for the IDE, a light-weight one is Visual Studio Code (which is awesome for programming in general).
This is the best environment that I have used when I have made something in python. It pretty much sets itelf up with an integrated debugger and doesn't try to force its own concepts on you.

I would only add that:

  • The documentation on the python website is pretty good and there are normally lots of examples. It won't walk you through building something, but there is a tutorial to get you started.
    https://docs.python.org/3/tutorial/
  • If you start making something that requires additional packages to be installed it is fairly critical to understand where these get installed. Typically you want to use something like a venv so that you can work on more than one project at a time, without needing the python and package versions to be compatible between the two projects. This can also affect things like the Visual Studio Code automated setup, because it will probably want to install some packages on your behalf. So typically a good starting point with Windows is to make sure that when you run the python installer you choose to install it per user and not globally for everyone on the computer, and then create a venv per project. I think PyCharm likes to get move involved and also manage venvs for you.

Laura Hunt

Thanks both! I'll start with Visual Studio Code then and see how it works for me :)

As to tutorials and such, I was thinking of maybe also getting a good old-fashioned dead-tree manual... Apparently Python Crash Course is really good? Or maybe something from O'Reilly?


Danvzare

Quote from: Laura Hunt on Sat 30/05/2020 09:21:20
Hi everybody.

I'm thinking of dipping my toes in the fantabulous world of Python, but there are so many online tutorials, courses, introductions and books out there that I'm overwhelmed by choice and don't even know where to start.

Could anybody recommend a good starting point? I'm a very hands-on learner, so I would definitely prefer tutorials that give you stuff to do with what you've learned.

In case this helps, I would like to focus eventually (when and if I achieve certain proficiency) on QA testing automation. I guess this is not really relevant right now that I'm just starting off, but maybe it can help determine what I should focus on the most.

Thanks in advance! :)

EDIT: Couple more questions: Python 2 or 3? And which IDE would be best to start with?
I'm not sure how much help this will be to you, but I learnt python by just getting a book called "Learn Python the Hard Way", then I went through the whole book.
Most of it is just you copying the code he wrote directly into a file using notepad++, with a little bit of explanation about what you just did. But as someone who already knows the basics of programming, I felt as though it learnt me a lot (also, it helped that it was structued in a way that I learnt how to program to begin with). I now use Python to quickly program any tiny things that I need. It's a brilliant language for prototyping.
I think there's a new edition that's for Python 3 as well.

Cassiebsg

That sounds like good method that fits me, Danvzare.
Ordered the book (python 3) at my library. Now to wait for it to be ready to be picked up.   :-D Thanks.
There are those who believe that life here began out there...

Laura Hunt

Quote from: Danvzare on Mon 01/06/2020 10:51:13
I'm not sure how much help this will be to you, but I learnt python by just getting a book called "Learn Python the Hard Way", then I went through the whole book.
Most of it is just you copying the code he wrote directly into a file using notepad++, with a little bit of explanation about what you just did. But as someone who already knows the basics of programming, I felt as though it learnt me a lot (also, it helped that it was structued in a way that I learnt how to program to begin with). I now use Python to quickly program any tiny things that I need. It's a brilliant language for prototyping.
I think there's a new edition that's for Python 3 as well.

Thanks! I have heard of that book, seems it's pretty famous but also quite divisive, so I wasn't sure whether to get that one or Python Crash Course. I think the best option in any case is going to be to start with an online tutorial and see if I feel motivated enough to drop money into this. If I do, I'll definitely take your advice into account!

morganw

If it helps, here is my 4 statement crash course.

Code: ags
$ python -c "print(isinstance(True, int))"
True
$ python -c "print(isinstance(False, int))"
True
$ python2 -c "print(3/2)"
1
$ python3 -c "print(3/2)"
1.5


Hopefully I've just saved you several hours.

Laura Hunt

#9
Quote from: morganw on Mon 01/06/2020 23:11:27
If it helps, here is my 4 statement crash course.

Code: ags
$ python -c "print(isinstance(True, int))"
True
$ python -c "print(isinstance(False, int))"
True
$ python2 -c "print(3/2)"
1
$ python3 -c "print(3/2)"
1.5


Hopefully I've just saved you several hours.

I'm guessing the first two lines should also be python2 and python3, respectively?

wtf tho.

morganw

Quote from: Laura Hunt on Tue 02/06/2020 09:12:49
I'm guessing the first two lines should also be python2 and python3, respectively?
No, the first two check if True and False are integers. They aren't integers, but the boolean type was created as a sub-class of integer, and so the function says they are.

Laura Hunt

Quote from: morganw on Tue 02/06/2020 10:29:18
Quote from: Laura Hunt on Tue 02/06/2020 09:12:49
I'm guessing the first two lines should also be python2 and python3, respectively?
No, the first two check if True and False are integers. They aren't integers, but the boolean type was created as a sub-class of integer, and so the function says they are.

Oh, ok. So the conclusion is... "don't learn Python"? :D

eri0o

#12
About learning python, I recommend finding a minimal project that you love and pursue it.

I liked the Android App below when I used years ago:
https://play.google.com/store/apps/details?id=com.sololearn.python

I learned Django from the videos of this guy:
https://www.youtube.com/user/sentdex

Five years ago this video on python packaging was useful, it appears still somewhat relevant:
https://www.youtube.com/watch?v=4fzAMdLKC5k

Having tried a bunch of IDEs, my conclusions are:

If you are building a system, PyCharm is the best IDE.
If you are only scripting, analyzing data or similar, then Spyder can help (gives a Matlab like interface).

All that said, I use a plain text editor 99% of the time and have the terminal to run the interpreter at whatever time I need.

These were my first lines of python when I wanted to make an engine: https://ericonotes.blogspot.com/2014/08/a-tilemap-in-pyqt-for-bigger-game.html
And, two years later, this was the engine I made: https://ericonotes.blogspot.com/2016/09/fgmk-is-my-first-attempt-at-game-maker.html

I think having the interpreter at hand and try ideas on it is the best thing of Python.

Laura Hunt

Thanks, eri0o. For now I've started with Visual Studio Code and I'm trying to find my way around the editor itself. I just ran my first Hello World script, so it begins! :)


Adeel

I suggest using Automate the Boring Stuff with Python. It's a free book. Teaches you Python (and programming) from scratch along with examples and gives practice projects to work on at the end of each chapter. It also has an accompanying video course which you can use if you benefit from learning in a video format.

Stay away from Django and other frameworks for the time being...

Laura Hunt

Quote from: Adeel on Sat 06/06/2020 02:01:43
I suggest using Automate the Boring Stuff with Python. It's a free book. Teaches you Python (and programming) from scratch along with examples and gives practice projects to work on at the end of each chapter. It also has an accompanying video course which you can use if you benefit from learning in a video format.

Stay away from Django and other frameworks for the time being...

Oh, I see this book being referenced often, but I hadn't realized it was available for free. Thank you, it looks fantastic!

SMF spam blocked by CleanTalk