GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — LearnPython/python_version36.py at master · gbchen/LearnPython

Expand file tree

/

python_version36.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
52 lines (37 loc) · 1.15 KB
/

python_version36.py

Copy path

File metadata and controls

52 lines (37 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# _*_ coding: utf-8 _*_
"""
python_version36.py by xianhu
"""
import asyncio
import decimal
from typing import List, Dict
# Formatted string literals
name = "Fred"
print(f"He said his name is {name}.") # 'He said his name is Fred.'
print("He said his name is {name}.".format(**locals()))
width = 10
precision = 4
value = decimal.Decimal("12.34567")
print(f"result: {value:{width}.{precision}}") #'result: 12.35'
# variable annotations
def test(a: List[int], b: int) -> int:
return a[0] + b
print(test([3, 1], 2))
primes: List[int] = []
captain: str
class Starship(object):
stats: Dict[str, int] = {}
# Underscores in Numeric Literals
a = 1_000_000_000_000_000 # 1000000000000000
b = 0x_FF_FF_FF_FF # 4294967295
'{:_}'.format(1000000) # '1_000_000'
'{:_x}'.format(0xFFFFFFFF) # 'ffff_ffff'
# Asynchronous Generators
async def ticker(delay, to):
"""Yield numbers from 0 to *to* every *delay* seconds."""
for i in range(to):
yield i
await asyncio.sleep(delay)
# Asynchronous Comprehensions
result = [i async for i in aiter() if i % 2]
result = [await fun() for fun in funcs if await condition()]
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.