Re: Whittle it on down

2016-05-05 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Fri, 6 May 2016 04:27 am, Jussi Piitulainen wrote: > >> Random832's pattern is fine. You need to use re.fullmatch with it. > > py> re.fullmatch > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute 'fullmatch'

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Chris Angelico
On Fri, May 6, 2016 at 1:07 PM, Dan Sommers wrote: > On Fri, 06 May 2016 02:46:22 +, Dan Sommers wrote: > >> Python 2.7.11+ (default, Apr 17 2016, 14:00:29) >> [GCC 5.3.1 20160409] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> filter

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Dan Sommers
On Fri, 06 May 2016 02:46:22 +, Dan Sommers wrote: > Python 2.7.11+ (default, Apr 17 2016, 14:00:29) > [GCC 5.3.1 20160409] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> filter(lambda x:x+1, [1, 2, 3, 4]) > [1, 2, 3, 4] > > P

Re: How to become more motivated to learn Python

2016-05-05 Thread jladasky
The best way to increase your motivation to learn Python is: 1. Select a non-trivial problem that you need to solve with programming. 2. Try to write the program you need in any other language (that you don't already know well). 3. Write the program you need in Python. 4. Gaze in astonishment at

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 07:46 PM, Dan Sommers wrote: > On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: > > > ''.join(x for x in string if x.isupper()) > > > The difference is, both filter and your list comprehension *build a > > list* which is not needed, and wasteful. The above ski

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Chris Angelico
On Fri, May 6, 2016 at 12:46 PM, Dan Sommers wrote: > filter used to build a list, but now it doesn't (where "used to" means > Python 2.7 and "now" means Python 3.5; I'm too lazy to track down the > exact point(s) at which it changed): > > Python 2.7.11+ (default, Apr 17 2016, 14:00:29) >

Re: After a year using Node.js, the prodigal son returns

2016-05-05 Thread Chris Angelico
On Fri, May 6, 2016 at 12:49 PM, Michael Torrie wrote: > On 05/04/2016 02:59 AM, Steven D'Aprano wrote: >> A year ago, Gavin Vickery decided to move away from Python and give >> Javascript with Node.js a try. Twelve months later, he has written about his >> experiences: >> >> >> http://geekforbrai

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Dan Sommers
On Thu, 05 May 2016 18:37:11 -0700, Stephen Hansen wrote: > ''.join(x for x in string if x.isupper()) > The difference is, both filter and your list comprehension *build a > list* which is not needed, and wasteful. The above skips building a > list, instead returning a generator ... filter u

Re: After a year using Node.js, the prodigal son returns

2016-05-05 Thread Michael Torrie
On 05/04/2016 02:59 AM, Steven D'Aprano wrote: > A year ago, Gavin Vickery decided to move away from Python and give > Javascript with Node.js a try. Twelve months later, he has written about his > experiences: > > > http://geekforbrains.com/post/after-a-year-of-nodejs-in-production Very inter

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 06:26 PM, Christopher Reimer wrote: > Which is one is correct (Pythonic)? Or does it matter? First, pylint is somewhat opinionated, and its default options shouldn't be taken as gospel. There's no correct: filter is fine. That said, the general consensus is, I believe, tha

Re: Pylint prefers list comprehension over filter...

2016-05-05 Thread Chris Angelico
On Fri, May 6, 2016 at 11:26 AM, Christopher Reimer wrote: > Below is the code that I mentioned in an earlier thread. > > string = "Whiskey Tango Foxtrot" > ''.join(list(filter(str.isupper, string))) > > 'WTF' > > That works fine and dandy. Except Pylint doesn't like it. According to t

Pylint prefers list comprehension over filter...

2016-05-05 Thread Christopher Reimer
Greetings, Below is the code that I mentioned in an earlier thread. string = "Whiskey Tango Foxtrot" ''.join(list(filter(str.isupper, string))) 'WTF' That works fine and dandy. Except Pylint doesn't like it. According to this link, list comprehensions have replaced filters and the

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Fri, 6 May 2016 04:27 am, Jussi Piitulainen wrote: > Random832's pattern is fine. You need to use re.fullmatch with it. py> re.fullmatch Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'fullmatch' -- Steven -- https://mail.python

