Re: How come StopIteration.__base__ is not BaseException?

2013-08-27 Thread Ethan Furman
On 08/26/2013 12:37 PM, Marco Buttu wrote: Since StopIteration is not an error, how come does it inherit directly from Exception and not from BaseException? Not all exceptions are errors. (Although not dealing with one can be. ;) -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-l

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 03:09 AM, Fabrice Pombet wrote: So I guess that we are actually all agreeing on this one. No, we are not. "encapsulation" != "inaccessible except by getters/setters" -- ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 12:13 PM, Roy Smith wrote: In article , Ethan Furman wrote: On 09/01/2013 03:09 AM, Fabrice Pombet wrote: So I guess that we are actually all agreeing on this one. No, we are not. "encapsulation" != "inaccessible except by getters/setters" Noth

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 02:54 PM, Tim Delaney wrote: Roy Smith wrote: Nothing is accessible in Python except via getters and setters. The only difference between Python and, say, C++ in this regard is that the Python compiler writes them for you most of the time and doesn't make you put ()'s at the end

Re: Encapsulation unpythonic?

2013-09-01 Thread Ethan Furman
On 09/01/2013 05:59 PM, Roy Smith wrote: Ethan Furman wrote: On 09/01/2013 02:54 PM, Tim Delaney wrote: Roy Smith wrote: Nothing is accessible in Python except via getters and setters. The only difference between Python and, say, C++ in this regard is that the Python compiler writes them

Re: How to split with "\" character, and licence copyleft mirror of ©

2013-09-02 Thread Ethan Furman
On 09/01/2013 07:40 PM, Tim Roberts wrote: Another altrnative is to use "raw" strings, in which backslashes are not interpreted: a = r'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav' a.split(r'\') Not quite. --> r'\' File "", line 1 r'\' ^ SyntaxError: EOL while scan

Re: to be pythonic: should caller or callee log?

2013-09-03 Thread Ethan Furman
On 09/03/2013 09:07 AM, Gildor Oronar wrote: What would you choose? Do you put logging routine into caller or callee? My intuitive answer is "callee does the logging, because that's where action takes place", like this: class Account(): def transaction(self, amount, target): loggi

Re: Importing Definitions

2013-09-05 Thread Ethan Furman
On 09/05/2013 05:39 AM, Azureaus wrote: This will throw an error saying "global name 'A' is not defined." In Python, "global" really means "module-level". Now I know if there was a method I wanted to reference I could do something like this in module2. from module1 import method1 which wo

Re: Python KeyError

2013-09-06 Thread Ethan Furman
On 09/05/2013 01:37 AM, Robert Gliguroski wrote: I have installed OpenERP, an open source ERP software and then I installed an extension for connecting it to Magento. But when I configure it and try to connect them, I am getting and error that says: [snip] You might try asking at either Stac

Re: Language design

2013-09-11 Thread Ethan Furman
On 09/11/2013 03:38 AM, Burak Arslan wrote: On 09/10/13 09:09, Steven D'Aprano wrote: What design mistakes, traps or gotchas do you think Python has? My favourite gotcha is this: elt, = elts It's a nice and compact way to do both: assert len(elts) == 0 Perhaps you meant 'assert

Re: Language design

2013-09-11 Thread Ethan Furman
On 09/11/2013 01:41 PM, Markus Rother wrote: 4. As has been mentioned already, some built-in functions do magic stuff behind the scenes: That's why they're called magic methods. ;) >>> () == [] False But: >>> bool(().__eq__([])) True This is not a tra

Re: Language design

2013-09-12 Thread Ethan Furman
On 09/12/2013 10:51 AM, Markus Rother wrote: On 11.09.2013 23:15, Ethan Furman wrote: On 09/11/2013 01:41 PM, Markus Rother wrote: >>> () == [] False But: >>> bool(().__eq__([])) True This is not a trap, this is simply the wrong way to

Re: statsmodels.api

2013-09-16 Thread Ethan Furman
On 09/16/2013 08:37 AM, Davide Dalmasso wrote: Hi, I intalled an executable version of statsmodels library for Windows 32-bit. When I import it in my Python Shell no problem occurs buy when I write: import statsmodels.api as sm the following error arises: Traceback (most recent call last):

Python variables? [was Re: class implementation]

2013-09-30 Thread Ethan Furman
On 09/30/2013 02:28 PM, Ned Batchelder wrote: On 9/30/13 3:34 PM, Dave Angel wrote: Python doesn't actually have variables, but the things it documents as variables are local names within a method. Those are not visible outside of the method, regardless of whether you're in a class or a subclas

Re: class implementation

2013-09-30 Thread Ethan Furman
On 09/30/2013 04:45 PM, Steven D'Aprano wrote: I can't speak for others, but in my own experience, I never *quite* understood the semantic differences between Python name bindings and Pascal variables until I came across the meme "Python has no variables". +1 -- https://mail.python.org/mailman

Re: Can arbitrary code run in a server if someone's know just the MySQL password?

2013-10-02 Thread Ethan Furman
On 10/02/2013 07:46 AM, Νίκος wrote: Στις 2/10/2013 4:58 μμ, ο/η Ned Batchelder έγραψε: As others have said in this thread, this is not a Python topic. Find another forum for this question. Do not ask it here again. You've said that you can improve. Show us by not asking non-Python questions

Re: feature requests

2013-10-03 Thread Ethan Furman
On 10/03/2013 09:12 AM, macker wrote: Hi, hope this is the right group for this: I miss two basic (IMO) features in parallel processing: 1. make `threading.Thread.start()` return `self` I'd like to be able to `workers = [Thread(params).start() for params in whatever]`. Right now, it's 5 ugly,

Re: Literal syntax for frozenset, frozendict

2013-10-03 Thread Ethan Furman
On 10/03/2013 05:18 PM, Ben Finney wrote: random...@fastmail.us writes: Hey, while we're on the subject, can we talk about frozen(set|dict) literals again? I really don't understand why this discussion fizzles out whenever it's brought up on python-ideas. Can you start us off by searching for

Re: API for custom Unicode error handlers

2013-10-04 Thread Ethan Furman
On 10/04/2013 06:56 AM, Steven D'Aprano wrote: Should the module holding the error handlers automatically register them? I think it should. Registration only needs to happen once, the module is useless without being registered, no threads nor processes are being started, and the only reason

Re: feature requests

2013-10-05 Thread Ethan Furman
On 10/05/2013 05:49 AM, macker wrote: Ugly, menial lines are a clue that a function to hide it could be useful. Or a clue to add a trivial change elsewhere (hint for Ethan: `return self` at the end of `Thread.start()`). I'm aware that would solve your issue. I'm also aware that Python rare

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/09/2013 11:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like possible = foo and foo.allowsit() if (possible is None) : print "foo not provided" if (possible is False) : print "foo doesn't allow it" A bit awkward,

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi wrote: I'm trying to think of a good example usage of echo-argument and. Maybe something like A bit awkward, echo-argument or is more naturally useful to

Re: Complex literals (was Re: I am never going to complain about Python again)

2013-10-10 Thread Ethan Furman
On 10/10/2013 07:20 AM, Chris Angelico wrote: On Fri, Oct 11, 2013 at 1:12 AM, Grant Edwards wrote: Nope. "i" is electical current (though it's more customary to use upper case). "j" is the square root of -1. and that hypercomplex numbers include i, j, k, and maybe even other terms, and I n

Re: Python's and and Pythons or

2013-10-10 Thread Ethan Furman
On 10/10/2013 06:41 PM, Terry Reedy wrote: On 10/10/2013 9:33 AM, Ethan Furman wrote: On 10/10/2013 12:43 AM, Terry Reedy wrote: On 10/10/2013 2:45 AM, Chris Angelico wrote: first_element = some_list[0]# Oops, may crash some_list[0:1] always works, and sometimes is usable, but you

Re: Skipping decorators in unit tests

2013-10-11 Thread Ethan Furman
On 10/10/2013 08:01 PM, Roy Smith wrote: On 10Oct2013 19:44, Ned Batchelder wrote: I have to admit I'm having a hard time understanding why you'd need to test the undecorated functions. After all, the undecorated functions aren't available to anyone. All that matters is how they behave with t

Re: Skipping decorators in unit tests

2013-10-11 Thread Ethan Furman
On 10/10/2013 08:13 PM, Cameron Simpson wrote: On 11Oct2013 02:55, Steven D'Aprano wrote: On Fri, 11 Oct 2013 09:12:38 +1100, Cameron Simpson wrote: Speaking for myself, I would be include to recast this code: @absolutize def addition(a, b): return a + b into: def _addition

Re: when to use __new__, when to use __init__

2013-10-14 Thread Ethan Furman
On 10/14/2013 03:07 PM, Peter Cacioppi wrote: I've dome some reading on the difference between __new__ and __init__, and never really groked it. I just followed the advice that you should almost always use __init__. Object creation in Python is a two step process: - create the object (aka

Re: Python was designed (was Re: Multi-threading in Python vs Java)

2013-10-17 Thread Ethan Furman
On 10/17/2013 01:57 PM, Ned Batchelder wrote: Read and listen more. Write and say less. Mark Janssen has no interest in learning. From a thread long-ago: Mark Janssen wrote: Ethan Furman wrote: Mark Janssen wrote: Really? --> int="five" --> [int(i) for i in ["1&

Re: Tkinter tutorial?

2013-10-22 Thread Ethan Furman
On 10/22/2013 03:06 PM, Ben Finney wrote: Walter Hurry writes: However, for a different project I need to get up to a reasonable speed with tkinter. Could some kind soul recommend a suitable on-line tutorial, or a (free) ebook? TkDocs http://www.tkdocs.com/> is both a book for purchase (“Mod

Re: Confused about timezones

2013-10-23 Thread Ethan Furman
On 10/23/2013 12:00 PM, Skip Montanaro wrote: > --> LOCAL_TZ.localize(dt1).utcoffset() datetime.timedelta(-1, 68400) --> LOCAL_TZ.localize(dt2).utcoffset() datetime.timedelta(-1, 64800) Why is the UTC offset the same for both datetime objects despite the presence/absence of Daylight Savings?

Re: Maintaining a backported module

2013-10-23 Thread Ethan Furman
On 10/23/2013 09:54 PM, Steven D'Aprano wrote: I'm looking for advice on best practices for doing so. Any suggestions for managing bug fixes and enhancements to two separate code-bases without them diverging too much? Confining your code to the intersection of 2.7 and 3.x is probably going to

Re: Will Python 3.x ever become the actual standard?

2013-10-24 Thread Ethan Furman
On 10/23/2013 09:57 PM, Peter Cacioppi wrote: Moreover, you get a lot of the good stuff with 2.7. And the "good stuff" in 2.7 makes it easier to take that last step to 3.x when the time comes to do so. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Ethan Furman
On 10/24/2013 06:41 AM, Tim Daneliuk wrote: But now I feel bad about myself and it's all your fault. Really? *plonk* -- https://mail.python.org/mailman/listinfo/python-list

Re: Reading From stdin After Command Line Redirection

2013-10-24 Thread Ethan Furman
On 10/24/2013 01:14 AM, Mark Lawrence wrote: On 24/10/2013 04:53, Ben Finney wrote: Tim Daneliuk writes: 'Easy there Rainman I'll thank you not to use mental deficiency as some kind of insult. Calling someone “Rainman” is to use autistic people as the punchline of a joke. We're a community

Re: Maintaining a backported module

2013-10-24 Thread Ethan Furman
On 10/24/2013 01:37 AM, Mark Lawrence wrote: On 24/10/2013 07:30, Ethan Furman wrote: On 10/23/2013 09:54 PM, Steven D'Aprano wrote: I'm looking for advice on best practices for doing so. Any suggestions for managing bug fixes and enhancements to two separate code-bases without them

Re: Python Coverage: testing a program

2013-10-24 Thread Ethan Furman
On 10/24/2013 01:54 PM, Ben Finney wrote: Terry Reedy writes: On 10/24/2013 1:46 PM, Ned Batchelder wrote: It's been fun dropping the contortions for coverage.py 4.x, though! One request: ignore "if __name__ == '__main__':" clauses at the end of files, which cannot be run under coverage.py,

Re: Basic Python Questions - Oct. 31, 2013

2013-11-01 Thread Ethan Furman
On 11/01/2013 08:42 AM, William Ray Wing wrote: Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries t

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-02 Thread Ethan Furman
On 10/30/2013 01:32 PM, Gene Heskett wrote: Congratulations Jonas. My kill file for this list used to have only one name, but now has 2. You have more patience than I! Jonas just made mine seven. :) -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Algorithm that makes maximum compression of completly diffused data.

2013-11-02 Thread Ethan Furman
On 10/30/2013 12:23 PM, jonas.thornv...@gmail.com wrote: What i actually saying is that you are indeed... [insult snipped] *plonk* -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] os.path.join

2013-11-04 Thread Ethan Furman
On 11/04/2013 08:07 AM, Chris Angelico wrote: On Tue, Nov 5, 2013 at 2:29 AM, anatoly techtonik wrote: Right. But I am working more with URL paths nowadays. In there if I want to join two paths, no matter if 2nd starts with slash or not, I don't really expect the 2nd to rewrite the first. The

Re: [Python-ideas] os.path.join

2013-11-04 Thread Ethan Furman
On 11/04/2013 09:29 AM, random...@fastmail.us wrote: I did, incidentally, notice a bug in macpath's *split* function; macpath.split(':foo::bar') should return (':foo::','bar') rather than (':foo:','bar'). Open a bug report. :) http://bugs.python.org -- ~Ethan~ -- https://mail.python.org/mai

Re: To whoever hacked into my Database

2013-11-06 Thread Ethan Furman
On 11/06/2013 03:57 PM, Chris Angelico wrote: On Thu, Nov 7, 2013 at 10:52 AM, Mark Lawrence wrote: On 06/11/2013 22:54, Chris Angelico wrote: On Thu, Nov 7, 2013 at 9:34 AM, Tim Chase wrote: On 2013-11-06 22:22, Grant Edwards wrote: Waving red flags at female bulls is rarely dangerous. ;)

Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-11 Thread Ethan Furman
On 11/11/2013 01:28 AM, wxjmfa...@gmail.com wrote: * Some languages are just fundamentally bad. The flexible string representation is a perfect exemple. Argh! He escaped! *chase* *scuffle* *stuff* *stuff* *stuff* Whew. Safely back in the troll bin. Okay, back to my day. -- ~Ethan~ --

