×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Simple python-abaqus question

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

RE: Simple python-abaqus question

1. You should run the command in the same directory as you saved the "distance.py" file.

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

helppoorpeople,
I am just curious, do you find this forum helpful in anyway ?

RE: Simple python-abaqus question

I hope so... he's been getting a lot of help lately!

RE: Simple python-abaqus question

(OP)
xerf and breg
Thank you for your replies
It is definitely helpful forum regardless of coming across some curious and arrogant replies sometimes.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources