搜尋此網誌

2026年9月29日星期二

Static and Instance Methods

String parsing usually means breaking down a string into smaller, meaningful components so you can work with them more easily.

Function chaining means calling multiple functions in sequence so that the output of one becomes the input of the next. It’s a way to build concise, readable pipelines.

Instance Methods

Definition: Regular methods that take self as the first parameter.

Purpose: Operate on a specific object (instance) of the class.

Access: Can access and modify instance attributes (self.name) and class attributes.

Static Methods

Definition: Declared with @staticmethod. They don’t take self or cls as the first parameter.

Purpose: Utility functions that logically belong to the class but don’t need access to instance or class data.

Access: Cannot access self (instance) or cls (class). They are independent.

A static attribute (also called a class attribute) is a variable defined directly inside a class body, outside of any methods. It belongs to the class itself rather than to individual objects, so all instances share the same value unless it’s overridden.

class WordSet:
    def __init__(self):
        self.words = set()
       
    def addText(self, text):
        text = WordSet.cleanText(text)
        for word in text.split():
            self.words.add(word)
           
       
    def cleanText(text):
        # chaining functions
        text = text.replace('!', '').replace('.', '').replace(',', '').replace('\'', '')
        return text.lower()
   
       
wordSet = WordSet()

wordSet.addText('Hi, I\'m Ryan! Here is a sentence I want to add!')
wordSet.addText('Here is another sentence I want to add.')

print(wordSet.words)

self.words = set() initializes an empty set.

A set automatically removes duplicates, so each word will only appear once.


Take a string (text) as input.

It calls WordSet.cleanText(text) to clean punctuation and lowercase the text.

Then it splits the text into words (text.split() → list of words).

Each word is added into self.words.

Because self.words is a set, duplicates are ignored.


Remove punctuation by chaining .replace() calls:

First removes !, then ., then ,, then '.

Finally, it converts the text to lowercase with .lower().

Example: "Hi, I'm Ryan!" → "hi im ryan"


You create a WordSet object.

You add two sentences.

Each sentence is cleaned, split, and words are stored in the set.

Finally, you print the set of unique words.


class WordSet:
    replacePuncs = ['!', '.', ',', '\'']
    def __init__(self):
        self.words = set()
       
    def addText(self, text):
        text = WordSet.cleanText(text)
        for word in text.split():
            self.words.add(word)
           
       
    def cleanText(text):
        # chaining functions
        for punc in WordSet.replacePuncs:
            text = text.replace(punc, '')
        return text.lower()
   
       
wordSet = WordSet()

wordSet.addText('Hi, I\'m Ryan! Here is a sentence I want to add!')
wordSet.addText('Here is another sentence I want to add.')

print(wordSet.words)


This is a class-level (static) attribute.

It belongs to the class WordSet, not to individual objects.

All instances of WordSet share the same list of punctuation marks to remove.

You can access it as WordSet.replacePuncs or wordSet.replacePuncs.


Loops through the static attribute WordSet.replacePuncs.

For each punctuation mark, it removes it from the text using .replace().

Finally, converts the text to lowercase.

Example: "Hi, I'm Ryan!" → "hi im ryan"


The @staticmethod decorator in Python is used to explicitly mark a method as a static method. This makes it clear that the method does not depend on the instance (self) or the class (cls). It’s essentially a utility function that just happens to live inside a class.


Microsoft Copilot

2026年9月28日星期一

製陶技法

「泥條盤築」是一種新石器時代常見的陶器成型技法,屬於手工製作方法之一。它的核心原理是用泥條一圈一圈盤繞、疊加,再拍打壓實,逐步築成器物的形體。這種方法在裴李崗文化、磁山文化等早期遺址中都有出土痕跡。

Microsoft Copilot

陶器術語一

「缽敝口」 是陶器學術術語,指缽類器物在製作或使用過程中,口沿出現破損、缺口或不完整的形態。這個詞常見於考古報告或古陶器描述,用來標註器物保存狀況。

Microsoft Copilot

陶器知識

夾砂紅陶是中國新石器時代常見的一類陶器,特徵是陶胎中摻入粗砂或細砂,以改善成型和燒製性能。它在裴李崗文化、磁山文化、仰韶文化等遺址中都有出土,是早期陶器技術的重要代表。

胎料:在陶泥中加入砂粒(粗砂或細砂),使胎體更耐火、不易開裂。

顏色:以紅色為主,因燒製時氧化氣氛強烈,形成紅陶。

火候:燒成溫度較低(約600–800℃),胎質疏鬆。

成型方式:多為手工拍打或泥條盤築,尚未使用陶輪。

Microsoft Copilot

裴李崗文化

裴李崗文化是中國新石器時代早期的重要文化之一,距今約9000–7000年,以河南新鄭裴李崗遺址為命名地。它標誌著中原地區由狩獵採集向定居農業過渡,出土了中國最早期的陶器、房屋遺跡和農業證據。

時間範圍:公元前7000–5000年(距今約9000–7000年)

核心遺址:河南新鄭市新村鎮裴李崗村

分布範圍:以新鄭為中心,東至河南東部,西至河南西部,南至大別山,北至太行山

重要遺址:賈湖遺址、石固遺址、中山寨遺址、莪溝北崗遺址等

陶器:泥質紅陶為主,夾砂陶與灰陶也有;典型器物包括小口雙耳壺、三足壺、深腹罐。

Microsoft Copilot

新石器時代陶器

磁山文化是中國華北地區新石器時代早期的重要考古文化,約公元前6000年至前5000年,核心遺址在河北武安磁山。它以最早人工栽培粟黍、最早馴養家雞、最早種植核桃而聞名,被視為世界農業與家禽馴化史的里程碑。

時間範圍:距今約8000–7000年前(公元前6000–5000年)

地理分布:太行山東麓、燕山南麓、黃河北部,核心在河北武安洺河流域

主要遺址:磁山遺址(河北武安)、坡上遺址(河北保定)、花窩遺址(河南淇縣)

陶器:手工夾砂陶,火候低,常見紋飾有繩紋、編織紋、篦紋;典型器物為三足陶盂與鳥頭形支座。

盂是指古代盛放食物或液體的大口器皿。

Microsoft Copilot

Google AI Overview

Starting the company

obligation: the state of being forced to do something because it is your duty, or because of a law, etc.

subtle: behaving or organized in a clever way, and using indirect methods, in order to achieve something

Bill Gates’s mother, Mary Maxwell Gates, was a trailblazing civic leader and the first female president of King County's United Way.

assuage: to make an unpleasant feeling less severe

give in: to admit that you have been defeated by somebody/something

perennial: continuing for a very long time; happening again and again

spat: (informal) a short argument about something unimportant

covet: to want something very much, especially something that belongs to somebody else

raspy: rough sound

Being self-conscious means feeling nervous, awkward, or uncomfortable because you worry about how other people see you or judge your actions.

bulldozer: a powerful vehicle with a broad steel blade (= cutting edge) in front, used for moving earth or knocking down buildings

domesticity: life at home with your family, taking care of the house, etc.

obsessed: preoccupied with or haunted by some idea, interest, etc.

Bill Gates "Source Code"

Online Dictionaries Used:

hk.dictionary.search.yahoo.com

www.oxfordlearnersdictionaries.com

www.merriam-webster.com/dictionary

Google AI Overview

信念與感知

pinprick: a small puncture made by or as if by a pin

fluke: a lucky or unusual thing that happens by accident, not because of planning or skill

ingrained (in somebody/something) (of a habit, an attitude, etc.) that has existed for a long time and is therefore difficult to change

Our beliefs can change our perception of the world around us and how we interpret it.

我們的信念會改變我們對周遭世界的感知,以及我們對其的詮釋方式。

個人或群體長期持有的想法、價值觀或假設,會影響我們注意、感受與觀察周遭事物的方式,並改變我們賦予這些感知的意義、判斷,以及對事件原因與重要性的解讀。

Nicole Vignola "Rewire"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

merriam-webster.com/dictionary

Microsoft Copilot

2026年9月27日星期日

Milkshake experiment

indulgent: (usually disapproving) tending to allow somebody to have or do whatever they want

ghrelin: a peptide hormone, produced predominantly in the stomach, that stimulates the secretion of growth hormone from the pituitary gland and increases appetite

「奶昔實驗」顯示:我們的身體不僅受食物營養影響,更受「心態」影響。參與者喝的是同一杯奶昔,但因為相信它是「高熱量放縱版」或「低熱量健康版」,身體的飢餓激素反應完全不同。

奶昔實驗的設計

  • 研究人員:耶魯大學與亞利桑那州立大學心理學家

  • 參與者:46位成年人

  • 方法:每位參與者分兩次喝同一杯 380卡路里奶昔,但標籤不同:

    • 一次標示為「放縱版」:620卡路里,濃郁、罪惡感重

    • 一次標示為「健康版」:140卡路里,輕盈、低卡

  • 測量:透過抽血檢測胃饑素 (ghrelin),這是一種控制飢餓與飽足感的激素。

實驗結果

  • 放縱版心態:參與者相信自己喝了高熱量奶昔 → 胃饑素急速下降,身體表現出「很飽」的反應。

  • 健康版心態:參與者相信自己喝了低熱量奶昔 → 胃饑素幾乎不變,身體表現出「還不夠飽」的反應。

  • 關鍵:兩杯奶昔其實完全一樣,但身體反應卻因「心態」不同而改變。

 意義與啟示

  • 心態影響生理:不只是心理感覺,連激素水平也會因「期待」而改變。

  • 挑戰傳統觀念:不僅僅是卡路里或營養決定飽足感,我們的認知與信念同樣重要。

  • 生活應用:

    • 如果把餐點視為「足夠、滿足、滋養」,身體更容易感到飽足。

    • 若總覺得自己在「節食、受限」,可能會持續感到飢餓,即使吃得足夠。

Nicole Vignola "Rewire"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

Microsoft Copilot

2026年9月22日星期二

陶瓷術語五

「篦劃紋」是陶瓷工藝中一種非常典型的裝飾技法。它的做法是用篦子(細齒狀工具) 在尚未完全乾硬的陶胎表面劃出規律的紋路。

工藝特徵

工具:篦子,形似梳子,齒密而均勻。

方法:在陶泥半乾時劃紋,留下平行或交錯的細線。

效果:紋路整齊,具有節奏感和裝飾性。

Microsoft Copilot

陶瓷術語四

陶瓷工藝語境:多指「淘洗」原料

將瓷石或陶土粉碎後,加水攪拌、沖洗,讓細顆粒隨水流進入淘洗池,粗顆粒和雜質被篩掉或沉澱。

經過一兩次淘洗後,料漿再進入沉澱池自然沉澱,擠乾水分,成為較純淨、細緻的坯料。

目的:去除鐵質、砂粒等雜質,提高泥料的純度與可塑性,使燒成後的胎體更細膩、顏色更均勻。

Perplexity.ai

陶瓷術語三

「陶泥」就是製作陶瓷器物的主要原料,也就是我們常說的「陶土」。它在陶瓷工藝裡扮演着非常重要的角色,因為胎體的品質、顏色、強度都取決於陶泥的性質。

陶泥的特點

成分:主要由黏土礦物(如高嶺土)、石英、長石等混合而成。

可塑性:濕潤時柔軟,容易塑形;乾燥後硬化,燒製後更堅固。

顏色:不同礦物含量會影響燒成後的顏色,例如白胎、紅胎、黑胎。

工藝流程

選泥:挑選合適的陶泥,決定器物的胎質。

練泥:反覆揉合,排除氣泡,讓泥質均勻。

成型:拉坯、捏塑或模具成型。

乾燥:自然或人工乾燥,避免開裂。

燒製:高溫燒成,陶泥轉化為堅硬的胎體。

Microsoft Copilot

「陶泥」是指用來製作陶器的黏土原料,又稱「陶土」,是一種具有良好可塑性、含鐵質而帶黃褐色、灰白色或紅紫色等色調的天然黏土。

與瓷泥的區別

陶泥(陶土):含鐵量和含砂量較高,雜質多,燒成溫度較低(約 1000–1150°C),胎體多孔、顏色較深,一般用於陶器。

瓷泥(瓷土/高嶺土):較純淨、含鐵量低,燒成溫度高,胎體緻密、白色或近白,部分可透光,用於瓷器。

Perplexity.ai

陶瓷術語二

「胎體」在陶瓷、瓷器或工藝品領域中,是一個非常核心的概念。簡單來說,它指的是器物的主體骨架,也就是在上釉、裝飾之前的坯體。

胎體若厚重,撇口就顯得穩重;胎體若輕薄,撇口則更顯秀雅。

Microsoft Copilot

瓷器在未燒之前稱為「坯」,燒成後就稱為「胎」;胎體就是這層坯燒結後形成的本體。

廣義上,胎體可以是由黏土、瓷土、金屬、竹木等材料製成的基底,其上再施釉、髹漆或裝飾。

在瓷器語境中,「胎體」通常專指瓷土燒成的內部質地,不包括表面的釉和彩。

