Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-08 Thread Chris Angelico via Python-list
On Sat, 9 Mar 2024 at 03:42, Grant Edwards via Python-list wrote: > > On 2024-03-08, Chris Angelico via Python-list wrote: > > On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list > > wrote: > > > >> One might argue that "global" isn't a good choice for what to call the > >> scope in questi

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-08 Thread Grant Edwards via Python-list
On 2024-03-08, Chris Angelico via Python-list wrote: > On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list > wrote: > >> One might argue that "global" isn't a good choice for what to call the >> scope in question, since it's not global. It's limited to that source >> file. It doesn't make s

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-08 Thread Chris Angelico via Python-list
On Sat, 9 Mar 2024 at 00:51, Grant Edwards via Python-list wrote: > One might argue that "global" isn't a good choice for what to call the > scope in question, since it's not global. It's limited to that source > file. It doesn't make sense to me to call a binding "global", when > there can be mul

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-08 Thread Grant Edwards via Python-list
On 2024-03-07, Cameron Simpson via Python-list wrote: > Yes. Note that the "global" namespace is the module in which the > function is defined. One might argue that "global" isn't a good choice for what to call the scope in question, since it's not global. It's limited to that source file. It d

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-07 Thread Cameron Simpson via Python-list
On 06Mar2024 15:12, Jacob Kruger wrote: So, this does not make sense to me in terms of the following snippet from the official python docs page: https://docs.python.org/3/faq/programming.html "In Python, variables that are only referenced inside a function are implicitly global. If a variable

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-07 Thread Jacob Kruger via Python-list
Thanks again, all. I think the python -i scoping2.py would have given me a good beginning as well - will archive that one for use. And, to maybe explain how I work - not an excuse at all - but, I am actually 100% blind, so a lot of the IDE's, or their common means/methods of interaction do

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Grant Edwards via Python-list
On 2024-03-07, dn via Python-list wrote: > The idea of importing a module into the REPL and then (repeatedly) > manually entering the code to set-up and execute is unusual (surely type > such into a script (once), and run that (repeatedly). As you say, most > of us would be working from an IDE

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread dn via Python-list
On 7/03/24 05:28, Jacob Kruger via Python-list wrote: ... So, yes, know this comes across like some form of a scam/joke, or list-garbage, since it doesn't make any sense to me at all, but still just wondering if missing something, or should I shift over to 3.12 to see if if works differently, o

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Grant Edwards via Python-list schreef op 6/03/2024 om 18:59: On 2024-03-06, Roel Schroeven via Python-list wrote: > Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >> >>> from scoping2 import * > > [...] > > I would advice not to use 'import *', if at all possible, for multiple

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Grant Edwards via Python-list
On 2024-03-06, Roel Schroeven via Python-list wrote: > Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >> >>> from scoping2 import * > > [...] > > I would advice not to use 'import *', if at all possible, for multiple > reasons, one of which is to prevent problems like this. Unfortun

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 17:40 schreef Jacob Kruger via Python-list: >>> from scoping2 import * Ah yes, that explains what's happening. After that statement, the name dt_expiry in the current namespace is bound to the same object that the name dt_expiry in the namespace of module scoping2 is bound to. F

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
Ok, Ethan, that makes sense - I generally work with modules in folders, etc., but, this was just test code, but, 'see' if I instead import scoping2 as sc2, and then refer to sc2.dt_expiry and sc2.do_it, then it does operate as it should - thanks, again. Jacob Kruger +2782 413 4791 "Resistance

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Ethan Furman via Python-list
On 3/6/24 08:28, Jacob Kruger via Python-list wrote: > C:\temp\py_try>python > Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> from scoping2 import * And it becomes c

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
You'll see more details in other mail, but, here I am firing up standard python interpreter from within windows terminal, and then executing following line: from scoping2 import * And, this is under windows 11 windows terminal, which is where I generally interact with my python code, via com

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
Matt, other mail is more relevant - seems to maybe have more to do with different behavour if import code, or not - no, does not make sense to me - but, here's the command line contents including printing out id() results, but, only working via importing code: #---start session--- C:\temp\py_

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
g the contents of a referenced variable is fine in this context, the moment I try to reassign it, that's where the issue is occurring . Here are relevant excerpts from the file:- # start code # original assignation in main part of file l_servers = [] # function wich is init

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 16:39 schreef Roel Schroeven via Python-list: Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interpreter"? Othe

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Roel Schroeven via Python-list
Op 6/03/2024 om 13:55 schreef Jacob Kruger via Python-list: If you import the contents of that file into the python interpreter, [...] What exactly to you mean by "import the contents of that file into the python interpreter"? Other people have put your code in a script, executed it, and saw

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Thomas Passin via Python-list
# function wich is initially being executed def interact(): global l_servers # extra code inbetween choosing what to carry out # ... # end of other code bl_response, o_out = list_servers() if bl_response: # just make sure other function call was successful

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Thomas Passin via Python-list
On 3/6/2024 5:59 AM, Alan Gauld via Python-list wrote: On 05/03/2024 22:46, Grant Edwards via Python-list wrote: Unfortunately (presumably thanks to SEO) the enshittification of Google has reached the point where searching for info on things like Python name scope, the first page of links are to

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Mats Wichmann via Python-list
On 3/6/24 05:55, Jacob Kruger via Python-list wrote: Ok, simpler version - all the code in a simpler test file, and working with two separate variables to explain exactly what am talking about: If you import the contents of that file into the python interpreter, dt_expiry will start off as "19

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
sponse, o_out = list_servers() if bl_response: # just make sure other function call was successful l_servers.clear() # first make reference to global variable for srv in o_out: l_servers.append(srv) # now re-populate items # end code snippet from inside interact function # end of in

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Jacob Kruger via Python-list
vers() if bl_response: # just make sure other function call was successful l_servers.clear() # first make reference to global variable for srv in o_out: l_servers.append(srv) # now re-populate items # end code snippet from inside interact function # end of interact function #

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-06 Thread Alan Gauld via Python-list
On 05/03/2024 22:46, Grant Edwards via Python-list wrote: > Unfortunately (presumably thanks to SEO) the enshittification of > Google has reached the point where searching for info on things like > Python name scope, the first page of links are to worthless sites like > geeksforgeeks. And not just

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread Grant Edwards via Python-list
On 2024-03-05, Cameron Simpson via Python-list wrote: > Because there are no variable definitions in Python, when you write > a function Python does a static analysis of it to decide which > variables are local and which are not. If there's an assignment to a > variable, it is a local variable.

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread Cameron Simpson via Python-list
On 05Mar2024 20:13, Jacob Kruger wrote: Now, what almost seems to be occurring, is that while just manipulating the contents of a referenced variable is fine in this context, the moment I try to reassign it, that's where the issue is occurring . Because there are no variable definitions in Py

Re: Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread dn via Python-list
o_out = list_servers()     if bl_response: # just make sure other function call was successful     l_servers.clear() # first make reference to global variable     for srv in o_out: l_servers.append(srv) # now re-populate items     # end code snippet from inside interact functio

Variable scope inside and outside functions - global statement being overridden by assignation unless preceded by reference

2024-03-05 Thread Jacob Kruger via Python-list
    if bl_response: # just make sure other function call was successful     l_servers.clear() # first make reference to global variable     for srv in o_out: l_servers.append(srv) # now re-populate items     # end code snippet from inside interact function # end of interact function #

Re: PYT - The expressions described in the Python language reference yield only boolean values

2022-02-26 Thread Peter J. Holzer
On 2022-02-19 23:28:28 +0100, vanyp wrote: > *I am trying to learn Python from the grammar given in the Python language > reference and I am surprised.* > > *Lets start here:* > > *"* > *6.3.4. Calls* > > A call calls a callable object (e.g., a funct

Re: PYT - The expressions described in the Python language reference yield only boolean values

2022-02-19 Thread Chris Angelico
On Sun, 20 Feb 2022 at 12:00, vanyp wrote: > > *I am trying to learn Python from the grammar given in the Python > language reference and I am surprised.* > The grammar is not the best way to learn the language. It'll show you a lot of unnecessary details. For technical reasons,

PYT - The expressions described in the Python language reference yield only boolean values

2022-02-19 Thread vanyp
*I am trying to learn Python from the grammar given in the Python language reference and I am surprised.* *Lets start here:* *"* *6.3.4. Calls* A call calls a callable object (e.g., a function <https://docs.python.org/3/glossary.html#term-function>) with a possibly empty series o

Re: Removing reference to local installed package

2020-01-07 Thread DL Neil via Python-list
site -package pip uninstall does not work as the package is not in site-package in the first place importing the package does not work as the package is not in site-package it won't install and won't delete Q: How do i remove the reference of a local package? Possibly releva

Removing reference to local installed package

2020-01-07 Thread Abdur-Rahmaan Janhangeer
site-package in the first place importing the package does not work as the package is not in site-package it won't install and won't delete Q: How do i remove the reference of a local package? Thanks Yours, Abdur-Rahmaan Janhangeer pythonmembers.club <http://www.pythonmembers.cl

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Abdur-Rahmaan Janhangeer
gmail.com> wrote: > >> Greetings, >> >> I'm doing this project: >> >> >> https://github.com/Abdur-rahmaanJ/cmdlaunch/blob/master/cmdlaunch/cmdlaunch.py >> >> Everything works fine, except for one thing. >> >> On line 60,

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Abdur-Rahmaan Janhangeer
excuses for typos! -- https://mail.python.org/mailman/listinfo/python-list

Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Calvin Spealman
rything works fine, except for one thing. > > On line 60, the button is taking an object in it's command parameter > > If you run the file, you'll see that all the different names are written on > the gui just the callback is takest the newest icon object for all three &g

Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-07 Thread Abdur-Rahmaan Janhangeer
erent names are written on the gui just the callback is takest the newest icon object for all three buttons I know just a reference issue but it's been **bugging** me. Thanks All -- Abdur-Rahmaan Janhangeer Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: Lifetime of a local reference

2019-03-01 Thread Gregory Ewing
Alan Bawden wrote: The Java compiler has no way to know whether a variable references an object with a finalize() method that has side effects It should be able to tell in some situations, e.g. String a = "hello"; String b = a.replace('e', 'u'); There

Re: Lifetime of a local reference

2019-03-01 Thread Alan Bawden
r...@zedat.fu-berlin.de (Stefan Ram) writes: > Alan Bawden writes: > >The Java compiler has no way to know whether a variable references an > >object with a finalize() method that has side effects > > java.lang.Object#finalize() is deprecated since Java 9. And we are advised to use a "Cleane

Re: Lifetime of a local reference

2019-02-28 Thread Chris Angelico
On Fri, Mar 1, 2019 at 9:31 AM Marko Rauhamaa wrote: > > Roel Schroeven : > > In the absence of any other mention of bindings being removed, to me > > it seems clear that bindings are not automatically removed. Otherwise > > many things become ambiguous. Example: the documentation for dicts > > de

Re: Lifetime of a local reference

2019-02-28 Thread Marko Rauhamaa
Roel Schroeven : > In the absence of any other mention of bindings being removed, to me > it seems clear that bindings are not automatically removed. Otherwise > many things become ambiguous. Example: the documentation for dicts > defines "d[key] = value" as "Set d[key] to value". Does that mean it

Re: Lifetime of a local reference

2019-02-28 Thread Roel Schroeven
ion points me to (https://docs.python.org/3/reference/datamodel.html#objects-values-and-types): "Objects are never explicitly destroyed; however, when they become unreachable they may be garbage-collected. An implementation is allowed to postpone garbage collection or omit it altogether — it

Re: Lifetime of a local reference

2019-02-28 Thread Marko Rauhamaa
Chris Angelico : > What if an exception gets raised at some point before the function has > returned? The exception object will give full access to the function's > locals. It wouldn't hurt for the Python gods to make an explicit ruling on the matter. Marko -- https://mail.python.org/mailman/li

Re: Lifetime of a local reference

2019-02-28 Thread Chris Angelico
it > > goes out of scope. A quick search in the documentation points me to > > (https://docs.python.org/3/reference/datamodel.html#objects-values-and-types): > > > > > > "Objects are never explicitly destroyed; however, when they become > > unreachable th

Re: Lifetime of a local reference

2019-02-28 Thread Rhodri James
On 27/02/2019 21:39, Roel Schroeven wrote: Rhodri James schreef op 27/02/2019 om 15:18: Aren't we overthinking this? I think it's pretty clear that a variable is never deleted before it goes out of scope. A quick search in the documentation points me to (https://docs.python.org/3

Re: Lifetime of a local reference

2019-02-28 Thread Marko Rauhamaa
; >object to be potentially reclaimable sooner. >> >> However, it only makes sense to do that if the compiler can be >> sure that reclaiming the object can't possibly have any side >> effects. That's certainly not true of things like file objects >> tha

Re: Lifetime of a local reference

2019-02-27 Thread Alan Bawden
> > However, it only makes sense to do that if the compiler can be > sure that reclaiming the object can't possibly have any side > effects. That's certainly not true of things like file objects > that reference resources outside of the program. I'd be pretty > upset if a

Re: Lifetime of a local reference

2019-02-27 Thread Gregory Ewing
Thomas Jollans wrote: If the inspect module's stack frame inspection machinery is supported, then any function call might access any local... (though I don't think a compliant Python implementation necessarily has to support the inspect module fully). You can be devious even without using the e

Re: Lifetime of a local reference

2019-02-27 Thread Gregory Ewing
sibly have any side effects. That's certainly not true of things like file objects that reference resources outside of the program. I'd be pretty upset if a Java implementation prematurely closed my files on the basis of this clause. Similar considerations apply to Python. Even more

Re: Lifetime of a local reference

2019-02-27 Thread Thomas Jollans
ation points me to > (https://docs.python.org/3/reference/datamodel.html#objects-values-and-types): > > > "Objects are never explicitly destroyed; however, when they become > unreachable they may be garbage-collected. An implementation is allowed > to postpone garbage co

Re: Lifetime of a local reference

2019-02-27 Thread Roel Schroeven
his? I think it's pretty clear that a variable is never deleted before it goes out of scope. A quick search in the documentation points me to (https://docs.python.org/3/reference/datamodel.html#objects-values-and-types): "Objects are never explicitly destroyed; however, whe

Re: Lifetime of a local reference

2019-02-27 Thread Thomas Jollans
On 27/02/2019 16.41, Marko Rauhamaa wrote: > Rhodri James : >> The description of the with statement does explicitly say that the >> context manager's __exit__() method won't be called until the suite >> has been executed, so the reference to the open file must

Re: Lifetime of a local reference

2019-02-27 Thread Marko Rauhamaa
ock") >> flock.flock(f, fcntl.LOCK_EX) >> do_stuff() >> sys.exit(0) > > I would go with: > > def fun(): > with open("lock") as f: > flock.flock(f, fcntl.LOCK_EX) > do_stuff() >

Re: Lifetime of a local reference

2019-02-27 Thread Rhodri James
() sys.exit(0) I would go with: def fun(): with open("lock") as f: flock.flock(f, fcntl.LOCK_EX) do_stuff() sys.exit(0) The description of the with statement does explicitly say that the context manager's __exit__() method won't

Re: Lifetime of a local reference

2019-02-27 Thread Thomas Jollans
riables > early. But I agree with you that the Python Language Reference does not > appear to address this question anywhere! > That's probably right. However, due to the nature of Python, things like this are possible: >>> v = 'a' >>> def f(): ...

Re: Lifetime of a local reference

2019-02-27 Thread Test Bot
Just to add on regarding file I/O. It would be more pythonic to use. with open(path): do_stuff() On Wed, Feb 27, 2019, 3:31 AM Marko Rauhamaa wrote: > > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() >

Re: Lifetime of a local reference

2019-02-26 Thread Marko Rauhamaa
is why Guile documentation mentions a special mechanism to prevent premature garbage collection: https://www.gnu.org/software/guile/docs/docs-2.0/guile-ref/Rememb ering-During-Operations.html> > I suspect that given the history of Python, pretty much everybody has > always assumed

Re: Lifetime of a local reference

2019-02-26 Thread Alan Bawden
tation. I suspect that given the history of Python, pretty much everybody has always assumed that a Python implementation will not delete local variables early. But I agree with you that the Python Language Reference does not appear to address this question anywhere! -- Alan Bawden -- https://mail.python.org/mailman/listinfo/python-list

Re: Lifetime of a local reference

2019-02-26 Thread Tim Daneliuk
On 2/26/19 3:54 PM, Marko Rauhamaa wrote: > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release the file l

Re: Lifetime of a local reference

2019-02-26 Thread Chris Angelico
On Wed, Feb 27, 2019 at 9:00 AM Marko Rauhamaa wrote: > Consider this function: > > def fun(): > f = open("lock") > flock.flock(f, fcntl.LOCK_EX) > do_stuff() > sys.exit(0) > > Question: can a compliant Python implementation close f (and, > consequently, release

Lifetime of a local reference

2019-02-26 Thread Marko Rauhamaa
Consider this function: def fun(): f = open("lock") flock.flock(f, fcntl.LOCK_EX) do_stuff() sys.exit(0) Question: can a compliant Python implementation close f (and, consequently, release the file lock) before/while do_stuff() is executed? I couldn't find a

Re: Cannot find reference 'bluetoothctl' in 'sh.py' less... (Ctrl+F1)

2018-11-15 Thread tommy yama
assume that it is not a Python package at all (but rather some > command line utility in some operating system package). At least > on my Ubuntu 18.04, "bluetoothctl" is an operating system utility. > > *from sh import bluetoothctl* > > *mac = "your bluetooth mac

Re: Cannot find reference 'bluetoothctl' in 'sh.py' less... (Ctrl+F1)

2018-11-14 Thread dieter
lity. *from sh import bluetoothctl* *mac = "your bluetooth mac"* *bluetoothctl("connect", mac)* > In the pycharm, I see the below error message : > > *Cannot find reference 'bluetoothctl' in 'sh.py' less... (Ctrl+F1) * > *Inspection info: Thi

Cannot find reference 'bluetoothctl' in 'sh.py' less... (Ctrl+F1)

2018-11-14 Thread srinivasan
de on pycharm and try to point on the word "bluetoothctl" in the beginning of the line "*from sh import bluetoothctl*" *from sh import bluetoothctl* *mac = "your bluetooth mac"* *bluetoothctl("connect", mac)* In the pycharm, I see the below error mes

Re: Reference cycles

2017-09-24 Thread Peter Otten
Steve D'Aprano wrote: > Is there a way to log when the garbage collector finds and collects a > reference cycle? > > I don't care about objects claimed by the reference counter, I only care > about cycles. I don't know, and I don't think so. Would a structure

Reference cycles

2017-09-24 Thread Steve D'Aprano
Is there a way to log when the garbage collector finds and collects a reference cycle? I don't care about objects claimed by the reference counter, I only care about cycles. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. --

Re: __del__ is not called after creating a new reference

2017-03-21 Thread Oleg Nesterov
On 03/21, Steve D'Aprano wrote: > > I changed the code to run: > > c = C() > del c > > and now I'm seeing the same thing as you: DEL is only printed once. Yes, I've forwared this question to python-dev, please see https://mail.python.org/pipermail/python-dev/2017-March/147631.html so the implemen

Re: __del__ is not called after creating a new reference

2017-03-20 Thread Steve D'Aprano
active interpreter, and forgot that it saves a reference to the last result using _ so of course the __del__ method didn't run at all. I changed the code to run: c = C() del c and now I'm seeing the same thing as you: DEL is only printed once. -- Steve “Cheer up,” they said, “things

Re: __del__ is not called after creating a new reference

2017-03-20 Thread Steve D'Aprano
On Sat, 18 Mar 2017 01:54 am, Oleg Nesterov wrote: [...] > However, this trivial test-case > > class C: > def __del__(self): > print("DEL") > global X > X = self > C() > print(X) > X = 0 > print(X) > > shows that __del__ is called only once, it is not called again after "X = > 0": > > DEL > <__

Re: __del__ is not called after creating a new reference

2017-03-17 Thread Oleg Nesterov
On 03/17, Terry Reedy wrote: > > On 3/17/2017 10:54 AM, Oleg Nesterov wrote: >> I started to learn python a few days ago and I am trying to understand what >> __del__() actually does. https://docs.python.org/3/reference/datamodel.html >> says: >&g

Re: __del__ is not called after creating a new reference

2017-03-17 Thread Terry Reedy
On 3/17/2017 10:54 AM, Oleg Nesterov wrote: I started to learn python a few days ago and I am trying to understand what __del__() actually does. https://docs.python.org/3/reference/datamodel.html says: object.__del__(self) ... Note that it is possible (though not

__del__ is not called after creating a new reference

2017-03-17 Thread Oleg Nesterov
I started to learn python a few days ago and I am trying to understand what __del__() actually does. https://docs.python.org/3/reference/datamodel.html says: object.__del__(self) ... Note that it is possible (though not recommended!) for the __del__() method to

Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Chris Green
Michael Torrie wrote: > On 03/10/2017 01:26 PM, Chris Green wrote: > > Wildman wrote: > >> On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote: > >> > >>> I'm using the excellent tutorial at > >>> https://python-gtk-3-tutorial.readthedoc

Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Michael Torrie
On 03/10/2017 01:26 PM, Chris Green wrote: > Wildman wrote: >> On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote: >> >>> I'm using the excellent tutorial at >>> https://python-gtk-3-tutorial.readthedocs.io >>> and occasionally w

Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Liste guru
Il 10/03/2017 20:26, Wildman via Python-list ha scritto: On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote: I'm using the excellent tutorial at https://python-gtk-3-tutorial.readthedocs.io and occasionally want reference documentation, is there reference documentation for this on

Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Chris Green
Wildman wrote: > On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote: > > > I'm using the excellent tutorial at > > https://python-gtk-3-tutorial.readthedocs.io > > and occasionally want reference documentation, is there reference > > documen

Re: Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Wildman via Python-list
On Fri, 10 Mar 2017 18:51:35 +, Chris Green wrote: > I'm using the excellent tutorial at > https://python-gtk-3-tutorial.readthedocs.io > and occasionally want reference documentation, is there reference > documentation for this on line? https://developer.gnome.org/gtk3

Where to find python GTK+ 3 reference documentation?

2017-03-10 Thread Chris Green
I'm using the excellent tutorial at https://python-gtk-3-tutorial.readthedocs.io and occasionally want reference documentation, is there reference documentation for this on line? -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: Django Application Model Reference

2016-11-05 Thread Chris Angelico
On Thu, Nov 3, 2016 at 4:44 AM, Dreyton Scott wrote: > On Wednesday, November 2, 2016 at 1:40:35 PM UTC-4, Dreyton Scott wrote: >> Hello. I am currently creating a notification django application that will >> need to be able to "hook" into another django application. What my app needs >> is a wa

Re: Django Application Model Reference

2016-11-02 Thread Dreyton Scott
On Wednesday, November 2, 2016 at 1:40:35 PM UTC-4, Dreyton Scott wrote: > Hello. I am currently creating a notification django application that will > need to be able to "hook" into another django application. What my app needs > is a way to retrieve all model classes in the connected applicatio

Django Application Model Reference

2016-11-02 Thread Dreyton Scott
Hello. I am currently creating a notification django application that will need to be able to "hook" into another django application. What my app needs is a way to retrieve all model classes in the connected application. Is there a way to do this? -- https://mail.python.org/mailman/listinfo/pyt

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
before* decreffing and verify that it's what you expect. Exactly, which is presumably what dieter meant by a refcount of 1 being the one you're holding. A refcount of *2* indicates another reference somewhere. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
Chris Angelico wrote: If you've Py_DECREFed it and then peek into its internals, you're aiming a gun at your foot. That's true. A safer way would be to look at the refcount *before* decreffing and verify that it's what you expect. -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Chris Angelico
On Wed, Sep 28, 2016 at 6:56 PM, Gregory Ewing wrote: > dieter wrote: >> >> dl l writes: >> >>> When I debug in C++, I see the reference count of a PyObject is 1. > >>> How can I find out where is referencing this object? >> >> >> Likel

Re: Python C API: How to debug reference leak?

2016-09-28 Thread Gregory Ewing
dieter wrote: dl l writes: When I debug in C++, I see the reference count of a PyObject is 1. >> How can I find out where is referencing this object? Likely, it is the reference, you are holding: Unless you've just Py_DECREFed it, expecting it to go away, and the recfcount is

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > When I debug in C++, I see the reference count of a PyObject is 1. I don't > know where is referencing this object. How can I find out where is > referencing this object? Likely, it is the reference, you are holding: typically, whenever you can access a Python objec

Re: Python C API: How to debug reference leak?

2016-09-28 Thread dieter
dl l writes: > Thanks for reply. Is there any function in C to get the reference objects > of a object? I want to debug where are referencing the object. Depending on your understanding of "reference objects", this would be "gc.get_referents" or "gc.get_referrers

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
When I debug in C++, I see the reference count of a PyObject is 1. I don't know where is referencing this object. How can I find out where is referencing this object? 2016-09-27 15:47 GMT+08:00 dl l : > Thanks for reply. Is there any function in C to get the reference objects > of

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dl l
Thanks for reply. Is there any function in C to get the reference objects of a object? I want to debug where are referencing the object. 2016-09-27 15:01 GMT+08:00 dieter : > dl l writes: > > I want to check the references of an object. Any way to get the > references > >

Re: Python C API: How to debug reference leak?

2016-09-27 Thread dieter
dl l writes: > I want to check the references of an object. Any way to get the references > of an object with Python C API? Like: gc.get_referrs(), is there similar > API in C lib? "gc" is a module. You can import and access modules from the C API. Thus, you can use "gc.get_referers" from "C" cod

Python C API: How to debug reference leak?

2016-09-26 Thread dl l
I want to check the references of an object. Any way to get the references of an object with Python C API? Like: gc.get_referrs(), is there similar API in C lib? -- https://mail.python.org/mailman/listinfo/python-list

Re: What is the common technique used to cross-reference in module's method?

2016-03-19 Thread Peter Otten
gt;... >return eval(...) # the returned object is a Piece object and would avoid the eval(). > class Piece(): > ... > def moves_available(self): > model = self.model > ... > if item not in model.all_occupied_positions(): >

What is the common technique used to cross-reference in module's method?

2016-03-19 Thread jfong
There are two modules (say model.py and piece.py) which has methods need to refer to each other module's methods. I saw in a book using the way below, by assigning one (the Model) object to an attribute of the other (the Piece) bject. - ##model.py import piece ... class Model(dict):

Re: Terminology: "reference" versus "pointer"

2015-09-16 Thread Chris Angelico
On Wed, Sep 16, 2015 at 6:24 PM, Ben Finney wrote: > Chris Angelico writes: > >> On Wed, Sep 16, 2015 at 6:14 PM, Gregory Ewing >> wrote: >> > This suggests an alternative model for Python computation. All data >> > is represented by cats. A variable is a box containing a cat. >> > Assignment re

Re: Terminology: "reference" versus "pointer"

2015-09-16 Thread Ben Finney
Chris Angelico writes: > On Wed, Sep 16, 2015 at 6:14 PM, Gregory Ewing > wrote: > > This suggests an alternative model for Python computation. All data > > is represented by cats. A variable is a box containing a cat. > > Assignment replaces one cat with an entangled copy of another cat, > > so

Re: Terminology: "reference" versus "pointer"

2015-09-16 Thread Chris Angelico
On Wed, Sep 16, 2015 at 6:14 PM, Gregory Ewing wrote: > Emile van Sebille wrote: > >> Shroedingers-cat-was-just-a-cat-in-a-box-too-ly y'rs, > > > The real question is, if you kill Schroedinger's cat, does > Heisenberg's cat die too? If so, then either they're the > same cat, or they're two entangl

Re: Terminology: "reference" versus "pointer"

2015-09-16 Thread Gregory Ewing
Emile van Sebille wrote: Shroedingers-cat-was-just-a-cat-in-a-box-too-ly y'rs, The real question is, if you kill Schroedinger's cat, does Heisenberg's cat die too? If so, then either they're the same cat, or they're two entangled cats. This suggests an alternative model for Python computation

Re: Terminology: "reference" versus "pointer"

2015-09-15 Thread Steven D'Aprano
On Tue, 15 Sep 2015 03:34 am, Random832 wrote: > On Mon, Sep 14, 2015, at 13:03, Steven D'Aprano wrote: >> On Tue, 15 Sep 2015 01:10 am, Random832 wrote: >> > That's not true in CPython. In fact, the range object in python >> > contains *four* reference

Re: Terminology: "reference" versus "pointer"

2015-09-15 Thread Steven D'Aprano
On Tue, 15 Sep 2015 04:02 am, Random832 wrote: > The point is that with immutable objects no-one cares if they are three > objects with the same value, or three references to the same object. Well, you might care... a = (1,)*(10**12) b = (1,)*(10**12) c = (1,)*(10**12) Each of those tuples wou

Re: Terminology: "reference" versus "pointer"

2015-09-14 Thread Akira Li
Ned Batchelder writes: > On Monday, September 14, 2015 at 3:32:46 PM UTC-4, Akira Li wrote: >> Ned Batchelder writes: >> ... >> > What do you feel is missing from Steven's diagram? >> >> I don't feel anything missing because I don't expect the model to be >> more detailed. > > Akira, you said,

  1   2   3   4   5   6   7   8   9   10   >