[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

RE: piping into a python script

Reedick, Andrew

1/24/2008 6:25:00 PM

> -----Original Message-----
> From: python-list-bounces+jr9445=att.com@python.org [mailto:python-
> list-bounces+jr9445=att.com@python.org] On Behalf Of Donn
> Sent: Thursday, January 24, 2008 12:03 PM
> To: Michal Bentkowski
> Cc: python-list@python.org
> Subject: Re: piping into a python script
>
> I have tested getopt and it strips the lone '-' out. I can get it from

Try 'foo.py -- -'. The '--' normally tells the parser to stop parsing args. Ex: date > -foo.txt; rm -foo.txt; rm -- -foo.txt


I think this will tell you if stdin is being piped in or not:
import sys
import os
print os.isatty(sys.stdin.fileno())

D:\>type a.txt | python a.py
False

D:\>python a.py
True


Also if you're lazy, look at the StringIO class:

if options.filelist is None and len(args) < 1: # read from stdin
f = sys.stdin
elif options.filelist is not None and len(args) < 1: # read filenames from file
f = open(options.filelist, 'r')
elif options.filelist is None and len(args) > 0: # filenames on command line
f = StringIO.StringIO('\n'.join(args))
else: ## Thanks for playing.
parser.print_help()
exit(1)

if f:
for filename in f:



> -- Segio Aragones (Groo the Wanderer Number 99)

Ah yes, Groo. Ever wonder who would win if Groo and Forrest Gump fought each other?



1 Answer

Gray Ghost

7/26/2014 3:44:00 PM

0

GOP_Decline_and_Fall <Dev@null.net> wrote in
news:nrg7t9pq93fcqhf7s6ttal5c1r3o04o6ic@4ax.com:

> On Sat, 26 Jul 2014 14:54:56 +0000 (UTC), Thomas Paine
><grey_ghost471-newsgroups@yahoo.com> wrote:
>
>>GOP_Decline_and_Fall <Dev@null.net> wrote in
>>news:gse7t99vf3cmvbjsf873ds9s6ioiu7g8ce@4ax.com:
>>
>>> On Sat, 26 Jul 2014 13:59:30 +0000 (UTC), Thomas Paine
>>><grey_ghost471-newsgroups@yahoo.com> wrote:
>>>
>>>>GOP_Decline_and_Fall <Dev@null.net> wrote in
>>>>news:uhd6t957c9atoohncqgqnnoc598kcj2k9u@4ax.com:
>>>>
>>>>> On Sat, 26 Jul 2014 02:38:41 +0000 (UTC), Thomas Paine
>>>>><grey_ghost471-newsgroups@yahoo.com> wrote:
>>>>>
>>>>>>Mitchell Holman <nomail@att.net> wrote in
>>>>>>news:XnsA375A2F962B5Cnomailattnet@216.196.121.131:
>>>>>>
>>>>>>> Thomas Paine <grey_ghost471-newsgroups@yahoo.com> wrote in
>>>>>>> news:XnsA375681513376Wereofftoseethewizrd@78.46.70.116:
>>>>>>>
>>>>>>>> GOP_Decline_and_Fall <Dev@null.net> wrote in
>>>>>>>> news:kie2t9l9skfvri9akqjnm3mvlsdo6bmbfp@4ax.com:
>>>>>>>>
>>>>>>>>> Obviously you are still clueless as to how much Bush lied.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Fantasize much?
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Bush was telling the truth about where
>>>>>>> he got his foreign policy?
>>>>>>>
>>>>>>>
>>>>>>> "God told me to strike at al Qaida and
>>>>>>> I struck them, and then He instructed me to
>>>>>>> strike at Saddam, which I did"
>>>>>>> George Bush, June 20, 2003
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>Yeah and exactly where is the confirmation of that fact? Because it
>>>>>>isn't independently quoted and attributed to Bush anywhere.
>>>>>
>>>>>
>>>>> http://www.haaretz.com/print-edition/news/road-map-is-a-lif...
>>>>> r-
>>us
>>>>> -pm-abbas-tells-hamas-1.92200
>>>>>
>>>>> Abbas said that at Aqaba, Bush promised to speak with Sharon about
>>>>> the siege on Arafat. He said nobody can speak to or pressure Sharon
>>>>> except the Americans.
>>>>>
>>>>> According to Abbas, immediately thereafter Bush said: "God told me
>>>>> to strike at al Qaida and I struck them, and then he instructed me
>>>>> to strike at Saddam, which I did, and now I am determined to solve
>>>>> the problem in the Middle East. If you help me I will act, and if
>>>>> not, the elections will come and I will have to focus on them."
>>>>>
>>>>
>>>>Abbas is your source? You should be killed for spreading enemy
>>propaganda.
>>>
>>> Enemy?
>>>
>>> What a sad political illiterate you are.
>>>
>>> Since when is the US at war with the Palestinian Authority and the
>>> Secretary of State's peace partner?
>>>
>>> Even Israel doesn't classify Abbas as an enemy.
>>>
>>
>>Yes stupid. People that launch missiles deliberately at civilians and
>>whose sole purpose seems to be completing the Nazi extermination of Jews
>>is an enemy of civilization and polite and civil society. And those that
>>don't understand that are to sick to cure.
>
> You are hopelessly ignorant and confused.
>
> Holocaust 'most heinous crime' of modern history, says Mahmoud Abbas
>
> http://www.theguardian.com/world/2014/apr/27/holocaust-crime-pa...
> president-mahmoud-abbas
>
> The Palestinian president, Mahmoud Abbas, has called the Holocaust the
> most heinous crime in modern history , in a rare acknowledgement by an
> Arab leader of Jewish suffering during the Nazi genocide as Israel
> began its annual commemoration of the event.
>
> In a statement published in English, Spanish and Arabic on Wafa,
> Palestine's official news agency, Abbas expressed sympathy with the
> families of the Jewish victims and other victims of the Nazis.
>
> "The Holocaust is a reflection of the concept of ethnic discrimination
> and racism which the Palestinians strongly reject and act against,"
> said Abbas, describing Nazi atrocities as "the most heinous crime to
> have occurred against humanity in the modern era". He added: "The
> world must do its utmost to fight racism and injustice in order to
> bring justice and equality to oppressed people wherever they are."
>
>
> http://www.haaretz.com/news/diplomacy-defens...
>
> In Ramallah, following a meeting of just over an hour with Palestinian
> President Mahmoud Abbas, Kerry said the limited progress was gained in
> the last 24 hours and pledged to continue working on the cease-fire
> when he returns to Cairo late Wednesday night.
>
> "We're doing this for one simple reason: the people in the Palestinian
> territories, the people in Israel, are all living under the threat or
> reality of immediate violence," Kerry told reporters outside Abbas'
> office. "And this needs to end, for everybody. We need to find a way
> forward that works. And it's not violence."
>
> Abbas made no public statements during Kerry's visit to Ramallah.
>

Then why doesn't he exterminate HAMAS?

--
When the government is no longer constrained by the laws of the land, then
neither are the people.