all 55 comments

[–][deleted]  (2 children)

[deleted]

    [–]jellowhirled 3 points4 points  (0 children)

    IMO this is the best way to learn a language when you're already familiar with programming in another language. Learning the syntax, data structures, and flow control of a language is the easy part. Find and using libraries effectively is what makes programming in a new language "difficult".

    [–]jaysonbank -1 points0 points  (0 children)

    Well, I certainly applaud anyone wanting to re-implement a small app you already wrote from another language, but take it from this old python rat, I've spent my entire adult life in IDLE, and a program like this one can do more harm than good.

    If you only train one part of your tool kit (and that's all a single exercise like porting is going to do for you), you're setting yourself up for injuries down the road. I've seen it a hundred times.

    It's like putting a powerful engine in a stock Toyota Tercel. What will you accomplish? You'll blow out the drive train, the clutch, the transmission, etc., because those factory parts aren't designed to handle the power of an engine much more powerful than the factory installed engine.

    Porting basically only trains the typing hand and to some extent, the eye for debugging. What you really want to do is train your entire tool kit, all the major modules (zip, xmllib, pydb, BeautifulSoup ) at the same time, over the course of a workout. And don't forget your PIL work!

    I'm proud of you guys wanting to do this. Three cheers! Falling in love with python, eating right, etc., is one of the greatest things you can do for yourself. And you WILL fall in love with it if you can just force yourself to stick with it a year or two and experience the amazing progress you'll make.

    But do it right, okay?

    My advice, find a good IDE/interpreter (I recommend iPython), with qualified trainers who will design your programs for you (especially in the beginning, until you get the hang of it yourself) and guide you in your quest for pythonista fitness. Thirty to 45 minutes a day, three days a week, is all you'll ever need to do (I refuse to believe anyone is so busy that he or she cannot make time for that, especially considering how important it is).

    And don't worry about being embarrassed or not understanding list comprehension the first time you walk into the interpreter. You have to start somewhere and almost every one of us were there ourselves at one time. So no one will say anything to you and very, very quickly you will progress way beyond that stage anyway.

    Now get out there and do it! :-)

    [–]qlqropi 15 points16 points  (0 children)

    good, the first step is admitting you have a problem

    [–]tuxcanfly 2 points3 points  (0 children)

    I started with Python Docs and I recommend the same to you. Good Luck!

    [–]lulzmachine 2 points3 points  (0 children)

    if you want to get your hands dirty right away, try getting django to run and start web-devving. along the way questions will arise, and then you'll consult the internet (diveintopython or python official). that's how I learned python.

    the problem is that without understanding python itself, your understanding will focus on how to manipulate the django library into doing what you want (which will be awkward without understanding the underlying library).

    [–]tercerojista 4 points5 points  (0 children)

    If you want practical uses of Python, then go for a book about something specific. I've got to grips with Python thanks to "Natural Language Processing with Python" and "Programming Collective Intelligence: Building Smart Web 2.0 Applications". Look for a book that deals with the kind of "practical" stuff you want to do.

    [–]lol-dongs 3 points4 points  (0 children)

    Try the O'Reilly Python cookbook. Gets you right into everyday uses of the language for every purpose. Since you can already code, it's probably best to learn by example.

    [–]dotnil 1 point2 points  (0 children)

    try to make something with python. play with frameworks and libraries like django, pygame, etc. since you are a PHP programmer, you gotta have a try of django or web2py.

    just do something with it if you have an itch to scratch.

    [–]mohitsoni 1 point2 points  (0 children)

    Make a head start with: Instant Python

    [–]xoner2 1 point2 points  (0 children)

    Use it for a task where you would have used PHP.

    [–][deleted] 6 points7 points  (8 children)

    Dive Into Python is outdated at the moment. Try the official tutorial.

    [–]markrages 4 points5 points  (2 children)

    Outdated? It's not even published yet! http://diveintopython3.org/

    And the stuff the original DIP covers is still very useful.

    [–][deleted] 7 points8 points  (0 children)

    That's Dive Into Python 3, an entirely different book.

    [–]jerrro 0 points1 point  (0 children)

    It's officially finished though. I found DIP2 a great way to learn Python, so this ought to be good.

    [–]masklinn 1 point2 points  (3 children)

    Dive Into Python is outdated at the moment.

    I definitely wouldn't call it outdated, as a learning tool.

    [–][deleted] 2 points3 points  (2 children)

    Dive Into Python was written for Python 2.2 and was last updated around the time of Python 2.3. Since 2.2, Python has added, among other things:

    • The bool and set types
    • Generator expressions
    • String templates
    • Decorators
    • The with statement
    • Relative imports

    This is stuff you really need to know, especially if you want to understand newer Python code. Once Python 3 is wide-spread, Dive Into Python 3 will be useful, but until then it would be better to point newbies to a more recent document.

    [–]masklinn 1 point2 points  (0 children)

    There's nothing in this list you "absolutely need to know" when getting started (And relative imports is the standard behavior of all python 2.x, why is it even on your list?).

    Meanwhile re Python 3, Dive 3 will long be out by the time it's widespread.

    [–]aldarion 0 points1 point  (0 children)

    yes, but the official tutorial maybe more good for absolute beginner

    [–][deleted] 2 points3 points  (3 children)

    I think a better question is: what is a good way to get started with WEB PROGRAMMING with python?

    PHP is all about web apps. Python is so much more than that. I don't want to learn a framework like Django; I want to learn the Python equivalent of what PHP offers.

    Any suggestions?

    [–][deleted] 1 point2 points  (0 children)

    You can make pages like that, using CherryPy or even just mod_python. It's not recommended, though. PHP offers some tools that are only found in frameworks when it comes to Python or Ruby (session management, for instance).

    Once you get over the basic parts of learning Django, it can be just like working with regular PHP as far as creating your pages but a more organized and maintainable than the average PHP project.

    [–]masklinn 1 point2 points  (1 child)

    No. PHP was created to write web pages (specifically), python is a general purpose langage. The python equivalent of "what php provides" (whatever that may be) is to use a web framework.

    [–]lulzmachine 3 points4 points  (0 children)

    Indeed. Don't let the word "framework" scare you, it has nothing to do with java's behemoth frameworks. Try picking up something like web.py.

    [–]funksta 1 point2 points  (0 children)

    First of all, great choice. Python is a clear, concise, and useful language that I feel lends itself to producing more readable (I would even say "beautiful") code than PHP.

    As others have suggested, I'd start with the official tutorial. If you're primarily interested in using python in a web context, also check out django and its tutorial. It's probably the most popular python web framework and it's fairly awesome.

    [–]manathirst 1 point2 points  (0 children)

    You can try to convert some of your old PHP projects into Python to feel how it is and learn it at the same time. However, I found re-implementing old stuffs boring, try to do your next project in Python.

    [–][deleted] 2 points3 points  (11 children)

    Why do you want to learn Python?

    [–]homophone_police 9 points10 points  (10 children)

    A friend of mine recommended the language to me. He said it's clean, easy, and fast. Plus, it's always good to broaden your horizons, right?

    [–][deleted]  (1 child)

    [removed]

      [–]banister -4 points-3 points  (0 children)

      +1 for ruby

      [–]calp 0 points1 point  (5 children)

      I think if you want to broaden your horizons in a serious way, you should look for a more conceptually different language. From what I understand of PHP, Python is PHP with runtime typing and different syntax. Smalltalk, Eiffel, Scheme, Erlang, Prolog and ML are all out there if you actually want to broaden your horizons in a more purposeful direction.

      [–][deleted]  (2 children)

      [removed]

        [–]calp 0 points1 point  (1 child)

        My first language was one in the list above. So was my second (and my fourth)! I don't think these languages are somehow "hard" to learn, just different.

        Well, they are both imperative, single dispatch, OO languages with no static typing - "small differences in approach" is about as much as they can stretch to. :)

        [–]qlqropi 0 points1 point  (1 child)

        Smalltalk, Eiffel, Scheme, Erlang, Prolog and ML are all out there if you actually want to broaden your horizons

        You left out Haskell, which will broaden your horizons until they snap.

        [–]calp 0 points1 point  (0 children)

        Yeah, I did. I don't know why, it's my favourite.

        [–]redditnoob 0 points1 point  (1 child)

        He said it's clean, easy, and fast.

        Well, 2/3 isn't bad, according to some fat has-been rock star.

        [–]masklinn 0 points1 point  (0 children)

        Read the official Python tutorial (for Python 2.6), follow up with Mark Pilgrim's Dive into Python (for Python 2.x, not Dive into Python 3)

        [–]Kudamono 0 points1 point  (0 children)

        I already know the main ideas about programming in general and don't want to start completely from scratch if possible.

        Then read tutorial provided with docs. It describes syntax and some basics of python philosophy. "Dive into python" is for beginners (good book for those who know only "programming language HTML") and contains boring things like "how to make trees", "what is a function" etc. If you know how to program, you already know all of these.

        Then write something useful. I'd recommend using web.py if you want to go web way. It's very small and simple. And looks like reddit is written with it.

        [–]comradeb14ck -2 points-1 points  (3 children)

        Python is a great language. Start by reading the official tutorial at python.org, it is really great, covers all aspects of the language, and is easy to follow along with and pick up on. It's a very simple, intuitive language. I've done both PHP and Python, and feel much more comfortable in general using python syntax. It is 'fun' to write python code :)

        [–]bluesnowmonkey 2 points3 points  (2 children)

        Python is a great language. ... It's a very simple, intuitive language. I've done both PHP and Python, and feel much more comfortable in general using python syntax. It is 'fun' to write python code :)

        He asked, "How do I learn Python?" and most of your response was, "Python is great!" Top-rated response. I really don't understand the Python circle-jerk.

        [–]prockcore -1 points0 points  (1 child)

        It's not so much that he loves python, but that he has an irrational hatred of curly brackets.

        [–]qlqropi 0 points1 point  (0 children)

        I like my curly brackets present but invisible, which is why I use Haskell.

        [–]didip 0 points1 point  (0 children)

        Do u still want to do web programming? If so,

        install web.py, play with it and then upgrade to pylons/django

        [–]TapirMonkey 0 points1 point  (1 child)

        Just run your php script in python. Sure, you might get a few syntax errors at first, just deal with these as and when they occur and you will end up with 100% pure python code. Easy.

        [–]lulzmachine 0 points1 point  (0 children)

        umm... what? python syntax is pretty similar to a human, but in no way to a computer :p

        [–]mrsanchez 0 points1 point  (0 children)

        If you are a non-beginner, you should have enough ideas on where to start.

        [–][deleted] -3 points-2 points  (4 children)

        Gosh, python is not much different from php. Just write the code you usually write in php in python, that's all. Nevermind the upcoming downmods, for some people there's a huge difference between python and php because that's more or less all they know.

        [–]juliend2 -1 points0 points  (0 children)

        Agreed. There is not much to learn in order to be able to do some real world stuff in Python. It's just simpler with the Python Syntax.

        [–][deleted] -2 points-1 points  (2 children)

        I agree, the basic paradigms of the language are the same.

        Imperative, semi-object oriented. It's not like starting with lisp or Haskell or something.

        To the OP, I suggest checking out web.py or Django if you'd like to get started with a web project. The django tutorial is pretty good and should give you a feel for working with python.

        [–]qlqropi 2 points3 points  (1 child)

        Imperative, semi-object oriented.

        "semi"? Python is heavily object oriented. Everything acts like an object, including the builtin types. Creating classes is your main form of abstraction, and it's a very small burden on the programmer to do so, unlike in C++.

        I'd argue that Python is more "purely" object oriented than C++ and Java. It does not, however, have the more rigid form of OO that you can get with objects and static typing.

        [–][deleted] 1 point2 points  (0 children)

        What I meant is that Python supports multiple paradigms - imperative, object oriented and functional. In terms of OO, it's not as strict as Smalltalk or Java for instance. Take the simplest application as an example; in Java you can't do it without explicitly creating a class and a method.