Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18702

Re: [BangPypers] re module help

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <noufal@nibrahim.net.in>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.02; 'to:name:bangalore python users group - india': 0.03; 'subject:module': 0.04; 'subject:BangPypers': 0.07; 'subprocess': 0.09; 'url:nibrahim': 0.09; '~noufal': 0.09; 'output': 0.10; 'subject:] ': 0.14; 'guys,': 0.16; 'localhost': 0.16; 'stdout': 0.16; 'stream.': 0.16; 'cc:addr:python-list': 0.16; 'to:addr:bangpypers': 0.17; '>>>': 0.18; 'sfxlen:2': 0.19; 'cc:no real name:2**0': 0.20; 'subject:help': 0.21; 'result.': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'creating': 0.25; 'writes:': 0.25; 'module': 0.26; 'import': 0.27; 'tried': 0.27; 'print': 0.29; 'cc:addr:python.org': 0.29; 'from:addr:noufal': 0.30; 'from:name:noufal ibrahim': 0.30; 'modules,': 0.30; "didn't": 0.31; 'header:User-Agent:1': 0.33; 'url:in': 0.33; 'match': 0.34; 'parse': 0.34; 'external': 0.35; 'regular': 0.35; 'file': 0.36; 'charset:us-ascii': 0.37; 'skip:" 10': 0.37; 'but': 0.37; 'created': 0.38; 'should': 0.39; 'to:addr:python.org': 0.40; 'url:net': 0.60; 'your': 0.61; 'received:122': 0.67; '127.0.0.1': 0.84; 'commands.': 0.84; 'received:122.172': 0.93
From Noufal Ibrahim <noufal@nibrahim.net.in>
To Bangalore Python Users Group - India <bangpypers@python.org>
Subject Re: [BangPypers] re module help
References <CAJzooYf1F6qavSyuQtvO6eMjDOSq2dzdTqLiTmng3cAn2JLYzg@mail.gmail.com>
Date Mon, 09 Jan 2012 14:45:33 +0530
In-Reply-To <CAJzooYf1F6qavSyuQtvO6eMjDOSq2dzdTqLiTmng3cAn2JLYzg@mail.gmail.com> (Ganesh Kumar's message of "Mon, 9 Jan 2012 14:41:21 +0530")
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4543.1326100744.27778.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326100744 news.xs4all.nl 6943 [2001:888:2000:d::a6]:59152
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:18702

Show key headers only | View raw


Ganesh Kumar <bugcy013@gmail.com> writes:

> Hi Guys,
>
> I have created regular expression with os modules, I have created file
> sdptool to match the regular expression pattern, will print the result.
> I want without creating file how to get required output, I tried but i
> didn't get output correctly, over stream.

You should use the subprocess module to deal with external commands.

>>> import subprocess
>>> s = subprocess.Popen(["head", "/etc/hosts"], stdout = subprocess.PIPE)
>>> hosts_head = s.stdout.read()
>>> print hosts_head
127.0.0.1       localhost

[...]

Use that get your output and then parse it with the regexp.


-- 
~noufal
http://nibrahim.net.in

The best cure for insomnia is to get a lot of sleep. -W. C. Fields

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [BangPypers] re module help Noufal Ibrahim <noufal@nibrahim.net.in> - 2012-01-09 14:45 +0530

csiph-web