[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Making A Module
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Making A Module
- From: "Dan Krol" <orblivion@xxxxxxxxx>
- Date: Mon, 29 Oct 2007 12:49:29 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 29 Oct 2007 13:49:38 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=2AahwfIP2l8oyqsoBrE5ScIQ6JgkUkNrfcLIzGZGgWo=; b=eoS2T4t2UlCDxkSyTJ3eeeIQHGov1G3JWmTHiuQ2+hx2gud6OxGmTaBUEu7jRHOTrw6mDbl0YUOReCPGyUV2UD+oXFRry2FlMNOix8PkcmrKe437KxLBftSxZufMJlxolhtdrGysuY+YpdUc9+D6l91oGl2JOKXDW1rVCE521E8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Hg0ctMXEfqb7spyTHTEO7JgAALIU474A/78oH4IVKeJYNno5CzEejbWv2PrfMJZTbJxdG0Bb7CdkAk0H1FDLAvkMKJOMDlkdDpUxuX4Lc0fEI9lKhq99z+7oycCb1pT3/NGCo9Xf2b7Fr+ZPRNMcYbp852tKO6k8/Dw0tTC9B9k=
- In-reply-to: <000501c81a59$f1a73da0$0301a8c0@brucetwer>
- References: <000501c81a59$f1a73da0$0301a8c0@brucetwer>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
You mean for Python in general? Just make a file, put your functions
in there, call it "whatever.py". Keep it in the same directory as your
main python code, and put:
import whatever
That way, to call a function, you say:
whatever.func()
If you don't want to type "whatever" all the time, instead of the
import statement above, say:
from whatever import *
then, to call the same function, just say:
func()
But be careful doing it this way, make sure you don't end up having
multiple functions with the same name when you do this. I personally
usually do the first method, or import individual functions:
from whatever import func1
But it sounds like this is what you were trying to avoid (having a
long list of functions).