Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36520 > unrolled thread

Re: Class confusion

Started byMatt Jones <matt.walker.jones@gmail.com>
First post2013-01-09 15:34 -0600
Last post2013-01-09 15:34 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Class confusion Matt Jones <matt.walker.jones@gmail.com> - 2013-01-09 15:34 -0600

#36520 — Re: Class confusion

FromMatt Jones <matt.walker.jones@gmail.com>
Date2013-01-09 15:34 -0600
SubjectRe: Class confusion
Message-ID<mailman.340.1357767313.2939.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

# Something like...

class SystemList(object):
   def get_systemid(self):
      return "System Id: bleh"

   def get_running_kernel(self):
      return "Kernel: bleh"


class SatelliteConnect(object):
   def get_systemlist(self):
      return SystemList()


# Now the code you wrote would work, only return those literals thought,
you'd want to do something meaningful inside of SystemList's methods.

*Matt Jones*


On Wed, Jan 9, 2013 at 3:28 PM, MRAB <python@mrabarnett.plus.com> wrote:

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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web