Re: Python 3 virtualenvs

2015-11-28 Thread Jon Ribbens
On 2015-11-28, D.M. Procida wrote: > I have a new installation of Debian Jessie, with Python 2.7 and 3.4 > installed. > > I want to use Python 3.4 by default for most things, so I want > virtualenv to create Python 3.4 virtualenvs unless I ask it to > otherwise. > > It turns out that this seems t

Re: Python 3 virtualenvs

2015-11-28 Thread Jon Ribbens
On 2015-11-28, D.M. Procida wrote: > Jon Ribbens wrote: > >> On 2015-11-28, D.M. Procida > wrote: >> > I have a new installation of Debian Jessie, with Python 2.7 and 3.4 >> > installed. >> > >> > I want to use Python 3.4 by default for most

Re: Python 3 virtualenvs

2015-11-29 Thread Jon Ribbens
On 2015-11-29, Laura Creighton wrote: > In a message of Sun, 29 Nov 2015 13:19:46 +0100, Lele Gaifax writes: >>Jon Ribbens writes: > No, Pyvenv is precisely what Daniele can not use. > The problem is that venv does not come with a big sign saying > > ONLY FOR PYTHON 3.x

Re: Python 3 virtualenvs

2015-11-30 Thread Jon Ribbens
On 2015-11-30, Carl Meyer wrote: > (Or maybe virtualenv will make the transition sooner, and you'll start > using venv under the hood for 3.3+ without even realizing it.) It does sound like that would be the ideal solution, and presumably can't be very hard if venv is supposed to do exactly what

Re: return from function

2015-12-21 Thread Jon Ribbens
On 2015-12-20, Emil Natan wrote: > I have the following function to find the parent for domain. It removes the > left most label from the name and then checks if SOA record exists for the > reminder, if not it calls itself recursively removing another label and > checking again for SOA record. It

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Jon Ribbens
On 2015-12-21, Ian Kelly wrote: > On Mon, Dec 21, 2015 at 1:58 PM, Ben Finney > wrote: >> Ian Kelly writes: >>> This isn't just a Usenet group; it's also a mailing list, and many >>> MUAs rely on the Subject header for proper threading. >> >> If such MUAs do that, they're misinterpreting the Su

Re: Meaning and purpose of the Subject field (was: Ignore error with non-zero exit status)

2015-12-21 Thread Jon Ribbens
On 2015-12-21, Steven D'Aprano wrote: > On Tue, 22 Dec 2015 08:44 am, Jon Ribbens wrote about mail clients that use > the Subject line to thread messages: >> Also: Thunderbird, The Bat!, Eudora, Gnus, Outlook, Outlook Express, >> Pegasus Mail, Pine, Apple Mail, Window

Re: [STORY-TIME] THE BDFL AND HIS PYTHON PETTING ZOO

2016-02-19 Thread Jon Ribbens
On 2016-02-19, Ethan Furman wrote: > On 02/02/2016 07:26 PM, Rick Johnson wrote: > > a bunch of garbage. > > *sigh* > > Time to update my procmail filters... > > Anyone know one for deleting all responses to a troll post? Well for this particular imbecile, just blocking posts without any lower-ca

Re: Processing multiple forms in a cgi script

2016-02-19 Thread Jon Ribbens
On 2016-02-19, Jeremy Leonard wrote: > I have a quick question regarding processing multiple forms. Most of > my experience has been where there is just one form so the logic was > pretty straight forward for me. My question revolves around how to > handle multiple forms. I've seen that you can ha

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-22, Ethan Furman wrote: > On 02/14/2016 04:08 PM, Ben Finney wrote: >> I am unconcerned with whether there is a real filesystem entry of that >> name; the goal entails having no filesystem activity for this. I want a >> valid unique filesystem path, without touching the filesystem. > >

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-22, Chris Angelico wrote: > On Tue, Feb 23, 2016 at 5:17 AM, Jon Ribbens > wrote: >> Weell, I have a lot of sympathy for that point, but on the other >> hand the whole concept of UUIDs ("import uuid") is predicated on the >> opposite assumption

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-22, Chris Angelico wrote: > On Tue, Feb 23, 2016 at 5:39 AM, Jon Ribbens > wrote: >> On 2016-02-22, Chris Angelico wrote: >>> On Tue, Feb 23, 2016 at 5:17 AM, Jon Ribbens >>> wrote: >>>> Weell, I have a lot of sympathy for that point, bu

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-23, Steven D'Aprano wrote: > On Tue, 23 Feb 2016 06:22 am, Jon Ribbens wrote: >> Suppose you had code like this: >> >> filename = binascii.hexlify(os.urandom(16)).decode("ascii") >> >> Do we really think that is insecure or that there a

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-22, Steven D'Aprano wrote: > On Tue, 23 Feb 2016 05:48 am, Marko Rauhamaa wrote: >> Jon Ribbens : >>> I was under the impression that the point of UUIDs is that you can be >>> *so* confident that there won't be a collision that for all practical >

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-23, Chris Angelico wrote: > On Tue, Feb 23, 2016 at 11:08 AM, Jon Ribbens > wrote: >>> If you generate 2**128 + 1 such numbers, you are *guaranteed* to >> >> ... have expired due to the heat death of the universe. > > Maybe... but by the time you ge

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-23, Chris Angelico wrote: > On Tue, Feb 23, 2016 at 11:26 AM, Jon Ribbens > wrote: >> On 2016-02-23, Chris Angelico wrote: >>> On Tue, Feb 23, 2016 at 11:08 AM, Jon Ribbens >>> wrote: >>>>> If you generate 2**128 + 1 such numbers, you are *

Re: Make a unique filesystem path, without creating the file

2016-02-22 Thread Jon Ribbens
On 2016-02-23, Ben Finney wrote: > Oscar Benjamin writes: >> What does unpredictable mean in this context? Maybe I'm reading too >> much into that... > > I think you may be, yes. The request in this thread requires making > direct use of the “generate a new valid temporary fielsystem path” > func

Re: Make a unique filesystem path, without creating the file

2016-02-25 Thread Jon Ribbens
On 2016-02-25, Steven D'Aprano wrote: > The links already provided go through the evidence. For example, they > explain that /dev/random and /dev/urandom both use the exact same CSPRNG. If > you don't believe that, you can actually read the source to Linux, FreeBSD, > OpenBSD and NetBSD. (But n

Re: Speaking of Javascript [was Re: Everything good about Python except GUI IDE?]

2016-03-02 Thread Jon Ribbens
On 2016-03-02, Chris Angelico wrote: > To be fair, this isn't a JS exploit; it's a trusting-of-trust issue - > eBay has declared that you can trust them to sanitize their sellers' > listings, and so you trust eBay, but this exploit gets past the > filter. This is true. It sounds like their filter

Re: Speaking of Javascript [was Re: Everything good about Python except GUI IDE?]

2016-03-02 Thread Jon Ribbens
On 2016-03-02, Chris Angelico wrote: > On Thu, Mar 3, 2016 at 5:29 AM, Jon Ribbens > wrote: >> On 2016-03-02, Chris Angelico wrote: >>> You're no more vulnerable looking at one of those listings >>> than you would be going to a web site entirely contro

Re: Question

2016-03-07 Thread Jon Ribbens
On 2016-03-07, Ian Kelly wrote: > On Mon, Mar 7, 2016 at 9:39 AM, Ben Morales wrote: >> I am trying to download Python but I have windows 10 and I do not see a 64 >> bit download for my operating system. Do you have a 64 bit for windows? > > What page are you looking at? > https://www.python.org/

Re: Question

2016-03-07 Thread Jon Ribbens
On 2016-03-07, Ian Kelly wrote: > On Mon, Mar 7, 2016 at 10:25 AM, Mark Lawrence > wrote: >> I've been running 64 bit Python on Windows for years with no problems. Why >> use 32 bit? I certainly don't understand why you'd need to. > > It seems to be easier to find 32-bit binaries for libraries.

Re: Question

2016-03-07 Thread Jon Ribbens
On 2016-03-07, mm0fmf wrote: > On 07/03/2016 18:09, Jon Ribbens wrote: >> It only appears to have downloads for 32-bit, or 64-bit AMD processors, >> not 64-bit Intel processors. > > You didn't read the bit that says > > "The binaries for AMD64 will also

Re: Question

2016-03-07 Thread Jon Ribbens
On 2016-03-07, Chris Angelico wrote: > 3) Use standard Python, and ditch Windows. This is what I do. :) This is also what I do nearly all of the time, but for PyWeek I needed a computer running Python that actually had a monitor attached ;-) Although to be fair, Python under Ubuntu Server has fo

