Re: importlib changes from py3.7 to py3.8

2020-09-20 Thread Eko palypse
On 19/09/20 7:51 am, Eko palypse wrote: > > ValueError: source code string cannot contain null bytes > > > > Any idea what happened here? > > > Seems I've missed that __init__.py's aren't allowed to be empty anymore. > > Adding a single # solved the issue. > >

Re: importlib changes from py3.7 to py3.8

2020-09-19 Thread Eko palypse
Seems I've missed that __init__.py's aren't allowed to be empty anymore. Adding a single # solved the issue. Eren -- https://mail.python.org/mailman/listinfo/python-list

importlib changes from py3.7 to py3.8

2020-09-18 Thread Eko palypse
With python3.7 I'm able to use _module = importlib.import_module('app.plugins.plugin_dir.plugin_name') succesfully but with python 3.8 this results in File "D:\ProgramData\Python\Python38_64\lib\importlib\__init__.py", line 127, in import_module return

Re: Embedded python: How to debug code in an isolated way

2020-08-24 Thread Eko palypse
l give it a try anyways. :-) Thx Eren Am So., 23. Aug. 2020 um 22:55 Uhr schrieb Barry : > > > > On 22 Aug 2020, at 20:53, Eko palypse wrote: > > > > Hello, > > > > background info first. On windows, python3.8.5 > > > > A cpp app has an embedded

Re: Embedded python: How to debug code in an isolated way

2020-08-22 Thread Eko palypse
ust nicer, I think. Eren Am Sa., 22. Aug. 2020 um 22:59 Uhr schrieb Chris Angelico : > On Sun, Aug 23, 2020 at 5:51 AM Eko palypse wrote: > > So the question is, what do I need to read/learn/understand in order to > solve this issue? > > Or in other words, how can I debug my

Embedded python: How to debug code in an isolated way

2020-08-22 Thread Eko palypse
Hello, background info first. On windows, python3.8.5 A cpp app has an embedded python interpreter which allows to modify/enhance the cpp app by providing objects to manipulate the cpp app and callbacks to act on certain events, like fileopen, fileclose, updateui ... which are send by the cpp

Re: Windows and Subclassing - 'OverflowError': int too long to convert

2020-07-29 Thread Eko palypse
, hWnd, msg, wParam, lParam): event_handler = self._event_handler.get(msg, None) if event_handler: return event_handler(msg, wParam, lParam) return False Once again, thank you Eren Am Mi., 29. Juli 2020 um 16:26 Uhr schrieb Eryk Sun : > On 7/28/20, Eko paly

Windows and Subclassing - 'OverflowError': int too long to convert

2020-07-28 Thread Eko palypse
Hello, I am subclassing a scintilla window and it happens every now and then that I get an OverflowError. I've logged the message and could narrow down that it is a single windows message which causes this trouble. It's WM_ERASEBKGND. Now the confusing part for me is the following. According to

Re: Threading module and embedded python

2020-04-16 Thread Eko palypse
st_window() Thanks Eren Am Do., 16. Apr. 2020 um 18:33 Uhr schrieb Barry Scott < ba...@barrys-emacs.org>: > > > > On 16 Apr 2020, at 14:55, Eko palypse wrote: > > > > Barry, sorry for sending you a private message yesterday, was not > intended. > >

Re: Threading module and embedded python

2020-04-16 Thread Eko palypse
* kwnames=0x)* The thread is neither suspended nor does it have any different status than the main thread which loops through its main event queue at this point. Thank you Eren Am Mi., 15. Apr. 2020 um 22:57 Uhr schrieb Barry : > > > > On 15 Apr 2020, at 21:18,

Re: Threading module and embedded python

2020-04-15 Thread Eko palypse
en Am Mi., 15. Apr. 2020 um 20:12 Uhr schrieb Barry Scott < ba...@barrys-emacs.org>: > > > > On 15 Apr 2020, at 13:30, Eko palypse wrote: > > > > Hi everyone, > > > > the following happens on Windows7 x64 and Python37 x64 > > > > I have a plugi

Threading module and embedded python

2020-04-15 Thread Eko palypse
Hi everyone, the following happens on Windows7 x64 and Python37 x64 I have a plugin DLL for a C++ application in which Python37 is embedded. The plugin itself works, except when I want to use the threading module. If I start a Python script in my plugin which uses the threading module I can

Re: Load python from different plugin dlls

2020-02-13 Thread Eko palypse
Thanks for the information. My test looks like this right now. I have two plugins which, when loaded separately, work. But when both are loaded, I get AccessVioletion messages from python37.dll. The init code for both dlls is this: cpp_init_code = f'''#include #include "PluginInterface.h"

Load python from different plugin dlls

2020-02-12 Thread Eko palypse
Assuming there is an CppApp which allows extending its functionality by adding plugins. Now let's assume there are plugin developer which use cython to create such a plugins. How can one check if there has been already a plugin loaded which itself loaded a python interpreter? And if this is

Re: How can i stop this Infinite While Loop - Python

2019-10-30 Thread Eko palypse
>From what I understand you want to give the user the possibility to try 10 times or enter -1 to end the script, right? If so, you need to check if item is -1 or total tries are already 10 and in such a case break the loop. No need for an else branch. Note, input returns an str object but you

Re: python3, regular expression and bytes text

2019-10-14 Thread Eko palypse
Am Montag, 14. Oktober 2019 13:56:09 UTC+2 schrieb Chris Angelico: > > (My apologies for saying this in reply to an unrelated post, but I > also don't see those posts, so it's not easy to reply to them.) > > ChrisA Nothing to apologize and thank you for clarification, I was already checking my

Re: python3, regular expression and bytes text

2019-10-14 Thread Eko palypse
Am Sonntag, 13. Oktober 2019 21:20:26 UTC+2 schrieb moi: > [Do not know why I spent hours with this...] > > To answer you question. > Yes, I confirm. > It seems that as soon as one works with bytes and when > a char is encoded in more than 1 byte, "re" goes into > troubles. > First, sorry for

Re: python3, regular expression and bytes text

2019-10-12 Thread Eko palypse
First of all many thanks to everyone for the active participation. @Chris Angelico I think I understand what you illustrated with the byte example, makes sense. As it was developed for 8-bit encoding only, it cannot be used for mulitbyte encoding. @Richard Damon and @MRAB thank you very much

Re: python3, regular expression and bytes text

2019-10-12 Thread Eko palypse
> You cannot. First, \w in re.LOCALE works only when the text is encoded > with the locale encoding (cp1252 in your case). Second, re.LOCALE > supports only 8-bit charsets. So even if you set the utf-8 locale, it > would not help. > > Regular expressions with re.LOCALE are slow. It may be more

Re: python3, regular expression and bytes text

2019-10-12 Thread Eko palypse
Thank you very much for your answer. > You have to be able to match bytes, not strings. May I ask you to elaborate on this, sorry non-native English speaker. The buffer I receive is a byte-like buffer. > I don't think you'll be able to 100% reliably match bytes in this way. > You're asking it

python3, regular expression and bytes text

2019-10-12 Thread Eko palypse
What needs to be set in order to be able to use a re search within utf8 encoded bytes? My test, being on a windows PC with cp1252 setup, looks like this import re import locale cp1252 = 'Ärger im Paradies'.encode('cp1252') utf8 = 'Ärger im Paradies'.encode('utf-8') print('cp1252:', cp1252)

Re: Synchronous and Asynchronous callbacks

2019-09-30 Thread Eko palypse
Am Montag, 30. September 2019 11:46:43 UTC+2 schrieb Barry Scott: > > On 29 Sep 2019, at 21:41, Eko palypse wrote: > > > > Am Sonntag, 29. September 2019 19:18:32 UTC+2 schrieb Barry Scott: > >>> On 29 Sep 2019, at 14:14, Eko palypse wrote: > >>> >

Re: Synchronous and Asynchronous callbacks

2019-09-29 Thread Eko palypse
Am Sonntag, 29. September 2019 19:18:32 UTC+2 schrieb Barry Scott: > > On 29 Sep 2019, at 14:14, Eko palypse wrote: > > > > Unfortunately, I can't make all callbacks synchronous or asynchronous > > because this has negative effects on the application in one way or anot

Re: Synchronous and Asynchronous callbacks

2019-09-29 Thread Eko palypse
Am Sonntag, 29. September 2019 01:02:48 UTC+2 schrieb Paul Rubin: > Eko palypse writes: > > Two dicts, one for sync and the other for async registrations? > > Why not make all the callbacks asynchronous? Clients that don't want to > handle a callback immediately can kee

Synchronous and Asynchronous callbacks

2019-09-28 Thread Eko palypse
Hello, I'm looking for a solution to a problem which is described best as an observer pattern issue I guess. The scenario is the following, client code can register a callback for one or a list of notifications. This is currently solved by having a dictionary with the possible notifications as

Re: Unable to start Python with Windows 7

2019-09-23 Thread Eko palypse
>What is strange is that I can run Python, but only with a short program ! Hi Crhistian, hard to tell, what might help is if you can copy/paste code which does not run (an example should be as small as possible). In addition, isn't there any output you get when the program doesn't run? A

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
Am Donnerstag, 19. September 2019 20:24:49 UTC+2 schrieb Peter Otten: > Eko palypse wrote: > > > Am Donnerstag, 19. September 2019 18:31:43 UTC+2 schrieb Peter Otten: > >> Eko palypse wrote: > >> > >> > No, I have to correct myself > >> > &g

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
Am Donnerstag, 19. September 2019 18:31:43 UTC+2 schrieb Peter Otten: > Eko palypse wrote: > > > No, I have to correct myself > > > > x = 5 > > def f1(): > > exec("x = x + 1; print('f1 in:', x)") > > return x > > print('f1

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
First thank you for all the answers, very much appreciated. I assume the root cause might be explained by the zen of python as well. If the implementation is hard to explain, it's a bad idea. Maybe I need to rethink my implementation :-) Eren --

Re: Unable to start Python with Windows 7

2019-09-19 Thread Eko palypse
Am Donnerstag, 19. September 2019 17:52:48 UTC+2 schrieb cdoa...@orange.com: > Hi, > I am no more able to start Python from Windows 7 environment. > I have the following message : > "The Application was unable to start correctly, (0xC142). Click OK to > close the application" > > Do you have

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
No, I have to correct myself x = 5 def f1(): exec("x = x + 1; print('f1 in:', x)") return x print('f1 out', f1()) results in the same, for me confusing, results. f1 in: 6 f1 out 5 Eren -- https://mail.python.org/mailman/listinfo/python-list

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
Am Donnerstag, 19. September 2019 12:56:59 UTC+2 schrieb Peter Otten: > Eko palypse wrote: > > >> Then it should be clear that the name 'test01' is put into globals(), if > >> load_module() doesn't throw an exception. No sharing or nesting of > >> namespaces ta

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
Am Donnerstag, 19. September 2019 12:45:35 UTC+2 schrieb Richard Damon: > On 9/19/19 6:16 AM, Eko palypse wrote: > >> In all cases, if the optional parts are omitted, the code is executed in > >> the current scope. ... > >> > >> > >>

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
> Then it should be clear that the name 'test01' is put into globals(), if > load_module() doesn't throw an exception. No sharing or nesting of > namespaces takes place. Thank you too for your answer. Ok, that means that in every case when exec imports something it has its own global namespace,

Re: exec and globals and locals ...

2019-09-19 Thread Eko palypse
> In all cases, if the optional parts are omitted, the code is executed in the > current scope. ... > > > You can see from it that "globals" is optional. > And that, if "globals" is missing, then > "exec" is executed in the current scope ("f1" in your case). Thank you for your answer, and that

exec and globals and locals ...

2019-09-18 Thread Eko palypse
Why does f1 work? I've expected an exception as no global dict has been provided, and why does throw f3 an exception if it does, more or less, the same as f1? x += 5 def f1(): exec("x += 1; print('f1 in:', x)") return x print('f1 out', f1()) # result => f1 in: 6 # result => f1 out 5

Re: Python3.7 singleton is not unique anymore

2019-09-17 Thread Eko palypse
Shame on me :-) Thank you very much Ethan. -- https://mail.python.org/mailman/listinfo/python-list

Python3.7 singleton is not unique anymore

2019-09-17 Thread Eko palypse
Using the following code in Python3.7 doesn't make FOO to be singleton anymore. import sys class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls._instances: cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)

Re: Metaclasses and classproperties

2019-09-10 Thread Eko palypse
Thank you for your thoughts. I'm trying to migrating en existing python2 api, which has been build using boost::python with pure python3 code. All of the py2 classes do have these additional properties names and values. You are right, using dict(Ordinal.__members__) for names could have been

Metaclasses and classproperties

2019-09-10 Thread Eko palypse
I'm fairly new when it comes to metaclass programming and therefore the question whether the following makes sense or not. The goal is to have two additional class properties which return a dictionary name:class_attribute and value:class_attribute for an IntEnum class and after reading about it I

Re: Color representation as rgb, int and hex

2019-09-09 Thread Eko palypse
> No, constructing a bytes literal from hex digits implies that they > follow the sequence in the string of digits. It's nothing to do with > the endinanness of integers. > ChrisA > Why should it imply that? You're asking it to create some bytes > from a string of hex digits -- no mention of

Re: Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
> ChrisA You are correct, but, sorry for not being clear what confused me. I assumed it would use the sys.byteorder but I guess this is simply a AssumedError exception. :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
> You haven't said whether your machine is big-endian or little-endian. Correct, it is little but I'm wondering why this isn't taking into account. I thought a method called fromhex would imply that bytes for an integer should be created and as that it would use the proper byte order to create

Color representation as rgb, int and hex

2019-09-08 Thread Eko palypse
I'm confused about the following import sys print(tuple(bytes.fromhex('282C34'))) print(tuple((0x282C34).to_bytes(3, byteorder=sys.byteorder))) which results in (40, 44, 52) (52, 44, 40) on my machine. Shouldn't I expect the same result? Thank you Eren --

How to annotate an IntEnum value

2019-09-03 Thread Eko palypse
Suppose the following from enum import IntEnum class ENDOFLINE(IntEnum): CRLF = 0 CR = 1 LF = 2 def get_eol() -> ??: return ENDOFLINE.CRLF def set_eol(eol_value) -> None: pass How should the return value from get_eol be annotated? As ENDOFLINE? The same question for

Re: a,b = 2,3 and [a,b] = [2,3]

2019-09-02 Thread Eko palypse
Am Montag, 2. September 2019 00:49:05 UTC+2 schrieb Hongyi Zhao: > Hi, > > What's differences: > > a,b = 2,3 and [a,b] = [2,3] > > Regards In this example the result is the same but the second one builds, internally, an additional list, therefore isn't as sufficient as the first one. --

Re: Using exec with embedded python interpreter 3.7

2019-09-02 Thread Eko palypse
@MRAB, I'm building a notepad++ plugin which can execute the written code and if one writes help(os) it gets executed via exec(editor.getText()) and output redirected to the plugin console window. Sorry to you as well as I have also replied to you directly. Thank you --

Re: Using exec with embedded python interpreter 3.7

2019-09-02 Thread Eko palypse
Just saw, that I replied to you directly instead to python list, sorry. That did it, changed encoding from function to property and now I'm able to call help(object) Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Using exec with embedded python interpreter 3.7

2019-09-01 Thread Eko palypse
I've already sent this through mail yesterday but it doesn't appear here, maybe because of the help word in the content. Please execute in case it appears a second time. Hello, I'm creating a notepad++ plugin which hosts an embedded python interpreter by using cffi to build the dll. So far so

Using exec with embedded python interpreter 3.7

2019-09-01 Thread Eko palypse
Hello, I'm creating a notepad++ plugin which hosts an embedded python interpreter by using cffi to build the dll. So far so good. One obstacle I've found is that I'm not able to use exec(help(object)) in order to get the wanted info from the object. The error I get is: Traceback (most recent