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

  • Home
  • SEARCH
  • 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 6848759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:54:30+00:00 2026-05-27T00:54:30+00:00

I apologize if this was asked somewhere else, but I do not know how

  • 0

I apologize if this was asked somewhere else, but I do not know how else to formulate this question.

I am a physicist and Python is my first object-oriented language. I love this language for its clean code, and somehow everything works as intended (by me ;).

However I have one problem, maybe it is more of a design choice, but since my object oriented programming is self-taught and very basic I am not sure which way to go.

So the question is: should I mainly pass arguments or manipulate the object data directly? Because, for instance:

class test(object):

    ...

    def dosomething(self, x, y):
        # do someting with x, y involving a lot of mathematic manipulations

    def calcit(self):
        k = self.dosomething(self.x[i], self.y[i])
        # do something else with k

produces much cleaner code than not passing x, y but passing i and writing the self explicitly every time. What do you prefer, or is this an object oriented paradigm that I am breaking?

Performance-wise this shouldn’t make a difference since the arguments are passed by reference, right?

  • 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-27T00:54:30+00:00Added an answer on May 27, 2026 at 12:54 am

    Object paradigm is that :
    you pack up methods and attributes together and call them an object.

    So, if you manipulate precisely one of those attributes you don’t need to pass them as parameters, you SHOULD use the object’s ones. If you use anything else then you got to pass it as parameters.

    And nothing prevents you from getting the values of your object into another variable if it bothers you to write self every time !

    To finish, your function that takes x and y as parameters should not be in your object but outside of it as an helper function if you really wanna do something like that, the reason being that there is no reason to pass your object as first parameter (even if it’s implicit) if you do not use it.

    and yeah performance wise it should be pretty similar !

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

Sidebar

Related Questions

I apologize if this question was asked already before but I could not find
Hopefully no one has asked this question - didn't see it, but I apologize
First off, let me apologize if this has been asked already, but I can’t
I know that this question has been asked loads of times, but I have
First off, I apologize if this question has been asked before. I've done a
I apologize if this has been asked before. I searched but did not find
First of all I apologize in advance for this question, a bit off the
This is a really weird question and I apologize: I've been asked if it's
I'm a python newbie so I apologize in advance if this question has been
Ok, first off, I applogize if this question has been asked before, I've spent

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.