# Like partial, but you can determine the order of *args
```python
pip install flexible-partial
```
```python
#######################################
Update 2022-12-04:
# When you use FlexiblePartialOwnName, you can define the output of __str__ and __repr__
from flexible_partial import FlexiblePartial, FlexiblePartialOwnName
import regex
from random import choice
from string import ascii_lowercase
text = """Hi, my friend, how are you?"""
allfus = [
FlexiblePartialOwnName(
regex.sub,
f'{x} Hello, I am a function!', # for __str__ and __repr__
True, # this_args_first = True (choice(list(ascii_lowercase)) will be the first arg when the function is called)
choice(list(ascii_lowercase)),
flags=regex.IGNORECASE,
)
for x in range(10)
]
for alsw in allfus:
print(f"Executing: {alsw}")
text = alsw("P", text)
print(text)
Executing: 0 Hello, I am a function!
Hi, my friePd, how are you?
Executing: 1 Hello, I am a function!
Hi, my friePd, how are you?
Executing: 2 Hello, I am a function!
Hi, mP friePd, how are Pou?
Executing: 3 Hello, I am a function!
Hi, mP friePd, how are Pou?
Executing: 4 Hello, I am a function!
Hi, mP friePd, hPw are PPu?
Executing: 5 Hello, I am a function!
Hi, mP friePd, hPw are PPu?
Executing: 6 Hello, I am a function!
Hi, PP friePd, hPw are PPu?
Executing: 7 Hello, I am a function!
Hi, PP friePd, hPP are PPu?
Executing: 8 Hello, I am a function!
Hi, PP friePd, hPP Pre PPu?
Executing: 9 Hello, I am a function!
Hi, PP friePd, hPP Pre PPP?
#######################################
from flexible_partial import FlexiblePartial
import regex
from random import choice
from string import ascii_lowercase
text = """Hi, my friend, how are you?"""
allfus = [
FlexiblePartial(
regex.sub,
True, # this_args_first = True (choice(list(ascii_lowercase)) will be the first arg when the function is called)
choice(list(ascii_lowercase)),
flags=regex.IGNORECASE,
)
for x in range(10)
]
for alsw in allfus:
print(f"Executing: {alsw}")
text = alsw("P", text)
print(text)
# Executing: regex.regex.sub('z', flags=regex.I)
# Hi, my friend, how are you?
# Executing: regex.regex.sub('o', flags=regex.I)
# Hi, my friend, hPw are yPu?
# Executing: regex.regex.sub('u', flags=regex.I)
# Hi, my friend, hPw are yPP?
# Executing: regex.regex.sub('y', flags=regex.I)
# Hi, mP friend, hPw are PPP?
# Executing: regex.regex.sub('z', flags=regex.I)
# Hi, mP friend, hPw are PPP?
# Executing: regex.regex.sub('b', flags=regex.I)
# Hi, mP friend, hPw are PPP?
# Executing: regex.regex.sub('k', flags=regex.I)
# Hi, mP friend, hPw are PPP?
# Executing: regex.regex.sub('w', flags=regex.I)
# Hi, mP friend, hPP are PPP?
# Executing: regex.regex.sub('k', flags=regex.I)
# Hi, mP friend, hPP are PPP?
# Executing: regex.regex.sub('a', flags=regex.I)
# Hi, mP friend, hPP Pre PPP?
text = """Hi, my friend, how are you?"""
allfus = [
FlexiblePartial(
regex.sub,
False, # this_args_first = False (text will be the last arg when the function is called)
text,
flags=regex.IGNORECASE,
)
for x in range(10)
]
for alsw in allfus:
print(f"Executing: {alsw}")
text = alsw(choice(list(ascii_lowercase)), choice(list(ascii_lowercase)))
print(text)
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, me friend, how are eou?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, mv friend, how are vou?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my friend, hos are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my frienh, how are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my friend, how are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my mriend, how are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my friend, how are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, mv friend, how are vou?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my friend, how are you?
# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)
# Hi, my friend, how rre you?
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/flexible_partial",
"name": "flexible-partial",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "partial,functools,args,kwargs",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/31/8c/2f4ed6bf784ceb82cb2e654616db27a08c8aee66eaf1061a4a9e8119e862/flexible_partial-0.12.tar.gz",
"platform": null,
"description": "\n# Like partial, but you can determine the order of *args\n\n\n\n```python\n\npip install flexible-partial\n\n```\n\n\n\n```python\n\n#######################################\n\nUpdate 2022-12-04:\n\n\n\n# When you use FlexiblePartialOwnName, you can define the output of __str__ and __repr__ \n\n\n\nfrom flexible_partial import FlexiblePartial, FlexiblePartialOwnName\n\nimport regex\n\nfrom random import choice\n\nfrom string import ascii_lowercase\n\ntext = \"\"\"Hi, my friend, how are you?\"\"\"\n\nallfus = [\n\n FlexiblePartialOwnName(\n\n regex.sub,\n\n f'{x} Hello, I am a function!', # for __str__ and __repr__ \n\n True, # this_args_first = True (choice(list(ascii_lowercase)) will be the first arg when the function is called)\n\n choice(list(ascii_lowercase)),\n\n flags=regex.IGNORECASE,\n\n )\n\n for x in range(10)\n\n]\n\nfor alsw in allfus:\n\n print(f\"Executing: {alsw}\")\n\n text = alsw(\"P\", text)\n\n print(text)\n\n \n\nExecuting: 0 Hello, I am a function!\n\nHi, my friePd, how are you?\n\nExecuting: 1 Hello, I am a function!\n\nHi, my friePd, how are you?\n\nExecuting: 2 Hello, I am a function!\n\nHi, mP friePd, how are Pou?\n\nExecuting: 3 Hello, I am a function!\n\nHi, mP friePd, how are Pou?\n\nExecuting: 4 Hello, I am a function!\n\nHi, mP friePd, hPw are PPu?\n\nExecuting: 5 Hello, I am a function!\n\nHi, mP friePd, hPw are PPu?\n\nExecuting: 6 Hello, I am a function!\n\nHi, PP friePd, hPw are PPu?\n\nExecuting: 7 Hello, I am a function!\n\nHi, PP friePd, hPP are PPu?\n\nExecuting: 8 Hello, I am a function!\n\nHi, PP friePd, hPP Pre PPu?\n\nExecuting: 9 Hello, I am a function!\n\nHi, PP friePd, hPP Pre PPP?\n\n\n\n#######################################\n\n\n\nfrom flexible_partial import FlexiblePartial\n\nimport regex\n\nfrom random import choice\n\nfrom string import ascii_lowercase\n\n\n\ntext = \"\"\"Hi, my friend, how are you?\"\"\"\n\n\n\nallfus = [\n\n FlexiblePartial(\n\n regex.sub,\n\n True, # this_args_first = True (choice(list(ascii_lowercase)) will be the first arg when the function is called)\n\n choice(list(ascii_lowercase)),\n\n flags=regex.IGNORECASE,\n\n )\n\n for x in range(10)\n\n]\n\n\n\nfor alsw in allfus:\n\n print(f\"Executing: {alsw}\")\n\n text = alsw(\"P\", text)\n\n print(text)\n\n\n\n# Executing: regex.regex.sub('z', flags=regex.I)\n\n# Hi, my friend, how are you?\n\n# Executing: regex.regex.sub('o', flags=regex.I)\n\n# Hi, my friend, hPw are yPu?\n\n# Executing: regex.regex.sub('u', flags=regex.I)\n\n# Hi, my friend, hPw are yPP?\n\n# Executing: regex.regex.sub('y', flags=regex.I)\n\n# Hi, mP friend, hPw are PPP?\n\n# Executing: regex.regex.sub('z', flags=regex.I)\n\n# Hi, mP friend, hPw are PPP?\n\n# Executing: regex.regex.sub('b', flags=regex.I)\n\n# Hi, mP friend, hPw are PPP?\n\n# Executing: regex.regex.sub('k', flags=regex.I)\n\n# Hi, mP friend, hPw are PPP?\n\n# Executing: regex.regex.sub('w', flags=regex.I)\n\n# Hi, mP friend, hPP are PPP?\n\n# Executing: regex.regex.sub('k', flags=regex.I)\n\n# Hi, mP friend, hPP are PPP?\n\n# Executing: regex.regex.sub('a', flags=regex.I)\n\n# Hi, mP friend, hPP Pre PPP?\n\n\n\ntext = \"\"\"Hi, my friend, how are you?\"\"\"\n\n\n\nallfus = [\n\n FlexiblePartial(\n\n regex.sub,\n\n False, # this_args_first = False (text will be the last arg when the function is called)\n\n text,\n\n flags=regex.IGNORECASE,\n\n )\n\n for x in range(10)\n\n]\n\n\n\nfor alsw in allfus:\n\n print(f\"Executing: {alsw}\")\n\n text = alsw(choice(list(ascii_lowercase)), choice(list(ascii_lowercase)))\n\n print(text)\n\n\n\n\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, me friend, how are eou?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, mv friend, how are vou?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my friend, hos are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my frienh, how are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my friend, how are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my mriend, how are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my friend, how are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, mv friend, how are vou?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my friend, how are you?\n\n# Executing: regex.regex.sub('Hi, my friend, how are you?', flags=regex.I)\n\n# Hi, my friend, how rre you?\n\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Like partial, but you can determine the order of *args",
"version": "0.12",
"project_urls": {
"Homepage": "https://github.com/hansalemaos/flexible_partial"
},
"split_keywords": [
"partial",
"functools",
"args",
"kwargs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5def0edafefc93745fcf5ec8035cc2271b6ea87987a8b2452c631f5e96362190",
"md5": "39d15639f528f0f21980fd1466905fa2",
"sha256": "3d41d3638dc6add3086f62f2deb25c11436859bdaceea048efed0971de145e28"
},
"downloads": -1,
"filename": "flexible_partial-0.12-py3-none-any.whl",
"has_sig": false,
"md5_digest": "39d15639f528f0f21980fd1466905fa2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6035,
"upload_time": "2022-12-04T22:22:50",
"upload_time_iso_8601": "2022-12-04T22:22:50.652444Z",
"url": "https://files.pythonhosted.org/packages/5d/ef/0edafefc93745fcf5ec8035cc2271b6ea87987a8b2452c631f5e96362190/flexible_partial-0.12-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "318c2f4ed6bf784ceb82cb2e654616db27a08c8aee66eaf1061a4a9e8119e862",
"md5": "a977d8227c4f1be48c031c88925d1aaf",
"sha256": "7e9441ce6198cef6906b56eb627ae1e3dd0e3434d5f0952e43dcbed70d85ab46"
},
"downloads": -1,
"filename": "flexible_partial-0.12.tar.gz",
"has_sig": false,
"md5_digest": "a977d8227c4f1be48c031c88925d1aaf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5198,
"upload_time": "2022-12-04T22:22:52",
"upload_time_iso_8601": "2022-12-04T22:22:52.281312Z",
"url": "https://files.pythonhosted.org/packages/31/8c/2f4ed6bf784ceb82cb2e654616db27a08c8aee66eaf1061a4a9e8119e862/flexible_partial-0.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-04 22:22:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hansalemaos",
"github_project": "flexible_partial",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "flexible-partial"
}