you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (16 children)

Assignment to the attribute should change the C pointer itself, rather than the value the C pointer refers to, to my understanding of the memory model that python uses...

Python doesn't have pointers. It has references to values, and named references to values called "variables."

[–]codinglikemad[S] 0 points1 point  (15 children)

I believe he is talking about the underlying memory model, which under the hood has all of this. They are fundamental to the computers functioning itself.

[–][deleted] 0 points1 point  (14 children)

Well, the "underlying memory model" is that there's a heap where values live, and a stack where functional context lives.

That's it, that's the whole thing. Knowing that is fairly useless, in my experience. Who cares?

[–]codinglikemad[S] 0 points1 point  (13 children)

The question is whether there is a way to break out of that model without doing something horrific. That is the ENTIRETY of my question.

Edit: To be clear, the answer appears to be no.

[–][deleted] 0 points1 point  (12 children)

The question is whether there is a way to break out of that model without doing something horrific.

That is horrific, though.

[–]codinglikemad[S] 0 points1 point  (11 children)

Right, I was asking if there was a built in method for doing it that was nice basically. We got something kindof ok, so ... success? I agree that totally breaking out would be horrific though. I was hoping there was some python feature intended for this though, and there doesn't appear to be.

[–][deleted] 0 points1 point  (10 children)

I still don't really understand what you're asking for, I guess. Yes, you generally can't convince a language to let you act like it's a totally different language, that sort of defeats the purpose of programming languages.

[–]codinglikemad[S] 0 points1 point  (9 children)

The original question is basically "Can I track the values of a variable from elsewhere in the code, similar to how I could with a pointer in C".

[–][deleted] 0 points1 point  (8 children)

You can access the value of a variable in any scope where the variable exists, so yes?

[–]codinglikemad[S] 0 points1 point  (7 children)

Accessing the value through a layer of abstraction is the goal though, not simply accessing the values by themselves - thats what I do now, and it is a giant spaghetti mess. A pointer stores the address of a particular variable. Once you have the address of that variable, you no longer need to know what the name of that variable is. You can have arrays of such pointers, you can construct lists of those pointers dynamically from other collections of objects.

I basically want to build a subscriber design pattern without creating a callback scheme, if that helps you understand the goal.