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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:29:59+00:00 2026-05-27T03:29:59+00:00

I have this python code which set A or B in a class. I

  • 0

I have this python code which set A or B in a class. I want to print what this class receives:

if options.A:
   print "setting A"
   class TmpClass(A): pass
else:
   print "nothing set in the command line => setting to B"
   class TmpClass(B): pass

print "selected=",TmpClass

I want to see either A or B in the output but I see:

selected= TmpClass
  • 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-27T03:30:00+00:00Added an answer on May 27, 2026 at 3:30 am

    What your code is doing, translated in English is:

    if option.A has a value that evaluates to True:
        define an empty class called "TmpClass" that inherits from the object called "A"
    otherwise:
        define an empty class called "TmpClass" that inherits from the object called "B"
    

    Now, if what the code is actually doing is indeed what you intended, my guess is that what you wanted could be to know whether your class is A or B -based… If I am right, then the line you want to have at the end is:

    print('TmpClass inherits from : %s' % TmpClass.__bases__)
    

    HTH!

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

Sidebar

Related Questions

I have this code in Python inputted = input(Enter in something: ) print(Input is
I'm a newbie to python and the app engine. I have this code that
I have a python script the runs this code: strpath = sudo svnadmin create
I have a python ndarray temp in some code I'm reading that suffers this:
I know python functions are virtual by default. Let's say I have this: class
In a Python system for which I develop, we usually have this module structure.
I have the following Python (3.2) code: from pygame import * class Application: def
I have a fairly long list in python which I want to return parts
I want to encode strings as Python do. Python code is this: def EncodeToUTF(inputstr):
I am learning python and have this error . I can figure out where\what

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.