[Tutor] file open error
Bill Campbell
bill at celestial.net
Fri Feb 9 00:34:51 CET 2007
On Thu, Feb 08, 2007, Jalil wrote:
>
> Hey guys,
> I have this simple code and i cant seem to get it to run.
> here is the code.
> from os import *
> import re
> hostname =raw_input("Host name : ") or '<unknown>'
> mac_addr =input("Mac address : ")
> filename='/etc/dhcpd.conf'
> fh=open(filename)
> m = re.match(hostname,fh.readlines())
> if m!=None:
> m.group()
> Here is the error I get when i try to run the code
> monkeysee% python sys_wireless.py
> Host name :
> Mac address : 1234567
> Traceback (most recent call last):
> File "sys_wireless.py", line 8, in ?
> fh=open("/etc/dhcpd.conf","r")
> TypeError: an integer is required
> I dont know what the issue is?
> any hints ?
It appears to me that your ``from os import *'' is biting you in
the butt as the os.open command is being executed instead of the
normal open.
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
``Liberty don't work as good in practice as it does in speeches.''
Will Rogers
More information about the Tutor
mailing list