Class Inheritance from different module

Jean-Michel Pichavant jeanmichel at
Mon Sep 22 14:09:33 CEST 2014

----- Original Message -----
> From: "Jean-Michel Pichavant" <jeanmichel at>
> To: "Juan Christian" <juan0christian at>
> Cc: "Python" <python-list at>
> Sent: Monday, 22 September, 2014 1:37:41 PM
> Subject: Re: Class Inheritance from different module
> > class User(Inheritance from API):
> > def __init__(self, ID):
> > steamapi.core.APIConnection(api_key = KEY)
> > super( " Inheritance SteamUser" (ID)) # creates the user using the
> > API
> > 
> > 
> > [...]
> > 
> > 
> > So that in my code when I need to create a new user, I just call
> > 'usr
> > = User("XXXXXXX")' instead of calling 'usr =
> > steamapi.user.SteamUser(76561197996416028)', is that possible?
> [snip

Sorry, sent the message by mistake.

Anyway if you just want a nice way to create an instance, you may simply write

import steamapi.user.SteamUser as User

usr = User('whatever')

However you don't create an APIConnection when creating a user, it does not make much sense, you only need one API connection per session and it will be shared by all the User objects.

# Note ApiConnection is a singleton, and you only need to execute this once, in you app/script initialization for instance.
api = APIConnection(api_key='dlkfnsdlfn')

# query the database
user1 = User('user1')
user2 = User('user2')



NB: I assumed you were using
NB2 : because APIConnection is a singleton, your original code probably works just fine, I'm just not a big fan of breaking to python module design


The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

More information about the Python-list mailing list