Kent Johnson wrote:
On Sun, Jun 22, 2008 at 3:50 PM, Zameer Manji <[EMAIL PROTECTED]> wrote:

I'm quite new to OOP, so forgive me if I am missing something obvious.
When you say that the User class should have a UserProfile as an
attribute, would it look something like this?

from lastfmapi import UserProfile
class User (object):
       def __init__:
               self.UserProfile = UserProfile('Bob')

Yes, that's about right. Of course 'Bob' should be an argument passed
to __init__()

Also what do you mean by 'accessors' for Neighbors ?

class User(object):
  ...
  def getNeighbors():
    """ Returns a list of this user's neighbors """

and similar for getTopArtists(), etc.


A couple of caveats though.
Don't forget "self", it should be :

class User (object):
    def __init__(self):
        self.UserProfile = UserProfile('Bob')


Passing 'Bob' to __init__ would be :

class User (object):
    def __init__(self, User='Bob'):
        self.UserProfile = UserProfile(User)

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to