胎體被視為瓷器的「骨肉」之一,是判斷產地、年代與真偽的關鍵依據:

  • 不同窯口使用的原料(如含鐵量高低)會使胎色、胎質明顯不同,例如:

  1. 鐵含量高:胎色偏灰、深灰、灰黑甚至黑色。
  2. 鐵含量低:胎色偏灰白、米白或白色。

  • 各時代的胎土配方、燒成溫度、修足工藝不同,形成可辨識的時代特徵,例如:

  1. 成化時期胎質細膩純淨,胎體多輕薄,迎光透視呈牙白或肉紅色。

  • 鑑定時常從露胎無釉的部位(如底足、開片處、斷面)觀察胎體的顏色、顆粒感、緻密度與輕重。
Perplexity.ai

陶瓷術語一

「瓶撇口」通常指的是瓶子在製作或使用過程中,瓶口邊緣被削斜或切斜的一種形態。

直口瓶子簡單實用,但撇口更講究工藝與使用體驗。

中國傳統陶瓷常見「撇口瓶」,例如宋代汝窯、明清青花瓷,瓶口略向外展,既美觀又實用。

Microsoft Copilot

在古董瓷器目錄或鑑定書中,常見句式如:「瓶撇口,短束頸,豐肩……」

這裡的「瓶撇口」=「此瓶為撇口(口沿外撇)」。

換句話說,它是在說明:這件瓶子的口部特徵是外撇的喇叭口。

Perplexity.ai

2026年9月20日星期日

Calculation of aperture

The f-number scale increases by multiples of
2the square root of 2 end-root
(approximately 1.414)
because doubling or halving the light entering the camera requires doubling or halving the area of the circular aperture, not its diameter.

Here is the simple mathematical breakdown of why this happens:

1. Light and Area
The amount of light that passes through a lens depends entirely on the area (A) of the optical opening. Since the aperture is a circle, its area is calculated using the formula:

This shows that the area (
Acap A
) is proportional to the square of the diameter (
D2cap D squared
)
.

2. The Inverse Relationship
From your previous formula, the diameter is
. This means the f-number (
Ncap N
) is in the denominator.
  • To let in half the light, you need half the area.
  • To get half the area, you must reduce the diameter by a factor of
    2the square root of 2 end-root
    .
  • Because
    Ncap N
    is inversely proportional to
    Dcap D
    , you must multiply the f-number by
    2the square root of 2 end-root
    to make the opening smaller by that exact ratio.
Google Gemini

Let 焦距 (f) be 35 mm and F值 (N) = 2

光圈孔直徑 (D) = f / N

D = 35 mm ÷ 2 = 17.5 mm

A = 3.1416 * 8.75mm * 8.75mm = 240.5 mm square

0.5 A = 3.1416  * r * r = 120.3 mm square

r * r = 38.3 mm square

r = 6.2 mm

Original diameter is 17.5mm
Area in half, new diameter is 12.4mm

D = f / N
12.4 = 35 / N
N = 2.8

2026年9月17日星期四

Main Uses of Microsoft PowerToys

1. Window & Workspace Management

  • FancyZones: Create custom window layouts (grids, columns, multi‑monitor setups) for efficient multitasking.

  • Always on Top: Pin a window above others with a shortcut.

  • Crop and Lock: Turn part of a window into a separate interactive thumbnail.

  • Grab and Move: Resize/move windows by dragging anywhere inside them with a modifier key.

2. File & Explorer Enhancements

  • PowerRename: Bulk rename files with regex or case conversion.

  • Image Resizer: Right‑click images to resize in batches.

  • File Explorer Add‑ons: Preview pane support for SVG, Markdown, PDF, and more.

  • File Locksmith: See which processes are locking a file.

  • Peek: Preview file contents instantly without opening apps.

3. Keyboard & Input Tools

  • Keyboard Manager: Remap keys or create custom shortcuts system‑wide.

  • Text Extractor (OCR): Copy text from images, PDFs, or dialogs.

  • Quick Accent: Type accented characters easily.

4. Mouse & Display Utilities

  • Find My Mouse: Highlight cursor with a double‑tap of Ctrl.

  • Mouse Highlighter & Crosshairs: Useful for presentations.

  • Power Display: Control monitor brightness, contrast, and input source.

  • Mouse Without Borders: Use one keyboard/mouse across multiple PCs.

