GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Default values for AST Nodes · Issue #84162 · python/cpython

Default values for AST Nodes #84162

New issue
Copy link
New issue
Copy link
Closed
Closed
Default values for AST Nodes#84162
Copy link
Labels
3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@isidentical
isidentical
opened on Mar 16, 2020
Issue body actions
BPO 39981
Nosy @benjaminp, @serhiy-storchaka, @pablogsal, @isidentical
PRs
  • bpo-39981: Default values for AST nodes #19031
  • bpo-39981: Introduce default values for AST node classes #21417
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-03-16.19:17:20.926>
    labels = ['type-feature', 'library', '3.9']
    title = 'Default values for AST Nodes'
    updated_at = <Date 2020-07-09.13:33:40.873>
    user = 'https://github.com/isidentical'

    bugs.python.org fields:

    activity = <Date 2020-07-09.13:33:40.873>
    actor = 'BTaskaya'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-03-16.19:17:20.926>
    creator = 'BTaskaya'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39981
    keywords = ['patch']
    message_count = 1.0
    messages = ['364355']
    nosy_count = 4.0
    nosy_names = ['benjamin.peterson', 'serhiy.storchaka', 'pablogsal', 'BTaskaya']
    pr_nums = ['19031', '21417']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue39981'
    versions = ['Python 3.9']

    Activity

    1. isidentical commented on Mar 16, 2020

      @isidentical
      isidentical
      on Mar 16, 2020
      SponsorMemberAuthor
      More actions
      For omitting some defaults, @serhiy.storchaka already added support to initialize some ast nodes with some default values (optional fields). An example;
      >>> ast.Constant().kind is None
      True
      
      This isn't exactly a default value, but some kind of class attribute. I think we can push this one step further and initialize all kinds of default values (both optionals and sequences). An example;
      >>> func = ast.FunctionDef("easy_func", ast.arguments(), body=[ast.Pass()])
      >>> func = ast.fix_missing_locations(func)
      >>> exec(compile(ast.Module(body=[func]), "<stdin>", "exec"))
      >>> easy_func()
      
      compared to this (other way around, compiler gives errors so does most of the ast based tool, including ast.unparser)
      >>> func = ast.FunctionDef("easy_func", ast.arguments(posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[]), decorator_list=[], body=[ast.Pass()])
      >>> func = ast.fix_missing_locations(func)
      >>> exec(compile(ast.Module(body=[func], type_ignores=[]), "<stdin>", "exec"))
      >>> easy_func()
    2. isidentical
      added
      3.9 (EOL)end of lifeend of life
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancementA feature request or enhancement
      on Mar 16, 2020
    3. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    4. JelleZijlstra commented on May 19, 2024

      @JelleZijlstra
      JelleZijlstra
      on May 19, 2024
      Member
      More actions

      This was implemented in #105858.

    5. JelleZijlstra
      closed this as completedon May 19, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.