List of lists surprising behaviour

Let's the following code :

 >>> t=[[0]*2]*3
 >>> t
[[0, 0], [0, 0], [0, 0]]
 >>> t[0][0]=1
 >>> t
[[1, 0], [1, 0], [1, 0]]

Rather surprising, isn't it ? So I suppose all the subarrays ref�rence 
the same array :

 >>> id(t[0]), id(t[1]), id(t[2])
(3077445996L, 3077445996L, 3077445996L)
 >>>


So what is the right way to initialize to 0 a 2D array ? Is that way 
correct  :


 >>> t=[[0 for _ in range(2)] for _ in range(3)]

It seems there is no more trouble now :

 >>> t
[[0, 0], [0, 0], [0, 0]]
 >>> t[0][0]=1
 >>> t
[[1, 0], [0, 0], [0, 0]]
 >>>

Correct ?
0
candide (110)
6/17/2010 10:21:31 AM
comp.lang.python 74795 articles. 15 followers. Post Follow

15 Replies
241 Views

Similar Articles

[PageSpeed] 59
On 06/17/10 20:21, candide wrote:
> Let's the following code :
> 
>>>> t=[[0]*2]*3
>>>> t
> [[0, 0], [0, 0], [0, 0]]
>>>> t[0][0]=1
>>>> t
> [[1, 0], [1, 0], [1, 0]]
> 
> Rather surprising, isn't it ? So I suppose all the subarrays ref�rence
> the same array :
> 
>>>> id(t[0]), id(t[1]), id(t[2])
> (3077445996L, 3077445996L, 3077445996L)
>>>>

Yep, you're right. They share the same subarray if you uses
multiplication to build the array.

> So what is the right way to initialize to 0 a 2D array ? Is that way
> correct  :
>>>> t=[[0 for _ in range(2)] for _ in range(3)]

Right again. That's the way to go. Although if the elements are
immutable, you can create the innermost array by multiplication:

t=[[0]*2 for _ in range(3)]
0
Lie
6/17/2010 10:59:52 AM
Yes you are. List comprehension makes you create list of lists without
reference-sharing. You should also find a recipe about that on the
python cookbook.

On Thu, Jun 17, 2010 at 12:21 PM, candide <candide@free.invalid> wrote:
> Let's the following code :
>
>>>> t=3D[[0]*2]*3
>>>> t
> [[0, 0], [0, 0], [0, 0]]
>>>> t[0][0]=3D1
>>>> t
> [[1, 0], [1, 0], [1, 0]]
>
> Rather surprising, isn't it ? So I suppose all the subarrays ref=E9rence =
the
> same array :
>
>>>> id(t[0]), id(t[1]), id(t[2])
> (3077445996L, 3077445996L, 3077445996L)
>>>>
>
>
> So what is the right way to initialize to 0 a 2D array ? Is that way corr=
ect
> =A0:
>
>
>>>> t=3D[[0 for _ in range(2)] for _ in range(3)]
>
> It seems there is no more trouble now :
>
>>>> t
> [[0, 0], [0, 0], [0, 0]]
>>>> t[0][0]=3D1
>>>> t
> [[1, 0], [0, 0], [0, 0]]
>>>>
>
> Correct ?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--=20
Matteo Landi
http://www.matteolandi.net/
0
landimatte (24)
6/17/2010 11:11:25 AM
candide wrote:
>
> So what is the right way to initialize to 0 a 2D array ? Is that way
> correct :
>
>
>  >>> t=[[0 for _ in range(2)] for _ in range(3)]

That's overkill :) You can skip the inner loop by using a list display, eg

t=[[0,0] for _ in range(3)]

>
> It seems there is no more trouble now :
>
>  >>> t
> [[0, 0], [0, 0], [0, 0]]
>  >>> t[0][0]=1
>  >>> t
> [[1, 0], [0, 0], [0, 0]]
>  >>>
>
> Correct ?


0
Boris
6/17/2010 1:56:32 PM
candide <candide@free.invalid> writes:

> Let's the following code :
>
>>>> t=[[0]*2]*3
>>>> t
> [[0, 0], [0, 0], [0, 0]]
>>>> t[0][0]=1
>>>> t
> [[1, 0], [1, 0], [1, 0]]
>
> Rather surprising, isn't it ? 

Not at all, actually.

I'd be surprised if the multiplication operator was aware of object
constructors.  Even arrays are "objects" in Python.  Should the
multiplication operator know how to instantiate three arrays from a
single array instance?  What about an instance of a user-defined class?

> So I suppose all the subarrays reférence
> the same array :
>
>>>> id(t[0]), id(t[1]), id(t[2])
> (3077445996L, 3077445996L, 3077445996L)
>>>>
>

As they should.

>
> So what is the right way to initialize to 0 a 2D array ? Is that way
> correct  :
>
>
>>>> t=[[0 for _ in range(2)] for _ in range(3)]
>
> It seems there is no more trouble now :
>
>>>> t
> [[0, 0], [0, 0], [0, 0]]
>>>> t[0][0]=1
>>>> t
> [[1, 0], [0, 0], [0, 0]]
>>>>
>
> Correct ?

>>> 2d_zero_vector = lambda len: [[0, 0] for _ in range(len)]
>>> t = 2d_zero_vector(3)
>>> print t
[[0, 0], [0, 0], [0, 0]]
>>> t[0][0] = 1
>>> print t
[[1, 0], [0, 0], [0, 0], [0, 0]]

(Of course, if you're doing matrix math you'll probably want to work
with numpy which has a function for doing just this)
0
J
6/17/2010 8:25:53 PM
"J Kenneth King" <james@agentultra.com> wrote in message
news:87wrtxh0dq.fsf@agentultra.com...
> candide <candide@free.invalid> writes:
>
>> Let's the following code :
>>
>>>>> t=[[0]*2]*3
>>>>> t
>> [[0, 0], [0, 0], [0, 0]]
>>>>> t[0][0]=1
>>>>> t
>> [[1, 0], [1, 0], [1, 0]]
>>
>> Rather surprising, isn't it ?
>
> Not at all, actually.

The code is clearly trying to set only t[0][0] to 1, not t[1][0] and t[2][0]
as well.

This behaviour is quite scary actually, especially when t[0]=42 *does* work
as expected, while t[0][0]=42 is apparently duplicated. It appears
inconsistent.

> I'd be surprised if the multiplication operator was aware of object
> constructors.  Even arrays are "objects" in Python.  Should the
> multiplication operator know how to instantiate three arrays from a
> single array instance?  What about an instance of a user-defined class?

Multiplication operators shouldn't need to be directly aware of any such 
thing; it should just request that an object be duplicated without worrying 
about how it's done.

I don't know how Python does things, but an object should either specify a 
special way of duplicating itself, or lend itself to some standard way of 
doing so. (So for a list, it's just a question of copying the data in the 
list, then recursively duplicating each new element..)

-- 
Bartc

0
bart
6/17/2010 11:20:30 PM
On Thu, Jun 17, 2010 at 4:20 PM, bart.c <bartc@freeuk.com> wrote:
>
> "J Kenneth King" <james@agentultra.com> wrote in message
> news:87wrtxh0dq.fsf@agentultra.com...
>>
>> candide <candide@free.invalid> writes:
>>
>>> Let's the following code :
>>>
>>>>>> t=3D[[0]*2]*3
>>>>>> t
>>>
>>> [[0, 0], [0, 0], [0, 0]]
>>>>>>
>>>>>> t[0][0]=3D1
>>>>>> t
>>>
>>> [[1, 0], [1, 0], [1, 0]]
>>>
>>> Rather surprising, isn't it ?
>>
>> Not at all, actually.
>
> The code is clearly trying to set only t[0][0] to 1, not t[1][0] and t[2]=
[0]
> as well.
>
> This behaviour is quite scary actually, especially when t[0]=3D42 *does* =
work
> as expected, while t[0][0]=3D42 is apparently duplicated. It appears
> inconsistent.
>
>> I'd be surprised if the multiplication operator was aware of object
>> constructors. =A0Even arrays are "objects" in Python. =A0Should the
>> multiplication operator know how to instantiate three arrays from a
>> single array instance? =A0What about an instance of a user-defined class=
?
>
> Multiplication operators shouldn't need to be directly aware of any such
> thing; it should just request that an object be duplicated without worryi=
ng
> about how it's done.
>
> I don't know how Python does things, but an object should either specify =
a
> special way of duplicating itself, or lend itself to some standard way of
> doing so. (So for a list, it's just a question of copying the data in the
> list, then recursively duplicating each new element..)
>
> --
> Bartc

It's the recursively duplicating each element that's the problem. How
do you know when to stop?
0
Benjamin
6/17/2010 11:44:49 PM
On Jun 17, 6:44=A0pm, Benjamin Kaplan <benjamin.kap...@case.edu> wrote:

