#!/usr/bin/env python
arr = [[0 for c in range(0, 10)] for r in range(0, 10)] #
10x10 array
arr[2,3] # throws TypeError: list indices must be
integers
arr[int(2), int(3)] # also throws TypeError: list indices must be
integers !
-------------------------------------------------
what is wrong in above script ? 4 12225
alefajnie wrote:
#!/usr/bin/env python
arr = [[0 for c in range(0, 10)] for r in range(0, 10)] #
10x10 array
arr[2,3] # throws TypeError: list indices must be
integers
arr[int(2), int(3)] # also throws TypeError: list indices must be
integers !
-------------------------------------------------
what is wrong in above script ?
try arr[2][3] instead.
basically your version is trying to index an array with a tuple argument (2,3).
--irmen
>
try arr[2][3] instead.
basically your version is trying to index an array with a tuple argument (2,3).
--irmen
oh, you're right.
btw, is any simple way to create multi-dimension array ?
any built-in function ?
On May 11, 12:05 pm, alefajnie <devp...@gmail.comwrote:
try arr[2][3] instead.
basically your version is trying to index an array with a tuple argument (2,3).
--irmen
oh, you're right.
btw, is any simple way to create multi-dimension array ?
any built-in function ?
test numpy from scipy package :)
on www.scipy.org
On May 11, 5:05*am, alefajnie <devp...@gmail.comwrote:
try arr[2][3] instead.
basically your version is trying to index an array with a tuple argument(2,3).
--irmen
oh, you're right.
btw, is any simple way to create multi-dimension array ?
any built-in function ?
it is not clear that two-dim arrays are faster than hashes in all
implementations of Python, or in every general language, or if they're
the right symbol for your program.
>>a= { } a[ 0, 1 ]= True a[ 4, 0 ]= True a[ 0, 1 ]
True
however, this one:
>>a[ 2, 1 ]
results in a KeyError. do you want a particular thing, or are you on
the clock?
if you want to define 'blanks', that takes time too. is it initally
empty? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Brandon J. Van Every |
last post by:
I'm realizing I didn't frame my question well.
What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
up in your chair and scream "Wow! Ruby has *that*? That is SO...
|
by: Stephen C. Waterbury |
last post by:
This seems like it ought to work, according to the
description of reduce(), but it doesn't. Is this
a bug, or am I missing something?
Python 2.3.2 (#1, Oct 20 2003, 01:04:35)
on linux2
Type...
|
by: Chris Cioffi |
last post by:
I started writing this list because I wanted to have definite points
to base a comparison on and as the starting point of writing something
myself. After looking around, I think it would be a...
|
by: Jonathan Fine |
last post by:
Giudo has suggested adding optional static typing to Python.
(I hope suggested is the correct word.)
http://www.artima.com/weblogs/viewpost.jsp?thread=85551
An example of the syntax he proposes...
|
by: Reed L. O'Brien |
last post by:
I see rotor was removed for 2.4 and the docs say use an AES module
provided separately... Is there a standard module that works alike or
an AES module that works alike but with better encryption?...
|
by: Ross Reyes |
last post by:
HI -
Sorry for maybe a too simple a question but I googled and also checked my
reference O'Reilly Learning Python
book and I did not find a satisfactory answer.
When I use readlines, what...
|
by: Xah Lee |
last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations
Xah Lee, 2006-03-15
Let me summarize: The LISP notation, is a functional notation, and is
not a...
|
by: walterbyrd |
last post by:
I understand that Python has them, but PHP doesn't.
I think that is because mod_php is built into apache, but mod_python
is not usually in apache. If mod_python was built into apache, would...
|
by: webtourist |
last post by:
Warning: New learner here
Not sure what the term means "implementation of Python".
So what exactly does it mean *"implementation of Python"* like
cpython, Jython, IronPython ?????
In terms of...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |