Re: list.pop(0) vs. collections.dequeue

2010-01-24 Thread Steve Howell
On Jan 23, 3:04 pm, Terry Reedy wrote: > On 1/23/2010 12:17 PM, Steve Howell wrote: > > > Terry Reedy said: > > > ''' > > If you try writing a full patch, as I believe someone did, or at least > > a > > prototype thereof, when the idea was d

Re: list.pop(0) vs. collections.dequeue

2010-01-24 Thread Steve Howell
On Jan 24, 11:28 am, a...@pythoncraft.com (Aahz) wrote: > In article , > Steve Howell   wrote: > > > > >Even with realloc()'s brokenness, you could improve pop(0) in a way > >that does not impact list access at all, and the patch would not change > >the time

Re: list.pop(0) vs. collections.dequeue

2010-01-24 Thread Steve Howell
On Jan 24, 12:44 pm, Paul Rubin wrote: > Steve Howell writes: > > Proposal: Improve list's implementation so that deleting elements from > > the front of the list does not require an O(N) memmove operation. ... > > It is possible now, of course, to use a data structure

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 24, 11:24 pm, Paul Rubin wrote: > Steve Howell writes: > > There is nothing wrong with deque, at least as far as I know, if the > > data strucure actually applies to your use case.  It does not apply to > > my use case. > > You haven't explained why dequ

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 24, 10:07 pm, Steven D'Aprano wrote: > On Sun, 24 Jan 2010 20:12:11 -0800, Steve Howell wrote: > >> > The most ambitious proposal is to fix the memory manager itself to > >> > allow the release of memory from the start of the chunk. > > &g

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 9:31 am, Steve Howell wrote: > On Jan 24, 11:24 pm, Paul Rubin wrote: > > > Steve Howell writes: > > > There is nothing wrong with deque, at least as far as I know, if the > > > data strucure actually applies to your use case.  It does not apply t

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 24, 1:51 pm, Daniel Stutzbach wrote: > On Sun, Jan 24, 2010 at 1:53 PM, Steve Howell wrote: > > I don't think anybody provided an actual link, but please correct me > > if I overlooked it. > > I have to wonder if my messages are all ending up in your spa

Re: medians for degree measurements

2010-01-25 Thread Steve Howell
On Jan 24, 5:26 pm, Robert Kern wrote: > On 2010-01-23 05:52 , Steven D'Aprano wrote: > > On Fri, 22 Jan 2010 22:09:54 -0800, Steve Howell wrote: > > >> On Jan 22, 5:12 pm, MRAB  wrote: > >>> Steve Howell wrote: > >>>> I just saw the thread for

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 1:32 pm, Arnaud Delobelle wrote: > Steve Howell writes: > > [...] > > > My algorithm does exactly N pops and roughly N list accesses, so I > > would be going from N*N + N to N + N log N if switched to blist. > > Can you post your algorithm?  It would be

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 1:32 pm, Arnaud Delobelle wrote: > Steve Howell writes: > > [...] > > > My algorithm does exactly N pops and roughly N list accesses, so I > > would be going from N*N + N to N + N log N if switched to blist. > > Can you post your algorithm?  It would be

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 1:00 pm, Paul Rubin wrote: > Steve Howell writes: > > These are the reasons I am not using deque: > > Thanks for these.  Now we are getting somewhere. > > >   1) I want to use native lists, so that downstream methods can use > > them as lists. > > I

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 1:32 pm, Arnaud Delobelle wrote: > Steve Howell writes: > > [...] > > > My algorithm does exactly N pops and roughly N list accesses, so I > > would be going from N*N + N to N + N log N if switched to blist. > > Can you post your algorithm?  It would be

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
--- On Mon, 1/25/10, Chris Colbert wrote: > > looking at that code, i think you could solve > your whole problem with a single called to reversed() (which > is NOT the same as list.reverse())  > I do not think that's actually true. It does no good to pop elements off a copy of the list if th

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 24, 11:28 am, a...@pythoncraft.com (Aahz) wrote: > In article , > Steve Howell   wrote: > > > > >Even with realloc()'s brokenness, you could improve pop(0) in a way > >that does not impact list access at all, and the patch would not change > >the time

Re: list.pop(0) vs. collections.dequeue

2010-01-25 Thread Steve Howell
On Jan 25, 8:31 pm, Paul Rubin wrote: > Steve Howell writes: > > I haven't profiled deque vs. list, but I think you are correct about > > pop() possibly being a red herring > > For really large lists, I suppose memmove() would eventually start to > > become

Re: list.pop(0) vs. collections.dequeue

2010-01-26 Thread Steve Howell
On Jan 25, 9:00 pm, Steve Howell wrote: > On Jan 24, 11:28 am, a...@pythoncraft.com (Aahz) wrote: > > > > > In article > > , > > Steve Howell   wrote: > > > >Even with realloc()'s brokenness, you could improve pop(0) in a way > > >that doe

Re: list.pop(0) vs. collections.dequeue

2010-01-27 Thread Steve Howell
On Jan 26, 11:34 pm, Arnaud Delobelle wrote: > Steve Howell writes: > > On Jan 25, 1:32 pm, Arnaud Delobelle wrote: > >> Steve Howell writes: > > >> [...] > > >> > My algorithm does exactly N pops and roughly N list accesses, so I > >> &g

overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
I ran the following program, and found its output surprising in one place: class OnlyAl: def __getitem__(self, key): return 'al' class OnlyBob(dict): def __getitem__(self, key): return 'bob' import sys; print sys.version al = OnlyAl() bob = OnlyBob() pri

Re: Python & Go

2009-11-15 Thread Steve Howell
On Nov 14, 3:26 am, kj wrote: > One more thing: I found Rob Pike's mutterings on generics (towards > the end of his rollout video) rather offputting, because he gave > the impression that some important aspects of the language were > not even considered before major decisions for it were set in s

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 10:25 am, Steve Howell wrote: > [see original post...] > I am most > interested in the specific mechanism for changing the __getitem__ > method for a subclass on a dictionary.  Thanks in advance! Sorry for replying to myself, but I just realized that the last statement in

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 11:19 am, Gary Herron wrote: > Steve Howell wrote: > > I ran the following program, and found its output surprising in one > > place: > > >     class OnlyAl: > >         def __getitem__(self, key): return 'al' > > >     class Onl

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 12:01 pm, Jon Clements wrote: > On Nov 15, 7:23 pm, Steve Howell wrote: > > > I am more precisely looking for a way to change the behavior of foo > > ['bar'] (side effects and possibly return value) where "foo" is an > > instance of a clas

Re: Slicing history?

2009-11-15 Thread Steve Howell
On Nov 15, 12:11 pm, Mark Dickinson wrote: > On Nov 15, 6:50 pm, a...@pythoncraft.com (Aahz) wrote: > > > Anyone remember or know why Python slices function like half-open > > intervals?  I find it incredibly convenient myself, but an acquaintance > > familiar with other programming languages thin

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 12:01 pm, Jon Clements wrote: > On Nov 15, 7:23 pm, Steve Howell wrote: > > > On Nov 15, 10:25 am, Steve Howell wrote: > > > > [see original post...] > > > I am most > > > interested in the specific mechanism for changing the __getitem__ &

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 4:03 pm, Christian Heimes wrote: > Steve Howell wrote: > > Does anybody have any links that points to the rationale for ignoring > > instance definitions of __getitem__ when new-style classes are > > involved?  I assume it has something to do with performance or &

Re: overriding __getitem__ for a subclass of dict

2009-11-15 Thread Steve Howell
On Nov 15, 4:58 pm, Steve Howell wrote: > On Nov 15, 4:03 pm, Christian Heimes wrote: > > > Try this untested code: > > > class Spam(dict): > >     def __getitem__(self, key): > >         getitem = self.__dict__.get("__getitem__", dict.__geti

Re: overriding __getitem__ for a subclass of dict

2009-11-16 Thread Steve Howell
On Nov 16, 2:35 am, Carl Banks wrote: > On Nov 15, 2:52 pm, Steve Howell wrote: > > > Does anybody have any links that points to the rationale for ignoring > > instance definitions of __getitem__ when new-style classes are > > involved?  I assume it has something t

Re: overriding __getitem__ for a subclass of dict

2009-11-16 Thread Steve Howell
On Nov 16, 5:46 pm, Steven D'Aprano wrote: > On Mon, 16 Nov 2009 10:32:19 -0800, Steve Howell wrote: > > Actually, the __getitem__ workaround that I proposed earlier only works > > on subclasses of dict, not dict themselves.  So given a pure dictionary > > object, it

Re: overriding __getitem__ for a subclass of dict

2009-11-16 Thread Steve Howell
On Nov 16, 4:06 pm, greg wrote: > Christian Heimes wrote: > > Most magic methods are implemented as descriptors. Descriptors only > > looked up on the type to increase the performance of the interpreter and > > to simply the C API. > > There's also a semantic problem. Since new-style > classes are

Re: overriding __getitem__ for a subclass of dict

2009-11-17 Thread Steve Howell
On Nov 16, 10:11 pm, Carl Banks wrote: > On Nov 16, 10:32 am, Steve Howell wrote: > > > > > On Nov 16, 2:35 am, Carl Banks wrote: > > > > On Nov 15, 2:52 pm, Steve Howell wrote: > > > > > Does anybody have any links that points to the rationale

Re: overriding __getitem__ for a subclass of dict

2009-11-17 Thread Steve Howell
On Nov 17, 7:11 am, Scott David Daniels wrote: > Steve Howell wrote: > > ... > > > Eventually, I realized that it was easier to just monkeypatch Django > > while I was in test mode to get a more direct hook into the behavior I > > was trying to monitor, and the

ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread Steve Howell
During the last few days I have written code in support of a small DDL language that encapsulates a concise representation of the manipulations needed to make a deep subcopy of a Python-like data structure. It is inspired by syntax from mainstream modern languages, including, of course, Python. The

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On the topic of "switch" statements and even-more-concise-then-we-have- already if/elif/else/end constructs, I have to say that Python does occasionally force you to write code like the code below. Maybe "force" is too strong a word, but Python lends itself to if/elif blocks like below, which get

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 1:32 am, Chris Rebert wrote: > On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell wrote: > > On the topic of "switch" statements and even-more-concise-then-we-have- > > already if/elif/else/end constructs, I have to say that Python does > > occasionally f

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 1:32 am, Chris Rebert wrote: > On Wed, Nov 18, 2009 at 1:15 AM, Steve Howell wrote: > > On the topic of "switch" statements and even-more-concise-then-we-have- > > already if/elif/else/end constructs, I have to say that Python does > > occasionally f

Re: ANN: a mini-language for encapsulating deep-copy operations on Python data structures

2009-11-18 Thread Steve Howell
On Nov 18, 4:34 am, "M.-A. Lemburg" wrote: > Steve Howell wrote: > > [...] > > Here is an example of the DDL (and I hate the terminology "DDL," just > > cannot think of anything better): > > >             { > >              

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 2:22 pm, Steven D'Aprano wrote: > On Wed, 18 Nov 2009 02:06:49 -0800, Steve Howell wrote: > > P.S. The underscores before the method names might look a little funny > > for inner methods, but it's the nature of the code..._dict and _list > > would lead

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 3:02 pm, Steven D'Aprano wrote: > > That depends on the code. In particular, it depends on how coupled the > code is. Ideally, you should have loosely coupled code, not highly > coupled. If the code is loosely coupled, then there's no problem with > understanding it in isolation. If the

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 3:02 pm, Steven D'Aprano wrote: > Lexical duplication is one of the weakest code smells around, because it > is so prone to false negatives. You often can't avoid referring to the > same lexical element multiple times: > > def sinc(x): >     if x != 0: >         return sin(x)/x >     re

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 5:13 pm, Steven D'Aprano wrote: > On Wed, 18 Nov 2009 15:58:24 -0800, Steve Howell wrote: > > On Nov 18, 2:22 pm, Steven D'Aprano > > wrote: > >> On Wed, 18 Nov 2009 02:06:49 -0800, Steve Howell wrote: > >> > P.S. The underscor

Re: Language mavens: Is there a programming with "if then else ENDIF" syntax?

2009-11-18 Thread Steve Howell
On Nov 18, 5:42 pm, Steven D'Aprano wrote: > On Wed, 18 Nov 2009 17:14:27 -0800, Steve Howell wrote: > > In my rewritten code, here is the smell: > > >     dispatches = { > >             'dict': _dict, > >             'list': _list, >

Re: Python/HTML integration: phileas v0.3 released

2009-11-20 Thread Steve Howell
On Nov 19, 10:53 am, papa hippo wrote: > The prime goal of 'phileas' is to enable html code to be seamlessly > included in python code in a natural looking syntax, without resorting > to templatng language. > > see: > > http://larry.myerscough.nl/phileas_project/ > > I intend to submit phileas to

parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
I have been writing some code that parses a mini-language, and I am running into what I know is a pretty common design pattern problem, but I am wondering the most Pythonic way to solve it. Basically, I have a bunch of really simple classes that work together to define an expression--in my oversim

Re: Go versus Brand X

2009-11-21 Thread Steve Howell
On Nov 21, 11:20 am, John Roth wrote: > On Nov 21, 8:40 am, Duncan Booth wrote: > > > a...@pythoncraft.com (Aahz) wrote: > > > Comparing Go to another computer language -- do you recognize it? > > > >http://www.cowlark.com/2009-11-15-go/ > > > Yes, spotted it at the first 'fi'. > > This isn't the

Re: parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
On Nov 21, 4:07 pm, MRAB wrote: > > I don't see the point of EvalNode and PrettyPrintNode. Why don't you > just give Integer, Sum and Product 'eval' and 'pprint' methods? That's a good question, and it's the crux of my design dilemma. If ALL I ever wanted to to with Integer/Sum/Product was to ev

Re: parallel class structures for AST-based objects

2009-11-21 Thread Steve Howell
On Nov 21, 4:33 pm, Richard Thomas wrote: > > This looks more structurally sound: > > class Node(object): >    def eval(self): >       raise NotImplementedError >    def pprint(self): >       raise NotImplementedError > My objection to the interface you describe is that Node defines the type of o

Re: Writing a Carriage Return in Unicode

2009-11-21 Thread Steve Howell
On Nov 21, 12:12 am, Steven D'Aprano wrote: > On Thu, 19 Nov 2009 23:22:22 -0800, Scott David Daniels wrote: > > > If you've actually typed on a physical typewriter, you know that moving > > the carriage back is a distinct operation from rolling the platen > > forward; > > I haven't typed on a phy

Re: Writing a Carriage Return in Unicode

2009-11-22 Thread Steve Howell
On Nov 21, 11:33 pm, Gregory Ewing wrote: > Steve Howell wrote: > > If you are > > going to couple character sets to their legacy physical > > implementations, you should also have a special extra character to dot > > your i's and cross your t's. > > No,

Re: parallel class structures for AST-based objects

2009-11-22 Thread Steve Howell
On Nov 22, 7:55 am, Simon Forman wrote: > On Sun, Nov 22, 2009 at 4:50 AM, Diez B. Roggisch wrote: > > > > > Steve Howell schrieb: > > >> On Nov 21, 4:07 pm, MRAB wrote: > > >>> I don't see the point of EvalNode and PrettyPrintNode. Why don&#x

Re: problem manipulating a list belonging to a class

2009-11-22 Thread Steve Howell
On Nov 22, 2:50 pm, Marc Leconte wrote: > Dear all, > > I have a problem with the following code (ubuntu 8.04, Python 2.5.2): > > class Toto(object): >         def __init__(self, number, mylist=[]) >                 self.number=number >                 self.mylist=mylist >                 pass >  

Re: problem manipulating a list belonging to a class

2009-11-22 Thread Steve Howell
On Nov 22, 3:14 pm, Steve Howell wrote: > Explanations of why you need to write it that will follow... I knew this had to be written up somewhere... http://www.ferg.org/projects/python_gotchas.html#contents_item_6 -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand += better

2009-11-22 Thread Steve Howell
On Nov 22, 7:28 pm, Lie Ryan wrote: > Roy Smith wrote: > > If I've got an object foo, and I execute: > > > foo.bar += baz > > > exactly what happens if foo does not have a 'bar' attribute?  It's > > pretty clear that foo.__getattr__('bar') gets called first, but it's a > > little murky after that.

Re: Implementation of Book Organization tool (Python2.[x])

2009-11-22 Thread Steve Howell
On Nov 22, 6:06 pm, "~km" wrote: > Hi together, > > I'm a python-proficient newbie and want to tackle a program with > Python 2.x, which basically organizes all my digital books (*.pdf, > *.chm, etc..) and to give them specific "labels", such as: > > "Author" -> string > "Read" -> boolean > "Last

Re: Trying to understand += better

2009-11-22 Thread Steve Howell
On Nov 22, 9:11 pm, n00m wrote: > > The first statement is creating a whole new list; > > Yes but *imo* not quite exactly so. > We can't think of 2 lists as of absolutely independent > things. > [...] You are correct that two lists can both have the same mutable object as items, and if you mutate

Re: KirbyBase : replacing string exceptions

2009-11-23 Thread Steve Howell
On Nov 23, 7:22 am, Brendan wrote: > In KirbyBase there is a method that uses string exceptions for > control, even though it has a defined exception. Is there any reason > the string exceptions below could not be replaced? > i.e. in code below replace: > raise "No Match" > with: > raise KBError()

Re: Go versus Brand X

2009-11-23 Thread Steve Howell
On Nov 23, 2:47 am, Antoine Pitrou wrote: > Le Mon, 23 Nov 2009 02:36:33 -0600, Robert Kern a écrit : > > > > > I think there is an overall design sensibility, it's just not a > > human-facing one. They claim that they designed the syntax to be very > > easily parsed by very simple tools in order

Re: Function attributes

2010-02-13 Thread Steve Howell
On Feb 10, 5:59 am, Muhammad Alkarouri wrote: > Hi everyone, > > What is the simplest way to access the attributes of a function from > inside it, other than using its explicit name? > In a function like f below: > > def f(*args): >     f.args = args >     print args > > is there any other way? >

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
On Feb 13, 6:41 pm, a...@pythoncraft.com (Aahz) wrote: > In article , > Alf P. Steinbach wrote: > > > > >My original statement, with reference to the Java language spec, > >didn't say much more about the language than that it has assignable > >references. > > Assuming this is what you're referring

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
On Feb 13, 6:10 pm, MRAB wrote: > Alf P. Steinbach wrote: > > * Steve Howell: > >> This thread is interesting on many levels.  What is the core question > >> that is being examined here? > > > I think that regarding the technical it is whether a Python na

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
This thread is interesting on many levels. What is the core question that is being examined here? -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
On Feb 13, 7:53 pm, Steven D'Aprano wrote: > On Sat, 13 Feb 2010 18:54:34 -0800, Steve Howell wrote: > > On Feb 13, 6:41 pm, a...@pythoncraft.com (Aahz) wrote: > > > Regardless of how CPython manages its state internally, Python as a > > > programming language d

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
On Feb 13, 9:13 pm, Steven D'Aprano wrote: > On Sat, 13 Feb 2010 20:11:06 -0800, Steve Howell wrote: > > For a suitably wide definition of pointers CPython does indeed have > > pointers, and your example is only a weaker case of that truth.  There > > is no reductio a

Re: Modifying Class Object

2010-02-13 Thread Steve Howell
On Feb 13, 11:21 pm, Steven D'Aprano wrote: > On Sat, 13 Feb 2010 21:33:50 -0800, Steve Howell wrote: > > You seem to be missing the point that "curly braces" is a concrete > > term that very specifically applies to spelling. > > And you seem to be missin

Re: Modifying Class Object

2010-02-14 Thread Steve Howell
On Feb 10, 6:16 am, Steven D'Aprano wrote: > > Alf, although your English in this forum has been excellent so far, I > understand you are Norwegian, so it is possible that you aren't a native > English speaker and possibly unaware that quotation marks are sometimes > ambiguous in English. > > Whil

Re: Modifying Class Object

2010-02-14 Thread Steve Howell
On Feb 14, 7:11 am, Steven D'Aprano wrote: > On Sat, 13 Feb 2010 23:45:47 -0800, Steve Howell wrote: > > The term "pointer" is very abstract.  Please give me a concrete > > definition of a pointer. > > A programming language data type whose value directly

Re: Python Optimization

2010-02-14 Thread Steve Howell
On Feb 14, 9:48 am, Mark Dickinson wrote: > On Feb 14, 4:53 pm, mukesh tiwari > wrote: > > > Hello everyone. I am new to python and previously i did programming in > > c/c++.Could some one please help me to improve the run time for this > > python program as i don't have idea how to optimized thi

Re: Please help with MemoryError

2010-02-14 Thread Steve Howell
On Feb 14, 10:32 am, Steve Holden wrote: > rantingrick wrote: > > On Feb 12, 4:10 pm, Steve Holden wrote: > >> Antoine Pitrou wrote: > >>> Le Fri, 12 Feb 2010 17:14:57 +, Steven D'Aprano a écrit : > > > On Feb 12, 4:10 pm, Steve Holden wrote: > >> Antoine Pitrou wrote: > >>> Le Fri, 12 Feb 2

Re: Please help with MemoryError

2010-02-14 Thread Steve Howell
On Feb 11, 5:50 pm, Steven D'Aprano wrote: > On Thu, 11 Feb 2010 15:39:09 -0800, Jeremy wrote: > > My Python program now consumes over 2 GB of memory and then I get a > > MemoryError.  I know I am reading lots of files into memory, but not 2GB > > worth. > > 2.    When do I need > > to manually a

Re: Python Optimization

2010-02-14 Thread Steve Howell
On Feb 14, 11:52 am, Mark Dickinson wrote: > On Feb 14, 4:53 pm, mukesh tiwari > wrote: > > > Hello everyone. I am new to python and previously i did programming in > > c/c++.Could some one please help me to improve the run time for this > > python program as i don't have idea how to optimized th

Re: Which mock library do you prefer?

2010-02-15 Thread Steve Howell
On Feb 15, 8:15 am, Lacrima wrote: > Hello! > > I am newbie mastering test driven development. I can't clarify myself > which mock library to use. > There are number of them and which one do you prefer? > > Two libraries that attracted my attention are: > * minimock > * dingus > As for me the late

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-17 Thread Steve Howell
On Feb 17, 5:39 pm, Steven D'Aprano wrote: > On Wed, 17 Feb 2010 17:04:00 -0800, Jonathan Gardner wrote: > > (What the heck is a procedure, anyway? Is this different from a > > subroutine, a method, or a block?) > > The name is used in Pascal, which probably means it originated from > Fortran or A

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-17 Thread Steve Howell
On Feb 16, 4:19 pm, Jonathan Gardner wrote: > On Feb 16, 11:41 am, Andrej Mitrovic > wrote: > > > > > On Feb 16, 7:38 pm, Casey Hawthorne > > wrote: > > > > Interesting talk on Python vs. Ruby and how he would like Python to > > > have just a bit more syntactic flexibility. > > > >http://blog.ex

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 1:23 am, Duncan Booth wrote: > Jonathan Gardner wrote: > > On Feb 17, 12:02 am, Lawrence D'Oliveiro > central.gen.new_zealand> wrote: > >> In message > >> <8ca440b2-6094-4b35-80c5-81d000517...@v20g2000prb.googlegroups.com>, > > >> Jonathan Gardner wrote: > >> > I used to think anonymo

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 7:50 am, Duncan Booth wrote: > Steve Howell wrote: > > If this is an argument against using anonymous functions, then it is a > > quadruple strawman. > > > Shipping buggy code is a bad idea, even with named functions. > > I doubt very much whether I have

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 3:00 pm, Steven D'Aprano wrote: > [...] > You wouldn't name your functions: > > f01, f02, f03, f04, ... f99 > Exactly. > (say), unless you were trying to deliberately obfuscate your code. > Anonymous functions are even more obfuscated than that. You can get away > with it so long as y

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 3:04 pm, "sjdevn...@yahoo.com" wrote: > On Feb 18, 11:15 am, Steve Howell wrote: > > >     def print_numbers() > >         [1, 2, 3, 4, 5, 6].map { |n| > >             [n * n, n * n * n] > >         }.reject { |square, cube| > >          

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 2:49 pm, Jonathan Gardner wrote: > On Feb 18, 8:15 am, Steve Howell wrote: > > > > >     def print_numbers() > >         [1, 2, 3, 4, 5, 6].map { |n| > >             [n * n, n * n * n] > >         }.reject { |square, cube| > >             sq

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 7:58 pm, Paul Rubin wrote: > Steve Howell writes: > >> But frankly, although there's no reason that you _have_ to name the > >> content at each step, I find it a lot more readable if you do: > > >> def print_numbers(): > >>  

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 8:27 pm, "sjdevn...@yahoo.com" wrote: > On Feb 18, 10:58 pm, Paul Rubin wrote: > > Steve Howell writes: > > >> But frankly, although there's no reason that you _have_ to name the > > >> content at each step, I find it a lot mor

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 7:58 pm, Paul Rubin wrote: > Steve Howell writes: > >> But frankly, although there's no reason that you _have_ to name the > >> content at each step, I find it a lot more readable if you do: > > >> def print_numbers(): > >>  

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:41 pm, Steven D'Aprano wrote: > On Thu, 18 Feb 2010 22:48:21 -0500, Steve Holden wrote: > > Next week: Lesson 2 - Ad Hominem Attacks > > I wouldn't pay any attention to Steve, all Stevens are notorious liars. > > -- > Steven Especially when their last name starts with H. Cheers, St

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:46 pm, Steven D'Aprano wrote: > On Thu, 18 Feb 2010 19:57:35 -0800, Steve Howell wrote: > > The names you give to the intermediate results here are terse--"tuples" > > and "filtered"--so your code reads nicely. > > > In a more real

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:37 pm, Kurt Smith wrote: > On Thu, Feb 18, 2010 at 10:46 PM, Steve Howell wrote: > > On Feb 18, 2:49 pm, Jonathan Gardner > > wrote: > >> On Feb 18, 8:15 am, Steve Howell wrote: > > >> >     def print_numbers() > >> >         [1,

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-18 Thread Steve Howell
On Feb 18, 9:52 pm, Gregory Ewing wrote: > Steve Howell wrote: > > Python may not support the broadest notion of anonymous functions, but > > it definitely has anonymous blocks.  You can write this in Python: > > >     for i in range(10): > >         p

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steve Howell
On Feb 19, 7:50 am, Roald de Vries wrote: > > This pipeline idea has actually been implemented further, see > blog.onideas.ws/stream.py>. > > > from stream import map, filter, cut > > range(10) >> map(lambda x: [x**2, x**3]) >> filter(lambda t: t[0]! > > =25 and t[1]!=64) >> cut[1] >> list > > [0

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-19 Thread Steve Howell
On Feb 19, 9:30 am, Steven D'Aprano wrote: > On Fri, 19 Feb 2010 08:32:53 -0800, Steve Howell wrote: > > The extra expressiveness of Ruby comes from the fact that you can add > > statements within the block, which I find useful sometimes just for > > debugging purpos

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-20 Thread Steve Howell
On Feb 20, 6:13 am, Michael Sparks wrote: > On Feb 18, 4:15 pm, Steve Howell wrote: > ... > > >     def print_numbers() > >         [1, 2, 3, 4, 5, 6].map { |n| > >             [n * n, n * n * n] > >         }.reject { |square, cube| > >             squar

Re: Efficient way to break up a list into two pieces

2010-02-21 Thread Steve Howell
On Feb 20, 5:55 pm, marwie wrote: > On 21 Feb., 02:30, Steven D'Aprano > cybersource.com.au> wrote: > > Python lists are arrays of pointers to objects, so copying a slice is > > fast: it doesn't have to copy the objects, just pointers. Deleting from > > the end of the list is also quick, because

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 8:35 pm, Jonathan Gardner wrote: > On Mon, Feb 22, 2010 at 12:31 PM, John Bokma wrote: > > > In my class there where basically 2 groups of people: the ones who got > > functional programming and the ones who had a hard time with it. The > > latter group consisted mostly of people who h

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 9:11 pm, Steve Howell wrote: > On Feb 22, 8:35 pm, Jonathan Gardner > wrote: > > > > > On Mon, Feb 22, 2010 at 12:31 PM, John Bokma wrote: > > > > In my class there where basically 2 groups of people: the ones who got > > > functional program

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Steve Howell
On Feb 22, 9:06 pm, Paul Rubin wrote: > Steve Howell writes: > > My gut instinct is that functional programming works well for lots of > > medium sized problems and it is worth learning. > > I think it's worth learning because it will make you a better programmer >

Re: When will Python go mainstream like Java?

2010-02-22 Thread Steve Howell
On Feb 22, 9:45 pm, Chris Rebert wrote: > On Mon, Feb 22, 2010 at 8:36 PM, Jonathan Gardner > > wrote: > > On Mon, Feb 22, 2010 at 1:56 PM, AON LAZIO wrote: > >> That will be superb > > > It already has. > > Indeed. Python is at position 7, just behind C#, in the TIOBE > Index:http://www.tiobe.

Re: Draft PEP on RSON configuration file format

2010-03-03 Thread Steve Howell
On Mar 3, 7:46 am, mk wrote: > Paul Rubin wrote: > > Patrick Maupin writes: > >> One of my complaints.  If you had read the document you would have > >> seen others.  I actually have several complaints about YAML, but I > >> tried to write a cogent summary. > > Yaml sucks, but seems to have gotte

Re: Generic singleton

2010-03-04 Thread Steve Howell
On Mar 4, 7:32 pm, Steven D'Aprano wrote: > > Python does have it's own singletons, like None, True and False. For some > reason, they behave quite differently: NoneType fails if you try to > instantiate it again, while bool returns the appropriate existing > singleton: > > >>> NoneType = type(Non

Re: A "scopeguard" for Python

2010-03-04 Thread Steve Howell
On Mar 3, 7:10 am, "Alf P. Steinbach" wrote: > For C++ Petru Marginean once invented the "scope guard" technique (elaborated > on > by Andrei Alexandrescu, they published an article about it in DDJ) where all > you > need to do to ensure some desired cleanup at the end of a scope, even when the

Re: Draft PEP on RSON configuration file format

2010-03-04 Thread Steve Howell
On Mar 4, 12:52 am, Paul Rubin wrote: > mk writes: > > OK, but how? How would you make up e.g. for JSON's lack of comments? > > Modify the JSON standard so that "JSON 2.0" allows comments. If you don't control the JSON standard, providing a compelling alternative to JSON might be the best way to

Re: Draft PEP on RSON configuration file format

2010-03-04 Thread Steve Howell
On Mar 4, 9:36 pm, Gregory Ewing wrote: > Paul Rubin wrote: > > ReST was another solution in search of a problem. > > I think the basic idea behind ReST is quite good, i.e. > understanding as markup various typographical conventions > that make sense in plain text, such as underlined > headings, b

Re: Draft PEP on RSON configuration file format

2010-03-05 Thread Steve Howell
On Mar 4, 11:46 pm, Paul Rubin wrote: > > Ehh, either the JSON standardizers care about this issue or else they > don't.  JSON (as currently defined) is a machine-to-machine > serialization format and just isn't that good a choice for handwritten > files.  Adding a comment specification is a small

Re: A "scopeguard" for Python

2010-03-05 Thread Steve Howell
On Mar 5, 8:29 am, Mike Kent wrote: > On Mar 4, 8:04 pm, Robert Kern wrote: > > > No, the try: finally: is not implicit. See the source for > > contextlib.GeneratorContextManager. When __exit__() gets an exception from > > the > > with: block, it will push it into the generator using its .throw(

Re: A "scopeguard" for Python

2010-03-05 Thread Steve Howell
On Mar 4, 5:04 pm, Robert Kern wrote: > On 2010-03-04 15:19 PM, Mike Kent wrote: > > > > > On Mar 3, 12:00 pm, Robert Kern  wrote: > >> On 2010-03-03 09:39 AM, Mike Kent wrote: > > >>> What's the compelling use case for this vs. a simple try/finally? > > >>>      original_dir = os.getcwd() > >>>  

<    1   2   3   4   5   >