5. System & Workflow Tools

  • PowerToys Run (Alt+Space): Instant launcher for apps, files, commands, and calculations.

  • Awake: Keep PC awake without changing system sleep settings.

  • Hosts File Editor: Manage domain/IP mappings.

  • Environment Variables Manager: Organize profiles for development.

  • Light Switch: Auto switch between light/dark themes.

  • Command Not Found: Suggests WinGet packages when a PowerShell command fails.

Microsoft Copilot

2026年9月16日星期三

Achilles tendon

Achilles:希臘英雄阿基里斯(Achilles),他全身刀槍不入,唯獨腳踝是弱點。

是人體最強壯、最厚的腱,但也容易受傷(例如運動員的「阿基里斯腱斷裂」)。

Microsoft Copilot

Keep yourself busy

if somebody/something works or happens in tandem with somebody/something else, they work together or happen at the same time

The Central Executive Network (CEN), also called the Frontoparietal Network, is a large‑scale brain system responsible for executive functions like working memory, decision‑making, and goal‑directed behavior. It is mainly anchored in the dorsolateral prefrontal cortex and posterior parietal cortex. 

ponder: to think about something carefully for a period of time

see-saw:  a piece of equipment for children to play on consisting of a long flat piece of wood that is supported in the middle. A child sits at each end and makes the see-saw move up and down.

The Salience Network (SN) is a core brain system that acts like a “switchboard,” helping you detect important internal and external stimuli and decide whether to engage the Default Mode Network (DMN) or the Central Executive Network (CEN).

salience: ​the quality of being particularly important or easy to notice

revert to something: to return to a former state; to start doing something again that you used to do in the past

dismantle something: to end an organization or a system gradually in an organized way

Emerging evidence means new, freshly uncovered, or developing facts and data that support a specific trend, hypothesis, or shift in clinical, scientific, or social understanding.

render: to cause somebody/something to be in a particular state or condition

vivid: (of memories, a description, etc.) producing very clear pictures in your mind

utmost: greatest; most extreme

unapologetically: without saying or showing that you are sorry about something, even in situations in which other people might expect you to

notable: deserving to be noticed or to receive attention; important

confines: limits or borders

Nicole Vignola "Rewire"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

dictionary.cambridge.org

Microsoft Copilot

Dreaming again

Canon EOS R8 Mark II is an entry level camera. RF 24‑105mm f/4L is a luxury lens. Although lens is more important than body, is it worthwhile to buy a luxury lens for an entry level camera?

This is a really thoughtful question — and it touches on one of the most debated topics in photography: is it better to invest in the lens or the body?

Lens importance: The lens defines sharpness, contrast, color rendering, and bokeh. A high‑quality lens like the RF 24‑105mm f/4L IS USM will deliver professional‑grade results even on an entry‑level body.

Body importance: The camera body contributes sensor performance, autofocus speed, ergonomics, and video features. But bodies evolve quickly — today’s “entry‑level” R8 Mark II already has IBIS, advanced AF, and strong video specs.

Yes, it’s worthwhile if you see photography as a long‑term pursuit. The lens will outlast the body and can move with you when you upgrade to R6 Mark III or R7 later.

No, it’s less worthwhile if budget is tight and you mainly shoot casual travel or family photos — in that case, the RF 24‑105mm STM (~395g, cheaper) gives good results without overspending.

Canon EOS R8 Mark II body is indeed lighter than the RF 24‑105mm f/4L IS USM lens. The center of gravity shifts forward. This is common with mirrorless cameras, since bodies are designed to be compact while pro lenses remain substantial.

Balance: You’ll feel the weight in your left hand supporting the lens, not in the grip. A wrist strap or tripod helps for long sessions.

Image quality: The L‑series optics more than compensate for the imbalance — sharper, better contrast, weather‑sealed.

Microsoft Copilot

2026年9月15日星期二

太空軍備競賽

The U.S. Space Force just made history: Air Force Secretary Troy Meink publicly confirmed for the first time that the U.S. has deployed on-orbit space weapons to defend against hostile adversaries. This marks a major shift in U.S. military transparency and could accelerate an arms race in space.

adversary: a person that somebody is opposed to and competing with in an argument or a battle

Microsoft Copilot

www.oxfordlearnersdictionaries.com

Prime lens

大光圈定焦鏡雖然提升低光能力,但景深淺、只能把焦點放在某一位置、背景會模糊。

