Jump to content
  • Advertisement
Sign in to follow this  
Splinter of Chaos

Classes? :Python

This topic is 4286 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for a good project to work on involving classes. I thought of an address maker, but that isn't really anything practical for practice. I'm looking for something to gain experience in many areas with a focus on class work and how to tie it to different things. I tried doing a text adventure, but found Python's lack of two dimensional arrays a difficult problem. So does any one know a good project?

Share this post


Link to post
Share on other sites
Advertisement
*What* lack of two-dimensional arrays?

(Seriously. A Python list can hold anything. Did you *try* holding lists?)

Share this post


Link to post
Share on other sites
Numpy is great, but what's wrong with something like:


def array2d(w,h,init_value=None):
return [[init_value]*w for i in range(0,h)]




What does it mean "lists are too general"? Usually we complain when something doesn't meet our requirements, not when it exceeds them.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
*What* lack of two-dimensional arrays?

(Seriously. A Python list can hold anything. Did you *try* holding lists?)


Holding lists? I no not wut meen. Sorry.


And about Numpy:
Looking into it, looks awsome.

Share this post


Link to post
Share on other sites
Quote:
Original post by Splinter of Chaos
Holding lists? I no not wut meen. Sorry.


He simply meant whether you tried using lists. If you put lists within a list as mikeman demonstrated, you have something similar to a 2D array.

Quote:
And about Numpy:
Looking into it, looks awsome.


You'll probably want to use its record arrays and the element type 'object'.

Share this post


Link to post
Share on other sites
Ah, now I see. Yes, I tried. The problem came from lack of experience and thus not knowing how arrays much work, that is withought creating my own array. And what I came up with was difficult to read.

Share this post


Link to post
Share on other sites
Mikeman, I've learnt programming in Python just a few months ago, and I have been using C++ for years. I couldn't yet get used to Pythons powerful constructs, so I missed the vectors, lists, deques etc., but your code showed me how to think in a Pythonic way.

Share this post


Link to post
Share on other sites
Before this thread becomes unused and thus worthless, I would like to jeer it back to the crux: A good exercise for working with and understanding classes, what is?

Is a text adventure a good starter?
Is it too advanced (or, is it a good starting ground for learning procedural progamming or isn't it)?
Are there other, simpler programms that use classes that are much better introductions?

Thanks in advance.

EDIT:
I know I said above that I'd like to get back to the main point, but can any one tell me what you have to do to make NumPy work? I tried put it in Python 2.5/lib/sit-packages and it didn't work when I imported Numpy, NumArray or a few other tries, and I even tried running the installer in its file. The NumPy website didn't seem to have suffician advice.

Anyone know what I should do?
(Wow I feel extra noobish right now :]

[Edited by - Splinter of Chaos on October 22, 2006 4:12:46 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!