473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deprecation wrapper

I have a "deprecatio n" wrapper that allows me to do this:

def oldFunc(x,y):
...

def newFunc(x,y):
...

oldFunc = deprecated(oldF unc, newFunc)

It basically wraps the definition of "oldFunc" with a DeprecationWarn ing
and some extra messages for code maintainers, and also prompts them to
look at "newFunc" as the replacement. This way, anyone who calls
oldFunc() will get the warning and messages automatically.

I'd like to expand this concept to classes and values defined in my
modules as well.

So, I'd like a deprecatedClass that would somehow take:

class OldClass:
...

class NewClass:
...

OldClass = deprecatedClass (OldClass, NewClass)

and would similarly give the warning and other messages when someone
tried to instantiate an OldClass object.
And, for general values, I'd like:

OLD_CONSTANT = "old"
NEW_CONSTANT = "new"

OLD_CONSTANT = deprecatedValue (OLD_CONSTANT, NEW_CONSTANT)

so any attempt to use OLD_CONSTANT (or just the first attempt) would
also output the warning and associated messages.
I think that setting it up for classes would just mean making a wrapper
class that generates the warning in its __init__ and then wraps the
instantiation of the old class.

But how can I do something similar for plain values like those constants?
Is there a better way to do this whole thing, in general? Anyone already
have a similar system set up?

Thanks in advance,
-David

--
Presenting:
mediocre nebula.

Jun 20 '06 #1
0 1012

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
4021
by: Robin Becker | last post by:
It seems that the rotor module is being deprecated in 2.3, but there doesn't seem to be an obvious alternative. I'm using it just for obfuscation. It seems we have ssl available in 2.3 for sockets, but there seems no obvious way to use that from python code. Is an alternative to rotor planned? -- Robin Becker
12
6393
by: zhi | last post by:
Really confused, when I use keyword style argument as following: >>> input(prompt="hello") Traceback (most recent call last): File "<pyshell#52>", line 1, in -toplevel- input(prompt="hello") TypeError: input() takes no keyword arguments While the library reference says the function is: input( )
12
4069
by: Egil M?ller | last post by:
Is there any way to create transparent wrapper objects in Python? I thought implementing __getattribute__ on either the wrapper class or its metaclass would do the trick, but it does not work for the built in operators: class Foo(object): class __metaclass__(type): def __getattribute__(self, name): print "Klass", name
7
1259
by: TeamHubbell | last post by:
Hello, I was wondering if anyone has some suggestions on how to deprecate C routines from a n already released API. I would like to be able to do this via the gcc compiler and be warn the end developers of the new routine to use if possible. Thanks,
185
17336
by: Martin Jørgensen | last post by:
Hi, Consider: ------------ char stringinput ..bla. bla. bla. do {
1
1651
by: psreddy71 | last post by:
i am trying to solve deprecation warning problem from past days.can any body help me please ? i am getting deprecation warning at method .can any body compile this program under jdk1.5 and let me know how to solve this problem. thx in advance
4
3192
by: Anoop | last post by:
Hi All, I am getting the following error while trying to use deprecation Please help 'a.b.mpilgrim.z' Traceback (most recent call last): File "<interactive input>", line 1, in ? AttributeError: 'list' object has no attribute 'joinfields'
9
1286
by: david.dynamicconcepts | last post by:
Now that Microsoft has deprecated many of the str.???(...) functions, and an increasing number of development shops and Business Software Development Groups are trying to eliminate these routines (which are easily subject to mis-use). What if any is the intention of the standards commitee for new releasesw of the standard?????
1
2933
by: Gennaro Prota | last post by:
James Kanze wrote: I see. You imply that, in theory, it couldn't be canceled? Or that it would require some long workflow? Yes, I know the etymology (BTW, terms of direct Latin derivation tend to be almost homographs to the Italian ones; and usually the Italian term is also the one used colloquially). But I was
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.