Re: python, ctypes and GetIconInfo issue

2016-05-05 Thread eryk sun
On Thu, May 5, 2016 at 3:47 PM, wrote: > > I try to make the GetIconInfo function work, but I can't figure out > what I'm doing wrong. > > From the MSDN documentation the function is > > https://msdn.microsoft.com/en-us/library/windows/desktop/ms648070%28v=vs.85%29.aspx > > # BOOL WINAPI GetI

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 1:39 AM, Stephen Hansen wrote: Given: input = [u'Espa\xf1ol', 'Health & Fitness Clubs (36)', 'Health Clubs & Gymnasiums (42)', 'Health Fitness Clubs', 'Name', 'Atlanta city guide', 'edit address', 'Tweet', 'PHYSICAL FITNESS CONSULTANTS & TRAINERS', 'HEALTH CLUBS & GYMNASIUMS', 'H

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 2:56 PM, Stephen Hansen wrote: On Thu, May 5, 2016, at 05:31 AM, DFS wrote: You are out of your mind. Whoa, now. I might disagree with Steven D'Aprano about how to approach this problem, but there's no need to be rude. Seriously not trying to be rude - more smart-alecky than anyt

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 1:54 PM, Steven D'Aprano wrote: On Thu, 5 May 2016 10:31 pm, DFS wrote: You are out of your mind. That's twice you've tried to put me down, first by dismissing my comments about text processing with "Linguist much", and now an outright insult. The first time I laughed it off and m

RE: Ctypes c_void_p overflow

2016-05-05 Thread Joseph L. Casale
> I generally avoid c_void_p because its lenient from_param method > (called to convert arguments) doesn't provide much type safety. If a > bug causes an incorrect argument to be passed, I prefer getting an > immediate ctypes.ArgumentError rather than a segfault or data > corruption. For example, w

python, ctypes and GetIconInfo issue

2016-05-05 Thread mymyxin
Hello, I try to make the GetIconInfo function work, but I can't figure out what I'm doing wrong. >From the MSDN documentation the function is https://msdn.microsoft.com/en-us/library/windows/desktop/ms648070%28v=vs.85%29.aspx # BOOL WINAPI GetIconInfo( # _In_ HICON hIcon, # _Ou

Re: Ctypes c_void_p overflow

2016-05-05 Thread eryk sun
On Thu, May 5, 2016 at 10:42 AM, Joseph L. Casale wrote: > I have CDLL function I use to get a pointer, several other functions happily > accept this > pointer which is really a long when passed to ctypes.c_void_p. However, only > one with > same type def in the prototype overflows. Docs suggest

Re: Comparing Python enums to Java, was: How much sanity checking is required for function inputs?

2016-05-05 Thread Ethan Furman
On 04/24/2016 08:20 AM, Ian Kelly wrote: On Sun, Apr 24, 2016 at 1:20 AM, Ethan Furman wrote: What fun things can Java enums do? Everything that Python enums can do, plus: > --> Planet.EARTH.value (5.976e+24, 6378140.0) --> Planet.EARTH.surface_gravity 9.802652743337129 This is incredibly

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 11:03 AM, Steven D'Aprano wrote: > - Nobody could possibly want to support non-ASCII text. (Apart from the > approximately 6.5 billion people in the world that don't speak English of > course, an utterly insignificant majority.) Oh, I'd absolutely want to support non-ASCII

Python is an Equal Opportunity Programming Language

2016-05-05 Thread Terry Reedy
https://motherboard.vice.com/blog/python-is-an-equal-opportunity-programming-language from an 'Intel® Software Evangelist' -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 05:31 AM, DFS wrote: > You are out of your mind. Whoa, now. I might disagree with Steven D'Aprano about how to approach this problem, but there's no need to be rude. Everyone's trying to help you, after all. -- Stephen Hansen m e @ i x o k a i . i o -- https://mail.pyt

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 10:43 AM, Steven D'Aprano wrote: > On Thu, 5 May 2016 11:32 pm, Stephen Hansen wrote: > > > On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: > >> Oh, a further thought... > >> > >> On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > >> > I don't even care about

