python父类中调用子类方法_python中父类能调用子类的方法?

<< (i*

return result

def readBytesAsInt(self, numBytes) :

result = 0

bytes = self.readSignedBytes(numBytes)

if len(bytes) == numBytes :

for i in range(numBytes) :

result |= bytes<< (i*

return result

def skipPadding(self) :

result = 0

if self.bytesRead % 4 != 0 :

paddingLength = 4 - self.bytesRead % 4

self.readPlainBytes(paddingLength)

result = paddingLength

return result

class SISFileReader(SISReader) :

def __init__(self, inStream) :

self.inStream = inStream

self.eof = False

self.bytesRead = 0

def readPlainBytes(self, numBytes) :

if self.eof :

return ""

if numBytes == 0 :

return ""

buf = ""

buf = self.inStream.read(numBytes)

if len(buf) < numBytes :

self.eof = True

return ""

self.bytesRead += numBytes

return buf

def isEof(self) :

return self.eof

class SISBufferReader(SISReader) :

def __init__(self, buffer) :

self.buffer = buffer

self.bytesRead = 0

def readPlainBytes(self, numBytes) :

if self.isEof() :

return ""

if numBytes == 0 :

return ""

result = self.buffer[self.bytesRead:self.bytesRead+numBytes]

self.bytesRead += numBytes

return result

def isEof(self) :

return self.bytesRead >= len(self.buffer)

class SISFieldParser :

def __init__(self) :

self.lastReadBytes = 0

def parseField(self, fileReader) :

"""Reads the next field from the fileReader stream and returns it"""

field = None

self.lastReadBytes = 0

type = fileReader.readBytesAsUint(4)

self.lastReadBytes += 4

if type != 0 :

field = sisfields.SISFieldTypes[type]()

field.type = type

field.initFromFile(fileReader)

self.lastReadBytes += field.length + 4 # Field length + length field

self.lastReadBytes += fileReader.skipPadding()

return field

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值