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