Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78140

Re: Class Inheritance from different module

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=335e18db2=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'assumed': 0.09; 'instance.': 0.09; 'nb:': 0.09; 'subject:module': 0.09; 'url:github': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'anyway': 0.14; 'creates': 0.14; '"python"': 0.16; 'inheritance': 0.16; 'key)': 0.16; 'objects.': 0.16; 'possible?': 0.16; 'sense,': 0.16; 'module': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'instance,': 0.24; 'sorry,': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'query': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'breaking': 0.31; 'fine,': 0.31; 'once,': 0.31; 'class': 0.32; 'probably': 0.32; '-----': 0.33; 'monday,': 0.33; 'skip:_ 10': 0.34; 'subject:from': 0.34; 'connection': 0.35; 'skip:s 30': 0.35; 'thank': 0.38; 'does': 0.39; 'subject:': 0.39; 'skip:u 10': 0.60; 'skip:a 30': 0.61; 'new': 0.61; 'simply': 0.61; 'you.': 0.62; 'information': 0.63; 're:': 0.63; 'received:194': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'user,': 0.69; 'disclose': 0.74; 'medium.': 0.91; 'subject:Class': 0.91
X-IronPort-AV E=Sophos;i="5.04,571,1406584800"; d="scan'208";a="3351111"
Date Mon, 22 Sep 2014 14:09:33 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Juan Christian <juan0christian@gmail.com>
In-Reply-To <1708546287.7032216.1411385861221.JavaMail.root@sequans.com>
Subject Re: Class Inheritance from different module
MIME-Version 1.0
X-Mailer Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC35 (Linux)/7.2.7_GA_2942)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14196.1411387774.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411387774 news.xs4all.nl 2904 [2001:888:2000:d::a6]:48892
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78140

Show key headers only | View raw


----- Original Message -----
> From: "Jean-Michel Pichavant" <jeanmichel@sequans.com>
> To: "Juan Christian" <juan0christian@gmail.com>
> Cc: "Python" <python-list@python.org>
> 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')

Cheers,

JM


NB: I assumed you were using https://github.com/smiley/steamapi
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


-- IMPORTANT NOTICE: 

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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Class Inheritance from different module Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-09-22 14:09 +0200

csiph-web