<div dir="ltr"><font color="#000000"><font face="courier new,monospace">Does this look sufficient for what?  You haven't actually told us what it is you're trying to accomplish.  I gave you the "how", you must supply the "why".</font></font></div>

<div class="gmail_extra"><br clear="all"><div><b>Matt Jones</b></div>
<br><br><div class="gmail_quote">On Wed, Jan 9, 2013 at 6:43 PM, Rodrick Brown <span dir="ltr"><<a href="mailto:rodrick.brown@gmail.com" target="_blank">rodrick.brown@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">Can anyone care to advise on the following? Based on the responses does this look sufficient?<div><br></div><div><div>#!/opt/local/bin/python</div><div><br></div><div>class SystemList(object):</div><div>    sysmap = { '1039' : 'nebula',</div>



<div>               '1040' : 'mercury'}</div><div><br></div><div>    def __init__(self, sysid):</div><div>        self.sysid = sysid</div><div><br></div><div>    def get_sysname(self):</div><div>        return self.sysmap[self.sysid]</div>



<div><br></div><div>class System(object):</div><div>    def __init__(self):</div><div>        pass</div><div><br></div><div>    def get_hostname(self,sysid):</div><div>        return  SystemList(sysid)</div><div><br></div>



<div>if __name__ == '__main__':</div><div>    sc = System()</div><div><br></div><div>    for sysid in ('1039','1040'):</div><div>        print(sc.get_hostname(sysid).get_sysname())</div><div><br></div>



</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 9, 2013 at 5:18 PM, Rodrick Brown <span dir="ltr"><<a href="mailto:rodrick.brown@gmail.com" target="_blank">rodrick.brown@gmail.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>On Wed, Jan 9, 2013 at 4:34 PM, Matt Jones <span dir="ltr"><<a href="mailto:matt.walker.jones@gmail.com" target="_blank">matt.walker.jones@gmail.com</a>></span> wrote:<br>



</div><div class="gmail_extra"><div class="gmail_quote"><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"><div dir="ltr"><font color="#000000"><font face="courier new,monospace"># Something like...</font></font><div>




<font color="#000000"><font face="courier new,monospace"><br></font></font></div><div><font color="#000000"><font face="courier new,monospace">class SystemList(object):</font></font></div>

<div><font color="#000000"><font face="courier new,monospace">   def get_systemid(self):</font></font></div><div><font color="#000000"><font face="courier new,monospace">      return "System Id: bleh"</font></font></div>






<div><font color="#000000"><font face="courier new,monospace"><br></font></font></div><div><font color="#000000"><font face="courier new,monospace">   def get_running_kernel(self):</font></font></div><div>

<font color="#000000"><font face="courier new,monospace">      return "Kernel: bleh"</font></font></div><div><font color="#000000"><font face="courier new,monospace"><br></font></font></div><div><font color="#000000"><font face="courier new,monospace"><br>






</font></font></div><div><font color="#000000"><font face="courier new,monospace">class SatelliteConnect(object):</font></font></div><div><font color="#000000"><font face="courier new,monospace">   def get_systemlist(self):</font></font></div>






<div><font color="#000000"><font face="courier new,monospace">      return SystemList()</font></font></div><div><font color="#000000"><font face="courier new,monospace"><br></font></font></div><div><font color="#000000"><font face="courier new,monospace"><br>






</font></font></div><div><font color="#000000"><font face="courier new,monospace"># Now the code you wrote would work, only return those literals thought, you'd want to do something meaningful inside of SystemList's methods.</font></font></div>




<span><font color="#888888">

</font></span></div><div class="gmail_extra"><span><font color="#888888"><br clear="all"></font></span></div></blockquote><div><br></div></div><div>Thanks for the tip Matt, I had no idea it was so simple. :-) </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"><div><div><div class="gmail_extra">

<span><font color="#888888"><div>
<b>Matt Jones</b></div></font></span><div><div>
<br><br><div class="gmail_quote">On Wed, Jan 9, 2013 at 3:28 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.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">






<div>On 2013-01-09 20:13, Rodrick Brown 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">
How can I make a class that has methods with attributes and other<br>
functions?<br>
I see a lot of code<br>
<br>
<br>
I'm reading the documentation to Redhat's Satellite software which has a<br>
XMLRPC interface and wrote the following code to test the api.<br>
<br>
I would like to extend this code to support methods with methods? I see<br>
this done a lot in python code but I'm not sure how to accomplish<br>
something like this?<br>
<br>
i.e.<br>
<br>
sc = SatelliteConnect()<br>
sc.get_systemlist().get_<u></u>systemid() ?<br>
or<br>
sc.get_systemlist().get_<u></u>running_kernel()<br>
<br>
How does one chain methods and attributes like this with classes?<br>
<br>
</blockquote></div>
[snip]<br>
This:<br>
<br>
    sc.get_systemlist().get_<u></u>systemid()<br>
<br>
simply means that the method "get_systemlist" returns an instance of<br>
some class (let's call it "SystemList") which has a method<br>
"get_systemid".<span><font color="#888888"><br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div></div></div>
<br></div></div><span><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></font></span></blockquote></div><br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>