Re: Idiosyncratic python

2015-09-23 Thread Terry Reedy
On 9/24/2015 2:35 AM, Steven D'Aprano wrote: On Thursday 24 September 2015 16:16, Paul Rubin wrote: Steven D'Aprano writes: for k, v in mydict.items(): del(k) That looks wrong: it's deleting k from what? The local namespace. py> k = 23 py> print k 23 py> del k py> print k Traceback

Re: Idiosyncratic python

2015-09-23 Thread Ben Finney
Steven D'Aprano writes: > On Thursday 24 September 2015 16:16, Paul Rubin wrote: > > > Steven D'Aprano writes: > >> for k, v in mydict.items(): > >> del(k) > > […] The obvious intent is to iterate over the *values* of the > dictionary, but the coder didn't know about values, so he iterated >

Re: Idiosyncratic python

2015-09-23 Thread Steven D'Aprano
On Thursday 24 September 2015 16:16, Paul Rubin wrote: > Steven D'Aprano writes: >> for k, v in mydict.items(): >> del(k) > > That looks wrong: it's deleting k from what? The local namespace. py> k = 23 py> print k 23 py> del k py> print k Traceback (most recent call last): File "", line

Re: Idiosyncratic python

2015-09-23 Thread Paul Rubin
Steven D'Aprano writes: > for k, v in mydict.items(): > del(k) That looks wrong: it's deleting k from what? > instead of the more obvious > for v in mydict.values(): > ... Maybe you mean while mydict: k, v = mydict.popitem() ... -- https://mail.python.org/mailman/list

Idiosyncratic python

2015-09-23 Thread Steven D'Aprano
I was looking at an in-house code base today, and the author seems to have a rather idiosyncratic approach to Python. For example: for k, v in mydict.items(): del(k) ... instead of the more obvious for v in mydict.values(): ... What are your favorite not-wrong-just-weird Pyth

Re: Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)

2015-09-23 Thread Robert Baer
Skybuck Flying wrote: (Click on little icon on website top left for menu): Information about challenge: http://www.cybergrandchallenge.com/site/index.html#about https://cgc.darpa.mil/CGC_Rules_16_May_14_Version_2.pdf Perhaps this will be a yearly contest. There is a catch though, to collect

Re: Readlines returns non ASCII character

2015-09-23 Thread paul . hermeneutic
After looking at this briefly, I am not sure that this is a plain-text file. Interpreting it as UTF-16 LE shows that the characters are as they appear. Immediately after the BOM is: SINGLE LOW-9 QUOTATION MARK' (U+201A) START OF HEADING (U+0001) SPACE (U+0020) SPACE (U+0020) LATIN SMALL LETTER Y

Re: Readlines returns non ASCII character

2015-09-23 Thread paul . hermeneutic
After looking at this briefly, I am not sure that this is a plain-text file. Interpreting it as UTF-16 LE shows that the characters are as they appear. Immediately after the BOM is: SINGLE LOW-9 QUOTATION MARK' (U+201A) START OF HEADING (U+0001) SPACE (U+0020) SPACE (U+0020) LATIN SMALL LETTER Y

Re: ConnectionError handling problem

2015-09-23 Thread shiva upreti
On Sunday, September 20, 2015 at 8:11:18 PM UTC+5:30, Laura Creighton wrote: > The discussion about why or why not to use a bare except has gotten us > away from the problem reported, which is "why is my script hanging?" > > In a message of Sat, 19 Sep 2015 17:18:12 +0100, Mark Lawrence writes: >

Re: Readlines returns non ASCII character

2015-09-23 Thread MRAB
On 2015-09-24 02:37, Ian Kelly wrote: On Wed, Sep 23, 2015 at 6:09 PM, MRAB wrote: On 2015-09-24 00:51, paul.hermeneu...@gmail.com wrote: If this starts at the beginning of the file, then it indicates that the file is UTF-16 (LE). UTF-8[t 1] EF BB BF 239 187 191 UTF-16 (BE)FE

Re: Readlines returns non ASCII character

2015-09-23 Thread Ian Kelly
On Wed, Sep 23, 2015 at 6:09 PM, MRAB wrote: > On 2015-09-24 00:51, paul.hermeneu...@gmail.com wrote: >> >> If this starts at the beginning of the file, then it indicates that >> the file is UTF-16 (LE). >> >> UTF-8[t 1] EF BB BF 239 187 191 >> UTF-16 (BE)FE FF 254 255 >>

Re: Modify environment variable for subprocess

2015-09-23 Thread Akira Li
loial writes: > I need to modify the LIBPATH environment variable when running a > process via subprocess, but otherwise retain the existing environment. > > Whats the best way to do that? Pass env=dict(os.environ, LIBPATH=value) parameter: import os import subprocess subprocess.check

Re: Readlines returns non ASCII character

2015-09-23 Thread MRAB
On 2015-09-24 00:51, paul.hermeneu...@gmail.com wrote: If this starts at the beginning of the file, then it indicates that the file is UTF-16 (LE). UTF-8[t 1] EF BB BF 239 187 191 UTF-16 (BE)FE FF 254 255 UTF-16 (LE)FF FE 255 254 UTF-32 (BE)00 00 FE FF

Re: Postscript to pdf

2015-09-23 Thread mithra
On Tuesday, September 22, 2015 at 2:20:56 AM UTC-5, Bala Ji wrote: > Hello, > This is my programe : on mac i was able to output ps file but i didn't > got the pdf file :/ > > # -*- coding: utf-8 -*- > # script lecture_gif.py > from Tkinter import * > import tkMessageBox > import Tkconstants > impo

Re: Readlines returns non ASCII character

2015-09-23 Thread paul . hermeneutic
If this starts at the beginning of the file, then it indicates that the file is UTF-16 (LE). UTF-8[t 1] EF BB BF 239 187 191 UTF-16 (BE)FE FF 254 255 UTF-16 (LE)FF FE 255 254 UTF-32 (BE)00 00 FE FF0 0 254 255 UTF-32 (LE)FF FE 00 00255 254 0 0 --

Re: Readlines returns non ASCII character

2015-09-23 Thread Ian Kelly
On Wed, Sep 23, 2015 at 3:02 PM, SANKAR . wrote: > Thanks Ian, > this isn't a text file, but when I read with readline I get the data I need > along with mojibake. UTF 32 returns following error: > > Traceback (most recent call last): > File "D:\RV\RV1.py", line 17, in > linenumx1 = file.r

Sending a python argument to a Boost.Python function

2015-09-23 Thread kenseehart
I have a python class that wraps a boost.python object. I am using a boost.python library function that requires the raw boost.python object. I want to be able to pass the python object to the boost api function. Is there a hook available on the python side that instructs boost to perform a co

Re: List comprehensions and evaluation of elements therein

2015-09-23 Thread Ian Kelly
On Wed, Sep 23, 2015 at 12:12 PM, James Harris wrote: > A list comprehension has various components. Anyone know when each of the > elements is evaluated? In the form > > [v0 for v0 in expr0 if expr1] > > If v0 appears in expr0 or expr1 the evaluation order matters. > > I think of the above as be

List comprehensions and evaluation of elements therein

2015-09-23 Thread James Harris
A list comprehension has various components. Anyone know when each of the elements is evaluated? In the form [v0 for v0 in expr0 if expr1] If v0 appears in expr0 or expr1 the evaluation order matters. I think of the above as being a rewrite of results = [] for v0 in expr0: if expr1:

Re: PyInstaller+ Python3.5 (h5py import error)

2015-09-23 Thread Christian Gollwitzer
Am 23.09.15 um 18:20 schrieb Heli Nix: Dear all, Thanks a lot for your replies. Very helpful. I have already done some trials with Virtualenv, but PyInstaller is much closer to the idea of an installer you can pass to someone. I have been using development version of PyInstaller in order to

Re: A little test for you Guys😜

2015-09-23 Thread alister
On Wed, 23 Sep 2015 00:56:19 +0100, MRAB wrote: > On 2015-09-23 00:32, Mark Lawrence wrote: >> On 22/09/2015 19:43, Python_Teacher via Python-list wrote: >>> you have 10 minutes😂 Good luck!! >>> >>> >>> 1. What is PEP8 ? >> >> It's the one between PEP7 and PEP9. >> >> >>> 2. What are the different

Video Tutorial Online On How To Create a Basic Dynamic Website In Python?

2015-09-23 Thread Cai Gengyang
Hello! So I have Python 2.7.10, 3.3.2, 3.3.4 downloaded on my Mac OS X Yosemite 10.10.2 and also downloaded pip and django. Is there an online tutorial on how to create a basic dynamic website in Python where I can put my image/photo/video sharing app ? I find it much easier to learn from somet

PyInstaller+ Python3.5 (h5py import error)

2015-09-23 Thread Heli Nix
Dear all, Thanks a lot for your replies. Very helpful. I have already done some trials with Virtualenv, but PyInstaller is much closer to the idea of an installer you can pass to someone. I have been using development version of PyInstaller in order to be able to use it with my script writt

Re: Python, convert an integer into an index?

