Re: [Tutor] List indexing problem

2008-07-26 Thread Kent Johnson
On Fri, Jul 25, 2008 at 7:35 PM, Mike Meisner <[EMAIL PROTECTED]> wrote:
> Do you happen to know if there is an efficient way to initialize a  list
> like this without explicitly writing out each element?

You can make a copy of the inner list each time through the loop:
IP = []
temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
# initialize to zero
for i in range(20):
IP.append(list(temp))

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] List indexing problem

2008-07-26 Thread Kent Johnson
On Fri, Jul 25, 2008 at 8:20 PM, Michiel Overtoom <[EMAIL PROTECTED]> wrote:
> Mike wrote...
>
>>Do you happen to know if there is an efficient way to initialize a  list
>>like this without explicitly writing out each element?
>
 temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
 print temp
> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>
 print [[0]*3]*3
> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

This has the same aliasing problem as the original:
>>> x=[[0]*3]*3
>>> x
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> x[0][0]=1
>>> x
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]

BTW this is a FAQ:
http://effbot.org/pyfaq/how-do-i-create-a-multidimensional-list.htm

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Online class/education for Python?

2008-07-26 Thread wesley chun
> I have the first edition of Python Programming for the Absolute Beginner.
> Will this work instead of the 2nd edition?


i just found out from bookpool today that the 2nd edition is now also
out-of-print. does anyone know if a 3rd edition is being worked on?

-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
 http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2008-07-26 Thread amit sethi
hi,
Can somebody tell me about tools to  convert stereo mp3 signal to mono wave
signal . I tried using pymedia but i am not able to understand how to
convert stereo signal to a mono signal .

-- 
A-M-I-T S|S
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Online class/education for Python?

2008-07-26 Thread Dick Moores

At 01:43 AM 7/26/2008, wesley chun wrote:

> I have the first edition of Python Programming for the Absolute Beginner.
> Will this work instead of the 2nd edition?


i just found out from bookpool today that the 2nd edition is now also
out-of-print.


But:


And at the Publisher:




 does anyone know if a 3rd edition is being worked on?


publisher contact info:


I used to have the author's email, but I've lost it.

Dick Moores

===
Have you seen Kelie Feng's video introducing the terrific and free
IDE, Ulipad? 
Get Ulipad 3.9 from 
svn for the latest revision 
Mailing list for Ulipad:  


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Unable to Reconfigure IDLE

2008-07-26 Thread Thomas Corbett

Running IDLE 1.2.2 under MacPython 2.5 on Mac OS X 5.1.

Configured shell window to wrong size, now can't seem to find the menu  
(Options > Configure) to resize the shell.


Tried going to username > Library > Preferences  and removing  
org.python* files, but that did not work.


Thanks!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unable to Reconfigure IDLE

2008-07-26 Thread Alan Gauld


"Thomas Corbett" <[EMAIL PROTECTED]> wrote

Configured shell window to wrong size, now can't seem to find the 
menu  (Options > Configure) to resize the shell.


Don't you just resize it then close it and the next time it opens
it uses the new size?

Thats how I thought it was supposed to work!

Alan G 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] where to report a bug?

2008-07-26 Thread Rick Pasotto
On Fri, Jul 25, 2008 at 03:11:57PM -0700, Dave Kuhlman wrote:
> On Fri, Jul 25, 2008 at 10:04:35AM -0400, Rick Pasotto wrote:
> > I have a script that works fine on my linux machine but bombs out when
> > run under windows using the exact same data files. The script downloads
> > a file then unzips it and then scans the resulting file for certain
> > records. Under Windows it gets a memory error in the unzip routine.
> > 
> > Where should I send the error report?
> 
> You might want to post your code here.  Someone might be able to
> suggest a fix (to your code) or at least a work-around.
> 
> One question -- Are you downloading the file and unzipping it with
> the zipfile module?  Or, are you downloading the file and then
> writing the file to disk.
> 
> If you are writing the file to disk, make sure that you open the
> file in binary mode, since a zipped file is binary data.  If you
> fail to do so, your code will work on Linux/UNIX, but not on
> Windows.  I've written code with that bug myself.

That was a good thought but when I double checked the code I found that
I was already opening the write file in 'wb' mode.

Here's where things stand now.

I searched comp.lang.python for 'zipfile' and found several messages
that talked about this error. It seems that Windows doesn't handle
memory allocation very well on large files (surprise, surprise). The
module was written to deal with small files and so that was not a
consideration in writing the module.

One of the messages included a workaround that replaced the 'write'
method with an 'explode' funtion that opperated on 8k chunks instead of
the whole file. This had the added advantage of my being able to tap
into the function to display a progress indicator.

Again, it worked fine on my linux machine but failed on Windows, but
this time with a different error. This error really surprises me.

The new explode function uses the zipfile.ZipInfo.file_offset attribute.
Windows reports that there is no such attribute. Turns out that while it
exists in 2.4, which is what I am still running, it does *not* exist in
2.5, which is what the python.org Windows installer uses. I have 2.5 on
my linux machine and when I run python2.5 there, ZipInfo.file_offset is
not in the dir(zipfile.ZipInfo) list. All the other attributes match.

Where did it go? And why? Was it intentionally removed? If so, why and
how do I get its functionality? I haven't spotted any reference to the
change in the changelists I've seen but maybe I haven't looked in the
right places.

What should be my next step?

-- 
"You are the only one who can use your ability. It is an awesome
 responsibility." -- Zig Zigler
Rick Pasotto[EMAIL PROTECTED]http://www.niof.net
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Online class/education for Python?

2008-07-26 Thread wesley chun
On Sat, Jul 26, 2008 at 7:11 AM, Dick Moores <[EMAIL PROTECTED]> wrote:
> At 01:43 AM 7/26/2008, wesley chun wrote:
>>
>> > I have the first edition of Python Programming for the Absolute
>> > Beginner.
>> > Will this work instead of the 2nd edition?
>>
>>
>> i just found out from bookpool today that the 2nd edition is now also
>> out-of-print.
>
> But:
> 
> 
> And at the Publisher:
> 
>
>
>>  does anyone know if a 3rd edition is being worked on?
>
> publisher contact info:
> 
>
> I used to have the author's email, but I've lost it.
>
> Dick Moores


hey, don't shoot the messenger!  here's what bookpool said yesterday:

> This book is now out of print, and we have removed it from our website.
> A new edition has not been released.

it's probly only still available at general retailers because they
have such massive stock.  of course the publisher has all remaining
inventory. i'm only letting folks here know in case they want this
book, it may disappear soon.

that's why i was also asking about a 3rd edition. also, as you can see
from the 2nd review for this author's "other" Python book, it could be
some nefarious actions from the publisher itself... no wonder it's
"out-of-print!"

http://amazon.com/dp/1423901126

caveat emptor!
-wesley

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
 http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unable to Reconfigure IDLE

2008-07-26 Thread Michiel Overtoom
Thomas wrote...

>Running IDLE 1.2.2 under MacPython 2.5 on Mac OS X 5.1.
>
>Configured shell window to wrong size, now can't seem to find the menu  
>(Options > Configure) to resize the shell.
>
>Tried going to username > Library > Preferences  and removing  
>org.python* files, but that did not work.

IDLE keeps it preferences in a hidden directory '.idlerc' in your home
directory. 

Greetings,

-- 
"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Vallopillil
http://www.catb.org/~esr/halloween/halloween4.html

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] List indexing problem

2008-07-26 Thread Dave Kuhlman
On Sat, Jul 26, 2008 at 03:08:45AM -0400, Kent Johnson wrote:
> On Fri, Jul 25, 2008 at 7:35 PM, Mike Meisner <[EMAIL PROTECTED]> wrote:
> > Do you happen to know if there is an efficient way to initialize a  list
> > like this without explicitly writing out each element?
> 
> You can make a copy of the inner list each time through the loop:
> IP = []
> temp = [[0, 0, 0],[0, 0, 0],[0, 0, 0]]
> # initialize to zero
> for i in range(20):
> IP.append(list(temp))

How about::

In [26]: IP = [[0, 0, 0] for x in range(5)]
In [27]: IP
Out[27]: [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]]
In [28]: id(IP[0])
Out[28]: 13122016
In [29]: id(IP[1])
Out[29]: 13121152
In [30]: id(IP[2])
Out[30]: 13121800

- Dave


-- 
Dave Kuhlman
http://www.rexx.com/~dkuhlman
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Online class/education for Python?

2008-07-26 Thread Alan Gauld


"wesley chun" <[EMAIL PROTECTED]> wrote

from the 2nd review for this author's "other" Python book, it could 
be

some nefarious actions from the publisher itself... no wonder it's
"out-of-print!"

http://amazon.com/dp/1423901126


At $88 for 500 pages it had better be good or he will be stuxck
with academic-only sales!

Alan G 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] urllib2 and php authentication

2008-07-26 Thread Daniele
Hi,
I'm trying to connect to a site that requires a php login. I used the
urllib2 module in the following way:

>>> import urllib2
>>> user='xxx'
>>> password='yyy'
>>> hp = urllib2.HTTPPasswordMgr()
>>> uri = 'http://s2.ikariam.it/index.php?action=loginAvatar&function=login'
>>> hp.add_password(None, uri, user, password)
>>> opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler( hp))
>>> req = urllib2.Request(uri)
>>> opener.open(req).readlines()

Needless to say, it doesn't work. I get an html page back from the
opener saying username and/or password are invalid.
Can anyone point me in the right direction?

thanks a lot,
Daniele
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] urllib2 and php authentication

2008-07-26 Thread W W
On Sat, Jul 26, 2008 at 7:31 PM, Daniele <[EMAIL PROTECTED]> wrote:

> Hi,
> I'm trying to connect to a site that requires a php login. I used the
> urllib2 module in the following way:
>

It requires a php login, or php handles the login?

>>> import urllib2
> >>> user='xxx'
> >>> password='yyy'
> >>> hp = urllib2.HTTPPasswordMgr()
> >>> uri = '
> http://s2.ikariam.it/index.php?action=loginAvatar&function=login'
> >>> hp.add_password(None, uri, user, password)
> >>> opener = urllib2.build_opener(urllib2.HTTPBasicAuthHandler( hp))
> >>> req = urllib2.Request(uri)
> >>> opener.open(req).readlines()
>
> Needless to say, it doesn't work. I get an html page back from the
> opener saying username and/or password are invalid.
> Can anyone point me in the right direction?
>

If php is handling the login, my guess is that it's receiving the info via
either POST or GET.

And if you don't have access to the script, and you're not sure what the
names of the values are, that might require some trial and error.

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unable to Reconfigure IDLE

2008-07-26 Thread Thomas Corbett


On Jul 26, 2008, at 9:02 AM, Alan Gauld wrote:



"Thomas Corbett" <[EMAIL PROTECTED]> wrote

Configured shell window to wrong size, now can't seem to find the  
menu  (Options > Configure) to resize the shell.


Don't you just resize it then close it and the next time it opens
it uses the new size?

Thats how I thought it was supposed to work!

Alan G

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



The window is too large to resize.

-Tom

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor