blob: aa45207206115c9cabd83b266ed7fba072e95e86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# -*- coding: utf-8 -*-
"""
compat.py
~~~~~~~~~
This module implements some helper function to compatibility with
Python 3k.
:copyright: (c) 2010 by Rafael Goncalves Martins
:license: GPL-2, see LICENSE for more details.
"""
__all__ = [
'py3k',
'open',
]
import codecs
import sys
py3k = sys.version_info >= (3, 0)
def open(filename, mode='r', encoding='utf-8'):
try:
return codecs.open(filename, mode=mode, encoding=encoding)
except:
return codecs.open(filename, mode=mode, encoding='iso-8859-15')
|