transform a "normal" decorator in one for async functions

2018-09-18 Thread vito . detullio
Hi.

Let's say I have this library that expose a decorator; it's meant to be used 
with normal functions.

but I have to "apply" the decorator to an async function.
>From what I understand I cannot "really" wait for this decorated async 
>function, as it's not really "async", and, from a simple test I made, I see 
>that the order of execution is not really "straight" (I have simplifield the 
>example to the bone)

import asyncio

def deco(fun): # the "classic" decorator
def wrap(*args, **kwargs):
print('wrap begin')
try:
return fun(*args, **kwargs)
finally:
print('wrap end')
return wrap

@deco
async def decorated_async():
print('a')
await asyncio.sleep(1)
print('b')


loop = asyncio.get_event_loop()
loop.run_until_complete(decorated_async())
loop.close()

the output of this script is

wrap begin
wrap end
a
b

while an "async-aware" decorator (with an "async" wrap that "await"s the fun 
call) would print the "wrap end" line at the end.

I can easily rewrite my dumb decorator to handle async functions (I can just 
make an "async def wrap" and "return await fun"), but I cannot rewrite this 
library.

is there a way to "convert" a "normal" decorator in one that can handle async 
functions?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Permutations using a recursive generator

2018-09-18 Thread ast

Hello

I found a smart and very concise code to
generate all permutations of a list.
I put it here if someone is interested to
figure out how it works


def permut(li, prefix=[]):

if len(li)==1:
yield prefix + li
else:
for elt in li:
li2 = li.copy()
li2.remove(elt)
yield from S(li2, prefix+[elt])


exemple of usage

>>> list(permut(['a', 'b', 'c']))
[['a', 'b', 'c'], ['a', 'c', 'b'], ['b', 'a', 'c'], ['b', 'c', 'a'], 
['c', 'a', 'b'], ['c', 'b', 'a']]


>>> list(permut([0,1,2,3]))
[[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], 
[0, 3, 2, 1], [1, 0, 2, 3], [1, 0, 3, 2], [1, 2, 0, 3], [1, 2, 3, 0], 
[1, 3, 0, 2], [1, 3, 2, 0], [2, 0, 1, 3], [2, 0, 3, 1], [2, 1, 0, 3], 
[2, 1, 3, 0], [2, 3, 0, 1], [2, 3, 1, 0], [3, 0, 1, 2], [3, 0, 2, 1], 
[3, 1, 0, 2], [3, 1, 2, 0], [3, 2, 0, 1], [3, 2, 1, 0]]

--
https://mail.python.org/mailman/listinfo/python-list


Re: Permutations using a recursive generator

2018-09-18 Thread ast

Le 18/09/2018 à 17:01, ast a écrit :

error: permut instead of S


     yield from permut(li2, prefix+[elt])

--
https://mail.python.org/mailman/listinfo/python-list


Re: transform a "normal" decorator in one for async functions

2018-09-18 Thread Thomas Jollans
On 2018-09-18 16:20, vito.detul...@gmail.com wrote:
> but I cannot rewrite this library.

Perhaps not, but surely you can write your own decorator that does
whatever this library's decorator does for async functions? Presumably
you have the code...

> is there a way to "convert" a "normal" decorator in one that can handle async 
> functions?

In general? No.


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Permutations using a recursive generator

2018-09-18 Thread Thomas Jollans
On 2018-09-18 17:05, ast wrote:
> Le 18/09/2018 à 17:01, ast a écrit :
>> Hello
>> 
>> I found a smart and very concise code to
>> generate all permutations of a list.
>> I put it here if someone is interested to
>> figure out how it works

When you say "found a [...] code" I hope you mean "wrote a function"
rather than "discovered a bit of code and decided to share it without
attribution or permission".

>> 
>> 
>> def permut(li, prefix=[]):
>> 
>> if len(li)==1:
>> yield prefix + li
>> else:
>> for elt in li:
>> li2 = li.copy()
>> li2.remove(elt)
>> yield from S(li2, prefix+[elt]) >
> error: permut instead of S
> 
>>  yield from permut(li2, prefix+[elt])

Nice. If you want to see more implementations of the same thing, have a
look in the standard library docs ;-)

https://docs.python.org/3/library/itertools.html#itertools.permutations




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: transform a "normal" decorator in one for async functions

2018-09-18 Thread vito . detullio
Il giorno martedì 18 settembre 2018 17:15:22 UTC+2, Thomas Jollans ha scritto:

