2

I am having problems with a class called LatencyList.

The complete code can be found here: http://pastebin.com/b5bemMsW

In this Class I have 2 method that dont need to reference to the object (self) but I can't remove the "self" parameter without making fail the DocTest:

def crop_latencies(self, lat_list):
    """
    Return "lat_list" with only latencies (exclude all None(s) that mean PacketLoss)
    """
    cropped_list = []
    for latency in lat_list:
        if latency is not None:
            cropped_list.append(latency)
    return cropped_list

def count_packetlost(self, lat_list):
    """
    Return None(packetloss) counts in "lat_list"
    """
    counter = 0
    for latency in lat_list:
        if latency is None:
            counter += 1
    return counter

Here the errors during DocTest if i try to remove the "self" parameter: http://pastebin.com/mm8YgRSM

What am I doing wrong?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
lomiz
  • 23
  • 3

1 Answers1

0

Try to use @staticmethod in front of your function declaration.

class A:
    def a_method(self):
        pass

    @staticmethod
    def a_static_method():
        pass

Visit LINK for more.

Community
  • 1
  • 1
moep moep
  • 63
  • 7