Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran/Python newbie tired of slogging through anti-tutorials online.

  1. Jul 28, 2009 #1
    Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Ok, here is a project I am giving myself. By this time next week I want to be compiling simple codes (in Windows Vista 32 bit), in Fortran and Python. I frankly haven't the slightest idea where to start. Ok, that was hyperbole. I do have Python 2.6.2 installed and I am aware that IDLE(the shell/"ide-ish" thingy that comes with Python) is not the best IDE to work in. I am really attracted to EMACS and have that installed but have no idea how to use it to compile Python programs. I am a complete newb. If this were Counter Strike, I would be shooting 10 feet above your heads. I really thought there would be more clear tutorials available online but I have just wasted 3 hours of my night off slogging through what I call "the anti-tutorials" on Python and Fortran (the getting them set up side of things).

    I would be very grateful if someone could treat me like an 8th grader on this, assuming I know nothing and that I am arguably even slightly retarted, which I have actually not completey ruled out.

    What I really want to do is avoid wasting time going this alone.

    Thx for any help.
     
  2. jcsd
  3. Jul 28, 2009 #2
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Well, use Emacs or some other editor (Notepad?) to put some Python code in a file. For example, your file could say
    Code (Text):

    print "Hello world"
     
    Save it as something.py. Then from the command prompt (in the directory you saved it in) type "python something.py" and it should print your message. Python sometimes compiles your code (creating a .pyc file) but doesn't need to. For more information see http://pyfaq.infogami.com/how-do-i-create-a-pyc-file

    I think IDLE is the usual python environment. Personally, I usually work from the command line python REPL (Read-Eval-Print Loop). To get into this, from the command line you type "python" (in the directory you saved in). Then type "import something" and it should run the commands in the file something.py. (If something.py has function definitions, it imports those definitions). If you make a change to something.py and want to run it again, just type "reload(something)".

    Most of the time I don't make standalone scripts designed to be run as applications themselves--instead I just make function definitions which I call from the python REPL. It's both easier (since I don't have to write a user interface) and more flexible (because I have the power of python at my disposal while calling the functions).

    On Unix-ish systems, you would usually change your PYTHONPATH variable to include the directory where you keep your python projects, so that you can import modules without being in the python directory that contains those modules. I'm not sure how that works on Windows.
     
    Last edited by a moderator: Apr 24, 2017
  4. Jul 28, 2009 #3
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Thanks. That was a helpful nudge. I noticed that merely with the python windows binary installed that it will compile programs (or build or whatever, i'm not up on the lingo) even though the Python application is not open. I wrote it in notepad then saved as test.py and ran it from Vista's command prompt by cd-ing to the directory and then merely typing in "test.py". It ran it in the command prompt window.

    Actually doing that kind of released a pressure valve on my frustration. But what do I need to do to write/build/debug etc. in a traditional IDE.? At this point I am way more interested in learning the mechanics of IDEs and being able to manipulate programs rather than just writing them. Most advice has been to the oppisite. Get the Newbie to doll out some easy programs first then learn the other. But I think that is bass-ackwards. I want to learn the environment machinary because that is where all the major frustrations proceed from. Write programs is a completely other sort of frustration.

    Thx for help.

     
    Last edited by a moderator: Apr 24, 2017
  5. Jul 29, 2009 #4
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Python is a mostly interpreted language, like Java, but unlike C. It does not (under normal circumstances) compile to native binaries. It compiles to Python bytecode, which is faster than interpreting the source code directly, but not as fast as machine code would be. Compilation is a bit beside the point with Python.

    If you want to learn how to use a Python "IDE," I'm the wrong guy to ask. I don't even use IDLE, I just use Emacs and the command line. I think IDLE is the most commonly used Python IDE, but it looks like there are alternatives:

    http://en.wikipedia.org/wiki/List_of_integrated_development_environments_for_Python#Python
     
  6. Jul 31, 2009 #5
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    I mostly use the IDLE. I'ts not that hard. Just open the GUI shell. On file click "New Window", then it will open a text editor window where you enter your program and when you are done, save your program as wateva.py(Rember the .py otherwise you will have to rename or resave to run) and click "Run" and your program wil be run from the shell.
     
  7. Jul 31, 2009 #6
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Oh and if you are looking for good Python tutorials, there is one that is realy good, but is intended for people with programming experience although I think it will suit anyone. It is called Dive into python and you can get it here: http://www.diveintopython.org/
     
    Last edited by a moderator: Apr 24, 2017
  8. Aug 1, 2009 #7
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    Yeah I'm not exactly sure why I didn't think IDLE would be sufficient for python. I just copied and pasted some test programs in "new window" and selected run and it ran them fine in the shell window. What I would like to test out is some complex longer science programs to see how well and fast they run in the Python shell window. Do you know if IDLE has any limits to what it can do, or for that matter the shell. Also something I need to learn is how to use the native debugger that comes with python.

    Thx for feedback.
     
  9. Aug 1, 2009 #8
    Re: Fortran/Python newbie tired of slogging through "anti-tutorials" online.

    The shell is only a more GUI-like interpreter so I don't think the shell has limits to what cann be run in it. Like if you have a GUI app and you run it in the shell, the shell will automatically run it in a window.

    About the debugger. I don't use debuggers. I rather debug using a log or printlining so I would be the wrong person to ask.

    Well then, good luck.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran/Python newbie tired of slogging through anti-tutorials online.
  1. Python Tutorial (Replies: 8)

  2. FORTRAN Tutorial (Replies: 24)

  3. A good python tutorial (Replies: 3)

Loading...