(self, file_name_or_object, name=None)
return self._bound_files[name]
Bind a native file name or object to an internal name.
Bind a native file name or object to an internal name.
Bind a native file name or object to an internal name .
def bind(self, file_name_or_object, name=None):
        """Bind a native file name or object to an internal name."""
        if not name:
            # get unused 7-hexit string
            num_ids = 0x10000000
            for _ in xrange(num_ids):
                name = (b'#%07x' % random.randint(0, num_ids)).upper()
                if name not in self._bound_files:
                    break
            else:
                # unlikely
                logging.error('No internal bound-file names available')
                raise error.BASICError(error.TOO_MANY_FILES)
        elif isinstance(name, text_type):
            name = self._codepage.unicode_to_bytes(name)
        self._bound_files[name] = BoundFile(self, self._codepage, file_name_or_object, name)
        return self._bound_files[name]
def bind ( self , file_name_or_object , name = None ) : if not name : # get unused 7-hexit string num_ids = 0x10000000 for _ in xrange ( num_ids ) : name = ( b'#%07x' % random . randint ( 0 , num_ids ) ) . upper ( ) if name not in self . _bound_files : break else : # unlikely logging . error ( 'No internal bound-file names available' ) raise error . BASICError ( error . TOO_MANY_FILES ) elif isinstance ( name , text_type ) : name = self . _codepage . unicode_to_bytes ( name ) self . _bound_files [ name ] = BoundFile ( self , self . _codepage , file_name_or_object , name ) return self . _bound_files [ name ]