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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:50:06+00:00 2026-06-02T11:50:06+00:00

is it possible in python to address class variables from other class variables within

  • 0

is it possible in python to address class variables from other class variables within the same class?

My problem is: I am trying to prepare some static code, that would look like this:

class MyBaseObject:
  SIGNAL_NAME_1 = "signal-name-1"
  SIGNAL_NAME_2 = "signal-name-2"

  ALL_SIGNALS = {
    SIGNAL_NAME_1: ( signal-definition ),
    SIGNAL_NAME_2: ( signal-definition ) }

My problem with the above is that, according to python SIGNAL_NAME_1 and _2 are not defined while creating dict. Accessing them by MyBaseObject.SIGNAL_NAME_1 also does not work (unknown object).

So question is – is it possible to have class variables referring to one another in python?

Thank you!

  • 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-02T11:50:07+00:00Added an answer on June 2, 2026 at 11:50 am

    No, there shouldn’t be any problem referring to other class variables just using there names. You cannot however refer to MyBaseObject as that isn’t defined until the class definition completes.

    The code you posted will work just fine (if signal and definition are defined), so if you are getting complaints about names not being defined that means you didn’t post the exact code you used. Try posting the exact code and the exact and complete error message.

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

Sidebar

Related Questions

Possible Duplicate: Python code to pick out all possible combinations from a list? I
Possible Duplicate: Python list append behavior Why does this code: x = [[]]*3 x[0].append('a')
Possible Duplicate: Calling Python from Objective-C I'm a long-time Python programmer and short-time Cocoa
The problem I see with this code is that although it is working, some
Is it possible to convert time retrieved from NTP server (with python script) in
Possible Duplicate: Python dictionary: are keys() and values() always the same order? If i
Possible Duplicate: How to send an e-mail from a Python script that is being
Is it possible to find the zip code based on a users IP address
Is it, in Python, possible to address a specific character in a string by
I'm considering integrating some C code into a Python system (Django), and I was

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.