What did everyone automate using python ?
What are some of the best things you have automated using Python?
Videos
Why use strings rather than the types themselves?
funcs = { 'A':ctypes.uint64, 'B':bool }
Then:
def make_func(name, ctype):
def func(self):
ans = ctype()
getattr(self.driver, 'get'+name)(ctypes.byref(ans))
return ans
func.__name__ = 'func'+name
return func
for a, b in funcs.items():
globals()['func'+a] = make_func(a, b)
Or ditch the dict and for loop and:
funcA = make_func('A', ctypes.uint64)
funcB = make_func('B', bool)
If you want to do this with code generation, you could just create some template for the function and then use str.format to fill in the parameters from your dictionary.
template = """def func{0}(self):
ans = ctypes.{1}()
self.driver.get{0}(ctypes.byref(ans))
return ans
"""
funcs = { 'A':'uint64', 'B':'bool'}
for a, b in funcs.items():
function = template.format(a, b)
print function
Just pipe the output to some file, or directly write it to a file instead of printing.
My friend and I are basically building this community-driven Large Action Model that's designed to take actions on user’s behalf using natural language prompts. Users can integrate their own custom actions, written in Python, to suit their specific needs, and the LAM can then layer multiple actions to perform more complex tasks. When you create these actions or functions, it contributes to the overall capabilities of the LAM, and everyone can now invoke the same action. For now, it uses Python 3 (Version 3.11), and the environment includes the following packages: BeautifulSoup, urllib3, requests, pyyaml.
I'm super interested in knowing what cool/useful python scripts you guys made to automate anything personal or business related. I'm looking for ideas that I can potentially integrate into the LAM, increasing its capabilities for everyone to use and benefit from :)