Re: how to return last condition if other 2 not met?

2018-05-23 Thread asa32sd23
On Wednesday, May 23, 2018 at 8:55:59 PM UTC-4, MRAB wrote: > On 2018-05-24 00:57, asa32s...@gmail.com wrote: > > i want to check/return for 3 conditions, it loops shortest str and finds > > diff in other > > 1. if difference is immediate before end of range, return index, exit > > 2. if string le

Re: Indented multi-line strings

2018-05-23 Thread Mikhail V
On Wed, May 23, 2018 at 11:56 PM, Bob van der Poel wrote: > On Wed, May 23, 2018 at 1:45 PM, MRAB wrote: > >> If you want additional indentation, then provide a string literal: >> >> def func(): >> foobar >> data = >> '': >> first line >> last line >> foobar >> >> for

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 8:46 PM, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Cameron Simpson
On 23May2018 23:14, Mark Lawrence wrote: On 23/05/18 22:56, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not sure

Re: how to return last condition if other 2 not met?

2018-05-23 Thread MRAB
On 2018-05-24 00:57, asa32s...@gmail.com wrote: i want to check/return for 3 conditions, it loops shortest str and finds diff in other 1. if difference is immediate before end of range, return index, exit 2. if string length is same and index loop is done, return 'identical' 3. if neither of abo

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 01:46, bartc wrote: On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but f

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 24/05/2018 00:44, Terry Reedy wrote: On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but faster. This illustrates one probl

Re: Usenet Gateway

2018-05-23 Thread Gene Heskett
On Wednesday 23 May 2018 19:24:52 Alan Bawden wrote: > Gene Heskett writes: > > You are stating an opinion, but no facts to back it up, so describe > > your environment that makes you write that, please. > > If he describes his environment and why he likes it, will that be a > "fact"? Or will yo

how to return last condition if other 2 not met?

2018-05-23 Thread asa32sd23
i want to check/return for 3 conditions, it loops shortest str and finds diff in other 1. if difference is immediate before end of range, return index, exit 2. if string length is same and index loop is done, return 'identical' 3. if neither of above is found. it means the short loop ended and eve

Re: how to handle captcha through machanize module or any module

2018-05-23 Thread Ben Finney
Jai writes: > please do replay how to handle captcha through machanize module Step 1: ‘import mechanize’. Step 2: be an actual human, and interact manually with the CAPTCHA. If you are attempting to fool a CAPTCHA with an automated tool, you are entering an arms race against those who design

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 6:07 PM, asa32s...@gmail.com wrote: On Wednesday, May 23, 2018 at 5:51:42 PM UTC-4, asa3...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks thanks, it

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Terry Reedy
On 5/23/2018 5:56 PM, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, Use -1, which is the same as len(s)-1 but faster. >>> s = 'kitty' >>> s[len(s)-1] 'y' >>> s[-1] 'y' -- Terry Jan Ree

Re: Indented multi-line strings

2018-05-23 Thread Mikhail V
On Wed, May 23, 2018 at 11:45 PM, MRAB wrote: >>> def func(): >>> foobar >>> data = /// s2 >>> first line >>> last line >>> foobar >>> > Instead of the "s2", etc: > > def func(): > foobar > data = >> : > first line > last line > foobar > > Leading

Re: Usenet Gateway

2018-05-23 Thread Alan Bawden
Gene Heskett writes: > You are stating an opinion, but no facts to back it up, so describe your > environment that makes you write that, please. If he describes his environment and why he likes it, will that be a "fact"? Or will you dismiss that as just another "opinion"? You asked: > can so

Re: Usenet Gateway

2018-05-23 Thread Chris Green
Gene Heskett wrote: > On Wednesday 23 May 2018 12:45:57 Chris Green wrote: > > > Abdur-Rahmaan Janhangeer wrote: > > > can someone explain to me why the mailing list (spam free) is not > > > used by everybody? > > > > Because the Usenet/NNTP interface (with a good newsreader) is so much > > bett

Re: Usenet Gateway

2018-05-23 Thread Gene Heskett
On Wednesday 23 May 2018 12:45:57 Chris Green wrote: > Abdur-Rahmaan Janhangeer wrote: > > can someone explain to me why the mailing list (spam free) is not > > used by everybody? > > Because the Usenet/NNTP interface (with a good newsreader) is so much > better! :-) > > -- > Chris Green > · You

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Mark Lawrence
On 23/05/18 22:56, Rob Gaddi wrote: On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks Not sure I'm following your question; len(s

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
On Wednesday, May 23, 2018 at 5:51:42 PM UTC-4, asa3...@gmail.com wrote: > s = "kitti" > > 0,1,2,3,4 > k,i,t,t,i > > how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a > function that gives me last number of index > > thanks thanks, it seems just a len(s) -1 is the righ

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread bartc
On 23/05/2018 22:51, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index Not for that trivial task. But you can create your own: def upb(x): return len(x)-1 # '

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
On Wednesday, May 23, 2018 at 5:56:26 PM UTC-4, Rob Gaddi wrote: > On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: > > s = "kitti" > > > > 0,1,2,3,4 > > k,i,t,t,i > > > > how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a > > function that gives me last number of index

