Author Topic: thonny  (Read 736 times)

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
thonny
« on: 22. February 2017, 08:54:58 »
Everybody knows that i don't like Python  ;D
but this one looks interesting
http://thonny.org/
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Transdiv

  • Newcomer
  • *
  • Posts: 4
    • View Profile
Re: thonny
« Reply #1 on: 22. February 2017, 15:38:47 »
Extremely interesting for begginers; Not the typical overwhelming IDE with one million options to choose from.

Tomaaz

  • Guest
Re: thonny
« Reply #2 on: 25. February 2017, 20:53:00 »
Everybody knows that i don't like Python  ;D
but this one looks interesting
http://thonny.org/

Do you mean the fact that it's been written in Python? Cause, apart from that, it's just another editor.  ::)

Extremely interesting for begginers; Not the typical overwhelming IDE with one million options to choose from.

Yes, but it's still far from perfection achieved by Aurel in his collection of editors for various languages.  ;)

Don't get me wrong. I'm not saying this is a bad editor, but it's just funny that, after a long break, the first thing I see here is Aurel posting about Python!  ;D

BTW Aurel, I can also see that you have a new forum and a new interpreter in development. So, nothing's really changed...  ;D

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #3 on: 27. February 2017, 19:06:34 »
WOW...tomek is alive.... ;D
It is interesting that you don't see things how i see ..
it is not just another editor than is editor + python in one package and is not
overhelmed with "things" in just 8megs ..winPython is 50megs
and some other heavy python distros ..
another thing ...i see very well debugger system and intermediate execution.

python ahh yes ... ;D

New Year ..new Interpreter and what is wrong with that
yes it is again in o2 but who care .... ;D
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #4 on: 27. February 2017, 22:55:44 »
It looks that respond properly... :o
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #5 on: 27. February 2017, 23:34:32 »
WHAT A MISTEKA TO MEKA  ;D
for testing i use one code from github
and add source to editor then i save and run and...
lily...mili..vanily,,, :o

Quote
SyntaxError: Missing parentheses in call to 'print'

>>> %Run BENbasic.py
  File "D:\Programs\Thonny\Scripts\BENbasic.py", line 582
    print str(i)+" "+lines
            ^
SyntaxError: invalid syntax

is that really true (is that because py3 ??? ) .he hee

why i use this as example ?
it looks to me like a ruben clone
 ;D
« Last Edit: 27. February 2017, 23:45:29 by Aurel »
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Tomaaz

  • Guest
Re: thonny
« Reply #6 on: 28. February 2017, 12:39:31 »
Quote
SyntaxError: Missing parentheses in call to 'print'

>>> %Run BENbasic.py
  File "D:\Programs\Thonny\Scripts\BENbasic.py", line 582
    print str(i)+" "+lines
            ^
SyntaxError: invalid syntax

is that really true (is that because py3 ??? ) .he hee

Yes. It should be print(str(i) + " " + lines[1]).
« Last Edit: 28. February 2017, 12:42:29 by Tomaaz »

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #7 on: 28. February 2017, 15:39:34 »
..and why is then written that way?
i mean there is also few other similar errors..
is that connected something with py2 - py3 relations
because i dont think that author made these mistakes just like that
right?
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Tomaaz

  • Guest
Re: thonny
« Reply #8 on: 28. February 2017, 20:55:02 »
Yes, this is Python 2 code that won't run with Python 3. In Python 3 print is a function and needs parentesis. In Python 2 parenthesis with print are optional.

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #9 on: 07. March 2017, 12:15:17 »
ahh py2...py3 what a stupid syntax changes
anyway i have found one on github called tooBasic as author says based on rfobasic
tokenizer
Code: [Select]
from .error import throw, BasicTokeniseError, get_line


token_type = {
    'word': 1,
    'keyword': 11,
    'number': 21,
    'string': 22,
    'label': 4,
    'operator': 5,
    'assign': 50,
    'paren': 8,
    'function':9,
    'EOL': 10,
    'EOF': 0,
    'continue': -1,
}

tokenize_state = {
    'default': 0,
    'word': 1,
    'number': 2,
    'string': 3,
    'comment': 4,
    'operator': 5,
    'continue': 6
}

Type = token_type
State = tokenize_state

