PyWart fixed mostly, was: Re: Python Gotcha's?

2013-01-22 Thread Bryan
On Apr 14 2012, 2:47 pm I wrote: Miki Tebeka wrote: If you have an interesting/common Gotcha (warts/dark corners ...) please share. Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, and in some/many/most *nix implementations, it likes to install in

Re: Python Gotcha's?

2012-04-19 Thread Albert van der Horst
In article 4f7de152$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 05 Apr 2012 08:32:10 -0400, Roy Smith wrote: In article 4f7d896f$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

Re: Python Gotcha's?

2012-04-19 Thread Chris Angelico
On Thu, Apr 19, 2012 at 11:11 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: I still think the doubling convention of Algol68 is superior: Help me Obiwan, she said, You're my only hope! No special treatment of any other symbol than the quote itself. A quoting symbol is such a

Re: Python Gotcha's?

2012-04-16 Thread Paul Rubin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Running both Python 2 and Python 3 on Windows is painful where it doesn't need to be. And how is that different from any other two versions of Python? 1. The backwards incompatibility between 2 and 3 is much more serious than between

Re: Python Gotcha's?

2012-04-16 Thread Bryan
Steven D'Aprano wrote: And how is that different from any other two versions of Python? Python 3.0, also known as “Python 3000” or “Py3K”, is the first ever *intentionally backwards incompatible* Python release. --GVR Unless both versions include the same libraries (either standard modules or

Re: Python Gotcha's?

2012-04-16 Thread rusi
On Apr 16, 11:44 am, Bryan bryanjugglercryptograp...@yahoo.com wrote: Steven D'Aprano wrote: And how is that different from any other two versions of Python? Python 3.0, also known as “Python 3000” or “Py3K”, is the first ever *intentionally backwards incompatible* Python release. --GVR

Re: Python Gotcha's?

2012-04-16 Thread Paul Rubin
rusi rustompm...@gmail.com writes: Costs can be single-cased (s) -- basically those that can be handled by a 2to3 module You can't really 2to3 a large python application and expect to then just start using it without further attention or testing. You may have to do a fairly complete (i.e.

Re: Python Gotcha's?

2012-04-16 Thread Mark Lawrence
On 16/04/2012 06:34, Steven D'Aprano wrote: The situation is worse on Windows, as Windows doesn't support hash-bang syntax. But that is being looked at now: http://www.python.org/dev/peps/pep-0397/ which should make supporting multiple Python versions much more pleasant Real Soon Now. No

Re: Python Gotcha's?

2012-04-15 Thread Bryan
Steven D'Aprano wrote: Bryan wrote: Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, And so it should. We disagree. Not surprising in a gotcha's thread. and in some/many/most *nix implementations, it likes to install in the same place. I won't

Re: Python Gotcha's?

2012-04-15 Thread Chris Angelico
On Sun, Apr 15, 2012 at 7:23 PM, Bryan bryanjugglercryptograp...@yahoo.com wrote: Yes, that was just silly of me to write that. All I want is a new general convention for the most-likely-to-work invocation that won't break with the change: #!/usr/bin/env python for Python 2 versus, for

Re: Python Gotcha's?

2012-04-15 Thread Mark Lawrence
On 15/04/2012 10:23, Bryan wrote: My perspective is simply different from yours. I'm not the one who installs python on most of the boxes where I work or play. There's little consistency, so I love conventions that usually work. I'd like to advocate for Python 3, but the default install on

Re: Python Gotcha's?

2012-04-15 Thread Steven D'Aprano
On Sun, 15 Apr 2012 02:23:27 -0700, Bryan wrote: Steven D'Aprano wrote: Bryan wrote: Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, And so it should. We disagree. Not surprising in a gotcha's thread. Yes, but I have reasons for disagreeing,

Re: Python Gotcha's?

2012-04-15 Thread Curt
On 2012-04-15, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: We disagree. Not surprising in a gotcha's thread. Yes, but I have reasons for disagreeing, which you trimmed out of your response. If you have reasons for thinking that a separate file extension for Python 3 is a

Re: Python Gotcha's?

2012-04-15 Thread Steven D'Aprano
On Sun, 15 Apr 2012 15:30:39 +, Curt wrote: On 2012-04-15, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: We disagree. Not surprising in a gotcha's thread. Yes, but I have reasons for disagreeing, which you trimmed out of your response. If you have reasons for thinking

Re: Python Gotcha's?

2012-04-15 Thread Bryan
Steven wrote: Yes, but I have reasons for disagreeing, which you trimmed out of your response. If you have reasons for thinking that a separate file extension for Python 3 is a good idea, you are keeping it to yourself. On Windows the file extension determines what executable opens the file.

Re: Python Gotcha's?

2012-04-15 Thread Terry Reedy
On 4/15/2012 4:01 PM, Bryan wrote: On Windows the file extension determines what executable opens the file. Running both Python 2 and Python 3 on Windows is painful where it doesn't need to be. I'd like to encourage my users to check out Python 3, but installing it on Windows will take over the

Re: Python Gotcha's?

2012-04-15 Thread Mark Lawrence
On 15/04/2012 21:01, Bryan wrote: Steven wrote: Yes, but I have reasons for disagreeing, which you trimmed out of your response. If you have reasons for thinking that a separate file extension for Python 3 is a good idea, you are keeping it to yourself. On Windows the file extension

Re: Python Gotcha's?

2012-04-15 Thread David Robinow
On Sun, Apr 15, 2012 at 4:01 PM, Bryan bryanjugglercryptograp...@yahoo.com wrote: On Windows the file extension determines what executable opens the file. Running both Python 2 and Python 3 on Windows is painful where it doesn't need to be. I'd like to encourage my users to check out Python 3,

Re: Python Gotcha's?

2012-04-15 Thread Andrew Berg
On 4/15/2012 3:01 PM, Bryan wrote: I'd like to encourage my users to check out Python 3, but installing it on Windows will take over the '.py' extension and break stuff that currently works. Have you tried telling your users to tell the installer not to do that? IIRC, it's a simple checkbox

Re: Python Gotcha's?

2012-04-15 Thread Steven D'Aprano
On Sun, 15 Apr 2012 13:01:54 -0700, Bryan wrote: Steven wrote: Yes, but I have reasons for disagreeing, which you trimmed out of your response. If you have reasons for thinking that a separate file extension for Python 3 is a good idea, you are keeping it to yourself. On Windows the file

Re: Python Gotcha's?

2012-04-15 Thread alex23
On Apr 16, 3:34 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: The situation is worse on Windows, as Windows doesn't support hash-bang syntax. But that is being looked at now: http://www.python.org/dev/peps/pep-0397/ which should make supporting multiple Python versions

Re: Python Gotcha's?

2012-04-14 Thread Bryan
Miki Tebeka wrote: If you have an interesting/common Gotcha (warts/dark corners ...) please share. Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, and in some/many/most *nix implementations, it likes to install in the same place. Python 3 is an

Re: Python Gotcha's?

2012-04-14 Thread Chris Angelico
On Sun, Apr 15, 2012 at 8:47 AM, Bryan bryanjugglercryptograp...@yahoo.com wrote: Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, and in some/many/most *nix implementations, it likes to install in the same place. Python 3 is an improvement upon Python

Re: Python Gotcha's?

2012-04-14 Thread MRAB
On 14/04/2012 23:47, Bryan wrote: Miki Tebeka wrote: If you have an interesting/common Gotcha (warts/dark corners ...) please share. Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, and in some/many/most *nix implementations, it likes to install in

Re: Python Gotcha's?

2012-04-14 Thread Steven D'Aprano
On Sat, 14 Apr 2012 15:47:54 -0700, Bryan wrote: Miki Tebeka wrote: If you have an interesting/common Gotcha (warts/dark corners ...) please share. Python 3(K) likes to use the same '.py' file extension as its incompatible predecessors, And so it should. Python 2 and Python 3 are two

Re: Python Gotcha's?

2012-04-09 Thread Neil Cerutti
On 2012-04-08, John Nagle na...@animats.com wrote: 6. Multiple inheritance is a mess. Especially super. Python allows you to get dirty. Super solves a messy problem. 10. Python 3 isn't upward compatible with Python 2. Even minor versions of Python are usually not forward compatible. In the

Re: Python Gotcha's?

2012-04-09 Thread Stefan Schwarzer
Hi Miki, On 2012-04-05 00:34, Miki Tebeka wrote: I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). I gave a somewhat similar talk

Re: Python Gotcha's?

2012-04-08 Thread Roy Smith
In article jlr2iu$ish$1...@dont-email.me, John Nagle na...@animats.com wrote: 1. Nobody is really in charge of third party packages. In the Perl world, there's a central repository, CPAN, and quality control. Python's pypi is just a collection of links. Many major packages are maintained

Re: Python Gotcha's?

2012-04-08 Thread Miki Tebeka
8. Opening a URL can result in an unexpected prompt on standard input if the URL has authentication. This can stall servers. Can you give an example? I don't think anything in the standard library does that. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-08 Thread Chris Angelico
On Mon, Apr 9, 2012 at 3:55 AM, Miki Tebeka miki.teb...@gmail.com wrote: 8.  Opening a URL can result in an unexpected prompt on standard input if the URL has authentication.  This can stall servers. Can you give an example? I don't think anything in the standard library does that. I just

Re: Python Gotcha's?

2012-04-08 Thread John Nagle
On 4/8/2012 10:55 AM, Miki Tebeka wrote: 8. Opening a URL can result in an unexpected prompt on standard input if the URL has authentication. This can stall servers. Can you give an example? I don't think anything in the standard library does that. It's in urllib. See

Re: Python Gotcha's?

2012-04-08 Thread André Malo
* Grzegorz Staniak wrote: On 06.04.2012, rusi rustompm...@gmail.com wroted: There should be one-- and preferably only one --obvious way to do it. Then again, practicality beats purity. Yes. If you ever grepped for, say, the usage of dictionary keys in a bigger application, you might

Re: Python Gotcha's?

2012-04-07 Thread Tim Roberts
Roy Smith r...@panix.com wrote: There's absolutely no reason why JSON should follow Python syntax rules. No, but there certainly is a justification for expecting JAVASCRIPT Object Notation (which is, after all, what JSON stands for) to follow Javascript's syntax rules. And Javascript happens

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 1:47 PM, Tim Roberts t...@probo.com wrote: No, but there certainly is a justification for expecting JAVASCRIPT Object Notation (which is, after all, what JSON stands for) to follow Javascript's syntax rules.  And Javascript happens to follow the same quoting rules as

Re: Python Gotcha's?

2012-04-07 Thread John Nagle
On 4/4/2012 3:34 PM, Miki Tebeka wrote: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). Thanks, -- Miki A few Python gotchas

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 2:01 PM, John Nagle na...@animats.com wrote: 4.  The syntax for expression-IF is just weird. Agreed. Putting an expression first feels weird; in every high level language I know of, the word if is followed by the condition, and then by what to do if true, and then what to

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 2:19 PM, Chris Angelico ros...@gmail.com wrote: Agreed. Putting an expression first feels weird; in every high level language I know of, the word if is followed by the condition, and then by what to do if true, and then what to do if false - not true, then condition,

Re: Python Gotcha's?

2012-04-06 Thread Steve Howell
On Apr 5, 10:36 pm, rusi rustompm...@gmail.com wrote: On Apr 6, 9:54 am, Steve Howell showel...@yahoo.com 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

Re: Python Gotcha's?

2012-04-06 Thread mwilson
rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published in their book _Software Tools_. Mel. --

Re: Python Gotcha's?

2012-04-06 Thread Roy Smith
In article jlmaid$hum$1...@dont-email.me, mwil...@the-wire.com wrote: rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published

Re: Python Gotcha's?

2012-04-06 Thread mwilson
Roy Smith wrote: In article jlmaid$hum$1...@dont-email.me, mwil...@the-wire.com wrote: rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did

Re: Python Gotcha's?

2012-04-06 Thread Steven D'Aprano
On Thu, 05 Apr 2012 21:28:01 -0700, rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others. Other languages like Perl, PHP and

Re: Python Gotcha's?

2012-04-06 Thread Grzegorz Staniak
On 06.04.2012, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wroted: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others.

Re: Python Gotcha's?

2012-04-06 Thread rusi
On Apr 6, 6:55 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 05 Apr 2012 21:28:01 -0700, rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML,

Re: Python Gotcha's?

2012-04-06 Thread André Malo
* 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 automobile with a hand crank

Re: Python Gotcha's?

2012-04-06 Thread rusi
On Apr 6, 7:18 pm, Grzegorz Staniak gstan...@gmail.com wrote: On 06.04.2012, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wroted: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML,

Re: Python Gotcha's?

2012-04-06 Thread rusi
On Apr 6, 8:40 pm, André Malo ndpar...@gmail.com wrote: * 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

Re: Python Gotcha's?

2012-04-06 Thread Grzegorz Staniak
On 06.04.2012, rusi rustompm...@gmail.com wroted: This is the 21st century, not 1960, and if the language designer is worried about the trivially small extra effort of parsing ' as well as then he's almost certainly putting his efforts in the wrong place. Yes, that's what you said

