Python's extra-clever function parameters
I'm not sure where I ran across this, but until recently I wasn't awarethat you could pre-explode lists and tuples when you declared whatparameters a function takes. That sounds stilted, so I'll give anexample:
def foo(a, (b, c, d)): print a, b, c, d
This is slightly more compact than the equivalent:
def bar(a, tmp): b, c, d = tmp print a, b,
霍元甲
刻度
我拒絕了母親和學生的約會,把自己鎖在斗室裡。收到認識的人的電話、很久沒見的朋友的
Weekly spam summary on February 25th, 2006
Here's how Hotmail stacks up this week:
- 4 messages accepted; unfortunately, one of them was definitely spamand at least two more probably were.
- 21 messages rejected because they came from non-Hotmail emailaddresses.
- 49 messages sent to our spamtraps.
- 4 messages refused because their sender addresses had already hitour spamtraps.
- 6 messages refused due to their origin IP address, all for beingin the SBL ; four from SBL17935 ,one from SBL27471 ,
The hassle of email (as compared to RSS)
In my recent 'give me RSS feeds' entry I wrote in passing '[...] these daysemail is just too much of a hassle'. Which it is. Let me illustrate how.
To subscribe to new mailing lists these days I need to:
- figure out how to subscribe
- make up a new email address to give the list
- go through a multi-stage subscription dance
- make sure our antispam filters won't eat the list messages
- adjust my filters to put the messages somewhere distinct
- remember to check
如同沒有,時間的刻度
每當時日過去,我覺得自己想要扭頭細數人生,就以這詩來抵擋。每一句都打擊我的心臟
A trick for handling mutable default arguments
One of the neat things about programming in Python is finding out aboutclever little idioms that are obvious in retrospect. My latest find isa little trick for handling mutable function arguments.
As I mentioned back when discussing the consequences of def beingan executable statement , the way I'd beenhandling mutable default arguments was something like:
def foo(a, blst = None): if blst is None: blst = []
At two lines, this is just verbose enough to grate lightly butirritatingly on my nerves
More clever (ab)use of and and or
In a comment on the last entry Imumbled yet again how I was annoyed that Python doesn't have anequivalent of C's '? :' conditional expression operator. Thensome neurons in the back of my mind woke up and asked 'didn'tGuido van Rossum say he was going to add this to Python 2.5 ?'
In the process of trying to figure out if thiswas still happening (it is), I read this message (via here )and found out about a
表面的和平
Wanted: RSS feeds for vendor software updates
Vendors, I have a simple request for you: give me an RSS feed foryour security fixes and system updates . No, please don't suggest thatI subscribe to your email announcement list, because these days emailis just too much of a hassle. Accept it; RSS is the new lightweightnotification format, and notification of new updates is just what Iwant.
And don't just give us one global RSS feed of everything. Be modern; letpeople get narrow feeds as well as broad ones