473,976 Members | 46,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filtering & Getting data out from a object

6 New Member
Hi,
I have written a the following python code to analyse a function or a method. I am having a script which is having a python function (add) and a class (MyClass) with a method (multiply).When I analyse it using the following method(analyze_ func) , I get an output like below.
The problem I am having is, I need to get the value 'MyClass.multip ly' from the obj. When I do obj.__name__ , I am only getting "multiply" only.So can anyone propose me how to get the value 'MyClass.multip ly'.



-----------------------------------------------
# OUTPUT
-----------------------------------------------
object passed to func() is <unbound method MyClass.multipl y>
Method: multiply

===testing code===
result is multiply
===testing code===

Method Arguments: var1 var2

object passed to func() is <function add at 0xb65aa7d4>
Function: add

===testing code===
result is add
===testing code===

Method Arguments: var1 var2

------------------------------------------------
# PYTHON SCRIPT
-----------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. def analyze_func(obj, method=False):   
  2.    str1 = ''
  3.    global result   
  4.    print '%s' % obj.__name__
  5.    print 'object passed to func() is ' , obj
  6.  
  7.    if method:
  8.        print 'Method: %s' % obj.__name__
  9.        strme = '%s' % obj.__name__
  10.        str1=strme
  11.  
  12.    else:
  13.        print 'Function: %s' % obj.__name__
  14.        strme = '%s' % obj.__name__
  15.        str1=strme      
  16.  
  17.  
  18.    arginfo = inspect.getargspec(obj)
  19.    args = arginfo[0]
  20.    argsvar = arginfo[1]
  21.  
  22.    print ''
  23.    print '===testing code==='
  24.  
  25.    a = arginfo[0]    
  26.  
  27.    print 'result is ' , str1
  28.    result = result + str1
  29.  
  30.    result = result + '@'
  31.  
  32.    print '===testing code==='
  33.    print ''
  34.  
  35.    if args:
  36.        if args[0] == 'self':
  37.            print '\t%s is an instance method' % obj.__name__
  38.            args.pop(0)
  39.        print '\tMethod Arguments: %s' % ' '.join(args)
  40.        if arginfo[3]:
  41.            dl = len(arginfo[3])
  42.            al = len(args)
  43.            defargs = args[al-dl:al]
  44.            print 'Default arguments:',zip(defargs, arginfo[3])
  45.  
  46.    if arginfo[1]:
  47.        print '\t Positional Args Param: %s' % arginfo[1]
  48.    if arginfo[2]:
  49.        print '\t Keyword Args Param: %s' % arginfo[2]
  50.  
  51.  
Apr 29 '08 #1
0 1027

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3168
by: Alex Ayzin | last post by:
Hi, I have a problem that might be easy to solve(possibly, I've just overlooked an easy solution). Here we go: I have a dataset with 2 datatables in it. Now, I need to do the following: if ds.table(0).rows(0).item("col1") = ds.table(1).rows(0).item("col2") then txtResult.text = ds.table(1).rows(0).item("col3")
4
6083
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3 script that grabs some web pages from the web, regex parse the data and stores it localy to xml file for further use.. at first i had no problem using python minidom and everything concerning
3
11125
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
1
1702
by: Jason | last post by:
I've gathered a bunch of data from Active Directory and placed it into a datatable ("ADTable"). I now need to sort and filter this table based on the selection of a drop down list("ddlCategory"). How can I filter the dataview of this datatable to display those records that match (partially or fully) the value selected in the drop down list? I have the following code that doesn't work, and returns zero rows (note that 'department' is a...
2
2614
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a good while and I'm getting really frustrated now! My problem is this - my custom controls periodically disappear from my
1
1468
by: dirk van waes | last post by:
Hello everyone, Being complete newbie in asp.net I am trying to make an example which works with a very simple database. First I made my project in VS- vb.net, draging an oledbconnection and an oledbdataadapter from the toolbox into my form. Everything worked fine on my local computer. I was able to search, update, delete and insert into my klanten.mdb database.
7
14832
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
2
2080
by: Gummy | last post by:
Hello All, I have a webpage that has two dropdown listboxes. Based on what is selected in these dropdown listboxes, it filters a DataGrid . That works fine. In the DataGrid , when I go to edit a row, I change the textbox (or other control), click Update, but it doesn't save my data. I then did this... In Page_Load, I added code to filter the DataGrid only when it was Not Page.IsPostBack. Then the editing/updating of the DataGrid data...
0
5594
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
11822
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5156
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3762
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.