staticmethod def string flow length int join takewhile lambda flow str

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@staticmethod
def string(flow):
length = int(''.join(takewhile(lambda x: x != ':', flow)))
string = ''.join(islice(flow, length))
return string
-------------------------------------------------------------------------
static object String(BinaryReader flow)
{
List<byte> lengthBytes = new List<byte>();
while (true)
{
byte x = flow.ReadByte();
if (x == Tokens.Delimiter) break;
lengthBytes.Add(x);
}
string lengthString = Encoding.ASCII.GetString(lengthBytes.ToArray());
int length = int.Parse(lengthString);
byte[] result = new byte[length];
flow.Read(result, 0, length);
return result;
}
-------------------------------------------------------------------------
See the difference, feel the difference...