473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Deprecation wrapper

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

def oldFunc(x,y):
...

def newFunc(x,y):
...

oldFunc = deprecated(oldFunc, newFunc)

It basically wraps the definition of "oldFunc" with a DeprecationWarning
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 992

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

Similar topics

46
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,...
12
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")...
12
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...
7
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...
185
by: Martin Jørgensen | last post by:
Hi, Consider: ------------ char stringinput ..bla. bla. bla. do {
1
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...
4
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 ?...
9
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.