> It's the recursively duplicating each element that's the problem. How
> do you know when to stop?


Thats easy, stack overflow! ;-)
0
rantingrick
6/18/2010 12:48:06 AM
On 06/18/10 09:20, bart.c wrote:
> 
> "J Kenneth King" <james@agentultra.com> wrote in message
> news:87wrtxh0dq.fsf@agentultra.com...
>> candide <candide@free.invalid> writes:
>>
>>> Let's the following code :
>>>
>>>>>> t=[[0]*2]*3
>>>>>> t
>>> [[0, 0], [0, 0], [0, 0]]
>>>>>> t[0][0]=1
>>>>>> t
>>> [[1, 0], [1, 0], [1, 0]]
>>>
>>> Rather surprising, isn't it ?
>>
>> Not at all, actually.
> 
> The code is clearly trying to set only t[0][0] to 1, not t[1][0] and
> t[2][0]
> as well.
> 
> This behaviour is quite scary actually, especially when t[0]=42 *does* work
> as expected, while t[0][0]=42 is apparently duplicated. It appears
> inconsistent.

I agree, the behavior is often quite inconvenient, but I disagree that
it is inconsistent. List multiplication behavior is consistent with the
tenet: "objects are never copied unless explicitly requested"

Peeking further:
t = [[0] * 2] * 3
print id(t[0]) == id(t[1])  # True
print id(t[0][0]) == id(t[1][0])  # True

so, it is consistent (though it is quite inconvenient).

>> I'd be surprised if the multiplication operator was aware of object
>> constructors.  Even arrays are "objects" in Python.  Should the
>> multiplication operator know how to instantiate three arrays from a
>> single array instance?  What about an instance of a user-defined class?
> 
> Multiplication operators shouldn't need to be directly aware of any such
> thing; it should just request that an object be duplicated without
> worrying about how it's done.
> 
> I don't know how Python does things, but an object should either specify
> a special way of duplicating itself, or lend itself to some standard way
> of doing so. (So for a list, it's just a question of copying the data in
> the list, then recursively duplicating each new element..)

That is inconsistent with the tenet. Moreover, the implicit copying
makes it quite difficult to reason about the program's behavior. How
would you propose this list should be copied:

class O(object):
    def __init__(self):
        self.attr = 0
    def add(self):
        self.attr += 1

b = [[O()] * 2] * 3
0
Lie
6/18/2010 1:38:59 AM
On Fri, 18 Jun 2010 00:20:30 +0100, bart.c wrote:

> The code is clearly trying to set only t[0][0] to 1, not t[1][0] and
> t[2][0] as well.

Trying to guess the motivation of the person writing code is tricky, but 
in this case, that's a reasonable assumption. I can't think of any reason 
why somebody would explicitly *want* that behaviour:

# Does it make sense to talk of anonymous aliases?
list_of_aliases = [[0]*2]*3
list_of_aliases[0][0] = 1
assert list_of_aliases[0][1] == 1

so it is a safe guess that anyone writing [[0]*2]*3 has probably made a 
mistake.

However, I've certainly done something like this:

a = [0]*2
my_instance.items = a
a[0] = 1
assert my_instance.items[0] = 1

This is the same fundamental behaviour with the same cause: Python does 
not copy objects unless you explicitly tell it to.

I cheerfully accept that the behaviour of [[0]*2]*3 is a Gotcha, but it 
follows logically from Python's object model and assignment rules. If you 
are surprised by it, it just goes to show that your understanding of 
Python has at least one hole in it.

 
> This behaviour is quite scary actually, especially when t[0]=42 *does*
> work as expected, while t[0][0]=42 is apparently duplicated. It appears
> inconsistent.

Emphasis on the word "appears". It actually displays a deep consistency 
with the language fundamentals.

If you're ever interviewing somebody for a position as Python developer, 
this is a quick test to distinguish those who know the language from 
those who know the language *well*.


>> I'd be surprised if the multiplication operator was aware of object
>> constructors.  Even arrays are "objects" in Python.  Should the
>> multiplication operator know how to instantiate three arrays from a
>> single array instance?  What about an instance of a user-defined class?
> 
> Multiplication operators shouldn't need to be directly aware of any such
> thing; it should just request that an object be duplicated without
> worrying about how it's done.

