Hacker News new | past | comments | ask | show | jobs | submit login
How I Learnt enough Python/Django to be Dangerous in 1 Month (eddychan.com)
156 points by eddy_chan on Jan 13, 2012 | hide | past | favorite | 55 comments



Nice post, I was in the same position about a year ago. It feels really good when you get to the stage when you can launch a project, which doesn't take very long with Django.

After a few months of working with Python/Django I realized how much else there is to learn and how shitty my first attempts really were. I keep going back over my old scripts every time I learn something new to see if I can improve the code. It's sometimes depressing thinking about how much there is to learn, but the power to create whatever you want is totally worth it!


I realize that the author is probably joking in saying they "learned enough to be dangerous", but I think it's worth pointing out that you can't really learn enough Python to be dangerous. That's one of the nice things about it. If you screw something up, it will let you know (albeit not necessarily as soon as a more strongly typed language would).

My advice: stop worrying about being "dangerous", and be bold! Experiment with any wild ideas you have and see if you can figure out a way to implement them in the language as well as (or perhaps even especially) the libraries that are included with the language. When you bring on a "real" programmer, they may want to kill you, but that's how you learn. Plus, if you're really that bad, you probably won't have written enough code to make that programmer's life miserable for long.


As long as you can `import os`, you can be dangerous in Python. :-)


I would be curious to see an example of such dangers. It would certainly take a lot of effort to do something stupid in such a way that your program won't necessarily crash with an exception (I'm thinking things like segfaults, heap corruption, etc). I don't doubt such a thing exists, nor do I doubt there's an idiot out there who can exploit it, but I think the vast majority of newbies out there are going to be more fascinated by other parts of the standard library. Did you know you can make HTTP requests using urllib2? Or that you can open a web browser using webbrowser? Or have you seen Django's automatic admin interface? How cool is that?!


I know Travis and yes he knows those things.

What he means by "being dangerous" are things like os.remove(), os.removedirs(), os.chmod(), etc. He wasn't talking about crashing your own Python code, but being able to do dangerous things to the OS you're running it on.


Why is that anymore dangerous than knowing how rm, rmdir, and chmod work on the commandline?

Python's os module is not exempt from permissions - it's obviously "dangerous" if you run the interpeter as root then start doing silly things like passing GET parameters to os.remove() directly... But that, IMHO, is no longer dangerous - that's just stupidity.

Really, there's nothing remotely dangerous about Python - in terms of using import os (excluding the above example which I consider idiocy), it's no more dangerous than elevating to root!?

[EDIT] I would argue that not knowing how something works is more dangerous, but that typically falls under the banner of ignorance.


"Why is that anymore dangerous than knowing how rm, rmdir, and chmod work on the commandline?"

To screw up is human. To screw up a million times per second takes a computer.

In absolute terms, the two are equivalent. But the capacity for your Python program using os.whatever to unpleasantly surprise you is much greater.


There's nothing like that sinking feeling you get when you do a DELETE FROM and forget the WHERE.


That's exactly why begin transaction is awesome.


None of that is _dangerous_ though because you've got a backup of all your data and your code is all versioned ... unless you're practicing your python on life-support systems or something?


Frank's response covers it for me. There's plenty of dangerous things you can do in os. Same goes for sys, etc. None of them are going to launch missiles at someone or cause elevators to stop working, but you could blow away a day's work, drop a directory by accident, or some such.


It's tongue in cheek from having to do a lot of copy writing at my last job. :) that being said I'm implementing a multiple-tenant app where I will have multiple user 'sites' or 'accounts' in my single django app. I've installed things like django-paypal and django-registration and had to modify them to suit my needs. I just love how there's so many pre-written modules out there on github.

At first I was really scared about modifying other people's code but as I read it through again and again it started making sense and I realized what I needed to change to make it hook into mine.


I learned Python and Django and don't feel dangerous enough yet. How much C does it take to cause serious trouble?


Knowing how to loop over an array is enough to cause a buffer overflow if you aren't careful.

edit:

Or just using the standard "gets" function really. There's an example on StackOverflow here: http://stackoverflow.com/questions/3026361/performing-simple...


I was extremely surprised when you said that you felt that there was more resources out there for Python than for Ruby.

Not saying you're wrong, I was just very surprised by it.

It feels like there are amazing Ruby resources everywhere you turn. I guess I hadn't clued into the Python world enough to notice.


In my experience current Python culture takes documentation very seriously. Popular projects like Django, SQLAlchemy, South, Pyramid, Fabric have extensive narrative documentation (in the form of an overview, a tutorial, a thematic guide, and finally a reference section). In contrast, I was pretty frustrated using Capistrano and finding third-party documentation scattered across blog posts and wikis.

This excellent culture is enabled by Sphinx, which makes it easy to publish documentation as static html content (and pdf and epub). Hosting on python.org and readthedocs.org makes it even easier to put great documentation online, and it is one of the best ways to brand a project as something people can build on.


On top of that there has been heavy use of Python for longer than Ruby.


I'm always happy to read posts from people who've learned something new and are excited to share it with the world. I feel like I don't make time to share my own learning experiences.

I would love to the see the author go a step (or maybe multiple steps) further and do some simple scale/performance testing. Essentially, how easy was it to develop and then deploy a Django app into production? What happened when too many requests came in? What did you do to diagnose?

Generally, I would love to see some simple performance measurement baseline to compare experiences with diagnosing and scaling. Like a best practices guide, maybe specific to certain frameworks of where to even begin when you're preparing to deploy an app.


I haven't got to that stage yet cos I'm still building the prototype with one other designer. I plan to use one of those selenium based services that can simulate a lot of requests at once. I need to do way more research here but as they say I've gotta get the app functional first before I worry about scaling.


That's a really great write up. It sounds like you were new to web programming as well.

How difficult was it to learn the principles of web development? Did you just learn that in the background as you learned Django?


Thanks for the props, not sure what you mean by principles of web dev?


Was it confusing to have to learn about HTTP, cookies, Javascript, HTML, stateless servers, etc?


I was a product manager for a CMS so i was already familiar with http, js but I rely only designer cofounder to actually produce all of it, I just stick the template variables, control flow and looping where necessary.

As for web programming practices i picked up the stuff on cookies, stateless servers, sessions by reading up on django middleware along the way as i started coding the app and had to add things like user registration.


I'll be following your blog. I am on a similar journey but you seems to be much more dedicated (quitting your job and all). I attempt to hack away evenings and weekends or any other spare time I find.

Also thanks for pointing me to Django by Example. I hadn't run into that resource before.


Hehe the world is not fair. I'll be the first to admit that luck has been on my side as i was a relatively early employee of the last startup that got acquired. It gave me a largish 5 figure payout that's now giving me the opportunity to devote the next 24 months to building my own.


Very awesome. I've been doing the same thing lately, except I've been building up from very little linux knowledge at all.

But now I can set up ubuntu server from scratch, and set it to serve django apps. Learned how from this link: http://blog.stannard.net.au/2010/12/11/installing-django-wit... Which is lean enough to get me up quick, but detailed enough to let me follow up and learn what's happening behind the scenes.

I'm building my own model as we speak as well. I have to say, Django is pretty damned awesome. It's worth it for the free admin interface and user system alone. Plus as a bonus I get to continue learning python.


This is almost exactly the same path I've taken to learn Python/Django. Right now I'm at where you were at the end of Week2 (stopped at Chpt8 in DjangoBook for same reasons), and have been trying to narrow down a good next step to help me fill-in some gaps in setting up a Django site I had in mind.

'Django by Example' seems like it's what I've been looking for, surprised I missed it when gathering resources.

Good luck building your app and thanks for sharing, will be keeping watch of your blog!


Hi Eddy,

Nice post. I'm curious how many total hours did you put in during the 4 weeks? Thinking about doing the same but I might have some time off and not sure if you did as well.


It was about 5-6 dedicated very focused hours per day, 5 days per week. I didn't have the stamina to go beyond that each day because there's so much learning and the mind (my mind) needed time to absorb the new material.


hey eddy, what's your background in programming? I see you have a degree in software engineering.


When I was at uni java was the language of choice for intro to programming, basic data structures and algorithms. We used C for operating systems, C++ for OO programming, oracle pl/SQL for databases. I wrote my thesis on formal methods, they were very much the flavors of the day. I did touch on web programming but we were using j2ee and I almost flunked that course. Overall I achieved above average college student experience (which wasn't very much) in all those things above and then I became an excel jockey at Accenture for my first job and never coded after that


I love this. A lot of my friends talk about creating a website and starting a company out of it, but they are too scared to actually "code." Just the term "code" is enough to scare them away. I wish you good luck in your endeavors and let me know if you need any advice (I've created ~10 django websites).


Thanks, Eddy. I hadn't seen Django by example before, and that's exactly what I was looking for.


Good post. I'm also going through the process of learning Python, but with no programming background. I found GOOG's class pretty straight forward (and so far a better resource than Learning Python the Hard Way, which I was using up to this week.)


Mind if I ask why you thought google's content was better and also what your previous background was? Could you code already?


Hi zed, Thanks for your awesome book. I started learning python from your book in preparation for a new job I was going to take and I had no previous experience about scripting languages. Not only did your book help me learn python, but the way you talked about programming in your book got me to believe that all I needed to do was to work harder to become a better programmer. I was at a point in my life where I thought that I just wasn't built for programming. I am still an average programmer, but now I know I just need to keep working. Thanks a lot.


For me, not to knock your work, it was nice to see some working on it visually. I should be much more clear here, I thought your book was very helpful and your insisting that people actually type the code out [edit] is very helpful. I have zero background in coding (or in any technical field.)


Ah, so it was the video aspect of the google course. Tell me, you watched the video and read the code in the video, so can you think about why a video with code in it was superior to a book with code in it? Was it the talking? The active watching and typing? The inclusion of faces?

Thanks for your time. I also have videos but I want to redo them so they're better. Any insight will help.


I believe it was the active watching and typing. Not sure why, but when I watch someone actually doing something it makes more sense to me. Also, watching very experienced people make minor mistakes removes some frustration from the learning process.


You should consider trying this (paid) video course by the author of LPTHW: http://www.udemy.com/learn-python-the-hard-way/


Alright cool, thanks. I actually have a video course, and what I tell people is to use the videos to get them "over the hump", then use the book like homework to complete. I may make that more explicit in later versions and point out that watching me make mistakes will help them.


Congratulations OP, and keep up the good work. Also, another good python web framework to learn on is Flask ( http://flask.pocoo.org/ ).


What exactly do "product guys" and "non technical" co-founders have to off to early-stage startups? That's the real mystery to me.


Honestly I asked this question all the time. Until a couple months ago a startup I know got a million dollar grant (no equity). Dude spent more than a year just continuously shooting for the stars with these applications and finally hit.


i'm sort of in the same boat - i'm heavily versed in perl but would like to learn python, if only that a lot of sci/research code is being written in it. Is the google code course comparable or better to the tutorial on python.org?


Keep in mind: I still consider myself a Python noob.

If by the "Google Code Course" you mean the course that is instructed by the guy with the Netscape shirt (Nick Parlante), yes, I would recommend it above the tutorials at python.org for a first round of Python knowledge gathering. Reason being: He brings up a bunch of problems and quirks of Python at the get-go, as well as a bunch of tricks and shortcuts. Overall, I think it's a very well-structured course.

Personally, I think that the tutorial and overall docs at python.org help only when you have most of the basics of Python hammered down. I found myself using them more once I started /getting/ the Pythonic way.


If you already know another programming language I think the book "Dive into Python" is the best way to get up to speed. Link is http://www.diveintopython.net/


Learn from http://diveintopython3.ep.io/ which is fresher. You may end up using Python2 due to library availability, but the differences aren't enormous.


I found the python.org tutorial quite good, but I also enjoyed Zed Shaw's "Learn Python the Hard Way":

http://learnpythonthehardway.org/book/

The same person that did Django by Example also did one for Python:

http://pbe.lightbird.net/

There are some NumPy tutorials online (and I seem to remember on Github too) which are worth tackling if that's the direction you're going in.


If you can already code the google one is better only for the fact it has those exercises which by doing them gives you more of those 'a-ha, I get python' moments. It's more learning by doing rather than learning by reading.

I just skimmed the python.org tutorial for the first time and it reads like the tl:dr version of full reference docs.


Check this out. http://python-courses.eu/ Not many people are aware of this. But its good.


Who did your graphic design, that looks nice on the blog.



The part about being "Dangerous" is either a joke or incredibly naive.

However I understand where he is coming from, it reminds me of when I learned Objective C / iPhone. I made a decent (Read:Not Great) game in 3 months of programming in my free time (Das Boot:The Hunt for U-505) The code was ugly and terribly dependent but I made 3k right out of the gate and I still get a deposit of around $50 a month from Apple 3.5 years later!

Objective C feels "easy" now and my code is clean, however it's hard not to be humbled by what you still don't know. I have been doing a lot of Server/Php/JSON/iPhone in my bootstrapping and it's really amazing how far I've come.

The journey of a thousand miles begins with a single step. Keep it up!


Dangerous in the sense he knows how to break things, but not fix them. It's a common expression for people who are getting past the beginner stage moving on to intermediate.

There's also the dunning-kruger angle. He doesn't yet know what he doesn't know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: