Giter Club home page Giter Club logo

Comments (7)

stevengj avatar stevengj commented on May 16, 2024

I would prefer to use the Julian syntax here (when in Rome...): @pyimport numpy: zeros, array, fromtxt etcetera.

from pycall.jl.

hammer avatar hammer commented on May 16, 2024

+1 been laboring with multi-line import statements due to lack of this feature.

from pycall.jl.

stevengj avatar stevengj commented on May 16, 2024

I'm a little worried about namespace conflicts. If I implement @pyimport numpy: zeros for example, by setting const zeros = pyimport("numpy")[:zeros], then I will overwrite the built-in Julia zeros function. It seems safer just to require you to call numpy.zeros(...).

@hammer, can you give a concrete example where this would be important to you?

from pycall.jl.

marius311 avatar marius311 commented on May 16, 2024

Obviously this is 2 years old, but maybe something has changed since then that warrants adding this? I think it'd be a great feature. I don't have concrete examples to add, just to say that obviously it would allow writing more concise easier-to-read code in many cases.

As for overwriting, once I've written @pyimport numpy: zeros doesn't that mean I want the overwriting to happen? Its not like it'd be unexpected in some way.

from pycall.jl.

stevengj avatar stevengj commented on May 16, 2024

Honestly, I'm thinking of getting rid of @pyimport completely, and telling people to just do numpy = pyimport("numpy"). The reason is that it is confusing that you can use . to get the members of a @pyimport module, but for everything else you need foo[:bar].

You can still just do z = pyimport("numpy")[:zeros], so a Pythonic syntax doesn't actually give you any new functionality.

from pycall.jl.

cstjean avatar cstjean commented on May 16, 2024

I would prefer to use the Julian syntax here (when in Rome...): @pyimport numpy: zeros, array, fromtxt etcetera.

I implemented it in ScikitLearn:

using ScikitLearn.Skcore: @pyimport2
@pyimport2 scipy.ndimage: (gaussian_filter, fourier_uniform)

but I struggled to get the hygiene right. I can make a PR for it if there is interest.

Honestly, I'm thinking of getting rid of @pyimport completely, and telling people to just do numpy = pyimport("numpy").

-1 for me, that would get tiring.

from pycall.jl.

marius311 avatar marius311 commented on May 16, 2024

Thanks guys, yea @pyimport2 is exactly what I'm looking for, helpful to know that's there.

Re: removing @pyimport completely, its true its slightly inconsistent that you get to use the dot notation for the first level, but honestly as a user that was pretty easy to figure out from skimming your docs and trying a few simple examples. For me it'd seem to be sacrificing too much convenience in the name of consistency. My own +1, as you could probably guess, would instead be incorporating the @pyimport2 functionality into PyCall.

from pycall.jl.

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.