blob: ec364c3b14f06f2338047e9f912c30ec61b4a8cd (
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
29
30
|
# -*- 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'):
'''custom implementation of the 'open' builtin, using the codecs module'''
try:
return codecs.open(filename, mode=mode, encoding=encoding)
except:
return codecs.open(filename, mode=mode, encoding='iso-8859-15')
|