rasbt/python_reference

%watermark addition.

Carreau opened this issue · 4 comments

FYI, IPython.sys_info() can be of help and give you commit hash or IPython and other stuff.

In [1]: import IPython
In [3]: print(IPython.sys_info())
{'commit_hash': b'4aea4a2',
 'commit_source': 'repository',
 'default_encoding': 'UTF-8',
 'ipython_path': '/Users/bussonniermatthias/ipython/IPython',
 'ipython_version': '3.0.0-dev',
 'os_name': 'posix',
 'platform': 'Darwin-11.4.2-x86_64-i386-64bit',
 'sys_executable': '/usr/local/opt/python3/bin/python3.4',
 'sys_platform': 'darwin',
 'sys_version': '3.4.0 (default, Apr  9 2014, 11:57:22) \n'
                '[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]'}

Thanks, but this is actually the same that I am already displaying right?

The thing is that I don't want to print too much, but only "selected" info. In my use case, I wouldn't find the commit_hash that useful for example. But people are welcome to fork the magic script and make additions :)

You don't show commit hash if it is a dev version of IPython for example, nor encoding which might be problematic on windows and for some benchmark on strings.
I'm just pointing out that it might be easy to get them from IPython.sys_info(). Also using IPython.sys_info() avoid code duplication like your def _get_pyversions(self): ... etc.

There are probably things where we can do a better job so PR welcome if you think we are doing some things wrong :-)

I see, but actually there is not much code duplication via _get_pyversions(self). This is just a wrapper for

            platform.python_implementation(),
            platform.python_version(), 
            IPython.__version__

Yes, sure I was just pointing out that we had similar logic somewhere if you add some of that at a later point ! Thanks.