2015-09-23 Thread Chris Roberts
Fantastic! I started a course, but I have been having issues with string/index/list/integer conversions and manipulations. This variation wasn't in any of my texts or class exercises either. Your way was both simple enough to understand and very informative! Thanks. On Tue, Sep 22, 2015 at 6:21 P

Re: Readlines returns non ASCII character

2015-09-23 Thread Ian Kelly
On Wed, Sep 23, 2015 at 6:47 AM, SANKAR . wrote: > Hi all, > > I am not a expert programmer but I have to extract information from a large > file. > I used codecs.open(..) with UTF16 encoding to read this file. It could > read all the lines in the file but returns with the non Ascii characters.

Re: Python, convert an integer into an index?

2015-09-23 Thread Tim Daneliuk
On 09/22/2015 04:43 PM, Chris Roberts wrote: > > (How do I make it into an index? ) > Preferably something fairly easy to understand as I am new at this. > > results = 134523 #(Integer) > > Desired: > results = [1, 2, 3, 4, 5, 2, 3] #(INDEX) > > Somehow I see ways to convert index to l

Re: Python, convert an integer into an index?

2015-09-23 Thread Denis McMahon
On Tue, 22 Sep 2015 14:43:55 -0700, Chris Roberts wrote: > results = 134523 #(Integer) This appears to be an integer expressed (presumably) in base 10 with 6 digits > Desired: > results = [1, 2, 3, 4, 5, 2, 3] #(INDEX) This appears to be a python list of 7 elements, with the first and t

Readlines returns non ASCII character

2015-09-23 Thread SANKAR .
Hi all, I am not a expert programmer but I have to extract information from a large file. I used codecs.open(..) with UTF16 encoding to read this file. It could read all the lines in the file but returns with the non Ascii characters. Below are 5 sample lines. How do I avoid having this non Asci

Python 3 windows installer problem [WAS: Re: an installing problem]

2015-09-23 Thread Lorenzo Sutton
Hi, Not too familiar with the 'new' Python 3 installer on windows.. but On 23/09/2015 13:37, Narges Asadi wrote: Hello I’ve encountered a problem when I wanted to install Python 3.5. I sent you the log file. Please help me to fix the problem. From the log: [0F4C:1110][2015-09-23T14:54:17]e0

Re: sort help

2015-09-23 Thread Larry Martell
On Tue, Sep 22, 2015 at 6:55 PM, Chris Angelico wrote: > On Wed, Sep 23, 2015 at 8:42 AM, Larry Martell > wrote: >> I currently have 3 lists of lists and I sort them based on a common >> field into a single list like this: >> >> def GetObjKey(a): >> return a[2] >> >>

Re: Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)

2015-09-23 Thread Skybuck Flying
Also very interesting read: http://blog.trailofbits.com/2015/07/15/how-we-fared-in-the-cyber-grand-challenge/ " How We Fared in the Cyber Grand Challenge July 15, 2015 by Artem Dinaburg 6 Comments The Cyber Grand Challenge qualifying event was held on June 3rd, at exactly noon Eastern time. At

Re: Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)

2015-09-23 Thread Skybuck Flying
Also very interesting read: https://cgc.darpa.mil/CGC_FAQ.pdf Just the list of common programming mistakes is already pretty interesting ! ;) =D Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list

Cyber Grand Challenge, prizes up to 2 million dollars ! (DARPA)

2015-09-23 Thread Skybuck Flying
(Click on little icon on website top left for menu): Information about challenge: http://www.cybergrandchallenge.com/site/index.html#about https://cgc.darpa.mil/CGC_Rules_16_May_14_Version_2.pdf Perhaps this will be a yearly contest. There is a catch though, to collect the prizes: "The prize

Re: True == 1 weirdness

2015-09-23 Thread Michael Schwarz
On 2015-09-19, at 09:19, Gregory Ewing wrote: > Random832 wrote: >> I'm disputing that chained comparisons are used for the particular >> combinations that I am actually arguing should not be used in python. >> Such as a < b > c or a != b != c [whereas a may or may not be equal to >> c] > > I c

Re: Modify environment variable for subprocess

2015-09-23 Thread Laura Creighton
In a message of Wed, 23 Sep 2015 02:51:53 -0700, loial writes: >I need to modify the LIBPATH environment variable when running a process via >subprocess, but otherwise retain the existing environment. > >Whats the best way to do that? import subprocess, os my_env = os.environ # if your program s

Re: Modify environment variable for subprocess

2015-09-23 Thread Cameron Simpson
On 23Sep2015 02:51, loial wrote: I need to modify the LIBPATH environment variable when running a process via subprocess, but otherwise retain the existing environment. Whats the best way to do that? Make a copy of os.environ, modify the copy, pass it via the env=parameter of subprocess.Pop

