Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 29th, 2004, 04:43 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
the 'stats' class

I wanted to use the 'reverse_order( )' object of the Stats class. How do I go abt it?

I did something like---->

obj1=Stats()
but this is giving me an error tho' I used to do it the same way with the classes defined by me...

how do I access the object? Pls guide!

Thanks & Rgds,
Subha

Reply With Quote
  #2  
Old October 29th, 2004, 08:17 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Just a guess but unless you used the from module import name from to import Stats() you need to preface Stats() with the modules name.

Could you post your program here; if it is too long then you'll to zip it up and attach it using the "Attach File" section of "Additional options" (under the form you use to post).

Also, a copy of the error message being returned by Python would be helpful.

Later Subha,

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old October 30th, 2004, 06:17 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Hi Mark,
Suppose I've made this class

Code:
>>> class myClass:
... 	def name(self,myName):
... 		self.name=myName
... 		return "Hi %s" %(self.name)


fine! then I mk an object 'x' of this class
Code:
>>> x=myClass()


now I call the method 'name'
Code:
>>> x.name('Subha')
'Hi Subha'


So this how it goes! Now I tried the same way with Stats Class too but that didn't work there. I wanted to use the 'reverse_order( ) ' method on the same lines ...but that cldn't be done.

Code:
object=Stats()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
NameError: name 'Stats' is not defined


This is the error it gave...do I've to import anything before using Stats...n the prob is how do I define an object of class Stats...n then finally using the method reverse_order()...

thats my question!!

Thanks & Rgds,
Subha

Reply With Quote
  #4  
Old October 30th, 2004, 12:47 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
The Profiler is petty complex... well, to a degree. You really need to sit down and read the documentation (below) before you start using it properly.

A much simpler way to do this kind of thing is to use the timeit module:

http://www.python.org/doc/2.3.4/lib/module-timeit.html

Code:
>>> import profile, pstats
>>> 
>>> profile.run('foo()', 'fooProfile')
>>> 
>>> aStatsInstance = pstats.Stats('fooProfile')
>>> reversed = aStatsInstance.reverse_order()
>>> reversed.print_stats()
Sat Oct 30 17:37:55 2004    fooProfile

         3 function calls in 0.001 CPU seconds
...


As you can see, you have to import the profile and pstats modules before the Stats class will be defined; pretty simple . Anyway, as promised heres a link to the profiler documentation.

http://docs.python.org/lib/profile.html

Take care,

Mark.

Reply With Quote
  #5  
Old November 2nd, 2004, 03:55 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Thanks for that!
You made it really simple...but one thought that comes to my mind is that ....whats the use of profiler...I mean it can give the information abt various things...but where can we actually put to use such data.

Thanks & Rgds,
Subha

Reply With Quote
  #6  
Old November 2nd, 2004, 01:01 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 11 m 13 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Generally we'd use the profiler to optimize/polish a working Python program; maybe when we want to improve performance – test an algorithm maybe. In theory it could probably help with debugging too, but thats probably overkill .

From the documentation:

Quote:
A profiler is a program that describes the run time performance of a program, providing a variety of statistics. This documentation describes the profiler functionality provided in the modules profile and pstats. This profiler provides deterministic profiling of any Python programs. It also provides a series of report generation tools to allow users to rapidly examine the results of a profile operation.


And, thats pretty much it. Simple a' .

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > the 'stats' class


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT