randombuiltin 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 robert-ish
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: randombuiltin
3
+ Version: 1.0.0
4
+ Summary: Randomly select and work with Python builtins.
5
+ Author: Robert
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/robert-ish/randombuiltin
8
+ Project-URL: Repository, https://github.com/robert-ish/randombuiltin
9
+ Keywords: python,builtins,random
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # randombuiltin
18
+ The name is self-explanatory, gets random builtins.
19
+ ## Installation
20
+ ```powershell
21
+ pip install randombuiltin
22
+ ```
23
+ ## Documentation
24
+ do i just paste the docstrings in here
25
+ ### randbuiltin()
26
+ Returns a random builtin.
27
+ ### randcallable()
28
+ Returns a random callable.
29
+ ### randvalue()
30
+ Returns a random non-callable builtin.
31
+ ### randof(typ)
32
+ Returns a random builtin of a specific type.
33
+ ### randpair()
34
+ Returns a random pair of Builtin Name, Builtin.
35
+ ### randcallablepair()
36
+ Returns a random pair of Builtin Name, CALLABLE Builtin.
37
+ ### randvaluepair()
38
+ Returns a random pair of Builtin Name, NON-CALLABLE Builtin.
39
+ ### randofpair(typ)
40
+ Returns a random pair of Builtin Name, Builtin OF A SPECIFIC TYPE.
41
+ ### allof(typ)
42
+ Returns all found builtins of a specific type
43
+ ### allofc(typ)
44
+ Returns all found builtins of a specific type (subtypes counted)
45
+ ### countof
46
+ Returns how many builtins there are of a specific type.
47
+ ### randcall(*args, attemps=999, **kwargs)
48
+ Calls a random builtin with the provided args until it works, tries for a certain amount of attempts, raises RuntimeError if couldnt call any builtin.
49
+ ### nameof(obj)
50
+ *Sigh* Gets the name of an object...
51
+
52
+ ## License
53
+ MIT.
@@ -0,0 +1,37 @@
1
+ # randombuiltin
2
+ The name is self-explanatory, gets random builtins.
3
+ ## Installation
4
+ ```powershell
5
+ pip install randombuiltin
6
+ ```
7
+ ## Documentation
8
+ do i just paste the docstrings in here
9
+ ### randbuiltin()
10
+ Returns a random builtin.
11
+ ### randcallable()
12
+ Returns a random callable.
13
+ ### randvalue()
14
+ Returns a random non-callable builtin.
15
+ ### randof(typ)
16
+ Returns a random builtin of a specific type.
17
+ ### randpair()
18
+ Returns a random pair of Builtin Name, Builtin.
19
+ ### randcallablepair()
20
+ Returns a random pair of Builtin Name, CALLABLE Builtin.
21
+ ### randvaluepair()
22
+ Returns a random pair of Builtin Name, NON-CALLABLE Builtin.
23
+ ### randofpair(typ)
24
+ Returns a random pair of Builtin Name, Builtin OF A SPECIFIC TYPE.
25
+ ### allof(typ)
26
+ Returns all found builtins of a specific type
27
+ ### allofc(typ)
28
+ Returns all found builtins of a specific type (subtypes counted)
29
+ ### countof
30
+ Returns how many builtins there are of a specific type.
31
+ ### randcall(*args, attemps=999, **kwargs)
32
+ Calls a random builtin with the provided args until it works, tries for a certain amount of attempts, raises RuntimeError if couldnt call any builtin.
33
+ ### nameof(obj)
34
+ *Sigh* Gets the name of an object...
35
+
36
+ ## License
37
+ MIT.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "randombuiltin"
7
+ version = "1.0.0"
8
+ description = "Randomly select and work with Python builtins."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+
12
+ authors = [
13
+ { name = "Robert" }
14
+ ]
15
+
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
18
+
19
+ keywords = [
20
+ "python",
21
+ "builtins",
22
+ "random"
23
+ ]
24
+
25
+ classifiers = [
26
+ "Programming Language :: Python :: 3",
27
+ "Operating System :: OS Independent"
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/robert-ish/randombuiltin"
32
+ Repository = "https://github.com/robert-ish/randombuiltin"
@@ -0,0 +1,119 @@
1
+ # AI Notice (???)
2
+ # I wrote basically all of it but ChatGPT helped me build some of it
3
+
4
+ import builtins
5
+ import random
6
+
7
+ python = builtins.__dict__
8
+ def randbuiltin():
9
+ """Returns a random builtin."""
10
+ f = random.choice(list(python.values()))
11
+ return f
12
+
13
+ def randcallable():
14
+ """Returns a random callable."""
15
+ f = random.choice(list(python.values()))
16
+ while not callable(f):
17
+ f = random.choice(list(python.values()))
18
+ return f
19
+
20
+ def randvalue():
21
+ """Returns a random non-callable builtin."""
22
+ f = random.choice(list(python.values()))
23
+ while callable(f):
24
+ f = random.choice(list(python.values()))
25
+ return f
26
+
27
+ def randof(typ):
28
+ """Returns a random builtin of a specific type."""
29
+ matches = [
30
+ f for f in python.values()
31
+ if isinstance(f, typ)
32
+ ]
33
+
34
+ if not matches:
35
+ raise ValueError(f"No builtin matching {typ}")
36
+
37
+ return random.choice(matches)
38
+
39
+ def randpair():
40
+ """Returns a random pair of Builtin Name, Builtin."""
41
+ name = random.choice(list(python))
42
+ return name, python[name]
43
+
44
+ def randcallablepair():
45
+ """Returns a random pair of Builtin Name, CALLABLE Builtin."""
46
+ f = randpair()
47
+ while not callable(f[1]):
48
+ f = random.choice(list(python.values()))
49
+ return f
50
+
51
+ def randvaluepair():
52
+ """Returns a random pair of Builtin Name, NON-CALLABLE Builtin."""
53
+ f = randpair()
54
+ while callable(f[1]):
55
+ f = random.choice(list(python.values()))
56
+ return f
57
+
58
+ def randofpair(typ):
59
+ """Returns a random pair of Builtin Name, Builtin OF A SPECIFIC TYPE."""
60
+ matches = [ #type: ignore
61
+ f for f in python.keys(), python.values()
62
+ if isinstance(f[1], typ)
63
+ ]
64
+
65
+ if not matches:
66
+ raise ValueError(f"No builtin matching {typ}")
67
+
68
+ return random.choice(matches)
69
+
70
+ def allof(typ):
71
+ """Returns all found builtins of a specific type"""
72
+ return [
73
+ value
74
+ for value in python.values()
75
+ if type(value) == typ
76
+ ]
77
+
78
+ def allofc(typ):
79
+ """Returns all found builtins of a specific type (subtypes counted)"""
80
+ return [
81
+ value
82
+ for value in python.values()
83
+ if isinstance(value, typ)
84
+ ]
85
+
86
+ def countof(typ) -> int:
87
+ """Returns how many builtins there are of a specific type."""
88
+ return len(allof(typ))
89
+
90
+ def randcall(*args, attempts=999, **kwargs):
91
+ """Calls a random builtin with the provided args until it works, tries for a certain amount of attempts, raises RuntimeError if couldnt call any builtin."""
92
+ for _ in range(attempts):
93
+ f = randcallable()
94
+
95
+ try:
96
+ return f(*args, **kwargs)
97
+ except Exception:
98
+ pass
99
+
100
+ raise RuntimeError("No builtin worked")
101
+
102
+ def nameof(obj):
103
+ """Gets the name of an object"""
104
+ for name, value in python.items():
105
+ if value is obj:
106
+ return name
107
+ return None
108
+ # i hate nameof i hate nameof i hate nameof i hate nameof i hate nameof chatgpt forced me to do this
109
+ __all__ = [
110
+ "randbuiltin",
111
+ "randcallable",
112
+ "randvalue",
113
+ "randof",
114
+ "randpair",
115
+ "allof",
116
+ "countof",
117
+ "randcall"
118
+ ]
119
+ # no im not putting NAMEOF into all
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: randombuiltin
3
+ Version: 1.0.0
4
+ Summary: Randomly select and work with Python builtins.
5
+ Author: Robert
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/robert-ish/randombuiltin
8
+ Project-URL: Repository, https://github.com/robert-ish/randombuiltin
9
+ Keywords: python,builtins,random
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # randombuiltin
18
+ The name is self-explanatory, gets random builtins.
19
+ ## Installation
20
+ ```powershell
21
+ pip install randombuiltin
22
+ ```
23
+ ## Documentation
24
+ do i just paste the docstrings in here
25
+ ### randbuiltin()
26
+ Returns a random builtin.
27
+ ### randcallable()
28
+ Returns a random callable.
29
+ ### randvalue()
30
+ Returns a random non-callable builtin.
31
+ ### randof(typ)
32
+ Returns a random builtin of a specific type.
33
+ ### randpair()
34
+ Returns a random pair of Builtin Name, Builtin.
35
+ ### randcallablepair()
36
+ Returns a random pair of Builtin Name, CALLABLE Builtin.
37
+ ### randvaluepair()
38
+ Returns a random pair of Builtin Name, NON-CALLABLE Builtin.
39
+ ### randofpair(typ)
40
+ Returns a random pair of Builtin Name, Builtin OF A SPECIFIC TYPE.
41
+ ### allof(typ)
42
+ Returns all found builtins of a specific type
43
+ ### allofc(typ)
44
+ Returns all found builtins of a specific type (subtypes counted)
45
+ ### countof
46
+ Returns how many builtins there are of a specific type.
47
+ ### randcall(*args, attemps=999, **kwargs)
48
+ Calls a random builtin with the provided args until it works, tries for a certain amount of attempts, raises RuntimeError if couldnt call any builtin.
49
+ ### nameof(obj)
50
+ *Sigh* Gets the name of an object...
51
+
52
+ ## License
53
+ MIT.
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ randombuiltin/__init__.py
5
+ randombuiltin.egg-info/PKG-INFO
6
+ randombuiltin.egg-info/SOURCES.txt
7
+ randombuiltin.egg-info/dependency_links.txt
8
+ randombuiltin.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ randombuiltin
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+