Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6930663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:28:36+00:00 2026-05-27T11:28:36+00:00

I am using some open SNS webiste’s API, the python version is a binding

  • 0

I am using some open SNS webiste’s API, the python version is a binding to its JSON version, but I really can’t understand below, why do things like this?

def mentions(self):
    comments = self.api.mentions()
    for comment in comments:
        self.obj = comment
        mid = self.getAtt("id")
        text = self.getAtt("text")
        print "mentions---"+ str(mid) +":"+ text

Why not access comment’s own attribute but assign to self.obj?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:28:36+00:00Added an answer on May 27, 2026 at 11:28 am

    Perhaps comment isn’t amenable to direct attribute access. If so…

    It looks like the API was designed by a Java programmer. A more Pythonic solution — assuming you can’t access the attributes of comment directly — would be to rename the getAtt method to __getattr__ and write, e.g., mid = self.id.

    But even then the idea of assigning each comment to self.obj in turn seems perverse. Some wrapper around comment would probably be better:

    c = attrgetter(comment)
    mid = c.id
    ⋮
    

    In fact, this would be sufficiently concise that you would even bother with local variables:

    c = attrgetter(comment)
    print "mentions---"+ str(c.mid) +":"+ c.text
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using org.w3c XML API to open an existing XML file. I'm removing some
Is there some open source project I can refer to? I'm using PHP. Anyone
I am looking for layer 2 traffic generator [open source]. Some OSS using winpcap
We are using Entity Framework 1.0. In some cases we need to explicitly open
I'd like to cross-compile some open-source libraries (libiconv, gettext, glib2) for windows using mingw
I am using SourceForge for some Open Source projects and I want to automate
I have a WebView that I'm using to open some files stored in the
How do I programmatically open the View Source window (using some Javascript) like when
I'd like to open single-file unix mailbox using some free java library. I want
I am using some python to do some variable name generation. For some reason

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.