Re: Users banned

2018-07-15 Thread Devin Jeanpierre
On Sun, Jul 15, 2018 at 5:09 PM Jim Lee wrote: > That is, of course, the decision of the moderators - but I happen to > agree with both Christian and Ethan. Banning for the simple reason of a > dissenting opinion is censorship, pure and simple. While Bart may have > been prolific in his argument

Kindness

2018-07-13 Thread Devin Jeanpierre
On Fri, Jul 13, 2018 at 10:49 AM Mark Lawrence wrote: > > On 13/07/18 16:16, Bart wrote: > > On 13/07/2018 13:33, Steven D'Aprano wrote: > >> On Fri, 13 Jul 2018 11:37:41 +0100, Bart wrote: > >> > >>> (** Something so radical I've been using them elsewhere since forever.) > >> > >> And you just ca

Re: Thread-safe way to add a key to a dict only if it isn't already there?

2018-07-07 Thread Devin Jeanpierre
On Sat, Jul 7, 2018 at 6:49 AM Marko Rauhamaa wrote: > Is that guaranteed to be thread-safe? The documentation ( s://docs.python.org/3/library/stdtypes.html#dict.setdefault>) makes no > such promise. It's guaranteed to be thread-safe because all of Python's core containers are thread safe (in as

Re: Why is the use of an undefined name not a syntax error?

2018-04-01 Thread Devin Jeanpierre
On Sun, Apr 1, 2018 at 2:38 PM, Chris Angelico wrote: > On Mon, Apr 2, 2018 at 7:24 AM, David Foster wrote: >> My understanding is that the Python interpreter already has enough >> information when bytecode-compiling a .py file to determine which names >> correspond to local variables in functi

Re: Why is the use of an undefined name not a syntax error?

2018-04-01 Thread Devin Jeanpierre
> But if it is cheap to detect a wide variety of name errors at compile time, > is there any particular reason it is not done? >From my perspective, it is done, but by tools that give better output than Python's parser. :) Linters (like pylint) are better than syntax errors here, because they co

Re: binary decision diagrams

2017-12-20 Thread Devin Jeanpierre
On Mon, Dec 18, 2017 at 5:00 AM, Wild, Marcel, Dr wrote: > Hello everybody: > I really don't know anything about Python (I'm using Mathematica) but with > the help of others learned that > > g=expr2bdd(f) > > makes the BDD (=binary decision diagram) g of a Boolean function f. But > what is th

Re: tempname.mktemp functionality deprecation

2017-04-29 Thread Devin Jeanpierre
On Sat, Apr 29, 2017 at 11:45 AM, Tim Chase wrote: > Unfortunately, tempfile.mktemp() is described as deprecated > since 2.3 (though appears to still exist in the 3.4.2 that is the > default Py3 on Debian Stable). While the deprecation notice says > "In version 2.3 of Python, this module was overh

Re: Clickable hyperlinks

2017-01-05 Thread Devin Jeanpierre
Sadly, no. :( Consoles (and stdout) are just text, not hypertext. The way to make an URL clickable is to use a terminal that makes URLs clickable, and print the URL: print("%s: %s" % (description, url)) -- Devin On Tue, Jan 3, 2017 at 11:46 AM, Deborah Swanson wrote: > Excel has a formula:

Re: Clickable hyperlinks

2017-01-03 Thread Devin Jeanpierre
Sadly, no. :( Consoles (and stdout) are just text, not hypertext. The way to make an URL clickable is to use a terminal that makes URLs clickable, and print the URL: print("%s: %s" % (description, url)) -- Devin On Tue, Jan 3, 2017 at 11:46 AM, Deborah Swanson wrote: > Excel has a formula: >

Re: Looking for ideas to improve library API

2015-11-28 Thread Devin Jeanpierre
Documentation is all you can do. -- Devin On Thu, Nov 26, 2015 at 5:35 AM, Chris Lalancette wrote: > On Thu, Nov 26, 2015 at 7:46 AM, Devin Jeanpierre > wrote: >> Why not take ownership of the file object, instead of requiring users >> to manage lifetimes? > > Yeah, I&#

Re: Looking for ideas to improve library API

2015-11-26 Thread Devin Jeanpierre
Why not take ownership of the file object, instead of requiring users to manage lifetimes? -- Devin On Wed, Nov 25, 2015 at 12:52 PM, Chris Lalancette wrote: > Hello, > I'm currently developing a library called pyiso ( > https://github.com/clalancette/pyiso), used for manipulating ISO disk

Re: Should non-security 2.7 bugs be fixed?

2015-07-20 Thread Devin Jeanpierre
I think you're missing the line where I said all the relevant conversation happened in IRC, and that you should refer to logs. On Sun, Jul 19, 2015 at 11:25 PM, Terry Reedy wrote: > On 7/19/2015 9:20 PM, Devin Jeanpierre wrote: > >> Search your logs for https://bugs.python.org/i

Re: Should non-security 2.7 bugs be fixed?

2015-07-19 Thread Devin Jeanpierre
On Sun, Jul 19, 2015 at 8:05 PM, Steven D'Aprano wrote: > On Mon, 20 Jul 2015 11:20 am, Devin Jeanpierre wrote: >> I was most frustrated by the first case -- the patch was (informally) >> rejected in favor of the "right" fix, and the "right" fix was >

Re: Should non-security 2.7 bugs be fixed?

2015-07-19 Thread Devin Jeanpierre
On Sat, Jul 18, 2015 at 9:45 PM, Steven D'Aprano wrote: >> It gets really boring submitting 2.7-specific patches, though, when >> they aren't accepted, and the committers have such a hostile attitude >> towards it. I was told by core devs that, instead of fixing bugs in >> Python 2, I should just

Re: Should non-security 2.7 bugs be fixed?

2015-07-18 Thread Devin Jeanpierre
On Sat, Jul 18, 2015 at 6:34 PM, Terry Reedy wrote: > On 7/18/2015 8:27 PM, Mark Lawrence wrote: >> On 19/07/2015 00:36, Terry Reedy wrote: >> Programmers don't much like doing maintainance work when they're paid to >> do it, so why would they volunteer to do it? > > Right. So I am asking: if a 3

Re: Should non-security 2.7 bugs be fixed?

2015-07-18 Thread Devin Jeanpierre
Considering CPython is officially accepting performance improvements to 2.7, surely bug fixes are also allowed? I have contributed both performance improvements and bug fixes to 2.7. In my experience, the problem is not the lack of contributors, it's the lack of code reviewers. I think this is so

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Devin Jeanpierre
On Sat, Jun 27, 2015 at 6:18 PM, Steven D'Aprano wrote: > On Sun, 28 Jun 2015 06:30 am, Devin Jeanpierre wrote: > >> On Fri, Jun 26, 2015 at 11:16 PM, Steven D'Aprano >> wrote: >>> On Sat, 27 Jun 2015 02:05 pm, Devin Jeanpierre wrote: >>> >>

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Devin Jeanpierre
On Fri, Jun 26, 2015 at 11:16 PM, Steven D'Aprano wrote: > On Sat, 27 Jun 2015 02:05 pm, Devin Jeanpierre wrote: > >> On Fri, Jun 26, 2015 at 8:38 PM, Steven D'Aprano >> wrote: >>> Now you say that the application encrypts the data, except that the user >&

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Devin Jeanpierre
On Fri, Jun 26, 2015 at 8:38 PM, Steven D'Aprano wrote: > Now you say that the application encrypts the data, except that the user can > turn that option off. > > Just make the AES encryption mandatory, not optional. Then the user cannot > upload unencrypted malicious data, and the receiver cannot

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Devin Jeanpierre
Johannes, I agree with a lot of what you say, but can you please have less of a mean attitude? -- Devin On Fri, Jun 26, 2015 at 3:42 PM, Johannes Bauer wrote: > On 26.06.2015 23:29, Jon Ribbens wrote: > >>> While you seem to think that Steven is rampaging about nothing, he does >>> have a fair p

Re: Pure Python Data Mangling or Encrypting

2015-06-25 Thread Devin Jeanpierre
On Thu, Jun 25, 2015 at 2:57 AM, Chris Angelico wrote: > On Thu, Jun 25, 2015 at 7:41 PM, Devin Jeanpierre > wrote: >>> I know that the OP doesn't propose using ROT-13, but a classical >>> substitution cipher isn't that much stronger. >> >> Yes, it

Re: Pure Python Data Mangling or Encrypting

2015-06-25 Thread Devin Jeanpierre
On Thu, Jun 25, 2015 at 2:25 AM, Steven D'Aprano wrote: > On Thursday 25 June 2015 14:27, Devin Jeanpierre wrote: >> The original post said that the sender will usually send files they >> encrypted, unless they are malicious. So if the sender wants them to >> be e

Re: Pure Python Data Mangling or Encrypting

2015-06-24 Thread Devin Jeanpierre
On Wed, Jun 24, 2015 at 9:07 PM, Steven D'Aprano wrote: > But just sticking to the three above, the first one is partially mitigated > by allowing virus scanners to scan the data, but that implies that the > owner of the storage machine can spy on the files. So you have a conflict > here. If it's

Re: Pure Python Data Mangling or Encrypting

2015-06-24 Thread Devin Jeanpierre
How about a random substitution cipher? This will be ultra-weak, but fast (using bytes.translate/bytes.maketrans) and seems to be the kind of thing you're asking for. -- Devin On Tue, Jun 23, 2015 at 12:02 PM, Randall Smith wrote: > Chunks of data (about 2MB) are to be stored on machines using a

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
Snipped aplenty. On Wed, Jun 10, 2015 at 8:21 PM, Steven D'Aprano wrote: > On Thu, 11 Jun 2015 08:10 am, Devin Jeanpierre wrote: > [...] >> I could spend a bunch of time writing yet another config file format, >> or I could use text format protocol buffers, YAML, or TO

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:46 PM, Terry Reedy wrote: > On 6/10/2015 7:39 PM, Devin Jeanpierre wrote: >> >> On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy wrote: >>> >>> On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: >>> >>>> The problem is

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:39 PM, Devin Jeanpierre wrote: > On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy wrote: >> On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: >> >>> The problem is that there are two different ways repr might write out >>> a dict equal to {&#x

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
On Wed, Jun 10, 2015 at 4:25 PM, Terry Reedy wrote: > On 6/10/2015 6:10 PM, Devin Jeanpierre wrote: > >> The problem is that there are two different ways repr might write out >> a dict equal to {'a': 1, 'b': 2}. This can make tests brittle > > >

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-10 Thread Devin Jeanpierre
AM, Steven D'Aprano wrote: > On Wednesday 10 June 2015 14:48, Devin Jeanpierre wrote: > > [...] >> and literal_eval is not a great idea. >> >> * the common serializer (repr) does not output a canonical form, and >> can serialize things in a way that they can't

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
On Tue, Jun 9, 2015 at 8:52 PM, Steven D'Aprano wrote: > On Wednesday 10 June 2015 10:47, Devin Jeanpierre wrote: > >> Passing around data that can be put into ast.literal_eval is >> synonymous with passing around data taht can be put into eval. It >> sounds lik

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
underrated. (Relatedly: underdocumented, too.) /me lifts head out of kool-aid and gasps for air -- Devin On Tue, Jun 9, 2015 at 5:17 PM, Irmen de Jong wrote: > On 10-6-2015 1:06, Chris Angelico wrote: >> On Wed, Jun 10, 2015 at 6:07 AM, Devin Jeanpierre >> wrote: >>> There&

Re: enhancement request: make py3 read/write py2 pickle format

2015-06-09 Thread Devin Jeanpierre
There's a lot of subtle issues with pickle compatibility. e.g. old-style vs new-style classes. It's kinda hard and it's better to give up. I definitely agree it's better to use something else instead. For example, we switched to using protocol buffers, which have much better compatibility propertie

Re: Pickle based workflow - looking for advice

2015-04-13 Thread Devin Jeanpierre
On Mon, Apr 13, 2015 at 10:58 AM, Fabien wrote: > Now, to my questions: > 1. Does that seem reasonable? A big issue is the use of pickle, which is: * Often suboptimal performance wise (e.g. you can't load only subsets of the data) * Makes forwards/backwards compatibility very difficult * Can mak

Re: You must register a new account to report a bug (was: Python 2 to 3 conversion - embrace the pain)

2015-03-15 Thread Devin Jeanpierre
On Sun, Mar 15, 2015 at 11:17 PM, Ben Finney wrote: > Sadly becoming the norm. People will run a software project and just > assume that users will be willing to go through a registration process > for every project just to report a bug. Registering for github is a lot easier than creating a repr

Re: Design thought for callbacks

2015-02-21 Thread Devin Jeanpierre
On Fri, Feb 20, 2015 at 9:42 PM, Chris Angelico wrote: > No, it's not. I would advise using strong references - if the callback > is a closure, for instance, you need to hang onto it, because there > are unlikely to be any other references to it. If I register a > callback with you, I expect it to

Re: meaning of: line, =

2015-02-06 Thread Devin Jeanpierre
Sorry for late reply, I somehow missed this email. On Thu, Feb 5, 2015 at 8:59 AM, Rustom Mody wrote: > The reason I ask: I sorely miss haskell's pattern matching in python. > > It goes some way: > ((x,y),z) = ((1,2),3) x,y,z > (1, 2, 3) > > But not as far as I would like: > ((x,y)

Re: meaning of: line, =

2015-02-05 Thread Devin Jeanpierre
On Thu, Feb 5, 2015 at 8:08 AM, Ian Kelly wrote: > On Thu, Feb 5, 2015 at 2:40 AM, Steven D'Aprano > wrote: >> Devin Jeanpierre wrote: >>> On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico wrote: >>>>>>>> [result] = f() >>>>>>>

Re: meaning of: line, =

2015-02-05 Thread Devin Jeanpierre
On Wed, Feb 4, 2015 at 1:18 PM, Chris Angelico wrote: > On Thu, Feb 5, 2015 at 4:36 AM, Peter Otten <__pete...@web.de> wrote: >> Another alternative is to put a list literal on the lefthand side: >> > def f(): yield 42 >> >> ... > [result] = f() > result >> 42 > > Huh, was not aware of

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

2015-02-03 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 6:20 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: >> Oops, I just realized why such a claim might be made: the >> documentation probably wants to be able to say that any method can use >> super(). So that's why it claims that it isn&#x

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

2015-02-03 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 6:07 AM, Steven D'Aprano wrote: > Run this code: > > # === cut === > > class K(object): > def f(self): pass > > def f(self): pass > > instance = K() > things = [instance.f, f.__get__(instance, K)] > from random import shuffle > shuffle(things) > print(things) > > # === c

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

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 5:00 AM, Devin Jeanpierre wrote: > On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano > wrote: >>> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano >>> wrote: >> Both K.f and K.g are methods, even though only one meets the definition &

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

2015-02-02 Thread Devin Jeanpierre
On Mon, Feb 2, 2015 at 4:06 AM, Steven D'Aprano wrote: >> On Sun, Feb 1, 2015 at 11:15 PM, Steven D'Aprano >> wrote: > Both K.f and K.g are methods, even though only one meets the definition > given in the glossary. The glossary is wrong. I agree, it oversimplified and has made a useless distinc

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

2015-02-01 Thread Devin Jeanpierre
-- 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

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
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 poly

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
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

Re: Python is DOOMED! Again!

2015-02-01 Thread Devin Jeanpierre
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 t

Re: Python is DOOMED! Again!

2015-01-31 Thread Devin Jeanpierre
Sorry, sort of responding to both of you. On Sat, Jan 31, 2015 at 10:12 PM, 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

Re: RAII vs gc (was fortran lib which provide python like data type)

2015-01-31 Thread Devin Jeanpierre
On Fri, Jan 30, 2015 at 1:28 PM, Sturla Molden wrote: > in Python. It actually corresponds to > > with Foo() as bar: > The problem with with statements is that they only handle the case of RAII with stack allocated variables, and can't handle transfer of ownership cleanly. Consider the case

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-29 Thread Devin Jeanpierre
On Wed, Jan 28, 2015 at 4:34 PM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: >> Git doesn't help if you lose your files in between commits, > > Sure it does? You just lose the changes made since the previous commit, but > that's no different from restoring

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Devin Jeanpierre
I distrust any backup strategy that requires explicit action by the user. I've seen users fail too often. (Including myself.) -- Devin On Wed, Jan 28, 2015 at 2:02 PM, Chris Angelico wrote: > On Thu, Jan 29, 2015 at 8:52 AM, Devin Jeanpierre > wrote: >> Git doesn't help

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Devin Jeanpierre
On Wed, Jan 28, 2015 at 1:40 PM, Chris Angelico wrote: > On Thu, Jan 29, 2015 at 5:47 AM, Chris Kaynor > wrote: >> I use Google Drive for it for all the stuff I do at home, and use SVN >> for all my personal projects, with the SVN depots also in Drive. The >> combination works well for me, I can

Re: multiprocessing module backport from 3 to 2.7 - spawn feature

2015-01-28 Thread Devin Jeanpierre
On Wed, Jan 28, 2015 at 10:06 AM, Skip Montanaro wrote: > On Wed, Jan 28, 2015 at 7:07 AM, Andres Riancho > wrote: >> The feature I'm specially interested in is the ability to spawn >> processes [1] instead of forking, which is not present in the 2.7 >> version of the module. > > Can you explain

Re: ANN: unpyc3 - a python bytecode decompiler for Python3

2015-01-28 Thread Devin Jeanpierre
FWIW I put all my source code inside Dropbox so that even things I haven't yet committed/pushed to Bitbucket/Github are backed up. So far it's worked really well, despite using Dropbox on both Windows and Linux. (See also: Google Drive, etc.) (Free) Dropbox has a 30 day recovery time limit, and I

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

2015-01-27 Thread Devin Jeanpierre
On Tue, Jan 27, 2015 at 9:37 PM, wrote: > On Tue, Jan 27, 2015, at 16:06, Mario Figueiredo wrote: >> That error message has me start that thread arguing that the error is >> misleading because the Sub object does have the __bases__ attribute. >> It's the Sub instance object that does not have it.

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

2015-01-24 Thread Devin Jeanpierre
On Sat, Jan 24, 2015 at 5:58 PM, Ethan Furman wrote: > 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

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

2015-01-24 Thread Devin Jeanpierre
On Sat, Jan 24, 2015 at 11:55 AM, Chris Angelico wrote: > That's still only able to assign to a key of a dictionary, using the > function name. There's no way to represent fully arbitrary assignment > in Python - normally, you can assign to a name, an attribute, a > subscripted item, etc. (Augment

Re: Trees

2015-01-20 Thread Devin Jeanpierre
There are similarly many kinds of hash tables. For a given use case (e.g. a sorted dict, or a list with efficient removal, etc.), there's a few data structures that make sense, and a library (even the standard library) doesn't have to expose which one was picked as long as the performance is good.

Re: Trees

2015-01-19 Thread Devin Jeanpierre
On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano wrote: > Zachary Gilmartin wrote: > >> Why aren't there trees in the python standard library? > > Possibly because they aren't needed? Under what circumstances would you use > a tree instead of a list or a dict or combination of both? > > That's not

Re: Hello World

2015-01-17 Thread Devin Jeanpierre
Sorry for necro. On Sat, Dec 20, 2014 at 10:44 PM, Chris Angelico wrote: > On Sun, Dec 21, 2014 at 5:31 PM, Terry Reedy wrote: >> Just to be clear, writing to sys.stdout works fine in Idle. > import sys; sys.stdout.write('hello ') >> hello #2.7 >> >> In 3.4, the number of chars? bytes? is r

Re: PyWart: Poor Documentation Examples

2015-01-10 Thread Devin Jeanpierre
On Sat, Jan 10, 2015 at 6:32 PM, Steven D'Aprano wrote: > At the point you are demonstrating reduce(), if the reader doesn't > understand or can't guess the meaning of "n = 4", "n+1" or range(), they > won't understand anything you say. > > Teachers need to understand that education is a process o

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 7:05 PM, Gregory Ewing wrote: > It's far from clear what *anything* multiplied by > itself zero times should be. > > A better way of thinking about what x**n for integer > n means is this: Start with 1, and multiply it by > x n times. The result of this is clearly 1 when n >

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 2:20 AM, Steven D'Aprano wrote: -snip- > I don't understand what you're trying to say here. You can't just > arbitrarily declare that 0**1 equals something other than 0 (or for that > matter, doesn't equal anything at all). You can, actually. It's just silly. (Similarly, yo

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 12:58 AM, Devin Jeanpierre wrote: >> Arguably, *integer* 0**0 could be zero, on the basis that you can't take >> limits of integer-valued quantities, and zero times itself zero times >> surely has to be zero. I should have responded in more deta

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
On Fri, Jan 9, 2015 at 12:49 AM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel wrote: >>> What you don't say is which behavior you actually expected. Since 0**0 >>> is undefined mathematically, I'd e

Re: Decimals and other numbers

2015-01-09 Thread Devin Jeanpierre
from which we derive its behavior on the reals. -- Devin On Thu, Jan 8, 2015 at 11:28 PM, Marko Rauhamaa wrote: > Devin Jeanpierre : > >> If 0**0 is defined, it must be 1. > > You can "justify" any value a within [0, 1]. For example, choose > >y(a, x) = log(a

Re: Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
Thanks Ben, with your encouragement I have filed http://bugs.python.org/issue23201 -- Devin On Thu, Jan 8, 2015 at 7:03 PM, Ben Finney wrote: > Dave Angel writes: > >> What you don't say is which behavior you actually expected. Since >> 0**0 is undefined mathematically, I'd expect either an ex

Re: Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
On Thu, Jan 8, 2015 at 6:43 PM, Dave Angel wrote: > What you don't say is which behavior you actually expected. Since 0**0 is > undefined mathematically, I'd expect either an exception or a NAN result. It can be undefined, if you choose for it to be. You can also choose to not define 0**1, of co

Decimals and other numbers

2015-01-08 Thread Devin Jeanpierre
I noticed some very PHP-ish behavior today: >>> import decimal >>> x = 0 >>> y = float(x) >>> z = decimal.Decimal(x) >>> x == y == z == x True >>> x ** x 1 >>> y**y 1.0 >>> z**z Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/decimal.py", line 2216, in __pow__

Re: Playing with threads

2015-01-07 Thread Devin Jeanpierre
I can't tell what you mean, but you can start a process via subprocess.Popen, do some work, and wait for it to finish. https://docs.python.org/2/library/subprocess.html Note that you don't need the stdout (or likely the stdin) of the process, you just need the return code -- whether or not grep su

Re: pickle, modules, and ImportErrors

2015-01-07 Thread Devin Jeanpierre
On Wed, Jan 7, 2015 at 2:12 PM, John Ladasky wrote: > If I execute "import my_svr" in an iPython interpreter, everything works as I > think that I should expect: -snip- > However, a nearly-identical program in the parent folder fails (note that all > I change is the relative path to the file): >

Re: Portable code: ‘from __future__ import unicode_literals’ a good idea? (was: Portable code: __import__ demands different string types between 2 and 3)

2014-12-15 Thread Devin Jeanpierre
On Mon, Dec 15, 2014 at 4:42 PM, Ben Finney wrote: > Devin Jeanpierre writes: > >> On Sun, Dec 14, 2014 at 11:29 PM, Ben Finney >> wrote: >> > from __future__ import unicode_literals >> >> Ordinarily, for 2.x/3.3+ code I would suggest not doing

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

2014-12-15 Thread Devin Jeanpierre
On Sun, Dec 14, 2014 at 11:29 PM, Ben Finney wrote: > I'm slowly learning about making Python code that will run under both > Python 2 (version 2.6 or above) and Python 3 (version 3.2 or above). > > This entails, I believe, the admonition to ensure text literals are > Unicode by default:: > >

Re: is_ as method or property?

2014-12-11 Thread Devin Jeanpierre
On Thu, Dec 11, 2014 at 1:33 PM, Ben Finney wrote: > Chris Angelico writes: > >> A property should be used if what you're creating is "virtually an >> attribute". > > Methods are attributes. Are you distinguishing here between “callable > attribute” versus “non-callable attribute”? Obviously, ye

Re: Template language for random string generation

2014-08-11 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 7:22 PM, Steven D'Aprano wrote: > Devin Jeanpierre wrote: > >> On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano >> wrote: > >>> I don't think that using a good, but not cryptographically-strong, random >>> number gene

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 9:31 AM, Steven D'Aprano wrote: >> (I've been working on this kind of thing with regexps, but it's still >> incomplete.) >> >>> * Uses SystemRandom class (if available, or falls back to Random) >> >> This sounds cryptographically weak. Isn't the normal thing to do to >> use

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Sun, Aug 10, 2014 at 9:34 AM, Paul Wolf wrote: > * No one will want to write that expression We've already established that one to be wrong. ;) > * The regex expression doesn't work anyway That's a cheap swipe. The regexp doesn't work because I used a colon instead of a comma, because I acci

Re: Template language for random string generation

2014-08-10 Thread Devin Jeanpierre
On Fri, Aug 8, 2014 at 2:01 AM, Paul Wolf wrote: > This is a proposal with a working implementation for a random string > generation template syntax for Python. `strgen` is a module for generating > random strings in Python using a regex-like template language. Example: > > >>> from strgen i

Re: Correct type for a simple "bag of attributes" namespace object (was: 3 Suggestions to Make Python Easier For Children)

2014-08-02 Thread Devin Jeanpierre
On Sat, Aug 2, 2014 at 2:05 PM, Chris Angelico wrote: > On Sun, Aug 3, 2014 at 6:46 AM, Mark Summerfield wrote: >> Naturally, I understand that adding a new name is a big deal and may be too >> much to ask for beginners. > > This is where you might want to consider putting some imports into > si

Re: Python 3 is killing Python

2014-07-15 Thread Devin Jeanpierre
On Tue, Jul 15, 2014 at 1:24 PM, Mark Lawrence wrote: > On 15/07/2014 18:38, Marko Rauhamaa wrote: >> >> Chris Angelico : >> >>> Fine. Tell me how you would go about adding true Unicode support to >>> Python 2.7, while still having it able to import an unchanged program. >>> Trick question - it's

Re: Proposal: === and !=== operators

2014-07-09 Thread Devin Jeanpierre
On Wed, Jul 9, 2014 at 12:00 AM, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which custo

Re: Question about metacharacter '*'

2014-07-07 Thread Devin Jeanpierre
On Mon, Jul 7, 2014 at 11:51 AM, wrote: > Would you give me an example using your pattern: `.*` -- `.`? > I try it, but it cannot pass. (of course, I use it incorrectly) Those are two patterns. Python 3.4.1 (default, Jul 7 2014, 13:22:02) [GCC 4.6.3] on linux Type "help", "copyright", "credits

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
The reason I did not use \d\d* or \d+ or ^\d+$ or any number of more-correct things was because the OP was new to regexps. -- Devin On Sun, Jul 6, 2014 at 3:49 PM, MRAB wrote: > On 2014-07-06 18:41, Albert-Jan Roskam wrote: >> >> >> >> >>> In article , >>> Rick Johnson wrote: >>> As an asi

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
In related news, the regexp I gave for numbers will match "1a". -- Devin On Sun, Jul 6, 2014 at 8:32 AM, MRAB wrote: > On 2014-07-06 13:09, Devin Jeanpierre wrote: >> >> On Sun, Jul 6, 2014 at 4:51 AM, wrote: >>> >>> Hi, >>> >>>

Re: Question about metacharacter '*'

2014-07-06 Thread Devin Jeanpierre
On Sun, Jul 6, 2014 at 4:51 AM, wrote: > Hi, > > I just begin to learn Python. I do not see the usefulness of '*' in its > description below: > > > > > The first metacharacter for repeating things that we'll look at is *. * > doesn't > match the literal character *; instead, it specifies that th

Re: Get named groups from a regular expression

2014-07-02 Thread Devin Jeanpierre
On Tue, Jul 1, 2014 at 8:58 AM, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__pete...@web.de> wrote: >> Easy, just write a regular expression to parse regular expressions ;) > > Hmm, is that even possible? AIUI you can't make a regex that correctly > parses nested tokens,

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

2014-06-10 Thread Devin Jeanpierre
Please don't be unnecessarily cruel and antagonistic. -- Devin On Tue, Jun 10, 2014 at 4:16 PM, Mark Lawrence wrote: > On 10/06/2014 20:43, alister wrote: >> >> On Tue, 10 Jun 2014 12:27:26 -0700, wxjmfauth wrote: >> > > [snip the garbage] > > >>> >>> jmf >> >> >> Your error reports always seem

Re: daemon thread cleanup approach

2014-05-30 Thread Devin Jeanpierre
On Fri, May 30, 2014 at 1:59 PM, Ethan Furman wrote: > Given the use-case (must shut down, cannot risk a hung process, orphan files > be damned) I don't think having a daemon thread die because it raised an > exception trying to access a missing global is a big deal. It's certainly suboptimal. Su

Re: Multi-line commands with 'python -c'

2014-05-30 Thread Devin Jeanpierre
In unix shells you can literally use a new line. Or is that only bash? -- Devin On Fri, May 30, 2014 at 2:11 PM, Duncan Booth wrote: > Chris Angelico wrote: > >> Problem: Translate this into a shell one-liner: >> >> import os >> for root, dirs, files in os.walk("."): >> if len(dirs + files)

Re: daemon thread cleanup approach

2014-05-30 Thread Devin Jeanpierre
Don't use daemon threads, they are inherently un-thread-safe: any global access you do anywhere inside a daemon thread can fail, because daemon threads are still potentially run during interpreter shutdown, when globals are being deleted from every module. Most functions you might call are not safe

Re: Make Python Compilable, convert to Python source to Go

2014-05-25 Thread Devin Jeanpierre
On Sun, May 25, 2014 at 3:24 AM, Mark Lawrence wrote: > On 25/05/2014 09:17, bookaa bookaa wrote: >> >> Maybe I will work on Python 3 later. >> > > That's good to know, it'll save me wasting my time looking at it now. This seems like an unnecessarily harsh way of putting it, Mark. Could you be le

Re: How keep Python 3 moving forward

2014-05-24 Thread Devin Jeanpierre
On Sat, May 24, 2014 at 2:59 AM, Marko Rauhamaa wrote: > blindanagram : > Instead of focusing on bringing legacy libraries to Python3 (for which > there never seems to be a critical need), Python3 needs a brand new > killer module/application/library that is only available on Python3. > > Asyncio

Re: Values and objects

2014-05-10 Thread Devin Jeanpierre
On Sat, May 10, 2014 at 12:10 PM, Ethan Furman wrote: > On 05/10/2014 02:32 AM, Chris Angelico wrote: >> >> >> Tell me, what may this function do in a compliant Python? >> >> def demo(): >> ret = spam >> spam = 23 >> return ret >> >> In CPython, that'll raise UnboundLocalError, beca

Re: Unicode in Python

2014-04-22 Thread Devin Jeanpierre
On Tue, Apr 22, 2014 at 10:52 PM, Steven D'Aprano wrote: > There's not just the keyboard mapping. There's the mental cost of knowing > which keyboard mapping you need ("is it Greek, Hebrew, or maths > symbols?"), the cost of remembering the mapping from the keys you see on > the keyboard to the ke

Re: Martijn Faassen: The Call of Python 2.8

2014-04-15 Thread Devin Jeanpierre
On Tue, Apr 15, 2014 at 4:11 PM, Joshua Landau wrote: > On 15 April 2014 23:18, Ned Batchelder wrote: >> On 4/15/14 5:34 PM, Joshua Landau wrote: >>> Arch is on 3.4 *default*. >>> >>> $> python >>> Python 3.4.0 (default, Mar 17 2014, 23:20:09) >>> [...] >>> >> Yeah, that's the wron

Re: Mutable objects inside tuples - good or bad?

2014-04-06 Thread Devin Jeanpierre
On Sun, Apr 6, 2014 at 1:25 AM, Chris Angelico wrote: > On Sun, Apr 6, 2014 at 5:55 PM, Devin Jeanpierre > wrote: >> Agreed. Putting mutable objects inside tuples is common and totally OK. > > There are many programming habits that can cause problems, even though > they w

Re: Mutable objects inside tuples - good or bad?

2014-04-06 Thread Devin Jeanpierre
On Sun, Apr 6, 2014 at 12:25 AM, Gary Herron wrote: > On 04/05/2014 11:53 PM, John Ladasky wrote: >> >> I find this programming pattern to be useful... but can it cause problems? > > No. > > What kind of problems are you considering? It won't break Python. It's > perfectly legal code. Agreed. Pu

Re: Yet Another Switch-Case Syntax Proposal

2014-04-04 Thread Devin Jeanpierre
If one were to add switch into Python, wouldn't it be desirable to make a pattern matching switch (think the "match" or "case" construct from Haskell or ML)? Python currently has poor support for union/sum types in general, not just enumerations. It feels weird to add better support for enumeration

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Devin Jeanpierre
On Mon, Mar 17, 2014 at 2:02 AM, Ben Finney wrote: > Mark Summerfield writes: > if getattr(sys, "frozen"):# ‘getattr’ will return None by default No it won't. > Lastly, it's slightly more Pythonic to execute the normal path > unconditionally, and let it raise an exception if there's a p

Re: Can one use Python to learn and even apply Functional Programming?

2014-02-15 Thread Devin Jeanpierre
On Sat, Feb 15, 2014 at 8:45 PM, Sam wrote: > I would like to learn and try out functional programming (FP). I love Python > and would like to use it to try FP. Some have advised me to use Haskell > instead because Python is not a good language for FP. I am sort of confused > at the moment. Is

Re: Working with the set of real numbers

2014-02-14 Thread Devin Jeanpierre
On Fri, Feb 14, 2014 at 3:30 AM, Gregory Ewing wrote: > Devin Jeanpierre wrote: >> There is no way to iterate over all the reals one at a time, no matter >> how fast you execute instructions. If you could, it would be trivial >> to show that the reals have the same cardin

  1   2   3   4   >