Вторая по частоте future-функция, которую я использовал, это абсолютный импорт
from __future__ import absolute_import
Что она делает?
Изменения, которые вносит эта инъекция описаны в PEP328
Покажу простой пример.
Допустим, есть такой пакет:
/my_package
/__init__.py
/main.py
/string.py
Смотрим код в my_package/main.py
# main.py
import string
Простой пример готов) Вопрос в том, какой модуль импортируется в данном случае? Есть два варианта:
1. модуль в моём пакете my_package.string
2. стандартный модуль string
И вот тут вступает в дело приоритет импортов. В Python2 порядок следующий: помимо иных источников, раньше ищется модуль внутри текущего пакета, а потом в стандартных библиотеках. Таким образом мы импортнём my_package.string.
Но в Python3 это поведение изменилось. Если мы указываем просто имя пакета, то ищется именно такой модуль, игнорируя имена в текущем пакете. Если мы хотим импортнуть именно подмодуль из нашего пакета то, мы должны теперь явно это указывать.
from my_package import string
или относительный импорт, но с указанием пути относительно текущего модуля main
from . import string
Еще одной неоднозначностью меньше 😎
Подробней про импорты здесь:
https://docs.python.org/3/tutorial/modules.html
#2to3#pep#basic
#GitHub#UserScript
🌏ChatGPT 网页增强脚本 —— KeepChatGPT
💡 KeepChatGPT 是一个服务于 ChatGPT 网页版的 UserScript,它可以在一定程度上改善网页版服务的使用体验。
🙅 脚本的亮点是可以解决 ChatGPT 在使用这种诸如 NetworkError when attempting to fetch resource / Something went wrong. If this issue persists please contact us through our help center at help.openai.com / Conversation not found / This content may violate our content policy. If you believe this to be in error, please submit your feedback — your input will aid our research in this area 这几类报错。同时也对聊天中断、频繁刷新等问题起到了缓解。并且能够使用言无不尽功能让 ChatGPT 持续发言,直至它说完全部内容。
🌐 除此之外,KeepChatGPT 还有许多增强体验的功能,由于该项目的 GitHub Readme 写得过于优秀,建议直接前往阅读。你可以使用支持油猴脚本的程序安装脚本来使用它,建议直接前往 GreasyFork 安装。
⚠️ 谷歌应用商店和微软应用商店上的同名拓展不是作者提供的,并且抄袭该项目,特此说明。
Proxy Redirect #Userscript
Redirection userscript for privacy-oriented and open-source proxy #frontends.
Proxy Redirect automatically redirects to instances of privacy-oriented frontends, such as Scribe, Nitter, Libreddit, etc.
This allows more reliable access to available public instances per service, while also helping to distribute traffic more evenly across all instances and avoid performance bottlenecks and rate-limiting.
https://openuserjs.org/scripts/sjehuda/Proxy_Redirect
#javascript#123pan#139_cloud#189_cloud#ali_netdisk#aliyun_drive#aria2#baidu#baidu_netdisk#baidunetdisk#baiduyun#motrix#quark_netdisk#tampermonkey#tampermonkey_script#tampermonkey_userscript#tianyi_netdisk#uc_netdisk#userscript#xunlei_netdisk#yidong_netdisk
LinkSwift is a browser script that helps you quickly get direct download links for files stored on popular Chinese cloud services like Baidu, Alibaba, 123, and others—saving you time and making downloads easier without needing to visit each service’s website separately. It also improves the look of these cloud storage pages and adds extra features, such as support for different download tools and customizable themes. The main benefit is convenience: you can manage and download your cloud files faster, with a nicer interface, all from your browser. Just install the script using a tool like Tampermonkey, and it works on Chrome, Edge, and other major browsers.
https://github.com/hmjz100/LinkSwift