globalrev a écrit :
wassup here?
7
Traceback (most recent call last):
File "C:\Python25\myPrograms\netflix\netflix.py", line 22, in
<module>
print cust1.getID()
AttributeError: 'NoneType' object has no attribute 'getID'
class customer:
1/ naming convention : class names should be CamelCased
2/ unless you need compatibility with years old Python versions, use
newstyle classes
class Customer(object):
def __init__(self, ID, movies):
self.ID = ID
self.movies = movies
3/ naming conventions : ALL_UPPER_NAMES denote (pseudo) constants
def __init__(self, id, movies):
self.id = id
self.movies = movies
def getID():
return self.ID
def getMovies():
return self.movies
4/ Python has support for computed attributes, so you just don't need
these getters.
import os
import customer
import movie
mv1 = open('C:\\Python25\\myPrograms\\netflix\\mv1exp2.txt', 'r+')
mv1str = mv1.read()
print mv1str.count(',5,')
cust1 = customer.__init__('12',['1','435','2332'])
__init__ is automagically called on instanciation, so you don't have to
call it yourself. And FWIW, your __init__ returns None.
cust1 = Customer('12', ['1', '435', '2332'])
print cust1.getID()
print cust1.id
--
http://mail.python.org/mailman/listinfo/python-list