Jump to content

IanH9999

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

1 Neutral
  1. IanH9999

    PPyObject V's Variant

    I'm finding that to use the various functions and procedures within the library I'm having to convert between instances of PPyObject and Variants a lot, but I have no idea why. I can see that the VarPyth.pas header states that that it allows you to use Python objects like COM automation objects, but I'm having trouble understanding the relationship between the two. For example, when calling BuiltInModule.setattr why do I need to pass a Variant rather than a PPyObject?
  2. IanH9999

    vars function within Delphi

    Hello and thanks for your help. Unfortunately I'm still a bit stuck 😞 I'm not sure how the Custom Variant is used. I can't find any example it in the P4D examples. I've also had a good look in the PyScripter source in case it's used there, but I couldn't find usage of it. I did find usage of the BuiltinModule in there which has helped. In my naivety, I was hoping it was going to be something like... function TForm1.spam_foo(pself, args : PPyObject) : PPyObject; cdecl; var v : Variant; begin with GetPythonEngine do begin for v in BuiltinModule.vars(args) do begin ... but it's obviously more complex than this. I assume the function "PyObjectAsVariant" isn't going to help out here is it? I've had a look for info on TCustomVariant as I'm not familiar with it but there doesn't seem to be much written about it. The information in the Embarcadero help file is difficult to relate to using it in this context. (I'm using XE5 in case that makes any difference) Ian
  3. IanH9999

    Wrong version required at runtime

    Hello Do the instructions here help? https://github.com/pyscripter/python4delphi/wiki/FindingPython Ian
  4. IanH9999

    vars function within Delphi

    Hello I've just started using Python4Delphi after watching the excellent videos by Kiriakos and Jim. Huge potential, but with a steep learning curve ! I've got the following python code that takes an object and prints it's attributes: def outputClassInfo(anObject): for att_name in vars(anObject): anAttr = getattr(anObject,att_name) print (att_name,anAttr.__class__) I'm trying to repeat this function in Delphi by adapting demo6 (adding a delphi method to module), but I'm really struggling as I can't find the equivalent of the "vars" function. Am I going about this the right way? I've trying using the debugger to examine the content of anObject but can't find anything in there either? Thanks for any help... Ian
×