Python Forum
script closed before i can see the error that occurs?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
script closed before i can see the error that occurs?
#8
(Dec-01-2016, 11:04 PM)wrestlemy69 Wrote:  I do not understand what that line (19 and 23) does. Is there a program that translate code to English? lol.
Python has interactive interpreter where you can test stuff out.
Here i just paste in line 19.
>>> gameid = header[:6]
Traceback (most recent call last):
 File "<string>", line 301, in runcode
 File "<interactive input>", line 1, in <module>
NameError: name 'header' is not defined

#Fix it
>>> header = 'Hello world'
>>> gameid = header[:6]
>>> gameid
'Hello '

>>> header[6:11]
'world'
[:6] is Slice notation sequence[start:stop:step]

Line 23:
>>> import re 

>>> gameid = 'hello world'
>>> match = re.search(r'\w+', gameid)
>>> match 
<_sre.SRE_Match object; span=(0, 5), match='hello'>
>>> bool(match)
True
>>> if match:
...     print('if True i run')
...     
if True i run
It's a good tool to use,and you can use it when you study the basic of Python.
Reply


Messages In This Thread
RE: Script help - by micseydel - Dec-01-2016, 05:30 PM
RE: Script help - by wrestlemy69 - Dec-01-2016, 05:38 PM
RE: Script help - by nilamo - Dec-01-2016, 06:03 PM
RE: Script help - by snippsat - Dec-01-2016, 06:21 PM
RE: script closed before i can see the error that occurs? - by snippsat - Dec-01-2016, 11:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  This result object does not return rows. It has been closed automatically dawid294 6 1,400 Mar-30-2024, 03:08 AM
Last Post: NolaCuriel
  OSError occurs in Linux. anna17 2 419 Mar-23-2024, 10:00 PM
Last Post: snippsat
  A question about 'Event loop is closed' fc5igm 2 2,313 Oct-05-2021, 02:00 AM
Last Post: fc5igm
  ValueError: I/O operation on closed file problem aliwien 0 2,162 Apr-23-2021, 05:50 PM
Last Post: aliwien
  Run an app in a standalone terminal and wait until it's closed glestwid 2 2,588 Aug-30-2020, 08:14 AM
Last Post: glestwid
  how do i loop a "def ..." when error occurs? Stan2292 0 1,664 Aug-12-2019, 05:28 AM
Last Post: Stan2292
  Inclusive (closed) range with float numbers mapg 4 4,094 Apr-27-2019, 09:09 PM
Last Post: Gribouillis
  New df from existing when condition occurs Devilish 0 1,409 Jan-10-2019, 12:03 AM
Last Post: Devilish
  VMware View - Session opened/closed? hhh 0 2,370 May-31-2018, 10:10 AM
Last Post: hhh
  How to make Python stops for debugging when the error occurs? Tim 5 5,958 Feb-16-2018, 09:50 AM
Last Post: Tim

Forum Jump:

User Panel Messages

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