Re:

2016-03-23 Thread Ethan Furman
On 03/22/2016 08:17 PM, Nick Eubank wrote: Relatedly, if this is a desired behavior, any advice one how best to work with dictionaries when one wants "True" and 1 to be different? I'm working on a function that accepts arguments that may be "True" or 1 (meaning very different things) and am seek

Re: Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-25 Thread Ethan Furman
On 03/25/2016 06:03 AM, Albert-Jan Roskam wrote: > Somebody wrote: >> Somebody else wrote: I know Python does not have variables, but names. Multiple names cant then be bound to the same objects. So this behavior --> b = 234 --> v = 234 --> b is v True according to the above that is ok But

Re: id == vs is

2014-10-26 Thread Ethan Furman
On 10/26/2014 05:23 PM, Ethan Furman wrote: On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Listen to MRAB, ignore me. That is all. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: id == vs is

2014-10-26 Thread Ethan Furman
On 10/26/2014 05:12 PM, Dan Stromberg wrote: Are the following two expressions the same? x is y Id(x) == id(y) ? Nope. If the value if `id(x)` is not interned, then the two value could be different objects that still represent the same value. -- ~Ethan~ -- https://mail.python.org/mailman

[ANN] dbf v0.96 is released

2014-10-28 Thread Ethan Furman
and finally supports Python 3! :) Versions supported are 2.5 - 2.7, and 3.2+ = dbf === dbf (also known as python dbase) is a module for reading/writing dBase III, FP, VFP, and Clipper .dbf database files. It's an ancient format that still finds lots of

Re: [ANN] dbf v0.96 is released

2014-10-28 Thread Ethan Furman
On 10/28/2014 01:08 PM, Tim Chase wrote: Just a little note to give thanks for all the work you put into such an unglamorous-yet-backside-saving project. It *is* appreciated by those of us who have had to disinter data from old client .dbf files. Thank you! :) -- ~Ethan~ -- https://mail.pyt

Re: [ANN] dbf v0.96 is released

2014-10-28 Thread Ethan Furman
On 10/28/2014 01:34 PM, Cousin Stanley wrote: dbf === dbf (also known as python dbase) is a module for reading/writing dBase III, FP, VFP, and Clipper .dbf database files. Available via PyPI at ? https://pypi.python.org/pypi/dbf/0.96.001 Ah, yes, that's the place! Althoug

Re: optional types

2014-10-29 Thread Ethan Furman
On 10/29/2014 10:18 AM, Kiuhnm wrote: On Wednesday, October 29, 2014 5:57:13 PM UTC+1, Peter Otten wrote: Kiuhnm wrote: I must say that the lack of static types in Python is a pain in the neck especially when I'm exploring new libraries. Recently, I learned a new language called Dart which hav

ANN: Antipathy v0.8

2014-10-30 Thread Ethan Furman
has just been made compatible with Python 3! It runs on everything from 2.4 forward, haven't testing anything prior to that. It is available for download at https://pypi.python.org//pypi/antipathy --- Antipathy -- for

Re: __index__

2014-11-01 Thread Ethan Furman
On 11/01/2014 10:11 AM, Ned Batchelder wrote: On 11/1/14 12:56 PM, duncan smith wrote: I have a Bloom filter class and want to (partially) serialize instances using hex() or oct(). Instances are mutable, so I can't inherit from long. I thought I'd found the answer when I came across __in

Re: __index__

2014-11-01 Thread Ethan Furman
On 11/01/2014 11:29 AM, Ethan Furman wrote: But I agree with Net ... Oops, should have ben 'Ned' -- apologies! -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Ethan Furman
This list is for the development _of_ Python, not development _with_ Python. Try asking on Python List. (forwarding...) On 11/04/2014 08:52 AM, Roberto Martínez wrote: I am trying to replace dinamically the __call__ method of an object using setattr. Example: $ cat testcall.py class A:

Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Ethan Furman
On 11/04/2014 11:01 AM, Roberto Martínez wrote: Yikes, I didn't realize the difference in inheritance. The thing with this is tricky. I need the change in the instance, not in the class, because I have multiple instances and all of them must have different implementations of __call__. The work

Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Ethan Furman
On 11/04/2014 11:01 AM, Roberto Martínez wrote: (Ethan, sorry for posting to python-dev, I thought that it was an implementation detail of CPython 3.X) No worries. It's good practice to post here first, just in case. ;) -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Ethan Furman
On 11/04/2014 11:23 AM, Nathaniel Smith wrote: (Or alternatively I guess you could go all in: Iä! Iä! Metaclasses Fhtagn!) Metaclasses aren't that bad! I've written one. And the dizzy spells are getting better! -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Real-world use of Counter

2014-11-05 Thread Ethan Furman
I'm looking for real-world uses of collections.Counter, specifically to see if anyone has been surprised by, or had to spend extra-time debugging, issues with the in-place operators. Background: Most Python data types will cause a TypeError to be raised if unusable types are passed in: --> {'

Re: [Python-Dev] Dinamically set __call__ method

2014-11-07 Thread Ethan Furman
On 11/06/2014 10:59 PM, dieter wrote: John Ladasky writes: On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote: If you really absolutely positively have to have the signature be correct for each instance, you may to either look at a function creating factory, a class creating

Re: [Python-Dev] Dinamically set __call__ method

2014-11-08 Thread Ethan Furman
On 11/07/2014 10:50 PM, dieter wrote: Ethan Furman writes: On 11/06/2014 10:59 PM, dieter wrote: John Ladasky writes: On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote: If you really absolutely positively have to have the signature be correct for each instance, you may

Re: [Python-Dev] Dinamically set __call__ method

2014-11-08 Thread Ethan Furman
On 11/08/2014 02:31 PM, Gregory Ewing wrote: Seems to depend on how you get hold of the object you're inspecting the signature of. I did an experiment: class C(object): @property def __call__(self): return self.call def f(x, y): print("Called f with %s, %s" % (x, y))

Re: [Python-Dev] Dinamically set __call__ method

2014-11-09 Thread Ethan Furman
On 11/09/2014 03:38 AM, Gregory Ewing wrote: Ethan Furman wrote: And the thing going on is the normal python behavior (in __getattribute__, I believe) of examining the returned attribute to see if it is a descriptor, and if so invoking it. Only if you look it up through the instance, though

Re: I don't read docs and don't know how to use Google. What does the print function do?

2014-11-10 Thread Ethan Furman
On 11/10/2014 11:59 AM, Larry Martell wrote: On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote: In article , sohcahto...@gmail.com wrote: Please help me this assignment is due in an hour. Don't give me hints, just give me the answer because I only want a grade. I'm not actually interested

Re: Communicating with a PHP script (and pretending I'm a browser)

2014-11-11 Thread Ethan Furman
On 11/11/2014 09:30 AM, Larry Martell wrote: They are technically savvy. They are a 100% PHP shop. They have a big, complicated app that they've been working on for 10 years. No one there knows python or django. They want to put some new frontends on their app. I was bought in for another projec

Re: I love assert

2014-11-11 Thread Ethan Furman
On 11/11/2014 11:40 AM, Peter Cacioppi wrote: I get the impression that most Pythonistas aren't as habituated with assert statements as I am. Is that just a misimpression on my part? If not, is there a good reason to assert less with Python than other languages? As far as I can tell, Python

Re: I love assert

2014-11-11 Thread Ethan Furman
On 11/11/2014 01:09 PM, Albert-Jan Roskam wrote: Ethan Furman wrote: asserts are a specialized tool, easily abused. Sounds like you are using them exactly as intended. Would you say that assert is baaadly abused in nose?*) I never tried it, but probably all tests pass when Python is run

Re: I love assert

2014-11-11 Thread Ethan Furman
On 11/11/2014 03:02 PM, Peter Cacioppi wrote: On Tue, Nov 11, 2014 at 12:57 PM, TP wrote: PyCharm uses docstrings to accomplish the same task [2] but can also use asserts/isinstance [3]. [2] https://www.jetbrains.com/pycharm/webhelp/type-hinting-in-pycharm.html

html page mail link to webmail program

2014-11-11 Thread Ethan Furman
Just in case that subject line is not perfectly clear: ;) My wife (using a Win7 machine) will be on a web page that has a link to mail somebody. She clicks on it, and it opens the currently installed but unused Thunderbird. Ideally, what would happen is a new window/tab would open to gmail w

Re: I love assert

2014-11-11 Thread Ethan Furman
On 11/11/2014 01:46 PM, Albert-Jan Roskam wrote: Ethan Furman wrote: I don't know, haven't used it nor read the code. It would certainly not be good if it failed in optimized mode. antonia@antonia-HP-2133 /tmp $ python -O test.py Ran 2 tests in 0.015s OK antonia@antonia-HP

