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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:12:42+00:00 2026-06-11T05:12:42+00:00

I can make a synthetic class cls1 that inherits from cls . >>> class

  • 0

I can make a synthetic class cls1 that inherits from cls.

>>> class cls(object):
...     def func(self,arg):
...         print 'func',arg
>>> def func1(self):
...     print "func 1 of cls1"
>>> def func2(self):
...     print "func2 of cls1"
>>> d=dict(func1=func1,func2=func2)
>>> cls1=type('cls1',(cls,),d)

Everything works as expected:

>>> obj=cls1()
>>> obj.func(7)
func 7

I can also replace cls1 with FOO:

>>> cls1=type('FOO',(cls,),d)

that gives me:

'cls1': <class '__main__.FOO'>,

Does this (changing __name__ variable) alter the behavior of cls1 and how (everything still works fine)?

  • 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-11T05:12:44+00:00Added an answer on June 11, 2026 at 5:12 am

    You’re just changing the name of your class, so it should matter only if you rely on the name somehow:

    >>> type(obj)
    __main__.FOO
    >>> isintance(obj, cls1)
    True
    

    That works fine, but what about pickling (that I think rely on the name) ?

    For example, before the name change, you can pickle obj without any problem. You can’t afterwards.

    PicklingError: Can't pickle <class '__main__.FOO'>: it's not found as __main__.FOO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can make a link within a facebox window that redirects it to another
I can make a variable's name from two variables' value: $a = 'tea'; $b
I can make a log in for easily, so that's not the problem. What
I can make an std::ostream object output integer numbers in hex, for example std::cout
Can someone tell me how I can make an IBAction that opens the current
I can make a sequence of numbers like this: s = seq(from=1, to=10, by=1)
We can make class Foo <T> , why can't I call new T() ?
How can I make that a site automagically show a nice Currently Offline page
I can make this code work without an object as input parameter for the
I can make infinite calling by returning $this in class body functions after creating

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.