Re: Python Gotcha's?

2012-04-06 Thread Barry W Brown
On Thursday, April 5, 2012 11:28:01 PM UTC-5, rusi wrote: On Apr 5, 4:06 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single:     v = json.loads({'test':'test'})  fails     v =

Re: Python Gotcha's?

2012-04-05 Thread Duncan Booth
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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 with valid JSON? Quelle surprise. -- Duncan Booth

Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Thu, Apr 5, 2012 at 9:06 PM, Duncan Booth duncan.booth@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single:     v = json.loads({'test':'test'})  fails     v = json.loads('{test:test}')  succeeds You mean JSON

Re: Python Gotcha's?

2012-04-05 Thread Steven D'Aprano
On Thu, 05 Apr 2012 11:06:11 +, Duncan Booth wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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 with

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article 4f7d896f$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You mean JSON expects a string with valid JSON? Quelle surprise. No. The surprise is that there exists a tool invented in the 21st century that makes a distinction

Re: Python Gotcha's?

2012-04-05 Thread Tim Wintle
On Thu, 2012-04-05 at 12:00 +, Steven D'Aprano wrote: The reason this is a Gotcha rather than a bug is because the JSON standard specifies the behaviour (probably in order to be compatible with Javascript). It's not to be compatible with javascript (you can use either in javascript) I

Re: Re: Python Gotcha's?

2012-04-05 Thread John Posner
On 4/4/2012 7:32 PM, Chris Angelico wrote: Don't know if it's what's meant on that page by the += operator, Yes, it is. a=([1],) a[0].append(2) # This is fine [In the following, I use the term name rather loosely.] The append() method attempts to modify the object whose name is a[0]. That

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
On Apr 5, 5:32 am, Roy Smith r...@panix.com 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

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
On Apr 5, 5:00 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 05 Apr 2012 11:06:11 +, Duncan Booth wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single:     v = json.loads({'test':'test'})  fails v =  

Re: Python Gotcha's?

2012-04-05 Thread Robert Kern
On 4/5/12 3:15 PM, John Posner wrote: On 4/4/2012 7:32 PM, Chris Angelico wrote: Don't know if it's what's meant on that page by the += operator, Yes, it is. a=([1],) a[0].append(2) # This is fine [In the following, I use the term name rather loosely.] The append() method attempts to

Re: Python Gotcha's?

2012-04-05 Thread Iain King
to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). Thanks, -- Miki -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
On Apr 5, 8:23 am, Iain King iaink...@gmail.com 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

Re: Python Gotcha's?

2012-04-05 Thread John Gordon
In 7367295.815.1333578860181.JavaMail.geo-discussion-forums@ynpp8 Miki Tebeka miki.teb...@gmail.com writes: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. This is fairly pedestrian as gotchas go

Re: Python Gotcha's?

2012-04-05 Thread Grzegorz Staniak
On 05.04.2012, Roy Smith r...@panix.com wroted: There's absolutely no reason why JSON should follow Python syntax rules. Making it support either kind of quotes would have complicated every JSON library in the world, for no added value. I think these days it's not just Python syntax, it's

Re: Python Gotcha's?

2012-04-05 Thread Tycho Andersen
On Thu, Apr 05, 2012 at 08:32:10AM -0400, Roy Smith wrote: One of the hardest things about writing parsers is generating helpful error messages when things don't parse. But, it's only of value to do that when you're parsing something you expect to be written by a human, and thus a human

Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 2:25 AM, Grzegorz Staniak gstan...@gmail.com wrote: On 05.04.2012, Roy Smith r...@panix.com wroted: There's absolutely no reason why JSON should follow Python syntax rules. Making it support either kind of quotes would have complicated every JSON library in the world,

Re: Python Gotcha's?

2012-04-05 Thread Alain Ketterlin
Miki Tebeka miki.teb...@gmail.com writes: [...] (Note that I want over http://wiki.python.org/moin/PythonWarts already). The local variable and scoping is, imho, something to be really careful about. Here is an example: class A(object): def __init__(self): self.x = 0 def

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article jlkh1c$msc$1...@mx1.internetia.pl, Grzegorz Staniak gstan...@gmail.com wrote: On 05.04.2012, Roy Smith r...@panix.com wroted: There's absolutely no reason why JSON should follow Python syntax rules. Making it support either kind of quotes would have complicated every JSON

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article jlkg90$ghk$1...@reader1.panix.com, John Gordon gor...@panix.com wrote: In 7367295.815.1333578860181.JavaMail.geo-discussion-forums@ynpp8 Miki Tebeka miki.teb...@gmail.com writes: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting

Re: Python Gotcha's?

2012-04-05 Thread Steven D'Aprano
On Thu, 05 Apr 2012 08:32:10 -0400, Roy Smith wrote: In article 4f7d896f$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You mean JSON expects a string with valid JSON? Quelle surprise. No. The surprise is that there exists a tool

Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 4:08 AM, Roy Smith r...@panix.com wrote: If you are working with data that is representable as either an integer or a string, choose one and stick to it.  Treating it as both/either will eventually lead to grief. Or, in other words: 1 != '1' Tell that to the PHP crowd

Re: Python Gotcha's?

2012-04-05 Thread Steven D'Aprano
On Thu, 05 Apr 2012 11:06:11 +, Duncan Booth wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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 with

Re: Re: Python Gotcha's?

2012-04-05 Thread Michael Hrivnak
This is not a gotcha, and it's not surprising. As John described, you're assigning a new value to an index of a tuple, which tuples don't support. a[0] += [3] is the same as a[0] = a[0] + [3] which after evaluation is the same as a[0] = [1, 3] You can always modify an item that happens to

Re: Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 4:44 AM, Michael Hrivnak mhriv...@hrivnak.org wrote: This is not a gotcha, and it's not surprising.  As John described, you're assigning a new value to an index of a tuple, which tuples don't support. a[0] += [3] is the same as a[0] = a[0] + [3] which after

Re: Python Gotcha's?

2012-04-05 Thread Michael Hrivnak
I'm surprised nobody beat me to posting this: def foo(stuff=[]): ... stuff.append('bar') ... print stuff ... foo() ['bar'] foo() ['bar', 'bar'] foo() ['bar', 'bar', 'bar'] On Wed, Apr 4, 2012 at 6:34 PM, Miki Tebeka miki.teb...@gmail.com wrote: Greetings, I'm going to give a Python

Re: Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
On 4/5/2012 13:24, Chris Angelico wrote: I think this example highlights a major point about gotchas: the difference between an obvious language feature and a gotcha depends on where you come from. To a PHP programmer, 1 and 1 are in many ways indistinguishable. To a C programmer, they're

Re: Python Gotcha's?

2012-04-05 Thread Jon Clements
On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka wrote: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). Thanks

Re: Python Gotcha's?

2012-04-05 Thread Ian Kelly
On Thu, Apr 5, 2012 at 12:52 PM, Michael Hrivnak mhriv...@hrivnak.org wrote: I'm surprised nobody beat me to posting this: The OP beat you to it -- it's in the list at the wiki link. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-05 Thread Emile van Sebille
On 4/5/2012 11:10 AM Jon Clements said... On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka wrote: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org

Re: Python Gotcha's?

2012-04-05 Thread Arnaud Delobelle
On 5 April 2012 21:06, Emile van Sebille em...@fenx.com wrote: Kind of begs for a contains method that returns the appropriate boolean: if text.contains('bob') It's already there: text.__contains__('bob') It's usually spelt otherwise though: 'bob' in text -- Arnaud --

Re: Python Gotcha's?

2012-04-05 Thread Ian Kelly
On Thu, Apr 5, 2012 at 2:06 PM, Emile van Sebille em...@fenx.com wrote: On 4/5/2012 11:10 AM Jon Clements said... On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka  wrote: Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark

Re: Python Gotcha's?

2012-04-05 Thread Grzegorz Staniak
On 05.04.2012, Roy Smith r...@panix.com wroted: There's absolutely no reason why JSON should follow Python syntax rules. Making it support either kind of quotes would have complicated every JSON library in the world, for no added value. I think these days it's not just Python syntax,

Re: Python Gotcha's?

2012-04-05 Thread André Malo
* 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 automobile with a hand crank to start the engine instead of an ignition. Even if there's a good reason for it

Re: Python Gotcha's?

2012-04-05 Thread Roy Smith
In article 4f7de152$0$29983$c3e8da3$54964...@news.astraweb.com, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I'm not the only one who has had trouble with JSON's poor design choice: This is getting a bit off-topic. If you wish to argue that JSON is designed poorly, you should