Re: html page mail link to webmail program

2014-11-11 Thread Ethan Furman
On 11/11/2014 05:08 PM, Ben Finney wrote: Ethan Furman writes: My wife (using a Win7 machine) will be on a web page that has a link to mail somebody. She clicks on it, and it opens the currently installed but unused Thunderbird. Ideally, what would happen is a new window/tab would open to

Re: __missing__ for the top-level Python script

2014-11-12 Thread Ethan Furman
On 11/12/2014 06:37 AM, Chris Angelico wrote: On Mon, Nov 10, 2014 at 10:31 AM, Chris Angelico wrote: So the semantics should be: If NameError would be raised (not including UnboundLocalError, which still represents an error), attempt to import the absent name. If successful, continue as if it

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-11-12 Thread Ethan Furman
On 11/12/2014 01:02 PM, John Ladasky wrote: I would like to start a discussion about whether Python should include a function which executes this evaluation, and hides all of the unfriendly dunderish details. And if that's a good idea, I would invite a discussion of how, exactly, it should b

Re: I love assert

2014-11-12 Thread Ethan Furman
On 11/12/2014 01:41 PM, Marko Rauhamaa wrote: Or I might indicate the exhaustion of possibilities: if status == OK: ... elif status == ERROR: ... else: assert status == WARNING ... And here's a nice example of what one should NOT do.

Re: I love assert

2014-11-12 Thread Ethan Furman
On 11/12/2014 02:41 PM, Ian Kelly wrote: On Wed, Nov 12, 2014 at 3:13 PM, Anton wrote: On Wednesday, November 12, 2014 2:05:17 PM UTC-8, Ian wrote: You don't need to remove it. Just reorganize it to make sure it indicates actual exhaustion of possibilities. E.g. using the "assert False" patter

Re: I love assert

2014-11-12 Thread Ethan Furman
On 11/12/2014 02:47 PM, Marko Rauhamaa wrote: Ian Kelly : Although to be honest I'd rather use something like "raise RuntimeError('Unreachable code reached')" than "assert False" here. If the expectation is that the code will never be executed, then there's no reason to ever optimize it out.

Re: SSLsocket.getpeercert - request to return ALL the fields of the certificate.

2014-11-12 Thread Ethan Furman
On 11/12/2014 08:39 PM, John Nagle wrote: In each revision of "getpeercert", a few more fields are returned. Python 3.2 added "issuer" and "notBefore". Python 3.4 added "crlDistributionPoints", "caIssuers", and OCSP URLS. But some fields still aren't returned. I happen to need CertificatePol

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-11-13 Thread Ethan Furman
On 11/12/2014 01:51 PM, Ian Kelly wrote: On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote: A decorator is an interesting idea, and should be easy to implement (only lightly tested): def main(func): if func.__module__ == "__main__": func() return func # The return coul

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-11-13 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/13/2014 12:33 PM, Ian Kelly wrote: > On Thu, Nov 13, 2014 at 11:32 AM, Ethan Furman wrote: >> On 11/12/2014 01:51 PM, Ian Kelly wrote: >>> >>> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote: >>>>

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 03:33 AM, Steven D'Aprano wrote: > > I agree with Marko in this case. Marko's example of defensive programming is > very similar to the one I gave in my > essay here: > > http://import-that.dreamwidth.org/676.html > > You're correct o

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 11:12 AM, Marko Rauhamaa wrote: > Ethan Furman wrote: > >> My point being: a safety net that is so easily disabled does not count >> (IMHO) as a backup. > > Correct. You never lean on assertions. They are p

Re: I love assert

2014-11-14 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/14/2014 06:58 PM, Steven D'Aprano wrote: > Ethan Furman wrote: >> >> My point being: a safety net that is so easily disabled does not count >> (IMHO) as a backup. > > Assertions are not a backup or a safety

Re: I love assert

2014-11-16 Thread Ethan Furman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/16/2014 06:09 PM, Steven D'Aprano wrote: > Ethan Furman wrote: >> On 11/14/2014 06:58 PM, Steven D'Aprano wrote: >>> Ethan Furman wrote: >>>> >>>> My point being: a safety net that is so eas

Re: Different behaviour in list comps and generator expressions

2014-11-17 Thread Ethan Furman
On 11/17/2014 03:38 PM, Dan Stromberg wrote: > > I'm inclined to say that list comprehensions and generator expressions > should be different. I don't really think they should be identical, > one being eager and one being lazy. Why let the implementation detail > of one impact the other? It's n

Re: Potential pitfalls when going from old-style to new-style classes

2014-11-19 Thread Ethan Furman
On 11/19/2014 11:14 AM, Skip Montanaro wrote: > I discussion on the code-quality list got me thinking. Suppose I have > an old-style class in a 2.x app: > > class Foo: > def __init__(self): > blah blah blah > > I still use 2.x exclusively, but anytime I run pylint over a bit of > code and i

Re: python 2.7 and unicode (one more time)

2014-11-20 Thread Ethan Furman
On 11/20/2014 07:53 AM, Chris Angelico wrote: > On Fri, Nov 21, 2014 at 2:40 AM, Peter Otten <__pete...@web.de> wrote: >> I think that you may get a Unicode/Encode/Error when you try to /decode/ a >> unicode string is more confusing... > > Hang on a minute, what does it even mean to decode a Unico

Re: Infinitely nested containers

2014-11-22 Thread Ethan Furman
On 11/21/2014 08:43 PM, Steven D'Aprano wrote: > random...@fastmail.us wrote: >> >> I think I tried on at least one python version and printing the tuple >> crashed with a recursion depth error, since it had no special protection >> for this case the way list printing does. > > It works fine now

Re: bug or feature in enum34 py2.7 backport?

2014-11-26 Thread Ethan Furman
On 11/26/2014 07:32 AM, random...@fastmail.us wrote: > > It seems like if it is a bug to reject long where int is accepted, it > should be likewise considered a bug to reject ASCII-only unicode where > str is accepted. While I agree, I don't know if there are currently any parts of core 2.7 that

Re: I love assert

2014-11-29 Thread Ethan Furman
On 11/28/2014 05:30 PM, Steven D'Aprano wrote: > alister wrote: > >> And as may wiser people than me have already highlighted Assertions can >> be switched off in python which means they cannot be relied upon in >> production code invalidating the authors suggestion that they can >> automate bug r

Re: I love assert

2014-11-30 Thread Ethan Furman
On 11/30/2014 12:18 AM, Steven D'Aprano wrote: > > Ah, wait, I see the reference. You're talking about the quote from James O > Coplien: > > "An even more professional approach is to leave the assertions > in the code when you ship, and to automatically file a bug report > on behalf

Re: Setting default_factory of defaultdict to key

2014-12-01 Thread Ethan Furman
On 12/01/2014 10:05 AM, Larry Martell wrote: > > Is there a way to set the default_factory of defaultdict so that > accesses to undefined keys get to set to the key? You need to subclass and modify __missing__ to actually pass along the key: --> class defaultdictkey(defaultdict): ... def __miss

Re: Setting default_factory of defaultdict to key

2014-12-01 Thread Ethan Furman
On 12/01/2014 10:29 AM, Larry Martell wrote: > On Mon, Dec 1, 2014 at 1:19 PM, Ethan Furman wrote: >> On 12/01/2014 10:05 AM, Larry Martell wrote: >>> >>> Is there a way to set the default_factory of defaultdict so that >>> accesses to undefined keys get

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-12-01 Thread Ethan Furman
On 11/13/2014 10:32 AM, Ethan Furman wrote: > On 11/12/2014 01:51 PM, Ian Kelly wrote: >> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor wrote: >>> >>> A decorator is an interesting idea, and should be easy to implement (only >>> lightly tested): >>> &g

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-12-01 Thread Ethan Furman
On 12/01/2014 03:19 PM, Ethan Furman wrote: > > Well, I've tried this out, and it's only okay. As soon as interesting things > start happening, spurious errors about > thread IDs start printing, which really messes up the user experience [...] So here's another th

Re: How about some syntactic sugar for " __name__ == '__main__' "?

