Re: [Tutor] Text Editors and Linux (was Re: exit message)

2013-05-07 Thread Prasad, Ramit
Steven D'Aprano wrote: * a decent console app that supports multiple tabs; Any reason to prefer tabs to virtual terminals (i.e. screen)? ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy

[Tutor] Argparse functions with N parameters

2013-05-07 Thread Danilo Chilene
Hello, I have the code below: import argparse class Myclass(object): def foo(self): print 'foo' def bar(self): print 'bar' def test(self,name,place): print name, place class Main(Myclass): def __init__(self): foo_parser =

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Peter Otten
Danilo Chilene wrote: Hello, I have the code below: import argparse class Myclass(object): def foo(self): print 'foo' def bar(self): print 'bar' def test(self,name,place): print name, place class Main(Myclass): def __init__(self):

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Prasad, Ramit
Peter Otten wrote: [snip] There may be a library out there that does this with bells and whistles, but I haven't looked. This is not related to the OP, but have you [Peter/tutors] taken a look at the docopt library? Any thoughts compared to argparse/optparse? ~Ramit This email is

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Dave Angel
On 05/07/2013 01:10 PM, Bjorn Madsen wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) 43816 L={x for x in range(1)} sys.getsizeof(L) 262260 ? kind regards, Bjorn Just curious: what did you expect? Sets have a different purpose, basically to be able to do an 'in'

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Oscar Benjamin
On 7 May 2013 18:10, Bjorn Madsen bjorn.h.mad...@googlemail.com wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) 43816 L={x for x in range(1)} sys.getsizeof(L) 262260 Firstly, these results may vary depending on operating system, processor architecture and build options

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Bjorn Madsen
Hi, Thanks for the quick response. Being curious I actually expected something like this: L={x:None for x in range(1)} sys.getsizeof(L) 196660 That is why I wondered why 6 times is a lot given that a dict can do the same at 3/4 of the mem-footprint. Just got surprised about the overhead

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Oscar Benjamin
On 7 May 2013 19:09, Bjorn Madsen bjorn.h.mad...@googlemail.com wrote: Hi, Thanks for the quick response. Being curious I actually expected something like this: L={x:None for x in range(1)} sys.getsizeof(L) 196660 That is why I wondered why 6 times is a lot given that a dict can do

[Tutor] Games from Mark Dawson#'s book

2013-05-07 Thread Stafford Baines
I recently wrote to this forum about the games downloaded from Mark Dawson's book Python Programming 3rd Edition and couldn't get the graphics games (chapters 11 and 12 of the book) to work. I had helpful and friendly advice from boB and Dave. The book has been written around python 3.1 and I

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Mark Lawrence
On 07/05/2013 17:15, Prasad, Ramit wrote: Peter Otten wrote: [snip] There may be a library out there that does this with bells and whistles, but I haven't looked. This is not related to the OP, but have you [Peter/tutors] taken a look at the docopt library? Any thoughts compared to

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Steven D'Aprano
On 08/05/13 03:10, Bjorn Madsen wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) 43816 L={x for x in range(1)} sys.getsizeof(L) 262260 ? Both sets and lists may be over-allocated. I expect that lists created with a list comprehension may not be over-allocated, but if you

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread eryksun
On Tue, May 7, 2013 at 2:09 PM, Bjorn Madsen bjorn.h.mad...@googlemail.com wrote: Being curious I actually expected something like this: L={x:None for x in range(1)} sys.getsizeof(L) 196660 That is why I wondered why 6 times is a lot given that a dict can do the same at 3/4 of the

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread eryksun
On Tue, May 7, 2013 at 9:30 PM, eryksun eryk...@gmail.com wrote: That is why I wondered why 6 times is a lot given that a dict can do the same at 3/4 of the mem-footprint. I hope it's clear that 3/4 here comes from 1/2 * 3/2. In other words the dict table has 1/2 the number of entries, and

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread wesley chun
Following Oscar's comment, It's also O(n) vs. O(1) tradeoff. --wesley On Tue, May 7, 2013 at 12:09 PM, Oscar Benjamin oscar.j.benja...@gmail.comwrote: On 7 May 2013 19:09, Bjorn Madsen bjorn.h.mad...@googlemail.com wrote: Hi, Thanks for the quick response. Being curious I actually