Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#python で #ruby の instance#methods みたいな感じで全てのメソッドを表示するらしき例 #1106

Open
YumaInaura opened this issue Apr 7, 2019 · 0 comments

Comments

@YumaInaura
Copy link
Owner

python

メソッドではなく attributes を表示するという扱いではあるらしい (詳細不明)

Python dir() - Python Standard Library

The dir() method tries to return a list of valid attributes of the object.

>>> dir("a")
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
>>> "a".title()
'A'

ruby

[1] pry(main)> "a".methods
=> [:include?,
 :%,
 :*,
 :+,
 :unicode_normalize,
 :shellsplit,
 :to_c,
 :unicode_normalize!,
 :unicode_normalized?,
 :shellescape,
 :count,
 :partition,
 :unpack,
 :next,
 :encode,
 :encode!,
 :casecmp,
 :insert,
 :bytesize,
 :match,
 :succ!,
 :next!,
 :upto,
 :index,
 :rindex,
 :replace,
 :clear,
 :+@,
 :-@,
 :getbyte,
 :chr,
 :<=>,
 :<<,
 :byteslice,
 :scrub,
 :setbyte,
 :==,
 :===,
 :scrub!,
 :=~,
 :upcase,
 :[],
 :[]=,
 :dump,
 :upcase!,
 :downcase,
 :capitalize,
 :swapcase,
 :hex,
 :empty?,
 :eql?,
 :swapcase!,
 :bytes,
 :oct,
 :downcase!,
 :capitalize!,
 :reverse!,
 :chars,
 :codepoints,
 :split,
 :lines,
 :concat,
 :end_with?,
 :crypt,
 :reverse,
 :start_with?,
 :center,
 :freeze,
 :inspect,
 :intern,
 :chomp,
 :sub,
 :gsub,
 :prepend,
 :rjust,
 :ord,
 :lstrip,
 :rstrip,
 :scan,
 :length,
 :size,
 :chomp!,
 :succ,
 :sub!,
 :chop,
 :chop!,
 :ljust,
 :strip!,
 :lstrip!,
 :tr_s,
 :delete,
 :strip,
 :tr!,
 :to_str,
 :to_sym,
 :gsub!,
 :each_line,
 :squeeze,
 :each_char,
 :to_s,
 :to_i,
 :tr,
 :slice!,
 :each_byte,
 :encoding,
 :each_codepoint,
 :tr_s!,
 :delete!,
 :rstrip!,
 :rpartition,
 :to_f,
 :b,
 :sum,
 :slice,
 :squeeze!,
 :to_r,
 :force_encoding,
 :valid_encoding?,
 :ascii_only?,
 :hash,
 :to_json,
 :to_json_raw,
 :to_json_raw_object,
 :<,
 :>,
 :<=,
 :>=,
 :between?,
 :pry,
 :__binding__,
 :pretty_print,
 :pretty_print_cycle,
 :pretty_print_instance_variables,
 :pretty_print_inspect,
 :tap,
 :public_send,
 :instance_variables,
 :instance_variable_set,
 :instance_variable_defined?,
 :remove_instance_variable,
 :private_methods,
 :kind_of?,
 :is_a?,
 :instance_variable_get,
 :method,
 :public_method,
 :singleton_method,
 :instance_of?,
 :extend,
 :define_singleton_method,
 :to_enum,
 :enum_for,
 :pretty_inspect,
 :!~,
 :respond_to?,
 :object_id,
 :display,
 :send,
 :nil?,
 :class,
 :singleton_class,
 :clone,
 :dup,
 :itself,
 :taint,
 :tainted?,
 :untaint,
 :untrust,
 :trust,
 :untrusted?,
 :methods,
 :protected_methods,
 :frozen?,
 :public_methods,
 :singleton_methods,
 :!,
 :!=,
 :__send__,
 :equal?,
 :instance_eval,
 :instance_exec,
 :__id__]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant