Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Saturday, June 1, 2013

Python Tip - If you've accidentally deleted your .py files, all is not lost...

Recover .py files using uncompyle

If you've accidentally deleted your .py file, all is not lost. Use uncompyle to recover:

  git clone https://github.com/gstarnberger/uncompyle.git
  cd uncompyle/
  sudo ./setup.py install

  uncompyler.py thank_goodness_this_exists.pyc > recovered_file.py


See Also

Python Tip - Create and detach a child process

Create and detach a child process

Use the following code to create and subsequently detach a child process

  DETACHED_PROCESS = 0x00000008
  pid = subprocess.Popen([sys.executable, "longtask.py"],
                         creationflags=DETACHED_PROCESS)

  pid.poll()  # Returns: None if child still active
              #          returncode otherwise 


In Sym, a complex component will be made up of a parent process and related child processes. 

See Also


Tuesday, May 28, 2013

Useful Python Packages for Sym

List of useful Python Packages

  1. Regular Expressions -- re
    • Very powerful but takes a bit getting used to - Perl hackers should have no problems
  2. Parsing HTML -- lxml | lxml+xpath
    • Install from binaries for Windows platform 
    • lxml expects a clean xml, use regular expressions if your input aren't clean
  3. Logging -- logging  
  4. GUI -- Tkinter | WxPython | Other GUI Toolkits 
  5. JSON-driven GUI --  why? | pytkgen 
  6. JSON schema -- why? | jsonschema | examples | other implementations