Most of the stuff you didn ' t know are bitwise operators . Normally and are left and rightshift operators . But in this case it some weird python 2 syntax to redirect the print to a specified stream . is the bitwise and , and is the bitwise or , ~ is bitwise negation . This os . ORDWRos . ONOCTTY looks like multiple applied flags . It is used very similary in more complex regex pattern for example . This is just analog to or . So basically I ' ve been googling around on how to prompt the user for text and then to return asterisk but I couldn ' t find a satisfying answer . I don ' t think that changing the code of a core lib is the way to go . I would recommend you to look into ANSI . b is the escape sequence to move back one position In ' hellobbbbb ' Out ' hellox 08 x 08 x 08 x 08 x 08 ' In print ' hellobbbbb ' In password ' secret ' In print ''. formatpassword , ' b ' lenpassword , '' lenpassword After you have understood how b works it will be easier to write a proper function to do it . prompttoolkit could also be very helpful for that .