By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,743 Members | 1,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,743 IT Pros & Developers. It's quick & easy.

Integer From A Float List?!?

P: n/a
Hello NG,

I was wondering if there is a way to obtain, from a list of floats,
a list of integers without loops. Probably is a basic question, but I can't
find an answer... I have had my eyes blinded by Matlab for years, but now
that I discovered Python+wxPython there seems to be no limit on what one
can do with these 2 tools. Anyway, following the Matlab style, I would like
to do something like this:

matrix = [1.5, 4.3, 5.5]
integer_matrix = int(matrix) (float for Matlab)

(In Matlab, "integer_matrix" is always a double anyway, here I would like
only to show the vector-matrix operation).

Obviously, Python complains about:

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: int() argument must be a string or a number

I would like to avoid loops because, having been blinded by Matlab vector-matrix
abilities (and corresponding SLOW for-while loops operations), I tend to
think that also Python will be slow if I use loops.

Does anyone have a suggestion (or maybe could anyone show me that I'm wrong
about loops?)

Thanks you a lot.

Andrea.

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.