搜尋此網誌

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