[Tutor] Ways of removing consequtive duplicates from a list

avi.e.gross at gmail.com avi.e.gross at gmail.com
Sun Jul 17 00:52:20 EDT 2022


Dennis,

I did not blame the sender as much as say what trouble I had putting
together in proper order what THIS mailer showed me. I am using Microsoft
Outlook getting mail with IMAP4 from gmail and also forwarding a copy to AOL
mail which was also driving me nuts by making my text look like that when I
sent. Oddly, that one received the lines nicely!!!

Standards annoy some people but some standards really would be helpful if
various email vendors agreed tio implement thigs as much the same as
possible. Realistically, many allow all kinds of customization. For some
things it matters less but for code and ESPECIALLY code in python where
indentation is part of the language, it is frustrating.

I may be getting touchy without the feely, but I am having trouble listening
to the way some people with cultural differences, or far left/right
attitudes, try to address me/us in forums like this. Alex may have been
amused by my retort, and there is NOTHING wrong with saying "Dear Sirs" when
done in many contexts, just like someone a while ago was writing to
something like "Esteemed Professors" but it simply rubs me wrong here.

Back to topic, if I may, sometimes things set our moods. I am here partially
to be helpful and partially for my own amusement and education as looking at
some of the puzzles presented presents opportunities to think and
investigate.

But before I could get to the reasonable question here, I was perturbed at
the overly formulaic politeness and wrongness of the greeting from my
perhaps touchy perspective for the reasons mentioned including the way it
seeming assumes no Ladies are present and we are somehow Gentlemen, but also
by the mess I saw on one wrapped line that was a pain to take apart. Then I
wondered why the question was being asked. Yes, weirdly, it is a question
you and I have discussed before when wondering which way of doing something
worked better, was more efficient, or showed a more brilliant way to use the
wrong method to do something nobody designed it for!

But as this is supposed to be a TUTORIAL or HELP website, even if Alan
rightfully may disagree and it is his forum, I am conscious of not wanting
to make this into a major discussion group where the people we want to help
just scratch their heads.

I am not sure who read my longish message, but I hope the main point is that
sometimes you should just TEST it. This is not long and complex code.
However, there cannot be any one test everyone will agree on and it often
depends on factors other than CPU cycles. A robust implementation that can
handle multiple needs may well be slower and yet more cost effective in some
sense.

I have mentioned I do lots of my playing around with other languages too.
Many have a minor variant of the issue here as in finding unique items in
some collection such as a vector or data.frame. The problem here did not say
whether the data being used can be in random order or already has all
instances of the same value in order or is even in sorted order. Has anyone
guessed if that is the case?

Because if something is already sorted as described, such as
[0,0,1,1,1,1,2,4,4,4,4,4,4,5,5] then there are even more trivial solutions
by using something like numpy.unique() using just a few lines and I wonder
how efficient this is:

>>> import numpy as np
>>> np.unique([0,0,1,1,1,1,2,4,4,4,4,4,4,5,5] )
array([0, 1, 2, 4, 5])

Admittedly this is a special case. But only the one asking the question can
tell us if that is true. It also works with character data and probably much
more:

>>> np.unique(["a", "a", "b", "b", "b", "c"])
array(['a', 'b', 'c'], dtype='|S1')

But this was not offered as one of his three choices, so never mind!






-----Original Message-----
From: Tutor <tutor-bounces+avi.e.gross=gmail.com at python.org> On Behalf Of
Dennis Lee Bieber
Sent: Saturday, July 16, 2022 8:17 PM
To: tutor at python.org
Subject: Re: [Tutor] Ways of removing consequtive duplicates from a list

On Sat, 16 Jul 2022 11:45:54 -0400, <avi.e.gross at gmail.com> declaimed the
following:

>Your message is not formatted properly in my email and you just asked 
>any

	Just a comment: Might be your client -- it did come in as correctly
"broken" lines in Gmane's news-server gateway to the mailing list.

	OTOH: I had problems with a genealogy mailing list (not available as
a "news group" on any server) with some posts. They are formatted properly
when reading, but become one snarled string when quoted in a reply. But only
from one or two posters -- so it is a combination of posting client vs
reading client... <G>


-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list