Wow, I turned my back to attend to $job and this conversation has
'exploded' (>80 msgs)!
TLDR;
With apologies, I started to reply to your reply, but then added 'bits'
as I read the conversation thereafter. The result (below) is a messy
hodge-podge, for which I can only apologise (as I don't ha
On Sun, Dec 15, 2019 at 10:01 PM wrote:
>
> On Thu, 12 Dec 2019 11:33:25 +
> Rhodri James wrote:
>
> > On 11/12/2019 21:32, mus...@posteo.org wrote:
> > > Plain and simple: When the refcount reaches zero.
>
> > You are assuming that "when" implies "immediately on the occurence."
>
> I'm not i
On Thu, 12 Dec 2019 11:33:25 +
Rhodri James wrote:
> On 11/12/2019 21:32, mus...@posteo.org wrote:
> > Plain and simple: When the refcount reaches zero.
> You are assuming that "when" implies "immediately on the occurence."
I'm not implying that. It's the dictionary definition of the word
On 14/12/19 5:13 pm, boB Stepp wrote:
is it true that CPython itself is free to
implement these behaviors differently in its own future versions?
Yes. That's why it's not a good idea to rely on them even
if you only intend to run your code on CPython.
--
Greg
--
https://mail.python.org/mailman
On Wed, Dec 11, 2019 at 6:51 PM Greg Ewing wrote:
>
> On 12/12/19 3:50 am, R.Wieser wrote:
> > I was rather clear about what my used version of Python was-and-is. I have
> > no idea why that was ignored. :-(
>
> I think we've all been talking at cross purposes for a while.
>
> What I meant to say
On 11/12/19 14:42, R.Wieser wrote:
> Michael,
>
>> It's a two-way street. It's hard to teach someone that won't be taught.
> Whacking a student over the head because he doesn't understand has never
> helped the student*.
You were not whacked for not understanding. You were wacked for
pretending
Hi Chris,
The most important distinction, which that note is emphasizing, is
that the "del" statement removes just one reference, and if there are
other references, then __del__ will not be called.
No argument there, that's how reference counting works, and it's clear
from the docs. What is n
On 11/12/2019 21:32, mus...@posteo.org wrote:
On Tue, 10 Dec 2019 14:56:10 -0500
Dennis Lee Bieber wrote:
It is called when the language IMPLEMENTATION decides to call
it. That time is not specified in the language description/reference
manual.
Yes it is:
"Note: del x doesn’t directl
On Thu, Dec 12, 2019 at 1:33 PM Daniel Haude wrote:
>
> Am 10.12.2019 22:29 schrieb Chris Angelico:
>
> > And once again, you are maintaining your assumptions despite being
> > very clearly shown that they are wrong. "del instance" does not
> > directly call __del__ any more than "instance = 1" do
On 12/12/19 2:17 pm, Python wrote:
I was very impressed back in the day when the
with statement and context manager protocol appeared in
Python. I've always wondered from what language(s) it was
borrowed from
It was partly inspired by the RAII pattern often used
in C++, but as far as I know, al
On Tue, 10 Dec 2019 22:08:48 +0100
"R.Wieser" wrote:
> And although you have been fighting me over when the __del__ method is
> called, it /is/ called directly as a result of an "del instance" and
> the refcount goes zero. There is /no/ delay.(with the only
> exception is when a circular ref
Am 10.12.2019 22:29 schrieb Chris Angelico:
And once again, you are maintaining your assumptions despite being
very clearly shown that they are wrong. "del instance" does not
directly call __del__ any more than "instance = 1" does. You HAVE been
shown.
Much of the confusion in this thread come
Greg Ewing wrote:
...
You deal with it by not relying on __del__ for anything
that needs to be done promptly. There are always alternatives:
e.g. file objects have a close() method, and the "with"
statement was invented to make it easy to do these kinds
of things properly.
By the way, I was ver
On 12/12/19 3:50 am, R.Wieser wrote:
I was rather clear about what my used version of Python was-and-is. I have
no idea why that was ignored. :-(
I think we've all been talking at cross purposes for a while.
What I meant to say originally was that you were relying on
an implementation detail
On Tue, 10 Dec 2019 14:56:10 -0500
Dennis Lee Bieber wrote:
>
> It is called when the language IMPLEMENTATION decides to call
> it. That time is not specified in the language description/reference
> manual.
Yes it is:
"Note: del x doesn’t directly call x.__del__() — the former decrements
R.Wieser schreef op 11/12/2019 om 11:43:> MRAB,
>
>> From the help:
> ...
>> Do not depend on immediate finalization of objects when they become
>> unreachable (so you should always close files explicitly).
>
> Do you notice there is not a single word about (the delayed action
of) the
> __del__
Am 11.12.2019 11:22 schrieb R.Wieser:
I think I will just go out on a limb and just assume that the __del__
method
/will/ be called as part of a "del instance" request causing the
reference
count to reach zero (directly or indirectly), before the next command
is
executed [...].
That's what
Am 11.12.2019 11:01 schrieb Greg Ewing:
On 11/12/19 7:47 am, R.Wieser wrote:
what happens when the reference becomes zero: is the __del__
method called directly (as I find logical), or is it only called when
the
garbage collector actually removes the instance from memory (which
Chris
thinks w
Chris,
> Yes, we know exactly how that's solved,
Nice.
> but you specifically said you weren't interested in learning.
Try taking a few courses of "understanding what you read". That is /not/
what I said.
Though it goes in par with your amadant "you're wrong" chanting, even if
there is at l
You could write the name of the class variable you want to import for example
class manager
On December 10, 2019, at 2:46 AM, Dennis Lee Bieber
wrote:
On Mon, 9 Dec 2019 20:21:39 +0100, "R.Wieser"
declaimed the following:
>
>And than when the instance is deleted the binding to the class is
Bev,
> You acknowledge that you are new to Python, yet you claimed
> to know better than Python experts. You claim you want an answer
> and yet you purposefully ignored their response because it didn't match
> what you wanted to hear.
No, I didn't. I just pointed out that their position simply w
On Thu, Dec 12, 2019 at 1:56 AM R.Wieser wrote:
> A question though: I have brought up that a delayed calling of the __del__
> method could/would most likely cause race problems. Do you have any idea
> how thats solved in environents like Jython ?
Yes, we know exactly how that's solved, but you
Greg,
> In CPython, these are the same thing. As soon as the reference
> count becomes zero, the __del__ method is called
That is what I assumed (the logical thing to do).
> *and* the object is removed from memory.
Which sounds reasonable too, especially in regard to the instances variables
ne
On 11/12/2019 14:17, Musbur wrote:
Am 10.12.2019 22:33 schrieb Paul Moore:
You do understand that the reference counting garbage collector is an
implementation detail of the CPython implementation *only*, don't you?
I don't think that's true. Here's a sentonce from near the top of the
"gc" m
Am 10.12.2019 22:33 schrieb Paul Moore:
You do understand that the reference counting garbage collector is an
implementation detail of the CPython implementation *only*, don't you?
I don't think that's true. Here's a sentonce from near the top of the
"gc" module documentation of Python 3:
ht
Antoon,
> There is a difference between not understanding why things are as
> you are told, and assuming because you don't understand, what you
> are told is wrong.
The other side is you guys, expecting from me that, even though I
appearantly do not understand it, just take whatever has being sa
Michael,
> It's a two-way street. It's hard to teach someone that won't be taught.
Whacking a student over the head because he doesn't understand has never
helped the student*. So, stop whacking and start /teaching/. Like
thinking of examples that could show the student where he goes wrong
Michael,
> You said it by implication.
>
> quote: "And as I do not think the designers of the language where that
> stupid I must therefore reject your claim to what you think happens."
I suggest you try reading that again, and imagine it being two centences,
the first ending after "stupid" and
> On Dec 11, 2019, at 6:09 AM, R.Wieser wrote:
>
> Paul,
>
>> You do understand that the reference counting garbage collector is an
>> implementation detail of the CPython implementation *only*, don't you?
>
> No, I don't. But do tell how that matters to me.
>
>> there can be an indefinite
MRAB,
> You don't "del" an instance, you "del" a reference, which might be in the
> form of a name in a namespace.
Remember me, the newbie to the language ?
Did you understand what I tried to to say ? Good. Thats al that matters.
> When the instance is collected, whenever that happens to be
Paul,
> You do understand that the reference counting garbage collector is an
> implementation detail of the CPython implementation *only*, don't you?
No, I don't. But do tell how that matters to me.
> there can be an indefinite delay between the last reference to
> a value being lost and the
MRAB,
> From the help:
...
> Do not depend on immediate finalization of objects when they become
> unreachable (so you should always close files explicitly).
Do you notice there is not a single word about (the delayed action of) the
__del__ method in there ? Why than do you think its talking a
Dennis,
This is the first time I've seen you post FUD. :-((
> It is called when the language IMPLEMENTATION decides to call it.
> That time is not specified in the language description/reference manual.
I'm rather sure it neither specifies that for any of the other commands.
Does that mean that
On 11/12/19 7:47 am, R.Wieser wrote:
what happens when the reference becomes zero: is the __del__
method called directly (as I find logical), or is it only called when the
garbage collector actually removes the instance from memory (which Chris
thinks what happens) ?
In CPython, these are the s
On 10/12/19 22:24, R.Wieser wrote:
> Roel,
>
>> Rudy, unless/until you know the language inside out, you'd better listen
>> to Chris and other people here who spend a lot of time and effort in
>> helping people like you.
> I tried. But what he said made no sense to me, and no matter how hard I
Michael Torrie wrote:
On 12/10/19 2:08 PM, R.Wieser wrote:
You might know a thing or two about Python, but you (and a number of others
here) positivily stink as teachers, incapable or even unwilling to place
themselves in the shoes of a newbie.
As it happens, I've heard Chris speak about teach
On 12/10/19 2:08 PM, R.Wieser wrote:
> You might know a thing or two about Python, but you (and a number of others
> here) positivily stink as teachers, incapable or even unwilling to place
> themselves in the shoes of a newbie.
As it happens, I've heard Chris speak about teaching Python to studen
On 2019-12-10 21:08, R.Wieser wrote:
Chris,
Once again, you make positive assertions about things you
don't understand.
And you have refused to bring any kind of help (explanation!) forward that
could have shown me the erring of my ways, as well as refusing to adress my
(attempting to explain
On 12/10/19 11:47 AM, R.Wieser wrote:
> Who did I call stupid ?I mentioned that the language doing it as Chris
> thinks it happens would be stupid, and I gave a reason for that (race
> conditions everywhere). But odd: Neither him nor you nor anyone else who
> complains about me thinking for
On Tue, 10 Dec 2019 at 21:12, R.Wieser wrote:
> And although you have been fighting me over when the __del__ method is
> called, it /is/ called directly as a result of an "del instance" and the
> refcount goes zero. There is /no/ delay.(with the only exception is
> when a circular reference e
On Wed, Dec 11, 2019 at 8:26 AM R.Wieser wrote:
>
> Roel,
>
> > Rudy, unless/until you know the language inside out, you'd better listen
> > to Chris and other people here who spend a lot of time and effort in
> > helping people like you.
>
> I tried. But what he said made no sense to me, and no
Roel,
> Rudy, unless/until you know the language inside out, you'd better listen
> to Chris and other people here who spend a lot of time and effort in
> helping people like you.
I tried. But what he said made no sense to me, and no matter how hard I
tried I could not get Chris (or others fo
Chris,
> Once again, you make positive assertions about things you
> don't understand.
And you have refused to bring any kind of help (explanation!) forward that
could have shown me the erring of my ways, as well as refusing to adress my
(attempting to explain) examples.
You might know a thing o
Dennis,
> In common Python, small integers are cached internally for reuse
That is what I imagined could possibly be happening, reading the specific
"the integer 5" formulation in the question ("reading between the lines" and
all that).
And thanks for that explanation, underbuild an all. :-)
On 10/12/2019 19:25, R.Wieser wrote:
And to repeat, you have*no* guarantee*at all* in the language spec that
this will happen.
There is also absolutily no guarantee in those specs that my 'puter will not
suddenly transform into a bonzai tree. Should I now expect it to happen ?
That's an im
On 2019-12-10 19:25, R.Wieser wrote:
Rhodri,
the object that is the integer 5 *isn't* deleted
That was not the question. And you're now referring to the object as well
as the integer, which makes it confusing. You also have not explained what
happens instead. In short, your above statement
Rhodri,
> the object that is the integer 5 *isn't* deleted
That was not the question. And you're now referring to the object as well
as the integer, which makes it confusing. You also have not explained what
happens instead. In short, your above statement has ZERO value to me.
> On the cont
R.Wieser schreef op 10/12/2019 om 13:44:
Also, when you scorn something without knowing your facts,
you tend to make yourself look like a fool :)
I tend to go with logic. No logic => it most likely doesn't work that way.
Choosing to go with a delayed action like you say will, as I already
e
On 10/12/2019 19:00, R.Wieser wrote:
MRAB,
You merely disabled the mark-and-sweep collector.
Nope. Go check the docs on "gc"
Yep. Go and check the docs on "gc" *carefully*
*plonk*
--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 11, 2019 at 6:06 AM R.Wieser wrote:
>
> MRAB,
>
> > You merely disabled the mark-and-sweep collector.
>
> Nope. Go check the docs on "gc"
>
https://docs.python.org/3/library/gc.html
"""
This module provides an interface to the optional garbage collector.
... Since the collector sup
MRAB,
> You merely disabled the mark-and-sweep collector.
Nope. Go check the docs on "gc"
Regards,
Rudy Wieser
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Dec 11, 2019 at 5:51 AM R.Wieser wrote:
>
> Michael,
>
> >> So, only the reference count gets lowered. Yep, thats daft.
> >
> > Why? Consider:
>
> You missed the point.
>
> It was-and-is not about decrementing a reference but still having it above
> zero, but what happens when the refere
Michael,
>> So, only the reference count gets lowered. Yep, thats daft.
>
> Why? Consider:
You missed the point.
It was-and-is not about decrementing a reference but still having it above
zero, but what happens when the reference becomes zero: is the __del__
method called directly (as I find
On 10/12/2019 17:18, R.Wieser wrote:
Chris,
Okay. What should happen when you do this?
x = 5
del x
Should the integer 5 be deleted?
Yep.
What do you think happens instead ? I've not seen you explain or support
anything in that regard, not even now.
As it happens, the object that is the
On 2019-12-10 17:18, R.Wieser wrote:
Chris,
Okay. What should happen when you do this?
x = 5
del x
Should the integer 5 be deleted?
Yep.
What do you think happens instead ? I've not seen you explain or support
anything in that regard, not even now.
There is a bit of a problem with the a
Antoon,
> Well yes that is why it is stupid to rely on the garbage collector to do
> those things for you. That is why Greg Ewing already stated:
>
>> If your object has a method for explicitly making it release its
>> resources, it would be better to use that rather than rely on
>> the garbage co
Chris,
> Okay. What should happen when you do this?
>
> x = 5
> del x
>
> Should the integer 5 be deleted?
Yep.
What do you think happens instead ? I've not seen you explain or support
anything in that regard, not even now.
There is a bit of a problem with the above though: It has got zero t
Python,
> which contradicts your previous statement.
I don't think so.
> "with" is "more stuff" it is the right way to deal with disposable
> ressource in the first place.
Than you have missed the point altogether. It isn't about what you think is
the perfect way to deal with something, but
On 12/10/19 5:44 AM, R.Wieser wrote:
>> Well, that's exactly what happens.
>
> So, only the reference count gets lowered. Yep, thats daft.
Why? Consider:
a = someobject
b = a
How many references for someobject? After "del a" what should be be?
It's still someobject (the same object).
Or the
On 10/12/19 16:56, Chris Angelico wrote:
> On Wed, Dec 11, 2019 at 2:36 AM Antoon Pardon wrote:
>> On 10/12/19 16:10, Chris Angelico wrote:
>>> On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote:
What would you want to happen in the following case:
foo1 = Bar()
foo2 = f
On Wed, Dec 11, 2019 at 2:36 AM Antoon Pardon wrote:
>
> On 10/12/19 16:10, Chris Angelico wrote:
> > On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote:
> >> What would you want to happen in the following case:
> >>
> >>foo1 = Bar()
> >>foo2 = foo1
> >>del foo1
> >>
> >> Should the
On 10/12/19 16:10, Chris Angelico wrote:
> On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote:
>> What would you want to happen in the following case:
>>
>>foo1 = Bar()
>>foo2 = foo1
>>del foo1
>>
>> Should the object be cleaned up now or not?
>>
> TBH both are plausible,
I find that
On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote:
> What would you want to happen in the following case:
>
>foo1 = Bar()
>foo2 = foo1
>del foo1
>
> Should the object be cleaned up now or not?
>
TBH both are plausible, and to a Python programmer it's immediately
obvious that "foo1.c
On 10/12/19 13:44, R.Wieser wrote:
> Chris,
>
>> Well, that's exactly what happens.
> So, only the reference count gets lowered. Yep, thats daft.
>
> ... unless you explain why it can only be done that way.
>
>> Also, when you scorn something without knowing your facts,
>> you tend to make yoursel
R.Wieser wrote:
Chris,
...
But, as you mentioned, I do not know (all) the facts. Please do present
them. Maybe there is a logic in there I do not yet see.
We may, but then you wrote:
Check out the 'with' statement.
I'm sorry, but nope.
Rule one: When debugging do *not* throw more stu
On Tue, Dec 10, 2019 at 11:46 PM R.Wieser wrote:
>
> Chris,
>
> > Well, that's exactly what happens.
>
> So, only the reference count gets lowered. Yep, thats daft.
>
> ... unless you explain why it can only be done that way.
Okay. What should happen when you do this?
x = 5
del x
Should the in
Chris,
> Well, that's exactly what happens.
So, only the reference count gets lowered. Yep, thats daft.
... unless you explain why it can only be done that way.
> Also, when you scorn something without knowing your facts,
> you tend to make yourself look like a fool :)
I tend to go with logic
On Tue, Dec 10, 2019 at 9:51 PM R.Wieser wrote:
>
> Greg,
>
> > In that case, it was only working by accident.
>
> I don't think so.
>
> Or you must be thinking that the __del__ method of an instance is only
> called by the garbage collector - which would be rather daft (just think of
> a file tha
Greg,
> In that case, it was only working by accident.
I don't think so.
Or you must be thinking that the __del__ method of an instance is only
called by the garbage collector - which would be rather daft (just think of
a file thats created when initialising an instance, but not closes until t
On 10/12/19 9:45 pm, R.Wieser wrote:
In my case deleting the instance was needed to release its hold on something
that was taken when the instance was initialised (in my case a GPIO pin on a
Raspberry Pi). I did not even think of garbage collection.
In that case, it was only working by accid
DL,
> I went through this cycle of thinking, first using if __name__... to
> 'hide' testing, then adding test functions within the module, and now keep
> test code quite separate from 'the real thing'.
:-) The normal newbie progression, off of which I'm in phase #1. Having a
working program
It might be becoming 'long', but this discussion contains much of profit
to many people!
Us 'silver surfers' do need to periodically question those beliefs we
hold as 'tenets' of ComSc. Amongst them is RAM (or "core"!)
conservation. It remains a virtue somewhat, but at the same time,
storage
Dennis,
> "del instance" only deletes the NAME.
[snip]
Yep, I already assumed that that would happen. Just wanted to keep it
simple.
> "instance" xyz does not shadow "class" xyz... instead, the name "xyz"
> only exists in the binding to the instance.
That is what I tried to say: the name-bind
Le 09/12/2019 à 09:15, R.Wieser a écrit :
...
You'll find that *any* form of import executes all the top-level code.
Thats certainly something I did not expect.
How could it be otherwise? Consider a module defining two
classes: Parent and Child, Child inheriting from Parent.
if you do "from
Greg,
> There's nothing stopping you from subsequently rebinding that name to some
> other object, or deleting it altogether.
Which is something I did not expect. But running into is what makes doing
something new interesting. :-)
And I just realized something else: I just assumed that the "d
Python,
> Child *depends* on Parent.
I'm sorry, but without any kind of underbuilding statements like that are of
no value to me I'm afraid.
Also: if I can just copy-and-paste the class into the file which origionally
included it and have the whole program run without a problem than that
depe
On 12/9/2019 2:36 AM, R.Wieser wrote:
Terry,
Standard for in-file test is
[snip]
Any reason to put the testcode in a procedure instead of just have it
directly follow the "if __name__ == '__main__' " test ?
One can, for instance, interactively do
>>> import mod
>>> mod.test()
and explore t
On 9/12/19 9:15 pm, R.Wieser wrote:
To be honest, I was not aware/did not assume that I could delete a class
definition that way (I even find it a bit weird, but as I'm a newbie in
regard to Python that does not say much).
Python is very dynamic. The class statement is actually an executable
st
Greg,
>>> Are you sure there's a difference between classes and functions here?
>>
>> Yes, quite sure.
>
> And we're even more sure that there isn't. :-)
As it turned out "we're" are right, and I was thrown off by the error
message. :-p
The problem is that I had no idea why I got that (rather e
DL,
> Some of this you will know. (Hopefully) some will be 'new':
Some of it is known to me, and indeed I do hope that there will be new stuff
in there too. Its why I took up Python. :-)
Thanks for the explanation (including the aliassing I wasn't aware of) and
the links.
Regards,
Rudy Wiese
Terry,
> Not really. The resulting global objects do not normally take enough
> space to worry about on normal modern desktops.
For some reason I still aim to keep my (running) programs as small as
possible - even though the ammount of memory has grown more than a
thousandfold since I started
On 9/12/19 6:28 am, R.Wieser wrote:
Are you sure there's a difference between classes and functions here?
Yes, quite sure.
And we're even more sure that there isn't. :-) Try it with
a test module containing a class definition, a function
definition and some top-level code that does somethin
On 9/12/19 7:29 AM, R.Wieser wrote:
...
Note that in all cases when you import a module (either by import the_file
or from the_file importe whatever) you actually import ALL of it
So much for my assumption only the class itself would be loaded - and a
wrench into my idea to have a number of cl
On 12/8/2019 1:29 PM, R.Wieser wrote:
from the_file import ClassName
from somemod import name
has the same effect as
import somemod
name = somemod.name
del somemod
which is to import a particular 'name' linked to a particular python
object into the namespace where the import is executed.
Dennis,
> Common practice is that the class is capitalized. Instances
>are lowercase.
Thanks.
Regards,
Rudy Wieser
--
https://mail.python.org/mailman/listinfo/python-list
Peter,
>> "from file import function" works, but fails when I try to do the same
>> with a class.
>
> Are you sure? It should behave the same for any name in the module.
I am.
At least, that is what the error said: "cannot import 'classname' from
'filename' "
But as it turns out the problem is
Python,
> from the_file import ClassName
>
> should work. I guess that your class name is not "class" right?
You guessed that right. :-) Not a good idea to pick confusing names like
that, especially when you do something the first time.
> Note that in all cases when you import a module (either
Chris,
> Are you sure there's a difference between classes and functions here?
Yes, quite sure.
If not my attempt to load a class he same way as a function would have
worked. Which it doesn't.
> Try "from file import function" and see if it runs commands at
> the root of the file.
What funct
R.Wieser wrote:
> Hello all,
>
> Using Python3 I would like to import a specific class from another file
> (in the same folder), and have trouble doing so.
>
> "from file import function" works, but fails when I try to do the same
> with a class.
Are you sure? It should behave the same for any
R.Wieser wrote:
Hello all,
Using Python3 I would like to import a specific class from another file (in
the same folder), and have trouble doing so.
"from file import function" works, but fails when I try to do the same with
a class.
"import file
x = file.class"
works, but also executes comman
On Mon, Dec 9, 2019 at 3:31 AM R.Wieser wrote:
>
> Hello all,
>
> Using Python3 I would like to import a specific class from another file (in
> the same folder), and have trouble doing so.
>
> "from file import function" works, but fails when I try to do the same with
> a class.
>
> "import file
>
Hello all,
Using Python3 I would like to import a specific class from another file (in
the same folder), and have trouble doing so.
"from file import function" works, but fails when I try to do the same with
a class.
"import file
x = file.class"
works, but also executes commands that are in t
92 matches
Mail list logo