Results of 1 - 10 of about 100 for raise (0.006 sec.)
- 8. エラーと例外 17112
- 8. エラーと例外 これまでエラーメッセージについては簡単に触れるだけでしたが、チュートリアル中の例を自分で試していたら、実際にいくつかのエラーメッセージを見ていることでしょう。エラーには (少なくとも) 二つのはっきり異なる種類があります。それは
...D の順に出力されます: class B ( Exception ): pass class C ( B ): pass class D ( C ): pass for cls in [ B , C , D ]: try : raise cls () except D : print ( "D" ) except C : print ( "C" ) except B : print ( "B" ) except 節 が逆に並んでいた場合 ( except...例外型は利便性のために __str__() を定義しており、 明示的に .args を参照しなくてもすべての引数を表示できます。 >>> try : ... raise Exception ( 'spam' , 'eggs' ) ... except Exception as inst : ... print ( type ( inst )) # 例外の型 ... print ( inst . args...( "データを整数に変換できません。" ) except Exception as err : print ( f "予期せぬエラー { err =} , { type ( err ) =} " ) raise try ... except 文には、オプションで else 節 (else clause) を設けることができます。 else 節を設ける場合、全ての except 節よ... - https://man.mtool.work/python/3.14/tutorial/errors.html
- sys.monitoring --- 実行イベントモニタリング 9934
- sys.monitoring --- 実行イベントモニタリング Added in version 3.12. 注釈 sys.monitoring は sys モジュール内の名前空間で、独立したモジュールではありません。 import sys.monitoring は ModuleNotFoundError で失敗します。 代わりに import sys を実行
...が右に進む。 sys.monitoring.events. CALL Python コードでの呼び出し (イベントは呼び出しの前に発生)。 sys.monitoring.events. C_RAISE Python 関数以外の呼び出し可能オブジェクトからの例外の送出 (イベントは呼び出しの終了後に発生)。 sys.monitoring.events. C_RE...IELD Python 関数からの yield (yield の直前に発生し、呼び出された関数のフレームはスタック上にある)。 sys.monitoring.events. RAISE 例外が送出される。 ただし STOP_ITERATION イベントを発生させるものは除く。 sys.monitoring.events. RERAISE 例えば finally ブ...上します。 付随するイベント 付随するイベントもほかのイベントと同じように監視できますが、別のイベントによって制御されます: C_RAISE C_RETURN C_RETURN と C_RAISE は CALL によって制御されます。 C_RETURN と C_RAISE を受け取れるのは、対応する CALL を監視して... - https://man.mtool.work/python/3.14/library/sys.monitoring.html
- デスクリプタ ガイド 9349
- デスクリプタ ガイド Author : Raymond Hettinger Contact : <python at rcn dot com> デスクリプタ を使うと、オブジェクトの属性の検索、保存、削除をカスタマイズできます。 本ガイドは4つの大項目から構成されています。 最初の「入門」では基本の紹介をし
...t__ ( self , * options ): self . options = set ( options ) def validate ( self , value ): if value not in self . options : raise ValueError ( f 'Expected { value !r} to be one of { self . options !r} ' ) class Number ( Validator ): def __init__ ( self...invalue = minvalue self . maxvalue = maxvalue def validate ( self , value ): if not isinstance ( value , ( int , float )): raise TypeError ( f 'Expected { value !r} to be an int or float' ) if self . minvalue is not None and value < self . minvalue :...Expected { value !r} to be at least { self . minvalue !r} ' ) if self . maxvalue is not None and value > self . maxvalue : raise ValueError ( f 'Expected { value !r} to be no more than { self . maxvalue !r} ' ) class String ( Validator ): def __init__... - https://man.mtool.work/python/3.14/howto/descriptor.html
- 7. 単純文 (simple statement) 9349
- 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_stmt | nonlocal_stmt | type_stmt 7.1. 式文 (express..." expression [ "," expression ] 単純な形式 assert expression は、次のコードと等価です。 if __debug__ : if not expression : raise AssertionError 拡張形式 assert expression1, expression2 は、次のコードと等価です。 if __debug__ : if not expression1 : rai...space, depending on whether the name occurs in a global statement in the same code block. Trying to delete an unbound name raises a NameError exception. 属性参照や添字参照の削除は、対象の一次語オブジェクトに委ねられます。 スライスの削除は、通常は適切な... - https://man.mtool.work/python/3.14/reference/simple_stmts.html
- モニタリング C API 8751
- モニタリング C API バージョン 3.13 で追加。 拡張モジュールがイベントモニタリングシステムと連携する必要がある場合があります。 イベントの購読やコールバックの登録は、 sys.monitoring が公開する Python API で行えます。 実行イベントの発生 以下の関
...t PyMonitoring_FirePyThrowEvent ( PyMonitoringState * state , PyObject * codelike , int32_t offset ) 現在の例外 ( PyErr_GetRaisedException() が返すもの) を使って PY_THROW イベントを発生させます。 int PyMonitoring_FireRaiseEvent ( PyMonitoringState * s...tate , PyObject * codelike , int32_t offset ) 現在の例外 ( PyErr_GetRaisedException() が返すもの) を使って RAISE イベントを発生させます。 int PyMonitoring_FireCRaiseEvent ( PyMonitoringState * sta...te , PyObject * codelike , int32_t offset ) 現在の例外 ( PyErr_GetRaisedException() が返すもの) を使って C_RAISE イベントを発生させます。 int PyMonitoring_FireReraiseEvent ( PyMonitoringState *... - https://man.mtool.work/python/3.14/c-api/monitoring.html
- bisect --- 配列二分法アルゴリズム 8361
- bisect --- 配列二分法アルゴリズム ソースコード: Lib/bisect.py このモジュールは、挿入のたびにリストをソートすることなく、ソートされた順序でリストを維持するためのサポートを提供します。 コストのかかる比較演算を伴う長いリストの場合、これは線形検
...x ( a , x ): 'xにちょうど等しい左端の値を見つける' i = bisect_left ( a , x ) if i != len ( a ) and a [ i ] == x : return i raise ValueError def find_lt ( a , x ): 'xより小さい右端の値を見つける' i = bisect_left ( a , x ) if i : return a [ i - 1 ] rais...e ValueError def find_le ( a , x ): 'x以下の右端の値を見つける' i = bisect_right ( a , x ) if i : return a [ i - 1 ] raise ValueError def find_gt ( a , x ): 'xより大きい左端の値を見つける' i = bisect_right ( a , x ) if i != len ( a ): return a [...i ] raise ValueError def find_ge ( a , x ): 'x以上の左端の要素を見つける' i = bisect_left ( a , x ) if i != len ( a ): return a [ i... - https://man.mtool.work/python/3.14/library/bisect.html
- doctest --- 対話型の Python の例をテストする 7568
- doctest --- 対話型の Python の例をテストする ソースコード: Lib/doctest.py doctest モジュールは Python の対話セッションに見えるテキストを探し、そのセッションを実行して記載どおりに動作するか検証します。 主な使い方は次のとおりです。 モジュール
...せん: >>> factorial(1e100) Traceback (most recent call last): ... OverflowError: n too large """ import math if not n >= 0 : raise ValueError ( "n must be >= 0" ) if math . floor ( n ) != n : raise ValueError ( "n must be exact integer" ) if n + 1 == n...: # 1e300 のような値を検出 raise OverflowError ( "n too large" ) result = 1 factor = 2 while factor <= n : result *= factor factor += 1 return result if __...ます。これは通常トレースバックの最後の行ですが、例外が複数行の詳細情報を持っている場合、複数の行にわたることもあります: >>> raise ValueError ( 'multi \n line \n detail' ) Traceback (most recent call last): File "<stdin>" , line 1 , in <module> ValueErr... - https://man.mtool.work/python/3.14/library/doctest.html
- 8. 複合文 (compound statement) 7477
- 8. 複合文 (compound statement) 複合文には、他の文 (のグループ) が入ります; 複合文は、中に入っている他の文の実行の制御に何らかのやり方で影響を及ぼします。一般的には、複合文は複数行にまたがって書かれますが、全部の文を一行に連ねた単純な書き方も
..."finally" ":" suite ] try3_stmt : "try" ":" suite "finally" ":" suite 例外に関するその他の情報は 例外 節にあります。また、 raise 文の使用による例外の生成に関する情報は、 raise 文 節にあります。 バージョン 3.14 で変更: 複数の例外型を指定するときに、それ...けると、 sys モジュールに格納されている例外の値が、一つ前の値に戻ります: >>> print ( sys . exception ()) None >>> try : ... raise TypeError ... except : ... print ( repr ( sys . exception ())) ... try : ... raise ValueError ... except : ... print ( rep...except* 節の内部で送出または再送出された例外とまとめます。 まとめられた例外グループは、その先へ伝播します。 >>> try : ... raise ExceptionGroup ( "eg" , ... [ ValueError ( 1 ), TypeError ( 2 ), OSError ( 3 ), OSError ( 4 )]) ... except * TypeError as... - https://man.mtool.work/python/3.14/reference/compound_stmts.html
- 組み込み例外 7373
- 組み込み例外 Python において、すべての例外は BaseException から派生したクラスのインスタンスでなければなりません。特定のクラスを言及する except 節を伴う try 文において、その節はそのクラスから派生した例外クラスも処理しますが、そのクラスの派生
...は、処理中の例外が自動的に設定されます。 例外の処理は、 except 節、 finally 節、 with 文を使うときに行われることがあります。 raise とともに from を使うと、この暗黙の例外コンテキストに明示的な原因を付け加えられます。 raise new_exc from original_exc from...には、その値が設定されます。 __cause__ を設定すると、 __suppress_context__ 属性も暗黙的に True に設定されます。 そのため、 raise new_exc from None を使うと、表示上は古い例外を新しい例外で置き換えられます (例えば KeyError から AttributeError への変換)。...トレースバックに同じようにフレームが追加されます。 try : ... except SomeException : tb = sys . exception () . __traceback__ raise OtherException ( ... ) . with_traceback ( tb ) __traceback__ この例外に関連付けられた トレースバックオブジェクト を保持する... - https://man.mtool.work/python/3.14/builtins/exceptions.html
- リモートデバッグのアタッチプロトコル 7177
- リモートデバッグのアタッチプロトコル このプロトコルを使うと、外部ツールから実行中の CPython プロセスにアタッチし、Python コードをリモートで実行できます。 別の Python プロセスへのアタッチには、プラットフォームによって追加の権限や設定が必要な
...bug_offsets = parse_debug_offsets ( data ) # 手順 3: 構造体の内容を検証する if debug_offsets . cookie != EXPECTED_COOKIE : raise RuntimeError ( "Invalid or missing debug cookie" ) if debug_offsets . version != LOCAL_PYTHON_VERSION : raise RuntimeError...( "Mismatch between caller and target Python versions" ) if debug_offsets . free_threaded != LOCAL_FREE_THREADED : raise RuntimeError ( "Mismatch in free-threaded configuration" ) return debug_offsets 警告 プロセスの一時停止を推奨 競合状態を避...g_offsets . runtime_state . interpreters_head ) interp_addr = read_pointer ( pid , interp_head_ptr ) if interp_addr == 0 : raise RuntimeError ( "No interpreter found in the target process" ) # 手順 2: インタープリタから threads_main ポインターを読む t... - https://man.mtool.work/python/3.14/howto/remote_debugging.html