Python交流
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,228
On Slideshare
1,220
From Embeds
8
Number of Embeds
2

Actions

Shares
Downloads
31
Comments
0
Likes
2

Embeds 8

http://www.slideshare.net 7
http://www.iweb34.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Python yanxu@staff.sina.com.cn 2009 11 4
  • 2. yield 2009 11 4
  • 3. def f1(t): newt = [] for i in t: newt.append(i+1) return newt def f2(t): for i in t: yield i+1 2009 11 4
  • 4. [i+1 for i in arr] (i+1 for i in arr) 2009 11 4
  • 5. __call__ 2009 11 4
  • 6. class M(object): def __init__(self,f): self.f = f def __call__(self,v): return v*self.f 2009 11 4
  • 7. >>>t2 = M(2) >>>t2(5) 10 >>>t3 = M(3) >>>t3(10) 30 >>>callable(t2) True 2009 11 4
  • 8. 2009 11 4
  • 9. __len__ 2009 11 4
  • 10. class A(object): def __len__(self): return 10 2009 11 4
  • 11. >>>a = A() >>>len(a) 10 2009 11 4
  • 12. from multiprocessing import Process,Pool,cpu_count 2009 11 4
  • 13. Meta Class 2009 11 4
  • 14. New Style vs Old Style 2009 11 4
  • 15. DClass = type(‘DClass’,(object,),{‘spam’:‘eggs’}) 2009 11 4