It would help to know why you chose to pipe data into the script rather than having the script get the data. Are you going to pipe the output of other programs into it, or is that just the way you knew how to pass data to a script?
If it's not something you intend to regularly pipe into then you'd be better off passing the file name as an argument like this.
Code:
import sys
def get_file( file_name ):
f = open( file_name, "r")
file_buffer = f.read()
f.close()
return file_buffer
def your_function( buffer ):
# your code goes here
def main():
file_name = sys.argv[1]
buffer = get_file( file_name )
your_function( buffer )
main()
That way you can do this.
Code:
> myscript.py <filename>
Bookmarks