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

  • Context: Python 
  • Thread starter Thread starter deltapapazulu
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the challenges faced by a newcomer to programming in Fortran and Python, particularly in setting up a development environment and understanding how to use various tools and IDEs effectively. Participants share their experiences and offer advice on compiling and running code, as well as navigating different programming environments.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Homework-related

Main Points Raised

  • The original poster expresses frustration with the lack of clear tutorials for setting up Fortran and Python, feeling overwhelmed by the available resources.
  • One participant suggests using Emacs or Notepad to write Python code, providing a simple example of a Python script and instructions for running it from the command prompt.
  • Another participant notes that Python can compile programs even without the application being open, sharing their experience of running a script successfully from the command prompt.
  • There is a discussion about the desire to learn the mechanics of IDEs rather than just writing simple programs, with one participant emphasizing the importance of understanding the development environment.
  • A participant mentions that Python is mostly interpreted and compiles to bytecode, which is faster than direct interpretation but not as fast as native machine code.
  • Some participants share their experiences with IDLE, describing its functionality and ease of use for running Python programs.
  • One participant raises concerns about the limitations of IDLE and the Python shell when running complex programs, seeking clarification on their capabilities.
  • There is a mention of a recommended tutorial, "Dive into Python," which is noted to be suitable for those with some programming experience.
  • Another participant expresses a preference for debugging through logging or print statements rather than using a debugger, indicating differing approaches to troubleshooting code.

Areas of Agreement / Disagreement

Participants generally share their experiences and preferences regarding IDEs and programming practices, but there is no consensus on the best approach to learning or using specific tools. Some participants advocate for IDLE, while others prefer command-line tools or Emacs, indicating a variety of opinions on the matter.

Contextual Notes

Participants express varying levels of familiarity with Python and Fortran, and there are references to different operating systems and environments, which may affect the applicability of advice given. The discussion reflects a range of experiences and preferences in programming practices and tools.

Who May Find This Useful

Newcomers to programming in Python and Fortran, individuals seeking to understand different development environments, and those interested in learning about IDEs and debugging techniques may find this discussion beneficial.

deltapapazulu
Messages
84
Reaction score
13
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.
 
Technology news on Phys.org


Well, use Emacs or some other editor (Notepad?) to put some Python code in a file. For example, your file could say
Code:
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:


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.

mXSCNT said:
Well, use Emacs or some other editor (Notepad?) to put some Python code in a file. For example, your file could say
Code:
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:


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
 


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.
 


Oh and if you are looking for good Python tutorials, there is one that is really 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:


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.
Sypher said:
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.
 


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.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
6K
  • · Replies 7 ·
Replies
7
Views
9K
  • · Replies 10 ·
Replies
10
Views
19K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
8K