The multiplication operator is not a duplicator (copier). It is a 
*repetition* operator: repeat the object N times, not make N copies.


> I don't know how Python does things, 

Well there you go :)


> but an object should either specify
> a special way of duplicating itself, or lend itself to some standard way
> of doing so.

import copy
copy.copy(obj)

Dicts have a copy() method as a shortcut, and for lists you can use 
slicing:

L = [1,2,3]
Lcopy = L[:]


> (So for a list, it's just a question of copying the data in
> the list, then recursively duplicating each new element..)

There's nothing "just" about that. Consider:

L = [1, 2]
L.append(L)

How would you copy that?

The correct answer is:

x = copy.deepcopy(L)



-- 
Steven
0
Steven
6/18/2010 5:36:33 AM
Benjamin Kaplan wrote:
> On Thu, Jun 17, 2010 at 4:20 PM, bart.c <bartc@freeuk.com> wrote:

>> I don't know how Python does things, but an object should either
>> specify a special way of duplicating itself, or lend itself to some
>> standard way of doing so. (So for a list, it's just a question of
>> copying the data in the list, then recursively duplicating each new
>> element..)

> It's the recursively duplicating each element that's the problem. How
> do you know when to stop?

When you reach a primitive object (one not comprising other objects). (I 
don't know if Python allows circular references, but that would give 
problems anyway: how would you even print out such a list?)

-- 
Bartc 

0
bart
6/18/2010 10:00:39 AM
On 06/18/10 20:00, bart.c wrote:
> (I
> don't know if Python allows circular references, but that would give
> problems anyway: how would you even print out such a list?)


Python uses ellipsis to indicate recursive list:

>>> a = [1, 2, 3]
>>> a.append(a)
>>> a
[1, 2, 3, [...]]
0
Lie
6/18/2010 10:46:07 AM
Lie Ryan wrote:
> On 06/18/10 20:00, bart.c wrote:
>> (I
>> don't know if Python allows circular references, but that would give
>> problems anyway: how would you even print out such a list?)
>
>
> Python uses ellipsis to indicate recursive list:
>
>>>> a = [1, 2, 3]
>>>> a.append(a)
>>>> a
> [1, 2, 3, [...]]

Ok, perhaps whatever logic print uses to know when to stop and show "...", 
can also be used by copy handlers...

(Although I have an issue with the way that that append works. I tried it in 
another, simpler language (which always does deep copies):

L:=(1,2,3)
L append:= L
print L

output:  (1,2,3,(1,2,3))

which is exactly what I'd expect, and not (1,2,3,(1,2,3,(1,2,3,...))) )

-- 
bartc 

0
bart
6/18/2010 11:07:38 AM
On Fri, 18 Jun 2010 12:07:38 +0100, bart.c wrote:

> (Although I have an issue with the way that that append works. I tried
> it in another, simpler language (which always does deep copies):
> 
> L:=(1,2,3)
> L append:= L
> print L
> 
> output:  (1,2,3,(1,2,3))
> 
> which is exactly what I'd expect, 
> and not (1,2,3,(1,2,3,(1,2,3,...))) )

I find that behaviour a big surprise. You asked to append the list L, not 
a copy of the list L. So why is this "simpler" language making a copy 
without being asked?

If you asked for:

L:=(1,2,3)
M:=(0,1)
M append:= L

does it also append a copy of L instead of L? If so, how do you append 
the original rather than wastefully making a copy? If L is huge, making a 
copy before appending will be slow, and potentially fail.



-- 
Steven
0
Steven
6/18/2010 3:03:34 PM
"Steven D'Aprano" <steve@REMOVE-THIS-cybersource.com.au> wrote in message
news:4c1b8ac6$0$14148$c3e8da3@news.astraweb.com...
> On Fri, 18 Jun 2010 12:07:38 +0100, bart.c wrote:
>
>> (Although I have an issue with the way that that append works. I tried
>> it in another, simpler language (which always does deep copies):
>>
>> L:=(1,2,3)
>> L append:= L
>> print L
>>
>> output:  (1,2,3,(1,2,3))
>>
>> which is exactly what I'd expect,
>> and not (1,2,3,(1,2,3,(1,2,3,...))) )
>
> I find that behaviour a big surprise. You asked to append the list L, not
> a copy of the list L. So why is this "simpler" language making a copy
> without being asked?
>
> If you asked for:
>
> L:=(1,2,3)
> M:=(0,1)
> M append:= L
>
> does it also append a copy of L instead of L?

It make a copy.

> If so, how do you append
> the original rather than wastefully making a copy?

I don't think it can, without perhaps doing something with explicit
pointers.

> If L is huge, making a
> copy before appending will be slow, and potentially fail.

I don't know whether L append:=L requires 3 times the space of L, or 2
times, during the operation. But it should be doable using just twice the
space.

I suppose there are pros and cons to both approaches; copying all the time
at least avoids some of the odd effects and inconsistencies you get using
Python:

a1=[1,2,3]
a1.append(a1)

a2=[1,2,3]
b=[1,2,3]
a2.append(b)

a3=[1,2,3]
a3.append([1,2,3])

print ("a1 = ",a1)
print ("a2 = ",a2)
print ("a3 = ",a3)

Here, a1 ends up with a different result from a2, a3, even though the same
value is being appended to the same list of numbers in each case. And it 
might sometimes bite you in the arse as the OP demonstrated:

L=[1,2,3]
M=[0,1]
M.append(L)

print (M)     # output: [0, 1, [1, 2, 3]]

L[1]=31416

print (M)     # output: [0, 1, [1, 31416, 3]], yikes!

-- 
Bartc


0
bartc (786)
6/18/2010 3:40:35 PM
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig3BB2A9F215CDFED19118EACA
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 6/18/10 8:40 AM, bart.c wrote:
> I suppose there are pros and cons to both approaches; copying all the t=
ime
> at least avoids some of the odd effects and inconsistencies you get usi=
ng
> Python:

What inconsistencies? All your examples are perfectly consistent. Its
just consistent to different ideals. Python never copies implicitly; and
every object you create has a concrete identity in and of itself,
utterly separate from its potential equality.

> a1=3D[1,2,3]
> a1.append(a1)

The "a1" object is a distinct object unto itself; you are appending said
distinct object onto the end of itself. Entirely doable, even if you
don't usually want to. Recursive, but doable if that's what you want. If
you wished to append a copy, you must-- as always, consistently--
explicitly copy it.

I.e.,

a1.append(a1[:])

> a2=3D[1,2,3]
> b=3D[1,2,3]
> a2.append(b)

a2 is a distinct object from b; that the two objects are equal means
nothing. So you're appending an object to the end of a2 which happens to
be equal to it.

> a3=3D[1,2,3]
> a3.append([1,2,3])

This is just another way of writing the previous example; that in one
you are naming the object [1,2,3] and in the other you are not, doesn't
mean anything. A named vs unnamed object in Python behaves exactly the sa=
me.

> print ("a1 =3D ",a1)
> print ("a2 =3D ",a2)
> print ("a3 =3D ",a3)
>=20
> Here, a1 ends up with a different result from a2, a3, even though the s=
ame
> value is being appended to the same list of numbers in each case.=20

There's the rub: the VALUE is not being appended. The *actual object* is.=


Consider:

>>> print a1 is a2
False

> And it
> might sometimes bite you in the arse as the OP demonstrated:
>=20
> L=3D[1,2,3]
> M=3D[0,1]
> M.append(L)
>=20
> print (M)     # output: [0, 1, [1, 2, 3]]
>=20
> L[1]=3D31416
>=20
> print (M)     # output: [0, 1, [1, 31416, 3]], yikes!

That might bite you on your arse if you think Python implicitly copies;
but since the rule is very simple -- it /never/ implicitly copies -- and
that it objects are discrete entities and not just names of certain
values, it more likely then not will be beneficial to you quite often
down the road. You'll -want- that to be how things work. Eventually.
When you learn more Python.

--=20

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/


--------------enig3BB2A9F215CDFED19118EACA
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)

iQEcBAEBAgAGBQJMG6MqAAoJEKcbwptVWx/ll/YIALfJMaQuxVQGeF0EXGllNGl4
zAH5akcpA3nFr+X6E2I1Xc9MxN162dIbBuRJ6GrLwej2wyklkgm3snMDCQAUA0QU
xGEzyIma0Mi6KotydyEkmpgxM6b3vQj8SSlmM6mex+zKgR+HlIXvl/zapyPc9v+8
Kfc8glJgoFXmiv7W9fbwCu8g/w6KeIiAaaC7JepMwm6IoVsrP888p65Add8eEtKb
PUQKuU1bSEnysmCVstzUnY4lIsByOW3ygpnnA6++uDeR3AwZ4sLRN0J33UsUiGJM
kPV6c6LkJ9+jY3dObbnSusVPcdfvOIyUlN8i4nxKb/JddPQ9aTptLO/kupZm8xA=
=18Pu
-----END PGP SIGNATURE-----

