other options are selected in configuration module assignments since it' impossible to predict all possible use case scenariospyedit takes liberal approachit supports all conceivable modesand allows the way it obtains file encodings to be heavily tailored by users in the package' own textconfig module it attempts one encoding name source after anotherif enabled in textconfiguntil it finds an encoding that works this aims to provide maximum flexibility in the face of an uncertain unicode world for examplesubject to settings in the configuration filesaves reuse the encoding used for the file when it was opened or initially savedif known both new files begun from scratch (with new or manual text insertsand files opened in binary mode as last resort have no known encoding until savedbut files previously opened as text do also subject to configuration file settingswe may prompt users for an encoding on save as (and possibly savebecause they may have preference for new files they create we also may prompt when opening an existing filebecause this requires its current encodingalthough the user may not always know what this is ( files fetched over the internet)the user may wish to provide it in others rather than choosing course of action in such caseswe rely on user configuration all of this is really relevant only to pyedit clients that request an initial file load or allow files to be opened and saved in the gui because content can be inserted as str or bytesclients can always open and read input files themselves prior to creating text editor object and insert the text manually for viewing moreoverclients can fetch content manually and save in any fashion preferred such manual approach might prove useful if pyedit' polices are undesirable for given context since the text widget always returns content as strthe rest of this program is unaffected by the data type of text inserted keep in mind that these policies are still subject to the unicode support and constraints of the underlying tk gui toolkitas well as python' tkinter interface to it although pyedit allows text to be loaded and saved in arbitrary unicode encodingsit cannot guarantee that the gui library will display such text as you wish that iseven if we get the unicode story right on the python side of the fencewe're still at the mercy of other software layers which are beyond the scope of this book tk seems to be robust across wide range of character sets if we pass it already decoded python str unicode strings (see the internationalization support in ' pymailgui for samples)but your mileage might vary unicode options and choices also keep in mind that the unicode policies adopted in pyedit reflect the use cases of its sole current userand have not been broadly tested for ergonomics and generalityas book examplethis doesn' enjoy the built-in test environment of open source projects other schemes and source orderings might work welltooand it' impossible to guess the preferences of every user in every context for instance complete gui programs