468,556 Members | 2,410 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,556 developers. It's quick & easy.

"term not defined" or "invalid syntax"

Hello,

I am a 1st semester Computer Science student in a Python class. Our current assignment calls for us to read a list from a file, create a 2-dimensional list from the file, and check to see whether or not 2-dim list constitutes a "magic square" (i.e. all the rows, columns and diagonals equal each other when added). We are to create several definitions, and I have had no problem reading from the file, creating the list, and getting the sum of the first row. The next thing I need to do is sum up the other rows and see if they are equal to the first row. If not equal, I return a false and the function ends, if all are equal, I return a True. When I try to call another function (def sum(list, dimensions)) in my "areRowSumsEqualToSum" function, I am getting a message telling me that the term "dimensions" is not defined, even though i use the same term in the "def sum(list, dimensions)" function. When I try to call sum(list, dimensions) in the definition name, I get an "invalid syntax" error.

The list file looks like this, the first line is the dimensions of the "square", with the list following after a blank space.

3

8
1
6
3
5
7
4
9
2

Here is my code, I appreciate any help, and I apologize if this is a mess. I'm pretty green still.

Expand|Select|Wrap|Line Numbers
  1. def main():
  2.     import string
  3.     value = True
  4.     while value:
  5.         try:
  6.             userfile = raw_input("Enter the file name where the list is located: ")
  7.             infile = open(userfile, 'r')
  8.             value = False
  9.         except IOError:
  10.             print "File not found"
  11.     dimensions = eval(infile.readline())
  12.     infile.readline()
  13.     list = construct2dimlist(infile, dimensions)
  14.     print sum(list, dimensions)
  15.     print areRowSumsEqualToSum(list, sum(list, dimensions))
  16.  
  17. def construct2dimlist(infile, dimensions):
  18.     outerlist = []
  19.     for i in range(dimensions):
  20.         sublist = []
  21.         for j in range(dimensions):
  22.             sublist = sublist + [eval(infile.readline())]
  23.         outerlist = outerlist + [sublist]
  24.     return outerlist
  25.  
  26.     print construct2dimlist(infile, dimensions)
  27.     infile.close
  28.  
  29. def sum(list, dimensions):
  30.     rowsum = 0
  31.     for i in range(dimensions):
  32.         rowsum = rowsum + list[0][i]
  33.     return rowsum
  34.  
  35. def areRowSumsEqualToSum(list, sum(list, dimensions)):
  36.     rowsums = 0
  37.     for i in range(1, len(list)):
  38.         for j in range(len(list)):
  39.             rowsums = rowsums + list[i][j]
  40.             if(sum(list) != rowsums):
  41.                 return False
  42.     return True
  43.  
  44. main() 
Thanks!

edit: i guess the indents don't show up here?
Jul 16 '07 #1
10 3625
bartonc
6,596 Expert 4TB
I can't quote your code here due to a bug in the system, but this should help:
edit: i guess the indents don't show up here?
I've added what are called code tags. Instructions are on the right hand side while posting or replying.

I've marked up your submission, but haven't tested any thing.
I can't stress this enough: Comment everything. You'll like yourself much more in the long run and getting help from others becomes easier, as well.

Have fun:
Expand|Select|Wrap|Line Numbers
  1. def construct2dimlist(infile, dimensions):
  2.     """Build a 2D list using the open file and DIMENSION_TUPLE????"""
  3.     outerlist = []
  4. ##    for i in range(dimensions):?????????
  5.     for i in range(dimensions[0]):
  6.         sublist = []
  7. ##        for j in range(dimensions):???????
  8.         for j in range(dimensions[1]):
  9. ##            sublist = sublist + [eval(infile.readline())]
  10.             sublist.append(eval(infile.readline()))
  11. ##        outerlist = outerlist + [sublist]
  12.         outerlist.append(sublist)
  13.     return outerlist
  14.  
  15. #### never executed ####
  16.     print construct2dimlist(infile, dimensions)
  17.     # don't close here, because in was not opened here, anyway
  18.     infile.close
  19.  
  20. #### Use python built-in function instead
  21. ##def sum(list, dimensions):
  22. ##    rowsum = 0
  23. ##    for i in range(dimensions):
  24. ##        rowsum = rowsum + list[0][i]
  25. ##    return rowsum
  26.  
  27. def areRowSumsEqualToSum(list, mustBeANameHere):
  28.     rowsums = 0
  29. ##    for i in range(1, len(list)): ## Use the list elements instead of an index
  30.     for subList in list[1:]:  # Might as well slice off the one that was already summed
  31.         # that's one way to do it
  32. ##        for j in range(len(list)):
  33. ##            rowsums = rowsums + list[i][j]
  34. ##            if mustBeANameHere != rowsums:
  35. ##                return False
  36.         if sum(subList) != mustBeANameHere
  37.             return False
  38.     return True
  39.  
  40.  
  41. def main():
  42.     import string
  43.     value = True
  44.     while value:
  45.         try:
  46.             userfile = raw_input("Enter the file name where the list is located: ")
  47.             infile = open(userfile, 'r')
  48.             value = False
  49.         except IOError:
  50.             print "File not found"
  51.             #### STOP EXECUTION ###
  52.             return
  53.  
  54.     dimensions = eval(infile.readline())
  55.     infile.readline()  # skip a line
  56.     # I like doing this - pass the prepared file to the worker
  57.     # but don't use python keywords like 'list', 'dict', etc for variable names (bad practice)
  58. ##    list = construct2dimlist(infile, dimensions)
  59.     a2DList = construct2dimlist(infile, dimensions) # dimensions is presumably a tuple
  60.     infile.close
  61.  
  62.     # sum() takes a list, just tell it which part of the array that you want to sum
  63. ##    theSum = sum(a2DList, dimensions)
  64.     theSum = sum(a2DList[0])
  65.     print areRowSumsEqualToSum(list, theSum)
  66.  
  67. if __name__ == "__main__":   # this makes it possible to import this module into others
  68.     main()
Jul 17 '07 #2
Thanks for the reply bartonc. I now get this error:

Expand|Select|Wrap|Line Numbers
  1. Traceback (most recent call last):
  2.   File "/Users/jonathan/Documents/pythonboard2.py", line 67, in <module>
  3.     main()
  4.   File "/Users/jonathan/Documents/pythonboard2.py", line 59, in main
  5.     a2DList = construct2dimlist(infile, dimensions) # dimensions is presumably a tuple
  6.   File "/Users/jonathan/Documents/pythonboard2.py", line 5, in construct2dimlist
  7.     for i in range(dimensions[0]):
  8. TypeError: 'int' object is unsubscriptable
I was wondering if you could look at my original code and possibly explain why I would be getting an invalid syntax error when I write my definition as:

def areRowSumsEqualToSum(list, sum(list, dimensions)):

Is it an illegal operation to have "list" in the parameters twice, in two different forms (if that makes sense at all)? As I mentioned before, if I leave out "dimensions", I get an error telling me that sum has two parameters, and I have left out one, or that "dimensions" is not defined.

Thanks again for the help!

Hmmm...I don't think I "coded" my code correctly for the message board.
Jul 17 '07 #3
bvdet
2,851 Expert Mod 2GB
Hello,

I am a 1st semester Computer Science student in a Python class. Our current assignment calls for us to read a list from a file, create a 2-dimensional list from the file, and check to see whether or not 2-dim list constitutes a "magic square" (i.e. all the rows, columns and diagonals equal each other when added). We are to create several definitions, and I have had no problem reading from the file, creating the list, and getting the sum of the first row. The next thing I need to do is sum up the other rows and see if they are equal to the first row. If not equal, I return a false and the function ends, if all are equal, I return a True. When I try to call another function (def sum(list, dimensions)) in my "areRowSumsEqualToSum" function, I am getting a message telling me that the term "dimensions" is not defined, even though i use the same term in the "def sum(list, dimensions)" function. When I try to call sum(list, dimensions) in the definition name, I get an "invalid syntax" error.

The list file looks like this, the first line is the dimensions of the "square", with the list following after a blank space.

3

8
1
6
3
5
7
4
9
2

Here is my code, I appreciate any help, and I apologize if this is a mess. I'm pretty green still.

Expand|Select|Wrap|Line Numbers
  1. def main():
  2.     import string
  3.     value = True
  4.     while value:
  5.         try:
  6.             userfile = raw_input("Enter the file name where the list is located: ")
  7.             infile = open(userfile, 'r')
  8.             value = False
  9.         except IOError:
  10.             print "File not found"
  11.     dimensions = eval(infile.readline())
  12.     infile.readline()
  13.     list = construct2dimlist(infile, dimensions)
  14.     print sum(list, dimensions)
  15.     print areRowSumsEqualToSum(list, sum(list, dimensions))
  16.  
  17. def construct2dimlist(infile, dimensions):
  18.     outerlist = []
  19.     for i in range(dimensions):
  20.         sublist = []
  21.         for j in range(dimensions):
  22.             sublist = sublist + [eval(infile.readline())]
  23.         outerlist = outerlist + [sublist]
  24.     return outerlist
  25.  
  26.     print construct2dimlist(infile, dimensions)
  27.     infile.close
  28.  
  29. def sum(list, dimensions):
  30.     rowsum = 0
  31.     for i in range(dimensions):
  32.         rowsum = rowsum + list[0][i]
  33.     return rowsum
  34.  
  35. def areRowSumsEqualToSum(list, sum(list, dimensions)):
  36.     rowsums = 0
  37.     for i in range(1, len(list)):
  38.         for j in range(len(list)):
  39.             rowsums = rowsums + list[i][j]
  40.             if(sum(list) != rowsums):
  41.                 return False
  42.     return True
  43.  
  44. main() 
Thanks!

edit: i guess the indents don't show up here?
I made a change to this code snippet of yours:
Expand|Select|Wrap|Line Numbers
  1. lst = construct2dimlist(infile, dimensions)
  2.     print sum(lst, dimensions)
  3.     print areRowSumsEqualToSum(lst, dimensions)
You cannot call a function in an argument list. Another change:
Expand|Select|Wrap|Line Numbers
  1. def areRowSumsEqualToSum(lst, dimensions):
  2.     rowsums = 0
  3.     for i in range(1, len(lst)):
  4.         for j in range(len(lst)):
  5.             rowsums = rowsums + lst[i][j]
  6.             if(sum(lst, dimensions) != rowsums):
  7.                 return False
  8.     return True
See if your code will execute now.
Jul 17 '07 #4
bartonc
6,596 Expert 4TB
Thanks for the reply bartonc. I now get this error:
Expand|Select|Wrap|Line Numbers
  1. Traceback (most recent call last):
  2.   File "/Users/jonathan/Documents/pythonboard2.py", line 67, in <module>
  3.     main()
  4.   File "/Users/jonathan/Documents/pythonboard2.py", line 59, in main
  5.     a2DList = construct2dimlist(infile, dimensions) # dimensions is presumably a tuple
  6.   File "/Users/jonathan/Documents/pythonboard2.py", line 5, in construct2dimlist
  7.     for i in range(dimensions[0]):
  8. TypeError: 'int' object is unsubscriptable
Your variable is called "dimentions" with an "s" so I assumed a tuple like
Expand|Select|Wrap|Line Numbers
  1. dimensions = (5, 5)
I see now that you assume a square array so take out the subscript "[0]" part.
I was wondering if you could look at my original code and possibly explain why I would be getting an invalid syntax error when I write my definition as:
Expand|Select|Wrap|Line Numbers
  1. def areRowSumsEqualToSum(list, sum(list, dimensions)):
Won't work because you must have a name in the argument list so that it may be referred to later in the function. The syntax would be allowed in the function call:
Expand|Select|Wrap|Line Numbers
  1. areRowSumsEqualToSum(list, sum(list, dimensions))
but not the definition.

Is it an illegal operation to have "list" in the parameters twice, in two different forms (if that makes sense at all)? As I mentioned before, if I leave out "dimensions", I get an error telling me that sum has two parameters, and I have left out one, or that "dimensions" is not defined.

Thanks again for the help!

Hmmm...I don't think I "coded" my code correctly for the message board.
Keep trying to get your latest code posted correctly. You have a full hour to get it right. Then it's no big deal for me to fix it after that.
Jul 17 '07 #5
bartonc,

If I could just ask you one more question, you'll be free of me (at least for the rest of this evening). Thank you for your help so far. I have finished my program, however, I am still having a hard time getting my "sum" into each of the different functions in order to compare it with other column/row/diagonal sums. After I calculated the sum in a definition, I figured if I defined "sum" as that definition (sum = sum(list, dimensions)), I'd be able to call that in my other functions easily. It obviously isn't working the way I had hoped-when I print what I hope will be a comparison between "sum" and one of the computed values, they don't equal each other (and they should). In fact, when I try to print "sum" in the other functions, I see "function sum at 0x11132b0", instead of an integer.

Is there any way to get that "sum" into my other definitions without major changes?

