Skip to main content

Home/ Python Programming/ Group items tagged except

Rss Feed Group items tagged

dshekhar17

Python Multiple Exception Handling (Try-Except) | Hack The Developer - 0 views

  •  
    Multiple Exception Handling in Python
reckoner reckoner

Cross platform way of finding number of processors on a machine? - comp.lang.python | G... - 0 views

  • > Is there a way to find the number of processors on a machine (on linux/ > windows/macos/cygwin) using python code (using the same code/cross > platform code)? From processing <http://cheeseshop.python.org/pypi/processing/0.34> : def cpuCount():     '''     Returns the number of CPUs in the system     '''     if sys.platform == 'win32':         try:             num = int(os.environ['NUMBER_OF_PROCESSORS'])         except (ValueError, KeyError):             pass     elif sys.platform == 'darwin':         try:             num = int(os.popen('sysctl -n hw.ncpu').read())         except ValueError:             pass     else:         try:             num = os.sysconf('SC_NPROCESSORS_ONLN')         except (ValueError, OSError, AttributeError):             pass     if num >= 1:         return num     else:         raise NotImplementedError --
dshekhar17

Python Custom Exception with Example | Hack The Developer - 0 views

  •  
    Create custom error in python
reckoner reckoner

Kill process based on window name (win32) - 0 views

  • Re: Kill process based on window name (win32) Thank you Roger. Your advice did the trick. For anyone interested, the basic code to terminate a process (politely) would be something like this (hwnd is retrieved using win32gui.EnumerateWindows): # Get the window's process id's t, p = win32process.GetWindowThreadProcessId(hwnd) # Ask window nicely to close win32gui.PostMessage(hwnd, win32con.WM_CLOSE, 0, 0) # Allow some time for app to close time.sleep(10) # If app didn't close, force close try: handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, 0, p) if handle: win32api.TerminateProcess(handle,0) win32api.CloseHandle(handle) except: pass:
reckoner reckoner

SendKeys - 0 views

  • SendKeys is a Python module for Windows (R) which can be used to send one or more keystrokes or keystroke combinations to the active window. SendKeys exports 1 function, SendKeys, and 1 exception, KeySe
reckoner reckoner

python_match.vim - Extend the % motion and define g%, [%, and ]% motions for Python fil... - 0 views

  •  
    This script redefines the % motion so that (in addition to its usual behavior) it cycles through if/elif/else, try/except/catch, for/continue/break, and while/continue/break structures. The script also defines g% to cycle in the opposite direction. Two ot
reckoner reckoner

Learning Python, Linux, Java, Ruby and more with Tutorial Videos - 0 views

  •  
    Aimed at Python Beginner Programmers, this fully-worked series builds a complete application that utilises a User Interface, the comma-separated-values (csv) module, reads and writes files, handles exceptions and gives useful error messages, uses test-dri
reckoner reckoner

Python Patterns - Implementing Graphs - 0 views

  • Few programming languages provide direct support for graphs as a data type, and Python is no exception. However, graphs are easily built out of lists and dictionaries. For instance, here's a simple graph (I can't use drawings in these columns, so I write down the graph's arcs):
anonymous

Intermediate and Advanced Software Carpentry in Python - 4 views

  • try: import psyco psyco.full() except ImportError: pass
  • >>> def simple_cache(fn): ... cache = {} ... ... def new_fn(n): ... if n in cache: ... print 'FOUND IN CACHE; RETURNING' ... return cache[n] ... ... # otherwise, call function & record value ... val = fn(n) ... cache[n] = val ... return val ... ... return new_fn
1 - 11 of 11
Showing 20 items per page