Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:12:47+00:00 2026-06-06T17:12:47+00:00

I’m trying to write C# code with an embedded IronPython script. Then want to

  • 0

I’m trying to write C# code with an embedded IronPython script. Then want to analyze the contents of the script, i.e. list all variables, functions, class and their members/methods.

There’s an easy way to start, assuming I’ve got a scope defined and code executed in it already:

dynamic variables=pyScope.GetVariables();
foreach (string v in variables)
{
    dynamic dynamicV=pyScope.GetVariable(); /*seems to return everything. variables,     functions, classes, instances of classes*/
}

But how do I figure out what the type of a variable is? For the following python ‘objects’,

dynamicV.GetType() 

will return different values:

x=5 –system.Int32

y=”asdf” –system.String

def func():… –IronPython.Runtime.PythonFunction

z=class() — IronPython.Runtime.Types.OldInstance, how can I identify what the actual python class is?

class NewClass — throws an error, GetType() is unavailable.

This is almost what I’m looking for. I could capture the exception thrown when unavailable and assume it’s a class declaration, but that seems unclean. Is there a better approach?

To discover the members/methods of a class it looks like I can use:

ObjectOperations op = pyEngine.Operations;
object instance = op.Call("className");
foreach (string j in op.GetMemberNames("className"))
{
    object member=op.GetMember(instance, j);
    Console.WriteLine(member.GetType());
    /*once again, GetType() provides some info about the type of the member, but returns null sometimes*/
}

Also, how do I get the parameters to a method?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:12:50+00:00Added an answer on June 6, 2026 at 5:12 pm

    This isn’t something that’s really supported, but all of the information is there. You have two options:

    1. Cast the objects to IronPython’s classes, like PythonFunction, and use the methods on them. These aren’t documented, and all of the necessary methods might not be public, but you can read the source code to figure out how to use them.
    2. Use the normal Python techniques for introspection, like __class__ and __dict__. This is probably the better option.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.