Re: Regex to extract multiple fields in the same line

2018-06-15 Thread Nathan Hilterbrand
On Wed, Jun 13, 2018 at 4:08 AM, Ganesh Pal wrote: > Hi Team, > > I wanted to parse a file and extract few feilds that are present after "=" > in a text file . > > > Example , form the below line I need to extract the values present after > --struct =, --loc=, --size= and --log_file= > > Sample

Re: Fwd: Is there a function of ipaddress to get the subnet only from input like 192.168.1.129/25

2017-10-17 Thread Nathan Hilterbrand
Absolutely, Stefan! I like yours a lot better. I am an old perl hack that is still learning the ins and outs of Python, and this is just the sort of thing that I like to see. Thanks! On Tue, Oct 17, 2017 at 4:19 PM, Stefan Ram wrote: > Nathan Hilterbrand writes: > >I may have misu

Fwd: Is there a function of ipaddress to get the subnet only from input like 192.168.1.129/25

2017-10-17 Thread Nathan Hilterbrand
Hit wrong button before. -- Forwarded message -- From: Nathan Hilterbrand Date: Tue, Oct 17, 2017 at 2:22 PM Subject: Re: Is there a function of ipaddress to get the subnet only from input like 192.168.1.129/25 To: Rob Gaddi I may have misunderstood what you were looking for

Re: "comprehend" into a single value

2017-10-07 Thread Nathan Hilterbrand
dict= {10: ['a',1,'c'], 20: ['d',2,'f']} p = sum([dict[i][1] for i in dict]) Something like that? On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z wrote: > Hello, > i wonder how can i accomplish the following as a one liner: > > dict= {10: ['a',1,'c'], 20: ['d',2,'f']} > p = 0 > for i in dict: >

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Nathan Hilterbrand
On 05/07/2016 05:22 PM, Chris Angelico wrote: On Sun, May 8, 2016 at 5:17 AM, Christopher Reimer wrote: pylint. Never know when an asshat hiring manager would reject my resume out of hand because my code fell short with pylint. I see that as a good motivation to make sure your code was go

Re: Exception handling for socket.error in Python 3.5/RStudio

2016-02-05 Thread Nathan Hilterbrand
On Feb 5, 2016 15:01, wrote: > > I am running this python script on R-studio. I have Python 3.5 installed on my system. > > count = 10 > while (count > 0): > try : > # read line from file: > print(file.readline()) > # parse > parse_json(file.readline()) >

Re: Daemon strategy

2016-02-05 Thread Nathan Hilterbrand
On 02/05/2016 01:39 PM, paul.hermeneu...@gmail.com wrote: It appears that python-deamon would be exactly what I need. Alas, appears not to run on Windows. If I am wrong about that, please tell me. To what tools should I turn? I am not eager to produce a "service" on Windows unless it cannot b

Re: psss...I want to move from Perl to Python

2016-01-29 Thread Nathan Hilterbrand
On Fri, Jan 29, 2016 at 3:42 PM, Fillmore wrote: > > I actually have a few followup question. > > - will iNotebook also work in Python 3? > > - What version of Python 3 do you recommend I install on Windows? > > - Is Python 3 available also for CygWin? > > - I use Ubuntu at home. Will I be able t

Re: psss...I want to move from Perl to Python

2016-01-28 Thread Nathan Hilterbrand
On 01/28/2016 07:01 PM, Fillmore wrote: I learned myself Perl as a scripting language over two decades ago. All through this time, I would revert to it from time to time whenever I needed some text manipulation and data analysis script. My problem? maybe I am stupid, but each time I have t

Re: Powerful perl paradigm I don't find in python

2016-01-15 Thread Nathan Hilterbrand
On 01/15/2016 04:24 AM, Charles T. Smith wrote: while ($str != $tail) { $str ~= s/^(head-pattern)//; use ($1); } IDK... maybe the OP is looking for something like this? : import re def do_something(matchobj): print("I found {}".format(matchobj.group(0))) return "" tail =

Re: ignoring or replacing white lines in a diff

2016-01-14 Thread Nathan Hilterbrand
On 01/14/2016 03:22 PM, Adriaan Renting wrote: Maybe someone here has a clue what is going wrong here? Any help is appreciated. I'm writing a regression test for a module that generates XML. I'm using diff to compare the results with a pregenerated one from an earlier version. I'm running in

Re: Problem to read from array

2015-11-21 Thread Nathan Hilterbrand
On 11/21/2015 10:26 AM, BartC wrote: On 21/11/2015 10:41, vostrus...@gmail.com wrote: Hi, I have a file with one parameter per line: a1 b1 c1 a2 b2 c2 a3 b3 c3 ... The parameters are lines of characters (not numbers) I need to load it to 2D array for further manipulations. So far I managed to

Re: What is wrong in this example code?

2015-11-13 Thread Nathan Hilterbrand
On Thu, Nov 12, 2015 at 6:59 PM, Larry Hudson via Python-list < python-list@python.org> wrote: Nothing to do with your original question, just a trivial suggestion which > you are free to ignore. You can shorten this tick() method by using the > divmod() function. It does a division and returns