Difference between C# ToString and python __str__ for lists

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, python
Domain
tooling

Research direction

The issue concerns ansys-pythonnet's conversion of C# arrays and List objects when exposed to Python; no files, tests, or entry points are named. Start by locating the collection string-conversion path and compare CPython's list behavior with IronPython's str. Done means an explicit option produces the requested Python-style output for both arrays and List objects without changing the default behavior.

Written by the indexing model from the issue text.

Description

In python, if you have a list and you convert it to string via str(my_list), it will print out the entire list.
With C#, calling .ToString() on either an array or a List object will just print out that it is a list.

This leads to a difference in behavior between APIs exposed via CPython and APIs exposed by IronPython. With IronPython, a python list is internally a C# List, but it's __str__ method matches the behavior of a python list.

There should be an option in ansys-pythonnet to provide pythonic string conversions for C# collections.

Dominant language
C#
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ansys/ansys-pythonnet

All issues in ansys/ansys-pythonnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.