Python Forum
yet another code that works on 2 but not in 3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
yet another code that works on 2 but not in 3
#1
Hi all
sorry for bothering with a similar problem but this time the trick Gribouillis gave me does not
work. The code below sends the input to a process created with subporcess.call() using a file descriptor generated with os.pipe(). It works with python 2 but not with python 3 and this time
including "os.set_inheritable(r,True)" does not work, i.e. the subprocess does not receive the input.

Any ideas

thanks in advance

import subprocess as sp


(r,w) = os.pipe()
#os.set_inheritable(r,True)

pipe = os.fdopen(w, 'w', -1)

pipe.write('title "TEST"\n')
pipe.flush()

f=sp.call(['xmgrace','-dpipe',repr(r),])
Reply
#2
Have you tried the -pipe option to read data from stdin or -npipe to read data from a named pipe as indicated in the man page?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 989 Nov-15-2023, 06:56 PM
Last Post: jst
  Code works but doesn't give the right results colin_dent 2 710 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Code used to work 100%, now sometimes works! muzicman0 5 1,427 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  Pyspark - my code works but I want to make it better Kevin 1 1,779 Dec-01-2021, 05:04 AM
Last Post: Kevin
Question email code works in 2.7 but not in 3 micksulley 3 2,567 Nov-04-2021, 09:44 PM
Last Post: micksulley
  My simple code don't works !! Nabi666 1 1,601 Sep-06-2021, 12:10 PM
Last Post: jefsummers
  HackerRank Problem: Code works on VS Code but not on the HackerRank site Pnerd 3 2,636 Feb-28-2021, 07:12 PM
Last Post: Pnerd
Question Google Foobar- Code works in my IDE but not in foobar. Static method? pr3ttykitty 4 4,940 Feb-24-2021, 05:03 PM
Last Post: nilamo
  Code that works on py2 and not in py3 rick666 3 2,846 Nov-29-2019, 01:37 PM
Last Post: rick666
  Simple code works in Jupyter but not VS Code Matt_O 2 3,923 Nov-17-2019, 01:15 AM
Last Post: Matt_O

Forum Jump:

User Panel Messages

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