Back to SDS/2 Parametric Scripts

 

# ['Property_name', ['Property_type', ['name', 'value']['path', 'c:\some\path']]]

'''

>   prop1 = ['name', 'value']

>   prop2 = ['path', 'c:\some\path']

>   prop3 = [prop1, prop2]

>   prop4 = ['Property', prop3]

'''

 

class Property(object):

    def __init__(self, name, value, path):

        self.name = name

        self.value = value

        self.path = path

        self.prop1 = [self.name, self.value]

        self.prop2 = "['path', '%s']" % (self.path)

        self.prop3 = "[%s, ['path', '%s']]" % ([self.name, self.value], self.path)

        self.prop4 = "['Property', [%s, ['path', '%s']]]" % ([self.name, self.value], self.path)

       

    def __str__(self):

        return "['%s', %s, '%s']" % (self.name, self.value, self.path)

 

    def __repr__(self):

        return "Property('%s', %d, '%s')" % (self.name, self.value, self.path)

 

    def print1(self):

        print self.prop1

       

    def print2(self):

        print self.prop2

 

    def print3(self):

        print self.prop3

 

    def print4(self):

        print self.prop4

 

a = Property('Farm', 120000, 'C:\some\path')

print a

a.print1()

a.print2()

a.print3()

a.print4()

 

'''

>>> [Farm, 120000, C:\some\path]

[Farm, 120000]

[path, C:\some\path]

[[Farm, 120000], [path, C:\some\path]]

[Property[[Farm, 120000], [path, C:\some\path]]]

>>> print a.prop4

['Property', [['Farm', 120000], ['path', 'C:\some\path']]]

>>> repr(a)

"Property('Farm', 120000, 'C:\\some\\path')"

>>> print repr(a)

Property('Farm', 120000, 'C:\some\path')

'''