Re: how to get INDEX count, or last number of Index

2018-05-23 Thread Rob Gaddi
On 05/23/2018 02:51 PM, asa32s...@gmail.com wrote: s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks Not sure I'm following your question; len(s)-1 is much faster than enumerating o

how to get INDEX count, or last number of Index

2018-05-23 Thread asa32sd23
s = "kitti" 0,1,2,3,4 k,i,t,t,i how do i retrieve '4'. i know i can do a len(s)-1, but i assume there is a function that gives me last number of index thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: decorat{or,ion}

2018-05-23 Thread Mike McClain
On Mon, May 21, 2018 at 09:11:02AM +0200, dieter wrote: < lots if good info snipped > Hi dieter, I'm still working my way through the info you posted and making sense of it (mostly) but didn't want to wait any longer to say 'Thanks.' Thanks, Mike -- Even duct tape can't fix stupid ... But it

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Peter Otten
digi...@gmail.com wrote: > I'm trying to read my iTunes library in Python using iterparse. My current > stub is: > parser.add_argument('infile', nargs='?', > type=argparse.FileType('r'), default=sys.stdin) > I'm getting an error on one part of the XML: > > > File "C:\Users\digit\Anaco

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-05-23 Thread Chris Angelico
On Thu, May 24, 2018 at 6:48 AM, Dan Stromberg wrote: > On Sat, May 19, 2018 at 3:58 PM, wrote: >> On Thursday, 29 January 2009 12:09:29 UTC-5, Anjanesh Lekshminarayanan >> wrote: >>> > It does auto-detect it as cp1252- look at the files in the traceback and >>> > you'll see lib\encodings\cp12

Re: Indented multi-line strings

2018-05-23 Thread Bob van der Poel
On Wed, May 23, 2018 at 1:45 PM, MRAB wrote: > On 2018-05-23 19:36, Mikhail V wrote: > >> On Wed, May 23, 2018 at 8:08 PM, Mikhail V wrote: >> >>> On Wed, May 23, 2018 at 4:19 PM, Dan Strohl wrote: >>> >> >> data = /// sN # and >>> data = /// tN >>> >>> Where N - is the amount of charac

Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to

2018-05-23 Thread Dan Stromberg
On Sat, May 19, 2018 at 3:58 PM, wrote: > On Thursday, 29 January 2009 12:09:29 UTC-5, Anjanesh Lekshminarayanan wrote: >> > It does auto-detect it as cp1252- look at the files in the traceback and >> > you'll see lib\encodings\cp1252.py. Since cp1252 seems to be the wrong >> > encoding, try ope

Re: Indented multi-line strings

2018-05-23 Thread MRAB
On 2018-05-23 19:36, Mikhail V wrote: On Wed, May 23, 2018 at 8:08 PM, Mikhail V wrote: On Wed, May 23, 2018 at 4:19 PM, Dan Strohl wrote: data = /// sN # and data = /// tN Where N - is the amount of characters, spaces (s) or tabs (t). This should cover most use cases. It implies o

Re: best way to remove leading zeros from a tuple like string

2018-05-23 Thread Dan Stromberg
On Sun, May 20, 2018 at 12:54 PM, wrote: > Lets say I have the following tuple like string. > (128, 020, 008, 255) > > What is the best way to to remove leading zeroes and end up with the > following. > (128, 20, 8, 255)-- I do not care about spaces > > This is the solution I came up

RE: "Data blocks" syntax specification draft

2018-05-23 Thread Schachner, Joseph
I understand that the /// data representation is meant to emphasize data structure (and de-emphasize existing Python syntax for that purpose). It's already been discussed that Python can export to pickle format, JSON, csv, XML and possibly others I can't think of right now. So having a data r

Re: Indented multi-line strings

2018-05-23 Thread Mikhail V
On Wed, May 23, 2018 at 8:08 PM, Mikhail V wrote: > On Wed, May 23, 2018 at 4:19 PM, Dan Strohl wrote: > data = /// sN # and > data = /// tN > > Where N - is the amount of characters, spaces (s) or > tabs (t). > This should cover most use cases. > It implies of course that the user shoul

Re: how to handle captcha through machanize module or any module

2018-05-23 Thread Chris Angelico
On Thu, May 24, 2018 at 4:01 AM, MRAB wrote: > On 2018-05-23 06:22, SACHIN CHAVAN wrote: >> >> On Wednesday, December 18, 2013 at 6:26:17 PM UTC+5:30, Jai wrote: >>> >>> please do replay how to handle captcha through machanize module >> >> >> I have the same issue, nothing find a solution yet! >>

Re: Usenet Gateway

2018-05-23 Thread Grant Edwards
On 2018-05-23, Chris Green wrote: > Abdur-Rahmaan Janhangeer wrote: >> can someone explain to me why the mailing list (spam free) is not used by >> everybody? > > Because the Usenet/NNTP interface (with a good newsreader) is so much > better! :-) Yes. NNTP and NNTP clients were designed from th

Re: how to handle captcha through machanize module or any module

2018-05-23 Thread MRAB
On 2018-05-23 06:22, SACHIN CHAVAN wrote: On Wednesday, December 18, 2013 at 6:26:17 PM UTC+5:30, Jai wrote: please do replay how to handle captcha through machanize module I have the same issue, nothing find a solution yet! The purpose of captcha is to ensure that talking to a human, not a b

Re: Usenet Gateway (was: Spam levels.)

2018-05-23 Thread Grant Edwards
On 2018-05-23, Abdur-Rahmaan Janhangeer wrote: > can someone explain to me why the mailing list (spam free) is not used by > everybody? 1) I perfer the user-interface offered by my NNTP client (slrn). 2) I don't want to archive many years worth of dozens of mailing lists (I let gmane do t

Re: Usenet Gateway

2018-05-23 Thread Ned Batchelder
On 5/23/18 12:03 PM, Gene Heskett wrote: On Wednesday 23 May 2018 11:20:34 Abdur-Rahmaan Janhangeer wrote: can someone explain to me why the mailing list (spam free) is not used by everybody? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Brain damaged by facebook, AOL, M$, Google

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Chris Angelico
On Thu, May 24, 2018 at 3:08 AM, Ian Kelly wrote: > I don't know if 'i' would be the right prefix character for this, but > it's unused and is short for 'indented': > > b = i''' > Here is a multi-line string > with indentation, which is > determined from the second > line.''' Sinc

RE: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Dan Strohl via Python-list
> > How about we instead just use the rules from PEP 257 so that there aren't two > different sets of multi-line string indentation rules to have to remember? > > https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation > I like that, better to be closer to the existing stand

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
digi...@gmail.com schrieb am 23.05.2018 um 00:56: > I'm trying to read my iTunes library in Python using iterparse. My current > stub is: > > Snip > > import sys > import datetime > import xml.etree.ElementTree as ET > import argparse > import re > > class Library: > > unmars

Re: Getting Unicode decode error using lxml.iterparse

2018-05-23 Thread Stefan Behnel
dieter schrieb am 23.05.2018 um 08:25: > If the encoding is not specified, "lxml" will try to determine it > and finally defaults to "utf-8" (which seems to be the correct encoding > for your case). Being an XML parser, it does not do that. XML parsers are designed to reject non-wellformed content

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 10:25 AM, Peter J. Holzer wrote: > How about this? > > x = > Here is a multi-line string > with > indentation. > > > This would be equivalent to > > x = 'Here is a multi-line string\nwith\n indentation.' > > Rules

Indented multi-line strings

2018-05-23 Thread Mikhail V
On Wed, May 23, 2018 at 4:19 PM, Dan Strohl wrote: > First of all, I suggest splitting this into a separate proposal (new thread) > that way you will avoid confusion for people who are still considering the > older proposal, and for the (probably many) people who have stopped reding > the old t

Re: Usenet Gateway

2018-05-23 Thread Chris Green
Abdur-Rahmaan Janhangeer wrote: > can someone explain to me why the mailing list (spam free) is not used by > everybody? > Because the Usenet/NNTP interface (with a good newsreader) is so much better! :-) -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: Target WSGI script cannot be loaded as Python module.

2018-05-23 Thread Νίκος
Τη Τετάρτη, 23 Μαΐου 2018 - 6:18:13 μ.μ. UTC+3, ο χρήστης John Gordon έγραψε: > Is your web server using Python 2 or Python 3 to execute WSGI? I really dont knwo that detail. How can i check that? -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 14:56, Chris Angelico wrote: Perfect! Now let's try that with other types. Tuple of three: 1, 2, 3 or 1, 2, 3, Not requiring any bracketing is poor IMO. If you wanted the tuple to co-exist with any other thing in an expression, rather than being the only thing the expression co

