#NEWLINE# def dictToKW( d ) : #NEWLINE# #INDENT# out = [ ] #NEWLINE# items = list ( d . items ( ) ) #NEWLINE# items . sort ( ) #NEWLINE# for ( k , v ) in items : #NEWLINE# #INDENT# if ( not isinstance ( k , str ) ) : #NEWLINE# #INDENT# raise NonFormattableDict ( ( "%r ain't a string" % k ) ) #NEWLINE# #UNINDENT# if ( not r . match ( k ) ) : #NEWLINE# #INDENT# raise NonFormattableDict ( ( "%r ain't an identifier" % k ) ) #NEWLINE# #UNINDENT# out . append ( ( '\n\x00%s=%s,' % ( k , prettify ( v ) ) ) ) #NEWLINE# #UNINDENT# return '' . join ( out )