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


Groups > comp.lang.python > #36520

Re: Class confusion

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <matt.walker.jones@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'api.': 0.04; 'mrab': 0.05; 'attributes': 0.07; 'python': 0.09; 'meaningful': 0.09; 'def': 0.10; '"system': 0.16; 'literals': 0.16; '\xa0def': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'jan': 0.18; 'work,': 0.22; 'this:': 0.23; 'id:': 0.24; 'header:In-Reply-To:1': 0.25; 'wrote': 0.26; 'extend': 0.26; 'i.e.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'interface': 0.27; 'this?': 0.28; 'methods.': 0.29; 'url:mailman': 0.29; '8bit%:5': 0.29; 'skip:& 10': 0.29; 'class': 0.29; "i'm": 0.29; 'code': 0.31; 'url:python': 0.32; 'url:listinfo': 0.32; 'skip:s 30': 0.33; 'to:addr:python- list': 0.33; 'skip:& 20': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'test': 0.36; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'url:mail': 0.40; 'brown': 0.65; 'satellite': 0.65; '2013': 0.84; 'subject:Class': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=4vRxzwiCRUR4LP1tRw/XJhj5Lg/yrBrEzj7swg0QwlA=; b=l8SuPs5NUMQbRlWwpr+Jtd6gIAp+tK5PSt5ol9uL8lIAM/vl0mMQDbHCKMJkmNmsj2 ubkBEB4ETTOiyxreDJ67lxNh4TIqg1bsCYgciM57m4wjifNgaUusuhDaVHb513TvyLIR EeZj/buLFZnQG+1SI3G2pw6pGK6l1kpt+eDdeSMSXQ+zXKKjJtPt3xznFGKUQQ/ZejWH m4fy6M7NHSgPGF1oWIE6VEJ8Qt8lU74sUFqHXk1nR5KWih1UqgGbcQCBVWWkCQC5NCrB lr/kRwYhxENx3thLj6Mg9+a13JZjzbc1e/NE6Zdi7XqwR2MN8X3hKe0i7lSAPFSKwuZM iViQ==
MIME-Version 1.0
In-Reply-To <50EDE103.6080609@mrabarnett.plus.com>
References <CABRP1o9HuUR3e5S5wj8FvNgqAW6jnqb7iBJ0yo9J+H1fNWfAxQ@mail.gmail.com> <50EDE103.6080609@mrabarnett.plus.com>
From Matt Jones <matt.walker.jones@gmail.com>
Date Wed, 9 Jan 2013 15:34:44 -0600
Subject Re: Class confusion
To python-list@python.org
Content-Type multipart/alternative; boundary=e89a8f8396e3e0d9b704d2e1d5ab
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.340.1357767313.2939.python-list@python.org> (permalink)
Lines 154
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1357767313 news.xs4all.nl 6933 [2001:888:2000:d::a6]:46242
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36520

Show key headers only | View raw


[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>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web