LoginSignup
0
0

More than 5 years have passed since last update.

Jupyter > 変数の初期化 > del 変数 | %reset

Last updated at Posted at 2017-10-07
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 16.04 LTS desktop amd64
TensorFlow v1.2.1
cuDNN v5.1 for Linux
CUDA v8.0
Python 3.5.2
IPython 6.0.0 -- An enhanced Interactive Python.
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
scipy v0.19.1
geopandas v0.3.0

Jupyter上での失敗。

#vor = Voronoi(points)

#以下でvorを使った処理

vorへの代入をコメントアウトしてしまい、それでも動作していた。
以前vorへ代入したものがJupyterでは記憶されているため。

対処法として変数の削除が考えられる。

参考: https://stackoverflow.com/questions/22934204/how-to-clear-variables-in-ipython

del vor

vor = 1
del vor
print(vor)
run
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-73-76b2d61c664a> in <module>()
      1 vor = 1
      2 del vor
----> 3 print(vor)

NameError: name 'vor' is not defined

きちんとエラーが出た。

%reset

vor = 1
%reset
print(vor)

実行後、以下のように質問される。y+[Enter]を入力するまで実行されない。

Once deleted, variables cannot be recovered. Proceed (y/[n])?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0