[{"data":1,"prerenderedAt":3979},["ShallowReactive",2],{"page-\u002Fpython\u002F03-operators-and-expressions":3},{"id":4,"title":5,"body":6,"description":27,"extension":3973,"meta":3974,"navigation":54,"path":3975,"seo":3976,"stem":3977,"__hash__":3978},"content\u002Fpython\u002F03-operators-and-expressions.md","03 — Operators & Expressions",{"type":7,"value":8,"toc":3943},"minimark",[9,13,18,351,868,872,1019,1028,1032,1068,1199,1211,1236,1333,1350,1354,1365,1541,1549,1671,1681,1695,1788,1795,1853,1859,2002,2006,2209,2220,2256,2263,2463,2504,2558,2565,2631,2667,2675,2692,2752,2756,2940,2944,3068,3077,3137,3141,3144,3310,3395,3399,3499,3503,3631,3635,3638,3742,3872,3876,3939],[10,11,5],"h1",{"id":12},"_03-operators-expressions",[14,15,17],"h2",{"id":16},"arithmetic-floor-division-and-modulo-are-not-c-style","Arithmetic — Floor Division and Modulo Are Not C-Style",[19,20,22],"code-wrapper",{"language":21},"python",[23,24,28],"pre",{"className":25,"code":26,"language":21,"meta":27,"style":27},"language-python shiki shiki-themes github-light github-dark","# Python's \u002F\u002F and % follow MATHEMATICAL flooring, not C\u002FJava truncation.\n# This matters in pagination, hashing, ring buffers, and modular arithmetic.\n\n# ── Truncation (C\u002FJava\u002FRust) vs Flooring (Python) ──\n#   C:     -7 \u002F 2  = -3   (truncates toward zero)\n#   Python: -7 \u002F\u002F 2 = -4  (floors toward -∞)\n\n# Production: ring buffer index computation\nBUFFER_SIZE = 256\n\ndef ring_index_c_style(offset):\n    \"\"\"WRONG — C-style truncation produces negative indices for negative offsets.\"\"\"\n    return int(offset \u002F BUFFER_SIZE) % BUFFER_SIZE   # truncation, not flooring\n\ndef ring_index_python(offset):\n    \"\"\"CORRECT — Python's % always returns a value with the sign of the DIVISOR.\"\"\"\n    return offset % BUFFER_SIZE   # always 0..255, even for negative offsets\n\nprint(ring_index_c_style(-1))     # 255 — accidentally works here, but breaks at other values\nprint(ring_index_python(-1))      # 255 — guaranteed correct: -1 % 256 = 255\nprint(ring_index_python(-257))    # 255 — correct: -257 % 256 = 255\n\n# ── The divmod() builtin — quotient + remainder in one operation ──\n# More efficient than computing \u002F\u002F and % separately (one division operation)\nquotient, remainder = divmod(-17, 5)\nprint(quotient, remainder)        # -4, 3  — q*floors*, r takes sign of divisor\n# Verify: quotient * divisor + remainder == dividend\nassert quotient * 5 + remainder == -17\n","",[29,30,31,43,49,56,62,68,77,82,88,102,107,121,128,157,162,172,178,193,198,219,237,255,260,266,275,304,315,321],"code",{"__ignoreMap":27},[32,33,36,40],"span",{"class":34,"line":35},"line",1,[32,37,39],{"class":38},"sdCPZ","# Python's",[32,41,42],{"class":38}," \u002F\u002F and % follow MATHEMATICAL flooring, not C\u002FJava truncation.\n",[32,44,46],{"class":34,"line":45},2,[32,47,48],{"class":38},"# This matters in pagination, hashing, ring buffers, and modular arithmetic.\n",[32,50,52],{"class":34,"line":51},3,[32,53,55],{"emptyLinePlaceholder":54},true,"\n",[32,57,59],{"class":34,"line":58},4,[32,60,61],{"class":38},"# ── Truncation (C\u002FJava\u002FRust) vs Flooring (Python) ──\n",[32,63,65],{"class":34,"line":64},5,[32,66,67],{"class":38},"#   C:     -7 \u002F 2  = -3   (truncates toward zero)\n",[32,69,71,74],{"class":34,"line":70},6,[32,72,73],{"class":38},"#   Python: -7",[32,75,76],{"class":38}," \u002F\u002F 2 = -4  (floors toward -∞)\n",[32,78,80],{"class":34,"line":79},7,[32,81,55],{"emptyLinePlaceholder":54},[32,83,85],{"class":34,"line":84},8,[32,86,87],{"class":38},"# Production: ring buffer index computation\n",[32,89,91,95,99],{"class":34,"line":90},9,[32,92,94],{"class":93},"snvgF","BUFFER_SIZE",[32,96,98],{"class":97},"svdQ7"," =",[32,100,101],{"class":93}," 256\n",[32,103,105],{"class":34,"line":104},10,[32,106,55],{"emptyLinePlaceholder":54},[32,108,110,113,117],{"class":34,"line":109},11,[32,111,112],{"class":97},"def",[32,114,116],{"class":115},"sIsaT"," ring_index_c_style",[32,118,120],{"class":119},"ssxIu","(offset):\n",[32,122,124],{"class":34,"line":123},12,[32,125,127],{"class":126},"sJ6F3","    \"\"\"WRONG — C-style truncation produces negative indices for negative offsets.\"\"\"\n",[32,129,131,134,137,140,143,146,149,152,154],{"class":34,"line":130},13,[32,132,133],{"class":97},"    return",[32,135,136],{"class":93}," int",[32,138,139],{"class":119},"(offset ",[32,141,142],{"class":97},"\u002F",[32,144,145],{"class":93}," BUFFER_SIZE",[32,147,148],{"class":119},") ",[32,150,151],{"class":97},"%",[32,153,145],{"class":93},[32,155,156],{"class":38},"   # truncation, not flooring\n",[32,158,160],{"class":34,"line":159},14,[32,161,55],{"emptyLinePlaceholder":54},[32,163,165,167,170],{"class":34,"line":164},15,[32,166,112],{"class":97},[32,168,169],{"class":115}," ring_index_python",[32,171,120],{"class":119},[32,173,175],{"class":34,"line":174},16,[32,176,177],{"class":126},"    \"\"\"CORRECT — Python's % always returns a value with the sign of the DIVISOR.\"\"\"\n",[32,179,181,183,186,188,190],{"class":34,"line":180},17,[32,182,133],{"class":97},[32,184,185],{"class":119}," offset ",[32,187,151],{"class":97},[32,189,145],{"class":93},[32,191,192],{"class":38},"   # always 0..255, even for negative offsets\n",[32,194,196],{"class":34,"line":195},18,[32,197,55],{"emptyLinePlaceholder":54},[32,199,201,204,207,210,213,216],{"class":34,"line":200},19,[32,202,203],{"class":93},"print",[32,205,206],{"class":119},"(ring_index_c_style(",[32,208,209],{"class":97},"-",[32,211,212],{"class":93},"1",[32,214,215],{"class":119},"))     ",[32,217,218],{"class":38},"# 255 — accidentally works here, but breaks at other values\n",[32,220,222,224,227,229,231,234],{"class":34,"line":221},20,[32,223,203],{"class":93},[32,225,226],{"class":119},"(ring_index_python(",[32,228,209],{"class":97},[32,230,212],{"class":93},[32,232,233],{"class":119},"))      ",[32,235,236],{"class":38},"# 255 — guaranteed correct: -1 % 256 = 255\n",[32,238,240,242,244,246,249,252],{"class":34,"line":239},21,[32,241,203],{"class":93},[32,243,226],{"class":119},[32,245,209],{"class":97},[32,247,248],{"class":93},"257",[32,250,251],{"class":119},"))    ",[32,253,254],{"class":38},"# 255 — correct: -257 % 256 = 255\n",[32,256,258],{"class":34,"line":257},22,[32,259,55],{"emptyLinePlaceholder":54},[32,261,263],{"class":34,"line":262},23,[32,264,265],{"class":38},"# ── The divmod() builtin — quotient + remainder in one operation ──\n",[32,267,269,272],{"class":34,"line":268},24,[32,270,271],{"class":38},"# More efficient than computing",[32,273,274],{"class":38}," \u002F\u002F and % separately (one division operation)\n",[32,276,278,281,284,287,290,292,295,298,301],{"class":34,"line":277},25,[32,279,280],{"class":119},"quotient, remainder ",[32,282,283],{"class":97},"=",[32,285,286],{"class":93}," divmod",[32,288,289],{"class":119},"(",[32,291,209],{"class":97},[32,293,294],{"class":93},"17",[32,296,297],{"class":119},", ",[32,299,300],{"class":93},"5",[32,302,303],{"class":119},")\n",[32,305,307,309,312],{"class":34,"line":306},26,[32,308,203],{"class":93},[32,310,311],{"class":119},"(quotient, remainder)        ",[32,313,314],{"class":38},"# -4, 3  — q*floors*, r takes sign of divisor\n",[32,316,318],{"class":34,"line":317},27,[32,319,320],{"class":38},"# Verify: quotient * divisor + remainder == dividend\n",[32,322,324,327,330,333,336,339,342,345,348],{"class":34,"line":323},28,[32,325,326],{"class":97},"assert",[32,328,329],{"class":119}," quotient ",[32,331,332],{"class":97},"*",[32,334,335],{"class":93}," 5",[32,337,338],{"class":97}," +",[32,340,341],{"class":119}," remainder ",[32,343,344],{"class":97},"==",[32,346,347],{"class":97}," -",[32,349,350],{"class":93},"17\n",[19,352,353],{"language":21},[23,354,356],{"className":25,"code":355,"language":21,"meta":27,"style":27},"# ── Production: parsing binary protocols with bitwise operators ──\n# TCP header flag extraction — real-world bit manipulation, not toy examples\n\ndef parse_tcp_flags(flags_byte: int) -> dict:\n    \"\"\"Extract TCP header flags from a single byte — bit masking in production code.\"\"\"\n    return {\n        \"FIN\":  bool(flags_byte & 0x01),   # bit 0 — AND isolates single bit, bool() normalizes\n        \"SYN\":  bool(flags_byte & 0x02),   # bit 1\n        \"RST\":  bool(flags_byte & 0x04),   # bit 2\n        \"PSH\":  bool(flags_byte & 0x08),   # bit 3\n        \"ACK\":  bool(flags_byte & 0x10),   # bit 4\n        \"URG\":  bool(flags_byte & 0x20),   # bit 5\n        \"ECE\":  bool(flags_byte & 0x40),   # bit 6\n        \"CWR\":  bool(flags_byte & 0x80),   # bit 7\n    }\n\n# SYN+ACK = 0x02 | 0x10 = 0x12 = 18\nflags = 0x12\nparsed = parse_tcp_flags(flags)\nprint(parsed)   # {'FIN': False, 'SYN': True, 'RST': False, 'PSH': False, 'ACK': True, ...}\n\n# ── Packed bitfield construction (e.g., for protocol headers) ──\ndef build_tcp_flags(fin=False, syn=False, rst=False, psh=False, ack=False, urg=False):\n    \"\"\"Pack boolean flags into a single byte using bit shifts and OR.\"\"\"\n    flags = 0\n    flags |= (fin \u003C\u003C 0)   # shift each flag to its bit position, OR into result\n    flags |= (syn \u003C\u003C 1)\n    flags |= (rst \u003C\u003C 2)\n    flags |= (psh \u003C\u003C 3)\n    flags |= (ack \u003C\u003C 4)\n    flags |= (urg \u003C\u003C 5)\n    return flags\n\nprint(build_tcp_flags(syn=True, ack=True))   # 18 = 0x12\n",[29,357,358,363,368,372,394,399,406,435,458,481,504,527,550,573,596,601,605,610,622,632,642,646,651,704,709,719,741,757,773,790,807,823,831,836],{"__ignoreMap":27},[32,359,360],{"class":34,"line":35},[32,361,362],{"class":38},"# ── Production: parsing binary protocols with bitwise operators ──\n",[32,364,365],{"class":34,"line":45},[32,366,367],{"class":38},"# TCP header flag extraction — real-world bit manipulation, not toy examples\n",[32,369,370],{"class":34,"line":51},[32,371,55],{"emptyLinePlaceholder":54},[32,373,374,376,379,382,385,388,391],{"class":34,"line":58},[32,375,112],{"class":97},[32,377,378],{"class":115}," parse_tcp_flags",[32,380,381],{"class":119},"(flags_byte: ",[32,383,384],{"class":93},"int",[32,386,387],{"class":119},") -> ",[32,389,390],{"class":93},"dict",[32,392,393],{"class":119},":\n",[32,395,396],{"class":34,"line":64},[32,397,398],{"class":126},"    \"\"\"Extract TCP header flags from a single byte — bit masking in production code.\"\"\"\n",[32,400,401,403],{"class":34,"line":70},[32,402,133],{"class":97},[32,404,405],{"class":119}," {\n",[32,407,408,411,414,417,420,423,426,429,432],{"class":34,"line":79},[32,409,410],{"class":126},"        \"FIN\"",[32,412,413],{"class":119},":  ",[32,415,416],{"class":93},"bool",[32,418,419],{"class":119},"(flags_byte ",[32,421,422],{"class":97},"&",[32,424,425],{"class":97}," 0x",[32,427,428],{"class":93},"01",[32,430,431],{"class":119},"),   ",[32,433,434],{"class":38},"# bit 0 — AND isolates single bit, bool() normalizes\n",[32,436,437,440,442,444,446,448,450,453,455],{"class":34,"line":84},[32,438,439],{"class":126},"        \"SYN\"",[32,441,413],{"class":119},[32,443,416],{"class":93},[32,445,419],{"class":119},[32,447,422],{"class":97},[32,449,425],{"class":97},[32,451,452],{"class":93},"02",[32,454,431],{"class":119},[32,456,457],{"class":38},"# bit 1\n",[32,459,460,463,465,467,469,471,473,476,478],{"class":34,"line":90},[32,461,462],{"class":126},"        \"RST\"",[32,464,413],{"class":119},[32,466,416],{"class":93},[32,468,419],{"class":119},[32,470,422],{"class":97},[32,472,425],{"class":97},[32,474,475],{"class":93},"04",[32,477,431],{"class":119},[32,479,480],{"class":38},"# bit 2\n",[32,482,483,486,488,490,492,494,496,499,501],{"class":34,"line":104},[32,484,485],{"class":126},"        \"PSH\"",[32,487,413],{"class":119},[32,489,416],{"class":93},[32,491,419],{"class":119},[32,493,422],{"class":97},[32,495,425],{"class":97},[32,497,498],{"class":93},"08",[32,500,431],{"class":119},[32,502,503],{"class":38},"# bit 3\n",[32,505,506,509,511,513,515,517,519,522,524],{"class":34,"line":109},[32,507,508],{"class":126},"        \"ACK\"",[32,510,413],{"class":119},[32,512,416],{"class":93},[32,514,419],{"class":119},[32,516,422],{"class":97},[32,518,425],{"class":97},[32,520,521],{"class":93},"10",[32,523,431],{"class":119},[32,525,526],{"class":38},"# bit 4\n",[32,528,529,532,534,536,538,540,542,545,547],{"class":34,"line":123},[32,530,531],{"class":126},"        \"URG\"",[32,533,413],{"class":119},[32,535,416],{"class":93},[32,537,419],{"class":119},[32,539,422],{"class":97},[32,541,425],{"class":97},[32,543,544],{"class":93},"20",[32,546,431],{"class":119},[32,548,549],{"class":38},"# bit 5\n",[32,551,552,555,557,559,561,563,565,568,570],{"class":34,"line":130},[32,553,554],{"class":126},"        \"ECE\"",[32,556,413],{"class":119},[32,558,416],{"class":93},[32,560,419],{"class":119},[32,562,422],{"class":97},[32,564,425],{"class":97},[32,566,567],{"class":93},"40",[32,569,431],{"class":119},[32,571,572],{"class":38},"# bit 6\n",[32,574,575,578,580,582,584,586,588,591,593],{"class":34,"line":159},[32,576,577],{"class":126},"        \"CWR\"",[32,579,413],{"class":119},[32,581,416],{"class":93},[32,583,419],{"class":119},[32,585,422],{"class":97},[32,587,425],{"class":97},[32,589,590],{"class":93},"80",[32,592,431],{"class":119},[32,594,595],{"class":38},"# bit 7\n",[32,597,598],{"class":34,"line":164},[32,599,600],{"class":119},"    }\n",[32,602,603],{"class":34,"line":174},[32,604,55],{"emptyLinePlaceholder":54},[32,606,607],{"class":34,"line":180},[32,608,609],{"class":38},"# SYN+ACK = 0x02 | 0x10 = 0x12 = 18\n",[32,611,612,615,617,619],{"class":34,"line":195},[32,613,614],{"class":119},"flags ",[32,616,283],{"class":97},[32,618,425],{"class":97},[32,620,621],{"class":93},"12\n",[32,623,624,627,629],{"class":34,"line":200},[32,625,626],{"class":119},"parsed ",[32,628,283],{"class":97},[32,630,631],{"class":119}," parse_tcp_flags(flags)\n",[32,633,634,636,639],{"class":34,"line":221},[32,635,203],{"class":93},[32,637,638],{"class":119},"(parsed)   ",[32,640,641],{"class":38},"# {'FIN': False, 'SYN': True, 'RST': False, 'PSH': False, 'ACK': True, ...}\n",[32,643,644],{"class":34,"line":239},[32,645,55],{"emptyLinePlaceholder":54},[32,647,648],{"class":34,"line":257},[32,649,650],{"class":38},"# ── Packed bitfield construction (e.g., for protocol headers) ──\n",[32,652,653,655,658,661,663,666,669,671,673,676,678,680,683,685,687,690,692,694,697,699,701],{"class":34,"line":262},[32,654,112],{"class":97},[32,656,657],{"class":115}," build_tcp_flags",[32,659,660],{"class":119},"(fin",[32,662,283],{"class":97},[32,664,665],{"class":93},"False",[32,667,668],{"class":119},", syn",[32,670,283],{"class":97},[32,672,665],{"class":93},[32,674,675],{"class":119},", rst",[32,677,283],{"class":97},[32,679,665],{"class":93},[32,681,682],{"class":119},", psh",[32,684,283],{"class":97},[32,686,665],{"class":93},[32,688,689],{"class":119},", ack",[32,691,283],{"class":97},[32,693,665],{"class":93},[32,695,696],{"class":119},", urg",[32,698,283],{"class":97},[32,700,665],{"class":93},[32,702,703],{"class":119},"):\n",[32,705,706],{"class":34,"line":268},[32,707,708],{"class":126},"    \"\"\"Pack boolean flags into a single byte using bit shifts and OR.\"\"\"\n",[32,710,711,714,716],{"class":34,"line":277},[32,712,713],{"class":119},"    flags ",[32,715,283],{"class":97},[32,717,718],{"class":93}," 0\n",[32,720,721,723,726,729,732,735,738],{"class":34,"line":306},[32,722,713],{"class":119},[32,724,725],{"class":97},"|=",[32,727,728],{"class":119}," (fin ",[32,730,731],{"class":97},"\u003C\u003C",[32,733,734],{"class":93}," 0",[32,736,737],{"class":119},")   ",[32,739,740],{"class":38},"# shift each flag to its bit position, OR into result\n",[32,742,743,745,747,750,752,755],{"class":34,"line":317},[32,744,713],{"class":119},[32,746,725],{"class":97},[32,748,749],{"class":119}," (syn ",[32,751,731],{"class":97},[32,753,754],{"class":93}," 1",[32,756,303],{"class":119},[32,758,759,761,763,766,768,771],{"class":34,"line":323},[32,760,713],{"class":119},[32,762,725],{"class":97},[32,764,765],{"class":119}," (rst ",[32,767,731],{"class":97},[32,769,770],{"class":93}," 2",[32,772,303],{"class":119},[32,774,776,778,780,783,785,788],{"class":34,"line":775},29,[32,777,713],{"class":119},[32,779,725],{"class":97},[32,781,782],{"class":119}," (psh ",[32,784,731],{"class":97},[32,786,787],{"class":93}," 3",[32,789,303],{"class":119},[32,791,793,795,797,800,802,805],{"class":34,"line":792},30,[32,794,713],{"class":119},[32,796,725],{"class":97},[32,798,799],{"class":119}," (ack ",[32,801,731],{"class":97},[32,803,804],{"class":93}," 4",[32,806,303],{"class":119},[32,808,810,812,814,817,819,821],{"class":34,"line":809},31,[32,811,713],{"class":119},[32,813,725],{"class":97},[32,815,816],{"class":119}," (urg ",[32,818,731],{"class":97},[32,820,335],{"class":93},[32,822,303],{"class":119},[32,824,826,828],{"class":34,"line":825},32,[32,827,133],{"class":97},[32,829,830],{"class":119}," flags\n",[32,832,834],{"class":34,"line":833},33,[32,835,55],{"emptyLinePlaceholder":54},[32,837,839,841,844,848,850,853,855,858,860,862,865],{"class":34,"line":838},34,[32,840,203],{"class":93},[32,842,843],{"class":119},"(build_tcp_flags(",[32,845,847],{"class":846},"sCrzJ","syn",[32,849,283],{"class":97},[32,851,852],{"class":93},"True",[32,854,297],{"class":119},[32,856,857],{"class":846},"ack",[32,859,283],{"class":97},[32,861,852],{"class":93},[32,863,864],{"class":119},"))   ",[32,866,867],{"class":38},"# 18 = 0x12\n",[14,869,871],{"id":870},"comparison-operators","Comparison Operators",[19,873,874],{"language":21},[23,875,877],{"className":25,"code":876,"language":21,"meta":27,"style":27},"print(3 \u003C 5)         # True\nprint(3 \u003C= 3)         # True\nprint(3 == 3.0)        # True  — value equality across numeric types\nprint(3 != \"3\")         # True — different types, never equal\nprint([1, 2] == [1, 2])  # True — lists compare by value, element-wise\nprint([1, 2] is [1, 2])  # False — two distinct list objects\n",[29,878,879,899,916,936,955,989],{"__ignoreMap":27},[32,880,881,883,885,888,891,893,896],{"class":34,"line":35},[32,882,203],{"class":93},[32,884,289],{"class":119},[32,886,887],{"class":93},"3",[32,889,890],{"class":97}," \u003C",[32,892,335],{"class":93},[32,894,895],{"class":119},")         ",[32,897,898],{"class":38},"# True\n",[32,900,901,903,905,907,910,912,914],{"class":34,"line":45},[32,902,203],{"class":93},[32,904,289],{"class":119},[32,906,887],{"class":93},[32,908,909],{"class":97}," \u003C=",[32,911,787],{"class":93},[32,913,895],{"class":119},[32,915,898],{"class":38},[32,917,918,920,922,924,927,930,933],{"class":34,"line":51},[32,919,203],{"class":93},[32,921,289],{"class":119},[32,923,887],{"class":93},[32,925,926],{"class":97}," ==",[32,928,929],{"class":93}," 3.0",[32,931,932],{"class":119},")        ",[32,934,935],{"class":38},"# True  — value equality across numeric types\n",[32,937,938,940,942,944,947,950,952],{"class":34,"line":58},[32,939,203],{"class":93},[32,941,289],{"class":119},[32,943,887],{"class":93},[32,945,946],{"class":97}," !=",[32,948,949],{"class":126}," \"3\"",[32,951,895],{"class":119},[32,953,954],{"class":38},"# True — different types, never equal\n",[32,956,957,959,962,964,966,969,972,974,977,979,981,983,986],{"class":34,"line":64},[32,958,203],{"class":93},[32,960,961],{"class":119},"([",[32,963,212],{"class":93},[32,965,297],{"class":119},[32,967,968],{"class":93},"2",[32,970,971],{"class":119},"] ",[32,973,344],{"class":97},[32,975,976],{"class":119}," [",[32,978,212],{"class":93},[32,980,297],{"class":119},[32,982,968],{"class":93},[32,984,985],{"class":119},"])  ",[32,987,988],{"class":38},"# True — lists compare by value, element-wise\n",[32,990,991,993,995,997,999,1001,1003,1006,1008,1010,1012,1014,1016],{"class":34,"line":70},[32,992,203],{"class":93},[32,994,961],{"class":119},[32,996,212],{"class":93},[32,998,297],{"class":119},[32,1000,968],{"class":93},[32,1002,971],{"class":119},[32,1004,1005],{"class":97},"is",[32,1007,976],{"class":119},[32,1009,212],{"class":93},[32,1011,297],{"class":119},[32,1013,968],{"class":93},[32,1015,985],{"class":119},[32,1017,1018],{"class":38},"# False — two distinct list objects\n",[14,1020,1022,1024,1025,1027],{"id":1021},"is-vs-identity-vs-equality",[29,1023,1005],{}," vs ",[29,1026,344],{}," — Identity vs Equality",[1029,1030,1031],"p",{},"This is the single most important distinction in this chapter.",[1033,1034,1035,1053],"ul",{},[1036,1037,1038,1043,1044,1047,1048,1052],"li",{},[1039,1040,1041],"strong",{},[29,1042,344],{}," calls ",[29,1045,1046],{},"__eq__"," and asks: \"do these objects have the same ",[1049,1050,1051],"em",{},"value","?\"",[1036,1054,1055,1059,1060,1063,1064,1067],{},[1039,1056,1057],{},[29,1058,1005],{}," asks: \"are these literally the ",[1049,1061,1062],{},"same object"," in memory (same ",[29,1065,1066],{},"id()",")?\"",[19,1069,1070],{"language":21},[23,1071,1073],{"className":25,"code":1072,"language":21,"meta":27,"style":27},"a = [1, 2, 3]\nb = [1, 2, 3]\nc = a\n\nprint(a == b)   # True  — same contents\nprint(a is b)   # False — two distinct list objects with equal contents\nprint(a is c)   # True  — c is literally a, same object\nprint(id(a), id(b), id(c))  # a and c share an id; b is different\n",[29,1074,1075,1097,1118,1128,1132,1147,1160,1174],{"__ignoreMap":27},[32,1076,1077,1080,1082,1084,1086,1088,1090,1092,1094],{"class":34,"line":35},[32,1078,1079],{"class":119},"a ",[32,1081,283],{"class":97},[32,1083,976],{"class":119},[32,1085,212],{"class":93},[32,1087,297],{"class":119},[32,1089,968],{"class":93},[32,1091,297],{"class":119},[32,1093,887],{"class":93},[32,1095,1096],{"class":119},"]\n",[32,1098,1099,1102,1104,1106,1108,1110,1112,1114,1116],{"class":34,"line":45},[32,1100,1101],{"class":119},"b ",[32,1103,283],{"class":97},[32,1105,976],{"class":119},[32,1107,212],{"class":93},[32,1109,297],{"class":119},[32,1111,968],{"class":93},[32,1113,297],{"class":119},[32,1115,887],{"class":93},[32,1117,1096],{"class":119},[32,1119,1120,1123,1125],{"class":34,"line":51},[32,1121,1122],{"class":119},"c ",[32,1124,283],{"class":97},[32,1126,1127],{"class":119}," a\n",[32,1129,1130],{"class":34,"line":58},[32,1131,55],{"emptyLinePlaceholder":54},[32,1133,1134,1136,1139,1141,1144],{"class":34,"line":64},[32,1135,203],{"class":93},[32,1137,1138],{"class":119},"(a ",[32,1140,344],{"class":97},[32,1142,1143],{"class":119}," b)   ",[32,1145,1146],{"class":38},"# True  — same contents\n",[32,1148,1149,1151,1153,1155,1157],{"class":34,"line":70},[32,1150,203],{"class":93},[32,1152,1138],{"class":119},[32,1154,1005],{"class":97},[32,1156,1143],{"class":119},[32,1158,1159],{"class":38},"# False — two distinct list objects with equal contents\n",[32,1161,1162,1164,1166,1168,1171],{"class":34,"line":79},[32,1163,203],{"class":93},[32,1165,1138],{"class":119},[32,1167,1005],{"class":97},[32,1169,1170],{"class":119}," c)   ",[32,1172,1173],{"class":38},"# True  — c is literally a, same object\n",[32,1175,1176,1178,1180,1183,1186,1188,1191,1193,1196],{"class":34,"line":84},[32,1177,203],{"class":93},[32,1179,289],{"class":119},[32,1181,1182],{"class":93},"id",[32,1184,1185],{"class":119},"(a), ",[32,1187,1182],{"class":93},[32,1189,1190],{"class":119},"(b), ",[32,1192,1182],{"class":93},[32,1194,1195],{"class":119},"(c))  ",[32,1197,1198],{"class":38},"# a and c share an id; b is different\n",[1029,1200,1201,1204,1205,1207,1208,1210],{},[1039,1202,1203],{},"Rule of thumb",": use ",[29,1206,344],{}," for value comparisons (the overwhelming majority of cases). Use ",[29,1209,1005],{}," only for:",[1212,1213,1214,1224,1233],"ol",{},[1036,1215,1216,1217,1220,1221],{},"Comparing against ",[29,1218,1219],{},"None",": ",[29,1222,1223],{},"if x is None",[1036,1225,1226,1227,297,1230],{},"Comparing against other singletons: ",[29,1228,1229],{},"if x is Ellipsis",[29,1231,1232],{},"if x is NotImplemented",[1036,1234,1235],{},"Deliberate identity checks (e.g., \"is this the exact cached instance\", sentinel objects)",[19,1237,1238],{"language":21},[23,1239,1241],{"className":25,"code":1240,"language":21,"meta":27,"style":27},"_SENTINEL = object()  # a unique, unforgeable sentinel\n\ndef get(d, key, default=_SENTINEL):\n    if key in d:\n        return d[key]\n    if default is _SENTINEL:\n        raise KeyError(key)\n    return default\n",[29,1242,1243,1259,1263,1279,1293,1301,1315,1326],{"__ignoreMap":27},[32,1244,1245,1248,1250,1253,1256],{"class":34,"line":35},[32,1246,1247],{"class":93},"_SENTINEL",[32,1249,98],{"class":97},[32,1251,1252],{"class":93}," object",[32,1254,1255],{"class":119},"()  ",[32,1257,1258],{"class":38},"# a unique, unforgeable sentinel\n",[32,1260,1261],{"class":34,"line":45},[32,1262,55],{"emptyLinePlaceholder":54},[32,1264,1265,1267,1270,1273,1275,1277],{"class":34,"line":51},[32,1266,112],{"class":97},[32,1268,1269],{"class":115}," get",[32,1271,1272],{"class":119},"(d, key, default",[32,1274,283],{"class":97},[32,1276,1247],{"class":93},[32,1278,703],{"class":119},[32,1280,1281,1284,1287,1290],{"class":34,"line":58},[32,1282,1283],{"class":97},"    if",[32,1285,1286],{"class":119}," key ",[32,1288,1289],{"class":97},"in",[32,1291,1292],{"class":119}," d:\n",[32,1294,1295,1298],{"class":34,"line":64},[32,1296,1297],{"class":97},"        return",[32,1299,1300],{"class":119}," d[key]\n",[32,1302,1303,1305,1308,1310,1313],{"class":34,"line":70},[32,1304,1283],{"class":97},[32,1306,1307],{"class":119}," default ",[32,1309,1005],{"class":97},[32,1311,1312],{"class":93}," _SENTINEL",[32,1314,393],{"class":119},[32,1316,1317,1320,1323],{"class":34,"line":79},[32,1318,1319],{"class":97},"        raise",[32,1321,1322],{"class":93}," KeyError",[32,1324,1325],{"class":119},"(key)\n",[32,1327,1328,1330],{"class":34,"line":84},[32,1329,133],{"class":97},[32,1331,1332],{"class":119}," default\n",[1029,1334,1335,1336,1339,1340,1342,1343,1345,1346,1349],{},"Using a private ",[29,1337,1338],{},"object()"," instance as a sentinel (rather than ",[29,1341,1219],{},") lets a function distinguish \"no default was passed\" from \"the caller explicitly passed ",[29,1344,1219],{}," as the default\" — a pattern impossible to express correctly with ",[29,1347,1348],{},"is None"," checks alone.",[14,1351,1353],{"id":1352},"chained-comparisons","Chained Comparisons",[1029,1355,1356,1357,1360,1361,1364],{},"Python allows mathematical-style chaining, which is evaluated left-to-right with implicit ",[29,1358,1359],{},"and",", and — critically — ",[1039,1362,1363],{},"each subexpression is evaluated only once",".",[19,1366,1367],{"language":21},[23,1368,1370],{"className":25,"code":1369,"language":21,"meta":27,"style":27},"x = 5\nprint(1 \u003C x \u003C 10)          # True — equivalent to (1 \u003C x) and (x \u003C 10)\nprint(10 > x > 1)          # True\nprint(1 \u003C x \u003C 10 \u003C 3)      # False — chains can mix any comparison operators\n\n# The single-evaluation guarantee matters with side effects:\ndef noisy(n):\n    print(f\"checked {n}\")\n    return n\n\nprint(0 \u003C noisy(5) \u003C 10)\n# prints \"checked 5\" ONCE — not twice, unlike a naive `0 \u003C noisy(5) and noisy(5) \u003C 10`\n",[29,1371,1372,1382,1407,1429,1455,1459,1464,1474,1501,1508,1512,1536],{"__ignoreMap":27},[32,1373,1374,1377,1379],{"class":34,"line":35},[32,1375,1376],{"class":119},"x ",[32,1378,283],{"class":97},[32,1380,1381],{"class":93}," 5\n",[32,1383,1384,1386,1388,1390,1392,1395,1398,1401,1404],{"class":34,"line":45},[32,1385,203],{"class":93},[32,1387,289],{"class":119},[32,1389,212],{"class":93},[32,1391,890],{"class":97},[32,1393,1394],{"class":119}," x ",[32,1396,1397],{"class":97},"\u003C",[32,1399,1400],{"class":93}," 10",[32,1402,1403],{"class":119},")          ",[32,1405,1406],{"class":38},"# True — equivalent to (1 \u003C x) and (x \u003C 10)\n",[32,1408,1409,1411,1413,1415,1418,1420,1423,1425,1427],{"class":34,"line":51},[32,1410,203],{"class":93},[32,1412,289],{"class":119},[32,1414,521],{"class":93},[32,1416,1417],{"class":97}," >",[32,1419,1394],{"class":119},[32,1421,1422],{"class":97},">",[32,1424,754],{"class":93},[32,1426,1403],{"class":119},[32,1428,898],{"class":38},[32,1430,1431,1433,1435,1437,1439,1441,1443,1445,1447,1449,1452],{"class":34,"line":58},[32,1432,203],{"class":93},[32,1434,289],{"class":119},[32,1436,212],{"class":93},[32,1438,890],{"class":97},[32,1440,1394],{"class":119},[32,1442,1397],{"class":97},[32,1444,1400],{"class":93},[32,1446,890],{"class":97},[32,1448,787],{"class":93},[32,1450,1451],{"class":119},")      ",[32,1453,1454],{"class":38},"# False — chains can mix any comparison operators\n",[32,1456,1457],{"class":34,"line":64},[32,1458,55],{"emptyLinePlaceholder":54},[32,1460,1461],{"class":34,"line":70},[32,1462,1463],{"class":38},"# The single-evaluation guarantee matters with side effects:\n",[32,1465,1466,1468,1471],{"class":34,"line":79},[32,1467,112],{"class":97},[32,1469,1470],{"class":115}," noisy",[32,1472,1473],{"class":119},"(n):\n",[32,1475,1476,1479,1481,1484,1487,1490,1493,1496,1499],{"class":34,"line":84},[32,1477,1478],{"class":93},"    print",[32,1480,289],{"class":119},[32,1482,1483],{"class":97},"f",[32,1485,1486],{"class":126},"\"checked ",[32,1488,1489],{"class":93},"{",[32,1491,1492],{"class":119},"n",[32,1494,1495],{"class":93},"}",[32,1497,1498],{"class":126},"\"",[32,1500,303],{"class":119},[32,1502,1503,1505],{"class":34,"line":90},[32,1504,133],{"class":97},[32,1506,1507],{"class":119}," n\n",[32,1509,1510],{"class":34,"line":104},[32,1511,55],{"emptyLinePlaceholder":54},[32,1513,1514,1516,1518,1521,1523,1526,1528,1530,1532,1534],{"class":34,"line":109},[32,1515,203],{"class":93},[32,1517,289],{"class":119},[32,1519,1520],{"class":93},"0",[32,1522,890],{"class":97},[32,1524,1525],{"class":119}," noisy(",[32,1527,300],{"class":93},[32,1529,148],{"class":119},[32,1531,1397],{"class":97},[32,1533,1400],{"class":93},[32,1535,303],{"class":119},[32,1537,1538],{"class":34,"line":123},[32,1539,1540],{"class":38},"# prints \"checked 5\" ONCE — not twice, unlike a naive `0 \u003C noisy(5) and noisy(5) \u003C 10`\n",[1542,1543,1545,1546,1548],"h3",{"id":1544},"the-gotcha-chained-comparisons-with-create-surprising-boolean-logic","The gotcha: chained comparisons with ",[29,1547,344],{}," create surprising boolean logic",[19,1550,1551],{"language":21},[23,1552,1554],{"className":25,"code":1553,"language":21,"meta":27,"style":27},"# A beginner might write this expecting \"is x equal to 1 OR 2?\"\nx = 3\nprint(x == 1 or 2)     # TRUTHY — this is (x == 1) or (2), and 2 is truthy!\nprint(bool(x == 1 or 2))  # True — ALWAYS true, regardless of x, because `2` is truthy\n\n# What they meant:\nprint(x == 1 or x == 2)   # False — correct\nprint(x in (1, 2))         # False — idiomatic\n",[29,1555,1556,1561,1570,1592,1616,1620,1625,1648],{"__ignoreMap":27},[32,1557,1558],{"class":34,"line":35},[32,1559,1560],{"class":38},"# A beginner might write this expecting \"is x equal to 1 OR 2?\"\n",[32,1562,1563,1565,1567],{"class":34,"line":45},[32,1564,1376],{"class":119},[32,1566,283],{"class":97},[32,1568,1569],{"class":93}," 3\n",[32,1571,1572,1574,1577,1579,1581,1584,1586,1589],{"class":34,"line":51},[32,1573,203],{"class":93},[32,1575,1576],{"class":119},"(x ",[32,1578,344],{"class":97},[32,1580,754],{"class":93},[32,1582,1583],{"class":97}," or",[32,1585,770],{"class":93},[32,1587,1588],{"class":119},")     ",[32,1590,1591],{"class":38},"# TRUTHY — this is (x == 1) or (2), and 2 is truthy!\n",[32,1593,1594,1596,1598,1600,1602,1604,1606,1608,1610,1613],{"class":34,"line":58},[32,1595,203],{"class":93},[32,1597,289],{"class":119},[32,1599,416],{"class":93},[32,1601,1576],{"class":119},[32,1603,344],{"class":97},[32,1605,754],{"class":93},[32,1607,1583],{"class":97},[32,1609,770],{"class":93},[32,1611,1612],{"class":119},"))  ",[32,1614,1615],{"class":38},"# True — ALWAYS true, regardless of x, because `2` is truthy\n",[32,1617,1618],{"class":34,"line":64},[32,1619,55],{"emptyLinePlaceholder":54},[32,1621,1622],{"class":34,"line":70},[32,1623,1624],{"class":38},"# What they meant:\n",[32,1626,1627,1629,1631,1633,1635,1637,1639,1641,1643,1645],{"class":34,"line":79},[32,1628,203],{"class":93},[32,1630,1576],{"class":119},[32,1632,344],{"class":97},[32,1634,754],{"class":93},[32,1636,1583],{"class":97},[32,1638,1394],{"class":119},[32,1640,344],{"class":97},[32,1642,770],{"class":93},[32,1644,737],{"class":119},[32,1646,1647],{"class":38},"# False — correct\n",[32,1649,1650,1652,1654,1656,1659,1661,1663,1665,1668],{"class":34,"line":84},[32,1651,203],{"class":93},[32,1653,1576],{"class":119},[32,1655,1289],{"class":97},[32,1657,1658],{"class":119}," (",[32,1660,212],{"class":93},[32,1662,297],{"class":119},[32,1664,968],{"class":93},[32,1666,1667],{"class":119},"))         ",[32,1669,1670],{"class":38},"# False — idiomatic\n",[14,1672,1674,1675,142,1677,1680],{"id":1673},"logical-operators-andor-return-operands-not-booleans","Logical Operators — ",[29,1676,1359],{},[29,1678,1679],{},"or"," Return Operands, Not Booleans",[1029,1682,1683,1684,142,1686,1688,1689,1691,1692,1364],{},"Unlike C-family languages, ",[29,1685,1359],{},[29,1687,1679],{}," in Python don't coerce to ",[29,1690,416],{}," — they short-circuit and return one of the ",[1039,1693,1694],{},"original operands",[19,1696,1697],{"language":21},[23,1698,1700],{"className":25,"code":1699,"language":21,"meta":27,"style":27},"print(3 and 5)        # 5   — both truthy, returns the LAST evaluated operand\nprint(0 and 5)         # 0   — first is falsy, short-circuits, returns it\nprint(3 or 5)           # 3   — first is truthy, short-circuits, returns it\nprint(None or \"default\") # \"default\" — classic default-value idiom\nprint([] or {})           # {}  — both falsy-ish, returns the last one evaluated\n",[29,1701,1702,1720,1737,1755,1773],{"__ignoreMap":27},[32,1703,1704,1706,1708,1710,1713,1715,1717],{"class":34,"line":35},[32,1705,203],{"class":93},[32,1707,289],{"class":119},[32,1709,887],{"class":93},[32,1711,1712],{"class":97}," and",[32,1714,335],{"class":93},[32,1716,932],{"class":119},[32,1718,1719],{"class":38},"# 5   — both truthy, returns the LAST evaluated operand\n",[32,1721,1722,1724,1726,1728,1730,1732,1734],{"class":34,"line":45},[32,1723,203],{"class":93},[32,1725,289],{"class":119},[32,1727,1520],{"class":93},[32,1729,1712],{"class":97},[32,1731,335],{"class":93},[32,1733,895],{"class":119},[32,1735,1736],{"class":38},"# 0   — first is falsy, short-circuits, returns it\n",[32,1738,1739,1741,1743,1745,1747,1749,1752],{"class":34,"line":51},[32,1740,203],{"class":93},[32,1742,289],{"class":119},[32,1744,887],{"class":93},[32,1746,1583],{"class":97},[32,1748,335],{"class":93},[32,1750,1751],{"class":119},")           ",[32,1753,1754],{"class":38},"# 3   — first is truthy, short-circuits, returns it\n",[32,1756,1757,1759,1761,1763,1765,1768,1770],{"class":34,"line":58},[32,1758,203],{"class":93},[32,1760,289],{"class":119},[32,1762,1219],{"class":93},[32,1764,1583],{"class":97},[32,1766,1767],{"class":126}," \"default\"",[32,1769,148],{"class":119},[32,1771,1772],{"class":38},"# \"default\" — classic default-value idiom\n",[32,1774,1775,1777,1780,1782,1785],{"class":34,"line":64},[32,1776,203],{"class":93},[32,1778,1779],{"class":119},"([] ",[32,1781,1679],{"class":97},[32,1783,1784],{"class":119}," {})           ",[32,1786,1787],{"class":38},"# {}  — both falsy-ish, returns the last one evaluated\n",[1029,1789,1790,1791,1794],{},"This enables the extremely common ",[1039,1792,1793],{},"default-value idiom",":",[19,1796,1797],{"language":21},[23,1798,1800],{"className":25,"code":1799,"language":21,"meta":27,"style":27},"def greet(name=None):\n    name = name or \"stranger\"\n    return f\"Hello, {name}!\"\n",[29,1801,1802,1818,1833],{"__ignoreMap":27},[32,1803,1804,1806,1809,1812,1814,1816],{"class":34,"line":35},[32,1805,112],{"class":97},[32,1807,1808],{"class":115}," greet",[32,1810,1811],{"class":119},"(name",[32,1813,283],{"class":97},[32,1815,1219],{"class":93},[32,1817,703],{"class":119},[32,1819,1820,1823,1825,1828,1830],{"class":34,"line":45},[32,1821,1822],{"class":119},"    name ",[32,1824,283],{"class":97},[32,1826,1827],{"class":119}," name ",[32,1829,1679],{"class":97},[32,1831,1832],{"class":126}," \"stranger\"\n",[32,1834,1835,1837,1840,1843,1845,1848,1850],{"class":34,"line":51},[32,1836,133],{"class":97},[32,1838,1839],{"class":97}," f",[32,1841,1842],{"class":126},"\"Hello, ",[32,1844,1489],{"class":93},[32,1846,1847],{"class":119},"name",[32,1849,1495],{"class":93},[32,1851,1852],{"class":126},"!\"\n",[1029,1854,1855,1858],{},[1039,1856,1857],{},"Gotcha",": this idiom breaks when a legitimate, intentionally-falsy value should be accepted:",[19,1860,1861],{"language":21},[23,1862,1864],{"className":25,"code":1863,"language":21,"meta":27,"style":27},"def set_volume(level=None):\n    level = level or 50          # BUG: set_volume(0) becomes 50, not 0!\n    return level\n\nprint(set_volume(0))    # 50 — wrong! Caller explicitly wanted silence.\n\n# Correct: check for None explicitly, don't rely on truthiness\ndef set_volume_fixed(level=None):\n    level = 50 if level is None else level\n    return level\n\nprint(set_volume_fixed(0))   # 0 — correct\n",[29,1865,1866,1882,1906,1913,1917,1931,1935,1940,1955,1978,1984,1988],{"__ignoreMap":27},[32,1867,1868,1870,1873,1876,1878,1880],{"class":34,"line":35},[32,1869,112],{"class":97},[32,1871,1872],{"class":115}," set_volume",[32,1874,1875],{"class":119},"(level",[32,1877,283],{"class":97},[32,1879,1219],{"class":93},[32,1881,703],{"class":119},[32,1883,1884,1887,1889,1892,1894,1897,1900,1903],{"class":34,"line":45},[32,1885,1886],{"class":119},"    level ",[32,1888,283],{"class":97},[32,1890,1891],{"class":119}," level ",[32,1893,1679],{"class":97},[32,1895,1896],{"class":93}," 50",[32,1898,1899],{"class":38},"          # ",[32,1901,1902],{"class":97},"BUG",[32,1904,1905],{"class":38},": set_volume(0) becomes 50, not 0!\n",[32,1907,1908,1910],{"class":34,"line":51},[32,1909,133],{"class":97},[32,1911,1912],{"class":119}," level\n",[32,1914,1915],{"class":34,"line":58},[32,1916,55],{"emptyLinePlaceholder":54},[32,1918,1919,1921,1924,1926,1928],{"class":34,"line":64},[32,1920,203],{"class":93},[32,1922,1923],{"class":119},"(set_volume(",[32,1925,1520],{"class":93},[32,1927,251],{"class":119},[32,1929,1930],{"class":38},"# 50 — wrong! Caller explicitly wanted silence.\n",[32,1932,1933],{"class":34,"line":70},[32,1934,55],{"emptyLinePlaceholder":54},[32,1936,1937],{"class":34,"line":79},[32,1938,1939],{"class":38},"# Correct: check for None explicitly, don't rely on truthiness\n",[32,1941,1942,1944,1947,1949,1951,1953],{"class":34,"line":84},[32,1943,112],{"class":97},[32,1945,1946],{"class":115}," set_volume_fixed",[32,1948,1875],{"class":119},[32,1950,283],{"class":97},[32,1952,1219],{"class":93},[32,1954,703],{"class":119},[32,1956,1957,1959,1961,1963,1966,1968,1970,1973,1976],{"class":34,"line":90},[32,1958,1886],{"class":119},[32,1960,283],{"class":97},[32,1962,1896],{"class":93},[32,1964,1965],{"class":97}," if",[32,1967,1891],{"class":119},[32,1969,1005],{"class":97},[32,1971,1972],{"class":93}," None",[32,1974,1975],{"class":97}," else",[32,1977,1912],{"class":119},[32,1979,1980,1982],{"class":34,"line":104},[32,1981,133],{"class":97},[32,1983,1912],{"class":119},[32,1985,1986],{"class":34,"line":109},[32,1987,55],{"emptyLinePlaceholder":54},[32,1989,1990,1992,1995,1997,1999],{"class":34,"line":123},[32,1991,203],{"class":93},[32,1993,1994],{"class":119},"(set_volume_fixed(",[32,1996,1520],{"class":93},[32,1998,864],{"class":119},[32,2000,2001],{"class":38},"# 0 — correct\n",[14,2003,2005],{"id":2004},"bitwise-operators","Bitwise Operators",[19,2007,2008],{"language":21},[23,2009,2011],{"className":25,"code":2010,"language":21,"meta":27,"style":27},"print(5 & 3)     # 1    — AND\nprint(5 | 3)      # 7    — OR\nprint(5 ^ 3)       # 6    — XOR\nprint(~5)           # -6   — NOT (two's complement: ~x == -x - 1)\nprint(5 \u003C\u003C 2)         # 20   — left shift (multiply by 2**2)\nprint(5 >> 1)           # 2    — right shift (floor-divide by 2**1)\n\n# Sets also overload these for set algebra (see chapter 08)\nprint({1, 2, 3} & {2, 3, 4})   # {2, 3} — intersection\nprint({1, 2, 3} | {2, 3, 4})   # {1, 2, 3, 4} — union\n",[29,2012,2013,2031,2049,2068,2084,2102,2120,2124,2129,2171],{"__ignoreMap":27},[32,2014,2015,2017,2019,2021,2024,2026,2028],{"class":34,"line":35},[32,2016,203],{"class":93},[32,2018,289],{"class":119},[32,2020,300],{"class":93},[32,2022,2023],{"class":97}," &",[32,2025,787],{"class":93},[32,2027,1588],{"class":119},[32,2029,2030],{"class":38},"# 1    — AND\n",[32,2032,2033,2035,2037,2039,2042,2044,2046],{"class":34,"line":45},[32,2034,203],{"class":93},[32,2036,289],{"class":119},[32,2038,300],{"class":93},[32,2040,2041],{"class":97}," |",[32,2043,787],{"class":93},[32,2045,1451],{"class":119},[32,2047,2048],{"class":38},"# 7    — OR\n",[32,2050,2051,2053,2055,2057,2060,2062,2065],{"class":34,"line":51},[32,2052,203],{"class":93},[32,2054,289],{"class":119},[32,2056,300],{"class":93},[32,2058,2059],{"class":97}," ^",[32,2061,787],{"class":93},[32,2063,2064],{"class":119},")       ",[32,2066,2067],{"class":38},"# 6    — XOR\n",[32,2069,2070,2072,2074,2077,2079,2081],{"class":34,"line":58},[32,2071,203],{"class":93},[32,2073,289],{"class":119},[32,2075,2076],{"class":97},"~",[32,2078,300],{"class":93},[32,2080,1751],{"class":119},[32,2082,2083],{"class":38},"# -6   — NOT (two's complement: ~x == -x - 1)\n",[32,2085,2086,2088,2090,2092,2095,2097,2099],{"class":34,"line":64},[32,2087,203],{"class":93},[32,2089,289],{"class":119},[32,2091,300],{"class":93},[32,2093,2094],{"class":97}," \u003C\u003C",[32,2096,770],{"class":93},[32,2098,895],{"class":119},[32,2100,2101],{"class":38},"# 20   — left shift (multiply by 2**2)\n",[32,2103,2104,2106,2108,2110,2113,2115,2117],{"class":34,"line":70},[32,2105,203],{"class":93},[32,2107,289],{"class":119},[32,2109,300],{"class":93},[32,2111,2112],{"class":97}," >>",[32,2114,754],{"class":93},[32,2116,1751],{"class":119},[32,2118,2119],{"class":38},"# 2    — right shift (floor-divide by 2**1)\n",[32,2121,2122],{"class":34,"line":79},[32,2123,55],{"emptyLinePlaceholder":54},[32,2125,2126],{"class":34,"line":84},[32,2127,2128],{"class":38},"# Sets also overload these for set algebra (see chapter 08)\n",[32,2130,2131,2133,2136,2138,2140,2142,2144,2146,2149,2151,2154,2156,2158,2160,2162,2165,2168],{"class":34,"line":90},[32,2132,203],{"class":93},[32,2134,2135],{"class":119},"({",[32,2137,212],{"class":93},[32,2139,297],{"class":119},[32,2141,968],{"class":93},[32,2143,297],{"class":119},[32,2145,887],{"class":93},[32,2147,2148],{"class":119},"} ",[32,2150,422],{"class":97},[32,2152,2153],{"class":119}," {",[32,2155,968],{"class":93},[32,2157,297],{"class":119},[32,2159,887],{"class":93},[32,2161,297],{"class":119},[32,2163,2164],{"class":93},"4",[32,2166,2167],{"class":119},"})   ",[32,2169,2170],{"class":38},"# {2, 3} — intersection\n",[32,2172,2173,2175,2177,2179,2181,2183,2185,2187,2189,2192,2194,2196,2198,2200,2202,2204,2206],{"class":34,"line":104},[32,2174,203],{"class":93},[32,2176,2135],{"class":119},[32,2178,212],{"class":93},[32,2180,297],{"class":119},[32,2182,968],{"class":93},[32,2184,297],{"class":119},[32,2186,887],{"class":93},[32,2188,2148],{"class":119},[32,2190,2191],{"class":97},"|",[32,2193,2153],{"class":119},[32,2195,968],{"class":93},[32,2197,297],{"class":119},[32,2199,887],{"class":93},[32,2201,297],{"class":119},[32,2203,2164],{"class":93},[32,2205,2167],{"class":119},[32,2207,2208],{"class":38},"# {1, 2, 3, 4} — union\n",[14,2210,2212,2213,297,2216,2219],{"id":2211},"augmented-assignment-etc","Augmented Assignment (",[29,2214,2215],{},"+=",[29,2217,2218],{},"-=",", etc.)",[19,2221,2222],{"language":21},[23,2223,2225],{"className":25,"code":2224,"language":21,"meta":27,"style":27},"x = 5\nx += 3     # x = x + 3\nprint(x)   # 8\n",[29,2226,2227,2235,2246],{"__ignoreMap":27},[32,2228,2229,2231,2233],{"class":34,"line":35},[32,2230,1376],{"class":119},[32,2232,283],{"class":97},[32,2234,1381],{"class":93},[32,2236,2237,2239,2241,2243],{"class":34,"line":45},[32,2238,1376],{"class":119},[32,2240,2215],{"class":97},[32,2242,787],{"class":93},[32,2244,2245],{"class":38},"     # x = x + 3\n",[32,2247,2248,2250,2253],{"class":34,"line":51},[32,2249,203],{"class":93},[32,2251,2252],{"class":119},"(x)   ",[32,2254,2255],{"class":38},"# 8\n",[1542,2257,2259,2260,2262],{"id":2258},"the-gotcha-on-a-list-is-an-in-place-mutation-but-reassignment-inside-a-function-is-not","The gotcha: ",[29,2261,2215],{}," on a list is an in-place mutation, but reassignment inside a function is not",[19,2264,2265],{"language":21},[23,2266,2268],{"className":25,"code":2267,"language":21,"meta":27,"style":27},"def append_wrong(lst):\n    lst = lst + [4]    # creates a NEW list, rebinds the LOCAL name `lst`\n                        # the caller's list is untouched\n    return lst\n\ndef append_right(lst):\n    lst += [4]          # for lists, += calls __iadd__ -> mutates IN PLACE\n    return lst           # (also rebinds locally, but the object itself changed)\n\noriginal = [1, 2, 3]\nresult = append_wrong(original)\nprint(original)    # [1, 2, 3]        — unchanged\nprint(result)        # [1, 2, 3, 4]\n\noriginal2 = [1, 2, 3]\nresult2 = append_right(original2)\nprint(original2)    # [1, 2, 3, 4]     — MUTATED, because list defines __iadd__\nprint(result2)        # [1, 2, 3, 4]\n",[29,2269,2270,2280,2303,2308,2315,2319,2328,2344,2354,2358,2379,2389,2399,2409,2413,2434,2444,2454],{"__ignoreMap":27},[32,2271,2272,2274,2277],{"class":34,"line":35},[32,2273,112],{"class":97},[32,2275,2276],{"class":115}," append_wrong",[32,2278,2279],{"class":119},"(lst):\n",[32,2281,2282,2285,2287,2290,2293,2295,2297,2300],{"class":34,"line":45},[32,2283,2284],{"class":119},"    lst ",[32,2286,283],{"class":97},[32,2288,2289],{"class":119}," lst ",[32,2291,2292],{"class":97},"+",[32,2294,976],{"class":119},[32,2296,2164],{"class":93},[32,2298,2299],{"class":119},"]    ",[32,2301,2302],{"class":38},"# creates a NEW list, rebinds the LOCAL name `lst`\n",[32,2304,2305],{"class":34,"line":51},[32,2306,2307],{"class":38},"                        # the caller's list is untouched\n",[32,2309,2310,2312],{"class":34,"line":58},[32,2311,133],{"class":97},[32,2313,2314],{"class":119}," lst\n",[32,2316,2317],{"class":34,"line":64},[32,2318,55],{"emptyLinePlaceholder":54},[32,2320,2321,2323,2326],{"class":34,"line":70},[32,2322,112],{"class":97},[32,2324,2325],{"class":115}," append_right",[32,2327,2279],{"class":119},[32,2329,2330,2332,2334,2336,2338,2341],{"class":34,"line":79},[32,2331,2284],{"class":119},[32,2333,2215],{"class":97},[32,2335,976],{"class":119},[32,2337,2164],{"class":93},[32,2339,2340],{"class":119},"]          ",[32,2342,2343],{"class":38},"# for lists, += calls __iadd__ -> mutates IN PLACE\n",[32,2345,2346,2348,2351],{"class":34,"line":84},[32,2347,133],{"class":97},[32,2349,2350],{"class":119}," lst           ",[32,2352,2353],{"class":38},"# (also rebinds locally, but the object itself changed)\n",[32,2355,2356],{"class":34,"line":90},[32,2357,55],{"emptyLinePlaceholder":54},[32,2359,2360,2363,2365,2367,2369,2371,2373,2375,2377],{"class":34,"line":104},[32,2361,2362],{"class":119},"original ",[32,2364,283],{"class":97},[32,2366,976],{"class":119},[32,2368,212],{"class":93},[32,2370,297],{"class":119},[32,2372,968],{"class":93},[32,2374,297],{"class":119},[32,2376,887],{"class":93},[32,2378,1096],{"class":119},[32,2380,2381,2384,2386],{"class":34,"line":109},[32,2382,2383],{"class":119},"result ",[32,2385,283],{"class":97},[32,2387,2388],{"class":119}," append_wrong(original)\n",[32,2390,2391,2393,2396],{"class":34,"line":123},[32,2392,203],{"class":93},[32,2394,2395],{"class":119},"(original)    ",[32,2397,2398],{"class":38},"# [1, 2, 3]        — unchanged\n",[32,2400,2401,2403,2406],{"class":34,"line":130},[32,2402,203],{"class":93},[32,2404,2405],{"class":119},"(result)        ",[32,2407,2408],{"class":38},"# [1, 2, 3, 4]\n",[32,2410,2411],{"class":34,"line":159},[32,2412,55],{"emptyLinePlaceholder":54},[32,2414,2415,2418,2420,2422,2424,2426,2428,2430,2432],{"class":34,"line":164},[32,2416,2417],{"class":119},"original2 ",[32,2419,283],{"class":97},[32,2421,976],{"class":119},[32,2423,212],{"class":93},[32,2425,297],{"class":119},[32,2427,968],{"class":93},[32,2429,297],{"class":119},[32,2431,887],{"class":93},[32,2433,1096],{"class":119},[32,2435,2436,2439,2441],{"class":34,"line":174},[32,2437,2438],{"class":119},"result2 ",[32,2440,283],{"class":97},[32,2442,2443],{"class":119}," append_right(original2)\n",[32,2445,2446,2448,2451],{"class":34,"line":180},[32,2447,203],{"class":93},[32,2449,2450],{"class":119},"(original2)    ",[32,2452,2453],{"class":38},"# [1, 2, 3, 4]     — MUTATED, because list defines __iadd__\n",[32,2455,2456,2458,2461],{"class":34,"line":195},[32,2457,203],{"class":93},[32,2459,2460],{"class":119},"(result2)        ",[32,2462,2408],{"class":38},[1029,2464,2465,2466,1043,2469,2472,2473,2476,2477,1043,2480,2483,2484,2487,2488,2491,2492,2494,2495,2497,2498,2500,2501,2503],{},"The underlying mechanism: ",[29,2467,2468],{},"lst = lst + [4]",[29,2470,2471],{},"__add__",", which returns a ",[1049,2474,2475],{},"brand-new"," list, and rebinding only affects the local name. ",[29,2478,2479],{},"lst += [4]",[29,2481,2482],{},"__iadd__"," if it exists (lists define it, tuples don't) which mutates the object in place and returns ",[29,2485,2486],{},"self"," — so the caller's original object is affected too. For ",[1039,2489,2490],{},"tuples"," (immutable, no ",[29,2493,2482],{},"), ",[29,2496,2215],{}," silently falls back to ",[29,2499,2471],{}," and just rebinds, exactly like the list ",[29,2502,2292],{}," case — no mutation is possible because tuples can't be mutated.",[19,2505,2506],{"language":21},[23,2507,2509],{"className":25,"code":2508,"language":21,"meta":27,"style":27},"t = (1, 2, 3)\nt += (4,)     # falls back to t = t + (4,) — creates a new tuple\nprint(t)       # (1, 2, 3, 4)\n",[29,2510,2511,2532,2548],{"__ignoreMap":27},[32,2512,2513,2516,2518,2520,2522,2524,2526,2528,2530],{"class":34,"line":35},[32,2514,2515],{"class":119},"t ",[32,2517,283],{"class":97},[32,2519,1658],{"class":119},[32,2521,212],{"class":93},[32,2523,297],{"class":119},[32,2525,968],{"class":93},[32,2527,297],{"class":119},[32,2529,887],{"class":93},[32,2531,303],{"class":119},[32,2533,2534,2536,2538,2540,2542,2545],{"class":34,"line":45},[32,2535,2515],{"class":119},[32,2537,2215],{"class":97},[32,2539,1658],{"class":119},[32,2541,2164],{"class":93},[32,2543,2544],{"class":119},",)     ",[32,2546,2547],{"class":38},"# falls back to t = t + (4,) — creates a new tuple\n",[32,2549,2550,2552,2555],{"class":34,"line":51},[32,2551,203],{"class":93},[32,2553,2554],{"class":119},"(t)       ",[32,2556,2557],{"class":38},"# (1, 2, 3, 4)\n",[1542,2559,2561,2562,2564],{"id":2560},"the-genuinely-infamous-one-inside-a-tuple-element","The genuinely infamous one: ",[29,2563,2215],{}," inside a tuple element",[19,2566,2567],{"language":21},[23,2568,2570],{"className":25,"code":2569,"language":21,"meta":27,"style":27},"t = ([1, 2], 3)\nt[0] += [4]\n# TypeError: 'tuple' object does not support item assignment\n# ...BUT the list was mutated anyway before the error!\nprint(t)   # ([1, 2, 4], 3)\n",[29,2571,2572,2594,2611,2616,2621],{"__ignoreMap":27},[32,2573,2574,2576,2578,2581,2583,2585,2587,2590,2592],{"class":34,"line":35},[32,2575,2515],{"class":119},[32,2577,283],{"class":97},[32,2579,2580],{"class":119}," ([",[32,2582,212],{"class":93},[32,2584,297],{"class":119},[32,2586,968],{"class":93},[32,2588,2589],{"class":119},"], ",[32,2591,887],{"class":93},[32,2593,303],{"class":119},[32,2595,2596,2599,2601,2603,2605,2607,2609],{"class":34,"line":45},[32,2597,2598],{"class":119},"t[",[32,2600,1520],{"class":93},[32,2602,971],{"class":119},[32,2604,2215],{"class":97},[32,2606,976],{"class":119},[32,2608,2164],{"class":93},[32,2610,1096],{"class":119},[32,2612,2613],{"class":34,"line":51},[32,2614,2615],{"class":38},"# TypeError: 'tuple' object does not support item assignment\n",[32,2617,2618],{"class":34,"line":58},[32,2619,2620],{"class":38},"# ...BUT the list was mutated anyway before the error!\n",[32,2622,2623,2625,2628],{"class":34,"line":64},[32,2624,203],{"class":93},[32,2626,2627],{"class":119},"(t)   ",[32,2629,2630],{"class":38},"# ([1, 2, 4], 3)\n",[1029,2632,2633,1220,2636,2639,2640,2643,2644,2646,2647,2650,2651,2654,2655,2658,2659,2662,2663,2666],{},[1039,2634,2635],{},"Why",[29,2637,2638],{},"t[0] += [4]"," desugars to ",[29,2641,2642],{},"t[0] = t[0].__iadd__([4])",". The ",[29,2645,2482],{}," call ",[1049,2648,2649],{},"succeeds"," (lists are mutable, so ",[29,2652,2653],{},"t[0]"," — the list — is mutated to ",[29,2656,2657],{},"[1, 2, 4]"," in place and returns itself). But then Python tries to execute ",[29,2660,2661],{},"t[0] = \u003Cresult>"," — assigning into the tuple's slot — which raises ",[29,2664,2665],{},"TypeError"," because tuples don't support item assignment. The mutation already happened before the failed assignment step, leaving the tuple in a state that looks \"impossible\" if you don't know the two-step desugaring.",[14,2668,2670,2671,2674],{"id":2669},"the-walrus-operator-assignment-expressions","The Walrus Operator ",[29,2672,2673],{},":="," (Assignment Expressions)",[1029,2676,2677,2678,2494,2685,2687,2688,2691],{},"Introduced in Python 3.8 (",[2679,2680,2684],"a",{"href":2681,"rel":2682},"https:\u002F\u002Fpeps.python.org\u002Fpep-0572\u002F",[2683],"nofollow","PEP 572",[29,2686,2673],{}," lets you assign a value ",[1039,2689,2690],{},"as part of a larger expression",", avoiding redundant computation or a separate statement.",[19,2693,2694],{"language":21},[23,2695,2697],{"className":25,"code":2696,"language":21,"meta":27,"style":27},"# Before 3.8 — compute twice or add a throwaway statement\ndata = get_data()\nif data:\n    process(data)\n\n# With walrus — assign and test in one expression\nif (data := get_data()):\n    process(data)\n",[29,2698,2699,2704,2714,2722,2727,2731,2736,2748],{"__ignoreMap":27},[32,2700,2701],{"class":34,"line":35},[32,2702,2703],{"class":38},"# Before 3.8 — compute twice or add a throwaway statement\n",[32,2705,2706,2709,2711],{"class":34,"line":45},[32,2707,2708],{"class":119},"data ",[32,2710,283],{"class":97},[32,2712,2713],{"class":119}," get_data()\n",[32,2715,2716,2719],{"class":34,"line":51},[32,2717,2718],{"class":97},"if",[32,2720,2721],{"class":119}," data:\n",[32,2723,2724],{"class":34,"line":58},[32,2725,2726],{"class":119},"    process(data)\n",[32,2728,2729],{"class":34,"line":64},[32,2730,55],{"emptyLinePlaceholder":54},[32,2732,2733],{"class":34,"line":70},[32,2734,2735],{"class":38},"# With walrus — assign and test in one expression\n",[32,2737,2738,2740,2743,2745],{"class":34,"line":79},[32,2739,2718],{"class":97},[32,2741,2742],{"class":119}," (data ",[32,2744,2673],{"class":97},[32,2746,2747],{"class":119}," get_data()):\n",[32,2749,2750],{"class":34,"line":84},[32,2751,2726],{"class":119},[1542,2753,2755],{"id":2754},"real-world-use-avoiding-repeated-expensive-calls-in-a-loop","Real-world use: avoiding repeated expensive calls in a loop",[19,2757,2758],{"language":21},[23,2759,2761],{"className":25,"code":2760,"language":21,"meta":27,"style":27},"import re\n\npattern = re.compile(r\"(\\d+)\")\nlines = [\"order 42 shipped\", \"no numbers here\", \"order 108 shipped\"]\n\n# Without walrus — the match object is computed, discarded, computed again\nresults = []\nfor line in lines:\n    if pattern.search(line):\n        results.append(pattern.search(line).group(1))   # searches TWICE\n\n# With walrus — search once, bind it, reuse it\nresults = []\nfor line in lines:\n    if (match := pattern.search(line)):\n        results.append(match.group(1))\n\nprint(results)   # ['42', '108']\n",[29,2762,2763,2771,2775,2802,2826,2830,2835,2845,2858,2865,2877,2881,2886,2894,2904,2916,2926,2930],{"__ignoreMap":27},[32,2764,2765,2768],{"class":34,"line":35},[32,2766,2767],{"class":97},"import",[32,2769,2770],{"class":119}," re\n",[32,2772,2773],{"class":34,"line":45},[32,2774,55],{"emptyLinePlaceholder":54},[32,2776,2777,2780,2782,2785,2788,2790,2793,2795,2798,2800],{"class":34,"line":51},[32,2778,2779],{"class":119},"pattern ",[32,2781,283],{"class":97},[32,2783,2784],{"class":119}," re.compile(",[32,2786,2787],{"class":97},"r",[32,2789,1498],{"class":126},[32,2791,2792],{"class":93},"(\\d",[32,2794,2292],{"class":97},[32,2796,2797],{"class":93},")",[32,2799,1498],{"class":126},[32,2801,303],{"class":119},[32,2803,2804,2807,2809,2811,2814,2816,2819,2821,2824],{"class":34,"line":58},[32,2805,2806],{"class":119},"lines ",[32,2808,283],{"class":97},[32,2810,976],{"class":119},[32,2812,2813],{"class":126},"\"order 42 shipped\"",[32,2815,297],{"class":119},[32,2817,2818],{"class":126},"\"no numbers here\"",[32,2820,297],{"class":119},[32,2822,2823],{"class":126},"\"order 108 shipped\"",[32,2825,1096],{"class":119},[32,2827,2828],{"class":34,"line":64},[32,2829,55],{"emptyLinePlaceholder":54},[32,2831,2832],{"class":34,"line":70},[32,2833,2834],{"class":38},"# Without walrus — the match object is computed, discarded, computed again\n",[32,2836,2837,2840,2842],{"class":34,"line":79},[32,2838,2839],{"class":119},"results ",[32,2841,283],{"class":97},[32,2843,2844],{"class":119}," []\n",[32,2846,2847,2850,2853,2855],{"class":34,"line":84},[32,2848,2849],{"class":97},"for",[32,2851,2852],{"class":119}," line ",[32,2854,1289],{"class":97},[32,2856,2857],{"class":119}," lines:\n",[32,2859,2860,2862],{"class":34,"line":90},[32,2861,1283],{"class":97},[32,2863,2864],{"class":119}," pattern.search(line):\n",[32,2866,2867,2870,2872,2874],{"class":34,"line":104},[32,2868,2869],{"class":119},"        results.append(pattern.search(line).group(",[32,2871,212],{"class":93},[32,2873,864],{"class":119},[32,2875,2876],{"class":38},"# searches TWICE\n",[32,2878,2879],{"class":34,"line":109},[32,2880,55],{"emptyLinePlaceholder":54},[32,2882,2883],{"class":34,"line":123},[32,2884,2885],{"class":38},"# With walrus — search once, bind it, reuse it\n",[32,2887,2888,2890,2892],{"class":34,"line":130},[32,2889,2839],{"class":119},[32,2891,283],{"class":97},[32,2893,2844],{"class":119},[32,2895,2896,2898,2900,2902],{"class":34,"line":159},[32,2897,2849],{"class":97},[32,2899,2852],{"class":119},[32,2901,1289],{"class":97},[32,2903,2857],{"class":119},[32,2905,2906,2908,2911,2913],{"class":34,"line":164},[32,2907,1283],{"class":97},[32,2909,2910],{"class":119}," (match ",[32,2912,2673],{"class":97},[32,2914,2915],{"class":119}," pattern.search(line)):\n",[32,2917,2918,2921,2923],{"class":34,"line":174},[32,2919,2920],{"class":119},"        results.append(match.group(",[32,2922,212],{"class":93},[32,2924,2925],{"class":119},"))\n",[32,2927,2928],{"class":34,"line":180},[32,2929,55],{"emptyLinePlaceholder":54},[32,2931,2932,2934,2937],{"class":34,"line":195},[32,2933,203],{"class":93},[32,2935,2936],{"class":119},"(results)   ",[32,2938,2939],{"class":38},"# ['42', '108']\n",[1542,2941,2943],{"id":2942},"walrus-inside-comprehensions","Walrus inside comprehensions",[19,2945,2946],{"language":21},[23,2947,2949],{"className":25,"code":2948,"language":21,"meta":27,"style":27},"# Filter and transform using a value that's expensive to compute, without\n# calling the expensive function twice per element\ndef expensive_check(n):\n    return n * n\n\nnumbers = [1, 2, 3, 4, 5, 6]\nsquared_evens = [y for n in numbers if (y := expensive_check(n)) % 2 == 0]\nprint(squared_evens)   # [4, 16, 36]\n",[29,2950,2951,2956,2961,2970,2981,2985,3019,3058],{"__ignoreMap":27},[32,2952,2953],{"class":34,"line":35},[32,2954,2955],{"class":38},"# Filter and transform using a value that's expensive to compute, without\n",[32,2957,2958],{"class":34,"line":45},[32,2959,2960],{"class":38},"# calling the expensive function twice per element\n",[32,2962,2963,2965,2968],{"class":34,"line":51},[32,2964,112],{"class":97},[32,2966,2967],{"class":115}," expensive_check",[32,2969,1473],{"class":119},[32,2971,2972,2974,2977,2979],{"class":34,"line":58},[32,2973,133],{"class":97},[32,2975,2976],{"class":119}," n ",[32,2978,332],{"class":97},[32,2980,1507],{"class":119},[32,2982,2983],{"class":34,"line":64},[32,2984,55],{"emptyLinePlaceholder":54},[32,2986,2987,2990,2992,2994,2996,2998,3000,3002,3004,3006,3008,3010,3012,3014,3017],{"class":34,"line":70},[32,2988,2989],{"class":119},"numbers ",[32,2991,283],{"class":97},[32,2993,976],{"class":119},[32,2995,212],{"class":93},[32,2997,297],{"class":119},[32,2999,968],{"class":93},[32,3001,297],{"class":119},[32,3003,887],{"class":93},[32,3005,297],{"class":119},[32,3007,2164],{"class":93},[32,3009,297],{"class":119},[32,3011,300],{"class":93},[32,3013,297],{"class":119},[32,3015,3016],{"class":93},"6",[32,3018,1096],{"class":119},[32,3020,3021,3024,3026,3029,3031,3033,3035,3038,3040,3043,3045,3048,3050,3052,3054,3056],{"class":34,"line":79},[32,3022,3023],{"class":119},"squared_evens ",[32,3025,283],{"class":97},[32,3027,3028],{"class":119}," [y ",[32,3030,2849],{"class":97},[32,3032,2976],{"class":119},[32,3034,1289],{"class":97},[32,3036,3037],{"class":119}," numbers ",[32,3039,2718],{"class":97},[32,3041,3042],{"class":119}," (y ",[32,3044,2673],{"class":97},[32,3046,3047],{"class":119}," expensive_check(n)) ",[32,3049,151],{"class":97},[32,3051,770],{"class":93},[32,3053,926],{"class":97},[32,3055,734],{"class":93},[32,3057,1096],{"class":119},[32,3059,3060,3062,3065],{"class":34,"line":84},[32,3061,203],{"class":93},[32,3063,3064],{"class":119},"(squared_evens)   ",[32,3066,3067],{"class":38},"# [4, 16, 36]\n",[1029,3069,3070,3072,3073,3076],{},[1039,3071,1857],{},": the walrus operator creates a binding that ",[1039,3074,3075],{},"leaks into the enclosing scope"," — unlike the loop variable of a comprehension (which is scoped to the comprehension in Python 3), a walrus target is NOT scoped to the comprehension.",[19,3078,3079],{"language":21},[23,3080,3082],{"className":25,"code":3081,"language":21,"meta":27,"style":27},"result = [y := x * 2 for x in range(3)]\nprint(y)    # 4 — leaked out of the comprehension into the enclosing scope!\nprint(x)    # NameError — the comprehension's own loop variable `x` did NOT leak\n",[29,3083,3084,3117,3127],{"__ignoreMap":27},[32,3085,3086,3088,3090,3092,3094,3096,3098,3100,3103,3105,3107,3110,3112,3114],{"class":34,"line":35},[32,3087,2383],{"class":119},[32,3089,283],{"class":97},[32,3091,3028],{"class":119},[32,3093,2673],{"class":97},[32,3095,1394],{"class":119},[32,3097,332],{"class":97},[32,3099,770],{"class":93},[32,3101,3102],{"class":97}," for",[32,3104,1394],{"class":119},[32,3106,1289],{"class":97},[32,3108,3109],{"class":93}," range",[32,3111,289],{"class":119},[32,3113,887],{"class":93},[32,3115,3116],{"class":119},")]\n",[32,3118,3119,3121,3124],{"class":34,"line":45},[32,3120,203],{"class":93},[32,3122,3123],{"class":119},"(y)    ",[32,3125,3126],{"class":38},"# 4 — leaked out of the comprehension into the enclosing scope!\n",[32,3128,3129,3131,3134],{"class":34,"line":51},[32,3130,203],{"class":93},[32,3132,3133],{"class":119},"(x)    ",[32,3135,3136],{"class":38},"# NameError — the comprehension's own loop variable `x` did NOT leak\n",[14,3138,3140],{"id":3139},"operator-precedence-abbreviated","Operator Precedence (Abbreviated)",[1029,3142,3143],{},"From highest to lowest (a small but high-value subset):",[3145,3146,3147,3160],"table",{},[3148,3149,3150],"thead",{},[3151,3152,3153,3157],"tr",{},[3154,3155,3156],"th",{},"Precedence",[3154,3158,3159],{},"Operators",[3161,3162,3163,3175,3191,3206,3216,3227,3235,3244,3252,3284,3293,3301],"tbody",{},[3151,3164,3165,3169],{},[3166,3167,3168],"td",{},"Highest",[3166,3170,3171,3174],{},[29,3172,3173],{},"**"," (exponentiation, right-associative)",[3151,3176,3177,3179],{},[3166,3178],{},[3166,3180,3181,3182,297,3185,297,3188],{},"unary ",[29,3183,3184],{},"+x",[29,3186,3187],{},"-x",[29,3189,3190],{},"~x",[3151,3192,3193,3195],{},[3166,3194],{},[3166,3196,3197,297,3199,297,3201,297,3204],{},[29,3198,332],{},[29,3200,142],{},[29,3202,3203],{},"\u002F\u002F",[29,3205,151],{},[3151,3207,3208,3210],{},[3166,3209],{},[3166,3211,3212,297,3214],{},[29,3213,2292],{},[29,3215,209],{},[3151,3217,3218,3220],{},[3166,3219],{},[3166,3221,3222,297,3224],{},[29,3223,731],{},[29,3225,3226],{},">>",[3151,3228,3229,3231],{},[3166,3230],{},[3166,3232,3233],{},[29,3234,422],{},[3151,3236,3237,3239],{},[3166,3238],{},[3166,3240,3241],{},[29,3242,3243],{},"^",[3151,3245,3246,3248],{},[3166,3247],{},[3166,3249,3250],{},[29,3251,2191],{},[3151,3253,3254,3256],{},[3166,3255],{},[3166,3257,3258,3259,297,3261,297,3264,297,3266,297,3269,297,3272,297,3274,297,3276,297,3279,297,3281],{},"comparisons: ",[29,3260,1397],{},[29,3262,3263],{},"\u003C=",[29,3265,1422],{},[29,3267,3268],{},">=",[29,3270,3271],{},"!=",[29,3273,344],{},[29,3275,1289],{},[29,3277,3278],{},"not in",[29,3280,1005],{},[29,3282,3283],{},"is not",[3151,3285,3286,3288],{},[3166,3287],{},[3166,3289,3290],{},[29,3291,3292],{},"not x",[3151,3294,3295,3297],{},[3166,3296],{},[3166,3298,3299],{},[29,3300,1359],{},[3151,3302,3303,3306],{},[3166,3304,3305],{},"Lowest",[3166,3307,3308],{},[29,3309,1679],{},[19,3311,3312],{"language":21},[23,3313,3315],{"className":25,"code":3314,"language":21,"meta":27,"style":27},"# ** is right-associative — surprising if you expect left-to-right\nprint(2 ** 3 ** 2)   # 512, NOT 64!  Evaluated as 2 ** (3 ** 2) = 2 ** 9\n\n# Unary minus binds tighter than ** on the LEFT but not cleanly on both sides\nprint(-2 ** 2)    # -4, NOT 4 — this is -(2 ** 2), because ** binds tighter than unary -\nprint((-2) ** 2)   # 4 — parenthesize to get what you probably meant\n",[29,3316,3317,3322,3344,3348,3353,3373],{"__ignoreMap":27},[32,3318,3319],{"class":34,"line":35},[32,3320,3321],{"class":38},"# ** is right-associative — surprising if you expect left-to-right\n",[32,3323,3324,3326,3328,3330,3333,3335,3337,3339,3341],{"class":34,"line":45},[32,3325,203],{"class":93},[32,3327,289],{"class":119},[32,3329,968],{"class":93},[32,3331,3332],{"class":97}," **",[32,3334,787],{"class":93},[32,3336,3332],{"class":97},[32,3338,770],{"class":93},[32,3340,737],{"class":119},[32,3342,3343],{"class":38},"# 512, NOT 64!  Evaluated as 2 ** (3 ** 2) = 2 ** 9\n",[32,3345,3346],{"class":34,"line":51},[32,3347,55],{"emptyLinePlaceholder":54},[32,3349,3350],{"class":34,"line":58},[32,3351,3352],{"class":38},"# Unary minus binds tighter than ** on the LEFT but not cleanly on both sides\n",[32,3354,3355,3357,3359,3361,3363,3365,3367,3370],{"class":34,"line":64},[32,3356,203],{"class":93},[32,3358,289],{"class":119},[32,3360,209],{"class":97},[32,3362,968],{"class":93},[32,3364,3332],{"class":97},[32,3366,770],{"class":93},[32,3368,3369],{"class":119},")    ",[32,3371,3372],{"class":38},"# -4, NOT 4 — this is -(2 ** 2), because ** binds tighter than unary -\n",[32,3374,3375,3377,3380,3382,3384,3386,3388,3390,3392],{"class":34,"line":70},[32,3376,203],{"class":93},[32,3378,3379],{"class":119},"((",[32,3381,209],{"class":97},[32,3383,968],{"class":93},[32,3385,148],{"class":119},[32,3387,3173],{"class":97},[32,3389,770],{"class":93},[32,3391,737],{"class":119},[32,3393,3394],{"class":38},"# 4 — parenthesize to get what you probably meant\n",[14,3396,3398],{"id":3397},"tips-tricks","💡 Tips & Tricks",[1033,3400,3401,3417,3440,3453,3470],{},[1036,3402,3403,3409,3410,3412,3413,3416],{},[1039,3404,3405,3408],{},[29,3406,3407],{},"math.isclose()"," for float comparisons"," — Never compare floats with ",[29,3411,344],{},"; ",[29,3414,3415],{},"math.isclose(a, b, rel_tol=1e-9)"," handles the inherent binary rounding error correctly, with configurable relative\u002Fabsolute tolerance.",[1036,3418,3419,3425,3426,3429,3430,3433,3434,3436,3437,3439],{},[1039,3420,3421,3424],{},[29,3422,3423],{},"divmod()"," for quotient and remainder together"," — ",[29,3427,3428],{},"divmod(17, 5)"," returns ",[29,3431,3432],{},"(3, 2)"," in one call, avoiding two separate ",[29,3435,3203],{}," and ",[29,3438,151],{}," operations when you need both (common in time\u002Funit conversion code).",[1036,3441,3442,3425,3445,3448,3449,3452],{},[1039,3443,3444],{},"Chained comparisons replace verbose range checks",[29,3446,3447],{},"if 0 \u003C= age \u003C 120:"," is both more readable and marginally faster than ",[29,3450,3451],{},"if age >= 0 and age \u003C 120:"," since the shared subexpression is evaluated once.",[1036,3454,3455,3425,3462,3465,3466,3469],{},[1039,3456,3457,3458,3461],{},"The walrus operator shines in ",[29,3459,3460],{},"while"," loops reading streams",[29,3463,3464],{},"while (chunk := file.read(8192)):"," is the idiomatic replacement for the old ",[29,3467,3468],{},"chunk = file.read(8192); while chunk: ...; chunk = file.read(8192)"," duplicated-read anti-pattern.",[1036,3471,3472,3425,3478,3481,3482,3484,3485,297,3488,3491,3492,3495,3496,1364],{},[1039,3473,3474,3477],{},[29,3475,3476],{},"operator"," module gives you operators as functions",[29,3479,3480],{},"from operator import add, itemgetter, attrgetter"," lets you pass ",[29,3483,2292],{},", item access, or attribute access as first-class callables to ",[29,3486,3487],{},"sorted(key=...)",[29,3489,3490],{},"reduce",", or ",[29,3493,3494],{},"map"," without writing a ",[29,3497,3498],{},"lambda",[14,3500,3502],{"id":3501},"️-edge-cases-gotchas","⚠️ Edge Cases & Gotchas",[1033,3504,3505,3541,3554,3578,3593],{},[1036,3506,3507,3425,3514,3517,3518,297,3520,297,3523,3526,3527,3529,3530,3533,3534,3537,3538,3540],{},[1039,3508,3509,142,3511,3513],{},[29,3510,1679],{},[29,3512,1359],{}," return operands, not booleans, and the truthy-default idiom silently breaks on legitimate falsy values",[29,3515,3516],{},"x = value or default"," treats ",[29,3519,1520],{},[29,3521,3522],{},"\"\"",[29,3524,3525],{},"[]",", and ",[29,3528,665],{}," as \"absent,\" which is wrong whenever those are valid inputs (see the ",[29,3531,3532],{},"set_volume(0)"," example above). Use ",[29,3535,3536],{},"x = default if value is None else value"," whenever ",[29,3539,1219],{}," specifically (not any falsy value) means \"absent.\"",[1036,3542,3543,3425,3546,3549,3550,3553],{},[1039,3544,3545],{},"Floor division floors toward negative infinity, not toward zero",[29,3547,3548],{},"-7 \u002F\u002F 2 == -4",", not ",[29,3551,3552],{},"-3",". Code ported from C\u002FJava that assumes truncation-toward-zero semantics for negative operands will be off by one.",[1036,3555,3556,3425,3563,3566,3567,3570,3571,3566,3574,3577],{},[1039,3557,3558,3560,3561],{},[29,3559,3173],{}," is right-associative; unary minus has lower precedence than ",[29,3562,3173],{},[29,3564,3565],{},"2 ** 3 ** 2"," is ",[29,3568,3569],{},"512"," (right-associative), and ",[29,3572,3573],{},"-2 ** 2",[29,3575,3576],{},"-4"," (unary minus applies after exponentiation). Both surprise programmers coming from languages with different precedence tables — parenthesize when in doubt.",[1036,3579,3580,3589,3590,3592],{},[1039,3581,3582,3585,3586,3588],{},[29,3583,3584],{},"a += b"," mutates in place for mutable types with ",[29,3587,2482],{}," (list) but rebinds for immutable types (tuple, str, int)"," — the same syntax has different aliasing consequences depending entirely on the type of ",[29,3591,2679],{},", which is invisible at the call site without knowing the type.",[1036,3594,3595,3425,3608,3611,3612,3615,3616,3618,3619,3621,3622,3625,3626,142,3628,3630],{},[1039,3596,3597,3598,3600,3601,142,3603,3605,3606],{},"Chained ",[29,3599,1005],{}," comparisons across ",[29,3602,1359],{},[29,3604,1679],{}," don't chain like ",[29,3607,1397],{},[29,3609,3610],{},"a is b is c"," DOES chain (",[29,3613,3614],{},"(a is b) and (b is c)","), but mixing ",[29,3617,1005],{}," with ",[29,3620,1679],{}," doesn't do what a beginner porting mathematical-notation intuition expects, per the ",[29,3623,3624],{},"x == 1 or 2"," example — ",[29,3627,1679],{},[29,3629,1359],{}," never implicitly distribute across a value the way chained comparisons do.",[14,3632,3634],{"id":3633},"spot-the-bug","🧠 Spot the Bug",[1029,3636,3637],{},"What does this print?",[19,3639,3640],{"language":21},[23,3641,3643],{"className":25,"code":3642,"language":21,"meta":27,"style":27},"def get_cache_entry(cache, key):\n    value = cache.get(key) or \"MISS\"\n    return value\n\ncache = {\"count\": 0, \"name\": \"widget\"}\nprint(get_cache_entry(cache, \"count\"))\nprint(get_cache_entry(cache, \"name\"))\nprint(get_cache_entry(cache, \"missing\"))\n",[29,3644,3645,3655,3670,3677,3681,3710,3721,3731],{"__ignoreMap":27},[32,3646,3647,3649,3652],{"class":34,"line":35},[32,3648,112],{"class":97},[32,3650,3651],{"class":115}," get_cache_entry",[32,3653,3654],{"class":119},"(cache, key):\n",[32,3656,3657,3660,3662,3665,3667],{"class":34,"line":45},[32,3658,3659],{"class":119},"    value ",[32,3661,283],{"class":97},[32,3663,3664],{"class":119}," cache.get(key) ",[32,3666,1679],{"class":97},[32,3668,3669],{"class":126}," \"MISS\"\n",[32,3671,3672,3674],{"class":34,"line":51},[32,3673,133],{"class":97},[32,3675,3676],{"class":119}," value\n",[32,3678,3679],{"class":34,"line":58},[32,3680,55],{"emptyLinePlaceholder":54},[32,3682,3683,3686,3688,3690,3693,3695,3697,3699,3702,3704,3707],{"class":34,"line":64},[32,3684,3685],{"class":119},"cache ",[32,3687,283],{"class":97},[32,3689,2153],{"class":119},[32,3691,3692],{"class":126},"\"count\"",[32,3694,1220],{"class":119},[32,3696,1520],{"class":93},[32,3698,297],{"class":119},[32,3700,3701],{"class":126},"\"name\"",[32,3703,1220],{"class":119},[32,3705,3706],{"class":126},"\"widget\"",[32,3708,3709],{"class":119},"}\n",[32,3711,3712,3714,3717,3719],{"class":34,"line":70},[32,3713,203],{"class":93},[32,3715,3716],{"class":119},"(get_cache_entry(cache, ",[32,3718,3692],{"class":126},[32,3720,2925],{"class":119},[32,3722,3723,3725,3727,3729],{"class":34,"line":79},[32,3724,203],{"class":93},[32,3726,3716],{"class":119},[32,3728,3701],{"class":126},[32,3730,2925],{"class":119},[32,3732,3733,3735,3737,3740],{"class":34,"line":84},[32,3734,203],{"class":93},[32,3736,3716],{"class":119},[32,3738,3739],{"class":126},"\"missing\"",[32,3741,2925],{"class":119},[3743,3744,3745,3749,3785,3791,3835,3849],"details",{},[3746,3747,3748],"summary",{},"Answer",[1029,3750,3751,3752,297,3755,297,3758,3760,3761,3764,3765,3767,3768,3771,3772,3775,3776,3778,3779,3781,3782,3784],{},"Prints ",[29,3753,3754],{},"MISS",[29,3756,3757],{},"widget",[29,3759,3754],{},". The bug: ",[29,3762,3763],{},"cache.get(\"count\")"," correctly returns ",[29,3766,1520],{}," (a legitimate cached value), but ",[29,3769,3770],{},"0 or \"MISS\""," evaluates to ",[29,3773,3774],{},"\"MISS\""," because ",[29,3777,1520],{}," is falsy — the function can never distinguish \"the cached value is genuinely ",[29,3780,1520],{},"\" from \"the key is absent.\" Only the second call behaves as intended, because ",[29,3783,3706],{}," happens to be truthy.",[1029,3786,3787,3788,3790],{},"The fix uses a sentinel or explicit ",[29,3789,1219],{}," check against a dict's actual absence signal:",[19,3792,3793],{"language":21},[23,3794,3796],{"className":25,"code":3795,"language":21,"meta":27,"style":27},"def get_cache_entry(cache, key):\n    value = cache.get(key)\n    return \"MISS\" if value is None else value\n",[29,3797,3798,3806,3815],{"__ignoreMap":27},[32,3799,3800,3802,3804],{"class":34,"line":35},[32,3801,112],{"class":97},[32,3803,3651],{"class":115},[32,3805,3654],{"class":119},[32,3807,3808,3810,3812],{"class":34,"line":45},[32,3809,3659],{"class":119},[32,3811,283],{"class":97},[32,3813,3814],{"class":119}," cache.get(key)\n",[32,3816,3817,3819,3822,3824,3827,3829,3831,3833],{"class":34,"line":51},[32,3818,133],{"class":97},[32,3820,3821],{"class":126}," \"MISS\"",[32,3823,1965],{"class":97},[32,3825,3826],{"class":119}," value ",[32,3828,1005],{"class":97},[32,3830,1972],{"class":93},[32,3832,1975],{"class":97},[32,3834,3676],{"class":119},[1029,3836,3837,3838,3840,3841,3844,3845,3848],{},"This still has a narrower edge case if ",[29,3839,1219],{}," is itself a valid cached value — in that case use ",[29,3842,3843],{},"key in cache"," or ",[29,3846,3847],{},"cache.get(key, _SENTINEL) is _SENTINEL"," instead.",[1029,3850,3851,1220,3854,3856,3857,3618,3860,3863,3864,297,3866,297,3868,3491,3870,1364],{},[1039,3852,3853],{},"The lesson",[29,3855,1679],{}," as a \"use this if the left side is missing\" idiom conflates ",[1049,3858,3859],{},"falsy",[1049,3861,3862],{},"absent"," — they are only the same thing if you've proven the valid value space never includes ",[29,3865,1520],{},[29,3867,3522],{},[29,3869,3525],{},[29,3871,665],{},[14,3873,3875],{"id":3874},"key-takeaways","Key Takeaways",[1033,3877,3878,3890,3902,3912,3928],{},[1036,3879,3880,3882,3883,3886,3887,3889],{},[29,3881,142],{}," always returns a ",[29,3884,3885],{},"float"," (true division); ",[29,3888,3203],{}," floors toward negative infinity, it does not truncate toward zero.",[1036,3891,3892,3893,3895,3896,3898,3899,3901],{},"Use ",[29,3894,344],{}," for value comparisons and ",[29,3897,1005],{}," only for ",[29,3900,1219],{},"\u002Fsingleton\u002Fsentinel identity checks — never for general value comparison, even on ints or strings.",[1036,3903,3904,142,3906,3908,3909,3911],{},[29,3905,1359],{},[29,3907,1679],{}," short-circuit and return one of the original operands, not a coerced boolean — this powers (and can silently break) the ",[29,3910,3516],{}," idiom.",[1036,3913,3914,3916,3917,3919,3920,3923,3924,3927],{},[29,3915,2215],{}," mutates in place for types with ",[29,3918,2482],{}," (like ",[29,3921,3922],{},"list",") but rebinds for immutable types (like ",[29,3925,3926],{},"tuple",") — the same syntax, different aliasing behavior depending on type.",[1036,3929,3930,3931,3933,3934,142,3936,3938],{},"The walrus operator (",[29,3932,2673],{},") assigns as part of an expression and is invaluable for avoiding duplicate computation in ",[29,3935,2718],{},[29,3937,3460],{},"\u002Fcomprehensions, but its binding leaks into the enclosing scope.",[3940,3941,3942],"style",{},"html pre.shiki code .sdCPZ, html code.shiki .sdCPZ{--shiki-default:#6A737D;--shiki-github-dark:#6A737D}html pre.shiki code .snvgF, html code.shiki .snvgF{--shiki-default:#005CC5;--shiki-github-dark:#79B8FF}html pre.shiki code .svdQ7, html code.shiki .svdQ7{--shiki-default:#D73A49;--shiki-github-dark:#F97583}html pre.shiki code .sIsaT, html code.shiki .sIsaT{--shiki-default:#6F42C1;--shiki-github-dark:#B392F0}html pre.shiki code .ssxIu, html code.shiki .ssxIu{--shiki-default:#24292E;--shiki-github-dark:#E1E4E8}html pre.shiki code .sJ6F3, html code.shiki .sJ6F3{--shiki-default:#032F62;--shiki-github-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html.github-dark .shiki span {color: var(--shiki-github-dark);background: var(--shiki-github-dark-bg);font-style: var(--shiki-github-dark-font-style);font-weight: var(--shiki-github-dark-font-weight);text-decoration: var(--shiki-github-dark-text-decoration);}html pre.shiki code .sCrzJ, html code.shiki .sCrzJ{--shiki-default:#E36209;--shiki-github-dark:#FFAB70}",{"title":27,"searchDepth":45,"depth":45,"links":3944},[3945,3946,3947,3949,3953,3955,3956,3963,3968,3969,3970,3971,3972],{"id":16,"depth":45,"text":17},{"id":870,"depth":45,"text":871},{"id":1021,"depth":45,"text":3948},"is vs == — Identity vs Equality",{"id":1352,"depth":45,"text":1353,"children":3950},[3951],{"id":1544,"depth":51,"text":3952},"The gotcha: chained comparisons with == create surprising boolean logic",{"id":1673,"depth":45,"text":3954},"Logical Operators — and\u002For Return Operands, Not Booleans",{"id":2004,"depth":45,"text":2005},{"id":2211,"depth":45,"text":3957,"children":3958},"Augmented Assignment (+=, -=, etc.)",[3959,3961],{"id":2258,"depth":51,"text":3960},"The gotcha: += on a list is an in-place mutation, but reassignment inside a function is not",{"id":2560,"depth":51,"text":3962},"The genuinely infamous one: += inside a tuple element",{"id":2669,"depth":45,"text":3964,"children":3965},"The Walrus Operator := (Assignment Expressions)",[3966,3967],{"id":2754,"depth":51,"text":2755},{"id":2942,"depth":51,"text":2943},{"id":3139,"depth":45,"text":3140},{"id":3397,"depth":45,"text":3398},{"id":3501,"depth":45,"text":3502},{"id":3633,"depth":45,"text":3634},{"id":3874,"depth":45,"text":3875},"md",{},"\u002Fpython\u002F03-operators-and-expressions",{"title":5,"description":27},"python\u002F03-operators-and-expressions","vs_MXm97BYmw6WPfgfX9PhAIG9izSDCo5Evz_cZaRj4",1789924651271]