Re: Question

2016-03-07 Thread Jon Ribbens
On 2016-03-07, Ian Kelly wrote: > On Mon, Mar 7, 2016 at 11:51 AM, Jon Ribbens > wrote: >> I must say that Python on Windows was a very poor experience indeed, >> "virtualenv" does not work and "venv" refuses to create the 'activate' >> shel

Re: Question

2016-03-08 Thread Jon Ribbens
On 2016-03-08, justin walters wrote: > Well, from that error message, it seems like you may have a permissions > issue. If that's true then it means the Python 3.5 installer is broken. However, I don't think it is true as actually running Python presents no problems. There's some bug in virtualen

Re: Question

2016-03-08 Thread Jon Ribbens
On 2016-03-08, justin walters wrote: > My apologies, but I really don't want to argue with you. That's nice to know. I didn't ask you to, but it's great to have your input anyway. > You may want to be a bit more humble when asking for help. I wasn't asking for help. HTH. -- https://mail.python

Re: Question

2016-03-08 Thread Jon Ribbens
On 2016-03-08, Ian Kelly wrote: > On Mon, Mar 7, 2016 at 6:41 PM, Jon Ribbens > wrote: >> It's not activate.bat, it's activate (no file extension) the posix >> shell script. I installed Git for Windows which provides bash (or >> something that looks like it).

