Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Python for Everyday

0350fb935be160186cd72472c9e5543b?s=47 HayaoSuzuki
September 11, 2021

Python for Everyday

Python Charity Talks in Japan 2021.09 Lightning Talk

0350fb935be160186cd72472c9e5543b?s=128

HayaoSuzuki

September 11, 2021
Tweet

Transcript

  1. ೔ৗੜ׆Ͱ࢖͏ Python Python for Everyday Hayao Suzuki Python Charity Talks

    in Japan 2021.09 September 11, 2021
  2. Who am I ? ͓લ୭Α ໊લ Hayao Suzukiʢླ໦ɹॣʣ Twitter @CardinalXaro

    ࢓ࣄ Software Developer @ BeProud Inc. › גࣜձࣾϏʔϓϥ΢υ › IT ษڧձࢧԉαʔϏε connpass › ΦϯϥΠϯֶशαʔϏε PyQ › γεςϜ։ൃͷͨΊͷυΩϡϝϯταʔϏε Tracery 2 / 13
  3. 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
  4. 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
  5. ࠓ೔ͷςʔϚ ೔ৗੜ׆Ͱ࢖͏ Python › Python ͷ׆༂৔ॴ͸࢓ࣄ͚ͩͰ͸ͳ͍ʂ › ೔ৗੜ׆Ͱ໾ʹཱͭ Python ඪ४ύοέʔδΛ঺հ͠·͢ɻ

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

    / 13
  7. ࣮࿩ ൃച೔·ͰͷΧ΢ϯτμ΢ϯ ʰೖ໳ Python 3 ୈ 2 ൛ʱ͕ 2021 ೥

    3 ݄ 22 ೔ʹൃߦ͞ΕΔ͕ɺ͋ͱԿ೔ͩΖ ͏͔ɻ 7 / 13
  8. ೔෇ܭࢉ datetime ύοέʔδͰ೔෇ܭࢉ >>> import datetime >>> xday = datetime.date(2021,

    3, 22) >>> today = datetime.date(2021, 9, 11) >>> f"຋༁ຊ͕ൃߦ͞Ε͔ͯΒ{(today - xday).days}೔ܦա" ' ຋༁ຊ͕ൃߦ͞Ε͔ͯΒ 173 ೔ܦա' େࣄͳه೦೔ܭࢉʹͥͻ datetime ύοέʔδΛ࢖͓͏ʂ 8 / 13
  9. ࣮࿩ ύεϫʔυΛϥϯμϜʹੜ੒͍ͨ͠ ύεϫʔυΛొ࿥͍͕ͨ͠ɺ࢖͍·Θ͠͸Α͘ͳ͍ɻؾܰʹ࡞Γ͍ͨɻ 9 / 13

  10. ύεϫʔυੜ੒ secrets ύοέʔδͰύεϫʔυੜ੒ >>> import secrets >>> secrets.token_urlsafe(8) # จࣈ਺੍ݶʹԠͯ͡దٓௐ੔

    'rwQ_XUqyrbo' େࣄͳύεϫʔυʹͥͻ secrets ύοέʔδΛ࢖͓͏ʂ ˞ύεϫʔυϚωʔδϟͷ࠾༻΋ݕ౼͠·͠ΐ͏ɻ 10 / 13
  11. ࣮࿩ ൿີͷ࣭໰ʹਅ໘໨ʹ౴͑ͨ͘ͳ͍ मֶཱྀߦͰߦͬͨ৔ॴ͸ʁ ೔ޫʂ ࡳຈʂ தֶߍͷमֶཱྀߦ͸ϨΞέʔεͳͷͰݴ͑·ͤΜɻ 11 / 13

  12. ൿີͷ࣭໰ 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
  13. ࠓ೔ͷςʔϚ ೔ৗੜ׆Ͱ࢖͏ Python › datetime ύοέʔδɿࠣࡉͳ೔࣌ܭࢉʹ › secrets ύοέʔδɿ҆શͳύεϫʔυੜ੒ʹ 13

    / 13