Giter Site home page Giter Site logo

devlights / try-python Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 1.0 3.89 MB

This is my TUTORIAL project for Python.

Home Page: https://devlights.hatenablog.com/

License: MIT License

Python 99.60% Dockerfile 0.40%
python python3 jetbrains pycharm pycharm-ide pytest tutorial

try-python's People

Contributors

devlights avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nomissbowling

try-python's Issues

enumのサンプル

メモ

列挙型を定義するためのライブラリ。

  • enum.Enum
  • enum.IntEnum
  • enum.auto()

[tkinter] tk.Frameで子クラス作成 (07)

import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master: tk.Tk = None):
        super().__init__(master)
        master.title('title')
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        """ここでウィジェットを作成して配置"""

root = tk.Tk()
app = Application(root)
app.mainloop()

argparseのサンプル

メモ

add_help

parserを作る際に add_helpをTrueにすると -h,--helpが有効になる。

add_argument

引数名は、arg_1 のようにする。これによりarg_1は必須引数になる。

オプション引数は --option_1のようにハイフンを2つつける。
これにより、--option_1 はオプション引数となる。略称をつけたい場合は

parser.add_argument('-o', '--option_1', help='option_1のヘルプ')

とする。

引数値の絞り込み

以下の指定で、引数の条件を絞り込みできる。

  • type
  • choices
  • required
parser.add_argument('--option_1', type=float, choices=[0.5,1.0,1.5], required=True)

difflib.Differのサンプル

メモ

difflib.Differ は差分オブジェクトを生成する。

compare メソッドで比較する。

  • - はシーケンス1のみに存在
  • + はシーケンス2のみに存在
  • ? は入力シーケンスのどちらにも存在しない

REFERENCES

shelveのサンプル

メモ

オブジェクトを保存し永続化するためのライブラリ。

永続的な辞書みたいな感じ。使い方も辞書をほぼ同じ。

writebackオプションをTrueで指定するとメモリ上キャッシュと辞書の書き戻しが自然に行われる。更新の整合性を高めたい場合はTrueにする。ただし、その分メモリとパフォーマンスヒットがある。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.