攝影時的直接調整(最推薦先嘗試)

  • 縮小光圈:把 f/2 改為 f/2.8 或 f/4 可顯著增加景深。若光線不足,可同步提高 ISO 或放慢快門(注意手持極限)。適用於可控制曝光或靜態場景。
  • 拉遠距離 / 改變構圖:把相機往後退、或讓被攝體離背景更近/遠,能改變景深感與背景模糊程度。這是最不破壞畫質的方式。

大光圈定焦鏡提供的是「畫面語言與光學特性」而非單純的曝光補償。

低光手持能力:即使有三腳架,很多場景需要手持快速反應(街拍、活動),大光圈能讓你用更低 ISO 或更快快門。

創作限制促進進步:定焦限制你移動與構圖,反而能鍛鍊視覺判斷與主題處理。

體積與重量:某些大光圈定焦比高端變焦更輕便,長時間外拍更省力。

Microsoft  Copilot

Anatomy of a class

In Python, instance attributes are variables that belong to a specific object created from a class. They are usually defined inside the __init__ method using self, and each object has its own independent copy of these attributes. This makes them different from class attributes, which are shared across all instances.

class Car:

    def __init__(self, brand, model):

        # Instance attributes

        self.brand = brand

        self.model = model


car1 = Car("Toyota", "Camry")

car2 = Car("Honda", "Civic")


print(car1.brand, car1.model)  # Toyota Camry

print(car2.brand, car2.model)  # Honda Civic


class Dog:
    def __init__(self, name):
        self.name = name
        self.legs = 4
    
    def speak(self):
        print(self.name + ' says: Bark!')

myDog = Dog('Rover')
print(myDog.name)
print(myDog.legs)

Class Definition
You define a class Dog with an __init__ method and a speak method.

__init__ Method
Runs automatically when you create a new Dog object.
self.name = name → assigns the given name to the instance.
self.legs = 4 → every dog object starts with 4 legs.

Instance Attributes
self.name and self.legs are instance attributes.
Each Dog object has its own copy of these attributes.

Creating an Object
myDog = Dog('Rover') → creates a new Dog instance with name = "Rover" and legs = 4.

Accessing Attributes
print(myDog.name) → prints "Rover".
print(myDog.legs) → prints 4.

Method Usage
If you call myDog.speak(), it will print:
Rover says: Bark!

adorable: very attractive and easy to feel love for

Static attributes in Python are what we usually call class attributes. Unlike instance attributes (unique to each object), static/class attributes are shared across all instances of the class. They are defined directly inside the class body, not inside __init__.

connotation: ​an idea suggested by a word in addition to its main meaning

In Python, a getter function is a method that allows you to safely access (or "get") the value of an attribute from a class. It’s often used together with properties to control how attributes are read, especially when you want to add validation, formatting, or encapsulation.

Encapsulation in Python is the practice of bundling data (attributes) and the methods (functions) that operate on that data into a single unit, typically a class. Its primary goal is to hide internal implementation details and restrict direct access to an object's state to prevent accidental modifications.

class Dog: _legs = 4 # static/class attribute def __init__(self, name): self.name = name # instance attribute def getLegs(self): # getter function return self._legs def speak(self): print(self.name + ' says: Bark!') myDog = Dog('Rover') print(myDog.name) # Rover print(myDog.getLegs()) # 4


In your example, you’ve introduced a static (class) attribute _legs and a getter function getLegs() to access it.

Static/Class Attribute (_legs)
Defined directly in the class body (_legs = 4).
Shared across all Dog objects.
Accessible via Dog._legs or through an instance (myDog._legs).

Instance Attribute (name)
Defined inside __init__ using self.name.
Unique to each object (e.g., Rover, Buddy, Max).

Getter Function (getLegs)
Provides controlled access to the static attribute.
Returns self._legs, which refers to the class-level _legs.

myDog = Dog('Rover') myDog._legs = 3 print(myDog.name) print(myDog.getLegs()) print(Dog._legs)

Class Attribute _legs = 4
Defined at the class level.
Shared by all Dog objects unless shadowed.

Instance Creation
myDog = Dog('Rover') → creates a new dog with name = "Rover".
At this point, myDog sees _legs from the class (Dog._legs = 4).

Assigning myDog._legs = 3
This does not change the class attribute.
Instead, it creates a new instance attribute _legs on myDog only.
Now myDog has its own _legs = 3, shadowing the class’s _legs.

Printing Values
print(myDog.name) → "Rover" (instance attribute).
print(myDog.getLegs()) → 3 (because self._legs now refers to the instance attribute).
print(Dog._legs) → 4 (class attribute remains unchanged).

Microsoft Copilot