Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - what does this mean....?

 
Thread Tools Search this Thread
Old 02-28-2009, 05:17 AM   #1
Default what does this mean....?


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



zaheer.agadi@gmail.com
  Reply With Quote
Old 02-28-2009, 05:50 AM   #2
John Machin
 
Posts: n/a
Default Re: what does this mean....?
On Feb 28, 4:17*pm, zaheer.ag...@gmail.com wrote:
> 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
| >>>


John Machin
  Reply With Quote
Old 02-28-2009, 06:44 AM   #3
zaheer.agadi@gmail.com
 
Posts: n/a
Default Re: what does this mean....?
On Feb 28, 10:50 am, "Rhodri James" <rho...@wildebst.demon.co.uk>
wrote:
> On Sat, 28 Feb 2009 05:17:41 -0000, <zaheer.ag...@gmail.com> wrote:
> > 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 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.
>
> --
> Rhodri James *-* Wildebeeste Herder to the Masses


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



zaheer.agadi@gmail.com
  Reply With Quote
Old 02-28-2009, 08:31 AM   #4
Gabriel Genellina
 
Posts: n/a
Default Re: what does this mean....?
En Sat, 28 Feb 2009 04:44:28 -0200, <> escribió:

> 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

--
Gabriel Genellina



Gabriel Genellina
  Reply With Quote
Old 02-28-2009, 09:13 AM   #5
zaheer.agadi@gmail.com
 
Posts: n/a
Default Re: what does this mean....?
On Feb 28, 1:50 pm, Ben Finney <bignose+hates-s...@benfinney.id.au>
wrote:
> "Gabriel Genellina" <gagsl-...@yahoo.com.ar> writes:
> > En Sat, 28 Feb 2009 04:44:28 -0200, <zaheer.ag...@gmail.com> escribió:

>
> > > One question off the topic.,

>
> > Usually it's better to post a separate message.

>
> 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.


zaheer.agadi@gmail.com
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46