Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ffada76d
Kaydet (Commit)
ffada76d
authored
Şub 23, 2008
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add examples to modulefinder docs. Written for GHOP by Josip Dzolonga.
üst
7d009926
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
modulefinder.rst
Doc/library/modulefinder.rst
+62
-0
No files found.
Doc/library/modulefinder.rst
Dosyayı görüntüle @
ffada76d
...
@@ -50,3 +50,65 @@ report of the imported modules will be printed.
...
@@ -50,3 +50,65 @@ report of the imported modules will be printed.
Analyze the contents of the *pathname* file, which must contain Python code.
Analyze the contents of the *pathname* file, which must contain Python code.
.. attribute:: ModuleFinder.modules
A dictionary mapping module names to modules. See :ref:`modulefinder-example`
.. _modulefinder-example:
Example usage of :class:`ModuleFinder`
--------------------------------------
The script that is going to get analyzed later on (bacon.py)::
import re, itertools
try:
import baconhameggs
except ImportError:
pass
try:
import guido.python.ham
except ImportError:
pass
The script that will output the report of bacon.py::
from modulefinder import ModuleFinder
finder = ModuleFinder()
finder.run_script('
bacon
.
py
')
print '
Loaded
modules
:
'
for name, mod in finder.modules.iteritems():
print '
%
s
:
' % name,
print '
,
'.join(mod.globalnames.keys()[:3])
print '
-
'*50
print '
Modules
not
imported
:
'
print '
\
n
'.join(finder.badmodules.iterkeys())
Sample output (may vary depending on the architecture)::
Loaded modules:
_types:
copy_reg: _inverted_registry,_slotnames,__all__
sre_compile: isstring,_sre,_optimize_unicode
_sre:
sre_constants: REPEAT_ONE,makedict,AT_END_LINE
sys:
re: __module__,finditer,_expand
itertools:
__main__: re,itertools,baconhameggs
sre_parse: __getslice__,_PATTERNENDERS,SRE_FLAG_UNICODE
array:
types: __module__,IntType,TypeType
---------------------------------------------------
Modules not imported:
guido.python.ham
baconhameggs
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment