On Nov 12, 7:21 am, rusi wrote:
> On Nov 12, 12:09 pm, rusi wrote:> This is a classic
> problem -- structure clash of parallel loops
>
>
>
> Sorry wrong solution :D
>
> The fidgetiness is entirely due to python not allowing C-style loops
> like these:
>
> >> while ((c=getchar()!= EOF) { ... }
>
On Nov 11, 4:44 pm, Cameron Simpson wrote:
> On 11Nov2012 11:16, Steve Howell wrote:
> | On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote:
> | > Steve Howell wrote:
> | > > On Nov 11, 1:09 am, Paul Rubin wrote:
> | > >> Cameron Simpson writes:
&g
On Nov 11, 4:31 pm, Oscar Benjamin wrote:
> On 11 November 2012 22:31, Steven D'Aprano
> > Nonsense. The length and direction of a vector is relative to the origin.
> > If the origin is arbitrary, as you claim, then so is the length of the
> > vector.
>
> Wrong on all counts. Neither the length n
On Nov 10, 11:33 am, Jennie wrote:
> What is the best solution to solve the following problem in Python 3.3?
>
> import math
> >>> class Point:
> ... def __init__(self, x=0, y=0):
> ... self.x = x
> ... self.y = y
> ... def __sub__(self, other):
> ... return Point(
On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote:
> Steve Howell wrote:
> > On Nov 11, 1:09 am, Paul Rubin wrote:
> >> Cameron Simpson writes:
> >> > | I'd prefer the original code ten times over this inaccessible beast.
> >> > M
On Nov 11, 9:48 am, tinn...@isbd.co.uk wrote:
> I'm sure this must be possible but at the moment I can't see how to do it.
>
> I want to send an E-Mail when the logging module logs a message above
> a certain level (probably for ERROR and CRITICAL messages only).
>
> I.e. I want some sort of hook t
On Nov 9, 4:48 pm, bruceg113...@gmail.com wrote:
> Is there a simpler way to modify all arguments in a function before using the
> arguments?
>
> For example, can the below code, in the modify arguments section be made into
> a few statements?
>
> def someComputation (aa, bb, cc, dd, ee, ff,
On Nov 11, 1:09 am, Paul Rubin wrote:
> Cameron Simpson writes:
> > | I'd prefer the original code ten times over this inaccessible beast.
> > Me too.
>
> Me, I like the itertools version better. There's one chunk of data
> that goes through a succession of transforms each of which
> is very str
t; Me, I like the itertools version better. There's one chunk of data
>
> > that goes through a succession of transforms each of which
>
> > is very straightforward.
>
>
>
> [Steve Howell]
>
> > def get_tweets(term, get_page):
On Nov 10, 2:58 pm, Roy Smith wrote:
> I'm trying to pull down tweets with one of the many twitter APIs. The
> particular one I'm using (python-twitter), has a call:
>
> data = api.GetSearch(term="foo", page=page)
>
> The way it works, you start with page=1. It returns a list of tweets.
> If the
I have been reading the thread "while expression feature proposal,"
and one of the interesting outcomes of the thread is the idea that
Python could allow you to attach names to subexpressions, much like C
allows. In C you can say something like this:
tax_next_year = (new_salary = salary * (1 +
On Sep 19, 11:34 am, Ian Kelly wrote:
> On Wed, Sep 19, 2012 at 9:37 AM, Steve Howell wrote:
> > Sequences are iterables, so I'd say the docs are technically correct,
> > but maybe I'm misunderstanding what you would be trying to clarify.
>
> The doc string su
On Sep 19, 8:06 am, Neil Cerutti wrote:
> On 2012-09-19, Ian Kelly wrote:
>
> > It notes in the doc string that it does not work on strings:
>
> > sum(...)
> > sum(sequence[, start]) -> value
>
> > Returns the sum of a sequence of numbers (NOT strings) plus
> > the value of parameter
It's been several years since I announced this page the first time, so
I feel like it's okay to announce it again, possibly introducing a few
new people to Python's elegance and simplicity.
This is my attempt to teach Python to programmers who have experience
in other languages, using gentle immer
On Sep 14, 6:05 am, Tim Chase wrote:
> On 09/14/12 07:01, Steven D'Aprano wrote:> [snip timeout class]
>
> > Holy over-engineering Batman!!!
>
> > No wonder you don't think much of decorators,
>
> [snip]
>
> > Most of my decorator functions are under a dozen lines. And that's the
> > complicated o
On Sep 6, 4:04 am, Oscar Benjamin wrote:
> On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote:
> > For random strings (as defined below), the average compare time is
> > effectively unrelated to the size of the string, once the size
> passes
> > some point.
> > Define random string as being a s
On May 8, 1:05 pm, John Gordon wrote:
> I'm trying to come up with a scheme for organizing exceptions in
> my application.
>
> Currently, I'm using a base class which knows how to look up the text
> of a specific error in a database table, keyed on the error class name.
>
> The base class looks li
On May 7, 8:46 pm, John Nagle wrote:
> On 5/6/2012 9:59 PM, Paul Rubin wrote:
>
> > Javier writes:
> >> Or not... Using directories may be a way to do rapid prototyping, and
> >> check quickly how things are going internally, without needing to resort
> >> to complex database interfaces.
>
> > db
On May 6, 10:21 pm, John Nagle wrote:
> On 5/4/2012 12:14 AM, Steve Howell wrote:
>
> > On May 3, 11:59 pm, Paul Rubin wrote:
> >> Steve Howell writes:
> >>> compressor = zlib.compressobj()
> >>> s = compressor.compress("foobar&qu
On May 3, 6:10 pm, Miki Tebeka wrote:
> > I'm looking for a fairly lightweight key/value store that works for
> > this type of problem:
>
> I'd start with a benchmark and try some of the things that are already in the
> standard library:
> - bsddb
> - sqlite3 (table of key, value, index key)
> -
On May 4, 1:01 am, Paul Rubin wrote:
> Steve Howell writes:
> > Makes sense. I believe I got that part correct:
>
> > https://github.com/showell/KeyValue/blob/master/salted_compressor.py
>
> The API looks nice, but your compress method makes no sense. Why do you
>
On May 3, 11:59 pm, Paul Rubin wrote:
> Steve Howell writes:
> > compressor = zlib.compressobj()
> > s = compressor.compress("foobar")
> > s += compressor.flush(zlib.Z_SYNC_FLUSH)
>
> > s_start = s
> > compressor2 = compres
On May 3, 11:03 pm, Paul Rubin wrote:
> Steve Howell writes:
> > Sounds like a useful technique. The text snippets that I'm
> > compressing are indeed mostly English words, and 7-bit ascii, so it
> > would be practical to use a compression library that just use
On May 3, 9:38 pm, Paul Rubin wrote:
> Steve Howell writes:
> > My test was to write roughly 4GB of data, with 2 million keys of 2k
> > bytes each.
>
> If the records are something like english text, you can compress
> them with zlib and get some compression gain by p
On May 3, 1:42 am, Steve Howell wrote:
> On May 2, 11:48 pm, Paul Rubin wrote:
>
> > Paul Rubin writes:
> > >looking at the spec more closely, there are 256 hash tables.. ...
>
> > You know, there is a much simpler way to do this, if you can afford to
> > us
On May 2, 11:48 pm, Paul Rubin wrote:
> Paul Rubin writes:
> >looking at the spec more closely, there are 256 hash tables.. ...
>
> You know, there is a much simpler way to do this, if you can afford to
> use a few hundred MB of memory and you don't mind some load time when
> the program first st
On May 2, 8:29 pm, Paul Rubin wrote:
> Steve Howell writes:
> > Thanks. That's definitely in the spirit of what I'm looking for,
> > although the non-64 bit version is obviously geared toward a slightly
> > smaller data set. My reading of cdb is that it has essen
On May 2, 7:46 pm, Paul Rubin wrote:
> Steve Howell writes:
> > keys are file paths
> > directories are 2 levels deep (30 dirs w/100k files each)
> > values are file contents
> > The current solution isn't horrible,
>
> Yes it is ;-)
> > As I
This is slightly off topic, but I'm hoping folks can point me in the
right direction.
I'm looking for a fairly lightweight key/value store that works for
this type of problem:
ideally plays nice with the Python ecosystem
the data set is static, and written infrequently enough that I
definitel
On Apr 20, 8:01 pm, Roy Smith wrote:
> In article <4f921a2d$0$29965$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
>
>
>
>
>
>
>
>
> > On Fri, 20 Apr 2012 09:41:25 -0400, Roy Smith wrote:
>
> > > In article <4f910c3d$0$29965$c3e8da3$54964...@news.astraweb.com>,
> > > Steven D'A
On Apr 15, 2:07 pm, Kiuhnm wrote:
> This is the behavior I need:
> path = path.replace('\\', '')
> msg = ". {} .. '{}' .. {} .".format(a, path, b)
> Is there a better way?
>
A little more context would help. The quadruple-toothpick idiom
predates Python. It's a little hard on the
On Apr 5, 10:36 pm, rusi wrote:
> On Apr 6, 9:54 am, Steve Howell wrote:
>
> > JS, YAML, and HTML are pretty similar to Python with respect to single
> > vs. double, as far as I know/remember/care.
>
> [Complete ignoramus here -- writing after a few minutes of googling]
On Apr 5, 9:59 pm, rusi wrote:
> On Apr 6, 6:56 am, Steve Howell wrote:
>
> > One of the biggest nuisances for programmers, just beneath date/time
> > APIs in the pantheon of annoyances, is that we are constantly dealing
> > with escaping/encoding/formatting issues.
>
On Apr 5, 9:59 pm, rusi wrote:
> On Apr 6, 6:56 am, Steve Howell wrote:
>
> > One of the biggest nuisances for programmers, just beneath date/time
> > APIs in the pantheon of annoyances, is that we are constantly dealing
> > with escaping/encoding/formatting issues.
>
On Apr 5, 9:28 pm, rusi wrote:
> On Apr 5, 4:06 pm, Duncan Booth wrote:
>
> > Steven D'Aprano wrote:
> > > JSON expects double-quote marks, not single:
> > > v = json.loads("{'test':'test'}") fails
> > > v = json.loads('{"test":"test"}') succeeds
>
> > You mean JSON expects a string wi
One of the biggest nuisances for programmers, just beneath date/time
APIs in the pantheon of annoyances, is that we are constantly dealing
with escaping/encoding/formatting issues.
I wrote this little program as a cheat sheet for myself and others.
Hope it helps.
# escaping quotes
legal_strin
On Apr 5, 6:03 pm, Steven D'Aprano wrote:
> On Thu, 05 Apr 2012 23:08:11 +0200, André Malo wrote:
> > * Steven D'Aprano wrote:
>
> >> For a 21st century programming language or data format to accept only
> >> one type of quotation mark as string delimiter is rather like having a
> >> 21st century
On Apr 5, 8:10 am, Steve Howell wrote:
> On Apr 5, 7:50 am, "Alex van der Spek" wrote:
>
>
>
>
>
>
>
>
>
> > I do not understand why the spooled write gives an error. See below.
> > The normal tempfile works just fine. They are supposed t
On Apr 5, 8:23 am, Iain King wrote:
> A common one used to be expecting .sort() to return, rather than mutate (as
> it does). Same with .reverse() - sorted and reversed have this covered, not
> sure how common a gotcha it is any more.
>
The sort()/sorted() variations are good to cover. To giv
On Apr 5, 7:50 am, "Alex van der Spek" wrote:
> I do not understand why the spooled write gives an error. See below.
> The normal tempfile works just fine. They are supposed to behave equal?
>
> All insight you can provide is welcome.
> Alex van der Spek
>
> +++
On Apr 5, 5:00 am, Steven D'Aprano wrote:
> On Thu, 05 Apr 2012 11:06:11 +, Duncan Booth wrote:
> > Steven D'Aprano wrote:
>
> >> JSON expects double-quote marks, not single:
> >> v = json.loads("{'test':'test'}") fails v =
> >> json.loads('{"test":"test"}') succeeds
>
> > You mean
On Apr 5, 5:32 am, Roy Smith wrote:
> [...] Nobody expects
> that a JSON parser will be parsing human-written input, [...]
Humans write JSON all the time. People use JSON as a configuration
language, and some people actually write JSON files by hand. A common
example would be writing package.js
On Apr 5, 5:25 am, Steven D'Aprano wrote:
> On Thu, 05 Apr 2012 12:16:09 +, Steven D'Aprano wrote:
> > On Thu, 05 Apr 2012 00:21:31 -0700, Steve Howell wrote:
> >> Why are you changing the invocation between versions of Python?
>
> > Because imaplib.IMA
On Apr 5, 12:09 am, Steven D'Aprano wrote:
> On Wed, 04 Apr 2012 22:13:55 -0700, Steve Howell wrote:
> > On Apr 4, 9:49 pm, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
> >> I can connect to an IMAP server using Python 2.6:
>
> >> st
On Apr 5, 12:09 am, Steven D'Aprano wrote:
> On Wed, 04 Apr 2012 22:13:55 -0700, Steve Howell wrote:
> > On Apr 4, 9:49 pm, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
> >> I can connect to an IMAP server using Python 2.6:
>
> >> st
On Apr 4, 9:49 pm, Steven D'Aprano wrote:
> I can connect to an IMAP server using Python 2.6:
>
> steve@runes:~$ python2.6
> Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>>
> import imaplib
> >>>
On Apr 4, 1:37 am, Chris Angelico wrote:
> On Wed, Apr 4, 2012 at 3:53 PM, Steven D'Aprano
>
> wrote:
> > On Tue, 03 Apr 2012 15:46:31 -0400, D'Arcy Cain wrote:
>
> >> def cp(infile, outfile):
> >> open(outfile, "w").write(open(infile).read())
>
> > Because your cp doesn't copy the FILE, it co
On Apr 3, 11:19 pm, Steven D'Aprano wrote:
> On Tue, 03 Apr 2012 08:39:14 -0400, Nathan Rice wrote:
> > Much like
> > with the terminal to GUI transition, you will have people attacking
> > declarative natural language programming as a stupid practice for noobs,
> > and the end of computing (even
On Apr 3, 3:13 pm, looking for wrote:
> Hi
>
> We are thinking about building a webservice server and considering
> python event-driven servers i.e. Gevent/Tornado/ Twisted or some
> combination thereof etc.
>
> We are having doubts about the db io part. Even with connection
> pooling and cache, t
On Apr 2, 2:50 pm, Chris Angelico wrote:
> On Fri, Mar 30, 2012 at 2:48 AM, Steve Howell wrote:
> > I agree with you on the overall point, but I think that Python
> > actually does a fine job of replacing REXX and PHP. I've used both of
> > the latter (and, of course,
Hi everyone, I have compiled over 500 Python programs from the Rosetta
Code website in this page:
http://shpaml.webfactional.com/misc/RosettaCoffee/python.htm
For those of you unfamiliar with Rosetta Code, you can read more
here:
http://rosettacode.org/wiki/Rosetta_Code
For the record,
On Mar 31, 3:29 am, Terry Reedy wrote:
> On 3/31/2012 2:22 AM, Yingjie Lan wrote:
>
> > Hi all,
>
> > I'd really like to share this idea of string interpolation for formatting.
> > Let's start with some code:
>
> > >>> name = "Shrek"
> > >>> print( "Hi, $name$!")
> > Hi, Shrek!
> > >>> balls =
On Apr 1, 8:30 pm, alex23 wrote:
> On Mar 31, 2:02 am, Steve Howell wrote:
>
> > Steven, how do you predict which abstractions are going to be useless?
>
> A useless abstraction is one that does nothing to simplify a problem
> *now*:
That's the very definition of shor
On Mar 30, 11:25 pm, Lie Ryan wrote:
> On 03/21/2012 01:44 PM, Steve Howell wrote:
>
> > Also, don't they call those thingies "object" for a reason? ;)
>
> A subject is (almost?) always a noun, and so a subject is also an object.
It's true that words that
On Mar 31, 1:13 pm, Tim Rowe wrote:
>
> I know 10 languages. But I'm not telling you what base that number is :)
>
Well, that means you know at least two programming languages, which
puts you ahead of a lot of people. :)
Some folks, when confronted with a problem, decide to solve it with
binary
On Mar 30, 1:20 pm, Chris Angelico wrote:
> > Really? Or could it be that algorithms for natural language
> > processing that don't fail miserably is a very recent development,
> > restricted natural languages more recent still, and pretty much all
> > commonly used programming languages are all
On Mar 29, 8:36 pm, Steven D'Aprano wrote:
> The Romans had perfectly functioning concrete without any abstract
> understanding of chemistry.
If I ever stumbled upon a technology that proved how useless abstract
thinking was, do you know what I would call it?
"Concrete."
Damn, those clever Rom
On Mar 29, 9:42 am, Devin Jeanpierre wrote:
> On Thu, Mar 29, 2012 at 10:03 AM, Chris Angelico wrote:
> > You can't merge all of them without making a language that's
> > suboptimal at most of those tasks - probably, one that's woeful at all
> > of them. I mention SQL because, even if you were to
On Mar 29, 9:38 pm, Nathan Rice
wrote:
> The mathematics of the 20th century, (from the early 30s onward) tend
> to get VERY abstract, in just the way Joel decries. Category theory,
> model theory, modern algebraic geometry, topos theory, algebraic graph
> theory, abstract algebras and topologic
On Mar 29, 11:53 am, Devin Jeanpierre wrote:
> Well, what sort of language differences make for English vs Mandarin?
> Relational algebraic-style programming is useful, but definitely a
> large language barrier to people that don't know any SQL. I think this
> is reasonable. (It would not matter
On Mar 29, 7:03 am, Chris Angelico wrote:
> On Fri, Mar 30, 2012 at 12:44 AM, Nathan Rice
>
> wrote:
> > We would be better off if all the time that was spent on learning
> > syntax, memorizing library organization and becoming proficient with
> > new tools was spent learning the mathematics, log
On Mar 28, 6:55 pm, Ben Finney wrote:
> Steven D'Aprano writes:
> > (By the way, I have to question the design of an exception with error
> > codes. That seems pretty poor design to me. Normally the exception *type*
> > acts as equivalent to an error code.)
>
> Have a look at Python's built-in OS
On Mar 26, 3:56 pm, Abhishek Pratap wrote:
> Hi Guys
>
> I am fwding this question from the python tutor list in the hope of
> reaching more people experienced in concurrent disk access in python.
>
> I am trying to see if there are ways in which I can read a big file
> concurrently on a multi cor
On Mar 23, 12:19 pm, Bernhard Herzog wrote:
> Steve Howell writes:
> > I have a use case where I'm running BaseHTTPServer.HTTPServer, and I
> > want to configure the request handler with some context. I've gotten
> > the code to work, but it feels overly heavy.
I have a use case where I'm running BaseHTTPServer.HTTPServer, and I
want to configure the request handler with some context. I've gotten
the code to work, but it feels overly heavy. I am wondering if
anybody could suggest an easier idiom for this.
This is a brief sketch of the code:
class
On Mar 22, 6:11 pm, Steven D'Aprano wrote:
> On Fri, 23 Mar 2012 06:14:46 +1100, Chris Angelico wrote:
> > On Fri, Mar 23, 2012 at 4:44 AM, Steven D'Aprano
> > wrote:
> >> The typical developer knows three, maybe four languages moderately
> >> well, if you include SQL and regexes as languages, an
On Mar 23, 12:05 am, Chris Angelico wrote:
> On Fri, Mar 23, 2012 at 1:48 PM, Steve Howell wrote:
> > On Mar 22, 6:11 pm, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
> >> In any case, I'm not talking about the best developers. I'm talking a
On Mar 22, 9:43 pm, MRAB wrote:
> On 23/03/2012 04:16, Steve Howell wrote:
>
>
>
>
>
>
>
> > On Mar 22, 8:20 pm, rusi wrote:
> >> On Mar 23, 7:42 am, Steve Howell wrote:
>
> >> > Do you think we'll always have a huge number of inc
On Mar 22, 8:20 pm, rusi wrote:
> On Mar 23, 7:42 am, Steve Howell wrote:
>
> > Do you think we'll always have a huge number of incompatible
> > programming languages? I agree with you that it's a fact of life in
> > 2012, but will it be a fact of life in 2
On Mar 22, 12:14 pm, Chris Angelico wrote:
> On Fri, Mar 23, 2012 at 4:44 AM, Steven D'Aprano
>
> wrote:
> > The typical developer knows three, maybe four languages
> > moderately well, if you include SQL and regexes as languages, and might
> > have a nodding acquaintance with one or two more.
>
On Mar 22, 6:11 pm, Steven D'Aprano wrote:
> On Fri, 23 Mar 2012 06:14:46 +1100, Chris Angelico wrote:
> > In any case, though, I agree that there's a lot of people professionally
> > writing code who would know about the 3-4 that you say. I'm just not
> > sure that they're any good at coding, eve
On Mar 22, 10:44 am, Steven D'Aprano wrote:
> On Thu, 22 Mar 2012 10:29:48 -0400, Nathan Rice wrote:
>
> Or at least before *I* black out. Even if somebody manages to write your
> meta-language, you're going to run into the problem of who is going to be
> able to use it. The typical developer know
On Mar 22, 7:29 am, Nathan Rice
wrote:
> On Thu, Mar 22, 2012 at 9:17 AM, Chris Angelico wrote:
> > On Thu, Mar 22, 2012 at 11:47 PM, Nathan Rice
> > wrote:
> >> Having one core language with
> >> many DSLs that can interoperate is infinitely better than having many
> >> languages that cannot.
On Mar 22, 1:56 am, Steven D'Aprano wrote:
> On Wed, 21 Mar 2012 18:35:16 -0700, Steve Howell wrote:
> > On Mar 21, 11:06 am, Nathan Rice
> > wrote:
> >> As for syntax, we have a lot of "real" domain specific languages, such
> >> as English, math a
On Mar 21, 11:06 am, Nathan Rice
wrote:
> As for syntax, we have a lot of "real" domain specific languages, such
> as English, math and logic. They are vetted, understood and useful
> outside the context of programming. We should approach the discussion
> of language syntax from the perspective o
On Mar 21, 4:34 pm, Steven D'Aprano wrote:
> On Wed, 21 Mar 2012 11:22:01 -0500, Evan Driscoll wrote:
> > On 01/-10/-28163 01:59 PM, Steve Howell wrote:
> >> Code shouldn't necessarily follow the example of English prose, but it
> >> seems that English has
On Mar 21, 9:22 am, Evan Driscoll wrote:
> On 01/-10/-28163 01:59 PM, Steve Howell wrote:
>
>
>
>
>
>
>
>
>
> > Code shouldn't necessarily follow the example of English prose, but it
> > seems that English has had some influence:
>
> > 1
On Mar 21, 12:16 am, Chris Rebert wrote:
> On Tue, Mar 20, 2012 at 11:52 PM, Steve Howell wrote:
> > On Mar 20, 10:40 pm, Chris Angelico wrote:
> >> On Wed, Mar 21, 2012 at 3:58 PM, Steve Howell wrote:
> >> > So saying "push(stack, item)
On Mar 20, 10:40 pm, Chris Angelico wrote:
> On Wed, Mar 21, 2012 at 3:58 PM, Steve Howell wrote:
> > So saying "push(stack, item)" or "push(item, stack)" seems very
> > unsophisticated, almost assembly-like in syntax, albeit at a higher
> > level concep
On Mar 20, 9:16 pm, Chris Angelico wrote:
> On Wed, Mar 21, 2012 at 1:44 PM, Steve Howell wrote:
> > I think it's a matter of perspective, so there's no right answer, but
> > I always think of the program object as also being the grammatical
> > object, with
On Mar 20, 3:50 pm, Ian Kelly wrote:
> On Tue, Mar 20, 2012 at 3:16 PM, Dennis Lee Bieber
>
> wrote:
> > On Tue, 20 Mar 2012 16:23:22 -0400, "J. Cliff Dyer"
> > declaimed the following in
> > gmane.comp.python.general:
>
> >> When trying to create a class with a dual-loop generator expression in
On Mar 20, 7:28 pm, Ben Finney wrote:
> Steve Howell writes:
> > Also, while the above idiom puts the verbs in the right order, it is
> > still backward to me to say "noun.verb." You don't noun a verb. You
> > verb a noun.
>
> When calling a method, the
On Mar 20, 5:22 pm, Steven D'Aprano wrote:
> On Tue, 20 Mar 2012 15:28:25 -0400, Nathan Rice wrote:
>
> > What if you are composing
> > three or four functions, each of which is conditional on the data? If
> > you extract things from a statement and assign them somewhat arbitrary
> > names, you'v
On Dec 14, 9:01 pm, Steven D'Aprano wrote:
> [...]
> So what are methods? In Python, methods are wrappers around functions
> which automatically pass the instance to the inner function object. Under
> normal circumstances, you create methods by declaring functions inside a
> class, but that's not
On Dec 14, 12:01 am, Steven D'Aprano wrote:
> [...]
>
> So the normal lookup rules that apply to data attributes, namely
> instance, then class, then superclasses, also applies to methods in
> Python. In languages that don't allow that sort of thing, like Java, you
> need to use convoluted design
I'm using Python 3.2.2, and the following program gives me an error
that I don't understand:
class Foo:
pass
foo = Foo()
foo.name = "Steve"
def add_goodbye_function(obj):
def goodbye():
print("goodbye " + obj.name)
obj.goodbye = goodbye
add_goodbye_function(foo)
foo.goodbye() # output
On Oct 14, 8:45 pm, Cameron Simpson wrote:
> On 14Oct2010 20:11, Steve Howell wrote:
> | Is there a way to extract code out of a generator function f() into
> | g() and be able to have f() yield g()'s result without this idiom?:
> |
> | for g_result in g():
> | yi
On Oct 14, 9:22 pm, Lawrence D'Oliveiro wrote:
> In message
> <12fcd67a-774d-42f0-851a-9c3497df9...@s24g2000pri.googlegroups.com>, Steve
>
> Howell wrote:
> > On Oct 14, 4:09 pm, Gregory Ewing wrote:
> >> Steve Howell wrote:
>
> >> Maybe &qu
Is there a way to extract code out of a generator function f() into
g() and be able to have f() yield g()'s result without this idiom?:
for g_result in g():
yield g_result
It feels like a clumsy hindrance to refactoring, to have to introduce
a local variable and a loop.
Here is a program t
On Oct 14, 7:08 pm, Paul Rubin wrote:
> Steven D'Aprano writes:
> > (4) Expensive generators. The beauty of generators is that they produce
> > values on demand. Making all generators cache their first value means
> > that you pay that cost even if you end up never needing the first value.
>
> Yo
On Oct 13, 8:32 pm, Lawrence D'Oliveiro wrote:
> In message
> , Steve
>
> Howell wrote:
> > Bulk-load strategies usually solve one or more of these problems:
>
> > network latency
>
> That’s not an issue. This is a bulk operation, after all.
>
> >
On Oct 14, 4:09 pm, Gregory Ewing wrote:
> Steve Howell wrote:
> > That was the original context of my comment. The term "symmetry" gets
> > used a couple times in that PEP, and I think we're in violent
> > agreement that the concept of "symmetry"
On Oct 13, 12:36 pm, jimgardener wrote:
> hi
> I have some demo python code hosted on a public host that uses
> subversion..and I want to modify one of the files using a patch file
> handed to me by another person..How do I do this?Generally I checkout
> the code and make the change and then comm
On Oct 13, 12:31 pm, Steven D'Aprano wrote:
0.2141693770623265
>
> Perhaps this will help illustrate what I'm talking about... the
> mathematician Mitchell Feigenbaum discovered in 1975 that, for a large
> class of chaotic systems, the ratio of each bifurcation interval to the
> next approached a
On Oct 13, 7:25 pm, Lawrence D'Oliveiro wrote:
> In message
> , Steve
>
> Howell wrote:
> > I guess a lot depends on how you define "symmetry." Is your
> > definition of "symmetry" equivalent to your definition of
> > "orthogonality&
On Oct 13, 4:27 pm, Lawrence D'Oliveiro wrote:
> In message
> <57a322df-8e42-4da5-af96-0c21c5733...@b14g2000pro.googlegroups.com>, Steve
>
> Howell wrote:
> > Lawrence, I was actually talking about symmetry, not orthogonality.
>
> So what’s the difference?
I d
On Oct 11, 1:40 am, Antoon Pardon
wrote:
> On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote:
> > On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote:
>
> > > On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano
> > > wrote:
> > >> On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote:
On Oct 12, 6:01 pm, Lawrence D'Oliveiro wrote:
> In message <4cb4ba4e$0$1641$742ec...@news.sonic.net>, John Nagle wrote:
>
> > In general, if you find yourself making millions of
> > SQL database requests in a loop, you're doing it wrong.
>
> I’ve done this. Not millions, but certainly on the orde
On Oct 12, 5:54 pm, Lawrence D'Oliveiro wrote:
> In message , D'Arcy
>
> J.M. Cain wrote:
> > On Tue, 12 Oct 2010 23:34 +1300
> > Lawrence D'Oliveiro wrote:
>
> >>> Symmetry is always a tricky balance in programming languages.
>
> >> Is that what we used to call “orthogonality”?
>
> > No, orthogo
On Oct 11, 5:11 pm, Gregory Ewing wrote:
> Robert Kern wrote:
> > The reasoning for this decision is spelled out in the PEP introducing
> > the iterator feature:
>
> > http://www.python.org/dev/peps/pep-0234/
>
> There's also the question of whether 'if x in dict' should
> compare keys only or bo
1 - 100 of 452 matches
Mail list logo