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

  • Fortran
  • Thread starter deltapapazulu
  • Start date
In summary: I'm sorry, I cannot provide a summary for this conversation as it does not contain any information related to the original topic.
  • #1
deltapapazulu
84
12
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
  • #2


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:
  • #3


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:
  • #4


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
 
  • #5


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.
 
  • #6


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:
  • #7


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.
 
  • #8


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.
 

1. What is the difference between Fortran and Python?

Fortran and Python are both programming languages, but they have different purposes and syntax. Fortran is primarily used for scientific and engineering applications, while Python is a general-purpose language used for a variety of tasks. Fortran is a compiled language, meaning that the code needs to be translated into machine code before it can be executed, while Python is an interpreted language, meaning that the code is executed line by line. Additionally, Fortran is known for its speed and efficiency in handling complex calculations, while Python is known for its readability and ease of use.

2. Which language is better for scientific programming, Fortran or Python?

It depends on the specific task and personal preference. Fortran is still widely used in the scientific community, especially for high-performance computing and numerical simulations. However, Python has also gained popularity in scientific programming due to its large selection of scientific libraries and packages. It is often used for data analysis and visualization. Some scientists may prefer Fortran for its speed and efficiency, while others may prefer Python for its versatility and ease of use.

3. Are there any resources specifically for beginners learning Fortran or Python?

Yes, there are many resources available online for beginners learning Fortran or Python. Some popular options include online tutorials, video courses, and interactive coding platforms. It may also be helpful to join online communities or forums dedicated to Fortran or Python programming, where you can ask for advice and tips from more experienced users.

4. How can I make the learning process more efficient and enjoyable?

One way to make the learning process more efficient and enjoyable is by finding projects or tasks that interest you and using them as a way to practice your coding skills. This can help make the learning process more practical and relevant. Additionally, breaking down larger concepts into smaller, manageable chunks and taking breaks when needed can also help prevent burnout and make the learning process more enjoyable.

5. How long does it take to become proficient in Fortran or Python?

The time it takes to become proficient in Fortran or Python can vary greatly depending on factors such as your background in programming, dedication to learning, and the complexity of the projects you are working on. Learning the basics of either language can take a few weeks or months, but becoming proficient can take years of practice and experience. It's important to remember that learning a programming language is an ongoing process, and there is always more to learn and improve upon.

Similar threads

  • Programming and Computer Science
Replies
7
Views
6K
  • Programming and Computer Science
Replies
7
Views
9K
  • Programming and Computer Science
Replies
10
Views
18K
  • STEM Career Guidance
Replies
4
Views
1K
Replies
4
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
2K
Replies
2
Views
6K
Back
Top