Re: What's an elegant way to test for list index existing?
Glen D souza wrote: > fld = [ ] > data = shlex.split(ln) > for item in data: >fld.append(item) > fld = fld + [0] * (5 - len(data)) There's no need to make a copy of data, one item at the time. It's a tedious way to build a new list, and you are throwing it away in the next line anyway, as adding first_list + second_list creates a new list containing the items of both. So: data = shlex.split(ln) fld = data + [""] * (5 - len(data)) # the OP wants strings -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
Glen D souza wrote: > i have a approach, it may not be best > > fld = [ ] > for data in shlex.split(ln): >fld.append(data) > It's certainly simple! :-) I (OP) have actually done something quite similar:- fld = shlex.split(ln) fld.append(999) fld.append(999) It means I can test for '999' as when read from ln they are text fields and it's text I have created so (unless I get *very* confused) it will never be 999. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
Chris Angelico wrote: > On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: > > > > I have a list created by:- > > > > fld = shlex.split(ln) > > > > It may contain 3, 4 or 5 entries according to data read into ln. > > What's the neatest way of setting the fourth and fifth entries to an > > empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > > clumsy somehow. > > shlex.split(ln) + ["", ""] > Now that *is* neat, I will probably do this. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
Bart wrote: > On 30/09/2018 11:14, Chris Green wrote: > > Chris Angelico wrote: > >> On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: > >>> > >>> I have a list created by:- > >>> > >>> fld = shlex.split(ln) > >>> > >>> It may contain 3, 4 or 5 entries according to data read into ln. > >>> What's the neatest way of setting the fourth and fifth entries to an > >>> empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels > >>> clumsy somehow. > >> > >> shlex.split(ln) + ["", ""] > >> > > Now that *is* neat, I will probably do this. > > Won't it give you 7 entries, when shlex.split(ln) returns 5? > > Or doesn't that matter? (In which case that's something not mentioned in > the specification.) No, it doesn't matter, I just need at least 5. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list
Re: What's an elegant way to test for list index existing?
On Sun, 30 Sep 2018 11:45:21 +0100, Bart wrote: > On 30/09/2018 11:14, Chris Green wrote: >> Chris Angelico wrote: >>> On Sat, Sep 29, 2018 at 12:21 PM Chris Green wrote: I have a list created by:- fld = shlex.split(ln) It may contain 3, 4 or 5 entries according to data read into ln. What's the neatest way of setting the fourth and fifth entries to an empty string if they don't (yet) exist? Using 'if len(fld) < 4:' feels clumsy somehow. >>> >>> shlex.split(ln) + ["", ""] >>> >> Now that *is* neat, I will probably do this. > > Won't it give you 7 entries, when shlex.split(ln) returns 5? > > Or doesn't that matter? (In which case that's something not mentioned in > the specification.) if only 5 entries are required than simply prune off the extra using a slice as I suggested yesterday -- DalNet is like the special olympics of IRC. There's a lot of drooling goin' on and everyone is a 'winner'. -- https://mail.python.org/mailman/listinfo/python-list
So apparently I've been banned from this list
I've been unexpectedly in hospital for the past two weeks, without internet or email. Just before my unexpected hospital stay, I was apparently banned (without warning) by Ethan Furman in what seems to me to be an act of retaliation for my protest against his overzealous and hostile tone-policing against a newcomer to the list, Reto Brunner: https://mail.python.org/pipermail/python-list/2018-September/737020.html (I did make one mistake in that post: I claimed that I hadn't said anything at the time on Ethan's last round of bans. That was incorrect, I actually did make an objection at the time.) Since I'm still catching up on emails, I have just come across Ethan's notice to me (copied below). Notwithstanding Ethan's comment about having posted the suspension notice on the list, I see no sign that he actually did so. At the risk of further retaliation from the moderators, I am ignoring the ban in this instance for the purposes of transparency and openness. (I don't know if this will show up on the mailing list or the newsgroup.) Since I believe this ban is illegitimate, I intend to challenge it if possible. In the meantime, I may not reply on-list to any responses. Subject: Fwd: Temporary Suspension To: From: Ethan Furman Date: Tue, 11 Sep 2018 11:22:40 -0700 In-Reply-To: Steven, you've probably already seen this on Python List, but I forgot to email it directly to you. My apologies. -- ~Ethan~ Python List Moderator Forwarded Message Subject: Temporary Suspension Date: Mon, 10 Sep 2018 07:09:04 -0700 From: Ethan Furman To: Python List Moderators As a list moderator, my goal for this list is to keep the list a useful resource -- but what does "useful" mean? To me it means a place that python users can go to ask questions, get answers, offer advice, and all without sarcasm, name-calling, and deliberate mis-understandings. Conversations should stay mostly on-topic. Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily suspended from Python List for a period of two months. This suspension, along with past suspensions, is being taken only after careful consideration and consultation with other Python moderators. -- ~Ethan~ Python List Moderator * posts in question: [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html -- Steven D'Aprano -- https://mail.python.org/mailman/listinfo/python-list
Re: So apparently I've been banned from this list
On Mon, Oct 1, 2018 at 2:34 AM Steven D'Aprano wrote: > Subject: Fwd: Temporary Suspension > To: > From: Ethan Furman > Date: Tue, 11 Sep 2018 11:22:40 -0700 > In-Reply-To: > > Steven, you've probably already seen this on Python List, but I forgot > to email it directly to you. My apologies. > > -- > ~Ethan~ > Python List Moderator > > > Forwarded Message > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > I don't recall seeing the twice-forwarded message here. Is it possible that the message about the suspension was sent only to -owner and not to the list? Was it meant to be sent to the whole list? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: So apparently I've been banned from this list
On 30/09/2018 18:30, Steven D'Aprano wrote: I've been unexpectedly in hospital for the past two weeks, without internet or email. Just before my unexpected hospital stay, I was apparently banned (without warning) by Ethan Furman in what seems to me to be an act of retaliation for my protest against his overzealous and hostile tone-policing against a newcomer to the list, Reto Brunner: https://mail.python.org/pipermail/python-list/2018-September/737020.html (I did make one mistake in that post: I claimed that I hadn't said anything at the time on Ethan's last round of bans. That was incorrect, I actually did make an objection at the time.) Since I'm still catching up on emails, I have just come across Ethan's notice to me (copied below). Notwithstanding Ethan's comment about having posted the suspension notice on the list, I see no sign that he actually did so. At the risk of further retaliation from the moderators, I am ignoring the ban in this instance for the purposes of transparency and openness. (I don't know if this will show up on the mailing list or the newsgroup.) Since I believe this ban is illegitimate, I intend to challenge it if possible. In the meantime, I may not reply on-list to any responses. Subject: Fwd: Temporary Suspension To: From: Ethan Furman Date: Tue, 11 Sep 2018 11:22:40 -0700 In-Reply-To: Steven, you've probably already seen this on Python List, but I forgot to email it directly to you. My apologies. -- ~Ethan~ Python List Moderator Forwarded Message Subject: Temporary Suspension Date: Mon, 10 Sep 2018 07:09:04 -0700 From: Ethan Furman To: Python List Moderators As a list moderator, my goal for this list is to keep the list a useful resource -- but what does "useful" mean? To me it means a place that python users can go to ask questions, get answers, offer advice, and all without sarcasm, name-calling, and deliberate mis-understandings. Conversations should stay mostly on-topic. Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily suspended from Python List for a period of two months. This suspension, along with past suspensions, is being taken only after careful consideration and consultation with other Python moderators. -- ~Ethan~ Python List Moderator * posts in question: [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html Hi, I hope you are getting better. Cheers Karim -- https://mail.python.org/mailman/listinfo/python-list
Re: So apparently I've been banned from this list
On Sun, Sep 30, 2018 at 6:30 PM, Steven D'Aprano wrote: > Notwithstanding Ethan's comment about having posted the suspension notice > on the list, I see no sign that he actually did so. At the risk of > further retaliation from the moderators, I am ignoring the ban in this > instance for the purposes of transparency and openness. (I don't know if > this will show up on the mailing list or the newsgroup.) [...] > > Forwarded Message > Subject: Temporary Suspension > Date: Mon, 10 Sep 2018 07:09:04 -0700 > From: Ethan Furman > To: Python List Moderators > > As a list moderator, my goal for this list is to keep the list a useful > resource -- but what does "useful" mean? To me it means a place that > python users can go to ask questions, get answers, offer advice, and all > without sarcasm, name-calling, and deliberate mis-understandings. > Conversations should stay mostly on-topic. > > Due to hostile and inappropriate posts*, Steven D'Aprano is temporarily > suspended from Python List for a period of two months. > > This suspension, along with past suspensions, is being taken only after > careful consideration and consultation with other Python moderators. > > -- > ~Ethan~ > Python List Moderator > > > * posts in question: > > [1] https://mail.python.org/pipermail/python-list/2018-July/735735.html > [2] https://mail.python.org/pipermail/python-list/2018-September/737020.html > I can assure you that I did not receive Ethan's message via the mailing list. First of all I would have noticed it, if it would have been a separate thread. But I also just went over all the messages and tried to find it. It never arrived in my mailbox. -- https://mail.python.org/mailman/listinfo/python-list