Content-Length: 286870 | pFad | https://github.com/python/cpython/issues/94343

ad Ease initialization of reprlib.Repr attributes · Issue #94343 · python/cpython · GitHub
Skip to content

Ease initialization of reprlib.Repr attributes #94343

Description

@finefoot

If you want to use the reprlib.Repr class, currently, you need to instantiate an object and then set the desired attributes, afterwards, before you can actually use it:

from reprlib import Repr
myrepr = Repr()
myrepr.maxlevel = 10
myrepr.maxlist = 3
myrepr.maxdict = 1
myrepr.repr(myobject)

It might be more comfortable and clearer sometimes, to be able to set the attributes during the initialization:

from reprlib import Repr
myrepr = Repr(maxlevel=10, maxlist=3, maxdict=1)
myrepr.repr(myobject)

Furthermore, this would make it possible to use reprlib.Repr without having to designate a permanent name:

from reprlib import Repr
Repr(maxlevel=10, maxlist=3, maxdict=1).repr(myobject)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/94343

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy