Python Forum
different baviour in script vs shell session
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
different baviour in script vs shell session
#1
Hi folks

I am new to python world

I recently wrote a little script to process system Verilog file, repair syntax violations, by regular expression matching

fixFileInFileList.py -i inp0 inp1 inp2

the matching strings were inputted in inp1:
('\S+\.h', '\S+\.H')
By the way, I tried square parenthesis also

That should interpreted as two elements list:
>>> excpType1 = ('\S+\.h' '\S+\.H')
>>> print(str(len(excpType1)))
12
>>> excpType1 = ('\S+\.h', '\S+\.H')
>>> print(str(len(excpType1)))
2
But in the program I placed print statement revealed totally unexpected results:
                  print(excpType1+str(len(excpType1)))
                  print(excpType1)
                  print(excpType1[einx])
yielded:
Output:
('\S+\.h', '\S+\.H')20 ('\S+\.h', '\S+\.H') ( In case of square parenthesis: ['\S+\.h', '\S+\.H']20 ['\S+\.h', '\S+\.H'] [
I am struggling for a few days now, please help,
What did I do wrong?
Why script functioned differently versus interpreter run, I even uses the same imports with script?
Or a different implementation to do the same thing?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 3,579 May-17-2021, 11:29 AM
Last Post: throwaway34
  win32 API: Launch Application to RDP session from background process python script rangeshgupta 0 2,136 May-28-2020, 09:41 PM
Last Post: rangeshgupta
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,288 May-28-2020, 05:27 PM
Last Post: micseydel
  running python script from shell invoked with os.system("x-terminal-emulator -e /bin/ markhaus 2 3,069 Feb-21-2019, 11:55 PM
Last Post: markhaus
  using a shell script within python Krszt 2 3,165 Oct-10-2018, 11:00 AM
Last Post: snippsat
  shell script inside python pannis 6 4,274 Sep-05-2018, 06:05 AM
Last Post: pannis
  Powershell Session translation to Python; Session code seems to not work Maverick494 1 3,594 Jun-26-2018, 05:16 PM
Last Post: Maverick494
  Collect logs for a function in python using shell script viru 1 3,788 Aug-28-2017, 07:54 PM
Last Post: nilamo
  Run python script in RPi2 from ssh session marciokoko 5 5,017 Jan-23-2017, 09:53 PM
Last Post: marciokoko

Forum Jump:

User Panel Messages

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