Re: Re: Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
On 4/5/2012 13:44, Michael Hrivnak wrote: This is not a gotcha, and it's not surprising. As John described, you're assigning a new value to an index of a tuple, which tuples don't support. Um, at least for me personally, yes, it is surprising, and yes, it is a gotcha. This goes back to what

Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
On 4/5/2012 17:11, Evan Driscoll wrote: In particular, the translation of 'a+=b' to 'temp = a + b; a = temp' is *not* a very natural one to me. To expand on this point slightly, because of common C++ idioms guided by efficiency, I would be much more likely to think of 'a + b' as 'temp = a, temp

Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 4:10 AM, Jon Clements jon...@googlemail.com wrote: One I've had to debug... text = 'abcdef' if text.find('abc'):        print 'found it!' # Nothing prints as bool(0) is False if text.find('bob'):        print 'found it!' found it! Someone new who hasn't read the

Re: Python Gotcha's?

2012-04-05 Thread Miki Tebeka
Now, if you wish to boggle your mind about something pythonic, how about mutexes not being thread safe (http://bugs.python.org/issue1746071)? This is and old and deprecated module, you should not use it. Use http://docs.python.org/library/threading.html#threading.Lock and friends instead.

Re: Python Gotcha's?

2012-04-05 Thread Cameron Simpson
On 05Apr2012 19:13, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: | Miki Tebeka miki.teb...@gmail.com writes: | (Note that I want over http://wiki.python.org/moin/PythonWarts already). | | The local variable and scoping is, imho, something to be really | careful about. Here is an example: |

Re: Python Gotcha's?

2012-04-05 Thread Cameron Simpson
On 05Apr2012 23:08, André Malo ndpar...@gmail.com 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 automobile with a hand crank to start the engine

Re: Python Gotcha's?

2012-04-05 Thread Steven D'Aprano
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 automobile with a hand crank to start the engine instead

String delimiter policy (was Re: Python Gotcha's?)

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 11:03 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: KISS is a reason *for* allowing multiple string delimiters, not against it. The simplicity which matters here are: * the user doesn't need to memorise which delimiter is allowed, and  which is

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
On Apr 5, 6:03 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info 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

Re: Python Gotcha's?

2012-04-05 Thread Dave Angel
On 04/05/2012 08:02 PM, Cameron Simpson wrote: On 05Apr2012 19:13, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: | Miki Tebeka miki.teb...@gmail.com writes: | (Note that I want over http://wiki.python.org/moin/PythonWarts already). | | The local variable and scoping is, imho, something

Re: Python Gotcha's?

2012-04-05 Thread Terry Reedy
On 4/5/2012 7:36 PM, Miki Tebeka wrote: Now, if you wish to boggle your mind about something pythonic, how about mutexes not being thread safe (http://bugs.python.org/issue1746071)? This is and old and deprecated module, you should not use it. Use

Re: Python Gotcha's?

2012-04-05 Thread Dan Sommers
On 06 Apr 2012 01:03:45 GMT Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: This is the 21st century, not 1960 ... Now there's a slippery slope, indeed. ;-) ... and if the language designer is worried about the trivially small extra effort of parsing ' as well as then he's

Re: Python Gotcha's?

2012-04-05 Thread John O'Hagan
On Thu, 05 Apr 2012 10:15:03 -0400 John Posner jjpos...@optimum.net wrote: On 4/4/2012 7:32 PM, Chris Angelico wrote: Don't know if it's what's meant on that page by the += operator, Yes, it is. a=([1],) a[0].append(2) # This is fine [In the following, I use the term name rather

Re: Python Gotcha's?

2012-04-05 Thread rusi
On Apr 5, 4:06 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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

Re: Python Gotcha's?

2012-04-05 Thread Chris Angelico
On Fri, Apr 6, 2012 at 2:28 PM, rusi rustompm...@gmail.com wrote: Are there languages (other than python) in which single and double quotes are equivalent? [No I dont claim to know all the languages out there, just that I dont know any other language which allows single and double quotes to

Re: Python Gotcha's?

2012-04-05 Thread Steve Howell
On Apr 5, 9:28 pm, rusi rustompm...@gmail.com wrote: On Apr 5, 4:06 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single:     v = json.loads({'test':'test'})  fails     v =

Re: Python Gotcha's?

2012-04-05 Thread rusi
On Apr 6, 9:54 am, Steve Howell showel...@yahoo.com 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] YAML:

Python Gotcha's?

2012-04-04 Thread Miki Tebeka
Greetings, I'm going to give a Python Gotcha's talk at work. If you have an interesting/common Gotcha (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). Thanks, -- Miki -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >