473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

cos: "Integer Required"?!?!?!?

Hello all,

I've just jumped into Python trying to develop X-Plane plugins.

All was chugging along well until I tried to use math.cos()

snippet:

import math

.....

cos_phi = math.cos(math.radians(XPLMGetDataf(self.ACphi))) # Error
occurs here

Now XPLMGetDataf should be returning float.

Is there something that I'm completely missing about how Python does
tyonig or something?

Thanks in advance,

Moonman

Jun 8 '06 #1
7 2096
moonman wrote:
import math

....

cos_phi = math.cos(math.radians(XPLMGetDataf(self.ACphi))) # Error
occurs here
what error ? it's a lot easier to help if you include the traceback.
Now XPLMGetDataf should be returning float.
should be ? have you verified this ? try adding

print self.ACphi, type(self.ACphi)
value = XPLMGetDataf(self.ACphi)
print value, type(value)

before the cos_phi line, and let us know what it prints.
Is there something that I'm completely missing about how Python does
tyonig or something?


not necessarily, but you may need to work a little on your trouble-
shooting skills (rule 1: when in doubt, use print. print is your friend).

</F>

Jun 8 '06 #2
First: Always post cut-paste tracebacks so we can see actual
error message.

Second: print out self.ACphi, XPLMGetDataf(self.ACphi) and
math.radians(XPLMGetDataf(self.ACphi)) before this statement
and you will find the problem.

-Larry Bates
moonman wrote:
Hello all,

I've just jumped into Python trying to develop X-Plane plugins.

All was chugging along well until I tried to use math.cos()

snippet:

import math

....

cos_phi = math.cos(math.radians(XPLMGetDataf(self.ACphi))) # Error
occurs here

Now XPLMGetDataf should be returning float.

Is there something that I'm completely missing about how Python does
tyonig or something?

Thanks in advance,

Moonman

Jun 8 '06 #3

print self.ACphi, type(self.ACphi) yields:
19412557 <type 'int'>

value = XPLMGetDataf(self.ACphi); print value type(value ) yields:
-0.674469709396 <type 'float'>

print math.radians(XPLMGetDataf(self.ACphi)),
type(math.radians(XPLMGetDataf(self.ACphi))) yields:

TypeError
:
an integer is required

Am I totally missing something about 'math'. Does it really expect an
int?
Moonman

Larry Bates wrote:
First: Always post cut-paste tracebacks so we can see actual
error message.

Second: print out self.ACphi, XPLMGetDataf(self.ACphi) and
math.radians(XPLMGetDataf(self.ACphi)) before this statement
and you will find the problem.

-Larry Bates
moonman wrote:
Hello all,

I've just jumped into Python trying to develop X-Plane plugins.

All was chugging along well until I tried to use math.cos()

snippet:

import math

....

cos_phi = math.cos(math.radians(XPLMGetDataf(self.ACphi))) # Error
occurs here

Now XPLMGetDataf should be returning float.

Is there something that I'm completely missing about how Python does
tyonig or something?

Thanks in advance,

Moonman


Jun 8 '06 #4
moonman wrote:
print self.ACphi, type(self.ACphi) yields:
19412557 <type 'int'>

value = XPLMGetDataf(self.ACphi); print value type(value ) yields:
-0.674469709396 <type 'float'>

print math.radians(XPLMGetDataf(self.ACphi)),
type(math.radians(XPLMGetDataf(self.ACphi))) yields:

TypeError
:
an integer is required

Am I totally missing something about 'math'. Does it really expect an
int?


nope.
import math
math.radians(-0.6744) -0.011770500475449759 math.cos(-0.1177)

0.99308134771019019

when you end up with exceptions that make no sense at all, and C
extensions are involved, the problem is quite often that some code in
the extension forgets to check for errors, or forgets to reset the
exception status when it has handled an error.

do you get any further if you do:

value = XPLMGetDataf(self.ACphi)
hasattr(value, "foo") # reset the exception status
print math.radians(value)

?

</F>

Jun 8 '06 #5
moonman wrote:
print self.ACphi, type(self.ACphi) yields:
19412557 <type 'int'>

value = XPLMGetDataf(self.ACphi); print value type(value ) yields:
-0.674469709396 <type 'float'>

print math.radians(XPLMGetDataf(self.ACphi)),
type(math.radians(XPLMGetDataf(self.ACphi))) yields:

TypeError
:
an integer is required

Am I totally missing something about 'math'. Does it really expect an
int?


