View Single Post
  #4   Spotlight this post!  
Unread 28-08-2010, 08:30
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Im doing something wrong here (python)

I wasn't able to spot the problem exactly, but try to check your objects' values (print them to the interactive shell) just before/after you repr/eval them, and try to see if there was some sort of mistake in there.

Aside from that, here are a couple of tips you might wanna' use to better you program's performance a bit, and make it easier to use:

Enums:
You have yet to represent the type of robot in your outputs, such as prettyfiy(), but I already see that you defined the member robotType as a numeric one, so just in case you'll want to represnt the robot's type in text and not in numbers, you could use enums for that:

Taken from http://stackoverflow.com/questions/3...enum-in-python

Quote:
Code:
def enum(**enums):
    return type('Enum', (), enums)
Used like so:

Code:
>>> Numbers = enum(ONE=1, TWO=2, THREE='three')
>>> Numbers.ONE
1
>>> Numbers.TWO
2
>>> Numbers.THREE
'three'
You can also easily support automatic enumeration with something like this:

Code:
def enum(*sequential, **named):
    enums = dict(zip(sequential, range(len(sequential))), **named)
    return type('Enum', (), enums)
Used like so:

Code:
>>> Numbers = enum('ZERO', 'ONE', 'TWO')
>>> Numbers.ZERO
0
>>> Numbers.ONE
1

Len(object):

The Len method is used to get the length of an object holding a collection. e.g, a string can be a collection (a collection of single strings or "chars" appended).
You could use it to return the count of items in your list, like this:

Code:
def countListElements(lists):
    return len(lists)
    # if you use this method only for the toCommit list, do it like this:
    # return len(self.toCommit)
Keep us updated on how the program is progressing.
__________________
TEAM 2230 ZECHARIA'S ANGELS

2009 Microsoft Israel FRC Regional Winners!
2009 Microsoft Israel FRC Regional Chairman's Award Winners!!!
---------------------------------
2008 Microsoft Israel FRC Regional semi-finalist.
2008 Microsoft Israel FRC Regional Delphi's "Driving Tommorow's Technology" Award winner.
2008 Robot Driver
---------------------------------
2007 GM/Technion Israel FRC Regional semi-Finalist.
2007 GM/Technion Israel FRC Regional Xerox Creativity Award winner.
2007 Robot Driver.