Re: datetime question

2013-11-11 Thread Ethan Furman
On 11/11/2013 11:19 AM, Denis McMahon wrote: On Mon, 11 Nov 2013 11:57:36 +0200, Νίκος Αλεξόπουλος wrote: lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( '%y-%m-%d %H:%M:%S' )# MySQL datetime format Someone has an idea what to add to this line to automatically adjust

Re: Design thought for callbacks

2015-02-26 Thread Ethan Furman
On 02/26/2015 11:54 AM, Ian Kelly wrote: > Sometimes I wonder whether anybody reads my posts. It's entirely possible the OP wasn't ready to understand your solution four days ago, but two days later the OP was. -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https://mail.

Re: Pyston 0.3 self-hosting

2015-02-27 Thread Ethan Furman
On 02/27/2015 12:41 PM, Travis Griggs wrote: > >> On Feb 24, 2015, at 9:47 PM, Steven D'Aprano >> wrote: >> >> Pyston 0.3, the latest version of a new high-performance Python >> implementation, has reached self-hosting sufficiency: >> >> >> http://blog.pyston.org/2015/02/24/pyston-0-3-self-host

Re: Python Worst Practices

2015-02-27 Thread Ethan Furman
On 02/27/2015 10:36 PM, Steven D'Aprano wrote: > Dan Sommers wrote: > >> On Sat, 28 Feb 2015 12:09:31 +1100, Steven D'Aprano wrote: >> >>> There's no harm in calling a local variable "id", if you don't use the >>> built-in id() inside that function. That's one of the reasons why >>> functions exis

Re: Python Worst Practices

2015-02-28 Thread Ethan Furman
On 02/28/2015 09:56 AM, MRAB wrote: > On 2015-02-28 16:03, Cousin Stanley wrote: >> >>> From : Tim Chase >>> >>> A quick google-and-tally for languages >>> and their corresponding number of keywords: >>> >> >>re-sorted >> >> 21 : Lua >> 31 : Python2.x >> 33 : Pyt

http: connection reset by peer

2015-03-03 Thread Ethan Furman
This may seem off-topic, but it's an issue for my roundup server which is written in Python, so hopefully that will buy me some slack. ;) And, yes, I did post a message to the Roundup Users mailing list first, but haven't received any replies. So, the basic problem is: I login to the roundup s

Re: http: connection reset by peer

2015-03-04 Thread Ethan Furman
On 03/04/2015 01:26 AM, Chris Angelico wrote: > On Wed, Mar 4, 2015 at 5:33 PM, Ethan Furman wrote: >> >> I login to the roundup server -- I can search, create new issues, post new >> messages via both email and the web >> interface, and I can attach files... but

Re: (Still OT) Nationalism, language and monoculture [was Re: Python Worst Practices]

