Re: argparse — adding a --version flag in the face of positional args

2022-11-27 Thread Matt Wheeler
able to tell argparse I'm going to process --verbose, then > exit? > > Thx, > > Skip > -- > https://mail.python.org/mailman/listinfo/python-list -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Not found in the documentation

2021-04-29 Thread Matt Wheeler
4, 5, 6, 7, 8, 9] ``` range objects are iterables, not iterators. We can see the consuming behaviour I think you are referring to by calling iter(): ``` >>> i = iter(r) >>> next(i) 0 >>> list(i) [1, 2, 3, 4, 5, 6, 7, 8, 9] ``` -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Code Formatter Questions

2021-03-29 Thread Matt Wheeler
> On 29 Mar 2021, at 04:45, Cameron Simpson wrote: > > yapf has many tunings. Worth a look. It is my preferred formatter. By > comparison, black is both opinionated and has basicly no tuning, > something I greatly dislike. This is not a mark or a vote against yapf (I’ve never used it), but I

[ANN] PyYAML-5.4.1 Released

2021-01-20 Thread Matt Davis
emitter for Python', 'name': 'PyYAML'} >>> print(yaml.dump(_)) name: PyYAML homepage: https://github.com/yaml/pyyaml description: YAML parser and emitter for Python keywords: [YAML, serialization, configuration, persistence, pickle] ``` Maintainers ==

[ANN] PyYAML-5.4 Released

2021-01-19 Thread Matt Davis
aml', 'description': 'YAML parser and emitter for Python', 'name': 'PyYAML'} >>> print(yaml.dump(_)) name: PyYAML homepage: https://github.com/yaml/pyyaml description: YAML parser and emitter for Python keywords: [YAML, serialization, configur

[ANN] PyYAML-5.4b1: Linux and Mac users, please test wheels!

2021-01-14 Thread Matt Davis
dump(_)) name: PyYAML homepage: https://github.com/yaml/pyyaml description: YAML parser and emitter for Python keywords: [YAML, serialization, configuration, persistence, pickle] Maintainers === The following people are currently responsible for maintaining PyYAML: * Ingy döt Net * Matt

Re: Is there any way to check/de-cruft/update Python packages installed using pip?

2020-12-29 Thread Matt Wheeler
On 29 Dec 2020, 14:48 +, Chris Green , wrote: > I seem to have quite a lot of old python packages installed over the > years using pip and would like, if I can. to clear some of them out. > > > Is there any way to tell if a python package was installed by me > directly using pip or was installe

Re: dict.get(key, default) evaluates default even if key exists

2020-12-15 Thread Matt Ruffalo
On 15/12/20 15:26, Grant Edwards wrote: > On 2020-12-15, Mark Polesky via Python-list wrote: > >> I see. Perhaps counterintuitive, > I guess that depends on what programming language you normally think > in. Python's handling of function parameters is exactly what I > expected, because all of the

Re: list of dictionaries search using kwargs

2020-12-07 Thread Matt Wheeler
for item in self.data:     if all(item[k] == v for k,v in kwargs.items()):         return item Or return [item for item in self.data if all(item[k] == v for k,v in kwargs.items())] to return all matches Beware though that either of these will be slow if your list of dicts is large. If the list

Re: How to remove "" from starting of a string if provided by the user

2020-08-12 Thread Matt Wheeler
On Tue, 11 Aug 2020, 02:20 Ganesh Pal, wrote: > The possible value of stat['server2'] can be either (a) > "'/fileno_100.txt'" or (b) '/fileno_100.txt' . > > How do I check if it the value was (a) i.e string started and ended > with a quote , so that I can use ast.literal_eval() > BAFP > def ma

Re: How to turn a defaultdict into a normal dict.

2020-06-16 Thread Matt Wheeler
t; >>> from collections import defaultdict > >>> d = defaultdict(list) > >>> d["x"] > [] > >>> d.default_factory = None > >>> d["y"] > Traceback (most recent call last): > File "", line 1, in > KeyE

Re: Threading

