Python Class Static Variable and Method

Jul 3, 2019
class SheetCol:    INDEX = 'A'    SYMBOL = 'B'    PRICE = 'C'    QUANTITY = 'D'    @staticmethod    def to_index0(char):        return ord(char) - 65

Usage

indexCol = SheetCol.to_index0(SheetCol.INDEX)   # A=0symbolCol = SheetCol.to_index0(SheetCol.SYMBOL) # B=1

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.