Re: Python is readable

2012-03-21 Thread Steve Howell
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

Re: Python is readable

2012-03-22 Thread Steve Howell
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

Re: Python is readable

2012-03-22 Thread Steve Howell
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.  

Re: Python is readable

2012-03-22 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-22 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-22 Thread Steve Howell
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. >

Re: Python is readable

2012-03-22 Thread Steve Howell
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

Re: Python is readable

2012-03-23 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Steve Howell
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

passing context into BaseHTTPRequestHandler

2012-03-23 Thread Steve Howell
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

Re: passing context into BaseHTTPRequestHandler

2012-03-23 Thread Steve Howell
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.

Re: concurrent file reading/writing using python

2012-03-26 Thread Steve Howell
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

Re: unittest: assertRaises() with an instance instead of a type

2012-04-02 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Steve Howell
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

Re: Python is readable

2012-04-02 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Steve Howell
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

Re: Python is readable

2012-04-02 Thread Steve Howell
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

Re: Python is readable

2012-04-02 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Steve Howell
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

Re: Python is readable

2012-04-02 Thread Steve Howell
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

Re: Python is readable

2012-04-02 Thread Steve Howell
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

Re: string interpolation for python

2012-04-02 Thread Steve Howell
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 =

588 Python programs

2012-04-02 Thread Steve Howell
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,

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Steve Howell
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,

Re: Async IO Server with Blocking DB

2012-04-04 Thread Steve Howell
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

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-04 Thread Steve Howell
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

Re: No os.copy()? Why not?

2012-04-04 Thread Steve Howell
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

Re: Cannot connect to IMAP server in Python 3.2

2012-04-04 Thread Steve Howell
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

Re: Cannot connect to IMAP server in Python 3.2

2012-04-05 Thread Steve Howell
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

Re: Cannot connect to IMAP server in Python 3.2

2012-04-05 Thread Steve Howell
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

Re: Cannot connect to IMAP server in Python 3.2

2012-04-05 Thread Steve Howell
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

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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

Re: Difference between tempfile and spooled tempfile?

2012-04-05 Thread Steve Howell
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 > > +++

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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

Re: Difference between tempfile and spooled tempfile?

2012-04-05 Thread Steve Howell
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

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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

escaping/encoding/formatting in python

2012-04-05 Thread Steve Howell
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

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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

Re: escaping/encoding/formatting in python

2012-04-05 Thread Steve Howell
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. >

Re: escaping/encoding/formatting in python

2012-04-05 Thread Steve Howell
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. >

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
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]

Re: escaping

2012-04-15 Thread Steve Howell
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

Re: How do you refer to an iterator in docs?

2012-04-20 Thread Steve Howell
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

key/value store optimized for disk storage

2012-05-02 Thread Steve Howell
cussing this here, I'm happy to follow up on any questions. Thanks, Steve P.S. I've already found some good information via Google, but there's a lot of noise out there. -- http://mail.python.org/mailman/listinfo/python-list

Re: key/value store optimized for disk storage

2012-05-02 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-02 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-03 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-03 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-03 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-03 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-04 Thread Steve Howell
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

Re: key/value store optimized for disk storage

2012-05-04 Thread Steve Howell
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 >

Re: key/value store optimized for disk storage

2012-05-04 Thread Steve Howell
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) > -

Re: key/value store optimized for disk storage

2012-05-07 Thread Steve Howell
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

Re: Creating a directory structure and modifying files automatically in Python

2012-05-07 Thread Steve Howell
>> to complex database interfaces. > > > dbm and shelve are extremely simple to use.  Using the file system for a > > million item db is ridiculous even for prototyping. > >     Right.  Steve Bellovin wrote that back when UNIX didn't have any > database programs, let al

Re: How to get outer class name from an inner class?

2012-05-08 Thread Steve Howell
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

Extracting DB schema (newbie Q)

2012-05-14 Thread Steve Sawyer
Brand-new to Python (that's a warning, folks) Trying to write a routine to import a CSV file into a SQL Server table. To ensure that I convert the data from the CSV appropriately, I"m executing a query that gives me the schema (data column names, data types and sizes) from the target table. What

Re: Extracting DB schema (newbie Q)

2012-05-14 Thread Steve Sawyer
x27;]['size'] # -> 200 table_dict['Artist']['size'] #-> 50 Is this (nesting dictionaries) a good way to store multiple attributes associated with a single key value? On Mon, 14 May 2012 17:05:17 + (UTC), John Gordon wrote: >In Steve Sawyer > writes

Re: Extracting DB schema (newbie Q)

2012-05-17 Thread Steve Sawyer
Thanks, James, but John Gordon identified my usage error so I'm good to go now. On Mon, 14 May 2012 09:28:06 -0700 (PDT), james hedley wrote: >On Monday, 14 May 2012 17:01:49 UTC+1, Steve Sawyer wrote: >> Brand-new to Python (that's a warning, folks) >> >> Tryi

Print Window on IDLE

2011-06-06 Thread Steve Oldner
Seems to work using 2.7 but not 3.2. On 3.2 it just closes all my python sessions. Is this a bug? Can someone point me to a "How To" on using a local printer in windows? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: new string formatting with local variables

2011-06-06 Thread Steve Crook
On Mon, 6 Jun 2011 12:15:35 -0400, Jabba Laci wrote in Message-Id: : > solo = 'Han Solo' > jabba = 'Jabba the Hutt' > print "{solo} was captured by {jabba}".format(solo=solo, jabba=jabba) > # Han Solo was captured by Jabba the Hutt How about:- print "%s was captured by %s" % (solo, jabba) -- ht

Re: Print Window on IDLE

2011-06-07 Thread Steve Oldner
Thanks Gabriel! Do you know where any documentation is on printing to a local printer for 3.2? I've found Hammond's and Golden's info for win32, but haven't seen if it works for 3.2. Again thank you for your reply and submitting the bug. -- Steve Oldner -Origin

Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
Hi all, I've always done key creation/incrementation using: if key in dict: dict[key] += 1 else: dict[key] = 1 Today I spotted an alternative: dict[key] = dict.get(key, 0) + 1 Whilst certainly more compact, I'd be interested in views on how pythonesque this method is. -- http://mail.p

Re: Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
On Tue, 14 Jun 2011 05:37:45 -0700 (PDT), AlienBaby wrote in Message-Id: <078c5e9a-8fad-4d4c-b081-f69d0f575...@v11g2000prk.googlegroups.com>: > How do those methods compare to the one I normally use; > > try: > dict[key]+=1 > except: > dict[key]=1 This is a lot slower in percentage terms. You

Re: Dictionaries and incrementing keys

2011-06-14 Thread Steve Crook
On Tue, 14 Jun 2011 13:16:47 +0200, Peter Otten wrote in Message-Id: : > Your way is usually faster than > >> dict[key] = dict.get(key, 0) + 1 Thanks Peter, ran it through Timeit and you're right. It's probably also easier to read the conditional version, even if it is longer. > You may also c

Community Involvement

2011-08-03 Thread Steve Holden
dth student would be abused and the thousandth murdered). So I wondered if anyone had any good ideas. regards Steve -- Steve Holden st...@holdenweb.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Community Involvement

2011-08-04 Thread Steve Holden
Haven't had much Cc input so far, but this one is definitely worth following up on. Thanks! regards Steve On Aug 4, 2011, at 5:42 PM, Eric Snow wrote: > On Wed, Aug 3, 2011 at 9:14 PM, Steve Holden wrote: >> [Ccs appreciated] >> After some three years labor I (@holdenweb)

Re: Case-insensitive string equality

2017-09-03 Thread Steve D'Aprano
ple all the time doesn't mean its not worthwhile. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: Case-insensitive string equality

