Classes? :Python
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?
*What* lack of two-dimensional arrays?
(Seriously. A Python list can hold anything. Did you *try* holding lists?)
(Seriously. A Python list can hold anything. Did you *try* holding lists?)
Hi
I think you should try Numpy.
Here is the doc.
BTW, I also found the lack of arrays disturbing, those lists are too general.
I think you should try Numpy.
Here is the doc.
BTW, I also found the lack of arrays disturbing, those lists are too general.
Numpy is great, but what's wrong with something like:
What does it mean "lists are too general"? Usually we complain when something doesn't meet our requirements, not when it exceeds them.
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.
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.
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'.
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.
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.
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement