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

  • SEARCH
  • Home
  • 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 1103111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:17:31+00:00 2026-05-17T01:17:31+00:00

I’m trying to take a python class (in IronPython), apply it to some data

  • 0

I’m trying to take a python class (in IronPython), apply it to some data and display it in a grid. The results of the functions become columns on the grid, and I would like the order of the functions to be the order of the columns. Is there a way to determine the order of python functions of a class in the order they were declared in the source code? I’ll take answers that use either IronPython or regular python.

So for instance, if I have a class:

class foo:
    def c(self):
        return 3
    def a(self):
        return 2
    def b(self):
        return 1

I would like to (without parsing the source code myself) get back a list of [c, a, b]. Any ideas?

As a caveat, IronPython used to keep the references of functions in the order they declared them. In .NET 4, they changed this behavior to match python (which always lists them in alphabetical order).

  • 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-05-17T01:17:32+00:00Added an answer on May 17, 2026 at 1:17 am

    In Python 2.X (IronPython is currently on Python 2) the answer is unfortunately no. Python builds a dictionary of the class members before creating the class object. Once the class is created there is no ‘record’ of the order.

    In Python 3 metaclasses (which are used to create classes) are improved and you can use a custom object instead of a standard dictionary to collect class members as the class is built. This allows you to know the order.

    However, for IronPython there is a hack that might work. Python dictionaries are inherently unordered – i.e. iterating over the members of a dictionary returns them in an arbitrary (but stable) order. In IronPython it used to be the case that, as an accident of implementation, iteration would return members in the order they were inserted. (Note that this may no longer be the case.)

    You could try:

     members = list(c.__dict__) # or c.__dict__.keys()
    

    You may find that this is ordered as you hope for. Unfortunately running the code under different versions of IronPython (or other implementations of Python) is likely to return them in a different order.

    Another (better but harder) approach is to use the ast module (or the IronPython parser) and walk the AST to find the entries. Not very hard, but more work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have some data like this: 1 2 3 4 5 9 2 6
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 have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
In my XML file chapters tag has more chapter tag.i need to display chapters

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.