![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
This is my first crack at making a game maker, so i would be glad if anyone here can test my engine and post some feedback on the blog. Thanks :-)
Link: http://phoenixengine.blogspot.com/ |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Quick comment about your site:
http://www.iomegatrix.com/Downloads/code.txt I don't think your Python code does what your Ruby code does. It doesn't even compile.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Thanks for letting me know, i have updated it. The problem was because i did not tab the code.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() |
It's still wrong. You have return s on the wrong identation level. Plus you're doing some other whacky things. Why do you append to the string for all clauses except the else clause?
class Point:
def __init__(self, x = 0, y = 0):
self.x , self.y = x, y
def __str__(self):
if (self.x < 0) :
s = "a value in is too small"
elif (self.x > -1 and self.y > -1):
s = "x = " + str(self.x) + " y = " + str(self.y)
else:
s = "<Point " + str(self) + " >"
return s
mypoint = Point()
# print str(mypoint)But I don't even know what the Ruby code does... so, meh.
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#5 | |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Quote:
. The s on the right indent. The point of the code is to show how to use if and else compare to ruby. Some part of the code is not need but to show an example. The sample is basically a point class, which can be used to store x and y point. And when the #toString method is called, it print what ever result is set for the to_s in ruby and calls __str__ for python. |
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() ![]() |
Uhhh... if you don't return s, str(my_point) will display a nullified NoneType variable. No s is being returned for the default case of (x, y) = (0, 0).
Run your code with the line "print str(mypoint)" at the bottom: >>> print str(mypoint) TypeError: __str__ returned non-string (type NoneType) My version of your code shows the (presumably) correct output: >>> print str(mypoint) x = 0 y = 0
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#7 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Can you post it. I will be glad to update it
![]() |
|
|
|
|
|
#8 |
|
Programming Guru
![]() ![]() |
I already did.
![]()
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges! Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download. |
|
|
|
|
|
#9 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
Sorry, i did not realized it
![]() |
|
|
|
|
|
#10 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
You are also missing out on one common python idiom, iteration. You do this:
python Syntax (Toggle Plain Text)
python Syntax (Toggle Plain Text)
__________________
Robotics @ Maryland AUV Team - Software Lead |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [C#] Phoenix - freeware delivery system | g3cka | Paid Job Offers | 14 | Jan 2nd, 2007 6:29 AM |