Hello,
I'm trying to set a default argument to be a function result.
So, in the example below I'm trying to add "index" to *myItem* but having
index default to number of items in *myListOfItems*

class myItem:
      def __init__(self, index = myListOfItems.itemCount(self)):
          self.index = index
      def __str__(self):
          return 'Index: %i' % (self.index)

class myListOfItems:
      def __init__(self, *args):
          self.items = list(args)
      def itemCount(self):
          len(self.items)
      def showAll(self):
          for item in self items:
              print item

if __name__ = '__main__':
      itemA = myItem()

      itemB = myItem()
      myListOfItems.showAll()

This wont work since myListOfItems is not defined on init, but the result
I'm after is:
'Index: 0'
'index: 1'

How can I achieve this result?

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to