> > but I cannot rewrite this library.
> 
> Perhaps not, but surely you can write your own decorator that does
> whatever this library's decorator does for async functions? Presumably
> you have the code...

well, maybe? While I could have access to the sources, I don't want to 
"maintain" (part of) this library.
Worst even if I need to maintain it in my project, and not upstream.

> > is there a way to "convert" a "normal" decorator in one that can handle 
> > async functions?
> In general? No.

Ouch.

I'm new to the "async" world, but so this mean that all of the (appliable) 
decorators present in the various libraries have to be "paired" with async 
versions?
-- 
https://mail.python.org/mailman/listinfo/python-list


PyLint and Mypy real-time (and on-demand) code inspection from within PyCharm/IDEA

2018-09-18 Thread Roberto Leinardi
Hello there,

I am the developer of pylint-pycharm and mypy-pycharm, two plugins
providing both real-time and on-demand scanning of Python files with
PyLint/Mypy from within PyCharm/IDEA.

The real-time code inspection works automatically the same way like the
PyCharm's build-in PEP8 check (you see the issues highlighted directly in
your code while typing).

The on-demand inspection has several options that go from just scanning the
current file to scan the entire project.

The plugins also offer an option to run a check on modified files before a
VCS checkin.

If you are familiar with Checkstyle-IDEA plugin for Java, they are very
similar and offer the same features (and share a lot of the code).

The plugins source code is available here:
https://github.com/leinardi/pylint-pycharm
https://github.com/leinardi/mypy-pycharm

But they can also be easily installed from the official JetBrains Plugin
Repository:
1. In PyCharm, open the Settings/Preferences dialog (CTRL+Alt+S), click
Plugins.
2. Click Browse repositories.
3. In the Browse Repositories dialog that opens, right-click on the plugin
named "Pylint" or "Mypy" and select Download and Install.
4. Confirm your intention to download and install the selected plugin.
5. Click Close.
6. Click OK in the Settings dialog and restart PyCharm for the changes to
take effect.

Thanks and enjoy linting!
Roberto
-- 
https://mail.python.org/mailman/listinfo/python-list


missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread Chandan Kumar Abhimanyu
how I download and install api-ms-win-crt-runtime-|1-1-0.dll  when I am
downloading by googling it is not installable file.
-- 
*Chandan Kumar Abhimanyu*
*+91 9876852058*
*Department of Management Studies,*
*Indian Institute of Technology (ISM), Dhanbad, *
*Jharkhand- 826004, India.*
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't import array in 3.7 python version

2018-09-18 Thread Cruey Cruel
I have subscribe to python list, please provide me any resolution
forpreviois below email

On Tue, 18 Sep 2018, 23:07 Cruey Cruel,  wrote:

> Hi team,
> Am facing issue in importing array.
>
> I use alatest version of pythonide and pycharm.
>
> Telle how can I fix this.
>
> Thanks and regards
> Jignesh
>
-- 
https://mail.python.org/mailman/listinfo/python-list


MIDI note timing

2018-09-18 Thread Tobiah

I'd like to do some algorithmic composing using python.
I've seen various libraries that seem to be capable of
sending a MIDI message to a MIDI port, but I don't know
where to get the timing from.  Normally, with something
like CSOUND, the program locks itself to the timing of
the soundcard and presumably uses that for timing.

Is there anything for python that could do this?
I've seen rather ridiculous examples using sleeps for
timing, but for musical applications the timing really
needs to come form a hardware soundcard, especially
as I'd like to play audio through the card at the
same time and have it line up perfectly with the MIDI.


Thanks for any suggestions.


Toby

--
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread eryk sun
On Tue, Sep 18, 2018 at 11:45 AM, Chandan Kumar Abhimanyu
 wrote:
> how I download and install api-ms-win-crt-runtime-|1-1-0.dll  when I am
> downloading by googling it is not installable file.

The Universal C Runtime (CRT) is an OS component for Windows Vista and
later. Make sure Windows Update is enabled and configured to install
optional updates. That said, Python's installer should have installed
the Universal CRT if it wasn't already installed. Maybe your system
just needs to be restarted.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread Mark Lawrence

On 18/09/18 17:45, Chandan Kumar Abhimanyu wrote:

how I download and install api-ms-win-crt-runtime-|1-1-0.dll  when I am
downloading by googling it is not installable file.



https://www.microsoft.com/en-us/download/details.aspx?id=49984

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread Gene Heskett
On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote:

