Python: Some Beginner Questions


(Andy Wootton) #1

After some deliberation and a couple of false starts, I’ve finally decided what programming language to learn:

I dismissed Ruby in favour of Python. I noticed people liked one or the other and those with Comp. Science backgrounds seem to prefer Python.

I applied for a job where Java was used, so decided to play with that, despite my misgivings about it being in Oracle’s grasping hands. I liked that I could have a hack at Android because I have an old phone I was willing to put at risk. The fact that someone at a Java meeting said Java was starting to show its age put me off slightly. And do I really want to do things the Google way or should I go HTML5 & PhoneGap?

I’d like to talk Webbish and play with Firefox Open Web, so I had a go at HTML5 but I found the online teaching resources assumed I was starting from somewhere else and/or wanted to lash something together without understanding much. I might be able to write web apps for Ubuntu but do I really want to support the Unity split?

I’m back to Python. It’s a good modern language that let’s me write code like I used to, straight away. It does CLI scripty-type things and I can learn new things as I go. It is Agile: value straight away.

QUESTION 1 : Why is there a religious war between Python 2 & Python 3? I’ve read that 2 is still the default on many Linux distros. Will I have problems if I choose to learn Python 3?

QUESTION 2: Should I use the Idle IDE? It seems to work a bit strangely on Linux but I like the simplicity of multiple editing windows with a ‘Run’ button but having an IDE per language seems crazy to me.

A PONDER: Should there be a Python area in Birmingham.io, for language specific questions? (Like there is for Ruby, Java & Perl) Maybe the same question for HTML/CSS, JavaScript.


(Daniel Hollands) #2

There used to be categories set-up for various meetup groups that wanted them on the site, but I’ve just finished deleting them after moved their posts into more relevant categories.

I’ll admit, I’m not that keen on creating forums for specific technologies, as I don’t think there will be enough call for it to make it worth it, but I’m more than happy for you (and everyone) to use this forum as a source of help.

Anyway I’d love to help you with your Python questions, but I chose Ruby, so that pretty much makes us mortal enemies :gun: :smile:


(Andy Wootton) #3

They were still there when I asked the question, I think. I thought you’d gone another way. Maybe a convention to have the language at the start of language-specific questions? I’ll change the title slightly, if I can.


(Stuart Langridge) #4

There isn’t a religious war as such; it’s that the transition wasn’t managed well. It goes like this: there are some things which have built up over the fifteen year lifetime of Python 2 which really needed fixing, but fixing them would have broken every bit of existing Python code. Examples of this are handling of Unicode, print being a statement and not a function, and weird capitalisation of various built-ins and standard library objects such as ConfigParser. So, the decision was taken that Python 3 would break backwards compatibility, in order that it could do these things right from the outset. However, because of this, you shouldn’t really think of Python 2 and Python 3 as version increments in a language; they are different languages which just happen to look a lot alike. Python 2 code will almost certainly not run under Python 3, and vice versa. Because many apps and OSes and so on have a large stock of Python 2 code, and many many many libraries were written for Python (and are also in Python 2), it wasn’t just possible to switch everyone to Python 3. So, the two are parallel-installable; the idea was that app developers would gradually migrate over to Python 3, library developers would port their libraries to Python 3, etc. (Tools were provided to make this porting process easier, but they didn’t make it fully automatic.) This process has been… a lot more gradual than the Python core team were hoping for; in practice, a whole lot of people said, why should I bother? I’ll just stick with Python 2. This was not helped by some fairly major existing Python libraries not porting to Python 3 and therefore anyone using any of those libraries was also stuck on Python 2.

There are efforts under way to convince everyone to use Python 3. Ubuntu has led the charge here; they have an explicit goal of not using any Python 2 code in the default release (which they have either attained or have very nearly attained), at least partially because Barry Warsaw (who is about as core a Python developer as can be imagined after Guido) works on the Ubuntu foundations team.

I would suggest that you use and learn Python 3. But be aware that a lot of what you will find written about Python, and a lot of the libraries you might plan to use, will be about Python 2.

I don’t think so. That’s useful if there are a zillion questions about it and it needs segregating off. That isn’t the case for any of our categories, yet. No premature optimisation required.


(Andy Wootton) #5

Thanks @sil. I was worried it was a XHTML situation, where people would be punished for doing the right thing.

@LimeBlast I think a lot of people who come from PHP choose Ruby but I don’t yet know why. I remember being warned that with my background in a strictly-typed 3GL, it would drive me crazy.


(Daniel Hollands) #6

I ended up choosing Ruby because of my exposure to both it, and Node, at the respective WMRUG and BrumJS meet ups. I went along to both, had a chance to learn about both languages, and decided that I preferred Ruby.

So why didn’t I attend a Python meetup group? Ignoring the fact that it doesn’t seem like there is one local to the area (although if I’m wrong, please let me know), it was mostly because it never entered my radar.

My main reason for doing a lot of career-based things is the web, which might explain why I started with PHP. Being a citizen of the web, I also often encountered people talking about Ruby (Rails, specifically) and Node, but never heard anyone talking about Python.

At the end of the day, for me at least, it all boiled down to exposure.

Now that’s not to say I’m never going to look at Python. I actually have access to two Python tutorials on Udemy which I plan on completing at some point - I’m having too much fun with Phaser for that to happen right now, however.


(Philip Wattis) #7

A few years ago I switched from Perl as my weapon of choice to PHP. It took about 1 day to pick up the fundamentals.

What I found took time was becoming aware of, choosing and learning the supportive resources; for example - which MVC framework to go with.

I wouldn’t labour over your decision to choose Python over Ruby, as I suspect that if you wanted to switch in the future it would be a doddle.


(Roman Goj) #8

Is there really a religious war between Python 2 & 3? Adoption is slow, but that’s understandable because of the changes (as @sil mentioned above). In practice, in my limited experience, it’s not too bad though - I contribute to an open source library that was written for Python 2 and is only slowly, gradually moving forward to Python 3, but people do use and develop it with Python 3 (not without issues of course). I’m still using Python 2, but if I were to learn now, I’d go for 3.

I’ve not seen anyone using Idle in practice apart from while learning the language, but as far as IDEs are concerned I’ve heard people say good things about PyCharm. In the “scientific software” space (I’ve not worked with Python anywhere else) people use good text editors combined with IPython and, more and more, the awesome IPython Notebook, which, in a (very limited) way, could be used as an IDE.

This seems to be the closest one: Python West Midlands, but I’ve not attended it and only learnt about it recently and it’s not very active at the moment, it would seem. Does anyone know any other local Python groups?


(Andy Wootton) #9

Thanks @PhilW. That’s what put me off Java. I’ve been thinking of blogging about this problem. We seem to have gone badly wrong somewhere, particularly on Unix-style systems.


(Philip Wattis) #10

I found Java almost alien at first, but that was because I had a background in functional programming. I guess if I revisited it now I’d be a little more comfortable with it. My degree in Electronic Engineering and Computer Science didn’t cover OOP, because it was some time ago. That said, at a time when everyone was using ANSI C or K&R, we were taught Modula II :frowning:


(Andy Wootton) #11

Quite right too! University is about education not training.


(Philip Wattis) #12

Well if I’m going to spend my time learning something, I’d rather it was something useful. If I had my time again, I’d pick a different Uni, or even not bother tbh.


(Andy Wootton) #13

Sorry, @rgoj, I didn’t see your reply. I’ve seen some fairly strongly worded suggestions that Python 3 should be avoided and it has been out a long time without being adopted by everyone. I decided to learn things the clean way then get dirty if I need to.


(Daniel Hollands) #14

You might want to take a look at the latest Humble Book Bundle.

I know these are aimed at kids, but I’ve been reading up about them (the Python one specifically) and they’re not patronising or childish, they’re simply written to be accessible.

I’m thinking about getting them myself.


(Andy Wootton) #15

Does it cover multiple inheritance? That was the final reason I rejected Java, my dislike of hierarchy :slight_smile:


(Daniel Hollands) #16

Alas, I have no idea :speak_no_evil:


(Roman Goj) #17

Interesting to know, I’ll need to dig into that sometime in the future then to make my own mind up, cheers for the interesting prompt. I only heard good things about Python 3… but haven’t really digged into the topic myself at all, assuming the Python guys couldn’t go wrong :wink:


(Andy Wootton) #18

I think @sil is right, we SHOULD use Python 3, just as Motorola should have beaten Intel, because they went back to the drawing board and designed their chip architecture for the future but they broke backward compatibility and that future never came.

Some reading I’ve done since suggests that the gap is being closed by increments to Python 2 but that might cause people to not bother moving. It is reducing the cost of the move but also the incentive.

The guidance @sil referred to is here: https://wiki.ubuntu.com/Python/3


(Joe Borg) #19

My friend, a very wise choice.

Not really, you can import __future__ in most cases in Py2 to get the behaviour of Py3. I would start with 3 as it’s the future (and officially present). It’s just a load of legacy code that keeps people on Py2.

Having an IDE really isn’t crazy, especially if you’re learning a new language. You’ve got a debugger and code completion (to name just 2 pros). I recommend PyCharm https://www.jetbrains.com/pycharm/.

This is only my second post, but yes, if there is for other languages.


(Andy Wootton) #20

The other languages were there when I asked the question but were deleted shortly after, as discussed elsewhere. There hadn’t been enough language-specific questions. I’ve prefixed my questions with “Python:” for easy sortability.