<div dir="ltr">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 class="gmail_extra"><div class="gmail_quote">
<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 class=""><font color="#888888">
</font></span></div><div class="gmail_extra"><span class=""><font color="#888888"><br clear="all"></font></span></div></blockquote><div><br></div><div style>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 class="gmail_extra"><span class=""><font color="#888888"><div>
<b>Matt Jones</b></div></font></span><div><div class="h5">
<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>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br></div></div>