Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected token ';'
#1
Hello Python Community!
This is driving me insane, I keep getting this error:
Error:
Unexcepted token ';'
It dosen't give me which line it's on nor is it in the SCRIPT!!!
I have no idea why this is happening Huh Huh

Script:
import vpython as vp
scene = vp.canvas(background=vp.color.cyan)

class Player:
  def __init__(self):
    self.instance = vp.box()
    self.direction = 0
    self.keys = {'w': False, 'a': False, 's': False,
      'd': False, ' ': False, 'left': False,
      'right': False}
      
    self.storage = {
      'grassblock': 0}
      
    scene.camera.rotate(axis=vp.vector(0, 1, 0), angle=vp.pi)
      
  def move(self, steps, dadd=0):
    self.instance.pos += vp.vector(
      vp.sin(self.direction + -vp.radians(dadd)) * steps / 25, 0,
      vp.cos(self.direction + -vp.radians(dadd)) * steps / 25)
      
  def rotate(self, angle):
    self.instance.rotate(axis=vp.vector(0, 1, 0), angle=-vp.radians(angle))
    scene.camera.rotate(axis=vp.vector(0, 1, 0), angle=-vp.radians(angle))
    self.direction -= vp.radians(angle)
    
  def place_block(self, blockitem):
    Block(
      self.instance.pos.x + vp.radians(vp.sin(self.direction)),
      self.instance.pos.z + vp.radians(vp.cos(self.direction)))
    
  def frame(self):
    if self.keys['w']: self.move(1)
    if self.keys['a']: self.move(1, -90)
    if self.keys['s']: self.move(-1)
    if self.keys['d']: self.move(1, 90)
    if self.keys[' ']: self.place_block('grassblock')
    if self.keys['left']: self.rotate(-1)
    if self.keys['right']: self.rotate(1)
    scene.center = self.instance.pos
    scene.camera.pos = self.instance.pos + vp.vector(
      -vp.sin(self.direction) * 4, 1.5,
      -vp.cos(self.direction) * 4)
      
class Block:
  blocks = []
  def __init__(self, x, z):
    self.instance = vp.box(pos=vp.vector(x, -1, z), height=0.5, color=vp.color.green)
    Block.blocks.append(self)
    
def rvector(vector):
  save = vp.vector(0, 0, 0)
  save.x = round(vector.x)
  save.y = round(vector.y)
  save.z = round(vector.z)
  return save

player = Player()

for x in range(5):
  for z in range(5):
    Block(x-2, z-2)

def key_down(event): player.keys[event.key] = True
def key_up(event): player.keys[event.key] = False
scene.bind('keydown', key_down)
scene.bind('keyup', key_up)

while True:
  vp.rate(200)
  player.frame()
P.S. mind the .instance(s), "super" leads into an error.
Reply
#2
There is no ';' character in the program and your error message is not Python's normal exception traceback message when there is an error. This error message normally has several lines each refering to precise positions in the program. Please post the complete error message.

So tell us precisely HOW you are running this script. In a terminal? in a IDE ? On which device? With which OS? etc.
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
(Jun-11-2025, 06:53 PM)Gribouillis Wrote: There is no ';' character in the program and your error message is not Python's normal exception traceback message when there is an error. This error message normally has several lines each refering to precise positions in the program. Please post the complete error message.

So tell us precisely HOW you are running this script. In a terminal? in a IDE ? On which device? With which OS? etc.
I am running it in the glowscript editor | trinket.io
(I mostly use a school laptop)
Reply
#4
The problem is related to trinket.io and it's not a Python-Problem.

I guess something with JS went wrong.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Refresh token for Wyze SDK duckredbeard 0 2,076 May-16-2022, 04:33 AM
Last Post: duckredbeard
  Need to sign JWT token with JWK key stucoder 1 2,921 Feb-21-2022, 09:04 AM
Last Post: stucoder
  Python requests oauth2 access token herobpv 6 9,307 Sep-27-2021, 06:54 PM
Last Post: herobpv
  unexpected token < in json at position 0 Frodoxzibit 5 5,073 Jul-10-2021, 09:33 AM
Last Post: Larz60+
  / token in function parameterlist tpourjalali 1 2,802 Apr-12-2020, 07:05 PM
Last Post: deanhystad
  Getting an "Unexpected Token" Error and don't know why... NotAHackusator 1 2,928 Nov-20-2019, 03:00 PM
Last Post: buran
  get and reuse the token value with huawei modem Reims 1 6,537 Oct-02-2019, 04:29 AM
Last Post: Reims
  Need help in adding xsrf token keerthiprashanth 1 3,059 Aug-08-2019, 02:35 PM
Last Post: keerthiprashanth
  syntax error near unexpected token btom529 5 14,508 Apr-21-2019, 09:03 PM
Last Post: btom529
  tweepy:invalid or expired token weareux 2 8,010 Dec-03-2017, 07:27 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020