--- id: python-class-self-parameter title: "Python Class Self Parameter" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["self parameter", "파이썬 self"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["python", "programming", "w3schools", "self"] raw_sources: ["https://www.w3schools.com/python/python_class_self.asp"] applied_in: [] github_commit: "" --- # [[Python Class Self Parameter]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `self` isn't a reserved keyword β€” it can legally be renamed to anything β€” but it must always be the first parameter of every method, and renaming it away from the "self" convention actively hurts readability for other developers. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`self`** β€” a reference to the current instance of the class; used to access its properties/methods. [S1] - **Must be first parameter** β€” every method in a class needs it as the first parameter. [S1] - **Not a reserved word** β€” can be renamed (e.g. `myobject`, `abc`), but convention strongly favors keeping `self`. [S1] - **Distinguishes instances** β€” without self, Python couldn't tell which object's properties a method should operate on. [S1] - **Calling one method from another** β€” `self.greet()` inside another method of the same class. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Two different objects, same method, different data** β€” `p1.printname()` and `p2.printname()` both call the same method definition, but `self` resolves to a different object each time, producing different output. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Basic self usage: `class Person: def __init__(self, name, age): self.name = name; self.age = age; def greet(self): print("Hello, my name is " + self.name)`. [S1] - Renamed (legal but discouraged): `def __init__(myobject, name, age): myobject.name = name`. [S1] - Calling another method via self: `def welcome(self): message = self.greet(); print(message + "!")`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. "self"λΌλŠ” 이름 μžμ²΄λŠ” 관둀일 뿐 κ°•μ œλ˜μ§€ μ•ŠλŠ”λ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 언급됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 클래슀 λ©”μ„œλ“œ μ „μ²΄μ—μ„œ 반볡적으둜 μ‚¬μš©λ˜λŠ” ν•„μˆ˜ 첫 λ§€κ°œλ³€μˆ˜λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Calling one method from another via self (Python): ```python class Person: def __init__(self, name): self.name = name def greet(self): return "Hello, " + self.name def welcome(self): message = self.greet() print(message + "! Welcome to our website.") ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[Python Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[Python Class Init Method]], [[Python Class Properties]], [[Python Class Methods]] - **μ°Έμ‘° λ§₯락:** λͺ¨λ“  클래슀 λ©”μ„œλ“œμ˜ 첫 λ§€κ°œλ³€μˆ˜ κ΄€λ‘€ β€” μΈμŠ€ν„΄μŠ€λ³„ 데이터 μ ‘κ·Όμ˜ 핡심. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” Python self Parameter β€” https://www.w3schools.com/python/python_class_self.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "Python self Parameter" page (Astra wiki-curation, P-Reinforce v3.1 format).