Ben Chuanlong Du's Blog

It is never too late to learn.

Hands on the urllib Module in Python

Comments

  1. It is suggested that you use the requests module instead of urllib unless you want to have minimal 3rd-party dependencies.

  2. You have to explicit import urllib.request in order to use it in Python 3. Please refer to https://bugs.python.org/issue36701 for more discussions. This is how Python 3 intends to work generally speaking. Of course, there are a few exceptions such as os.path

Copy Object in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

You can use the copy module to copy objects in Python. Customized coping behavior can be achived by overriding the methods __copy__ (for shallow copy) and __deepcopy__ (for deep copy).

References …

Return a New Object Or Mutate the Existing Object

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Generally speaking, prefer to return a new object rather than mutating the existing object. This is true in most programming languages besides C who seeks for best peformance.

The pandas package …