Re: working with pointers



Michael wrote:
Do expicit pointers exist in python??

if i do:

a = [5,7]
b = a

a.empty()

b = ?

This is what the interactive prompt is for. Try it:

py> a = [5,7]
py> b = a
py> a.empty()
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
AttributeError: 'list' object has no attribute 'empty'

Well, looks like you get an AttributeError. Let's try a method that actually exists instead:

py> a.pop()
7
py> a
[5]
py> b
[5]

So, as you can see, since 'a' and 'b' are both names referring to the same object, when you modify the object referred to by 'a', you are also modifying the object referred to by 'b'.

how do i do explicit pointers??

I don't know what you mean by "explicit pointers". Care to elaborate? It also might help if you explained what it is you think you want "explicit pointers" to do.


STeVe
.



Relevant Pages

  • Re: property () for Java Programmers ?
    ... michael wrote: ... Well, if you actually want your getx/setx/delx to be called, then you ... Traceback: ... AttributeError: 'C' object has no attribute '_C__x' ...
    (comp.lang.python)
  • Re: Code Group Security policy deployment
    ... > Don't try to modify these files manually. ... >> Use of included script samples are subject to the terms specified at ...
    (microsoft.public.dotnet.security)
  • Re: Modifying data in complex type
    ... Michael, ... syntax incorrect somewhere, or my predicates weren't correct, or something. ... >> modify() ... >>> update the old tree with the new one. ...
    (microsoft.public.sqlserver.xml)
  • Re: SQLXML and column name with hypen (-)
    ... one) from an external system, I need to modify it on my side to solve ... >> Hi Michael, ... Below is my actual xml file with ...
    (microsoft.public.sqlserver.xml)
  • RE: Forms loading slowly
    ... "Michael" wrote: ... "John Germany" wrote: ... Lately my forms have been taking up to 10 seconds to load when I modify or ...
    (microsoft.public.fox.programmer.exchange)