On Saturday, June 22, 2013 8:25:15 AM UTC+5:30, Rick Johnson wrote:
> On Friday, June 21, 2013 9:32:43 PM UTC-5, rusi wrote:
> > So Rick... I agree with you... all these theoreticians
> > should be burnt at the stake!
> > On a more serious note: many
> > people make similar mistakes eg Haskellers
Ombongi Moraa Fe writes:
> I'm working with suds to send send messages to smsc. I've notices the
> messages with ' are really not processed on my side (which could mean
> an error occurs somewhere - most probably in my php script). SMSC has also
> asked that I 'take care of the '' as it's the rea
Yves S. Garret wrote:
> Hi, I have a question about breaking up really long lines of code in
> Python.
>
> I have the following line of code:
> log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
> settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)
>
> Given th
On Friday, June 21, 2013 9:32:43 PM UTC-5, rusi wrote:
> So Rick... I agree with you... all these theoreticians
> should be burnt at the stake! On a more serious note: many
> people make similar mistakes eg Haskellers who think
> Haskell is safe. Safer (than something or other) -- Ok
> Safe -- NO
On 06/21/2013 07:41 PM, Chris Angelico wrote:
>> While we're at it, I would like to petition for a function
>> terminates(f, args) that I can use to determine whether a function
>> will terminate before I actually call it.
>
> Nice idea from a theoretical point of view, but practicality beats
> pu
On Saturday, June 22, 2013 7:34:18 AM UTC+5:30, MRAB wrote:
> Pure functional languages don't have mutables, or even variables, but
> then we're not talking about a pure functional language, we're talking
> about Python.
In which case neither do mathematicians. Do we rewrite the last 1000 years o
On Friday, June 21, 2013 8:38:21 PM UTC-5, Ian wrote:
> The answer to this conundrum is staring you in the face.
Thanks for posting a solution for this. Not sure if i'll
ever need it, but nice to know.
> Note that the TypeError complains that you passed it an
> "unhashable" type, and not that you
On Saturday, June 22, 2013 6:57:42 AM UTC+5:30, Ian wrote:
> While we're at it, I would like to petition for a function
> terminates(f, args) that I can use to determine whether a function
> will terminate before I actually call it.
I was going to say something about this -- viz that in prog. lang
On Friday, June 21, 2013 8:54:50 PM UTC-5, MRAB wrote:
> On 22/06/2013 00:51, Rick Johnson wrote:
> > On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote:
> > My argument has always been that mutables should not be
> > passed into subroutines as default arguments because bad
> > things can happen
On 22/06/2013 03:18, Chris Angelico wrote:
On Sat, Jun 22, 2013 at 12:01 PM, Rotwang wrote:
class hashablelist(list):
... def __hash__(self):
... return hash(tuple(self))
There's a vulnerability in that definition:
a=hashablelist((1,[],3))
a
[1, [], 3]
{a:1}
Traceback (most
On Sat, Jun 22, 2013 at 12:01 PM, Rotwang wrote:
class hashablelist(list):
> ... def __hash__(self):
> ... return hash(tuple(self))
There's a vulnerability in that definition:
>>> a=hashablelist((1,[],3))
>>> a
[1, [], 3]
>>> {a:1}
Traceback (most recent call last):
File "", l
On 22/06/2013 02:15, Rick Johnson wrote:
On Friday, June 21, 2013 6:40:51 PM UTC-5, Rotwang wrote:
On 21/06/2013 19:26, Rick Johnson wrote:
[...]
I didn't ask what alternative methods of handling default
argument binding exist (I can think of several, but none
of them strikes me as preferable to
On 22/06/2013 02:40, Chris Angelico wrote:
On Sat, Jun 22, 2013 at 11:31 AM, Steven D'Aprano
wrote:
Thinking about this, I think that the only safe thing to do in Rickython
4000 is to prohibit putting mutable objects inside tuples. Putting a list
or a dict inside a tuple is just a bug waiting t
On 22/06/2013 00:51, Rick Johnson wrote:
On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote:
I notice that you've omitted any mention of how you'd know that the
argument was mutable.
My argument has always been that mutables should not be
passed into subroutines as default arguments because
On Fri, Jun 21, 2013 at 7:37 PM, Chris Angelico wrote:
class HashableList(list):
> def __hash__(self):
> return 42
Hey, we both picked exactly the same example!
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, Jun 21, 2013 at 7:15 PM, Rick Johnson
wrote:
>> > Let's imagine for a second if Python allowed mutable keys in
>> > a dictionary,
>> which it does
>
> Am i just to take your word for this? You cannot provide an
> example? Here, allow me to "break the ice":
>
> # Literal
> py> d = {
On Friday, June 21, 2013 8:31:35 PM UTC-5, Steven D'Aprano wrote:
> Tuples have to go into the "Bad List" because, although
> they themselves are immutable, their contents may not be.
> Imagine the confusion and horror that poor developers will
> experience when they do something like this:
>
> de
On Sat, Jun 22, 2013 at 11:27 AM, Ian Kelly wrote:
> On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano
> wrote:
>> On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote:
>>
>>> On 21/06/2013 21:44, Rick Johnson wrote:
>> [...]
Which in Python would be the "MutableArgumentWarning".
*school-
On Sat, Jun 22, 2013 at 11:31 AM, Steven D'Aprano
wrote:
> Thinking about this, I think that the only safe thing to do in Rickython
> 4000 is to prohibit putting mutable objects inside tuples. Putting a list
> or a dict inside a tuple is just a bug waiting to happen!
I think you're onto something
On Sat, Jun 22, 2013 at 11:15 AM, Rick Johnson
wrote:
> # Literal
> py> d = {[1]:2}
> Traceback (most recent call last):
> File "", line 1, in
> d = {[1]:2}
> TypeError: unhashable type: 'list'
> # Symbol
> py> lst = [1]
> py> d = {lst:2}
> Traceback
On Sat, 22 Jun 2013 05:07:59 +1000, Chris Angelico wrote:
> Oh! I know. Function argument defaults will now be restricted to
> int/float/tuple. That would do it, right? Nobody would be bothered by
> little restrictions like that, would they.
Alas, tuples won't do it. Fortunately, you can include
On Fri, 21 Jun 2013 17:48:54 -0400, Ray Cote wrote:
> Also remember when entering long lines of text that strings concatenate
> within parenthesis. So,
> ("a, b, c"
> "d, e, f"
> "g, h, i")
>
> Is the same as ("a, b, cd, e, fg, h, i")
Technically, you don't need the parentheses. You can also us
On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano
wrote:
> On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote:
>
>> On 21/06/2013 21:44, Rick Johnson wrote:
> [...]
>>> Which in Python would be the "MutableArgumentWarning".
>>>
>>> *school-bell*
>>>
>> I notice that you've omitted any mention of how yo
On Friday, June 21, 2013 6:40:51 PM UTC-5, Rotwang wrote:
> On 21/06/2013 19:26, Rick Johnson wrote:
> [...]
> I didn't ask what alternative methods of handling default
> argument binding exist (I can think of several, but none
> of them strikes me as preferable to how Python currently
> does it).
On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote:
> On 21/06/2013 21:44, Rick Johnson wrote:
[...]
>> Which in Python would be the "MutableArgumentWarning".
>>
>> *school-bell*
>>
> I notice that you've omitted any mention of how you'd know that the
> argument was mutable.
That's easy. Just call is
On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote:
> I notice that you've omitted any mention of how you'd know that the
> argument was mutable.
My argument has always been that mutables should not be
passed into subroutines as default arguments because bad
things can happen. And Python's excu
On 21/06/2013 19:26, Rick Johnson wrote:
On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote:
It isn't clear to me from your posts what exactly you're
proposing as an alternative to the way Python's default
argument binding works. In your version of Python, what
exactly would happen when I
On 21/06/2013 21:44, Rick Johnson wrote:
On Friday, June 21, 2013 2:25:49 PM UTC-5, MRAB wrote:
On 21/06/2013 19:26, Rick Johnson wrote:
>
> The Apathetic Approach:
>
> I c
On 6/21/2013 5:17 PM, Yves S. Garret wrote:
Hi, I have a question about breaking up really long lines of code in Python.
I have the following line of code:
log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)
G
On 06/21/2013 02:17 PM, Yves S. Garret wrote:
Hi, I have a question about breaking up really long lines of code in
Python.
I have the following line of code:
log.msg("Item wrote to MongoDB database %s/%s"
%(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']),
level=log.DEBUG, spider=spide
On Fri, Jun 21, 2013 at 5:48 PM, Ray Cote
wrote:
>
> --
>
> *From: *"Yves S. Garret"
> *To: *python-list@python.org
> *Sent: *Friday, June 21, 2013 5:17:28 PM
> *Subject: *n00b question on spacing
>
>
> Hi, I have a question about breaking up really long lines of code
- Original Message -
> From: "Yves S. Garret"
> To: python-list@python.org
> Sent: Friday, June 21, 2013 5:17:28 PM
> Subject: n00b question on spacing
> Hi, I have a question about breaking up really long lines of code in
> Python.
> I have the following line of code:
> log.msg("Item w
In "Yves S. Garret"
writes:
> Hi, I have a question about breaking up really long lines of code in Python.
> I have the following line of code:
> log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
> settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)
> Given
Hi, I have a question about breaking up really long lines of code in Python.
I have the following line of code:
log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)
Given the fact that it goes off very far to the
On Friday, June 21, 2013 2:25:49 PM UTC-5, MRAB wrote:
> On 21/06/2013 19:26, Rick Johnson wrote:
> >
> > The Apathetic Approach:
> >
> > I could just assume that a programmer
On Friday, June 21, 2013 2:20:22 PM UTC-5, Neil Cerutti wrote:
> Rick, it's not a wart, It's a gotcha. The reason it's a
> gotcha is this: In order to predict what will happen
> correctly, you have to have mastered three separate Python
> concepts.
>
> 1. How name-binding works.
> 2. How argument p
On Friday, June 21, 2013 2:18:27 PM UTC-5, Rick Johnson wrote:
> On Friday, June 21, 2013 1:37:13 PM UTC-5, Steven D'Aprano wrote:
>
> > Okay, you're trolling.
Steven, you wouldn't know "trolling" even if you were an honorary salad tosser
at a troll face-sitting contest.
--
http://mail.python.
Op 19-06-13 23:13, ru...@yahoo.com schreef:
On 06/19/2013 04:57 AM, Antoon Pardon wrote:
Op 19-06-13 05:46, ru...@yahoo.com schreef:
On 06/18/2013 02:22 AM, Antoon Pardon wrote:
I don't remember making such a claim. What I do remember is
you among others claiming that the problem was not (so
On 21/06/2013 19:26, Rick Johnson wrote:
On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote:
It isn't clear to me from your posts what exactly you're
proposing as an alternative to the way Python's default
argument binding works. In your version of Python, what
exactly would happen when I
On 2013-06-21, Chris Angelico wrote:
> On Sat, Jun 22, 2013 at 4:26 AM, Rick Johnson
> wrote:
>> I could cast a "virtual net" over my poor lemmings before
>> they jump off the cliff by throwing an exception:
>>
>> Traceback (most recent screw-up last):
>>Line BLAH in SCRIPT
>> def f(x =
On Friday, June 21, 2013 1:37:13 PM UTC-5, Steven D'Aprano wrote:
> Okay, you're trolling. Time for another month in the kill-file.
> *plonk*
That's so typical of you. You start losing an argument, and
when you have no remaining counter arguments, you resort to
name calling. Why am i not surprise
On Sat, Jun 22, 2013 at 4:26 AM, Rick Johnson
wrote:
> I could cast a "virtual net" over my poor lemmings before
> they jump off the cliff by throwing an exception:
>
> Traceback (most recent screw-up last):
>Line BLAH in SCRIPT
> def f(x = [None, b, [a, [4]]]):
> ArgumentError: No mut
On Fri, 21 Jun 2013 11:26:39 -0700, Rick Johnson wrote:
> You know, out of all these post, not one of you guys has presented a
> valid use-case that will give validity to the existence of this PyWart
LOL.
Okay, you're trolling. Time for another month in the kill-file.
*plonk*
--
Steven
--
h
On Friday, June 21, 2013 12:47:56 PM UTC-5, Rotwang wrote:
> It isn't clear to me from your posts what exactly you're
> proposing as an alternative to the way Python's default
> argument binding works. In your version of Python, what
> exactly would happen when I passed a mutable argument as a
> de
On Friday, June 21, 2013 9:49:01 PM UTC+5:30, Ian wrote:
>
> The level of hospitality is already decreasing for me. That's why I'm
> speaking up.
I believe that this can be a point of unanimity -- "The level of hospitality
having gone down enough, I felt the need to speak up".
And with the imme
On 21/06/2013 18:01, Rick Johnson wrote:
[stuff]
It isn't clear to me from your posts what exactly you're proposing as an
alternative to the way Python's default argument binding works. In your
version of Python, what exactly would happen when I passed a mutable
argument as a default value
On Friday, June 21, 2013 10:57:17 AM UTC-5, Steven D'Aprano wrote:
> On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote:
> > py> class FuncAdd(object):
> > ... def __init__(self, ivalue):
> > ... self.ivalue = ivalue
> Notice how you are storing state here? I thought you said,
On Thu, 20 Jun 2013 20:16:19 -0700, Rick Johnson wrote:
> On Thursday, June 20, 2013 7:57:28 PM UTC-5, Steven D'Aprano wrote:
>> On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote:
>> They [default argument values] have to be stored *somewhere*, and
>> Python chooses to store them as an attri
On Fri, Jun 21, 2013 at 3:18 AM, Antoon Pardon
wrote:
> Op 21-06-13 04:40, Ian Kelly schreef:
>
>> On Thu, Jun 20, 2013 at 3:41 AM, Antoon Pardon
>> wrote:
>>> There are two problems with your reasoning. The first is that you
>>> are equivocating on "expect". "Expect" can mean you will be surpris
On Thu, 20 Jun 2013 11:05:32 -0700, Rick Johnson wrote:
> Python functions are objects that take arguments, of which (the
> arguments) are then converted to attributes of the function object.
> Ah-Ha! Urm, but wait! We already have a method to define Objects. Heck,
> I can even create my own calla
Thank you Peter and Dieter, will give those thoughts a try and report back.
--
http://mail.python.org/mailman/listinfo/python-list
On Thursday, June 20, 2013 5:28:06 PM UTC-5, Lefavor, Matthew
(GSFC-582.0)[MICROTEL LLC] wrote:
>
> [snip example showing dummy coder doing something dumb]
>
> +1. This is what convinces me that keeping references to
> keyword arguments is actually the right thing to do.
>
> Perhaps I'm biased b
On 2013-06-20, Cameron Simpson wrote:
> On 20Jun2013 13:55, Neil Cerutti wrote:
>| On 2013-06-20, Joshua Landau wrote:
>| > On 20 June 2013 04:11, Cameron Simpson wrote:
>| >> Also, opening-and-not-closing a set of brackets is almost the
>| >> only way in Python to make this kind of error (synt
On Friday, June 21, 2013 2:10:49 AM UTC-5, Chris Angelico wrote:
> Why should that be? Why is a subroutine not allowed to
> retain any state?
I refuse to repeat myself for lazy readers!
> You're free to write code in a purely functional style if
> you like
I don't want to write code in a purely
On 06/20/2013 06:20 AM, Jonathan Harden wrote:
Hi,
We have a class which executes external processes in a controlled environment and does
"things" specified by the client program with each line of output. To do this
we have been attaching stdout from the subprocess.Popen to a pseudo terminal (
Hello again!
Wow, I didn't expect so many responses in a so short amount of time! You guys
are amazing! All were very helpful, and after a quick read now I guess I can at
least figure out a more focused path to achieve my goal.
I'm already checking the Tkinter tutorial, and as soon as I get a
On Thursday, 20 June 2013 11:20:20 UTC+1, Jonathan Harden wrote:
>
...SNIP
>
Sorry about the second post, it took a very long time to show up, long enough I
thought it had been lost.
--
http://mail.python.org/mailman/listinfo/python-list
On Thursday, 20 June 2013 23:04:39 UTC+1, Peter Otten wrote:
> (2) Fiddle with terminal options, e. g.
>
> attrs = termios.tcgetattr(outSlave)
> attrs[1] = attrs[1] & (~termios.ONLCR) | termios.ONLRET
> termios.tcsetattr(outSlave, termios.TCSANOW, attrs)
>
> p = subprocess.Pop
Or, in many MANY cases, the choice was the right one, but isn't
obvious to everyone.
I think it's worth pointing out that changing function defaults to
late-binding would merely change the nature of the gotcha, not eliminate it.
words = ("one", "two", "red", "blue", "fish")
def join_strings(stri
Hello,
I'm working with suds to send send messages to smsc. I've notices the
messages with ' are really not processed on my side (which could mean
an error occurs somewhere - most probably in my php script). SMSC has also
asked that I 'take care of the '' as it's the reason my subscribers
may not
Hi,
We have a class which executes external processes in a controlled environment
and does "things" specified by the client program with each line of output. To
do this we have been attaching stdout from the subprocess.Popen to a pseudo
terminal (pty) made with pty.openempty and opened with os.
Hans writes:
> I'm doing a regular expression matching, let's say
> "a=re.search(re_str,match_str)", if matching, I don't know how many
> str/item will be extracted from re_str
Can you show an example of the pattern, and several examples of text you
want to match? This will help to understand yo
Τη Παρασκευή, 21 Ιουνίου 2013 12:15:59 μ.μ. UTC+3, ο χρήστης Peter Otten έγραψε:
> nickgan@windowslive.com wrote:
>
>
>
> > I have recently started to solve my first Python problems but I came
>
> > across to this:
>
> > Write a version of a palindrome recogniser that accepts a file name f
Hans wrote:
> Hi,
>
> I'm doing a regular expression matching, let's say
> "a=re.search(re_str,match_str)", if matching, I don't know how many
> str/item will be extracted from re_str, maybe a.group(1), a.group(2) exist
> but a.group(3) does not.
>
> Can I somehow check it? something like:
> if
Op 21-06-13 04:40, Ian Kelly schreef:
> On Thu, Jun 20, 2013 at 3:41 AM, Antoon Pardon
> wrote:
>> There are two problems with your reasoning. The first is that you
>> are equivocating on "expect". "Expect" can mean you will be surprised
>> if it doesn't happen but it can also mean you will feel
nickgan@windowslive.com writes:
> I think I coded it correctly but still I get no output. I do not
> have any errors I just do not get any output.
>
> This is the code:
>
> ***
> import is_palindrome
>
> filename = raw_input('Enter a file: ') # A text file
> f = open(filename)
> while True:
nickgan@windowslive.com wrote:
> I have recently started to solve my first Python problems but I came
> across to this:
> Write a version of a palindrome recogniser that accepts a file name from
> the user, reads each line, and prints the line to the screen if it is a
> palindrome.(by http://w
Hi,
I'm doing a regular expression matching, let's say
"a=re.search(re_str,match_str)", if matching, I don't know how many str/item
will be extracted from re_str, maybe a.group(1), a.group(2) exist but
a.group(3) does not.
Can I somehow check it? something like:
if exist(a.group(1)): print a.
Greetings to everybody,
I have recently started to solve my first Python problems but I came across to
this:
Write a version of a palindrome recogniser that accepts a file name from the
user, reads each line, and prints the line to the screen if it is a
palindrome.(by http://www.ling.gu.se/~lag
On Fri, Jun 21, 2013 at 1:16 PM, Rick Johnson
wrote:
> On Thursday, June 20, 2013 7:57:28 PM UTC-5, Steven D'Aprano wrote:
>> Python functions are
>> created *once*, when defined. The cost of building the
>> function -- compiling the source code to byte code,
>> assembling the pieces into a functi
70 matches
Mail list logo