User Tools

Site Tools


lib_compatibility

====== Differences ====== This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
lib_compatibility [2015/08/19 10:22]
damien created
lib_compatibility [2015/08/20 08:56] (current)
flavio ajouter une precision sur l'incompatibilité des libs
Line 1: Line 1:
-Let's say you have a library that may be called from python 2.x or 3.x, but you don't know which one yet. You have a directory structure thus laid out:+Let's say you have a library that may be called from python 2.x or 3.x, but you don't know which one you'll have to use yet. And obviously let's say there is NO way to make a lib compatible with both (because of metaclasses for example). You have a directory structure thus laid out:
 <​code>​. <​code>​.
 +--libs2x +--libs2x
Line 17: Line 17:
  
 if sys.version_info.major == 3: if sys.version_info.major == 3:
- dir_name = "​libs_3x"​+    ​dir_name = "​libs_3x"​
 elif sys.version_info.major == 2: elif sys.version_info.major == 2:
- dir_name = "​libs_2x"​+    ​dir_name = "​libs_2x"​
 else: else:
- print("​WTF?​!"​)+    raise ImportError
  
 lib_path = os.path.dirname(__file__) # Start from the file and lib_path = os.path.dirname(__file__) # Start from the file and
lib_compatibility.1439979756.txt.gz · Last modified: 2015/08/19 10:22 by damien