Here is my (almost) final code:
Expand|Select|Wrap|Line Numbers
  1. #magicsquarechecker.py
  2. #This program creates a two-dimensional list of any dimension using
  3. #input from a user-created file.  It then evaluates the 2D list to
  4. #determine whether or not it constitues a "Magic Square".
  5.  
  6. def main():
  7.     import string
  8.     print "This program constructs a two-dimensional list from a"
  9.     print "user-supplied file and checks to see whether the list constitutes"
  10.     print "a 'magic square'."
  11.     value = True
  12.     while value:
  13.         try:
  14.             userfile = raw_input("Enter the file name where the list is located: ")
  15.             infile = open(userfile, 'r')
  16.             value = False
  17.         except IOError:
  18.             print "File not found"
  19.     dimensions = eval(infile.readline())
  20.     infile.readline()
  21.     list = construct2dimlist(infile, dimensions)
  22.     print list
  23.     print areRowSumsEqualToSum(list, sum)
  24.     print areColumnSumsEqualToSum(list, sum)
  25.     print isDownDiagonalSumEqualToSum(list, sum)
  26.     print isUpDiagonalSumEqualToSum(list, sum)
  27.     print isMagicSquare(list)
  28.  
  29. def construct2dimlist(infile, dimensions):
  30.     outerlist = []
  31.     for i in range(dimensions):
  32.         sublist = []
  33.         for j in range(dimensions):
  34.             sublist = sublist + [eval(infile.readline())]
  35.         outerlist = outerlist + [sublist]
  36.     return outerlist
  37.     construct2dimlist(infile, dimensions)
  38.     print areRowSumsEqualToSum(list, sum)
  39.     infile.close
  40.  
  41. def sum(list, dimensions):
  42.     rowsum = 0
  43.     for i in range(dimensions):
  44.             rowsum = rowsum + list[0][i]
  45.     return rowsum
  46.  
  47.     sum = sum(list, dimensions)
  48.  
  49. def areRowSumsEqualToSum(list, sum):
  50.     otherrowsums = 0
  51.     for i in range(1, len(list)):
  52.         for j in range(len(list)):
  53.             otherrowsums = otherrowsums + list[i][j]
  54.         if(sum != otherrowsums):
  55.             return False
  56.     return True
  57.  
  58. def areColumnSumsEqualToSum(list, sum):
  59.     columnsums = 0
  60.     for i in range(len(list)):
  61.         for j in range(len(list)):
  62.             columnsums = columnsums + list[j][i]
  63.         if(sum != columnsums):
  64.             return False
  65.     return True
  66.  
  67. def isDownDiagonalSumEqualToSum(list, sum):
  68.     downdiagonalsum = 0
  69.     for i in range(len(list)):
  70.         downdiagonalsum = downdiagonalsum + list[i][i]
  71.     if(sum != downdiagonalsum):
  72.         return False
  73.     return True
  74.  
  75. def isUpDiagonalSumEqualToSum(list, sum):
  76.     updiagonalsum = 0
  77.     for i in range((len(list))-1, -1, -1):
  78.         updiagonalsum = updiagonalsum + list[i][((len(list))-1)-i]
  79.     if(sum != updiagonalsum):
  80.         return False
  81.     return True
  82.  
  83. def isMagicSquare(list):
  84.     if(areRowSumsEqualToSum(list, sum) and areColumnSumsEqualToSum(list, sum) and isDownDiagonalSumEqualToSum(list, sum) and isUpDiagonalSumEqualToSum(list, sum)):
  85.         return "Yes, the two-dimensional list is a magic square"
  86.     return "No, the list does not constitute a magic square."
  87.  
  88. main()
One more thing, where do I select "Python Code"?

Thanks again!

Jon
Jul 17 '07 #6
bartonc
6,596 Expert 4TB
I have to admit being a little disappointed when I saw that you had not made some of the changes that I had suggested. I tried, here, to keep as much of your work as possible, but I can't in good conscience let you create lists by adding them together. I have used list.append() as it should be used.

As for code tag syntax, see the reason for edit at the bottom of your post. The thing is that, if I type it here, it won't show up. You can alway see the raw text of a post when you reply to it, though.
Expand|Select|Wrap|Line Numbers
  1. #magicsquarechecker.py
  2. #This program creates a two-dimensional list of any dimension using
  3. #input from a user-created file.  It then evaluates the 2D list to
  4. #determine whether or not it constitues a "Magic Square".
  5.  
  6. def construct2dimlist(infile, dimensions):
  7.     outerlist = []
  8.     for i in range(dimensions):
  9.         sublist = []
  10.         for j in range(dimensions):
  11.             sublist.append(eval(infile.readline()))
  12. ##            sublist = sublist + [eval(infile.readline())]
  13.         outerlist.append(sublist)
  14. ##        outerlist = outerlist + [sublist]
  15.     return outerlist
  16.  
  17.     ## never executed due to the return above
  18.     construct2dimlist(infile, dimensions)
  19.     print areRowSumsEqualToSum(list, sum)  # It's bad practice to use built-in names as argument names
  20.     infile.close
  21.  
  22. def my_sum(aList, rowNum): # don't use built-in names for your function names
  23.     """Return the some of a given row"""
  24. ##    rowsum = 0
  25. ##    for i in range(dimensions):
  26. ##            rowsum = rowsum + aList[0][i]
  27. ##    return rowsum
  28.     return sum(aList[rowNum]) # call built-in sum()
  29.  
  30.     ## never executed due to the return above
  31. ##    sum = my_sum(aList, dimensions)
  32.  
  33. def sum_all(aList):
  34.     """Return the total of all rows in the array"""
  35.     return sum([sum(item) for item in aList])  # List comprehentions are very handy
  36.  
  37. def areRowSumsEqualToSum(aList, total):
  38.     otherrowsums = 0
  39.     for i in range(1, len(aList)):
  40.         for j in range(len(aList)):
  41.             otherrowsums = otherrowsums + aList[i][j]
  42.         if(total != otherrowsums):
  43.             return False
  44.     return True
  45.  
  46. def areColumnSumsEqualToSum(aList, total):
  47.     columnsums = 0
  48.     for i in range(len(aList)):
  49.         for j in range(len(aList)):
  50.             columnsums = columnsums + aList[j][i]
  51.         if(total != columnsums):
  52.             return False
  53.     return True
  54.  
  55. def isDownDiagonalSumEqualToSum(aList, total):
  56.     downdiagonalsum = 0
  57.     for i in range(len(aList)):
  58.         downdiagonalsum = downdiagonalsum + aList[i][i]
  59.     if(total != downdiagonalsum):
  60.         return False
  61.     return True
  62.  
  63. def isUpDiagonalSumEqualToSum(aList, total):
  64.     updiagonalsum = 0
  65.     for i in range((len(aList))-1, -1, -1):
  66.         updiagonalsum = updiagonalsum + aList[i][((len(aList))-1)-i]
  67.     if(total != updiagonalsum):
  68.         return False
  69.     return True
  70.  
  71. def isMagicSquare(aList):
  72.     if(areRowSumsEqualToSum(aList, total) and \
  73.             areColumnSumsEqualToSum(aList, total) and \
  74.             isDownDiagonalSumEqualToSum(aList, total) and \
  75.             isUpDiagonalSumEqualToSum(aList, total)):
  76.         return "Yes, the two-dimensional list is a magic square"
  77.     return "No, the list does not constitute a magic square."
  78.  
  79. def main():
  80.     # don't import string unless you really need some constant defined there
  81. ##    import string
  82.     print "This program constructs a two-dimensional list from a"
  83.     print "user-supplied file and checks to see whether the list constitutes"
  84.     print "a 'magic square'."
  85.     value = True
  86.     while value:
  87.         try:
  88.             userfile = raw_input("Enter the file name where the list is located: ")
  89.             infile = open(userfile, 'r')
  90.             value = False
  91.         except IOError:
  92.             print "File not found"
  93.     dimensions = eval(infile.readline())    # An iteger defining BOTH dimensions
  94.     infile.readline()                       # Skip a line
  95.     a2DList = construct2dimlist(infile, dimensions)
  96.     ### close the file here! ###
  97.     infile.close
  98.  
  99.     print a2DList
  100.     ## Caluculate the sum of the zeroth row ##
  101.     rowZeroSum = my_sum(a2DList, 0)
  102.     print areRowSumsEqualToSum(a2DList, rowZeroSum)
  103.     print areColumnSumsEqualToSum(a2DList, rowZeroSum)
  104.     print isDownDiagonalSumEqualToSum(a2DList, rowZeroSum)
  105.     print isUpDiagonalSumEqualToSum(a2DList, rowZeroSum)
  106.     print isMagicSquare(a2DList)
  107.  
  108.  
  109. if __name__ == "__main__":
  110.  
  111. ##    # used for testing without a file
  112. ##    from random import randint
  113. ##    size = 5    # the size of each side of the array
  114. ##    a2DList = [[randint(0, 50) for i in range(size)] for j in range(size)]
  115.  
  116.     main()
