Page 1 of 1

Inherit from a C++ exposed class?

Posted: Fri Aug 24, 2012 12:28 am
by BackRaw
Hi guys,

Is there a way to inherit from a C++ exposed class in Python? Take this for example

Syntax: Select all

from Source import Player

class _Player(Player.IPlayerInfo): # or something else, I can't get an overview of the C++ sources somehow..
def __init__(self, player_edict):
Player.IPlayerInfo.__init__(self, player_edict)

# add some attributes and stuff

Posted: Fri Aug 24, 2012 6:00 pm
by Monday
Well you could always just test it?

If it doesnt work you could always do something like this:

Syntax: Select all

class MyPlayer(object):
def __init__(self, *args):
'''Called when a server-var is initilized.'''
self.IPlayerInfo = blah

def __getattr__(self, name):
'''Runs missing attributes and methods against IPlayerInfo instance'''
return getattr(self.IPlayerInfo, name)

Posted: Fri Aug 24, 2012 10:11 pm
by BackRaw
Monday wrote:Well you could always just test it?

If it doesnt work you could always do something like this:

Syntax: Select all

class MyPlayer(object):
def __init__(self, *args):
'''Called when a server-var is initilized.'''
self.IPlayerInfo = blah

def __getattr__(self, name):
'''Runs missing attributes and methods against IPlayerInfo instance'''
return getattr(self.IPlayerInfo, name)


Yeah testing would be fine but I'm in trouble installing a linux CS:GO server... can't connect to steam somehow... i'll try it out sometime later. Thanks for your answer tho =)