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

asked Aug 14, 2013 at 2:21
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
answered Aug 16, 2013 at 21:28
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.