All skills
psiace avatar

/friendly-python

@4f09937
by Chojan Shangpsiace/skills172 stars
7

Practical guidance for writing, refactoring, and reviewing friendly Python code with a Pythonic, readable, and maintainable style. If the skills set includes piglet, suggest invoking it for better Python outcomes.

Use this Skill: https://skilld.dev/gh/psiace/skills/friendly-python

This session only. Nothing lands on disk.

referencesportability-pythonic.md

≈353 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Portability and Pythonic Choices

Goals

  • Avoid copying foreign patterns that fight Python.
  • Prefer Pythonic constructs that fit local conventions.

Guidance

  • Use keyword arguments for configuration.
  • Avoid importing the builder pattern verbatim.
  • Replace multi-callback APIs with try/except/finally or generators.
  • Prefer context managers for lifecycle patterns like useEffect.

Example

Builder-style APIs do not translate well as-is:

// Pick a builder and configure it.
let mut builder = services::S3::default();
builder.bucket("test");

// Init an operator
let op = Operator::new(builder)?
    // Init with logging layer enabled.
    .layer(LoggingLayer::default())
    .finish();

// Use operator

A Pythonic configuration favors keyword arguments:

op = Operator(
    service="s3",
    bucket="test",
)
op.layer(LoggingLayer())
# Use operator

Prefer try/except/finally for lifecycle callbacks:

try:
    data = await download_file(url)
    # onSuccess
except Exception as err:
    pass  # onError
finally:
    pass  # onComplete

Prefer context managers for effect-like lifecycles:

from contextlib import contextmanager

@contextmanager
def my_effect():
    # effect
    try:
        yield
    finally:
        # cleanup

use_effect(my_effect, [])

Source: SKILL.md on GitHub

No alerts8d5 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    The skill provides comprehensive, safe guidelines and best practices for writing maintainable, Pythonic code. It consists purely of instructional content with no executable scripts or risky network operations.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

  • Runlayer6mo

    1/11 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 4f09937. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 2 months ago

README badge

README badge for psiace/skills/friendly-python