0

I need help please, I have searching but none of the answers I found is working for my problem

I need to set a variable in a class method in another module

(frist.py)

class car(object)
   @staticmethod
   def reg_number(self, regno):
       self.builder.get_object("label1").set_text(regno)

   def __init__(self):
       self.data = Data()

.
.
.
.
if __name__ == "__main__":
     app = car()
     gtk.main()

(second.py)

from first import car

def set_reg_no():
    cr = car()
    cr.reg_number('CVM107')

The call to cr.reg_number('CVM107') is raising an error. I have tried car.reg_number('CVM107'), first.car.reg_number('CVM107') among a lot of other combinations but I keep getting errors

Any help will be appreciated

Thanks

Piet

pietvr
  • 1
  • 1

1 Answers1

1

You should remove the self argument in the staticmethod: Like this:

>>> class car(object):
...     @staticmethod
...     def test(str):
...             print str
... 
>>> car.test('a')
a
Oliver Hu
  • 81
  • 8