-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpy3.py
39 lines (34 loc) · 1.14 KB
/
py3.py
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
31
32
33
34
35
36
37
38
39
# sdobrev 2011
'using same code for python2 and python3'
import sys
v3 = sys.version_info[0]>=3
if v3:
from collections import OrderedDict as dictOrder
import collections
try: callable = callable #gone in 3.2, back in 3.3 , moved out of __builtin__ in 3.10
except AttributeError:
def callable(x): return isinstance( x, collections.Callable)
unicode=str
basestring=str
file=open
#obsolete modules
#dictOrder = collections.OrderedDict
#setOrder = ?
#assignment_order: use metaclass.__prepare__
#diff = difflib
#module.import_fullname ~= import_lib.import_module
else:
import __builtin__
basestring= __builtin__.basestring
unicode = __builtin__.unicode
file = __builtin__.file
try:
from collections import OrderedDict as dictOrder
except:
from dictOrder import dictOrder
#from __future__ import print_function, unicode_literals
def prn( *a, **kargs):
stderr = use_stderr or 'use_stderr' in kargs or 'stderr' in kargs
o = stderr and sys.stderr or sys.stdout
o.write( ' '.join( unicode(x) for x in a) + '\n')
# vim:ts=4:sw=4:expandtab