Counter to track success/failure rates [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
1
down vote

favorite












I am iterating over folders and files trying to fix the lines. After each folder or file, I'd like to print how many times the code fixed/failed/skipped the lines inside.



Here is a working solution:



from collections import Counter

class AttemptCounter:
def __init__(self):
self.fixed, self.failed, self.skipped = Counter(), Counter(), Counter()

def fixed(self, items):
self.fixed.update(items)

def failed(self, items):
self.failed.update(items)

def skipped(self, items):
self.skipped.update(items)

def show(self, name):
return f'self.fixed[name] fixed, '
f'self.failed[name] failed, '
f'self.skipped[name] skipped.'


After each line I call one of the fixed/failed/skipped methods with argument [file_name, folder_name] and afterwards I call either show(file_name) or show(folder_name).



I feel that there has to be a cleaner solution for this. Could you help?







share|improve this question













closed as off-topic by jonrsharpe, t3chb0t, Stephen Rauch, Dannnno, Daniel Jun 10 at 16:44


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – jonrsharpe, t3chb0t, Dannnno, Daniel
If this question can be reworded to fit the rules in the help center, please edit the question.












  • Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
    – jonrsharpe
    Jun 9 at 12:06











  • @jonrsharpe I get no error when running it?
    – esote
    Jun 9 at 13:54










  • @esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
    – jonrsharpe
    Jun 9 at 14:03










  • @jonrsharpe Thanks for clarifying.
    – esote
    Jun 9 at 14:16







  • 1




    We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
    – jonrsharpe
    Jun 9 at 20:30

















up vote
1
down vote

favorite












I am iterating over folders and files trying to fix the lines. After each folder or file, I'd like to print how many times the code fixed/failed/skipped the lines inside.



Here is a working solution:



from collections import Counter

class AttemptCounter:
def __init__(self):
self.fixed, self.failed, self.skipped = Counter(), Counter(), Counter()

def fixed(self, items):
self.fixed.update(items)

def failed(self, items):
self.failed.update(items)

def skipped(self, items):
self.skipped.update(items)

def show(self, name):
return f'self.fixed[name] fixed, '
f'self.failed[name] failed, '
f'self.skipped[name] skipped.'


After each line I call one of the fixed/failed/skipped methods with argument [file_name, folder_name] and afterwards I call either show(file_name) or show(folder_name).



I feel that there has to be a cleaner solution for this. Could you help?







share|improve this question













closed as off-topic by jonrsharpe, t3chb0t, Stephen Rauch, Dannnno, Daniel Jun 10 at 16:44


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – jonrsharpe, t3chb0t, Dannnno, Daniel
If this question can be reworded to fit the rules in the help center, please edit the question.












  • Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
    – jonrsharpe
    Jun 9 at 12:06











  • @jonrsharpe I get no error when running it?
    – esote
    Jun 9 at 13:54










  • @esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
    – jonrsharpe
    Jun 9 at 14:03










  • @jonrsharpe Thanks for clarifying.
    – esote
    Jun 9 at 14:16







  • 1




    We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
    – jonrsharpe
    Jun 9 at 20:30













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am iterating over folders and files trying to fix the lines. After each folder or file, I'd like to print how many times the code fixed/failed/skipped the lines inside.



Here is a working solution:



from collections import Counter

class AttemptCounter:
def __init__(self):
self.fixed, self.failed, self.skipped = Counter(), Counter(), Counter()

def fixed(self, items):
self.fixed.update(items)

def failed(self, items):
self.failed.update(items)

def skipped(self, items):
self.skipped.update(items)

def show(self, name):
return f'self.fixed[name] fixed, '
f'self.failed[name] failed, '
f'self.skipped[name] skipped.'


After each line I call one of the fixed/failed/skipped methods with argument [file_name, folder_name] and afterwards I call either show(file_name) or show(folder_name).



I feel that there has to be a cleaner solution for this. Could you help?







share|improve this question













I am iterating over folders and files trying to fix the lines. After each folder or file, I'd like to print how many times the code fixed/failed/skipped the lines inside.



Here is a working solution:



from collections import Counter

class AttemptCounter:
def __init__(self):
self.fixed, self.failed, self.skipped = Counter(), Counter(), Counter()

def fixed(self, items):
self.fixed.update(items)

def failed(self, items):
self.failed.update(items)

def skipped(self, items):
self.skipped.update(items)

def show(self, name):
return f'self.fixed[name] fixed, '
f'self.failed[name] failed, '
f'self.skipped[name] skipped.'


After each line I call one of the fixed/failed/skipped methods with argument [file_name, folder_name] and afterwards I call either show(file_name) or show(folder_name).



I feel that there has to be a cleaner solution for this. Could you help?









share|improve this question












share|improve this question




share|improve this question








edited Jun 9 at 12:06









jonrsharpe

12.8k12554




12.8k12554









asked Jun 9 at 9:29









Pranasas

1092




1092




closed as off-topic by jonrsharpe, t3chb0t, Stephen Rauch, Dannnno, Daniel Jun 10 at 16:44


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – jonrsharpe, t3chb0t, Dannnno, Daniel
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by jonrsharpe, t3chb0t, Stephen Rauch, Dannnno, Daniel Jun 10 at 16:44


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – jonrsharpe, t3chb0t, Dannnno, Daniel
If this question can be reworded to fit the rules in the help center, please edit the question.











  • Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
    – jonrsharpe
    Jun 9 at 12:06











  • @jonrsharpe I get no error when running it?
    – esote
    Jun 9 at 13:54










  • @esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
    – jonrsharpe
    Jun 9 at 14:03










  • @jonrsharpe Thanks for clarifying.
    – esote
    Jun 9 at 14:16







  • 1




    We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
    – jonrsharpe
    Jun 9 at 20:30

















  • Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
    – jonrsharpe
    Jun 9 at 12:06











  • @jonrsharpe I get no error when running it?
    – esote
    Jun 9 at 13:54










  • @esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
    – jonrsharpe
    Jun 9 at 14:03










  • @jonrsharpe Thanks for clarifying.
    – esote
    Jun 9 at 14:16







  • 1




    We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
    – jonrsharpe
    Jun 9 at 20:30
















Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
– jonrsharpe
Jun 9 at 12:06





Is that your actual code? Because you seem to have attributes with the same name as methods, so I'd expect TypeError: 'Counter' object is not callable.
– jonrsharpe
Jun 9 at 12:06













@jonrsharpe I get no error when running it?
– esote
Jun 9 at 13:54




@jonrsharpe I get no error when running it?
– esote
Jun 9 at 13:54












@esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
– jonrsharpe
Jun 9 at 14:03




@esote it will run just fine, until you instantiate the class and try to call a method that just got shadowed with a Counter in __init__.
– jonrsharpe
Jun 9 at 14:03












@jonrsharpe Thanks for clarifying.
– esote
Jun 9 at 14:16





@jonrsharpe Thanks for clarifying.
– esote
Jun 9 at 14:16





1




1




We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
– jonrsharpe
Jun 9 at 20:30





We're not here to review ideas of code, but actual implementations. Please review to ensure the code actually does what you say then edit accordingly. Also: what concerns you about the current code, how do you think it could be "cleaner"?
– jonrsharpe
Jun 9 at 20:30
















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Greedy Best First Search implementation in Rust

Function to Return a JSON Like Objects Using VBA Collections and Arrays

C++11 CLH Lock Implementation