python:les_modules
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteDernière révisionLes deux révisions suivantes | ||
python:les_modules [2014/01/30 20:45] – [Fabric] root | python:les_modules [2016/10/29 10:31] – [Ctypes] root | ||
---|---|---|---|
Ligne 401: | Ligne 401: | ||
os.system(' | os.system(' | ||
</ | </ | ||
+ | |||
+ | ===== readline ===== | ||
+ | |||
+ | <code python readline.py> | ||
+ | # | ||
+ | |||
+ | import readline, signal | ||
+ | prompt = ' | ||
+ | |||
+ | def signal_handler(signal, | ||
+ | |||
+ | raw_input(prompt) | ||
+ | return | ||
+ | |||
+ | signal.signal(signal.SIGINT, | ||
+ | readline.parse_and_bind(" | ||
+ | |||
+ | class completer: | ||
+ | def __init__(self, | ||
+ | self.tree = tree | ||
+ | |||
+ | def _parser(self, | ||
+ | if search is None: | ||
+ | return [] | ||
+ | elif len(line) == 0: | ||
+ | return [x for x in search] | ||
+ | elif len(line) == 1 and readline.get_line_buffer()[-1] != ' ': | ||
+ | return ['%s ' % x for x in search if x.startswith(line[0])] | ||
+ | else: | ||
+ | return self._parser(line[1: | ||
+ | return [] | ||
+ | |||
+ | def complete(self, | ||
+ | line = readline.get_line_buffer().split() | ||
+ | results = self._parser(line, | ||
+ | return results[state] | ||
+ | |||
+ | tree = { | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }, | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }, | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | }, | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | } | ||
+ | }, | ||
+ | ' | ||
+ | { | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | readline.set_completer(completer(tree).complete) | ||
+ | l = '' | ||
+ | while l != (' | ||
+ | try: | ||
+ | l = raw_input(prompt) | ||
+ | except EOFError: | ||
+ | |||
+ | break | ||
+ | except: | ||
+ | continue | ||
+ | </ | ||
+ | |||
===== Twisted ===== | ===== Twisted ===== | ||
Ligne 428: | Ligne 531: | ||
import ctypes, ctypes.util | import ctypes, ctypes.util | ||
- | ctypes.cdll.LoadLibrary(ctypes.util.find_library(' | + | libc=ctypes.cdll.LoadLibrary(ctypes.util.find_library(' |
libc.printf(" | libc.printf(" | ||
</ | </ |
python/les_modules.txt · Dernière modification : 2017/06/03 13:08 de root