Steven D'Aprano writes:
> No apples and no oranges aren't the same thing, but if somebody is expecting
> no apples, and I give them no oranges instead, it would be churlish for them
> to complain that none of them are the wrong kind of fruit.
https://davedevine.wordpress.com/2011/01/20/the-sart
-- Devin
On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano
wrote:
> Gregory Ewing wrote:
>
>> Steven D'Aprano wrote:
>>> [quote]
>>> If the object has a method named __dir__(), this method will
>>> be called and must return the list of attributes.
>>> [end quote]
>>>
>>> The first
Michael Torrie :
> http://en.cppreference.com/w/cpp/utility/functional/function
>
> Thus if we were to shoehorn your example into C++, the result would be
> idiomatically very similar to what you have in your Python code.
I can understand why you wouldn't write out my example in C++:
using st
Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> [quote]
>> If the object has a method named __dir__(), this method will
>> be called and must return the list of attributes.
>> [end quote]
>>
>> The first inaccuracy is that like all (nearly all?) dunder methods,
>> Python only loo
Paul Rubin wrote:
> Chris Angelico writes:
>> So since you can set something to Nothing regardless of type, and
>> compare it against Nothing regardless of type, it doesn't really much
>> matter that there are different types of Nothing. Right?
>
> No that's not how type inference works. If you
Chris Angelico wrote:
> On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
> wrote:
>> And there are underspecified rules too. What is the plural of octopus? No
>> fair looking it up in the dictionary.
>
> Standard and well-known piece of trivia, and there are several
> options. "Octopodes" is one
Chris Angelico writes:
> If you say "x = 5" and pass it to a function that accepts "Int or
> String", the compiler knows that it's actually an Int. If you then
> also pass that x to something that takes "Int or List", is that legal?
You'd have to do that with type classes, but yeah, the compiler
On Mon, Feb 2, 2015 at 5:07 PM, Paul Rubin wrote:
> Chris Angelico writes:
>> So since you can set something to Nothing regardless of type, and
>> compare it against Nothing regardless of type, it doesn't really much
>> matter that there are different types of Nothing. Right?
>
> No that's not ho
Steven D'Aprano writes:
> if type(ptr) == A:
> if ptr != Anil: ...
> if type(ptr) == B:
> if ptr != Bnil: ...
> etc. That would be insane. So how does Haskell do this?
That wouldn't make sense in Haskell: the types are known at compile
time, so you wouldn't do that runtime switching on t
Chris Angelico writes:
> So since you can set something to Nothing regardless of type, and
> compare it against Nothing regardless of type, it doesn't really much
> matter that there are different types of Nothing. Right?
No that's not how type inference works. If you have x = Nothing and
pass i
Devin Jeanpierre wrote:
I answered my own question later, by accident: Java nulls are castable
to each other if you do it explicitly (routing through Object -- e.g.
(Something)((Object) ((SomeOtherThing) null.
So in that sense, there is only one null, just with some arbitrary
compiler distin
On Mon, Feb 2, 2015 at 4:19 PM, Gregory Ewing
wrote:
> In Haskell you would just go ahead and compare ptr
> with Nothing (or more likely pattern-match it against
> Nothing).
So since you can set something to Nothing regardless of type, and
compare it against Nothing regardless of type, it doesn't
Steven D'Aprano wrote:
> Checking the REPL first would have revealed that [].__dir__ raises
> AttributeError. In other words, lists don't have a __dir__ method.
?
Python 3.4.2 (default, Nov 29 2014, 00:45:45)
[GCC 4.8.3] on linux
Type "help", "copyright", "credits" or "license" for more informa
Steven D'Aprano wrote:
If I have an arbitrary pointer, and I want to check if it is safe to
dereference, how do I do it? Surely I'm not expected to write something
like:
if type(ptr) == A:
if ptr != Anil: ...
if type(ptr) == B:
if ptr != Bnil: ...
etc. That would be insane. So how doe
Steven D'Aprano wrote:
[quote]
If the object has a method named __dir__(), this method will
be called and must return the list of attributes.
[end quote]
The first inaccuracy is that like all (nearly all?) dunder methods, Python
only looks for __dir__ on the class, not the inst
Howdy all,
I am pleased to announce the release of version 2.0.5 of the
‘python-daemon’ library.
The current release is always available at
https://pypi.python.org/pypi/python-daemon/>.
The project's forums and VCS are hosted at Alioth
https://alioth.debian.org/projects/python-daemon/>.
Signif
On Mon, Feb 2, 2015 at 3:14 PM, Roy Smith wrote:
> In article <54ceda0b$0$12977$c3e8da3$54964...@news.astraweb.com>,
> Steven D'Aprano wrote:
>
>> What is the plural of octopus?
>
> It's a trick question. Octopus is already plural. Monopus is singular.
People is already plural, too, but you c
On Monday, February 2, 2015 at 9:34:53 AM UTC+5:30, Rustom Mody wrote:
> On Monday, February 2, 2015 at 9:22:51 AM UTC+5:30, Rustom Mody wrote:
> > On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote:
> > > Rustom Mody wrote:
> > >
> > > > The other day I was taking a class i
In article <54ceda0b$0$12977$c3e8da3$54964...@news.astraweb.com>,
Steven D'Aprano wrote:
> What is the plural of octopus?
It's a trick question. Octopus is already plural. Monopus is singular.
--
https://mail.python.org/mailman/listinfo/python-list
In article ,
Chris Angelico wrote:
> On Mon, Feb 2, 2015 at 1:35 PM, Matthew Barnett
> wrote:
> > And the plural of "virus" is "viruses", not "viri" (that's the plural of
> > "vir") or "virii" (that would be the plural of "virius", if it existed).
>
> Yes indeed."Virii" and "octopi" are as wro
On Monday, February 2, 2015 at 9:22:51 AM UTC+5:30, Rustom Mody wrote:
> On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote:
> > Rustom Mody wrote:
> >
> > > The other day I was taking a class in which I was showing
> > > - introspection for discovering -- help, type, dir et
On Sunday, February 1, 2015 at 9:51:11 PM UTC+5:30, Steven D'Aprano wrote:
> Rustom Mody wrote:
>
> > The other day I was taking a class in which I was showing
> > - introspection for discovering -- help, type, dir etc at the repl
> > - mapping of surface syntax to internals eg. a + b ←→ a.__add__
On Mon, Feb 2, 2015 at 1:35 PM, Matthew Barnett
wrote:
> And the plural of "virus" is "viruses", not "viri" (that's the plural of
> "vir") or "virii" (that would be the plural of "virius", if it existed).
Yes indeed."Virii" and "octopi" are as wrong as "hice" for "houses"
(paralleling mice).
Chr
On 2015-02-02 02:04, Chris Angelico wrote:
On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
wrote:
And there are underspecified rules too. What is the plural of
octopus? No fair looking it up in the dictionary.
Standard and well-known piece of trivia, and there are several
options. "Octopodes
Steven D'Aprano wrote:
> Of course people make grammar mistakes that they don't spot.
Ironically, this is one of them. It should of course be "grammatical
mistakes".
Seriously, I didn't do that on purpose. I only noticed the error on reading
it back after sending.
--
Steven
--
https://mail
Devin Jeanpierre wrote:
> So in that sense, there is only one null, just with some arbitrary
> compiler distinctions you can break through if you try hard enough.
Woo hoo! I was right!
*Dances the Dance of Victory!*
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list
On Mon, Feb 2, 2015 at 12:59 PM, Steven D'Aprano
wrote:
> And there are underspecified rules too. What is the plural of octopus? No
> fair looking it up in the dictionary.
Standard and well-known piece of trivia, and there are several
options. "Octopodes" is one of the most rigorously formal, but
Marko Rauhamaa wrote:
> Steven D'Aprano :
>
>> Marko Rauhamaa wrote:
>>
>>> The natural language has a rigorous grammar plus a lexicon that includes
>>> a number of idioms. Nobody has so far been able to codify a natural
>>> language completely because the rigorous grammar consists of maybe
>>> 1
On 02/01/2015 05:50 PM, Michael Torrie wrote:
> Honestly with the C++ standard library implementing std::function and
> std::bind macros, idiomatically it would look very much similar to the
> Python code you showed.
Make that templates, not macros.
--
https://mail.python.org/mailman/listinfo/py
On 02/01/2015 12:12 PM, Marko Rauhamaa wrote:
> So please implement this small piece of Python code in C++ so we can
> compare the idioms:
So I though I might just for kicks code up a C++ version. In doing so,
I realized that idomatically, this particular example would not really
use callbacks in
On 02/01/2015 12:12 PM, Marko Rauhamaa wrote:
> Christian Gollwitzer :
>
>> Am 01.02.15 um 08:58 schrieb Marko Rauhamaa:
>>> Qt gave up on C++ when it comes to callbacks ("signals") and went for
>>> an apocryphal metacompiler.
>>
>> Yes, but only because C++ compilers were not good enough when QT
On Sun, Feb 1, 2015 at 2:27 PM, Paul Rubin wrote:
> Devin Jeanpierre writes:
>> That said, Haskell (and the rest) do have a sort of type coercion, of
>> literals at compile time (e.g. 3 can be an Integer or a Double
>> depending on how you use it.)
>
> That's polymorphism, not coercion.
OK, yes,
Devin Jeanpierre writes:
> That said, Haskell (and the rest) do have a sort of type coercion, of
> literals at compile time (e.g. 3 can be an Integer or a Double
> depending on how you use it.)
That's polymorphism, not coercion. The compiler figures out at compile
time what type of 3 you actuall
On 01Feb2015 14:17, Skip Montanaro wrote:
On Sun, Feb 1, 2015 at 1:35 PM, Peter Otten <__pete...@web.de> wrote:
$ LANG=en_US.UTF-8 python3 -c 'import locale;
print(locale.getpreferredencoding(False))'
Aha!
hgpython% LANG=en_US.UTF-8 python3.5 -c 'import locale;
print(locale.getpreferredenco
Steven D'Aprano writes:
> C has a single nil pointer compatible with all pointer types.
C++11 has a separate type just for the null pointer, which can be
automatically coerced to other pointer types. I'm not sure but I think
that means it is couthing up slightly.
http://en.cppreference.com/w/cp
On Sun, Feb 1, 2015 at 2:31 PM, Chris Angelico wrote:
> Try the other variations: include the hyphen
> but don't capitalize, and the other way around. On my system, all four
> work equally:
Yes, on my system, case doesn't matter, but the hyphen does.
I just tried it out on one of my Linux system
On 2/1/2015 12:45 PM, Chris Angelico wrote:
Simple answer: You write dunder methods and the interpreter calls
them. You don't call them yourself.
I can't currently think of any situation where it's appropriate to
call a dunder method manually (cue the swamping of such situations on
the list); yo
On Sun, Feb 1, 2015 at 4:36 PM, Rustom Mody wrote:
> The other day I was taking a class in which I was showing
> - introspection for discovering -- help, type, dir etc at the repl
> - mapping of surface syntax to internals eg. a + b ←→ a.__add__(b)
>
> And a student asked me the diff between
> dir
On Mon, Feb 2, 2015 at 6:36 AM, Ian Kelly wrote:
>> At long last my quest seeking the final entry for the Zen of Python is over.
>> I'll be delighted to let you accept the honour of raising an issue on the
>> bug tracker to get the "this" module changed to reflect my new found wisdom.
>
> And whil
On Mon, Feb 2, 2015 at 7:17 AM, Skip Montanaro wrote:
> Thank you. I always thought these Unicode encodings were supposed to
> be case-insensitive.
I'd have thought so, too. Try the other variations: include the hyphen
but don't capitalize, and the other way around. On my system, all four
work eq
On 01/02/2015 19:36, Ian Kelly wrote:
On Sun, Feb 1, 2015 at 11:49 AM, Mark Lawrence wrote:
On 01/02/2015 18:14, Grant Edwards wrote:
A loop containing 1 line of code will execute in the same abount of
time as that loop with 1 line of code and 99 blanks lines.
The latter loop is running at 10
On Sun, Feb 1, 2015 at 1:35 PM, Peter Otten <__pete...@web.de> wrote:
> $ LANG=en_US.UTF-8 python3 -c 'import locale;
> print(locale.getpreferredencoding(False))'
Aha!
hgpython% LANG=en_US.UTF-8 python3.5 -c 'import locale;
print(locale.getpreferredencoding(False))'
UTF-8
hgpython% LANG=en_US.ut
On Sun, Feb 1, 2015 at 11:49 AM, Mark Lawrence wrote:
> On 01/02/2015 18:14, Grant Edwards wrote:
>> A loop containing 1 line of code will execute in the same abount of
>> time as that loop with 1 line of code and 99 blanks lines.
>>
>> The latter loop is running at 100 times as many lines/second
Skip Montanaro wrote:
> On Sun, Feb 1, 2015 at 11:20 AM, Peter Otten <__pete...@web.de> wrote:
>> Try setting the environment variable
>>
>> PYTHONIOENCODING=UTF-8
>
> Thanks, but that didn't help. I still get the same exception.
The pager is invoked by os.popen(), and after some digging I find
Christian Gollwitzer :
> Am 01.02.15 um 08:58 schrieb Marko Rauhamaa:
>> Qt gave up on C++ when it comes to callbacks ("signals") and went for
>> an apocryphal metacompiler.
>
> Yes, but only because C++ compilers were not good enough when QT came
> out, and later is was too late to change it to a
On 1/31/2015 10:45 PM, Frank Millman wrote:
If the opening balance is positive, it appears as '+0021.45'
If it is negative, it appears as '+0-21.45'
My advise is to get cash in payment.
:)
Emile
--
https://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano :
> Marko Rauhamaa wrote:
>
>> The natural language has a rigorous grammar plus a lexicon that includes
>> a number of idioms. Nobody has so far been able to codify a natural
>> language completely because the rigorous grammar consists of maybe
>> 10,000 rules.
>
> If nobody has co
On 01/02/2015 18:14, Grant Edwards wrote:
No, you've got that backwards. You want_more_ blank lines. A blank
line takes zero time to run, but it still counts as a line in your
lines/second stats.
You want more blanks lines to satisfy bean counting managers who want
you to report "number of l
On Sat, Jan 31, 2015 at 7:38 PM, Jason Friedman wrote:
>> I have two lists
>>
>> l1 = ["a","b","c","d","e","f","g","h","i","j"]
>> l2 = ["aR","bR","cR"]
>>
>> l2 will always be smaller or equal to l1
>>
>> numL1PerL2 = len(l1)/len(l2)
>>
>> I want to create a dictionary that has key from l1 and v
On 01/02/2015 18:14, Grant Edwards wrote:
On 2015-02-01, Chris Angelico wrote:
On Sun, Feb 1, 2015 at 2:06 PM, Mark Lawrence wrote:
The one-liner might not be better code, but it must be better speed wise
precisely because it's on one line, right? :)
Well of course it is. Python code speed
On Sun, Feb 1, 2015 at 11:20 AM, Peter Otten <__pete...@web.de> wrote:
> Try setting the environment variable
>
> PYTHONIOENCODING=UTF-8
Thanks, but that didn't help. I still get the same exception.
Skip
--
https://mail.python.org/mailman/listinfo/python-list
On 2015-02-01, Chris Angelico wrote:
> On Sun, Feb 1, 2015 at 2:06 PM, Mark Lawrence wrote:
>> The one-liner might not be better code, but it must be better speed wise
>> precisely because it's on one line, right? :)
>
> Well of course it is. Python code speed is always measured in lines
> per mi
On Sun, Feb 1, 2015 at 8:31 AM, Steven D'Aprano
wrote:
> Paul Rubin wrote:
>> It's completely practical: polymorphism and type inference get you the
>> value you want with usually no effort on your part.
>
> But it's the "usually" that bites you.
>
> If I have an arbitrary pointer, and I want to c
On Sun, Feb 1, 2015 at 9:55 AM, Steven D'Aprano
wrote:
> Steven D'Aprano wrote:
>
>> len tries to call __len__ if it exists, and if not, it tries walking the
>> iterable counting items.
>
> Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby.
I think you just got it backward. iter
Skip Montanaro wrote:
> I finally got sort of smart, and started up a pydoc server. Looking at
> the sqlite3 docs through my browser, I see right off the bat, I see
>
> #-*- coding: ISO-8859-1 -*-
> # pysqlite2/__init__.py: the pysqlite2 package.
> #
> # Copyright (C) 2005 Gerhard Häring
>
> so
Steven D'Aprano wrote:
> Devin Jeanpierre wrote:
>
>> It's really only dynamically typed languages that have a single null
>> value of a single type. Maybe I misunderstand the original statement.
>
> Pascal is statically typed and has a single null pointer compatible with
> all pointer types.
Steven D'Aprano wrote:
> len tries to call __len__ if it exists, and if not, it tries walking the
> iterable counting items.
Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby.
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, Feb 1, 2015 at 8:34 AM, Steven D'Aprano
wrote:
> Devin Jeanpierre wrote:
>
>> It's really only dynamically typed languages that have a single null
>> value of a single type. Maybe I misunderstand the original statement.
>
> Pascal is statically typed and has a single null pointer compatibl
Marko Rauhamaa wrote:
> The natural language has a rigorous grammar plus a lexicon that includes
> a number of idioms. Nobody has so far been able to codify a natural
> language completely because the rigorous grammar consists of maybe
> 10,000 rules.
If nobody has codified the rigorous grammar,
I finally got sort of smart, and started up a pydoc server. Looking at
the sqlite3 docs through my browser, I see right off the bat, I see
#-*- coding: ISO-8859-1 -*-
# pysqlite2/__init__.py: the pysqlite2 package.
#
# Copyright (C) 2005 Gerhard Häring
so my challenge is how to tell Python my te
Devin Jeanpierre wrote:
> It's really only dynamically typed languages that have a single null
> value of a single type. Maybe I misunderstand the original statement.
Pascal is statically typed and has a single null pointer compatible with all
pointer types. C has a single nil pointer compatible
Paul Rubin wrote:
> Steven D'Aprano writes:
>> Some degree of weakness in a type system is not necessarily bad. Even the
>> strongest of languages usually allow a few exceptions, such as numeric
>> coercions.
>
> Haskell doesn't have automatic coercions of any sort. You have to call
> a convers
Rustom Mody wrote:
> The other day I was taking a class in which I was showing
> - introspection for discovering -- help, type, dir etc at the repl
> - mapping of surface syntax to internals eg. a + b ←→ a.__add__(b)
>
> And a student asked me the diff between
> dir([])
> and
> [].__dir__()
>
>
I build several versions of Python from Mercurial sources on a regular
basis. I am starting on a new collection of programs for some database
work and figured I should start using Python 3. I wanted to look
something up quickly about the sqlite3 module, so I tried "pydoc
sqlite3". That worked fine,
On Sun, Feb 1, 2015 at 12:45 AM, Frank Millman wrote:
> Is this a recognised format, and is there a standard way of parsing it? If
> not, I will have to special-case it, but I would prefer to avoid that if
> possible.
Doesn't look "standard" to me in any fashion. You shouldn't need to
special cas
alb wrote:
>> But wait, "".join() only accepts strings so let's change
>>
>>yield [node]
>>
>> to
>>yield [node.name] # str(node) would also work
>
> Again my question, why not simply yield node.name?
I've been conditioned to build a string from many substrings like so
>>> parts = ["foo", "bar"
On 01/31/2015 11:23 PM, Mark Lawrence wrote:
> On 01/02/2015 06:45, Frank Millman wrote:
>>
>>
>> Most transaction amounts are in the format '-0031.23' or '+0024.58'
>>
>> This can easily be parsed using decimal.Decimal().
>>
>> If the opening balance is positive, it appears as '+0021.4
Am 01.02.15 um 08:58 schrieb Marko Rauhamaa:
> Paul Rubin :
>
>> Marko Rauhamaa writes:
>>> Stroustrup apparently has never had to deal with callbacks; his thick
>>> books never made a mention of them last time I checked.
>>
>> C++ has function pointers just like C,
>
> Et tu, Brute!
>
> C's ca
On 01/31/2015 09:36 PM, Rustom Mody wrote:
>
> And a student asked me the diff between
> dir([])
> and
> [].__dir__()
>
> I didnt know what to say...
> Now surely the amount of python I dont know is significantly larger than what
> I know
> Still it would be nice to have surface-syntax ←→ dunder
Paul Rubin :
> Marko Rauhamaa writes:
>> Stroustrup apparently has never had to deal with callbacks; his thick
>> books never made a mention of them last time I checked.
>
> C++ has function pointers just like C,
Et tu, Brute!
C's callbacks always use a void pointer for the "self reference." In
70 matches
Mail list logo