Slide 1

Slide 1 text

೔ৗੜ׆Ͱ࢖͏ Python Python for Everyday Hayao Suzuki Python Charity Talks in Japan 2021.09 September 11, 2021

Slide 2

Slide 2 text

Who am I ? ͓લ୭Α ໊લ Hayao Suzukiʢླ໦ɹॣʣ Twitter @CardinalXaro ࢓ࣄ Software Developer @ BeProud Inc. › גࣜձࣾϏʔϓϥ΢υ › IT ษڧձࢧԉαʔϏε connpass › ΦϯϥΠϯֶशαʔϏε PyQ › γεςϜ։ൃͷͨΊͷυΩϡϝϯταʔϏε Tracery 2 / 13

Slide 3

Slide 3 text

Who am I ? ؂༁ɾࠪಡٕͨ͠ज़ॻʢൈਮʣ › ೖ໳ Python 3 ୈ 2 ൛ (O’Reilly Japan) › Effective Python ୈ 2 ൛ (O’Reilly Japan) › ػցֶशʹΑΔ࣮༻ΞϓϦέʔγϣϯߏங (O’Reilly Japan) › PyTorch ͱ fastai Ͱ͸͡ΊΔσΟʔϓϥʔχϯά (O’Reilly Japan) › ࣮ફ ࣌ܥྻղੳ (O’Reilly Japan) New! https://xaro.hatenablog.jp/ ʹϦετ͕͋Γ·͢ɻ 3 / 13

Slide 4

Slide 4 text

Who am I ? ൃදϦετʢൈਮʣ › ϨΨγʔ Django ΞϓϦέʔγϣϯͷݱ୅Խ (DjangoCongress JP 2018) › SymPy ʹΑΔ਺ࣜॲཧ (PyCon JP 2018) › Python ͱָ͠Ήॳ౳੔਺࿦ (PyCon mini Hiroshima 2019) › ܅͸ cmath Λ஌͍ͬͯΔ͔ (PyCon mini Shizuoka 2020) › ΠϯϝϞϦʔετϦʔϜ׆༻ज़ (PyCon JP 2020) https://xaro.hatenablog.jp/ ʹϦετ͕͋Γ·͢ɻ 4 / 13

Slide 5

Slide 5 text

ࠓ೔ͷςʔϚ ೔ৗੜ׆Ͱ࢖͏ Python › Python ͷ׆༂৔ॴ͸࢓ࣄ͚ͩͰ͸ͳ͍ʂ › ೔ৗੜ׆Ͱ໾ʹཱͭ Python ඪ४ύοέʔδΛ঺հ͠·͢ɻ 5 / 13

Slide 6

Slide 6 text

ࠓ೔ͷςʔϚ ೔ৗੜ׆Ͱ࢖͏ Python › datetime ύοέʔδ › secrets ύοέʔδ 6 / 13

Slide 7

Slide 7 text

࣮࿩ ൃച೔·ͰͷΧ΢ϯτμ΢ϯ ʰೖ໳ Python 3 ୈ 2 ൛ʱ͕ 2021 ೥ 3 ݄ 22 ೔ʹൃߦ͞ΕΔ͕ɺ͋ͱԿ೔ͩΖ ͏͔ɻ 7 / 13

Slide 8

Slide 8 text

೔෇ܭࢉ datetime ύοέʔδͰ೔෇ܭࢉ >>> import datetime >>> xday = datetime.date(2021, 3, 22) >>> today = datetime.date(2021, 9, 11) >>> f"຋༁ຊ͕ൃߦ͞Ε͔ͯΒ{(today - xday).days}೔ܦա" ' ຋༁ຊ͕ൃߦ͞Ε͔ͯΒ 173 ೔ܦա' େࣄͳه೦೔ܭࢉʹͥͻ datetime ύοέʔδΛ࢖͓͏ʂ 8 / 13

Slide 9

Slide 9 text

࣮࿩ ύεϫʔυΛϥϯμϜʹੜ੒͍ͨ͠ ύεϫʔυΛొ࿥͍͕ͨ͠ɺ࢖͍·Θ͠͸Α͘ͳ͍ɻؾܰʹ࡞Γ͍ͨɻ 9 / 13

Slide 10

Slide 10 text

ύεϫʔυੜ੒ secrets ύοέʔδͰύεϫʔυੜ੒ >>> import secrets >>> secrets.token_urlsafe(8) # จࣈ਺੍ݶʹԠͯ͡దٓௐ੔ 'rwQ_XUqyrbo' େࣄͳύεϫʔυʹͥͻ secrets ύοέʔδΛ࢖͓͏ʂ ˞ύεϫʔυϚωʔδϟͷ࠾༻΋ݕ౼͠·͠ΐ͏ɻ 10 / 13

Slide 11

Slide 11 text

࣮࿩ ൿີͷ࣭໰ʹਅ໘໨ʹ౴͑ͨ͘ͳ͍ मֶཱྀߦͰߦͬͨ৔ॴ͸ʁ ೔ޫʂ ࡳຈʂ தֶߍͷमֶཱྀߦ͸ϨΞέʔεͳͷͰݴ͑·ͤΜɻ 11 / 13

Slide 12

Slide 12 text

ൿີͷ࣭໰ secrets ύοέʔδͰൿີͷ࣭໰΁ճ౴ import secrets hira = "".join([chr(x) for x in range(ord("͋"), ord("Μ") + 1)]) kana = "".join([chr(x) for x in range(ord("Ν"), ord("ϲ") + 1)]) cs = hira + kana for _ in range(15): print("".join([secrets.choice(cs) for x in range(8)])) ൿີͷ࣭໰ʹͥͻ secrets ύοέʔδͰཱͪ޲͔͓͏ʂ 12 / 13

Slide 13

Slide 13 text

ࠓ೔ͷςʔϚ ೔ৗੜ׆Ͱ࢖͏ Python › datetime ύοέʔδɿࠣࡉͳ೔࣌ܭࢉʹ › secrets ύοέʔδɿ҆શͳύεϫʔυੜ੒ʹ 13 / 13