RE: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Dan Strohl via Python-list
> > > Personally though, I would not hard code it to knock out 4 leading > > spaces. I would have it handle spaces the same was that the existing > > parser does, if there are 4 spaces indending the next line, then it > > removes 4 spaces, if there are 6 spaces, it removes 6 spaces, etc... > >

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 14:11, Steven D'Aprano wrote: On Wed, 23 May 2018 11:10:33 +0100, bartc wrote: (x,) Tuple of one item Incorrect. Yet again, you have failed to do enough testing. No special form is required. Only a comma: py> x = 1, py> type(x) It isn't enough to test examples which confirm a

Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Peter J. Holzer
On 2018-05-22 23:25:36 +, Dan Strohl via Python-list wrote: > > So, e.g. this: > > > > data = /// s4 > > first line > > last line > > the rest python code > > > > - will parse the block and knock out leading 4 spaces. > > i.e. if the first line has 5 leading spaces then 1 space will b

Re: Usenet Gateway (was: Spam levels.)

2018-05-23 Thread Gene Heskett
On Wednesday 23 May 2018 11:20:34 Abdur-Rahmaan Janhangeer wrote: > can someone explain to me why the mailing list (spam free) is not used > by everybody? > > Abdur-Rahmaan Janhangeer > https://github.com/Abdur-rahmaanJ Brain damaged by facebook, AOL, M$, Google, yahoo yadda yadda into thinking

Re: Usenet Gateway (was: Spam levels.)

2018-05-23 Thread Abdur-Rahmaan Janhangeer
can someone explain to me why the mailing list (spam free) is not used by everybody? Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ > > -- https://mail.python.org/mailman/listinfo/python-list

Re: Target WSGI script cannot be loaded as Python module.

2018-05-23 Thread John Gordon
In <34bc9890-90c9-473d-bd26-3f62264aa...@googlegroups.com> =?UTF-8?B?zp3Or866zr/Pgg==?= writes: > I have both python installed in parallel. > python2.7 and python3.6 > I have installed the modules as > pip3.6 install bottle bottle-pymysql geopip2 > and they were installed successfully. Is you

Usenet Gateway (was: Spam levels.)

2018-05-23 Thread Peter J. Holzer
On 2018-05-23 10:00:56 -0400, Dennis Lee Bieber wrote: > On Wed, 23 May 2018 08:01:35 +0200, dieter declaimed > the following: > > >Maybe something went wrong with the integration of your NTTP server > >with the Gmane one? > > GMANE doesn't (to my knowledge) peer to NNTP servers. It provid

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Chris Angelico
On Wed, May 23, 2018 at 11:11 PM, Steven D'Aprano wrote: > On Wed, 23 May 2018 11:10:33 +0100, bartc wrote: >> 0 items within the list: >> >> ()Empty tuple >> []Empty list >> {}Empty dict > > Aye ... as we've acknowledged numerous times now, the empty tuple *is* a > genuine special cas

RE: "Data blocks" syntax specification draft

2018-05-23 Thread Dan Strohl via Python-list
First of all, I suggest splitting this into a separate proposal (new thread) that way you will avoid confusion for people who are still considering the older proposal, and for the (probably many) people who have stopped reding the old thread due to some of the more heated conversations in there.

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Steven D'Aprano
On Wed, 23 May 2018 11:10:33 +0100, bartc wrote: [...] >> You haven't done enough testing. All you have done is found that "round >> brackets give a tuple, other brackets don't". But you need to test what >> happens if you take away the brackets to be sure that it is the round >> brackets which cr

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Steven D'Aprano
On Wed, 23 May 2018 03:02:48 -0600, Ian Kelly wrote: > Maybe you are the one who is being overly pedantic. I resemble that remark! -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 07:03, Chris Angelico wrote: On Wed, May 23, 2018 at 3:32 PM, Christian Gollwitzer wrote: I'd think that the definitive answer is in the grammar, because that is what is used to build the Python parser: https://docs.python.org/3/reference/grammar.html Actually, I'm a

Re: "Data blocks" syntax specification draft

2018-05-23 Thread bartc
On 23/05/2018 07:47, Steven D'Aprano wrote: On Tue, 22 May 2018 18:51:30 +0100, bartc wrote: On 22/05/2018 15:25, Chris Angelico wrote: [...] The tuple has nothing to do with the parentheses, except for the special case of the empty tuple. It's the comma. No? Take these: a = (10,20,30)

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Comments, suggestions are welcome. > nice effort well as far as i've seen, it is more suited as a data standard than a direct python integration why? same as why do we write .json files, xml files, csv files apart as, in-source you wan

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 12:49 AM, Steven D'Aprano wrote: > On Tue, 22 May 2018 09:43:55 -0600, Ian Kelly wrote: > >> In other words, the rule is not really as simple as "commas make >> tuples". I stand by what I wrote. > > Being pedantic is great, but if you're going to be pedantic, it pays to > b