Why do I see digest replies to posts I never saw in a digest? [was: RE: Why I fail so bad to check for memory leak with this code?]

2022-07-23 Thread pjfarley3
OT to the original subject, but can anyone explain to me why in the forum 
digest emails I receive I often see a reply to a post that I never saw the 
original of in any prior digest?

Peter

> -Original Message-
> From: Marco Sulla 
> Sent: Friday, July 22, 2022 3:41 PM
> To: Barry 
> Cc: MRAB ; Python-list@python.org
> Subject: Re: Why I fail so bad to check for memory leak with this code?
> 
> On Fri, 22 Jul 2022 at 09:00, Barry  wrote:
> > With code as complex as python’s there will be memory allocations that
> occur that will not be directly related to the python code you test.
> >
> > To put it another way there is noise in your memory allocation signal.
> >
> > Usually the signal of a memory leak is very clear, as you noticed.
> >
> > For rare leaks I would use a tool like valgrind.
> 
> Thank you all, but I needed a simple decorator to automatize the memory leak
> (and segfault) tests. I think that this version is good enough, I hope that 
> can be
> useful to someone:
 
--

-- 
https://mail.python.org/mailman/listinfo/python-list


spyder v5: invalid file name when selecting interpreter in preferences

2022-07-23 Thread Leif Svalgaard
error message: invalid file path: C:/Users/leifs/anaconda3/python3105.exe
what is wrong with that?

-- 
Leif
l...@leif.org
-- 
https://mail.python.org/mailman/listinfo/python-list


Object in List : how?

2022-07-23 Thread Khairil Sitanggang
Hello Expert:

I just started using python. Below is a simple code.  I was trying to check
if, say, NO1 is not in the NODELIST[:].NO
How can I achieve this purpose?

Regards,
-Irfan


class Node:
def __init__(self):
self.NO = 0
self.A = 20

NODE = Node()
NODELIST = []

NODE.NO = 10
NODELIST.append(NODE)

NODE.NO = 20
NODELIST.append(NODE)

NODE.NO = 30
NODELIST.append(NODE)


NO1 = 20
if NO1 not in NODELIST[:].NO  ???
-- 
https://mail.python.org/mailman/listinfo/python-list


Information about updating my python notebook

2022-07-23 Thread nhlanhlah198506
Can I update my python account Sent from my Galaxy
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why do I see digest replies to posts I never saw in a digest?

2022-07-23 Thread Peter J. Holzer
On 2022-07-23 14:01:09 -0400, pjfarl...@earthlink.net wrote:
> OT to the original subject, but can anyone explain to me why in the
> forum digest emails I receive I often see a reply to a post that I
> never saw the original of in any prior digest?

I think in most cases this is because both messages were posted to the
usenet group but the first one didn't make it through the gateway for
some reason (usually because the poster is banned on the mailinglist).
In this case I'm not sure which messages you are referring to, since I
see the whole chain from the one you quoted to the start of the thread
(although the one by Barry has neither an In-Reply-To nor a References
header so it isn't sorted in at the correct spot).

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: spyder v5: invalid file name when selecting interpreter in preferences

2022-07-23 Thread MRAB

On 23/07/2022 18:30, Leif Svalgaard wrote:

error message: invalid file path: C:/Users/leifs/anaconda3/python3105.exe
what is wrong with that?

Is there a file called python3105.exe in the folder 
C:/Users/leifs/anaconda3?


That filename looks wrong to me because the file is usually called 
python.exe.


This page:

https://docs.anaconda.com/anaconda/user-guide/tasks/integration/python-path/

suggests to me that the path is probably more like 
C:\Users\leifs\anaconda3\python.exe (or, if you prefer, 
C:/Users/leifs/anaconda3/python.exe).

--
https://mail.python.org/mailman/listinfo/python-list


Re: Object in List : how?

2022-07-23 Thread MRAB

On 23/07/2022 05:28, Khairil Sitanggang wrote:

Hello Expert:

I just started using python. Below is a simple code.  I was trying to check
if, say, NO1 is not in the NODELIST[:].NO
How can I achieve this purpose?

Regards,
-Irfan


class Node:
 def __init__(self):
 self.NO = 0
 self.A = 20

NODE = Node()
NODELIST = []

NODE.NO = 10
NODELIST.append(NODE)

NODE.NO = 20
NODELIST.append(NODE)

NODE.NO = 30
NODELIST.append(NODE)


NO1 = 20
if NO1 not in NODELIST[:].NO  ???


No, you can't do it that way. You have to iterate through the list and 
check each member individually:


if any(NO1 == N.NO for N in NODELIST):

And another thing: you've created only 1 node, and you're changing it 
each time before adding it to the list, so the list ends up with 3 
references to the _same_ object.

--
https://mail.python.org/mailman/listinfo/python-list


Re: Information about updating my python notebook

2022-07-23 Thread dn
On 24/07/2022 04.16, nhlanhlah198506 wrote:
> Can I update my python account Sent from my Galaxy

How did you install Python, and on which OpSys?

In what respect to you want to "update"?
What do you mean by "notebook" - and "account"?

-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Object in List : how?

2022-07-23 Thread Khairil Sitanggang
Thank you.
I did it as you said. Yes, I forgot to create a new object Node() for each of 
the 3 instances.

The reason I wanted to do as I asked was that I expected Python provides that 
convenient feature (since it is a high level language). I use Matlab a lot and 
it is so rich of features that allow  us to process object array in many 
different ways.

Anyway, as I said, I just started playing with Python, and I like it so much. 
Thanks to Visual Studio Code making coding very enjoyable.



Get Outlook for iOS

From: Python-list  on behalf 
of MRAB 
Sent: Saturday, July 23, 2022 4:57:34 PM
To: python-list@python.org 
Subject: Re: Object in List : how?

On 23/07/2022 05:28, Khairil Sitanggang wrote:
> Hello Expert:
>
> I just started using python. Below is a simple code.  I was trying to check
> if, say, NO1 is not in the NODELIST[:].NO
> How can I achieve this purpose?
>
> Regards,
> -Irfan
>
>
> class Node:
>  def __init__(self):
>  self.NO = 0
>  self.A = 20
>
> NODE = Node()
> NODELIST = []
>
> NODE.NO = 10
> NODELIST.append(NODE)
>
> NODE.NO = 20
> NODELIST.append(NODE)
>
> NODE.NO = 30
> NODELIST.append(NODE)
>
>
> NO1 = 20
> if NO1 not in NODELIST[:].NO  ???

No, you can't do it that way. You have to iterate through the list and
check each member individually:

 if any(NO1 == N.NO for N in NODELIST):

And another thing: you've created only 1 node, and you're changing it
each time before adding it to the list, so the list ends up with 3
references to the _same_ object.
--
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Object in List : how?

2022-07-23 Thread dn
On 24/07/2022 09.57, MRAB wrote:
> On 23/07/2022 05:28, Khairil Sitanggang wrote:
>> Hello Expert:
>>
>> I just started using python. Below is a simple code.  I was trying to
>> check
>> if, say, NO1 is not in the NODELIST[:].NO
>> How can I achieve this purpose?
>>
>> Regards,
>> -Irfan
>>
>>
>> class Node:
>>  def __init__(self):
>>  self.NO = 0
>>  self.A = 20
>>
>> NODE = Node()
>> NODELIST = []
>>
>> NODE.NO = 10
>> NODELIST.append(NODE)
>>
>> NODE.NO = 20
>> NODELIST.append(NODE)
>>
>> NODE.NO = 30
>> NODELIST.append(NODE)
>>
>>
>> NO1 = 20
>> if NO1 not in NODELIST[:].NO  ???
> 
> No, you can't do it that way. You have to iterate through the list and
> check each member individually:
> 
>     if any(NO1 == N.NO for N in NODELIST):
> 
> And another thing: you've created only 1 node, and you're changing it
> each time before adding it to the list, so the list ends up with 3
> references to the _same_ object.

+1


Imagine the object (Node) was instead a person, and a bunch of us-people
get together in a room. You could shout (above the polite conversation)
"is Fred here?" and Fred will reply - or if Fred is elsewhere, silence
will reign. That works - but only because everyone knows their own name.

Now imagine something like (my) grade school, where the teacher takes a
roll/register to note who is present for (or absent from) class. In this
case another staff-member could enter the room and instead of shouting
(which would be rude), can ask the teacher "is Fred here?". The teacher
is able to answer from the roll.

The former case is (sort of) the solution proposed above - in looking
for Fred, you walk through the room, asking each person in-turn "are you
Fred?".

The latter is the case for Node and what you were hoping to implement.

Thus, an alternate approach is to keep a register of nodes. Note that
this is more than a list, because each element of the list (each node)
is also identified (on the list) by its name. So, two pieces of
(related) data: the id of the node, and the node itself - the name of
the person and the person him-/her-self.

Assuming you only have one ID that will be used to access a node,
Python's built-in dict[ionary] data-structure will provide the advantage
of direct-access (instead of going through (on average) half the nodes,
asking each one in-turn, are you ...

So:

> NODE = Node()
> NODELIST = []
> 
> NODE.NO = 10
> NODELIST.append(NODE)

becomes:

graph = dict{}  # could be written as: graph = {}
node10 = Node( 10 )
graph[ node.id ] = node10

or even:

graph[ 20 ] = Node( 20 )

if you don't need lots of nodes 'hanging around' outside of the 'list'
(actually a dict) representing the graph.


Then:

> NO1 = 20
> if NO1 not in NODELIST[:].NO  ???

becomes a single line:

the_node_required = graph[ 20 ]

where "20" is the search-criteria.

Does that make sense?


If it does, and when you realise that you'd like to do more with the
graph than retrieve single nodes (and more-importantly, should you want
(or dare) to delve further into the depths of Object-Oriented
Programming) you could declare a second class (graph) containing a
number of "methods". If one of the methods implemented is __contains__()
then you could indeed ask:

if 20 in graph:

ie "is Fred in-class today?"
but just as we would ask "is Fred here?" rather than "is someone
identified by the name 'Fred' here?", it would seem better form to write:

if node( 20 ) in graph:

ie is there a node with the id of 20, somewhere within the graph?


Such might involve sub-classing OrderedDict, UserDict, or even UserList,
from the Collections library in the (provided/"batteries-included")
Python Standard Library: https://docs.python.org/3/library/collections.html

If needed, the extra methods you choose to implement might include such
functionality as connecting nodes 10 and 20 with a path/edge, being able
to traverse edges, and so-on...

Thus, we've covered two categories of class/object: one, a 'data-class'
which contains data about a single node; the other a 'collection-class'
which contains multiple nodes making-up the graph. A useful distinction
and a common related-pair of data-constructs!
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Object in List : how?

2022-07-23 Thread Khairil Sitanggang
dn,

Thanks for the good analogy and explanation.  I need some time to digest it.

Regards,
-Irfan


On Sat, Jul 23, 2022 at 6:55 PM dn  wrote:

> On 24/07/2022 09.57, MRAB wrote:
> > On 23/07/2022 05:28, Khairil Sitanggang wrote:
> >> Hello Expert:
> >>
> >> I just started using python. Below is a simple code.  I was trying to
> >> check
> >> if, say, NO1 is not in the NODELIST[:].NO
> >> How can I achieve this purpose?
> >>
> >> Regards,
> >> -Irfan
> >>
> >>
> >> class Node:
> >>  def __init__(self):
> >>  self.NO = 0
> >>  self.A = 20
> >>
> >> NODE = Node()
> >> NODELIST = []
> >>
> >> NODE.NO = 10
> >> NODELIST.append(NODE)
> >>
> >> NODE.NO = 20
> >> NODELIST.append(NODE)
> >>
> >> NODE.NO = 30
> >> NODELIST.append(NODE)
> >>
> >>
> >> NO1 = 20
> >> if NO1 not in NODELIST[:].NO  ???
> >
> > No, you can't do it that way. You have to iterate through the list and
> > check each member individually:
> >
> > if any(NO1 == N.NO for N in NODELIST):
> >
> > And another thing: you've created only 1 node, and you're changing it
> > each time before adding it to the list, so the list ends up with 3
> > references to the _same_ object.
>
> +1
>
>
> Imagine the object (Node) was instead a person, and a bunch of us-people
> get together in a room. You could shout (above the polite conversation)
> "is Fred here?" and Fred will reply - or if Fred is elsewhere, silence
> will reign. That works - but only because everyone knows their own name.
>
> Now imagine something like (my) grade school, where the teacher takes a
> roll/register to note who is present for (or absent from) class. In this
> case another staff-member could enter the room and instead of shouting
> (which would be rude), can ask the teacher "is Fred here?". The teacher
> is able to answer from the roll.
>
> The former case is (sort of) the solution proposed above - in looking
> for Fred, you walk through the room, asking each person in-turn "are you
> Fred?".
>
> The latter is the case for Node and what you were hoping to implement.
>
> Thus, an alternate approach is to keep a register of nodes. Note that
> this is more than a list, because each element of the list (each node)
> is also identified (on the list) by its name. So, two pieces of
> (related) data: the id of the node, and the node itself - the name of
> the person and the person him-/her-self.
>
> Assuming you only have one ID that will be used to access a node,
> Python's built-in dict[ionary] data-structure will provide the advantage
> of direct-access (instead of going through (on average) half the nodes,
> asking each one in-turn, are you ...
>
> So:
>
> > NODE = Node()
> > NODELIST = []
> >
> > NODE.NO = 10
> > NODELIST.append(NODE)
>
> becomes:
>
> graph = dict{}  # could be written as: graph = {}
> node10 = Node( 10 )
> graph[ node.id ] = node10
>
> or even:
>
> graph[ 20 ] = Node( 20 )
>
> if you don't need lots of nodes 'hanging around' outside of the 'list'
> (actually a dict) representing the graph.
>
>
> Then:
>
> > NO1 = 20
> > if NO1 not in NODELIST[:].NO  ???
>
> becomes a single line:
>
> the_node_required = graph[ 20 ]
>
> where "20" is the search-criteria.
>
> Does that make sense?
>
>
> If it does, and when you realise that you'd like to do more with the
> graph than retrieve single nodes (and more-importantly, should you want
> (or dare) to delve further into the depths of Object-Oriented
> Programming) you could declare a second class (graph) containing a
> number of "methods". If one of the methods implemented is __contains__()
> then you could indeed ask:
>
> if 20 in graph:
>
> ie "is Fred in-class today?"
> but just as we would ask "is Fred here?" rather than "is someone
> identified by the name 'Fred' here?", it would seem better form to write:
>
> if node( 20 ) in graph:
>
> ie is there a node with the id of 20, somewhere within the graph?
>
>
> Such might involve sub-classing OrderedDict, UserDict, or even UserList,
> from the Collections library in the (provided/"batteries-included")
> Python Standard Library:
> https://docs.python.org/3/library/collections.html
>
> If needed, the extra methods you choose to implement might include such
> functionality as connecting nodes 10 and 20 with a path/edge, being able
> to traverse edges, and so-on...
>
> Thus, we've covered two categories of class/object: one, a 'data-class'
> which contains data about a single node; the other a 'collection-class'
> which contains multiple nodes making-up the graph. A useful distinction
> and a common related-pair of data-constructs!
> --
> Regards,
> =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list