Advertisement · 728 × 90
#
Hashtag
#pyparsing
Advertisement · 728 × 90
Snippet of AI instructions, available by calling `pyparsing.show_best_practices()` from Python

Snippet of AI instructions, available by calling `pyparsing.show_best_practices()` from Python

Example showing DeprecationWarning raised when calling pyparsing `parseString` instead of `parse_string`

Example showing DeprecationWarning raised when calling pyparsing `parseString` instead of `parse_string`

TINY code example of a leap year determination function.

Complete code:
int is_divisible(int a, int b) {
    float quo := a / b;
    int iquo := quo;
    return quo = iquo;
}

int is_leap_year(int yr) {
    int div_by_400 := is_divisible(yr, 400);
    if div_by_400 then return 1; end

    int div_by_100 := is_divisible(yr, 100);
    if div_by_100 then return 0; end

    int div_by_4 := is_divisible(yr, 4);
    return div_by_4;
}

int main() {
    string s;
    int year;
    int this_year;

    read this_year;
    repeat
        read yr;
        if yr = "q" then return 0; end
        year := yr;
        is_leap := is_leap_year(year);

        write year; write " ";
        if is_leap then
            if year > this_year then
                write "will be";
            elseif year < this_year then
                write "was";
            else
                write "is";
            end
        else
            if year > this_year then
                write "will not be";
            elseif year < this_year then
                write "was not";
            else
                write "is not";
            end
        end
        write " a leap year"; write endl;
    until 0
}

TINY code example of a leap year determination function. Complete code: int is_divisible(int a, int b) { float quo := a / b; int iquo := quo; return quo = iquo; } int is_leap_year(int yr) { int div_by_400 := is_divisible(yr, 400); if div_by_400 then return 1; end int div_by_100 := is_divisible(yr, 100); if div_by_100 then return 0; end int div_by_4 := is_divisible(yr, 4); return div_by_4; } int main() { string s; int year; int this_year; read this_year; repeat read yr; if yr = "q" then return 0; end year := yr; is_leap := is_leap_year(year); write year; write " "; if is_leap then if year > this_year then write "will be"; elseif year < this_year then write "was"; else write "is"; end else if year > this_year then write "will not be"; elseif year < this_year then write "was not"; else write "is not"; end end write " a leap year"; write endl; until 0 }

This past weekend I pushed version 3.3.1 of pyparsing to PyPI (3.3.0 had a small but CI-stopping packaging blip). Includes AI instructions of pyparsing best practices. Deprecated camelCase names now throw DeprecatedWarnings. TINY teaching language parser+REPL
#PythonDevelopment #python #pyparsing

0 0 0 0
Preview
Release Pyparsing 3.3.0b1 · pyparsing/pyparsing (added in 3.3.0b1) Implemented a TINY language parser/interpreter using pyparsing, in the examples/tiny directory. This is a little tutorial language that I used to demonstrate how to use pyparsi...

I just published pyparsing version 3.3.0b1, with some significant additions:
- example implementation of the TINY language
- performance tests with scripts to run and tabulate results using pyparsing 3.1-3.3 and Python 3.9-3.14

Github link: github.com/pyparsing/py...

#pyparsing #python #parsing

1 0 1 0

With the upcoming release of #pyparsing 3.3.0, this code would emit DeprecationWarnings: nestedExpr is deprecated in favor of nested_expr, and parseString in favor of parse_string. A conversion utility ships with pyparsing to auto-update all of these pre-PEP8 names to PEP-8 compliant snake case.

1 0 0 0
Snippet extracted from the AI instructions that will be bundled with the upcoming 3.3.0 release of pyparsing:

$ python -m pyparsing.ai.show_best_practices
<!-- 
This file contains instructions for best practices for developing parsers with pyparsing, and can be used by AI agents
when generating Python code using pyparsing.
-->

## Planning
- If not provided or if target language definition is ambiguous, ask for examples of valid strings to be parsed
- Before developing the pyparsing expressions, define a Backus-Naur Form definition and save this in docs/grammar.md. Update this document as changes are made in the parser.

## Implementing
- Import pyparsing using "import pyparsing as pp", and use that for all pyparsing references.
- When writing parsers that contain recursive elements (using Forward() or infix_notation()), immediately enable packrat parsing for performance: `pp.ParserElement.enable_packrat()` (call this right after importing pyparsing). See https://pyparsing-docs.readthedocs.io/en/latest/HowToUsePyparsing.html.
  - For recursive grammars, define placeholders with `pp.Forward()` and assign later using the `<<=` operator; give Forwards meaningful names with `set_name()` to improve errors.
- Use PEP8 method and argument names in the pyparsing API ("parse_string", not "parseString").
- Do not include expressions for matching whitespace in the grammar. Pyparsing skips whitespace by default.
...

Snippet extracted from the AI instructions that will be bundled with the upcoming 3.3.0 release of pyparsing: $ python -m pyparsing.ai.show_best_practices <!-- This file contains instructions for best practices for developing parsers with pyparsing, and can be used by AI agents when generating Python code using pyparsing. --> ## Planning - If not provided or if target language definition is ambiguous, ask for examples of valid strings to be parsed - Before developing the pyparsing expressions, define a Backus-Naur Form definition and save this in docs/grammar.md. Update this document as changes are made in the parser. ## Implementing - Import pyparsing using "import pyparsing as pp", and use that for all pyparsing references. - When writing parsers that contain recursive elements (using Forward() or infix_notation()), immediately enable packrat parsing for performance: `pp.ParserElement.enable_packrat()` (call this right after importing pyparsing). See https://pyparsing-docs.readthedocs.io/en/latest/HowToUsePyparsing.html. - For recursive grammars, define placeholders with `pp.Forward()` and assign later using the `<<=` operator; give Forwards meaningful names with `set_name()` to improve errors. - Use PEP8 method and argument names in the pyparsing API ("parse_string", not "parseString"). - Do not include expressions for matching whitespace in the grammar. Pyparsing skips whitespace by default. ...

The upcoming 3.3.0 release of pyparsing will include AI instructions for best practices when using this package. They can be accessed from the command-line using `python -m pyparsing.ai.show_best_practices` (They work for human developers too.) #python #pythondev #pyparsing #ai

3 1 1 0
Preview
PyPI · The Python Package Index The Python Package Index (PyPI) is a repository of software for the Python programming language.

#art link: paulmcguireart.com
#python #pyparsing link: pypi.org/project/pypa...
Python #littletable link: pypi.org/project/litt...

1 0 0 0
A digital art abstract image of blues and greens, with a ragged white bottom. The title of this piece is "wave"

A digital art abstract image of blues and greens, with a ragged white bottom. The title of this piece is "wave"

A digital art abstract image, mostly white, but with a field of pale colors in the lower left corner, with a ragged diagonal border running from upper left to lower right. In the middle of this border is an irregular clump of color, as if it were a stain from multiple colors of ink, washed over the side of a snowy ridge. The title of this piece is "water music II".

A digital art abstract image, mostly white, but with a field of pale colors in the lower left corner, with a ragged diagonal border running from upper left to lower right. In the middle of this border is an irregular clump of color, as if it were a stain from multiple colors of ink, washed over the side of a snowy ridge. The title of this piece is "water music II".

Greetings, BlueSky-ers! I'm new here so I wanted to do a quick introduction. My name is Paul McGuire, I've been using Python for about 24 years. I maintain the #pyparsing package, which is about to have its release 3.3.0 next month. I also make digital art. #PythonDev #Python #Introduction

5 0 2 0