Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10261 > unrolled thread

Pipe in the "return" statement

Started byArchard Lias <archardlias@googlemail.com>
First post2011-07-25 05:00 -0700
Last post2011-07-26 11:22 -0400
Articles 20 on this page of 22 — 13 participants

Back to article view | Back to comp.lang.python


Contents

  Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 05:00 -0700
    Re: Pipe in the "return" statement Ian Collins <ian-news@hotmail.com> - 2011-07-26 00:03 +1200
      Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 07:16 -0700
        Re: Pipe in the "return" statement Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-25 10:31 -0400
          Re: Pipe in the "return" statement Ethan Furman <ethan@stoneleaf.us> - 2011-07-25 13:07 -0700
            Re: Pipe in the "return" statement Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-28 08:26 +0200
        Re: Pipe in the "return" statement Oliver Bestwalter <oliver@bestwalter.de> - 2011-07-25 16:35 +0200
          Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:05 -0700
        Re: Pipe in the "return" statement John Gordon <gordon@panix.com> - 2011-07-25 14:39 +0000
          Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:06 -0700
        Re: Pipe in the "return" statement gwowen <gwowen@gmail.com> - 2011-07-25 07:42 -0700
    Re: Pipe in the "return" statement Christian Heimes <lists@cheimes.de> - 2011-07-25 14:33 +0200
      Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 08:28 -0700
        Re: Pipe in the "return" statement Christian Heimes <lists@cheimes.de> - 2011-07-25 18:11 +0200
          Re: Pipe in the "return" statement Archard Lias <archardlias@googlemail.com> - 2011-07-25 09:30 -0700
    Re: Pipe in the "return" statement TonyO <guinness.tony@gmail.com> - 2011-07-25 05:52 -0700
      Re: Pipe in the "return" statement gwowen <gwowen@gmail.com> - 2011-07-25 06:00 -0700
      Re: Pipe in the "return" statement red floyd <redfloyd@gmail.com> - 2011-07-25 14:04 -0700
        reading  zipfile; problem using raw buffer "Sells, Fred" <fred.sells@adventistcare.org> - 2011-07-26 08:42 -0400
          Re: reading  zipfile; problem using raw buffer Billy Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com> - 2011-07-26 08:49 -0400
        Re: reading  zipfile; problem using raw buffer Peter Otten <__peter__@web.de> - 2011-07-26 15:04 +0200
        RE: reading  zipfile; problem using raw buffer "Sells, Fred" <fred.sells@adventistcare.org> - 2011-07-26 11:22 -0400

Page 1 of 2  [1] 2  Next page →


#10261 — Pipe in the "return" statement

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 05:00 -0700
SubjectPipe in the "return" statement
Message-ID<acaab166-32c1-43df-b1a4-e3b47c62be36@m10g2000yqd.googlegroups.com>
Hi,

I have come across something I don't really understand and would be
grateful if someone could shed some light into my understanding of it.

In the documentation of the Qt4 libs in the page regarding the
QAbstractTableModel you find, to make the table editable, the
following:

Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
{
    if (!index.isValid())
        return Qt::ItemIsEnabled;

     return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}

Now I'm working with PySide, the Python bindings from Nokia and I
figured the
return in the function to be related with a parent
(QAbstractItemModel)
followed by the actual Flag that says: "yes the item, the index is
pointing
at, is actually editable". So translation of the C++ to Python would
be, and
it actually worked:

def flags(self, index):
    if not index.isValid():
        return Qt.ItemIsEnabled

    return super(self.__class__, self).flags(index) |
Qt.ItemIsEditable

Still I dont get how I am supposed to understand the pipe and its task/
idea/influece on control flow, of:
return <statement> | <statement>
??

Thankful if you could help me with this.

Kind regards,
Archard Lias

[toc] | [next] | [standalone]


#10262

