From 26b49f8d01fffb80b124029aaf1ec3f49d56bc2f Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 11 Dec 2018 00:11:49 +0100 Subject: [PATCH] Make the profile_output script usable for Python 2 as well --- scripts/profile_output.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/profile_output.py b/scripts/profile_output.py index 528def6f..27b9e9f5 100755 --- a/scripts/profile_output.py +++ b/scripts/profile_output.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3.6 +# -*- coding: utf-8 -*- """ Profile a piece of Python code with ``profile``. Tries a completion on a certain piece of code. @@ -18,7 +19,11 @@ Options: """ import time -import profile +try: + # For Python 2 + import cProfile as profile +except ImportError: + import profile import pstats from docopt import docopt