Hello, I have a problem with calling a staticmethod from another staticmethod when I try use dictionary {} to handle.
My code is very basic, but in the future I will add many other static method:
# -*- coding: utf-8 -*-
import sys
class DateFormat():
"""Class to format and translate date to polish"""
labels = {
'monday' : u'poniedziałek',
'tuesday' : u'wtorek',
'wenesday' : u'środa',
'thursday' : u'czwartek',
'friday' : u'piątek',
'saturday' : u'sobota',
'sunday' : u'niedziela',
}
@staticmethod
def small(date_string):
return date_string.lower()
# I know this is very simple example
@staticmethod
def big(date_string):
return date_string.upper()
# handler to format function
filters = {
'small' : small,
'big' : big,
}
@staticmethod
def get_date(label, *args):
try:
new_format = DateFormat.labels[label]
except:
return new_format
for format in args:
print ('format:' + str(format))
new_format = DateFormat.filters[format](new_format)
return new_format
Now when I try use:
translate = DateFormat.get_date('friday')
I get correct answer: 'piątek'
But when I try use this method with some filter I get incorrect answer:
translate = DateFormat.get_date('friday', 'big')
I get: TypeError: 'staticmethod' object is not callable, but I don't know why?