# Save and load vars, functions, objects ...
### How to save the global vars (or any other variable)
```python
# Create a file
import pandas as pd
from save_load_vars import save_vars_pkl
df = pd.read_csv(
"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv"
)
def myfunction(x):
return str(x) + "bbbb"
myfunction2 = lambda k: myfunction(k)
partofframe = df.Name.copy()[:50]
# Save the global vars
save_vars_pkl(g=globals(), folder=f"f:\\pklsavetest", interface="dill", protocol=None)
```
### How to load the saved data
```python
from save_load_vars import load_vars_pkl
load_vars_pkl(folder=f'f:\\pklsavetest',
name=__name__,interface='dill')
print(df)
print(myfunction(44))
print(partofframe)
print(df.Cabin.apply(myfunction2))
```
### How to create global variables from a dict
```python
from save_load_vars import globals_from_dict
didi={
'a':'bobo',
'b':'bobao',
'c': [4,3,3]
}
globals_from_dict(didi,__name__)
print(a)
print(b)
print(c)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hansalemaos/save_load_vars",
"name": "save-load-vars",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pickle,dill",
"author": "Johannes Fischer",
"author_email": "<aulasparticularesdealemaosp@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/6d/12/09254651dc0a963ba6cc0bd34e9141e78bef4b60d52486f0ec2e592432d0/save_load_vars-0.11.tar.gz",
"platform": null,
"description": "\n# Save and load vars, functions, objects ...\n\n\n\n\n\n### How to save the global vars (or any other variable)\n\n```python\n\n# Create a file\n\n\n\nimport pandas as pd\n\nfrom save_load_vars import save_vars_pkl\n\n\n\ndf = pd.read_csv(\n\n \"https://raw.githubusercontent.com/pandas-dev/pandas/main/doc/data/titanic.csv\"\n\n)\n\n\n\n\n\ndef myfunction(x):\n\n return str(x) + \"bbbb\"\n\n\n\n\n\nmyfunction2 = lambda k: myfunction(k)\n\npartofframe = df.Name.copy()[:50]\n\n\n\n# Save the global vars \n\nsave_vars_pkl(g=globals(), folder=f\"f:\\\\pklsavetest\", interface=\"dill\", protocol=None)\n\n\n\n```\n\n\n\n\n\n### How to load the saved data\n\n```python\n\nfrom save_load_vars import load_vars_pkl\n\n\n\n\n\nload_vars_pkl(folder=f'f:\\\\pklsavetest',\n\n name=__name__,interface='dill')\n\n\n\nprint(df)\n\nprint(myfunction(44))\n\nprint(partofframe)\n\nprint(df.Cabin.apply(myfunction2))\n\n```\n\n\n\n\n\n### How to create global variables from a dict\n\n```python\n\nfrom save_load_vars import globals_from_dict\n\ndidi={\n\n 'a':'bobo',\n\n 'b':'bobao',\n\n 'c': [4,3,3]\n\n}\n\nglobals_from_dict(didi,__name__)\n\nprint(a)\n\nprint(b)\n\nprint(c)\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Save and load vars, functions ...",
"version": "0.11",
"split_keywords": [
"pickle",
"dill"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e33dc1bfc110128cc45cc4118a969de631ab7d3006347672f16964bfb8c6c75a",
"md5": "a8c70ddff6fd97d018d1a20e21290029",
"sha256": "4ce80d5fd3ef27d0161c7d5abc74317da80d9efdede690ad04a5a3f3878a2115"
},
"downloads": -1,
"filename": "save_load_vars-0.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a8c70ddff6fd97d018d1a20e21290029",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5772,
"upload_time": "2023-02-08T20:40:33",
"upload_time_iso_8601": "2023-02-08T20:40:33.325224Z",
"url": "https://files.pythonhosted.org/packages/e3/3d/c1bfc110128cc45cc4118a969de631ab7d3006347672f16964bfb8c6c75a/save_load_vars-0.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6d1209254651dc0a963ba6cc0bd34e9141e78bef4b60d52486f0ec2e592432d0",
"md5": "979d0816c91a1190108ac6d156260265",
"sha256": "bcfb8dae2c660dd080c054727e694e81e2773bb76ae8492a78991ccb8464afe4"
},
"downloads": -1,
"filename": "save_load_vars-0.11.tar.gz",
"has_sig": false,
"md5_digest": "979d0816c91a1190108ac6d156260265",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4278,
"upload_time": "2023-02-08T20:40:35",
"upload_time_iso_8601": "2023-02-08T20:40:35.033645Z",
"url": "https://files.pythonhosted.org/packages/6d/12/09254651dc0a963ba6cc0bd34e9141e78bef4b60d52486f0ec2e592432d0/save_load_vars-0.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-08 20:40:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "hansalemaos",
"github_project": "save_load_vars",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "save-load-vars"
}