How to Run a Shell Command from Python and Get The Output?

In Python, often you may want to execute linux command and get the output of the command as string variable. There are multiple ways to execute shell command and get output using Python. A naive way to do that is to execeute the linux command, save the output in file and parse the file. Get… Continue reading How to Run a Shell Command from Python and Get The Output?

Eleven IPython Keyboard Shortcuts to Move Around Easily

Eleven IPython keyboard tips/shortcuts to Move Around Easily. Ctrl-p or up-arrow: Access command history in backward Ctrl-n or down-arrow: Access command history  in forward Ctrl-a: Move cursor to beginning of line Ctrl-e: Move cursor to end of line Ctrl-f: Move cursor forward one character Ctrl-b: Move cursor back one character Ctrl-l: Clear screen Ctrl-r: reverse history… Continue reading Eleven IPython Keyboard Shortcuts to Move Around Easily

3 Ways to Write Text to a File in Python

If you are interested in writing text to a file in Python, there is probably many ways to do it. Here is three ways to write text to a output file in Python.  The first step in writing to a file is create the file object by using the built-in Python command “open”. To create and… Continue reading 3 Ways to Write Text to a File in Python

7 Tips to Play With File Names, Directory Names, and Paths in Python

Python’s OS.path module have a lots of commands/methods that are greatly useful for all things files/directories/paths. Here are seven tips for playing with files, directories, and paths using Python os.path. These commands will help you check if a given path is a directory or not? find given path is a file? check if a file… Continue reading 7 Tips to Play With File Names, Directory Names, and Paths in Python

Mastering Lists in Python Using List Comprehensions

Ever faced the problem of creating a unique lists in Python? or Accessing only specific elements of lists in Python? Python’s “List Comprehensions” offers you the immense power to create and use lists. Here is a brief introduction to understand and getting started on using List Comprehensions in Python. Python’s List Comprehensions Example 1 The… Continue reading Mastering Lists in Python Using List Comprehensions