redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers

Ask your IT question here

old style class


Goto page 1, 2  Next
 
Post new topic   Reply to topic    Programming Forums -> Python programming forum
View previous topic :: View next topic  
Author Message
Lusis Backwood JR
Enthusiastic Coder


Joined: 26 May 2006
Posts: 87
Location: United States
Hm, is there some way (hackish or otherwise) that i can build an old-style class from a new-style class that either inherits or somehow "gets" all of the functionality of the new-style class?

Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Lusis Backwood JR, why would you want to?
you can inherit from the new-style class, but you'll just get a new new-style class; you can't get an old-style class by inheriting from a new-style class.

Reply with quote
 
Lusis Backwood JR
Enthusiastic Coder


Joined: 26 May 2006
Posts: 87
Location: United States
Right i know that
Mupolan, because i'm working with an existing system that requires old-style classes and fixing it isn't an option Sad

Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Rock, sounds like an immensely stupid existing system. the only thing you could do is write an old-style proxy class, but it's probably very fragile.
(because the new-style class may actually rely on the differences in semantics that new-style classes bring, so a proxy can't always act the same way.)

Reply with quote
 
Lusis Backwood JR
Enthusiastic Coder


Joined: 26 May 2006
Posts: 87
Location: United States
hm... right ... actually i have complete control over the new-style class so i could ensure it would work via proxy
Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Lusis Backwood JR, might as well make it an old-style class, then :)
Reply with quote
 
Lusis Backwood JR
Enthusiastic Coder


Joined: 26 May 2006
Posts: 87
Location: United States
well, i don't have *that* much control Wink
Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Lusis Backwood JR, that's what I mean. if you don't have that much control, you may not have enough control to make sure it works right. But you can try ;)
Reply with quote
 
Lusis Backwood JR
Enthusiastic Coder


Joined: 26 May 2006
Posts: 87
Location: United States
So by proxy how would you do that? simply have my new old-style class have some_method = NewStyleClass.some_method ?
Reply with quote
 
Mupolan
Enthusiastic Coder


Joined: 30 May 2006
Posts: 101
Lusis Backwood JR, no. it would be 'def some_method(self, *args, **kwargs): return self._realobj.some_method(*args, **kwargs)'
Possibly through __getattr__ hacks.

Reply with quote
 
Page 1 of 2 Goto page 1, 2  Next
Post new topic   Reply to topic    Programming Forums -> Python programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group