Skip to main content

Save and load vars, functions ...

Project description

Save and load vars, functions, objects ...

How to save the global vars (or any other variable)

# 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

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

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

save_load_vars-0.11.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

save_load_vars-0.11-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file save_load_vars-0.11.tar.gz.

File metadata

  • Download URL: save_load_vars-0.11.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for save_load_vars-0.11.tar.gz
Algorithm Hash digest
SHA256 bcfb8dae2c660dd080c054727e694e81e2773bb76ae8492a78991ccb8464afe4
MD5 979d0816c91a1190108ac6d156260265
BLAKE2b-256 6d1209254651dc0a963ba6cc0bd34e9141e78bef4b60d52486f0ec2e592432d0

See more details on using hashes here.

File details

Details for the file save_load_vars-0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for save_load_vars-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 4ce80d5fd3ef27d0161c7d5abc74317da80d9efdede690ad04a5a3f3878a2115
MD5 a8c70ddff6fd97d018d1a20e21290029
BLAKE2b-256 e33dc1bfc110128cc45cc4118a969de631ab7d3006347672f16964bfb8c6c75a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page