On Thu, 30 Jan 2020 20:40:50 +1300
DL Neil via Python-list wrote:
> Why do we have [argparse] at the cmdLN and yet not have something
> similar for input?
Because argparse works on input, too?
Many examples on https://docs.python.org/3/library/argparse.html¹
explicitly pass a list of strings
Further thoughts on the OP's point:-
On 29/01/20 4:51 PM, sushma ms wrote:
...
But why can't we make output of input also dynamic data assignment.
...
when i'm assigning value dynamically and when we comparing in "if"
loop
it is throwing compiler error. It should not throw
Sushma added the comment:
Thank you
On Tue, Jan 28, 2020, 6:30 PM Steven D'Aprano
wrote:
>
> Steven D'Aprano added the comment:
>
> The "num" variable is not a number, it *is* a string. Just because you
> call it "num" doesn't magically turn it into a number. The `input` function
> returns
On 29/01/20 4:51 PM, sushma ms wrote:
Thanks a lot.
But why can't we make output of input also dynamic data assignment.
1 please don't 'top post': the normal sequence of a conversation is
question THEN answer!
2 ambiguity! It is not possible for the input() mechanism to tell
whether you
Thanks a lot.
But why can't we make output of input also dynamic data assignment.
Thanks & Regards,
Sushma MS
On Tue, Jan 28, 2020, 9:54 PM Mariatta wrote:
> input() returns a string. If you want it to be treated as an int you need
> to cast it, example:
>
> num =int(input ("Enter number"))
>
Terry J. Reedy added the comment:
Sushma, asking about the exception message on python-list was the right thing
to do. You should have waited for the answers you got there. At this point,
bugs in basic python operations are extremely rare.
--
nosy: +terry.reedy
On 28/01/2020 12:03, sushma ms wrote:
Hi
Please find below example and the compiler error,
when i'm assigning value dynamically and when we comparing in "if" loop it
is throwing compiler error. It should not throw error
It absolutely should throw an error.
it should assign and
act as int
input() returns a string. If you want it to be treated as an int you need
to cast it, example:
num =int(input ("Enter number"))
On Tue, Jan 28, 2020, 5:13 AM sushma ms wrote:
> Hi
>
> Please find below example and the compiler error,
>
> when i'm assigning value dynamically and when we
Hi
Please find below example and the compiler error,
when i'm assigning value dynamically and when we comparing in "if" loop it
is throwing compiler error. It should not throw error it should assign and
act as int why it is thinking as string.
*Code Snippet:*
print("Hello World")
num =
Steven D'Aprano added the comment:
The "num" variable is not a number, it *is* a string. Just because you call it
"num" doesn't magically turn it into a number. The `input` function returns a
string.
You might be thinking of Python 2.7 where `input` automatically evaluated the
string as
ot all arguments converted during string formatting
--
messages: 360865
nosy: Sush0907
priority: normal
severity: normal
status: open
title: Not convinced with the dynamic data type assignment
type: compile error
versions: Python 3.8
___
Python trac
11 matches
Mail list logo