Posts

Showing posts from August, 2018

Subprocess_Shutil_Module

###Contents Module -subprocess - replaces os.system and os.spawn Pytest Pytest - Example Test coverage File and Directory Access filecmp — File and Directory Comparisons fileinput — Iterate over lines from multiple input streams Data Compression and Archiving shutil — High-level file operations ---------------------------------------------------------- ###*** Module -subprocess - replaces os.system and os.spawn import subprocess #Arguments meaning stdin, stdout and stderr     specify the executed program's standard input,     standard output and standard error file handles,     values are PIPE, DEVNULL, an existing file descriptor (a positive integer),     an existing file object, and None      stderr can be STDOUT  universal_newlines     if it is False the file objects stdin, stdout and stderr will be opened as binary streams,     and no line ending conversion is done shell ...

Python Syntax

for         - Iterator looping - str, list, set, dict(keys) in, not in  - checking existence, str, list, set, dict(key) ==          - content checking str, list, set, dict [start:end:step]     - slice, str, list L[ : ]  -> creates a copy L[ ::-1 ] -> reverses L[ len(L): ] = Iterator  -> appends I L[ :0 ] = Iterator -> prepends I L[ i:i ] = Iter -> inserts I at i ################################################################################################# list mutable - assignment to slice is possible str immutable tuple immutable set mutable dict mutable +  List-returns a new copy, str- concatenation, number -add +=  List- inplace append, for immutable, expands to s = s + I empty []   list [] ()   tuple tuple() {}   set set() {:}  dict {} conversion methods to List    list() t...

Python_Quick_Datastructure

-------------------------------------------------------------- str - Immutable -------------------------------------------------------------- Create empty string                 s="" or s='' Create string                       s="Hello" or 'Hello' Find length of string               len(s) Does a substring exist              "Hel" in s Compare two string                  s == "Hello" Take each alphabet from string      for e in s:                                         #do some work with e Concatenate two strings             s + "hello (returns new String)              ...