Re: Question

2016-03-08 Thread Jon Ribbens
On 2016-03-08, Ian Kelly wrote: > On Tue, Mar 8, 2016 at 10:56 AM, Jon Ribbens > wrote: >> The only things I can think of that are at all 'weird' are that there >> are spaces in the filenames, and there's more than one drive. But >> the former of those i

Re: Question

2016-03-09 Thread Jon Ribbens
On 2016-03-09, Ian Kelly wrote: > It looks like the shell environment that comes with Git for Windows is > actually Windows Powershell [1], so presumably the activate.ps1 script > that's already provided by venv is what's needed, not a bash script. This is not true. I installed Git for Windows an

Re: Question

2016-03-09 Thread Jon Ribbens
On 2016-03-08, Steven D'Aprano wrote: > On Wed, 9 Mar 2016 04:19 am, Ian Kelly wrote: >> On Mon, Mar 7, 2016 at 6:41 PM, Jon Ribbens >> wrote: >>> 'virtualenv' works even less well, it just says: >>> >>> $ virtualenv test >>>

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread Jon Ribbens
On 2016-03-09, BartC wrote: > (Isn't it better that it's automatic? Someone sends you a text file that > you want to open within a Python program. Are you supposed to analyze it > first, or expect the sender to tell you what it is (they probably won't > know) then need to hack the program to re

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread Jon Ribbens
On 2016-03-09, Steven D'Aprano wrote: > generate the output. Without seeing the code you used, I have *no idea* how > you could get that result. If you read the file in binary, you should get > this: > > b'\xef\xbb\xbf\xe2\x82\xac\xe2\x82\xac\xe2\x82\xac' > > Or in decimal: > > 239, 187, 191, 226,

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread Jon Ribbens
On 2016-03-09, Chris Angelico wrote: > Then *get interested*. Unicode is the only way that you'll ever not be > parochially bound to a subset of English - or, worse, bound to an > arbitrary eight-bit codepage that you don't even control the choice > of, such that your program behaves differently o

Re: Pyhon 2.x or 3.x, which is faster?

2016-03-09 Thread Jon Ribbens
On 2016-03-10, Chris Angelico wrote: > On Thu, Mar 10, 2016 at 10:48 AM, Jon Ribbens > wrote: >> On 2016-03-09, Chris Angelico wrote: >>> Then *get interested*. Unicode is the only way that you'll ever not be >>> parochially bound to a subset of English - o

Re: Question

2016-03-10 Thread Jon Ribbens
On 2016-03-10, Dennis Lee Bieber wrote: > On Wed, 9 Mar 2016 12:28:30 - (UTC), Jon Ribbens > declaimed the following: >>On 2016-03-09, Ian Kelly wrote: >>> It looks like the shell environment that comes with Git for Windows is >>> actually Windows Pow

Re: How to program round this poplib error?

2016-03-10 Thread Jon Ribbens
On 2016-03-10, c...@isbd.net wrote: > # Read each message into a string and then parse with the email > module, if > # there's an error retrieving the message then just throw it away > # > try: > popmsg = pop3.retr(i+1) > except: >

Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Steven D'Aprano wrote: > Suppose somebody passes me an open file handle. What's the right way to tell > if it is seekable in Python 2? > > I see that stdin has a seek and tell method, but they raise: > > py> sys.stdin.tell() > Traceback (most recent call last): > File "", line 1,

Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Marko Rauhamaa wrote: > Jon Ribbens : >> I'd just do something like: >> >> try: >> fileobj.seek(where-i-want-to-seek-to) >> except (AttributeError, EnvironmentError): >> # file is not seekable > > Unlike Java, Pyth

Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Marko Rauhamaa wrote: > Jon Ribbens : >> On 2016-03-15, Marko Rauhamaa wrote: >>> I think it points to a big practical problem in the whole exception >>> paradigm. >> >> Well, no. That one individual language screwed up its implementation &

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Jon Ribbens
On 2016-03-22, Chris Angelico wrote: > The first step in any program is to write it in the very simplest way > possible. That usually means ignoring all error handling. And yes, > this is true in EVERY language - C, PHP, Pike, DeScribe Macro > Language, you name it. I'm afraid I have to say I thi

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-22 Thread Jon Ribbens
On 2016-03-22, Chris Angelico wrote: > On Wed, Mar 23, 2016 at 12:46 AM, Jon Ribbens > wrote: >> On 2016-03-22, Chris Angelico wrote: >>> The first step in any program is to write it in the very simplest way >>> possible. That usually means ignoring all error handl

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Jon Ribbens
On 2016-03-24, BartC wrote: > On 24/03/2016 13:50, Steven D'Aprano wrote: >> Likewise clearing a list: >> >> for i in range(len(mylist)-1, -1, 0): >> del mylist[i] > > That's wouldn't be I'd call clearing a list, more like destroying it > completely! > > How would you actually clear a list b

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Jon Ribbens
On 2016-03-24, BartC wrote: > On 24/03/2016 15:03, Jon Ribbens wrote: >> On 2016-03-24, BartC wrote: >>> On 24/03/2016 14:08, Jon Ribbens wrote: >>>> if you thought you needed to do that then most likely what you >>>> should actually be doing is re-writi

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Jon Ribbens
On 2016-03-24, BartC wrote: > On 24/03/2016 14:08, Jon Ribbens wrote: >> if you thought you needed to do that then most likely what you >> should actually be doing is re-writing your code so you no longer >> need to. However, you could do: >> >>L[:] = [0]

Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-24 Thread Jon Ribbens
On 2016-03-24, Steven D'Aprano wrote: > On Fri, 25 Mar 2016 02:03 am, Jon Ribbens wrote: >> On 2016-03-24, BartC wrote: >>> On 24/03/2016 14:08, Jon Ribbens wrote: >>>> if you thought you needed to do that then most likely what you >>>> should actu

Lazy-evaluation lists/dictionaries

2014-10-26 Thread Jon Ribbens
I have a need, in a Python C extension I am writing, for lists and dictionaries with "lazy evaluation" - by which I mean that at least some of the values in the lists/dictionaries are "proxy objects" which, rather than returning as themselves, should return the thing they are a proxy for when retri

Re: Lazy-evaluation lists/dictionaries

2014-10-27 Thread Jon Ribbens
On 2014-10-26, Terry Reedy wrote: > On 10/26/2014 10:14 AM, Jon Ribbens wrote: >> Is there any better way to do this other than simply re-implementing >> these types from scratch, emulating all their methods and operations? >> (i.e. using UserList/UserDict). I was under the

Re: Lazy-evaluation lists/dictionaries

2014-10-27 Thread Jon Ribbens
On 2014-10-26, Tim Delaney wrote: > On 27 October 2014 01:14, Jon Ribbens wrote: >> I have a need, in a Python C extension I am writing, for lists and >> dictionaries with "lazy evaluation" - by which I mean that at least >> some of the values in the lists/

Re: Comprehension with two variables - explanation needed

2014-11-23 Thread Jon Ribbens
On 2014-11-23, Roy Smith wrote: > In article , > Skip Montanaro wrote: >> > But it breaks all the picture that I've built in my head about comps till >> > now... >> >> Note that list comprehensions are little more than syntactic sugar for for >> loops. If you're having terrible writing or under

Re: Python is DOOMED! Again!

2015-01-22 Thread Jon Ribbens
On 2015-01-22, Steven D'Aprano wrote: > You can't use "raise" as a parameter name, since that's a keyword. Using > floats for money is Just Wrong and anyone who does so should have their > licence to program taken away. And I really don't understand what this > function is supposed to do, that it

Re: Python Worst Practices

2015-03-02 Thread Jon Ribbens
On 2015-03-02, Dennis Lee Bieber wrote: > A pub's a bar; a bar's a gate; a gate's a street If each of those is supposed to be English first and then the American equivalent second, then I'm afraid the first one is misleading and the other two are just nonsense. -- https://mail.python.org/m

Re: Python Worst Practices

2015-03-02 Thread Jon Ribbens
On 2015-03-02, sohcahto...@gmail.com wrote: > On Monday, March 2, 2015 at 9:13:21 AM UTC-8, Jon Ribbens wrote: >> On 2015-03-02, Dennis Lee Bieber wrote: >> >A pub's a bar; a bar's a gate; a gate's a street >> >> If each of those is suppo

Re: Python Worst Practices

2015-03-03 Thread Jon Ribbens
On 2015-03-03, Dennis Lee Bieber wrote: > On Mon, 2 Mar 2015 17:12:24 + (UTC), Jon Ribbens > declaimed the following: >>On 2015-03-02, Dennis Lee Bieber wrote: >>> A pub's a bar; a bar's a gate; a gate's a street >> >>If each of those is su

Re: Python Worst Practices

2015-03-03 Thread Jon Ribbens
On 2015-03-03, Steven D'Aprano wrote: > Jon Ribbens wrote: >> On 2015-03-02, Dennis Lee Bieber wrote: >>> A pub's a bar; a bar's a gate; a gate's a street >> >> If each of those is supposed to be English first and then the American >

Re: Python 3 lack of support for fcgi/wsgi.

2015-03-29 Thread Jon Ribbens
On 2015-03-29, John Nagle wrote: > The Python 2 module "fcgi" is gone in Python 3. > The Python 3 documentation at > > https://docs.python.org/3/howto/webservers.html > > recommends "flup" and links here: > > https://pypi.python.org/pypi/flup/1.0 > > That hasn't been updated since 2007, and the SV

Re: New to Python - block grouping (spaces)

2015-04-16 Thread Jon Ribbens
On 2015-04-16, Blake McBride wrote: > 2. Having been an employer, it is difficult to force programmers to > use any particular editor or style. Different editors handle tabs > and spaces differently. This is all a bloody nightmare with Python. > > 3. Languages that use braces (or the like) can

Re: Huh? No way to markup announcements here?

2015-04-18 Thread Jon Ribbens
On 2015-04-18, edream...@gmail.com wrote: > Many google groups support markdown or other markup. > > I see no mention of markup here: > https://www.python.org/community/clpya-guidelines.txt/ > > Is there any way to format announcements? If so, how. If not, why not? Because this is not a "google

Re: l = range(int(1E9))

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof wrote: > If I execute: > l = range(int(1E9) > > The python process gobbles up all the memory and is killed. The > problem is that after this my swap is completely used, because other > processes have swapped to it. This make those programs more slowly. Is > there

Re: Is my implementation of happy number OK

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Cecil Westerhof wrote: > Besides it need some documentation: is it a good implementation? Or > are there things I should do differently? Here's an alternative implementation which is a bit neater: def find_happy(maximum): """Return set of happy numbers between 1 and `m

Re: Is my implementation of happy number OK

2015-04-30 Thread Jon Ribbens
On 2015-04-30, Dave Angel wrote: > Finally, I did some testing on Jon Ribben's version. His was > substantially faster for smaller sets, and about the same for 10*7. So > it's likely it'll be slower than yours and mine for 10**8. You know what they say about assumptio

Re: Is my implementation of happy number OK

2015-05-01 Thread Jon Ribbens
On 2015-04-30, Dave Angel wrote: > On 04/30/2015 07:31 PM, Jon Ribbens wrote: >> On 2015-04-30, Dave Angel wrote: >>> But the real reason I didn't like it was it produced a much larger >>> set of happy_numbers, which could clog memory a lot sooner. For >>&

Re: Is my implementation of happy number OK

2015-05-02 Thread Jon Ribbens
On 2015-05-01, Peter Otten <__pete...@web.de> wrote: > A computer that cannot calculate a lookup table with all 3-digit cases > should be almost as hard to find as the one needed by Jon ;) ... or anyone else writing code to return the set of happy numbers. -- https://mail.python

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > So do I, I think, if no-one is willing to admit that the original way of > implementing range() was a glaring mistake. I think the issue is that nobody else here thinks the "original way" of iterating was to use range(), for anything other than extremely small range

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, Terry Reedy wrote: > On 5/2/2015 5:40 PM, Jon Ribbens wrote: >> For information, it looks like xrange() was added on 26 Oct 1993, >> which pre-dates Python 1.0. > > 1.0 was released Feb 1991. 3.2 exactly 20 years later. No, you are thinking of 0.9, which was

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-02, BartC wrote: > On 02/05/2015 22:40, Jon Ribbens wrote: >> I think the issue is that nobody else here thinks the "original way" >> of iterating was to use range(), for anything other than extremely >> small ranges. > > What /is/ the way to ite

Re: l = range(int(1E9))

2015-05-02 Thread Jon Ribbens
On 2015-05-03, Terry Reedy wrote: > On 5/2/2015 8:01 PM, Jon Ribbens wrote: >> On 2015-05-02, Terry Reedy wrote: >>> On 5/2/2015 5:40 PM, Jon Ribbens wrote: >>>> For information, it looks like xrange() was added on 26 Oct 1993, >>>> which pre-dates Pyt

Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
If I have a string containing surrogate pairs like this in Python 3.4: "\udb40\udd9d" How do I convert it into the proper form: "\U000E019D" ? The answer appears not to be "unicodedata.normalize". -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, Chris Angelico wrote: > On Mon, May 4, 2015 at 12:40 AM, Jon Ribbens > wrote: >> If I have a string containing surrogate pairs like this in Python 3.4: >> >> "\udb40\udd9d" >> >> How do I convert it into the proper form: >> &g

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, MRAB wrote: > On 2015-05-03 16:32, Jon Ribbens wrote: >> That would, unfortunately, be "tell the Unicode Consortium to format >> their documents differently", which seems unlikely to happen. I'm >> trying to read in: http://www.unicode.org/Publ

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, Chris Angelico wrote: > On Mon, May 4, 2015 at 1:32 AM, Jon Ribbens > wrote: >> That would, unfortunately, be "tell the Unicode Consortium to format >> their documents differently", which seems unlikely to happen. I'm >> trying to read in: h

Re: Unicode surrogate pairs (Python 3.4)

2015-05-03 Thread Jon Ribbens
On 2015-05-03, MRAB wrote: > There's also a mistake in this bit: > > """ > # Note that according to the \u escaping convention, a supplemental > character (> 0x10) is represented > # by a sequence of two surrogate characters: the first between D800 and > DBFF, and the second between DC00

Re: Stripping unencodable characters from a string

2015-05-05 Thread Jon Ribbens
On 2015-05-05, Paul Moore wrote: > I want to write a string to an already-open file (sys.stdout, > typically). However, I *don't* want encoding errors, and the string > could be arbitrary Unicode (in theory). The best way I've found is > > data = data.encode(file.encoding, errors='replace').de

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Jon Ribbens
On 2015-05-06, Denis McMahon wrote: > You need to format your CSV date into a date format that Excel > understands when it imports it. > > First thing to try would be to export some dates from excel as CSV and > see what format excel puts them in. Beware of assuming that Excel can import its ow

Re: fork/exec & close file descriptors

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Skip Montanaro wrote: > Yeah, I'm still on 2.7, and am aware of PEP 446. Note that many of the file > descriptors will not have been created by my Python code. They will have > been created by underlying C/C++ libraries, so I can't guarantee which > flags were set on file open. The

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > At the moment I am playing with things like: > p = subprocess.Popen('ls -l', shell = True, stdout = subprocess.PIPE) > > I think that most of the times this are the values I want. So it would > be nice to overrule the defaults. What is the best way to do

Re: subprocess.getstatusoutput does not exist in 2.7

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > At the moment I want my code to run with 2.7 and 3.4+. > > But the command: > subprocess.getstatusoutput > does not exist in 2.7. Is this an oversight or is there a reason for > it? > > I can rewrite the code (back) to work with Popen again, but I found

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > Op Tuesday 19 May 2015 19:36 CEST schreef Jon Ribbens: > >> On 2015-05-19, Cecil Westerhof wrote: >>> At the moment I am playing with things like: p = >>> subprocess.Popen('ls -l', shell = True, stdout = subproces

Re: Best way to rewrite Popen

2015-05-19 Thread Jon Ribbens
On 2015-05-19, Cecil Westerhof wrote: > It looks like that this does what I want (the dot is needed so that it > also works with 2.7): > files = sorted(os.listdir('.')) > p = re.compile('actions-2015-05-[0-9][0-9].sql$') > current_month = [ file for file in files if p.match(file) ] Yo

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

2015-05-23 Thread Jon Ribbens
On 2015-05-23, Michael Torrie wrote: > On 05/22/2015 10:10 PM, Ian Kelly wrote: >> There is still some value in TLS with a self-signed certificate in >> that at least the connection is encrypted and can't be eavesdropped >> by an attacker who can only read the channel, but there is no >> assuranc

Re: Decoding JSON file using python

2015-05-27 Thread Jon Ribbens
On 2015-05-27, Karthik Sharma wrote: > I tried modifying the program as follows as per your > suggestion.Doesn't seem to work. That's because you didn't modify the program as per their suggestion, you made completely different changes that bore no relation to what they said. > import cjson What

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)

2015-05-29 Thread Jon Ribbens
On 2015-05-29, Ian Kelly wrote: > On Fri, May 29, 2015 at 2:05 AM, anatoly techtonik > wrote: >> Added Mailman to my suxx tracker: >> https://github.com/techtonik/suxx-tracker#mailman > > What a useless tool. Instead of tiredly complaining that things suck, > why not take some initiative to make

Re: fork/exec & close file descriptors

2015-06-02 Thread Jon Ribbens
On 2015-06-02, Marko Rauhamaa wrote: > Skip Montanaro : > >> On Tue, Jun 2, 2015 at 10:28 AM, Marko Rauhamaa wrote: >>> >>> The only problem is that you don't know how high you need to go in >>> general. >> >> Sure, but I didn't know anyway, so no matter what upper bound I choose >> (or what func

Re: Everything is an object in python - object class and type class

2015-06-02 Thread Jon Ribbens
On 2015-06-02, BartC wrote: > On 02/06/2015 18:00, Steven D'Aprano wrote: >> Again, this is not relevant. Javascript is dynamically typed, but some >> values are machine primitives and other values are objects. The interpreter >> keeps track of this at runtime. > > Javascript primitives include Nu

Re: Everything is an object in python - object class and type class

2015-06-02 Thread Jon Ribbens
On 2015-06-02, Dr. Bigcock wrote: > It doesn't really do anything. No one uses integers as objects. > (Any dissenters?) Yes. *Everyone* uses integers as objects. Containers such as lists and dictionaries and tuples etc contain objects. If integers weren't objects then you wouldn't be able to put

Re: Why does the unit test fail of the pyPDF2 package?

2015-06-24 Thread Jon Ribbens
On 2015-06-24, fl wrote: > You can make a rectangular selection by dragging over the console > window the mouse pointer. > > Excuse me. I don't understand your idea. On the command window, there is > no content copied through a mouse click/drag (even no screen difference). > Do you mean using S

Re: Pure Python Data Mangling or Encrypting

2015-06-25 Thread Jon Ribbens
On 2015-06-25, Steven D'Aprano wrote: > On Thursday 25 June 2015 14:27, Devin Jeanpierre wrote: >> If it's encrypted malware, and you can't decrypt it, there's no threat. > > If the *only* threat is that the sender will send malware, you can mitigate > around that by dropping the file in an unenc

Re: Pure Python Data Mangling or Encrypting

2015-06-25 Thread Jon Ribbens
On 2015-06-25, Steven D'Aprano wrote: > On Thu, 25 Jun 2015 08:03 pm, Jon Ribbens wrote: >> That won't stop virus scanners etc potentially making their own minds >> up about the file. > > *shrug* Sure, but I was specifically referring to the risk of the malw

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Jon Ribbens
On 2015-06-26, Chris Angelico wrote: > On Fri, Jun 26, 2015 at 1:26 AM, Jon Ribbens > wrote: >> Well, it means you need to send 256 times as much data, which is a >> start. If you're instead using a 256-byte translation table then >> an attack becomes utterly impract

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Jon Ribbens
On 2015-06-26, Johannes Bauer wrote: > On 26.06.2015 22:09, Randall Smith wrote: >> You've gone on a rampage about nothing. My original description said >> the client was supposed to encrypt the data, but you want to assume the >> opposite for some unknown reason. > > While you seem to think that

Re: Pure Python Data Mangling or Encrypting

2015-06-26 Thread Jon Ribbens
On 2015-06-26, 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 point: You consistently were vague about wheter you want to >>> have encryption, authenticatio

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Jon Ribbens
On 2015-06-27, Ian Kelly wrote: > On Fri, Jun 26, 2015 at 7:21 PM, Chris Angelico wrote: >> On Sat, Jun 27, 2015 at 6:09 AM, Randall Smith wrote: >>> Give me one plausible scenario where an attacker can cause malware to hit >>> the disk after bytearray.translate with a 256 byte translation table

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Jon Ribbens
On 2015-06-27, Chris Angelico wrote: > On Sat, Jun 27, 2015 at 7:07 PM, Johannes Bauer wrote: >> On 27.06.2015 10:53, Chris Angelico wrote: >>> On Sat, Jun 27, 2015 at 6:38 PM, Steven D'Aprano >>> wrote: I'm not a security expert. I'm not even a talented amateur. *Every time* I sugges

Re: Pure Python Data Mangling or Encrypting

2015-06-27 Thread Jon Ribbens
On 2015-06-27, Johannes Bauer wrote: > On 27.06.2015 11:27, Jon Ribbens wrote: >> Johannes might have all the education in the world, but he's >> demonstrated quite comprehensively in this thread that he doesn't >> have a clue what he's talking about. > >

Re: Pure Python Data Mangling or Encrypting

2015-06-28 Thread Jon Ribbens
On 2015-06-27, Steven D'Aprano wrote: > Despite his initial claim that he doesn't want to use AES because it's too > slow implemented as pure Python, Randall has said that the application will > offer AES encryption as an option. (He says it is enabled by default, > except that the user can turn i

Re: Pure Python Data Mangling or Encrypting

2015-06-28 Thread Jon Ribbens
On 2015-06-27, Randall Smith wrote: > Thankyou. Nice points. I do think given the risks (there are always > risks) discussed, a successful attack of this nature is not very likely. > Worse case, something that looks like this would land on the disk. > > crc32 checksum + translation table + ma

Re: Pure Python Data Mangling or Encrypting

2015-06-29 Thread Jon Ribbens
On 2015-06-29, Randall Smith wrote: > Same reason newer filesystems like BTRFS use checkusms (BTRFS uses > CRC32). The storage machine runs periodic file integrity checks. It > has no control over the underlying filesystem. True, but presumably neither does it have anything it can do to recti

Re: Pure Python Data Mangling or Encrypting

2015-06-30 Thread Jon Ribbens
On 2015-06-30, Steven D'Aprano wrote: > On Tue, 30 Jun 2015 06:52 am, Randall Smith wrote: >> Not sure why you posted the link. The crc32 checksum is just to check >> for possible filesystem corruption. The system does periodic data >> corruption checks. BTRFS uses crc32 checksums also. Please

Re: Pure Python Data Mangling or Encrypting

2015-06-30 Thread Jon Ribbens
On 2015-06-30, Steven D'Aprano wrote: > On Tue, 30 Jun 2015 10:19 pm, Jon Ribbens wrote: >> Eh? The game is over right there. I don't trust you, and yet >> I have just given you my private data, unencrypted. > > Yes. That is exactly the problem. If the application

Re: Pure Python Data Mangling or Encrypting

2015-06-30 Thread Jon Ribbens
On 2015-06-30, Steven D'Aprano wrote: > I don't think there has been much research into keeping at least *some* > security even when keys have been compromised, apart from as it relates to > two-factor authentication. That's because "the key" is all the secret part. If an attacker knows the algor

<    1   2   3   4   5   6   7   8   9   10   >