Re: Finding the name of an object's source file

2017-06-06 Thread Gregory Ewing
Matt Wheeler wrote: import importlib, os importlib.import_module(os.path.split.__module__).__file__ '/Users/matt/.pyenv/versions/3.6.0/lib/python3.6/posixpath.py' Or just look the module name up in sys.modules, if we know (as we do here) that the module has already been imported. -- Greg --

Re: Finding the name of an object's source file

2017-06-06 Thread Friedrich Rentsch
On 06/06/2017 03:52 PM, Matt Wheeler wrote: On Tue, 6 Jun 2017 at 11:20 Peter Otten <__pete...@web.de> wrote: import os inspect.getsourcefile(os.path.split) '/usr/lib/python3.4/posixpath.py' And so much more fun than scanning the documentation :) Alternatively, without using inspect, we c

Re: Finding the name of an object's source file

2017-06-06 Thread Matt Wheeler
On Tue, 6 Jun 2017 at 11:20 Peter Otten <__pete...@web.de> wrote: > > >>> import os > >>> inspect.getsourcefile(os.path.split) > '/usr/lib/python3.4/posixpath.py' > > And so much more fun than scanning the documentation :) > Alternatively, without using inspect, we can get around `Object.__module

Re: Finding the name of an object's source file

2017-06-06 Thread Peter Otten
Friedrich Rentsch wrote: > Hi all, > > Developing a project, I have portions that work and should be assembled > into a final program. Some parts don't interconnect when they should, > because of my lack of rigor in managing versions. So in order to get on, > I should next tidy up the mess and th

Finding the name of an object's source file

2017-06-06 Thread Friedrich Rentsch
Hi all, Developing a project, I have portions that work and should be assembled into a final program. Some parts don't interconnect when they should, because of my lack of rigor in managing versions. So in order to get on, I should next tidy up the mess and the way I can think of to do it is t