All Questions
Tagged with meta-programming python
10 questions with no upvoted or accepted answers
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...