2014-12-02 Thread Ethan Furman
On 12/01/2014 05:15 PM, Chris Angelico wrote: > On Tue, Dec 2, 2014 at 11:45 AM, Ethan Furman wrote: >> >> Put the above somewhere in your path (e.g. /usr/local/bin), make it >> executable, and then instead of shebanging your >> scripts with `/usr/local/bin/python`

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Ethan Furman
On 12/02/2014 09:41 AM, Zachary Ware wrote: > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: >> >> Wouldn’t it be neat to write: >> >>foo == 42 or else >> >> and have that be an synonym for: >> >> assert foo == 42 > > Never going to happen, but I like it! Perhaps raise IntimidationErro

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/04/2014 09:36 AM, Jean-Michel Pichavant wrote: > > I know you specifically stated you didn't want to do this but > > import os > > os.path.isfile() > > is the best option imo, especially from the reader point of view ("Namespaces > are one honking great idea"). But, "Flat is better

Re: Style question: Importing modules from packages - 'from' vs 'as'

2014-12-04 Thread Ethan Furman
On 12/03/2014 03:02 AM, Chris Angelico wrote: > > Throughout the code, I want to refer to "path.split()", > "path.isfile()", etc, without the "os." in front of them. I could do > either of these: > > import os.path as path > from os import path > > Which one would you recommend? Does it depend o

Re: Do you like the current design of python.org?

2014-12-04 Thread Ethan Furman
On 12/04/2014 09:09 AM, Peter Otten wrote: > > Did you ever hit the "Socialize" button? Are you eager to see the latest > tweets when you are reading a PEP? Do you run away screaming from a page > where nothing moves without you hitting a button? Do you appreciate the > choice between ten or so

Re: Do you like the current design of python.org?

2014-12-09 Thread Ethan Furman
On 12/05/2014 03:30 AM, Fetchinson responded to > Steven D'Aprano's rant of: >> >> Many links are broken. When you click on the broken link, it says that it >> has been reported and will be fixed, but weeks later it remains broken, >> e.g.: >> >> https://www.python.org/doc/essays/metaclasses/Eiffe

Re: is_ as method or property?

2014-12-11 Thread Ethan Furman
On 12/11/2014 09:34 AM, Mateusz Loskot wrote: > > def is_(): > pass > > like 'is_even'. > > Should I define it as a classic method > > def is_even(self): > pass > > or as a property > > @property > def is_even(self): > pass > > So, a classic method or a property, which one is the Py

Re: Portable code: __import__ demands different string types between 2 and 3

2014-12-15 Thread Ethan Furman
On 12/14/2014 11:29 PM, Ben Finney wrote: > > This entails, I believe, the admonition to ensure text literals are > Unicode by default:: > > from __future__ import unicode_literals > > and to specify bytes literals explicitly with ‘b'wibble'’ if needed. For some scripts this works great (I

Re: Portable code: __import__ demands different string types between 2 and 3

2014-12-15 Thread Ethan Furman
On 12/15/2014 05:36 PM, Ben Finney wrote: > > That's not the issue at all. I know how to declare a literal such that > it is Unicode in Python 2 and Python 3 (that's what the ‘from __future__ > import unicode_literals’ does). > > Rather, the problem is ‘__import__’ having incompatible expectation

missing os.lchmod, os.lchflags

2014-12-24 Thread Ethan Furman
According to the docs [1] these functions should be available as of 2.6, yet they are missing on a 2.7, 3.2, and 3.4 install (ubuntu 12.10 and 14.04) Any ideas why? -- ~Ethan~ [1] https://docs.python.org/2/library/os.html#os.lchmod -- https://mail.python.org/mailman/listinfo/python-list

Re: missing os.lchmod, os.lchflags

2014-12-24 Thread Ethan Furman
On 12/24/2014 01:23 PM, Chris Angelico wrote: On Thu, Dec 25, 2014 at 7:22 AM, Tim Chase wrote: On 2014-12-24 11:42, Ethan Furman wrote: According to the docs [1] these functions should be available as of 2.6, yet they are missing on a 2.7, 3.2, and 3.4 install (ubuntu 12.10 and 14.04

Re: Comparisons and sorting of a numeric class....

2015-01-07 Thread Ethan Furman
On 01/06/2015 07:37 PM, Andrew Robinson wrote: > Explain; How does mere subclassing of bool break the contract that bool has? > eg: What method or data would the superclass have that my subclass would not? bool's contract is that there are only two values (True and False) and only one instance e

Re: Is anyone else unable to log into the bug tracker?

2015-01-09 Thread Ethan Furman
On 01/09/2015 05:48 PM, Steven D'Aprano wrote: > > I'm having trouble logging into the bug tracker. Is anyone else having the > same problem, that is, your user name and password worked earlier but > doesn't work now? I was just able to log in both using the Google short cut, and with my name/pas

Re: PyWart: Poor Documentation Examples

2015-01-10 Thread Ethan Furman
On 01/10/2015 06:32 PM, Steven D'Aprano wrote: > > If you treat your readers as idiots, only idiots will read your writing. Or the morbidly curious, which I presume covers your case (along with a handful of others ;) . -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https

Re: Namespace puzzle, list comprehension fails within class definition

2015-01-12 Thread Ethan Furman
On 01/12/2015 12:25 PM, John Ladasky wrote: > d = {0:"a", 1:"b", 2:"c", 3:"d"} > e = [d[x] for x in (0,2)] > > class Foo: > f = {0:"a", 1:"b", 2:"c", 3:"d"} > print(f) > g = [f[x] for x in (0,2)] In Foo 'f' is part of an unnamed namespace; the list comp 'g' has its own namespace, eff

Re: Namespace puzzle, list comprehension fails within class definition

2015-01-12 Thread Ethan Furman
On 01/12/2015 08:49 PM, Steven D'Aprano wrote: > On Mon, 12 Jan 2015 12:40:13 -0800, Ethan Furman wrote: >> >> [...] class name lookup skips nonlocal namespaces. > > Actually, no it doesn't. > [...] > The "problem" is that *functions* lookup don&

Re: lambdak: multi-line lambda implementation in native Python

2015-01-15 Thread Ethan Furman
On 01/15/2015 09:29 PM, Ian Kelly wrote: > > In Python you just have one initializer with defaults for the optional > arguments, so it's not an issue. What, Python makes it easy? That must be a mistake somewhere! ;) -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https:/

Re: What killed Smalltalk could kill Python

2015-01-21 Thread Ethan Furman
On 01/21/2015 05:36 PM, Chris Angelico wrote: > On Thu, Jan 22, 2015 at 11:09 AM, Mario Figueiredo wrote: >> "I want to become a programmer so I can make games" is, on the vast >> majority of cases, the quote of someone who will never become a >> programmer. Why should teachers reward that kind of

Re: Python is DOOMED! Again!

2015-01-21 Thread Ethan Furman
On 01/21/2015 08:30 PM, Steven D'Aprano wrote: > > So what is this unspeakable, nightmarish, cryptic abomination going to look > like? Here's an example from PEP 484: > > def greeting(name: str) -> str: > return 'Hello ' + name > > > I don't know about you, but I think anyone who cannot re

Re: kivy secret of mana game

2015-01-23 Thread Ethan Furman
On 01/22/2015 09:13 AM, Automn wrote: > > I am programming a "Secret of Mana" (Seiken Densetsu) game in kivy, it runs > on a phone with kivy launcher. AWESOME That was a totally fabulous game -- one of the very few I actually played to the end. :) -- ~Ethan~ signature.asc Description:

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Ethan Furman
On 01/23/2015 10:28 PM, Chris Angelico wrote: > > cmd = {} > def command(func): > cmd[func.__name__] = func > return func > > @command > def foo(*args): > print("You asked to foo.") > > but this is hardly generic. There's no convenient way to give an > argument to a decorator that sa

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-01-24 Thread Ethan Furman
On 01/24/2015 11:55 AM, Chris Angelico wrote: > On Sun, Jan 25, 2015 at 5:56 AM, Ethan Furman wrote: >> If the non-generic is what you're concerned about: >> >> # not tested >> dispatch_table_a = {} >> dispatch_table_b = {} >> dispatch_table_c = {}

Re: An object is an instance (or not)?

2015-01-27 Thread Ethan Furman
On 01/27/2015 12:12 PM, Mario Figueiredo wrote: > > Because, from my own study of Python, I've came to realize that the > distinction between objects and instances of objects actually exists. In > Python, class objects cannot participate in OOP, only their instances. I haven't followed the othe

Re: The Most Diabolical Python Antipattern

2015-01-29 Thread Ethan Furman
On 01/29/2015 09:36 AM, Skip Montanaro wrote: > On Thu, Jan 29, 2015 at 11:17 AM, Mark Lawrence > wrote: >> >> ... but what do you guys and gals think? > > I saw that blog referenced elsewhere a day or two ago. I think he's > correct. There are the occasional instance where I need to recover > f

Re: joke

2015-01-29 Thread Ethan Furman
On 01/29/2015 10:58 AM, sohcahto...@gmail.com wrote: > On Thursday, January 29, 2015 at 10:30:46 AM UTC-8, Automn wrote: >> What about : >> >> - "The royal Python is Clean your highness." >> - "Thank you." > > I don't get it. I suspect it is a reference to an old Eddie Murphy (?) movie in which

Re: [OT]very high tech humour

2015-01-31 Thread Ethan Furman
LOL! -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is DOOMED! Again!

2015-01-31 Thread Ethan Furman
On 01/31/2015 07:16 PM, Steven D'Aprano wrote: > > But by default, Python will fallback on __repr__ if __str__ doesn't exist, > or __str__ if __repr__ doesn't exist, or both. Or something. (I always > forget what the rules are exactly.) If __str__ is missing, __repr__ is called. If __repr__ is m

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-01 Thread Ethan Furman
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

Re: CSV and number formats

2015-02-01 Thread Ethan Furman
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

Re: dunder-docs (was Python is DOOMED! Again!)

2015-02-03 Thread Ethan Furman
On 02/03/2015 03:32 PM, Marko Rauhamaa wrote: > Gregory Ewing : > >> You seem to be suggesting an optimisation that pre-creates bound >> methods when the instance is created. Keeping a cache of bound methods >> would achieve the same thing without changing the semantics. I think >> CPython might a

Re: meaning of: line, =

2015-02-04 Thread Ethan Furman
On 02/04/2015 07:04 AM, Chris Angelico wrote: > On Thu, Feb 5, 2015 at 1:38 AM, Albert-Jan Roskam wrote: >> I have also never seen this before, but perhaps this: >> > f = lambda: [42] > result, = f() > result >> 42 >> >> ... is slightly cleaner than this: > result = f()[0] > re

Re: Setuptools, __init__ and __main__

2015-02-06 Thread Ethan Furman
On 02/06/2015 02:20 PM, Rob Gaddi wrote: > > My library code isn't in __init__.py (or previously in __main__) because > I'm trying to dodge recursive imports; it's there because the code is > short enough and tightly-coupled enough that I didn't see upside in > splitting any of it out to a sepa

Re: Setuptools, __init__ and __main__

2015-02-06 Thread Ethan Furman
On 02/06/2015 02:56 PM, Ben Finney wrote: > > It's not Setuptools per se, it's Python's import mechanism. It is a > deliberate design decision that direct import of a module makes that > module blind to its location in the package hierarchy. > > That's a design decision I deplore, because it make

Re: Incompatible idioms: relative imports, top-level program file

2015-02-06 Thread Ethan Furman
On 02/06/2015 04:44 PM, Ben Finney wrote: > Ethan Furman writes: > >> On 02/06/2015 02:56 PM, Ben Finney wrote: >>> It is a deliberate design decision that direct import of a module >>> makes that module blind to its location in the package hierarchy. >>>

Re: What killed Smalltalk could kill Python

2015-02-09 Thread Ethan Furman
On 01/21/2015 03:37 PM, Tim Daneliuk wrote: > > I wrote some rambling disquisition on these matters some years ago ... > > http://www.tundraware.com/TechnicalNotes/Python-Is-Middleware > > http://www.tundraware.com/TechnicalNotes/How-To-Pick-A-Programming-Language Very enjoyable, thank you!

Re: TypeError: list indices must be integers, not tuple

2015-02-09 Thread Ethan Furman
On 02/09/2015 03:52 PM, james8boo...@hotmail.com wrote: > import random > RandomNum = random.randint(0,7) > restraunt = raw_input("What's your favourite takeaway?Pizza, Chinease or > Indian?") > if restraunt == ("Pizza"): > fav = ("1") > > elif restraunt == ("Chinease"): > fav = ("2") >

Re: __next__ and StopIteration

2015-02-10 Thread Ethan Furman
On 02/09/2015 08:46 PM, Chris Angelico wrote: > > class Grid: > blah blah > > def __iter__(self): > for row in range(self._rows): > for col in range(self._cols): > if self._grid[row][col]: > yield self._grid[row][col] I strongly sug

Re: __next__ and StopIteration

2015-02-10 Thread Ethan Furman
On 02/10/2015 08:53 AM, Ian Kelly wrote: > On Tue, Feb 10, 2015 at 9:44 AM, Ethan Furman wrote: >> On 02/09/2015 08:46 PM, Chris Angelico wrote: >>> >>> class Grid: >>> blah blah >>> >>> def __iter__(self): >>> for

