Help On file IO
Bengt Richter
bokr at oz.net
Wed Jul 24 20:09:10 EDT 2002
On Tue, 23 Jul 2002 18:13:16 +0530, "jayant kawadkar" <jayantkawadkar at hotmail.com> wrote:
>
> Hello ,
>
> I want a help on File IO ,as I 'm new to Python langauge.
> As I want to use the API :
>
> char* PyModule_GetFilename(PyObject *module)
>
> in my python programm
>
> What should I import for that I can use this .
>
> Now it is giving the error that:
>
> PyModule_GetFilename is not defined.
To be unambiguous, it's best to copy an interactive example
showing the error happening, and paste it into your post.
Plz help the helpers ;-)
>
>
> Plz help ....
>
That is getting the __file__ attribute of a module, it it exists
(which it will if the module was imported from a file, not built-in, etc.)
Example in Python source (or are you writing a C extension?)
>>> import urllib
>>> urllib.__file__
'D:\\python22\\lib\\urllib.pyc'
>>> import math
>>> math.__file__
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute '__file__'
>>> math
<module 'math' (built-in)>
>>> urllib
<module 'urllib' from 'D:\python22\lib\urllib.pyc'>
Regards,
Bengt Richter
More information about the Python-list
mailing list