Simple python-abaqus question
Simple python-abaqus question
(OP)
I am learning Python... while going through a simple example in the Doc
I have copied the statements below into a file called distance.py in my local directory C.
Then (as instructed in the ABAQUS Doc) I typied the following at the system prompt:
abaqus python distance.py 30 40
but the ABAQUS\6.5.1\cae\python.exe: can't open file'distance'
can anybody tell me why. in addition what are '30 40' for in the statement abaqus python distance.py 30 40
import sys, math
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def distance(x, y):
"""
Prints distance from origin to (x, y).
Takes two command line arguments, x and y.
"""
# Square the arguments and add them.
a = x**2 + y**2
# Return the square root.
return math.sqrt(a)
# Retrieve the command line arguments and
# convert the strings to floating-point numbers.
x = float(sys.argv[1])
y = float(sys.argv[2])
# Call the distance function.
d = distance(x, y)
# Print the result.
print 'Distance to origin = ', d
I have copied the statements below into a file called distance.py in my local directory C.
Then (as instructed in the ABAQUS Doc) I typied the following at the system prompt:
abaqus python distance.py 30 40
but the ABAQUS\6.5.1\cae\python.exe: can't open file'distance'
can anybody tell me why. in addition what are '30 40' for in the statement abaqus python distance.py 30 40
import sys, math
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def distance(x, y):
"""
Prints distance from origin to (x, y).
Takes two command line arguments, x and y.
"""
# Square the arguments and add them.
a = x**2 + y**2
# Return the square root.
return math.sqrt(a)
# Retrieve the command line arguments and
# convert the strings to floating-point numbers.
x = float(sys.argv[1])
y = float(sys.argv[2])
# Call the distance function.
d = distance(x, y)
# Print the result.
print 'Distance to origin = ', d





RE: Simple python-abaqus question
2. If you look at the commands in your script:
x = float(sys.argv[1])
y = float(sys.argv[2])
you'll understand what the "30 40" mean. They are "arguments". Python processes arguments just like other programming languages (C, C++, perl etc etc)
Finally, you should check out a good genreal python programming guide such as Practical Python. You'll get a lot of good background understanding such as this...
RE: Simple python-abaqus question
I am just curious, do you find this forum helpful in anyway ?
RE: Simple python-abaqus question
RE: Simple python-abaqus question
Thank you for your replies
It is definitely helpful forum regardless of coming across some curious and arrogant replies sometimes.