Re: Whittle it on down

2016-05-05 Thread Random832
On Thu, May 5, 2016, at 14:27, Jussi Piitulainen wrote: > Random832's pattern is fine. You need to use re.fullmatch with it. Heh, in my previous post I said "and one could easily imagine an API that implicitly anchors at the end". So easy to imagine it turns out that someone already did, as it tur

Re: Whittle it on down

2016-05-05 Thread Random832
On Thu, May 5, 2016, at 14:03, Steven D'Aprano wrote: > You failed to anchor the string at the beginning and end of the string, > an easy mistake to make, but that's the point. I don't think anchoring is properly a concern of the regex itself - .match is anchored implicitly at the beginning, and o

PyDev 5.0.0 Released

2016-05-05 Thread Fabio Zadrozny
PyDev 5.0.0 Released Release Highlights: --- * **Important** PyDev now requires Java 8. * PyDev 4.5.5 is the last release supporting Java 7. * See: http://www.pydev.org/update_sites/index.html for the update site of older versions of PyDev. * See: the **PyDev does not

Re: Whittle it on down

2016-05-05 Thread Jussi Piitulainen
Steven D'Aprano writes: > On Fri, 6 May 2016 03:49 am, Jussi Piitulainen wrote: > >> Steven D'Aprano writes: >> >>> I get something like this: >>> >>> r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" >>> >>> >>> but it fails on strings like "AA & A & A". What am I doing wrong? >> >> It cannot spl

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Fri, 6 May 2016 03:49 am, Jussi Piitulainen wrote: > Steven D'Aprano writes: > >> I get something like this: >> >> r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" >> >> >> but it fails on strings like "AA & A & A". What am I doing wrong? > > It cannot split the string as (LETTERS & LETTERS)(L

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:21 pm, Random832 wrote: > On Thu, May 5, 2016, at 03:36, Steven D'Aprano wrote: >> Putting non-ASCII letters aside for the moment, how would you match these >> specs as a regular expression? > > Well, obviously *your* language (not the OP's), given the cases you > reject, is

Re: Whittle it on down

2016-05-05 Thread Jussi Piitulainen
Steven D'Aprano writes: > I get something like this: > > r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" > > > but it fails on strings like "AA & A & A". What am I doing wrong? It cannot split the string as (LETTERS & LETTERS)(LETTERS & LETTERS) when the middle part is just one LETTER. That's som

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 10:31 pm, DFS wrote: > You are out of your mind. That's twice you've tried to put me down, first by dismissing my comments about text processing with "Linguist much", and now an outright insult. The first time I laughed it off and made a joke about it. I won't do that again. Y

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:32 pm, Stephen Hansen wrote: > On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: >> Oh, a further thought... >> >> On Thursday 05 May 2016 16:46, Stephen Hansen wrote: >> > I don't even care about faster: Its overly complicated. Sometimes a >> > regular expression rea

Re: Ctypes c_void_p overflow

2016-05-05 Thread Steven D'Aprano
On Fri, 6 May 2016 01:42 am, Joseph L. Casale wrote: > I have CDLL function I use to get a pointer, several other functions > happily accept this pointer which is really a long when passed to > ctypes.c_void_p. However, only one with same type def in the prototype > overflows. Docs suggest c_void_

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:13 pm, Random832 wrote: > On Thu, May 5, 2016, at 04:41, Steven D'Aprano wrote: >> > There's no situation where "&" and " " will exist in the given >> > dataset, and recognizing that is important. You don't have to account >> > for every bit of nonsense. >> >> Whenev

Ctypes c_void_p overflow

2016-05-05 Thread Joseph L. Casale
I have CDLL function I use to get a pointer, several other functions happily accept this pointer which is really a long when passed to ctypes.c_void_p. However, only one with same type def in the prototype overflows. Docs suggest c_void_p takes an int but that is not what the first call returns,

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 06:17 pm, Peter Otten wrote: >> I get something like this: >> >> r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" >> >> >> but it fails on strings like "AA & A & A". What am I doing wrong? > test("^A+( *& *A+)*$") Thanks Peter, that's nice! -- Steven -- https://mail.pyt

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 9:32 AM, Stephen Hansen wrote: On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: Oh, a further thought... On Thursday 05 May 2016 16:46, Stephen Hansen wrote: I don't even care about faster: Its overly complicated. Sometimes a regular expression really is the clearest way to

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: > Oh, a further thought... > > On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > > I don't even care about faster: Its overly complicated. Sometimes a > > regular expression really is the clearest way to solve a problem. > > Putting no

