Chinaunix首页 | 论坛 | 博客
  • 博客访问: 217506
  • 博文数量: 261
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2641
  • 用 户 组: 普通用户
  • 注册时间: 2020-08-10 06:35
文章分类
文章存档

2025年(13)

2024年(33)

2023年(86)

2022年(53)

2021年(42)

2020年(34)

我的朋友

分类: Python/Ruby

2025-01-06 09:05:12


057如何删除print函数_dunder_builtins_系统内建模块9 播放 · 0 赞同视频点击可播放视频
[词根溯源]如何删除print函数_dunder_builtins_系统内建模块 回忆上次内容
  • 上次 用到了 下划线
位置
作用
放后面
避免名字冲突
添加图片注释,不超过 140 字(可选)
  • 为什么 很多本地变量
  • 两边 都有 两个下划线
  • __name__
  • __doc__
  • __builtins__

  • 有什么说法吗??????
询问
添加图片注释,不超过 140 字(可选)
  • 双下划线
  • 是 系统建立的
  • 有特殊的含义

  • 去游乐场
  • 问问python本人

说明文档
  • 直接help主题的名字
help("IDENTIFIERS")
  • 查找 标识符的帮助
添加图片注释,不超过 140 字(可选)
  • 两边双下划线
  • 代表 系统定义的标识符
  • 比如__builtins__

添加图片注释,不超过 140 字(可选)
  • 突然发现print函数不在本地
删除
  • 可以删除print函数吗?
del print
  • 无法删除!
添加图片注释,不超过 140 字(可选)
  • 如果我想删除呢?
找到位置 print
  • print是
  • built-in function
  • 内建模块 的 函数

添加图片注释,不超过 140 字(可选)
  • 内建模块 是不是 就是
  • __builtins__ ???????

查看 type(__builtins__)
  • builtins 是 内建模块
  • print会不会在这个模块里?

添加图片注释,不超过 140 字(可选)
  • 如何调用模块中的函数来着?
回忆火星文
添加图片注释,不超过 140 字(可选)
  • 新艺术 是怎么清屏的呢?
  • 使用 系统命令
  • clear

os.system("clear")
  • os 是模块名
  • 后面的点(.) 表示里面的
  • system 是函数名

照猫画虎 __builtins__ __builtins__.print __builtins__.print("Hello world!")
  • 确实找到了!
  • print 就是
  • __builtins__ 模块里的 函数

添加图片注释,不超过 140 字(可选)
  • 能删除吗?
删除 del __builtins__.print print
  • 带着模块名 一起删
添加图片注释,不超过 140 字(可选)
  • 删完了
  • 就真的 连 print 都找不到了!!!????

  • __builtins__
  • 这个系统模块
  • 太重要了!!!
  • 怎么读呢?

dunder来历
  • 两个下划线
  • Double UNDERscore
  • 省略读法 dunder

Dunder (Double UNDERscore) Alias Mark Jackson was the first to suggest dunder as a speech shorthand for double underscores (__) in a reply to a query from Pat Notz. Ned Batchelder later stressed the need for a way of pronouncing __: An awkward thing about programming in Python : there are lots of double underscores. [snip] My problem with the double underscore is that it's hard to say. How do you pronounce init__? "underscore underscore init underscore underscore"? "under under init under under"? Just plain "init" seems to leave out something important. I have a solution: double underscore should be pronounced "dunder". So __init is "dunder init dunder", or just "dunder init".
  • {BANNED}最佳初 是为了 说起来省事
  • 连读 再加 吞字 得到的

对比
  • 在发明 dunder 之前
  • __init__ 要念作 double underscore init
  • 其中的double underscore
  • 有17个字符
  • 发音是6声

  • 而dunder
  • 只有6个字符
  • 发音是2声
  • 简单多了



添加图片注释,不超过 140 字(可选)
  • dunder 意味着 这个变量
  • 系统定义 的!
  • 能删吗?????

删除 del __builtins__ __builtins__
  • __builtins__ 迅速重生
  • 快得就像韭菜

添加图片注释,不超过 140 字(可选)
  • 能把这个__builtins__覆盖了吗?
总结
  • 这次玩的 还是 下划线
位置和数量
作用
一个放后面
避免名字冲突
两个放两边
系统变量
添加图片注释,不超过 140 字(可选)
  • 能把内建模块(builtins)
  • 覆盖掉吗??????

  • 我们下次再说!????
  • 蓝桥->
  • github->
  • gitee->


阅读(46) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~