format discs.
Taka
taka at net.hr
Wed Jul 9 10:37:03 EDT 2003
On Wed, 09 Jul 2003 15:00:33 +0200, Gerhard Häring wrote:
> Taka wrote:
>> On Wed, 09 Jul 2003 06:26:38 +0000, Flanagan wrote:
>>>hello to all
>>>
>>>somebody can say to me whereupon I modulate of python I can format
>>>discs.
>>>
>>>
>>>thanks flanagan
>>
>> Let's presume you want to format a unix partition and that it is
>> /dev/hda1.
>> The do this:
>>
>> #!/bin/python
>>
>> import os
>> partition = open ('/dev/hda1', 'w')
>>
>> for x in range(os.path.getsize('/dev/hda1'):
>> partition.write ('0')
>>
>> partition.close()
>>
>>
>> :)
>
> Didn't you mean ;-) instead of :) ?
>
> Your approach is hard to beat in inefficiency.
>
> -- Gerhard
Yes, but since file partitions are usualy bigger than your physical RAM,
you cannot do
import string
partition.write (string.zfill('0', partition.getsize('/dev/hda10')-1)
More information about the Python-list
mailing list