You Are Here:

Community: Developer Discussion Boards

#1 Old self arg can't be coerced to - 2007-01-27, 19:20

Join Date: Mar 2003
Posts: 564
cassioli's Avatar
cassioli
Offline
Super Contributor
B]self arg can't be coerced to[/b]
What does this error mean?
I get it upon using these commands; it's Jython, but I guess this is a standard Python error:

>>> import javax.power.monitor.PowerMonitor
>>> pm = javax.power.monitor.PowerMonitor
>>> print pm.getBatteryLevel()
TypeError:
getBatteryLevel():
expected 1 arg; not 0

If I specify an argument:
>>> print pm.getBatteryLevel(0)

I get:
getBatteryLevel(): self arg can't be coerced to
Reply With Quote

#2 Old Re: self arg can't be coerced to - 2007-01-28, 15:13

Join Date: Jan 2007
Posts: 135
Location: Oulu, Finland
GameDude
Offline
Regular Contributor
Quote:
pm = javax.power.monitor.PowerMonitor
You are not creating an instance here. It just assigns the Class PowerMonitor to pm -variable.

Code:
pm = javax.power.monitor.PowerMonitor()
I'm not familiar with Jython api, but the code above should make it work unless PowerMonitor requires some parameters. Or you may need to use PowerMonitor.getInstance() since it is used in many Java examples. The error doesn't seem to be very standard though. My desktop Python raises TypeError in both cases and gives better error message with similar code.

Quote:
What does this error mean?
The first error appears because the method expects 'self' as the first argument. It is given automatically for instance methods but there is no instance here so that's why it complains about 1 missing argument. And the second error means that the '0' you gave is an integer and it can't be converted to PowerMonitor -instance.
Reply With Quote

#3 Old Re: self arg can't be coerced to - 2007-01-28, 15:20

Join Date: Mar 2003
Posts: 564
cassioli's Avatar
cassioli
Offline
Super Contributor
That's right, this is the working version:
>>> import javax.power.monitor.PowerMonitor
>>> pm = javax.power.monitor.PowerMonitor.getInstance()
>>> print pm.getBatteryLevel()

Unfortunately, it always returns same value (0x07fff.ffff); I wonder if some initialisation is required before using this function...
Does any Nokia phone support Javaphone API? Thus I could ask somebody for help...
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in returning length thru TSockXfrLength Arg. in RSocket class mishrasaurabh General Symbian C++ 4 2003-12-17 15:42
problem in returning length thru TSockXfrLength Arg. in RSocket class mishrasaurabh Symbian Networking & Messaging 0 2003-12-17 05:34
Problem in returning length thru TSockXfrLength Arg. in RSocket class mishrasaurabh General Symbian C++ 0 2003-12-15 12:32

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia