If you have formatted code block with proper indentation and want to test it by copying and pasting on a python interpreter, you will be frustrated at Python for complaining at you. iPython offers great solutions coding with Python and for copying and pasting the code on the terminal. One useful command in iPython to […]
Python
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 […]
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 […]
How to Sort Lists in-place in Python?
Let us starting simple and start with easy sort. Python has two sort functions; one function that sorts a list in-place and the other sort function “sorted” that creates a new sorted list. In this post, we will see examples of “in-place” sorting. Python’s in-place sorting As the name suggests the in-place sorting replaces the […]
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 […]