per page, with , order by , clip by
Results of 1 - 10 of about 32 for elif (0.004 sec.)
numbers --- 数の抽象基底クラス 15401
numbers --- 数の抽象基底クラス ソースコード: Lib/numbers.py numbers モジュール ( PEP 3141 ) は、下位になるほど多くの演算を定義する、数値の 抽象基底クラス の階層を定義しています。 このモジュールで定義する型は、どれもインスタンス化を目的とした ... Integral ): def __add__ ( self , other ): if isinstance ( other , MyIntegral ): return do_my_adding_stuff ( self , other ) elif isinstance ( other , OtherTypeIKnowAbout ): return do_my_other_adding_stuff ( self , other ) else : return NotImplemented ... def __radd__ ( self , other ): if isinstance ( other , MyIntegral ): return do_my_adding_stuff ( other , self ) elif isinstance ( other , OtherTypeIKnowAbout ): return do_my_other_adding_stuff ( other , self ) elif isinstance ( other , Int ... egral ): return int ( other ) + int ( self ) elif isinstance ( other , Real ): return float ( other ) + float ( self ) elif isinstance ( other , Complex ): return complex ( ...
https://man.mtool.work/python/3.14/library/numbers.html
Argparse チュートリアル 10584
Argparse チュートリアル author : Tshepang Mbambo このチュートリアルでは、 argparse を丁寧に説明します。 argparse は、Python 標準ライブラリの一部であり、おすすめのコマンドライン引数の解析モジュールです。 注釈 標準ライブラリには、コマンドライ ... () answer = args . square ** 2 if args . verbosity == 2 : print ( f "the square of { args . square } equals { answer } " ) elif args . verbosity == 1 : print ( f " { args . square } ^2 == { answer } " ) else : print ( answer ) 実行してみましょう: $ p ... () answer = args . square ** 2 if args . verbosity == 2 : print ( f "the square of { args . square } equals { answer } " ) elif args . verbosity == 1 : print ( f " { args . square } ^2 == { answer } " ) else : print ( answer ) 実行してみましょう: $ p ... () answer = args . square ** 2 if args . verbosity == 2 : print ( f "the square of { args . square } equals { answer } " ) elif args . verbosity == 1 : print ( f " { args . square } ^2 == { answer } " ) else : print ( answer ) もう一つの action である ...
https://man.mtool.work/python/3.14/howto/argparse.html
タイマーファイル記述子 HOWTO 10423
タイマーファイル記述子 HOWTO リリース : 1.13 この HOWTO では、Linux のタイマーファイル記述子を Python で使う方法を説明します。 使用例 次の例は、タイマーファイル記述子を使って 1 秒に 2 回関数を実行する方法を示します。 # 実用的なスクリプトでは ... setblocking ( False ) print ( f "Accepted connection { conn } from { addr } " ) ep . register ( conn , select . EPOLLIN ) elif conn and fd == conn . fileno (): # 読み取るデータがあるか確認する。 print ( f "Reading data { fd } " ) data = conn . recv ... 上データがないので接続を閉じる print ( f "Closing connection { fd } " ) ep . unregister ( conn ) conn . close () conn = None elif fd in fds : print ( f "Reading timer { fd } " ) count = int . from_bytes ( os . read ( fd , 8 ), byteorder = sys . byteord ... ept () conn . setblocking ( False ) print ( f "Accepted connection { conn } from { addr } " ) select_fds . append ( conn ) elif conn and fd == conn : # Check if there is data to read. print ( f "Reading data { fd } " ) data = conn . recv ( 1024 ) if ...
https://man.mtool.work/python/3.14/howto/timerfd.html
10. 完全な文法仕様 9907
10. 完全な文法仕様 以下は Python の完全な文法で、CPython のパーサを生成するための文法から直接得たものです ( Grammar/python.gram を参照)。 ここでは、コード生成とエラー回復に関する詳細を省略しています。 ここで使う記法は、これまでのドキュメント ... ssion default : '=' expression | invalid_default # If statement # ------------ if_stmt : | 'if' named_expression ':' block elif_stmt | 'if' named_expression ':' block [ else_block ] elif_stmt : | 'elif' named_expression ':' block elif_stmt | 'elif' n ...
https://man.mtool.work/python/3.14/reference/grammar.html
4. その他の制御フローツール 9037
4. その他の制御フローツール 前章で紹介した while 文の他にも、 Python にはいくつか制御フローツールがあり、本章で説明します。 4.1. if 文 おそらく最もおなじみの文型は if 文でしょう。例えば: >>> x = int ( input ( "Please enter an integer: " )) ... Please enter an integer: 42 >>> if x < 0 : ... x = 0 ... print ( 'Negative changed to zero' ) ... elif x == 0 : ... print ( 'Zero' ) ... elif x == 1 : ... print ( 'Single' ) ... else : ... print ( 'More' ) ... More ゼロ個以上 ... の elif 部を使うことができ、 else 部を付けることもできます。キーワード ' elif ' は 'else if' を短くしたもので、過剰なインデントを避 ... けるのに役立ちます。一連の if ... elif ... elif ... は、他の言語における switch 文や case 文の代用となります。 同じ値を複数の定数と比較する場合や、特定の型や属性 ...
https://man.mtool.work/python/3.14/tutorial/controlflow.html
getopt --- C 形式のコマンドラインオプション解析 8522
getopt --- C 形式のコマンドラインオプション解析 ソースコード: Lib/getopt.py 注釈 このモジュールは機能が完成したものとされています。 この API より宣言的で拡張しやすい代替手段として、 optparse モジュールがあります。 コマンドライン引数処理のさ ... " などと表示する usage () sys . exit ( 2 ) output = None verbose = False for o , a in opts : if o == "-v" : verbose = True elif o in ( "-h" , "--help" ): usage () sys . exit () elif o in ( "-o" , "--output" ): output = a else : assert False , "unhand ...
https://man.mtool.work/python/3.14/library/getopt.html
difflib --- 差分の計算の補助 8183
difflib --- 差分の計算の補助 ソースコード: Lib/difflib.py このモジュールはシーケンスを比較するクラスと関数を提供します。 その多くは、テキスト行のシーケンス (文字列のリストや ファイルオブジェクト など) を比較し、相違点を報告する 差分 (diff) ... () if options . u : diff = difflib . unified_diff ( fromlines , tolines , fromfile , tofile , fromdate , todate , n = n ) elif options . n : diff = difflib . ndiff ( fromlines , tolines ) elif options . m : diff = difflib . HtmlDiff () . make_file ( ... l : return fail ( str ( detail )) noisy = 1 qseen = rseen = 0 for opt , val in opts : if opt == "-q" : qseen = 1 noisy = 0 elif opt == "-r" : rseen = 1 whichfile = val if qseen and rseen : return fail ( "can't specify both -q and -r" ) if rseen : if ...
https://man.mtool.work/python/3.14/library/difflib.html
email: 使用例 8183
email : 使用例 ここでは email パッケージを使って電子メールメッセージを読む・書く・送信するいくつかの例を紹介します。より複雑な MIME メッセージについても扱います。 まず、単純なテキストメッセージを作成して送信する方法を見てみましょう (テキスト ... 'content-type' ] . subtype == 'plain' : for line in richest . get_content () . splitlines (): print ( line ) sys . exit () elif richest [ 'content-type' ] . subtype == 'html' : body = richest else : print ( "Don't know how to display {} " . format ( ... richest . get_content_type ())) sys . exit () elif richest [ 'content-type' ] . content_type == 'multipart/related' : body = richest . get_body ( preferencelist = ( 'html' ) ...
https://man.mtool.work/python/3.14/library/email.examples.html
re --- 正規表現操作 8022
re --- 正規表現操作 ソースコード: Lib/re/ このモジュールは Perl に見られる正規表現マッチング操作と同様のものを提供します。 パターンおよび検索される文字列には、Unicode 文字列 ( str ) や 8 ビット文字列 ( bytes ) を使います。ただし、Unicode 文 ... up () column = mo . start () - line_start if kind == 'NUMBER' : value = float ( value ) if '.' in value else int ( value ) elif kind == 'ID' and value in keywords : kind = value elif kind == 'NEWLINE' : line_start = mo . end () line_num += 1 continue ... elif kind == 'SKIP' : continue elif kind == 'MISMATCH' : raise RuntimeError ( f ' { value !r} unexpected on line { line_num } ' ...
https://man.mtool.work/python/3.14/library/re.html
Python で Curses プログラミング 7845
Python で Curses プログラミング Author : A.M. Kuchling, Eric S. Raymond Release : 2.04 概要 このドキュメントでは curses 拡張モジュールでテキストモードディスプレイを制御する方法について記述します。 curses ってなに? curses ライブラリは、VT100 ... ain loop of your program may look something like this: while True : c = stdscr . get_wch () if c == 'p' : PrintDocument () elif c == 'q' : break # while ループを抜ける elif c == curses . KEY_HOME : x = y = 0 curses.ascii モジュールには、整数または 1 ...
https://man.mtool.work/python/3.14/howto/curses.html
PREV 1 2 3 4 NEXT