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 1015459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:24:14+00:00 2026-05-16T10:24:14+00:00

Being probably one of the worst OOP programmers on the planet, I’ve been reading

  • 0

Being probably one of the worst OOP programmers on the planet, I’ve been reading through a lot of example code to help ‘get’ what a class can be used for. Recently I found this example:

class NextClass:                            # define class
    def printer(self, text):                # define method
        self.message = text                 # change instance
        print self.message                  # access instance

x = NextClass()                             # make instance

x.printer('instance call')              # call its method

print x.message                               # instance changed

NextClass.printer(x, 'class call')      # direct class call

print x.message                               # instance changed again

It doesn’t appear there is any difference between what the direct class call does and the instance call does; but it goes against the Zen to include features like that without some use to them. So if there is a difference, what is it? Performance? Overhead reduction? Maybe readability?

  • 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-16T10:24:15+00:00Added an answer on May 16, 2026 at 10:24 am

    There is no difference. instance.method(...) is class.method(instance, ...). But this doesn’t go against the Zen, since it says (emphasis mine):

    There should be one– and preferably only one —obvious way to do it.

    The second way is possible, and everyone with good knowledge of Python should know that (and why), but it’s a nonobvious way of doing that, nobody does it in real code.

    So why is it that way? It’s just how methods work in any language – a method is some code that operates on an object/instance (and possibly more arguments). Except that usually, the instance is supplied implicitly (e.g. this in C++/Java/D) – but since the Zen says “explicit is better than implicit”, self is explicitly a parameter of every method, which inevitable allows this. Explicitly prohibiting it would be pointless.

    And apart from that, the fact that methods are not forced to (implicitly) take an instance allows class methods and static methods to be defined without special treatment of the language – the first is just a method that expects a class instead of an instance, and the latter is just a method that doesn’t expect an instance at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am being an idiot, probably, but can someone help. I want to change
I'm probably just being an idiot - it's been a long day! I've misunderstood
I'm probably being stupid, because its Friday afternoon, but I just can't work this
it's late, I'm tired, and probably being quite dense.... I have written an application
This is probably just me being stupid somehow or the other, but I am
This is probably not a rocket science question, so forgive me for being a
I'm having an odd probably with rails right now... a class is being defined
This is probably one of the things that all new users find out about
I'm probably typical in being bewildered by the many syntaxes of Wpf binding. Does
this will probably get downvoted etc for being ambiguous, but I am strapped for

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.