[Tutor] Running and passing variables to/from Fortran

2007-05-06 Thread John Washakie
I have a FORTRAN program which reads in unformatted sparse matrix
data. Rather than rewriting the code in Python, I was hoping there is
a way to call the Fortran program, passing filename variables TO
Fortran, and returning the data (which is an array) back to my .py
code for use there.

Is there a simple example of this that someone knows of?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running and passing variables to/from Fortran

2007-05-06 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Simple is the wrong idea. But I'd guess that you can access your Fortan
from C. If so, Pyrex provides a C-for-Python-coder tool. OTOH, just
reading the stuff in Python might be simpler than doing all the
interfacing. (I presume that you are just reading the data. If you have
verified working numeric code in Fortran, it's probably worthwhile to
interface with it instead of porting it).

Andreas

John Washakie wrote:
 I have a FORTRAN program which reads in unformatted sparse matrix
 data. Rather than rewriting the code in Python, I was hoping there is
 a way to call the Fortran program, passing filename variables TO
 Fortran, and returning the data (which is an array) back to my .py
 code for use there.
 
 Is there a simple example of this that someone knows of?
 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGPaUvHJdudm4KnO0RAtj2AJ9qqOxK0IxompMORJLEz7x62M8GSACdFSj/
kMxIV3hwO8eMPYG1FhYVLOQ=
=zZXq
-END PGP SIGNATURE-
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Working with error messages

2007-05-06 Thread Alan Gilfoy
I have a number-to-Roman numeral program that churns out ValueError  
messages with a few improper input cases:

1. not an integer
2. larger than 3999
3. smaller than 0

When I run the program via IDLE, and I give one of these improper  
inputs, the interpreter closes down the program and then displays the  
appropriate ValueError message.

I would like the appropriate ValueError message to be displayed before  
the program shuts down, or at least a generic ValueError message.

Is looking at my specific pieces of code necessary to help with this?

I want this because if the program's being run as an application, the  
application window closes down as soon as the program closes, and the  
user doesn't get to see the message. [When I doubleclick on the .py  
file in Windows Explorer, it runs as a .exe, for example.]
-- 
Computers were the first God-Satan collaboration project.
Blind faith in bad leadership is not patriotism.

One of the most horrible features of war is that all the war-propaganda, all
the screaming and lies and hatred, comes invariably from people who are not
fighting.-George Orwell, _Homage to Catalonia





___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Working with error messages

2007-05-06 Thread Andre Engels
2007/5/6, Alan Gilfoy [EMAIL PROTECTED]:
 I have a number-to-Roman numeral program that churns out ValueError
 messages with a few improper input cases:

 1. not an integer
 2. larger than 3999
 3. smaller than 0

 When I run the program via IDLE, and I give one of these improper
 inputs, the interpreter closes down the program and then displays the
 appropriate ValueError message.

 I would like the appropriate ValueError message to be displayed before
 the program shuts down, or at least a generic ValueError message.

 Is looking at my specific pieces of code necessary to help with this?

 I want this because if the program's being run as an application, the
 application window closes down as soon as the program closes, and the
 user doesn't get to see the message. [When I doubleclick on the .py
 file in Windows Explorer, it runs as a .exe, for example.]

You could try something like:

try:
   Your program
except ValueError:
   raw_input(I got a ValueError. Press enter to end the program.)
   raise

Of course, the more appropriate thing to do would be to catch the
error at a lower level than the whole program - check where you get
the ValueError, put that line in a try, and take an appropriate action
in the except.

-- 
Andre Engels, [EMAIL PROTECTED]
ICQ: 6260644  --  Skype: a_engels
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] command lines

2007-05-06 Thread Jason Coggins
Is there a way to send a command to the Linux Terminal from inside a Python 
program?

Jason___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] command lines

2007-05-06 Thread Rikard Bosnjakovic
On 5/6/07, Jason Coggins [EMAIL PROTECTED] wrote:

 Is there a way to send a command to the Linux Terminal from inside a Python
 program?

os.system(), os.popen(), etc.

-- 
- Rikard - http://bos.hack.org/cv/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] when to introduce classes

2007-05-06 Thread Kent Johnson
Rohan Deshpande wrote:
 Hi All,
 
 I am wondering when is a good time to introduce classes into a python
 program.  Is there any rule of thumb as to when they are necessary,
 and when it is okay to just stick with regular functions and
 variables?

http://personalpages.tds.net/~kent37/stories/00014.html

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running and passing variables to/from

2007-05-06 Thread emilia12
 hi john,
what about f2py - Fortran to Python interface generator

Port description for lang/f2py

Writing Python C/API wrappers for Fortran routines can be a
very tedious task,
especially if a Fortran routine takes more than 20 arguments
but only few of
them are relevant for the problems that they solve. So, I
have developed a
tool that generates the C/API modules containing wrapper
functions of Fortran
routines. I call this tool as F2PY - Fortran to Python
Interface Generator.
It is completely written in Python language and can be
called from the command
line as f2py.

WWW: http://cens.ioc.ee/projects/f2py2e/

e.

-

SCENA - Единственото БЕЗПЛАТНО списание за мобилни комуникации и технологии.
http://www.bgscena.com/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor