จากส่วนหนึ่งของ ไลบรารี่ pymsn ครับ


class Contact(gobject.GObject):
"""Contact related information
@undocumented: gsignals, gproperties, do_get_property"""

__gsignals__ =  {
        "infos-changed": (gobject.SIGNAL_RUN_FIRST,
            gobject.TYPE_NONE,
            (object,)),
        }

__gproperties__ = {
        "memberships": (gobject.TYPE_UINT,
            "Memberships",
            "Membership relation with the contact.",
            0, 15, 0, gobject.PARAM_READABLE),

        "display-name": (gobject.TYPE_STRING,
            "Friendly name",
            "A nickname that the user chooses to display to others",
            "",
            gobject.PARAM_READWRITE),

        "personal-message": (gobject.TYPE_STRING,
            "Personal message",
            "The personal message that the user wants to display",
            "",
            gobject.PARAM_READABLE),

        "current-media": (gobject.TYPE_PYOBJECT,
            "Current media",
            "The current media that the user wants to display",
            gobject.PARAM_READABLE),

        "presence": (gobject.TYPE_STRING,
            "Presence",
            "The presence to show to others",
            Presence.OFFLINE,
            gobject.PARAM_READABLE),

         "groups": (gobject.TYPE_PYOBJECT,
             "Groups",
             "The groups the contact belongs to",
             gobject.PARAM_READABLE),

        "infos": (gobject.TYPE_PYOBJECT,
            "Informations",
            "The contact informations",
            gobject.PARAM_READABLE),

        "contact-type": (gobject.TYPE_PYOBJECT,
            "Contact type",
            "The contact automatic update status flag",
             gobject.PARAM_READABLE),

        "client-capabilities": (gobject.TYPE_UINT64,
            "Client capabilities",
            "The client capabilities of the contact 's client",
            0, 0xFFFFFFFF, 0,
            gobject.PARAM_READABLE),

        "msn-object": (gobject.TYPE_STRING,
            "MSN Object",
            "MSN Object attached to the contact, this generally represent "
            "its display picture",
            "",
            gobject.PARAM_READABLE),
        }

def __init__(self, id, network_id, account, display_name, cid=None,
        memberships=Membership.NONE, contact_type=ContactType.REGULAR):
    """Initializer"""
    gobject.GObject.__init__(self)
    self._id = id
    self._cid = cid or "00000000-0000-0000-0000-000000000000"
    self._network_id = network_id
    self._account = account

    self._display_name = display_name
    self._presence = Presence.OFFLINE
    self._personal_message = ""
    self._current_media = None
    self._groups = set()

    self._memberships = memberships
    self._contact_type = contact_type
    self._client_capabilities = ClientCapabilities()
    self._msn_object = None
    self._infos = {}
    self._attributes = {'icon_url' : None}

def __repr__(self):
    def memberships_str():
        m = []
        memberships = self._memberships
        if memberships & Membership.FORWARD:
            m.append('FORWARD')
        if memberships & Membership.ALLOW:
            m.append('ALLOW')
        if memberships & Membership.BLOCK:
            m.append('BLOCK')
        if memberships & Membership.REVERSE:
            m.append('REVERSE')
        if memberships & Membership.PENDING:
            m.append('PENDING')
        return " | ".join(m)
    template = "<pymsn.Contact id='%s' network='%u' account='%s' memberships='%s'>"
    return template % (self._id, self._network_id, self._account, memberships_str())

@property
def id(self):
    """Contact identifier in a GUID form
        @type: GUID string"""
    return self._id

@property
def attributes(self):
    """Contact attributes
        @type: {key: string => value: string}"""
    return self._attributes.copy()

@property
def cid(self):
    """Contact ID
        @type: GUID string"""
    return self._cid

@property
def network_id(self):
    """Contact network ID
        @type: L{NetworkID<pymsn.profile.NetworkID>}"""
    return self._network_id

@property
def account(self):
    """Contact account
        @type: utf-8 encoded string"""
    return self._account

@property
def presence(self):
    """Contact presence
        @type: L{Presence<pymsn.profile.Presence>}"""
    return self._presence

@property
def display_name(self):
    """Contact display name
        @type: utf-8 encoded string"""
    return self._display_name

@property
def personal_message(self):
    """Contact personal message
        @type: utf-8 encoded string"""
    return self._personal_message

@property
def current_media(self):
    """Contact current media
        @type: (artist: string, track: string)"""
    return self._current_media

