跳转到主要内容

允许在Python中充分发挥shadok逻辑的效率。

项目描述

shadok

一个Python库,允许释放shadok逻辑的全部效率。

安装

pip3 install shadok

用法

ShadokInteger

您可以从int或字符串创建一个ShadokInteger

from shadok import ShadokInteger
i = ShadokInteger("BugaZoMeu")
j = ShadokInteger(56)
k = ShadokInteger("◿")
print(i,j,k)
# −𝙾ᒧ◿ ◿ᒧ𝙾 ◿
print(int(i), int(j), int(k))
# 75 56 3
print(i.pronunciation, j.pronunciation, k.pronunciation)
# BuGaZoMeu MeuZoGa Meu

您不能从包含多个单词的字符串创建一个ShadokInteger。以下代码将引发错误。但您失败得越多,您就越接近成功

from shadok import ShadokInteger
ShadokInteger("Buga ZoMeu")

将得到以下错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/shadok/shadok/shadok_integer.py", line 14, in __init__
    % value
shadok.path_to_success.ImproperShadokLogic: Cannot cast string containing
multiple words ('Buga ZoMeu') to an int.

ShadokString

您可以从由空格分隔的多个单词的shadok句子创建一个ShadokString。如果一个单词是shadok整数,您可以使用int()获取其值。ShadokString是字符串,这意味着您可以从一个创建一个ShadokInteger

from shadok import ShadokString
a = ShadokString("zogabuzomEu")
b = ShadokString("ZoGabuzoMeu")
c = ShadokString("Gabu")
c += "◿ᒧ𝙾 ZoMEU"  # Mutlitple words
print(a,b,c)
# ZoGaBuZoMeu ZoGaBuZoMeu GaBu ◿ᒧ𝙾 ZoMeu
print(int(a), int(b)) # c cannot be casted to int
# 539 539

您不能在ShadokString中使用不正确的shadok语法

from shadok import ShadokString
ShadokString("Gabu Gibi")

将得到以下错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/shadok/shadok/shadok_string.py", line 42, in __init__
    MagicFaucet.check_syntax(self.raw_string)
  File "/home/shadok/shadok/magic_faucet.py", line 42, in check_syntax
    raise ImproperShadokSyntax(word, matches)
shadok.path_to_success.ImproperShadokSyntax:
Incorrect shadok syntax in 'Gibi'
                            ^^^^
Au Goulp !

您还可以将ShadokString翻译成法语

import itertools
from shadok import ShadokString
result = lambda val:print("Translation of {} : {}".format(val, ShadokString(val).translation))
letters = ["Ga", "Bu", "Zo", "Meu"]
for a in  letters:
    result(a)
for a, b in itertools.product(letters, letters):
    result(a+b)
for a,b,c in itertools.product(letters, letters, letters):
    result(a+b+c)

将产生以下输出

Translation of Ga : {0, 'Moi', 'Intérieur', 'Non'}
Translation of Bu : {1, 'Oui', 'Eau'}
Translation of Zo : {'Nouille', 2, 'Extérieur', 'Lui'}
Translation of Meu : {'Trou', 3}
Translation of GaGa : {0, 'Toi'}
Translation of GaBu : {1, 'Notion'}
Translation of GaZo : {2}
Translation of GaMeu : {3}
Translation of BuGa : {4, 'Petite pompe'}
Translation of BuBu : {5}
Translation of BuZo : {6}
Translation of BuMeu : {7}
Translation of ZoGa : {8}
Translation of ZoBu : {9}
Translation of ZoZo : {10}
Translation of ZoMeu : {11}
Translation of MeuGa : {12}
Translation of MeuBu : {13}
Translation of MeuZo : {14}
Translation of MeuMeu : {'Trous', 15}
Translation of GaGaGa : {0, "Espèce d'imbécile"}
Translation of GaGaBu : {1}
Translation of GaGaZo : {2}
Translation of GaGaMeu : {3}
Translation of GaBuGa : {4}
Translation of GaBuBu : {5}
Translation of GaBuZo : {6}
Translation of GaBuMeu : {7}
Translation of GaZoGa : {8}
Translation of GaZoBu : {9}
Translation of GaZoZo : {10}
Translation of GaZoMeu : {11}
Translation of GaMeuGa : {12}
Translation of GaMeuBu : {13}
Translation of GaMeuZo : {14}
Translation of GaMeuMeu : {15}
Translation of BuGaGa : {16, 'Grosse pompe'}

