Skip to main content

Add not pythonic syntax into your python.

Project description

hdytto: How do you turn this on

A library adding new syntax into your Python. i.e. It is NOT Pythonic :)

Compatibility

  • Python >=3.8

Getting Started

Install from PyPI:

$ pip install hdytto

This library cannot be used by import hdytto as in other libraries, but the usage is simple. At first, make sitecustomize.py:

from hdytto import register_hdytto
register_hdytto()

Set the environmental variable PYTHONPATH the path to the directory containing the sitecustomize.py (e.g. export PYTHONPATH=.). Then, run main.py:

# coding: hdytto

a = 5
print(a++)
print(a)

The output will be

5
6

REPL

Additionally, make .pythonrc.py:

import sys
import sitecustomize
sys.stdin.reconfigure(encoding='hdytto')

Set the environmental variable PYTHONSTARTUP the path to this .pythonrc.py (e.g. export PYTHONSTARTUP=.pythonrc.py). Then, type python:

$ python
>>> a = 5
>>> a++
5
>>> do:
...     b = ++a
...     while b < 10
...
>>> b
10

hdytto Reference

Increment / Decrement

Syntax

x++
++x
x--
--x

Example

# coding: hdytto
a = 5
print(a++)
print(++a)
b = 10 - --a
print(b--)

Output:

5
7
4

do...while

Syntax

do:
    statement
    while condition

Example

# coding: hdytto
do:
    a = 5
    while a < 3
do:
    b = a * 2
    while a++ < 10:
        pass
    while b <= 20
print(b)

Output:

22

Comment

Syntax

/* */

Example

# coding: hdytto
a = /* foo */ 10
print(a)
if a == 10:
    b = 5
    /*b = 10
print(a - 20)*/
print(b)

Output:

10
5

const

Syntax

const name = value

Example

# coding: hdytto

import time

def foo(x, const y):
    y = 20
    print(x + y)

print('long time process here.')
const a = 30
time.sleep(a) # a process requiring long time

foo(1, 2)

Output:

  File "main.py", line 6
    y = 20
         ^
SyntaxError: invalid assignment to const y

SyntaxError: encoding problem: hdytto

This is SyntaxError, so does not require running the process requiring long time.

Caution

hdytto's const only prohibits =, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, **=, //=, @=, :=, otherwise is allowed (e.g. const l = [] and l.append(5) is allowed).

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

hdytto-0.2.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

hdytto-0.2.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file hdytto-0.2.1.tar.gz.

File metadata

  • Download URL: hdytto-0.2.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.1

File hashes

Hashes for hdytto-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ae3095c12ae7ae46e674c61a3929bfb8640b2489b5c9f7bb387f7586b1cb9207
MD5 b650130c5094cde87d891683c49e82a6
BLAKE2b-256 a8f46f77dcc872a9303dd8212e3e2d8c23611ba4daf4ebef175a376006ed6750

See more details on using hashes here.

File details

Details for the file hdytto-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: hdytto-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.1

File hashes

Hashes for hdytto-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5486a00e0fa0079eca0083bc1a9345e738b7091cb30b6a4362252ab63e191a0
MD5 2ff99346d98d5fc661d43babd692ed26
BLAKE2b-256 69c729f5a99a418393c7d1b0f92eb9001928df125840e38bb83236e0633edad7

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