M BUZZ CRAZE NEWS
// news

Remove lines which contain 'logging' [duplicate]

By Emma Johnson

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?

1

1 Answer

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 '.