0

I am new to Python and to Pycharm. And new to coding generally, although I did do some hobby stuff in Basic on a Commodore Plus4 back in the 80s.

Anyway, I am using Win 7 SP1, Pycharm 5.0.2 and Python 3.5.1 and trying to follow a webinar put out by MS Virtual Academy. (I also have Python 2.7.11 to follow a CodeAcademy Python course).

I am writing to code: print(variable.lower())

But I am not getting autocomplete suggestions for lower, upper, swapcase etc...see image. I have had a look in settings, but to be honest, I am not sufficiently familiar with the terminology to know where I should be looking.

I have tried using CTRL+SPACE and CTRL+SHIFT+SPACE...the result is the same, shown in the image.

Pycharm 5.0.2 autocomplete

I would be grateful for any suggestions or pointers, please?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Pollik
  • 11
  • 1
  • 2
  • Did you select the correct interpreter for the project? It may not know where to find your python path if not. – Bob Dylan Dec 21 '15 at 22:07
  • This answer might be useful - http://stackoverflow.com/a/12518290/5203702 – H. U. Dec 21 '15 at 22:08
  • Thank you for your replies. I have double checked I selected the correct interpreter, via Settings/Project[name]/Project Interpreter. It is definitely Python 3.5.1 I had already seen the other similarly named thread and tried cache invalidation, to no avail, as well as View/Quick Documentation,but thank you for pointing me to it. I would have chosen to use Visual Studio, but I struggled to get it installed with Python Visual Tools, and so I chose Pycharm which seemed to be the next best. – Pollik Dec 22 '15 at 13:22

2 Answers2

0

Python 2's "input" function returns a value with the type set to whatever Python guessed it to be. If you type in 99, then it is an integer. Python 3 converts its return value to a string.

My guess is, PyCharm doesn't correctly recognize that you are using Python 3. If you'd like a work-around: name = str(input("What is your name")) and then PyCharm will know that name is a string.

Paul Everitt
  • 651
  • 5
  • 10
  • One difference between Python 2 and Python 3 is how it treats the print statement/function. In my setup: print "text here" brings up an error, suggesting that it is correctly using the intrepreter for Python3 (as it should) rather than Python2 Your suggestion of forcing the string at the point of declaration does work for me, thank you, and I am now getting the autocomplete bubble. It is not a perfect solution but thank you to everyone for your suggestions – Pollik Dec 23 '15 at 14:26
0

Very odd, I've got a similar setup (Python 3.5.1/Pycharm 5.0.2), just a different OS (Fedora 23). I have this code:

x = 'Text'

print(x.lower())

x.lower() correctly auto completed. I was able to get it to not autocomplete by making it equal to a function as so:

x = input('Text')

print(x.lower())

The reason for this is because str.lower() won't autocomplete something that is a function (it's not supposed to), but when the string outputs it'll correctly identify the string and lower it all.

Logan
  • 439
  • 4
  • 10