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

Fix FAQ example to use __import__('functools').reduce #85565

Closed
wyz23x2 mannequin opened this issue Jul 25, 2020 · 3 comments
Closed

Fix FAQ example to use __import__('functools').reduce #85565

wyz23x2 mannequin opened this issue Jul 25, 2020 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir

Comments

@wyz23x2
Copy link
Mannequin

wyz23x2 mannequin commented Jul 25, 2020

BPO 41393
Nosy @ericvsmith, @cryvate, @wyz23x2

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-07-25.12:49:19.272>
created_at = <Date 2020-07-25.12:38:04.795>
labels = ['3.8', '3.9', '3.10', '3.7', 'invalid', 'docs']
title = "Fix FAQ example to use __import__('functools').reduce"
updated_at = <Date 2020-07-25.13:29:30.153>
user = 'https://github.com/wyz23x2'

bugs.python.org fields:

activity = <Date 2020-07-25.13:29:30.153>
actor = 'eric.smith'
assignee = 'docs@python'
closed = True
closed_date = <Date 2020-07-25.12:49:19.272>
closer = 'serhiy.storchaka'
components = ['Documentation']
creation = <Date 2020-07-25.12:38:04.795>
creator = 'wyz23x2'
dependencies = []
files = []
hgrepos = []
issue_num = 41393
keywords = []
message_count = 3.0
messages = ['374258', '374259', '374265']
nosy_count = 4.0
nosy_names = ['eric.smith', 'docs@python', 'cryvate', 'wyz23x2']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue41393'
versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

@wyz23x2
Copy link
Mannequin Author

wyz23x2 mannequin commented Jul 25, 2020

https://docs.python.org/3/faq/programming.html#is-it-possible-to-write-obfuscated-one-liners-in-python
https://github.com/python/cpython/blob/3.8/Doc/faq/programming.rst
The 3rd raises a NameError because reduce was moved into functools. __import__('functools').reduce should fix this.

@wyz23x2 wyz23x2 mannequin added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels Jul 25, 2020
@wyz23x2 wyz23x2 mannequin assigned docspython Jul 25, 2020
@wyz23x2 wyz23x2 mannequin added 3.8 only security fixes docs Documentation in the Doc dir 3.9 only security fixes 3.10 only security fixes labels Jul 25, 2020
@wyz23x2 wyz23x2 mannequin assigned docspython Jul 25, 2020
@wyz23x2 wyz23x2 mannequin added the docs Documentation in the Doc dir label Jul 25, 2020
@Cryvate
Copy link
Mannequin

Cryvate mannequin commented Jul 25, 2020

It doesn't raise an error when you run the whole example, it has "from functools import reduce" at the top.

@ericvsmith
Copy link
Member

I agree that the example is okay as-is.

Plus, I can't see us using __import__ in examples. "import" is the preferred way to load modules.

Although now that I think about it, maybe __import__ would fit in with the subject "Is it possible to write obfuscated one-liners in Python?"!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants