Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Chris Angelico
On Tue, Dec 11, 2018 at 1:12 PM Avi Gross wrote: > I would then "generate" all possible combinations of digits 0-9 of length N. > There are an amazing number of ways to do that ranging from taking a > range(10**N) and converting it to a string then a list of numeral characters > then tossing

RE: Why Python don't accept 03 as a number?

2018-12-10 Thread Avi Gross
onary and pruning any attempts if the word you are building wanders off a leaf. Another story. I apologize for the length. The main question was whether eval is particularly expensive. -Original Message- From: Python-list On Behalf Of Antoon Pardon Sent: Monday, December 10, 2018 5:00

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Antoon Pardon
On 10/12/18 11:16, Chris Angelico wrote: > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon wrote: >> On 10/12/18 11:03, Chris Angelico wrote: >>> Considering that, in a problem of that description, neither S nor M >>> may represent zero, I don't think there's a problem here. >> Not all such

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Chris Angelico
On Mon, Dec 10, 2018 at 10:31 PM wrote: > > Chris Angelico於 2018年12月10日星期一 UTC+8下午7時09分01秒寫道: > > Yet most human beings will agree that you don't write out an > > arithmetic problem as: > > > >0 1 9 8 > > + 7 1 3 > > = > > Python3 gives me the error message is because of the

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread jfong
Chris Angelico於 2018年12月10日星期一 UTC+8下午7時09分01秒寫道: > On Mon, Dec 10, 2018 at 9:46 PM wrote: > > > > Chris Angelico於 2018年12月10日星期一 UTC+8下午6時17分14秒寫道: > > > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon > > > wrote: > > > > > > > > On 10/12/18 11:03, Chris Angelico wrote: > > > > > Considering

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Chris Angelico
On Mon, Dec 10, 2018 at 9:46 PM wrote: > > Chris Angelico於 2018年12月10日星期一 UTC+8下午6時17分14秒寫道: > > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon wrote: > > > > > > On 10/12/18 11:03, Chris Angelico wrote: > > > > Considering that, in a problem of that description, neither S nor M > > > > may

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread jfong
Chris Angelico於 2018年12月10日星期一 UTC+8下午6時17分14秒寫道: > On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon wrote: > > > > On 10/12/18 11:03, Chris Angelico wrote: > > > Considering that, in a problem of that description, neither S nor M > > > may represent zero, I don't think there's a problem here. > > >

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Chris Angelico
On Mon, Dec 10, 2018 at 9:11 PM Antoon Pardon wrote: > > On 10/12/18 11:03, Chris Angelico wrote: > > Considering that, in a problem of that description, neither S nor M > > may represent zero, I don't think there's a problem here. > > Not all such problems have that condition. They should.

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Antoon Pardon
On 10/12/18 11:03, Chris Angelico wrote: > On Mon, Dec 10, 2018 at 9:01 PM Antoon Pardon wrote: >> On 8/12/18 06:00, Cameron Simpson wrote: >>> On 07Dec2018 20:24, Jach Fong wrote: Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > What is it exactly that you're trying to accomplish with this?

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Antoon Pardon
On 8/12/18 07:59, Serhiy Storchaka wrote: > 08.12.18 03:17, jf...@ms4.hinet.net пише: > 00 >> 0 > 03 >>    File "", line 1 >> 03 >>   ^ >> SyntaxError: invalid token > > > In Python 3.8 the error message will be more informative: > 03 >   File "", line 1 > SyntaxError:

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Chris Angelico
On Mon, Dec 10, 2018 at 9:01 PM Antoon Pardon wrote: > > On 8/12/18 06:00, Cameron Simpson wrote: > > On 07Dec2018 20:24, Jach Fong wrote: > >> Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > >>> What is it exactly that you're trying to accomplish with this? Perhaps > >>> there's a better way than

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Antoon Pardon
On 8/12/18 06:00, Cameron Simpson wrote: > On 07Dec2018 20:24, Jach Fong wrote: >> Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: >>> What is it exactly that you're trying to accomplish with this? Perhaps >>> there's a better way than using eval. >> >> This problem comes from solving a word puzzle, >>  

Re: Why Python don't accept 03 as a number?

2018-12-10 Thread Antoon Pardon
On 8/12/18 09:35, Ian Kelly wrote: > On Fri, Dec 7, 2018 at 11:56 PM Henrik Bengtsson > wrote: >> A comment from the sideline: one could imagine extending the Python syntax >> with a (optional) 0d prefix that allows for explicit specification of >> decimal values. They would "complete" the

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Sat, Dec 8, 2018 at 7:57 PM wrote: > > Grant Edwards於 2018年12月9日星期日 UTC+8上午12時52分04秒寫道: > > Just to be clear: you do _not_ want to use eval on the string. > > > > If you're not the one who created the string, it might wipe your hard > > drive or empty your bank account. If you _are_ the one

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
b': 4, 'c': 'any digit', 'd': 5, 'e': 9} > {'a': '0', 'b': 5, 'c': 'any digit', 'd': 1, 'e': 6} > {'a': '0', 'b': 5, 'c': 'any digit', 'd': 2, 'e': 7} > {'a': '0', 'b': 5, 'c': 'any digit', 'd': 3, 'e': 8} > {'a': '0', 'b': 5, 'c': 'any digit', 'd': 4, 'e': 9} > {'a': '0', 'b':

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
Grant Edwards於 2018年12月9日星期日 UTC+8上午12時52分04秒寫道: > On 2018-12-08, Cameron Simpson wrote: > > On 07Dec2018 20:24, Jach Fong wrote: > >>Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > >>> What is it exactly that you're trying to accomplish with this? Perhaps > >>> there's a better way than using eval.

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Richard Damon
On 12/8/18 6:23 PM, Avi Gross wrote: > [DISCLAIMER: less about python than analysis of a puzzle] > > Richard, > > Thank you for pointing out that c in the puzzle is constrained. That > explains why my 320 answers are too many. It cannot be 0 as "a" is always > zero and it cannot be the three other

RE: Why Python don't accept 03 as a number?

2018-12-08 Thread Avi Gross
: Saturday, December 8, 2018 5:30 PM To: python-list@python.org Subject: Re: Why Python don't accept 03 as a number? On 12/8/18 12:40 PM, Avi Gross wrote: > You are solving for: ab + aa + cd == ce Actually, an even quicker analysis for this particular problem is: from the 10s digits, a + a + c

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Richard Damon
On 12/8/18 12:40 PM, Avi Gross wrote: > You are solving for: ab + aa + cd == ce Actually, an even quicker analysis for this particular problem is: from the 10s digits, a + a + c + carryin = c Thus a and carryin must both be 0 (carryin can not be negative, nor any of the variables) thus the

RE: Why Python don't accept 03 as a number?

2018-12-08 Thread Avi Gross
'a': '0', 'b': 7, 'c': 'any digit', 'd': 1, 'e': 8} {'a': '0', 'b': 7, 'c': 'any digit', 'd': 2, 'e': 9} {'a': '0', 'b': 8, 'c': 'any digit', 'd': 1, 'e': 9} ### END OUTPUT ## -Original Message- From: Python-list On Behalf Of jf...@ms4.hinet.net Sent: Saturday, De

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Grant Edwards
On 2018-12-08, Cameron Simpson wrote: > On 07Dec2018 20:24, Jach Fong wrote: >>Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: >>> What is it exactly that you're trying to accomplish with this? Perhaps >>> there's a better way than using eval. >> >>This problem comes from solving a word puzzle, >>

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Richard Damon
On 12/7/18 11:24 PM, jf...@ms4.hinet.net wrote: > Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: >> What is it exactly that you're trying to accomplish with this? Perhaps >> there's a better way than using eval. > This problem comes from solving a word puzzle, > ab + aa + cd == ce > Each character

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread jfong
Avi Gross at 2018/12/8 UTC+8 PM2:09:20 wrote: > [[READERS DIGEST CONDENSED ANSWER: use int("string") ]] > > Since we all agree python will not make notations like "05" work > indefinitely, and the need expressed is how to solve a symbolic puzzle (see > message below) then it makes sense to look

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Serhiy Storchaka
08.12.18 08:53, Henrik Bengtsson пише: A comment from the sideline: one could imagine extending the Python syntax with a (optional) 0d prefix that allows for explicit specification of decimal values. They would "complete" the family: * 0b: binary number * 0o: octal number * 0d: decimal number *

Re: Why Python don't accept 03 as a number?