Not my Python:
math.radians(-0.674469709396)

-0.011771717133929535

This all seems very confusing. Have you tried exactly the above?

Do you perhaps have a module of your own called math, that Python might
be importing? Or is your math not a module, but some other object that
happens to have a method called radians, that expects an int? Or have
you accidentally redefined math.radians?

/MiO
Jun 8 '06 #6
I'm using ActiveState PythonV2.4.1

I'm certainly not affecting 'math'. I wonder if the XPlane SDK Python
binding is touching anything.

I'll download the latest ActiveState Python and keep on plugging.

Thanks!
Mikael Olofsson wrote:
moonman wrote:
print self.ACphi, type(self.ACphi) yields:
19412557 <type 'int'>

value = XPLMGetDataf(self.ACphi); print value type(value ) yields:
-0.674469709396 <type 'float'>

print math.radians(XPLMGetDataf(self.ACphi)),
type(math.radians(XPLMGetDataf(self.ACphi))) yields:

TypeError
:
an integer is required

Am I totally missing something about 'math'. Does it really expect an
int?


Not my Python:
>>> math.radians(-0.674469709396)

-0.011771717133929535

This all seems very confusing. Have you tried exactly the above?

Do you perhaps have a module of your own called math, that Python might
be importing? Or is your math not a module, but some other object that
happens to have a method called radians, that expects an int? Or have
you accidentally redefined math.radians?

/MiO


Jun 8 '06 #7
It appears that the cause of this problem was indirect.

I input something incorrect as an argument to an xplane sdk function
and the cos/integer type error followed.

Thanks for the help. The diagnostic functions I learned in this thread
will be very helpful in the future.
moonman wrote:
I'm using ActiveState PythonV2.4.1

I'm certainly not affecting 'math'. I wonder if the XPlane SDK Python
binding is touching anything.

I'll download the latest ActiveState Python and keep on plugging.

Thanks!
Mikael Olofsson wrote:
moonman wrote:
print self.ACphi, type(self.ACphi) yields:
19412557 <type 'int'>

value = XPLMGetDataf(self.ACphi); print value type(value ) yields:
-0.674469709396 <type 'float'>

print math.radians(XPLMGetDataf(self.ACphi)),
type(math.radians(XPLMGetDataf(self.ACphi))) yields:

TypeError
:
an integer is required

Am I totally missing something about 'math'. Does it really expect an
int?


Not my Python:
>>> math.radians(-0.674469709396)

-0.011771717133929535

This all seems very confusing. Have you tried exactly the above?

Do you perhaps have a module of your own called math, that Python might
be importing? Or is your math not a module, but some other object that
happens to have a method called radians, that expects an int? Or have
you accidentally redefined math.radians?

/MiO


Jun 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vijay | last post by:
<xs:element name="product"> <xs:complexType> <xs:complexContent> <xs:restriction base="xs:integer"> <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:restriction>...
2
by: Dave Hammond | last post by:
I've got what should be a simple assignment of either an element value or a default string to a variable, but when the element doesn't exist I get an "Object required" error rather than an...
7
by: Ian | last post by:
Using Access 97 I have a form with several text boxes, I am trying to get each text box to display the word "Required" for the appropriate boxes on a new record. A friend gave me the following line...
2
by: Peter Ignarson | last post by:
Hi, simple question Is there a syntax (other than the one below that is invalid) that will let me declare and initialize two variables at the same time (using VS 2003, 1.1) ? Thank you Pete ...
4
by: Supra | last post by:
value of type "Integer" cannot be convert to system.color Public Sub APIHighlight2(ByVal BgColour As Integer, ByVal FgColour As Integer) SelectionHighlightBackColour(BgColour) Dim rtb As New...
2
by: Supra | last post by:
value of type "Integer" cannot be convert to system.color. in procedure events: Function doColor(ByVal rtb As RichTextBox, ByVal a As String) Dim bColor, fColor, fgcolor, bgcolor As Integer .....
20
by: chutsu | last post by:
I'm trying to compare between pointer and integer in an "IF" statement how do I make this work? if(patient.id != NULL){ } Thanks Chris
5
by: kj | last post by:
I'm trying to subclass file, overriding the readline method. The new method definition begins with def readline(self, size=None): line = self.file.readline(size) # etc., etc. ....where the...
2
by: Alexei Lebedev | last post by:
Hi all. As you know Coldfusion dynamically generates js code for cfinput tags. And there is required="yes" feature. I want to automatically add red asterisk at the end of input field when...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.