def dkey(type):
    """ get the key name from value
    used for debugging the token stream
    """
    return str(list(Type.keys())[ list(Type.values()).index(type) ])

class Token:
    """ Defines a single token """

    def __init__(self, value, type, line=0, pos=0):
        self.value = value
        self.type = type
        self.line = line # used for debugging
        self.position = pos # used for debugging

    def __str__(self):
        """ conversion to string form
        used for debugging the token stream
        """
        key = dkey(self.type)
        if dkey(self.type) == 'EOL':
            return '.'

        return key[:1].upper() + '' + str(self.value) + '  '

       
def tokenize(source):
    """ tokenizes source code for use with the parser

    returns token stream
    """

    tokens = []
    token = '' # current token
    state = State['default']

    operators = ('=', '+', '-', '*', '/', '<', '>', ';', ',', '&', '|', '!', '^')
    compassign = ('*=', '/=', '+=', '-=')
    boolean = ('<>', '!=', '<=', '>=', '=>', '=<', '||', '&&')

    from .ast import kwords
    keywords = kwords()

    line = 1 # line tracker
    pos = -1 # position in line

    def p(token, pos):
        return pos-len(token)

    linebeg = True
    cmt = ''

    for i, c in enumerate(source):
        pos += 1
        if not c in (' ', '!', '\n') and linebeg:
            linebeg = False
        elif c == '!' and linebeg and not cmt == 'double':
            state = State['comment']
            if source[i-1] == '!': # an ugly block comment hack
                cmt = 'double'
            continue

        if state == State['continue'] and not c == '\n':
            throw(BasicTokeniseError,
                'expected newline', line, pos, c)

        if state == State['default']:
            if c.isalpha() or c in ('_', '@', '$', '?'):
                token = c
                state = State['word']
            elif c.isdigit() or c == '.':
                token = c
                state = State['number']

            elif c in ('(', ')', '[', ']', '{', '}'):
                tokens.append(Token(c, Type['paren'], line, pos))
            elif c == '"':
                state = State['string']
            elif c == '%':
                token += c
                state = State['comment']
            elif c == '!':
                token += c
                state = State['operator']
            elif c in operators:
                token = c
                state = State['operator']
           
            elif c == '~':
                if not tokens[-1].value == ',':
                    tokens.append(Token('~', Type['continue'], line, pos))
                    pos+=1
                state = State['continue']

            elif c not in (' ', '\n', ',', ':'):
                throw(BasicTokeniseError,
                    'unexpected character', line, pos, c)

        elif state == State['operator']:
            if c in operators:
                token += c
                if len(token)>1 \
                and token not in compassign+boolean:
                    tokens.append(
                        Token(token[0], Type['operator'], line, p(token, pos)))
                    token = token[1:]
            else:
                if token in compassign:
                    tokens.append(
                        Token(token, Type['assign'], line, p(token, pos))
                    )
                else:
                    #if c.isdigit() and token == '-':
                    #    token += c
                    #    state = State['number']
                    #    continue
                    #else:
                        tokens.append(
                            Token(token, Type['operator'], line, p(token, pos))
                        )
                if c.isdigit():
                    token = c
                    state = State['number']
                elif c.isalpha() or c in ('_', '@', '$'):
                    token = c
                    state = State['word']
                elif c == '(':
                    tokens.append(
                        Token(c, Type['paren'], line, pos)
                    )
                    token = ''
                    state = State['default']
                elif c == '"':
                    token = ''
                    state = State['string']
                else:
                    token = ''
                    state = State['default']

        elif state == State['word']:
            if c.isalnum() or c in ('_','@','$', '.'):
                token += c
            else:
                ptoken = token.lower()
                token = ''
                state = State['default']

                if not c == ':' and not ptoken == 'rem' \
                and not ptoken in keywords: # not a label/comment/keyword
                    tokens.append(
                        Token(
                            ptoken, Type['word'],line, p(ptoken, pos)
                        )
                    )

                if ptoken in keywords:
                    tokens.append(
                        Token(
                            ptoken, Type['keyword'],
                            line, p(ptoken, pos)
                        )
                    )

                if c == ':' and ptoken in keywords:
                    throw(BasicTokeniseError, 'keyword cannot be a label',
                        line, p(ptoken, pos), ptoken)
 

                if c == ':': # if line is a label
                    tokens.append(
                        Token(
                            ptoken, Type['label'], line, p(ptoken, pos)
                        )
                    )
                    continue

                elif ptoken == 'rem' or c == '%': # comment
                    state = State['comment']

                elif c in operators:
                    token = c
                    state = State['operator']

                elif c in ('(', ')', '[', ']', '{', '}'):
                    tokens.append(Token(c, Type['paren'], line, pos))

                elif c == '"':
                    state = State['string']

                elif c not in (' ', '\n', ','):
                    throw(BasicTokeniseError,
                        'unexpected character', line, pos, c)

        elif state == State['number']:
            if c.isdigit() or c == '.':
                token += c
            else:
                tokens.append(
                    Token(token, Type['number'], line, p(token, pos))
                )
                if not c == ' ':
                    token = c
                else:
                    token = ''
                state = State['default']

                if c in (')', ']', '}'):
                    tokens.append(Token(c, Type['paren'], line, pos))
                elif c in operators:
                    state = State['operator']
                elif c.isalpha() or c in ('_', '@', '$'):
                    state = State['word']
                elif c == '%':
                    state = State['comment']
                elif c == '~':
                    tokens.append(Token(',', Type['operator'], line, p(',', pos)))
                    state = State['continue']
                elif c not in (' ', '\n', ',') + operators:
                    throw(BasicTokeniseError,
                        'unexpected character', line, pos, c)

        elif state == State['string']:
            if not c == '"':
                token += c
            else:
                tokens.append(
                    Token(token, Type['string'], line, p(token, pos-1))
                )
                token = ''
                state = State['default']

        elif state == State['comment']:
            #contains ugly block comment workarounds
            if c == '\n' and not cmt == 'double':
                state = State['default']
            elif c == '\n':
                tokens.append(Token('', Type['EOL'], line, pos))
                line+=1
                linebeg = True
                pos=-1
            if c == '!' and source[i-1] == '!' and cmt == 'double':
                cmt = ''
                state = State['default']

        if c in ('\n', ':') and not state in (State['string'], State['comment']):
            if not state == State['continue']:
                tokens.append(Token('', Type['EOL'], line, pos))
            if not c == ':':
                line += 1
            pos = -1
            state = State['default']
            linebeg = True
               
    return tokens

new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Tomaaz

  • Guest
Re: thonny
« Reply #10 on: 10. March 2017, 19:03:56 »
ahh py2...py3 what a stupid syntax changes

Yes. That's probably the worse thing that happened to Python. I want to believe there was a really important reason for that.

anyway i have found one on github called tooBasic as author says based on rfobasic
tokenizer

What's the point of posting the source code instead of link to the github page?

EDIT Aurel, is the forum I mentioned in my first post here already gone? Did you manage to start a new one in the meantime? What is current life expectancy of your forums? A month? A week? ;D
« Last Edit: 10. March 2017, 19:20:25 by Tomaaz »

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #11 on: 11. March 2017, 00:01:32 »
no forum is still there.. maybe i made mistake ;D
about link ..it is easy just type under github
about py3 hmm it looks is not "popular" like py2
anyway who care?
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

Tomaaz

  • Guest
Re: thonny
« Reply #12 on: 11. March 2017, 10:26:43 »
no forum is still there..

So, why the address in your profile has been changed? ;D

about py3 hmm it looks is not "popular" like py2
anyway who care?

Why double quotes? Python is quite popular on Github - http://githut.info/ .

Aurel

  • Regular Member
  • Sr. Member
  • *
  • Posts: 272
    • View Profile
Re: thonny
« Reply #13 on: 11. March 2017, 18:23:57 »
Quote
So, why the address in your profile has been changed?
ahh...i see i will change that crap  >:(
 ;D
yes of course it is popular on github
but most of sources are in python2 ..so not work with thonny( require v3)..
anyway there (on github) we can find many interesting things  :D
new basic pro forum on;
http://basicpro.spacefor.site/smf/
GUEST posting enabled

John

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
Re: thonny
« Reply #14 on: 12. March 2017, 19:44:28 »
Quote
Python is quite popular on Github

My experience with Python has been that the interpreter has a huge memory footprint, everything is an IMPORT and the C interface is a kludge. (putting all the other quirks aside)