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


Groups > comp.lang.python > #28643

Re: Setting up a class

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 <python-python-list@m.gmane.org>
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 <wlfraed@ix.netcom.com>
Subject Re: Setting up a class
Date Thu, 06 Sep 2012 17:23:37 -0400
Organization > Bestiaria Support Staff <
References <a451e907-5167-4e3e-a7f2-d63ffa0f2821@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.330.1346966626.27098.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Thu, 6 Sep 2012 05:00:32 -0700 (PDT), shaun
<shaun.wiseman91@gmail.com> 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/

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


Thread

Setting up a class shaun <shaun.wiseman91@gmail.com> - 2012-09-06 05:00 -0700
  Re: Setting up a class Joel Goldstick <joel.goldstick@gmail.com> - 2012-09-06 08:16 -0400
  Re: Setting up a class MRAB <python@mrabarnett.plus.com> - 2012-09-06 13:20 +0100
    Re: Setting up a class "Colin J. Williams" <cjw@ncf.ca> - 2012-09-06 09:41 -0400
  Re: Setting up a class Dave Angel <d@davea.name> - 2012-09-06 09:41 -0400
  Re: Setting up a class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-06 17:23 -0400

csiph-web