Author Topic: Python Syntax problems.  (Read 466 times)

0 Members and 1 Guest are viewing this topic.

Offline Cranoo

  • NULL
  • Posts: 3
  • Cookies: 0
    • View Profile
Python Syntax problems.
« on: February 07, 2015, 10:44:02 pm »
I'm back to Python after about two years (had too much to do) and now I can't get my old scripts to run because of syntax errors.

Is there any decent Python3 tutorials out there? I've checked google but I couldn't find a decent one.

Thanks in advance. I'm fairly new to Python too.

Offline Phage

  • VIP
  • Overlord
  • *
  • Posts: 1280
  • Cookies: 120
    • View Profile
Re: Python Syntax problems.
« Reply #1 on: February 07, 2015, 10:53:56 pm »
Honestly, if you already know how to program, the offical docs should be enough.

Anyway, I'll leave two links:
"Ruby devs do, in fact, get all the girls. No girl wants a python, but EVERY girl wants rubies" - connection

"It always takes longer than you expect, even when you take into account Hofstadter’s Law."

Offline Cranoo

  • NULL
  • Posts: 3
  • Cookies: 0
    • View Profile
Re: Python Syntax problems.
« Reply #2 on: February 07, 2015, 10:56:19 pm »
Thanks mate, like I meant all my scripts written in 2 won't run in Py3. I've first messed around with Py3 tonight and there's alot of syntax change, am I going to have to rewrite everything? Know what I mean? That's for the tutorials.

Edit: Should I just stick with Py2 for now?
« Last Edit: February 07, 2015, 10:57:34 pm by Cranoo »

Offline Pavornoc

  • /dev/null
  • *
  • Posts: 11
  • Cookies: -1
    • View Profile
Re: Python Syntax problems.
« Reply #3 on: February 08, 2015, 08:49:32 am »
Hey Cranoo,

Yeah, the syntax changed a bit (i.e raw_input() just became input() ), but something to consider is do you really need to use 3 over 2?

Don't get me wrong, I'm not saying don't learn it; I used python 3 to create a script to sort through IP subnets at work because of the handy IP modules 3 has.  However, python 2 comes installed on a lot of systems currently, like Macs and most Linux distros, whereas anything needing 3 you would need to install 3 specifically.  If you're trying to execute a python script on a remote system, you may want to just do it in 2.  There's also a tool called py2exe that can create .exe files for Windows off of python 2 scripts, but it doesn't work on python 3 (last time I checked the project).

But if this is just for your own scripts/education, I would say check out what Phage suggested and the official docs. There's more support out there for 2 right now so you'll probably need to do things the hard way for 3 for now.

Good luck!
« Last Edit: February 08, 2015, 08:50:35 am by Pavornoc »