Oct-10-2024, 08:38 PM
I have a binary file being read from, but unfortunately the file object has no tell method.
As an example, assume the following shell command is run:
echo "abcdefghijklmnopqrstuvxyz" > foo.txt
The following are python commands and their output:
>>> f = open('foo.txt', 'rb')
>>> f.read(3)
b'abc'
>>> f.tell()
3
>>> f.seek(0, 1)
3
>>> f.read()
b'defghijklmnopqrstuvxyz\n'
>>> f.close()
If looks like tell() and seek(0, 1) return the same value. Am I missing something, or am I spot on?
The reason for this is my use of the wav module while trying to concatenate .wav files. When I get to the point were it calls the tell() function the following message is displayed:
AttributeError: 'WindowsPath' object has no attribute 'tell'
I can override the method that that package's calls to tell() to instead call a method that returns seel(0, 1).
As an example, assume the following shell command is run:
echo "abcdefghijklmnopqrstuvxyz" > foo.txt
The following are python commands and their output:
>>> f = open('foo.txt', 'rb')
>>> f.read(3)
b'abc'
>>> f.tell()
3
>>> f.seek(0, 1)
3
>>> f.read()
b'defghijklmnopqrstuvxyz\n'
>>> f.close()
If looks like tell() and seek(0, 1) return the same value. Am I missing something, or am I spot on?
The reason for this is my use of the wav module while trying to concatenate .wav files. When I get to the point were it calls the tell() function the following message is displayed:
AttributeError: 'WindowsPath' object has no attribute 'tell'
I can override the method that that package's calls to tell() to instead call a method that returns seel(0, 1).