0

I receive an indentation error that I cannot figure out the reason.
The error is

('unexpected indent', ('C:/Hamid/Failure_index.py',15,1,'\tSDV2=xyList[0]\n')). 

My code is

from abaqusConstants import *
from odbAccess import *
from visualization import *

#---------------------------------------------------------------------------
out_file= 'C:\Hamid\Stochastic\Python_script_for_Monte_Carlo_simulation\Microtensile/Failure_index.dat'
fid = open(out_file,'w')
for i in range(1,50):
    odb_path = 'C:\Hamid\Stochastic\Python_script_for_Monte_Carlo_simulation\Microtensile/Microtens-'+str(i)+'_xs.odb'
    session.openOdb(name=odb_path)
    odb = session.odbs[odb_path]
    session.viewports['Viewport: 1'].setValues(displayedObject=odb)
    xyList = session.xyDataListFromField(odb=odb, outputPosition=INTEGRATION_POINT, variable=(('SDV2', INTEGRATION_POINT), ), elementSets=(' ALL ELEMENTS', ))
    SDV2 = xyList[0]
    fid.write(SDV2+'\n')
    odb.close()

fid.close()
Limon Monte
  • 52,539
  • 45
  • 182
  • 213

1 Answers1

1

You are mixing tabs and spaces in your source code, and Python's algorithm for expanding tabs to spaces causes SDV2 = xyList[0] to be indented 8 spaces, not 4 like the other lines in the for loop.

chepner
  • 497,756
  • 71
  • 530
  • 681
  • Thank you very much, it worked. I am new to Python, therefore, my questions might be primitive. I really appreciate your time. – Hamid Reza Oct 28 '14 at 19:39