> how I download and install api-ms-win-crt-runtime-|1-1-0.dll  when
> I am downloading by googling it is not installable file.
> --
> *Chandan Kumar Abhimanyu*
> *+91 9876852058*
> *Department of Management Studies,*
> *Indian Institute of Technology (ISM), Dhanbad, *
> *Jharkhand- 826004, India.*


I'd delete it and go get it from a more reputable site preferably the M$ 
site as its a freely distributall part for one of their C++ variations.

Best fix instructions seems to be at:



So apparently the | is a legal filename component, to a windows box. 
Windows never ceases to amaze me. 7 machines running here right now, but 
not a single windows install.

-- 
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't import array in 3.7 python version

2018-09-18 Thread MRAB

On 2018-09-18 18:48, Cruey Cruel wrote:

I have subscribe to python list, please provide me any resolution
forpreviois below email


What error message does it print?

It might be that you have a named a file the same as one of those in 
Python's standard library, e.g. "array.py".


If that's not the problem, then you'll need to provide some more 
details. Copy the traceback and post it here.



On Tue, 18 Sep 2018, 23:07 Cruey Cruel,  wrote:


Hi team,
Am facing issue in importing array.

I use alatest version of pythonide and pycharm.

Telle how can I fix this.

Thanks and regards
Jignesh




--
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread MRAB

On 2018-09-18 19:43, Gene Heskett wrote:

On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote:


how I download and install api-ms-win-crt-runtime-|1-1-0.dll  when
I am downloading by googling it is not installable file.
--
*Chandan Kumar Abhimanyu*
*+91 9876852058*
*Department of Management Studies,*
*Indian Institute of Technology (ISM), Dhanbad, *
*Jharkhand- 826004, India.*



I'd delete it and go get it from a more reputable site preferably the M$
site as its a freely distributall part for one of their C++ variations.

Best fix instructions seems to be at:



So apparently the | is a legal filename component, to a windows box.
Windows never ceases to amaze me. 7 machines running here right now, but
not a single windows install.

Either that, or it's a spelling mistake. Which do you think is more 
likely? :-)

--
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread eryk sun
On Tue, Sep 18, 2018 at 1:43 PM, Gene Heskett  wrote:
>
> 
>
> So apparently the | is a legal filename component, to a windows box.

"l1-1-0" starts with "l" (ordinal 0x6c, i.e. lower-case "L"), not "|"
(pipe, 0x7c).

Other than the OS path separator, \ (backslash, 0x5c), the set of
reserved characters is up to the file system. It's recommended to
reserve NUL (0x00), / (slash, 0x2f) and the 5 wildcard characters:
*?"<> (0x2a, 0x3f, 0x22, 0x3c, 0x3e). NTFS additionally reserves :
(colon, 0x3a) as the delimeter for stream names and types, | (pipe,
0x7c) for no good reason, and control characters (0x01 - 0x1F). In
contrast, if you're running Windows as a guest OS in a VirtualBox VM,
its VboxSF file system (for sharing folders with the host OS) actually
allows colon, pipe, and control characters in filenames.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: missing- api-ms-win-crt-runtime-|1-1-0.dll

2018-09-18 Thread Gene Heskett
On Tuesday 18 September 2018 15:59:52 MRAB wrote:

> On 2018-09-18 19:43, Gene Heskett wrote:
> > On Tuesday 18 September 2018 12:45:38 Chandan Kumar Abhimanyu wrote:
> >> how I download and install api-ms-win-crt-runtime-|1-1-0.dll 
> >> when I am downloading by googling it is not installable file.
> >> --
> >> *Chandan Kumar Abhimanyu*
> >> *+91 9876852058*
> >> *Department of Management Studies,*
> >> *Indian Institute of Technology (ISM), Dhanbad, *
> >> *Jharkhand- 826004, India.*
> >
> > I'd delete it and go get it from a more reputable site preferably
> > the M$ site as its a freely distributall part for one of their C++
> > variations.
> >
> > Best fix instructions seems to be at:
> >
> >  >-runtime-l1-1-0dll-error-3676874/>
> >
> > So apparently the | is a legal filename component, to a windows box.
> > Windows never ceases to amaze me. 7 machines running here right now,
> > but not a single windows install.
>
> Either that, or it's a spelling mistake. Which do you think is more
> likely? :-)

I'm fresh out of quarters to flip on that.  The character, as it existed 
all over the net when I did the google thing, was an |, not a lowercase 
l, as you have it, exists 50+ times in the reading of google hits I did 
last night. So you'll have to ask M$ which it is.

-- 
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list