Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, Pavol Lisy wrote: > But althoug return from execute is undefined ( > https://www.python.org/dev/peps/pep-0249/#id16 ), you could iterate > over cursor ( https://www.python.org/dev/peps/pep-0249/#iter ) ... which is also optional. --

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, Peter Otten <__pete...@web.de> wrote: > Jon Ribbens wrote: >> Indeed. I think this would not work, in general. For example, I think >> with MySQLdb it would work if you use a standard Cursor class, as that >> downloads the entire result set as

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, DFS <nos...@dfs.com> wrote: > On 5/31/2017 6:26 AM, Jon Ribbens wrote: >> Yes, this is indeed a problem with DB-API - you have to keep *two* >> objects around all the time (the connection and the cursor) and pass >> them to functions, etc, when in any sen

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, Peter Otten <__pete...@web.de> wrote: > Jon Ribbens wrote: >> You would do: >> >> cur.execute("SELECT ...") >> for row1 in cur.fetchall(): >> cur.execute("SELECT ...") >> for row2 in cur.

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, Skip Montanaro wrote: > I'm kind of stuck with the database API I have. ("Love the child you > have, not the one you wish you had?") Given that I have the choice to > execute those three statements to bound a transaction, is there any > reason not to use

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Jon Ribbens
On 2017-05-31, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, May 30, 2017 at 4:57 PM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> A DB-API "cursor" is a database connection > > Baloney. Creating a cursor does not spawn a new connection

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Jon Ribbens
On 2017-05-30, Ian Kelly <ian.g.ke...@gmail.com> wrote: > On Tue, May 30, 2017 at 1:27 PM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: > A cursor is just a control structure for traversing over a result set. Exactly - so it makes no sense at all to have one when t

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Jon Ribbens
On 2017-05-30, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > On Tue, 30 May 2017 15:12:55 -0000 (UTC), Jon Ribbens ><jon+use...@unequivocal.eu> declaimed the following: >>I can't make head nor tail of what they are trying to say there. >>Mind you, it doesn'

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Jon Ribbens
On 2017-05-30, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > On Tue, 30 May 2017 13:42:14 -0000 (UTC), Jon Ribbens ><jon+use...@unequivocal.eu> declaimed the following: >>On 2017-05-30, Skip Montanaro <skip.montan...@gmail.com> wrote: >>> Assuming the un

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Jon Ribbens
On 2017-05-30, Joseph L. Casale wrote: >> There's no difference I'm aware of in the implementations I've used, >> but having a consistent API does allow for constructions such as: >> >> try: >> do_stuff(conn) >> except: >> conn.rollback() >> finally: >>

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Jon Ribbens
On 2017-05-30, Skip Montanaro wrote: > Assuming the underlying database supports transactions, is there any > difference between calling the commit() method on the connection and > calling the execute method on the cursor with the "commit transaction" > statement? It

Re: How to `eval` code with `def`?

2017-05-28 Thread Jon Ribbens
On 2017-05-29, Peng Yu wrote: > I got the following error when I try to eval the following code with > def. Does anybody know what is the correct way to evaluation python > code that contains `def`? Thanks. exec -- https://mail.python.org/mailman/listinfo/python-list

Re: Dictionary order (Is it consistent up to py3.3 unless using -R or PYTHONHASHSEED is set)

2017-05-28 Thread Jon Ribbens
On 2017-05-28, Steve D'Aprano wrote: > What exactly did you think I got wrong? 3.6 does preserve the dict order. It isn't a guarantee so may change in future versions, but it is what 3.6 actually does. >> If you're asking "given a fixed Python version, and where

Re: Dictionary order (Is it consistent up to py3.3 unless using -R or PYTHONHASHSEED is set)

2017-05-28 Thread Jon Ribbens
On 2017-05-28, Bill Deegan wrote: > As a follow up to a discussion on IRC #python channel today. > > Assuming the same order of insertions of the same items to a dictionary > would the iteration of a dictionary be the same (not as the order of > insertion, just from run

Re: Battle of the garbage collectors, or ARGGHHHHHH!!!!

2017-04-24 Thread Jon Ribbens
On 2017-04-24, CFK wrote: > Long version: I'm trying to write bindings for python via ctypes to control > a library written in C that uses the bdwgc garbage collector ( > http://www.hboehm.info/gc/). The bindings mostly work, except for when > either bdwgc or python's garbage

Re: Test if Script Already Running

2017-04-20 Thread Jon Ribbens
On 2017-04-20, Cameron Simpson wrote: > Others have pointed the way to an exact implementation. > > For myself, I like mkdir. It is portable. It is atomic. It fails if > the target exists. It works over NFS etc. It is easy. > > os.mkdir('lock') > ... do stuff ... >

Re: Test if Script Already Running

2017-04-18 Thread Jon Ribbens
On 2017-04-19, Matt wrote: > I have a number of simple scripts I run with cron hourly on Centos > linux. I want the script to check first thing if its already running > and if so exit. > > In perl I did it with this at the start of every script: > > use Fcntl

[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens
Jon Ribbens added the comment: So on further investigation, with the new API and policy=SMTP, it does generate correct base64 output. So I guess on the basis that the new version can generate the right output, and it appears to be a deliberate choice that the default policy breaks the RFCs

[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens
Jon Ribbens added the comment: OK cool, but please note that this is a MIME issue not an SMTP issue - if the message has text that is being base64-encoded then it must use CRLF line breaks regardless of whether SMTP is involved

[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread Jon Ribbens
Jon Ribbens added the comment: Just a note for anyone finding this in searching results: it appears that what David means by "python3 API" is actually a new API in Python 3.6 (email.message.EmailMessage). -- ___ Python tr

[issue30033] email module base64-encodes utf-8 text

2017-04-10 Thread Jon Ribbens
New submission from Jon Ribbens: The email module, when creating text parts using character encoding utf-8, base64-encodes the output even though this is often inappropriate (e.g. if it is a Western language it is almost never appropriate). >>> from email.mime.text import MIMET

[issue30032] email module creates base64 output with incorrect line breaks

2017-04-10 Thread Jon Ribbens
New submission from Jon Ribbens: The email module, when creating base64-encoded text parts, does not process line breaks correctly - RFC 2045 s6.8 says that line breaks must be converted to CRLF before base64-encoding, and the email module is not doing this. >>> from email.mime.te

Re: Pillow ImportError: No module named Image

2017-04-10 Thread Jon Ribbens
On 2017-04-10, jorge.conr...@cptec.inpe.br wrote: > I installed the Pillow in my computer. The I did: > > import Image, ImageMath > > ImportError: No module named Image Try: from PIL import Image, ImageMath --

Re: Recompilation of Python3.6.x

2017-03-22 Thread Jon Ribbens
On 2017-03-22, Grant Edwards <grant.b.edwa...@gmail.com> wrote: > On 2017-03-22, Thomas Nyberg <tomuxi...@gmx.com> wrote: >> On 03/22/2017 03:22 PM, Jon Ribbens wrote: >>> A simple table with a list of the library names, the debian package >>> names, and the

Re: Recompilation of Python3.6.x

2017-03-22 Thread Jon Ribbens
On 2017-03-22, Thomas Nyberg wrote: > I can't speak for the maintainers, but I don't think that providing such > a list is super reasonable considering that there are many different OSs > which have sometimes have slightly different library package names > (though of course

Re: Who are the "spacists"?

2017-03-21 Thread Jon Ribbens
On 2017-03-21, Michael Torrie wrote: > On 03/21/2017 08:15 AM, Mikhail V wrote: >> Didn't want to say this, but you know it was quite predictable from >> the beginning that the arguments will end up somewhere in "linux >> console is the center of the universe, e-macs is mother

Re: Who are the "spacists"?

2017-03-19 Thread Jon Ribbens
On 2017-03-19, Erik <pyt...@lucidity.plus.com> wrote: > On 19/03/17 22:29, Jon Ribbens wrote: >> Not to mention plenty of editors (e.g. vim) will unindent when you >> press backspace. > > I don't think that's strictly true. If you have just indented with a tab

Re: Who are the "spacists"?

2017-03-19 Thread Jon Ribbens
On 2017-03-19, breamore...@gmail.com wrote: > On Sunday, March 19, 2017 at 9:54:52 PM UTC, Larry Hudson wrote: >> A trivial point (and irrelevant)... The thing I find annoying >> about an editor set to expand tabs to spaces is that it takes one >> keypress to indent but

Re: Who are the "spacists"?

2017-03-18 Thread Jon Ribbens
On 2017-03-18, Grant Edwards wrote: > On 2017-03-18, Mikhail V wrote: >> How would one come to the idea to use spaces for indentation at all? > > Because tabs are a major security vulnerability and should be outlawed > in all source code. You

Re: Dynamically replacing an objects __class__; is it safe?

2017-03-16 Thread Jon Ribbens
On 2017-03-16, Robin Becker wrote: > On 15/03/2017 13:53, Steve D'Aprano wrote: >> You probably can't make a whale fly just by changing the class to bird. It >> will need wings, and feathers, at the very least. > > the whale in the Hitchhiker's Guide found itself flying

Re: When will os.remove fail?

2017-03-14 Thread Jon Ribbens
On 2017-03-14, Lele Gaifax <l...@metapensiero.it> wrote: > Jon Ribbens <jon+use...@unequivocal.eu> writes: >>>Otherwise, if a file is unwritable, standard input is a terminal, and >>>the -f or --force option is not given, or the -i or --in

Re: When will os.remove fail?

2017-03-14 Thread Jon Ribbens
On 2017-03-14, Frank Millman wrote: > If I type 'alias' at the console, it lists current aliases. 'root' shows > exactly what Jon quoted above. 'frank' shows no alias for 'rm'. > > I had a quick look to see what was setting it, but there is nothing in > /etc/profile or in

Re: When will os.remove fail?

2017-03-14 Thread Jon Ribbens
On 2017-03-14, Chris Angelico <ros...@gmail.com> wrote: > On Wed, Mar 15, 2017 at 12:30 AM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> rm does not ask before deleting. However some Linux distributions >> take it upon themselves to put "alias rm='

Re: When will os.remove fail?

2017-03-14 Thread Jon Ribbens
On 2017-03-14, Chris Angelico wrote: >> (The bash rm command will ask you before deleting, but Python's os.remove >> just removes it.) > > (And the rm command won't ask if you say "-f".) rm does not ask before deleting. However some Linux distributions take it upon themselves

Re: Usage of ast.

2017-02-28 Thread Jon Ribbens
On 2017-02-28, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Feb 28, 2017 at 11:35 AM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> Sorry, I must have missed something here. What are you talking about? >> "lambda: [1,2,3]" is

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Feb 28, 2017 at 3:58 AM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> Seeing as most of it is code along the lines of "is this an integer >> constant? if so the value is tha

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Feb 28, 2017 at 3:17 AM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> On 2017-02-27, Chris Angelico <ros...@gmail.com> wrote: >>> Actually it does execute, as you can see from the s

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Feb 28, 2017 at 1:18 AM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> "execution" isn't really the right way to describe literal_eval(). >> It isn't an code executor or even an expre

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Vincent Vande Vyvre wrote: > Le 27/02/17 à 14:09, Chris Angelico a écrit : >> The message is a little confusing, but the error comes from the fact >> that literal_eval permits a very few legal operations, and calling a >> function isn't one of them.

Re: Rename file without overwriting existing files

2017-01-30 Thread Jon Ribbens
On 2017-01-30, Peter Otten <__pete...@web.de> wrote: > Jon Ribbens wrote: >> On 2017-01-30, Peter Otten <__pete...@web.de> wrote: >>> However, the current Python version of link() is sufficiently different >>> from >>><https://linux.die.net

Re: Rename file without overwriting existing files

2017-01-30 Thread Jon Ribbens
On 2017-01-30, Peter Otten <__pete...@web.de> wrote: > Jon Ribbens wrote: >> A lot of the functions of the 'os' module do nothing but call the >> underlying OS system call with the same name. It would not only be >> redundant to copy the OS documentation into the Python

Re: Rename file without overwriting existing files

2017-01-30 Thread Jon Ribbens
On 2017-01-30, Jussi Piitulainen wrote: > It doesn't seem to be documented. I looked at help(os.link) on Python > 3.4 and the corresponding current library documentation on the web. I > saw no mention of what happens when dst exists already. > > Also, creating a

Re: Need reviews for my book on introductory python

2017-01-27 Thread Jon Ribbens
On 2017-01-27, D'Arcy Cain wrote: > On 2017-01-27 03:17 PM, bob gailer wrote: >> sudo apt-get won't work on Windows. Tell the reader that this is how to >> do it in Unix, and show the Windows equivalent. > > Actually it doesn't work on Unix either. It only works on Linux.

Re: How coding in Python is bad for you

2017-01-24 Thread Jon Ribbens
On 2017-01-24, alister <alister.w...@ntlworld.com> wrote: > On Mon, 23 Jan 2017 20:39:26 +0000, Jon Ribbens wrote: >> That's a meaningless statement. *Everything* is a poison in sufficient >> quantities. > > indees when I here someone saying "I won't have an

Re: How coding in Python is bad for you

2017-01-23 Thread Jon Ribbens
On 2017-01-23, alister wrote: > On Tue, 24 Jan 2017 07:19:42 +1100, Chris Angelico wrote: >> I believe that's "bad for you" in the sense that chocolate is bad for >> you. >> >> It isn't. > > chocolate is a poison (lethal dose for a human approx 22lb) That's a

Re: Is Python SSL API thread-safe?

2017-01-22 Thread Jon Ribbens
On 2017-01-22, Grant Edwards wrote: > Is the Python SSL API thread-safe with respect to recv() and send()? > > IOW, can I have one thread doing blocking recv() calls on an SSL > connection object while "simultaneously" a second thread is calling > send() on that same

Re: Extended ASCII

2017-01-13 Thread Jon Ribbens
On 2017-01-13, D'Arcy Cain wrote: > I thought I was done with this crap once I moved to 3.x but some > Winblows machines are still sending what some circles call "Extended > ASCII". I have a file that I am trying to read and it is barfing on > some characters. For

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-14 Thread Jon Ribbens
On 2016-12-14, mm0fmf wrote: > On 14/12/2016 02:40, Paul Rubin wrote: >> Skip Montanaro writes: >>> Does the lack of a physical ESC key create problems for people, especially >>> Emacs users? >> >> Not a Mac user and I rarely use ESC instead of ALT

Re: CLP stats: last 500 posts

2016-12-11 Thread Jon Ribbens
On 2016-12-11, Wildman wrote: > I don't think it is a problem with the code but any thoughts > why giganews is not playing nice? Most likely because you're calling XHDR on a header which is not in the server's overview file. --

Re: CLP stats: last 500 posts

2016-12-09 Thread Jon Ribbens
On 2016-12-09, DFS wrote: > import sys as y,nntplib as t,datetime as d > s='' > g=y.argv[1] > n=t.NNTP(s,119,'','') > r,a,b,e,gn=n.group(g) > def printStat(st,hd,rg): > r,d=n.xhdr(st,'%s-%s'%rg) > p=[] > for i in range(len(d)): > v=d[i][1] >

Re: python 2.7.12 on Linux behaving differently than on Windows

2016-12-06 Thread Jon Ribbens
On 2016-12-06, Chris Angelico wrote: > On Tue, Dec 6, 2016 at 10:56 PM, BartC wrote: >> In that directory (which was on Windows but accessible via a virtual Linux), >> typing any Linux command followed by * would have required all 3.4 million >> directory

Re: Guido? Where are you?

2016-11-22 Thread Jon Ribbens
On 2016-11-22, Gilmeh Serda wrote: > On Mon, 21 Nov 2016 00:53:33 -0800, Ethan Furman wrote: >> Unfortunately, we do not have any control over the comp.lang.python >> newsgroup > > Gee, "unfortunately"? Really!? Gosh! I'm glad I don't have to live > anywhere

Re: Python String Handling

2016-11-12 Thread Jon Ribbens
On 2016-11-12, subhabangal...@gmail.com wrote: > I am restating the problem. > > "Hello my name is Richard" > > is a string. > > I have tagged the words Hello and Richard > as "Hello/Hi" and "Richard/P". > After this I could get the string as a list of words > as in,

Re: pip3 : command not found

2016-11-06 Thread Jon Ribbens
On 2016-11-06, Michael Torrie wrote: > I'm guessing that it notices by examining the path it was launched from > and looks for virtual environment files relative to that path. Indeed, the mysterious thing is what are "virtual environment files"? The official docs say "A venv

Re: pip3 : command not found

2016-11-06 Thread Jon Ribbens
On 2016-11-06, Chris Angelico <ros...@gmail.com> wrote: > On Sun, Nov 6, 2016 at 4:27 PM, Jon Ribbens <jon+use...@unequivocal.eu> wrote: >>> 2) If Python notices that its executable comes from a venv, it uses it. >> >> Yes. My question is *how does it notic

Re: pip3 : command not found

2016-11-06 Thread Jon Ribbens
On 2016-11-06, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Jon Ribbens <jon+use...@unequivocal.eu> writes: > >> He […] lied about me "not arguing in good faith" > > I find you to be not arguing in good faith; I find that to be particularly po

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-11-06, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Jon Ribbens <jon+use...@unequivocal.eu> writes: >> On 2016-11-06, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: >> > *plonk* >> >> Thank feck for that, I was beginning to th

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-11-06, Chris Angelico <ros...@gmail.com> wrote: > On Sun, Nov 6, 2016 at 3:03 PM, Jon Ribbens <jon+use...@unequivocal.eu> wrote: >> I don't suppose anyone else more constructive and informed actually >> knows the answer to my rather simple question of how Pyt

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-11-06, Steve D'Aprano wrote: > *plonk* Thank feck for that, I was beginning to think he'd never shut up. I don't suppose anyone else more constructive and informed actually knows the answer to my rather simple question of how Python knows it's in a venv? ;-)

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-11-05, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > On Sun, 6 Nov 2016 02:55 am, Jon Ribbens wrote: >> I'm afraid I can only suggest that you try re-reading the subthread >> again until you manage to understand it. It wasn't really that >> complicated bu

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-11-05, Steve D'Aprano wrote: > Your implied question here: > >> Maybe he meant what you are saying, I don't know, but >> it isn't what he wrote. He clearly implied that you can run Python >> in the context of a virtualenv by just invoking that virtualenv's >>

Re: pip3 : command not found

2016-11-05 Thread Jon Ribbens
On 2016-10-31, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > On Mon, 31 Oct 2016 07:21 pm, Jon Ribbens wrote: >> On 2016-10-31, Ben Finney <ben+pyt...@benfinney.id.au> wrote: >>> Instead, you should invoke the exact Python interpreter you want – and, >>&g

Re: pip3 : command not found

2016-10-31 Thread Jon Ribbens
On 2016-10-31, Ben Finney wrote: > Instead, you should invoke the exact Python interpreter you want – and, > by extension, the Python environment into which you want packages > installed. > > $ /foo/bar/virtualenv/bin/python3 -m pip install LoremIpsum I'm slightly

Re: Calling Bash Command From Python

2016-10-31 Thread Jon Ribbens
On 2016-10-31, Wildman wrote: > Here is a bash command that I want to run from a python > program: sudo grep "^user\:" /etc/shadow > > If I enter the command directly into a terminal it works > perfectly. If I run it from a python program it returns an > empty string. Below

Re: Internet Data Handling » mailbox

2016-10-23 Thread Jon Ribbens
On 2016-10-23, Jason Friedman wrote: >> >> for message in mailbox.mbox(sys.argv[1]): >> if message.has_key("From") and message.has_key("To"): >> addrs = message.get_all("From") >> addrs.extend(message.get_all("To")) >>

Re: Internet Data Handling » mailbox

2016-10-23 Thread Jon Ribbens
On 2016-10-23, Jon Ribbens <jon+use...@unequivocal.eu> wrote: > On 2016-10-23, Jason Friedman <jsf80...@gmail.com> wrote: >>> >>> for message in mailbox.mbox(sys.argv[1]): >>> if message.has_key("From") and message.has_key(&quo

Re: Generator comprehension - list None

2016-10-18 Thread Jon Ribbens
On 2016-10-18, Steve D'Aprano wrote: > On Tue, 18 Oct 2016 10:43 pm, Sayth Renshaw wrote: >> I was solving a problem to create a generator comprehension with 'Got ' >> and a number for each in range 10. >> >> This I did however I also get a list of None. I don't

Re: Any ReST aware editors?

2016-09-22 Thread Jon Ribbens
On 2016-09-22, Yann Kaiser <kaiser.y...@gmail.com> wrote: > On Thu, Sep 22, 2016, 12:59 Jon Ribbens <jon+use...@unequivocal.eu> wrote: >> On 2016-09-22, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: >> > I have editors which will use syntax highlightin

Re: Any ReST aware editors?

2016-09-22 Thread Jon Ribbens
On 2016-09-22, Steve D'Aprano wrote: > I have editors which will use syntax highlighting on .rst files, but I'm > hoping for something a bit smarter. > > What I'd like is an editor with a split window, one side showing the rst > that I can edit, the other side showing

Re: Does This Scare You?

2016-08-26 Thread Jon Ribbens
On 2016-08-24, Chris Angelico wrote: > On Thu, Aug 25, 2016 at 7:00 AM, eryk sun wrote: >> I discovered why "Logs/con.txt" isn't working right in Windows 7, >> while "Logs/nul.txt" does get redirected correctly to r"\\.\nul". >> Prior to Windows 8 the console

Re: saving octet-stream png file

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Larry Martell <larry.mart...@gmail.com> wrote: > On Mon, Aug 22, 2016 at 1:25 PM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> On 2016-08-22, Larry Martell <larry.mart...@gmail.com> wrote: >>> (Pdb) type(request.POST[key]) >&

Re: Does This Scare You?

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Steve D'Aprano wrote: > I'm not really sure what the question is -- we've established that there's a > bug in the non-Windows implementation that tries to emulate Window's > behaviour. What else is there to argue about? It doesn't seem to be "the

Re: Does This Scare You?

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: > On Mon, 22 Aug 2016 09:50 pm, Jon Ribbens wrote: >> I don't know what purpose you are envisaging this function being used >> for, but the only one I can think of is input sanitisation. e.g. a web >> fo

Re: saving octet-stream png file

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Larry Martell <larry.mart...@gmail.com> wrote: > On Sun, Aug 21, 2016 at 5:24 PM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> On 2016-08-19, Larry Martell <larry.mart...@gmail.com> wrote: >>> fd.write(request.POST[key]) >> >

Re: Does This Scare You?

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Chris Angelico wrote: > I tried things like "con.txt" and it simply failed (no such file or > directory), without printing anything to the console. I'm not sure how you got that to fail, but writing to "con.txt" certainly does write to the console in Windows 10 -

Re: Does This Scare You?

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Chris Angelico <ros...@gmail.com> wrote: > On Mon, Aug 22, 2016 at 8:33 PM, Jon Ribbens <jon+use...@unequivocal.eu> > wrote: >> On 2016-08-22, Steve D'Aprano <steve+pyt...@pearwood.info> wrote: >>> On Mon, 22 Aug 2016 10:38 am, eryk sun wrote

Re: Does This Scare You?

2016-08-22 Thread Jon Ribbens
On 2016-08-22, Steve D'Aprano wrote: > On Mon, 22 Aug 2016 10:38 am, eryk sun wrote: >> To me it's scary that this check misses cases because it's trying to >> be cross-platform instead of simply relying on GetFullPathName to do >> the work. For example, it misses at

Re: saving octet-stream png file

2016-08-21 Thread Jon Ribbens
On 2016-08-19, Larry Martell wrote: > fd.write(request.POST[key]) You could try: request.encoding = "iso-8859-1" fd.write(request.POST[key].encode("iso-8859-1")) It's hacky and nasty and there might be a better "official" method but I think it should work. --

Re: index for regex.search() beyond which the RE engine will not go.

2016-08-19 Thread Jon Ribbens
On 2016-08-19, iMath wrote: > for > regex.search(string[, pos[, endpos]]) > The optional parameter endpos is the index into the string beyond > which the RE engine will not go, while this lead me to believe the > RE engine will still search on till the endpos position even

Re: JSON confusion

2016-08-17 Thread Jon Ribbens
On 2016-08-17, Steve Simmons wrote: > I'm trying to write a small utility to find the closest railway station > to a given (UK) postcode but the result is in JSON and I'm not familiar > with it. I've got as far as extracting the JSON object and I can print > the first

Re: Use pip to install non-python?

2016-08-04 Thread Jon Ribbens
On 2016-08-04, Tennis Smith wrote: > I have several utility scripts I want to install in /usr/local/bin. > Some are python, some are simple bash scripts. Can I use pip to > install them? If so, can anyone point me to some examples? By the looks of it*, you should be able

Re: Call function via literal name

2016-07-29 Thread Jon Ribbens
On 2016-07-29, TUA wrote: > Rather than do this: > > if test['method'] == 'GET': > res = requests.get(test['endpoint'],auth=test['auth'], > verify=False) > elif test['method'] == 'POST': > res =

Re: Operator Precedence/Boolean Logic

2016-06-29 Thread Jon Ribbens
On 2016-06-29, Grant Edwards wrote: > On 2016-06-29, Steven D'Aprano wrote: >> To Nick, having 1+True return 2 is an accident of implementation, > > My recollection is that it was not an accident of impliementation. It > was an intentional

Re: Break and Continue: While Loops

2016-06-23 Thread Jon Ribbens
On 2016-06-23, Chris Angelico wrote: > On Thu, Jun 23, 2016 at 8:15 PM, BartC wrote: >> Actually pretty much any expression can be used, because Python can >> interpret almost anything as either True or False. Don't ask for the rules >> because they can be

Re: (repost) Advisory: HTTP Header Injection in Python urllib

2016-06-21 Thread Jon Ribbens
On 2016-06-21, Steven D'Aprano wrote: > "In our case, if we could fool an internal Python application into fetching > a URL for us, then we could easily access memcached instances. Consider the > URL: ..." > > and then they demonstrate an attack against memcache. Except, the

Re: Recursive type annotations

2016-06-08 Thread Jon Ribbens
On 2016-06-08, Nagy László Zsolt wrote: > class Test: > def test(self, child : Test): > pass > > NameError: name 'Test' is not defined I think you can fix this by using a string annotation as follows: class Test: def test(self, child: "Test"):

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Jun 7, 2016 at 2:05 AM, Jon Ribbens ><jon+use...@unequivocal.co.uk> wrote: >> On 2016-06-06, Chris Angelico <ros...@gmail.com> wrote: >>> In that case, please never insult the intelligence of y

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Chris Angelico <ros...@gmail.com> wrote: > On Tue, Jun 7, 2016 at 1:27 AM, Jon Ribbens ><jon+use...@unequivocal.co.uk> wrote: >>>> You should put brackets around expressions when it's at all unclear >>>> what the meaning is. You could thin

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Marko Rauhamaa <ma...@pacujo.net> wrote: > Jon Ribbens <jon+use...@unequivocal.co.uk>: >> On 2016-06-06, Marko Rauhamaa <ma...@pacujo.net> wrote: >>> You *can* assume other people have read the spec. Even more >>> importantly, y

Re: Operator precedence problem

2016-06-06 Thread Jon Ribbens
On 2016-06-06, Marko Rauhamaa wrote: > Random832 : >> Sure, it's obvious to _me_ that << and >> have higher precedence than & >> and |, and that "and" has a higher precedence than "or", but can I >> assume the other people know this? > > No need to

Re: Find the max number of elements in lists as value in a dictionary

2016-05-25 Thread Jon Ribbens
On 2016-05-25, Daiyue Weng wrote: > I want to find the maximal number of elements contained in a nested > dictionary, e.g. > > data = { > 'violations': > { > 'col1': {'err': [elem1, elem2, elem3]}, > 'col2': {'err': [elem1, elem2]} >

Re: for / while else doesn't make sense

2016-05-24 Thread Jon Ribbens
On 2016-05-24, Steven D'Aprano <st...@pearwood.info> wrote: > On Tue, 24 May 2016 08:54 pm, Jon Ribbens wrote: >> On 2016-05-24, Steven D'Aprano <st...@pearwood.info> wrote: >>> On Tue, 24 May 2016 03:09 am, Jon Ribbens wrote: >>>> On 2016-05-23, S

Re: for / while else doesn't make sense

2016-05-24 Thread Jon Ribbens
On 2016-05-24, Steven D'Aprano <st...@pearwood.info> wrote: > On Tue, 24 May 2016 03:09 am, Jon Ribbens wrote: >> On 2016-05-23, Steven D'Aprano <st...@pearwood.info> wrote: >>> But one thing is certain: very few people, Jon Ribbens being one of them, >>> e

Re: for / while else doesn't make sense

2016-05-23 Thread Jon Ribbens
On 2016-05-23, Chris Angelico <ros...@gmail.com> wrote: > On Tue, May 24, 2016 at 3:09 AM, Jon Ribbens ><jon+use...@unequivocal.co.uk> wrote: >> On 2016-05-23, Steven D'Aprano <st...@pearwood.info> wrote: >>> But one thing is certain: very few people, Jon Rib

Re: for / while else doesn't make sense

2016-05-23 Thread Jon Ribbens
On 2016-05-23, Steven D'Aprano <st...@pearwood.info> wrote: > But one thing is certain: very few people, Jon Ribbens being one of them, > expects 1/3 to return 0. And that is why Python changed the meaning of > the / operator: because using it for integer division was deeply unpopu

Re: for / while else doesn't make sense

2016-05-23 Thread Jon Ribbens
On 2016-05-23, breamore...@gmail.com <breamore...@gmail.com> wrote: > On Monday, May 23, 2016 at 2:04:01 AM UTC+1, Jon Ribbens wrote: >> On 2016-05-23, Chris Angelico <ros...@gmail.com> wrote: >> > The point of arithmetic in software is to do what mathematics defi

Re: for / while else doesn't make sense

2016-05-22 Thread Jon Ribbens
On 2016-05-23, Chris Angelico <ros...@gmail.com> wrote: > On Mon, May 23, 2016 at 10:36 AM, Jon Ribbens ><jon+use...@unequivocal.co.uk> wrote: >> On 2016-05-22, Steven D'Aprano <st...@pearwood.info> wrote: >>> On Mon, 23 May 2016 01:52 am, Jon Ribbens wrote:

Re: for / while else doesn't make sense

2016-05-22 Thread Jon Ribbens
On 2016-05-22, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: > Jon Ribbens <jon+use...@unequivocal.co.uk> writes: > >> No, in Python integers are closed under the standard arithmetic >> operators (+ - * / % **) - except, since Python 3, for "/", which >

Re: for / while else doesn't make sense

2016-05-22 Thread Jon Ribbens
On 2016-05-22, Steven D'Aprano <st...@pearwood.info> wrote: > On Mon, 23 May 2016 01:52 am, Jon Ribbens wrote: >> On 2016-05-22, Steven D'Aprano <st...@pearwood.info> wrote: >>> How is this any better though? Complicated or not, people want to divide >>> 1 b

Re: for / while else doesn't make sense

2016-05-22 Thread Jon Ribbens
On 2016-05-22, Random832 <random...@fastmail.com> wrote: > On Sun, May 22, 2016, at 11:52, Jon Ribbens wrote: >> No, it *adheres* to the principle of least surprise. Floats appearing >> out of nowhere is surprising. Python 2's behaviour adhered to the >> princ

<    1   2   3   4   5   6   7   >