Python code uses the indentation to denote code blocks, and a tab 
character is not the same as 4 spaces (even though when you view the file 
in an editor they may appear equivalent).

The recommendation is to always use spaces in your STAX jobs.  Most 
text/xml editors have settings to allow you to use soft tabs (so when you 
press the Tab key it will emulate with spaces).

Here is a link with some useful information about Python indentation:

http://www.secnetix.de/olli/Python/block_indentation.hawk
 
Thanks, 
David 

David Bender 
STAF/STAX Development 
IBM Software Group, WPLC 
 
11501 Burnet Rd. 
Bldg. 903-5B002 
Austin, TX 78758-3400 
 
Phone (T/L): 1-512-286-5315 (363-5315) 
ITN: 23635315 
Email: bda...@us.ibm.com 
 





Sangram Bakshi <san...@gmail.com> 
08/18/2009 07:24 AM

To
staf-users@lists.sourceforge.net
cc

Subject
Re: [staf-users] Staf Stax Python Code Indentation






 
Hi ,
 
I observe the code compiles with four spaces after a "if" or "for "  , but 
it fails to compile if by mistake we give a "tab"(equivalent to four 
spaces). I am able to work fine , my code compiles fine.
 
 
Do suggest any other tips for indentation.
 
 
Regards

On Tue, Aug 18, 2009 at 5:12 PM, Sangram Bakshi <san...@gmail.com> wrote:
Hi ,
 
I was coding python in staf stax job.  I follow  basic python indentation.
 
 
For e.g:
 
  nodeList = document.getElementsByTagName("machine_name")
  x = nodeList.getLength()
  if nodeList.getLength():
      nodeList = document.getElementsByTagName("machine_name")
      for i in range(nodeList.getLength()):
          node = nodeList.item(i)
 
I give four spaces after a if or for .
 
The code compiles sometimes , it does'nt compiles sometimes if i disturb 
it it a little bit and gain maintain the space indentation.
 
Any simple rule to follow while coding to keep proper indentation.
 
I feel the env is very sensitive.
 
 
For e.g:
 
<script>
     machname = []
     vmware_value = []
     vmware_attr = []
     sangram = 'None'
        
     nodeList = document.getElementsByTagName("machine_name")
     x = nodeList.getLength()
     if nodeList.getLength():
         nodeList = document.getElementsByTagName("machine_name")
         for i in range(nodeList.getLength()):
             node = nodeList.item(i)
             if node.getNodeType() == Node.ELEMENT_NODE:
                 children = node.getChildNodes()
                 for j in range(children.getLength()):
                     thisChild = children.item(j)
                     if (thisChild.getNodeType() == Node.TEXT_NODE):
                         machname.append( thisChild.getNodeValue())
        
Till yellow highlighted it compiles fine : after that the following does 
not compiles.
   
     nodeList = document.getElementsByTagName("vmware")
     if nodeList.getLength():
         nodeList = document.getElementsByTagName("vmware") 
  #for i in range(nodeList.getLength()):
      #node = nodeList.item(i)
         #  id = ""
          # attrList = node.getAttributes()
           #for k in range(attrList.getLength()):
         #   thisAttr = attrList.item(k)
          #  if thisAttr.getNodeName() == "id":
        #     id = thisAttr.getNodeValue()
         #    vmware_attr.append(id)
          #if node.getNodeType() == Node.ELEMENT_NODE:
          # children = node.getChildNodes()
           #for j in range(children.getLength()):
          #  thisChild = children.item(j)
           # if (thisChild.getNodeType() == Node.TEXT_NODE): 
         #    vmware_value.append(thisChild.getNodeValue())
    
  </script>
 
Kinldy suggest a easy technique to follow indentation. 
 
 
Regards
Sangram
 
 
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 
30-Day 
trial. Simplify your report design, integration and deployment - and focus 
on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to