On Jan 11, 12:56 am, Munir cloudgi...@gmail.com wrote:
I have an array x=[1,2,3]
Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?
I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]
Have you tried:
y = x*3
y.sort()
Munir
A single line version of this:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de writes:
I have an array x=[1,2,3]
In python such an object is called a list.
(In cpython it's implemented as an automatically resizable array.)
I don't think the OP's terminology needs correction.
A Python list is an array
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de writes:
I have an array x=[1,2,3]
In python such an object is called a list.
(In cpython it's implemented as an automatically resizable array.)
I don't think the OP's
Thank you for your answers! I actually implemented it using for loops
before I posted here, but I was curious if there is a more elegant
solution (judging from the post, Alf will probably say, that for loops
are already elegant).
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list
Alf P. Steinbach wrote:
Re the thing I don't understand: it's the same in C++, people using hours
on figuring out how to do something very simple in an ungrokkable indirect
and compiled way using template metaprogramming stuff, when they could
just write a simple 'for' loop and be done with
* Steven D'Aprano:
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de writes:
I have an array x=[1,2,3]
In python such an object is called a list.
(In cpython it's implemented as an automatically resizable array.)
I don't think
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote:
* Steven D'Aprano:
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de writes:
I have an array x=[1,2,3]
In python such an object is called a list.
(In
* Chris Rebert:
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote:
* Steven D'Aprano:
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de writes:
I have an array x=[1,2,3]
In python such an object is called a
On Mon, Jan 11, 2010 at 2:20 AM, Alf P. Steinbach al...@start.no wrote:
* Chris Rebert:
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote:
* Steven D'Aprano:
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian sebastian.lan...@gmx.de
I have an array x=[1,2,3]
Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?
I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]
Have you tried:
y = x*3
y.sort()
Munir
--
http://mail.python.org/mailman/listinfo/python-list
* Chris Rebert:
On Mon, Jan 11, 2010 at 2:20 AM, Alf P. Steinbach al...@start.no wrote:
* Chris Rebert:
On Mon, Jan 11, 2010 at 1:03 AM, Alf P. Steinbach al...@start.no wrote:
* Steven D'Aprano:
On Mon, 11 Jan 2010 08:56:36 +0100, Alf P. Steinbach wrote:
* Paul Rudin:
Sebastian
try
---
#!/usr/bin/env python
from types import ListType, IntType
def array_expander( ar=None, ex=None ):
if type( ex ) != IntType:
return []
if ex = 0:
return []
if type( ar ) != ListType:
return []
# working code starts
On Mon, 11 Jan 2010 10:03:04 +0100, Alf P. Steinbach wrote:
A Python list is an array functionality-wise.
If one isn't observant of that fact then one ends up with O(n^2) time
for the simplest things.
Well that's certainly not true. Some operations may be O(N**2), but
others are not:
On Jan 11, 4:21 pm, Sebastian sebastian.lan...@gmx.de wrote:
I also tried [[b,b,b] for b in x] which led to [[1,2,3],[1,2,3],
[1,2,3]]
Sorry, I have to correct myself. The quoted line above resulted in
[[1,1,1],[2,2,2],[3,3,3]] of course!
Cheers, Sebastian
--
On Sun, Jan 10, 2010 at 10:21 PM, Sebastian sebastian.lan...@gmx.de wrote:
Hi there,
I have an array x=[1,2,3]
Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?
I tried x*3, which resulted in [1,2,3,1,2,3,1,2,3]
I also tried [[b,b,b] for b in x] which led to
Sebastian sebastian.lan...@gmx.de writes:
Hi there,
I have an array x=[1,2,3]
In python such an object is called a list.
(In cpython it's implemented as an automatically resizable array.)
Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?
There's no operator
Paul Rudin wrote:
Sebastian sebastian.lan...@gmx.de writes:
Hi there,
I have an array x=[1,2,3]
In python such an object is called a list.
(In cpython it's implemented as an automatically resizable array.)
Is there an operator which I can use to get the result
On Sun, 10 Jan 2010 22:21:54 -0800, Sebastian wrote:
Hi there,
I have an array x=[1,2,3]
You have a list. Python has an array type, but you have to import array
to use it.
Is there an operator which I can use to get the result
[1,1,1,2,2,2,3,3,3] ?
Not an operator, but you can do it
18 matches
Mail list logo