methodverse 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: methodverse
3
+ Version: 1.0.0
4
+ Summary: A quick reference tool for Python built-in methods.
5
+ Author-email: marvinminhaz <marvinminhaz@outlook.com>
6
+ Keywords: python,reference,methods,builtins
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Methodverse
13
+ A fast, lightweight reference engine for Python built-in methods. Get quick
14
+ explanations and examples without digging through official documentation.
15
+
16
+ ## Installation
17
+ pip install methodverse
18
+
19
+ ## Usage
20
+ from methodverse import explain, enlist
21
+
22
+ explain('list', 'append') # prints description + example
23
+ enlist('dict') # prints all available dict methods
24
+
25
+ ## Structure
26
+ ```
27
+ methodverse/
28
+ ├── methodverse/
29
+ │ ├── __init__.py
30
+ │ └── core.py
31
+ ├── README.md
32
+ ├── LICENSE
33
+ └── pyproject.toml
34
+ ```
@@ -0,0 +1,23 @@
1
+ # Methodverse
2
+ A fast, lightweight reference engine for Python built-in methods. Get quick
3
+ explanations and examples without digging through official documentation.
4
+
5
+ ## Installation
6
+ pip install methodverse
7
+
8
+ ## Usage
9
+ from methodverse import explain, enlist
10
+
11
+ explain('list', 'append') # prints description + example
12
+ enlist('dict') # prints all available dict methods
13
+
14
+ ## Structure
15
+ ```
16
+ methodverse/
17
+ ├── methodverse/
18
+ │ ├── __init__.py
19
+ │ └── core.py
20
+ ├── README.md
21
+ ├── LICENSE
22
+ └── pyproject.toml
23
+ ```
@@ -0,0 +1 @@
1
+ from .core import explain, enlist
@@ -0,0 +1,267 @@
1
+ # ── PYTHON BUILT-IN METHOD REFERENCE LIBRARY ──────────────────────────────────
2
+ # Each dictionary below covers one built-in type.
3
+ # Keys → method name (str)
4
+ # Values → description string + inline usage example
5
+ # Format: 'method_name': 'method(): What it does. example -> result'
6
+
7
+
8
+ # ── INTEGERS ──────────────────────────────────────────────────────────────────
9
+ integers = {
10
+ # Binary & Bitwise Operations
11
+ 'bit_length': 'bit_length(): Returns the number of bits required to represent the integer in binary, excluding the sign and leading zeros. (37).bit_length() -> 6',
12
+ 'bit_count': 'bit_count(): Returns the number of ones (1s) in the binary representation of the absolute value of the integer (added in Python 3.10). (37).bit_count() -> 3',
13
+
14
+ # Ratios
15
+ 'as_integer_ratio': 'as_integer_ratio(): Returns a tuple of two integers whose ratio exactly equals the integer. For whole numbers, the second number is always 1. (10).as_integer_ratio() -> (10, 1)',
16
+
17
+ # Byte Conversions
18
+ 'to_bytes': 'to_bytes(): Converts the integer into an array of bytes for low-level memory storage or network transmission. (1024).to_bytes(2, byteorder="big") -> b"\\x04\\x00"',
19
+ 'from_bytes': 'from_bytes(): A class method that converts an array of bytes back into a standard integer. int.from_bytes(b"\\x04\\x00", byteorder="big") -> 1024'
20
+ }
21
+
22
+
23
+ # ── FLOATS ────────────────────────────────────────────────────────────────────
24
+ floats = {
25
+ # Type Checking & Fractions
26
+ 'is_integer': 'is_integer(): Returns True if the float has no fractional part (ends exactly in .0). (2.5).is_integer() -> False',
27
+ 'as_integer_ratio': 'as_integer_ratio(): Returns a tuple of two integers whose exact mathematical ratio equals the float. (0.5).as_integer_ratio() -> (1, 2)',
28
+
29
+ # Hexadecimal Conversions
30
+ 'hex': 'hex(): Returns a hexadecimal string representation of the floating-point number. (1.5).hex() -> "0x1.8000000000000p+0"',
31
+ 'fromhex': 'fromhex(): A class method that converts a hexadecimal string back into a standard float. float.fromhex("0x1.8p+0") -> 1.5'
32
+ }
33
+
34
+
35
+ # ── STRINGS ───────────────────────────────────────────────────────────────────
36
+ strings = {
37
+ # Changing Case
38
+ 'capitalize': 'capitalize(): Capitalizes only the very first character; lowers the rest. "hello WORLD".capitalize() -> "Hello world"',
39
+ 'lower': 'lower(): Converts all characters to lowercase. "HeLlO".lower() -> "hello"',
40
+ 'upper': 'upper(): Converts all characters to uppercase. "hello".upper() -> "HELLO"',
41
+ 'title': 'title(): Capitalizes the first letter of every word (Title Case). "hello world".title() -> "Hello World"',
42
+ 'swapcase': 'swapcase(): Flips uppercase to lowercase and vice versa. "Hello".swapcase() -> "hELLO"',
43
+ 'casefold': 'casefold(): Removes all case distinctions for aggressive matching. "groß".casefold() -> "gross"',
44
+
45
+ # Searching & Counting
46
+ 'count': 'count(): Counts how many times a substring appears. "banana".count("an") -> 2',
47
+ 'find': 'find(): Returns first index of substring, or -1 if not found. "hello".find("l") -> 2',
48
+ 'rfind': 'rfind(): Returns last index of substring, or -1 if not found. "hello".rfind("l") -> 3',
49
+ 'index': 'index(): Returns first index of substring, raises ValueError if not found. "hello".index("l") -> 2',
50
+ 'rindex': 'rindex(): Returns last index of substring, raises ValueError if not found. "hello".rindex("l") -> 3',
51
+
52
+ # Formatting & Padding
53
+ 'center': 'center(): Centers string inside space padding of a given width. "hi".center(6) -> " hi "',
54
+ 'ljust': 'ljust(): Left-justifies string inside space padding of a given width. "hi".ljust(5) -> "hi "',
55
+ 'rjust': 'rjust(): Right-justifies string inside space padding of a given width. "hi".rjust(5) -> " hi"',
56
+ 'zfill': 'zfill(): Pads left side of string with zeros to a given width. "42".zfill(5) -> "00042"',
57
+ 'expandtabs': 'expandtabs(): Replaces tab characters (\\t) with spaces. "a\\tb".expandtabs(2) -> "a b"',
58
+ 'format': 'format(): Injects variables into bracket {} placeholders. "{}, {}!".format("Hello", "World") -> "Hello, World!"',
59
+ 'format_map': 'format_map(): Maps dictionary keys directly into named placeholders. "{n}".format_map({"n": "Alice"}) -> "Alice"',
60
+
61
+ # Stripping & Trimming
62
+ 'strip': 'strip(): Removes leading and trailing whitespace. " hi ".strip() -> "hi"',
63
+ 'lstrip': 'lstrip(): Removes leading whitespace from the left side. " hi ".lstrip() -> "hi "',
64
+ 'rstrip': 'rstrip(): Removes trailing whitespace from the right side. " hi ".rstrip() -> " hi"',
65
+ 'removeprefix': 'removeprefix(): Cuts off a specific starting substring if present. "test_file.py".removeprefix("test_") -> "file.py"',
66
+ 'removesuffix': 'removesuffix(): Cuts off a specific ending substring if present. "test_file.py".removesuffix(".py") -> "test_file"',
67
+
68
+ # Splitting, Joining & Partitioning
69
+ 'split': 'split(): Breaks a string into a list based on a delimiter. "a b c".split() -> ["a", "b", "c"]',
70
+ 'rsplit': 'rsplit(): Breaks a string into a list starting from the right side. "a b c".rsplit(maxsplit=1) -> ["a b", "c"]',
71
+ 'splitlines': 'splitlines(): Splits a string at line breaks (\\n) into a list. "a\\nb".splitlines() -> ["a", "b"]',
72
+ 'join': 'join(): Glues a list of strings together using the main string. "-".join(["a", "b"]) -> "a-b"',
73
+ 'partition': 'partition(): Splits at first delimiter into a 3-tuple (before, match, after). "a-b-c".partition("-") -> ("a", "-", "b-c")',
74
+ 'rpartition': 'rpartition(): Splits at last delimiter into a 3-tuple (before, match, after). "a-b-c".rpartition("-") -> ("a-b", "-", "c")',
75
+
76
+ # Replacing & Translating
77
+ 'replace': 'replace(): Swaps an old substring for a new one. "abc".replace("b", "z") -> "azc"',
78
+ 'maketrans': 'maketrans(): Creates a translation dictionary map for character swapping. str.maketrans("ae", "12") -> {97: 49, 101: 50}',
79
+ 'translate': 'translate(): Applies a maketrans map to swap characters in text. "apple".translate(table) -> "1ppl2"',
80
+ 'encode': 'encode(): Converts string into bytes (defaults to UTF-8). "hi".encode("utf-8") -> b"hi"',
81
+
82
+ # Boolean Checks (is...)
83
+ 'startswith': 'startswith(): True if the string starts with the given value. "apple".startswith("ap") -> True',
84
+ 'endswith': 'endswith(): True if the string ends with the given value. "apple".endswith("le") -> True',
85
+ 'isalnum': 'isalnum(): True if all characters are letters or numbers. "a1".isalnum() -> True',
86
+ 'isalpha': 'isalpha(): True if all characters are letters only. "abc".isalpha() -> True',
87
+ 'isascii': 'isascii(): True if all characters fit in the standard ASCII table. "hi".isascii() -> True',
88
+ 'islower': 'islower(): True if all cased characters are lowercase. "hi".islower() -> True',
89
+ 'isupper': 'isupper(): True if all cased characters are uppercase. "HI".isupper() -> True',
90
+ 'istitle': 'istitle(): True if string follows Title Case rules. "Hello World".istitle() -> True',
91
+ 'isspace': 'isspace(): True if string contains only whitespace characters. " \\n\\t ".isspace() -> True',
92
+ 'isprintable': 'isprintable(): True if all characters are visible/printable. "hi".isprintable() -> True',
93
+ 'isidentifier': 'isidentifier(): True if string is a valid variable name pattern. "my_var1".isidentifier() -> True',
94
+ 'isdecimal': 'isdecimal(): True if string only contains strict digits 0-9. "123".isdecimal() -> True',
95
+ 'isdigit': 'isdigit(): True if string contains digits 0-9 or superscripts. "123²".isdigit() -> True',
96
+ 'isnumeric': 'isnumeric(): True if string contains digits, superscripts, or fractions. "½".isnumeric() -> True'
97
+ }
98
+
99
+
100
+ # ── LISTS ─────────────────────────────────────────────────────────────────────
101
+ lists = {
102
+ # Adding Elements
103
+ 'append': 'append(): Adds a single element to the very end of the list in place. [1, 2].append(3) -> [1, 2, 3]',
104
+ 'extend': 'extend(): Appends all elements from an iterable (like another list) to the end in place. [1].extend([2, 3]) -> [1, 2, 3]',
105
+ 'insert': 'insert(): Inserts an element at a specific index, shifting everything else right. [1, 3].insert(1, 2) -> [1, 2, 3]',
106
+
107
+ # Removing Elements
108
+ 'pop': 'pop(): Removes and RETURNS the element at a given index (defaults to the last item). [10, 20].pop() -> returns 20, list becomes [10]',
109
+ 'remove': 'remove(): Removes the first occurrence of a specific value; raises ValueError if not found. [1, 2, 1].remove(1) -> [2, 1]',
110
+ 'clear': 'clear(): Removes all elements from the list, leaving it completely empty. [1, 2].clear() -> []',
111
+
112
+ # Searching & Counting
113
+ 'count': 'count(): Returns the number of times a specific value appears in the list. [1, 2, 2].count(2) -> 2',
114
+ 'index': 'index(): Returns the first index of a value; raises ValueError if the value is missing. ["a", "b"].index("b") -> 1',
115
+
116
+ # Ordering & Reversing
117
+ 'sort': 'sort(): Sorts the list items in place (ascending order by default). [3, 1, 2].sort() -> [1, 2, 3]',
118
+ 'reverse': 'reverse(): Reverses the order of the elements in the list completely in place. [1, 2, 3].reverse() -> [3, 2, 1]',
119
+
120
+ # Copying
121
+ 'copy': 'copy(): Returns a shallow, independent copy of the original list. old = [1, 2]; new = old.copy() -> new becomes [1, 2]'
122
+ }
123
+
124
+
125
+ # ── DICTIONARIES ──────────────────────────────────────────────────────────────
126
+ dictionaries = {
127
+ # Retrieving Values Safely
128
+ 'get': 'get(): Returns the value for a key if it exists; otherwise returns a default value (None if not specified) without crashing. {"a": 1}.get("b", 0) -> 0',
129
+ 'setdefault': 'setdefault(): Returns the value of a key if it exists. If not, inserts the key with a specified default value. d = {"a": 1}; d.setdefault("b", 2) -> returns 2, d becomes {"a": 1, "b": 2}',
130
+
131
+ # Accessing Keys, Values & Pairs (View Objects)
132
+ 'keys': 'keys(): Returns a dynamic view object of all keys in the dictionary. {"a": 1, "b": 2}.keys() -> dict_keys(["a", "b"])',
133
+ 'values': 'values(): Returns a dynamic view object of all values in the dictionary. {"a": 1, "b": 2}.values() -> dict_values([1, 2])',
134
+ 'items': 'items(): Returns a dynamic view object of all key-value pairs as a list of tuples. {"a": 1}.items() -> dict_items([("a", 1)])',
135
+
136
+ # Adding & Modifying Data
137
+ 'update': 'update(): Merges another dictionary or iterable of key-value pairs into the current one, overwriting existing keys in place. {"a": 1}.update({"b": 2}) -> {"a": 1, "b": 2}',
138
+ 'fromkeys': 'fromkeys(): A class method that creates a new dictionary with a given sequence of keys and a single shared value. dict.fromkeys(["a", "b"], 0) -> {"a": 0, "b": 0}',
139
+
140
+ # Removing Data
141
+ 'pop': 'pop(): Removes a specific key and returns its value; raises KeyError if missing unless a default fallback is provided. {"a": 1}.pop("a") -> returns 1, dict becomes {}',
142
+ 'popitem': 'popitem(): Removes and returns the LAST inserted key-value pair as a tuple (LIFO order). {"a": 1, "b": 2}.popitem() -> returns ("b", 2), dict becomes {"a": 1}',
143
+ 'clear': 'clear(): Removes all keys and values, leaving the dictionary completely empty. {"a": 1}.clear() -> {}',
144
+
145
+ # Copying
146
+ 'copy': 'copy(): Returns a shallow, independent copy of the original dictionary. old = {"a": 1}; new = old.copy() -> new becomes {"a": 1}'
147
+ }
148
+
149
+
150
+ # ── TUPLES ────────────────────────────────────────────────────────────────────
151
+ # Tuples are immutable, so only two methods are available: count and index.
152
+ tuples = {
153
+ # Searching & Counting
154
+ 'count': 'count(): Returns the number of times a specified value appears in the tuple. (1, 2, 2, 3).count(2) -> 2',
155
+ 'index': 'index(): Returns the first index of a specified value; raises ValueError if the value is missing. ("a", "b", "c").index("b") -> 1'
156
+ }
157
+
158
+
159
+ # ── SETS ──────────────────────────────────────────────────────────────────────
160
+ sets = {
161
+ # Adding & Removing
162
+ 'add': 'add(): Adds an element to the set. If the element is already present, the set remains unchanged. {1, 2}.add(3) -> {1, 2, 3}',
163
+ 'remove': 'remove(): Removes a specified element; raises KeyError if the element is not found. {1, 2}.remove(1) -> {2}',
164
+ 'discard': 'discard(): Removes a specified element; does nothing (no error) if the element is not found. {1, 2}.discard(3) -> {1, 2}',
165
+ 'pop': 'pop(): Removes and returns an arbitrary element from the set; raises KeyError if the set is empty. {1, 2}.pop() -> 1',
166
+ 'clear': 'clear(): Removes all elements from the set. {1, 2}.clear() -> set()',
167
+
168
+ # Set Operations (Mathematical)
169
+ 'union': 'union(): Returns a new set containing all unique elements from both sets. {1, 2}.union({2, 3}) -> {1, 2, 3}',
170
+ 'intersection': 'intersection(): Returns a new set with elements common to both sets. {1, 2}.intersection({2, 3}) -> {2}',
171
+ 'difference': 'difference(): Returns a new set with elements in the first set but not in the second. {1, 2}.difference({2, 3}) -> {1}',
172
+ 'symmetric_difference': 'symmetric_difference(): Returns a new set with elements in either set, but not both. {1, 2}.symmetric_difference({2, 3}) -> {1, 3}',
173
+
174
+ # Membership & Subsets
175
+ 'issubset': 'issubset(): Returns True if all elements of the set are present in another set. {1, 2}.issubset({1, 2, 3}) -> True',
176
+ 'issuperset': 'issuperset(): Returns True if the set contains all elements of another set. {1, 2, 3}.issuperset({1, 2}) -> True',
177
+ 'isdisjoint': 'isdisjoint(): Returns True if the two sets have no elements in common. {1, 2}.isdisjoint({3, 4}) -> True',
178
+
179
+ # Copying
180
+ 'copy': 'copy(): Returns a shallow copy of the set. s = {1, 2}; s2 = s.copy() -> s2 becomes {1, 2}'
181
+ }
182
+
183
+
184
+ # ── ROUTER ────────────────────────────────────────────────────────────────────
185
+ # Central alias map shared by both functions.
186
+ # Multiple keys can point to the same dict (e.g. 'int', 'integer', 'integers').
187
+ # To add a new type: define its dict above, then add its aliases here.
188
+ router = {
189
+ 'int': integers, 'integer': integers, 'integers': integers,
190
+ 'float': floats, 'floats': floats,
191
+ 'str': strings, 'string': strings, 'strings': strings,
192
+ 'list': lists, 'lists': lists, 'lst': lists,
193
+ 'dict': dictionaries, 'dictionary': dictionaries, 'dictionaries': dictionaries,
194
+ 'tuple': tuples, 'tuples': tuples,
195
+ 'set': sets, 'sets': sets
196
+ }
197
+
198
+
199
+ # ── EXPLAIN ───────────────────────────────────────────────────────────────────
200
+
201
+ def explain(the_object: str, the_method: str) -> None:
202
+ '''
203
+ Retrieves and prints the explanation for a specific method of a given Python data structure.
204
+
205
+ This function acts as a lookup utility. It maps a string identifier for a data structure
206
+ to its corresponding dictionary of method explanations, then prints the definition
207
+ and usage example for the requested method.
208
+
209
+ Args:
210
+ the_object (str): The name or alias of the data structure (e.g., 'list', 'dict', 'int').
211
+ the_method (str): The specific method name to explain (e.g., 'append', 'get').
212
+
213
+ Returns:
214
+ None
215
+
216
+ Example:
217
+ >>> explain('list', 'append')
218
+ list.append(): Adds a single element to the very end of the list in place.
219
+ '''
220
+
221
+ # Normalize input: strip whitespace and lowercase before router lookup.
222
+ # Returns None if the type alias isn't recognised.
223
+ data = router.get(the_object.lower().strip())
224
+
225
+ if data:
226
+ # Look up the method; fall back to an error string if it doesn't exist in this type.
227
+ print(f"{the_object}.{data.get((the_method.strip().lower()), f"Error: Method '{the_method}' not found in {the_object}")}")
228
+ else:
229
+ print(f"'{the_object}' not in library")
230
+
231
+
232
+ # ── ENLIST ────────────────────────────────────────────────────────────────────
233
+
234
+ def enlist(the_object: str) -> None:
235
+ '''
236
+ Displays all available method names for a specified Python data structure.
237
+
238
+ This function uses the shared router to map type aliases (e.g., 'lst', 'list', 'lists')
239
+ to their corresponding method dictionaries, then prints all available method names.
240
+
241
+ Args:
242
+ the_object (str): The name or alias of the data structure
243
+ to look up (e.g., 'list', 'dict', 'int', 'tuple', 'str', 'set').
244
+
245
+ Returns:
246
+ None
247
+
248
+ Example:
249
+ >>> enlist('list')
250
+ List methods: ['append', 'extend', 'insert', 'pop', 'remove', ...]
251
+ '''
252
+
253
+ # Normalize input before lookup; same logic as explain() for consistency.
254
+ data = router.get(the_object.lower().strip())
255
+
256
+ if data:
257
+ # Print only the method names (keys), not their full description strings.
258
+ print(f"{the_object.capitalize()} methods: {list(data.keys())}")
259
+ else:
260
+ print(f"'{the_object}' not in library")
261
+
262
+
263
+ # ── EXAMPLE USAGE ─────────────────────────────────────────────────────────────
264
+ # explain('dict', 'get') # explains the usage of dict.get() method
265
+ # explain('dataframe', 'pop') # 'dataframe' is not in the library → triggers not-found message
266
+ # enlist('tuple') # Lists the two methods available on tuples: count, index
267
+ # enlist('dataframe') # 'dataframe' is not in the library → triggers not-found message
@@ -0,0 +1,34 @@
1
+ Metadata-Version: 2.4
2
+ Name: methodverse
3
+ Version: 1.0.0
4
+ Summary: A quick reference tool for Python built-in methods.
5
+ Author-email: marvinminhaz <marvinminhaz@outlook.com>
6
+ Keywords: python,reference,methods,builtins
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Methodverse
13
+ A fast, lightweight reference engine for Python built-in methods. Get quick
14
+ explanations and examples without digging through official documentation.
15
+
16
+ ## Installation
17
+ pip install methodverse
18
+
19
+ ## Usage
20
+ from methodverse import explain, enlist
21
+
22
+ explain('list', 'append') # prints description + example
23
+ enlist('dict') # prints all available dict methods
24
+
25
+ ## Structure
26
+ ```
27
+ methodverse/
28
+ ├── methodverse/
29
+ │ ├── __init__.py
30
+ │ └── core.py
31
+ ├── README.md
32
+ ├── LICENSE
33
+ └── pyproject.toml
34
+ ```
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ methodverse/__init__.py
4
+ methodverse/core.py
5
+ methodverse.egg-info/PKG-INFO
6
+ methodverse.egg-info/SOURCES.txt
7
+ methodverse.egg-info/dependency_links.txt
8
+ methodverse.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ methodverse
@@ -0,0 +1,17 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "methodverse"
7
+ version = "1.0.0"
8
+ description = "A quick reference tool for Python built-in methods."
9
+ readme = "README.md"
10
+ license = { file = "LICENSE" }
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "marvinminhaz", email = "marvinminhaz@outlook.com" }]
13
+ keywords = ["python", "reference", "methods", "builtins"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+