2nd Edition of Learn Python the Hard Way Released
theodp writes "Are you or your kid intrigued by Python, but not quite ready to purchase an in-depth O'Reilly book? Zed A. Shaw's 2nd edition of Learn Python The Hard Way may be a friendlier option. Shaw's path to Python programming is simple: 1. Go through each exercise, 2. Type in each sample exactly, 3. Make it run. If $60 for the hardcover is too much to ask, or $15.99 for paperback, you can spend a measly buck for the PDF/ePub download. Still too steep? OK, there's even a free online HTML edition. After completing the 52 exercises, Shaw's concluding Advice From An Old Programmer says, 'Which programming language you learn and use doesn't matter. Do not get sucked into the religion surrounding programming languages as that will only blind you to their true purpose of being your tool for doing interesting things.'"
Is it as hard as donating your liver, or is only as hard as getting slapped with a fish?
How is that the hard way? What ever happened to sharpening your teeth on man pages and samples written by people far better than you?
I expect the language laid out in monospaced ASN.1 tables from the get-go.
They can be in your way, they can make you jump though hoops, they can require you to create so much noise that you need tools to write anything in it (java is a prime example). If you are a truly good programmer, you want a language that does not tell you how to do things and just lets you do what you think is right. Even if that language has less extensive libraries than others.
Personally, I like Python, Lua and C at this time. Python does OO but does not force a specific, limited model on you as most other OO languages do. The one thing that comes close is Eiffel, but at the price of the compiler needing global scope. Lua is just plain elegant minimalistic and again supports OO, but as you see fit, not some restrictive inheritance model. And C just lets you do what you want, very fast if you know what you are doing, although OO, while feasible, has no language support at all. But often you can do without in C anyways. (Yes, even people that understand and like OO sometimes find that not using it is better.) In addition, all three languages are light-weight.
As to C++, I think that abomination would have been better aborted before birth. You need to know far too much about its internal execution model to write efficient code. At the same time, it is not light-weight anymore.
I also have observed that most of the Java crowd never manages to get to the level of being even mediocre programmers. To me these people look more like "library call sequencers" that could not ever do anything useful without these libraries and development tools that automatize a lot. Quite often this leads to slow, complex and insecure solutions, where the code is basically unreadable due to too much code, to many layers, too much abstractions and no insight on the part of the programmer. Sometimes Java code is 95% clutter and noise. This problem is less pronounced with other languages. One piece of advice I therefore give to anybody that wants to learn programming is to avoid Java like the plague. This is definitely only a language for quite advanced programmers, although the typical Java programmer is very far from that indeed.
Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
"A programmer will eventually tell you to use Mac OSX or Linux. If the programmer likes fonts and typography, they'll tell you to get a Mac OSX computer. If they like control and have a huge beard, they'll tell you to install Linux. Again, use whatever computer you have right now that works."
Philip Greenspun has some good titles: Philip and Alex's Guide to Web Publishing (dated, but I paid cash money for it back in the day), Software Engineering for Internet Applications, and SQL for Web Nerds. If you find yourself in the DB2 world, Graeme Birchall's DB2 SQL Cookbook is a must-have.
I have a fever, and the only cure is more COBOL.
Looks like a good attempt on programming, but if I am starting on Python today, I'd prefer using the current version.
This is a good price-point; yet, if you want to do anything more than an evening with Python, try...
http://diveintopython3.org/ or
Computer Programming for Kids http://cp4k.blogspot.com/
I am a novice level programmer in C++/Python and I thought I could benefit from this book. But the exercises seem to be ridiculously simple and it seems a book only suited for someone with zero or negligible programming background.
A month or so ago I decided to pick up a Python book at the Borders-is-dying sale, and while it's from O'Reilly, the book is too much of a reference - a lot of bottom-up "here's are six different list-like things" and "nobody expected the Spanish Inquisition, which is why you need to use this method to catch the exception it throws, but you can change that by overloading _ _ that _ _ method name's variable __pope__ or using _ComFyChaiR_ instead, but you can't set __pope__ to French, because that object uses __antipope__ instead, though in later versions you can modify it by using Cardinal()."
A friend of mine pointed me to python.org's tutorials", which were going to be my next step, but this looks pretty simple and accessible too.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
Too late! At $1 (£ 0.65) and ease of paypal, I literally just grabbed myself a PDF copy. In my defence, the popular 3D program Blender uses Python.
Check out MIT's OCW. Free lectures with a GPL Python programming book that does an excellent job at explaining programming and the Python language. The lectures are bad quality but the projects are good for practice.
Anyone else think this was about watching Monty Python on VHS?
When you bought the PDF, what format was it - Kindle-shaped, or letter-sized paper (A4 or 8.5x11 etc.) or something else? If it's Kindle, it looks like a good price.
Also, I was surprised by the terms of the free HTML - you're not allowed to change it! The big reason for reading it in that format is precisely to change it, by copying code examples and pasting them into your Python interpreter to see what they do :-)
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
One of the things I really liked about C was that once you've learned a few basics like how pointers and structs work, looking at code written by people much better at C than you just makes sense and comments like /* you are not expected to understand this */ are quite rare. That wasn't as true about C++ or Java, where many kinds of things are readable (after getting the basic "object" stuff down") but some of the template stuff is too obscure. It wasn't true at all about APL or PERL :-)
I was expecting Python to resemble LISP with a different syntax, but it's looking a lot messier than even Common LISP, and of course a lot of the moving parts are hidden in the large number of pre-written modules that come with Python.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
I'd heard of "Learn Python the Hard Way", but I thought it was a joke.
If you know any other programming language, Python is very easy.
You can always grab the ePub for that same $1 and use Calibre to convert it to a format the Kindle can use. I just bought it myself, looks great on my Nook.
Today is red jello day - all workers must eat all of their red jello. Failure to comply will result in five demerits.
And, for text processing? It's "up there" with the likes of PERL, because of RegExp... good stuff!
* I co-wrote a system to obtain HOSTS file data with my nephew (from DNSBL lists, HOSTS files of others, & other data sources, including my own researches) in Python 2.7x to:
---
1.) De-duplicate it/normalize said data
2.) Alphabetize it
3.) Convert the larger + slower 127.0.0.1 blocking IP Address of the "loopback adapter" address to the smaller + faster & most "universally compatible" 0.0.0.0 blocking IP address
---
For HOSTS files... that's doing so, as I write this, & "automagically", via Python!
Why?
Well - I first used to do it circa 1997-2002 using Access Databases & a SELECT * DISTINCT ORDER BY query system after data import, & then export back to text file for the HOSTS file & yes... it worked, but, it didn't "nab" the data itself automatically & on timed intervals!
So, about mid 2002, I later opted for a Borland Delphi system (because it's fast on strings), & @ the time? I used a "pure brute force" normalization route (slow on LARGE lists, but extremely fast on "smallish ones" (up to 1/2 million line iterms or so)).
That's because in those days?
Heh - That's when a 16,000 line HOSTS file for blocking out adbanners &/or known malicious sites/servers/hosts-domains was "huge"...
Heh - I have, as of writing this & checking the tempfile my system uses before final commission back to the actual HOSTS file here, over 1,459,188++ entries in it... that telling anyone anything?
Not nowadays though!
Fact is, the malware-in-general & online attacks via bogusly scripted sites, botnets, & more problem got bad, and I can tell you this FOR A FACT from when my data started flooding in FAR FASTER than it used to, started around 2003-2004...
I needed something BETTER on large data sets! I was contemplating rewriting the Delphi program algorithm to compensate (took 2 hrs. time on a Intel Core I7 920 CPU).
See - Around the time I got to 750,000 entries though?
The "brute force" deduplication algorithm I used in Delphi couldn't really "do the job" as well as it used to... was great & fast (tops 2-4 minutes on 1/2 million records IF I busted up the data into 48 parts, which the program had the options to do that IF I had lots of data) - this was a "temporary fix" though, vs. an algorithm that wasn't fitting the data set sizes anymore though!
So, sure, I could have rewritten it, but Delphi isn't used as much as it used to be! Time to change...
(BUT, in its day? In, of all places, a competing trade journal "VB Programmers Journal" Sept./Oct. 1997 issue, it KNOCKED THE CHOCOLATE out of both MSVC++ & VB5... by DOUBLE on MATH & STRINGS! Which is, why I used it of course - HOSTS are text data, & composed of strings!)
So... what to do?
Well, my nephew gets the idea to try my idea of HOSTS file processing (he's a junior @ RIT), & to do it in Python
Guess what... it worked GREAT on this size file!
The libs in Python have been written VERY well, lots of "DataStructures coursework" thinking went into their libs (written in C/C++ iirc)
In fact it worked SO well, I decided to take what he had & extend it with errtrapping, better filtration, cleaning up some mistakes he made in filtration, adding console outputs, & better automation with parameter passing functions etc./et al!
Hell of a LOT LESS WORK TOO, than Delphi or C/C++ code, even with their native string functions libs... which are good, but more work (Python turned up to be "VB-EZ" in fact!)
So - I tried Python, for TEXT PROCESSING (when I was actually considering PERL first, actually) & have NOT looked back since!
(Don't knock it, till you've tried it, & with every language, it tends to lend itself WELL, to certain things... for text & string proc
and then from the next paragraph:
Got a nice help online for this also, very cool!
http://pythonconquerstheuniverse.wordpress.com/2009/11/12/how-do-i-reverse-a-string-in-python-3/
APK
P.S.=> One of the things I like about Python is the AMAZING amount of help online there is for it... unreal! Since I like to do "ReVeRsE-PsYcHoLoGy" on trolls? It's an idea... apk
Learn Python "the Hard Way" to me implies an advanced book. It seems they meant "Learn Basic Python Well". I kind of prefer this title, too--it's much friendlier for the apparent target audience, even if it's not as catchy.
This was an outstanding post!
Pro Git is a great resource if you want to get into Git. (You can buy a dead tree version as well.)
There's no -1 for "I don't get it."
By watching The Life of Brian, Monty Python's Flying Circus, and Monty Python and the Holy Grail
General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
Actually you're not supposed to copy and paste the code. That would definitely not be the hard way. You are supposed to retype the examples yourself, just like back when books were print only.
It is the libraries, frameworks, and targets. These are the difference between just learning a language and having grown up with it.
No, the fact the language doesn't deal with the real programmer's life issues with (eventually) bad text editor, or simply because there will always people with bad or diverging habits is python downside.
In the same way that the the it is difficult to drive nails into wood with a nail file is the downside of a nail. Once you apply the correct tool in the correct fashion the problem vanishes.
Really all you have to do is alias python to path/python -tt and there is no problem only a syntax error. Or Alternatively, I have a "bad habit" I tend on occasion to leave the semi-colon off the end of the line when writing in Perl or C. Thus both Perl and C's "downside" is that they "[don't] with the real programmer's life issues .. simply because there will always people with bad or diverging habits." Makes sense to me.
The fact that one may or may not use a text editor that you consider "good"
I wrote "... whatever text editor you have you ought to be able to set this up." If you can't then the editor is not "good," but not as a function of my personal aesthetics, but due to its lack of fitness to do its job. Are there really programmer's text editors out there that cannot substitute a tab for four spaces throughout a file?!!
You may "like it", and I can see why ... but do not dismiss the issues associated with it.
After 2 or 3 months annoyance with the tabs/spaces "issue" followed by about 10 years withoIn factut even noticing any, I think I'm entitled to dismiss the "issues associated with it."
As it happens I wasn't dismissing the issue, I was offering advice about how anyone still suffering from this issue could dismiss it.
Better to be despised for too anxious apprehensions, than ruined by too confident a security. --Edmund Burke
NOW - First note that the very SECOND I said "HOSTS FILE", note the reply my init. post got by an Anonymous Coward?
There's a reason for it, read on!
(Especially in my p.s. below where actual PROOF is & this argument with the same AC here today I blew him away on, regarding my Python HOSTS file processing program I noted here -> http://yro.slashdot.org/comments.pl?sid=2265388&cid=36604424 ):
NOTE THE MODERATION, to "Insightful"? here in the parent troll's post:
http://developers.slashdot.org/comments.pl?sid=2278690&cid=36606908
And then, the downward moderation by HONEST others afterwards?
Again - There's a reason for it!
It's obviously a troll, & modded up, INITIALLY (but in a cheating way by the trolltalk.com bunch I have caught them in before, see below, keep reading this only gets better):
I.E.-> Trolltalk.com members here mod others down, @ the decent posters' expense no less, & mod themselves up, via nefarious tricks... tricks & off topic harassing trolling + libel I will produce proof of!
So - that all "said & aside":
IF some of you have EVER wondered WHY a post of yours was modded down (especially vs. countertrolling, or tomhudson, for example (there ARE others amongst their bogus group too))?
Don't wonder!
Especially if you "blow the away" many times on tech topics & get their "geek angst up", as I have vs. tomhudson here as an example thereof -> http://slashdot.org/comments.pl?sid=2230966&cid=36418796
ONCE YOU DO THAT?
Well - They will scan for you either by SearchSlashdot, or GOOGLE if need be (or your post history) & mod you down to "oblivion" as they have literally told me they would IF I ever took a registered "LUSER" account here!
E.G.:
---
"First off, why don't you just get an account instead of posting AC? Some (many) of us are tired of you're trolling and would like to be able to mod you down" - by Anonymous Coward on Monday May 23, @01:08PM (#36219132)
FROM -> http://it.slashdot.org/comments.pl?sid=2177744&cid=36219132
---
(I would register here actually, & yes, even IF they down-modded me, because I have hundreds of mod ups EVEN AS AN AC (& we start @ ZERO, unlike registered LUSERS (no, the good folks here are not that - just the trolltalk.com crew)).
So, why don't I?
Well... A gent named Andy K. has "APK" already, & I won't settle for another username (I like being myself online, nobody can take THAT from you anyhow).
Plus, & I'll be STRAIGHT about this: As an AC, I have a very simple & FAST method to post as much as I like, & no dumb discriminatory "10 posts per 24 hour limit" most AC's have that are NOT registered accounts!
So that all "said & aside", you want PROOF of my accusations, beyond that quote above...?
See my p.s. below!
Especially in regards to HOSTS files, myself being modded down for posting about them, & tomhudson + countertrolling MOSTLY & often by AC replies!
(Because I've blown tomhudson's DOORS OFF many times on technical issues when he has trolled me, see link above on THAT note!)
APK
P.S.=> HOW TROLLTALK.COM (tomhudson, countertrolling & others) cheat the moderation system!
(Here is where countertrolling explains what he's doing while he trolls myself to his fellow trolltalk.com friends in fact)
NOW, they do this MOSTLY to harass you, to get you into theirr "journals" they CLAIM are the "most viewed" etc. & highly rated etc./et al!
That's the
O'Reilly only publishes crappy titles these days anyway
Most of this "advice" is bullshit. The "line I've been programming for a very long time. So long that it's incredibly boring to me. At the time that I wrote this book, I knew about 20 programming languages and could learn new ones in about a day to a week depending on how weird they were. " gives it away.
Sure if you've got a background covering C you can pick up those languages based on C syntax pretty quickly - in terms of writing raw statements - but that means very little as most of the heavy lifting these days is done using the supporting libraries. Sure myself I picked up C# syntax in about that, but groking .Net to a productive level takes a fair bit longer. Even Javascript, which appears very simple for someone with a C background is deceptively simple to think you've got but you're probably missing out on the subtleties whole protoypical inheritance model. And then there's C++. Can anyone who doesn't code C++ as their day-job for less than two years really claim to have C++ and completely under their fingers?
And we haven't even considered more unusual things like Haskell or Prolog, or even Lisp where it's not just a question of the syntax. Sure if by 'picking up' you mean getting to the point of being able to code Quicksort then yes, but otherwise - well I call bullshit. And I've got over 20 years experience and an average of one language a year over that (but I'd only claim to really have half a dozen completely understood).
This is exactly how I like to learn, a dew lines about the code, the code, and expected output. Its concise, no crud in there. Its a format i'd like to see more of. I remember reading a C++ book, one of those monster ones from the late 90s that used up about 50 pages printing out encoded resource files, pages and pages of non-human readable crap. (Being a nub at the time I actually typed a lot of it out)
> 1. Go through each exercise, 2. Type in each sample exactly
> Do not get sucked into the religion surrounding programming
> languages as that will only blind you to their true purpose of being
> your tool for doing interesting things.
Yes, but to type in the programming exercises, do you recommend using vi or emacs? :-/
I've never seen an in-depth O'Reilly book. They all seem to be printouts of man pages. Does anyone have a list of gems from O'Reilly that they'd like to share because I found most of their stuff a waste of time.
GNU Emacs, of course.
Agree. I'm always being told how wonderful/portable it is but every time I try to run a Python program I get "wrong version" or something.
Chapter 0 of the book has "Make sure you install Python 2 not Python 3.". Uhuh, there's a language I want to invest some time in. Not.
Is there a reason why the language designers didn't put some kind of versioning into their language when they took the decision that backwards compatibility wasn't important to them? Some sort of shebang on the first line with the version number...? It's not difficult.
The other setup advice, ie.:
Open Edit->Preferences select the Editor tab.
Change Tab width: to 4.
Select (make sure a check mark is in) Insert spaces instead of tabs.
Turn on "Automatic indentation" as well.
Doesn't inspire me to learn Python either. Why impose a rigid spacing structure on a language in a world where tabs aren't standardized (and never will be)? Brackets (or whatever) aren't difficult.
I grok that Python is great for I'm-too-busy-to-learn-a-proper-language programmers to knock batch scripts together quickly but it's not a language for serious work (ie. programs that take more than a day or so to write).
No sig today...
Use sharepoints/ms access and get a promotion! I am a techgod in the eyes of computer illiterates!
Just use 'cat > program.py'.
So, your post comes down to "I've never used python, let alone programmed in it, but I know enough to insult those who do".
I programmed in mostly C++ and java (with some lisp and ML) for 20 years before I tried python, and when python is a little sluggish for my needs, I fall back on them but I hardly ever need to. Maybe you're the one who can't be bothered to learn something new and are looking to justify that to yourself.
http://rareformnewmedia.com/
Yes, but to type in the programming exercises, do you recommend using vi or emacs? :-/
The author suggests gedit, for all platforms, which is a fair enough suggestion. However he then insists on using spaces over tabs, without any explanation of the relative merits, thus already choosing a side in yet another programming disagreement. A simple "choose one and stick to it" would have sufficed.
Personally If I follow the book I'll be using vim + tabs, because those are what I'm used to and prefer, but that's just me.
Cited from http://learnpythonthehardway.org/book/ex50.html :
"Other Python programmers will warn you that lpthw.web is just a fork of another web framework called web.py, and that web.py has too much "magic". If they say this, point out to them that Google App Engine originally used web.py and not a single Python programmer complained that it had too much magic, because they all worked at Google. If it's good enough for Google, then it's good enough for you to get started. Then, just get back to learning to code and ignore their goal of indoctrination over education."
Hmmm... I remember times when Guido v.Rossum, Tim Peters and others were working at a company called BeOpen.com ... may this shows my age.
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany
Advice from and old programmer. (Score:-1, Flamebait)
Is now the moderation on his post, when it was this before:
Advice from and old programmer. (Score:0, Insightful)
---
* So, as the saying goes: "The community takes care of its own"
(Good job fellas)
These trolltalk.com pests are EXACTLY what I said they were in my post about them here:
http://developers.slashdot.org/comments.pl?sid=2278690&cid=36608082
That showed how they operate unfairly against myself, & probably others here too... & what they do AND how they go about doing it, in down-moderating others, & modding one another up in teams (even if their post is a troll or just plain useless b.s.!).
* Trust me: Unfortunately, I know, 1st hand - They've literally been doing it to me for over a year now here on /. forums
(Just because I "blew them away" here -> http://slashdot.org/comments.pl?sid=2230966&cid=36418796 shown, & many times for their attacks on myself on HOSTS or Windows - talk about "geek angst"...)
APK
P.S.=> These trolltalk.com pests that infest the /. (slashdot) forums (mainly tomhudson &/or countertrolling)? Victims of their OWN "geek angst" & absolutely NO morals/scruples/principals/ethics whatsoever...
... apk
Neither:
If a programmer tells you to use vim or emacs, tell them, "No." These editors are for when you are a better programmer. All you need right now is an editor that lets you put text into a file. We will use gedit because it is simple and the same on all computers.
The road to tyranny has always been paved with claims of necessity.
Adobe Reader X "Properties" says it's been made using LaTex and is 8.25 by 10.75 inches (20.1x 27.3 cm), doesn't look very A4 to me.
Yes, but to type in the programming exercises, do you recommend using vi or emacs? :-/
The author suggests gedit, for all platforms, which is a fair enough suggestion. However he then insists on using spaces over tabs, without any explanation of the relative merits, thus already choosing a side in yet another programming disagreement. A simple "choose one and stick to it" would have sufficed.
Personally If I follow the book I'll be using vim + tabs, because those are what I'm used to and prefer, but that's just me.
I think that's a foolish decision.
Sure, either tabs or spaces will work fine, as long as you're consistent. The problem is that once you move beyond toy programs you will be sharing code with other developers, modifying code you get from other sources, etc. And that other code will use spaces, which means that when you mix your tab-using code with it, stuff will break.
When writing Python, follow the Python community's coding conventions, and one of the strongest and most important is to use spaces, not tabs, for indentation.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
Does OSX actually have any advantages over any other OS when it comes to typography?
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
Sorry, had to say it...
I like (and use) Java a lot but there's some truth to the statement.
Java has a funny learning curve. You can start writing things that
work pretty quickly, but it takes a very long time to learn how to
map your problem to java correctly the first time -- I mean years.
And a long time to learn to have enough confidence to rip something
out and start over when you realize you've gone down the wrong path. And if
you're working with a group, it's even harder to restructure. Plus
people working commercially have managers beating them up
with deadlines. So people crank out what they know and patch
up large systems keeping time impact to other programmers and
existing releases to a minimum, and you end up with a lot of
sub-optimal code.
But you can get it right. We've got one system that we got pretty
close to right a few years back and it's held up without much change
while being retargeted over and over again to different applications.
Why? We got the underlying model right, and we mapped that model to
Java the right way.
#TrollTalkComReversePsychologyKiller.py (Ver #3 by APK)
import re
def reverse(s):
try:
trollstring = ""
for apksays in s:
trollstring = apksays + trollstring
except:
print("error/abend in reverse function")
return trollstring
s = ""
print reverse(s)
try:
s = '...and once word got round of "APK'' + ''s AMAZING DISCOVERIE!!", Python usage plummeted.'
match = re.search('"(.*)', s)
if match:
s.replace ('"','')
s = reverse(s)
print(s)
except Exception as e:
print(e)
I think if you start with the Holy Grail or Life of Brian first, its much easier. Then maybe hit the Flying Circus series.
Can't beat that.
You don't have to hit enter when you reach the end of the textbox. There is a thing called word wrap.
nihilism where the most meaningful syntactic element is the empty nothingness of space.
Is there a reason why the language designers didn't put some kind of versioning into their language [...] Some sort of shebang on the first line with the version number...? It's not difficult.
C:\>python
>>> import sys
>>> sys.version
'2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]'
>>> sys.version_info
(2, 6, 5, 'final', 0)
You were saying?
I perused the chapters from start to end, skimming over all-too familiar ones, and looking at the writing and examples explained. It's a fine read for people new to programming.
It may not be very technically in-depth, may not cover all examples, and it may not warn about all the caveats, but it's a good place nonetheless.
That's the point of this book.
If you already know programming, you might find it a bit slow, and would probably prefer something like Dive Into Python.
I like the creative examples near the end, which introduces ideas like string manipulation and sentence parsing.
I found some of the writing too prolix, for my liking, but that's just me. And no, I don't have ADHD; my other personality might though.
Kudos to the Author, Zed.
It's your loss. I spent a lot of time learning "proper languages" before getting around to trying Python.
When I finally got around to looking at the language, I regretted not learning it sooner. I was able to both learn the language and write the program that I needed in less time than it would have taken me using the languages I already knew.
Python is a handy tool to have available. Sure, it isn't the best tool for every job, but neither is duct tape.
I never copy paste code even when I can and probably should. Instead I type it out. I find my understanding of what it does deepens, and I tend to retain it longer.
I am Bennett Haselton! I am Bennett Haselton!
Python is a language that takes a day to relearn every time you have to switch to it. I foolishly chose it over Java for my Google app engine code. Only a few hundred lines, but so stupidly different in syntax to every other language that I regularly use it's just a pain. I hate it. Python is fine if that's the only language you use, or if you have a keyboard where it's really hard to type { and }.
I'm a scientific programmer, mostly working on mathematical models and simulation. Almost all the work I do is for myself, and I have very little experience working with others' code. Many of the people I know who use Python are in similar situations. I have personally had far less trouble with tabs than with spaces (aesthetically and functionally), and it's what I'm going to continue using until my circumstances change, since Python doesn't care either way (only the community, who will never see my code).
I just think that if you're going to tell people to use spaces instead of tabs, at least explain why. It's rather inconsistent considering the author tried to avoid the issue with text editors.
> Most of this "advice" is bullshit.
I've seen endless numbers of programming tutorials that start with "type this in, and run it." Rarely do they adequately explain in advance what the code is supposed to do and what it means. They never offer any help if your example won't compile/run either. You're stuck.
The very first lesson should be about program design, not code. You wouldn't build a house without drawing up a blueprint first, would you? Otherwise how do you know what you're building? Yet the vast majority of programming books tell you to start coding right off the bat. I think this is a significant contributor to why we have so much bad software out there today.
> 1. Go through each exercise, 2. Type in each sample exactly
> Do not get sucked into the religion surrounding programming
> languages as that will only blind you to their true purpose of being
> your tool for doing interesting things.
Yes, but to type in the programming exercises, do you recommend using vi or emacs? :-/
He didn't get sucked into that - he recommends gedit.
Different purposes:
designing a house and developing a "real" application
vs.
learning how to use a scroll saw and how to use a programming language.
I'm writing a project in IronPython at the moment - my first serious venture into the language. Actually I find it not at all bad mostly and most things certainly code up pretty quickly - much more so than C# or VB. However when I trip over an I really trip over an issue because all the documentation for .Net is in C# and whilst translating is generally easy enough, occasionally it's a complete nightmare. I've probably saved myself a little time over writing in C#, and it's certainly very nice looking code, but not without issues.
Python is relatively exotic in syntax compared to the run of C/C++/Java/Javascript type languages, but it's not that far from the nest.
This method is pretty horrifying. It's as if someone suggested learning German by repeating hundreds of sentences in German. You can't learn by merely copying stuff down; you have to learn by doing. If the book had a bunch of exercises that started with a code sample and then said, "look at this example and try to do something subtly different," that would be "learning python the hard way." This is just "learning python the boring way." This book takes learning programming, which should be fun, and turns it into a chore.
"If a programmer tells you to use vim or emacs, tell them, "No." These editors are for when you are a better programmer. All you need right now is an editor that lets you put text into a file. We will use gedit because it is simple and the same on all computers. Professional programmers use gedit so it's good enough for you starting out."
It's right there in the book which makes your joke kinda dumb.
Python is a handy tool to have available. Sure, it isn't the best tool for every job, but neither is duct tape.
Sacrilege! How dare you besmirch the holy duct tape! Burn him! Burn the heretic!
I laughed at the weak who considered themselves good because they lacked claws.
#TrollTalkComReversePsychologyKiller.py (Ver #2b by APK)
def reverse(s):
try:
trollstring = ""
for apksays in s:
trollstring = apksays + trollstring
except:
print("error/abend in reverse function")
return trollstring
s = "String to reverse."
print reverse(s)
try:
print(5)
s = "...and once word got round of \"APK\'s AMAZING DISCOVERIE!!\", Python usage plummeted..."
s = reverse(s)
print(s)
except Exception as e:
print(e)
---
And, there we go - most "primitive build" there is, but it works just using / escapes.
APK
P.S.=> Which will, of course, save me time when I do a "ReVeRsE-PsYcHoLoGy" reply back to the trolltalk.com trolls like tomhudson &/or countertrolling doing to myself here for more than a year... apk
At the same time, drawing up the blueprint doesn't do you any good if you don't know how to nail two boards together properly...
Nothing to see here
I've got almost 40 years in, and long ago lost count of languages, operating systems, and hardware environments.
You'll get past this stage.
You will never have any living computer language "completely understood" for any significant amount of time if you are working on anything more meaningful than simply tracking that language's implementation arc in a world of constantly changing underlying platforms.
There's a difference between learning a language and memorizing that language's commands and libraries. There's a difference between knowing a language and knowing which language features are optimally supported on a specific OS or hardware implementation, too.
Learning how you learn is the key, and I think you've already got that. Trying to learn every single thing there is to know about a computer language is a waste of time that could be better spent creating something wonderful. Instead, just learn language weaknesses and vulnerabilities, and google for syntactic boilerplate as you need it.
Hopefully you'll reach a point where you know exactly what you want to accomplish, and how that can be optimally computed in the target execution environment (regardless of whether that evironment is an embedded RISC processor or a browser DOM) and you'll plot the best path to get to that goal in whatever languages are available to you.
Eventually you'll probably start avoiding the use of any libraries at all, and start liking languages with very terse syntax. When you find yourself preferring to write fifty lines of C rather than five lines of perl that calls in 50,000 lines of code from CPAN, look out! If you don't keep that tendency well under control, you might turn into Paul Graham.
To avoid that fate, train yourself to always write code that is maintainable by people who are far less skilled than you are. That way you can delegate maintenance and enhancement to less skilled hands, and go do more interesting things yourself.
From the article:
If a programmer tells you to use vim or emacs, tell them, "No." These editors are for when you are a better programmer. All you need right now is an editor that lets you put text into a file. We will use gedit because it is simple and the same on all computers. Professional programmers use gedit so it's good enough for you starting out.
Agree. I'm always being told how wonderful/portable it is but every time I try to run a Python program I get "wrong version" or something.
Chapter 0 of the book has "Make sure you install Python 2 not Python 3.". Uhuh, there's a language I want to invest some time in. Not.
Is there a reason why the language designers didn't put some kind of versioning into their language when they took the decision that backwards compatibility wasn't important to them? Some sort of shebang on the first line with the version number...? It's not difficult.
The other setup advice, ie.: Open Edit->Preferences select the Editor tab. Change Tab width: to 4. Select (make sure a check mark is in) Insert spaces instead of tabs. Turn on "Automatic indentation" as well.
Doesn't inspire me to learn Python either. Why impose a rigid spacing structure on a language in a world where tabs aren't standardized (and never will be)?
That's only the convention the author is using. Python spacing rules are more flexible than that. If you wanted to really know them you could have googled it a long time ago. As for the rationale (again, google it?) it does make up for much readable code. I know that for some it is an idea that they cannot stomach, but readability as part of the syntax is a good think.
And as of why, have you ever had to face code with horrendous indentation or no indentation at all? Specially when people mix code with markup (oh the atrocity)? If you haven't then either you have been a lucky bastard always working with the best of programmers in eternal bliss, or you don't have much work experience at all. Newsflash: most programmers suck at writing readable code. And no, sometimes you cannot run a formatter on source code to fix the damned thing (for political and sometimes even technical reasons.)
In times like these (which are far more often that one would wish), you do end up wishing for some sort of readability function as part of the syntax.
Brackets (or whatever) aren't difficult.
And yet people still fail at writing readable code blocks and scopes with them. For that matter, if it compiles it's great, even if it is impossible to read.
I grok that Python is great for I'm-too-busy-to-learn-a-proper-language programmers to knock batch scripts together quickly but it's not a language for serious work (ie. programs that take more than a day or so to write).
It is the premier language for scientific computation and game scripting. And it has been used quite successfully in the enterprise - even if it hurts you - for writing complex applications. At this point you are just trolling and pulling arguments out of thin air just to justify your dislike for the language. I mean, it is your right to like or dislike as you please. Just don't pretend that you are being accurate, educated or objective about it.
+5! (Score: 6, Hilarious)
insensitive clod overlords obligatory xkcd car analogy russian reversals whoosh pedant fanbois ftfy in 3...2...1..PROFIT
isn't nihilism more about a belief that everything is meaningless, so what's the point?
if the meaningful synctactic element is the nothingness of space, that is probably closer to buddhist ideas, where the emptiness of things is as important (and definitely not meaningless) if not more important than the substance of things.
Guys, I'm just like you. I put my pants on one leg at a time. The only difference is once my pants are on I make killer apps!
insensitive clod overlords obligatory xkcd car analogy russian reversals whoosh pedant fanbois ftfy in 3...2...1..PROFIT
Guys talking about "Experienced Programmers" is, they haven't learned what I said @ the bottom of my 1st reply, & that is that EVERY LANGUAGE HAS A "NICHE" IT IS PARTICULARLY GOOD AT, & they all lend themselves to certain thing very well.
Let's see - Since 1982 here, I've written code professionally in:
COBOL .NET dialects (mostly VB.NET &/or ASP.NET)
RPG
FORTRAN
Assembly
C
C++
JAVA
PASCAL & variants thereof (Delphi)
BASIC & variants thereof (such as VB or VBA)
PERL
Python
DOS Batch &/or *NIX shell scripts
SQL (not really a language, it is, & it isn't by itself @ least)
HTML (not really a language, more text process markup tool)
* And, it's ALWAYS work too, even on shorter stuff like I did above, because it's NOT just about writing the code, it's about making sure the DATA COMES OUT STRAIGHT too!
There's system analysis/business analysis involved as well!
(Imo, you most always see things you could have done differently or better & more "generically"/catch all for more circumstances etc./et al, later on OR even then... but, then it's a matter of deadline & time free you have IF you can "get back to it later" & correct for it (if REALLY needed that is) & further "optimize" past the QA & bugtest regression tests cycles).
If you aren't willing to learn new things, then, you're really "limiting" yourself... because diff. shops/companies use diff. tools, & they're are NOT going to change entire codebases to suit you (I learned that early on, my 1st 2yrs. coding professionally really).
APK
P.S.=> The parent poster & the fellow you replied to, imo @ least, are the kinds of guys "stuck in their loops" perhaps @ that which they learnt & stuck by ONLY... & aren't flexible enough or willing to change + learn/grow!
... apk
it does this. the extra credit on each exercise gives a challenge based on what the basic goal of the exercise was. I havent looked through all of these to find if there are some that are especially exciting or fun, but the chance at a bit of entry-level creativity is there.
gedit
I think that believing you'll never have to share code with others is eventually going to cause you great pain. I hope I'm wrong :-)
Oh, and vim can be configured to always use spaces, but make that completely transparent to you.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
I have done very little programming (other than excel) since my college classes in Pascal. based on the reviews here, and the fact that the book is available online for free, I decided to give this book a try.
I have gotten to this, "Try more format characters. %r is a very useful one. It's like saying "print this no matter what". Search online for all of the Python format characters."
Well, I searched online. I went to http://docs.python.org/library/stdtypes.html and found this
Just to ask, do you really think this means much to a person who has not been involved in programming for several years?
This book is both too basic, with the instructions of "just type what you see," and too advanced, with an assumption that the reader already knows about the subject and needs no explanation beyond "go look it up somewhere"