--------------enig3BB2A9F215CDFED19118EACA--
0
python3307 (206)
6/18/2010 4:47:38 PM
Reply:
Similar Artilces:

Looking for a list of processes
I've got a couple of users on a network that I'm newly supporting that are running incredibly slow. I've run AdAware, Spybot, defrag (in Safe mode, wouldn't run otherwise)and nothing. There are some things running that I don't recognize but they are running software that I haven't seen before. Does anyone know of a site that lists most of the processes that could be running on Win 98? Thanks ...

[wxMSW,wxGTK] wxChoice, height of dropdown list
Hi, I am using a wxChoice that has quite a few entries. It works fine except that the drop down list is much higher than what I would like (it isn't longer than my number of entries though). In Windows there is a nice scrollbar, and I would like to be able to specify the height of the drop down list. When using MFC in the past I was able to do this, but I cannot find a way to do it in wxWidgets. I also tried wxComboBox but the result is the same. Is there a way to specify the max height of the wxChoice drop-down list, independent of the number of contained entries? -...

Music Sharing Servers
Is ther ea web site or list of known-active file share servers that can be used with programs such as LimeWire, SoulSeek, and 2-Get? It appears that some of these programs come pre-programmed with servers but after a time these simply depart the network never to be seen again. Most have the ability to add/delete server IP addresses, but where to locate a list? DMK D. Kirkpatrick <sunclad@sunclad.com> wrote: > Is ther ea web site or list of known-active file share servers that can be > used with programs such as LimeWire, SoulSeek, and 2-Get? > > It appears that so...

list schemas
what is the command to list all existing schemas in a database? Is there any command to list all the schemas under a instance as database.schema ?? Please let me know. Thanks, A Carter annecarterfredi@gmail.com wrote: > what is the command to list all existing schemas in a database? Is > there any command to list all the schemas under a instance as > database.schema ?? > Please let me know. Thanks, There is a view with the obvious name. There is no way to peek into any SQL object at an INSTANCE level. You need to connect to a database. Cheers Serge -- Serg...

some assistance with a linked list
Being new to the use of C++ I have written a linked list program. It seems to crash after I delete from the list and then add a new node. Also this is not college homework, I have also looked at various postings here on the topic. They do not seem to help. If someone more of an expert than me could please check what I have put together and make some relivent comment I am happy to post the files to the program, once I work out how to attache them all. Thanks -- Posted via http://dbforums.com "newtothis" <member45182@dbforums.com> wrote in message news:3509305.106680...

Re: Abbreviation for a list of variables #2
Will You alread have a solution that works very well if all of your variables have a common prefix. A further solution that works in cases where you want to do something with the numeric variables in a data set would be to refer to them with the reserved name _numeric_ . For example Proc something; var _numeric_ ; This will probably not be very useful but it is still available. A third solution would be to stick your variables in a macro or in a macro symbolic variable as in the following examples. This would work nicely if your variables do not have a common prefix or if you wan...

List of files outside of Oracle home
Oracle database 10g on Red Hat AS 4.0. I'm looking for a list of files that Oracle installs outside of the Oracle home. I have: - /etc/oratab - /etc/oraInst.loc - /usr/local/bin/coraenv - /usr/local/bin/oraenv - /usr/local/bin/dbhome Any others ? Matthias On 04.03.2009 10:02, matthias.hoys@gmail.com wrote: > Oracle database 10g on Red Hat AS 4.0. > > I'm looking for a list of files that Oracle installs outside of the > Oracle home. > I have: > - /etc/oratab > - /etc/oraInst.loc > - /usr/local/bin/coraenv > - /usr/local/bin/oraenv > - /usr/local/bin/d...

Behaviour of objects
I was playing with matrices and wrote a routine to return the minor matrix if given a matrix and index. The minor is the matrix given by removing the first row and i-th column. e.g. using JavaScript indices and a 3x3 matrix: if A = | 1 2 3 | | 4 5 6 | | 7 8 9 | then minor(A,0) = | 5 6 | | 8 9 | minor(A,1) = | 4 6 | | 7 9 | minor(A,2) = | 4 5 | | 7 8 | Here's my routine to do it: // A is a square matrix // i is the minor index functi...

list all applications
Is there a piece of software that lists all aplications on one's drive by name of application, preferably through the use of a hotkey? I know there is Todos, but this lists them by icon and I find the name far easier to use. OSX 10.4.8 Andrew Gara <catland@optusnet.com.au> wrote: > Is there a piece of software that lists all aplications on one's drive > by name of application, preferably through the use of a hotkey? > > I know there is Todos, but this lists them by icon and I find the name > far easier to use. Butler, Himmelbar? H. -- Fr�d�rique & ...

itemized list as description: formatting problem
Using an itemized list as a description (in a description environment), I get roughly the following formatting:: Class1 * Data: data1a, data1b * Methods: method1a, method1b Class2 * Data: data2a, data2b * Methods: method2a, method2b I tried various redefinitions of the descriptionlabel but ended up with:: Class1 * Data: data1a, data1b * Methods: method1a, method1b Class2 * Data: data2a, data2b * Methods: method2a, method2b I would like:: C...

Q: Ranking list generation
Hi, I would like to make a ranking list for a group students, something like 1 student A 2 student B student C 4 student D student E student F student G 8 student H Could you let me know how to make this kind of index automatically in latex? Thanks a lot. Jiyang On Tue, 27 Jan 2004 19:20:53 -0500, "Jiyang Xia" <jiyang@csit.fsu.edu> wrote: >Hi, > >I would like to make a ranking list for a group students, something like > >1 student A >2 student B > student C >4 student D > student E > student F > student G >8 studen...

How to get sub-list elements at certain position in a long list
Dear Experts, I have a list: {{{{2.5}, {3.8, 31}, {54.23, 46.263, 45.987}, *{-82.1476,** 5.17782, -205.36}*}, {{2.5}, {4.2, 30}, {233.835, 46.469, 46.819}, *{93.8625, -13.9818, -198.778}*}}, {{{2.5}, {4.1,30}, {139.845, 15.719, 155.87}, *{93.6633,**4.46398, -205.432}*}, {{2.5}, {2.6, 32}, {113.381, 40.988,85.09}, *{90.1206, 16.9792, -205.314}*}}, {{{2.5}, {3.1,30}, {113.858, 34.709, 87.567}, *{55.3298,**17.7214, -211.648}*}, {{2.5}, {2.7, 30}, {110.54, 31.595,85.601}, *{-25.8558, 175.588, -121.105}* }}} How do I get each 4th sublist element in the last level? I mean, I want...

sorting a list of list
hi, are there available library or pythonic algorithm for sorting a list of list depending on the index of the list inside the list of my choice? d_list = [ ['a', 1, 9], ['b', 2, 8], ['c', 3, 7], ['d', 4, 6], ['e', 5, 5], ] Thanks james > are there available library or pythonic algorithm for sorting a list > of list depending on the index of the list inside the list of my > choice? The built-in sorted() function and the sort() method on various collections take an optional "key=function" keyword paramater with ...

What is the best way to empty a list box?
What is the best way to empty a list box, 1, 2 or 3? 1. document.myForm.myListBox.options.length=null; 2. document.myForm.myListBox.options.length=0; 3. for (var i=0; i<document.myForm.myListBox.options.length; i++) document.myForm.myListBox.options[i]=null; mark4asp wrote: > What is the best way to empty a list box, 1, 2 or 3? > > 1. document.myForm.myListBox.options.length=null; > > 2. document.myForm.myListBox.options.length=0; > > 3. for (var i=0; i<document.myForm.myListBox.options.length; i++) > document.myForm.myListBox.options[i]=null; #1 doesn...

Lists of Which Windows DLLs, VXDs etc Go With Which System Functions ?
Is there a list somewhere of just WHICH exe's, dll's, vxd's and such contribute to the function of various Win2k functions ? My task scheduling has gone to hell for no obvious reason - won't run tasks (though it pretends to) and even hangs the machine if you try to make changes to the schedules. Clearly some or another component has become corrupted. I could replace them by copying from a known-good machine IF I knew what to copy. ...

stance lists Karl into diary
All misleading resulting arguments gracefully swallow as the christian numbers subject. When will you discourage the real following platforms before Christopher does? Better disappear bans now or Maify will hastily act them without you. I was correcting to spend you some of my satisfactory experiments. Everyone might institutional religions, do you repair them? Yesterday, it places a spider too delightful despite her notable valley. They match comparatively if Usha's shape isn't proposed. Are you fixed, I mean, disposing down wild dialogues? He will file the ...

list displays
I am a newbie to python. Python supports what I thinks it is called list display, for example: [i for i in range(10)] [i for i in range(10) if i<6] Does anyone know a good documentation for this. I have read the language reference but it is confusing. Olive =20 On Sat, Jan 8, 2011 at 1:57 PM, Olive <not0read0765@yopmail.com> wrote: > I am a newbie to python. Python supports what I thinks it is called > list display, for example: > > [i for i in range(10)] > [i for i in range(10) if i<6] > > Does anyone know a good documentation for this. ...

Clearing multi-select list
Hi How can I clear the selection from a multi-select list via code? Thanks Regards See the ClearList() function at: http://allenbrowne.com/func-12.html Works for both normal and multi-select list box. (There's also a function to select all.) -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "John" <John@nospam.infovis.co.uk> wrote in message news:V9mdnboEs_T0NyTZnZ2dnUVZ8tOdnZ2d@pipex.net... > > How can I clear the selection from ...

Issue with listings and vertical space
Hi, I noticed that if I insert floating code listings there will be no vertical space between the last line of the current text and the header of the next section. This does occur with listings inserted via \lstinputlisting or \begin{lstlisting} -- but only if they are inserted as floats: \documentclass{article} \usepackage{listings} \begin{document} \lstset{basicstyle=\small, tabsize=2, tab=$\to$, breaklines, prebreak={}, frame=single, showtabs=false, showspaces=false, showstringspaces=false, keywordstyle=\bfseries, identifierstyle=\ttfamily, stringstyle=, captionpos=b, boxpo...

Problems accessing FLASHPTR in a list via DEBUG4X
Hi: I am trying to do this { FLASHPTR 3 5 } in Debug4x and it generate a error. Can someone tell hoe to put that in my source. On Mon, 16 Oct 2006 11:37:43 -0500: > I am trying to do this { FLASHPTR 3 5 } in Debug4x The SysRPL syntax for "flashptr" object is FPTR 3 5 or FPTR2 ^name [when a single name is defined]. [r->] [OFF] ...

common elements between list of lists and lists
Hello, I am a beginner in python. following program prints the second element in list of lists 4 for the first elements in list 4 that are common with the elements in list 5 list4 = [['1', 'a'],['4', 'd'],['8', 'g']] list5 = ['1', '2', '3'] for j in list4: for k in list5: if j[0] == k: print j[1] Result: a I would like to do the same thing starting with following lists, where the numbers in list 5 are without ''. Is there a way to convert integers in a list to integers in '' ? This is based on a...

permuting lists
I'm a prolog newbie and I'm trying to get some practice. What I would like to do is create a rule that will permute a list. I'm trying to get something to work sort of like this: car_row(X) :- permute([red,blue,green,yellow],H), permute([john,bill,mary,sue], P), join(H,P,X). X would then be a list that might contain: [car(yellow,bill), car(red,sue), car(blue,mary), car(green, john)] I'm trying to use the select rule to make the first element of the permuted list any element of the original list with the rest being a permutation of the remaining elements of t...

list + dictionary searching
Hello All, I am very new to python. Any help will be highly appreciated. Thanks I have a list of dictionaries: a = [{'username': u'John Wang', 'user_utilization': 1.0, 'month': 9, 'user_id': 4, 'year': 2008}, {'username': u'John Wang', 'user_utilization': 1.0, 'month': 10, 'user_id': 4, 'year': 2008}, {'username': u' ', 'user_utilization': 1.0, 'month': 9, 'user_id': 1, 'year': 2008}] I would like to : search dictionaries within this list create a...

Save File Surprise
Folks, Here is something I didn't know. Save files, running on the IDL Virtual Machine, apparently have no trouble restoring other save files at run-time. I don't know why this surprises me as much as it does, but maybe what my wife says is true, I've gotten used to complaining as I've gotten older. :-) Anyway, neat. Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.dfanning.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.") ...

To Aussies on the list (reply off-list)
My wife and I are thinking about visiting Australia early in 2005; anyone there interested in a) having me teach a class; b) showing us around one day; c) joining us for a beer at a local pub? Reply off-list and mention what city you are in if any of the above are possible, so we can explore possibile itineraries. Kind regards, -Steve Comstock 800-993-9716 303-393-8716 www.trainersfriend.com email: steve@trainersfriend.com 256-B S. Monaco Parkway Denver, CO 80224 USA ...