2015-03-04 Thread Ethan Furman
On 03/04/2015 11:14 AM, Steven D'Aprano wrote: > > [...] > > > Wow -- a new level of succinctness! ;) -- ~Ethan~ signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: http: connection reset by peer

2015-03-05 Thread Ethan Furman
On 03/04/2015 01:26 AM, Chris Angelico wrote: > Do you have Mozilla Firebug, and if so, can you try the file > attachment with Firebug active? At very least, you should be able to > see exactly what request is getting reset, and then you could try to > simulate that exact request with a simpler ha

Re: Is nan in (nan,) correct?

2015-03-05 Thread Ethan Furman
On 03/05/2015 06:55 PM, Ben Finney wrote: > class NullType(object): > """ A type whose value never equals any other. > > This type's values will behave correctly when tested for > membership in a collection:: > > >>> foo = NullType() >

Re: Is nan in (nan,) correct?

2015-03-05 Thread Ethan Furman
On 03/05/2015 07:26 PM, Ben Finney wrote: > Ethan Furman writes: > >> On 03/05/2015 06:55 PM, Ben Finney wrote: >> >>> class NullType(object): >>> """ A type whose value never equals any other. >>> >>>

How fast does your grass grow? [was Re: HELP!! How to ask a girl out with a simple witty Python code??]

2015-03-05 Thread Ethan Furman
On 03/05/2015 07:37 PM, Chris Angelico wrote: > I'm sure there's something more interesting to talk about... like the > rate at which the grass is growing. My grass doesn't grow -- I ripped it all out and put down pea-gravel and planter boxes. Oh, wait, I have some bamboo in the back -- that's

Re: Is nan in (nan,) correct?

2015-03-06 Thread Ethan Furman
On 03/06/2015 10:04 AM, Rustom Mody wrote: > On Friday, March 6, 2015 at 10:29:19 PM UTC+5:30, Steven D'Aprano wrote: >> def inverse(x): >> return 1.0/x >> >> There's an exception there, waiting to bite. If I include inverse() in some >> complex calculation: >> >> def function(x, y): >> re

Re: __new__() does not return anything, on singletong pattern

2015-03-11 Thread Ethan Furman
On 03/11/2015 04:33 PM, Mario Figueiredo wrote: > The following code runs just fine. But PyCharm flags the assignment > with a warning telling me that generate() does not return anything and > the I lose code completion on the mmap variable. > > if __name__ == '__main__': > mmap = Map.generat

Re: Function decorator having arguments is complicated

2015-04-26 Thread Ethan Furman
On 04/27, Makoto Kuwata wrote: > > I feel that function decorator having arguments is complicated, > because three 'def' are nested: > > def multiply(n): > def deco(func): > def newfunc(*args, **kwargs): > return n * func(*args, **kwargs) > return newfunc > return de

Re: Function decorator having arguments is complicated

2015-04-26 Thread Ethan Furman
On 04/27, Chris Angelico wrote: > On Mon, Apr 27, 2015 at 2:24 PM, Ethan Furman wrote: > > On 04/27, Makoto Kuwata wrote: > >> > >> I feel that function decorator having arguments is complicated, > >> because three 'def' are nested: >

Re: Function decorator having arguments is complicated

2015-04-27 Thread Ethan Furman
On 04/27, Maxime S wrote: > Le lun. 27 avr. 2015 à 04:39, Makoto Kuwata a écrit : > > > > If function decorator notation could take arguments, > > decorator definition would be more simple: > > > > def multiply(func, n): > > def newfunc(*args, **kwargs): > > return n * func(*args, **kw

Re: Clize 3.0b1: An argument parser that draws a CLI from your function sigature

2015-04-27 Thread Ethan Furman
On 04/28, Chris Angelico wrote: > That's a lot of separate pieces. Here's the docstringargs equivalent: > > https://github.com/Rosuav/snippets/blob/dsa/snippets.py Just for grins, here's that using Scription: -- 8< """Store an

Re: Not possible to hide local variables

2015-04-28 Thread Ethan Furman
On 04/28, Cecil Westerhof wrote: > If I remember correctly you can not hide variables of a class or make > them read-only? > > I want to rewrite my moving average to python. The init is: > def __init__(self, length): > if type(length) != int: > raise ParameterError, 'Parame

Re: Looking for direction

2015-05-13 Thread Ethan Furman
On 05/13/2015 04:24 PM, 20/20 Lab wrote: I'm a beginner to python. Reading here and there. Written a couple of short and simple programs to make life easier around the office. That being said, I'm not even sure what I need to ask for. I've never worked with external data before. I have a LARG

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Ethan Furman
On 05/14/2015 08:45 AM, Steven D'Aprano wrote: I'd like to do a little survey, and get a quick show of hands. How many people have written GUI or text-based applications or scripts where a "Move file to trash" function would be useful? Never. Would you like to see that in the standard librar

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Ethan Furman
On 05/14/2015 11:43 AM, Chris Warrick wrote: And if you are looking for a mostly-compliant Python library/app (and a shameless plug): https://pypi.python.org/pypi/trashman/1.5.0 The docs listed link to Package Builder. How is that related to TrashMan? -- ~Ethan~ -- https://mail.python.org/m

Re: pip grabs tar.gz file instead of whl?

2015-05-15 Thread Ethan Furman
On 05/15/2015 06:04 AM, Mark Lawrence wrote: C:\Users\Mark\Documents\MyPython>pip install --no-cache-dir --trusted-host http://www.lfd.uci.edu/ -U -f http://www.lfd.uci.edu/~gohlke/pythonlibs/ numba > Collecting numba This repository located at www.lfd.uci.edu is not a trusted host, if this

Re: fork/exec & close file descriptors

2015-05-19 Thread Ethan Furman
On 05/19/2015 05:59 AM, Skip Montanaro wrote: Due to presumed bugs in an underlying library over which I have no control, I'm considering a restart in the wee hours of the morning. The basic fork/exec dance is not a problem, but how do I discover all the open file descriptors in the new child

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ethan Furman
On 05/22/2015 01:34 PM, Marko Rauhamaa wrote: Ian Kelly : An "object" in Javascript is basically just a collection of properties. For example: js> typeof([1, 2, 3]) "object" js> typeof({a: 1, b: 2, c: 3}) "object" Here's what happens when you try to access a property on null: js> null.foo ty

Re: What is considered an "advanced" topic in Python?

2015-05-29 Thread Ethan Furman
On 05/29/2015 10:03 AM, sohcahto...@gmail.com wrote: On Friday, May 29, 2015 at 9:02:06 AM UTC-7, Mike Driscoll wrote: I've been asked on several occasions to write about intermediate or advanced topics in Python and I was wondering what the community considers to be "intermediate" or "adv

Re: What is considered an "advanced" topic in Python?

2015-05-29 Thread Ethan Furman
On 05/29/2015 02:06 PM, sohcahto...@gmail.com wrote: On Friday, May 29, 2015 at 10:18:29 AM UTC-7, Ethan Furman wrote: Metaclasses change the way a class behaves. For example, the new (in 3.4) Enum class uses a metaclass. class SomeEnum(Enum): first = 1 second = 2

Re: What is considered an "advanced" topic in Python?

2015-05-29 Thread Ethan Furman
On 05/29/2015 02:28 PM, Jason Swails wrote: ​[...] e.g., if the person creating an Enum subclass didn't bother to correctly implement [...] __iter__, and __len__ for their subclass For __iter__ and __len__ to work on the Enum /class/ it must be defined in the metaclass. -- ~Ethan~ -- https:/

Re: Using Python instead of Bash

2015-05-31 Thread Ethan Furman
Just for funsies, I did a slight rewrite using my scription[1] library: --8<-- #!/usr/bin/python3 """ Convert scanned images: contrast is increased, size is enlarged, format is changed from jpeg to png. """ from __future

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason that message failed. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Retrying to send message

2015-06-03 Thread Ethan Furman
On 06/03/2015 01:37 PM, Mark Lawrence wrote: On 03/06/2015 19:28, Ethan Furman wrote: On 06/03/2015 09:15 AM, Cecil Westerhof wrote: I kept the except. I like to see the message that went wrong. ;-) That's fine, but then add a `raise` after you print the error so you can see the reason

Re: Set a flag on the function or a global?

2015-06-15 Thread Ethan Furman
On 06/15/2015 04:57 PM, Steven D'Aprano wrote: Thoughts and feedback? Please vote: a module global, or a flag on the object? Please give reasons, and remember that the function is intended for interactive use. Function attribute. Setting a global on the module (which I may not have, and proba

Re: Set a flag on the function or a global?

