I just want to address some confusion first. __file__ is not a wildcard it is an attribute. Double underscore attributes and methods are considered to be "special" by convention and serve a special purpose.
http://docs.python.org/reference/datamodel.html shows many of the special methods and attributes, if not all of them.
In this case __file__ is an attribute of a module (a module object). In Python a .py file is a module. So import amodule will have an attribute of __file__ which means different things under difference circumstances.
Taken from the docs:
__file__ is the pathname of the file from which the module was loaded, if it was loaded from a file. The __file__ attribute is not present
for C modules that are statically linked into the interpreter; for
extension modules loaded dynamically from a shared library, it is the
pathname of the shared library file.
In your case the module is accessing it's own __file__ attribute in the global namespace.
To see this in action try:
# file: test.py
print globals()
print __file__
And run:
python test.py
{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__file__':
'test_print__file__.py', '__doc__': None, '__package__': None}
test_print__file__.py