2020-01-24 Thread Matt
> Not quite. > > 1. Create a list of threads. > > 2. Put the items into a _queue_, not a list. > > 3. Start the threads. > > 4. Iterate over the list of threads, using .join() on each. > > If you're going to start the threads before you've put all of the items > into the queue, you can also put a

Re: Threading

2020-01-24 Thread Matt
"Creating Threads..." port = 80 for i in range(1, 10): t = threading.Thread(target=start_test) t.start() print "Waiting on Threads..." t.join() print "Finished..." On Fri, Jan 24, 2020 at 2:44 PM Chris Angelico wrote: > > On Sat, Jan 25, 2020 at 7:3

Re: Threading

2020-01-24 Thread Matt
thread safe? On Fri, Jan 24, 2020 at 2:44 PM Chris Angelico wrote: > > On Sat, Jan 25, 2020 at 7:35 AM Matt wrote: > > > > I am using this example for threading in Python: > > > > from threading import Thread > > > > def start_test( address, port ): &

Threading

2020-01-24 Thread Matt
I am using this example for threading in Python: from threading import Thread def start_test( address, port ): print address, port sleep(1) for line in big_list: t = Thread(target=start_test, args=(line, 80)) t.start() But say big_list has thousands of items and I only want to h

Re: issue with regular expressions

2019-10-22 Thread Matt Wheeler
On Tue, 22 Oct 2019, 09:44 joseph pareti, wrote: > the following code ends in an exception: > > import re > pattern = 'Sottoscrizione unica soluzione' > mylines = []# Declare an empty list. with open ('tmp.txt', 'rt') as myfile: # Open tmp.txt for reading tex

Re: Python string with character exchange

2019-07-15 Thread Matt Zand
Thanks Reto. I got it now. Matt On Sun, Jul 14, 2019 at 2:26 PM Reto wrote: > On Sun, Jul 14, 2019 at 12:20:56PM -0400, Matt Zand wrote: > > Given a string, return a new string where the first and last chars have > > been exchanged. > > This sounds awfully like a homework

Python string with character exchange

2019-07-14 Thread Matt Zand
I am new to Python. I am trying to solve below Python question: Given a string, return a new string where the first and last chars have been exchanged. -- Cheers, Matt Zand Cell: 202-420-9192 Work: 240-200-6131 High School Technology Services <https://myhsts.org/> DC Web Makers

Version numbers in Standard Library

2019-03-01 Thread Thompson, Matt (GSFC-610.1)[SCIENCE SYSTEMS AND APPLICATIONS INC] via Python-list
o according to git blame. In tarfile.py, the version string was last changed 12 years ago. But in both, the modules were edited in 2018 so they haven't been static for a decade. Are those strings there just for historic purposes? Not a big deal, I was just wondering. Thanks, Matt -- Matt Tho

Re: Generators, generator expressions, and loops

2018-11-16 Thread Matt Wheeler
> On 16 Nov 2018, at 14:54, Steve Keller wrote: > More elegant are generator expressions but I cannot think of a way > without giving an upper limit: > >for i in (2 ** i for i in range(100)): >... > > which looks ugly. Also, the double for-loop (and also the two loops > in the

Re: All of a sudden code started throwing errors

2018-11-14 Thread Matt Wheeler
ntextmanager def pushd(path): old_dir = os.getcwd() os.chdir(path) try: yield finally: os.chdir(old_dir) ``` (I tend to just copy this into projects where I need it (or write it again), as a whole dependency for something so tiny seems like it would be overk

Re: virtualenv and ubuntu

2018-08-28 Thread Matt Ruffalo
On 2018-08-28 07:26, stone.zh...@gmail.com wrote: > Hi there, > > Sorry if the question is naive, I am on Ubuntu 16.04 with Python 3.5.2, now I > want to use virtualenv, I noticed there are two ways to get virtualenv > installed: > > 1) do "sudo apt-get install virtualenv" > 2) do "pip3 install v

Re: Pandas cat.categories.isin list, is this a bug?

2018-05-15 Thread Matt Ruffalo
On 2018-05-15 06:23, Zoran Ljubišić wrote: > Matt, > > thanks for the info about pydata mailing group. I didn't know it exists. > Because comp.lang.python is not appropriate group for this question, I > will continue our conversation on gmail. > > I have put len(

Re: Pandas cat.categories.isin list, is this a bug?

2018-05-14 Thread Matt Ruffalo
On 2018-05-14 07:05, zljubi...@gmail.com wrote: > Hi, > > I have dataframe with CRM_assetID column as category dtype: > > df.info() > > > RangeIndex: 1435952 entries, 0 to 1435951 > Data columns (total 75 columns): > startTime1435952 non-null object > CRM_assetID

Re: psutil

2018-02-27 Thread Matt Wheeler
path you have here this looks like you have a non standard python package for EL7 (in addition to the system one, or you'd be having a worse day), which is probably the root of your problem. Are you using python packages from scl perhaps? If so you probably need to install python27-pytho

RE: libxml2 installation/binding issue with Python 3.6.4

2018-02-06 Thread Priest, Matt
Dieter, I'm sure it's the Python version, I was hoping the "latest" set of the dependencies would get me there. I'll explore stepping that version back and let you know... Thank you, Matt -Original Message- From: Python-list [mailto:python-list-

libxml2 installation/binding issue with Python 3.6.4

2018-02-05 Thread Priest, Matt
DEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes python3-config -ldflags; -L/nfs/sc/disks/slx_1353/mlpriest/sl1/work_root/a0/development/sfwr/lib/python3.6/config-3.6m-x86_64-linux-gnu -L/nfs/sc/disks/slx_1353/mlpriest/sl1/work_root/a0/development/sfwr/lib -lpython3.6m -lpthread -ldl -lutil -lr

Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Matt Wheeler
27;t particularly helpful advice if you're sitting in any seat other than the driver's seat, however. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: unabe to import /pyd file.

2017-12-25 Thread Matt Wheeler
botframework remote library [ https://github.com/robotframework/RemoteInterface] to run the Java-dependent parts in Jython & the CPython-dependent parts in CPython (I've not used the remote library myself so don't know how easy it is to work with, but it should work either way around)) * pip install robotframework > -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Recommended pypi caching proxy?

2017-12-18 Thread Matt Wheeler
same functionality and all of which > are a few years old. > Recommendations from the crowd? > In the past I've used https://github.com/devpi/devpi It may have many features you don't need if all you're after is a caching proxy, but I found it does that well and it appear

Re: Compile Python 3 interpreter to force 2-byte unicode

2017-11-29 Thread Matt Wheeler
ty of any other cross-platform incompatibilities playing a part? > -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: import issues python3.4

2017-11-10 Thread Matt Wheeler
vailable in the local $PATH [0] https://tox.readthedocs.io/en/latest/ [1] http://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Vim, ctags jump to python standard library source

2017-10-19 Thread Matt Schepers
I prefer to use vim and ctags when developing python, but I'm having trouble getting ctags to index the standard library. Sometimes I would like to see an object's constructor etc... Does anyone know how to do this? Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Printing a Chunk Of Words

2017-09-27 Thread Matt Wheeler
n) > I guess you still didn't run it ;D (see the 2nd `for` statement). I diffed my output against the original, which is why I'm confident in the correctness of my solution ;) Actually I managed to shave off another byte by changing `l.insert(i,'')` to `l[i:i]=['']`, so now I'm on 259. I should probably stop now... -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Printing a Chunk Of Words

2017-09-27 Thread Matt Wheeler
inal string. > I guess you didn't try it? (or see `upper()` in the body of the `for` below) > l=[" Boolean Operators\n"+"-"*24] > > for x in [(l,p,r)for p in(a,o)for l in(t,f)for r > in(t,f)]+[(n,t),(n,f)]:x=' > > '.join(x);l+=[x[0].upper()+x

Re: Printing a Chunk Of Words

2017-09-27 Thread Matt Wheeler
,f)for r in(t,f)]+[(n,t),(n,f)]:x=' '.join(x);l+=[x[0].upper()+x[1:]+" is "+str(eval(x))] for i in 12,9,5,0:l.insert(i,'') print('\n'.join(l)) Reproducing the original string exactly the best I've managed is 260: t,f,a,o,n='True','False

Re: Unicode

2017-09-17 Thread Matt Ruffalo
On 2017-09-17 17:27, leam hall wrote: > > Ah! So this works in Py2: >def __str__(self): > name= self.name.encode("utf-8") > > > It completely fails in Py3: > PVT b'Lakeisha F\xc3\xa1bi\xc3\xa1n' 7966A4 [F] Age: 22 > > > Note that moving __str__() to display() gets the same result

Re: People choosing Python 3

2017-09-11 Thread Matt Ruffalo
On 2017-09-10 05:42, Chris Warrick wrote: > > RHEL’s release process starts at forking a recent Fedora release. It > wouldn’t make much sense for them to undo the Python 3 progress that > happened over the past few years in Fedora — including dnf, an > improved package manager written in Python 3.

Re: Send mouse clicks to minimized window

2017-08-28 Thread Matt Wheeler
window-manager level automation tool (and will also solve the focus problem for you). [0] https://github.com/pywinauto/pywinauto -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new syntax

2017-08-10 Thread Matt Wheeler
nk you.) > > [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5] > [1, 2, 3, 4, 5] > How about these? > > [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)] > [100, 200, 101, 201, 102, 202] > [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y i

Re: Subclassing dict to modify values

2017-08-02 Thread Matt Wheeler
tions-abstract-base-classes All of the mixin methods (the ones defined for you) will call the abstract methods you override. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: @lru_cache on functions with no arguments

2017-08-01 Thread Matt Wheeler
On Tue, 1 Aug 2017 at 12:53 Thomas Nyberg wrote: > On 08/01/2017 01:06 PM, Matt Wheeler wrote: > > A function which is moderately expensive to run, that will always return > > the same result if run again in the same process, and which will not be > > needed in every sessio

Re: @lru_cache on functions with no arguments

2017-08-01 Thread Matt Wheeler
un, maintaining the interface would trump simplicity for the simple case). I've not investigated the Django codebase, so I don't know if my guesses line up with it exactly, but it should be quite easy to construct a grep or sed script to scan the source to find out :) -- -- Matt Wheeler

Re: is @ operator popular now?

2017-07-15 Thread Matt Wheeler
aps it should also be listed at https://docs.python.org/3.6/genindex-Symbols.html -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: is @ operator popular now?

2017-07-15 Thread Matt Wheeler
uld be more appropriate) > -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Google Sheets API Error

2017-06-17 Thread Matt Wheeler
your intention has been mangled somewhere along the way, and in any case the code seems to be missing parts. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: API Help

2017-06-14 Thread Matt Wheeler
{"warehouseCode":"AB-1-CA","quantityAvailable":1.0},{"warehouseCode":"WA-1-US","quantityAvailable":0.0},{"warehouseCode":"PO-1-CA","quantityAvailable":0.00000}]}] >>> json.loads(s) [{u&#

Test String Contents

2017-06-13 Thread Matt
What is easiest way to determine if a string ONLY contains a-z upper or lowercase. I also want to allow the "-" and "_" symbols. No spaces or anything else. -- https://mail.python.org/mailman/listinfo/python-list

Re: New to Python - Career question

2017-06-07 Thread Matt
On Tuesday, June 6, 2017 at 3:37:56 PM UTC-7, Marko Rauhamaa wrote: > pta...@gmail.com: > > > New to Python and have been at it for about a month now. I'm doing > > well and like it very much. Considering a career change down the road > > and have been wondering... What are the job prospects for a

Re: Finding the name of an object's source file

2017-06-06 Thread Matt Wheeler
ively, without using inspect, we can get around `Object.__module__` being a string by importing it as a string: >>> import importlib, os >>> importlib.import_module(os.path.split.__module__).__file__ '/Users/matt/.pyenv/versions/3.6.0/lib/python3.6/posixpath.py' -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Logging function calls without changing code

2017-05-24 Thread Matt Wheeler
og the arguments passed to the functions (you didn't say that) things get a bit more complex, but it's still certainly achievable. If you actually need to wrap the class in place for testing you might look into combining something like the above with the mock library. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: How to update python from 3.5.2 to 3.5.3 on Linux

2017-05-03 Thread Matt Ruffalo
On 2017-05-03 12:43, Thomas Nyberg wrote: > On 05/03/2017 11:47 AM, Wolfgang Maier wrote: >> On 03.05.2017 17:11, Thomas Nyberg wrote: >>> On 05/03/2017 11:04 AM, Daiyue Weng wrote: nope, I was thinking it might be good to update to 3.5.3 for security reasons? >>> (CCing back in pyth

Test if Script Already Running

2017-04-18 Thread Matt
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 ':flock'; INIT { open LH, $0 or die "Can't open $0 for lockin

net-snmp-python

2017-04-01 Thread Matt
Does anyone have an example of using netsnmp library to do a snmpset on a snmp v2 device? I have gotten snmpget to work fine with python I just cannot get snmpset to work. I know I have the snmp device configured correctly with read/write access since I can use snmpset on the linux(centos7) comma

SNMP

2017-03-23 Thread Matt
What is easiest way to read and write SNMP values with Python? -- https://mail.python.org/mailman/listinfo/python-list

Re: Substitute a mock object for the metaclass of a class

2017-03-13 Thread Matt Wheeler
A small correction... On Mon, 13 Mar 2017 at 22:36 Matt Wheeler wrote: > ``` > from unittest.mock import patch > > import lorem > > > @patch('lorem.type') > def test_things(mocktype): > lorem.quux(metameta.Foo()) > > lorem.return_value.assert

Re: Substitute a mock object for the metaclass of a class

2017-03-13 Thread Matt Wheeler
'Foo', unittest.mock.ANY, unittest.mock.ANY) > When I try to add the stub_metaclass side_effect in to my code I get `TypeError: __new__() missing 2 required positional arguments: 'bases' and 'namespace'` ... which seems quite reasonable, an