FromIan Collins <ian-news@hotmail.com>
Date2011-07-26 00:03 +1200
Message-ID<9954ddFkjuU10@mid.individual.net>
In reply to#10261
On 07/26/11 12:00 AM, Archard Lias wrote:
> Hi,
>
> Still I dont get how I am supposed to understand the pipe and its task/
> idea/influece on control flow, of:
> return<statement>  |<statement>
> ??

It's simply a bitwise OR.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#10271

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 07:16 -0700
Message-ID<1c175da2-79f4-40ed-803f-217dc935df6c@m8g2000yqo.googlegroups.com>
In reply to#10262
On Jul 25, 2:03 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> On 07/26/11 12:00 AM, Archard Lias wrote:
>
> > Hi,
>
> > Still I dont get how I am supposed to understand the pipe and its task/
> > idea/influece on control flow, of:
> > return<statement>  |<statement>
> > ??
>
> It's simply a bitwise OR.
>
> --
> Ian Collins

Yes, but how does it get determined, which one actually gets returned?

[toc] | [prev] | [next] | [standalone]


#10272

FromBilly Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com>
Date2011-07-25 10:31 -0400
Message-ID<j0juod$193$1@speranza.aioe.org>
In reply to#10271
On 07/25/2011 10:16 AM, Archard Lias wrote:
> On Jul 25, 2:03 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>> On 07/26/11 12:00 AM, Archard Lias wrote:
>>
>>> Hi,
>>
>>> Still I dont get how I am supposed to understand the pipe and its task/
>>> idea/influece on control flow, of:
>>> return<statement>    |<statement>
>>> ??
>>
>> It's simply a bitwise OR.
>>
>> --
>> Ian Collins
>
> Yes, but how does it get determined, which one actually gets returned?


The return statement returns a single value from a function context. 
The pipe operator takes 2 values and bitwise ORs* them together.  That 
result is then returned to the caller.  The pipe character in this 
instance is not the same as in a shell.

* This is not exactly true, but don't worry about it.

--
Bill

[toc] | [prev] | [next] | [standalone]


#10305

FromEthan Furman <ethan@stoneleaf.us>
Date2011-07-25 13:07 -0700
Message-ID<mailman.1472.1311623510.1164.python-list@python.org>
In reply to#10272
Billy Mays wrote:
> On 07/25/2011 10:16 AM, Archard Lias wrote:
>> On Jul 25, 2:03 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>>> On 07/26/11 12:00 AM, Archard Lias wrote:
>>>> Still I dont get how I am supposed to understand the pipe and its task/
>>>> idea/influece on control flow, of:
>>>> return<statement>    |<statement>
>>>> ??
>>>
>>> It's simply a bitwise OR.
>>
>> Yes, but how does it get determined, which one actually gets returned?
> 
> The return statement returns a single value from a function context. The 
> pipe operator takes 2 values and bitwise ORs* them together.  That 
> result is then returned to the caller.

Just for completeness, if the actual line had been

return <statement1> or <statement2>

then Python would compute <statement1>, and if its boolean value was 
True would return the computation of <statement1>, otherwise it would 
compute <statement2> and return that.  When 'or' is used, the first 
truthy* item is return, or the last falsey* item if none evaluate to True.

--> None or 2 or 0
2
--> None or 2 or 3
2
--> None or [] or 0
0

With 'and', the first falsey item is returned, unless all the items are 
   truthy in which case the last item is returned:

--> 2 and 3
3
--> 2 and 0 and 9
0

Hope this helps.

~Ethan~

* 'truthy' = bool(some expression or object) == True
* 'falsey' = bool(some expression or object) == False

[toc] | [prev] | [next] | [standalone]


#10433

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2011-07-28 08:26 +0200
Message-ID<5540261.NEBpaLTAqx@PointedEars.de>
In reply to#10305
Ethan Furman wrote:

> Billy Mays wrote:
>> On 07/25/2011 10:16 AM, Archard Lias wrote:
>>> On Jul 25, 2:03 pm, Ian Collins<ian-n...@hotmail.com>  wrote:
>>>> On 07/26/11 12:00 AM, Archard Lias wrote:
>>>>> Still I dont get how I am supposed to understand the pipe and its
>>>>> task/ idea/influece on control flow, of:
>>>>> return<statement>    |<statement>
>>>>> ??
>>>>
>>>> It's simply a bitwise OR.
>>>
>>> Yes, but how does it get determined, which one actually gets returned?
>> The return statement returns a single value from a function context. The
>> pipe operator takes 2 values and bitwise ORs* them together.  That
>> result is then returned to the caller.
> Just for completeness, if the actual line had been
> 
> return <statement1> or <statement2>
> 
> then Python would compute <statement1>, and if its boolean value was
> True would return the computation of <statement1>, otherwise it would
> compute <statement2> and return that.  When 'or' is used, the first
> truthy* item is return, or the last falsey* item if none evaluate to True.

Hence "*bitwise* OR" (as Billy wrote), _not_ logical OR (as you wrote), 
probably.
 
-- 
PointedEars

Bitte keine Kopien per E-Mail. / Please do not Cc: me.

[toc] | [prev] | [next] | [standalone]


#10273

FromOliver Bestwalter <oliver@bestwalter.de>
Date2011-07-25 16:35 +0200
Message-ID<mailman.1456.1311604515.1164.python-list@python.org>
In reply to#10271
Hello Archard,

On 25.07.2011, at 16:16, Archard Lias wrote:

> On Jul 25, 2:03 pm, Ian Collins <ian-n...@hotmail.com> wrote:
>> On 07/26/11 12:00 AM, Archard Lias wrote:
>> 
>>> Hi,
>> 
>>> Still I dont get how I am supposed to understand the pipe and its task/
>>> idea/influece on control flow, of:
>>> return<statement>  |<statement>
>>> ??
>> 
>> It's simply a bitwise OR.
>> 
>> --
>> Ian Collins
> 
> Yes, but how does it get determined, which one actually gets returned?

You do a Bitwise OR with numbers. Your statements are both returning numbers and those are combined with a bitwise OR. Combining b0001 with b0010 results in 0011 for example, you can see this very often done in C Code to set and check flags. Here is a gentle introduction:

http://www.codeproject.com/KB/tips/Binary_Guide.aspxhttp://www.codeproject.com/KB/tips/Binary_Guide.aspx

Cheers
Oliver

[toc] | [prev] | [next] | [standalone]


#10278

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 08:05 -0700
Message-ID<2f79be80-f6a5-47a9-a80b-53346566ed7d@a4g2000yqg.googlegroups.com>
In reply to#10273
On Jul 25, 4:35 pm, Oliver Bestwalter <oli...@bestwalter.de> wrote:
> Hello Archard,
>
> On 25.07.2011, at 16:16, Archard Lias wrote:
>
>
>
>
>
>
>
>
>
> > On Jul 25, 2:03 pm, Ian Collins <ian-n...@hotmail.com> wrote:
> >> On 07/26/11 12:00 AM, Archard Lias wrote:
>
> >>> Hi,
>
> >>> Still I dont get how I am supposed to understand the pipe and its task/
> >>> idea/influece on control flow, of:
> >>> return<statement>  |<statement>
> >>> ??
>
> >> It's simply a bitwise OR.
>
> >> --
> >> Ian Collins
>
> > Yes, but how does it get determined, which one actually gets returned?
>
> You do a Bitwise OR with numbers. Your statements are both returning numbers and those are combined with a bitwise OR. Combining b0001 with b0010 results in 0011 for example, you can see this very often done in C Code to set and check flags. Here is a gentle introduction:
>
> http://www.codeproject.com/KB/tips/Binary_Guide.aspxhttp://www.codepr...
>
> Cheers
> Oliver

Oh!, never gave it a thought about the fact that what I was looking at
where flags... Thank you very much for the link, is a great
introduction to something I had not known before.

[toc] | [prev] | [next] | [standalone]


#10274

FromJohn Gordon <gordon@panix.com>
Date2011-07-25 14:39 +0000
Message-ID<j0jv6l$phb$1@reader1.panix.com>
In reply to#10271
In <1c175da2-79f4-40ed-803f-217dc935df6c@m8g2000yqo.googlegroups.com> Archard Lias <archardlias@googlemail.com> writes:

> > > return <statement> | <statement>
> >
> > It's simply a bitwise OR.

> Yes, but how does it get determined, which one actually gets returned?

Neither value is returned on its own; the bitwise OR of both values is
computed and that value is returned.

It seems that you don't understand what the term "bitwise or" means.
Perhaps a Google search might help.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#10277

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 08:06 -0700
Message-ID<5291febc-eae3-4baf-8359-e5ef0ee7d1b4@h17g2000yqn.googlegroups.com>
In reply to#10274
On Jul 25, 4:39 pm, John Gordon <gor...@panix.com> wrote:
> In <1c175da2-79f4-40ed-803f-217dc935d...@m8g2000yqo.googlegroups.com> Archard Lias <archardl...@googlemail.com> writes:
>
> > > > return <statement> | <statement>
>
> > > It's simply a bitwise OR.
> > Yes, but how does it get determined, which one actually gets returned?
>
> Neither value is returned on its own; the bitwise OR of both values is
> computed and that value is returned.
>
> It seems that you don't understand what the term "bitwise or" means.
> Perhaps a Google search might help.
>
> --
> John Gordon                   A is for Amy, who fell down the stairs
> gor...@panix.com              B is for Basil, assaulted by bears
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"

It figures, that you are right :P.

[toc] | [prev] | [next] | [standalone]


#10275

Fromgwowen <gwowen@gmail.com>
Date2011-07-25 07:42 -0700
Message-ID<382edbf0-eab9-4df3-b912-667a442a9371@en1g2000vbb.googlegroups.com>
In reply to#10271
On Jul 25, 3:16 pm, Archard Lias <archardl...@googlemail.com> wrote:

> Yes, but how does it get determined, which one actually gets returned?


It's a bit-wise or, not a logical or so what get returns is a
combination of the two results.  The n-th bit of the return value is 1
if the n-th bit of either (or both) of the two statements

(Fixed width font)
a     1 1 0 0 0 1 1 1 0 0 1 0 1 ...
b     0 1 0 1 0 0 1 0 0 0 0 1 1 ...
a|b   1 1 0 1 0 1 1 0 0 0 1 1 1 ...
(/Fixed width font)

[toc] | [prev] | [next] | [standalone]


#10266

FromChristian Heimes <lists@cheimes.de>
Date2011-07-25 14:33 +0200
Message-ID<mailman.1453.1311597213.1164.python-list@python.org>
In reply to#10261
Am 25.07.2011 14:00, schrieb Archard Lias:
> def flags(self, index):
>     if not index.isValid():
>         return Qt.ItemIsEnabled
> 
>     return super(self.__class__, self).flags(index) |

Your use of super() is incorrect and will not work as you might expect.
You *must* use the class here, never self.__class__.

Christian

[toc] | [prev] | [next] | [standalone]


#10280

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 08:28 -0700
Message-ID<7064a3b1-2f5b-45e5-bf4f-57b62b4be457@gc8g2000vbb.googlegroups.com>
In reply to#10266
On Jul 25, 2:33 pm, Christian Heimes <li...@cheimes.de> wrote:
> Am 25.07.2011 14:00, schrieb Archard Lias:
>
> > def flags(self, index):
> >     if not index.isValid():
> >         return Qt.ItemIsEnabled
>
> >     return super(self.__class__, self).flags(index) |
>
> Your use of super() is incorrect and will not work as you might expect.
> You *must* use the class here, never self.__class__.
>
> Christian

