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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:23:56+00:00 2026-05-11T22:23:56+00:00

How do I put off attribute access in Python? Let’s assume we have: def

  • 0

How do I put off attribute access in Python?

Let’s assume we have:

    def foo():
        ...

    class Bar:
        ...

    bar = Bar()

Is it possible to implement Bar so that any time bar is accessed, a value returned by the callback foo() would be provided?

bar name already exists in the context. That’s why it’s access semantics should be preserved (it cannot be a callable, turning bar into a property of a class, using SomeClass.bar instead of bar also won’t work). I need to keep everything as-is, but change the program so that bar would refer to on-the-fly generated data by foo().

UPD: Thanks all for your answers, from which it seems impossible to do this type of thing in Python. I’m gonna find a workaround.

  • 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-11T22:23:56+00:00Added an answer on May 11, 2026 at 10:23 pm

    Thanks for the clarification!

    This just can’t work! A variable is a variable in most languages, not a function-call. You can do much in Python, but you just can’t do that.

    The reason is, that you have always some intrinsic language rules. One rule in Python is, that variables are variables. When you read a variable (not modifying it or anything else) you can rely, that it will be the same in the next code-line.

    Monkeypatching it to be a function call would just change this rule.

    What you want, could only be done by a still more dynamic language. Something like a macro-processing system or a language that do not have variables but something like labels that can be attached to anything. But this would also make compiler-creation for it much more difficult — hence fully dynamic. The compiler would have to take all coding in the program into account.

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

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is a SupportPac that installs a program called "saveqmgr.exe".… May 12, 2026 at 12:23 am
  • Editorial Team
    Editorial Team added an answer Supposing you maintain a foreign key constraint between TABLE1 and… May 12, 2026 at 12:23 am
  • Editorial Team
    Editorial Team added an answer AFIK there is no standard way of doing this. Replication… May 12, 2026 at 12:23 am

Related Questions

How do I put off attribute access in Python? Let's assume we have: def
I have been making a few apps here and there, and I know my
How do I go about the [HandleError] filter in asp.net MVC Preview 5? I
Following on from my recent question on Large, Complex Objects as a Web Service
Do you know how can I make splint ignore where I declare my variables?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.