Hi,
How to check the class attributes/member variable values while debuging in 'PythonWin'?.
I need to watch all the member varibales values of a class ,given the object or etc.
Thanks
PSB
4 1752 bvdet 2,851
Recognized Expert Moderator Specialist
Hi,
How to check the class attributes/member variable values while debuging in 'PythonWin'?.
I need to watch all the member varibales values of a class ,given the object or etc.
Thanks
PSB
This is what I use to check the contents of an instance dictionary: - def formatDict(hdr_str, dd):
-
listCopy = dd.keys()
-
listCopy.sort()
-
maxLen = max([len(i) for i in listCopy])
-
return '%s%s%s' % (hdr_str, "\n", ''.join(["Key = %s %s Value = %s\n" % \
-
(i, " " * (maxLen - len(i)) + " ", dd[i]) for i in listCopy]))
-
-
a = YourClass()
-
print formatDict("\nObject Attributes:", a.__dict__)
HTH :)
This is what I use to check the contents of an instance dictionary: - def formatDict(hdr_str, dd):
-
listCopy = dd.keys()
-
listCopy.sort()
-
maxLen = max([len(i) for i in listCopy])
-
return '%s%s%s' % (hdr_str, "\n", ''.join(["Key = %s %s Value = %s\n" % \
-
(i, " " * (maxLen - len(i)) + " ", dd[i]) for i in listCopy]))
-
-
a = YourClass()
-
print formatDict("\nObject Attributes:", a.__dict__)
HTH :)
Thanks for the reply,
It is not a dictionary,it is a class attributes.Whic h I would like to watch in the Debug window of the python
-PSB
bvdet 2,851
Recognized Expert Moderator Specialist
Thanks for the reply,
It is not a dictionary,it is a class attributes.Whic h I would like to watch in the Debug window of the python
-PSB
I always debug with print statements. To check the status of class attributes, you can do something like this: - class Demo:
-
a1 = 1
-
a2 = 2
-
def __init__(self, data={}):
-
self.data = data
-
def chk_att(self):
-
for item in ['a1', 'a2']:
-
print '%s = %s' % (item, eval('Demo.%s' % item))
-
-
-
print '\n'.join(['%s = %s' % (item, eval('Demo.%s' % item)) for item in dir(Demo) if item in ['a1', 'a2']])
-
print
-
a = Demo([1,2,3,4])
-
a.chk_att()
-
-
print
-
-
Demo.a2 = 5000
-
print '\n'.join(['%s = %s' % (item, eval('Demo.%s' % item)) for item in dir(Demo) if item in ['a1', 'a2']])
-
print
-
a.chk_att()
- >>> a1 = 1
-
a2 = 2
-
-
a1 = 1
-
a2 = 2
-
-
a1 = 1
-
a2 = 5000
-
-
a1 = 1
-
a2 = 5000
-
>>>
bartonc 6,596
Recognized Expert Expert
Hi,
How to check the class attributes/member variable values while debuging in 'PythonWin'?.
I need to watch all the member varibales values of a class ,given the object or etc.
Thanks
PSB
Since I don't use PythonWin (or any other debugger), I use the inspect module: -
>>> import inspect
-
>>> class aClass:
-
... aValue = 1
-
... bValue = 'test'
-
...
-
>>> anInstance = aClass()
-
>>> print [(name, value) for name, value in inspect.getmembers(anInstance) if not name.startswith("_")]
-
[('aValue', 1), ('bValue', 'test')]
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: mickeyg |
last post by:
Is there a way to step thru php application?
What tools do I need?
I will like to see what lines are being executed and maybe variables values
Thanks in advance
|
by: Vincent Finn |
last post by:
Hi,
I have some controls (VB.Net) written be someone else
They are loaded using an asp page
How can I debug the contol?
I have tried attaching the process to IExplorer and aspnet_wp.exe but
I get nothing, no breakpoints are hit
I assume it is something simple but I can't find it in the MSDN.
|
by: serge calderara |
last post by:
Dear all,
I try to debug a strore procedure within VS studio server explorer.
Problem I have is when selecting my store procedure and then Step into menu
I get error message that I have no debug rights on master db or something
like that
What should I do to make it working
Thnaks for your help
|
by: joe |
last post by:
Hi when iam writing a console program it is preatty simple to ouput
variables to stdout, but how do i do that with a windows app?
i am compiling a windows app tha uses cp and cpp libs and i am trying to
get the parametes for a function inside the function. is there a way to pop
up a window with the value? or do i have to write them to a file?
|
by: bob |
last post by:
Hello,
I've tried a few testing frameworks with C# but so far haven't found a
way to debug into a failing test. I'm used to S Unit (Smalltalk)
where when a test fails you just right click on it and say debug and
the program halts at the point where the test fails. This makes it
very easy to debug the test as you have the stack, locals etc. At
them moment I'm having to recompile the main loop to call the failing
test and put a break in...
| |
by: Jason |
last post by:
In the c++ debugger I could give it a memory address of some data and it
would break when that data changed. It is very helpful when you have a
single value change of a large amount of code and you just want to know
what/where/why its changing. I tried to hook it up like I in C++, opening up
the new break point window, going to the data tab and supplying a pointer...
just for fun I put in the var name ( since there are no pointers in c# )...
|
by: FOX User Group |
last post by:
Hi,
Migh be this is the stupid question, does anyone know the root cause of the
following problem:
1. I create project Web Application, say just put label 'Testing" on the
page
2. I run the web page by pressing F5 key after that appear error message:
"Unable to start debuging on the web server. Server side-error occurred
on sending debug HTTP request"
|
by: Rogers |
last post by:
When I tried to run an application developed by VB.net in IIS6,This
error occured,The error message is "Current credit level setting desn't
support Debuging"(in chinese),I dont't know how to translate it,I hope you
can undenstand it.
I create a website and added two virtual directorys to it,But both two
applications doesn't work,The error message is upwards.
And the setting of this website is default,I didn't change anything
after I...
|
by: Carlos Albert |
last post by:
Hello group,
I have a weird problem with VS2003 & VS2005 using both ASP.NET 1.1 and 2.0,
that is that 90% of the times I hit debug, doesn't debug anything, just runs
as I was releasing. Sometimes it works, one or two pages, or even the same
page after a postback, just stop debuging.
Didn't try debuging a windows app, cause I only do web development.
I'm running Win2003, IIS6, .NET framework 1.1 and 2.0, VS 2003 and VS2005.
|
by: Tina |
last post by:
How can I debug with a querystring in vs.net? Is there some place to put
the querystring?
thanks,
T
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |