Get metadata from installed Python package

To get the metadata information which has been defined in setup.py/setup.cfg, you can simply use a built-in method get_distribution like this:

from pkg_resources import get_distribution
pkg = get_distribution('')

for info in pkg.get_metadata_lines('METADATA'): # Some might need to use `PKG-INFO`
    print(info)

Use `getattr()` to get attributes/methods dynamically

I have a handy script which helps me to handle a lot of things, and the structure looks like this:

/lib
    |- /arguments_handlers
    |---- __init__.py
    |---- crawler.py
    |---- create.py
    |---- delete.py
    |- arguments.py

Continue reading “Use `getattr()` to get attributes/methods dynamically” →

Git commit with gitpython and SSH key

Using Python to commit files to Git is easy, but having a fully CI/CD automation process to setup Git SSH for the Python script is not so easy since you cannot handle any prompt during the installation process.

If you need to use Python programmatically commit files to Git by using headless accounts or even setup CI/CD automation process; this article might be able to help you.
Continue reading “Git commit with gitpython and SSH key” →

Dart or Not Dart? This is the question that’s still too early to tell.

I do hope that we can have a new, strict, well-structured, and well-perform program language which can completely replace JavaScript, and this is why I still put some hope on Dart.

JavaScript is a language which has pretty long history, it has good parts, but also many bad parts. Many JavaScript experts try to teach people how to write JavaScript in a good pattern; unfortunately, there are still many people doesn’t really understand those good patterns.
Continue reading “Dart or Not Dart? This is the question that’s still too early to tell.” →

Python & Twitter OAuth

I always need to rethink again whenever I need to deal with Twitter OAuth, which annoys me a lot. Therefore I decided to put it in here as a simple article, so I can easily find the information I need in the future.

Before testing Twitter OAuth, you will need to create your application in here. If you have any question about creating Twitter application, please follow this good article How to register a Twitter APP in 8 easy steps to create the app step by step.
Continue reading “Python & Twitter OAuth” →