I have a Runtime Warning when I use __name__ variable in my script
python, python-2.7, ubuntu-12.04
Solution
You should not set `__name__` in your script; Python already sets it and relies on the value for other purposes such as importing. The `__name__` value of a python script or module can be changed but you need to know what you are doing and understand Python's internals before you should attempt to do so.
Don't set double underscore variables in general even. They are reserved for Python use only; only set them when they are documented as settable, such as `__all__` in a module.
See the Python data model documentation for an overview of what double-underscore names (dunder names) are currently in use.
Problem
I tried to use `___name__` at the beginning of my python script: ``` #!/usr/bin/python # Comments... # blabla # __name__="cigarline_by_pos.py" __synopsis__ = "cigarline_by_pos.py | INPUT_BAM_FILE --output OUTPUT_FILE [--output OUTPUT_FILE_R2 --readsplit]" __example__ = "cigarline_by_pos.py hg18.bam --output hg18_read1.csv --output hg18_read2.csv --readsplit" __date__ = "05/2013" __authors__ = "Frederic Escudie & Antoine Leleu" __keywords__ = "SAM Alignment" __description__ = "Sum by position the status of reads. This provides for example the number of reads that have a mismatch at first base." __version__ = '2.3.1' import argparse,re,sys the rest of the code... ``` but then Python prints a warning: ``` cigarline_by_pos.py:29: RuntimeWarning: Parent module 'cigarline_by_pos' not found while handling absolute import import argparse,re,sys ``` and I have no idea of what it could come from. I just know that if I remove the line with `___name__` my script works, but I want this variable. Can somebody help me?