multi line string formatting in python

One way to make multi-line literal strings look good is to use a backslash to escape the newline, like this: output However, PEP-008 discourages backslash usage like that. It’s too fragile: if there’s a space between the backslash and the newline then the newline won’t get escaped, and the backslash will get printed. A more … Read more

What __init__ and self do in Python?

In this code: … the self variable represents the instance of the object itself. Most object-oriented languages pass this as a hidden parameter to the methods defined on an object; Python does not. You have to declare it explicitly. When you create an instance of the A class and call its methods, it will be passed automatically, as in … Read more

How do I undo ‘git add’ before commit?

You can undo git add before commit with which will remove it from the current index (the “about to be committed” list) without changing anything else. You can use without any file name to unstage all due changes. This can come in handy when there are too many files to be listed one by one in a … Read more