-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python 3 support now complete for units and quantities.
- Loading branch information
1 parent
2542dff
commit aa7af52
Showing
4 changed files
with
29 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys | ||
|
||
def isstr(obj): | ||
return True | ||
|
||
def strrep(obj): | ||
if sys.version_info[0] < 3: | ||
return unicode(obj).encode('utf-8') | ||
return obj.__unicode__() | ||
|
||
class UnicodeMixin(object): | ||
|
||
"""Mixin class to handle defining the proper __str__/__unicode__ | ||
methods in Python 2 or 3.""" | ||
|
||
if sys.version_info[0] >= 3: # Python 3 | ||
def __str__(self): | ||
return self.__unicode__() | ||
else: # Python 2 | ||
def __str__(self): | ||
return self.__unicode__().encode('utf8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters