Code Monkey home page Code Monkey logo

magic-python's Introduction

👋 Hello, folks! :

  • 🖥 I'm product developer and technical writer based in Xiamen, China.
  • ✍️ I wrote dev articles on My Blog
  • 🧐 I'm Interested in cloud computing. Recent focus on kubernetes and kubevirt.

🌈 Languages and Tools:

python linux go kubernetes kubevirt docker openstack vuejs

📖 Ebooks

wechat Wechat Official Accounts

  • wechat 搜 “写点代码的明哥”
  • wechat 搜 “Python 编程时光”
  • wechat 搜 “Go 编程时光”

magic-python's People

Contributors

imba-tjd avatar iswbm avatar neutron3529 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magic-python's Issues

为微信引流的行为比较ex

rt,我还以为就其它社交平台给的网盘里压缩包有密码和二维码,结果连release给的压缩包也是,扫码进去吧,还说什么取关过,得加微信好友才行,就这?挺反感的就是

1.15中的shebang

所以当我在 /usr/local/sbin 下创建一个名字也为 python 的可执行文件时,就会执行 /usr/bin/python 了。

在/usr/local/sbin下创建名为python的可执行文件,执行的不应该是/usr/local/sbin/python吗?

示例不严谨

第二节,end的使用方法,你的示例中不管那种都必被if或者else捕获,然后直接return,压根就走不到end的地方,我没有亲自实验,但是没报错不能说明这个东西有用,只能证明这个东西没有报错,请考虑一个严谨的例子。不然怕是误人误己

numba 示例代码报错

http://magic.iswbm.com/zh/latest/c07/c07_05.html#id1

python 3.8.5 32bit , numba 0.52.0

from numba import jit
import time


@jit
def foo(x, y):
    tt = time.time()
    s = 0
    for i in range(x, y):
        s += i
    print("Time used: {} sec".format(time.time() - tt))
    return s


print(foo(1, 100000000))
c:\Users\wuyudi\Desktop\新建 Python File (3).py:5: NumbaWarning: 
Compilation is falling back to object mode WITH looplifting enabled because Function "foo" failed type inference due to: Unknown attribute 'time' of type Module(<module 'time' (built-in)>)

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

During: typing of get attribute at c:\Users\wuyudi\Desktop\新建 Python File (3).py (7)

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  @jit
c:\Users\wuyudi\Desktop\新建 Python File (3).py:5: NumbaWarning: 
Compilation is falling back to object mode WITHOUT looplifting enabled because Function "foo" failed type inference due to: Cannot determine Numba type of <class 'numba.core.dispatcher.LiftedLoop'>

File "Desktop\新建 Python File (3).py", line 9:
def foo(x, y):
    <source elided>
    s = 0
    for i in range(x, y):
    ^

  @jit
D:\Program Files\Python3.8.5\lib\site-packages\numba\core\object_mode_passes.py:151: NumbaWarning: Function "foo" was compiled in object mode without forceobj=True, but has lifted loops.

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  warnings.warn(errors.NumbaWarning(warn_msg,
D:\Program Files\Python3.8.5\lib\site-packages\numba\core\object_mode_passes.py:161: NumbaDeprecationWarning: 
Fall-back from the nopython compilation path to the object mode compilation path has been detected, this is deprecated behaviour.

For more information visit https://numba.pydata.org/numba-doc/latest/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit

File "Desktop\新建 Python File (3).py", line 7:
def foo(x, y):
    tt = time.time()
    ^

  warnings.warn(errors.NumbaDeprecationWarning(msg,
Time used: 0.12804293632507324 sec
887459712

中英文搜索

感谢分享,请问Sphinx中英文搜索在conf.py中如何设置呢?

3.11节小问题

3.9.2下,io.open和open应该是一个函数,os.open才应该是底层的文件I/O流

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> (open1:=open) is (open2:=os.open)
False
>>> import io
>>> (open3:=open) is (open3:=io.open)
True

魔法冷知识中的几个问题

10.哪些情况下不需要续行符 中:

在多行文本注释中,续行符也是可以不写的,但是会变成\n。

text = '''talk is cheap, show me the code.'''

输出:'talk is cheap,\nshow me the code.'

11.用户无感知的小整数池

在同一行里,同时给两个变量赋同一值时,结果依然为False。

a = 257; b = 257 a is b

输出:False

12.神器的intern机制

如果一个字符串长度超过20个字符,不启动intern机制,这个数字好像不是20

s1 = "a"*100 s2 = "a"*100 s1 is s2

输出:True

s1 = "a"*10001 s2 = "a"*10001 s1 is s2

输出:False

5.6 中的简化臃肿代码可以使用海象运算符

def read_from_file(filename: str, block_size: int = 1024 * 8) -> iter:
    with open(filename, "r") as fp:
        while chunk := fp.read(block_size):
            yield chunk

使用 Python3.8 中的海象运算符可以使函数更加易读。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.