I’m an idiot when it comes to any sort of coding. I’ve seen Python listed as a job requirement in a couple of job recruiters have sent me this week in the financial industry. The last time I did anything with computers was when I took a course (online) in R about 5 years ago.
What do you think? Easy enough to get at least the basics down?
Python is easy, but it’s also easy to mess up because there is not a syntax checker. R is a compiled language, which means the compiler reads your program and finds any syntax errors. Python just runs the text file that you write. If you make a syntax error, the problem is found when Python tries to run that line. There is some initial checking of the file when it’s loaded, but stuff like misspelled variable names will only be found when Python tries to run the line and it fails. Python is similar to shell scripting if you’ve ever done that (stuff like Windows batch files or Unix scripts).
If a lot of your job offers require Python, you can easily start learning it now. There are plenty of Python tutorials online you can get started with right now.
Well, let’s not go overboard. Python is certainly easier to learn to program than C/C++, C#, or (ugh) Java, but you still have to master programming fundamentals. Python was designed from the outset to encourage programmers to write routines in a uniform way (hence, the extensive specifications and enforced use of whitespace), but if you’re expecting to write Python code as a vocation you are probably going to have to master design patterns, understand the object model in both abstract and implementation, and have a good grasp of data structures. Python makes this somewhat easier insofar as everything is an object, but it isn’t BASIC or Logo; the current reference implementation only as about seventy base functions but the Python Standard Library is enormous, and the supplemental libraries are extensive.
The advantage of this is that if you want to implement some desired capability, there is probably a module out there that can at least be a starting point for doing so, so you’re not like some Bell Labs programmer circa 1975 trying to figure out how to write a sort routine from scratch, but that extensiveness can also lead to a paralysis of riches, e.g. there are so many ways to do a lot of things you can burn up a lot of time just playing with different modules. The other thing is that Python has a lot of features such as list comprehensions that make it really powerful, but these things also confuse people–even experienced programmers–when they first encounter them. You can go down a lot of rabbit holes figuring out how to do things efficiently and ‘Pythonically’.
If you are compentent in functional and imperative programming, you can probably sit down and get a workable “Hello, World!” program going within a few minutes. Understanding the fundamentals and implementation of complex data structures and object orient programming, on the other hand, will take months. I’ve been working with Python off and on for around fifteen years and I don’t claim to have mastered it; at best, I’m pretty good at scientific programming with NumPy and SciPy, have a good grasp of visualization with Matplotlib and Seaborn (still working on Maya), and have a pretty solid grasp of fundamentals although I learn new things every time I start a new project.
From what I’ve seen, most job recruiters are looking for experienced Python programmers and will present you with practical problems to show your competence. I’d recommend devoting at least a few hundred hours of time working on different types of projects to develop your skill with it as well as studying features of the language, at least getting through an intermediate-level text like Fluent Python (there is probably something newer and better; I just picked it because it is on my bookshelf) and understanding the specific type of applications these jobs will be developing. Python is great, and has easily become my go-to language of choice for nearly everything I do now, from scientific data processing to automating computing tasks, but it’s a big elephant to try to eat in a few bites.
Many editors designed to work with Python have pyflakes (syntax checker) and pylint (style checker) built in. And even if they’re not built in, you can run them manually.
R as a lot of precompiled packages, and you can make modules and have them compiled, but it’s primarily an interpreted language. Like with Python you can use an editor with built in syntax checking to weed out many such errors before you run the program, but you’re also likely to have some left to pick out at runtime. (Advice, have some variables define how much of your data you work on so you can run it on a small dataset until all the bugs are gone. That way you won’t wait hours and come back to an error message. Unless you run out of memory of course.)
I’ve taught people programming, but not Python, and have experience with Python. The biggest hurdle is learning any type of programming, but Python itself is not hard as far as languages go.
R is a common competitor, but it’s kind of like Python’s stupid sibling. A lot of frustrating parts. But while I hated 1-indexing when I first encountered it (MATLAB and later R) I hated it, but now I understand some of the value, and how they didn’t choose that just to be frustrating.
I think Python syntax is pretty easy to learn, but it’s harder to do it right. I worked on a project in the dark ages where I had to fix some C code written by a Fortran programmer – no tabs, goto statements with spaghetti code. I mean, it compiled in C, but it was basically crappy Fortran code.
Same with Python – I learned the syntax at some point, but if you saw any of my code, you’d see that it doesn’t have any list comprehensions and it never dynamically adds elements to objects. It would be C++ code in Python form (or, these days, VB code in Python form). If I could find a way to have it force me to dimension all my variables, I would.
Some day, I’ll understand functional programming and do things the right way, but not today. Tomorrow isn’t looking good either.
I don’t know if I’d exactly call R a competitor to program; R is purpose-designed as a language for statistical data manipulation, whereas Python is a general purpose language originally intended for prototyping but has become a powerful language in its own right. Most of the features that once made R superior for data wrangling have since been introduced to Python and SciPy, and there is of course the RPy interface library to drive R code from Python, but for people who are experenced with R/S, SAS, and Stata it probably feels more comfortable.
I think more direct competitors to Python are languages like Ruby and Go, although I think Python has maintained significantly more popularity; I remember hearing people going on about Ruby-on-Rails twelve years or so ago and it seemed to be on the way to pretty wide adoption at some point but seems to have fallen out of favor compared to Django and Flask, and of course all of the commercial ASP.NET and JavaScript frameworks that dominate the market. Of course, while building web applications is a major area in programming it is far from the only thing a potential Python programmer could end up doing.
But that brings up another point, which is that when you are picking a language to learn for vocational marketability, you aren’t just learning the language; you are learning the applications and libraries that you expect to use in programming. nobody is going to build a modern web framework from soup-to-nuts; you’re going to select and use one of the existing frameworks, and knowing those is just as key as understanding the core language. Ditto for other types of applications; if you are building visualization dashboards or doing data analysis you’ll have multiple options available to you in the modern languages used for that purpose (whether R, Python, Julia, Scala, et cetera) and so you need to hava a familarity with them. If you are doing plotting, you might have a lot of familiarity with Matplotlib but if your potential client or employer is looking for dynamic webpage data visualization then you should probably bone up on Plotly or Bokeh.
As for the indexing from 0, it is one of those confounding things that puts off people trying to transition from Matlab or other scientific packages, and if all you are using it for is handling data it can seem obtuse and annoying, but if you are actually writting real functional programs instead of a collection of scripts, it makes so many things easier. One of the biggest problems people seem to have in coming to Python from other languages is that they continue to try to program the same way in Python as they would in C, Java, or Matlab, (hence the old joke about how a Fortran programmer can write Fortran code in any language) and then miss out on the unique functionality and optimal performance of things like using iterators and list comprehensions.
Someone coming to Python without that experience may actually have an easier time learning to write good Python code, although they are then going to be frustrated when they go to other languages and realize that the features they use all the time aren’t available in other languages. I came from using Mathematica, Fortran, and C, and currently have to work back and forth between Python/NumPy/SciPy and Matlab, and I have to say that I’d much rather write general purpose applications in Python and do data mangling in NumPy and SciPy than in anything else, but all of my Matlab users are really reluctant to switch over even though most of them aren’t using anything that doesn’t have an equivalent library in Python (save for Simulink) and I’ve ported a number of applications over with minimal effort and increased their performance and features dramatically.
The syntax checking isn’t really an issue; as @MrDibble notes, most modern IDEs will do syntax checking and autocompletion; heck, even IDLE will do that and it’s been around since Python 1.5. The bigger problem is dynamic typing; if you aren’t used to static typing and being dilligent about being explicit on values going into the code, you can get wound around the axle with weird errors. But Python is far from the only dynamically typed language, and you can always enforce data types and do runtime checking as necessary.
“Just because you can do a thing, doesn’t mean you must do that thing.”
I’ve seen ‘compiled’ Python, and it is the enemy; often slow, inconsistent, and sometimes blows up in weird ways when trying to multiplatform it. Python is an interpreted language by design, and if you really need something to run on bare metal you should prototype it in Python but then write it in C or C++.(Technically, Python code is compiled into bytecode the first time you run it, which is why every .py file will have a .pyc sibling, but you still need the interpreter to run the bytecode.)
I mean more in data science, Python and R (and several specific dependent libraries, etc.) are the two more requested.
The people I’ve taught are general public (non-CS students) so at least a select few have a lot of trouble getting the entire conceptual framework of how to program and plan a program, it’s so daunting to them. So I find any programming experience helps in that context.
I was used to 0-indexing first, which is why 1 was difficult. Someone starting with a 1 language might not have those issues. But then I got into (limited) matrix math, and 1 works much better there.
Oh, and I’ve had very very limited experience with Java, but the few hours I spent also made me hate it.
Yeah, aside from the commercial packages R and Python are definitely the heavy hitters in data science . I’ve been meaning to get up to speed with Julia and it seems to be slowly gaining some traction, especially where dynamic 3D visualization is required but Python and the NumPy/SciPy libraries serve my current needs really well.
You, sir, are a gentleman of deep perception and exceptional learning. Java is indeed a vile abomination. I would rather write a natural language text parser in C++ than to write “Hello, World” in Java.
I’m trying to understand what roles would require someone to know Python, but are such that someone without computer knowledge would qualify for the position. Can you give an example of the type of role we’re talking about? Then we’d have a better understanding of the level of Python knowledge that should be expected. For example, my team works with a lot of financial data, and I require Python skills, but I also require SQL and many other technical skills as well. You might very well be able to look up the methods of the Beautiful Soup package, but if you don’t know HTML, it won’t do you much good.
Alternatively, you could waltz into the technical portion, type ‘import this’ into the interpreter, press Enter, and walk away. It just might work.
For those without ready access to a Python interpreter:
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren’t special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you’re Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it’s a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea – let’s do more of those!
It is indeed an Easter Egg. It represents 20 guiding principles of Python, but the creator of the list left the last one to be filled in by Guido van Rossum, Python’s creator and Benevolent Dictator for Life. It’s still blank…
As a non-coder trying to assist my non-coding daughter through a course that we didn’t expect to include a lot of coding (by assist I mean I’d learn it, then try to teach her it - cheating was pointless) I found Python really hard. Java, on the other hand, we both found pretty easy. My only previous experience was informally learning C++ (I think) to make websites 10-15 years before that, without any training, so I just had to basically stab things in and see if they worked and then change them if they didn’t, then learn from that.
Java fitted in pretty well with that, since there were existing language structures to build on; Python was starting from scratch.
Even the Wikpaedia articles on Java and Python are very different in terms of how accessible they are for a newbie to understand.
But I have heard that young kids don’t find Python difficult. That’s probably because they don’t have the pre-existing knowledge, even if basic, of other programming languages. Also, a lot of the people who like Python and find it so easy that they were baffled that I didn’t like it were Mac users.