C#
C#

help

Root Question Message

Core Dream Studios
Core Dream Studios10/30/2022
Need Python to C Sharp Conversion

```
Summary:
Trying to port a CRC32 lib Martin Scharrer created in Python, I see no known C# version and I am barely a Python dev.

Sources:
https://github.com/MartinScharrer/crccheck/blob/main/crccheck/crc.py
https://github.com/MartinScharrer/crccheck/blob/main/crccheck/checksum.py


I do have the crc.py, I will add it to this post if anyone can give me a clue.

I appreciate you so much and yes I'd include his license and credit. 🙂
zonedetec
zonedetec10/30/2022
zonedetec
zonedetec10/30/2022
what about executing python code from c#, because what you are asking seems quiet difficult
Core Dream Studios
Core Dream Studios10/30/2022
Yeah my issue is I do not know python enough to convert
Core Dream Studios
Core Dream Studios10/30/2022
I found this site, but the output is sloppy and doesn't even work, probably AI based.: https://pythoncsharp.com/
Core Dream Studios
Core Dream Studios10/30/2022
I could call python from C# but I need all the return values etc.
zonedetec
zonedetec10/30/2022
please then change your post title as "Executing python function and gets their return value" so more people can help you. This is something I've never done but it is definitely possible
Core Dream Studios
Core Dream Studios10/30/2022
Was hoping to port it to native C# and still keep the license under him (did email)
Core Dream Studios
Core Dream Studios10/30/2022
but if needed, will change title
zonedetec
zonedetec10/30/2022
sure
zonedetec
zonedetec10/30/2022
do you need all the python function or just some of them?
Core Dream Studios
Core Dream Studios10/30/2022
well whatever is in the .py's to do all those checks, pretty much
Core Dream Studios
Core Dream Studios10/30/2022
i wish i knew python enough to figure it out 😦
zonedetec
zonedetec10/30/2022
even if you knew python you wouldn't want to convert 2205 python lines into c# I guess
Core Dream Studios
Core Dream Studios10/30/2022
I tried so far:
Core Dream Studios
Core Dream Studios10/30/2022
well via that website converter
Core Dream Studios
Core Dream Studios10/30/2022
Core Dream Studios
Core Dream Studios10/30/2022
but it's a mess so far lol
Core Dream Studios
Core Dream Studios10/30/2022
and nothing works from conversion
Core Dream Studios
Core Dream Studios10/30/2022
ok
Ero
Ero10/30/2022
?
zonedetec
zonedetec10/30/2022
there's a problem with that website : because python does not use any type things (ie. x could be a string, then a int, then an array), the website put all variable as "object"
Core Dream Studios
Core Dream Studios10/30/2022
sec
Core Dream Studios
Core Dream Studios10/30/2022
yeah i saw that too
Core Dream Studios
Core Dream Studios10/30/2022
Does this do what all those .py libs do?
Ero
Ero10/30/2022
how should i know
Ero
Ero10/30/2022
test it
Core Dream Studios
Core Dream Studios10/30/2022
yeah good point XD
Core Dream Studios
Core Dream Studios10/30/2022
thanks
Core Dream Studios
Core Dream Studios10/30/2022
this might just be enough to do it, well minus the checksum part but i can figure it out if i try hard enough. 🙂
Core Dream Studios
Core Dream Studios10/30/2022
question 2
Core Dream Studios
Core Dream Studios10/30/2022
python to C#
Core Dream Studios
Core Dream Studios10/30/2022
since this one has no native C# library, doing by hand:
Core Dream Studios
Core Dream Studios10/30/2022
Converted:
Core Dream Studios
Core Dream Studios10/30/2022
  public static object intersperse(object lst, object item) {
            var result = new List<object> {
                item
            } * (lst.Count * 2 - 1);
            result[0:2:] = lst;
            return result;
        }
Core Dream Studios
Core Dream Studios10/30/2022
What is [0:2:] ?
Core Dream Studios
Core Dream Studios10/30/2022
was in .py too
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy