memes
has same name as its encolising class Memes
92 page_formatter=format_meme_page, whisper=ctx.whisper)
93 await menu.start()
94
95 memes = app_commands.Group( 96 name="memes", description="Interact with memes", guild_ids=[cfg.guild_id])
97
98 @mod_and_up()
logger
has same name as its encolising class Logger
150 ap_logger.addHandler(self.HNDLR)
151 if not args.disable_webhook_logging:
152 ap_logger.addHandler(WebhookLogger())
153 self.logger = logging.Logger(__name__)154 self.logger.setLevel(logging.INFO)
155 self.logger.addHandler(self.HNDLR)
156 if not args.disable_webhook_logging:
tasks
has same name as its encolising class Tasks
52 'default': MongoDBJobStore(database="botty", collection="jobs", host=os.environ.get("DB_CONNECTION_STRING")),
53 }
54
55 self.tasks = AsyncIOScheduler( 56 jobstores=jobstores, executors=executors, job_defaults=job_defaults, event_loop=bot.loop, timezone=utc)
57 self.tasks.start()
58
cases
has same name as its encolising class Cases
3
4class Cases(mongoengine.Document):
5 _id = mongoengine.IntField(required=True)
6 cases = mongoengine.EmbeddedDocumentListField(Case, default=[]) 7 meta = {
8 'db_alias': 'default',
9 'collection': 'cases'
timezones
has same name as its encolising class Timezones
47class Timezones(commands.Cog):
48 timezone_country = {}
49 for countrycode in pytz.country_timezones:
50 timezones = pytz.country_timezones[countrycode] 51 for timezone in timezones:
52 timezone_country[timezone] = countrycode
53
There is a class member with the same name (not considering the case difference) as its enclosing class.
This can cause confusion while reading the code later on keeping a track of what the field represents. It is strongly recommended to provide self-explanatory names so that someone who's reading the code doesn't have to spend time keeping a track of the variable/method names.
class Orange:
'''We mean, the fruit.'''
orange = "#FFA500"
# Other class implementations
def get_orange(self):
return abc
fruit = Orange()
render_to_frontend(fruit.orange) # Rendering a color, but one can get confused with the fruit
render_bg(fruit.get_orange) # Not clear that `get_orange` is returning a color
class Orange:
'''We mean, the fruit.'''
color = "#FFA500"
# Other class implementations
def get_color(self):
return abc
fruit = Orange()
render_to_frontend(fruit.color) # Evident that we are working with color
render_bg(fruit.get_color) # Evident that we are fetching the fruit's color