Jul 17 '07 #7
bartonc
6,596 Expert 4TB
You may ask all the questions that you like. That's what the Python Forum is here for.
Expand|Select|Wrap|Line Numbers
  1. In fact, when I try to print "sum" in the other functions, I see "function sum at 0x11132b0", instead of an integer.
I think that I can put that into terms that are understandable:
Expand|Select|Wrap|Line Numbers
  1. >>> def aFunction():    # everything in python is an object of some sort
  2. ...     return "hello world"    # a function object returns an object of some sort
  3. ... 
  4. >>> # when you use this syntax:
  5. >>> result = aFunction()   # you call the function object and work gets done
  6. >>> print result
  7. hello world
  8. >>> result = aFunction  # if you do this by mistake (or in your case not keeping names clear)
  9. >>> print result    # you get the function object itself. not the result of the function call
  10. <function aFunction at 0x02F21C30>
  11. >>> 
Jul 17 '07 #8
bvdet
2,851 Expert Mod 2GB
You may ask all the questions that you like. That's what the Python Forum is here for.
Expand|Select|Wrap|Line Numbers
  1. In fact, when I try to print "sum" in the other functions, I see "function sum at 0x11132b0", instead of an integer.
I think that I can put that into terms that are understandable:
Expand|Select|Wrap|Line Numbers
  1. >>> def aFunction():    # everything in python is an object of some sort
  2. ...     return "hello world"    # a function object returns an object of some sort
  3. ... 
  4. >>> # when you use this syntax:
  5. >>> result = aFunction()   # you call the function object and work gets done
  6. >>> print result
  7. hello world
  8. >>> result = aFunction  # if you do this by mistake (or in your case not keeping names clear)
  9. >>> print result    # you get the function object itself. not the result of the function call
  10. <function aFunction at 0x02F21C30>
  11. >>> 
You have done some good work on this thread Barton. I have taken a slightly different approach to this problem. Pass the list to a function. In the function, initialize a set, sum each row, sum each column, sum the two diagonals, and add the results to the set. If the set length is greater than 1, the list is not a magic square and returns False:
Expand|Select|Wrap|Line Numbers
  1. def areAllSumsEqual(a2DList):
  2.     sumSet = set()
  3.     # sum each row
  4.     for row in a2DList:
  5.         sumSet.add(sum(row))
  6.  
  7.     # sum each column
  8.     for i in range(len(a2DList)):
  9.         sumSet.add(sum([row[i] for row in a2DList]))
  10.  
  11.     # sum diagonals
  12.     sumSet.add(sum([a2DList[i][i] for i in range(len(a2DList))]))
  13.     indxList = (range(len(a2DList)-1,-1,-1), range(len(a2DList)))
  14.     sumSet.add(sum([a2DList[indxList[0][i]][indxList[1][i]] for i in range(len(a2DList))]))
  15.  
  16.     if len(sumSet) > 1:
  17.         return False
  18.     return True
Jul 17 '07 #9
I have to admit being a little disappointed when I saw that you had not made some of the changes that I had suggested. I tried, here, to keep as much of your work as possible, but I can't in good conscience let you create lists by adding them together. I have used list.append() as it should be used.
The thing is, I'm at a point very early in the game, and some of the changes you made we haven't learned about yet in class. Also, we have very strict assignment specs, what you see in my code is the way my instructor INSISTS on things being done. So while my instructor encouraged us to ask around when we get stuck, I wouldn't feel right about copying portions of your code without really understanding them, and probably wouldn't have gotten credit for them.

But I really do appreciate the input, thank you.
Jul 17 '07 #10
bartonc
6,596 Expert 4TB
The thing is, I'm at a point very early in the game, and some of the changes you made we haven't learned about yet in class. Also, we have very strict assignment specs, what you see in my code is the way my instructor INSISTS on things being done. So while my instructor encouraged us to ask around when we get stuck, I wouldn't feel right about copying portions of your code without really understanding them, and probably wouldn't have gotten credit for them.

But I really do appreciate the input, thank you.
Fair enough. I'll go ahead and stick in "best practices" when I see that your instructor is leading you astray (IMO), but won't expect to see them implemented in your re-posts.

Most of all, HAVE FUN WITH PYTHON! It's a really great language.
Jul 17 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

34 posts views Thread by jblazi | last post: by
1 post views Thread by wiredog | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.