Results of 1 - 10 of about 12 for choice (0.010 sec.)
- random --- 疑似乱数を生成する 13725
- random --- 疑似乱数を生成する ソースコード: Lib/random.py このモジュールでは様々な分布をもつ擬似乱数生成器を実装しています。 整数用に、ある範囲からの一様な選択があります。 シーケンス用には、シーケンスからのランダムな要素の一様な選択、リスト
...randrange ( start , stop [ , step ] ) range(start, stop, step) の要素からランダムに選ばれた要素を返します。 これはおおむね choice(range(start, stop, step)) と等価ですが、任意の大きさの範囲を扱え、一般的なケース向けに最適化されています。 位置引数のパター...数を生成できるようになります。 バージョン 3.9 で変更: k の値として 0 が許されるようになりました。 シーケンス用の関数 random. choice ( seq ) 空でないシーケンス seq からランダムに要素を返します。 seq が空のときは、 IndexError が送出されます。 random. choic...ssumed to be non-negative and finite. A ValueError is raised if all weights are zero. 与えられた種に対して、同じ重みを持つ choices() 関数は、一般に choice() を繰り返し呼び出す場合とは異なるシーケンスを生成します。 choices() で使用されるアルゴリズムは、... - https://man.mtool.work/python/3.14/library/random.html
- Logging クックブック 10524
- Logging クックブック Author : Vinay Sajip <vinay_sajip at red-dove dot com> このページは、過去に有用であるとされていた、logging に関連するいくつものレシピを含んでいます。チュートリアルやリファレンス情報へのリンクについては その他のリソース
...マット文字列を使って以下に示すように似たような出力を得られます。これはスクリプトの例です: import logging from random import choice class ContextFilter ( logging . Filter ): """ This is a filter which injects contextual information into the log. Rather t...'fred' , 'sheila' ] IPS = [ '123.231.231.123' , '127.0.0.1' , '192.168.0.1' ] def filter ( self , record ): record . ip = choice ( ContextFilter . IPS ) record . user = choice ( ContextFilter . USERS ) return True if __name__ == '__main__' : levels =...a1 . debug ( 'A debug message' ) a1 . info ( 'An info message with %s ' , 'some parameters' ) for x in range ( 10 ): lvl = choice ( levels ) lvlname = logging . getLevelName ( lvl ) a2 . log ( lvl , 'A message at %s level with %d %s ' , lvlname , 2 , '... - https://man.mtool.work/python/3.14/howto/logging-cookbook.html
- secrets --- 機密を扱うために安全な乱数を生成する 10524
- secrets --- 機密を扱うために安全な乱数を生成する Added in version 3.6. ソースコード: Lib/secrets.py secrets モジュールは、パスワード、アカウント認証、セキュリティトークン、その他の機密情報の管理に適した、暗号学的に強い乱数を生成するために使
...質なソースを用いて乱数を生成するためのクラスです。更に詳しいことについては random.SystemRandom を参照してください。 secrets. choice ( seq ) 空でないシーケンスから要素をランダムに選択して返します。 secrets. randbelow ( exclusive_upper_bound ) [0, exclusiv...するには: import string import secrets alphabet = string . ascii_letters + string . digits password = '' . join ( secrets . choice ( alphabet ) for i in range ( 8 )) 注釈 アプリケーションは、平文であろうと暗号化されていようと、 復元可能な形式でパスワード...rt string import secrets alphabet = string . ascii_letters + string . digits while True : password = '' . join ( secrets . choice ( alphabet ) for i in range ( 10 )) if ( any ( c . islower () for c in password ) and any ( c . isupper () for c in passwo... - https://man.mtool.work/python/3.14/library/secrets.html
- optparse --- コマンドラインオプションのパーサー 8437
- optparse --- コマンドラインオプションのパーサー ソースコード: Lib/optparse.py 引数解析ライブラリの選択 標準ライブラリには、引数を解析するライブラリが三つあります。 getopt : C の手続き型の getopt API に忠実に対応するモジュールです。 optparse
...り大きい場合、 optparse は値のタプルを dest に保存します。 Option. const 定数を格納する動作のための、その定数です。 Option. choices "choice" 型オプションに対してユーザが選べる選択肢となる文字列のリストです。 Option. callback アクションが "callback" であ...には必須の属性があり、そのアクションを使うオプションでは必ず指定しなければなりません。 "store" [関連: type , dest , nargs , choices ] オプションの後には必ず引数が続きます。引数は type に従って値に変換されて dest に保存されます。 nargs > 1 の場合、複数の...取り出します。引数は全て type に従って変換され、 dest にタプルとして保存されます。 標準のオプション型 節を参照してください。 choices を(文字列のリストかタプルで) 指定した場合、型のデフォルト値は "choice" になります。 type を指定しない場合、デフォルトの値... - https://man.mtool.work/python/3.14/library/optparse.html
- argparse --- コマンドラインオプションや引数、サブコマンド向けのパーサー 8012
- argparse --- コマンドラインオプションや引数、サブコマンド向けのパーサー Added in version 3.2. ソースコード: Lib/argparse.py 注釈 argparse は基本的なコマンドラインアプリケーションの実装に推奨される標準ライブラリのモジュールですが、動作を厳密
...er がエラー情報を表示して終了するかどうか (デフォルト: True ) suggest_on_error - Enables suggestions for mistyped argument choices and subparser names (default: False ) color - 色付きの出力を許可する (デフォルト: True ) バージョン 3.5 で変更: allow_abb...t ) _StoreAction(option_strings=['--integers'], dest='integers', nargs=None, const=None, default=None, type=<class 'int'>, choices=None, help=None, metavar=None) >>> try : ... parser . parse_args ( '--integers a' . split ()) ... except argparse . Argum...) ... Catching an argumentError Added in version 3.9. suggest_on_error By default, when a user passes an invalid argument choice or subparser name, ArgumentParser will exit with error info and list the permissible argument choices (if specified) or su... - https://man.mtool.work/python/3.14/library/argparse.html
- 10. 標準ライブラリをひとめぐり 8012
- 10. 標準ライブラリをひとめぐり 10.1. オペレーティングシステムとのインターフェース os モジュールは、オペレーティングシステムと対話するための多くの関数を提供しています: >>> import os >>> os . getcwd () # Return the current working directory '
...1024 , 2 ) 10.0 random モジュールは、乱数に基づいた要素選択のためのツールを提供しています: >>> import random >>> random . choice ([ 'apple' , 'pear' , 'banana' ]) 'apple' >>> random . sample ( range ( 100 ), 10 ) # 重複なしでサンプリング [30, 83, 16,... - https://man.mtool.work/python/3.14/tutorial/stdlib.html
- What's New In Python 3.2 8012
- What's New In Python 3.2 著者 : Raymond Hettinger この記事では Python 3.1 と比較した Python 3.2 の新機能を説明します。 Python 3.2 は 2011 年 2 月 20 日にリリースされました。 主な変更点をいくつか取り上げ、例を示します。 すべての詳細については
...# ヘルプの主な説明 epilog = 'Tested on Solaris and Linux' ) # ヘルプの後に表示 parser . add_argument ( 'action' , # 引数名 choices = [ 'deploy' , 'start' , 'stop' ], # 許可する三つの値 help = 'action on each target' ) # ヘルプメッセージ parser . add_ar...の選択肢を作成し、 0 <= x < n の範囲に入ったもののみを保持します。 影響を受ける関数やメソッドは randrange() 、 randint() 、 choice() 、 shuffle() ならびに sample() です。 (Contributed by Raymond Hettinger; bpo-9025 .) poplib POP3_SSL クラスが context パ...ジェクト情報を提供します。前者はそれを文字列で返し、後者は印字します: >>> import dis , random >>> dis . show_code ( random . choice ) Name: choice Filename: /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/random.py Argument count: 2 Kw-on... - https://man.mtool.work/python/3.14/whatsnew/3.2.html
- The Python Profilers 7871
- The Python Profilers Source code: Lib/profile.py and Lib/pstats.py Introduction to the profilers cProfile and profile provide deterministic profiling of Python programs. A profile is a set of statistics that describes how often and for how
...c list within the object. Note that by default ascending vs descending order is properly selected based on the sort key of choice. print_stats ( * restrictions ) This method for the Stats class prints out a report as described in the profile.run() defi... - https://man.mtool.work/python/3.14/library/profile.html
- ライブラリと拡張 FAQ 7729
- ライブラリと拡張 FAQ ライブラリ一般の質問 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか? ライブラリリファンレス から関係がありそうな標準ライブラリモジュールがあるかどうか調べてください。 (標準ライブラリに何があるかが
...rmalvariate(mean, sdev) は正規 (ガウス) 分布をサンプリングします。 シーケンスに直接作用する高水準な関数もあります。例えば: choice(S) は与えられたシーケンスからランダムな要素を選びます。 shuffle(L) はリストをインプレースにシャッフルします。すなわち、ラン... - https://man.mtool.work/python/3.14/faq/library.html
- Argparse チュートリアル 7729
- Argparse チュートリアル author : Tshepang Mbambo このチュートリアルでは、 argparse を丁寧に説明します。 argparse は、Python 標準ライブラリの一部であり、おすすめのコマンドライン引数の解析モジュールです。 注釈 標準ライブラリには、コマンドライ
..." , type = int , help = "display a square of a given number" ) parser . add_argument ( "-v" , "--verbosity" , type = int , choices = [ 0 , 1 , 2 ], help = "increase output verbosity" ) args = parser . parse_args () answer = args . square ** 2 if args ....みましょう: $ python prog.py 4 -v 3 usage: prog.py [-h] [-v {0,1,2}] square prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, 1, 2) $ python prog.py 4 -h usage: prog.py [-h] [-v {0,1,2}] square positional arguments: square displa... - https://man.mtool.work/python/3.14/howto/argparse.html