Re: Wildly OT: pop-up virtual keyboard for Mac or Linux?

2015-02-10 Thread Ethan Furman
On 02/10/2015 01:05 PM, Skip Montanaro wrote: > [request for alternate function when key is held down] Not exactly what you asked for, but here's how to combine characters in Vim: http://vim.wikia.com/wiki/Entering_special_characters Hopefully somebody knows about a pop-up window type thingie

Re: line_profiler: what am I doing wrong?

2015-02-10 Thread Ethan Furman
On 02/10/2015 04:06 PM, Neal Becker wrote: > I inserted > @profile > def run(...) > > into a module-level global function called 'run'. Something is very wrong > here. > 1. profile results were written before anything even ran > 2. profile is not defined? > > kernprof -l ./test_unframed.py --

Re: Alternative to multi-line lambdas: Assign-anywhere def statements

2015-02-11 Thread Ethan Furman
On 02/11/2015 05:04 AM, Albert van der Horst wrote: > That's the reason why my ideal Python doesn't attach a name to a lambda > denotation: > > x -> x**2 Hmmm. So now let's say you have a few dozen of these types of functions, and you want to talk about the twenty-sixth one with a peer... are

Re: Python discussed in Nature

2015-02-12 Thread Ethan Furman
On 02/12/2015 12:46 AM, Steven D'Aprano wrote: > > "Nature", one of the world's premier science journals, has published an > excellent article about programming in Python: > > http://www.nature.com/news/programming-pick-up-python-1.16833 That is a very nice article, thanks for sharing! -- ~Etha

Re: Python implementations in JavaScript

2015-02-14 Thread Ethan Furman
On 02/14/2015 05:28 PM, Ian Kelly wrote: > On Fri, Feb 13, 2015 at 4:05 PM, Jonathan Hayward wrote: >> >> What is the relative maturity of different Python implementations in >> JavaScript? Are any of the implementations ready to rely on? > > Brython is about two years old now. I remember a pos

Re: line_profiler: what am I doing wrong?

2015-02-16 Thread Ethan Furman
On 02/16/2015 11:42 AM, Neal Becker wrote: > Robert Kern wrote: >> Ah, do you have the package `future` installed? >> >> https://github.com/rkern/line_profiler/issues/12 > > Yes, I do. What do you suggest as a workaround? I would think importing 'profile' directly would be the workaround. -- ~

Re: What the Pythons docs means by "container" ?

2015-02-18 Thread Ethan Furman
On 02/17/2015 06:14 PM, candide wrote: > Le mercredi 18 février 2015 01:50:16 UTC+1, Chris Angelico a écrit : > >> >> So, what's a container? It's a thing that you put other objects into. > > I agree with this approach. The important point to consider here is the last > word in your definition :

Re: can python handle CHIME .spt files?

2015-02-18 Thread Ethan Furman
On 02/18/2015 12:56 PM, James Zimmerman wrote: > > I have a lot of old files that were written in Chime, then made compatible > with Jmol. > Now there are problems with that. Will Python give me a way to be able to > show the > .spt files that Chime could read? I don’t want to start learning P

Re: can python handle CHIME .spt files?

2015-02-18 Thread Ethan Furman
On 02/18/2015 01:55 PM, Davin Potts wrote: > * If you want a way to parse problematic .spt files that can no longer be > read in using Jmol or MDL Chime, it is > possible to create an .spt parser in Python capable of reading your files > though my quick searches for an existing .spt > parser lib

Re: sqlite3 and dates

2015-02-18 Thread Ethan Furman
On Thu, Feb 19, 2015 at 9:17 AM, rurpy wrote: > That you would equate that to a JSON blob [...] Chris wrote: > I didn't equate them. >> Chris wrote earlier: >>> and you manipulate it just the same as if it were a big fat blob >>> of JSON That sure sounds like equating. Chris also wrote: > But

When to use SQLite3 [was Re: 'Lite' Databases (Re: sqlite3 and dates)]

2015-02-18 Thread Ethan Furman
At the risk of using actual data, I looked this up at http://www.sqlite.org/whentouse.html: Checklist For Choosing The Right Database Engine * Is the data separated from the application by a network? → choose client/server Relational database engines act as a bandwidth-reducing data filt

<    5   6   7   8   9   10   11   12   13   14   >