Re: PEP 393 vs UTF-8 Everywhere

2017-01-21 Thread Matt Ruffalo
On 2017-01-21 10:50, Pete Forman wrote: > Thanks for a very thorough reply, most useful. I'm going to pick you up > on the above, though. > > Surrogates only exist in UTF-16. They are expressly forbidden in UTF-8 > and UTF-32. The rules for UTF-8 were tightened up in Unicode 4 and RFC > 3629 (2003)

Re: Screwing Up looping in Generator

2017-01-05 Thread Matt Wheeler
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler wrote: > range() is not part of the for syntax at all, it's completely separate, it > simply returns an iterator which the for loop can use, like any other. > *iterable -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/ma

Re: Screwing Up looping in Generator

2017-01-05 Thread Matt Wheeler
to do. range() is not part of the for syntax at all, it's completely separate, it simply returns an iterator which the for loop can use, like any other. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Screwing Up looping in Generator

2017-01-03 Thread Matt Wheeler
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler wrote: > range() is not part of the for syntax at all, it's completely separate, it > simply returns an iterator which the for loop can use, like any other. > *iterable -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/ma

Re: Screwing Up looping in Generator

2017-01-03 Thread Matt Wheeler
. range() is not part of the for syntax at all, it's completely separate, it simply returns an iterator which the for loop can use, like any other. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Matt Wheeler
i if your computer is fast enough (it's a bit of a resource hog), and syntastic as a great way to integrate style checkers & linters into vim. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: just started

2016-12-19 Thread Matt Wheeler
ip3.5 and the command python3.5 -m pip > install automatically translates into pip3.5 ? > Actually it's the other way around. The `pip3.5` (and `pip3`) commands both map to (effectively) `python3.5 -m pip`. You can see this if you run `cat $(which pip3)`. -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

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

2016-12-16 Thread Matt Wheeler
s? So... Not for me, but obviously with the caveats above. Giving it a try in an Apple store is definitely a good idea :) -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: correct way to catch exception with Python 'with' statement

2016-11-29 Thread Matt Wheeler
On Tue, 29 Nov 2016 at 23:59 wrote: > If you want to do something only if the file exists (or does not), use > os.path.isfile(filename) > This opens you up to a potential race condition (and has potential security implications, depending on the application), as you're using LBYL[0]. If you want

Re: Function to take the minimum of 3 numbers

2016-10-09 Thread Matt Wheeler
nsistent operators is not required but is easier to read and less > confusing. > Unfortunately in this case it's also less correct > -- -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Can this be easily done in Python?

2016-09-28 Thread Matt Wheeler
On Tue, 27 Sep 2016 at 20:58 TUA wrote: > Is the following possible in Python? > > Given how the line below works > > TransactionTerms = 'TransactionTerms' > > > have something like > > TransactionTerms = > > that sets the variable TransactionTerms to its own name as string > representation with

Re: how to automate java application in window using python

2016-09-20 Thread Matt Wheeler
On Tue, 20 Sep 2016, 02:47 meInvent bbird, wrote: > can it contorl Maplesoft's maple which is a java executable file? > I don't know maple so I can't answer that. Which programming language an application is written in isn't really relevant for pywinauto, it's the graphical toolkit in use which

Re: how to automate java application in window using python

2016-09-18 Thread Matt Wheeler
On Thu, 15 Sep 2016, 08:12 meInvent bbird, wrote: > how to automate java application in window using python > > 1. scroll up or down of scroll bar > 2. click button > 3. type text in textbox > I would recommend having a look at pywinauto https://github.com/pywinauto/pywinauto It presents a very

Re: *args and **kwargs

2016-09-04 Thread Matt Ruffalo
On 2016-09-02 15:44, Ben Finney wrote: > Note that this has nothing to do with how the function is defined; in > the definition of the function, parameters are neither positional nor > keyword. You name each of them, and you define an order for them; and > neither of those makes any of them “positi

Re: PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Matt Ruffalo
On 2016-08-29 23:56, Chris Angelico wrote: > Up until very recently, the system Python has only been the Python 2. > (For a while, it wasn't even 2.7, but I could easily use altinstall > for that.) I have deliberately wanted to use 3.6 for ALL testing, not > just by messing with venvs or shell alia

Re: PSA: Debian Stretch, apt-listchanges, and Python 3

2016-08-29 Thread Matt Wheeler
I think the real PSA is "don't mess with the system python(3) version". On Mon, 29 Aug 2016 at 13:18 Chris Angelico wrote: > If, like me, you build Python 3.6 from source and make it your default > 'python3' binary, you may run into issues with the latest > apt-listchanges, which has switched to

Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-06 Thread Matt Ruffalo
On 2016-08-04 15:45, Random832 wrote: > On Thu, Aug 4, 2016, at 15:22, Malcolm Greene wrote: >> Hi Chris, >> >> Thanks for your suggestions. I would like to capture the specific bad >> codes *before* they get replaced. So if a line of text has 10 bad codes >> (each one raising UnicodeError), I woul

Re: Win32 API in pywin32

2016-08-05 Thread Matt Wheeler
On Fri, 5 Aug 2016, 02:23 Lawrence D’Oliveiro, wrote: > On Friday, August 5, 2016 at 12:06:23 PM UTC+12, Igor Korot wrote: > > > > On Thu, Aug 4, 2016 at 4:57 PM, Lawrence D’Oliveiro wrote: > >> On Friday, August 5, 2016 at 11:50:28 AM UTC+12, jj0ge...@gmail.com > wrote: > >>> According to Python

Re: functools.partial [was Re: and on - topic and and off topic]

2016-07-29 Thread Matt Wheeler
On Fri, 29 Jul 2016, 09:20 Steven D'Aprano, wrote: > I'm not sure that partial is intended as an optimization. It may end up > saving time by avoiding evaluating arguments, but that's not why it exists. > It exists to enable the functional programming idiom of partial evaluation > in a simpler, m

Re: Running yum/apt-get from a virtualenv

2016-07-04 Thread Matt Wheeler
On Fri, 24 Jun 2016, 03:32 Tiglath Suriol, wrote: > Let us say that I install PostgreSQL from an activated virtualenv using > yum or apt-get, will PostgrSQL be local or global? > Global I understand that virtualenv isolates the Python environment only, so I > surmise that it will make no differ

Re: Re - Contradictory error messages in Python 3.4 - standard library issue!

2016-06-16 Thread Matt Wheeler
On Thu, 16 Jun 2016, 23:31 Harrison Chudleigh, < harrison.chudlei...@education.nsw.gov.au> wrote: > Sorry! I was trying to indent a line and accidentally sent only half of the > message. > It would be helpful if your reply was actually a reply to your previous message, to enable us to follow the

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread Matt Wheeler
First of all welcome :) The other suggestions you've received so far are good so I won't repeat them... (note that in particular I've reused the names you've chosen in your program where I've given code examples, but that's purely for clarity and I agree with the others who've said you should use

Re: I'm wrong or Will we fix the ducks limp?

2016-06-03 Thread Matt Wheeler
Hi, On Fri, 3 Jun 2016, 16:04 Sayth Renshaw, wrote: > > So at the point I create the variable it refers to an object. > It's best to think of them as names, rather than variables, as names in python don't behave quite how you'll expect variables to if you're coming from some other languages. M

Re: Don't understand a probleme of module time not defined when calling a foo func

2016-05-30 Thread Matt Wheeler
On Mon, 30 May 2016, 21:08 Ni Va, wrote: > > _ > Output: > Traceback (most recent call last): > File "", line 1, in > File "", line 16, in PyExecReplace > File "", line 22, in > File "", line 11, in foo > NameError: global name 'time' is not defined > Based on your tracebac

Re: re.search - Pattern matching review

2016-05-30 Thread Matt Wheeler
On 30 May 2016 at 10:03, Ganesh Pal wrote: > Thanks Matt for the reply and lovely analysis . I was trying to complicate > the simple task :( > > Here is how the code looks now , the whole idea was just to match the > pattern and return it > > > def get_b

Re: re.search - Pattern matching review

2016-05-29 Thread Matt Wheeler
eturn block else: logging.info("block not found") >return False > logging.info("block not found") > return block And you probably don't need to explicitly return false, python functions implicitly return None (which is falsey) if they don't reach a return statement, but that's perhaps a matter of taste. -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Question on List processing

2016-04-25 Thread Matt Wheeler
On Mon, 25 Apr 2016 15:56 , wrote: > Dear Group, > > I have a list of tuples, as follows, > > list1=[u"('koteeswaram/BHPERSN engaged/NA himself/NA in/NA various/NA > philanthropic/NA activities/NA ','class1')", u"('koteeswaram/BHPERSN is/NA > a/NA very/NA nice/NA person/NA ','class1')", u"('kot

Re: How much sanity checking is required for function inputs?

2016-04-23 Thread Matt Wheeler
r something') class Queen(Piece): def validate_move(self, new): return any((test(self.position, new) for test in (move_straight, move_diag))) Ok I'll stop before I get too carried away... This is completely untested so bugs will abound I'm sure :) -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Moderation and slight change of (de facto) policy

2016-04-17 Thread Matt Ruffalo
Hi- That seems like a reasonable approach, though I think there *really* needs to be an option along the lines of "subscribed to the list for the purposes of moderation, but not receiving list messages via email". I think I did this with the Git mailing list in the past, and it was quite useful. I

Re: sum accuracy

2016-04-15 Thread Matt Wheeler
ect > > exact_sum([0.3, 0.7]) > > to be 1. and make def not_exact_but_probably_the_sum_you_wanted(nums): return sum(map(lambda x:Fraction(x).limit_denominator(), nums)) -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

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

2016-03-24 Thread Matt Wheeler
L[i]=0 That doesn't clear the list, that results in a list of the same length where every element is 0. That might sound like the same thing if you're used to a bounded array of ints, for example, but in Python it's very much not. -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: newbie question

2016-03-24 Thread Matt Wheeler
On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: > On 24.03.2016 11:57, Matt Wheeler wrote: > >>>> import ast > >>>> s = "(1, 2, 3, 4)" > >>>> t = ast.literal_eval(s) > >>>> t > > (1, 2, 3, 4) > > I suppose

Re: newbie question

2016-03-24 Thread Matt Wheeler
o recover the tuple in a variable t > > t = (1, 2, 3, 4) > > how would you do ? > > > -- > https://mail.python.org/mailman/listinfo/python-list -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: monkey patching __code__

2016-03-21 Thread Matt Wheeler
On 20 March 2016 at 16:46, Sven R. Kunze wrote: > On 19.03.2016 00:58, Matt Wheeler wrote: >> >> I know you have a working solution now with updating the code & >> defaults of the function, but what about just injecting your function >> into the modules that ha

Using SSL socket as stdin for subprocess.Popen

2016-03-21 Thread Matt Ruffalo
Hi all- I'm writing a backup client for automating the synchronization of btrfs snapshots between machines -- essentially piping the output of `btrfs send` on my laptop/desktop to `btrfs receive` on a server. I've been doing this manually for quite a while, and something automated would be much mo

Re: monkey patching __code__

2016-03-19 Thread Matt Wheeler
, prefix=None, > current_app=None): > > > Some ideas? I know you have a working solution now with updating the code & defaults of the function, but what about just injecting your function into the modules that had already imported it after the monkeypatching? Seems perhaps cleaner

Re: Review Request of Python Code

2016-03-10 Thread Matt Wheeler
On 10 March 2016 at 18:12, wrote: > Matt, thank you for if...else suggestion, the data of NewTotalTag.txt > is like a simple list of words with unconventional tags, like, > > w1 tag1 > w2 tag2 > w3 tag3 > ... > ... > w3 tag3 > > like that. I suspected so. The

Re: Review Request of Python Code

2016-03-09 Thread Matt Wheeler
On 9 March 2016 at 12:06, Matt Wheeler wrote: > But we can still do better. A list is a poor choice for this kind of > lookup, as Python has no way to find elements other than by checking > them one after another. (given (one of the) name(s) you've given it > sounds a bit li

Re: Review Request of Python Code

2016-03-09 Thread Matt Wheeler
ld definitely still do that too!), especially if your word list is very large. This is because the set type uses a hashmap internally, making lookups for matches extremely fast, compared to scanning through the list. -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: urlopen, six, and py2

2016-03-02 Thread Matt Wheeler
s is wordier and more fragile than using a context manager to clean up for you, I expect you won't bother :). [1] https://docs.python.org/2/library/contextlib.html#contextlib.closing -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Considering migrating to Python from Visual Basic 6 for engineering applications

2016-02-19 Thread Matt Wheeler
m sure there was a recent thread about returning the best fit type (i.e. int, if not then float, if not then str)? -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

Re: Guido on python3 for beginners

2016-02-18 Thread Matt Wheeler
On Thu, 18 Feb 2016 11:07 Chris Angelico wrote: > By the way... For bash users, adding this to .bashrc may make venvs a > bit easier to keep straight: > > checkdir() { > [ -n "$VIRTUAL_ENV" ] && ! [[ `pwd` =~ `dirname $VIRTUAL_ENV`* ]] > && echo Deactivating venv $VIRTUAL_ENV... && deactivate

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

2016-02-14 Thread Matt Wheeler
pfile.NamedTemporaryFile with your newly created temp dir and an arbitrary suffix, and strip the suffix off to get the name you actually use.) -- Matt Wheeler http://funkyh.at -- https://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   >