g 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
, 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
> 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
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
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
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
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
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
> 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
manager
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 overkill :
7/psutil/_psutil_common.o
>
Based on the include 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 y
ly 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
ry [
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
it does that well and it appears to still be pretty
active.
> --
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
ty of any other cross-platform incompatibilities playing a part?
> --
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
call` it will be available
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
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 st
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[1:]+" is "+str(eval(x))]
> &
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[1:]+" is "+str(eval(x))]
for i in 12,9,5,0:l.insert(i,'')
print('\n'.join(l))
--
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
ger 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
f x < 5 for y in (100, 200)]
[100, 200, 101, 201, 102, 202, 103, 203, 104, 204]
--
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
collections.abc.html#collections-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
On Tue, 1 Aug 2017 at 12:53 Thomas Nyberg <tomuxi...@gmx.com> 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
> &
nment during a single run, 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 :)
--
--
on.org/dev/peps/pep-0465/
Perhaps 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
module level would be
more appropriate)
> --
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
ntention 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
uantityAvailable":0.0}]}]
>>> json.loads(s)
[{u'inventory': [{u'quantityAvailable': 0.0, u'warehouseCode': u'UT1-US'},
{u'quantityAvailable': 0.0, u'warehouseCode': u'KY1US'},
{u'quantityAvailable': 14.0, u'warehouseCode': u'TX-1-US'},
{u'quantityAvailable': 4.0, u'warehouseCode': u'CA-1-US'},
{u'quantityAvailable': 1.0, u'warehouseCode': u'AB-1-CA'},
{u'quantityAvailable': 0.0, u'warehouseCode': u'WA-1-US'},
{u'quantityAvailable': 0.0, u'warehouseCode': u'PO-1-CA'}],
u'itemNumber': u'75-5044'}]
Looks like json to me, and to json.loads, which is probably more
authoritative :)
--
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
hout 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
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://
A small correction...
On Mon, 13 Mar 2017 at 22:36 Matt Wheeler <m...@funkyhat.org> wrote:
> ```
> from unittest.mock import patch
>
> import lorem
>
>
> @patch('lorem.type')
> def test_things(mocktype):
> lorem.quux(metameta.Foo())
>
> lorem.return
'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, and I expect you're in a
better position to figur
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler <m...@funkyhat.org> 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://
nge() 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
On Tue, 3 Jan 2017 at 21:46 Matt Wheeler <m...@funkyhat.org> 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://
t 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
ur 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
d. I have only pip3.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
lems?
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
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
quivalent. Consider `a, b, c = 1, 7, 4`
> Using consistent 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
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
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
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
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,
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:
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
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
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
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
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
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
>
e.
Attempting to protect against other possibilities will at best provide
no benefit, and is likely to make your job harder when you're
debugging later on.
Another thing to note for future reference is if you want to use a
try:except block to inject logging you can re-raise the original
except
g.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
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
('or 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
pect
>
> 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
esn'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
On Thu, 24 Mar 2016 11:10 Sven R. Kunze, <srku...@mail.de> 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
quot;
>
> and I want to 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
On 20 March 2016 at 16:46, Sven R. Kunze <srku...@mail.de> 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
None, 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, u
ictionary("NewTotalTag.txt")
You also aren't closing the file that you open at any point -- once
you've loaded the data from it there's no need to keep the file opened
(look up context managers).
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
On 9 March 2016 at 12:06, Matt Wheeler <m...@funkyhat.org> 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
>
h you should 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
ile 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
ad 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
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
same dir then perhaps use
tempfile.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
you must patch the standard library tarfile module then I would
suggest patching it to have an extra, default False, argument to
enable your printing behaviour, so you don't risk messing up anyone
else's use of it.
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
sorry about that, I think our aim was a little off with a few of the
brandings.
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
On 8 February 2016 at 12:17, Jussi Piitulainen
<jussi.piitulai...@helsinki.fi> wrote:
> Also, what would be the nicest current way to express a priority union
> of dicts?
>
> { k:(d if k in d else e)[k] for k in d.keys() | e.keys() }
Since Python 3.5: {**e, **d}
--
est to just try out your
script and find out though.
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
//b)
...
>>> num = 3**171
>>> num
3870210234510307998744588107535211184800325224934979257430349324033792477926791547
>>> num2 = 4**80
>>> num2
1461501637330902918203684832716283019655932542976
>>> intdiv(num, num2)
2648105301871818722187687529062555
And if y do :
>
>>>> a="""test
> . . . to
> . . . see
> . . . if
> . . . it
> . . . is
> . . . working"""
>>>>a
> 'test\nto\nsee\nif\nit\nis\nworking'
>>>>
\n is an escape sequence rather than a comma
Cython
to achieve what you want...
...but then you might start to see the benefits of dynamic typing :)
--
Matt Wheeler
http://funkyh.at
--
https://mail.python.org/mailman/listinfo/python-list
I'll just answer the one part I don't feel has had enough attention yet,
all other parts chopped...
On Sat, 25 Jul 2015 10:39 E.D.G. edgrs...@ix.netcom.com wrote:
Posted by E.D.G. July 25,
2015
6. What is Python's version of the DOS level System command that many
programs use as in:
system
Changes by Matt Wheeler m...@funkyhat.org:
--
nosy: +funkyhat
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6931
___
___
Python-bugs-list mailing
78 matches
Mail list logo