Skip to main content

Utility functions for LogicBase

Project description

Utility Functions for Logic Bank, and others (no Logic Bank dependencies).

Addressing Python Path, for proper import operation

This is from stackoverflow. Essentially, many of us have discovered the hard way is that:

  • import statements often work in PyCharm

  • but fail in VSCode, Command Line, etc

Setting `PYTHONPATH` is what makes imports work. I use the following VSCODE .env content so that it works for any project:

PYTHONPATH=${PROJ_DIR}:${PYTHONPATH}

This is essentially what PyCharm does when you check Add Content Roots to PYTHONPATH in your run/debug configuration. It’s a helpful setting, but it spoils you because your code fails outside PyCharm.

Or, if you run in terminal, first export:

export PYTHONPATH=…

add_python_path

You may find it easier to address this in your application, by calling the following:

def add_python_path(project_dir: str, my_file: str) -> (str, str):
    """
    @param project_dir: enclosing path node, with optional "*" for starts-with (e.g., LogicBank, LogicBank*)
    @param my_file: callers __file__ variable
    @result (path_was_fixed, path)

For example, if you are several levels deep in a project were the root is `MyProjectRoot`:

import logic_bank_utils.util as logic_bank_utils

(did_fix_path, sys_env_info) = \
    logic_bank_utils.add_python_path(project_dir="MyProjectRoot", my_file=__file__)
print("\n" + did_fix_path + "\n\n" + sys_env_info + "\n\n")

Depends on:

  • Python 3.8

Change Log

0.3.0 - Initial Version

0.4.0 - Improved doc

0.5.0 - More formatting on return string

0.6.0 - Provide for my-project* (startsWith)

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

logicbankutils-0.6.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

logicbankutils-0.6.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file logicbankutils-0.6.0.tar.gz.

File metadata

  • Download URL: logicbankutils-0.6.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for logicbankutils-0.6.0.tar.gz
Algorithm Hash digest
SHA256 6b3640c1bd82218f96cf2e2fd052bf962510e1bf173cd9be4d8cf042ad3eee33
MD5 4ec6f13b1903e389a1efcdd95998d209
BLAKE2b-256 d5c83190492d41ea0c6a4f36f96e7883fef846b7327e3465bff470d709d8dbb5

See more details on using hashes here.

File details

Details for the file logicbankutils-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: logicbankutils-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for logicbankutils-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16de713b061d27ea4a8b01dda9749ee3c5e2323a1ee1f178931fc38dcbc13bcf
MD5 d87e2a0e9ae7ff2ce8263b4e85ebd70f
BLAKE2b-256 dc05dc32559d19e27758c15e05edb2a24ad0a8de6bb1866f9cfddec952ee11eb

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