2017-09-03 Thread Steve D'Aprano
ot allowed in > German? If so, that's very different from English. Germans use ALLCAPS for headlines, book titles, emphasis etc just as English speakers do. For example: http://www.spiegel.de/politik/index.html -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Steve D'Aprano
t; # continues on for millions more characters does the interpreter make a copy of the 100MB string? If not, then it isn't pass (call) by value. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Capital ß [was Re: Case-insensitive string equality]

2017-09-03 Thread Steve D'Aprano
On Sat, 2 Sep 2017 01:48 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>[1] I believe that the German government has now officially recognised the >>uppercase form of ß. > > [skip to the last paragraph for some "ß" content, > unless you want to r

Re: A question on modification of a list via a function invocation

2017-09-03 Thread Steve D'Aprano
by immutability? Pass the salt? My understanding is that LISP has more-or-less the same calling mechanism as Python, only it had it long before Barbara Liskov gave a name to it when describing CLU. [1] What, only one? *wink* -- Steve “Cheer up,” they said, “things could be worse.” So I c

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
x27;s just understood. Nevertheless, terms such > as "object reference" and "reference to an object" do > get used in relation to Python when clarity is needed. Certainly they do. That has nothing to do with the question of whether Python has references as values. We use t

Re: meaning of [ ]

2017-09-04 Thread Steve D'Aprano
e same one? > As Peter pointed out this is a no-op > ie > [p for p in sys.path] > > could be written as > list(sys.path) That's not what "no-op" means. If it returns a result, it isn't a no-op. > [Not sure why he didnt say just sys.path] Because sys.path re

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
uot;third-class" even makes sense, but pointers, and references, are not values of *any* class in Python. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
about assignment talks about reference counts. Does that mean that IronPython and Jython aren't implementations of Python? They have no reference counts. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 01:31 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>That makes arrays (and strings) in C a bit of an odd corner case, and an >>exception to the usual rules, like unboxed machine types in Java. We should >>acknowledge them, but as exceptional case

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
r-passing-nomenclature arguments are just > the fallout of that. This is not a dispute unique to the Python community. Similar arguments take place in the Java and Ruby communities, and I daresay many others. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sur

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 12:09 am, Antoon Pardon wrote: > Op 04-09-17 om 15:26 schreef Steve D'Aprano: >> On Mon, 4 Sep 2017 08:52 pm, Antoon Pardon wrote: >> >>> Op 04-09-17 om 12:22 schreef Stefan Ram: >>>> Rustom Mody writes: >>>>>>

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Mon, 4 Sep 2017 11:30 pm, Antoon Pardon wrote: > Op 04-09-17 om 15:24 schreef Steve D'Aprano: >> I accept that many people dislike, or do not understand, conceptual models >> where objects can be in more than one location at once. For many people, >> dropping i

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
rn self and attempts to bind the return result to the target: temp = t[0].__iadd__([999]) t[0] = temp The assignment is necessary to support types like tuples, ints, strings etc. which don't perform an in-place modification. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 12:59 am, Rustom Mody wrote: > On Monday, September 4, 2017 at 7:50:39 PM UTC+5:30, Steve D'Aprano wrote: >> On Mon, 4 Sep 2017 01:11 pm, Rustom Mody wrote: >> > Simply put: pythonistas have no coherent/consistent sense of what python >> > value

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
-- but I don't see the point of it. What conclusion do you draw from that? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
On Tue, 5 Sep 2017 02:51 am, Stefan Ram wrote: > Steve D'Aprano writes: >>Sorry Stefan, that is the same trap that many others fall into. You are >>assuming that there are exactly two evaluation conventions: >>- pass by reference >>- pass by value >>and so

Re: meaning of [ ]

2017-09-04 Thread Steve D'Aprano
aid the opposite? [...] > People prefer to give the implementation of comprehensions > rather than giving the connection to its parent notion+notation which in > all probability the OP knows and is simply unable to connect because of > clunkyness of ASCII-fied syntax You have no evi

Re: A question on modification of a list via a function invocation

2017-09-04 Thread Steve D'Aprano
; The default passing mechanism would be similar to the description of C# > ("boxed" types being implicit copies of references allowing mutation > in-place, but assignment to the parameter itself has no effect on the > caller). I suspect it too has some means to explicitly produce a > by-reference parameter. > > Python... does not have this dichotomy of "simple" and "reference" > types -- everything is a "reference" type but may be immutable or mutable; > mutable can be modified in-place, immutables can not be modified. > Assignment to a parameter name replaces the object locally, with no effect > on the argument provided by the caller. There is no provision to expose a > reference (to a reference) nor to dereference any thing. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I find what kind of exception is thrown.

2017-09-05 Thread Steve D'Aprano
ed trouble > > Now I found the following in the logs: [Errno 131] Connection reset by peer > > This is a problem I would like to catch earlier however I have no idea what > exception I would have to catch in order to treat this case. try: do_stuff except Exception as err: p

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
nability to refer to the reference itself, the lack of references to references, and the inability to have a container of references, makes them second-class values -- or possibly not values at all. (I don't know enough about C++ to distinguish between the last two opinions, but I'm stron

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:08 pm, Stefan Ram wrote: > Steve D'Aprano writes: >>[quote] >>The mistake they make is in the definition of >>Figure 7: (Java) Defining a Dog pointer >>Dog d; >>itself. When you write that definition, you are defining a pointer to a

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:47 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> [quoting Scott Stanchfield] >> Figure 7: (Java) Defining a Dog pointer >> Dog d; >> >> When you write that definition, you are defining a pointer to a Dog

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-05 Thread Steve D'Aprano
atical expression. (That's not a dot product.) > What were Turing, Church, von Neumann, even Knuth by training? Mathematicians > or CS-ists? > > And what are the contributions of Turing, Church, von Neumann, Knuth to CS? Who cares? We're talking about Python, not Computer Scien

Re: Case-insensitive string equality

2017-09-05 Thread Steve D'Aprano
;s good style. It is true that in general we don't write ordinary prose in all caps, there are plenty of non-kook uses for it. But speaking of capitals on the Internet: HI EVERYBODY!! try pressing the the Caps Lock key O THANKS!!! ITS SO MUCH EASIER TO WRITE NOW!!! fuck me http://bash.org/?835030 -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-05 Thread Steve D'Aprano
On Tue, 5 Sep 2017 11:11 pm, Gregory Ewing wrote: > Steve D'Aprano wrote: >> The third entity is the reference linking the name to the object (the arrow). >> This isn't a runtime value in Python, nor is it a compile time entity that >> exists in source code. It is p

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
ly seems > strange when someone like Dijkstra grumbles at the anthropomorphism and asks > why its not called 'store'. And if it were called "store" (grocery store? shoe store? clothes store?) Dijkstra would have grumbled at the metaphor and asked why it wasn't called &q

Re: Using __init__.py

2017-09-06 Thread Steve D'Aprano
ct directory, and the full contents of sys.path. Do not try to retype them from memory. Accuracy is essential: copy and paste the paths so that they are accurate. Thank you. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
ent2(p: intpointer); begin p^ := p^ + 1 end; var a: integer; b: integer; begin a := 99; increment(a); writeln(a); {will print 100} b := 99; increment2(@b); writeln(b); {will print 100} end. If there's a difference, its a subtle one which I haven't found in a short amount of testing. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list

Re: A question on modification of a list via a function invocation

2017-09-06 Thread Steve D'Aprano
On Wed, 6 Sep 2017 10:11 pm, Rustom Mody wrote: > On Wednesday, September 6, 2017 at 5:08:20 PM UTC+5:30, Steve D'Aprano wrote: >> On Wed, 6 Sep 2017 07:13 pm, Rustom Mody wrote: >> >> >> > Can you explain what "id" and "is" without talking

<    1   2   3   4   5   6   7   8   9   10   >