Re: Can't match str/unicode

2017-01-07 Thread CM
On Sunday, January 8, 2017 at 1:17:56 AM UTC-5, Steven D'Aprano wrote: > On Sunday 08 January 2017 15:33, CM wrote: > > > On Saturday, January 7, 2017 at 7:59:01 PM UTC-5, Steve D'Aprano wrote: > [...] > >> Start by printing repr(candidate_text) and see what you really have. > > > > Yes, that did

Grumpy: Python to Go compiler

2017-01-07 Thread Steven D'Aprano
Grumpy, an experimental project from Google, transpiles Python code into Go, allowing Python programs to be compiled and run as static binaries using the Go toolchain. http://www.infoworld.com/article/3154624/application-development/google-boosts-python-by-turning-it-into-go.html -- Steven "E

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Jussi Piitulainen
Pablo Lucena writes: > How about using the second usage of builtin iter()? > > In [92]: iter? > Docstring: > iter(iterable) -> iterator > iter(callable, sentinel) -> iterator Nice to learn about that. But it has the same problem as itertools.takewhile: > In [88]: numbers > Out[88]: [1, 9, 8, 11,

Re: Using sudo with pip3?

2017-01-07 Thread Cameron Simpson
On 07Jan2017 22:26, jim wrote: You've convinced me. I will have to buckle down and figure out to use virtualenv/venv. I see Chris recommends venv. I read through PEP405 and this link https://docs.python.org/3.5/library/venv.html. I don't pretend to fully understand it all but it does seem to

Re: Using namedtuples field names for column indices in a list of lists

2017-01-07 Thread Steven D'Aprano
On Sunday 08 January 2017 16:39, Deborah Swanson wrote: > What I've done so far: > > with open('E:\\Coding projects\\Pycharm\\Moving\\Moving 2017 in.csv', > 'r') as infile: > ls = list(csv.reader(infile)) > lst = namedtuple('lst', ls[0]) > > where 'ls[0]' is the header row of the csv, an

Re: Can't match str/unicode

2017-01-07 Thread Steven D'Aprano
On Sunday 08 January 2017 15:33, CM wrote: > On Saturday, January 7, 2017 at 7:59:01 PM UTC-5, Steve D'Aprano wrote: [...] >> Start by printing repr(candidate_text) and see what you really have. > > Yes, that did it. The repr of that one was, in fact: > > u'match /r' Are you sure it is a forwar

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Jussi Piitulainen
Paul Rubin writes: > Jussi Piitulainen writes: >>> Use itertools.takewhile >> How? It consumes the crucial stop element: > > Oh yucch, you're right, it takes it from both sides. How about this: > > from itertools import takewhile, islice > def minabs(xs): > a = iter(xs) > m =

Using namedtuples field names for column indices in a list of lists

2017-01-07 Thread Deborah Swanson
What I've done so far: with open('E:\\Coding projects\\Pycharm\\Moving\\Moving 2017 in.csv', 'r') as infile: ls = list(csv.reader(infile)) lst = namedtuple('lst', ls[0]) where 'ls[0]' is the header row of the csv, and it works perfectly well. 'lst' is a namedtuple instance with each of th

Re: Can't match str/unicode

2017-01-07 Thread Chris Angelico
On Sun, Jan 8, 2017 at 3:31 PM, CM wrote: > On Saturday, January 7, 2017 at 6:42:25 PM UTC-5, Chris Angelico wrote: > >> What happens if you print the repr of each string? Or, if one of them >> truly is a literal, just print the repr of the one you got from >> win32com. >> >> ChrisA > > Yes, that

What is PyOleMissing object? (win32com)

2017-01-07 Thread CM
Trying to manipulate z-order for MSOffice with win32com and wasn't sure what argument was needed. Using help on that ZOrder method gives: >>> Help on method ZOrder in module win32com.client.dynamic: ZOrder(self, ZOrderCmd=) method of win32com.client.CDispatch instance So, what does " mean in

Re: Can't match str/unicode

2017-01-07 Thread CM
On Saturday, January 7, 2017 at 7:59:01 PM UTC-5, Steve D'Aprano wrote: > On Sun, 8 Jan 2017 08:40 am, CM wrote: > > > So what's going on here? Why isn't a string with the content 'match' equal > > to another string with the content 'match'? > > You don't know that the content is 'match'. All you

Re: Can't match str/unicode

2017-01-07 Thread CM
On Saturday, January 7, 2017 at 6:42:25 PM UTC-5, Chris Angelico wrote: > What happens if you print the repr of each string? Or, if one of them > truly is a literal, just print the repr of the one you got from > win32com. > > ChrisA Yes, that did it. The repr of that one was, in fact: u'match /

Re: Using sudo with pip3?

2017-01-07 Thread jim
On 01/07/2017 08:42 PM, Cameron Simpson wrote: On 07Jan2017 19:45, jim wrote: On 01/07/2017 05:58 PM, Clint Moyer wrote: So to minimize your issues with installing Python packages, take the path of least resistance and install through your system repo. And use Python2 or Python3 explicitly to

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Paul Rubin
Jussi Piitulainen writes: >> Use itertools.takewhile > How? It consumes the crucial stop element: Oh yucch, you're right, it takes it from both sides. How about this: from itertools import takewhile, islice def minabs(xs): a = iter(xs) m = min(map(abs,takewhile(lambda x:

Re: Using sudo with pip3?

2017-01-07 Thread Clint Moyer
I would lightly advise against, assuming both Pip and your package manager are trying to accomplish nearly the same thing. Stick with updating through the repo. If you find that the version your OS provides is out-of-date compared to what's on PyPi or Github, then you might want to remove from you

Re: Using sudo with pip3?

2017-01-07 Thread Cameron Simpson
On 07Jan2017 19:45, jim wrote: On 01/07/2017 05:58 PM, Clint Moyer wrote: So to minimize your issues with installing Python packages, take the path of least resistance and install through your system repo. And use Python2 or Python3 explicitly to avoid conflicts. As I mentioned in another pos

Re: Using sudo with pip3?

2017-01-07 Thread Cameron Simpson
On 07Jan2017 19:02, jim wrote: On 01/07/2017 03:17 PM, Dennis Lee Bieber wrote: On Sat, 7 Jan 2017 12:22:45 -0600, jim declaimed the following: What is "system python"? If I do $ which python I get /usr/bin/python which points to python 2.7xx. So if everything I added was for python 3 either

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Pablo Lucena
How about using the second usage of builtin iter()? In [92]: iter? Docstring: iter(iterable) -> iterator iter(callable, sentinel) -> iterator Get an iterator from an object. In the first form, the argument must supply its own iterator, or be a sequence. *In the second form, the callable is calle

Re: Using sudo with pip3?

2017-01-07 Thread jim
On 01/07/2017 05:58 PM, Clint Moyer wrote: Not sure how you guys got this thread so far off topic, but I think it is valuable to present the current situation in the context of Jim's sudo question. Staying on topic, the emphasis should be on taking the path of least resistance with your current O

Re: Can't match str/unicode

2017-01-07 Thread Steve D'Aprano
On Sun, 8 Jan 2017 08:40 am, CM wrote: > So what's going on here? Why isn't a string with the content 'match' equal > to another string with the content 'match'? You don't know that the content is 'match'. All you know is that when printed, it *looks like* 'match'. Hint: s = 'match ' print 'mat

Re: Using sudo with pip3?

2017-01-07 Thread jim
On 01/07/2017 03:17 PM, Dennis Lee Bieber wrote: On Sat, 7 Jan 2017 12:22:45 -0600, jim declaimed the following: What is "system python"? If I do $ which python I get /usr/bin/python which points to python 2.7xx. So if everything I added was for python 3 either using pip3 or apt-get would I b

Re: Using sudo with pip3?

2017-01-07 Thread Clint Moyer
Not sure how you guys got this thread so far off topic, but I think it is valuable to present the current situation in the context of Jim's sudo question. Staying on topic, the emphasis should be on taking the path of least resistance with your current OS. The only thing to be gleaned from PEP394 i

Re: python 3 dict: .keys(), .values(), and .item()

2017-01-07 Thread Steve D'Aprano
On Sun, 8 Jan 2017 08:48 am, Ethan Furman wrote: > In Python 2 we have: > >dict().keys() \ >dict().items() --> separate list() of the results >dict().values() / > > and > >dict().iter_keys() \ >dict().iter_items() --> integrated iter() of the results >dict().it

Re: Using sudo with pip3?

2017-01-07 Thread Cameron Simpson
On 08Jan2017 11:22, Chris Angelico wrote: On Sun, Jan 8, 2017 at 10:51 AM, Cameron Simpson wrote: Here's an example: $ mkdir ~/var ~/var/venv # where I keep my virtualenvs $ virtualenv -p /usr/bin/python3 --system-site-packages ~/var/venv/3 $ ~/var/venv/3/bin/python3# invokes the virt

Re: Error with math.sqrt

2017-01-07 Thread Chris Angelico
On Sun, Jan 8, 2017 at 11:15 AM, Jack Harvey wrote: > I'm starting out with Python 3.5. My current frustration is with: > > math.sqrt(25) > Traceback (most recent call last): > File "", line 1, in > math.sqrt(25) > NameError: name 'math' is not defined > > > Advice? A lot of Pyt

Re: Using sudo with pip3?

2017-01-07 Thread Chris Angelico
On Sun, Jan 8, 2017 at 10:51 AM, Cameron Simpson wrote: > Here's an example: > > $ mkdir ~/var ~/var/venv # where I keep my virtualenvs > $ virtualenv -p /usr/bin/python3 --system-site-packages ~/var/venv/3 > $ ~/var/venv/3/bin/python3# invokes the virtualenv python3 > $ ~/var/venv/3/bin/

Error with math.sqrt

2017-01-07 Thread Jack Harvey
I'm starting out with Python 3.5. My current frustration is with: >>> math.sqrt(25) Traceback (most recent call last): File "", line 1, in math.sqrt(25) NameError: name 'math' is not defined >>> Advice? Jack -- https://mail.python.org/mailman/listinfo/python-list

Re: Using sudo with pip3?

2017-01-07 Thread Cameron Simpson
On 07Jan2017 12:22, jim wrote: On 01/06/2017 08:24 PM, Cameron Simpson wrote: On 06Jan2017 23:03, Clint Moyer wrote: Packages supplied by your distribution can be trusted more than packages from PyPi. Just my two cents. Most distros offer nearly all the useful Python modules directly from the

Re: Can't match str/unicode

2017-01-07 Thread Chris Angelico
On Sun, Jan 8, 2017 at 8:40 AM, CM wrote: > > This is candidate_text: match > > > False > > and, of course, doesn't enter that "do something" loop since apparently > candidate_text != 'match'...even though it seems like it does. > > So what's going on here? Why isn't a string with the content '

Re: Using sudo with pip3?

2017-01-07 Thread Chris Angelico
On Sun, Jan 8, 2017 at 9:34 AM, Michael Torrie wrote: > On 01/07/2017 11:39 AM, Clint Moyer wrote: >> All Linux operating systems come with Python installed, with more >> recent systems such as Arch defaulting /usr/bin/python to Python3, >> since Python2 discontinued some 7-9 years ago. > > Poor c

Re: python 3 dict: .keys(), .values(), and .item()

2017-01-07 Thread Ethan Furman
On 01/07/2017 03:04 PM, Peter Otten wrote: Ethan Furman wrote: In Python 2 we have: dict().keys() \ dict().items() --> separate list() of the results dict().values() / and dict().iter_keys() \ dict().iter_items() --> integrated iter() of the results dict().i

Re: python 3 dict: .keys(), .values(), and .item()

2017-01-07 Thread Peter Otten
Ethan Furman wrote: > In Python 2 we have: > >dict().keys() \ >dict().items() --> separate list() of the results >dict().values() / > > and > >dict().iter_keys() \ >dict().iter_items() --> integrated iter() of the results >dict().iter_values() / I guess you di

Re: Using sudo with pip3?

2017-01-07 Thread Michael Torrie
On 01/07/2017 11:39 AM, Clint Moyer wrote: > All Linux operating systems come with Python installed, with more > recent systems such as Arch defaulting /usr/bin/python to Python3, > since Python2 discontinued some 7-9 years ago. Poor choice of words, in my opinion. Python 2 has not received new

Re: Using sudo with pip3?

2017-01-07 Thread Clint Moyer
All Linux operating systems come with Python installed, with more recent systems such as Arch defaulting /usr/bin/python to Python3, since Python2 discontinued some 7-9 years ago. I believe Ubuntu still defaults that to Python2, however. So when you run pip3 you are attempting to download and inst

python 3 dict: .keys(), .values(), and .item()

2017-01-07 Thread Ethan Furman
In Python 2 we have: dict().keys() \ dict().items() --> separate list() of the results dict().values() / and dict().iter_keys() \ dict().iter_items() --> integrated iter() of the results dict().iter_values() / By "separate list" I mean a snapshot of the dict at the time,

Can't match str/unicode

2017-01-07 Thread CM
This is probably very simple but I get confused when it comes to encoding and am generally rusty. (What follows is in Python 2.7; I know.). I'm scraping a Word docx using win32com and am just trying to do some matching rules to find certain paragraphs that, for testing purposes, equal the word

Re: The hardest problem in computer science...

2017-01-07 Thread Ethan Furman
On 01/06/2017 11:34 PM, Steve D'Aprano wrote: On Sat, 7 Jan 2017 12:03 am, Steve D'Aprano wrote: The second hardest problem in computer science is cache invalidation. The *hardest* problem is naming things. After puzzling over this for three days, it suddenly hit me: Theme = namedtuple("The

Re: Using sudo with pip3?

2017-01-07 Thread jim
On 01/06/2017 08:24 PM, Cameron Simpson wrote: On 06Jan2017 23:03, Clint Moyer wrote: Thanks everyone for the advice. Please note in my following comments I am not arguing with anyone, merely trying to understand. I am not a professional programmer, just someone who enjoys programing for my

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Jussi Piitulainen
Rustom Mody writes: > On a Saturday, Jussi Piitulainen wrote: [snip] >> You switched to a simpler operator. Would Haskell notice that >> >>def minabs(x, y): return min(x, y, key = abs) >> >> has a meaningful zero? Surely it has its limits somewhere and then >> the programmer needs to supply

Re: Pexpect

2017-01-07 Thread alister
On Fri, 06 Jan 2017 12:00:32 +1200, Iranna Mathapati wrote: > Hi Team, > > How to match latter(caps and small) ,numbers and # symbol in python > pexpect. > > > Thanks, > Iranna M Simple just write a small program -- New screensaver released: Curtains for Windows. -- https://mail.python.

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Rustom Mody
On Saturday, January 7, 2017 at 1:42:47 PM UTC+5:30, Jussi Piitulainen wrote: > Rustom Mody writes: > > > On Saturday, Jussi Piitulainen wrote: > >> Paul Rubin writes: > >> > >> > Peter Otten writes: > >> >> How would you implement stopmin()? > >> > > >> > Use itertools.takewhile > >> > >> How?

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Peter Otten
Peter Otten wrote: > Example: you are looking for the minimum absolute value in a series of > integers. As soon as you encounter the first 0 it's unnecessary extra work > to check the remaining values, but the builtin min() will continue. > > The solution is a minimum function that allows the use

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Peter Otten
Steve D'Aprano wrote: > On Sat, 7 Jan 2017 01:04 am, Peter Otten wrote: > >> Example: you are looking for the minimum absolute value in a series of >> integers. As soon as you encounter the first 0 it's unnecessary extra >> work to check the remaining values, but the builtin min() will continue.

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Peter Otten
Paul Rubin wrote: > Peter Otten <__pete...@web.de> writes: >> How would you implement stopmin()? > > Use itertools.takewhile I should have mentioned that I had already run into that -- let's call it -- off-by-one bug. -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Peter Otten
Wolfgang Maier wrote: > On 1/6/2017 15:04, Peter Otten wrote: >> Example: you are looking for the minimum absolute value in a series of >> integers. As soon as you encounter the first 0 it's unnecessary extra >> work to check the remaining values, but the builtin min() will continue. >> >> The sol

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Peter Otten
Jussi Piitulainen wrote: > Peter Otten writes: > >> Example: you are looking for the minimum absolute value in a series of >> integers. As soon as you encounter the first 0 it's unnecessary extra >> work to check the remaining values, but the builtin min() will continue. >> >> The solution is a m

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Steve D'Aprano
On Sat, 7 Jan 2017 07:06 am, Wolfgang Maier wrote: > On 1/6/2017 15:04, Peter Otten wrote: [...] >> How would you implement stopmin()? >> > > How about: > > def stopmin (iterable, key, stop): > def take_until (): > for e in iterable: > yield e > if key(e)

RE: Namedtuples: TypeError: 'str' object is not callable

2017-01-07 Thread Deborah Swanson
Gregory Ewing wrote, on January 07, 2017 1:13 AM > > Deborah Swanson wrote: > > File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py", > > line 139, in moving() > > for lst in map(listings._make, csv.reader(open('E:\\Coding > > projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r")

Re: Using sudo with pip3?

2017-01-07 Thread Michiel Overtoom
> On 2017-01-07, at 03:24, Cameron Simpson wrote: > > Having your on virtualenv is good for: [...] having an isolated environment > for packages (you can make more than one virtual environment). Yes, indeed. For example, if you have to maintain two different codebases, one using Django 1.8 an

Re: Namedtuples: TypeError: 'str' object is not callable

2017-01-07 Thread Gregory Ewing
Deborah Swanson wrote: File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py", line 139, in moving() for lst in map(listings._make, csv.reader(open('E:\\Coding projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))): TypeError: 'str' object is not callable I know you've found the

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Jussi Piitulainen
Chris Angelico writes: > On Sat, Jan 7, 2017 at 7:12 PM, Jussi Piitulainen wrote: >> You switched to a simpler operator. Would Haskell notice that >> >>def minabs(x, y): return min(x, y, key = abs) >> >> has a meaningful zero? Surely it has its limits somewhere and then >> the programmer need

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Chris Angelico
On Sat, Jan 7, 2017 at 7:12 PM, Jussi Piitulainen wrote: > You switched to a simpler operator. Would Haskell notice that > >def minabs(x, y): return min(x, y, key = abs) > > has a meaningful zero? Surely it has its limits somewhere and then the > programmer needs to supply the information. If

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Jussi Piitulainen
Rustom Mody writes: > On Saturday, Jussi Piitulainen wrote: >> Paul Rubin writes: >> >> > Peter Otten writes: >> >> How would you implement stopmin()? >> > >> > Use itertools.takewhile >> >> How? It consumes the crucial stop element: >> >>it = iter('what?') >>list(takewhile(str.isalpha,

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Steve D'Aprano
On Sat, 7 Jan 2017 01:04 am, Peter Otten wrote: > Example: you are looking for the minimum absolute value in a series of > integers. As soon as you encounter the first 0 it's unnecessary extra work > to check the remaining values, but the builtin min() will continue. > > The solution is a minimum