1

Where does the text that is invoked by print random.random.__doc__ live?

FWIW, I've read the docs page: https://docs.python.org/2/library/random.html

and understand the interval notation and help()

but reading through C:\Python27\Lib\random.py

I don't find the doc string: random() -> x in the interval [0, 1).

Where is the file this text is printed from?

BorrajaX's answer made me think it might be in os.py, but I couldn't even find urandom in os.py and after reading this:

https://docs.python.org/2/library/os.html#os.urandom

I figure that os.py isn't the place to look.

Community
  • 1
  • 1
MmmHmm
  • 3,435
  • 2
  • 27
  • 49
  • 2
    https://hg.python.org/cpython/file/tip/Modules/_randommodule.c#l418 – jonrsharpe May 21 '16 at 21:05
  • @jonrsharpe - I know nothing of cpython. Does this file live somewhere in C:\Python27 ? – MmmHmm May 24 '16 at 01:17
  • I think the structure of that folder should be the same as of the repo, so check C:\Python27\Modules – jonrsharpe May 24 '16 at 09:10
  • win7... no C:\Python27\Modules :\ I've access to a Linux OS and will check there. This link has some useful info: http://stackoverflow.com/questions/18857355/where-are-math-py-and-sys-py – MmmHmm May 25 '16 at 03:28
  • @jonrsharpe, well, I've looked on an Ubuntu system to no avail in usr/lib/python2.7. Found the 2.7.py scripts but no cpython and no Modules... ? – MmmHmm May 30 '16 at 05:42
  • Then I guess you only have the compiled code locally, not the source. – jonrsharpe May 30 '16 at 08:22
  • thanks @jonrsharpe - this was also helpful: https://docs.python.org/2/faq/library.html#where-is-the-math-py-socket-py-regex-py-etc-source-file – MmmHmm May 31 '16 at 00:55

1 Answers1

1

per @jonrsharpe: Modules/_randommodule.c https://hg.python.org/cpython/file/tip/Modules/_randommodule.c#l418

This was also helpful: https://docs.python.org/2/faq/library.html#where-is-the-math-py-socket-py-regex-py-etc-source-file

on my win7 lappy, putting this in the powershell:

PS C:\Users\patrick> Get-ChildItem -Path C:\ -Filter *.c -Recurse

resulted in only *.c files associated with ffmpeg...

Slapping this in the python shell per the docs url:

>>> import sys
>>> print sys.builtin_module_names

I get this:

('__builtin__', '__main__', ... '_random',...)

MmmHmm
  • 3,435
  • 2
  • 27
  • 49