473,378 Members | 1,309 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,378 software developers and data experts.

problem of types:

I do not understand why he is talking me about 'str', no str given!!!

I have this:

---------------------------------------------

def to_float(elt):
if type(elt) is list:
return map(to_float, elt)
else:
return float(elt)

def Denombrement(A,b,c,type):
Jan 14 '06 #1
2 1325
Laurent wrote:
I do not understand why he is talking me about 'str', no str given!!!

I have this:

---------------------------------------------

def to_float(elt):
if type(elt) is list:
this uses type
if __name__ == '__main__':
A = [[1,0],[0,1]]
b = [2,2]
c = [1,1]
type = 'min'
and this sets type to a string.
if type(elt) is list:
TypeError: 'str' object is not callable

Changing 'list' to 'type(list)' don't change anything!!!!


that's because the error says that you're trying to call a string,
which is exactly what happens here.

</F>

Jan 14 '06 #2
Laurent wrote:
I do not understand why he is talking me about 'str', no str given!!!

I have this:

---------------------------------------------

def to_float(elt):
if type(elt) is list:
return map(to_float, elt)
else:
return float(elt)

def Denombrement(A,b,c,type):
.
.
.
A = to_float(A)
b = to_float(b)
c = to_float(c)
.
.
.

if __name__ == '__main__':
A = [[1,0],[0,1]]
b = [2,2]
c = [1,1]
type = 'min'

Denombrement(A, b, c, type)

-------------------------------------------

And this error msg:
-------------------------
Traceback (most recent call last):
File "./Denombrement.py", line 160, in ?
Denombrement(A, b, c, type)
File "./Denombrement.py", line 31, in Denombrement
A = to_float(A)
File "./Denombrement.py", line 10, in to_float
if type(elt) is list:
TypeError: 'str' object is not callable

------------------------------------------

Changing 'list' to 'type(list)' don't change anything!!!!


Your string variable type is masking the built-in type
function. You should avoid variables with names like
type, list, str, tuple, ... (e.g. built-ins). As they
will mask the built-ins from your program.

-Larry Bates
Jan 17 '06 #3

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

Similar topics

4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
6
by: Hendrik Schober | last post by:
Hi, I have a problem with extending some existing code. In a simplified form, the problem looks like this: I have four types, A, B, C, and D. Each A refers to zero, one, or more B's and each...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
2
by: jiang.haiyun | last post by:
Hi, I am having some serious problems with PyQT4, when i run pyqt script, I always get 'Segmentation fault'. the script is simple: ====================== %less qttest.py from PyQt4 import...
0
by: Syoam4ka | last post by:
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery. I have a tabcontainer. It includes...
2
by: Dark Wind | last post by:
Hi, I have been using OPT++ to solve a non linear programming problem. I am totally new to C++, but I looked at an example given on OPT++ website and modified it according to my problem. But I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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.