From a3f863ff186e22941edfb9eb20ba807ae7c24366 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 3 Aug 2019 19:02:24 -0700 Subject: [PATCH] Move is_numerical() to joy.gui.utils. --- joy/gui/textwidget.py | 3 ++- joy/gui/utils.py | 8 ++++++++ joy/gui/world.py | 10 +--------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/joy/gui/textwidget.py b/joy/gui/textwidget.py index 9eea55b..08c1734 100644 --- a/joy/gui/textwidget.py +++ b/joy/gui/textwidget.py @@ -49,7 +49,8 @@ import os, sys from joy.utils.stack import stack_to_string from .mousebindings import MouseBindingsMixin -from .world import World, is_numerical +from .utils import is_numerical +from .world import World def make_gui(dictionary): diff --git a/joy/gui/utils.py b/joy/gui/utils.py index 3b7abfa..e187d12 100644 --- a/joy/gui/utils.py +++ b/joy/gui/utils.py @@ -10,6 +10,14 @@ COMMITTER = 'Joy ' DEFAULT_JOY_HOME = expanduser(join('~', '.joypy')) +def is_numerical(s): + try: + float(s) + except ValueError: + return False + return True + + def home_dir(path): '''Return the absolute path of an existing directory.''' diff --git a/joy/gui/world.py b/joy/gui/world.py index 4fe4514..14c8dac 100644 --- a/joy/gui/world.py +++ b/joy/gui/world.py @@ -28,14 +28,7 @@ from joy.joy import run from joy.parser import Symbol from joy.utils.stack import stack_to_string from joy.utils.types import type_check - - -def is_numerical(s): - try: - float(s) - except ValueError: - return False - return True +from .utils import is_numerical class World(object): @@ -121,7 +114,6 @@ class World(object): class StackDisplayWorld(World): - def __init__(self, repo, filename, rel_filename, dictionary=None, text_widget=None): self.filename = filename stack = self.load_stack() or ()