推銷員之死

他們覺得我怎麼樣,我才不在乎吶!多少年他們取笑爸爸,你知道為甚麼?因為我們和這個瘋人院似的城市合不來!我們應該在空曠的原野攪拌洋灰,或者―或者做木匠。木匠是可以隨便吹口哨的!

多麼偉大的女性阿!上帝造了她之後,就把模子給毀了。

你跟他談話的時候,要是他桌上有甚麼東西掉在地上—比如說一個包兒或甚麼的—你可別把它撿起來。

我總是跟垃圾場泡上了!我剛付清汽車的分期付款,那架車快就要壽終正寢了。這個電冰箱好像鬼上身的瘋子一樣,橡膠帶剛換上就給咬斷了。他們是算準時間的,他們把機器算定時間,等你付清最後一期的錢,機器也就玩兒完了。

八十四歲的年紀,他不用走出房間,就可以靠這樣吃飯。我看在眼裡才恍然大悟,原來推銷員是個再好不過的行業。一個人到了八十四歲的年紀還能夠跑二三十個碼頭,拿起電話來就有那麼許多人記得他,喜歡他,幫他的忙。還有甚麼比這個更美的事嗎?你知道嗎?他死的時候──說起來,他死也死得像推銷員──他死的時候,有好幾百個推銷員和買主去送葬。一連幾個月有火車上有很多人為著他傷心。那時候講人品,講尊敬,講交情,講知恩必報。現在,甚麼都是死牌死板的,再也沒有講交情講人品的餘地了。你明白我的意思嗎?他們都不認識我了。

你不能像吃橘子一樣就把橘皮扔了的──人可不是水果阿!

這個世界只有你能賣錢的東西才是你的。可笑的是:你是個推銷員,可是連這個道理你都不懂。

這是豬狗不如的日子。我後悔世界大戰的時候,他們沒把我拉到軍隊裡去,到現在不見得就不活著了。

他只對我看了一眼───我就恍然大悟:我這一輩子整個而是多麼大一個謊,笑死人的謊!

在那座大廈半中間,我站住了,我瞧見───天空。我看見了世界上我心愛的東西。工作,吃的東西,和坐著抽菸的閒工夫,我望著那隻墨水筆,自己跟自己說:我他媽的偷這個東西幹嘛阿?為甚麼我要把自己變成一個我不願意做的人?為甚麼我要在一個辦公室裏做大傻瓜,苦苦哀求得讓人家瞧不起?實際上我所要的就在外邊兒等我,只要我開口說:我知道我是老幾!

發表留言

Python Beyond the Basics

Entities

  • class: blueprint for an instance
  • instance: a constructed object of the class
  • type: indicates the class/instance belongs to
  • attribute: value of any object
  • method: a callable attribute defined in the class

Instance Methods

  • instance methods are variables define in the class
  • when call through the instance, the instance is automatically passed as first argument (named self) to the method, e.g. below:
  • because of this automatic passing of the instance, instance method are known as “bound” methods, i.e. bound to the instance upon which it is called

Encapsulation

  • breaking encapsulation: setting the object value without using the setter method

 

  • enforce encapsulation:

Python Class Variable v.s. Instance Attribute

Set class variable and instance attribute the same name to show the difference and look up order:

The attribute look up order: when request an attribute to an instance, it looks for that attribute in the instance first then in the class.

Access class variable in instance:

Polymorphism

  • Different classes has same interface (i.e., method name), we can say that this group of related classes implement the same action
  • Being able to work with different types to call methods without checking it’s possible and handle errors using exception handling is called DOCK TYPING
  • Checking the type ahead of time is generally considered un-pythonic

An example from stackoverflow:

or an built in len method as an interface implemented by list and set object:

Inheriting the Constructor

  • __init__ can be inherited
  • if a class doesn’t have an __init__ constructor, Python will check its parent class, as soon as it finds one, Python calls it and stops looking
  • we can use the super() function to call method in the parents class, or we may want to initialize in the parent class

Depth-First Order

Multiple inheritance

After Python 2.3, add a role for diamond shape ambiguous inheritance

(Make C inherit A in this example)

Abstract Class

  • An abstract class is not designed to and can’t not construct instances, but subclassed by regular classes
  • An interface / methods that defined in abstract class must be implement by its subclass
  • The python abc module enables the creation of abstract class

Composition

  • Inheritance could be brittle (a change may require changes elsewhere)
  • Decoupled code could work independently or interactively
  • classes interactions will work with an interface
  • Not checking types: polymorphic and Pythonic

Here is an example for inheritance and composition working together:

Magic Functions

Attribute Encapsulation

  • @property should not encapsulate expensive operations, because attribute setting looks cheap
  • @property only controls attributes that are expected

“with” in Python

Custom Exception

 

發表留言