Re: Whittle it on down

2016-05-05 Thread Random832
On Thu, May 5, 2016, at 03:36, Steven D'Aprano wrote: > Putting non-ASCII letters aside for the moment, how would you match these > specs as a regular expression? Well, obviously *your* language (not the OP's), given the cases you reject, is "one or more sequences of letters separated by space*-a

Re: Whittle it on down

2016-05-05 Thread Random832
On Thu, May 5, 2016, at 04:41, Steven D'Aprano wrote: > > There's no situation where "&" and " " will exist in the given > > dataset, and recognizing that is important. You don't have to account > > for every bit of nonsense. > > Whenever a programmer says "This case will never happen",

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 1:53 AM, Jussi Piitulainen wrote: Either way is easy to approximate with a regex: import re upper = re.compile(r'[A-Z &]+') lower = re.compile(r'[^A-Z &]') print([datum for datum in data if upper.fullmatch(datum)]) print([datum for datum in data if not lower.search(datum)]) This

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 1:39 AM, Stephen Hansen wrote: pattern = re.compile(r"^[A-Z\s&]+$") output = [x for x in list if pattern.match(x)] Holy Shr"^[A-Z\s&]+$" One line of parsing! I was figuring a few list comprehensions would do it - this is better. (note: the reason I specified 'spaces aroun

Re: Whittle it on down

2016-05-05 Thread DFS
On 5/5/2016 2:04 AM, Steven D'Aprano wrote: On Thursday 05 May 2016 14:58, DFS wrote: Want to whittle a list like this: [...] Want to keep all elements containing only upper case letters or upper case letters and ampersand (where ampersand is surrounded by spaces) Start by writing a functi

Re: Interacting with Subprocesses

2016-05-05 Thread eryk sun
On Wed, May 4, 2016 at 4:04 PM, Akira Li <4kir4...@gmail.com> wrote: > > Pass stdin=PIPE, stdout=PIPE and use p.stdin, p.stdout file objects to > write input, read output from the child process. > > Beware, there could be buffering issues or the child process may change > its behavior some other wa

smtplib not working when python run under windows service via Local System account

2016-05-05 Thread loial
I have a python 2.7.10 script which is being run under a windows service on windows 2012 server . The python script uses smtplib to send an email. It works fine when the windows service is run as a local user, but not when the windows service is configured to run as Local System account. I get n

Re: No SQLite newsgroup, so I'll ask here about SQLite, python and MS Access

2016-05-05 Thread cl
There's a gmane 'newsgroup from a mailing list' for sqlite:- gmane.comp.db.sqlite.general It's quite active and helpful too. (Also 'announce' and others) -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thursday 05 May 2016 17:34, Stephen Hansen wrote: > Meh. You have a pedantic definition of wrong. Given the inputs, it > produced right output. Very often that's enough. Perfect is the enemy of > good, it's said. And this is a *perfect* example of why we have things like this: http://www.bbc

Re: Whittle it on down

2016-05-05 Thread Peter Otten
Steven D'Aprano wrote: > Oh, a further thought... > > > On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > >> On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: >>> Start by writing a function or a regex that will distinguish strings >>> that match your conditions from those that don'

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
Oh, a further thought... On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: >> Start by writing a function or a regex that will distinguish strings that >> match your conditions from those that don't. A regex might be faster, but >> he

Re: Whittle it on down

2016-05-05 Thread Stephen Hansen
On Thu, May 5, 2016, at 12:04 AM, Steven D'Aprano wrote: > On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > > > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: > >> Start by writing a function or a regex that will distinguish strings that > >> match your conditions from those that do

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: >> Start by writing a function or a regex that will distinguish strings that >> match your conditions from those that don't. A regex might be faster, but >> here's a function version. >>