• Re: Pycharm IDE

    From aapost@21:1/5 to Kevin M. Wilson on Tue Apr 18 20:02:49 2023
    On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dn@21:1/5 to Kevin M. Wilson via Python-list on Wed Apr 19 12:02:33 2023
    On 19/04/2023 11.18, Kevin M. Wilson via Python-list wrote:
    Greetings... Kevin here:I need help, as you have guessed!I have this line: The Print Statement... Why complain about a 'comma', or a ')'???def play_game():
    number = random.randint(1, LIMIT)
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")Or is this a setting in the IDE, I need to reassign?

    The code is a bit difficult to read (wrapping), but the error message
    may be an assumption (on Python's part).

    Should the line be:

    print( F"I am thinking...
    ^
    no extraneous/unbalanced apostrophe here?

    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Kevin M. Wilson via Python-list on Tue Apr 18 19:48:12 2023
    On 4/18/2023 7:18 PM, Kevin M. Wilson via Python-list wrote:
    Greetings... Kevin here:I need help, as you have guessed!I have this line: The Print Statement... Why complain about a 'comma', or a ')'???def play_game():
    number = random.randint(1, LIMIT)
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")Or is this a setting in the IDE, I need to reassign?

    I'm not sure what error you are talking about, but the f-string isn't
    closed (and doesn't appear to need the double quotes, either, though
    that is not an error). So -

    print (f'I am thinking of a number between 1 to {LIMIT}')

    (print() will add its own newline at the end so you don't need the \n
    unless you actually want another newline).

    Next time, please include the actual error message and make sure you
    include line breaks so things don't run together.


    Regards, Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."
    Isaiah 43:2

    | | Virus-free.www.avg.com |


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kevin M. Wilson@21:1/5 to All on Tue Apr 18 23:18:57 2023
    Greetings... Kevin here:I need help, as you have guessed!I have this line: The Print Statement... Why complain about a 'comma', or a ')'???def play_game():
    number = random.randint(1, LIMIT)
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")Or is this a setting in the IDE, I need to reassign?

    Regards, Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
    Isaiah 43:2

    | | Virus-free.www.avg.com |

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kevin M. Wilson@21:1/5 to Kevin M. Wilson on Wed Apr 19 05:16:00 2023
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing that
    it expects a single quotation mark or ')'! No error message is displayed. Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
    Isaiah 43:2

    On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost <aapost@idontexist.club> wrote:

    On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
          print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print
    --
    https://mail.python.org/mailman/listinfo/python-list


    | | Virus-free.www.avg.com |

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kevin M. Wilson@21:1/5 to Kevin M. Wilson on Wed Apr 19 05:27:56 2023
    Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"),
    and Pycharm stopped complaining about it... WHY??
    Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
    Isaiah 43:2

    On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list <python-list@python.org> wrote:

    print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing
    that it expects a single quotation mark or ')'! No error message is displayed. Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."     
    Isaiah 43:2

        On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost <aapost@idontexist.club> wrote: 

    On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
          print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print
    --
    https://mail.python.org/mailman/listinfo/python-list
     

    |  | Virus-free.www.avg.com |

    --
    https://mail.python.org/mailman/listinfo/python-list


    | | Virus-free.www.avg.com |

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dn@21:1/5 to Kevin M. Wilson via Python-list on Wed Apr 19 19:17:03 2023
    Kevin,

    As mentioned in another response, the format of these messages seems
    very confused.

    Please copy-paste all of (the pertinent part of) the code, and ensure
    that the line-endings are in the correct places, tab/indentation looks
    correct, etc?
    (this will allow us to copy the same code into our PyCharm software and
    see what is happening!)

    There still appears to be both an apostrophe (') and quotation-marks
    ("). Do you want the user to see one/both?

    There was mention of this being an input prompt - hence the
    question-mark. Are you aware that this could be done as part of the
    input() function?

    How about creating a string and then printing that, eg

    prompt = f'"I am thinking of a number between 1 to {LIMIT}"
    print( prompt )

    NB because of the question asked earlier, the above code is NOT syntactically-correct Python!
    NBB am assuming there's previous code which defines LIMIT



    On 19/04/2023 17.27, Kevin M. Wilson via Python-list wrote:
    Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"),
    and Pycharm stopped complaining about it... WHY??
    Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."
    Isaiah 43:2

    On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list <python-list@python.org> wrote:

    print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing
    that it expects a single quotation mark or ')'! No error message is displayed.
    Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."
    Isaiah 43:2

        On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost <aapost@idontexist.club> wrote:

    On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
          print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print

    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dn@21:1/5 to Kevin M. Wilson on Wed Apr 19 21:33:19 2023
    On 19/04/2023 21.13, Kevin M. Wilson wrote:
    Sorry the code snippet I sent was what is written in PyCharm. LIMIT is defined and is not causing an error!
    PyCharm is flagging the Parentheses at the end. It is not seeing the Parentheses as the end of the print function.

    def play_game():
    number= random.randint(1, LIMIT)
    print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    Observe... Look at the color of the parenthesis, it's green!!!
    !!! = WTH


    Same question!

    Please explain: why is there a (single) apostrophe?

    NB some email clients don't notice list communications and ReplyList -
    you may need to do that manually...

    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Kevin M. Wilson via Python-list on Wed Apr 19 08:33:21 2023
    On 4/19/2023 1:27 AM, Kevin M. Wilson via Python-list wrote:
    Ok, I got rid of the "print (f'"I am thinking of a number between 1 to {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"),

    I think you misunderstand several things at the same time here.

    1. These errors originate from syntax errors. They are basically Python errors. It's possible that behind the scenes, PyCharm is running one or another Python program to detect them, but they are errors in your
    Python code.

    2. print() doesn't care whether you give it an f-string or not, because
    a f-string is a string too.

    3. All strings need to be closed with the same kind of quote they
    started with. If one is not closed, then Python thinks the string is
    supposed to continue, and - say- the final parenthesis of the print()
    function looks like it is part of the string. So Python (or PyCharm)
    notices that the closing parenthesis of the print() expression is missing.

    4. in an f-string, the expression in braces is evaluated and replaced by
    its string value. So if you try to do this

    print('{LIMIT}')

    then that will be printed as is with no substitution - because it is
    not an f-string. So you will see "{LIMIT}" But you thought you were
    going to see "42" (if LIMIT == 42, that is). OTOH,

    print(f'{LIMIT})

    will substitute the string value of LIMIT before printing the string.
    Both are legitimate but the first is not what you seem to want.

    5. As I posted earlier, you almost certainly do not need to add the "\n".

    So, some suggestions:

    - If you are having a problem with some piece of code, try to simplify
    it down to the smallest bit that shows the problem.

    - If you are having trouble with f-strings, then think about what you
    want to achieve and look up information about f-strings with that in mind.

    - If you are having trouble with the print statement, think what you
    want it to display and look up information about the print function with
    that in mind.

    - If your tool - PyCharm in this case - is producing messages but you
    don't understand why they are being produced, try to look up information
    about how and when PyCharm produces error messages

    Do you see a pattern here?

    Also note that just because you don't see an error message does not mean
    that the code is correct. It may be correct from the point of view of
    Python syntax but that doesn't mean that it will perform correctly nor
    how you expect.

    and Pycharm stopped complaining about it... WHY??
    Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."
    Isaiah 43:2

    On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson via Python-list <python-list@python.org> wrote:

    print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had the impression that the format specifier 'f' was necessary for the print function, but the double quotes are for the string printed to the user, as a prompt!The Pycharm IDE is showing
    that it expects a single quotation mark or ')'! No error message is displayed.
    Perplexed
    "When you pass through the waters, I will be with you: and when you pass through the rivers, they will not sweep over you. When you walk through the fire, you will not be burned: the flames will not set you ablaze."
    Isaiah 43:2

        On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost <aapost@idontexist.club> wrote:

    On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
          print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mark Bourne@21:1/5 to Thomas Passin on Wed Apr 19 21:06:18 2023
    Thomas Passin wrote:
    On 4/19/2023 1:27 AM, Kevin M. Wilson via Python-list wrote:
    Ok, I got rid of the "print (f'"I am thinking of a number between 1 to
    {LIMIT}\n")"print ("I am thinking of a number between 1 to {LIMIT}\n"),

    I think you misunderstand several things at the same time here.

    1. These errors originate from syntax errors.  They are basically Python errors.  It's possible that behind the scenes, PyCharm is running one or another Python program to detect them, but they are errors in your
    Python code.

    2. print() doesn't care whether you give it an f-string or not, because
    a f-string is a string too.

    3. All strings need to be closed with the same kind of quote they
    started with.  If one is not closed, then Python thinks the string is supposed to continue, and - say- the final parenthesis of the print() function looks like it is part of the string. So Python (or PyCharm)
    notices that the closing parenthesis of the print() expression is missing.

    4. in an f-string, the expression in braces is evaluated and replaced by
    its string value.  So if you try to do this

    print('{LIMIT}')

    then that will be printed as is with no  substitution - because it is
    not an f-string.  So you will see "{LIMIT}" But you thought you were
    going to see "42" (if LIMIT == 42, that is). OTOH,

    print(f'{LIMIT})

    ^ I think this one should be:

    print(f'{LIMIT}')

    with the closing quote ;o)

    will substitute the string value of LIMIT before printing the string.
    Both are legitimate but the first is not what you seem to want.

    5. As I posted earlier, you almost certainly do not need to add the "\n".

    So, some suggestions:

    - If you are having a problem with some piece of code, try to simplify
    it down to the smallest bit that shows the problem.

    - If you are having trouble with f-strings, then think about what you
    want to achieve and look up information about f-strings with that in mind.

    - If you are having trouble with the print statement, think what you
    want it to display and look up information about the print function with
    that in mind.

    - If your tool - PyCharm in this case - is producing messages but you
    don't understand why they are being produced, try to look up information about how and when PyCharm produces error messages

    Do you see a pattern here?

    Also note that just because you don't see an error message does not mean
    that the code is correct.  It may be correct from the point of view of Python syntax but that doesn't mean that it will perform correctly nor
    how you expect.

    and Pycharm stopped complaining about it... WHY??
    Perplexed
    "When you pass through the waters, I will be with you: and when
    you pass through the rivers, they will not sweep over you. When you
    walk through the fire, you will not be burned: the flames will not set
    you ablaze."
    Isaiah 43:2

         On Tuesday, April 18, 2023 at 11:17:52 PM MDT, Kevin M. Wilson
    via Python-list <python-list@python.org> wrote:
      print (f'"I am thinking of a number between 1 to {LIMIT}\n")I had
    the impression that the format specifier 'f' was necessary for the
    print function, but the double quotes are for the string printed to
    the user, as a prompt!The Pycharm IDE is showing that it expects a
    single quotation mark or ')'! No error message is displayed.
    Perplexed
    "When you pass through the waters, I will be with you: and when
    you pass through the rivers, they will not sweep over you. When you
    walk through the fire, you will not be burned: the flames will not set
    you ablaze."
    Isaiah 43:2

         On Tuesday, April 18, 2023 at 06:44:37 PM MDT, aapost
    <aapost@idontexist.club> wrote:
      On 4/18/23 19:18, Kevin M. Wilson wrote:
    Why complain about a 'comma', or a ')'???
           print (f'"I am thinking of a number between 1 to {LIMIT}\n")

    my version says it expects ' first (to close the fstring)
    then on a new line below it, it mentions the comma and )
    I believe that is just showing you after ' it expects you to end the
    print with ) as you have
    or , to add additional arguments to print


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Mark Bourne on Wed Apr 19 16:59:51 2023
    On 4/19/2023 4:06 PM, Mark Bourne wrote:

    print(f'{LIMIT})

    ^ I think this one should be:

    print(f'{LIMIT}')

    with the closing quote ;o)

    Yup a typo! Where's pylint when I need it?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dn@21:1/5 to Thomas Passin on Thu Apr 20 11:48:30 2023
    On 20/04/2023 08.59, Thomas Passin wrote:
    On 4/19/2023 4:06 PM, Mark Bourne wrote:

    print(f'{LIMIT})

    ^ I think this one should be:

    print(f'{LIMIT}')

    with the closing quote ;o)

    Yup a typo!  Where's pylint when I need it?

    but (and you designed it this way - right?) an excellent object-lesson
    for the OP

    AND

    great rationale for why linters are so handy!


    I am bullish on F-strings, but they can stretch the typing fingers and
    strain the eyes. Remember the days when pythonista used to make
    deprecating remarks about the superiority of Python's syntax because we
    didn't have 'all those braces' (and other punctuation-characters)
    cluttering-up the code???

    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to dn via Python-list on Thu Apr 20 08:52:59 2023
    On 4/19/2023 7:48 PM, dn via Python-list wrote:
    On 20/04/2023 08.59, Thomas Passin wrote:
    On 4/19/2023 4:06 PM, Mark Bourne wrote:

    print(f'{LIMIT})

    ^ I think this one should be:

    print(f'{LIMIT}')

    with the closing quote ;o)

    Yup a typo!  Where's pylint when I need it?

    but (and you designed it this way - right?) an excellent object-lesson
    for the OP

    AND

    great rationale for why linters are so handy!

    The Leo editor, which I use, checks the file you are working on for
    syntax errors and also for undefined variables, missing imports, and the
    like, when you save it. It gives you a clickable link to the line in
    question. This is a good compromise because it stays out of your way
    until you take a break by saving.

    I am bullish on F-strings, but they can stretch the typing fingers and
    strain the eyes. Remember the days when pythonista used to make
    deprecating remarks about the superiority of Python's syntax because we didn't have 'all those braces' (and other punctuation-characters) cluttering-up the code???

    When you get right down for it, there isn't much difference between

    'Here is the result: %s, %s' %(a.b, c)

    and

    'Here is the result: {}, {}'.format(a.b, c)

    Readability and typeability aren't much different. It's only when we
    get to f-strings that there's a real change, and the second form started
    to prepare us for it (yes, I know that the .format() form lets you use
    your own formatter - probably a real advantage though I never had
    occasion to use it)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)