AI Skill Report Card
Using Python Built In Constants
Quick Start13 / 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.
Workflow11 / 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
-
True/False- Instances of
int(subclassbool);True == 1,False == 0. - Never reassign — reserved keywords since Python 3.
- Instances of
-
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.
- The sole instance of
-
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 raiseTypeError. - Do NOT use in a boolean context (
if x == NotImplementedis wrong — deprecated/warns); usex is NotImplemented. - Distinct from
NotImplementedError(an exception, used in abstract methods).
- Returned (not raised) from binary special methods (
-
Ellipsis(...)- Singleton, usable as literal
.... - Common uses: NumPy/array slicing, type hint stubs (
.pyifiles), placeholder body for unimplemented functions,typing.Callable[..., ReturnType].
- Singleton, usable as literal
-
__debug__Trueunder normal execution,Falsewhen Python started with-O/-OO.- Read-only; assigning to it is a
SyntaxError. assertstatements are compiled out entirely when__debug__isFalse— don't rely onassertfor 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.
Examples12 / 20
Example 1: Input: "Bagaimana cara mengecek apakah variabel kosong di Python?" Output:
Pythonvalue = 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:
Pythonclass 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:
Pythondef 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.
Best Practices
- Gunakan
is/is notuntukNone,NotImplemented,Ellipsis— ini adalah singleton by identity, bukan value. - Jangan gunakan
assertuntuk validasi input produksi (bisa hilang dengan-O); gunakanraise ValueError(...)eksplisit. - Saat overload operator, selalu
return NotImplemented(bukanraise) 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.
Common Pitfalls
- Menulis
if x == Noneatauif x == NotImplemented— gunakanis. - Meng-raise
NotImplementedseolah exception — itu bukan exception, gunakanNotImplementedErroruntuk abstract method yang belum diimplementasikan. - Bergantung pada
assertuntuk logic penting yang harus selalu jalan di production. - Mencoba assign ke
__debug__,True,False, atauNone— akan menghasilkanSyntaxError. - Lupa memverifikasi bahwa dokumentasi versi 3.16 masih development/unstable — selalu cross-check dengan changelog resmi sebelum mengunci skill ke versi tersebut.