Re: [Python-ideas] Class autoload

2018-03-05 Thread Ethan Furman
On 03/03/2018 10:46 AM, Jamesie Pic wrote: While i understand it would be harder to make it memory efficient, but this is python not go, and also this sort feature could be easily optional, also, it might even help against circular import issues, whoever hasn't imported a module from inside a

Re: [Python-ideas] Class autoload

2018-03-04 Thread Nick Coghlan
On 4 March 2018 at 03:42, Chris Angelico wrote: > On Sun, Mar 4, 2018 at 4:12 AM, Jamesie Pic wrote: > > > > Hello everybody, > > > > I thought perhaps we could allow the usage of a "new" keyword to > instanciate > > an object, ie: > > > >obj = new yourmodule.YourClass() > > > > In this case

Re: [Python-ideas] Class autoload

2018-03-04 Thread Stephen J. Turnbull
Jamesie Pic writes: > obj = new yourmodule.YourClass() I don't understand what this is good for. Keeping up with PHP is not something that is a goal for Python. Borrowing useful features is definitely an idea, but you need to explain why it's useful. I also don't understand why you call this

Re: [Python-ideas] Class autoload

2018-03-03 Thread Cameron Simpson
On 03Mar2018 19:46, Jamesie Pic wrote: While i understand it would be harder to make it memory efficient, but this is python not go, and also this sort feature could be easily optional, also, it might even help against circular import issues, whoever hasn't imported a module from inside a functi

Re: [Python-ideas] Class autoload

2018-03-03 Thread Steven D'Aprano
On Sat, Mar 03, 2018 at 06:12:06PM +0100, Jamesie Pic wrote: > Hello everybody, > > I thought perhaps we could allow the usage of a "new" keyword to > instanciate an object, ie: > >obj = new yourmodule.YourClass() > > In this case, it would behave the same as from yourmodule import YourClass;

Re: [Python-ideas] Class autoload

2018-03-03 Thread Nathaniel Smith
On Sat, Mar 3, 2018 at 9:12 AM, Jamesie Pic wrote: > > Hello everybody, > > I thought perhaps we could allow the usage of a "new" keyword to instanciate > an object, ie: > >obj = new yourmodule.YourClass() > > In this case, it would behave the same as from yourmodule import YourClass; > obj =

Re: [Python-ideas] Class autoload

2018-03-03 Thread Steven D'Aprano
On Sat, Mar 03, 2018 at 02:33:36PM -0500, Terry Reedy wrote: > def autoload(mod, cls, *args, **kwargs): > from mod import cls > return cls(*args, **kwargs) > > obj = autoload(yourmodule, YourClass) That won't work unless yourmodule and YourClass have already been imported, since you'll

Re: [Python-ideas] Class autoload

2018-03-03 Thread Greg Ewing
Jamesie Pic wrote: obj = new yourmodule.YourClass() This would also eliminate the need to manage an import list at the beginning of a script in most case. I like the fact that I can usually tell what modules a module depends on by looking at the top for import statements. If people were

Re: [Python-ideas] Class autoload

2018-03-03 Thread Terry Reedy
On 3/3/2018 2:33 PM, Terry Reedy wrote: On 3/3/2018 12:12 PM, Jamesie Pic wrote: Hello everybody, I thought perhaps we could allow the usage of a "new" keyword to instanciate an object, ie:     obj = new yourmodule.YourClass() In this case, it would behave the same as from yourmodule impor

Re: [Python-ideas] Class autoload

2018-03-03 Thread Terry Reedy
On 3/3/2018 12:12 PM, Jamesie Pic wrote: Hello everybody, I thought perhaps we could allow the usage of a "new" keyword to instanciate an object, ie:    obj = new yourmodule.YourClass() In this case, it would behave the same as from yourmodule import YourClass; obj = YourClass(), except t

Re: [Python-ideas] Class autoload

2018-03-03 Thread Rob Cliffe via Python-ideas
On 03/03/2018 17:38, Eric V. Smith wrote: I'd just do:     import yourmodule     obj = yourmodule.YourClass() Or as one line, if that's your thing:     import yourmodule; obj = yourmodule.YourClass() Which is     More transparent: it's evident what the imported module is used for.     More m

Re: [Python-ideas] Class autoload

2018-03-03 Thread Jamesie Pic
While i understand it would be harder to make it memory efficient, but this is python not go, and also this sort feature could be easily optional, also, it might even help against circular import issues, whoever hasn't imported a module from inside a function in their life may throw the first rock

Re: [Python-ideas] Class autoload

2018-03-03 Thread Chris Angelico
On Sun, Mar 4, 2018 at 4:12 AM, Jamesie Pic wrote: > > Hello everybody, > > I thought perhaps we could allow the usage of a "new" keyword to instanciate > an object, ie: > >obj = new yourmodule.YourClass() > > In this case, it would behave the same as from yourmodule import YourClass; > obj =

Re: [Python-ideas] Class autoload

2018-03-03 Thread Eric V. Smith
On 3/3/2018 12:12 PM, Jamesie Pic wrote: Hello everybody, I thought perhaps we could allow the usage of a "new" keyword to instanciate an object, ie:    obj = new yourmodule.YourClass() I'd just do: import yourmodule obj = yourmodule.YourClass() Or as one line, if that's your thi

[Python-ideas] Class autoload

2018-03-03 Thread Jamesie Pic
Hello everybody, I thought perhaps we could allow the usage of a "new" keyword to instanciate an object, ie: obj = new yourmodule.YourClass() In this case, it would behave the same as from yourmodule import YourClass; obj = YourClass(), except that it wouldn't need to be imported. This would