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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:19:18+00:00 2026-06-15T01:19:18+00:00

It seems that atomic types (int, string, …) are passed by value, and all

  • 0

It seems that atomic types (int, string, …) are passed by value, and all others (objects, pointers to functions, pointers to methods, …) are passed by reference.

What is the best way to check if a variable will be passed by value or by reference?

isinstance(input_, float) or isinstance(input_, basestring) or <...>

seems to be very inelegant.

The reason why I need it is below: I have a class that wraps wx.Button, if args/kwargs are of types that are passed by value, updating their values in other objects will not be taken into account. So some checks will be beneficial

class PalpyButton(wx.Button):        
    def __init__(self, parent, btnLabel, handler, successMsg = None, args = (), kwargs = {}):
        super(PalpyButton, self).__init__(parent, -1, btnLabel)
        self.handler = handler
        self.successMsg = successMsg
        parent.Bind(wx.EVT_BUTTON, lambda event: self.onClick(event, *args, **kwargs), self)
    def onClick(self, event, *args, **kwargs):
        try:
            self.handler(*args, **kwargs)
            if self.successMsg != None:
                if hasattr(self.successMsg, '__call__'):
                    showInfoMessageBox(self.successMsg())
                else:
                    showInfoMessageBox(self.successMsg)
        except BaseException, detail:
            showErrorMessageBox(detail)
  • 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-06-15T01:19:19+00:00Added an answer on June 15, 2026 at 1:19 am

    The question does not arise. Everything is passed in exactly the same way, regardless of type, value, operating system, phase of the moon, etc.

    Whether that style of argument passing is best described as pass by value, pass by reference, or something else, is up for debate (though note that using “pass by value/reference” requires non-standard definitions of “value”/”reference”, which is the primary reasoning for other terms such as “pass by object”). It doesn’t matter here. It’s just always the same.

    Edit: In terms of your example, the semantics of handler doesn’t change based on the argument types. Either is assigns to the variables (AKA names):

    def my_handler(x):
        x = <whatever>
    

    … but then my_handler(<anything>) does not change what object the argument refers to (and it doesn’t matter either if you pass in a local variable, an object attribute, the result of a more complex expression, or anything else). By the way, everything is an object, your artificial distinctions (“atomic”, “pointers to functions”) make no sense.

    Alternatively, the function (tries to) change the value of the objects (e.g. add/remove items to a collection, change an object attribute, call a method that changes some state that can be observed indirectly). That may raise exceptions if the object does not support that (e.g. call a method that does not exist), but that happens for any access, not just for mutation. If the object’s value is indeed changed, this is always visible through every reference to that object. As new references to existing objects are created in a number of cases (such as argument passing, variable assignment, attribute assignment, etc.) you can observe that objects are not copied by changing their value in one place and observing the change in another place. This is true for all objects (again, provided you can change the object’s value).

    Now, some objects are immutable, which (by definition) means you can’t change their value, and hence can’t observe the object “sharing” in this way (you can observe it in other ways though). That doesn’t mean assignment has different semantics depending on mutability (it doesn’t), it just means you can do things with mutable objects which you can’t do with immutable objects. The operations you can perform on both work the same for both.

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

Sidebar

Related Questions

Are java primitive integers (int) atomic at all, for that matter? Some experimentation with
Seems that This will be an easy question for you but this problem is
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that we can show layers and even use a different zPosition for
It seems that runClasses() doesn't terminate the code being tested even after the test
It seems that JavaScript's Date() function can only return local date and time. Is
It seems that often I find that my code when moving either from one
It seems that it is not advisable to use <meta http-equiv=REFRESH CONTENT=3;url=url> for redirects
It seems that there is a implementation of rope in my /usr/include/c++/4.5.1/ext/rope (and ropeimpl.h
It seems that css animations on firefox are pixelating the edges of elements: Here

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.