Saravanan666/pypi-org huggingface dataset:
Package: ast2json
Introductionast2json is a small module that will convert any python AST node into its ast
representation formated in a JSON compatible python representation (list and
dicts containing string, ints and null).Installationpip install ast2json
# or to have lastest version
pip install git+git://github.com/Psycojoker/ast2json.gitUsage>>> import json
>>> from ast import parse
>>> from ast2json import ast2json

>>> ast = ast2json(parse(open('some_python_source_file.py').read()))
>>> print json.dumps(ast, indent=4)If you are lazy, “str2json” will apply the “parse” method of ast on a string for you, so you’ll be able to write:>>> str2json(open('some_python_source_file.py').read())ExampleThis is the result of converting ‘print “Hello World!”’ (and applying json.dumps on the result).{
    "body": [
        {
            "_type": "Print",
            "nl": true,
            "col_offset": 0,
            "dest": null,
            "values": [
                {
                    "s": "Hello World!",
                    "_type": "Str",
                    "lineno": 1,
                    "col_offset": 6
                }
            ],
            "lineno": 1
        }
    ],
    "_type": "Module"
}Changelog0.3 (2022-04-25)add support for elipsis0.2.1 (2016-11-13)fix broken pip installation by @abolger0.2 (2016-09-03)python 3 support and some unit testing by Juncheol Cho @zironychoLicenceBSD
Package: astana-hub
Installationpip install astana-hubFeaturesGet company list fromhttps://astanahub.com/account/company/Optional filter by tags: ('tag_startup', 'tag_it_company', 'tag_corp_partner', 'tag_techpark', 'tag_ts_member')Get user list fromhttps://astanahub.com/account/company/Optional filter by tags: ('tag_intern', 'tag_it_specialist', 'tag_investor', 'tag_international_agent')Async by aiohttpHTML parsing with bs4+lxmlUsageimport asyncio
import astana_hub

async def main():
    async with astana_hub.Parser.create() as p:
        company_list_page1 = await p.get_company_page()
        print(company_list_page1)
        
        user_list_page1 = await p.get_user_page()
        print(user_list_page1)

        all_users = await p.parse_all(page_type='user')
        print(all_users)

        all_startups = await p.parse_all(page_type='company', tag='tag_startup')
        print(all_startups)

