Results of 1 - 5 of about 5 for inst (0.004 sec.)
- 8. エラーと例外 11582
- 8. エラーと例外 これまでエラーメッセージについては簡単に触れるだけでしたが、チュートリアル中の例を自分で試していたら、実際にいくつかのエラーメッセージを見ていることでしょう。エラーには (少なくとも) 二つのはっきり異なる種類があります。それは
...rgs を参照しなくてもすべての引数を表示できます。 >>> try : ... raise Exception ( 'spam' , 'eggs' ) ... except Exception as inst : ... print ( type ( inst )) # 例外の型 ... print ( inst . args ) # 引数は .args に格納される ... print ( inst ) # __str__...は args を直接出力しますが、 ... # 例外のサブクラスで上書きされる場合もあります ... x , y = inst . args # args をアンパックする ... print ( 'x =' , x ) ... print ( 'y =' , y ) ... <class 'Exception'> ('spam', 'eggs') ('... - https://man.mtool.work/python/3.14/tutorial/errors.html
- オブジェクトプロトコル (object protocol) 10663
- オブジェクトプロトコル (object protocol) PyObject * Py_GetConstant ( unsigned int constant_id ) 次に属します: Stable ABI (バージョン 3.13 より). 定数への 強参照 を取得します。 constant_id が無効な場合、例外を設定して NULL を返します。 const
...roper error handling, use PyObject_HasAttrStringWithError() , PyObject_GetOptionalAttrString() or PyObject_GetAttrString() instead. PyObject * PyObject_GetAttr ( PyObject * o , PyObject * attr_name ) 戻り値: 新しい参照。 次に属します: Stable ABI . オ...ジェクトに __bases__ 属性 (基底クラスのタプルでなければなりません) を持たせることで、この判定を変えられます。 int PyObject_IsInstance ( PyObject * inst , PyObject * cls ) 次に属します: Stable ABI . inst がクラス cls もしくは cls の子クラスのインスタンス...素に対してチェックします。 少なくとも1つのチェックで 1 が返ったとき、結果は 1 となり、それ以外のとき 0 になります。 cls に __instancecheck__() メソッドがある場合、 PEP 3119 に従って判定するためにこのメソッドが呼び出されます。 そうでなければ、 inst のク... - https://man.mtool.work/python/3.14/c-api/object.html
- 7. 単純文 (simple statement) 9284
- 7. 単純文 (simple statement) 単純文とは、単一の論理行内に収められる文です。単一の行内には、複数の単純文をセミコロンで区切って入れることができます。単純文の構文は以下の通りです: simple_stmt : expression_stmt | assert_stmt | assignment_stmt |
...はクラス属性を参照し、左辺は新しいインスタンス属性を代入のターゲットとして生成するようなとき: class Cls : x = 3 # クラス変数 inst = Cls () inst . x = inst . x + 1 # Cls.x は 3 のままで、inst.x を 4 にする この説明は、 @property で作成したプロパティなど... - https://man.mtool.work/python/3.14/reference/simple_stmts.html
- デスクリプタ ガイド 7887
- デスクリプタ ガイド Author : Raymond Hettinger Contact : <python at rcn dot com> デスクリプタ を使うと、オブジェクトの属性の検索、保存、削除をカスタマイズできます。 本ガイドは4つの大項目から構成されています。 最初の「入門」では基本の紹介をし
...= None , maxvalue = None ): self . minvalue = 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 n...): self . minsize = minsize self . maxsize = maxsize self . predicate = predicate def validate ( self , value ): if not isinstance ( value , str ): raise TypeError ( f 'Expected { value !r} to be a str' ) if self . minsize is not None and len ( valu...obj , objtype ) # data descriptor if hasattr ( obj , '__dict__' ) and name in vars ( obj ): return vars ( obj )[ name ] # instance variable if descr_get is not null : return descr_get ( cls_var , obj , objtype ) # non-data descriptor if cls_var is n... - https://man.mtool.work/python/3.14/howto/descriptor.html
- What's New in Python 2.6 6489
- What's New in Python 2.6 著者 : A.M. Kuchling (amk at amk.ca) この記事では、2008 年 10 月 1 日にリリースされた Python 2.6 の新機能を説明します。 リリース日程は PEP 361 に記載されています。 Python 2.6 の主要なテーマは、言語を大幅に再設計する
...方法を制御できます。 このメソッドは、書式指定子という一つの引数を受け取ります。 def __format__ ( self , format_spec ): if isinstance ( format_spec , unicode ): return unicode ( str ( self )) else : return str ( self ) 単一の値を書式化する組み込み関数...引数のリストを str() で文字列化した 12 バイト文字列を返します。 2.6 での bytes の主な使いみちはオブジェクトの型のテストに isinstance(x, bytes) とすることでしょう。またこれは、 2.x コードが文字列として ASCII 文字と 8 ビットバイトのどちらを意図しているの...ABC) は、それに相当する Python の機能です。 ABC のサポートは、 ABCMeta というメタクラスを含む abc モジュール、組み込みの isinstance() と issubclass() によるそのメタクラスの特別な扱い、そして Python 開発者が広く役立つと考える基本的な ABC 群からなります... - https://man.mtool.work/python/3.14/whatsnew/2.6.html
PREV
1
NEXT