Learning Python!
-
So I am taking a Machine Learning class at University. In it we will be using python. Now, other than a quick (like hour long) stint with it back before I had any programming experience, I have avoided and disliked python for utterly silly and arbitrary reasons (whitespace as syntax? eww. Also I prefer explicit typing, in lieu of types being converted willy nilly and strange errors being silently swallowed by implicit conversions). However, I have to learn it and by golly, I take pride in my work. To that end, where is a good place to learn python? Good tutorials? And even more helpful, what is a simple project I could do in a few days to test my skill and learn me some python?
TL;DR I need to learn python, throw links at me
Warning: Python 3
-
-
I... I'm sorry? I believe I have missed something.
...I haven't learned any python from that at all!
-
This is ben. Don't worry, as long as he doesn't suggest a python tutorial written in dwarf fortress you are good.
How good are you in other languages?
Do you already have small projects in those languages you can simply rebuild in python? Ime that's usually pretty helpful because it showcases differences between the languages and does not require you to think aboutboringsuper interesting structure stuff that would be the same either way.Filed under : Food for thought
edit : fixed for correct value
-
I have significant (as in, actual experience in an enterprise and consumer facing industry application) experience with java, significant but untested experience with C, and at least a familiarity with many many other languages. I have a significant number of little programs written for different university classes that I could probably convert, and there's always project euler https://projecteuler.net/
boring structure stuff
BLASPHEMY!!! That is the LEAST boring kind of stuff
-
This is the overall most highly regarded python book around:
Upsides:
- It's doing a pretty good job at cheering you onward and motivating you to complete its stupid exercises
- It's free
Downsides:
- It's targeted at complete programming noobs.
Not a bad choice, but if you're an experienced programmer, you might get bored at some point.
The other thing I recently started doing is this:
It's mostly just a way to motivate myself to type in code, so I can hit my head against the wall and look shit up in documentation. I just started with this, so no strong recommendation from me yet.
-
My one hour first look was with python the hard way. I didn't like how it focused so much on file I/O. Also isn't it for python 2.7? Either way, I guess the consensus is I just have to get off my bum and learn
-
what is a simple project I could do in a few days to test my skill and learn me some python?
I would suggest finding a problem you currently have and solving it with python. Think about what repetitive tasks you have that could be sped up with automation, perhaps. In my experience if you are not doing some contrived project, you will enjoy it more.
-
for knowing that your reasons are arbitrary
Given that you're coming from Java you'll want to read Python is not Java. The state of things isn't so disparate these days as it was then, but the cultures are pretty different. If you're looking at doing Machine Learning you'll want to look at Jupyter (or more specifically, ipython 4, which is the Python front-end for the tool), because it's a great way (so I'm told) to show your work. Depending on the kind of machine learning you are doing, you will probably also want to look at pandas as it makes all that IO that you want to abstract ... disappear.
As for a project - you might just want to dig through one of the smaller of the AWS public data sets and pull interesting facts out of it (I assume you are taking the Machine Learning class because you find such things interesting, not because you have to)
Things you probably already knew
pip + virtualenv
is the closest thing Python has tomaven
/gradle
/leiningen
/sbt
Do your experiments in virtual environments - if you screw up the env, you just throw it away and try again, rather than having to un-break your system installation.Python 3.5 is coming with optional type hints based on MyPy - it won't get you all the way back to the security of the compiler, but it does a pretty good job getting you 40% of the way.
Don't worry about willy-nilly conversions - that doesn't happen in Python. It's dynamically but strongly typed.
1 + "123"
is aTypeError
just as"123" + 1
is It still has gotchas, but they're of the "char
isint
" variety not the "Oh, but you had a leading zero in that string so I thought I should treat it as an octal number " of some languages.
-
Considering you have specific application you want to learn in Python (Machine Learning) I suggest not to dive deep into Python-ish things like VirtualEnv, ... just start with Jupyter/iPython Qt Console, Scikit-Learn and Pylab/Matplotlib.
This is BTW what I do for living :)
-
Python
-
Given that you're coming from Java you'll want to read Python is not Java. The state of things isn't so disparate these days as it was then, but the cultures are pretty different.
Not to put too fine a point on it, but it reads like it was written by a Python person with only limited exposure to Java.
For example, this nugget:
Code duplication is quite often a necessary evil in Java, where you must often write the same method over and over with minor variations (usually because of static typing constraints).
Even back before generics were a thing in Java... well, @codinghorrorbot can tell you what I'd be doing if I did it this way.
Interfaces, for example. While you can't guarantee the existence of a variable in a class using them, you can guarantee a specific method exists... including a getter and/or setter. Interfaces have been in Java from the start. So, I can write interface
Bar
and write the signature for methodFoo
like this:public void Foo(Bar something)
and voila, it doesn't matter which type I pass in as long as it implementsBar
..
-
@powerlord Is Doing It Wrong™
-
-
Default Methods didn't show up until last year and this article was written in 2004.
-
So? The article you're talking about is obviously even more obsolete than it was. :)
-
Why learn Python yourself when you can just hire the hottest tech talent?
[img]https://pbs.twimg.com/media/CNWrs6VUAAA0ZEm.jpg:large[/img]
Filed under: From the company that brought you Slashdot...
-
-
Code duplication is quite often a necessary evil in Java, where you must often write the same method over and over with minor variations (usually because of static typing constraints).
Even back before generics were a thing in Java...
I don't think he's talking about things which can be handled by generics. There are a lot of places where type classes or duck-typing would be used where your only choice in Java is a lot of boilerplate. At its simplest:
package third.party.one; interface Thing1 { public String getMagic(); } package third.party.two; interface Thing2 { public String getMagic(); } package third.party.three; interface Thing3 { public String getMagic(); } package your.namespace.here; interface HandleThings { public String extractMagic(WHAT_TYPE_GOES_HERE anyThing); }
-
Err, I'm not sure I'm getting your example, care to exain further?
-
I learned a lot about python by simply reading the official docs, specifically their tutorial. Not the whole thing though. But it's well written and structured.
-
If they're really coincident like that, you can do:
interface MixedThing extends Thing1,Thing2,Thing3 {}
and then just use that interface. You're not usually that lucky; it's more likely that one will want you to return an
int
, one aDouble
(because raisins) and one aString
. Then you're stuck doing stupid adapters for everything.
-
Funny enough, today I'll be givin a 4h crash course on Python to QA colleagues.
I have for them at the end of the session:
The code academy course is my favourite. Has a nice flow, in form of mini-projects, introducing new concepts as you advance.
-
https://www.youtube.com/watch?v=8VSTzGwkMiM
This is the Help area Ben. You are expected to be helpful, at least until the OP says that the requested help has been found.
-
He did help me. He gave me a rough idea of how it feels when you run python for the first time and get yelled at for not having ":" in all the right places. un-C-like syntax is un-C-like