-4

I'm writing a python script wherein I need to use the continue word.

I know that it is a python keyword.

So how should I write my script so that python will not complain that I am using a keyword as a string literal.

Thanks in advance for your time.

Hamza Ahmed
  • 1,571
  • 4
  • 18
  • 35

2 Answers2

1

You should use something like: _continue

But why not using more descriptive and longer variable name?! like: continue_whatever or go_on ...

Mehdi Seifi
  • 515
  • 11
  • 22
0

The normal practice is to use a trailing underscore to use a keyword that already being used by the language, like continue_ or input_.

I don't think anyone would think that just overwriting keywords is every a good idea.

Jules G.M.
  • 3,624
  • 1
  • 21
  • 35
  • I am constrained to use the continue keyword since I am invoking another python script (Not written by me or in my control) that makes use of the 'continue' word as one of its arguments – Hamza Ahmed Oct 06 '16 at 07:23
  • how does that force you to use continue in a way that would cause problems with the keyword? – Jules G.M. Oct 06 '16 at 07:24
  • I'm pretty sure `fooo(continue=whatever)` should not cause the interpreter to complain – Jules G.M. Oct 06 '16 at 07:26
  • I am writing my python script in visual studio code and editor colors it and recognizes it as a keyword with other keywords like with, for, import etc – Hamza Ahmed Oct 06 '16 at 07:26
  • That's an argument, not a string literal. – Ignacio Vazquez-Abrams Oct 06 '16 at 07:27
  • 2
    @HamzaAhmedZia Editors are often do not implement the full language’s grammar, so they may incorrectly show keywords as special even though they appear in places where they are not recognized. Just run the script and see if it works. – poke Oct 06 '16 at 07:27
  • also, there shouldn't ever be a problem using continue in a string litteral – Jules G.M. Oct 06 '16 at 07:29