Re: working with pointers



"Steven Bethard" <steven.bethard@xxxxxxxxx> wrote in message
news:JJSdnXLcZdUsLQHfRVn-1w@xxxxxxxxxxxxxx
> 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

sorry, I'm used to working in c++ :-p

if i do
a=2
b=a
b=0
then a is still 2!?

so when do = mean a reference to the same object and when does it mean make
a copy of the object??

regards

Mike


.



Relevant Pages

  • Re: Function pointers: performance penalty?
    ... Nope, function pointers are faster. ... For what I use them for, function pointers /are/ faster*. ... At the point of a call, even function names are explicit pointers in C, ... Any true emperor never needs to wear clothes. ...
    (comp.lang.c)
  • Re: Function pointers: performance penalty?
    ... Nope, function pointers are faster. ... For what I use them for, function pointers /are/ faster*. ... If I'd replied to the OP, which I didn't, I would only have addressed the obvious question, comparing ordinary function calls with those via explicit pointers. ...
    (comp.lang.c)
  • Re: Whats the position of pointers
    ... If you are able to solve it without using the pointers, ... couldn't have made if you'd bothered to compile your code before ... without bothering to compile it.) ... You mean that the code shouldn't *directly* modify a. ...
    (comp.lang.c)
  • Re: Ginastub domain list
    ... I am interested in how you hooked the callback functions. ... modify the pointers in the pWinLogonFunctions dispatch table? ... > populates the domain list, or how to set the combobox the way I want to. ...
    (microsoft.public.platformsdk.security)
  • Re: Whats the position of pointers
    ... couldn't have made if you'd bothered to compile your code before ... It's not possible for the value of a to become 20 unless you modify ... problems which cann;t be solved without using the pointers. ... can be a solution without using call by reference here. ...
    (comp.lang.c)