2015-06-15 Thread Ethan Furman
On 06/15/2015 05:07 PM, Chris Angelico wrote: On Tue, Jun 16, 2015 at 9:57 AM, Steven D'Aprano wrote: I have two ideas for this, a module-level global, or a flag set on the function object itself. Remember that the usual way of using this will be "from module import edir", there are two obviou

Re: Set a flag on the function or a global?

2015-06-15 Thread Ethan Furman
On 06/15/2015 05:37 PM, Paul Rubin wrote: Steven D'Aprano writes: Thoughts and feedback? Please vote: a module global, or a flag on the object? Please give reasons, and remember that the function is intended for interactive use. Both are bad. More state to remember, ugh. Instead have separa

Re: Set a flag on the function or a global?

2015-06-16 Thread Ethan Furman
On 06/16/2015 06:56 AM, Michael Torrie wrote: On 06/15/2015 06:19 PM, Ethan Furman wrote: Setting a global on the module (which I may not have, and probably didn't, import) for only one function is overkill. What do you mean? Even if you pull in just one function from the module

Re: Testing random

2015-06-16 Thread Ethan Furman
On 06/16/2015 06:01 PM, Chris Angelico wrote: The only instance of gambler's fallacy I'm seeing here is "PointedEars didn't understand the last dozen emails, so he's due to understand the next one". I've given up trying to explain. +1 QotW -- https://mail.python.org/mailman/listinfo/python-lis

converting boolean filter function to lambda

2015-06-25 Thread Ethan Furman
I have the following function: def phone_found(p): for c in contacts: if p in c: return True return False with the following test data: contacts = ['672.891.7280 x999', '291.792.9000 x111'] main = ['291.792.9001', '291.792.9000'] which works: filter(phone_found, main) # ['291.79

Re: converting boolean filter function to lambda

2015-06-25 Thread Ethan Furman
On 06/25/2015 05:09 PM, Mark Lawrence wrote: On 26/06/2015 00:59, Chris Angelico wrote: On Fri, Jun 26, 2015 at 1:59 AM, Ethan Furman wrote: My attempt at a lambda function fails: filter(lambda p: (p in c for c in contacts), main) # ['291.792.9001', '291.792.9000'] Be

Re: (side-)effects and ...

2015-07-06 Thread Ethan Furman
On 07/05/2015 01:29 PM, Stefan Ram wrote: The function »datetime.datetime.now().time()« does not yield a value that is determined by the expression »time()«; instead its value can /differ/ between two calls even when the call »time()« does not differ. In mathematics, however, a ca

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-13 Thread Ethan Furman
Antoon, I think Chris is arguing in good faith; certainly asking for examples should be a reasonable request. Even if he is not, we would have better discussions and other participants would learn more if you act like he is. I would love to see good functional examples as it is definitely a

Re: Mapping, with sequence as key, wildcard and subsequence matching

2015-07-15 Thread Ethan Furman
On 07/15/2015 10:53 PM, Ben Finney wrote: Steven D'Aprano writes: You can't use a dict for the mapping, not unless you're smarter than me, due to the requirement to hash the keys. Dang. It's the mapping that I really need to solve, I think. A mapping that has a custom “does this candidate m

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Ethan Furman
On 07/16/2015 09:43 AM, Chris Angelico wrote: True. That said, though, it's not a justification for dropping stack frames; even in the form that's printed to stderr, there is immense value in them. It may be possible to explicitly drop frames that a programmer believes won't be useful, but a gen

Re: A new module for performing tail-call elimination

2015-07-16 Thread Ethan Furman
On 07/16/2015 01:07 AM, Steven D'Aprano wrote: The point is, people keep insisting that there are a vast number of algorithms which are best expressed using recursion and which require TCO to be practical, and yet when asked for examples they either can't give any examples at all, or they give e

Re: A new module for performing tail-call elimination

2015-07-16 Thread Ethan Furman
On 07/16/2015 06:35 AM, Antoon Pardon wrote: On 07/16/2015 01:11 PM, Chris Angelico wrote: Unless, of course, *all* TCO examples, even real-world ones, could be trivially reimplemented some other way, a theory which is gaining currency... Of course they could be rather trivially reimplemente

Re: Possibly Pythonic Tail Call Optimization (TCO/TRE)

2015-07-16 Thread Ethan Furman
On 07/16/2015 12:14 PM, Joonas Liik wrote: You are giving the programmer a choice between "run out of stack and crash" and "mutilate interpreter internals and crash or zero out the hard drive" this is not a real choice.. +1 -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: A new module for performing tail-call elimination

2015-07-16 Thread Ethan Furman
On 07/16/2015 12:45 PM, Terry Reedy wrote: On 7/16/2015 2:02 PM, Ethan Furman wrote: On 07/16/2015 06:35 AM, Antoon Pardon wrote: Here is one way to do the odd, even example. def even(n): return odd_even('even', n) def odd(n): return odd_even('odd', n)

Re: Proposed keyword to transfer control to another function

2015-07-16 Thread Ethan Furman
On 07/16/2015 04:46 PM, Chris Angelico wrote: Examples: # derived from Paul Rubin's example def quicksort(array, start, end): midp = partition(array, start, end) if midp <= (start+end)//2: quicksort(array, start, midp) transfer quicksort(array, midp+1, end) e

Re: Proposed keyword to transfer control to another function

2015-07-17 Thread Ethan Furman
On 07/17/2015 12:17 AM, Antoon Pardon wrote: On 07/17/2015 01:46 AM, Chris Angelico wrote: Open for bikeshedding: What should the keyword be? We can't use "exec", which would match Unix and shell usage, because it's already used in a rather different sense in Python. Current candidates: "transfe

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Ethan Furman
On 06/05/2014 04:30 PM, Marko Rauhamaa wrote: What I'm afraid of is that the Python developers are reserving the right to remove the buffer and detach attributes from the standard streams in a future version. Being afraid is silly. If you have a question, ask it. -- ~Ethan~ -- https://mail.

Re: Python 3.2 has some deadly infection

2014-06-06 Thread Ethan Furman
On 06/05/2014 11:30 AM, Marko Rauhamaa wrote: > How text is represented is very different from whether text is a fundamental data type. A fundamental text file is such that ordinary operating system facilities can't see inside the black box (that is, they are *not* encoded as far as the applicati

Re: Python 3.2 has some deadly infection

2014-06-06 Thread Ethan Furman
On 06/05/2014 09:32 AM, Steven D'Aprano wrote: But whatever the situation, and despite our differences of opinion about Unicode, THANK YOU for having updated ReportLabs to 3.3. +1000 -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: try/except/finally

2014-06-07 Thread Ethan Furman
On 06/06/2014 11:22 AM, Ned Batchelder wrote: On 6/6/14 1:47 PM, Frank B wrote: Ok; thanks for the underscore and clarification. Just need to adjust my thinking a bit. Did this come up in real code? I've seen this point about finally/return semantics a number of times, but haven't seen re

Re: os.startfile hanging onto the launched app, or my IDE?

2014-06-09 Thread Ethan Furman
On 06/09/2014 03:21 PM, Josh English wrote: So this quirk is coming from PyScripter, which is a shame, because I don't think it's under development, so it won't be fixed. The nice thing about Python code is you can at least fix your copy. :) -- ~Ethan~ -- https://mail.python.org/mailman/lis

Re: os.startfile hanging onto the launched app, or my IDE?

2014-06-10 Thread Ethan Furman
On 06/09/2014 09:46 PM, Tim Golden wrote: On 09/06/2014 23:31, Ethan Furman wrote: On 06/09/2014 03:21 PM, Josh English wrote: So this quirk is coming from PyScripter, which is a shame, because I don't think it's under development, so it won't be fixed. The nice thing about

Re: First time I looked at Python was(...)

2014-06-10 Thread Ethan Furman
On 06/09/2014 01:54 PM, Carlos Anselmo Dias wrote: [snip] *plonk* -- https://mail.python.org/mailman/listinfo/python-list

Re: try/except/finally

2014-06-10 Thread Ethan Furman
On 06/10/2014 01:38 PM, Roy Smith wrote: Chris Angelico wrote: # Yeah. As soon as you take on board a hard-and-fast rule, you open yourself up to stupid cases where the rule ought to have been broken. I don't know a single piece of programming advice which, if taken as an inviolate rule, doesn'

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-10 Thread Ethan Furman
On 06/10/2014 04:29 PM, Devin Jeanpierre wrote: Please don't be unnecessarily cruel and antagonistic. I completely agree. jmf should leave us alone and stop cruelly and antagonizingly baiting us with stupidity and falsehoods. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-lis

<    7   8   9   10   11   12   13   14   15   16   >