Skip to main content

All Questions

10 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
891 views

Writing a metaclass to ensure a class is thread-safe

Python allows the creation of classes to be modified via metaclasses. They can perform all sorts of operations that might appear to be magical to languages that do not have the capability. The goal of ...
Noctis Skytower's user avatar
5 votes
0 answers
715 views

Implement OO interfaces in Python

Edit: Whoops! I just remembered there's already an long-lived package for this, zope.interface. I'd like a review all the same. This is a proof-of-concept ...
shadowtalker's user avatar
4 votes
0 answers
102 views

Inherit docstrings from specified parent

I was recently working on some python where I was working with multiple inheritance and mixins and stuff like that, and I wanted to inherit docstrings for specific functions, from specific parents (...
Andrew's user avatar
  • 61
4 votes
0 answers
317 views

Python breakpoints in Vim (Vimscript)

I recently decided that putting strategically placed print statements scattered about my python programs to debug was getting to be a little messy. I had thought ...
Jebby's user avatar
  • 261
3 votes
0 answers
83 views

Metaclass to run a __first__ method for the first instantiation of a class

I had an idea for a __first__ special method for a class. It would be run after __new__ and before ...
13ros27's user avatar
  • 390
3 votes
0 answers
151 views

Cumulative profiler for a function

I have created a cumulative profiler, meaning it runs a function several times in a row and prints the cumulative profiler results. it's python >= 3.6 specific, but you can remove ...
moshevi's user avatar
  • 270
3 votes
1 answer
145 views

config files for different development environments (Production, Dev, Testing)

I am following a guide that specifies how to manage different configurations (DB_URI, LOGGER_NAME, etc...) per development environments. I create a config module ...
moshevi's user avatar
  • 270
2 votes
0 answers
2k views

Making a default value a property

I recently asked a question on StackOverflow, looking for a way to more easily turn a class attribute into a @property, but only if no other value has been provided ...
Tobias Kienzler's user avatar
1 vote
0 answers
84 views

Using metaclass to decorate derived classes to be `attrs` classes

I am currently developing a framework to facilitate writing controller programs for scientific instruments. I use attrs extensively in the internal parts of the ...
Çağlar Kutlu's user avatar
1 vote
0 answers
1k views

Marking a class as final or sealing a class

Which of these metaclasses should be preferred, and is there room for improvement? Some people are not familiar with the philosophies that come with working in Python and have a desire embedded in ...
Noctis Skytower's user avatar