Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion using "*" to make a list of lists with repeated (and independent) elements
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ramchandra Apte  
View profile  
 More options Sep 29 2012, 9:46 am
Newsgroups: comp.lang.python
From: Ramchandra Apte <maniandra...@gmail.com>
Date: Sat, 29 Sep 2012 06:46:22 -0700 (PDT)
Local: Sat, Sep 29 2012 9:46 am
Subject: Re: using "*" to make a list of lists with repeated (and independent) elements

On Thursday, 27 September 2012 04:14:42 UTC+5:30, Tim Chase  wrote:
> On 09/26/12 17:28, 88888 Dihedral wrote:

> > 88888 Dihedral於 2012年9月27日星期四UTC+8上午6時07分35秒寫道:

> >>>> In these conditions, how to make this list [[0,0,0],[0,0,0]] with "*"

> >>>> without this behavior?

> >>>     >>> a = [[0]*3 for i in xrange(2)]

> >>>     >>> a[0][0]=2

> >>>     >>> a

> >>>     [[2, 0, 0], [0, 0, 0]]

> > def zeros(m,n):

> >       a=[]

> >       for i in xrange(m):

> >               a.append([0]*n)

> >       return a

> > If  one wants to tranlate to C, this is the style.

> But this is Python, so why the heck would anybody want to emulate

> *C* style?  It could also be written in an assembly-language style,

> COBOL style, or a Fortran style...none of which are particularly

> valuable.

> Besides, a C-style would allocate a single array of M*N slots and

> then calculate 2d offsets into that single array. :-P

> -tkc

88888 Dihedral is a bot.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.