Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'method.': 0.05; 'attributes': 0.07; 'class,': 0.07; 'classes.': 0.07; 'python': 0.09; '"class"': 0.09; 'called.': 0.09; 'notation.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'ignore': 0.13; 'language': 0.14; 'passing': 0.15; '"global"': 0.16; '(other': 0.16; 'instances,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'instance': 0.17; 'thu,': 0.17; 'variables': 0.17; 'module': 0.19; 'variable': 0.20; 'parameters': 0.20; 'trying': 0.21; 'import': 0.21; 'java': 0.21; "haven't": 0.23; 'seems': 0.23; 'script': 0.24; 'pass': 0.25; 'wondering': 0.26; 'appreciated.': 0.26; 'module.': 0.27; 'newer': 0.27; "doesn't": 0.28; 'header:X -Complaints-To:1': 0.28; 'questions?': 0.29; 'class': 0.29; 'this.': 0.29; "i'm": 0.29; 'related': 0.30; '(including': 0.30; 'classes': 0.30; 'call.': 0.30; 'normally': 0.30; '(and': 0.32; 'could': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'done': 0.34; 'doing': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'method': 0.36; 'anything': 0.36; 'should': 0.36; 'too': 0.36; 'charset:us-ascii': 0.36; 'problems': 0.36; 'correctly': 0.37; 'being': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'first': 0.61; 'back': 0.62; 'information': 0.63; 'different.': 0.84; 'manual,': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Setting up a class Date: Thu, 06 Sep 2012 17:23:37 -0400 Organization: > Bestiaria Support Staff < References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-223-184.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1346966626 news.xs4all.nl 6906 [2001:888:2000:d::a6]:50290 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:28643 On Thu, 6 Sep 2012 05:00:32 -0700 (PDT), shaun declaimed the following in gmane.comp.python.general: > > But I'm having major problems since I am new to python I keep trying to do it as I would do it in Java but classes seem to be very different. I was wondering could someone answer a few questions? > First mistake... IGNORE anything you know about Java classes. (Including the one-class-per-file). > 1) Is there anything I should know about passing in variables from another script to the class? Normally you don't pass variables to the "class" -- you create an INSTANCE of the class (and may pass some parameters to the __init__() method. > > 2) When I'm passing variables back to the script they seem to come back blank as if I haven't done it correctly (I declare the empty variable at the top of the class, I use the information I get from the database to fill it and I send it back) Is there anything I'm not doing right with this. > Python doesn't have "declarations" (other than "global" and related in newer versions). Normally one "return"s data from a method call. Otherwise one access instance attributes using instance.attribute notation. > 3)When I want to use a method from a class in another class method it never seems to work for me, I have a feeling this is to do with "self" but im not too sure?? > "self" is the instance whose method is being called. If you are trying to use a class for something that has no instances, forget it, just package everything up as module and import the module. > Any help would be appreciated. Read the language reference manual, and the Python tutorial... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/