471,055 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

Hexbin

Hi,

Im a newcomer to Python and I've got some error that I totaly dont
understand.

I've made a program that is made to extract a couple of binhex files.

Here is my sourccode:

import binhex, os
current = os.getcwd() #Gets current cwd
files = os.path.join(current, "files") #joins current path with path
files
for filename in os.listdir(files): #checks every file in DIR: files
os.chdir(files) #changes dir 2 files
file2 = win32file.CreateFile(filename, win32file.GENERIC_READ, \
0, None, win32file.OPEN_EXISTING, 0, None ) #opens hexbin file
filename2 = filename+".exe" #changes filename to .exe extention
binhex.HexBin(file2, filename2) #translate hexed file 2 binary

If I run this one, an exeption is raised:

Traceback (most recent call last):
File
"C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 407, in ImportFile
exec codeObj in __main__.__dict__
File "<auto import>", line 1, in ?
File "C:\WINDOWS\temp123\Stuf\all2.py", line 9, in ?
binhex.HexBin(file2, filename2) #translate hexed file 2 binary
TypeError: __init__() takes exactly 2 arguments (3 given)

I've got only 2 arguments, but python thinks I've got there 3...

Can anybody help me? (maybe its a stupid question but i'm only a newbie =) )
I'm running on Win XP Home
Jul 18 '05 #1
1 2578
MaximusBrood wrote:
Im a newcomer to Python and I've got some error that I totaly dont
understand. [...] If I run this one, an exeption is raised:

Traceback (most recent call last):
File
"C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" ,
line 407, in ImportFile
exec codeObj in __main__.__dict__
File "<auto import>", line 1, in ?
File "C:\WINDOWS\temp123\Stuf\all2.py", line 9, in ?
binhex.HexBin(file2, filename2) #translate hexed file 2 binary
TypeError: __init__() takes exactly 2 arguments (3 given)

I've got only 2 arguments, but python thinks I've got there 3...


Here's my quickie response, since I don't see that anyone else
has tried to reply as of yet. If this doesn't do it, I can
look into it further tomorrow.

The definition of __init__ always looks like this:

def __init__(self, ...):

where ... represents zero or more arguments. Note that the
"self" argument counts as one for purposes of the error message,
so if it says it wants exactly two arguments, that means it
really wants only one argument in addition to self.

I don't know what binhex.HexBin() looks like, but it appears to
be different than what you think. Taking a look at the source
in python/lib/binhex.py might help you... find the __init__
method for class HexBin and you may solve your own problem
once you learn what the one non-self argument is expected
to be.

Also checking the docs again might clear things up for you now.

-Peter
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.