@property
def groups(self):
    """Contact list of groups
        @type: set(L{Group<pymsn.profile.Group>}...)"""
    return self._groups

@property
def infos(self):
    """Contact informations
        @type: {key: string => value: string}"""
    return self._infos

@property
def memberships(self):
    """Contact membership value
        @type: bitmask of L{Membership<pymsn.profile.Membership>}s"""
    return self._memberships

@property
def contact_type(self):
    """Contact automatic update status flag
        @type: L{ContactType<pymsn.profile.ContactType>}"""
    return self._contact_type

@property
def client_capabilities(self):
    """Contact client capabilities
        @type: L{ClientCapabilities}"""
    return self._client_capabilities

@property
def msn_object(self):
    """Contact MSN Object
        @type: L{MSNObject<pymsn.p2p.MSNObject>}"""
    return self._msn_object

@property
def domain(self):
    """Contact domain, which is basically the part after @ in the account
        @type: utf-8 encoded string"""
    result = self._account.split('@', 1)
    if len(result) > 1:
        return result[1]
    else:
        return ""
        
@property
def profile_url(self):
    """Contact profile url
        @type: string"""
    account = self._account
    return "http://members.msn.com/default.msnw?mem=%s&pgmarket=" % account

### membership management
def is_member(self, memberships):
    """Determines if this contact belongs to the specified memberships
        @type memberships: bitmask of L{Membership<pymsn.profile.Membership>}s"""
    return (self.memberships & memberships) == memberships

def _set_memberships(self, memberships):
    self._memberships = memberships
    self.notify("memberships")

def _add_membership(self, membership):
    self._memberships |= membership
    self.notify("memberships")

def _remove_membership(self, membership):
    """removes the given membership from the contact

        @param membership: the membership to remove
        @type membership: int L{Membership}"""
    self._memberships ^= membership
    self.notify("memberships")

def _server_property_changed(self, name, value): #FIXME, should not be used for memberships
    if name == "client-capabilities":
        value = ClientCapabilities(client_id=value)
    attr_name = "_" + name.lower().replace("-", "_")
    old_value = getattr(self, attr_name)
    if value != old_value:
        setattr(self, attr_name, value)
        self.notify(name)

def _server_attribute_changed(self, name, value):
    self._attributes[name] = value

def _server_infos_changed(self, updated_infos):
    self._infos.update(updated_infos)
    self.emit("infos-changed", updated_infos)
    self.notify("infos")

### group management
def _add_group_ownership(self, group):
    self._groups.add(group)

def _delete_group_ownership(self, group):
    self._groups.discard(group)

def do_get_property(self, pspec):
    name = pspec.name.lower().replace("-", "_")
    return getattr(self, name)

gobject.type_register(Contact)

class Group(gobject.GObject):
"""Group
@undocumented: gsignals, gproperties, do_get_property"""

__gproperties__ = {
    "name": (gobject.TYPE_STRING,
             "Group name",
             "Name that the user chooses for the group",
             "",
             gobject.PARAM_READABLE)
    }

def __init__(self, id, name):
    """Initializer"""
    gobject.GObject.__init__(self)
    self._id = id
    self._name = name

@property
def id(self):
    """Group identifier in a GUID form
        @type: GUID string"""
    return self._id

@property
def name(self):
    """Group name
        @type: utf-8 encoded string"""
    return self._name

def _server_property_changed(self, name, value):
    attr_name = "_" + name.lower().replace("-", "_")
    old_value = getattr(self, attr_name)
    if value != old_value:
        setattr(self, attr_name, value)
        self.notify(name)

def do_get_property(self, pspec):
    name = pspec.name.lower().replace("-", "_")
    return getattr(self, name)

gobject.type_register(Group)

คำถามแรกนะครับคือ @property คืออะไรหน่ะครับ
คำถามที่สองอ่ะครับ คือผมเรียกใช้ คลาส contact เรียกใช้ contact.domain / contact.contact_tpye / contact.client_capabilities/ contact.msn_object/ เรียกใช้ได้ปกติ แต่ ทำไมผมเรียกใช้ contact.profile_url ไม่ได้ ไม่ทราบว่าผมต้องเข้าใจอะไรตรงไหนก่อนไหมครับ ขึ้น error ว่า
"print contact.profile_url
AttributeError: 'Contact' object has no attribute 'profile_url'" เจอปัญหานี่ เล่นเอา อึ้งเลยครับ

ขอบคุณครับ

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand