Python Input from keyboard

2006-09-22 Thread utab

hi,
I could not understand why python stdin and stdout are not explained in
any of the tutorials on the net,

I want to read some input continuously from keyboard and then I would
like to process these input.

I have a code like this but getting errors, I would like to terminate
when there is an empty string in the input, why is not this easy as the
"cin" or "scanf". I had to search for even this easy operation. Is
there a way to send EOF signal to terminate input(ctrl+??)

#!/usr/bin/env python
import sys, math   # load system and math module
x=[]
y=[]
IN=True
print 'input x and y values :   '
while IN:
xt,yt=input()

if (xt==' ' or yt==' '):
print 'you have not entered x or y, quiting'
break
else:
xt= float(xt);yt=float(yt)
x.append(xt);y.append(yt)

for i in range(x):
print x[i]

-- 
http://mail.python.org/mailman/listinfo/python-list


Numeric Python

2006-05-03 Thread utab
Dear all, I am new to python however not new to programming world,

I have got the Numeric package I think because the output seems OK

>>> from Numeric import *
>>>

seems OK but when I try to view a picture file which is supplied in the
install and test documentation of numpy it fails

>>>view(greece)
Traceback (most recent call last):
 File "", line 1, in ?
NameError: name 'view' is not defined

There it is written that the numpy directory must be under the demo
directory but I do not have a demo directory under the python
directory.

Sth is missing I guess but could not figure out, actually I did not
have much time to search and find the error :) , hope for your
understanding. I am seeking a step by step installation description so
your help is very much appreciated.

Regards,

U.T.

-- 
http://mail.python.org/mailman/listinfo/python-list


Python Graphics Library

2006-05-08 Thread utab
Dear all,

Could you please recommend me a graphics library for python. I saw PYX
which has nice screenshots on the webpage.

My first ambition is to be able to draw 2D or 3D graphs for my
mathematical results. Maybe later, I can handle other types of
graphical operations.

Regards.

-- 
http://mail.python.org/mailman/listinfo/python-list


change some lines from a read file

2009-05-04 Thread utab
Dear all,

I have to change some lines from a template file, which is rather long
to paste here, but I would like to make some parts of some lines
optional with my command line arguments but I could not see this
directly, I can count the line numbers and decide on this basis to
decide the lines to be configured to my will.

More specifically, say, I have a that file includes

this is an example python file to play around
.
.
.
some lines
.
.
.
. -> an option line for example.
.
.
.
-> another option line so on.

and execute the script
./myScript option1 option2

so that the options at correct locations will be written.

Any other options for this simple job that i can improve my Python a
bit as well.

Best,
Umut
--
http://mail.python.org/mailman/listinfo/python-list


Re: change some lines from a read file

2009-05-05 Thread utab
On May 4, 10:06 pm, Anthra Norell  wrote:
> utab wrote:
> > Dear all,
>
> > I have to change some lines from a template file, which is rather long
> > to paste here, but I would like to make some parts of some lines
> > optional with my command line arguments but I could not see this
> > directly, I can count the line numbers and decide on this basis to
> > decide the lines to be configured to my will.
>
> > More specifically, say, I have a that file includes
>
> > this is an example python file to play around
> > .
> > .
> > .
> > some lines
> > .
> > .
> > .
> > . -> an option line for example.
> > .
> > .
> > .
> > -> another option line so on.
>
> > and execute the script
> > ./myScript option1 option2
>
> > so that the options at correct locations will be written.
>
> > Any other options for this simple job that i can improve my Python a
> > bit as well.
>
> > Best,
> > Umut
> > --
> >http://mail.python.org/mailman/listinfo/python-list
>
> Your description is not explicit enough to convey your intention. If
> your template file is too long to post, post a short representative
> section, an input data sample and a hand-edited sample of the output
> data you want to generate. You will get more and better advice. .
>
> Frederic

Thanks here is a  sample Session file from a commercial finite element
pre-post processor PATRAN, the file longer but the ideas are the same
so that let me give an example, say I would like to make write line 10
composed of some command line arguments: path+database_name, Also
there are some lines similar to this in the below sections of the
file. I am doing it with a if-elif-else clause checking the line
numbers with which I thought of there should be a better way and ended
up asking...

 1 $# Session file patran.ses.02 started recording at 05-May-09
11:12:25
 2 $# Build: 15.0.038 Mon Aug 20 21:31:45 PDT 2007
 3 $# Recorded by: Patran 2007 r1b
 4 $# FLEXlm initialization complete.  Acquiring license(s)...
 5 $# License File: /opt/patran-2007r1b/license.dat
 6 $# Patran 2007 r1b has obtained 1 concurrent license(s) from
FLEXlm per a
 7 $# request to execute on Linux node hpc06(001e4f20c494) (Linux
 8 $# 2.6.23.15-80.fc7) at 05-May-09 11:12:25.
 9 uil_file_new.go( "/opt/patran-2007r1b/template.db",  @
10 "/home/utabak/PATRAN/cavityModels/fromGmsh.db" )
11 $# Question from application FILE
12 $# Database /home/utabak/PATRAN/cavityModels/fromGmsh.db
already exists.
13 $# Do you wish to delete the existing database and create a new
one ?
14 $? YES 3602
15 $# Copying /opt/patran-2007r1b/template.db to
16 $# /home/utabak/PATRAN/cavityModels/fromGmsh.db
17 $# Template copy complete.
18 $# Database version 3.8 created by Patran 2007 r1b successfully
opened.
19 ga_viewport_size_set( "default_viewport", 14.571214, 7.509466,
1 )
20 ga_viewport_location_set( "default_viewport", 0.00,
1.088771, 1 )
21 $# Creating journal file /home/utabak/PATRAN/cavityModels/
fromGmsh.db.jou at
22 $# 05-May-09 11:12:43
23 nastran_input_import( "/home/utabak/PATRAN/cavityModels/
toPatran.bdf",  @
24 "default_group", 10, [TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, FALSE,  @
25 TRUE], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0,
0, 0], [ @
26 -20, -20, -20, -20,
-20, -20,  @
27 -20, -20, 0, 0] )
28 $# Reading of MSC.Nastran input file completed.
29 ui_exec_function( "mesh_seed_display_mgr", "init" )

Best,
--
http://mail.python.org/mailman/listinfo/python-list