我尝试在python脚本的开头使用___name__
:
#!/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...
但是Python打印了一个警告:
cigarline_by_pos.py:29: RuntimeWarning: Parent module 'cigarline_by_pos' not found while handling absolute import
import argparse,re,sys
我也不知道这是怎么回事。你知道吗
我只知道,如果我删除带有___name__
的行,我的脚本可以工作,但我需要这个变量。你知道吗
有人能帮我吗?你知道吗
您不应该在脚本中设置
__name__
;Python已经设置了它,并且依赖该值用于其他目的,例如导入。python脚本或模块的__name__
值可以更改,但您需要知道自己在做什么,并且在尝试这样做之前了解python的内部结构。你知道吗通常不要设置双下划线变量甚至。它们只保留给Python使用;只有当它们被记录为可设置时才设置它们,例如模块中的
__all__
。你知道吗请参阅Python data model documentation,了解当前使用的双下划线名称(dunder名称)的概述。你知道吗
相关问题 更多 >
编程相关推荐