[vtk-developers] Handling deprecated methods in Python.

Andrew Maclean andrew.amaclean at gmail.com
Thu Sep 21 18:27:45 EDT 2017


Ok, thanks.

On Thu, Sep 21, 2017 at 10:58 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> Ah, I think that I misunderstood.  You're specifically talking about how
> to change the VTK examples?
>
> In your sample code, if a VTK method has merely been deprecated, then the
> exception won't be triggered (unless VTK was configured with
> VTK_LEGACY_REMOVE.)  So you would still get the deprecation warning popping
> up in the dialog box.
>
>  - David
>
> On Wed, Sep 20, 2017 at 11:38 PM, Andrew Maclean <
> andrew.amaclean at gmail.com> wrote:
>
>> I know that they already print a warning but I wanted those using older
>> versions of VTK to note that the change is coming up.
>>
>> Also often when running tests the warning is displayed very briefly. For
>> example when using *vtk.test.Testing* I want to basically just use
>> *vtk.vtkOutputWindow()* for important messages and still alert users to
>> the future change if they are running old versions of VTK by reading the
>> code or perhaps printing to the console.
>> I hope this makes sense!
>>
>> On Thu, Sep 21, 2017 at 3:17 PM, David Gobbi <david.gobbi at gmail.com>
>> wrote:
>>
>>> Hi Andrew,
>>>
>>> Deprecated methods already print a warning if they are declared with
>>> VTK_LEGACY().  Is there a reason that we would want the methods to live
>>> longer in Python than they do in C++?
>>>
>>>  - David
>>>
>>> On Wed, Sep 20, 2017 at 5:55 PM, Andrew Maclean <
>>> andrew.amaclean at gmail.com> wrote:
>>>
>>>> What is the best way to handle deprecated methods?
>>>>
>>>> I'm thinking of doing this:
>>>>
>>>> try:
>>>>     windowToImageFilter.SetScale(1)
>>>> except NameError:
>>>>     print('windowToImageFilter.SetMagnification() is deeprecated in VTK8.1')
>>>>     windowToImageFilter.SetMagnification(1)
>>>>
>>>> The thinking here is that if a deprecated method is ultimately removed,
>>>> this will still work.
>>>> ​Any better ideas?​
>>>>
>>>
>>>
>>
>>
>> --
>> ___________________________________________
>> Andrew J. P. Maclean
>>
>> ___________________________________________
>>
>
>


-- 
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20170922/82a40b67/attachment.html>


More information about the vtk-developers mailing list