<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 style><font color="#000000"><font face="courier new,monospace">class SystemList(object):</font></font></div>

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

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

<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 style><font color="#000000"><font face="courier new,monospace">class SatelliteConnect(object):</font></font></div><div style><font color="#000000"><font face="courier new,monospace">   def get_systemlist(self):</font></font></div>

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

</font></font></div><div style><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>

</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 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On 2013-01-09 20:13, Rodrick Brown wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc 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 class="HOEnZb"><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>