[Python-ideas] pep8 clarification, conditional top-level class/function leading newlines

David Blaschke dwblas at gmail.com
Sat Mar 2 22:21:25 CET 2013


I generally use something like (assuming either x or y will always exist)
try:
      import x as value
except ImportError:
      import y as value


class A:
    def foo(self):
        # magic using value

A real world example
try:
    import Tkinter as tk     ## Python 2.x
except ImportError:
    import tkinter as tk     ## Python 3.x



More information about the Python-ideas mailing list