-
Notifications
You must be signed in to change notification settings - Fork 1.8k
String literals
Adrian Sampson edited this page Apr 7, 2018
·
4 revisions
beets is very attached to unicode input and output. So when writing code you should follow these guidelines for usage of string literals in beets source:
-
All outputs to logging module should be marked with
u
. (log.debug/warn/info/etc(u'foo')
-
Arguments to exceptions: Almost always
u
. (raise Exception(u'foo')
) -
print_
and such: Alwaysu
.(print(u'foo')
) -
Methods
__str__()
and__repr__()
should always return native python strings (return 'foo'
) -
URLs and data for HTTP requests: native strings (
'foo'
) -
SQL Statements: native strings (
'foo'
) -
Pieces of filenames: Always
b
, unless it's in some parts of thedestination
method before the path is encoded. (b'foo.mp3'
)
For details and discussion on string and unicode literals see #1887