It would be great if you could elaborate a little more on that. Am I
not supposed to access the parent here?

--
Archard

[toc] | [prev] | [next] | [standalone]


#10285

FromChristian Heimes <lists@cheimes.de>
Date2011-07-25 18:11 +0200
Message-ID<mailman.1463.1311610284.1164.python-list@python.org>
In reply to#10280
Am 25.07.2011 17:28, schrieb Archard Lias:
> It would be great if you could elaborate a little more on that. Am I
> not supposed to access the parent here?

You must spell out the parent explicitly, otherwise subclasses call
super() with themselves rather than the correct parent class.
self.__class__ is too dynamic here. Have a look at this example:

class A(object):
    def method(self):
        pass

class B(A):
    def method(self):
        super(self.__class__, self).method()

class C(B):
    pass

In this example, C().method() results in "super(C, self).method()"
because self.__class__ is C. However that is wrong because you have to
call super() with the direct parent.

Christian

[toc] | [prev] | [next] | [standalone]


#10288

FromArchard Lias <archardlias@googlemail.com>
Date2011-07-25 09:30 -0700
Message-ID<f040d72b-33e5-4170-8b54-06207f3cfde0@eb1g2000vbb.googlegroups.com>
In reply to#10285
On 25 Jul., 18:11, Christian Heimes <li...@cheimes.de> wrote:
> Am 25.07.2011 17:28, schrieb Archard Lias:
>
> > It would be great if you could elaborate a little more on that. Am I
> > not supposed to access the parent here?
>
> You must spell out the parent explicitly, otherwise subclasses call
> super() with themselves rather than the correct parent class.
> self.__class__ is too dynamic here. Have a look at this example:
>
> class A(object):
>     def method(self):
>         pass
>
> class B(A):
>     def method(self):
>         super(self.__class__, self).method()
>
> class C(B):
>     pass
>
> In this example, C().method() results in "super(C, self).method()"
> because self.__class__ is C. However that is wrong because you have to
> call super() with the direct parent.
>
> Christian

Oh! Get it, thanks a lot :P

--
Archard

[toc] | [prev] | [next] | [standalone]


#10267

FromTonyO <guinness.tony@gmail.com>
Date2011-07-25 05:52 -0700
Message-ID<08098816-0332-4ae2-a125-35418bac0da2@dp9g2000vbb.googlegroups.com>
In reply to#10261
> Still I dont get how I am supposed to understand the pipe and its task/
> idea/influece on control flow, of:
> return <statement> | <statement>

In the words of René Magritte,

return <statement> | <statement>
                   ^
Ceci n'est pas une pipe.

[toc] | [prev] | [next] | [standalone]


#10268

Fromgwowen <gwowen@gmail.com>
Date2011-07-25 06:00 -0700
Message-ID<bd73ae4c-e7e2-4ed2-939f-6e4cd7a8976c@w27g2000yqk.googlegroups.com>
In reply to#10267
On Jul 25, 1:52 pm, TonyO <guinness.t...@gmail.com> wrote:

>> return <statement> | <statement>
>
> In the words of René Magritte,
>
> return <statement> | <statement>
>                    ^
> Ceci n'est pas une pipe.

*golf clap*

[toc] | [prev] | [next] | [standalone]


#10311

Fromred floyd <redfloyd@gmail.com>
Date2011-07-25 14:04 -0700
Message-ID<ab8b6e1f-f850-446b-aa34-47997974825d@d7g2000vbv.googlegroups.com>
In reply to#10267
On Jul 25, 5:52 am, TonyO <guinness.t...@gmail.com> wrote:
> > Still I dont get how I am supposed to understand the pipe and its task/
> > idea/influece on control flow, of:
> > return <statement> | <statement>
>
> In the words of René Magritte,
>
> return <statement> | <statement>
>                    ^
> Ceci n'est pas une pipe.

