(self, filename=None, file=None, **options)
Construct a new TextFile object.  At least one of 'filename'
           (a string) and 'file' (a file-like object) must be supplied.
           They keyword argument options are described above and affect
           the values returned by 'readline()'.
Construct a new TextFile object.  At least one of 'filename'
           (a string) and 'file' (a file-like object) must be supplied.
           They keyword argument options are described above and affect
           the values returned by 'readline()'.
Construct a new TextFile object . At least one of filename ( a string ) and file ( a file - like object ) must be supplied . They keyword argument options are described above and affect the values returned by readline () .
def __init__(self, filename=None, file=None, **options):
        """Construct a new TextFile object.  At least one of 'filename'
           (a string) and 'file' (a file-like object) must be supplied.
           They keyword argument options are described above and affect
           the values returned by 'readline()'."""
        if filename is None and file is None:
            raise RuntimeError("you must supply either or both of 'filename' and 'file'")

        # set values for all options -- either from client option hash
        # or fallback to default_options
        for opt in self.default_options.keys():
            if opt in options:
                setattr(self, opt, options[opt])
            else:
                setattr(self, opt, self.default_options[opt])

        # sanity check client option hash
        for opt in options.keys():
            if opt not in self.default_options:
                raise KeyError("invalid TextFile option '%s'" % opt)

        if file is None:
            self.open(filename)
        else:
            self.filename = filename
            self.file = file
            self.current_line = 0       # assuming that file is at BOF!

        # 'linebuf' is a stack of lines that will be emptied before we
        # actually read from the file; it's only populated by an
        # 'unreadline()' operation
        self.linebuf = []
def __init__ ( self , filename = None , file = None , * * options ) : if filename is None and file is None : raise RuntimeError ( "you must supply either or both of 'filename' and 'file'" ) # set values for all options -- either from client option hash # or fallback to default_options for opt in self . default_options . keys ( ) : if opt in options : setattr ( self , opt , options [ opt ] ) else : setattr ( self , opt , self . default_options [ opt ] ) # sanity check client option hash for opt in options . keys ( ) : if opt not in self . default_options : raise KeyError ( "invalid TextFile option '%s'" % opt ) if file is None : self . open ( filename ) else : self . filename = filename self . file = file self . current_line = 0 # assuming that file is at BOF! # 'linebuf' is a stack of lines that will be emptied before we # actually read from the file; it's only populated by an # 'unreadline()' operation self . linebuf = [ ]