By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,400 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,400 IT Pros & Developers. It's quick & easy.

How To Uses Modules And Plugins

P: n/a
I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.
Apr 6 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Lie
On Apr 7, 12:28 am, mar...@everautumn.com wrote:
I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.
I think you're doing it with the wrong approach, a map is a data so it
should not be placed in a .py file, instead it should be placed in
something like .map files which is read by your program to generate
the map object. To read a file in python, use:

f = file('path/path/file.map', 'r') # for reading
g = file('path/path/file.map', 'rw') # for read and write

m = f.readline() # To read until meeting a '\n'
n = f.read() # To read until EOF (End of File)
for line in g:
#
# To read the file line by line
# using the very convenient for
#

f.close() # Don't forget to close the file after use
g.close()

Apr 6 '08 #2

P: n/a
En Sun, 06 Apr 2008 14:28:44 -0300, <ma****@everautumn.comescribió:
I am working on a client/server, computer role-play game using Python.
I want to gradually expand the game world by creating maps as
individual py files in a map directory. I am a little foggy of how to
do this. I have read about the __import__() function. I want to
understand what the difference is between using modules and plugins.
Are they the same thing? How will my root script interact with the
individual modules once it has loaded them? If you can point me to a
web site or tutorial on this subject I would be thankful.
Look for recent posts about "plugin" in this group.

--
Gabriel Genellina

Apr 6 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.