docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
---
|
||||
id: python-tutorial-index
|
||||
title: "Python Tutorial"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Tutorial", "Python MOC", "Topic_Python index", "Python 목차"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.90
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "moc", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/python/"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Tutorial]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Map of Content (MOC) for the W3Schools Python Tutorial — the root that links every core-Python-language knowledge page in this topic folder. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- This folder (`Topic_Python`) wikifies the **core Python language** portion of the W3Schools Python Tutorial sidebar, one knowledge page per document, in P-Reinforce v3.1 format — same convention as `Topic_SQL` / `Topic_HTML` / `Topic_CSS` / `Topic_JavaScript`. [S1]
|
||||
- Scope: **tutorial + "Learning by examples" pages only**, restricted to pure Python language content. Explicitly **excluded**: reference dumps (`python_ref_*`: Built-in Functions/String/List/Dict/Tuple/Set/File Methods, Keywords, Exceptions, Glossary), How-To recipes (`python_howto_*` — belongs to the separate "HOW TO" category), per-chapter Exercise pages (`*_exercises.asp` — pure quiz links, no content), meta pages (Quiz/Compiler/Certificate/Bootcamp/Syllabus/Study Plan/Training/Interview Q&A/Server), 8 dead/404 legacy URLs, and content that belongs to **other already-planned top-level categories**: NumPy (`numpy_*`), Pandas (`pandas_*`), Matplotlib (`matplotlib_*`), SciPy (`scipy_*`), Python ML (`python_ml_*` → Machine Learning/AI), Python DSA (`python_dsa_*`/`python_dsa.asp` → DSA), and standalone Modules reference (`module_*`). [S1]
|
||||
- **Included as Python-specific** (no separate top-level category exists for these): `python_mysql_*` (Python+MySQL driver usage) and `python_mongodb_*` (Python+MongoDB driver usage). [S1]
|
||||
- **Progress:** **136 of 136 planned docs complete — Python category done.**
|
||||
- Every page roots its Knowledge Graph back to this `[[Python Tutorial]]` node.
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
|
||||
### Basics
|
||||
- [[Python Intro]] ✅
|
||||
- [[Python Syntax]] ✅
|
||||
- [[Python Statements]] ✅
|
||||
- [[Python Output]] ✅
|
||||
- [[Python Print Numbers]] ✅
|
||||
- [[Python Comments]] ✅
|
||||
|
||||
### Variables
|
||||
- [[Python Variables]] ✅
|
||||
- [[Python Variable Names]] ✅
|
||||
- [[Python Assign Multiple Values]] ✅
|
||||
- [[Python Output Variables]] ✅
|
||||
- [[Python Global Variables]] ✅
|
||||
|
||||
### Data Types
|
||||
- [[Python Data Types]] ✅
|
||||
- [[Python Bytes]] ✅
|
||||
- [[Python Bytearray]] ✅
|
||||
- [[Python Memoryview]] ✅
|
||||
- [[Python Numbers]] ✅
|
||||
- [[Python Casting]] ✅
|
||||
|
||||
### Strings
|
||||
- [[Python Strings]] ✅
|
||||
- [[Python Strings Slicing]] ✅
|
||||
- [[Python Strings Modify]] ✅
|
||||
- [[Python Strings Concatenate]] ✅
|
||||
- [[Python Strings Format]] ✅
|
||||
- [[Python Strings Escape]] ✅
|
||||
- [[Python Strings Methods]] ✅
|
||||
|
||||
### Booleans & Operators
|
||||
- [[Python Booleans]] ✅
|
||||
- [[Python Operators]] ✅
|
||||
- [[Python Operators Arithmetic]] ✅
|
||||
- [[Python Operators Assign]] ✅
|
||||
- [[Python Ternary Operator]] ✅
|
||||
- [[Python Operators Comparison]] ✅
|
||||
- [[Python Operators Logical]] ✅
|
||||
- [[Python Operators Identity]] ✅
|
||||
- [[Python Operators Membership]] ✅
|
||||
- [[Python Operators Bitwise]] ✅
|
||||
- [[Python Operators Precedence]] ✅
|
||||
|
||||
### Lists
|
||||
- [[Python Lists]] ✅
|
||||
- [[Python Lists Access]] ✅
|
||||
- [[Python Lists Change]] ✅
|
||||
- [[Python Lists Add]] ✅
|
||||
- [[Python Lists Remove]] ✅
|
||||
- [[Python Lists Loop]] ✅
|
||||
- [[Python Lists Comprehension]] ✅
|
||||
- [[Python Lists Sort]] ✅
|
||||
- [[Python Lists Copy]] ✅
|
||||
- [[Python Lists Join]] ✅
|
||||
- [[Python Lists Methods]] ✅
|
||||
|
||||
### Tuples
|
||||
- [[Python Tuples]] ✅
|
||||
- [[Python Tuples Access]] ✅
|
||||
- [[Python Tuples Update]] ✅
|
||||
- [[Python Tuples Unpack]] ✅
|
||||
- [[Python Tuples Loop]] ✅
|
||||
- [[Python Tuples Join]] ✅
|
||||
- [[Python Tuples Methods]] ✅
|
||||
|
||||
### Sets
|
||||
- [[Python Sets]] ✅
|
||||
- [[Python Sets Access]] ✅
|
||||
- [[Python Sets Add]] ✅
|
||||
- [[Python Sets Remove]] ✅
|
||||
- [[Python Sets Loop]] ✅
|
||||
- [[Python Sets Join]] ✅
|
||||
- [[Python Frozenset]] ✅
|
||||
- [[Python Sets Methods]] ✅
|
||||
|
||||
### Dictionaries
|
||||
- [[Python Dictionaries]] ✅
|
||||
- [[Python Dictionaries Access]] ✅
|
||||
- [[Python Dictionaries Change]] ✅
|
||||
- [[Python Dictionaries Add]] ✅
|
||||
- [[Python Dictionaries Remove]] ✅
|
||||
- [[Python Dictionaries Loop]] ✅
|
||||
- [[Python Dictionaries Copy]] ✅
|
||||
- [[Python Dictionaries Nested]] ✅
|
||||
- [[Python Dictionaries Methods]] ✅
|
||||
|
||||
### Conditions & Control Flow
|
||||
- [[Python If Statement]] ✅
|
||||
- [[Python Elif]] ✅
|
||||
- [[Python Else]] ✅
|
||||
- [[Python If Shorthand]] ✅
|
||||
- [[Python Operators Logical]] ✅ (merged duplicate chapter python_if_logical.asp here instead of a separate file)
|
||||
- [[Python Nested If]] ✅
|
||||
- [[Python Pass Statement]] ✅
|
||||
- [[Python Match]] ✅
|
||||
- [[Python While Loops]] ✅
|
||||
- [[Python For Loops]] ✅
|
||||
- ~~Python Data Processing~~ (dead 404 link, removed from scope)
|
||||
|
||||
### Functions
|
||||
- [[Python Functions]] ✅
|
||||
- [[Python Arguments]] ✅
|
||||
- [[Python Args Kwargs]] ✅
|
||||
- [[Python Scope]] ✅
|
||||
- [[Python Decorators]] ✅
|
||||
- [[Python Lambda]] ✅
|
||||
- [[Python Recursion]] ✅
|
||||
- [[Python Generators]] ✅
|
||||
|
||||
### Iteration & Utility
|
||||
- [[Python Range]] ✅
|
||||
- [[Python Arrays]] ✅
|
||||
- [[Python Iterators]] ✅
|
||||
- [[Python Modules]] ✅
|
||||
- [[Python Dates]] ✅
|
||||
- [[Python Math]] ✅
|
||||
- [[Python JSON]] ✅
|
||||
- [[Python RegEx]] ✅
|
||||
- [[Python PIP]] ✅
|
||||
- [[Python Try Except]] ✅
|
||||
- [[Python String Formatting]] ✅
|
||||
- [[Python None]] ✅
|
||||
- [[Python User Input]] ✅
|
||||
- [[Python VirtualEnv]] ✅
|
||||
|
||||
### OOP
|
||||
- [[Python OOP]] ✅
|
||||
- [[Python Classes]] ✅
|
||||
- [[Python Class Init Method]] ✅
|
||||
- [[Python Class Self Parameter]] ✅
|
||||
- [[Python Class Properties]] ✅
|
||||
- [[Python Class Methods]] ✅
|
||||
- [[Python Inheritance]] ✅
|
||||
- [[Python Polymorphism]] ✅
|
||||
- [[Python Encapsulation]] ✅
|
||||
- [[Python Inner Classes]] ✅
|
||||
|
||||
### File Handling
|
||||
- [[Python File Handling]] ✅
|
||||
- [[Python Read Files]] ✅
|
||||
- [[Python Write Create Files]] ✅
|
||||
- [[Python Delete Files]] ✅
|
||||
|
||||
### Python MySQL
|
||||
- [[Python MySQL Create Database]] ✅
|
||||
- [[Python MySQL Create Table]] ✅
|
||||
- [[Python MySQL Insert]] ✅
|
||||
- [[Python MySQL Select]] ✅
|
||||
- [[Python MySQL Where]] ✅
|
||||
- [[Python MySQL Order By]] ✅
|
||||
- [[Python MySQL Delete]] ✅
|
||||
- [[Python MySQL Drop Table]] ✅
|
||||
- [[Python MySQL Update]] ✅
|
||||
- [[Python MySQL Limit]] ✅
|
||||
- [[Python MySQL Join]] ✅
|
||||
|
||||
### Python MongoDB
|
||||
- [[Python MongoDB Create DB]] ✅
|
||||
- [[Python MongoDB Create Collection]] ✅
|
||||
- [[Python MongoDB Insert]] ✅
|
||||
- [[Python MongoDB Find]] ✅
|
||||
- [[Python MongoDB Query]] ✅
|
||||
- [[Python MongoDB Sort]] ✅
|
||||
- [[Python MongoDB Delete]] ✅
|
||||
- [[Python MongoDB Drop Collection]] ✅
|
||||
- [[Python MongoDB Update]] ✅
|
||||
- [[Python MongoDB Limit]] ✅
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
136 knowledge documents generated, all grounded in the corresponding W3Schools pages via the project's Playwright-based extraction pipeline (custom noise-stripped extractor, adapted from Datacollector_MAC's `web_extract.mjs`).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[10_Wiki]]
|
||||
- **관련 개념:** [[Python Intro]], [[Python Functions]], [[Python OOP]], [[SQL Tutorial]], [[Topic_Programming]]
|
||||
- **참조 맥락:** SQL에 이어 W3Schools 지식화 시리즈의 다음 카테고리. NumPy/Pandas/Matplotlib/SciPy/DSA/Machine Learning은 별도 카테고리로 예정됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Tutorial — https://www.w3schools.com/python/
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Created Python Tutorial MOC with scope decisions and full planned page list (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: python-args-kwargs
|
||||
title: "Python Args Kwargs"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["*args", "**kwargs", "arbitrary arguments", "파이썬 가변인자"]
|
||||
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", "functions", "args", "kwargs", "unpacking"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_args_kwargs.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Args Kwargs]]
|
||||
|
||||
# 참고: 원문 제목은 "Python *args and **kwargs"
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`*args` collects any number of positional arguments into a tuple, `**kwargs` collects any number of keyword arguments into a dict, and the same `*`/`**` syntax also works in reverse at the call site to unpack a list/dict back into separate arguments. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`*args`** — a single `*` before a parameter collects unlimited positional arguments into a tuple. [S1]
|
||||
- **`**kwargs`** — double `**` collects unlimited keyword arguments into a dict. [S1]
|
||||
- **Ordering rule** — regular parameters, then `*args`, then `**kwargs`, in that order in the function signature. [S1]
|
||||
- **Unpacking a list with `*`** — `my_function(*numbers)` expands a list into positional arguments at the call site. [S1]
|
||||
- **Unpacking a dict with `**`** — `my_function(**person)` expands a dict into keyword arguments at the call site. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Same symbols, opposite direction** — `*`/`**` in a function DEFINITION collect scattered arguments into one tuple/dict; `*`/`**` in a function CALL do the reverse, expanding a tuple/dict into scattered arguments. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic *args: `def my_function(*kids): print(kids[2]); my_function("Emil","Tobias","Linus")`. [S1]
|
||||
- *args as a tuple: `def my_function(*args): print(type(args)) # <class 'tuple'>`. [S1]
|
||||
- Regular + *args: `def my_function(greeting, *names): for name in names: print(greeting, name)`. [S1]
|
||||
- Basic **kwargs: `def my_function(**kid): print(kid["lname"]); my_function(fname="Tobias", lname="Refsnes")`. [S1]
|
||||
- Regular + **kwargs: `def my_function(username, **details): ...`. [S1]
|
||||
- All three together: `def my_function(title, *args, **kwargs): ...`. [S1]
|
||||
- Unpack a list into positional args: `my_function(*numbers)`. [S1]
|
||||
- Unpack a dict into keyword args: `my_function(**person)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Decorators 챕터에서 `(*args, **kwargs)`가 임의의 함수를 감싸는 범용 wrapper 시그니처로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Collect-vs-unpack duality (Python):
|
||||
```python
|
||||
def my_function(a, b, c):
|
||||
return a + b + c
|
||||
|
||||
def collect(*args):
|
||||
return args # collects into a tuple
|
||||
|
||||
numbers = [1, 2, 3]
|
||||
result = my_function(*numbers) # unpacks list into args
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Arguments]], [[Python Decorators]], [[Python Tuples Unpack]]
|
||||
- **참조 맥락:** 임의 개수 인자 처리의 표준 문법 — Decorators의 범용 wrapper 시그니처로 재사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python *args and **kwargs — https://www.w3schools.com/python/python_args_kwargs.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python *args and **kwargs" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: python-arguments
|
||||
title: "Python Arguments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Function Arguments", "positional-only", "keyword-only", "파이썬 함수 인자"]
|
||||
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", "functions", "arguments", "parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_arguments.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Arguments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python arguments can be positional or keyword-based (order-independent), and the `/` and `*` markers in a parameter list force a parameter to be positional-only or keyword-only respectively, catching call-site misuse at the language level. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Parameter vs. argument** — a parameter is the variable in the function definition; an argument is the actual value passed at the call site. [S1]
|
||||
- **Argument count must match by default** — calling with the wrong number of arguments raises an error. [S1]
|
||||
- **Default parameter values** — `def my_function(name="friend")` — used when the argument is omitted. [S1]
|
||||
- **Keyword arguments** — `my_function(name="Buddy", animal="dog")` — order doesn't matter. [S1]
|
||||
- **Positional arguments** — order matters when no keywords are used. [S1]
|
||||
- **Mixing rule** — positional arguments must come before keyword arguments in a call. [S1]
|
||||
- **Positional-only marker `/`** — `def my_function(name, /):` disallows calling with `name=...`. [S1]
|
||||
- **Keyword-only marker `*`** — `def my_function(*, name):` disallows calling positionally. [S1]
|
||||
- **Combining both** — `def my_function(a, b, /, *, c, d):` — a,b positional-only; c,d keyword-only. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`/` and `*` as call-site contracts** — these markers exist purely to constrain HOW callers may pass arguments, not to change what the function does — a form of API design enforcement. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Default value: `def my_function(name = "friend"): print("Hello", name); my_function()` → "Hello friend". [S1]
|
||||
- Keyword arguments (order-independent): `my_function(name = "Buddy", animal = "dog")`. [S1]
|
||||
- Mixed positional+keyword: `my_function("dog", name = "Buddy", age = 5)` — positional args first. [S1]
|
||||
- Positional-only: `def my_function(name, /): ...` — `my_function(name="Emil")` raises an error. [S1]
|
||||
- Keyword-only: `def my_function(*, name): ...` — `my_function("Emil")` raises an error. [S1]
|
||||
- Combined: `def my_function(a, b, /, *, c, d): return a + b + c + d; my_function(5, 10, c=15, d=20)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 라이브러리 API 설계에서 호출 방식을 강제하고 싶을 때(예: 위치 인자만 허용) `/`, `*` 마커가 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Positional-only and keyword-only combined (Python):
|
||||
```python
|
||||
def my_function(a, b, /, *, c, d):
|
||||
return a + b + c + d
|
||||
|
||||
result = my_function(5, 10, c=15, d=20)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Functions]], [[Python Args Kwargs]]
|
||||
- **참조 맥락:** 함수 호출 방식(위치/키워드)을 제어하는 표준 문법 — *args/**kwargs로 확장된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Function Arguments — https://www.w3schools.com/python/python_arguments.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Function Arguments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: python-arrays
|
||||
title: "Python Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 배열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "arrays", "lists"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_arrays.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has no dedicated array type — "arrays" in Python are just Lists used array-style, and a real fixed-type array requires importing a library like NumPy. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **No native array type** — Python lists serve the array role; true arrays need a library like NumPy. [S1]
|
||||
- **Array (as list)** — holds multiple values under one name, indexed. [S1]
|
||||
- **Access/modify by index** — `cars[0]`, `cars[0] = "Toyota"`. [S1]
|
||||
- **`len()`** — array length is one more than its highest index. [S1]
|
||||
- **Loop with for-in** — same as list iteration. [S1]
|
||||
- **`append()`** — adds an element. [S1]
|
||||
- **`pop(index)` / `remove(value)`** — remove by index or by value (first occurrence only). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **This entire chapter is a list-as-array framing** — every method table row (append/clear/copy/count/extend/index/insert/pop/remove/reverse/sort) is identical to the List Methods chapter — the content doesn't introduce anything new beyond terminology. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create: `cars = ["Ford", "Volvo", "BMW"]`. [S1]
|
||||
- Access: `x = cars[0]`. [S1]
|
||||
- Modify: `cars[0] = "Toyota"`. [S1]
|
||||
- Length: `x = len(cars)`. [S1]
|
||||
- Add: `cars.append("Honda")`. [S1]
|
||||
- Remove by index: `cars.pop(1)`. [S1]
|
||||
- Remove by value: `cars.remove("Volvo")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. "Python에는 배열이 없다"는 점이 문서 시작과 끝에서 반복 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다른 언어에서 넘어온 개발자가 "array"라는 용어로 검색했을 때 List로 안내하는 용어 매핑 문서다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
List used as an array (Python):
|
||||
```python
|
||||
cars = ["Ford", "Volvo", "BMW"]
|
||||
cars.append("Honda")
|
||||
cars.pop(1)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists]], [[Python Lists Methods]]
|
||||
- **참조 맥락:** 다른 언어의 "array" 개념을 Python List로 매핑하는 용어 안내 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Arrays — https://www.w3schools.com/python/python_arrays.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-assign-multiple-values
|
||||
title: "Python Assign Multiple Values"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Unpacking", "Multiple Assignment", "파이썬 다중 할당"]
|
||||
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", "variables", "unpacking"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_variables_multiple.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Assign Multiple Values]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python supports one-line multi-variable assignment three ways — distinct values per variable, one shared value across variables, or unpacking a collection's elements directly into named variables. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Many values to multiple variables** — `x, y, z = "Orange", "Banana", "Cherry"`; the count of variables must match the count of values. [S1]
|
||||
- **One value to multiple variables** — `x = y = z = "Orange"` assigns the same value to all three. [S1]
|
||||
- **Unpacking a collection** — extracting a list/tuple's elements directly into separate variables, e.g. `x, y, z = fruits`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Count-matching requirement** — unpacking/multi-assignment requires the number of variables to exactly match the number of values/elements, or Python raises an error. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Multiple distinct values: `x, y, z = "Orange", "Banana", "Cherry"`. [S1]
|
||||
- Shared value: `x = y = z = "Orange"`. [S1]
|
||||
- Unpack a list: `fruits = ["apple", "banana", "cherry"]; x, y, z = fruits`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 SQL Tuples Unpack 챕터에서 더 확장된 언패킹(별표 문법 등)이 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Three multi-assignment styles (Python):
|
||||
```python
|
||||
x, y, z = "Orange", "Banana", "Cherry"
|
||||
x = y = z = "Orange"
|
||||
fruits = ["apple", "banana", "cherry"]
|
||||
x, y, z = fruits
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Variables]], [[Python Tuples Unpack]], [[Python Lists]]
|
||||
- **참조 맥락:** 여러 변수를 한 줄로 초기화하거나 컬렉션을 분해할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Variables - Assign Multiple Values — https://www.w3schools.com/python/python_variables_multiple.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Variables - Assign Multiple Values" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: python-booleans
|
||||
title: "Python Booleans"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bool()", "truthiness", "파이썬 불리언"]
|
||||
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", "boolean", "truthiness"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_booleans.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Booleans]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Almost every Python value is truthy by default — only a small, fixed set (empty collections, 0, "", None, False, and objects whose `__len__` returns 0) evaluates to False. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Boolean** — represents one of two values: True or False. [S1]
|
||||
- **`bool()` function** — evaluates any value/variable and returns True or False. [S1]
|
||||
- **Most values are True** — any non-empty string, any non-zero number, any non-empty list/tuple/set/dict. [S1]
|
||||
- **Falsy exceptions** — `()`, `[]`, `{}`, `""`, `0`, `None`, `False`. [S1]
|
||||
- **Custom falsy objects** — an object from a class whose `__len__` returns 0 (or False) also evaluates to False. [S1]
|
||||
- **Functions can return booleans** — including built-ins like `isinstance()`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`__len__`-based falsiness** — Python's truthiness protocol extends to custom classes via `__len__`, meaning "empty-like" custom objects behave like empty built-in collections. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Comparison expressions return booleans: `print(10 > 9); print(10 == 9); print(10 < 9)`. [S1]
|
||||
- Truthy check: `bool("Hello") # True`, `bool(15) # True`. [S1]
|
||||
- Falsy check: `bool(False); bool(None); bool(0); bool(""); bool(()); bool([]); bool({})`. [S1]
|
||||
- Custom falsy via `__len__`: [S1]
|
||||
```python
|
||||
class myclass():
|
||||
def __len__(self):
|
||||
return 0
|
||||
myobj = myclass()
|
||||
print(bool(myobj)) # False
|
||||
```
|
||||
- `isinstance()` returns a boolean: `print(isinstance(x, int))`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — if 조건문/논리 연산자 챕터 전체가 이 불리언 평가 규칙을 전제로 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Custom class controlling its own truthiness (Python):
|
||||
```python
|
||||
class myclass():
|
||||
def __len__(self):
|
||||
return 0
|
||||
|
||||
myobj = myclass()
|
||||
print(bool(myobj)) # False
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python If Else]], [[Python Operators Logical]], [[Python Operators Comparison]]
|
||||
- **참조 맥락:** 조건문/논리 연산의 기초 — if 문/while 루프의 조건 평가 방식을 정의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Booleans — https://www.w3schools.com/python/python_booleans.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Booleans" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-bytearray
|
||||
title: "Python Bytearray"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bytearray type", "파이썬 바이트어레이"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "bytearray", "binary"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_bytearray.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Bytearray]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
bytearray is the mutable counterpart to bytes — same integer-0-255 sequence semantics, but individual elements can be reassigned in place. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **bytearray** — a mutable sequence of integers in range 0-255, useful when a modifiable byte sequence is needed. [S1]
|
||||
- **Creation** — from a size (`bytearray(5)`), from an iterable of integers, or by decoding bytes. [S1]
|
||||
- **Mutability** — individual items can be changed by index assignment. [S1]
|
||||
- **Common operations** — indexing, slicing, appending, extending, `.find()`, `.replace()`; convertible to `bytes()`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **In-place item mutation** — `b[0] = 97` changes a single byte value directly, something plain `bytes` cannot do. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create from size: `x = bytearray(5)`. [S1]
|
||||
- Create from values and mutate: `b = bytearray([65, 66, 67]); b[0] = 97; print(b) # bytearray(b'aBC')`. [S1]
|
||||
- Append and decode: `b = bytearray(b"Hello "); b.extend(b"World"); print(b.decode("utf-8"))`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — bytes의 가변(mutable) 대응물로, 바이트 단위 수정이 필요할 때 사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mutate a single byte in place (Python):
|
||||
```python
|
||||
b = bytearray([65, 66, 67])
|
||||
b[0] = 97 # change 'A' to 'a'
|
||||
print(b) # bytearray(b'aBC')
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Bytes]], [[Python Memoryview]]
|
||||
- **참조 맥락:** 바이트를 직접 수정해야 할 때 사용 — 불변이면 충분하면 bytes를 대신 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python bytearray — https://www.w3schools.com/python/python_bytearray.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python bytearray" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: python-bytes
|
||||
title: "Python Bytes"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["bytes type", "파이썬 바이트"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "bytes", "binary"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_bytes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Bytes]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
bytes is an immutable sequence of integers 0-255 used for binary data, created from literals/encoded strings/integer iterables, and supports the same indexing/slicing/iteration operations as other sequences. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **bytes** — an immutable sequence of integers in range 0-255, typically for binary data (files, network protocols, UTF-8 text). [S1]
|
||||
- **Creation** — from a literal (`b"Hello"`), by encoding a string (`s.encode("utf-8")`), or from an iterable of integers. [S1]
|
||||
- **Sequence operations** — supports indexing, slicing, iteration, membership tests despite being immutable. [S1]
|
||||
- **Decoding** — `bytes.decode()` converts bytes back to a string. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Literal creation: `x = b"Hello"; print(type(x))`. [S1]
|
||||
- Encoding a string: `s = "café"; b = s.encode("utf-8"); print(b) # b'caf\xc3\xa9'`. [S1]
|
||||
- Indexing/slicing/iterating: `b = b"ABCDEF"; print(b[0]) # 65; print(b[1:4]) # b'BCD'`. [S1]
|
||||
- Decoding: `b = b"caf\xc3\xa9"; print(b.decode("utf-8")) # café`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 가변 버전인 bytearray와 대비해서 이해해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Encode and decode (Python):
|
||||
```python
|
||||
s = "café"
|
||||
b = s.encode("utf-8")
|
||||
print(b.decode("utf-8")) # café
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Bytearray]], [[Python Memoryview]], [[Python Data Types]]
|
||||
- **참조 맥락:** 이진 데이터를 다뤄야 할 때 사용 — 불변이 필요하면 bytes, 가변이 필요하면 bytearray.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python bytes — https://www.w3schools.com/python/python_bytes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python bytes" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-casting
|
||||
title: "Python Casting"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["int() float() str()", "파이썬 형변환"]
|
||||
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", "casting"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_casting.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Casting]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Because Python's primitive types are themselves classes, casting is done through constructor function calls (int(), float(), str()) rather than a dedicated cast syntax, and int() truncates rather than rounds. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Casting via constructors** — Python is object-oriented and uses classes even for primitive types, so casting means calling a constructor function. [S1]
|
||||
- **`int()`** — builds an integer from an int/float literal (removing decimals) or a string that represents a whole number. [S1]
|
||||
- **`float()`** — builds a float from an int/float/string literal representing a float or integer. [S1]
|
||||
- **`str()`** — builds a string from a wide variety of data types. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`int()` truncates, doesn't round** — `int(2.8)` gives `2`, not `3` — casting a float to int discards the decimal portion rather than rounding to the nearest integer. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Integer casting: `x = int(1); y = int(2.8) # 2; z = int("3")`. [S1]
|
||||
- Float casting: `x = float(1); y = float(2.8); z = float("3"); w = float("4.2")`. [S1]
|
||||
- String casting: `x = str("s1"); y = str(2); z = str(3.0)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Numbers/Variables 챕터에서 이미 예고된 캐스팅 문법이 여기서 상세화된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
int() truncates decimals (Python):
|
||||
```python
|
||||
x = int(1) # x will be 1
|
||||
y = int(2.8) # y will be 2 (truncated, not rounded)
|
||||
z = int("3") # z will be 3
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Variables]], [[Python Numbers]], [[Python Data Types]]
|
||||
- **참조 맥락:** 타입 간 명시적 변환이 필요할 때 사용 — int() 절삭 동작에 유의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Casting — https://www.w3schools.com/python/python_casting.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Casting" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: python-class-init-method
|
||||
title: "Python Class Init Method"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["__init__()", "constructor", "파이썬 초기화 메서드"]
|
||||
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", "init", "constructor"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_class_init.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Class Init Method]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`__init__()` runs automatically every time a class creates a new object, replacing the need to manually set properties one by one after instantiation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`__init__()`** — a built-in method automatically executed when a class is instantiated. [S1]
|
||||
- **Purpose** — assigns values to object properties or performs setup operations. [S1]
|
||||
- **Without `__init__()`** — properties must be set manually on each object after creation. [S1]
|
||||
- **Default parameter values** — `def __init__(self, name, age=18):` — parameters can have defaults, same as regular functions. [S1]
|
||||
- **Multiple parameters** — `__init__()` can take as many parameters as needed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic init: `class Person: def __init__(self, name, age): self.name = name; self.age = age; p1 = Person("Emil", 36)`. [S1]
|
||||
- Manual setup without init: `class Person: pass; p1 = Person(); p1.name = "Tobias"; p1.age = 25`. [S1]
|
||||
- Default value: `def __init__(self, name, age=18): ...; p1 = Person("Emil")` → age defaults to 18. [S1]
|
||||
- Multiple parameters: `def __init__(self, name, age, city, country): ...`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Inheritance 챕터에서 자식 클래스가 `__init__()`을 재정의하거나 `super().__init__()`으로 부모 초기화를 호출하는 패턴으로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Init with a default parameter value (Python):
|
||||
```python
|
||||
class Person:
|
||||
def __init__(self, name, age=18):
|
||||
self.name = name
|
||||
self.age = age
|
||||
|
||||
p1 = Person("Emil") # age defaults to 18
|
||||
p2 = Person("Tobias", 25)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Classes]], [[Python Class Self Parameter]], [[Python Inheritance]]
|
||||
- **참조 맥락:** 객체 생성 시 자동 실행되는 초기화 메서드 — Inheritance에서 super().__init__()으로 재사용된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python __init__() Method — https://www.w3schools.com/python/python_class_init.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python __init__() Method" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: python-class-methods
|
||||
title: "Python Class Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["__str__() method", "파이썬 클래스 메서드"]
|
||||
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", "methods", "__str__"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_class_methods.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Class Methods]]
|
||||
|
||||
# 참고: 원문 제목은 "Python Class Methods"
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Without a `__str__()` method, `print(obj)` shows an unhelpful memory-address-style representation — defining `__str__()` lets a class control exactly what string represents it when printed. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Method** — a function that belongs to a class, defining object behavior; always needs `self` as first parameter. [S1]
|
||||
- **Methods with parameters** — work like regular function parameters, just after `self`. [S1]
|
||||
- **Methods accessing/modifying properties** — via `self.property`. [S1]
|
||||
- **`__str__()`** — controls what's returned when an object is printed; without it, printing shows a default unhelpful representation. [S1]
|
||||
- **Multiple methods** — a class can have many methods that call each other and share state (e.g. a Playlist with add/remove/show methods). [S1]
|
||||
- **Deleting a method** — `del ClassName.method` removes it; calling it afterward errors. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic method: `class Person: def __init__(self, name): self.name = name; def greet(self): print("Hello, my name is " + self.name)`. [S1]
|
||||
- Method with parameters: `class Calculator: def add(self, a, b): return a + b`. [S1]
|
||||
- Method modifying state: `def celebrate_birthday(self): self.age += 1`. [S1]
|
||||
- `__str__()` override: `def __str__(self): return f"{self.name} ({self.age})"` — `print(p1)` now shows this instead of the default. [S1]
|
||||
- Multi-method class: a `Playlist` class with `add_song`, `remove_song`, `show_songs` methods collaborating via shared `self.songs`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — `__str__()`은 디버깅/로깅 시 객체를 사람이 읽기 좋은 형태로 출력하는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Custom __str__() for readable printing (Python):
|
||||
```python
|
||||
class Person:
|
||||
def __init__(self, name, age):
|
||||
self.name = name
|
||||
self.age = age
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.age})"
|
||||
|
||||
p1 = Person("Tobias", 36)
|
||||
print(p1) # Tobias (36)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Class Self Parameter]], [[Python Class Properties]], [[Python Polymorphism]]
|
||||
- **참조 맥락:** 클래스 동작 정의의 기본 — __str__()은 디버깅/로깅에 표준적으로 쓰인다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Class Methods — https://www.w3schools.com/python/python_class_methods.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Class Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: python-class-properties
|
||||
title: "Python Class Properties"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["instance properties", "class properties", "파이썬 클래스 속성"]
|
||||
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", "class-properties"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_class_properties.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Class Properties]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A property defined inside `__init__()` belongs to each individual object, but one defined directly in the class body is shared across ALL instances — changing it via `ClassName.prop = value` updates what every object sees, even ones created before the change. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Instance property** — defined via `self.x = ...` inside `__init__()`; unique per object. [S1]
|
||||
- **Class property** — defined directly in the class body (not inside a method); shared by ALL instances. [S1]
|
||||
- **Dot notation access** — `obj.property`. [S1]
|
||||
- **Modifying properties** — `p1.age = 26` changes just that instance. [S1]
|
||||
- **`del obj.property`** — deletes a property from a specific object. [S1]
|
||||
- **Modifying a CLASS property** — `Person.lastname = "Refsnes"` affects every instance, including ones already created. [S1]
|
||||
- **Adding properties dynamically** — `p1.age = 25` adds a property to just that one object, not to the class. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Class-level mutation is retroactive** — because a class property is shared storage, not copied per instance, changing it via the class name propagates to every existing object immediately — a common source of surprise bugs if mistaken for an instance property. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Instance property: `class Person: def __init__(self, name, age): self.name = name; self.age = age`. [S1]
|
||||
- Delete a property: `del p1.age` — `p1.name` still works, but `p1.age` now errors. [S1]
|
||||
- Class vs. instance property: `class Person: species = "Human"; def __init__(self, name): self.name = name` — `species` shared, `name` per-instance. [S1]
|
||||
- Modifying a class property: `Person.lastname = "Refsnes"` — affects `p1.lastname` and `p2.lastname` both. [S1]
|
||||
- Dynamic per-object addition: `p1.age = 25; p1.city = "Oslo"` — only affects `p1`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 클래스 속성은 모든 인스턴스가 공유해야 하는 설정값(예: 종(species))에 쓰이고, 인스턴스 속성은 객체별 고유 데이터에 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Class property shared across all instances (Python):
|
||||
```python
|
||||
class Person:
|
||||
lastname = "" # class property
|
||||
def __init__(self, name):
|
||||
self.name = name # instance property
|
||||
|
||||
p1 = Person("Linus")
|
||||
p2 = Person("Emil")
|
||||
Person.lastname = "Refsnes"
|
||||
print(p1.lastname) # Refsnes
|
||||
print(p2.lastname) # Refsnes
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** 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 Methods]], [[Python Encapsulation]]
|
||||
- **참조 맥락:** 인스턴스 속성 vs 클래스 속성의 차이 — 공유 상태와 개별 상태를 구분해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Class Properties — https://www.w3schools.com/python/python_class_properties.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Class Properties" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
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).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: python-classes
|
||||
title: "Python Classes"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Classes/Objects", "class keyword", "파이썬 클래스"]
|
||||
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", "classes", "objects"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_classes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Classes]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Each object created from the same class is fully independent, holding its own separate copy of the class's properties — modifying one instance never affects another. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`class` keyword** — creates a class, an "object constructor" or blueprint. [S1]
|
||||
- **Instantiation** — `p1 = MyClass()` creates an object from the class. [S1]
|
||||
- **`del`** — deletes an object. [S1]
|
||||
- **Multiple independent objects** — each object from the same class has its own copy of properties. [S1]
|
||||
- **`pass`** — required for an otherwise-empty class body. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic class: `class MyClass: x = 5`. [S1]
|
||||
- Create object: `p1 = MyClass(); print(p1.x)`. [S1]
|
||||
- Delete object: `del p1`. [S1]
|
||||
- Independent instances: `p1 = MyClass(); p2 = MyClass(); p3 = MyClass()` — each independent. [S1]
|
||||
- Empty class: `class Person: pass`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 __init__()/self 챕터로 클래스 초기화가 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic class and object (Python):
|
||||
```python
|
||||
class MyClass:
|
||||
x = 5
|
||||
|
||||
p1 = MyClass()
|
||||
print(p1.x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python OOP]], [[Python Class Init Method]], [[Python Class Self Parameter]]
|
||||
- **참조 맥락:** 클래스/객체 기본 개념 — __init__()/self 챕터로 이어진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Classes and Objects — https://www.w3schools.com/python/python_classes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Classes and Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: python-comments
|
||||
title: "Python Comments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_comments.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Comments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has no true multiline comment syntax — `#` handles single lines, so multiline "comments" are either repeated `#` per line or a trick using an unassigned triple-quoted string literal. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Purpose** — explain code, improve readability, or temporarily disable execution while testing. [S1]
|
||||
- **Single-line comments** — start with `#`; Python ignores the rest of the line. [S1]
|
||||
- **Inline comments** — can be placed at the end of a code line. [S1]
|
||||
- **Disabling code via comment** — commenting out a line prevents its execution without deleting it. [S1]
|
||||
- **No real multiline syntax** — Python has no dedicated multiline comment construct. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Unassigned triple-quoted string as pseudo-comment** — since Python ignores string literals not assigned to a variable, a `"""..."""` block used standalone acts as a de facto multiline comment (not a true comment, but achieves the same effect). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic comment: `#This is a comment` above `print("Hello, World!")`. [S1]
|
||||
- Inline comment: `print("Hello, World!") #This is a comment`. [S1]
|
||||
- Disabling a line: `#print("Hello, World!")` followed by an active `print("Cheers, Mate!")`. [S1]
|
||||
- Repeated `#` for multiline: three consecutive `#`-prefixed lines. [S1]
|
||||
- Triple-quoted pseudo-comment: an unassigned `"""..."""` block used purely for its ignored side-effect. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 트리플쿼트 방식은 "완전히 의도된 방식은 아니다(not quite as intended)"라고 소스 스스로 명시함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 디버깅 중 코드 일부를 임시 비활성화하는 용도로 실무에서 흔히 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Pseudo multiline comment via unassigned string (Python):
|
||||
```python
|
||||
"""
|
||||
This is a comment
|
||||
written in
|
||||
more than just one line
|
||||
"""
|
||||
print("Hello, World!")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Syntax]], [[Python Strings]]
|
||||
- **참조 맥락:** 코드 문서화 및 디버깅 시 임시 비활성화에 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Comments — https://www.w3schools.com/python/python_comments.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: python-data-types
|
||||
title: "Python Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Built-in Data Types", "파이썬 자료형"]
|
||||
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", "datatypes"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_datatypes.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python's built-in types span nine categories — text, three numeric, three sequence/collection families, mapping, set, boolean, three binary, and None — and each has both an implicit literal form and an explicit constructor-function form. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Text Type** — `str`. [S1]
|
||||
- **Numeric Types** — `int`, `float`, `complex`. [S1]
|
||||
- **Sequence Types** — `list`, `tuple`, `range`. [S1]
|
||||
- **Mapping Type** — `dict`. [S1]
|
||||
- **Set Types** — `set`, `frozenset`. [S1]
|
||||
- **Boolean Type** — `bool`. [S1]
|
||||
- **Binary Types** — `bytes`, `bytearray`, `memoryview`. [S1]
|
||||
- **None Type** — `NoneType`. [S1]
|
||||
- **`type()` function** — reveals any object's current data type. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Literal vs. constructor duality** — every type can be set via a literal (`x = 20`) or via an explicit constructor function (`x = int(20)`) — the constructor form is what [[Python Casting]] relies on. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Literal assignment examples: `x = "Hello World"` (str), `x = 20` (int), `x = 20.5` (float), `x = 1j` (complex), `x = ["apple","banana","cherry"]` (list), `x = ("apple","banana","cherry")` (tuple), `x = range(6)` (range), `x = {"name":"John","age":36}` (dict), `x = {"apple","banana","cherry"}` (set), `x = frozenset({...})` (frozenset), `x = True` (bool), `x = b"Hello"` (bytes), `x = bytearray(5)` (bytearray), `x = memoryview(bytes(5))` (memoryview), `x = None` (NoneType). [S1]
|
||||
- Constructor-function equivalents: `str()`, `int()`, `float()`, `complex()`, `list()`, `tuple()`, `range()`, `dict()`, `set()`, `frozenset()`, `bool()`, `bytes()`, `bytearray()`, `memoryview()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 문서에서 정의한 9개 타입 카테고리가 각각 이후 전용 챕터(Strings/Numbers/Lists/Tuples/Sets/Dictionaries/bytes/bytearray/memoryview)로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Type via literal vs. constructor (Python):
|
||||
```python
|
||||
x = 20 # literal -> int
|
||||
x = int(20) # constructor -> int
|
||||
print(type(x))
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Numbers]], [[Python Strings]], [[Python Lists]], [[Python Dictionaries]], [[Python Casting]]
|
||||
- **참조 맥락:** Python 타입 시스템 전체 개론 — 이후 각 타입별 전용 챕터의 상위 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Data Types — https://www.w3schools.com/python/python_datatypes.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-dates
|
||||
title: "Python Dates"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["datetime module", "strftime", "파이썬 날짜"]
|
||||
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", "datetime", "dates"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_datetime.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dates]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has no native date type — dates are objects from the `datetime` module, constructed with year/month/day (time/timezone optional, defaulting to 0/None), and rendered into any custom string format via `strftime()`'s directive codes. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **No native date type** — must `import datetime` to work with dates as objects. [S1]
|
||||
- **`datetime.datetime.now()`** — returns the current date/time (year, month, day, hour, minute, second, microsecond). [S1]
|
||||
- **`datetime.datetime(year, month, day, ...)`** — constructs a specific date; time/timezone parameters are optional. [S1]
|
||||
- **`.strftime(format)`** — formats a datetime object into a custom string using directive codes. [S1]
|
||||
- **Common directives** — `%A`/`%a` weekday full/short, `%B`/`%b` month full/short, `%Y`/`%y` year full/short, `%H`/`%I` hour 24/12, `%M` minute, `%S` second, `%p` AM/PM, `%j` day-of-year, `%U`/`%W` week number. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Current date: `import datetime; x = datetime.datetime.now(); print(x)`. [S1]
|
||||
- Date attributes: `print(x.year); print(x.strftime("%A"))`. [S1]
|
||||
- Construct a specific date: `x = datetime.datetime(2020, 5, 17)`. [S1]
|
||||
- Format with strftime: `x = datetime.datetime(2018, 6, 1); print(x.strftime("%B"))` → "June". [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Dates 챕터에서 다룬 날짜 포맷 불일치 문제와 유사하게, Python에서도 strftime 포맷 코드를 정확히 알아야 원하는 문자열을 얻을 수 있다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Construct and format a specific date (Python):
|
||||
```python
|
||||
import datetime
|
||||
x = datetime.datetime(2018, 6, 1)
|
||||
print(x.strftime("%B")) # June
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Modules]], [[SQL Dates]]
|
||||
- **참조 맥락:** 날짜/시간 데이터를 다뤄야 하는 모든 로직의 기초 — SQL Dates의 포맷 불일치 문제와 유사한 주의가 필요하다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Datetime — https://www.w3schools.com/python/python_datetime.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Datetime" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,88 @@
|
||||
---
|
||||
id: python-decorators
|
||||
title: "Python Decorators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["@decorator", "functools.wraps", "파이썬 데코레이터"]
|
||||
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", "decorators", "closures"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_decorators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Decorators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A decorator wraps a function with new behavior without touching its source code, but the wrap silently destroys the original function's `__name__`/`__doc__` metadata unless `functools.wraps` is used to preserve it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Decorator** — a function that takes another function as input and returns a new function, adding behavior without modifying the original code. [S1]
|
||||
- **`@decorator_name` syntax** — placed directly above a function definition to apply the decorator. [S1]
|
||||
- **Reusable across functions** — the same decorator can be applied to multiple functions. [S1]
|
||||
- **Handling arguments** — the wrapper function must accept and forward whatever arguments the decorated function needs; `(*args, **kwargs)` makes this fully generic. [S1]
|
||||
- **Decorators with their own arguments** — requires an extra wrapper level (a "decorator factory"). [S1]
|
||||
- **Stacking decorators** — applied in REVERSE order — the one closest to the function runs first. [S1]
|
||||
- **Metadata loss** — a decorated function's `__name__`/`__doc__` become the WRAPPER's, not the original's, unless fixed. [S1]
|
||||
- **`functools.wraps`** — preserves the original function's name and docstring through decoration. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`(*args, **kwargs)` as the universal wrapper signature** — since a decorator author often doesn't know what arguments the decorated function takes, the generic collect-and-forward pattern from [[Python Args Kwargs]] is the standard fix. [S1]
|
||||
- **Bottom-up stacking order** — `@a` `@b` `def f()` applies `b` first, then `a` — reading decorator stacks requires reading from the function outward, not top-down. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic decorator: `def changecase(func): def myinner(): return func().upper(); return myinner; @changecase def myfunction(): return "Hello Sally"`. [S1]
|
||||
- Generic argument forwarding: `def myinner(*args, **kwargs): return func(*args, **kwargs).upper()`. [S1]
|
||||
- Decorator factory (decorator with its own argument): a decorator taking `n` and returning a decorator that behaves differently based on `n`. [S1]
|
||||
- Stacked decorators: `@changecase @addgreeting def myfunction(): return "Tobias"` — addgreeting runs first, then changecase. [S1]
|
||||
- Preserving metadata: `import functools; def changecase(func): @functools.wraps(func) def myinner(): ...`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 메타데이터 손실이 데코레이터의 부작용으로 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 로깅, 인증 검사, 캐싱처럼 함수 실행 전후에 공통 로직을 끼워 넣을 때 표준적으로 쓰이는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Metadata-preserving decorator (Python):
|
||||
```python
|
||||
import functools
|
||||
|
||||
def changecase(func):
|
||||
@functools.wraps(func)
|
||||
def myinner(*args, **kwargs):
|
||||
return func(*args, **kwargs).upper()
|
||||
return myinner
|
||||
|
||||
@changecase
|
||||
def myfunction():
|
||||
return "Have a great day!"
|
||||
|
||||
print(myfunction.__name__) # myfunction, not myinner
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Args Kwargs]], [[Python Scope]], [[Python Functions]]
|
||||
- **참조 맥락:** 함수를 감싸 공통 로직을 추가하는 표준 패턴 — 클로저(Scope의 Enclosing)에 기반한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Decorators — https://www.w3schools.com/python/python_decorators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Decorators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-delete-files
|
||||
title: "Python Delete Files"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["os.remove()", "os.rmdir()", "파이썬 파일 삭제"]
|
||||
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", "file-handling", "delete", "os"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_file_remove.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Delete Files]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
File deletion isn't part of the file-object API at all — it lives in the separate `os` module, and `os.rmdir()` only removes EMPTY folders, so non-empty directories need a different approach entirely. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`os` module required** — file/folder deletion needs `import os`. [S1]
|
||||
- **`os.remove(filename)`** — deletes the specified file. [S1]
|
||||
- **`os.path.exists(filename)`** — checks existence before deleting, to avoid an error. [S1]
|
||||
- **`os.rmdir(foldername)`** — deletes a folder, but ONLY if it's empty. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Remove a file: `import os; os.remove("demofile.txt")`. [S1]
|
||||
- Safe removal (check first): `import os; if os.path.exists("demofile.txt"): os.remove("demofile.txt") else: print("The file does not exist")`. [S1]
|
||||
- Remove an empty folder: `import os; os.rmdir("myfolder")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. `os.rmdir()`이 빈 폴더만 삭제 가능하다는 제약이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 존재 여부를 먼저 확인하고 삭제하는 패턴은 Python Try Except의 예외 처리 없이도 안전하게 파일을 다루는 대안적 방식이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Safe file deletion with existence check (Python):
|
||||
```python
|
||||
import os
|
||||
if os.path.exists("demofile.txt"):
|
||||
os.remove("demofile.txt")
|
||||
else:
|
||||
print("The file does not exist")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Write Create Files]], [[Python Modules]]
|
||||
- **참조 맥락:** 파일/폴더 삭제는 os 모듈이 담당 — 존재 확인 후 삭제하는 안전한 관용구.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Delete File — https://www.w3schools.com/python/python_file_remove.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Delete File" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: python-dictionaries
|
||||
title: "Python Dictionaries"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 딕셔너리"]
|
||||
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", "dictionaries"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A dictionary stores key:value pairs — ordered since Python 3.7, changeable, no duplicate keys — and assigning to an existing key silently OVERWRITES it rather than raising an error or creating a duplicate. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Dictionary** — stores data in key:value pairs; one of 4 built-in collection types. [S1]
|
||||
- **Ordered (3.7+)** — item order is defined and persists; prior to 3.7, dictionaries were unordered. [S1]
|
||||
- **Changeable** — items can be changed, added, removed after creation. [S1]
|
||||
- **No duplicate keys** — repeating a key in a literal overwrites the earlier value. [S1]
|
||||
- **`dict()` constructor** — alternative creation syntax: `dict(name="John", age=36)`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Silent overwrite on duplicate key** — `{"year": 1964, "year": 2020}` doesn't error or keep both; the later value simply wins — a subtle footgun if a dict literal is built programmatically with accidental key collisions. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic creation: `thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}`. [S1]
|
||||
- Access by key: `print(thisdict["brand"])`. [S1]
|
||||
- Duplicate key overwrite: `{"year": 1964, "year": 2020}` → keeps only 2020. [S1]
|
||||
- Mixed value types: `{"brand": "Ford", "electric": False, "year": 1964, "colors": ["red","white","blue"]}`. [S1]
|
||||
- Constructor: `thisdict = dict(name="John", age=36, country="Norway")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **순서 보장은 버전 종속적**: Python 3.7+부터 순서 보장, 이전 버전은 무순서. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 Access/Change/Add/Remove/Loop/Copy/Nested/Methods 챕터의 기초 개론이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic dictionary creation and access (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
print(thisdict["brand"])
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists]], [[Python Sets]], [[Python Dictionaries Access]]
|
||||
- **참조 맥락:** 4대 컬렉션 타입 중 이름-값 매핑이 필요할 때 사용하는 타입.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Dictionaries — https://www.w3schools.com/python/python_dictionaries.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Dictionaries" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: python-dictionaries-access
|
||||
title: "Python Dictionaries Access"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Access Items", "파이썬 딕셔너리 접근"]
|
||||
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", "dictionaries", "keys", "values"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_access.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Access]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`keys()`, `values()`, and `items()` return live VIEWS of the dictionary, not static snapshots — modifying the original dictionary afterward automatically updates any view object already captured in a variable. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Bracket access** — `thisdict["model"]`. [S1]
|
||||
- **`get(key)`** — equivalent alternative to bracket access. [S1]
|
||||
- **`keys()`** — returns a view of all keys. [S1]
|
||||
- **`values()`** — returns a view of all values. [S1]
|
||||
- **`items()`** — returns a view of key:value pairs as tuples. [S1]
|
||||
- **Views are live** — any of the three view objects automatically reflects later changes to the source dictionary. [S1]
|
||||
- **Membership check** — `"model" in thisdict` tests key presence. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **View-not-copy is the defining trait** — `x = car.keys()` captured BEFORE a new key is added still shows the new key when printed AFTER, because `x` is a live view bound to `car`, not a frozen copy. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Bracket vs. get: `x = thisdict["model"]` and `x = thisdict.get("model")` give the same result. [S1]
|
||||
- Live keys view: `car = {...}; x = car.keys(); car["color"] = "white"; print(x) # includes "color"`. [S1]
|
||||
- Live values view: same live-update behavior for `car.values()`. [S1]
|
||||
- Live items view: same live-update behavior for `car.items()`. [S1]
|
||||
- Membership: `if "model" in thisdict: print(...)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Loop Dictionaries 챕터에서 keys()/values()/items()가 순회 목적으로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Live view reflects later changes (Python):
|
||||
```python
|
||||
car = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
x = car.keys()
|
||||
car["color"] = "white"
|
||||
print(x) # dict_keys(['brand', 'model', 'year', 'color'])
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries]], [[Python Dictionaries Loop]], [[Python Dictionaries Methods]]
|
||||
- **참조 맥락:** keys()/values()/items()가 라이브 뷰라는 성질 — Loop Dictionaries에서 순회용으로 재사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Access Dictionary Items — https://www.w3schools.com/python/python_dictionaries_access.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Access Dictionary Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: python-dictionaries-add
|
||||
title: "Python Dictionaries Add"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Add Items", "파이썬 딕셔너리 추가"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "dictionaries", "add"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_add.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Add]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Adding a new key is symmetric with changing an existing one — the same bracket-assignment and update() syntax works for both, since Python simply creates the key if it doesn't already exist. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **New key via assignment** — `thisdict["color"] = "red"` creates the key if absent. [S1]
|
||||
- **`update()` also adds** — if the key given to `update()` doesn't exist yet, it's added rather than updated. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Assignment-based add: `thisdict["color"] = "red"`. [S1]
|
||||
- Update-based add: `thisdict.update({"color": "red"})`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Change Dictionary Items 챕터와 문법이 완전히 동일하며, 키 존재 여부만 "수정 vs 추가"를 가른다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Add a new key (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
thisdict["color"] = "red"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries Change]], [[Python Dictionaries Remove]]
|
||||
- **참조 맥락:** 딕셔너리에 새 키를 추가하는 방법 — Change Dictionary Items와 동일한 문법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Add Dictionary Items — https://www.w3schools.com/python/python_dictionaries_add.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Add Dictionary Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: python-dictionaries-change
|
||||
title: "Python Dictionaries Change"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Change Items", "파이썬 딕셔너리 수정"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "dictionaries", "update"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_change.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Change]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A dictionary value can be changed either by direct key assignment or via update() with a dict argument — the latter accepts any iterable of key:value pairs, not just a literal dict. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Direct assignment** — `thisdict["year"] = 2018` changes an existing key's value. [S1]
|
||||
- **`update()` method** — `thisdict.update({"year": 2020})` updates using another dict (or key:value iterable) as the argument. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Direct change: `thisdict["year"] = 2018`. [S1]
|
||||
- Update method: `thisdict.update({"year": 2020})`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — update()는 Add Dictionary Items 챕터에서 "키가 없으면 추가"라는 동작으로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Update a value via update() (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
thisdict.update({"year": 2020})
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries]], [[Python Dictionaries Add]]
|
||||
- **참조 맥락:** 딕셔너리 값 수정의 기본 — update()는 Add Dictionary Items에서 신규 키 추가로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Change Dictionary Items — https://www.w3schools.com/python/python_dictionaries_change.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Change Dictionary Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: python-dictionaries-copy
|
||||
title: "Python Dictionaries Copy"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Copy Dictionaries", "파이썬 딕셔너리 복사"]
|
||||
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", "dictionaries", "copy", "reference"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_copy.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Copy]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`dict2 = dict1` creates a reference, not a copy — exactly the same footgun as lists — so `copy()` or `dict()` must be used to get a truly independent dictionary. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Reference trap** — `dict2 = dict1` makes `dict2` reference `dict1`; changes to one affect both. [S1]
|
||||
- **`copy()` method** — `mydict = thisdict.copy()` makes an independent copy. [S1]
|
||||
- **`dict()` constructor** — `mydict = dict(thisdict)` is an alternative copy method. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Copy via method: `mydict = thisdict.copy()`. [S1]
|
||||
- Copy via constructor: `mydict = dict(thisdict)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Lists Copy 챕터와 동일한 참조/복사 함정을 딕셔너리에도 그대로 적용해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Independent copy via copy() (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
mydict = thisdict.copy()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Copy]], [[Python Dictionaries]]
|
||||
- **참조 맥락:** 리스트와 동일한 참조 vs 복사 함정 — 딕셔너리에도 그대로 적용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Copy Dictionaries — https://www.w3schools.com/python/python_dictionaries_copy.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Copy Dictionaries" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-dictionaries-loop
|
||||
title: "Python Dictionaries Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Loop Dictionaries", "파이썬 딕셔너리 반복"]
|
||||
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", "dictionaries", "loop"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_loop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A plain `for x in dict` loop yields KEYS by default, not values — to get values directly or both key and value together, you need `.values()` or `.items()` respectively, with items() enabling the two-variable unpacking form `for x, y in dict.items()`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Default loop yields keys** — `for x in thisdict: print(x)` prints key names. [S1]
|
||||
- **Get values via key** — `for x in thisdict: print(thisdict[x])`. [S1]
|
||||
- **`.values()` loop** — `for x in thisdict.values(): print(x)` iterates values directly. [S1]
|
||||
- **`.keys()` loop** — `for x in thisdict.keys(): print(x)` — explicit equivalent of the default loop. [S1]
|
||||
- **`.items()` loop** — `for x, y in thisdict.items(): print(x, y)` unpacks key and value together. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Keys by default: `for x in thisdict: print(x)`. [S1]
|
||||
- Values via key lookup: `for x in thisdict: print(thisdict[x])`. [S1]
|
||||
- Values directly: `for x in thisdict.values(): print(x)`. [S1]
|
||||
- Both key and value: `for x, y in thisdict.items(): print(x, y)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Nested Dictionaries 챕터에서 items() 순회가 중첩 구조 탐색에 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Loop through both keys and values (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
for x, y in thisdict.items():
|
||||
print(x, y)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries Access]], [[Python Dictionaries Nested]], [[Python For Loops]]
|
||||
- **참조 맥락:** 딕셔너리 순회의 5가지 방식 — items()는 중첩 딕셔너리 순회에도 재사용된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Loop Dictionaries — https://www.w3schools.com/python/python_dictionaries_loop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Loop Dictionaries" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: python-dictionaries-methods
|
||||
title: "Python Dictionaries Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Dictionary Methods", "파이썬 딕셔너리 메서드"]
|
||||
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", "dictionaries", "methods"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_methods.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Methods]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`setdefault()` is the one dictionary method not covered in earlier chapters — it returns a key's value if present, or inserts the key with a default value and returns that, in one atomic operation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`clear()`** — removes all elements. [S1]
|
||||
- **`copy()`** — returns a copy. [S1]
|
||||
- **`fromkeys()`** — returns a dictionary with specified keys and a shared value. [S1]
|
||||
- **`get()`** — returns the value of a specified key. [S1]
|
||||
- **`items()`** — returns key-value tuple pairs. [S1]
|
||||
- **`keys()`** — returns dictionary keys. [S1]
|
||||
- **`pop()`** — removes the element with a specified key. [S1]
|
||||
- **`popitem()`** — removes the last inserted key-value pair. [S1]
|
||||
- **`setdefault()`** — returns a key's value; if the key doesn't exist, inserts it with the specified value. [S1]
|
||||
- **`update()`** — updates the dictionary with specified key-value pairs. [S1]
|
||||
- **`values()`** — returns all values. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`setdefault()` combines get-or-insert into one call** — avoids the two-step "check if key exists, then insert if not" pattern that would otherwise need an explicit `if key not in dict` check. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 이전 챕터들(Access/Change/Add/Remove/Copy)에서 개별적으로 다룬 딕셔너리 메서드 전체를 하나의 표로 정리한 레퍼런스 챕터다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — setdefault()는 "키가 없으면 기본값으로 초기화" 로직을 한 줄로 줄이는 데 유용하다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
setdefault as atomic get-or-insert (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford"}
|
||||
x = thisdict.setdefault("model", "Mustang") # inserts if missing, returns value
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries]], [[Python Dictionaries Access]], [[Python Dictionaries Remove]]
|
||||
- **참조 맥락:** 딕셔너리 메서드 전체 요약 — setdefault()가 이 챕터에서 유일하게 새로 소개되는 메서드.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Dictionary Methods — https://www.w3schools.com/python/python_dictionaries_methods.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Dictionary Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: python-dictionaries-nested
|
||||
title: "Python Dictionaries Nested"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Nested Dictionaries", "파이썬 중첩 딕셔너리"]
|
||||
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", "dictionaries", "nested"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_nested.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Nested]]
|
||||
|
||||
# 참고: 원문 제목은 "Python - Nested Dictionaries"
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A dictionary can contain other dictionaries as values, and chained bracket access (`outer["child2"]["name"]`) drills into the nesting exactly like accessing a plain key. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested dictionary** — a dictionary whose values are themselves dictionaries. [S1]
|
||||
- **Two construction styles** — inline literal nesting, or assembling separate named dicts and combining them into an outer dict. [S1]
|
||||
- **Chained access** — `myfamily["child2"]["name"]` accesses the outer dict, then the inner dict. [S1]
|
||||
- **Nested loop via items()** — an outer `for x, obj in myfamily.items()` combined with an inner `for y in obj` walks the full nested structure. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Inline nested literal: [S1]
|
||||
```python
|
||||
myfamily = {
|
||||
"child1" : {"name" : "Emil", "year" : 2004},
|
||||
"child2" : {"name" : "Tobias", "year" : 2007},
|
||||
"child3" : {"name" : "Linus", "year" : 2011}
|
||||
}
|
||||
```
|
||||
- Assembled from separate dicts: `child1 = {...}; child2 = {...}; child3 = {...}; myfamily = {"child1": child1, "child2": child2, "child3": child3}`. [S1]
|
||||
- Chained access: `print(myfamily["child2"]["name"])`. [S1]
|
||||
- Nested loop: [S1]
|
||||
```python
|
||||
for x, obj in myfamily.items():
|
||||
print(x)
|
||||
for y in obj:
|
||||
print(y + ':', obj[y])
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — JSON과 유사한 계층적 데이터 구조를 표현할 때 표준적으로 쓰이는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained access into a nested dict (Python):
|
||||
```python
|
||||
myfamily = {
|
||||
"child1": {"name": "Emil", "year": 2004},
|
||||
"child2": {"name": "Tobias", "year": 2007},
|
||||
}
|
||||
print(myfamily["child2"]["name"]) # Tobias
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries]], [[Python Dictionaries Loop]], [[Python JSON]]
|
||||
- **참조 맥락:** 계층적 데이터 구조 표현의 기본 — JSON 챕터와 자연스럽게 연결된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Nested Dictionaries — https://www.w3schools.com/python/python_dictionaries_nested.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Nested Dictionaries" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: python-dictionaries-remove
|
||||
title: "Python Dictionaries Remove"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Remove Items", "파이썬 딕셔너리 삭제"]
|
||||
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", "dictionaries", "pop", "popitem", "del"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_dictionaries_remove.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Dictionaries Remove]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
pop() removes by key name, popitem() removes the LAST-inserted pair (a random pair before Python 3.7), and del/clear() handle the whole-dictionary and empty-contents cases respectively. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`pop(key)`** — removes the item with the specified key. [S1]
|
||||
- **`popitem()`** — removes the last inserted key-value pair (random pair in versions before 3.7). [S1]
|
||||
- **`del dict[key]`** — removes the item with the specified key (keyword form). [S1]
|
||||
- **`del dict`** — deletes the entire dictionary variable. [S1]
|
||||
- **`clear()`** — empties the dictionary. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`popitem()`의 버전 의존적 동작** — 3.7+에서는 "마지막 삽입 항목"이라는 예측 가능한 동작이지만, 이전 버전에서는 임의(random) 항목을 제거했다 — 버전별 동작 차이를 인지해야 한다. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Remove by key: `thisdict.pop("model")`. [S1]
|
||||
- Remove last inserted: `thisdict.popitem()`. [S1]
|
||||
- Del by key: `del thisdict["model"]`. [S1]
|
||||
- Del entire dict: `del thisdict`. [S1]
|
||||
- Clear contents: `thisdict.clear()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **`popitem()` 동작이 버전에 따라 다름**: 3.7+ = 마지막 삽입 항목, 그 이전 = 임의 항목. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 5가지 삭제 방법 중 키 기반(pop/del)과 전체 삭제(del/clear)를 구분해서 이해해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Remove by key vs. remove last-inserted (Python):
|
||||
```python
|
||||
thisdict = {"brand": "Ford", "model": "Mustang", "year": 1964}
|
||||
thisdict.pop("model") # remove by key
|
||||
thisdict.popitem() # remove last-inserted pair (3.7+)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries Add]], [[Python Dictionaries Methods]]
|
||||
- **참조 맥락:** 딕셔너리에서 항목/전체를 삭제하는 5가지 방법.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Remove Dictionary Items — https://www.w3schools.com/python/python_dictionaries_remove.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Remove Dictionary Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: python-elif
|
||||
title: "Python Elif"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Elif Statement", "파이썬 elif"]
|
||||
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", "elif", "conditions"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_if_elif.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Elif]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`elif` checks conditions top-to-bottom and stops at the FIRST true one — so even if multiple conditions would be true, only the first matching block executes, making elif chains cheaper than separate independent if statements. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`elif`** — "if the previous conditions were not true, then try this condition". [S1]
|
||||
- **Multiple elif** — as many as needed; Python checks each in order. [S1]
|
||||
- **First-match-wins** — execution stops at the first true condition, even if later ones would also be true. [S1]
|
||||
- **When to use** — for multiple mutually exclusive conditions; more efficient than separate if statements since checking stops early. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Mutual-exclusivity assumption** — elif chains are designed for conditions that are logically exclusive (e.g. grade bands); using elif for conditions that could overlap silently discards all but the first match. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic elif: `if b > a: ... elif a == b: print("a and b are equal")`. [S1]
|
||||
- Grade band chain: `if score >= 90: "A" elif score >= 80: "B" elif score >= 70: "C" elif score >= 60: "D"` — score 75 prints "C" only. [S1]
|
||||
- Day-of-week chain: 7 elif branches, one per day number. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 등급 분류, 요일 판별처럼 상호 배타적인 다중 조건 로직의 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
First-match-wins elif chain (Python):
|
||||
```python
|
||||
score = 75
|
||||
if score >= 90:
|
||||
print("Grade: A")
|
||||
elif score >= 80:
|
||||
print("Grade: B")
|
||||
elif score >= 70:
|
||||
print("Grade: C") # this one executes
|
||||
elif score >= 60:
|
||||
print("Grade: D")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python If Statement]], [[Python Else]], [[Python Match]]
|
||||
- **참조 맥락:** 상호 배타적 다중 조건 분기 — Match 문(3.10+)의 대안으로도 비교된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Elif Statement — https://www.w3schools.com/python/python_if_elif.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Elif Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-else
|
||||
title: "Python Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Else Statement", "파이썬 else"]
|
||||
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", "else", "conditions"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_if_else.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
else is the fallback that catches everything not matched by preceding if/elif conditions, and it must always come last — Python doesn't allow an elif after an else. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`else`** — catches anything not caught by preceding if/elif conditions. [S1]
|
||||
- **Must come last** — no elif can follow an else. [S1]
|
||||
- **Works with or without elif** — a simple `if/else` two-way branch is valid on its own. [S1]
|
||||
- **Common uses** — error handling, validation, providing default values. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- With elif: `if b > a: ... elif a == b: ... else: print("a is greater than b")`. [S1]
|
||||
- Without elif (simple two-way): `if b > a: ... else: print("b is not greater than a")`. [S1]
|
||||
- Even/odd check: `if number % 2 == 0: "even" else: "odd"`. [S1]
|
||||
- Validation fallback: `if len(username) > 0: print(f"Welcome, {username}!") else: print("Error: Username cannot be empty")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 입력 검증/기본값 제공처럼 "그 외 모든 경우"를 처리하는 표준 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Fallback validation pattern (Python):
|
||||
```python
|
||||
username = "Emil"
|
||||
if len(username) > 0:
|
||||
print(f"Welcome, {username}!")
|
||||
else:
|
||||
print("Error: Username cannot be empty")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python If Statement]], [[Python Elif]], [[Python If Shorthand]]
|
||||
- **참조 맥락:** if/elif 체인의 기본 폴백 — 유효성 검사/기본값 제공에 표준적으로 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Else Statement — https://www.w3schools.com/python/python_if_else.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Else Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: python-encapsulation
|
||||
title: "Python Encapsulation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["name mangling", "private properties", "protected properties", "파이썬 캡슐화"]
|
||||
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", "encapsulation", "private", "name-mangling"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_encapsulation.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Encapsulation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has no true private access control — double-underscore "private" properties are just name-mangled to `_ClassName__prop` internally, still technically accessible from outside if you know the mangled name, which is why it's a convention backed by tooling, not a hard security boundary. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Encapsulation** — keeping data and methods together in a class while controlling external access; protects against accidental changes. [S1]
|
||||
- **Private properties (`__` prefix)** — cannot be accessed directly from outside the class. [S1]
|
||||
- **Getter method** — a method that returns a private property's value. [S1]
|
||||
- **Setter method** — a method that sets/validates a private property's value. [S1]
|
||||
- **Protected properties (`_` prefix)** — a convention only; Python does NOT enforce this restriction. [S1]
|
||||
- **Private methods (`__` prefix)** — same restriction as private properties; can only be called from within the class. [S1]
|
||||
- **Name mangling** — Python internally renames `__age` to `_ClassName__age`; this is HOW "private" is implemented. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Name mangling reveals private isn't truly private** — `p1._Person__age` still works and accesses the "private" value directly — Python's encapsulation is a naming convention enforced by mangling, not a hard access-control mechanism like in some other languages. [S1]
|
||||
- **Getter+setter enables validation** — a setter like `set_age()` can reject invalid values (`if age > 0: ...`) at the point of mutation, something direct attribute assignment can't do. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Private property (inaccessible directly): `class Person: def __init__(self, name, age): self.name = name; self.__age = age` — `p1.__age` errors. [S1]
|
||||
- Getter: `def get_age(self): return self.__age`. [S1]
|
||||
- Setter with validation: `def set_age(self, age): if age > 0: self.__age = age else: print("Age must be positive")`. [S1]
|
||||
- Protected (convention only): `self._salary = salary` — accessible but discouraged. [S1]
|
||||
- Private method: `def __validate(self, num): ...` — callable only internally. [S1]
|
||||
- Name mangling revealed: `print(p1._Person__age)` — works, but not recommended. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **"Private"가 진짜 비공개가 아님**: 네임 맹글링된 이름(`_ClassName__prop`)으로 여전히 접근 가능하다는 점이 소스에서 명시적으로 경고됨 — "not recommended"라고 언급하지만 기술적으로는 우회 가능. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Student 클래스의 성적 검증(`set_grade`)처럼 값 검증이 필요한 속성에 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Getter/setter with validation (Python):
|
||||
```python
|
||||
class Person:
|
||||
def __init__(self, name, age):
|
||||
self.name = name
|
||||
self.__age = age
|
||||
def get_age(self):
|
||||
return self.__age
|
||||
def set_age(self, age):
|
||||
if age > 0:
|
||||
self.__age = age
|
||||
else:
|
||||
print("Age must be positive")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Class Properties]], [[Python Class Methods]]
|
||||
- **참조 맥락:** 데이터 보호/검증이 필요한 속성에 사용 — Python의 "private"은 관례일 뿐 강제되지 않음에 유의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Encapsulation — https://www.w3schools.com/python/python_encapsulation.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Encapsulation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: python-file-handling
|
||||
title: "Python File Handling"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["open() modes", "파이썬 파일 처리"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "file-handling", "open"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_file_handling.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python File Handling]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`open()` takes a filename and a mode string combining an action (r/a/w/x) with a format (t/b, both defaulting) — so `open("file.txt")` is silently shorthand for `open("file.txt", "rt")`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`open()`** — the key function for file access; takes filename and mode. [S1]
|
||||
- **Action modes** — `"r"` read (default, errors if missing), `"a"` append (creates if missing), `"w"` write (creates if missing, overwrites), `"x"` create (errors if it already exists). [S1]
|
||||
- **Format modes** — `"t"` text (default), `"b"` binary (e.g. images). [S1]
|
||||
- **Default shorthand** — `open("demofile.txt")` == `open("demofile.txt", "rt")`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Read mode default: `f = open("demofile.txt")` is equivalent to `f = open("demofile.txt", "rt")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 개론 뒤에 Read/Write/Delete 전용 챕터가 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
open() default mode shorthand (Python):
|
||||
```python
|
||||
f = open("demofile.txt") # same as:
|
||||
f = open("demofile.txt", "rt")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Read Files]], [[Python Write Create Files]], [[Python Delete Files]]
|
||||
- **참조 맥락:** 파일 입출력 챕터군의 개론 — open() 모드 문자를 정의.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python File Open (Handling overview) — https://www.w3schools.com/python/python_file_handling.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python File Handling" overview page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: python-for-loops
|
||||
title: "Python For Loops"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["for loop", "range()", "nested loops", "파이썬 for 반복문"]
|
||||
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", "for", "loop", "range"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_for_loops.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python For Loops]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python's for loop is an iterator over any sequence (list, tuple, dict, set, string) rather than a counter-based loop like in C-style languages, and `range(6)` yields 0 through 5, not 0 through 6 — the end value is always exclusive. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`for` loop** — iterates over a sequence (list, tuple, dictionary, set, string); no indexing variable needed. [S1]
|
||||
- **Iterates any sequence, including strings** — `for x in "banana":` loops over characters. [S1]
|
||||
- **`break`** — exits the loop early. [S1]
|
||||
- **`continue`** — skips to the next iteration. [S1]
|
||||
- **`range()`** — generates a number sequence; default starts at 0, increments by 1, end value EXCLUSIVE (`range(6)` = 0..5). [S1]
|
||||
- **`range(start, stop)`** — custom start. [S1]
|
||||
- **`range(start, stop, step)`** — custom increment. [S1]
|
||||
- **`else`** — runs when the loop finishes normally; skipped if stopped by `break` (same rule as while loops). [S1]
|
||||
- **Nested loops** — inner loop runs fully for each iteration of the outer loop. [S1]
|
||||
- **`pass`** — required placeholder for an otherwise-empty for loop body. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **break-before-vs-after-print changes output** — placing the `if x == "banana": break` check BEFORE the print vs. AFTER it changes whether "banana" itself gets printed before the loop exits — order within the loop body matters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic loop: `fruits = ["apple","banana","cherry"]; for x in fruits: print(x)`. [S1]
|
||||
- range() exclusive end: `for x in range(6): print(x)` → prints 0,1,2,3,4,5. [S1]
|
||||
- range() with start: `for x in range(2, 6):` → 2,3,4,5. [S1]
|
||||
- range() with step: `for x in range(2, 30, 3):`. [S1]
|
||||
- Nested loop: `for x in adj: for y in fruits: print(x, y)`. [S1]
|
||||
- else on natural completion: `for x in range(6): print(x) else: print("Finally finished!")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 List Comprehension 챕터에서 이 for 순회가 한 줄 표현식으로 압축된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
range() with custom start/stop/step (Python):
|
||||
```python
|
||||
for x in range(2, 30, 3):
|
||||
print(x)
|
||||
```
|
||||
Nested loop over two lists (Python):
|
||||
```python
|
||||
adj = ["red", "big", "tasty"]
|
||||
fruits = ["apple", "banana", "cherry"]
|
||||
for x in adj:
|
||||
for y in fruits:
|
||||
print(x, y)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python While Loops]], [[Python Lists Comprehension]], [[Python Range]]
|
||||
- **참조 맥락:** Python 2대 반복문 중 하나 — List Comprehension으로 압축 가능한 순회 패턴.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python For Loops — https://www.w3schools.com/python/python_for_loops.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python For Loops" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: python-frozenset
|
||||
title: "Python Frozenset"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["frozenset()", "파이썬 프로즌셋"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "frozenset"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_frozenset.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Frozenset]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
frozenset is a set that can never be modified after creation — no add/remove exists — but it still supports every non-mutating set operation (union, intersection, difference, subset/superset checks). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **frozenset** — an immutable version of a set; unique, unordered, unchangeable elements. [S1]
|
||||
- **No mutation methods** — elements cannot be added or removed after creation. [S1]
|
||||
- **All non-mutating set operations still work** — `copy()`, `difference()`, `intersection()` (`&`), `isdisjoint()`, `issubset()` (`<=`/`<`), `issuperset()` (`>=`/`>`), `symmetric_difference()` (`^`), `union()` (`|`). [S1]
|
||||
- **Creation** — `frozenset()` constructor from any iterable. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create and check type: `x = frozenset({"apple", "banana", "cherry"}); print(type(x))`. [S1]
|
||||
- All frozenset operations mirror set operations but return a new frozenset instead of a set. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 딕셔너리 키나 다른 셋의 원소로 써야 하는 등 해시 가능(hashable)한 셋이 필요할 때 사용된다(불변이므로 해시 가능). [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Create and inspect a frozenset (Python):
|
||||
```python
|
||||
x = frozenset({"apple", "banana", "cherry"})
|
||||
print(type(x)) # <class 'frozenset'>
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Sets]], [[Python Sets Join]], [[Python Tuples]]
|
||||
- **참조 맥락:** Set의 불변 버전 — Tuple이 List의 불변 버전인 것과 대칭 관계.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python frozenset — https://www.w3schools.com/python/python_frozenset.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python frozenset" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: python-functions
|
||||
title: "Python Functions"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["def keyword", "파이썬 함수"]
|
||||
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", "functions"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_functions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Functions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A function reaching `return` stops executing immediately and sends the value back; a function with no `return` statement at all simply returns `None`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Function** — a reusable block of code that only runs when called; helps avoid repetition. [S1]
|
||||
- **`def` keyword** — defines a function: `def my_function(): ...`. [S1]
|
||||
- **Function naming** — same rules as variables (start with letter/underscore, alphanumeric+underscore only, case-sensitive). [S1]
|
||||
- **`return`** — sends a value back and immediately stops execution. [S1]
|
||||
- **No return → `None`** — a function without a return statement returns `None` by default. [S1]
|
||||
- **`pass`** — required for a syntactically empty function body. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **DRY via functions** — the canonical motivating example is replacing repeated Fahrenheit→Celsius conversion code with one `fahrenheit_to_celsius()` function called multiple times. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic definition and call: `def my_function(): print("Hello from a function"); my_function()`. [S1]
|
||||
- Reusable calculation: `def fahrenheit_to_celsius(fahrenheit): return (fahrenheit - 32) * 5 / 9`. [S1]
|
||||
- Using the return value directly: `print(get_greeting())`. [S1]
|
||||
- Empty placeholder: `def my_function(): pass`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 Arguments/Scope/Lambda/Recursion/Generators 챕터 전체의 기초가 되는 개론이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reusable function replacing repeated code (Python):
|
||||
```python
|
||||
def fahrenheit_to_celsius(fahrenheit):
|
||||
return (fahrenheit - 32) * 5 / 9
|
||||
|
||||
print(fahrenheit_to_celsius(77))
|
||||
print(fahrenheit_to_celsius(95))
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Arguments]], [[Python Scope]], [[Python Lambda]]
|
||||
- **참조 맥락:** 함수 챕터군 전체의 진입점.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Functions — https://www.w3schools.com/python/python_functions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Functions" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: python-generators
|
||||
title: "Python Generators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["yield keyword", "generator expression", "파이썬 제너레이터"]
|
||||
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", "generators", "yield", "iterators"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_generators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Generators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`yield` pauses a function and remembers its state instead of terminating it like `return` — letting a generator produce values one at a time on demand (e.g. an infinite Fibonacci sequence) without ever holding the full result set in memory. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Generator** — a function that can pause and resume execution; calling it returns a generator object (an iterator) without running the body yet. [S1]
|
||||
- **`yield` keyword** — pauses the function, returns a value, and resumes from that exact point on the next call — unlike `return`, which terminates. [S1]
|
||||
- **Memory efficiency** — values are produced on-the-fly instead of building the whole collection in memory. [S1]
|
||||
- **`next()`** — manually advances a generator one step. [S1]
|
||||
- **`StopIteration`** — raised when a generator has no more values to yield. [S1]
|
||||
- **Generator expression** — `(x*x for x in range(5))` — same idea as list comprehension but with `()` instead of `[]`, producing a generator instead of a list. [S1]
|
||||
- **`send()`** — sends a value INTO a running generator at its current yield point. [S1]
|
||||
- **`close()`** — stops the generator; any `finally` block inside still runs. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Infinite generator via `while True`** — `def fibonacci(): a, b = 0, 1; while True: yield a; a, b = b, a+b` can generate the Fibonacci sequence forever, since nothing forces the whole sequence to materialize at once — only consumed as far as the caller iterates. [S1]
|
||||
- **Priming a generator before `send()`** — the generator must be advanced once with `next(gen)` before `send()` can inject a value, since `send()` resumes execution at the currently-paused `yield`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic generator: `def my_generator(): yield 1; yield 2; yield 3; for value in my_generator(): print(value)`. [S1]
|
||||
- Counting generator: `def count_up_to(n): count = 1; while count <= n: yield count; count += 1`. [S1]
|
||||
- Memory-efficient large sequence: `def large_sequence(n): for i in range(n): yield i` — a million-item generator never builds a million-item list. [S1]
|
||||
- Manual iteration: `gen = simple_gen(); print(next(gen)); print(next(gen))`. [S1]
|
||||
- Generator expression vs list comprehension: `[x*x for x in range(5)]` vs `(x*x for x in range(5))`. [S1]
|
||||
- Infinite Fibonacci generator: `def fibonacci(): a, b = 0, 1; while True: yield a; a, b = b, a + b`. [S1]
|
||||
- `send()`: `gen = echo_generator(); next(gen); gen.send("Hello")`. [S1]
|
||||
- `close()` with `finally`: generator's `finally` block runs on `.close()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대용량 데이터 순회, 무한 시퀀스 생성처럼 메모리 효율이 중요한 상황에서 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Infinite Fibonacci generator (Python):
|
||||
```python
|
||||
def fibonacci():
|
||||
a, b = 0, 1
|
||||
while True:
|
||||
yield a
|
||||
a, b = b, a + b
|
||||
|
||||
gen = fibonacci()
|
||||
for _ in range(100):
|
||||
print(next(gen))
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Iterators]], [[Python Recursion]], [[Python Lists Comprehension]]
|
||||
- **참조 맥락:** 메모리 효율적인 지연 평가(lazy evaluation) 순회의 표준 도구.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Generators — https://www.w3schools.com/python/python_generators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Generators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: python-global-variables
|
||||
title: "Python Global Variables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["global keyword", "파이썬 전역 변수"]
|
||||
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", "variables", "scope", "global"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_variables_global.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Global Variables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A variable created outside any function is global and visible everywhere, but assigning to a same-named variable inside a function creates a separate local shadow — unless the `global` keyword explicitly binds it to the outer scope. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Global variable** — created outside a function; usable both inside and outside functions. [S1]
|
||||
- **Shadowing** — creating a same-named variable inside a function makes it local to that function; the global variable of the same name is untouched. [S1]
|
||||
- **`global` keyword** — declares that a variable inside a function refers to the global scope, both for creating and for modifying it. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Local-by-default assignment** — assignment inside a function is local unless `global` is explicitly declared, which is a common source of confusion for beginners expecting the outer variable to change. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Read a global variable inside a function: `x = "awesome"; def myfunc(): print("Python is " + x); myfunc()`. [S1]
|
||||
- Shadowing (local wins inside the function, global unaffected outside): `x = "awesome"; def myfunc(): x = "fantastic"; print("Python is " + x); myfunc(); print("Python is " + x)` — prints "fantastic" then "awesome". [S1]
|
||||
- Using `global` to modify the outer variable: `x = "awesome"; def myfunc(): global x; x = "fantastic"; myfunc(); print("Python is " + x)` — prints "fantastic" after the call. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Scope 챕터에서 지역/전역 범위 규칙이 더 체계적으로 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Modify a global variable inside a function (Python):
|
||||
```python
|
||||
x = "awesome"
|
||||
def myfunc():
|
||||
global x
|
||||
x = "fantastic"
|
||||
|
||||
myfunc()
|
||||
print("Python is " + x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Variables]], [[Python Scope]], [[Python Functions]]
|
||||
- **참조 맥락:** 함수 내부/외부 변수 범위 규칙의 기초 — Scope 챕터에서 더 체계적으로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Global Variables — https://www.w3schools.com/python/python_variables_global.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Global Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-if-shorthand
|
||||
title: "Python If Shorthand"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Short Hand If", "conditional expression", "파이썬 축약 조건문"]
|
||||
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", "if", "conditional-expression"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_if_shorthand.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python If Shorthand]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A single-statement if can sit on one line (still needs the colon), and a one-line if/else conditional expression can even be chained multiple times — but the tutorial itself warns not to overuse chaining for complex logic, favoring regular if/else instead. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **One-line if** — `if a > b: print("a is greater than b")` when only one statement follows. [S1]
|
||||
- **One-line if/else (conditional expression / "ternary operator")** — `print("A") if a > b else print("B")`. [S1]
|
||||
- **Assign a value with if/else** — `bigger = a if a > b else b` — pattern: `variable = value_if_true if condition else value_if_false`. [S1]
|
||||
- **Chained conditional expressions** — `print("A") if a > b else print("=") if a == b else print("B")`. [S1]
|
||||
- **When to use** — simple conditions/actions, readability improvement, quick conditional assignment. [S1]
|
||||
- **When NOT to use** — complex conditions or multi-line logic — the source explicitly recommends regular if-else there. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- One-line if: `if a > b: print("a is greater than b")`. [S1]
|
||||
- One-line if/else: `print("A") if a > b else print("B")`. [S1]
|
||||
- Conditional assignment: `bigger = a if a > b else b`. [S1]
|
||||
- Default-value pattern: `display_name = username if username else "Guest"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 다만 "간결하지만 복잡한 조건에는 남용하지 말라"는 명시적 사용 가이드가 있음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Ternary Operator 챕터(Operators 섹션)와 사실상 동일한 개념을 조건문 관점에서 재조명한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Default-value assignment via one-line if/else (Python):
|
||||
```python
|
||||
username = ""
|
||||
display_name = username if username else "Guest"
|
||||
print("Welcome,", display_name)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Ternary Operator]], [[Python If Statement]], [[Python Else]]
|
||||
- **참조 맥락:** Ternary Operator 챕터와 개념적으로 동일 — 짧은 조건부 할당에 사용, 복잡한 로직에는 남용 금지.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Shorthand If — https://www.w3schools.com/python/python_if_shorthand.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Shorthand If" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-if-statement
|
||||
title: "Python If Statement"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Conditions", "파이썬 조건문"]
|
||||
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", "if", "conditions"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_conditions.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python If Statement]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An if statement runs its indented block only when its condition evaluates True — and a bare boolean variable (or almost any non-empty/non-zero value) can serve as the condition directly, without an explicit comparison. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Standard comparisons** — `==`, `!=`, `<`, `<=`, `>`, `>=`. [S1]
|
||||
- **`if` keyword** — evaluates a condition; executes the indented block if True, skips it if False. [S1]
|
||||
- **Indentation-defined scope** — same as elsewhere in Python; missing/inconsistent indentation raises an error. [S1]
|
||||
- **Multiple statements in one block** — all must share the same indentation level. [S1]
|
||||
- **Boolean variables used directly** — `if is_logged_in:` needs no explicit `== True`. [S1]
|
||||
- **Truthy/falsy in conditions** — 0, `""`, `None`, and empty collections are False; everything else (including negative numbers and non-empty strings like `"False"`) is True. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic if: `a = 33; b = 200; if b > a: print("b is greater than a")`. [S1]
|
||||
- Multi-statement block: `if age >= 18: print("You are an adult"); print("You can vote"); print("You have full legal rights")` (all same indentation). [S1]
|
||||
- Boolean variable directly: `is_logged_in = True; if is_logged_in: print("Welcome back!")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Booleans 챕터에서 이미 다룬 truthy/falsy 평가 규칙이 여기서 if 조건 평가로 직접 적용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Boolean variable used directly as a condition (Python):
|
||||
```python
|
||||
is_logged_in = True
|
||||
if is_logged_in:
|
||||
print("Welcome back!")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Booleans]], [[Python Elif]], [[Python Else]], [[Python Operators Comparison]]
|
||||
- **참조 맥락:** 조건문 전체의 진입점 — Elif/Else 챕터로 확장된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python If Statement — https://www.w3schools.com/python/python_conditions.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python If Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: python-inheritance
|
||||
title: "Python Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["super()", "parent class", "child class", "파이썬 상속"]
|
||||
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", "inheritance", "super"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_inheritance.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Adding a child class's own `__init__()` silently OVERRIDES the parent's — inheritance of the parent's initialization is only restored by explicitly calling `Parent.__init__(self, ...)` or, more idiomatically, `super().__init__(...)`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Parent (base) class** — the class being inherited from. [S1]
|
||||
- **Child (derived) class** — the class that inherits: `class Student(Person):`. [S1]
|
||||
- **`pass` for pure inheritance** — a child class with no additions just inherits everything as-is. [S1]
|
||||
- **Overriding `__init__()`** — adding `__init__()` to the child REMOVES the automatic inheritance of the parent's `__init__()`. [S1]
|
||||
- **Explicit parent call** — `Person.__init__(self, fname, lname)` restores the parent's initialization behavior. [S1]
|
||||
- **`super()`** — a cleaner way to call the parent's methods without naming the parent class explicitly. [S1]
|
||||
- **Adding new properties/methods** — the child class can extend beyond what it inherited (e.g. `graduationyear`, `welcome()`). [S1]
|
||||
- **Method overriding** — a child method with the same name as a parent method REPLACES the parent's version for that child. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **super() decouples child from parent's name** — using `super().__init__(...)` instead of `Person.__init__(self, ...)` means if the parent class is ever renamed, the child code doesn't need to change. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Pure inheritance: `class Student(Person): pass`. [S1]
|
||||
- Overridden init (loses parent init): `class Student(Person): def __init__(self, fname, lname): #...`. [S1]
|
||||
- Restored via explicit call: `class Student(Person): def __init__(self, fname, lname): Person.__init__(self, fname, lname)`. [S1]
|
||||
- Restored via super(): `class Student(Person): def __init__(self, fname, lname): super().__init__(fname, lname)`. [S1]
|
||||
- Extended with new property: `super().__init__(fname, lname); self.graduationyear = year`. [S1]
|
||||
- New method: `def welcome(self): print("Welcome", self.firstname, self.lastname, "to the class of", self.graduationyear)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 자식 클래스의 __init__() 추가가 부모 초기화 상속을 깨뜨린다는 점이 명시적으로 경고됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Polymorphism 챕터에서 자식 클래스가 부모 메서드를 오버라이드하는 패턴이 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
super() to extend the parent's init (Python):
|
||||
```python
|
||||
class Student(Person):
|
||||
def __init__(self, fname, lname, year):
|
||||
super().__init__(fname, lname)
|
||||
self.graduationyear = year
|
||||
|
||||
x = Student("Mike", "Olsen", 2019)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** 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 Polymorphism]]
|
||||
- **참조 맥락:** 클래스 재사용의 핵심 메커니즘 — Polymorphism에서 메서드 오버라이드로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Inheritance — https://www.w3schools.com/python/python_inheritance.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: python-inner-classes
|
||||
title: "Python Inner Classes"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["nested class", "파이썬 내부 클래스"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "inner-class", "nested-class"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_class_inner.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Inner Classes]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An inner class defined inside another does NOT automatically get access to the outer instance — the outer object must explicitly pass itself as an argument to the inner class for the inner class to reach the outer's data. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Inner class** — a class defined inside another class. [S1]
|
||||
- **Purpose** — grouping helper classes that are only used within the outer class's context, improving organization. [S1]
|
||||
- **Accessing from outside** — `outer = Outer(); inner = outer.Inner(); inner.display()`. [S1]
|
||||
- **No automatic outer access** — inner classes do NOT automatically see the outer instance; the outer instance must be passed explicitly as a parameter. [S1]
|
||||
- **Multiple inner classes** — a class can contain several inner classes (e.g. `Computer` containing `CPU` and `RAM`). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Self-referential composition** — `self.engine = self.Engine()` inside `Car.__init__` is the idiomatic way to instantiate an inner class as a property of the outer instance, giving each `Car` object its own `Engine` sub-object. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic inner class access: `outer = Outer(); inner = outer.Inner(); inner.display()`. [S1]
|
||||
- Passing outer instance for access: `class Inner: def __init__(self, outer): self.outer = outer; def display(self): print(f"Outer class name: {self.outer.name}")`; created via `inner = outer.Inner(outer)`. [S1]
|
||||
- Practical composition example: `Car` class instantiates its own `Engine` inner class as `self.engine = self.Engine()`, then `car.engine.start()` controls the sub-object. [S1]
|
||||
- Multiple inner classes: `Computer` class with `self.cpu = self.CPU()` and `self.ram = self.RAM()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Car의 Engine, Computer의 CPU/RAM처럼 "부품" 관계를 표현하는 컴포지션 패턴에 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Self-referential inner class composition (Python):
|
||||
```python
|
||||
class Car:
|
||||
def __init__(self, brand, model):
|
||||
self.brand = brand
|
||||
self.model = model
|
||||
self.engine = self.Engine()
|
||||
class Engine:
|
||||
def __init__(self):
|
||||
self.status = "Off"
|
||||
def start(self):
|
||||
self.status = "Running"
|
||||
|
||||
car = Car("Toyota", "Corolla")
|
||||
car.engine.start()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Classes]], [[Python Class Init Method]]
|
||||
- **참조 맥락:** 부품(has-a) 관계를 표현하는 클래스 구성 패턴 — OOP 챕터의 마지막 개념.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Inner Classes — https://www.w3schools.com/python/python_class_inner.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Inner Classes" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: python-intro
|
||||
title: "Python Intro"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Introduction", "What is Python", "파이썬 소개"]
|
||||
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", "basics"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_intro.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python is a readable, whitespace-scoped, interpreted language created by Guido van Rossum in 1991 that supports procedural, object-oriented, and functional styles across web, scripting, data, and math workloads. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Origin** — created by Guido van Rossum, released in 1991. [S1]
|
||||
- **Use cases** — web development (server-side), software development, mathematics, system scripting. [S1]
|
||||
- **Cross-platform** — runs on Windows, Mac, Linux, Raspberry Pi, etc. [S1]
|
||||
- **Readable syntax** — designed for readability, similar to English, influenced by mathematics. [S1]
|
||||
- **Interpreted** — runs on an interpreter, so code executes as soon as it's written, enabling fast prototyping. [S1]
|
||||
- **Multi-paradigm** — can be used procedurally, object-oriented, or functionally. [S1]
|
||||
- **Newline + indentation syntax** — uses newlines to end statements (not semicolons) and whitespace indentation to define scope (not curly braces). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Whitespace-as-syntax** — Python's reliance on indentation for scope (loops/functions/classes) is a structural difference from brace-delimited languages, not just a style preference. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Hello World: `print("Hello, World!")`. [S1]
|
||||
- Python 3 is the version used throughout this tutorial (the most recent major version). [S1]
|
||||
- Can be written in a plain text editor or an IDE (Thonny, PyCharm, NetBeans, Eclipse). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 Syntax/Variables 챕터에서 여기서 언급된 들여쓰기·줄바꿈 문법이 구체화된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Hello World (Python):
|
||||
```python
|
||||
print("Hello, World!")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Syntax]], [[Python Variables]], [[Python Comments]]
|
||||
- **참조 맥락:** Python 튜토리얼 전체의 진입점.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Introduction — https://www.w3schools.com/python/python_intro.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Introduction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,97 @@
|
||||
---
|
||||
id: python-iterators
|
||||
title: "Python Iterators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["iterator protocol", "__iter__", "__next__", "파이썬 이터레이터"]
|
||||
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", "iterators", "iterable"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_iterators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Iterators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
An iterable (list, tuple, string, etc.) is a container you can get an iterator FROM via `iter()`; a custom class becomes its own iterator by implementing `__iter__()` (return self) and `__next__()` (return the next value, raising StopIteration to terminate). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Iterator** — an object implementing the iterator protocol (`__iter__()` and `__next__()`); contains a countable number of values. [S1]
|
||||
- **Iterable vs. iterator** — lists/tuples/dicts/sets are iterable (have an `iter()` method to GET an iterator); the iterator itself is what `next()` advances. [S1]
|
||||
- **`iter()`** — returns an iterator from an iterable object. [S1]
|
||||
- **`next()`** — advances the iterator one step, returning the next value. [S1]
|
||||
- **for loop internals** — a for loop actually creates an iterator object internally and calls `next()` on each pass. [S1]
|
||||
- **Custom iterator class** — implement `__iter__()` (must return the iterator object itself) and `__next__()` (must return the next value in sequence). [S1]
|
||||
- **`StopIteration`** — raised inside `__next__()` to signal the end, preventing infinite iteration in a for loop. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Without StopIteration, custom iterators run forever in a for loop** — the example shows that a `__next__()` with no terminating condition would loop forever if placed in a `for` loop (unlike manual `next()` calls, which just stop when you stop calling them). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Get iterator from a tuple: `mytuple = ("apple","banana","cherry"); myit = iter(mytuple); print(next(myit))`. [S1]
|
||||
- Custom iterator class: [S1]
|
||||
```python
|
||||
class MyNumbers:
|
||||
def __iter__(self):
|
||||
self.a = 1
|
||||
return self
|
||||
def __next__(self):
|
||||
x = self.a
|
||||
self.a += 1
|
||||
return x
|
||||
```
|
||||
- With StopIteration to prevent infinite loop: `if self.a <= 20: ... else: raise StopIteration`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Generators 챕터의 `yield`가 이 이터레이터 프로토콜을 훨씬 간결하게 구현하는 대안이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Custom iterator with a StopIteration terminating condition (Python):
|
||||
```python
|
||||
class MyNumbers:
|
||||
def __iter__(self):
|
||||
self.a = 1
|
||||
return self
|
||||
def __next__(self):
|
||||
if self.a <= 20:
|
||||
x = self.a
|
||||
self.a += 1
|
||||
return x
|
||||
else:
|
||||
raise StopIteration
|
||||
|
||||
myclass = MyNumbers()
|
||||
myiter = iter(myclass)
|
||||
for x in myiter:
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Generators]], [[Python For Loops]], [[Python Classes]]
|
||||
- **참조 맥락:** for 루프가 내부적으로 사용하는 프로토콜 — Generators가 이를 간결화한 대안이다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Iterators — https://www.w3schools.com/python/python_iterators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Iterators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: python-json
|
||||
title: "Python JSON"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["json.loads", "json.dumps", "파이썬 제이슨"]
|
||||
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", "json"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_json.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python JSON]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`json.loads()` parses a JSON string into a Python dict, `json.dumps()` does the reverse — and the type mapping isn't 1:1: both Python `list` and `tuple` collapse to a JSON `Array`, since JSON has no separate concept of an immutable sequence. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`json` module** — Python's built-in package for working with JSON data. [S1]
|
||||
- **`json.loads(string)`** — parses a JSON string into a Python dictionary. [S1]
|
||||
- **`json.dumps(obj)`** — converts a Python object into a JSON string. [S1]
|
||||
- **Convertible Python types** — dict, list, tuple, string, int, float, True, False, None. [S1]
|
||||
- **Type mapping (Python → JSON)** — dict→Object, list→Array, tuple→Array, str→String, int/float→Number, True/False→true/false, None→null. [S1]
|
||||
- **Formatting parameters** — `indent` (pretty-print spacing), `separators` (custom item/key separators), `sort_keys` (order keys alphabetically). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **list and tuple both become Array** — the type mapping table shows JSON has no equivalent of Python's mutable/immutable sequence distinction, so information about "was this a tuple or a list" is lost on serialization. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Parse JSON: `x = '{ "name":"John", "age":30 }'; y = json.loads(x); print(y["age"])`. [S1]
|
||||
- Serialize to JSON: `x = {"name": "John", "age": 30}; y = json.dumps(x)`. [S1]
|
||||
- Pretty-print: `json.dumps(x, indent=4)`. [S1]
|
||||
- Custom separators: `json.dumps(x, indent=4, separators=(". ", " = "))`. [S1]
|
||||
- Sorted keys: `json.dumps(x, indent=4, sort_keys=True)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. list/tuple이 모두 Array로 변환된다는 점이 표에서 명시적으로 드러남. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Dictionaries Nested 챕터의 중첩 구조가 JSON 직렬화의 자연스러운 대상이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Round-trip parse and serialize (Python):
|
||||
```python
|
||||
import json
|
||||
x = '{ "name":"John", "age":30, "city":"New York"}'
|
||||
y = json.loads(x)
|
||||
print(y["age"])
|
||||
|
||||
z = json.dumps(y, indent=4, sort_keys=True)
|
||||
print(z)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Dictionaries Nested]], [[Python Modules]], [[JSON]]
|
||||
- **참조 맥락:** 데이터 교환 포맷의 표준 도구 — 중첩 딕셔너리와 자연스럽게 결합된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python JSON — https://www.w3schools.com/python/python_json.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python JSON" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: python-lambda
|
||||
title: "Python Lambda"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["lambda function", "anonymous function", "파이썬 람다"]
|
||||
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", "lambda", "map", "filter", "sorted"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lambda.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lambda]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A lambda is a small anonymous function limited to exactly one expression — its real power shows when a normal function returns a lambda closing over an outer argument, letting one function definition generate a whole family of specialized functions (like doubler/tripler). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Lambda function** — a small anonymous function; can take any number of arguments but only ONE expression. [S1]
|
||||
- **Syntax** — `lambda arguments : expression`. [S1]
|
||||
- **Function-returning-lambda pattern** — a normal `def` function can return a lambda that captures (closes over) the outer function's parameter, producing specialized functions. [S1]
|
||||
- **Common pairing with `map()`, `filter()`, `sorted()`** — lambdas are typically used as the throwaway function argument to these built-ins. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Lambda-as-function-factory** — `def myfunc(n): return lambda a: a * n` demonstrates using a lambda's closure over `n` to generate `mydoubler = myfunc(2)` and `mytripler = myfunc(3)` from ONE function definition. [S1]
|
||||
- **`key=` argument idiom** — `sorted(list, key=lambda x: ...)` is the standard way to customize sort order without writing a named function. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic lambda: `x = lambda a : a + 10; print(x(5))`. [S1]
|
||||
- Multi-argument lambda: `x = lambda a, b, c : a + b + c`. [S1]
|
||||
- Function factory: `def myfunc(n): return lambda a : a * n; mydoubler = myfunc(2); mytripler = myfunc(3)`. [S1]
|
||||
- With `map()`: `doubled = list(map(lambda x: x * 2, numbers))`. [S1]
|
||||
- With `filter()`: `odd_numbers = list(filter(lambda x: x % 2 != 0, numbers))`. [S1]
|
||||
- With `sorted()` key: `sorted_students = sorted(students, key=lambda x: x[1])` (sort tuples by second element). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Sort Lists 챕터의 `key=` 커스텀 정렬이 여기서 람다로 완성된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Lambda as a sort key (Python):
|
||||
```python
|
||||
students = [("Emil", 25), ("Tobias", 22), ("Linus", 28)]
|
||||
sorted_students = sorted(students, key=lambda x: x[1])
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Functions]], [[Python Lists Sort]], [[Python Lists Comprehension]]
|
||||
- **참조 맥락:** 짧은 익명 함수가 필요한 곳(map/filter/sorted의 key)에서 표준적으로 쓰인다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Lambda — https://www.w3schools.com/python/python_lambda.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Lambda" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: python-lists
|
||||
title: "Python Lists"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 리스트"]
|
||||
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", "lists"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Lists are one of Python's four collection types — ordered, changeable, duplicate-allowing, and mixed-type-capable — distinguished from Tuple (unchangeable), Set (unordered, no duplicates), and Dictionary (key-value, no duplicates). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **List** — stores multiple items in a single variable; created with square brackets. [S1]
|
||||
- **Ordered** — items have a defined order that persists (new items go to the end) unless a method explicitly reorders them. [S1]
|
||||
- **Changeable (mutable)** — items can be changed, added, or removed after creation. [S1]
|
||||
- **Allows duplicates** — since lists are indexed, identical values can appear multiple times. [S1]
|
||||
- **Mixed types** — a single list can hold strings, ints, booleans together. [S1]
|
||||
- **`list()` constructor** — alternative creation syntax: `list(("apple", "banana", "cherry"))`. [S1]
|
||||
- **Four collection types compared** — List (ordered, changeable, duplicates OK), Tuple (ordered, unchangeable, duplicates OK), Set (unordered, effectively unchangeable, no duplicates), Dictionary (ordered since 3.7, changeable, no duplicate keys). [S1]
|
||||
|
||||
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
||||
|
||||
| 항목 (Option) | 장점 | 단점 | 언제 선택 |
|
||||
|---|---|---|---|
|
||||
| **List** | 순서 보장, 변경 가능, 중복 허용 | Set 대비 멤버십 검사가 느림 | 순서가 중요하고 자주 수정되는 컬렉션 |
|
||||
| **Tuple** | 불변이라 안전, 해시 가능 | 생성 후 수정 불가 | 변경되면 안 되는 고정 데이터 |
|
||||
| **Set** | 빠른 멤버십 검사, 중복 자동 제거 | 순서 없음, 인덱싱 불가 | 고유값 집합 연산이 필요할 때 |
|
||||
| **Dictionary** | 키로 빠른 조회, 3.7+부터 순서 보장 | 중복 키 불가 | 이름-값 매핑이 필요할 때 |
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic creation: `thislist = ["apple", "banana", "cherry"]`. [S1]
|
||||
- Duplicates allowed: `thislist = ["apple", "banana", "cherry", "apple", "cherry"]`. [S1]
|
||||
- Mixed types: `list1 = ["abc", 34, True, 40, "male"]`. [S1]
|
||||
- Length: `print(len(thislist))`. [S1]
|
||||
- Type check: `print(type(mylist)) # <class 'list'>`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **딕셔너리 순서 보장은 버전에 따라 다름**: Python 3.7+부터는 순서가 보장되지만, 3.6 이전에는 순서가 보장되지 않았다는 점이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 Access/Change/Add/Remove/Loop/Sort/Copy/Join/Methods 챕터 전체의 기초가 되는 개론 문서다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic list creation and type check (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
print(type(thislist)) # <class 'list'>
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Tuples]], [[Python Sets]], [[Python Dictionaries]], [[Python Data Types]]
|
||||
- **참조 맥락:** Python 4대 컬렉션 타입 중 하나 — Tuple/Set/Dictionary와의 차이를 이해하는 것이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Lists — https://www.w3schools.com/python/python_lists.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-lists-access
|
||||
title: "Python Lists Access"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Access List Items", "파이썬 리스트 접근"]
|
||||
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", "lists", "indexing", "slicing"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_access.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Access]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
List items are accessed by 0-based index (positive from the start, negative from the end), and range slicing returns a NEW list of items from a start index (inclusive) to an end index (exclusive). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Positive indexing** — `thislist[1]` gets the second item (0-indexed). [S1]
|
||||
- **Negative indexing** — `thislist[-1]` gets the last item, `-2` the second-last, etc. [S1]
|
||||
- **Range slicing** — `thislist[2:5]` returns a new list from index 2 (inclusive) to 5 (exclusive). [S1]
|
||||
- **Omit start/end** — `thislist[:4]` starts at the beginning; `thislist[2:]` goes to the end. [S1]
|
||||
- **Negative range slicing** — `thislist[-4:-1]` slices using negative bounds. [S1]
|
||||
- **Membership check** — `"apple" in thislist` tests presence. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Positive index: `thislist = ["apple", "banana", "cherry"]; print(thislist[1])`. [S1]
|
||||
- Negative index: `print(thislist[-1])`. [S1]
|
||||
- Range slice: `thislist[2:5]`. [S1]
|
||||
- Negative range: `thislist[-4:-1]`. [S1]
|
||||
- Membership: `if "apple" in thislist: print("Yes, 'apple' is in the fruits list")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 슬라이싱 문법은 Change List Items 챕터에서 값 대입에도 그대로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Range slicing (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
|
||||
print(thislist[2:5]) # ['cherry', 'orange', 'kiwi']
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists]], [[Python Lists Change]], [[Python Strings Slicing]]
|
||||
- **참조 맥락:** 리스트 인덱싱/슬라이싱의 기초 — Change List Items에서 대입 문법으로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Access List Items — https://www.w3schools.com/python/python_lists_access.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Access List Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-lists-add
|
||||
title: "Python Lists Add"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Add List Items", "파이썬 리스트 추가"]
|
||||
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", "lists", "append", "extend"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_add.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Add]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
append() adds one item to the end, insert() adds one item at a specific position, and extend() adds every element of ANY iterable (not just lists) to the end. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`append(item)`** — adds a single item to the end of the list. [S1]
|
||||
- **`insert(index, item)`** — adds a single item at a specific index. [S1]
|
||||
- **`extend(iterable)`** — appends each element of another iterable to the end. [S1]
|
||||
- **`extend()` accepts any iterable** — not just lists; tuples, sets, dictionaries also work. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Append: `thislist.append("orange")`. [S1]
|
||||
- Insert at position: `thislist.insert(1, "orange")`. [S1]
|
||||
- Extend with another list: `thislist.extend(tropical)`. [S1]
|
||||
- Extend with a tuple: `thistuple = ("kiwi", "orange"); thislist.extend(thistuple)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — extend()가 튜플/셋/딕셔너리도 받아들인다는 점은 이후 Join Lists 챕터의 리스트 병합 방법 중 하나로 다시 등장한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
extend() with a non-list iterable (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
thistuple = ("kiwi", "orange")
|
||||
thislist.extend(thistuple)
|
||||
print(thislist)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Change]], [[Python Lists Join]], [[Python Lists Remove]]
|
||||
- **참조 맥락:** 리스트에 항목을 추가하는 3가지 방법 — Join Lists 챕터에서 extend()가 리스트 병합 방법으로 재등장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Add List Items — https://www.w3schools.com/python/python_lists_add.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Add List Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-lists-change
|
||||
title: "Python Lists Change"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Change List Items", "파이썬 리스트 수정"]
|
||||
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", "lists", "mutation"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_change.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Change]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Assigning a differently-sized list to an index range replaces exactly those slots with the new items, automatically growing or shrinking the list to fit — the count of items doesn't need to match the range's original length. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Single item change** — `thislist[1] = "blackcurrant"` replaces one item by index. [S1]
|
||||
- **Range replacement** — `thislist[1:3] = ["blackcurrant", "watermelon"]` replaces a slice with new values. [S1]
|
||||
- **Insert-more-than-replaced** — assigning more items than the slice covers grows the list, shifting remaining items. [S1]
|
||||
- **Insert-fewer-than-replaced** — assigning fewer items than the slice covers shrinks the list. [S1]
|
||||
- **`insert()` method** — `thislist.insert(2, "watermelon")` inserts without replacing anything, at the given index. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single replacement: `thislist[1] = "blackcurrant"`. [S1]
|
||||
- Range replacement (same count): `thislist[1:3] = ["blackcurrant", "watermelon"]`. [S1]
|
||||
- Range replacement (more items, list grows): `thislist[1:2] = ["blackcurrant", "watermelon"]`. [S1]
|
||||
- Range replacement (fewer items, list shrinks): `thislist[1:3] = ["watermelon"]`. [S1]
|
||||
- Pure insert (no replacement): `thislist.insert(2, "watermelon")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 슬라이스 대입으로 리스트 길이를 자동 조정하는 패턴은 Add/Remove 챕터와 함께 이해해야 완전해진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Slice assignment that grows the list (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
thislist[1:2] = ["blackcurrant", "watermelon"]
|
||||
print(thislist) # ['apple', 'blackcurrant', 'watermelon', 'cherry']
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Access]], [[Python Lists Add]], [[Python Lists Remove]]
|
||||
- **참조 맥락:** 리스트 항목을 직접 수정할 때 사용 — insert()와 함께 Add List Items로 이어진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Change List Items — https://www.w3schools.com/python/python_lists_change.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Change List Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: python-lists-comprehension
|
||||
title: "Python Lists Comprehension"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["List Comprehension", "파이썬 리스트 컴프리헨션"]
|
||||
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", "lists", "comprehension"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_comprehension.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Comprehension]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`[expression for item in iterable if condition]` collapses a filter-and-transform for-loop into one line, where the condition filters which items pass through and the expression can transform (not just pass through) each surviving item. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Purpose** — shorter syntax for creating a new list based on an existing iterable. [S1]
|
||||
- **Syntax** — `newlist = [expression for item in iterable if condition == True]`. [S1]
|
||||
- **Original unchanged** — always returns a NEW list; the source iterable is untouched. [S1]
|
||||
- **Condition is optional** — can be omitted entirely, in which case every item passes through. [S1]
|
||||
- **Iterable can be anything iterable** — list, tuple, set, `range()`, etc. [S1]
|
||||
- **Expression can transform, not just pass through** — e.g. `.upper()` each item, or replace items with a constant, or conditionally substitute values. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Filter vs. transform via expression** — the `if condition` filters WHICH items are included; a conditional INSIDE the expression itself (`x if x != "banana" else "orange"`) instead transforms the VALUE of included items — two different jobs that look similar but aren't. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Traditional for-loop equivalent: [S1]
|
||||
```python
|
||||
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
|
||||
newlist = []
|
||||
for x in fruits:
|
||||
if "a" in x:
|
||||
newlist.append(x)
|
||||
```
|
||||
- Same result via comprehension: `newlist = [x for x in fruits if "a" in x]`. [S1]
|
||||
- No condition (copy-transform only): `newlist = [x for x in fruits]`. [S1]
|
||||
- Iterable from `range()`: `newlist = [x for x in range(10) if x < 5]`. [S1]
|
||||
- Transform expression (uppercase): `newlist = [x.upper() for x in fruits]`. [S1]
|
||||
- Transform expression (conditional substitution, not filtering): `newlist = [x if x != "banana" else "orange" for x in fruits]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Loop Lists 챕터에서 예고된 리스트 컴프리헨션이 여기서 필터/변환 문법으로 완성된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Filter-and-transform comprehension (Python):
|
||||
```python
|
||||
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
|
||||
newlist = [x.upper() for x in fruits if "a" in x]
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Loop]], [[Python Lambda]], [[Python For Loops]]
|
||||
- **참조 맥락:** 필터링+변환을 한 줄로 표현하는 Python 관용구 — 조건은 필터, 표현식은 변형이라는 역할 구분이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - List Comprehension — https://www.w3schools.com/python/python_lists_comprehension.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - List Comprehension" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: python-lists-copy
|
||||
title: "Python Lists Copy"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Copy Lists", "파이썬 리스트 복사"]
|
||||
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", "lists", "copy", "reference"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_copy.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Copy]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`list2 = list1` does NOT copy a list — it creates a second reference to the same object, so changes through either name affect both; `copy()`, `list()`, or the `[:]` slice operator are the three real ways to get an independent copy. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Reference trap** — `list2 = list1` makes `list2` a reference to `list1`, not an independent copy; mutating one mutates both. [S1]
|
||||
- **`copy()` method** — `mylist = thislist.copy()` makes a true independent copy. [S1]
|
||||
- **`list()` constructor** — `mylist = list(thislist)` is another way to copy. [S1]
|
||||
- **Slice operator `[:]`** — `mylist = thislist[:]` also creates an independent copy. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **This is the same footgun as [[Python Operators Identity]]'s `is` vs `==`** — `list2 = list1` creates an alias (same object, `is` True), which is exactly the identity-vs-equality distinction covered earlier. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Copy via method: `mylist = thislist.copy()`. [S1]
|
||||
- Copy via constructor: `mylist = list(thislist)`. [S1]
|
||||
- Copy via full slice: `mylist = thislist[:]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 원본을 보존하면서 리스트를 수정해야 하는 모든 함수/알고리즘에서 재사용되는 필수 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Three ways to make an independent copy (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
mylist = thislist.copy() # method
|
||||
mylist = list(thislist) # constructor
|
||||
mylist = thislist[:] # slice
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators Identity]], [[Python Lists]], [[Python Dictionaries Copy]]
|
||||
- **참조 맥락:** 참조(reference)와 복사(copy)의 차이를 이해해야 하는 핵심 챕터 — 딕셔너리 복사에도 동일한 함정이 존재.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Copy Lists — https://www.w3schools.com/python/python_lists_copy.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Copy Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: python-lists-join
|
||||
title: "Python Lists Join"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Join Lists", "파이썬 리스트 병합"]
|
||||
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", "lists", "join", "concatenation"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_join.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Two lists can be joined three ways — the `+` operator (creates a new combined list), a manual for-loop with append(), or the extend() method — with `+` being the most direct for simple concatenation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+` operator** — `list3 = list1 + list2` concatenates into a new list. [S1]
|
||||
- **Manual append loop** — `for x in list2: list1.append(x)` appends each item individually. [S1]
|
||||
- **`extend()` method** — `list1.extend(list2)` adds all of list2's elements to list1 in place. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Plus operator: `list1 = ["a","b","c"]; list2 = [1,2,3]; list3 = list1 + list2`. [S1]
|
||||
- Manual append loop: `for x in list2: list1.append(x)`. [S1]
|
||||
- Extend method: `list1.extend(list2)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — extend()는 Add List Items 챕터에서 이미 소개된 것과 동일한 메서드이며, 여기서는 "두 리스트 병합"이라는 목적으로 재조명된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Join with the + operator (Python):
|
||||
```python
|
||||
list1 = ["a", "b", "c"]
|
||||
list2 = [1, 2, 3]
|
||||
list3 = list1 + list2
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Add]], [[Python Lists]]
|
||||
- **참조 맥락:** 두 리스트를 하나로 합치는 3가지 방법 — Add List Items의 extend()와 동일 메서드가 재사용됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Join Lists — https://www.w3schools.com/python/python_lists_join.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Join Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: python-lists-loop
|
||||
title: "Python Lists Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Loop Lists", "파이썬 리스트 반복"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "lists", "loop"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_loop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A list can be looped four ways — direct for-in, index-based via range(len(...)), a while loop with a manual counter, or a one-line list comprehension — each trading off simplicity against index access. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Direct for loop** — `for x in thislist: print(x)` — simplest, but no index access. [S1]
|
||||
- **Index-based for loop** — `for i in range(len(thislist)): print(thislist[i])` — gives index access. [S1]
|
||||
- **While loop** — manual counter incremented each iteration, same effect as index-based for. [S1]
|
||||
- **List comprehension as loop shorthand** — `[print(x) for x in thislist]` is the shortest syntax for a simple per-item action. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Direct loop: `for x in thislist: print(x)`. [S1]
|
||||
- Index-based loop: `for i in range(len(thislist)): print(thislist[i])`. [S1]
|
||||
- While loop: `i = 0; while i < len(thislist): print(thislist[i]); i = i + 1`. [S1]
|
||||
- Comprehension-as-loop: `[print(x) for x in thislist]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터 List Comprehension에서 리스트 컴프리헨션이 "새 리스트 생성" 목적으로 본격 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Index-based loop (Python):
|
||||
```python
|
||||
thislist = ["apple", "banana", "cherry"]
|
||||
for i in range(len(thislist)):
|
||||
print(thislist[i])
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python For Loops]], [[Python While Loops]], [[Python Lists Comprehension]]
|
||||
- **참조 맥락:** 리스트 순회의 4가지 방법 — List Comprehension 챕터에서 새 리스트 생성용으로 심화.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Loop Lists — https://www.w3schools.com/python/python_lists_loop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Loop Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: python-lists-methods
|
||||
title: "Python Lists Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["List Methods", "파이썬 리스트 메서드"]
|
||||
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", "lists", "methods"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_methods.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Methods]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python's list type has 11 built-in methods covering the full add/remove/inspect/reorder lifecycle, consolidating everything taught across the Access/Change/Add/Remove/Sort/Copy/Join chapters into one reference table. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`append()`** — adds an element at the end. [S1]
|
||||
- **`clear()`** — removes all elements. [S1]
|
||||
- **`copy()`** — returns a copy of the list. [S1]
|
||||
- **`count()`** — returns the number of elements with a specified value. [S1]
|
||||
- **`extend()`** — adds elements of an iterable to the end. [S1]
|
||||
- **`index()`** — returns the index of the first element with a specified value. [S1]
|
||||
- **`insert()`** — adds an element at a specified position. [S1]
|
||||
- **`pop()`** — removes the element at a specified position. [S1]
|
||||
- **`remove()`** — removes the item with a specified value. [S1]
|
||||
- **`reverse()`** — reverses the order of the list. [S1]
|
||||
- **`sort()`** — sorts the list. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 이전 챕터들(Access/Change/Add/Remove/Loop/Sort/Copy/Join)에서 개별적으로 다룬 리스트 메서드 전체를 하나의 표로 정리한 레퍼런스 챕터다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 리스트 메서드를 빠르게 찾아볼 때 참조하는 요약 레퍼런스다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 실행 코드 예시 없음 (메서드 이름/설명 표 위주의 레퍼런스형 챕터).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists]], [[Python Lists Add]], [[Python Lists Remove]], [[Python Lists Sort]]
|
||||
- **참조 맥락:** 리스트 메서드 전체 요약 — 필요한 메서드를 찾을 때 참조.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - List Methods — https://www.w3schools.com/python/python_lists_methods.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - List Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: python-lists-remove
|
||||
title: "Python Lists Remove"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Remove List Items", "파이썬 리스트 삭제"]
|
||||
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", "lists", "remove", "pop", "del"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_remove.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Remove]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python offers four distinct ways to shrink a list — remove() by value, pop() by index (or last item if omitted), del by index or to delete the whole variable, and clear() to empty it while keeping the list object. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`remove(value)`** — removes the first occurrence of the specified value. [S1]
|
||||
- **`pop(index)`** — removes the item at the given index; omitting the index removes the last item. [S1]
|
||||
- **`del list[index]`** — removes the item at the given index (keyword, not a method). [S1]
|
||||
- **`del list`** — deletes the entire list variable. [S1]
|
||||
- **`clear()`** — empties the list's contents; the list object itself still exists. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **First-occurrence-only removal** — `remove()` on a value present multiple times only deletes the first match, leaving duplicates intact. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Remove by value: `thislist.remove("banana")`. [S1]
|
||||
- Pop by index: `thislist.pop(1)`. [S1]
|
||||
- Pop last (no index): `thislist.pop()`. [S1]
|
||||
- Del by index: `del thislist[0]`. [S1]
|
||||
- Del entire list: `del thislist`. [S1]
|
||||
- Clear contents: `thislist.clear()` → `[]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — `del`은 리스트 외에도 변수 자체를 지우는 범용 키워드라는 점에서 다른 메서드들과 성격이 다르다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Four removal methods (Python):
|
||||
```python
|
||||
thislist.remove("banana") # by value, first match
|
||||
thislist.pop(1) # by index
|
||||
del thislist[0] # by index (keyword)
|
||||
thislist.clear() # empty, keep the list object
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists Add]], [[Python Lists Change]], [[Python Lists Methods]]
|
||||
- **참조 맥락:** 리스트에서 항목을 제거하는 4가지 방법 — 어떤 방식이 값 기준인지 인덱스 기준인지 구분해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Remove List Items — https://www.w3schools.com/python/python_lists_remove.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Remove List Items" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: python-lists-sort
|
||||
title: "Python Lists Sort"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Sort Lists", "파이썬 리스트 정렬"]
|
||||
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", "lists", "sort"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_lists_sort.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Lists Sort]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
sort() is case-sensitive by default (capitals sort before lowercase), but passing a key function like `str.lower` or a custom function fixes that, while reverse() simply flips the current order without re-sorting. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`sort()`** — sorts the list in place, alphanumerically ascending by default. [S1]
|
||||
- **`reverse=True` argument** — sorts descending. [S1]
|
||||
- **`key=function` argument** — customizes the sort criterion; the function returns a number used for ordering (lowest first). [S1]
|
||||
- **Case sensitivity** — default sort puts all capital letters before lowercase letters. [S1]
|
||||
- **`key=str.lower`** — a built-in function used as the key for case-insensitive sorting. [S1]
|
||||
- **`reverse()`** — reverses the current order of the list (not the same as descending sort). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Custom sort via distance function** — `key = myfunc` where `myfunc` returns `abs(n - 50)` sorts numbers by closeness to 50 rather than by raw value — showing `key` can encode arbitrary sort logic. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Ascending (default): `thislist.sort()`. [S1]
|
||||
- Descending: `thislist.sort(reverse = True)`. [S1]
|
||||
- Custom key function: `def myfunc(n): return abs(n - 50); thislist.sort(key = myfunc)`. [S1]
|
||||
- Case-insensitive: `thislist.sort(key = str.lower)`. [S1]
|
||||
- Reverse (not sort): `thislist.reverse()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대소문자 무시 정렬은 실무에서 텍스트 정렬 시 흔히 필요한 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Case-insensitive and custom-key sorting (Python):
|
||||
```python
|
||||
thislist = ["banana", "Orange", "Kiwi", "cherry"]
|
||||
thislist.sort(key=str.lower)
|
||||
|
||||
def myfunc(n):
|
||||
return abs(n - 50)
|
||||
numlist = [100, 50, 65, 82, 23]
|
||||
numlist.sort(key=myfunc)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Lists]], [[Python Lambda]], [[Python Functions]]
|
||||
- **참조 맥락:** 리스트 정렬 커스터마이징 — key 함수 개념은 이후 Lambda 챕터와도 연결된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Sort Lists — https://www.w3schools.com/python/python_lists_sort.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Sort Lists" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: python-match
|
||||
title: "Python Match"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["match statement", "structural pattern matching", "파이썬 매치 문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "match", "switch"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_match.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Match]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
match (Python's switch-like statement) selects one block by comparing a value against each `case`, with `_` as a catch-all default, `|` to combine multiple values in one case, and an optional `if` guard for extra conditions. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`match` statement** — replaces long if/elif chains; selects one of many code blocks. [S1]
|
||||
- **Syntax** — `match expression: case x: ... case y: ... case z: ...`. [S1]
|
||||
- **Evaluation** — the expression is evaluated once, then compared against each case in order. [S1]
|
||||
- **`_` default case** — matches anything; must be placed LAST to act as a true default (since it always matches). [S1]
|
||||
- **`|` combine values** — `case 1 | 2 | 3:` matches any of the listed values in one case. [S1]
|
||||
- **`if` guard** — `case 1 | 2 | 3 if month == 4:` adds an extra condition to a case. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`_` must be last** — since `_` always matches, placing it before other cases would make those cases unreachable — its position enforces its role as fallback. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic match: `match day: case 1: print("Monday") ... case 7: print("Sunday")`. [S1]
|
||||
- Default case: `match day: case 6: ... case 7: ... case _: print("Looking forward to the Weekend")`. [S1]
|
||||
- Combined values: `case 1 | 2 | 3 | 4 | 5: print("Today is a weekday")`. [S1]
|
||||
- Guarded case: `case 1 | 2 | 3 | 4 | 5 if month == 4: print("A weekday in April")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 요일/상태 판별처럼 elif 체인이 길어질 상황에서 대안으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combined values with a default case (Python):
|
||||
```python
|
||||
match day:
|
||||
case 1 | 2 | 3 | 4 | 5:
|
||||
print("Today is a weekday")
|
||||
case 6 | 7:
|
||||
print("I love weekends!")
|
||||
case _:
|
||||
print("Unknown day")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Elif]], [[Python If Statement]]
|
||||
- **참조 맥락:** elif 체인이 길어질 때의 대안 — 다른 언어의 switch 문에 대응.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Match — https://www.w3schools.com/python/python_match.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Match" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: python-math
|
||||
title: "Python Math"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["math module", "파이썬 수학"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "math"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_math.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Math]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Basic math (min/max/abs/pow) needs no import at all, but everything beyond that — sqrt, ceil, floor, pi — requires `import math`, marking a clear line between built-in functions and the standard math module. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Built-in, no-import functions** — `min()`, `max()`, `abs()`, `pow(x, y)`. [S1]
|
||||
- **`math` module** — extends built-in math capability; must `import math`. [S1]
|
||||
- **`math.sqrt()`** — square root. [S1]
|
||||
- **`math.ceil()` / `math.floor()`** — round up / round down to nearest integer. [S1]
|
||||
- **`math.pi`** — the constant π. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- No-import functions: `min(5,10,25)`, `max(5,10,25)`, `abs(-7.25)`, `pow(4,3)`. [S1]
|
||||
- Square root: `import math; x = math.sqrt(64)`. [S1]
|
||||
- Ceil/floor: `x = math.ceil(1.4) # 2; y = math.floor(1.4) # 1`. [S1]
|
||||
- Pi constant: `x = math.pi`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python User Input 챕터에서 `math.sqrt(float(x))`처럼 사용자 입력값 계산에 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
No-import vs. math-module functions (Python):
|
||||
```python
|
||||
x = pow(4, 3) # no import needed
|
||||
|
||||
import math
|
||||
y = math.sqrt(64)
|
||||
z = math.ceil(1.4) # 2
|
||||
w = math.floor(1.4) # 1
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Numbers]], [[Python Modules]], [[Python User Input]]
|
||||
- **참조 맥락:** 수학 계산의 기본 도구 — User Input 챕터의 제곱근 계산에서 재사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Math — https://www.w3schools.com/python/python_math.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Math" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: python-memoryview
|
||||
title: "Python Memoryview"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["memoryview type", "파이썬 메모리뷰"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "memoryview", "binary"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_memoryview.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Memoryview]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
memoryview exposes a buffer-protocol object's raw data without copying it — slicing and, if the underlying object is mutable, writing through the view directly modifies the original buffer. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **memoryview** — a Python-level view of an object's internal data (any object supporting the buffer protocol, like bytes/bytearray), without copying. [S1]
|
||||
- **Creation** — wrap a bytes-like object with `memoryview()`. [S1]
|
||||
- **Zero-copy access** — reading/slicing accesses the underlying buffer directly. [S1]
|
||||
- **Write-through (mutable underlying object)** — assigning through the memoryview modifies the original bytearray in place. [S1]
|
||||
- **`.tobytes()`** — converts a view (or slice of it) into an actual bytes copy. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **View vs. copy distinction** — a memoryview is a lens onto existing memory, not a new object; `.tobytes()` is the explicit boundary where you opt into copying. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create from bytes: `x = memoryview(bytes(5)); print(type(x))`. [S1]
|
||||
- Slice and write-through on a mutable buffer: `b = bytearray(b"abcdef"); v = memoryview(b); print(v[1:4].tobytes()) # b'bcd'; v[0] = ord('Z'); print(b) # bytearray(b"Zbcdef")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대용량 바이너리 데이터를 복사 없이 다뤄야 하는 성능 민감 상황에서 쓰이는 개념이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Write-through a mutable buffer via memoryview (Python):
|
||||
```python
|
||||
b = bytearray(b"abcdef")
|
||||
v = memoryview(b)
|
||||
v[0] = ord('Z')
|
||||
print(b) # bytearray(b"Zbcdef")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Bytes]], [[Python Bytearray]]
|
||||
- **참조 맥락:** 복사 없이 바이너리 버퍼를 조회·수정해야 하는 성능 민감 상황에서 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python memoryview — https://www.w3schools.com/python/python_memoryview.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python memoryview" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: python-modules
|
||||
title: "Python Modules"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["import statement", "파이썬 모듈"]
|
||||
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", "modules", "import"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_modules.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Modules]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A module is just a `.py` file, imported via `import` and accessed with dot notation (`module.function`) — except when using `from module import x`, which drops the module prefix entirely. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Module** — a code library; a file containing functions (and variables) meant to be reused. [S1]
|
||||
- **Creating a module** — just save code in a `.py` file. [S1]
|
||||
- **Using a module** — `import mymodule; mymodule.greeting("Jonathan")`. [S1]
|
||||
- **Module variables** — modules can hold variables of any type (dicts, lists, objects), accessed the same dot-notation way. [S1]
|
||||
- **Aliasing** — `import mymodule as mx` renames the module reference. [S1]
|
||||
- **Built-in modules** — Python ships several ready to import, e.g. `platform`. [S1]
|
||||
- **`dir()`** — lists all names (functions/variables) defined in a module, including custom ones. [S1]
|
||||
- **`from ... import ...`** — imports only specific parts; when used, do NOT prefix with the module name at the call site. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **`from import` changes the access syntax** — `import mymodule; mymodule.person1` vs. `from mymodule import person1; person1` — mixing these two styles by prefixing after a `from import` is a common beginner mistake. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create a module (mymodule.py): `def greeting(name): print("Hello, " + name)`. [S1]
|
||||
- Use it: `import mymodule; mymodule.greeting("Jonathan")`. [S1]
|
||||
- Alias: `import mymodule as mx; a = mx.person1["age"]`. [S1]
|
||||
- Built-in module: `import platform; x = platform.system()`. [S1]
|
||||
- List module contents: `import platform; x = dir(platform)`. [S1]
|
||||
- Partial import: `from mymodule import person1; print(person1["age"])`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python PIP 챕터에서 서드파티 모듈을 설치해 동일한 import 방식으로 사용하는 과정으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Aliased import (Python):
|
||||
```python
|
||||
import mymodule as mx
|
||||
a = mx.person1["age"]
|
||||
print(a)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python PIP]], [[Python Math]], [[Python JSON]]
|
||||
- **참조 맥락:** 코드 재사용의 기본 단위 — 이후 math/json/re 등 표준 모듈 챕터의 전제.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Modules — https://www.w3schools.com/python/python_modules.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Modules" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: python-mongodb-create-collection
|
||||
title: "Python MongoDB Create Collection"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["collection", "파이썬 MongoDB 컬렉션 생성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mongodb", "w3schools", "collection", "pymongo"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_create_collection.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Create Collection]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A MongoDB collection maps conceptually to a SQL table, but exhibits the same lazy-creation behavior as the database itself — it isn't created until a document is actually inserted into it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Collection** — MongoDB's equivalent of a SQL table. [S1]
|
||||
- **`mydb["collectionname"]`** — references (but doesn't yet create) a collection. [S1]
|
||||
- **Lazy creation** — the collection isn't created until a document is inserted. [S1]
|
||||
- **`mydb.list_collection_names()`** — lists all collections in a database, for existence checks. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Reference a collection: `mycol = mydb["customers"]`. [S1]
|
||||
- List collections: `print(mydb.list_collection_names())`. [S1]
|
||||
- Check specific collection: `collist = mydb.list_collection_names(); if "customers" in collist: print("The collection exists.")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Insert Document 챕터에서 실제 문서를 삽입해야 컬렉션이 진짜로 생성된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Reference and check a collection (Python):
|
||||
```python
|
||||
mycol = mydb["customers"]
|
||||
collist = mydb.list_collection_names()
|
||||
if "customers" in collist:
|
||||
print("The collection exists.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Create DB]], [[Python MongoDB Insert]], [[SQL Create Table]]
|
||||
- **참조 맥락:** SQL 테이블에 대응하는 MongoDB 컬렉션 — 마찬가지로 지연 생성됨.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Create Collection — https://www.w3schools.com/python/python_mongodb_create_collection.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Create Collection" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-mongodb-create-db
|
||||
title: "Python MongoDB Create DB"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pymongo", "MongoClient", "파이썬 MongoDB 데이터베이스 생성"]
|
||||
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", "mongodb", "w3schools", "database", "pymongo"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_create_db.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Create DB]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike MySQL's explicit `CREATE DATABASE`, MongoDB is lazy — `myclient["mydatabase"]` doesn't actually create anything on the server until a collection with at least one document is inserted into it. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`pymongo.MongoClient(url)`** — connects to a MongoDB server. [S1]
|
||||
- **`myclient["dbname"]`** — references (but does not yet create) a database. [S1]
|
||||
- **Lazy creation** — MongoDB doesn't create the database until a collection with content exists. [S1]
|
||||
- **`myclient.list_database_names()`** — lists all databases, used to check existence. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Content-triggered creation is the opposite of SQL** — where `CREATE DATABASE` is an explicit imperative command in SQL, MongoDB treats database existence as a side effect of inserting data, not a standalone action. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Connect and reference a database: `myclient = pymongo.MongoClient("mongodb://localhost:27017/"); mydb = myclient["mydatabase"]`. [S1]
|
||||
- List all databases: `print(myclient.list_database_names())`. [S1]
|
||||
- Check specific database: `dblist = myclient.list_database_names(); if "mydatabase" in dblist: print("The database exists.")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **SQL과의 근본적 차이**: SQL은 `CREATE DATABASE`로 즉시 생성되지만, MongoDB는 컬렉션+문서가 실제로 삽입되기 전까지 데이터베이스가 생성되지 않는다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 다음 챕터(Create Collection, Insert)를 완료해야 실제로 데이터베이스가 존재하게 된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Connect to MongoDB and reference a database (Python):
|
||||
```python
|
||||
import pymongo
|
||||
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
|
||||
mydb = myclient["mydatabase"]
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Create Collection]], [[Python MySQL Create Database]]
|
||||
- **참조 맥락:** MongoDB의 지연 생성(lazy creation) 특성 — MySQL의 즉시 생성 방식과 대비.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Create Database — https://www.w3schools.com/python/python_mongodb_create_db.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Create Database" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-mongodb-delete
|
||||
title: "Python MongoDB Delete"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["delete_one()", "delete_many()", "파이썬 MongoDB 삭제"]
|
||||
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", "mongodb", "w3schools", "delete"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_delete.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Delete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`delete_many({})` with an EMPTY query object deletes every document in the collection — the empty-filter-means-everything convention is the same footgun as SQL's missing-WHERE-clause deletes everything. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`delete_one(query)`** — deletes the FIRST document matching the query, even if multiple match. [S1]
|
||||
- **`delete_many(query)`** — deletes ALL documents matching the query. [S1]
|
||||
- **`delete_many({})`** — empty query object deletes ALL documents in the collection. [S1]
|
||||
- **`DeleteResult.deleted_count`** — the number of documents actually deleted. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Empty filter = delete everything** — matches the same risk pattern as omitting WHERE in SQL DELETE; MongoDB's version of the danger is passing `{}` to `delete_many()`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Delete one (first match only): `myquery = {"address": "Mountain 21"}; mycol.delete_one(myquery)`. [S1]
|
||||
- Delete many by regex: `myquery = {"address": {"$regex": "^S"}}; x = mycol.delete_many(myquery); print(x.deleted_count, "documents deleted.")`. [S1]
|
||||
- Delete all in collection: `x = mycol.delete_many({}); print(x.deleted_count, "documents deleted.")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Delete의 "WHERE 누락 = 전체 삭제" 위험이 MongoDB에서는 "빈 쿼리 객체 = 전체 삭제"로 그대로 재현된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Delete all documents in a collection (Python):
|
||||
```python
|
||||
x = mycol.delete_many({})
|
||||
print(x.deleted_count, " documents deleted.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Query]], [[SQL Delete]], [[Python MongoDB Drop Collection]]
|
||||
- **참조 맥락:** SQL Delete의 WHERE 누락 위험이 MongoDB의 빈 쿼리 객체로 재현된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Delete Document — https://www.w3schools.com/python/python_mongodb_delete.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Delete Document" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: python-mongodb-drop-collection
|
||||
title: "Python MongoDB Drop Collection"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["drop()", "파이썬 MongoDB 컬렉션 삭제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mongodb", "w3schools", "drop", "collection"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_drop_collection.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Drop Collection]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`drop()` returns a boolean (True on success, False if the collection didn't exist) instead of raising an error — letting calling code check success without wrapping the call in try/except. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`collection.drop()`** — deletes an entire collection (SQL's DROP TABLE equivalent). [S1]
|
||||
- **Return value** — `True` if dropped successfully, `False` if the collection didn't exist. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Drop a collection: `mycol = mydb["customers"]; mycol.drop()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL DROP TABLE IF EXISTS와 유사한 안전성을, 예외 대신 불리언 반환값으로 얻는다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Drop a collection (Python):
|
||||
```python
|
||||
mycol = mydb["customers"]
|
||||
mycol.drop()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Drop Table]], [[Python MongoDB Create Collection]]
|
||||
- **참조 맥락:** SQL DROP TABLE에 대응 — 예외 대신 불리언 반환값으로 성공 여부를 알려준다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Drop Collection — https://www.w3schools.com/python/python_mongodb_drop_collection.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Drop Collection" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: python-mongodb-find
|
||||
title: "Python MongoDB Find"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["find()", "find_one()", "projection", "파이썬 MongoDB 조회"]
|
||||
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", "mongodb", "w3schools", "find", "projection"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_find.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Find]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The find() projection object can't mix 0s and 1s (except for `_id`) — including one field with `1` implicitly excludes everything else, while excluding one field with `0` implicitly includes everything else; mixing both raises an error. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`find_one()`** — returns the first matching document. [S1]
|
||||
- **`find()`** — returns ALL matching documents; empty query object = all documents (like `SELECT *`). [S1]
|
||||
- **Projection (2nd parameter)** — an object specifying which fields to include (`1`) or exclude (`0`); optional. [S1]
|
||||
- **`_id` exception** — the only field allowed to mix with either 0 or 1 alongside the other fields. [S1]
|
||||
- **Mixing 0 and 1 on non-`_id` fields is an error** — pick one style: either include specific fields (`1`) or exclude specific fields (`0`), not both. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Implicit-opposite rule** — specifying `1` for one field implicitly sets all UNMENTIONED fields to `0`, and vice versa — this is why mixing explicit `0`s and `1`s (beyond `_id`) is contradictory and rejected. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Find one: `x = mycol.find_one(); print(x)`. [S1]
|
||||
- Find all: `for x in mycol.find(): print(x)`. [S1]
|
||||
- Include only specific fields: `for x in mycol.find({},{"_id": 0, "name": 1, "address": 1}): print(x)`. [S1]
|
||||
- Exclude one field: `for x in mycol.find({},{"address": 0}): print(x)`. [S1]
|
||||
- Invalid mix (raises error): `mycol.find({},{"name": 1, "address": 0})`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. `_id` 필드만 예외적으로 0/1 혼용이 허용된다는 규칙이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL의 SELECT 컬럼 지정과 개념적으로 대응하지만, 문법은 0/1 규칙이라는 독특한 방식이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Include only specific fields, excluding _id (Python):
|
||||
```python
|
||||
for x in mycol.find({}, {"_id": 0, "name": 1, "address": 1}):
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Query]], [[Python MongoDB Insert]], [[Python MySQL Select]]
|
||||
- **참조 맥락:** SQL SELECT의 컬럼 지정에 대응 — 0/1 프로젝션 규칙이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Find — https://www.w3schools.com/python/python_mongodb_find.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Find" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: python-mongodb-insert
|
||||
title: "Python MongoDB Insert"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["insert_one()", "insert_many()", "파이썬 MongoDB 삽입"]
|
||||
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", "mongodb", "w3schools", "insert", "document"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_insert.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Insert]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
If you don't supply an `_id`, MongoDB auto-generates a unique one for every document — but if you DO supply `_id` values yourself (e.g. sequential integers), you're responsible for ensuring they're unique across the collection. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Document** — MongoDB's equivalent of a SQL record; a dictionary of field names/values. [S1]
|
||||
- **`insert_one(dict)`** — inserts a single document. [S1]
|
||||
- **`InsertOneResult.inserted_id`** — the ID of the just-inserted document. [S1]
|
||||
- **Auto-generated `_id`** — assigned automatically if not specified, guaranteed unique. [S1]
|
||||
- **`insert_many(list_of_dicts)`** — inserts multiple documents at once. [S1]
|
||||
- **`InsertManyResult.inserted_ids`** — list of IDs for all inserted documents. [S1]
|
||||
- **Custom `_id` values** — can be specified manually, but must be unique — MongoDB won't auto-check for you beyond the uniqueness constraint. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Insert one: `mydict = {"name": "John", "address": "Highway 37"}; x = mycol.insert_one(mydict)`. [S1]
|
||||
- Get inserted ID: `print(x.inserted_id)`. [S1]
|
||||
- Insert many: `mylist = [{"name": "Amy", ...}, ...]; x = mycol.insert_many(mylist); print(x.inserted_ids)`. [S1]
|
||||
- Insert many with custom IDs: `mylist = [{"_id": 1, "name": "John", ...}, {"_id": 2, ...}, ...]`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. `_id`를 직접 지정할 경우 고유성은 사용자 책임임이 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 삽입 작업이 실제로 데이터베이스/컬렉션을 처음 생성시키는 트리거다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Insert many and get generated IDs (Python):
|
||||
```python
|
||||
mylist = [
|
||||
{"name": "Amy", "address": "Apple st 652"},
|
||||
{"name": "Hannah", "address": "Mountain 21"},
|
||||
]
|
||||
x = mycol.insert_many(mylist)
|
||||
print(x.inserted_ids)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Create Collection]], [[Python MongoDB Find]], [[Python MySQL Insert]]
|
||||
- **참조 맥락:** 데이터베이스/컬렉션을 실제로 생성시키는 트리거 — Find 챕터에서 이 데이터를 조회한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Insert Document — https://www.w3schools.com/python/python_mongodb_insert.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Insert Document" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: python-mongodb-limit
|
||||
title: "Python MongoDB Limit"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["limit()", "파이썬 MongoDB 제한"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mongodb", "w3schools", "limit"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_limit.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Limit]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`.limit(n)` chains onto `find()` exactly like `.sort()` does, capping the result to `n` documents — MongoDB's equivalent of SQL's `LIMIT`, but as a method call rather than a SQL keyword. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`.limit(n)`** — chained onto `find()`; restricts the result to `n` documents. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Limit to 5: `myresult = mycol.find().limit(5); for x in myresult: print(x)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL LIMIT/Python MySQL Limit과 개념은 같지만 메서드 체이닝 문법으로 표현된다는 점이 핵심 차이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Limit results via method chaining (Python):
|
||||
```python
|
||||
myresult = mycol.find().limit(5)
|
||||
for x in myresult:
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Select Top]], [[Python MySQL Limit]], [[Python MongoDB Sort]]
|
||||
- **참조 맥락:** SQL LIMIT에 대응 — 메서드 체이닝 문법(find().limit())으로 표현.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Limit — https://www.w3schools.com/python/python_mongodb_limit.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Limit" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: python-mongodb-query
|
||||
title: "Python MongoDB Query"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["$gt", "$regex", "query modifiers", "파이썬 MongoDB 쿼리"]
|
||||
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", "mongodb", "w3schools", "query", "regex"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_query.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Query]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
MongoDB filter conditions use `$`-prefixed modifier keys (like `$gt`, `$regex`) nested inside the field's value, rather than SQL's inline operator syntax — the same "greater than" idea is expressed structurally instead of with `>`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Query object (1st parameter of `find()`)** — filters which documents match, e.g. `{"address": "Park Lane 38"}` for exact match. [S1]
|
||||
- **`$gt` modifier** — greater-than comparison: `{"address": {"$gt": "S"}}`. [S1]
|
||||
- **`$regex` modifier** — regular expression matching (strings only): `{"address": {"$regex": "^S"}}`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Modifiers nest inside the field, not beside it** — SQL writes `WHERE address > 'S'`; MongoDB nests the operator as a key inside the field's value object: `{"address": {"$gt": "S"}}` — a structural rather than syntactic comparison expression. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Exact match filter: `myquery = {"address": "Park Lane 38"}; mydoc = mycol.find(myquery)`. [S1]
|
||||
- Greater-than filter: `myquery = {"address": {"$gt": "S"}}`. [S1]
|
||||
- Regex filter (starts with "S"): `myquery = {"address": {"$regex": "^S"}}`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 쿼리 객체 패턴이 이후 Delete/Update 챕터에서 "대상 지정" 역할로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Regex-based query modifier (Python):
|
||||
```python
|
||||
myquery = { "address": { "$regex": "^S" } }
|
||||
mydoc = mycol.find(myquery)
|
||||
for x in mydoc:
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Find]], [[Python MongoDB Delete]], [[Python MongoDB Update]], [[SQL Where]]
|
||||
- **참조 맥락:** SQL WHERE에 대응하는 필터 표현식 — $ 접두 modifier가 이후 Delete/Update의 대상 지정에도 재사용된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Query — https://www.w3schools.com/python/python_mongodb_query.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Query" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: python-mongodb-sort
|
||||
title: "Python MongoDB Sort"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["sort()", "파이썬 MongoDB 정렬"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mongodb", "w3schools", "sort"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_sort.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Sort]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
sort()'s direction parameter uses raw integers (1 ascending, -1 descending) rather than keywords like SQL's ASC/DESC — a numeric convention distinct from the SQL family's text-based approach. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`.sort(fieldname, direction)`** — chained onto `find()`; direction defaults to ascending. [S1]
|
||||
- **`1`** — ascending (default). [S1]
|
||||
- **`-1`** — descending. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Ascending (default): `mydoc = mycol.find().sort("name")`. [S1]
|
||||
- Descending: `mydoc = mycol.find().sort("name", -1)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **정렬 방향 문법이 SQL과 다름**: SQL은 키워드(ASC/DESC)를 쓰지만, MongoDB는 정수(1/-1)를 사용한다. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Order By와 개념은 같지만 문법 표기가 다르다는 점에 유의해야 한다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Sort descending (Python):
|
||||
```python
|
||||
mydoc = mycol.find().sort("name", -1)
|
||||
for x in mydoc:
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Order By]], [[Python MongoDB Find]], [[Python MySQL Order By]]
|
||||
- **참조 맥락:** SQL Order By에 대응하되, 문법이 키워드(ASC/DESC)가 아닌 정수(1/-1) 방식.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Sort — https://www.w3schools.com/python/python_mongodb_sort.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Sort" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: python-mongodb-update
|
||||
title: "Python MongoDB Update"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["update_one()", "update_many()", "$set", "파이썬 MongoDB 수정"]
|
||||
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", "mongodb", "w3schools", "update"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mongodb_update.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MongoDB Update]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
update_one() and update_many() both take a query (which document(s) to target) as the first argument and a `$set`-wrapped object (what to change) as the second — and update_one() silently updates only the FIRST match, exactly mirroring delete_one()'s behavior. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`update_one(query, newvalues)`** — updates the first matching document; `newvalues` must be wrapped in `{"$set": {...}}`. [S1]
|
||||
- **First-match-only for `update_one`** — if multiple documents match the query, only the first is updated. [S1]
|
||||
- **`update_many(query, newvalues)`** — updates ALL matching documents. [S1]
|
||||
- **`UpdateResult.modified_count`** — number of documents actually changed. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Update one: `myquery = {"address": "Valley 345"}; newvalues = {"$set": {"address": "Canyon 123"}}; mycol.update_one(myquery, newvalues)`. [S1]
|
||||
- Update many by regex: `myquery = {"address": {"$regex": "^S"}}; newvalues = {"$set": {"name": "Minnie"}}; x = mycol.update_many(myquery, newvalues); print(x.modified_count, "documents updated.")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. update_one()이 첫 번째 일치 항목만 수정한다는 점이 delete_one()과 동일한 패턴으로 명시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Update의 WHERE 로직에 대응하며, 값 변경은 반드시 `$set`으로 감싸야 한다는 문법적 차이가 핵심이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Update many documents matching a regex (Python):
|
||||
```python
|
||||
myquery = { "address": { "$regex": "^S" } }
|
||||
newvalues = { "$set": { "name": "Minnie" } }
|
||||
x = mycol.update_many(myquery, newvalues)
|
||||
print(x.modified_count, "documents updated.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MongoDB Query]], [[Python MongoDB Delete]], [[SQL Update]]
|
||||
- **참조 맥락:** SQL Update에 대응 — 값 변경은 반드시 $set으로 감싸야 하는 문법적 차이.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MongoDB Update — https://www.w3schools.com/python/python_mongodb_update.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MongoDB Update" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: python-mysql-create-database
|
||||
title: "Python MySQL Create Database"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["mysql.connector", "파이썬 MySQL 데이터베이스 생성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mysql", "w3schools", "database", "connector"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_create_db.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Create Database]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `mysql.connector` module lets Python execute any SQL statement via a cursor object — creating a database is just `mycursor.execute("CREATE DATABASE ...")`, no special API beyond raw SQL execution. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`mysql.connector.connect()`** — opens a connection given host/user/password (and optionally database). [S1]
|
||||
- **`mydb.cursor()`** — creates a cursor object used to execute SQL statements. [S1]
|
||||
- **`mycursor.execute(sql)`** — runs a raw SQL statement, e.g. `"CREATE DATABASE mydatabase"`. [S1]
|
||||
- **Checking existence** — `execute("SHOW DATABASES")` then iterate the cursor to list all databases. [S1]
|
||||
- **Connect directly to a database** — pass `database="mydatabase"` to `connect()`; errors if it doesn't exist. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create a database: `mycursor.execute("CREATE DATABASE mydatabase")`. [S1]
|
||||
- List databases: `mycursor.execute("SHOW DATABASES"); for x in mycursor: print(x)`. [S1]
|
||||
- Connect to a specific database: `mysql.connector.connect(host=..., user=..., password=..., database="mydatabase")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 챕터에서 정의한 connect/cursor/execute 패턴이 이후 모든 Python MySQL 챕터에서 반복 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Create a database via mysql.connector (Python):
|
||||
```python
|
||||
import mysql.connector
|
||||
mydb = mysql.connector.connect(
|
||||
host="localhost", user="yourusername", password="yourpassword"
|
||||
)
|
||||
mycursor = mydb.cursor()
|
||||
mycursor.execute("CREATE DATABASE mydatabase")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MySQL Create Table]], [[SQL Create DB]]
|
||||
- **참조 맥락:** Python에서 MySQL을 다루는 connect/cursor/execute 패턴의 진입점.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Create Database — https://www.w3schools.com/python/python_mysql_create_db.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Create Database" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: python-mysql-create-table
|
||||
title: "Python MySQL Create Table"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 테이블 생성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mysql", "w3schools", "createtable", "primarykey"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_create_table.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Create Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`INT AUTO_INCREMENT PRIMARY KEY` is the standard way to add a self-incrementing unique ID column, and it can be applied either at table creation or retrofitted onto an existing table via `ALTER TABLE ... ADD COLUMN`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`CREATE TABLE`** — executed via `mycursor.execute("CREATE TABLE ...")`; the connection must specify the target database. [S1]
|
||||
- **`SHOW TABLES`** — checks existing tables, same iteration pattern as SHOW DATABASES. [S1]
|
||||
- **`INT AUTO_INCREMENT PRIMARY KEY`** — auto-generates a unique, incrementing ID starting at 1. [S1]
|
||||
- **Adding a primary key to an existing table** — `ALTER TABLE customers ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Create table: `mycursor.execute("CREATE TABLE customers (name VARCHAR(255), address VARCHAR(255))")`. [S1]
|
||||
- With primary key: `mycursor.execute("CREATE TABLE customers (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), address VARCHAR(255))")`. [S1]
|
||||
- Add PK after the fact: `mycursor.execute("ALTER TABLE customers ADD COLUMN id INT AUTO_INCREMENT PRIMARY KEY")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Insert Into 챕터에서 이 테이블에 실제 레코드를 채우는 과정으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Create table with auto-increment primary key (Python):
|
||||
```python
|
||||
mycursor.execute(
|
||||
"CREATE TABLE customers (id INT AUTO_INCREMENT PRIMARY KEY, "
|
||||
"name VARCHAR(255), address VARCHAR(255))"
|
||||
)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MySQL Create Database]], [[Python MySQL Insert]], [[SQL Auto Increment]]
|
||||
- **참조 맥락:** MySQL 테이블 생성 및 기본키 설정 — 이후 Insert Into로 데이터가 채워진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Create Table — https://www.w3schools.com/python/python_mysql_create_table.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Create Table" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-mysql-delete
|
||||
title: "Python MySQL Delete"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 삭제"]
|
||||
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", "mysql", "w3schools", "delete", "commit"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_delete.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Delete]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Just like INSERT, a DELETE needs `mydb.commit()` to actually take effect, and omitting the WHERE clause deletes every row — the same two warnings from raw SQL DELETE apply identically through the Python connector. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`DELETE FROM ... WHERE ...`** — deletes matching records. [S1]
|
||||
- **`mydb.commit()`** — required for the delete to persist. [S1]
|
||||
- **Missing WHERE = delete everything** — same risk as raw SQL DELETE. [S1]
|
||||
- **`mycursor.rowcount`** — number of rows deleted. [S1]
|
||||
- **SQL injection prevention** — use `%s` placeholders for user-provided delete criteria. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic delete: `sql = "DELETE FROM customers WHERE address = 'Mountain 21'"; mycursor.execute(sql); mydb.commit(); print(mycursor.rowcount, "record(s) deleted")`. [S1]
|
||||
- Parameterized delete: `sql = "DELETE FROM customers WHERE address = %s"; adr = ("Yellow Garden 2",); mycursor.execute(sql, adr); mydb.commit()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. WHERE 누락 시 전체 삭제된다는 경고가 SQL Delete 챕터와 동일하게 반복됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Delete 챕터의 규칙(WHERE 필수, commit 필요)이 mysql.connector API로 그대로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parameterized delete with commit (Python):
|
||||
```python
|
||||
sql = "DELETE FROM customers WHERE address = %s"
|
||||
adr = ("Yellow Garden 2", )
|
||||
mycursor.execute(sql, adr)
|
||||
mydb.commit()
|
||||
print(mycursor.rowcount, "record(s) deleted")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Delete]], [[Python MySQL Insert]], [[Python MySQL Update]]
|
||||
- **참조 맥락:** SQL Delete의 위험성(WHERE 누락)이 mysql.connector에서도 동일하게 적용된다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Delete From By — https://www.w3schools.com/python/python_mysql_delete.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Delete" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: python-mysql-drop-table
|
||||
title: "Python MySQL Drop Table"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 테이블 삭제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mysql", "w3schools", "droptable"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_drop_table.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Drop Table]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Adding `IF EXISTS` to a DROP TABLE statement avoids an error when the table is already gone — a defensive habit especially useful in scripts that might run more than once. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`DROP TABLE`** — permanently deletes a table, executed the same way as any other SQL via the cursor. [S1]
|
||||
- **`DROP TABLE IF EXISTS`** — avoids an error if the table doesn't exist. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic drop: `sql = "DROP TABLE customers"; mycursor.execute(sql)`. [S1]
|
||||
- Safe drop: `sql = "DROP TABLE IF EXISTS customers"; mycursor.execute(sql)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 반복 실행 가능한 셋업 스크립트에서 IF EXISTS를 습관적으로 사용하는 것이 안전하다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Safe drop with IF EXISTS (Python):
|
||||
```python
|
||||
sql = "DROP TABLE IF EXISTS customers"
|
||||
mycursor.execute(sql)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Drop Table]], [[Python MySQL Create Table]]
|
||||
- **참조 맥락:** SQL Drop Table 문법을 mysql.connector로 실행 — 재실행 가능한 스크립트에 IF EXISTS 권장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Drop Table — https://www.w3schools.com/python/python_mysql_drop_table.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Drop Table" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: python-mysql-insert
|
||||
title: "Python MySQL Insert"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["executemany()", "lastrowid", "파이썬 MySQL 삽입"]
|
||||
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", "mysql", "w3schools", "insert", "commit"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_insert.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Insert]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`mydb.commit()` is not optional — without it, INSERT/executemany() changes silently never reach the table, since the connector buffers writes until explicitly committed. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`%s` placeholders** — `sql = "INSERT INTO customers (name, address) VALUES (%s, %s)"` — parameterized, injection-safe insertion. [S1]
|
||||
- **`mycursor.execute(sql, val)`** — executes with a tuple of values bound to the placeholders. [S1]
|
||||
- **`mydb.commit()`** — REQUIRED to persist changes; without it, no changes are made to the table. [S1]
|
||||
- **`mycursor.rowcount`** — number of rows affected by the last statement. [S1]
|
||||
- **`executemany(sql, val)`** — inserts multiple rows at once; `val` is a list of tuples. [S1]
|
||||
- **`mycursor.lastrowid`** — the auto-generated ID of the last inserted row (only the LAST row's ID if multiple were inserted). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **commit() is the universal write-finalizer** — every mutating operation (INSERT/UPDATE/DELETE) in this whole Python-MySQL series requires the same `mydb.commit()` call, making it the single most important line to remember across all of them. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single insert with commit: `sql = "INSERT INTO customers (name, address) VALUES (%s, %s)"; val = ("John", "Highway 21"); mycursor.execute(sql, val); mydb.commit(); print(mycursor.rowcount, "record inserted.")`. [S1]
|
||||
- Multiple rows: `val = [('Peter','Lowstreet 4'), ...]; mycursor.executemany(sql, val); mydb.commit()`. [S1]
|
||||
- Get last inserted ID: `print("1 record inserted, ID:", mycursor.lastrowid)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. commit()이 없으면 아무 변경도 반영되지 않는다는 점이 "Important!"로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Injection/Parameters 챕터에서 배운 파라미터화 쿼리(%s)가 여기서 mysql.connector의 실제 구현으로 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Insert with required commit() (Python):
|
||||
```python
|
||||
sql = "INSERT INTO customers (name, address) VALUES (%s, %s)"
|
||||
val = ("John", "Highway 21")
|
||||
mycursor.execute(sql, val)
|
||||
mydb.commit() # required, or no changes persist
|
||||
print(mycursor.rowcount, "record inserted.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MySQL Create Table]], [[SQL Parameters]], [[Python MySQL Update]]
|
||||
- **참조 맥락:** commit()이 필요한 모든 쓰기 작업(Insert/Update/Delete)의 공통 패턴 확립.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Insert Into Table — https://www.w3schools.com/python/python_mysql_insert.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Insert Into Table" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: python-mysql-join
|
||||
title: "Python MySQL Join"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 조인"]
|
||||
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", "mysql", "w3schools", "join", "innerjoin", "leftjoin", "rightjoin"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_join.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Join]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
INNER JOIN silently drops users with no favorite product (Hannah, Michael) — the same rows only reappear if you switch to LEFT JOIN, making the choice of join type directly visible in which rows survive. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **JOIN via raw SQL** — combining `users` and `products` tables on `users.fav = products.id`, executed through the same cursor pattern. [S1]
|
||||
- **INNER JOIN (default via JOIN)** — only matching rows in both tables; users with no favorite product are excluded. [S1]
|
||||
- **LEFT JOIN** — keeps ALL users, even those without a matching product (fav is NULL). [S1]
|
||||
- **RIGHT JOIN** — keeps ALL products, even those no user has favorited. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Missing rows are the tell** — the source explicitly points out that Hannah and Michael (no favorite product) vanish under INNER/RIGHT JOIN but reappear under LEFT JOIN — a concrete way to verify which join type is actually in effect. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Sample data: `users` table has `fav` referencing `products.id`; some users (Hannah, Michael) have no `fav` value. [S1]
|
||||
- INNER JOIN: `sql = "SELECT users.name AS user, products.name AS favorite FROM users INNER JOIN products ON users.fav = products.id"` — excludes users with no favorite. [S1]
|
||||
- LEFT JOIN: same query with `LEFT JOIN` — includes ALL users, even without a favorite. [S1]
|
||||
- RIGHT JOIN: same query with `RIGHT JOIN` — includes ALL products, even unfavorited ones; still excludes favorite-less users. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Inner/Left/Right Join 챕터에서 이미 배운 동작 차이를 실제 mysql.connector 쿼리로 재확인하는 문서다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
LEFT JOIN to include unmatched rows (Python):
|
||||
```python
|
||||
sql = "SELECT \
|
||||
users.name AS user, \
|
||||
products.name AS favorite \
|
||||
FROM users \
|
||||
LEFT JOIN products ON users.fav = products.id"
|
||||
mycursor.execute(sql)
|
||||
myresult = mycursor.fetchall()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Inner Join]], [[SQL Left Join]], [[SQL Right Join]], [[Python MySQL Select]]
|
||||
- **참조 맥락:** SQL JOIN 동작 차이를 mysql.connector로 실증 — 사라지는/나타나는 행으로 join 유형을 검증할 수 있다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Join — https://www.w3schools.com/python/python_mysql_join.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Join" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: python-mysql-limit
|
||||
title: "Python MySQL Limit"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["OFFSET", "파이썬 MySQL 제한"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mysql", "w3schools", "limit", "offset", "pagination"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_limit.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Limit]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`LIMIT n OFFSET m` together implement pagination — LIMIT caps how many rows come back, OFFSET skips past the first m rows before counting, letting you page through a large result set in fixed-size chunks. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`LIMIT n`** — restricts the result to `n` records. [S1]
|
||||
- **`OFFSET m`** — starts the result from position `m` (skipping the first `m` rows). [S1]
|
||||
- **Combined** — `LIMIT 5 OFFSET 2` returns 5 records starting from the 3rd row. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Limit only: `mycursor.execute("SELECT * FROM customers LIMIT 5")`. [S1]
|
||||
- Limit + offset: `mycursor.execute("SELECT * FROM customers LIMIT 5 OFFSET 2")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 대용량 결과를 페이지 단위로 나눠 보여주는 페이지네이션(pagination) 구현의 기초다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Pagination via LIMIT + OFFSET (Python):
|
||||
```python
|
||||
mycursor.execute("SELECT * FROM customers LIMIT 5 OFFSET 2")
|
||||
myresult = mycursor.fetchall()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Select Top]], [[Python MySQL Select]], [[Python MySQL Order By]]
|
||||
- **참조 맥락:** 대용량 결과의 페이지네이션 구현 — Order By와 함께 사용해야 일관된 페이지 순서를 보장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Limit — https://www.w3schools.com/python/python_mysql_limit.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Limit" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: python-mysql-order-by
|
||||
title: "Python MySQL Order By"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 정렬"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "mysql", "w3schools", "orderby"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_orderby.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Order By]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
ORDER BY sorts ascending by default when passed through as raw SQL to `execute()` — sorting logic lives entirely in the SQL string, not in any Python-side API. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`ORDER BY`** — sorts results; ascending by default. [S1]
|
||||
- **`DESC`** — sorts descending. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Ascending (default): `sql = "SELECT * FROM customers ORDER BY name"`. [S1]
|
||||
- Descending: `sql = "SELECT * FROM customers ORDER BY name DESC"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Order By 챕터와 문법이 완전히 동일하며, mysql.connector를 통해 그대로 실행된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Sort descending via mysql.connector (Python):
|
||||
```python
|
||||
sql = "SELECT * FROM customers ORDER BY name DESC"
|
||||
mycursor.execute(sql)
|
||||
myresult = mycursor.fetchall()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Order By]], [[Python MySQL Select]]
|
||||
- **참조 맥락:** SQL Order By 문법을 mysql.connector로 실행하는 예제.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Order By — https://www.w3schools.com/python/python_mysql_orderby.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Order By" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: python-mysql-select
|
||||
title: "Python MySQL Select"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fetchall()", "fetchone()", "파이썬 MySQL 조회"]
|
||||
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", "mysql", "w3schools", "select", "fetchall", "fetchone"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_select.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Select]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Running a SELECT doesn't itself return rows — the cursor must be drained with `fetchall()` (every row) or `fetchone()` (just the first row) after `execute()`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`execute("SELECT * FROM customers")`** — runs the query. [S1]
|
||||
- **`fetchall()`** — fetches ALL rows from the last executed statement. [S1]
|
||||
- **Selecting specific columns** — `SELECT name, address FROM customers`. [S1]
|
||||
- **`fetchone()`** — returns only the first row of the result. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Select all, fetch all: `mycursor.execute("SELECT * FROM customers"); myresult = mycursor.fetchall(); for x in myresult: print(x)`. [S1]
|
||||
- Select specific columns: `mycursor.execute("SELECT name, address FROM customers")`. [S1]
|
||||
- Fetch just one row: `myresult = mycursor.fetchone(); print(myresult)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Where/Order By/Limit 챕터에서 이 SELECT+fetch 패턴에 필터/정렬/제한이 추가된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Select and fetch all rows (Python):
|
||||
```python
|
||||
mycursor.execute("SELECT * FROM customers")
|
||||
myresult = mycursor.fetchall()
|
||||
for x in myresult:
|
||||
print(x)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python MySQL Where]], [[Python MySQL Order By]], [[Python MySQL Limit]]
|
||||
- **참조 맥락:** 조회 결과를 가져오는 fetchall()/fetchone() 패턴 — 이후 필터/정렬/제한 챕터의 기초.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Select From — https://www.w3schools.com/python/python_mysql_select.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Select From" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-mysql-update
|
||||
title: "Python MySQL Update"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 수정"]
|
||||
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", "mysql", "w3schools", "update", "commit"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_update.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Update]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
UPDATE follows the identical commit()-required, WHERE-critical, %s-parameterized pattern as INSERT and DELETE — by this point in the series, the risk warnings are a repeated refrain across every mutating SQL operation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`UPDATE ... SET ... WHERE ...`** — modifies matching records. [S1]
|
||||
- **`mydb.commit()`** — required for the update to persist. [S1]
|
||||
- **Missing WHERE = update everything** — same risk as raw SQL UPDATE. [S1]
|
||||
- **`mycursor.rowcount`** — number of rows affected. [S1]
|
||||
- **Parameterized update** — `%s` placeholders for both the SET value and the WHERE condition. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic update: `sql = "UPDATE customers SET address = 'Canyon 123' WHERE address = 'Valley 345'"; mycursor.execute(sql); mydb.commit(); print(mycursor.rowcount, "record(s) affected")`. [S1]
|
||||
- Parameterized update: `sql = "UPDATE customers SET address = %s WHERE address = %s"; val = ("Valley 345", "Canyon 123"); mycursor.execute(sql, val); mydb.commit()`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — SQL Update의 WHERE 필수 규칙과 commit() 요구사항이 mysql.connector에서도 동일하게 적용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parameterized update with two placeholders (Python):
|
||||
```python
|
||||
sql = "UPDATE customers SET address = %s WHERE address = %s"
|
||||
val = ("Valley 345", "Canyon 123")
|
||||
mycursor.execute(sql, val)
|
||||
mydb.commit()
|
||||
print(mycursor.rowcount, "record(s) affected")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Update]], [[Python MySQL Insert]], [[Python MySQL Delete]]
|
||||
- **참조 맥락:** SQL Update의 WHERE 필수 규칙과 commit() 요구사항이 mysql.connector에서도 동일하게 적용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Update Table — https://www.w3schools.com/python/python_mysql_update.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Update Table" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-mysql-where
|
||||
title: "Python MySQL Where"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 MySQL 조건 필터"]
|
||||
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", "mysql", "w3schools", "where", "sql-injection", "like"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_mysql_where.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python MySQL Where]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
When a filter value comes from user input, it must be passed as a bound `%s` parameter to `execute()` rather than string-concatenated into the SQL — the exact SQL-injection defense taught earlier, now shown in the mysql.connector API. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **WHERE filter** — `sql = "SELECT * FROM customers WHERE address ='Park Lane 38'"`. [S1]
|
||||
- **Wildcard with `LIKE`** — `%` represents any characters: `WHERE address LIKE '%way%'`. [S1]
|
||||
- **SQL injection prevention** — escape user-provided values via the `%s` placeholder and pass them as a tuple to `execute(sql, val)`, rather than concatenating strings. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **This is [[SQL Injection]] and [[SQL Parameters]] applied concretely** — the exact string-concatenation vulnerability and `%s`-placeholder fix from those SQL-category chapters reappear here in the mysql.connector Python API. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic WHERE: `sql = "SELECT * FROM customers WHERE address ='Park Lane 38'"`. [S1]
|
||||
- Wildcard search: `sql = "SELECT * FROM customers WHERE address LIKE '%way%'"`. [S1]
|
||||
- Injection-safe parameterized query: `sql = "SELECT * FROM customers WHERE address = %s"; adr = ("Yellow Garden 2",); mycursor.execute(sql, adr)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 사용자 입력을 쿼리에 넣어야 하는 모든 상황에서 %s 파라미터화가 표준 방어책이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parameterized WHERE to prevent injection (Python):
|
||||
```python
|
||||
sql = "SELECT * FROM customers WHERE address = %s"
|
||||
adr = ("Yellow Garden 2", )
|
||||
mycursor.execute(sql, adr)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[SQL Injection]], [[SQL Parameters]], [[Python MySQL Select]]
|
||||
- **참조 맥락:** SQL Injection 방어의 mysql.connector 구현 — 사용자 입력을 다룰 때 항상 %s 파라미터화 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python MySQL Where — https://www.w3schools.com/python/python_mysql_where.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python MySQL Where" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: python-nested-if
|
||||
title: "Python Nested If"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Nested If Statements", "파이썬 중첩 조건문"]
|
||||
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", "if", "nested"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_if_nested_if.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Nested If]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Nesting an if inside another if lets the inner condition depend on the outer one being true first, and it's interchangeable with `and` when both conditions are equally simple — nesting wins when the inner logic is genuinely conditional on the outer branch. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Nested if** — an if statement inside another if statement; the inner one only runs when the outer condition is true. [S1]
|
||||
- **Multiple nesting levels** — legal to any depth, but readability degrades quickly with too many levels. [S1]
|
||||
- **Nested if vs. `and`** — `if temperature > 20: if is_sunny: ...` is equivalent to `if temperature > 20 and is_sunny: ...` when there's no independent action tied to just the outer condition. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **When to nest vs. combine with `and`** — use nested if when the inner logic is complex or genuinely depends on the outer condition (e.g. different messages at each level); use `and` when both conditions are simple and equally weighted. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic nesting: `if x > 10: print("Above ten,"); if x > 20: print("and also above 20!") else: print("but not above 20.")`. [S1]
|
||||
- Three-level nesting: score → attendance → submitted, each gating the next. [S1]
|
||||
- Equivalent forms: `if temperature > 20: if is_sunny: ...` ≡ `if temperature > 20 and is_sunny: ...`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 로그인 검증(username→password→is_active)처럼 단계적으로 좁혀지는 조건 체크에 전형적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested if for step-wise validation (Python):
|
||||
```python
|
||||
username = "Emil"
|
||||
password = "python123"
|
||||
is_active = True
|
||||
if username:
|
||||
if password:
|
||||
if is_active:
|
||||
print("Login successful")
|
||||
else:
|
||||
print("Account is not active")
|
||||
else:
|
||||
print("Password required")
|
||||
else:
|
||||
print("Username required")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python If Statement]], [[Python Operators Logical]], [[Python Elif]]
|
||||
- **참조 맥락:** 단계적 조건 분기의 표준 패턴 — `and` 연산자와 상호 대체 가능한 경우가 많다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Nested If — https://www.w3schools.com/python/python_if_nested_if.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Nested If" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-none
|
||||
title: "Python None"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["NoneType", "파이썬 None"]
|
||||
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", "none", "nonetype"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_none.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python None]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
None is the sole instance of its own type (NoneType), evaluates to False in a boolean context, and should be compared with `is`/`is not` (identity) rather than `==`/`!=` (equality). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`None`** — a special constant representing the absence of a value; data type `NoneType`. [S1]
|
||||
- **Single instance** — None is the only instance of NoneType. [S1]
|
||||
- **Comparison** — use `is` / `is not`, not `==`/`!=`, to check for None. [S1]
|
||||
- **Falsy** — `bool(None)` is False. [S1]
|
||||
- **Default function return** — a function with no explicit `return` returns None. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Assign and check type: `x = None; print(type(x)) # <class 'NoneType'>`. [S1]
|
||||
- Identity comparison: `if result is None: print("No result yet") else: print("Result is ready")`. [S1]
|
||||
- Truthiness: `print(bool(None)) # False`. [S1]
|
||||
- Implicit None return: `def myfunc(): x = 5; x = myfunc(); print(x) # None`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Functions 챕터에서 이미 예고된 "return 없으면 None"이 여기서 정식으로 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Identity comparison with None (Python):
|
||||
```python
|
||||
result = None
|
||||
if result is None:
|
||||
print("No result yet")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Functions]], [[Python Operators Identity]], [[Python Booleans]]
|
||||
- **참조 맥락:** "값 없음"을 표현하는 표준 상수 — is/is not 비교 규칙이 핵심.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python None — https://www.w3schools.com/python/python_none.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python None" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-numbers
|
||||
title: "Python Numbers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["int float complex", "파이썬 숫자"]
|
||||
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", "numbers"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_numbers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Numbers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has three numeric types — unbounded-length int, decimal/scientific-notation float, and `j`-suffixed complex — freely convertible into each other except complex, which cannot convert into anything else. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **int** — a whole number, positive or negative, without decimals, of unlimited length. [S1]
|
||||
- **float** — a number with one or more decimals; can also use scientific notation (`e`/`E` for powers of 10). [S1]
|
||||
- **complex** — written with a `j` suffix for the imaginary part (e.g. `3+5j`). [S1]
|
||||
- **Type conversion** — `int()`, `float()`, `complex()` convert between numeric types. [S1]
|
||||
- **Complex is a one-way street** — complex numbers cannot be converted into another number type. [S1]
|
||||
- **Random numbers** — Python has no built-in `random()` keyword, but the `random` module (`random.randrange(1, 10)`) generates them. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic declarations: `x = 1 # int`, `y = 2.8 # float`, `z = 1j # complex`. [S1]
|
||||
- Scientific notation floats: `x = 35e3; y = 12E4; z = -87.7e100`. [S1]
|
||||
- Conversion: `a = float(x); b = int(y); c = complex(x)`. [S1]
|
||||
- Random number: `import random; print(random.randrange(1, 10))`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. complex는 다른 타입으로 변환 불가하다는 예외가 명시적으로 강조됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — random 모듈은 이후 여러 예제(리스트 셔플, 게임 로직 등)에서 재사용되는 표준 도구다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Random number via the random module (Python):
|
||||
```python
|
||||
import random
|
||||
print(random.randrange(1, 10))
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Data Types]], [[Python Casting]], [[Python Math]]
|
||||
- **참조 맥락:** 숫자 타입 3종의 기초 — Casting/Math 챕터로 이어진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Numbers — https://www.w3schools.com/python/python_numbers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Numbers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: python-oop
|
||||
title: "Python OOP"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Object-Oriented Programming", "DRY", "파이썬 객체지향"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "oop"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_oop.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python OOP]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
OOP organizes code around classes (blueprints) and objects (instances), directly serving the DRY principle by letting repeated structure live in one class definition instead of scattered code. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **OOP** — Object-Oriented Programming; Python structures code using classes and objects. [S1]
|
||||
- **Advantages** — clear structure, easier maintenance/reuse/debugging, DRY code, reusable applications with less code. [S1]
|
||||
- **Class** — defines what an object should look like (a blueprint). [S1]
|
||||
- **Object** — an instance created based on a class. [S1]
|
||||
- **DRY principle** — avoid writing the same code more than once; move repeated code into functions/classes. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
이 문서는 OOP 챕터군 전체의 개론이며, __init__()/self/properties/methods/inheritance/polymorphism/encapsulation/inner classes가 이어지는 전용 챕터에서 다뤄진다. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 개론 뒤에 OOP 핵심 개념 8개 챕터가 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (개론 페이지, 각 OOP 챕터에서 코드 제공).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Classes]], [[Python Inheritance]], [[Python Encapsulation]]
|
||||
- **참조 맥락:** OOP 챕터군 전체의 개론.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python OOP — https://www.w3schools.com/python/python_oop.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python OOP" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
id: python-operators
|
||||
title: "Python Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "operators"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python groups its operators into seven families — arithmetic, assignment, comparison, logical, identity, membership, bitwise — each covered in its own dedicated chapter. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Operators** — perform operations on variables and values, e.g. `+` for addition. [S1]
|
||||
- **Operand flexibility** — the same operator (e.g. `+`) works on two literals, a variable and a literal, or two variables. [S1]
|
||||
- **Seven operator groups** — Arithmetic, Assignment, Comparison, Logical, Identity, Membership, Bitwise. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic addition: `print(10 + 5)`. [S1]
|
||||
- Chained variable arithmetic: `sum1 = 100 + 50; sum2 = sum1 + 250; sum3 = sum2 + sum2`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이 개론 뒤에 7개 연산자 그룹 각각의 전용 챕터가 이어진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
소스에 코드 예시 없음 (개론 페이지, 각 연산자 그룹 챕터에서 코드 제공).
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators Arithmetic]], [[Python Operators Comparison]], [[Python Operators Logical]]
|
||||
- **참조 맥락:** 7개 연산자 그룹 챕터의 상위 개론 문서.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Operators — https://www.w3schools.com/python/python_operators.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: python-operators-arithmetic
|
||||
title: "Python Operators Arithmetic"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Arithmetic Operators", "파이썬 산술 연산자"]
|
||||
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", "operators", "arithmetic"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_arithmetic.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Arithmetic]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python has two distinct division operators — `/` always returns a float, while `//` (floor division) always returns an integer, rounding DOWN rather than to the nearest whole number. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Arithmetic operators** — `+` addition, `-` subtraction, `*` multiplication, `/` division, `%` modulus, `**` exponentiation, `//` floor division. [S1]
|
||||
- **`/` vs `//`** — `/` returns a float; `//` returns an integer, rounded down (not to nearest). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All operators demoed: `x = 15; y = 4; print(x + y); print(x - y); print(x * y); print(x / y); print(x % y); print(x ** y); print(x // y)`. [S1]
|
||||
- Division always float: `x = 12; y = 5; print(x / y) # 2.4`. [S1]
|
||||
- Floor division rounds down: `print(x // y) # 2`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 Operator Precedence 챕터에서 이 연산자들의 우선순위가 정의된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Division vs floor division (Python):
|
||||
```python
|
||||
x = 12
|
||||
y = 5
|
||||
print(x / y) # 2.4 (float)
|
||||
print(x // y) # 2 (int, rounds down)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators]], [[Python Operators Precedence]], [[Python Numbers]]
|
||||
- **참조 맥락:** 기본 산술 연산 — 나눗셈의 두 가지 방식(`/` vs `//`)을 반드시 구분해야 한다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Arithmetic Operators — https://www.w3schools.com/python/python_operators_arithmetic.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Arithmetic Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: python-operators-assign
|
||||
title: "Python Operators Assign"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Assignment Operators", "Walrus Operator", "파이썬 대입 연산자"]
|
||||
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", "operators", "assignment", "walrus"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_assign.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Assign]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Beyond the usual compound-assignment shorthands (`+=`, `-=`, etc.), Python 3.8's walrus operator `:=` uniquely assigns a value AND returns it as part of a larger expression, e.g. directly inside an `if` condition. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Assignment operators** — `=`, `+=`, `-=`, `*=`, `/=`, `%=`, `//=`, `**=`, `&=`, `|=`, `^=`, `>>=`, `<<=`, each a shorthand for `x = x <op> value`. [S1]
|
||||
- **Walrus operator `:=`** (Python 3.8+) — assigns a value to a variable as part of a larger expression, rather than as a standalone statement. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Assign-and-use in one step** — the walrus operator lets a value be computed once, bound to a name, AND used in a condition simultaneously, avoiding a separate assignment line before the `if`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Compound assignment: `x += 3` is the same as `x = x + 3`. [S1]
|
||||
- Walrus operator inside a condition: [S1]
|
||||
```python
|
||||
numbers = [1, 2, 3, 4, 5]
|
||||
if (count := len(numbers)) > 3:
|
||||
print(f"List has {count} elements")
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 왈러스 연산자는 while 루프 조건에서 "값을 계산하며 동시에 검사"하는 패턴에도 흔히 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Walrus operator inside an if condition (Python):
|
||||
```python
|
||||
numbers = [1, 2, 3, 4, 5]
|
||||
if (count := len(numbers)) > 3:
|
||||
print(f"List has {count} elements")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators]], [[Python If Else]], [[Python While Loops]]
|
||||
- **참조 맥락:** 값 할당 축약 문법 — 왈러스 연산자는 조건문/반복문 조건에서 특히 유용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Assignment Operators — https://www.w3schools.com/python/python_operators_assign.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Assignment Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: python-operators-bitwise
|
||||
title: "Python Operators Bitwise"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Bitwise Operators", "파이썬 비트 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "operators", "bitwise"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_bitwise.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Bitwise]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Bitwise operators (`&`, `|`, `^`, `~`, `<<`, `>>`) compare numbers at their binary-digit level rather than as whole values — e.g. `6 & 3` compares `0110` and `0011` bit-by-bit to get `0010` (2). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`&` (AND)** — sets each bit to 1 if both bits are 1. [S1]
|
||||
- **`|` (OR)** — sets each bit to 1 if at least one bit is 1. [S1]
|
||||
- **`^` (XOR)** — sets each bit to 1 if exactly one of the two bits is 1. [S1]
|
||||
- **`~` (NOT)** — inverts all bits. [S1]
|
||||
- **`<<` (zero fill left shift)** — shifts left, pushing zeros in from the right. [S1]
|
||||
- **`>>` (signed right shift)** — shifts right, pushing copies of the leftmost bit in from the left. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- AND: `print(6 & 3)` → `0110 & 0011 = 0010` = 2. [S1]
|
||||
- OR: `print(6 | 3)` → `0110 | 0011 = 0111` = 7. [S1]
|
||||
- XOR: `print(6 ^ 3)` → `0110 ^ 0011 = 0101` = 5. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 플래그 비트 조합, 저수준 최적화 등에서 쓰이는 연산이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Bitwise AND/OR/XOR (Python):
|
||||
```python
|
||||
print(6 & 3) # 2 (0110 & 0011 = 0010)
|
||||
print(6 | 3) # 7 (0110 | 0011 = 0111)
|
||||
print(6 ^ 3) # 5 (0110 ^ 0011 = 0101)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators]], [[Python Operators Precedence]]
|
||||
- **참조 맥락:** 이진수 레벨 연산이 필요한 저수준 로직에서 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Bitwise Operators — https://www.w3schools.com/python/python_operators_bitwise.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Bitwise Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,64 @@
|
||||
---
|
||||
id: python-operators-comparison
|
||||
title: "Python Operators Comparison"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Comparison Operators", "파이썬 비교 연산자"]
|
||||
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", "operators", "comparison"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_comparison.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Comparison]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python allows chaining comparison operators directly (`1 < x < 10`) as a shorthand for the logically equivalent `and`-joined pair (`1 < x and x < 10`). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comparison operators** — `==`, `!=`, `>`, `<`, `>=`, `<=`; each returns True or False. [S1]
|
||||
- **Chaining** — `1 < x < 10` is valid Python and equivalent to `1 < x and x < 10`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- All six operators demoed: `x = 5; y = 3; print(x == y); print(x != y); print(x > y); print(x < y); print(x >= y); print(x <= y)`. [S1]
|
||||
- Chained comparison: `x = 5; print(1 < x < 10); print(1 < x and x < 10)` — both give the same result. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 범위 체크(`1 < x < 10`)는 여러 언어에서 지원되지 않는 Python 특유의 편의 문법이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained range check (Python):
|
||||
```python
|
||||
x = 5
|
||||
print(1 < x < 10) # equivalent to: 1 < x and x < 10
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators]], [[Python Operators Logical]], [[Python If Else]]
|
||||
- **참조 맥락:** 조건문에서 범위 체크를 간결하게 표현할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Comparison Operators — https://www.w3schools.com/python/python_operators_comparison.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Comparison Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: python-operators-identity
|
||||
title: "Python Operators Identity"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["is operator", "is not operator", "파이썬 식별 연산자"]
|
||||
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", "operators", "identity"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_identity.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Identity]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`is` checks whether two variables reference the exact same object in memory, while `==` checks whether their values are equal — two equal-valued lists can still be `is not` the same object. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`is`** — True if both variables are the same object (same memory location). [S1]
|
||||
- **`is not`** — True if both variables are NOT the same object. [S1]
|
||||
- **`is` vs `==`** — `is` checks identity (same object), `==` checks value equality. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Equal-but-not-identical** — two separately created lists with identical contents are `==` True but `is` False, since they occupy different memory locations; only an alias (`z = x`) is `is` True with the original. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Same object vs. equal value: [S1]
|
||||
```python
|
||||
x = ["apple", "banana"]
|
||||
y = ["apple", "banana"]
|
||||
z = x
|
||||
print(x is z) # True (same object)
|
||||
print(x is y) # False (different objects)
|
||||
print(x == y) # True (equal values)
|
||||
```
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — `is None` 체크처럼, 값이 아닌 정확한 객체 동일성을 확인해야 할 때 사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
is vs == distinction (Python):
|
||||
```python
|
||||
x = [1, 2, 3]
|
||||
y = [1, 2, 3]
|
||||
print(x == y) # True (equal values)
|
||||
print(x is y) # False (different objects)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators Comparison]], [[Python None]]
|
||||
- **참조 맥락:** 값이 아닌 객체 동일성을 확인해야 할 때 사용 — `is None` 체크의 근거.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Identity Operators — https://www.w3schools.com/python/python_operators_identity.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Identity Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
id: python-operators-logical
|
||||
title: "Python Operators Logical"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Logical Operators", "파이썬 논리 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.9
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: ["merged duplicate chapter python_if_logical.asp (same topic, richer examples) on 2026-07-04"]
|
||||
tags: ["python", "programming", "w3schools", "operators", "logical"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_logical.asp", "https://www.w3schools.com/python/python_if_logical.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Logical]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`and`/`or`/`not` combine or invert conditional statements — `and` requires both true, `or` requires at least one true, `not` inverts the result — and Python evaluates `not` before `and` before `or` when they're combined. [S1][S2]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`and`** — True if both statements are true. [S1]
|
||||
- **`or`** — True if at least one statement is true. [S1]
|
||||
- **`not`** — reverses the result (True→False, False→True). [S1]
|
||||
- **Evaluation order** — `not` evaluates before `and`, which evaluates before `or`. [S2]
|
||||
- **Parentheses for clarity** — recommended when combining multiple logical operators, both to control evaluation order and to make intent readable. [S2]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Truth-table thinking** — `and` is true only for (True,True); `or` is false only for (False,False) — memorizing these two edge cases covers every case. [S2]
|
||||
- **Guard-clause style combination** — real-world conditions often combine range checks, negation, and a "membership"-style boolean in one expression (e.g. `(age < 18 or age > 65) and not is_student or has_discount_code`), so parenthesizing sub-groups is what keeps such an expression debuggable. [S2]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- AND: `x = 5; print(x > 0 and x < 10)`. [S1]
|
||||
- OR: `x = 5; print(x < 5 or x > 10)`. [S1]
|
||||
- NOT: `x = 5; print(not(x > 3 and x < 10))`. [S1]
|
||||
- Truth table (AND): (True,True)→True; any False present→False. [S2]
|
||||
- Truth table (OR): (False,False)→False; any True present→True. [S2]
|
||||
- Parenthesized complex condition: `if (temperature > 20 and not is_raining) or is_weekend: print("Great day for outdoor activities!")`. [S2]
|
||||
- Multi-variable auth check: `if username and password and is_verified: print("Login successful")`. [S2]
|
||||
- Range check via and: `if score >= 0 and score <= 100: print("Valid score")`. [S2]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음. 동일 주제가 W3Schools 사이트 내에서 "Operators" 섹션과 "Conditions" 섹션 양쪽에 거의 동일한 제목으로 중복 게재되어 있어, 이 문서에서 두 페이지 내용을 병합함. [S1][S2]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — if 조건문/Comparison Operators 챕터와 결합되어 복합 조건을 표현할 때 쓰인다. [S1][S2]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Parenthesized complex condition (Python):
|
||||
```python
|
||||
age = 25
|
||||
is_student = False
|
||||
has_discount_code = True
|
||||
if (age < 18 or age > 65) and not is_student or has_discount_code:
|
||||
print("Discount applies!")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 사이트 내 중복 챕터(python_if_logical.asp)를 발견해 이 문서로 병합함 (New discovery, then merged)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators Comparison]], [[Python If Statement]], [[Python Booleans]], [[Python Nested If]]
|
||||
- **참조 맥락:** 복합 조건 표현의 기본 — if/while 조건문에서 상시 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Logical Operators (Operators 섹션) — https://www.w3schools.com/python/python_operators_logical.asp
|
||||
- [S2] W3Schools — Python Logical Operators (Conditions 섹션, 확장판) — https://www.w3schools.com/python/python_if_logical.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Logical Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
- 2026-07-04: Merged content from the duplicate "Conditions" section chapter (python_if_logical.asp) — added truth tables, parenthesization guidance, and additional examples.
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: python-operators-membership
|
||||
title: "Python Operators Membership"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["in operator", "not in operator", "파이썬 멤버십 연산자"]
|
||||
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", "operators", "membership"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_membership.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Membership]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`in`/`not in` test whether a value exists within any sequence — lists and strings alike — using identical syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`in`** — True if a specified value is present in the sequence. [S1]
|
||||
- **`not in`** — True if a specified value is NOT present in the sequence. [S1]
|
||||
- **Works across sequence types** — lists and strings both support membership testing. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- List membership: `fruits = ["apple", "banana", "cherry"]; print("banana" in fruits)`. [S1]
|
||||
- List non-membership: `print("pineapple" not in fruits)`. [S1]
|
||||
- String membership: `text = "Hello World"; print("H" in text); print("hello" in text) # False, case-sensitive; print("z" not in text)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이미 Python Strings 챕터에서 문자열 대상 `in`이 선행 소개되었고, 여기서 리스트로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Membership test on a list (Python):
|
||||
```python
|
||||
fruits = ["apple", "banana", "cherry"]
|
||||
print("banana" in fruits)
|
||||
print("pineapple" not in fruits)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Strings]], [[Python Lists]], [[Python If Else]]
|
||||
- **참조 맥락:** 시퀀스(리스트/문자열)에 값이 존재하는지 확인할 때 사용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Membership Operators — https://www.w3schools.com/python/python_operators_membership.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Membership Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,66 @@
|
||||
---
|
||||
id: python-operators-precedence
|
||||
title: "Python Operators Precedence"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Operator Precedence", "파이썬 연산자 우선순위"]
|
||||
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", "operators", "precedence"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_operators_precedence.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Operators Precedence]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python evaluates parentheses first, then a fixed hierarchy from exponentiation down through logical OR, and falls back to left-to-right evaluation whenever two operators share the same precedence tier. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Operator precedence** — the order in which operations are performed. [S1]
|
||||
- **Parentheses highest** — expressions inside `()` are always evaluated first. [S1]
|
||||
- **Same-precedence tie-break** — left-to-right evaluation when precedence is equal. [S1]
|
||||
- **Precedence order (highest → lowest)** — `()` → `**` → unary `+x -x ~x` → `* / // %` → `+ -` → `<< >>` → `&` → `^` → `|` → comparisons/identity/membership (`== != > >= < <= is is not in not in`) → `not` → `and` → `or`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Parentheses first: `print((6 + 3) - (6 + 3))`. [S1]
|
||||
- Multiplication before addition: `print(100 + 5 * 3) # 115, not 315`. [S1]
|
||||
- Left-to-right on equal precedence: `print(5 + 4 - 7 + 3)` evaluates strictly left to right. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 복합 표현식의 평가 순서를 예측해야 할 때 항상 참조하는 표다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Multiplication evaluated before addition (Python):
|
||||
```python
|
||||
print(100 + 5 * 3) # 115
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Operators Arithmetic]], [[Python Operators Bitwise]], [[Python Operators Logical]]
|
||||
- **참조 맥락:** 모든 연산자를 종합한 우선순위 표 — 복합 표현식의 평가 순서 확인용.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Operator Precedence — https://www.w3schools.com/python/python_operators_precedence.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Operator Precedence" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,67 @@
|
||||
---
|
||||
id: python-output
|
||||
title: "Python Output"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Print", "print() function", "파이썬 출력"]
|
||||
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", "print", "output"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_output.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Output]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
print() displays text or values and ends with a newline by default, but the `end` parameter lets you override that to print on the same line. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **print() function** — displays text or output values; can be called as many times as needed. [S1]
|
||||
- **New line by default** — each print() call ends with a newline. [S1]
|
||||
- **Quoting required** — text must be inside quotes, either `"` or `'`; unquoted text raises a syntax error. [S1]
|
||||
- **`end` parameter** — overrides the default trailing newline, e.g. `end=" "` to keep printing on the same line. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic print: `print("Hello World!")`. [S1]
|
||||
- Either quote style works: `print("This will work!")` and `print('This will also work!')`. [S1]
|
||||
- Print without a new line: `print("Hello World!", end=" ")` followed by another print continues on the same line. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 모든 예제의 출력 확인에 반복적으로 사용되는 가장 기본적인 함수다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Print without a trailing newline (Python):
|
||||
```python
|
||||
print("Hello World!", end=" ")
|
||||
print("I will print on the same line.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Print Numbers]], [[Python Strings]], [[Python Variables Output]]
|
||||
- **참조 맥락:** 모든 코드 예제의 결과 확인에 쓰이는 가장 기본적인 함수.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Output / Print — https://www.w3schools.com/python/python_output.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Output / Print" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: python-output-variables
|
||||
title: "Python Output Variables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["파이썬 변수 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "variables", "print"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_variables_output.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Output Variables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Multiple variables can be printed together via comma (which handles mixed types safely) or `+` (which requires matching types and fails on string+number mixes). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comma-separated print** — `print(x, y, z)` outputs multiple variables. [S1]
|
||||
- **`+` operator concatenation** — `print(x + y + z)` also combines variables, but only works if types match. [S1]
|
||||
- **`+` on numbers** — acts as addition, not concatenation, when operands are numeric. [S1]
|
||||
- **Type mismatch error** — `print(x + y)` where `x` is a number and `y` is a string raises an error. [S1]
|
||||
- **Comma is the safe default** — commas support different data types simultaneously, unlike `+`. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Comma vs. plus trade-off** — comma auto-adds a space and tolerates mixed types; `+` requires manual spacing and same-type operands, but is needed when you want no separating space at all (by omitting it) or true numeric addition. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Comma-separated output: `x = "Python"; y = "is"; z = "awesome"; print(x, y, z)`. [S1]
|
||||
- Plus-concatenated output (same type): `print(x + y + z)`, noting trailing spaces must be added manually in each string. [S1]
|
||||
- Plus as addition (numbers): `x = 5; y = 10; print(x + y)`. [S1]
|
||||
- Type mismatch error: `x = 5; y = "John"; print(x + y)` fails. [S1]
|
||||
- Safe mixed-type output: `print(x, y)` where `x=5` and `y="John"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이후 문자열 포맷팅(f-string 등) 챕터에서 더 정교한 출력 방식이 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Safe mixed-type output via comma (Python):
|
||||
```python
|
||||
x = 5
|
||||
y = "John"
|
||||
print(x, y)
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Output]], [[Python Variables]], [[Python String Formatting]]
|
||||
- **참조 맥락:** 변수를 출력할 때 콤마 vs + 연산자 선택 기준.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python - Output Variables — https://www.w3schools.com/python/python_variables_output.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python - Output Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: python-pip
|
||||
title: "Python PIP"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pip install", "파이썬 패키지 관리자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "pip", "packages"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_pip.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python PIP]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
PIP ships with Python 3.4+ by default, and its command surface is small and symmetric — install/uninstall/list — with packages found via the pypi.org registry. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **PIP** — a package manager for Python packages/modules; included by default since Python 3.4. [S1]
|
||||
- **Package** — contains all files needed for a module. [S1]
|
||||
- **`pip install <name>`** — downloads and installs a package. [S1]
|
||||
- **`pip uninstall <name>`** — removes a package (with a y/n confirmation prompt). [S1]
|
||||
- **`pip list`** — lists all installed packages with versions. [S1]
|
||||
- **pypi.org** — the registry to find more packages. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Check version: `pip --version`. [S1]
|
||||
- Install: `pip install camelcase`. [S1]
|
||||
- Use it: `import camelcase; c = camelcase.CamelCase()`. [S1]
|
||||
- Uninstall: `pip uninstall camelcase` → confirm with `y`. [S1]
|
||||
- List installed: `pip list`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Python Virtual Environment 챕터에서 pip install이 격리된 환경 안에서 실행되는 맥락으로 확장된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Install and use a package (shell + Python):
|
||||
```
|
||||
pip install camelcase
|
||||
```
|
||||
```python
|
||||
import camelcase
|
||||
c = camelcase.CamelCase()
|
||||
txt = "hello world"
|
||||
print(c.hump(txt))
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Modules]], [[Python VirtualEnv]]
|
||||
- **참조 맥락:** 서드파티 패키지 설치의 기본 도구 — Virtual Environment 챕터에서 격리된 설치로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python PIP — https://www.w3schools.com/python/python_pip.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python PIP" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: python-pass-statement
|
||||
title: "Python Pass Statement"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["pass keyword", "파이썬 pass 문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "pass"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_if_pass.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Pass Statement]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Python cannot have a truly empty code block — a comment alone raises an IndentationError — so `pass` exists as an actual (no-op) statement that satisfies the syntax requirement while doing nothing. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`pass`** — a null operation; nothing happens when it executes; a placeholder. [S1]
|
||||
- **Why needed** — if/for/function/class blocks cannot be syntactically empty in Python. [S1]
|
||||
- **Common uses** — sketching structure before implementing logic, satisfying syntax when no action is needed, placeholders during development, empty functions/classes planned for later. [S1]
|
||||
- **`pass` vs. comments** — a comment is ignored entirely by Python and does NOT satisfy the "block needs a statement" requirement; `pass` does. [S1]
|
||||
- **Works in other contexts too** — loops, functions, classes, not just if statements. [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Comment-only block is a common beginner error** — `if score > 90: # comment` with no actual statement raises `IndentationError`, since comments aren't statements — `pass` is the fix. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic pass: `if b > a: pass`. [S1]
|
||||
- Comment-only block fails: `if score > 90: # This is excellent` alone raises IndentationError. [S1]
|
||||
- Fixed with pass: `if score > 90: pass # This is excellent`. [S1]
|
||||
- In a function stub: `def calculate_discount(price): pass # TODO: Implement discount logic`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 함수/클래스의 스텁(stub) 구현에 표준적으로 쓰이는 패턴이다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
pass as a function stub placeholder (Python):
|
||||
```python
|
||||
def calculate_discount(price):
|
||||
pass # TODO: Implement discount logic
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python If Statement]], [[Python For Loops]], [[Python Functions]]
|
||||
- **참조 맥락:** 빈 블록이 필요한 모든 곳(if/for/함수/클래스)에서 재사용되는 플레이스홀더.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Pass Statement — https://www.w3schools.com/python/python_if_pass.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Pass Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: python-polymorphism
|
||||
title: "Python Polymorphism"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["method overriding", "파이썬 다형성"]
|
||||
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", "polymorphism", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_polymorphism.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Polymorphism]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Polymorphism lets one for-loop call `.move()` on Car, Boat, and Plane objects uniformly — and combined with inheritance, a child class can inherit a method wholesale (Car) or override it entirely (Boat, Plane) while still fitting the same interface. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Polymorphism** — "many forms"; methods/functions/operators with the same name executable on many different objects/classes. [S1]
|
||||
- **Function polymorphism** — a single function like `len()` behaves appropriately across different types (string length, tuple item count, dict key-value pair count). [S1]
|
||||
- **Class polymorphism** — unrelated classes (Car, Boat, Plane) each define their own `move()`; calling `.move()` in a loop over mixed objects "just works" for each type. [S1]
|
||||
- **Inheritance + polymorphism** — child classes of a common parent can either inherit the parent's method unchanged (Car) or override it with their own version (Boat, Plane). [S1]
|
||||
|
||||
## 🧩 추출된 패턴 (Extracted patterns)
|
||||
- **Uniform iteration over mixed types** — `for x in (car1, boat1, plane1): x.move()` works regardless of each object's actual class, because polymorphism guarantees `.move()` exists on all of them with the same call signature. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `len()` across types: `len("Hello World!")`, `len(("apple","banana","cherry"))`, `len({"brand":"Ford",...})` — same function, different behavior per type. [S1]
|
||||
- Unrelated classes sharing a method name: `Car`, `Boat`, `Plane` each define `move()` independently. [S1]
|
||||
- Inheritance-based polymorphism: `Vehicle` parent defines `move()`; `Car` inherits it unchanged (`pass`), `Boat`/`Plane` override it with their own version. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 공통 인터페이스를 가진 서로 다른 객체를 동일한 코드로 다뤄야 할 때(예: 도형 넓이 계산) 표준적으로 쓰인다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Uniform call over heterogeneous objects (Python):
|
||||
```python
|
||||
class Vehicle:
|
||||
def move(self): print("Move!")
|
||||
class Car(Vehicle): pass
|
||||
class Boat(Vehicle):
|
||||
def move(self): print("Sail!")
|
||||
class Plane(Vehicle):
|
||||
def move(self): print("Fly!")
|
||||
|
||||
for x in (Car("Ford","Mustang"), Boat("Ibiza","Touring 20"), Plane("Boeing","747")):
|
||||
x.move()
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Inheritance]], [[Python Class Methods]]
|
||||
- **참조 맥락:** 공통 인터페이스를 가진 이종 객체를 동일하게 다룰 때 사용 — Inheritance와 결합해 메서드 오버라이드로 확장.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Polymorphism — https://www.w3schools.com/python/python_polymorphism.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Polymorphism" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: python-print-numbers
|
||||
title: "Python Print Numbers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Python Output Numbers", "파이썬 숫자 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.88
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["python", "programming", "w3schools", "print", "numbers"]
|
||||
raw_sources: ["https://www.w3schools.com/python/python_output_numbers.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[Python Print Numbers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Numbers passed to print() are never quoted, arithmetic can be evaluated directly inside the call, and mixing text with numbers just requires comma separation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Numbers are unquoted** — unlike text, numbers are not wrapped in quotes when printed. [S1]
|
||||
- **Inline math** — arithmetic expressions can be evaluated directly inside print(), e.g. `print(3 + 3)`. [S1]
|
||||
- **Mixing text and numbers** — separate them with a comma to combine both in one output call. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Print plain numbers: `print(3); print(358); print(50000)`. [S1]
|
||||
- Print arithmetic results: `print(3 + 3); print(2 * 5)`. [S1]
|
||||
- Mix text and numbers: `print("I am", 35, "years old.")`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
소스에서 모순되는 정보는 발견되지 않음.
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 텍스트와 숫자를 함께 출력하는 방식은 이후 Variables/Strings 챕터에서 더 다뤄진다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Mix text and numbers (Python):
|
||||
```python
|
||||
print("I am", 35, "years old.")
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.88
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[Python Tutorial]]
|
||||
- **관련 개념:** [[Python Output]], [[Python Numbers]], [[Python Strings]]
|
||||
- **참조 맥락:** 숫자 출력의 기본 문법 — Variables/Strings 챕터의 텍스트+숫자 결합으로 이어진다.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — Python Output Numbers — https://www.w3schools.com/python/python_output_numbers.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "Python Output Numbers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user