<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 18, 2014 at 10:00 AM, Beppe <span dir="ltr"><<a href="mailto:giuseppecostanzi@gmail.com" target="_blank">giuseppecostanzi@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">hi to everybody,<br>
in the following scrip I try to call the function read_parameters () but returns me that wants two arguments!?!?!<br>
My intent is to have in the class, Engine (), some static attributes that can be used by  other instances without to redefine this every time.<br>
These matters could be for example a path or a connection to a database.<br>
suggestions?<br>
<br>
regards<br>
beppe<br>
<br>
class Master(object):<br>
    def __init__(self,):<br>
        pass<br>
<br>
class Engine(Master):<br>
    dict_parameters = {}<br>
    def __init__(self,):<br>
        super(Engine, self).__init__()<br>
<br>
    @staticmethod<br>
    def read_parameters(self,path):<br>
<br>
        self.dict_parameters = {1:"a",2:"b"}<br></blockquote><div><br></div><div>What you probably want here, based on your description is (untested):</div><div>@classmethod</div><div>def read_parameters(cls, path): # Note, the name is "cls". This is not required, but is convention, similar to "self".<br>

    cls.dict_parameters = {1:"a",2:"b"}</div><div><br></div><div>@staticmethod creates a method that does not receive any special parameter, so the signature would be "def read_parameters(path)".<br>

</div><div><br></div><div>Note that, personally, I would name the method "parse_parameters" to make it clearer what it does.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<br>
    def check_parameters(self):<br>
        self.read_parameters("hello_world")</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<br>
<br>
foo=Engine()<br>
foo.check_parameters()<br>
<br>
p.s.<br>
I'm on Debian 6<br></blockquote><div> </div></div></div></div>