Giter Club home page Giter Club logo

Comments (3)

daren-thomas avatar daren-thomas commented on July 18, 2024

never use os.cwd for finding paths! this depends on where you started the script. instead, you can find the folder including the script like this:

src_folder = os.path.dirname(__file__)

And then use os.path.join(...) to create the paths. You can add relative paths using the .. special folders to indicate "parent-directory".

from hive.

JustinZarb avatar JustinZarb commented on July 18, 2024

Thanks for your reply Daren! I decided to put it in the grasshopper Libraries folder, which is where some other components put their .dll files. This should avoid the need to move the .dll file to the working directory. Your thoughts?

clipper_path = os.getenv('APPDATA')+'\Grasshopper\Libraries\clipper_library.dll'

from hive.

daren-thomas avatar daren-thomas commented on July 18, 2024

It's a bug:

  • don't concatenate strings to create paths. Use os.path.join.
    • actually, I mentioned that above...
  • don't use backslashes (without escaping them) in string literals
    • unless you're using the "raw" strings: r'\Grasshopper\Libraries\clipper_library.dll'. Note the r at the beginning of the string? This tells python not to view the backslash as an escaping character. You just got lucky here. If any of the characters following the backslash had been one of those used in an escape sequence, you would not have gotten the result you expected.
  • why didn't you keep the dll relative to the script? now it's harder to install your software, as you can't just "copy paste". also, you now have to figure out how to package it when publishing for pip install.
  • your code is now hardcoded to look for the dll in the user's APPDATA folder - that means, it is now not possible to install the software for all users. This is a mistake I have made too with my RPS software.

The line should read:

clipper_path = os.path.join(os.getenv('APPDATA'), 'Grasshopper', 'Libraries', 'clipper_library.dll')

from hive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.