python Programming Glossary: foo.py
Get __name__ of calling function's module in Python http://stackoverflow.com/questions/1095543/get-name-of-calling-functions-module-in-python of calling function's module in Python Suppose myapp foo.py contains def info msg caller_name print ' s s' caller_name msg..
Python: Get list of all classes within current module http://stackoverflow.com/questions/1796180/python-get-list-of-all-classes-within-current-module all of the classes from a module usually something like # foo.py class Foo pass # test.py import inspect import foo for name.. how to get all of the classes from the current module. # foo.py import inspect class Foo pass def print_classes for name obj..
how can i get the executable's current directory in py2exe? http://stackoverflow.com/questions/2292703/how-can-i-get-the-executables-current-directory-in-py2exe go with sys.argv 0 unconditionally. Evidence foo.py # coding ascii import sys os.path print 'sys has frozen ' hasattr.. distutils.core import setup import py2exe setup console 'foo.py' results C junk so py2exe python26 python foo.py sys has frozen.. console 'foo.py' results C junk so py2exe python26 python foo.py sys has frozen False using sys.executable 'C python26' using..
__getattr__ on a module http://stackoverflow.com/questions/2447353/getattr-on-a-module insist but that's generally less useful . E.g. # module foo.py import sys class Foo def funct1 self args code def funct2 self..
Dynamic module import in Python http://stackoverflow.com/questions/301134/dynamic-module-import-in-python __init__.py commands __init__.py command1.py command2.py foo.py bar.py So I want the application to find the available command..
Python Nose Import Error http://stackoverflow.com/questions/3073259/python-nose-import-error Here's the the package file structure . __init__.py . foo.py . tests . __init__.py . test_foo.py foo.py contains def dumb_true.. . __init__.py . foo.py . tests . __init__.py . test_foo.py foo.py contains def dumb_true return True tests test_foo.py.. . __init__.py . foo.py . tests . __init__.py . test_foo.py foo.py contains def dumb_true return True tests test_foo.py contains..
How to properly use relative or absolute imports in Python modules? http://stackoverflow.com/questions/3616952/how-to-properly-use-relative-or-absolute-imports-in-python-modules a sample file importing foo module import foo ... # foo foo.py from . import bar ... if __name__ __main__ pass # foo bar.py.. __main__ pass # foo bar.py a submodule of foo used by foo.py from . import foo ... if __name__ __main__ pass How should I.. the sample code in order to be able to execute all test.py foo.py and bar.py I'm looking for a solution that works with python..
Python - Using __getattribute__ method http://stackoverflow.com/questions/371753/python-using-getattribute-method hell you were in before. Ipython output with code in foo.py In 1 from foo import In 2 d D In 3 d.test Out 3 0.0 In 4 d.test2..
How do I unload (reload) a Python module? http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module restarting the server. What's the best way do do this if foo.py has changed unimport foo How do I do this import foo myfoo foo.Foo..
Redirect stdout to a file in Python? http://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python
Tab completion in Python's raw_input() http://stackoverflow.com/questions/5637124/tab-completion-in-pythons-raw-input ext tab extension extra Enter section name extra foo tab foo.py foo.txt foo Enter section name extra foo tab foo bar.txt foo..
Import a module from a relative path http://stackoverflow.com/questions/279237/import-a-module-from-a-relative-path given its relative path For example if dirFoo contains Foo.py and dirBar and dirBar contains Bar.py how do I import Bar.py.. and dirBar contains Bar.py how do I import Bar.py into Foo.py Here's a visual representation dirFoo Foo.py dirBar Bar.py Foo.. Bar.py into Foo.py Here's a visual representation dirFoo Foo.py dirBar Bar.py Foo wishes to include Bar but restructuring the..
IronPython: EXE compiled using pyc.py cannot import module “os” http://stackoverflow.com/questions/6195781/ironpython-exe-compiled-using-pyc-py-cannot-import-module-os &ldquo os&rdquo I have a simple IronPython script # Foo.py import os def main print Hello if __main__ __name__ main It.. fine and prints Hello if I run it with IronPython as ipy Foo.py Following the instructions given in IronPython how to compile.. this IronPython script to a EXE using ipy pyc.py main Foo.py target exe Executing Foo.exe gives this error Unhandled Exception..
Python: How to run unittest.main() for all source files in a subdirectory? http://stackoverflow.com/questions/644821/python-how-to-run-unittest-main-for-all-source-files-in-a-subdirectory the directory structure dirFoo test.py dirBar __init__.py Foo.py Bar.py To test either Foo.py or Bar.py I would add this at the.. test.py dirBar __init__.py Foo.py Bar.py To test either Foo.py or Bar.py I would add this at the end of the Foo.py and Bar.py.. either Foo.py or Bar.py I would add this at the end of the Foo.py and Bar.py source files if __name__ __main__ unittest.main And..
|