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

2
  • Post the full traceback in the question body. Commented Aug 14, 2013 at 2:39
  • There is no self in a staticmethod. Please remove the the @staticmethod if you expect to get an instance passed. Commented Aug 14, 2013 at 2:48

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.