AI Skill Report Card

Using Python Built In Constants

B68·Aug 12, 2026·Source: Web
13 / 15
Python
# Boolean constants — subclass of int, True == 1, False == 0 is_active = True count = int(True) + int(False) # 1 # None — the singleton "no value" sentinel def find_user(id): return None # use `is None` / `is not None`, never `== None` result = find_user(1) if result is None: print("not found") # NotImplemented — return from rich comparison / arithmetic dunder methods class Vector: def __eq__(self, other): if not isinstance(other, Vector): return NotImplemented return self.x == other.x and self.y == other.y # Ellipsis (...) — placeholder in slices, stubs, unfinished code def stub_function() -> int: ... matrix[..., 0] # advanced slicing # __debug__ — True unless Python run with -O if __debug__: assert isinstance(count, int)
Recommendation
Language inconsistency: examples and best practices switch to Indonesian while the rest of the skill is in English — pick one language for consistency and clarity across all users.
11 / 15

Progress:

  • Identify which built-in constant fits the situation (boolean, sentinel, fallback, placeholder, debug flag)
  • Apply correct comparison/usage idiom (is, not ==, for singletons)
  • Verify no accidental reassignment or shadowing of constant names
  • Test behavior under normal and optimized (-O) execution if __debug__ is involved
  • Apply the pattern into your target AI model/agent prompts or codebase

Detail per constant

  1. True / False

    • Instances of int (subclass bool); True == 1, False == 0.
    • Never reassign — reserved keywords since Python 3.
  2. None

    • The sole instance of NoneType. Represents absence of value.
    • Always compare with is None / is not None.
    • Default return value of functions with no explicit return.
  3. NotImplemented

    • Returned (not raised) from binary special methods (__eq__, __lt__, __add__, etc.) when the operation is unsupported for given operand types, letting Python try the reflected method or raise TypeError.
    • Do NOT use in a boolean context (if x == NotImplemented is wrong — deprecated/warns); use x is NotImplemented.
    • Distinct from NotImplementedError (an exception, used in abstract methods).
  4. Ellipsis (...)

    • Singleton, usable as literal ....
    • Common uses: NumPy/array slicing, type hint stubs (.pyi files), placeholder body for unimplemented functions, typing.Callable[..., ReturnType].
  5. __debug__

    • True under normal execution, False when Python started with -O/-OO.
    • Read-only; assigning to it is a SyntaxError.
    • assert statements are compiled out entirely when __debug__ is False — don't rely on assert for required runtime validation (e.g., input sanitization).
Recommendation
Examples are phrased as translated Q&A prompts rather than concrete input/output code pairs typical of a skill; make them more like direct code scenarios (e.g., 'buggy code -> fixed code') for stronger before/after contrast.
12 / 20

Example 1: Input: "Bagaimana cara mengecek apakah variabel kosong di Python?" Output:

Python
value = None if value is None: print("Variabel kosong")

Explanation: gunakan is None, bukan == None, karena None adalah singleton.

Example 2: Input: "Buat class custom yang bisa dibandingkan dengan == tapi aman terhadap tipe lain." Output:

Python
class Money: def __init__(self, amount): self.amount = amount def __eq__(self, other): if not isinstance(other, Money): return NotImplemented return self.amount == other.amount

Example 3: Input: "Tulis stub function untuk API yang belum diimplementasi." Output:

Python
def process_payment(order_id: str) -> bool: ...

Example 4: Input: "Kapan assert tidak akan jalan?" Output: Ketika script dijalankan dengan python -O script.py, karena __debug__ menjadi False dan semua statement assert dihilangkan saat compile.

Recommendation
The workflow checklist item 'Apply the pattern into your target AI model/agent prompts or codebase' is vague and out of place — remove or clarify since this skill is about Python semantics, not prompt engineering.
  • Gunakan is/is not untuk None, NotImplemented, Ellipsis — ini adalah singleton by identity, bukan value.
  • Jangan gunakan assert untuk validasi input produksi (bisa hilang dengan -O); gunakan raise ValueError(...) eksplisit.
  • Saat overload operator, selalu return NotImplemented (bukan raise) agar Python bisa fallback ke reflected method operand lain.
  • Simpan hasil riset dokumentasi resmi (docs.python.org) sebagai referensi utama sebelum menerapkan ke prompt AI Agent — pastikan versi Python yang ditarget sesuai (di sini 3.16, masih pre-release/dev docs, cek ulang saat versi stabil rilis).
  • Saat menerapkan skill ke berbagai platform AI (multi-platform workflow), uji konsistensi output pada tiap platform sebelum finalisasi.
  • Menulis if x == None atau if x == NotImplemented — gunakan is.
  • Meng-raise NotImplemented seolah exception — itu bukan exception, gunakan NotImplementedError untuk abstract method yang belum diimplementasikan.
  • Bergantung pada assert untuk logic penting yang harus selalu jalan di production.
  • Mencoba assign ke __debug__, True, False, atau None — akan menghasilkan SyntaxError.
  • Lupa memverifikasi bahwa dokumentasi versi 3.16 masih development/unstable — selalu cross-check dengan changelog resmi sebelum mengunci skill ke versi tersebut.
0
Grade BAI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
13/15
Workflow
11/15
Examples
12/20
Completeness
16/20
Format
14/15
Conciseness
12/15