Re: problem building python 3.5 extensions for windows

2015-09-23 Thread Robin Becker
On 22/09/2015 22:37, cjgoh...@gmail.com wrote: On Tuesday, September 22, 2015 at 1:49:16 PM UTC-7, Terry Reedy wrote: On 9/22/2015 9:35 AM, Robin Becker wrote: On 22/09/2015 11:14, Robin Becker wrote: On 22/09/2015 01:36, CG wrote: .t .

Modify environment variable for subprocess

2015-09-23 Thread loial
I need to modify the LIBPATH environment variable when running a process via subprocess, but otherwise retain the existing environment. Whats the best way to do that? -- https://mail.python.org/mailman/listinfo/python-list

Re: Successfully send sms with python

2015-09-23 Thread Cameron Simpson
On 23Sep2015 01:46, Pavel S wrote: I don't understand why all of you are telling him about '\r\n\, write(),..' instead of recommending to use take library which already has all problems resolved (python-gammu / wammu). Sometimes it is useful to know how things are done instead of which big d

Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)

2015-09-23 Thread Skybuck Flying
Also here is test set 2 to test input values: // input test 2, c version a1 = 1; a2 = 0; a3 = 0; a4 = 1; b1 = 1; b2 = 1; b3 = 0; c1 = 1; d1 = 1; d2 = 1; d3 = 0; d4 = 0; d5 = 1; d6 = 0; Bye, Skybuck. -- https://mail.python.org/mailman/listinfo/python-list

Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)

2015-09-23 Thread Skybuck Flying
Here is the C version of the example in case your Delphi-to-C skills are not so great or you lazy lol =D: // ParallelDecodingCVersion.cpp : Defines the entry point for the console application. // #include "stdafx.h" // Begin of Dummy Decoder Example const int MaxProcessorCount = 4; int _tm

Re: Successfully send sms with python

2015-09-23 Thread Laura Creighton
In a message of Tue, 22 Sep 2015 22:25:31 -0600, Michael Torrie writes: >Consider something like this with no error checking when using the >serial port, no context managers for the serial device: >file sms.py: >-- >import serial >import time > >serial_port = 'COM13' >timeout =

Re: Dummy Decoder Example (was Re: Parallel decoding lesson for you.)

2015-09-23 Thread Skybuck Flying
The example may be modified as much as needed. For now my solution needs a little reading pad to avoid costly mods or branches or whatever. I think this is a nice speedy solution, so code may be modified as follows: const MaxProcessorCount = 4; var // information stream, input Stream : array[

Re: 64bit Python builds on HP-UX ia64 and PA-RISC (Using GCC)

2015-09-23 Thread Laura Creighton
In a message of Wed, 23 Sep 2015 09:03:21 +0100, James Matthews writes: >Hi, > >I'm having some issues getting 64bit Python builds on HP-UX. I'm using the >GCC version available from the HP website. I've also tried using HP's >compiler but don't have much success either, even following the readme.

Re: Successfully send sms with python

2015-09-23 Thread Pavel S
I don't understand why all of you are telling him about '\r\n\, write(),..' instead of recommending to use take library which already has all problems resolved (python-gammu / wammu). When one will write custom templating stuff, you would also recommend him to take jinja. -- https://mail.pytho

64bit Python builds on HP-UX ia64 and PA-RISC (Using GCC)

2015-09-23 Thread James Matthews
Hi, I'm having some issues getting 64bit Python builds on HP-UX. I'm using the GCC version available from the HP website. I've also tried using HP's compiler but don't have much success either, even following the readme. These are the results I get: PA-RISC: ./configure CC=/opt/hp-gcc64-4.7.1/bi

ANN: eGenix mxODBC Connect 2.1.4 - Remote Python Database Interface

2015-09-23 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix.com mxODBC Connect Remote Python Database Interface Version 2.1.4 mxODBC Connect is our commercially supported client-server product

Re: sort help

2015-09-23 Thread Peter Otten
Larry Martell wrote: > I currently have 3 lists of lists and I sort them based on a common > field into a single list like this: > > def GetObjKey(a): > return a[2] > > sorted(a + b + c, key=GetObjKey) > > Which works just fine. > > But now, I need to have just the

Re: Python, convert an integer into an index?

2015-09-23 Thread marco . nawijn
On Wednesday, September 23, 2015 at 1:27:51 AM UTC+2, MRAB wrote: > On 2015-09-22 23:21, Laura Creighton wrote: > > In a message of Tue, 22 Sep 2015 14:43:55 -0700, Chris Roberts writes: > >> > >> > >>(How do I make it into an index? ) > >>Preferably something fairly easy to understand as I am new