Differences between revisions 4 and 11 (spanning 7 versions)
Revision 4 as of 2005-12-01 02:12:01
Size: 412
Editor: limodou
Comment:
Revision 11 as of 2009-12-25 07:15:55
Size: 1651
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
##language:zh
Line 6: Line 5:
::-- limodou [[[DateTime(2005-12-01T01:50:56Z)]]]
[[TableOfContents]]
::-- limodou [<<DateTime(2005-12-01T01:50:56Z)>>]
<<TableOfContents>>
Line 11: Line 10:
It's an functions capsulation module, which can make sequence functions a single object, and execute in order. And it also can make functions run as a thread, you can choose onprocess callback function to show the execution status. It will support multi thread schedule. It will make all these things easily.
Line 13: Line 14:
 * Or you can just download it from here attachment:Casing.py  * Or you can just download it from here [[attachment:Casing.py]]
Line 16: Line 17:
== Example 1: Capsulate some functions together ==

{{{#!python
import Casing

def test_A():
    print 'A'
       
def test_B():
    print 'B'
       
def test_C():
    print 'C'
       
d = Casing.Casing(test_A) + Casing.Casing(test_B) + Casing.Casing(test_C)
d.start()
}}}

As you can see, three functions are bundled as a single '''Casing''' object, and it can be execute together in the order of bundle. There are many methods to create a Casing object, you can also write the code as:

{{{#!python
d = Casing.Casing(test_A)
d += Casing.Casing(test_B)
d += Casing.Casing(test_C)
d.start()
}}}

or using left add (+=)

{{{#!python
d = Casing.Casing(test_A)
d.append(test_B)
d.append(test_C)
d.start()
}}}

using append method or

{{{#!python
d = Casing.Casing()
d.append(test_A)
d.append(test_B)
d.append(test_C)
d.start()
}}}

creating an empty Casing object and append function later.

Description the usage of Casing module ::-- limodou [2005-12-01 01:50:56]

1. What's it?

It's an functions capsulation module, which can make sequence functions a single object, and execute in order. And it also can make functions run as a thread, you can choose onprocess callback function to show the execution status. It will support multi thread schedule. It will make all these things easily.

2. Download

  • Casing module is shipped with NewEdit, so you can download the NewEdit source code and find it in modules folder.

  • Or you can just download it from here Casing.py

3. Examples

3.1. Example 1: Capsulate some functions together

   1 import Casing
   2 
   3 def test_A():
   4     print 'A'
   5        
   6 def test_B():
   7     print 'B'
   8        
   9 def test_C():
  10     print 'C'
  11        
  12 d = Casing.Casing(test_A) + Casing.Casing(test_B) + Casing.Casing(test_C)
  13 d.start()

As you can see, three functions are bundled as a single Casing object, and it can be execute together in the order of bundle. There are many methods to create a Casing object, you can also write the code as:

   1 d = Casing.Casing(test_A)
   2 d += Casing.Casing(test_B)
   3 d += Casing.Casing(test_C)
   4 d.start()

or using left add (+=)

   1 d = Casing.Casing(test_A)
   2 d.append(test_B)
   3 d.append(test_C)
   4 d.start()

using append method or

   1 d = Casing.Casing()
   2 d.append(test_A)
   3 d.append(test_B)
   4 d.append(test_C)
   5 d.start()

creating an empty Casing object and append function later.

4. FeedBack

Casing (last edited 2009-12-25 07:15:55 by localhost)