Chapter 4, Automating Regular Administrative Activities

  1. The readline() method reads one entire line from the file. A trailing newline character is kept in the string. If the size argument is present and non-negative, it is a maximum byte count including the trailing newline, and an incomplete line may be returned.
  2. Reading: cat.
    Creating the new file : touch.
    Deletion of the file : rm.
    List the file in current directory: ls.
  3. Following is the answer:
os.system(“shell_command”)
subprocess.getstatusoutput(“shell_command”)
  1. Following is the answer:
import configparser as config
config.set(section, option, value)
  1. Following is the answer:
       psutil, fabric, salt, asnible, buildbot, shinken
  1. Following is the answer:
input() 
sys.stdin.readline()
  1. Use list.sort() when you want to mutate the list, sorted() when you want a new sorted object back. Use sorted() when you want to sort something that is an iterable, which is not a list yet. For lists, list.sort() is faster than sorted() because it doesn't have to create a copy.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset