Re: Keeping track of things with dictionaries

2014-04-07 Thread Josh English
On Monday, April 7, 2014 9:08:23 PM UTC-7, Chris Angelico wrote: > That depends on whether calling Brand() unnecessarily is a problem. > Using setdefault() is handy when you're working with a simple list or > something, but if calling Brand() is costly, or (worse) if it has side > effects that you

Re: threading

2014-04-07 Thread Marko Rauhamaa
Dennis Lee Bieber : > That's been my experience too... Threading works for me... My > attempts at so called asyncio (whatever language) have always led to > my having to worry about losing data if some handler takes too long to > return. > > To me, asyncio is closer to a polling interr

Re: Keeping track of things with dictionaries

2014-04-07 Thread Chris Angelico
On Tue, Apr 8, 2014 at 2:02 PM, Josh English wrote: > On Sunday, April 6, 2014 12:44:13 AM UTC-7, Giuliano Bertoletti wrote: > > >> obj = brands_seen.get(brandname) >> >> if obj is None: >> obj = Brand() >> brands_seen[brandname] = obj >> >> > > Would dict.setdefault() solve this problem?

Re: Keeping track of things with dictionaries

2014-04-07 Thread Josh English
On Sunday, April 6, 2014 12:44:13 AM UTC-7, Giuliano Bertoletti wrote: > obj = brands_seen.get(brandname) > > if obj is None: > obj = Brand() > brands_seen[brandname] = obj > > Would dict.setdefault() solve this problem? Is there any advantage to defaultdict over setdefault() Josh

change spacing to two instead of four with pep8 or flake8?

2014-04-07 Thread Dennis
Hi, In Pylint you can change the spacing multiplier from 4 spaces to two in its pylintrc, but for the life of me I cannot find a way to do this with the flake8 / pep8 utilities. I want to avoid ignoring E111 altogether if at all possible, because it may catch other spacing problems that are not a

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-07 Thread Chris Angelico
On Tue, Apr 8, 2014 at 11:33 AM, Mark H Harris wrote: > Does a function (or generator) 'do' something (based on name and parms) or > does it 'return' something based on name and parms? If it has no side effects, then it does something, where the 'something' is returning a value. "Return" is a ver

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Steven D'Aprano
On Mon, 07 Apr 2014 20:16:05 -0400, Terry Reedy wrote: > On 4/7/2014 11:26 AM, Paul Kölle wrote: > >> >>> c = (1,2,3) >> >>> d = (1,2,3) >> >>> c is d >> False > > An implementation would be allowed to make that True, as it does for > small ints and short strings that could be identifiers. A

gdb python print truncated string

2014-04-07 Thread Wesley
Hi all, I have a question regarding gdb python. I use gdb7.7 and python2.7.6. Here is snippet that py-print one variable: (gdb) py-print self local 'self' = , timer513645288=<_Timeout at remote 0xb42f760>, timer1248840930=<_Timeout at remote 0x7f85f7f4c300>, timer1678666863=<_Timeout at remote

Re: threading

2014-04-07 Thread Sturla Molden
Dennis Lee Bieber wrote: > That's been my experience too... Threading works for me... My attempts > at so called asyncio (whatever language) have always led to my having to > worry about losing data if some handler takes too long to return. > > To me, asyncio is closer to a polling

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-07 Thread MRAB
On 2014-04-08 02:33, Mark H Harris wrote: On 4/6/14 12:31 PM, Rustom Mody wrote: I think python wins because it (usually) lets people do their thing (includes but not limited to CS-research) and gets out of the way. To say therefore that it is irrelevant to the research is a strange inversion

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-07 Thread Mark H Harris
On 4/6/14 12:31 PM, Rustom Mody wrote: I think python wins because it (usually) lets people do their thing (includes but not limited to CS-research) and gets out of the way. To say therefore that it is irrelevant to the research is a strange inversion of its advantages. I think so too. I f

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Terry Reedy
On 4/7/2014 11:26 AM, Paul Kölle wrote: >>> c = (1,2,3) >>> d = (1,2,3) >>> c is d False An implementation would be allowed to make that True, as it does for small ints and short strings that could be identifiers. >>> a = 'one' >>> b = 'one' >>> a == b; a is b True True However, duplica

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Chris Angelico
On Tue, Apr 8, 2014 at 5:46 AM, Paul Kölle wrote: > Thanks Chris, stupid error indeed ;) Error, at least :) This is why we have a mailing list: errors, inaccuracies, and typos, regardless of who makes them or when, are pretty much guaranteed to be caught. ChrisA -- https://mail.python.org/mailm

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Paul Kölle
Am 07.04.2014 17:44, schrieb Chris Angelico: On Tue, Apr 8, 2014 at 1:26 AM, Paul Kölle wrote: It seems a tuple's immutability is debatable, or is this another instance of the small-integer-reuse-implementation-detail-artifact? Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on li

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Chris Angelico
On Tue, Apr 8, 2014 at 1:26 AM, Paul Kölle wrote: > It seems a tuple's immutability is debatable, or is this another instance of > the small-integer-reuse-implementation-detail-artifact? > > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) > [GCC 4.4.5] on linux2 > > Type "help", "copyright", "cre

Re: Mutable objects inside tuples - good or bad?

2014-04-07 Thread Paul Kölle
Am 06.04.2014 09:25, schrieb Gary Herron: On 04/05/2014 11:53 PM, John Ladasky wrote: I find this programming pattern to be useful... but can it cause problems? No. What kind of problems are you considering? It won't break Python. It's perfectly legal code. The tuple c is still immutable, co

Re: threading

2014-04-07 Thread Chris Angelico
On Tue, Apr 8, 2014 at 12:51 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Mon, Apr 7, 2014 at 11:49 PM, Marko Rauhamaa wrote: >>> Roy Smith : >>> IOW, the processes are there to exercise the CPUs and should not >>> represent individual connections or other dynamic entities. >> >> That's p

Re: threading

2014-04-07 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Apr 7, 2014 at 11:49 PM, Marko Rauhamaa wrote: >> Roy Smith : >> IOW, the processes are there to exercise the CPUs and should not >> represent individual connections or other dynamic entities. > > That's potentially brutal on a shared system! I hope it's controlled > by

ANN: Wing IDE 5.0.5 released

2014-04-07 Thread Wingware
Hi, Wingware has released version 5.0.5 of Wing IDE, our cross-platform integrated development environment for the Python programming language. Wing IDE includes a professional quality code editor with vi, emacs, visual studio, and other key bindings, auto-completion, call tips, goto-definiti

Re: threading

2014-04-07 Thread Chris Angelico
On Mon, Apr 7, 2014 at 11:49 PM, Marko Rauhamaa wrote: > Roy Smith : > >> The idea that we should continue to use threading just because Windows >> makes process creation hideously expensive compared to thread creation >> doesn't impress me as an argument in favor of threading. It impresses >> me

Re: threading

2014-04-07 Thread Chris Angelico
On Mon, Apr 7, 2014 at 11:22 PM, Roy Smith wrote: > In all things technology related, there is an evolutionary path. It > goes something like this: > > * bleeding edge > * avant-garde > * what the kewl kids are using > * modern > * mainstream > * traditional > * corporate standard > * legacy > *

testfixtures 3.0.2 Released!

2014-04-07 Thread Chris Withers
Hi All, I'm pleased to announce the release of testfixtures 3.0.2. This is a bug fix release featuring the following changes: - Document ShouldRaise.raised and make it part of the official API. - Fix rare failures when cleaning up TempDirectory instances on Windows. If you haven't bumped int

Re: threading

2014-04-07 Thread Marko Rauhamaa
Roy Smith : > The idea that we should continue to use threading just because Windows > makes process creation hideously expensive compared to thread creation > doesn't impress me as an argument in favor of threading. It impresses > me as an argument in favor of ditching Windows. There are many re

Re: threading

2014-04-07 Thread Mark Lawrence
On 07/04/2014 14:22, Roy Smith wrote: When I started using Python (1.4), it was somewhere around avant-garde. Now, I figure it's mainstream, which probably means it's time for me to move on to something else soon :-) Python 2.8? -- My fellow Pythonistas, ask not what our language can do for

Re: threading

2014-04-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Apr 7, 2014 at 10:26 PM, Roy Smith wrote: > > Whether something works well on Windows is really not something I worry > > about a lot. > > It's a concern for some of us. You have my sympathy. > it's a fully-supported platform for a lot of Python s

Re: threading

2014-04-07 Thread Chris Angelico
On Mon, Apr 7, 2014 at 10:26 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Mon, Apr 7, 2014 at 1:48 PM, Roy Smith wrote: >> > There is (or at least, was) another reason. Creating a new process used >> > to be far more expensive than creating a new thread. In modern Unix

Re: threading

2014-04-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Apr 7, 2014 at 1:48 PM, Roy Smith wrote: > > There is (or at least, was) another reason. Creating a new process used > > to be far more expensive than creating a new thread. In modern Unix > > kernels, however, the cost difference has become much

Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

2014-04-07 Thread Steven D'Aprano
On Mon, 07 Apr 2014 07:54:27 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 06 Apr 2014 23:10:47 +0300, Marko Rauhamaa wrote: >>> It is academic because the author, Raymond Smullyan, was a professor >>> of philosophy and, more importantly, my professor selected that as a >>> textbo

What is Application Context and Request Context in Flask and WerkZeug.

2014-04-07 Thread Norah Jones
Hi, I am developing a web application using flask, Werkzeug and jinja2. I am very much confused with these terms and wanted to know the meaning of the terms and how they are interrelated to the CGI environment variables. What is global variable g and how it is related to the application contex