Skip to main content

a python library that convert string to code.

Reason this release was yanked:

broken

Project description

tocode

Python version BSD Licence Project Initiator Repo Size Downloads PyPI version shields.io GitHub Workflow Status

This is a library that can convert the strings to code and return the literal eval of that it will convert strings which contain:

  • lists
  • tuples
  • dictionaries
  • sets

Overview

into the python eval and the most important thing in this library that make it unique is:
if your strings don't have any quotation no worries it will add quotations for you!

example

before:

! "{'this': 5, (Alex, Daniel): are good boys, (5, 4): 8.5}" 

after:

+ "{'this': 5, ('Alex', 'Daniel'): 'are good boys', (5, 4): 8.5}

Usage

In the following paragraphs, I am going to describe how you can get and use tocode for your own projects.

Getting it

To download tocode library, either fork this github repo or simply use Pypi via pip.

$ pip install tocode

Using it

tocode was programmed with ease-of-use in mind. First, import literal_eval from tocode.

for more exact usage documents you can see the example files here

import tocode

# Example:
my_array = " ['Hello', Goodbye my friend, 2.5, (4, ok), {one: 450, 'two': 12}] "
my_array = tocode.literal_eval(my_array, no_string_quotation=True)
"""
  if some of the strings don't have quotation set `no_string_quotation` to True
  otherwise, set it to False or leave it.
"""
# will return the list into a python list

output:

['Hello', 'Goodbye my friend', 2.5, (4, 'ok'), {'one': 450, 'two': 12}]

Support

Supported versions of python for this library are as follow:

License

This project is under BST license read it here:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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

tocode-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tocode-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file tocode-0.1.1.tar.gz.

File metadata

  • Download URL: tocode-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tocode-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3474ace8e5cbe3a59c80f192285d2bca01f77646a09b4006a2f270537726f159
MD5 9c15e5622f72aa6b724f8c9c4f7241ce
BLAKE2b-256 bd66e73ebb324451883ceec6d48f663e0e4c4162e8093dfb3c637c848ffdbeba

See more details on using hashes here.

File details

Details for the file tocode-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tocode-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for tocode-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e067503026dc7be160938389b50c0775bfe24448f9a77304b69fd69198efb5e
MD5 e1b25da72b84d810e19d8bc1be98d18b
BLAKE2b-256 66bbbfa6a20c7c96627566974f45f1e65079baef360371f3713da491ebd56870

See more details on using hashes here.

Supported by

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