Results of 1 - 10 of about 107 for tuple (0.011 sec.)
- typing --- 型ヒントのサポート 14028
- typing --- 型ヒントのサポート Added in version 3.5. ソースコード: Lib/typing.py 注釈 Python ランタイムは、関数や変数の型アノテーションを強制しません。型アノテーションは、 type checkers や IDE、linterなどのサードパーティーツールで使われます。
...化するのに有用です。例えば: from collections.abc import Sequence type ConnectionOptions = dict [ str , str ] type Address = tuple [ str , int ] type Server = tuple [ Address , ConnectionOptions ] def broadcast_message ( message : str , servers : Sequen...アノテーションと # 以下のアノテーションを同等のものとして扱う。 def broadcast_message ( message : str , servers : Sequence [ tuple [ tuple [ str , int ], dict [ str , str ]]] ) -> None : ... type 文はPython 3.12で新しく導入されました。 後方互換性のために...同じ型ではない要素を持つことは、慣用的なPythonコードでは一般的です。 このため、タプルはPythonの型システムの中でも特殊です。 tuple は任意の数の型引数を受け入れます。 # OK: ``x`` に代入されるのは長さ1のタプルで、要素は int x : tuple [ int ] = ( 5 ,) # OK... - https://man.mtool.work/python/3.14/library/typing.html
- itertools --- 効率的なループ用のイテレータ生成関数群 10677
- itertools --- 効率的なループ用のイテレータ生成関数群 このモジュールは イテレータ を構築する部品を実装しています。プログラム言語 APL, Haskell, SML からアイデアを得ていますが、 Python に適した形に修正されています。 このモジュールは、高速でメモ
...DEFG', 3) → ABC DEF G if n < 1 : raise ValueError ( 'n must be at least one' ) iterator = iter ( iterable ) while batch := tuple ( islice ( iterator , n )): if strict and len ( batch ) != n : raise ValueError ( 'batched(): incomplete batch' ) yield ba...tions ( iterable , r ): # combinations('ABCD', 2) → AB AC AD BC BD CD # combinations(range(4), 3) → 012 013 023 123 pool = tuple ( iterable ) n = len ( pool ) if r > n : return indices = list ( range ( r )) yield tuple ( pool [ i ] for i in indices )...+ n - r : break else : return indices [ i ] += 1 for j in range ( i + 1 , r ): indices [ j ] = indices [ j - 1 ] + 1 yield tuple ( pool [ i ] for i in indices ) itertools. combinations_with_replacement ( iterable , r ) 入力 iterable から、それぞれの要... - https://man.mtool.work/python/3.14/library/itertools.html
- traceback --- スタックトレースの表示または取得 9808
- traceback --- スタックトレースの表示または取得 ソースコード: Lib/traceback.py このモジュールは、Python プログラムのスタックトレースを抽出、書式化、表示する標準的なインターフェースを提供します。 インタープリタのデフォルトのトレースバック表示
...limit 引数は print_stack() と同じ意味を持ちます。 traceback. print_list ( extracted_list , file = None ) Print the list of tuples as returned by extract_tb() or extract_stack() as a formatted stack trace to the given file. If file is None , the output...たものも含められます。 lookup_line が False の場合、 FrameSummary の line 属性にアクセスするまでソースコードを取得しません ( tuple への変換時にも、この属性へのアクセスが発生します)。 line を直接指定すると、ソースコード行の取得を完全に避けられます。 loca...まざまな方法を示します。 import sys , traceback def lumberjack (): bright_side_of_life () def bright_side_of_life (): return tuple ()[ 0 ] try : lumberjack () except IndexError as exc : print ( "*** print_tb:" ) traceback . print_tb ( exc . __traceback_... - https://man.mtool.work/python/3.14/library/traceback.html
- プログラミング FAQ 9680
- プログラミング FAQ 一般的な質問 ブレークポイントやステップ実行ができる、ソースコードレベルのデバッガはありますか? はい。 Python 用のデバッガについては次に解説してあり、組み込みの breakpoint() 関数でそれらのデバッガに処理を移せます。 pdb モジ
...プルや整数は変更しません( a_list += [1, 2, 3] は a_list.extend([1, 2, 3]) と同じ意味で、そして a_list を変更しますが、 some_tuple += (1, 2, 3) と some_int += 1 は新しいオブジェクトを作ります)。 言い換えると: mutable オブジェクト ( list , dict , set のよ...作を用いてそれを変えることができ、それを参照する どの変数にも その変更が反映されます。 immutable オブジェクト ( str , int , tuple のような) の場合は、それを参照する どの変数も同じ値を参照しますが、その値を新しい値に変換する操作では 常に新しいオブジェク...トは次のようになります: >>> help ( divmod ) Help on built-in function divmod in module builtins: divmod(x, y, /) Return the tuple (x//y, x%y). Invariant: div*y + mod == x. この引数リストの末尾にスラッシュは、この2つの仮引数が両方とも位置専用引数であるこ... - https://man.mtool.work/python/3.14/faq/programming.html
- ast --- 抽象構文木 9565
- ast --- 抽象構文木 ソースコード: Lib/ast.py ast モジュールは、Python の抽象構文を表す木を Python アプリケーションで処理するための機能を提供します。 抽象構文自体は Python のリリースごとに変わる可能性がありますが、このモジュールを使えば、現在
...( expr value , expr_context ctx ) | Name ( identifier id , expr_context ctx ) | List ( expr * elts , expr_context ctx ) | Tuple ( expr * elts , expr_context ctx ) -- can appear only in Subscript | Slice ( expr ? lower , expr ? upper , expr ? step ) -...( identifier name , expr ? bound , expr ? default_value ) | ParamSpec ( identifier name , expr ? default_value ) | TypeVarTuple ( identifier name , expr ? default_value ) attributes ( int lineno , int col_offset , int end_lineno , int end_col_offset...at_spec は同時に指定できます。 FormattedValue.format_spec と同じ意味を持ちます。 class ast. List ( elts , ctx ) class ast. Tuple ( elts , ctx ) リストまたはタプルをあらわします。 elts は内包する要素を表現するノードのリストを保持します。 ctx はコンテナ... - https://man.mtool.work/python/3.14/library/ast.html
- random --- 疑似乱数を生成する 9194
- random --- 疑似乱数を生成する ソースコード: Lib/random.py このモジュールでは様々な分布をもつ擬似乱数生成器を実装しています。 整数用に、ある範囲からの一様な選択があります。 シーケンス用には、シーケンスからのランダムな要素の一様な選択、リスト
...random_product ( * iterables , repeat = 1 ): "次からランダムに選択: itertools.product(*iterables, repeat=repeat)" pools = tuple ( map ( tuple , iterables )) * repeat return tuple ( map ( random . choice , pools )) def random_permutation ( iterable ,...r = None ): "次からランダムに選択: itertools.permutations(iterable, r)" pool = tuple ( iterable ) r = len ( pool ) if r is None else r return tuple ( random . sample ( pool , r )) def random_combination ( it...erable , r ): "次からランダムに選択: itertools.combinations(iterable, r)" pool = tuple ( iterable ) n = len ( pool ) indices = sorted ( random . sample ( range ( n ), r )) return tuple ( pool [ i ] for i in in... - https://man.mtool.work/python/3.14/library/random.html
- 3. データモデル 8938
- 3. データモデル 3.1. オブジェクト、値、および型 オブジェクト は、Python がデータを抽象化したものです。 Python プログラム内のすべてのデータは、オブジェクトまたはオブジェクト間の関係として表されます。 コードもオブジェクトで表されます。 すべて
...使うと、指定したテキストエンコーディングで str を bytes に変換できます。 逆の変換には bytes.decode() を使えます。 タプル型 (tuple) tuple の要素には任意の Python オブジェクトを使えます。 2 個以上の要素を持つタプルは、式をコンマで区切って並べることで作成...nction. __closure__ None 、または関数の コードオブジェクト の co_freevars 属性に指定された名前の束縛を保持するセルからなる tuple 。 セルオブジェクトは属性 cell_contents を持っています。 これはセルの値を設定するのに加えて、セルの値を得るのにも使えます。...前です。モジュール名がない場合は None になります。 function. __defaults__ デフォルト値を持つ位置 仮引数 のデフォルト値を含む tuple 。 該当する引数がなければ None です。 function. __code__ コンパイルされた関数本体を表す コードオブジェクト 。 function. __... - https://man.mtool.work/python/3.14/reference/datamodel.html
- string.templatelib --- テンプレート文字列リテラルのサポート 8695
- string.templatelib --- テンプレート文字列リテラルのサポート ソースコード: Lib/string/templatelib.py 参考 フォーマット済み文字列リテラル テンプレート文字列リテラル(t-string)の構文 PEP 750 テンプレート文字列 Added in version 3.14. テンプレート
...分かりやすくなります。 template . strings : ( 'Ah! We do have ' , '.' ) template . values : ( 'Camembert' , ) 属性 strings : tuple [ str , ... ] テンプレート内の静的な文字列の tuple 。 >>> cheese = 'Camembert' >>> template = t 'Ah! We do have { cheese }...>> t '' . values () >>> t ' { 'cheese' } ' . strings ('', '') >>> t ' { 'cheese' } ' . values ('cheese',) interpolations : tuple [ Interpolation , ... ] テンプレート内の補間部分の tuple 。 >>> cheese = 'Camembert' >>> template = t 'Ah! We do have { ch...タプルは空の場合もあり、常に strings タプルより値が 1 つ少なくなります。 >>> t 'Red Leicester' . interpolations () values : tuple [ object , ... ] テンプレート内で補間されるすべての値のタプル。 >>> cheese = 'Camembert' >>> template = t 'Ah! We do have... - https://man.mtool.work/python/3.14/library/string.templatelib.html
- email.utils: 各種ユーティリティ 8324
- email.utils : 各種ユーティリティ ソースコード: Lib/email/utils.py email.utils モジュールには、いくつかの便利なユーティリティがあります: email.utils. localtime ( dt = None ) Return local time as an aware datetime object. If called without ar
...拒否するようになりました。 email.utils. formataddr ( pair , charset = 'utf-8' ) The inverse of parseaddr() , this takes a 2-tuple of the form (realname, email_address) and returns the string value suitable for a To or Cc header. If the first element of...オプションが追加されました。 email.utils. getaddresses ( fieldvalues , * , strict = True ) This function returns a list of 2-tuples of the form returned by parseaddr() . fieldvalues is a sequence of header field values as might be returned by Message.ge...an RFC 2822 date, such as "Mon, 20 Nov 1995 19:12:08 -0500" . If it succeeds in parsing the date, parsedate() returns a 9-tuple that can be passed directly to time.mktime() ; otherwise None will be returned. Note that indexes 6, 7, and 8 of the resul... - https://man.mtool.work/python/3.14/library/email.utils.html
- 組み込み型 7698
- 組み込み型 以下のセクションでは、インタプリタに組み込まれている標準型について記述します。 主要な組み込み型は、数値、シーケンス、マッピング、クラス、インスタンス、および例外です。 コレクションクラスには、ミュータブルなものがあります。コレクシ
...ds. More information about generators can be found in the documentation for the yield expression . シーケンス型 --- list , tuple , range 基本的なシーケンス型は 3 つあります: リスト、タプル、range オブジェクトです。 バイナリデータ や テキスト文字列 を処...オブジェクトでインプレースに結合できます。 bytearray オブジェクトはミュータブルで、効率のいい割り当て超過機構を備えています tuple オブジェクトを結合するなら、代わりに list を拡張してください その他の型については、関連するクラスのドキュメントを調べてくだ...装している演算のうち、ミュータブルなシーケンス型がサポートしていないのは、組み込みの hash() だけです。 このサポートにより、 tuple インスタンスのようなイミュータブルなシーケンスは、 dict のキーとして使え、 set や frozenset インスタンスに保存できます。 ハ... - https://man.mtool.work/python/3.14/builtins/stdtypes.html