We have a WINNER!!!!!!

[toc] | [prev] | [next] | [standalone]


#10329 — reading zipfile; problem using raw buffer

From"Sells, Fred" <fred.sells@adventistcare.org>
Date2011-07-26 08:42 -0400
Subjectreading zipfile; problem using raw buffer
Message-ID<mailman.1493.1311684149.1164.python-list@python.org>
In reply to#10311
I'm tring to unzip a buffer that is uploaded to django/python.  I can
unzip the file in batch mode just fine, but when I get the buffer I get
a "BadZipfile exception.  I wrote this snippet to try to isolate the
issue but I don't understand what's going on.  I'm guessing that I'm
losing some header/trailer somewhere?

def unittestZipfile(filename):
    buffer = ''
    f = open(filename)
    for i in range(22):
        block = f.read()
        if len(block) == 0: 
            break
        else:
            buffer += block

    print len(buffer)
    tmp = open('tmp.zip', 'w')
    tmp.write(buffer)
    tmp.close()
    zf = zipfile.ZipFile('tmp.zip')
    print dir(zf)
    for name in zf.namelist():
        print name
        print zf.read(name)
____________________________________________________________
2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
Traceback (most recent call last):
  File
"C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
line 162, in <module>
    unittestZipfile('wk1live7.8to7.11.zip')    
  File
"C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
line 146, in unittestZipfile
    print zf.read(name)
  File "C:\alltools\python26\lib\zipfile.py", line 837, in read
    return self.open(name, "r", pwd).read()
  File "C:\alltools\python26\lib\zipfile.py", line 867, in open
    raise BadZipfile, "Bad magic number for file header"
zipfile.BadZipfile: Bad magic number for file header

[toc] | [prev] | [next] | [standalone]


#10332 — Re: reading zipfile; problem using raw buffer

FromBilly Mays <81282ed9a88799d21e77957df2d84bd6514d9af6@myhashismyemail.com>
Date2011-07-26 08:49 -0400
SubjectRe: reading zipfile; problem using raw buffer
Message-ID<j0md56$p6h$3@speranza.aioe.org>
In reply to#10329
On 07/26/2011 08:42 AM, Sells, Fred wrote:
> I'm tring to unzip a buffer that is uploaded to django/python.  I can
> unzip the file in batch mode just fine, but when I get the buffer I get
> a "BadZipfile exception.  I wrote this snippet to try to isolate the
> issue but I don't understand what's going on.  I'm guessing that I'm
> losing some header/trailer somewhere?
>
> def unittestZipfile(filename):
>      buffer = ''
>      f = open(filename)
>      for i in range(22):
>          block = f.read()
>          if len(block) == 0:
>              break
>          else:
>              buffer += block
>
>      print len(buffer)
>      tmp = open('tmp.zip', 'w')
>      tmp.write(buffer)
>      tmp.close()
>      zf = zipfile.ZipFile('tmp.zip')
>      print dir(zf)
>      for name in zf.namelist():
>          print name
>          print zf.read(name)
> ____________________________________________________________
> 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
> Traceback (most recent call last):
>    File
> "C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
> line 162, in<module>
>      unittestZipfile('wk1live7.8to7.11.zip')
>    File
> "C:\all\projects\AccMDS30Server\mds30\app\uploaders\xmitzipfile.py",
> line 146, in unittestZipfile
>      print zf.read(name)
>    File "C:\alltools\python26\lib\zipfile.py", line 837, in read
>      return self.open(name, "r", pwd).read()
>    File "C:\alltools\python26\lib\zipfile.py", line 867, in open
>      raise BadZipfile, "Bad magic number for file header"
> zipfile.BadZipfile: Bad magic number for file header
>

You need to specify the file mode since I'm guessing you use Windows 
from the traceback:

f = open(filename, 'rb')

and later:

tmp = open('tmp.zip', 'wb')

--
Bill

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web