asyncio.run(main())
Package: astar-devopstool
参考资料[1]https://github.com/ASTARCHEN/astartool[2]https://blog.csdn.net/qq_43057091/article/details/82179301[3]https://blog.csdn.net/qq_41841569/article/details/83824278[4] ftp自动下载、自动上传脚本，可以递归目录操作http://blog.csdn.net/ouyang_peng/article/details/79271113
Package: astar-python
# astar_pythonusing:- from astar_python.astar import Astarbuild your weight map:```pythonmat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],]```Init the Astar object```pythonastar = Astar(mat)```Run astar with a start point and a end point like [x, y] (left to right = x, top to bottom = y```pythonresult = astar.run([0, 0], [10, 9])```result is an array of point:```pythonprint(result)--[[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 9]]```If no way to the end, A* return Nonegive:```python[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0][0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]```# WeightsA weight on the matrix is the cost to cross the point.Cost can be:* positive: more it is positive, more it's difficult to cross the region* negative: is like a booster, you can custom your way* 0: a normal point* None: not crossableExemple: The number '1' is the way taken, others are weights```python# A simple barrage[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 0][0, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]# It decided to cross barrage[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 0][0, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 5, 0, 0, 0, 0, 0][0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0][0, 0, 0, 0, 0, None, 0, 1, 1, 1, 1]astar_python[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0][0, 1, 0, -5, -5, -5, 0, 0, 0, 0, 0][0, 0, 1, 0, 0, 5, 1, 0, 0, 0, 0][0, 0, 0, 0, 0, 5, 0, 1, 0, 0, 0][0, 0, 0, 0, 0, 5, 0, 0, 1, 0, 0][0, 0, 0, 0, 0, 5, 0, 0, 0, 1, 0][0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1][0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1][0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1][0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]```
Package: astarRobi
A* Search Algorithm.Anyone of you can use this library to do A* searchGithub Open SourceExisting methodsfeed(self,heuristic_value_list,adjacency_matrix,node_name_dictionary)path() - Show the solved path with lowest costusing process1st need to add the librarypipinstallastarRobi2nd You must need to implement neccessary list and dictionary like this ->node_dict={0:"S",1:'A',2:'B',3:'C',4:'D'}adj_node=[[-1,1,4,-1,-1],[-1,-1,2,5,12],[-1,-1,-1,2,-1],[-1,-1,-1,-1,3],[-1,-1,-1,-1,-1]]h_val=[7,2,6,1,0]#here heuristic value 0 denotes the goal node.3rd import aster and feed the data into itimportastarRobiasastartest=astar.feed(h_val,adj_node,node_dict)#feeding the algorithm neccessary datatest.path()#Showing the computed result :)N.B: part 2 is customizable you could feed any graph you want here a demo data is given. :)
Package: astar-tcn
This repository contains the experiments done in the work [An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling](https://arxiv.org/abs/1803.01271) by Shaojie Bai, J. Zico Kolter and Vladlen Koltun.We specifically target a comprehensive set of tasks that have been repeatedly used to compare the effectiveness of different recurrent networks, and evaluate a simple, generic but powerful (purely) convolutional network on the recurrent nets’ home turf.Experiments are done in PyTorch. If you find this repository helpful, please cite our work:
Package: astarte-device-sdk
Astarte Python device SDKPython device SDK forAstarte. Create Astarte Devices
and Simulators with Python3.
It integrates with asyncio to ensure a smooth developer experience and to hide complex details
regarding threading and MQTT interactions.How to get with PipThe Astarte device SDK can be obtained by running:pip install astarte-device-sdkBasic usageCreate a deviceInitializing an instance of a device can be performed in three steps, as seen below.fromastarte.deviceimportDeviceMqtt# Create the device instancedevice=DeviceMqtt(device_id="device id",realm="realm",credentials_secret="credentials secret",pairing_base_url="pairing url",persistency_dir=".",ignore_ssl_errors=False,)# Add a single interface from a .json filedevice.add_interface_from_file(Path("interfaces/path/file.json"))# Use `device.add_interfaces_from_dir(Path("interfaces/path"))` instead to add all the interfaces in a directory# Connect to Astartedevice.connect()Publish data from devicePublishing new values can be performed using thesendandsend_aggregatefunctions.fromastarte.deviceimportDeviceMqttfromdatetimeimportdatetime,timezone# ... Create a device and connect it to Astarte ...# Send an individual datastream or a propertydevice.send(interface_name="datastream_interface",interface_path=f"/path/name",payload="payload",timestamp=None,)# Send an aggregated object datastreampayload={"endpoint1":"value1","endpoint2":42}device.send_aggregate(interface_name="aggregate_interface",interface_path=f"/path/name",payload=payload,timestamp=datetime.now(tz=timezone.utc),)Receive a server publicationThe device automatically polls for new messages. The user can use a call back function to process
received data. Callback functions are also available for connect/disconnect events.fromastarte.deviceimportDeviceMqttdefmy_callback(device:DeviceMqtt,name:str,path:str,payload:dict):print(f"Received message for{name}{path}:{payload}")# ... Create a device and connect it to Astarte ...# Setup the callbackdevice.set_events_callbacks(on_data_received=my_callback)# Keep the program runningwhileTrue:pass
Package: astarte-message-hub-proto
Astarte message hub protocol buffers for PythonThis module provides access to the Astarte message hub protocol buffers through a Python API.Basic usageUsepipto install theastarte-message-hub-protopackage.Then include and use it in your sources as follows:fromdatetimeimportdatetime,timezoneimportgrpcfromgoogle.protobuf.timestamp_pb2importTimestampfromastarteplatform.msghub.message_hub_service_pb2_grpcimportMessageHubStubfromastarteplatform.msghub.node_pb2importNodefromastarteplatform.msghub.astarte_message_pb2importAstarteMessagefromastarteplatform.msghub.astarte_type_pb2importAstarteDataType,AstarteDataTypeIndividualgrpc_channel=grpc.insecure_channel("server address")message_hub_stub=MessageHubStub(grpc_channel)message_hub_node=Node(uuid="node uuid",interface_jsons=[b"interface 1 bin",b"interface 2 bin"])message_hub_stream=message_hub_stub.Attach(message_hub_node)# Transmit a very simple messageprotobuf_value=AstarteDataType(astarte_individual=AstarteDataTypeIndividual(astarte_double=42.1))protobuf_timestamp=Timestamp()protobuf_timestamp.FromDatetime(datetime.now(tz=timezone.utc))msg=AstarteMessage('interface_name'="interface name",'path'="path",'timestamp'=protobuf_timestamp,'astarte_data'=protobuf_value)message_hub_stub.Send(msg)# Never ending receive loopforastarte_messageinmessage_hub_stream:# Parse astarte_message (AstarteMessage) as you see fit.print(astarte_message.interface_name)print(astarte_message.path)print(astarte_message.WhichOneof("payload"))
Package: astartool
toolkit for python.A.Star私房工具包唉~ 写了辣么多代码，总觉得过于臃肿。
我把简单的代码能重复利用的摘出来作为工具包，以后就引用他了目前此代码包含一下几部分:
1. data_structurekeymap: 两端键值的类字典
linked_list: 链表
queue: 链式队列2. error
错误的包MethodNotFoundError: 方法错误
ParameterError: 参数错误
ParameterTypeError: 参数类型错误
ParameterValueError: 参数值错误exception异常的包filedownloadhelper: 大文件下载
excelhelper: excel生成
filehelper: 简单的文件哈希、文件简单操作
imagehelper: 简单的图片转化,目前对base64转imagenumbernumber包包含数论/数字处理的一些基本代码equals_zero: 与numpy.isclose类似，只不过这个是专门判断0的equals_zero_any: 只要有一个为0,则返回True, 否则是Falseequals_zero_all: 只有全部为0, 返回True, 否则是Falseishex: 判断是否是16进制字符串gcd: 辗转相处法求最大公约lcm: 最小公倍数prime_factorzation: 筛选法求素数rotate_left: 循环左移projectfile_logging/std_logging 日志装饰器_project: 文档模板生成_platform: 判断当前运行环境操作系统类型time_clock: 对time.clock的改良，操作系统导致使用错误randomrandom 包包含随机数相关的函数generate_password: 随机密码random_digit_string: 随机生成n位数字random_string: 随机生成一个长度为n的字符串random_hex_string: 随机生成n位16进制字符串random_ip: 随机生成一个ip地址, 目前只支持IPV4security_random_hex: 基于国密SM3的KDFsetuptool包含打包相关的函数_tool: 调用setup方法之前做一些处理_version: 版本管理string包含字符串处理相关函数is_email: 判断是不是邮箱is_mobile: 判断是否是手机号generate_number: 生成n位带时间编号check_number: 检验生成n位带时间编号to_binary: str转bytesto_text: bytes转strpassword_check 检查口令合法性的小工具
Package: astar-utils
Astar UtilsThis package is devloped and maintained byAstar Viennaand contains commonly-used utilities for the group's projects to avoid both duplicating code and circular dependencies.ContentsThe package currently contains the following public functions and classes:NestedMapping: adict-like structure supporting !-style nested keys.RecursiveNestedMapping: a subclass ofNestedMappingalso supporting keys that reference other !-style keys.NestedChainMap: a subclass ofcollections.ChainMapsupporting instances ofRecursiveNestedMappingas levels and referencing !-style keys across chain map levels.is_bangkey(): simple convenience function to check if something is a !-style key.is_nested_mapping(): convenience function to check if something is a mapping containing a least one other mapping as a value.UniqueList: alist-like structure with no duplicate elements and some convenient methods.Badgeand subclasses: a family of custom markdown report badges. See docstring for details.BadgeReport: context manager for collection and generation of report badges. See docstring for details and usage.get_logger(): convenience function to get (or create) a logger with givennameas a child of the universalastarlogger.get_astar_logger(): convenience function to get (or create) a logger with the nameastar, which serves as the root for all A*V packages and applications.Loggers moduleloggers.ColoredFormatter: a subclass oflogging.Formatterto produce colored logging messages for console output.DependenciesDependencies are intentionally kept to a minimum for simplicity. Current dependencies are:more-itertoolspyyamlVersion requirement for these dependencies can be found in thepyproject.tomlfile.
Package: astatine
Some handy helper functions for Python’s AST module.Astatineis a chemical element with the symbol At and atomic number 85.
Its name comes from the Greek astatos (ἄστατος), meaning “unstable”.
It’s a fitting name for Python’sastmodule, which has been unstable between releases.DocsTestsPyPIAnacondaActivityQAOtherInstallationastatinecan be installed from PyPI or Anaconda.To install withpip:$python-mpipinstallastatineTo install withconda:First add the required channels$condaconfig--addchannelshttps://conda.anaconda.org/conda-forge$condaconfig--addchannelshttps://conda.anaconda.org/domdfcodingThen install$condainstallastatine
Package: astax
fastaxOverviewfastax is a Deep Learning Library built on top of Google'sJAXthat tries to
facilitate doing research by providing a combination of JAX's versatility with implementations of
the most used neural networks layers and utilities.More concrete information and namingfastax is both a combination of fastai and JAX and fastai and stax:It is built on top of JAX and most of its original code comes from its Neural Network mini-library staxOne of the long term goals of this library is implementing Jeremy Howard's fastai course"Deep Learning From the Foundations"For more information visithttps://github.com/joaogui1/fastax
Package: astboom
astboomVisualize Python AST/CST/ST in console using ASCII graphics using various engines.Engines available:astmoduleparsermodulelib2to3LibCSTExampleUsageSimply provide a valid Python source code string as an argument
and a corresponding AST/CST/ST will be displayed.ASTUsage: astboom ast [OPTIONS] [SOURCE]

  Display Abstract Syntax Tree for a given source.

Options:
  --no-pos      Hide 'col_offset' and 'lineno' fields.
  --hide-empty  Hide empty fields.lib2to3 CSTUsage: astboom cst [OPTIONS] [SOURCE]

  Display Concrete Source Tree for a given source.

Options:
  --show-prefix  Display value stored in 'prefix' field of the node.Python parse treeUsage: astboom st [OPTIONS] [SOURCE]

  Display Python parse tree for a given source.LibCST treeUsage: astboom libcst [OPTIONS] [SOURCE]

  Display LibCST tree for a given source.

Options:
  --hide-default   Hide fields that contain default value
                   (MaybeSentinel.DEFAULT).
  --hide-empty     Hide fields that contain empty values ([], (), '').
  --hide-fmt       Hide formatting-related fields and objects (whitespace,
                   newlines).
  --show-children  Show contents of the 'children' attribute.If no source provided as an argument, then tool will attempt to read it
fromSTDIN.Installation# pip install astboomGetting started with development# git clone https://github.com/lensvol/astboom# poetry installLicenseThis project is licensed under the MIT License - see theLICENSEfile for detailsAuthorsKirill Borisov(lensvol@gmail.com)
Package: astc-codec
ASTC_CodecAn ASTC decoder for PIL.The decoder usesGoogle/astc-codecto decompress the data.InstallationCython requiredPIPpip install astc_codecManualpython setup.py installUsagevalid block_sizesblock sizefootprintfootprint id(4, 4)k4x40(5, 4)k5x41(5, 5)k5x52(6, 5)k6x53(6, 6)k6x64(8, 5)k8x55(8, 6)k8x66(10, 5)k10x57(10, 6)k10x68(8, 8)k8x89(10, 8)k10x810(10, 10)k10x1011(12, 10)k12x1012(12, 12)k12x1213PIL.Image decoderfromPILimportImageimportastc_codec#needs to be imported once in the active code, so that the codec can register itselfraw_astc_image_data:bytesblock_size=(int,int)# see valid block_sizesimg=Image.frombytes('RGBA',size,raw_astc_image_data,'astc',block_size)raw decoderfromastc_codecimportdecompress_astc,ASTCDecompressToRGBA# ASTC to RGBArgba_data=decompress_astc(astc_data:bytes,block_size:(int,int),width:int,height:int)# ASTC to RGBA, direct mapping to the C++ function# footprint = footprint id from valid block_sizesrgba_data=ASTCDecompressToRGBA(astc_data:bytes,astc_data_size:int,width:int,height:int,footprint:int,out_buffer_size:int,out_buffer_stride:int)
Package: astc-decomp
ASTC_DecompAn ASTC decoder for PIL.The decoder usesrichgel999/astc_decto decompress the ASTC blocks.InstallationCython requiredPIPpip install astc_decompManualpython setup.py installUsageArgumentsblock_width: - Block width, in pixels.block_height: - Block height, in pixels.is_srgb: - If isSRGB is true, the spec requires the decoder to scale the LDR 8-bit endpoints to 16-bit before interpolation slightly differently, which will lead to different outputs. So be sure to set it correctly (ideally it should match whatever the encoder did).
(optional arg, default : False)PIL.Image decoderfromPILimportImageimportastc_decomp#needs to be imported once in the active code, so that the codec can register itselfastc_data:bytesblock_width:intblock_height:intis_srgb:bool=Falseimg=Image.frombytes('RGBA',size,astc_data,'astc',(block_width,block_height,is_srgb))raw decoderfromastc_decompimportdecompress_astc# ASTC to RGBArgba_data=decompress_astc(astc_data:bytes,width:int,height:int,block_width:int,block_height:int,is_srgb:bool=False)
Package: astc-decomp-faster
bconstanzo:this is a fork of K0lb3's work focused on improving performance by adding some Cython magic (types, which took a bit of effort to get right). Since it completely removes python from the hot loop (and almost all of the decompression function) it achieves some nice speedups (6-8 times faster). Any bottlenecks would then be inside the C++ functions, or your compilers ability to optimize said code.The main reason I'm making this fork is that iLEAPP had the astc_decomp module as a bottleneck at the time of release, and I worked a couple of weeks into improving it. There may be better alternatives for ASTC decompression out there.K0lb3's original readme follows:ASTC_DecompAn ASTC decoder for PIL.The decoder usesrichgel999/astc_decto decompress the ASTC blocks.InstallationCython requiredPIPpip install astc_decompManualpython setup.py installUsageArgumentsblock_width: - Block width, in pixels.block_height: - Block height, in pixels.is_srgb: - If isSRGB is true, the spec requires the decoder to scale the LDR 8-bit endpoints to 16-bit before interpolation slightly differently, which will lead to different outputs. So be sure to set it correctly (ideally it should match whatever the encoder did).
(optional arg, default : False)PIL.Image decoderfromPILimportImageimportastc_decomp#needs to be imported once in the active code, so that the codec can register itselfastc_data:bytesblock_width:intblock_height:intis_srgb:bool=Falseimg=Image.frombytes('RGBA',size,astc_data,'astc',(block_width,block_height,is_srgb))raw decoderfromastc_decompimportdecompress_astc# ASTC to RGBArgba_data=decompress_astc(astc_data:bytes,width:int,height:int,block_width:int,block_height:int,is_srgb:bool=False)
Package: astcheck
astcheck compares Python Abstract Syntax Trees against a template. This is
useful for testing software that automatically generates or modifies Python code.Installation:pip install astcheckExample use:importast,astchecktemplate=ast.Module(body=[ast.FunctionDef(name='double',args=ast.arguments(args=[ast.arg(arg='a')])),ast.Assign(value=ast.Call(func=ast.Name(id='double')))])sample="""
def double(a):
    do_things()
    return a*2
b = double(a)
"""astcheck.assert_ast_like(ast.parse(sample),template)Only the parts specified in the template are checked. In this example, the code
inside the function, and the assignment target (b) could be anything.For more details, seethe documentation.
Package: ast-comments
ast-commentsAn extension to the built-inastmodule.
Finds comments in source code and adds them to the parsed tree.Installationpip install ast-commentsUsageThere is no difference in usage betweenastandast-comments>>> from ast_comments import *
>>> tree = parse("hello = 'hello' # comment to hello")Parsed tree is an instance of the originalast.Moduleobject.
The only difference is that there is a new type of tree node:Comment>>> tree
<_ast.Module object at 0x7ffba52322e0>
>>> tree.body
[<ast.Assign object at 0x10a01d5b0>, <ast_comments.Comment object at 0x10a09e0a0>]
>>> tree.body[1].value
'# comment to hello'
>>> dump(tree)
"Module(body=[Assign(targets=[Name(id='hello', ctx=Store())], value=Constant(value='hello')), Comment(value='# comment to hello', inline=True)], type_ignores=[])"If you have python3.9 or above it's also possible to unparse the tree object with its comments preserved.>>> print(unparse(tree))
hello = 'hello'  # comment to helloNote: Pythoncompile()cannot be run on the tree output from parse. The includedpre_compile_fixer()function can be used to fix the tree (stripping
comment nodes) if it will be necessary to compile the output.More examples can be found in test_parse.py and test_unparse.py.ContributingYou are welcome to open an issue or create a pull request
Package: ast-compat
AST-Compatbackward compatibility library for Python standard libraryast.What is AST-Compat for?backward compatibility for constructing ASTsFor instance,ast.argumentsis changed since Python 3.8, that another fieldposonlyargis introduced,
hence you should construct anast.argumentswith an additional argumentposonlyarg=...since Python 3.8
and it wouldn't work if your code is written before Python 3.8.Throughast_compat, you don't have to worry about above question if a new argument isoptional or a list.Note that you should useast_compat.XXXinstead ofast.XXXto construct ASTs.Supportast.Constantbefore Python 3.6.ast.Constantis convenient, and things likeast.Numare redundant according to this observation and improvement:https://bugs.python.org/issue32892However,ast.Constantis not available in 3.5 or earlier versions, thus we backportast.Constantin this library.To access the content ofast.Constantin a compatible way, useast_compat.get_constantinstead of.value.Support dumping AST to string withast_compat.unparse, which synchronizes the tooling code provided by CPython official repo.Usageimportast_compatasastcfromast_compatimportget_constantassertget_constant(astc.Constant((1,2)))==(1,2)empty_args=astc.arguments()# work for all of Python 3.5-3.11Implementation, and rebuildThe compatibility is following the specification of Python ASTs, i.e,
the ADSL file you can find athttps://github.com/python/cpython/blob/<branch/tag>/Parser/Python.asdl.We parse the file, and generate verifications and default argument factories,
checkast_compat/compat3k*_{ast|unparse}.py. To explain,ast_compat/compat3k5_*.pyis for
Python 3.5, andast_compat/compat3k9_*.pyis for Python 3.9.The file of generator isgenerate_ast_compat.py, and the use of generator API is in this way:fromgenerate_ast_compatimportcompatcompat((3,5))# generate ast_compat/compat3k5_ast.py and  ast_compat/compat3k5_unparse.pycompat((3,6))compat((3,7))compat((3,8))prerelease_url="https://raw.githubusercontent.com/python/cpython/v3.9.0a3/parser/python.asdl"compat((3,9),prerelease_url)The code generation needs Python 3.7+, though this library works for Python 3.5 and 3.5+.