Skip to content

foreach over dynamic PyObject #1680

@CodingMadness

Description

@CodingMadness

Environment

  • Pythonnet version: 3.0.0
  • Python version: 3.9.5
  • Operating System: windows 10
  • .NET Runtime: .NET 6

Details

  • Describe what you were trying to get done.

  • foreach a tuple at runtime via "dynamic" keyword

  • What commands did you run to trigger this issue? If you can provide a
    [Minimal, Complete, and Verifiable example] (http://stackoverflow.com/help/mcve)
    this will help us understand the issue.
    `
    dynamic sys = Py.Import("sys");
    dynamic path2 = sys.path;

    foreach (PyObject item in path2)
    {
    Console.WriteLine(item);
    }
    `

  • If there was a crash, please include the traceback here.

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: "Cannot implicitly convert type 'Python.Runtime.PyObject' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy