Skip to main content

Convert Fortran format specifiers to Python format strings.

Project description

Convert Fortran format specifiers to Python format strings.

Build status Test coverage

PyPI Package latest release Supported versions PyPI Wheel Status

Requirements

Installation

fortran-format-converter is on PyPI so the easiest way to install it is:

$ pip install fortran-format-converter

Usage

Currently fortran-format-converter only handles simple conversions and in a single direction, Fortan -> Python.

We begin by importing the converter.

import fortran_format_converter as ffc

Now to convert a Fortran style format specification to a Python format string is as simple as supplying the convert function with the Fortran formatting specification.

>>> ffc.convert('F6.2')
'6.2f'

Most types of Fortran format specifications are supported, such as binary.

>>> ffc.convert('B16.16')
'016b'

If an invalid format string is given an error will be raised.

>>> ffc.convert('J4')
Traceback (most recent call last):
...
ValueError: 'J4' is not a valid Fortran format specifier

Sometimes it may be desirable to parameterized the format. This can be accomplished with the width, align, and precision fields of the Format class.

>>> format = ffc.Format('F5.2')
>>> '{:{width}.{prec}f}'.format(2.718281828459, width=format.width, prec=format.precision)
 2.72

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

fortran-format-converter-0.1.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fortran-format-converter-0.1.3.tar.gz.

File metadata

  • Download URL: fortran-format-converter-0.1.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for fortran-format-converter-0.1.3.tar.gz
Algorithm Hash digest
SHA256 389fa8bc3ee46c0fdae7dd930c9fa6f0582755ffbb4a6bbb97e8559c2feb5559
MD5 eb06c5ae212f082ee4a72d859b88db81
BLAKE2b-256 e7d22edd076fc506f3e0ba3cb29c7bd81c43e07c3c7f25ee4f78379531cf260d

See more details on using hashes here.

File details

Details for the file fortran_format_converter-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fortran_format_converter-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for fortran_format_converter-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 df92d4ebad750f9d043143abef6517f82d676af6c0f7f21ca561996888d58192
MD5 f189ffe38b0800f7b0bb5053deeb3968
BLAKE2b-256 9a92abfc900b7746742e99db17cab6584680a803f484508eb9f35409a5d60fca

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