Hello syphilis,

Why don't you try to get the path and then convert it?

Sample of code:

#!/usr/bin/python import sysconfig sysconfig_output_before = sysconfig._getuserbase() sysconfig_output_after = '\\'.join(sysconfig_output_before.split('/')) print sysconfig_output_before print sysconfig_output_after

Sample of output:

/home/user/PythonVirtualEnvironment/bin/python /home/user/Downloads/Py +thonProject/test.py /home/user/.local \home\user\.local

Update: Maybe also this could help (Windows shell string operations (changing backslash to slash)). I do not have WindowsOS so I can not really test it (sorry).

Update2: I remember many many years ago when I was running WindowsOS I used to use (Cygwin). If I remember correctly it uses forward slashes, again (sorry) I do not have WindowsOS so I can not really test it.

Update3: In your case you have to reverse the parameters of course. I did not mention that before I did not thought that it is necessary.

Update4: I also found (Kernel::System::SysConfig - to manage sys config settings). I do not know if it helps but from the documentation is more or less what sysconfig — Provide access to Python’s configuration information. Just an idea. UnixOS

Update5: I also found (Win32::kernel32). I do not know if it helps but from the documentation: SearchPath can provide you:

1. the directory from which the application loaded. 2. the current directory 3. the Windows system directory 4. the Windows directory 5. the directories in the PATH environment variable

Just an idea and this is for. WindowsOS

Update6: Most likely you have thought about it already but just came into my mind. Why you do not execute your Python script and capture the output and convert it with Perl?

Sample of code:

#!/usr/bin/perl use strict; use warnings; my $path_before = qx(/home/user/Downloads/PythonProject/test.py 2>&1); print "Befofe: " . $path_before; my $path_new = $path_before; $path_new =~ s{/}{\\}g; # Use s/\\/\//g; print "After: " . $path_new; __END__ perl test_2.pl Befofe: /home/user/.local After: \home\user\.local

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: [OT++] Seeking Win32 Python Wisdom by thanos1983
in thread [OT++] Seeking Win32 Python Wisdom by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.