...
Translation of MeuMeuMeu : {63}

MagicFaucet

MagicFaucet 允许检查字符串是否在正确的shadok语法中

from shadok import MagicFaucet
# Proper syntax, nothing will happen
MagicFaucet.check_syntax("GabuZo")
# Will raise an ImproperShadokSyntax exception
MagicFaucet.check_syntax("GabuZoMi")

将得到以下错误

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/shadok/shadok/magic_faucet.py", line 42, in check_syntax
    raise ImproperShadokSyntax(word, matches)
shadok.path_to_success.ImproperShadokSyntax:
Incorrect shadok syntax in 'GabuZoMi'
                                  ^^
Au Goulp !

MagicFaucet 还允许在没有实例化ShadokString的情况下美化您的shadok

from shadok import MagicFaucet
print(MagicFaucet.pretty_print("meumEumEUmEu"))
# 'MeuMeuMeuMeu'

常见问题解答

  • 我需要在大型数字上执行严肃的算术运算,这个库提供这样的功能吗?

遗憾的是,目前可达的最高元-二进制阶仅为31。这些是非常大的非常元-二进制。

  • 为什么当我把GaGaGaGaGaBu转换成int时它变成了Bu

请参阅 "我的空元箱不见了"。

  • 当我创建ShadokInteger时,我的空元箱不见了?!但我的数字变大了,我需要它们!

您应该只在需要它们以提高效率时创建元箱。

  • 我的字符串是Gagaga,被转换成布尔值。它返回了False,不应该意味着你是傻瓜!并返回True吗?

当评估只包含 Ga 的字符串时,你必须问自己:为什么进行简单的测试,而复杂的测试也能做到呢?沙多克逻辑告诉我们,在评估布尔值时需要将其转换为 int。我们还需要去掉整数中的空元组。所以 Gagaga 等于 0,等于 [False, "You fool !"]。因此,当转换为布尔值时,你有 1/33 的几率等于 False,有 1/2 的几率等于 "You fool !"。它也可能是 True,但这可能纯属偶然,也许是个错误。

  • 使用这个库是否有任何副作用?

是的,对于小型操作,我们正在尝试依赖成为父级(BuBu)所需的新阈值。如果你在使用它被创建之前编写的程序,并且如果新的改革尚未生效,我们可以计算到旧的限制(BuGa),如果我们不小心,可能会创建几百万个沙多克的蛋。然而,请注意,对于大型操作,这有助于性能,因为沙多克一旦孵化就可以帮助并行处理,所以在这种情况下,我们故意计算超过 5。

  • 我可以并行运行它吗?

见上面的问题,这是默认设置,但你需要先数到 −−。如果你数到 −𝙾 或更少,你为什么还要并行运行呢?

  • 当你使用 MagicFaucet 美化打印时,你会数到 −𝙾 吗?

不。

  • 当我实例化我的 Colander 时,我得到一个 ColanderIsInFactABusError

你的漏斗看起来像一个锅,请确保你的锅有一个把手,并且实际上不是一个公共汽车。

项目详情


下载文件

下载您平台上的文件。如果您不确定要选择哪个,请了解更多关于 安装软件包 的信息。

源代码分发

此版本没有可用的源代码分发文件。请参阅 生成分发存档 的教程。

构建分发

shadok-1.2.3-py3-none-any.whl (14.5 kB 查看哈希值)

上传时间 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面