what does this mean....?

Z

zaheer.agadi

I am trying to download a file from the server, I am getting this
error,what does this mean

localFile = open(localFileName, 'wb')
TypeError: coercing to Unicode: need string or buffer, type found
 
J

John Machin

I am trying to download a file from the server, I am getting this
error,what does this mean

   localFile = open(localFileName, 'wb')
TypeError: coercing to Unicode: need string or buffer, type found

the name localFileName is bound to a type ... and of course it's
expecting a string.

You must have done something weird with localFileName, like this:

| >>> fname = type(2)
| >>> fname
| <type 'int'>
| >>> f = open(fname)
| Traceback (most recent call last):
| File "<stdin>", line 1, in <module>
| TypeError: coercing to Unicode: need string or buffer, type found
| >>>
 
Z

zaheer.agadi

The rest of the traceback and enough of your code to make sense of
it would have helped. Without context, my best guess is that
"localFileName" isn't actually a string.

Ohh thats my bad, I was actually passing a file type instead of
string,thanks a lot .
One question off the topic.,
How to create a .pyz file. I have python project that has some modules
in it , I want to create a zip file so that I can use it as we use
java jar file
Like I want to do a
mypyFiles.pyz --sendFile C:\\testFile
I currently have a module that does this when run as single python
module, but I want to do same this using a zip file which will have
some other modules within it.

Any help..?

Thanks
 
G

Gabriel Genellina

One question off the topic.,

Usually it's better to post a separate message.
How to create a .pyz file. I have python project that has some modules
in it , I want to create a zip file so that I can use it as we use
java jar file
Like I want to do a
mypyFiles.pyz --sendFile C:\\testFile
I currently have a module that does this when run as single python
module, but I want to do same this using a zip file which will have
some other modules within it.

Just put all your modules inside the zip, and create a __main__.py file.
Execute it using:

python foo.zip

See http://docs.python.org/using/cmdline.html#command-line
 
Z

zaheer.agadi

More specifically (and I only say this because many people seem not to
observe the distinction), when starting an entirely new topic of
discussion, you should not reply to an existing message since it's
then confusingly related with the same thread; instead, compose a
*new* message with the appropriate subject.

--
\ “Either he's dead or my watch has stopped.” —Groucho Marx |
`\ |
_o__) |
Ben Finney

I agree I should have posted a new topic, Point taken..
Thanks Gabriel ,I will try this if could not get this to work will
post a new thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top