Results of 1 - 10 of about 91 for pass (0.007 sec.)
- Python 2.3 のメソッド解決順序 17450
- Python 2.3 のメソッド解決順序 注釈 これは公式ドキュメントの付録として提供する歴史的な文書です。 ここで説明するメソッド解決順序は Python 2.3 で 導入 されましたが、Python 3 を含む後のバージョンでも使われています。 著者: Michele Simionato 。 概
...化を持つクラスを派生できない場合があります。 その例を示します。 次の階層を考えてください: >>> O = object >>> class X ( O ): pass >>> class Y ( O ): pass >>> class A ( X , Y ): pass >>> class B ( Y , X ): pass この階層は次の継承図で表せます。 O は、新ス...つか見ないと、この規則は理解しにくいでしょう ;-) 使用例 最初の例です。 次の階層を考えます: >>> O = object >>> class F ( O ): pass >>> class E ( O ): pass >>> class D ( O ): pass >>> class C ( D , F ): pass >>> class B ( D , E ): pass >>> class A ( B ,...C ): pass この場合、継承図は次のように描けます: 6 --- Level 3 | O | (more general) / --- \ / | \ | / | \ | / | \ | --- --- --- | Lev... - https://man.mtool.work/python/3.14/howto/mro.html
- timeit --- 小さなコードスニペットの実行時間計測 11225
- timeit --- 小さなコードスニペットの実行時間計測 ソースコード: Lib/timeit.py このモジュールは、小さな Python コードの実行時間を簡単に計測する手段を提供します。 Command-Line Interface と、 Python から呼び出せるインターフェース の両方があります
...説明しています。 Python Interface このモジュールは 3 つの有用な関数と 1 つの公開クラスを持っています: timeit. timeit ( stmt='pass' , setup='pass' , timer=<default timer> , number=1000000 , globals=None ) 指定された文、 setup コード、 timer 関数で Timer...、コードを実行する名前空間を指定します。 バージョン 3.5 で変更: 任意の globals 引数が追加されました。 timeit. repeat ( stmt='pass' , setup='pass' , timer=<default timer> , repeat=5 , number=1000000 , globals=None ) 指定された文、 setup コード、 timer 関...秒を返します。 バージョン 3.3 で変更: デフォルトのタイマーが time.perf_counter() になりました。 class timeit. Timer ( stmt='pass' , setup='pass' , timer=<timer function> , globals=None ) 小さなコード片の実行時間を計測するためのクラスです。 コンストラク... - https://man.mtool.work/python/3.14/library/timeit.html
- symtable --- コンパイラーの記号表へのアクセス 8286
- symtable --- コンパイラーの記号表へのアクセス ソースコード: Lib/symtable.py 記号表は、バイトコードを生成する直前にコンパイラーが AST から生成します。 コード内のすべての識別子のスコープを決める役割を担います。 symtable はこれらの記号表を調べ
...は、 get_methods() の結果には含まれません。 例えば: >>> import symtable >>> st = symtable . symtable ( ''' ... def outer(): pass ... ... class A: ... def f(): ... def w(): pass ... ... def g(self): pass ... ... @classmethod ... async def h(cls): pass...... ... global outer ... def outer(self): pass ... ''' , 'test' , 'exec' ) >>> class_A = st . get_children ()[ 2 ] >>> class_A . get_methods () ('f', 'g', 'h') A().f() は...が関数または class 文のターゲットとして使われるならば、真です。 例えば: >>> table = symtable . symtable ( "def some_func(): pass" , "string" , "exec" ) >>> table . lookup ( "some_func" ) . is_namespace () True 一つの名前が複数のオブジェクトに束縛されう... - https://man.mtool.work/python/3.14/library/symtable.html
- typing --- 型ヒントのサポート 8113
- typing --- 型ヒントのサポート Added in version 3.5. ソースコード: Lib/typing.py 注釈 Python ランタイムは、関数や変数の型アノテーションを強制しません。型アノテーションは、 type checkers や IDE、linterなどのサードパーティーツールで使われます。
...ort NewType UserId = NewType ( 'UserId' , int ) # 実行時にエラーとなり、型チェックも通らない class AdminUserId ( UserId ): pass しかし、 'derived' である NewType をもとにした NewType は作ることが出来ます: from typing import NewType UserId = NewType (...ない関数を定義するためにも使えます。 from typing import Never # または NoReturn def never_call_me ( arg : Never ) -> None : pass def int_or_str ( arg : int | str ) -> None : never_call_me ( arg ) # 型チェッカーのエラー match arg : case int (): print (...ping import Self , reveal_type class Foo : def return_self ( self ) -> Self : ... return self class SubclassOfFoo ( Foo ): pass reveal_type ( Foo () . return_self ()) # 表示される型は "Foo" reveal_type ( SubclassOfFoo () . return_self ()) # 表示される... - https://man.mtool.work/python/3.14/library/typing.html
- 10. 完全な文法仕様 7953
- 10. 完全な文法仕様 以下は Python の完全な文法で、CPython のパーサを生成するための文法から直接得たものです ( Grammar/python.gram を参照)。 ここでは、コード生成とエラー回復に関する詳細を省略しています。 ここで使う記法は、これまでのドキュメント
...e # * Rule names starting with "invalid_" are used for specialized syntax errors # - These rules are NOT used in the first pass of the parser. # - Only if the first pass fails to parse, a second pass including the invalid # rules will be executed. #...- If the parser fails in the second phase with a generic syntax error, the # location of the generic failure of the first pass will be used (this avoids # reporting incorrect locations due to the invalid rules). # - The order of the alternatives inv...throw a SyntaxError. simple_stmt : | assignment | type_alias | star_expressions | return_stmt | import_stmt | raise_stmt | pass_stmt | del_stmt | yield_stmt | assert_stmt | break_stmt | continue_stmt | global_stmt | nonlocal_stmt compound_stmt : | fu... - https://man.mtool.work/python/3.14/reference/grammar.html
- 4. その他の制御フローツール 7873
- 4. その他の制御フローツール 前章で紹介した while 文の他にも、 Python にはいくつか制御フローツールがあり、本章で説明します。 4.1. if 文 おそらく最もおなじみの文型は if 文でしょう。例えば: >>> x = int ( input ( "Please enter an integer: " ))
...プの else 句は break されなかった場合に実行されます。 try 文と例外についての詳細は 例外を処理する を参照してください。 4.6. pass 文 pass 文は何もしません。 pass は、文を書くことが構文上要求されているが、プログラム上何の動作もする必要がない時に使われま...す: >>> while True : ... pass # キーボード割り込み(Ctrl+C)のためのビジーウェイト ... これは最小のクラスを作るときによく使われる方法です: >>> class MyEmp...tyClass : ... pass ... pass のもう 1 つの使い道は、新しいコードを書いているときの関数や条件文の仮置きの本体としてです。こうすることで、より抽... - https://man.mtool.work/python/3.14/tutorial/controlflow.html
- 7. 単純文 (simple statement) 7621
- 7. 単純文 (simple statement) 単純文とは、単一の論理行内に収められる文です。単一の行内には、複数の単純文をセミコロンで区切って入れることができます。単純文の構文は以下の通りです: simple_stmt : expression_stmt | assert_stmt | assignment_stmt |
...augmented_assignment_stmt | annotated_assignment_stmt | pass_stmt | del_stmt | return_stmt | yield_stmt | raise_stmt | break_stmt | continue_stmt | import_stmt | future_stmt | global_...る必要はありません。 __debug__ への代入は不正な操作です。組み込み変数の値は、インタプリタが開始するときに決定されます。 7.4. pass 文 pass_stmt : "pass" pass はヌル操作 (null operation) です --- pass が実行されても、何も起きません。 pass は、構文法的には...文が必要だが、コードとしては何も実行したくない場合のプレースホルダとして有用です。例えば: def f ( arg ): pass # (今のところ) 何もしない関数 class C : pass # (今のところ) メソッドを持たないクラス 7.5. del 文 del_stmt : "del" target_l... - https://man.mtool.work/python/3.14/reference/simple_stmts.html
- ast --- 抽象構文木 7381
- ast --- 抽象構文木 ソースコード: Lib/ast.py ast モジュールは、Python の抽象構文を表す木を Python アプリケーションで処理するための機能を提供します。 抽象構文自体は Python のリリースごとに変わる可能性がありますが、このモジュールを使えば、現在
..., alias * names , int ? level ) | Global ( identifier * names ) | Nonlocal ( identifier * names ) | Expr ( expr value ) | Pass | Break | Continue -- col_offset is the byte offset in the utf8 string the parser uses attributes ( int lineno , int col_o...Module( body=[ Delete( targets=[ Name(id='x', ctx=Del()), Name(id='y', ctx=Del()), Name(id='z', ctx=Del())])]) class ast. Pass pass 文をあらわします。 >>> print ( ast . dump ( ast . parse ( 'pass' ), indent = 4 )) Module( body=[ Pass()]) class ast....ます。 body はノードのリストです。 >>> print ( ast . dump ( ast . parse ( """ \ ... try: ... a + 1 ... except TypeError: ... pass ... """ ), indent = 4 )) Module( body=[ Try( body=[ Expr( value=BinOp( left=Name(id='a', ctx=Load()), op=Add(), right=Cons... - https://man.mtool.work/python/3.14/library/ast.html
- inspect --- 活動中のオブジェクトを調査する 7142
- inspect --- 活動中のオブジェクトを調査する ソースコード: Lib/inspect.py inspect モジュールは、モジュール、クラス、メソッド、関数、トレースバック、フレームオブジェクト、コードオブジェクトなど、実行中のオブジェクトの情報を取得する便利な関数を
...対する Signature オブジェクトを返します: >>> from inspect import signature >>> def foo ( a , * , b : int , ** kwargs ): ... pass >>> sig = signature ( foo ) >>> str ( sig ) '(a, *, b: int, **kwargs)' >>> str ( sig . parameters [ 'b' ]) 'b: int' >>> si...n をコピーされた Signature インスタンスから削除したい場合、 Signature.empty を渡してください。 >>> def test ( a , b ): ... pass ... >>> sig = signature ( test ) >>> new_sig = sig . replace ( return_annotation = "new return anno" ) >>> str ( new_sig )...オブジェクトを返します。 このメソッドは Signature からサブクラスを作る作業を簡素化します: class MySignature ( Signature ): pass sig = MySignature . from_callable ( sum ) assert isinstance ( sig , MySignature ) このメソッドの振る舞いは、上記を除けば s... - https://man.mtool.work/python/3.14/library/inspect.html
- modulefinder --- スクリプト中で使用されているモジュールの検索 7142
- modulefinder --- スクリプト中で使用されているモジュールの検索 ソースコード: Lib/modulefinder.py このモジュールでは、スクリプト中で import されているモジュールセットを調べるために使える ModuleFinder クラスを提供しています。 modulefinder.py は
...の使用例 解析対象のスクリプトはこれ (bacon.py) です: import re , itertools try : import baconhameggs except ImportError : pass try : import guido.python.ham except ImportError : pass bacon.py のレポートを出力するスクリプトです: from modulefinder imp... - https://man.mtool.work/python/3.14/library/modulefinder.html