github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

shuckins / sph_code

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 1
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Assorted and divers code of varying length and utility. — Read more

  cancel

http://samuelhuckins.com/

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

 * Adding test of Blueprint 
shuckins (author)
Sat Jan 23 20:03:28 -0800 2010
commit  21510b631a0bf48337b3c83b29530f474577f544
tree    34647be00f88b661592216b70e0ccea46d56a393
parent  7c87c725ac36cc93fd0b1e6a0eb0a4f2cf56b415
sph_code / python-programming / utilities / utils.py python-programming/utilities/utils.py
100644 47 lines (40 sloc) 1.436 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
"""
Assorted utilities.
"""
 
def mf(obj, term):
    """
Searches through the methods defined for obj,
looks for those containing the term passed.
Prints all matches or 'No matches' if none found.
 
Initial version improved by Jason R. Coombs:
https://svn.jaraco.com/jaraco/python/jaraco.util/jaraco/lang/python.py
 
>>> mf(set, "diff")
['difference', 'difference_update', 'symmetric_difference', 'symmetric_difference_update']
"""
    methods = dir(obj)
    term = term.lower()
    result = [m for m in methods if term in m.lower()] or 'No matches'
    return result
 
def obinfo(obj):
    """
Print useful information about object.
 
From http://www.ibm.com/developerworks/library/l-pyint.html
 
Initial version improved by Jason R. Coombs:
https://svn.jaraco.com/jaraco/python/jaraco.util/jaraco/lang/python.py
"""
    if hasattr(obj, '__name__'):
        print "NAME: ", obj.__name__
    if hasattr(obj, '__class__'):
        print "CLASS: ", obj.__class__.__name__
    print("ID: ", id(obj))
    print("TYPE: ", type(obj))
    print("VALUE: ", repr(obj))
    print("CALLABLE:", ['No', 'Yes'][callable(obj)])
    if hasattr(obj, '__doc__'):
        doc = getattr(obj, '__doc__')
        doc = doc.strip()
        topfive = doc.split('\n')[0:4]
        print "DOC: ", "\n".join(topfive)
    else:
        print "No docstring. Yell at the author."
 
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server