Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: show workaround for backward compatibility #13985

Merged
merged 1 commit into from
Jul 14, 2019
Merged

Conversation

mattip
Copy link
Member

@mattip mattip commented Jul 14, 2019

Continuation of #13945

Document a workaround for using code to span pre-1.17 versions

@charris charris added this to the 1.17.0 release milestone Jul 14, 2019

.. code-block:: python

func = getattr(rg, 'integers', getattr(rg, 'randint', None))
Copy link
Member

@eric-wieser eric-wieser Jul 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getattr(rg, 'integers', None) or rg.randint would be safer and faster. Frankly I'd encourage the longer more readable form:

try:
    rg_integers = rg.integers
except AttributeError:
    rg_integers = rg.randint

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Eric's last version is an improvement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adopted

@charris
Copy link
Member

charris commented Jul 14, 2019

Not waiting on the CI here, shippable is way behind gobbling up merges.

Thanks Matti.

@charris charris merged commit f6358a9 into numpy:master Jul 14, 2019
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 14, 2019
@charris charris removed this from the 1.17.0 release milestone Jul 14, 2019
@mattip mattip deleted the doc-how branch October 13, 2020 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants