Author Topic: Learning Python  (Read 686 times)

Learning Python
« on: 30 May 2020, 09:21 »
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?
« Last Edit: 30 May 2020, 10:33 by Laura Hunt »

Re: Learning Python
« Reply #1 on: 30 May 2020, 09:40 »
Well, I found this nice video on Pythons for beginners;

Re: Learning Python
« Reply #2 on: 30 May 2020, 11:22 »
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.
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: Learning Python
« Reply #3 on: 30 May 2020, 12:11 »
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.

Re: Learning Python
« Reply #4 on: 30 May 2020, 12:17 »
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

  • The Man with No Name
    • I can help with AGS tutoring
    • I can help with proof reading
    • I can help with scripting
    • I can help with voice acting
    • Danvzare worked on one or more games that was nominated for an AGS Award!
Re: Learning Python
« Reply #5 on: 01 Jun 2020, 10:51 »
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

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Learning Python
« Reply #6 on: 01 Jun 2020, 17:52 »
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...

Re: Learning Python
« Reply #7 on: 01 Jun 2020, 21:21 »
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!

Re: Learning Python
« Reply #8 on: 01 Jun 2020, 23:11 »
If it helps, here is my 4 statement crash course.

Code: [Select]
$ 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.

Re: Learning Python
« Reply #9 on: 02 Jun 2020, 09:12 »
If it helps, here is my 4 statement crash course.

Code: [Select]
$ 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.
« Last Edit: 02 Jun 2020, 09:15 by Laura Hunt »

Re: Learning Python
« Reply #10 on: 02 Jun 2020, 10:29 »
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.

Re: Learning Python
« Reply #11 on: 02 Jun 2020, 10:38 »
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

Re: Learning Python
« Reply #12 on: 05 Jun 2020, 01:23 »
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:


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.
« Last Edit: 05 Jun 2020, 02:58 by eri0o »

Re: Learning Python
« Reply #13 on: 05 Jun 2020, 08:01 »
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

  • Cavefish
    • Adeel worked on one or more games that was nominated for an AGS Award!
Re: Learning Python
« Reply #14 on: 06 Jun 2020, 02:01 »
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...
-

Re: Learning Python
« Reply #15 on: 06 Jun 2020, 07:42 »
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!