notice that code passed to exec(or eval(does not consider the classname of the invoking class to be the current classthis is similar to the effect of the global statementthe effect of which is likewise restricted to code that is byte-compiled together the same restriction applies to getattr()setattr(and delattr()as well as when referencing __dict__ directly odds and ends sometimes it is useful to have data type similar to the pascal "recordor "struct"bundling together few named data items an empty class definition will do nicelyclass employeepass john employee(create an empty employee record fill the fields of the record john name 'john doejohn dept 'computer labjohn salary piece of python code that expects particular abstract data type can often be passed class that emulates the methods of that data type instead for instanceif you have function that formats some data from file objectyou can define class with methods read(and readline(that get the data from string buffer insteadand pass it as an argument instance method objects have attributestoom __self__ is the instance object with the method ()and __func__ is the function object corresponding to the method iterators by now you have probably noticed that most container objects can be looped over using for statementfor element in [ ]print(elementfor element in ( )print(elementfor key in {'one': 'two': }print(keyfor char in " "print(charfor line in open("myfile txt")print(lineend=''this style of access is clearconciseand convenient the use of iterators pervades and unifies python behind the scenesthe for statement calls iter(on the container object the function returns an iterator object that defines the method __next__(which accesses elements in the container one at time when there are no more elements__next__(raises stopiteration exception which tells the for loop to terminate you can call the __next__(method using the next(built-in functionthis example shows how it all workss 'abcit iter(sit (continues on next page odds and ends