import sublime, sublime_plugin

class SumCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        sum_view = self.view.window().new_file()
        sum_view.set_name('Sum')

        file_text = self.view.substr(sublime.Region(0, self.view.size()))
        sum_view.insert(edit, 0, file_text)

        sum_view.set_read_only(True)
        sum_view.set_scratch(True)

import sublime, sublime_plugin

class SumCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        sum_view = self.view.window().new_file()
        sum_view.set_name('Sum')

        file_text = self.view.substr(sublime.Region(0, self.view.size()))

        numbers = []
        for s in file_text.split():
            if s.isdigit():
                numbers.append(int(s))
            else:
                try:
                    numbers.append(float(s))
                except ValueError:
                    pass

        result = sum(numbers)
        sum_view.insert(edit, 0, str(result))

        sum_view.set_read_only(True)
        sum_view.set_scratch(True)

Add up all ints (base 10) and floats in the file