-
Content Count
1020 -
Joined
-
Last visited
-
Days Won
66
Posts posted by pyscripter
-
-
I think this has to do with the default encoding of the pipe stdout. Python uses utf8, however since the script is run from a Delphi program it may inherit the encoding from the parent process. Just a guess.
-
uses VarPyth; ... var Res, S: string; PythonEngine1.ExecStrings(sl); Res := MainModule.Parser(S);
It would help to watch the tutorial videos and play with the Demos.
-
2
-
-
34 minutes ago, djxandytche said:create a singleton for the TPythonModule and TPyDelphiWrapper classes
A single TPythonModule and TPyDelphiWrapper should do.
34 minutes ago, djxandytche said:Wouldn't this cause problems with multi-threads since the DataSnap server can receive several requests at the same time?
Running python code in threads is quite complex. See PythonThreads · pyscripter/python4delphi Wiki (github.com) for details.
-
Why create/destroy/recreate the PythonModule and PythonWrapper instead of reusing them?
To avoid the finalization of the PythonEngine keep at least one client alive.
-
Do you have the appropriate python lib in your system?
eg.
See also the replies in Getting started with Ubuntu 18.04. Error Could not open DLL - Python4Delphi - Delphi-PRAXiS [en] (delphipraxis.net)
I would try first to run a console app and when this works then try an FMX app.
-
2 hours ago, JGMS said:The code line "if PyBytes_AsStringAndSize(presult, P, Len) < 0
I meant call CheckError before that.
-
Also have a look at Demo 35 to see how you transfer arrays and array-like objects from Python to Delphi using the buffer protocol.
-
Add some error checking after the call.
GetPythonEngine.CheckError;
What is the error you are getting?
It might help to post a minimal project.
-
4 minutes ago, PeaShooter_OMO said:How would copy and paste work?
It is explained in the link to CudaText I gave above.
-
All modern code editors have multi-select and multi-caret functionality (Visual Studio, VS-Code, Scintilla, Atom etc.). Also the freepascal CudaText. See CudaText - Free Pascal wiki for how it works. Very useful.
I am currently working to add this to SynEdit.
-
5
-
1
-
-
The sample code above uses VarPyth for high level access to python objects.
MainModule is custom variant wrapping the __main__ python module. Unless you provide optional parameters to ExecStrings, the code is executed in the context of the __main__ module.
-
1
-
1
-
-
How about?
var SL := TStringList.Crete; try SL.LoadFromFile('example.py'); PyEngine.ExecStrings(SL); var Res := MainModule.DoExample('input'); finally SL.Free; end;
-
1
-
-
On 12/29/2023 at 12:11 PM, delphivi said:Hello, Yes, I have read it
Are you calling SetPythonHome, as suggested in that page?
On 12/29/2023 at 12:11 PM, delphivi said:SetExceptionMask(exAllArithmeticExceptions);
Have you tried
MaskFPUExceptions(True)
instead?
Is the Conda Library\bin subdirectory in the system path? If not try adding it.
-
Have you read FindingPython · pyscripter/python4delphi Wiki (github.com) regarding Conda? Is the DLLs subdirectory in the environment path?
-
57 minutes ago, MarkShark said:Thanks! Is using Searchbuf (unfortunately with the $if to fix this issue) ok to use as a solution to the SynEdit search engine issue I've been working on? Otherwise, we'd need a reverse version of the current "Next" function which looks like it might be a Boyer-Moore implementation?
Please open an issue and describe the problem. Using SearchBuf should be OK.
-
35 minutes ago, MarkShark said:Also is there a way to do an ifdef specific to 11.2?
See
-
1
-
-
-
Please submit an issue to the relevant repo. I would expect that simply recompiling the component source with Delphi 12 should work.
-
1 hour ago, Vandrovnik said:Will you be able do print/export with TDirect2dCanvas?
The Direct2D way of printing is to use the ID2D1PrintControl interface (Printing and command lists - Win32 apps | Microsoft Learn). You can look at SynEdit/Source/SynEditPrint.pas at master · pyscripter/SynEdit (github.com) for how this works.
-
Features missing in the Delphi editor:
-
Proper Unicode handling
. It does not even support combining characters.
- Multi-cursor/selection editing
- Modification (track changes) bar that works with undo.
- Accessibility support
- Drag & drop editing
- triple and quadruple click support
- double/triple click and drag support
- Enhanced scroll bar as in VS Code
- ...
-
2
-
Proper Unicode handling
-
-
Here is a lock-free implementation for your FHIROperationFactory function.
var SingletonFHIROperationFactory : IFHIROperationFactory function FHIROperationFactory: IFHIROperationFactory; var LFHIROperationFactory: IFHIROperationFactory; begin if SingletonFHIROperationFactory = nil then begin LFHIROperationFactory := TFHIROperationFactory.Create; if InterlockedCompareExchangePointer(Pointer(SingletonFHIROperationFactory), Pointer(LFHIROperationFactory), nil) = nil then SingletonFHIROperationFactory._AddRef; end; Result := SingletonFHIROperationFactory; end;
Delphi does something similar in some places.
-
2 hours ago, fastbike said:if the first thread called TMonitor.Enter(Self) on the object would that prevent another thread from making the same call to the object before TMonitor.Exit(Self) had been called by the first thread.
Indeed. This is the whole purpose of locking.
-
The Embarcadero fork of P4D, is often ahead of the PyScripter repo, but it is currently behind. Its main focus is the generation of the delphivcl and delphifmx extension modules as well as Android support. The two repos are synced regularly. I am only responsible for the pyscripter P4D home repo. In most cases it does not matter which one you use.
RegExpressions and preUnGreedy
in RTL and Delphi Object Pascal
Posted · Edited by pyscripter
See the record helpers in https://github.com/pyscripter/Pcre-Jit-Delphi/blob/master/Demos/benchmark.dpr and the methods SetAdditionalPCREOptions