Skip to main content
Planned maintenance impacting Stack Overflow and all Stack Exchange sites is scheduled for Monday, September 16, 2024, 5:00 PM-10:00 PM EDT (Monday, September 16, 21:00 UTC- Tuesday, September 17, 2:00 UTC). The email/password authentication method will be unavailable for logging in and registering. Read more here

Questions tagged [decorator-pattern]

Filter by
Sorted by
Tagged with
4 votes
1 answer
54 views

role_required decorator for FastAPI route

Disclaimer: It's been quite a long time since I asked questions here, and also I am a complete novice in FastAPI. I am playing with FastAPI authorization and wondering how can I protect my routes from ...
John's user avatar
  • 217
5 votes
3 answers
648 views

Password checker using Decorator Pattern

I'm currently trying a Password checker for password in Decorator Pattern, which will point out what the current password missing to be a strong password (my example will check for 8 characters, at ...
DEF ABC's user avatar
  • 53
2 votes
0 answers
322 views

Decorator to log function calls and return values

I want to write a decorator in Python 3.11 that adds some basic logging to functions. I want to use the decorator without any keyword arguments: @add_logging In ...
uli's user avatar
  • 21
1 vote
1 answer
387 views

Protecting functions from empty DataFrames

Pandas likes to throw cryptic errors when you feed its functions with empty DataFrames saying nothing that would help you to identify the root cause. In order to ...
t3chb0t's user avatar
  • 44.3k
3 votes
1 answer
62 views

Cancelling function execution with a ContinuationError

Although throwing excptions for control flow is a controversial topic there are some quite popular examples of using this anti-pattern like C#'s async routines throwing the ...
t3chb0t's user avatar
  • 44.3k
5 votes
1 answer
238 views

decorator to execute sqlite statement

I'd like to wrap all my sqlite statement functions with a decorator which collects the statement and the lists of values I will inject in place of placeholders in my statement (to avoid sql injection)....
FTG's user avatar
  • 165
1 vote
0 answers
70 views

Check that inputs are valid dates

I have a method in a class that accepts either a datetime or string parameter. It is shown in the last code block (I didn't include the class). A little background is that I am defining a wrapper ...
Travis DePriest's user avatar
1 vote
0 answers
72 views

Using a decorator for init in Python3+Pyside6, to avoid writing boilerplate code [closed]

I'm building a GUI application with Python3+Pyside6 and have many QDialog classes that are similar, and i was looking for a way to avoid having to rewrite the same ...
sunyata's user avatar
  • 111
5 votes
0 answers
62 views

Message-free flow-oriented logger

Today, I've got a small FlowLogger for you to review. The idea is not to log pure messages, but focus on the flow of the app that might contain such items as: <...
t3chb0t's user avatar
  • 44.3k
0 votes
1 answer
329 views

Decorator Pattern with member functions

Motivation: without SaveDecorator, we would have to write: ...
prestokeys's user avatar
  • 1,391