Source code for itertools

vsoler vicente.soler at gmail.com
Wed Sep 1 21:29:52 CEST 2010


On 31 ago, 05:33, Rolando Espinoza La Fuente <dark... at gmail.com>
wrote:
> On Mon, Aug 30, 2010 at 11:06 PM, vsoler <vicente.so... at gmail.com> wrote:
> > On 31 ago, 04:42, Paul Rubin <no.em... at nospam.invalid> wrote:
> >> vsoler <vicente.so... at gmail.com> writes:
> >> > I was expecting an itertools.py file, but I don't see it in your list.
> >> >> ./python3.1-3.1.2+20100829/Modules/itertoolsmodule.c
>
> >> looks promising.  Lots of stdlib modules are written in C for speed or
> >> access to system facilities.
>
> > Lawrence, Paul,
>
> > You seem to be running a utility I am not familiar with. Perhaps this
> > is because I am using Windows, and most likely you are not.
>
> > How could I have found the answer in a windows environment?
>
> Hard question. They are using standard unix utilities.
>
> But you can find the source file of a python module within python:
>
> >>> import itertools
> >>> print(itertools.__file__)
>
> /usr/lib/python2.6/lib-dynload/itertools.so
>
> Yours should point to a windows path. If the file ends with a ".py",
> you can open the file
> with any editor. If ends with ".so" or something else  likely is a
> compiled module in C
> and you should search in the source distribution, not the binary distribution.
>
> Hope it helps.
>
> Regards,
>
> Rolando Espinoza La fuentewww.insophia.com

Thank you Rolando for your contribution.

Followinf your piece of advice I got:

>>> import itertools
>>> print(itertools.__file__)
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    print(itertools.__file__)
AttributeError: 'module' object has no attribute '__file__'
>>>

So, I undestand that the module is written in C.

Vicente Soler



More information about the Python-list mailing list