看板 Python 關於我們 聯絡資訊
大家好 小弟最近正在閱讀 python程式的原始碼 發現沒有遇過的規則 Q1:def __init__(self, data: bytes): 請問 data:bytes這是表達什麼意思? Q2: def __repr__(self) -> str: 為什麼一個func可以透過指標(? 指向一個str? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.17.132.135 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1474462446.A.029.html
crazycy: 應該是type hints?09/21 21:11
crazycy: A1: data的型態是bytes09/21 21:12
crazycy: A2: 這個func的return值是str09/21 21:13
原來是python3的規則 謝謝回覆
mikapauli: cython?
09/21 21:13 ※ 編輯: splasky (1.170.120.1), 09/21/2016 21:53:44 ※ 編輯: splasky (1.170.120.1), 09/21/2016 21:54:16
Typebrook: A2: PEP484的簡單介紹: (基本上對function沒影響) 09/21 22:00
Typebrook: #function-annotations 09/21 22:00
Yshuan: 還以為能做pattern matching @@ 09/21 23:18
gozule: 其實我很好奇的事情是以後cython是否可以用python3指定的 09/23 11:04
gozule: type直接編譯,而不必在前面再加上一次type。 09/23 11:05
Yshuan: 就我對python.h裡面的pyObject理解 c階段改成指定type 09/25 10:30
Yshuan: 是不太可能的吧 09/25 10:31
s06yji3: 印象中聽過使用type hint並不會提高效率XD 09/26 09:17
kenduest: 對 ide 來說應該會有幫助 10/01 17:24