0

I have the following codes:

class Solution:
    def three_sum(self, nums: List[int]) -> List[List[int]]:
        nums.sort()
        output_set: set = set() #Notice 
        if len(nums) < 3:
            return []

        for i in range(len(nums)-2): #at least 2 element left
            sub_nums = nums[i+1:]
            sub_target = 0 - nums[i]
            logging.warning(f"sub_target: {sub_target}")

            two_sum_output = self.two_sum(sub_nums, sub_target)
            logging.warning(f"two_sum_output: {two_sum_output}")
            if two_sum_output != None:
                temp = { (nums[i],) + tuple(l) for l in two_sum_output }
                output_set.update(temp)
        output = [ list(t) for t in output_set] #conver to list
        logging.warning(f"final output count: {len(output)}:\n {output}")

        return output 

I want to delete lines with logging,

grep could them

$ grep "logging" twoSum.py 
import logging
# logging.disable(level=CRITICAL)
logging.basicConfig(level=logging.debug, 
logging.info(f"Start of twoSum Process {os.getpid()}")
# logging.debug(f"{ps.stdout.decode('utf-8')}")
            logging.info(f'find: {find} ')
            logging.info(f"j: {j}")

How could delete them?

pa4080
  • 29,831
Alice
  • 1,710
  • 2
    Beware that the line containing basicConfig seems to continue on the next line and removing just the first line probably brakes your code. – PerlDuck Mar 21 '19 at 16:43

1 Answers1

3

use grep -v and copy to another file

grep -v logging twoSum.py > logging-new

Notes:

  • this does what you ask for, removing the physical lines containing "logging". That might be a bad idea, as noted by PerlDuck
  • if there is no space or strange char in the grepped text, you don't need " or '.
wjandrea
  • 14,236
  • 4
  • 48
  • 98
Fibo
  • 56