2018-12-08 Thread Ian Kelly
On Fri, Dec 7, 2018 at 11:56 PM Henrik Bengtsson wrote: > > A comment from the sideline: one could imagine extending the Python syntax > with a (optional) 0d prefix that allows for explicit specification of > decimal values. They would "complete" the family: > > * 0b: binary number > * 0o: octal

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Serhiy Storchaka
08.12.18 03:17, jf...@ms4.hinet.net пише: 00 0 03 File "", line 1 03 ^ SyntaxError: invalid token In Python 3.8 the error message will be more informative: 03 File "", line 1 SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Henrik Bengtsson
A comment from the sideline: one could imagine extending the Python syntax with a (optional) 0d prefix that allows for explicit specification of decimal values. They would "complete" the family: * 0b: binary number * 0o: octal number * 0d: decimal number * 0x: hexadecimal number I understand

RE: Why Python don't accept 03 as a number?

2018-12-07 Thread Avi Gross
iginal Message- From: Python-list On Behalf Of jf...@ms4.hinet.net Sent: Friday, December 7, 2018 11:25 PM To: python-list@python.org Subject: Re: Why Python don't accept 03 as a number? Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > What is it exactly that you're trying to accomplish with

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Cameron Simpson
On 07Dec2018 20:24, Jach Fong wrote: Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: What is it exactly that you're trying to accomplish with this? Perhaps there's a better way than using eval. This problem comes from solving a word puzzle, ab + aa + cd == ce Each character will be translate to

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
I can understand the difficulty of throwing old thing away and accept new one in human. There seems have a huge inertia there. This phenomenon appears on every aspects, not only on the transition from Python2 to Python3. But, as a new comer of Python like me, I have no difficulty to accept it

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
Ian at 2018/12/8 UTC+8 AM11:28:34 wrote: > What is it exactly that you're trying to accomplish with this? Perhaps > there's a better way than using eval. This problem comes from solving a word puzzle, ab + aa + cd == ce Each character will be translate to a digit and evaluate the correctness,

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread MRAB
On 2018-12-08 03:49, Joe Pfeiffer wrote: jf...@ms4.hinet.net writes: MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: Before Python 3, a leading 0 in an integer literal would indicate an octal (base 8) number. So, the reason is historical. The old form is now invalid in order to reduce the

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Joe Pfeiffer
jf...@ms4.hinet.net writes: > MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: >> Before Python 3, a leading 0 in an integer literal would indicate an >> octal (base 8) number. > > So, the reason is historical. > >> The old form is now invalid in order to reduce the chance of bugs. > > I encounter this

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Ian Kelly
On Fri, Dec 7, 2018 at 7:47 PM wrote: > > MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > > Before Python 3, a leading 0 in an integer literal would indicate an > > octal (base 8) number. > > So, the reason is historical. > > > The old form is now invalid in order to reduce the chance of bugs. > > I

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Chris Angelico
On Sat, Dec 8, 2018 at 1:46 PM wrote: > > MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > > Before Python 3, a leading 0 in an integer literal would indicate an > > octal (base 8) number. > > So, the reason is historical. > > > The old form is now invalid in order to reduce the chance of bugs. > > I

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote: > Before Python 3, a leading 0 in an integer literal would indicate an > octal (base 8) number. So, the reason is historical. > The old form is now invalid in order to reduce the chance of bugs. I encounter this problem on trying to do something like

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread MRAB
On 2018-12-08 01:17, jf...@ms4.hinet.net wrote: 00 0 03 File "", line 1 03 ^ SyntaxError: invalid token Any particular reason? Before Python 3, a leading 0 in an integer literal would indicate an octal (base 8) number. In Python 2.7: >>> 010 8 That notation was borrowed

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Paulo da Silva
Às 01:17 de 08/12/18, jf...@ms4.hinet.net escreveu: 00 > 0 03 > File "", line 1 > 03 > ^ > SyntaxError: invalid token > > Any particular reason? > Not sure but I think that after 0 it expects x for hexadecimal, o for octal, b for binary, ... may be others. 0xa 10

Why Python don't accept 03 as a number?

2018-12-07 Thread jfong
>>> 00 0 >>> 03 File "", line 1 03 ^ SyntaxError: invalid token >>> Any particular reason? -- https://mail.python.org/mailman/listinfo/python-list