pycharm

Partial stub in PyCharm

社会主义新天地 提交于 2020-01-04 14:21:17
问题 I would like to introduce partial type annotation to my project. For example for overloading. I found that pep561 introduce partial stub file support. I develop my project with PyCharm and I add corresponding *.pyi file. And got expected information, but PyCharm reports that cannot find reference in pyi file. It is possible to force PyCharm to look to orginal py file when there is no entry in pyi file? Or maybe it is also doable with partial entry for class? I create sample project to show

服务器远程同步(pycharm and vscode)

懵懂的女人 提交于 2020-01-04 09:30:50
pycharm 在菜单栏依次点击 Tools->Deployment->Configuration ,进入以下 Connection 界面: 填写相关信息,重要的是 Root path ,填写好根目录,因为后续的映射是这个的 相对目录 。 进入 Mapping 界面: 填写本机同步代码的目录 Local path ,然后填写 Deployment path ,此处应为相对目录,如 /xx/xxx/xxxx ,点击OK便配置好啦,然后可以在 Tools->Deployment->Browse Remote Host 将远程服务器的目录了调出来。既可以在远程目录中调出文件进行修改,上传;也可以在本地文件进行修改,ctrl+s保存后会自动上传。 不过最好选择一种方式进行操作!!不然很轻易会覆盖掉新修改的代码 还可以选择远程的编译器对代码进行解释: Files->Project->Project Interpreter ,点击小齿轮-> add ,选择 SSH Interpreter : 输入Host, Username;password之后进入如下界面: 选择解释器所在的位置, Finish 即可。这样代码就会根据远程服务器的解释器进行自动补全啦。 VScode 安装 sftp 插件 打开本地要同步的文件夹 shift+ctrl+p ,输入 stfp ,找到 config

Tkinter window closes automatically after Python program has run in PyCharm

浪子不回头ぞ 提交于 2020-01-04 06:49:51
问题 I am programming a small Python game in PyCharm. I am doing this on a Macbook with Python version 3.4. The game opens a Tkinter window and adds some stuff to it. However, when running the game, it shows up very briefly and closes immediately. I found some tips here on Stackoverflow to add input('Press to close the window') at the end of the game. Indeed, this ensures that the window is not closed immediately, but it is not practical for the game. In the game, the user needs to use his arrow

Tkinter window closes automatically after Python program has run in PyCharm

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 06:49:19
问题 I am programming a small Python game in PyCharm. I am doing this on a Macbook with Python version 3.4. The game opens a Tkinter window and adds some stuff to it. However, when running the game, it shows up very briefly and closes immediately. I found some tips here on Stackoverflow to add input('Press to close the window') at the end of the game. Indeed, this ensures that the window is not closed immediately, but it is not practical for the game. In the game, the user needs to use his arrow

Why does PyCharm raise a warning when using @property here?

风流意气都作罢 提交于 2020-01-04 05:27:18
问题 In tutorials I have seen two types of instance attribute naming for the purpose of using @property. Here is code showing examples of both. They also seem to work differently. class A: def __init__(self, x): self.x = x @property def x(self): return self.__x @x.setter def x(self, x): if x > 1000: self.__x = 1000 else: self.__x = x # Instance attribute __x defined outside __init__ class B: def __init__(self, x): self._x = x @property def x(self): return self._x @x.setter def x(self, x): if x >

PyCharm Notebook: Widget javascript not detected

无人久伴 提交于 2020-01-04 04:26:30
问题 This python code in the PyCharm notebook viewer produces the error: Widget Javascript not detected. It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension" Code: from ipywidgets import widgets from IPython.display import display text = widgets.Text() display(text) I did enable the extension with the suggested command from the error. The code works from a web-based jupyter notebook session. I

4,模块-time-os-sys

假装没事ソ 提交于 2020-01-04 04:21:25
time模块, os模块 sys模块 和时间有关的我们就要用到时间模块,在使用模块之前,需要先导入模块. import time print(123) print(234) time.sleep(15) #程序暂停3s后执行 #(线程)推迟指定的时间运行,单位秒 print(345) print(456) print(time.time())#输出:1531273400.7828987 表示时间的三种方式 在python中,通常有这三种方式,来表示时间:时间戳,元组(struct_time),格式化的时间字符串, (1)时间戳(timestamp):通常来说,时间戳表示的是从1970年1月1日00:00:00开始按秒记算的偏移量,我们运行'type(time.time()',返回的是float类型. import time time1=time.time() print(time1,type(time1)) #输出:1531274153.0989287 <class 'float'> (2)格式化的时间字符串(Format String):'1992.04.14' import time # print(time.time(),type(time.time())) ret=time.strftime("%Y-%m-%d %H:%M:%S") print(ret,type(ret))

Pycharm: enable tooltip for variables / names / tokens with mouse hover?

谁说我不能喝 提交于 2020-01-04 03:58:41
问题 I'm looking for something similar to how Visual Studio will show tooltips when hovering the mouse over anything in the editor (type information, method details, other useful information, etc.). Is this a configurable option in PyCharm? I've yet to find it. Thanks. 回答1: It's available via quick documentation hotkey only, vote for the issue so that it also works on hover. 来源: https://stackoverflow.com/questions/7921160/pycharm-enable-tooltip-for-variables-names-tokens-with-mouse-hover

Autocompletion in PyCharm based on type

前提是你 提交于 2020-01-04 02:51:19
问题 I'm using PyCharm for python coding. The autocompletion in PyCharm is not as good as in IntelliJ (Java). Consider the below code a = [1,2,3,4] a. In this case, after I press the dot , PyCharm gives the full set of autocompletion options. Consider the below case def func_a(a): a. Here, to the function func_a I'm passing a list as an argument. But when I press dot after a , PyCharm doesn't give any autocompletion options. I know this is because Python is dynamically typed language and PyCharm

PyCharm referencing older, removed variable

旧巷老猫 提交于 2020-01-04 02:43:07
问题 I just encountered an issue with PyCharm. While I did find a workaround, I'm interested to know if there's a better solution to this issue. During development, I had a variable named rIndex. I didn't notice until today that it was throwing out the following error, sent multiple times (2-4): Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.1.4\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1081, in do_it result = pydevd_vars.evaluate