Re: Re: More on the simple Gibbs sampler shootout
2012-05-18 22:24:45 GMT
Well, that's sort of what I was talking about before. For programmatic usage, I think it makes more sense to have an iterator that provides all the items in a directory in streamed fashion, using opendir/readdir/closedir. For now just printing them is easy and does what Kevin and Joaquim wanted. The advanced approach is along the lines of what I outlined before, having ls return a Dir object that can be iterated or shown by listing the files in it.
For my purposes, it would be nice if ls() returned the results of running ls rather than printing them out.-- JohnOn May 18, 2012, at 5:37 PM, Stefan Karpinski wrote:Done.On Fri, May 18, 2012 at 4:54 PM, Kevin Squire <kevin.squire-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:I'm not looking for directories or files to be types, but having shell-like command at a repl I do find quite useful. In Matlab (before the gui days, and even after), I would use "ls" all the time, and do so frequently in other repls when available. When it's not, I miss it. But maybe that's just me.
On Friday, May 18, 2012 10:59:32 AM UTC-7, Stefan Karpinski wrote:I dunno about this. Is the aim here to turn the repl into a shell? Because having it behave as a human-friendly shell versus having it behave in a programming-friendly manner are very different. If you want something shell-like, then you'll want `ls()` to print a list of files. If you're programming, you'd want something more like `for file in ls() ... end`, which is pretty different. The two could maybe be made to play well together, if, for example ls()/dir() returns a Dir() object that displays like the ls command would, but is also iterable, yielding a File() object for each iteration (not an opened file, mind you, but an object representing a file in the abstract, which could then be opened and such). This starts getting pretty OO-ish. I kind of like my APIs to be simpler: why introduce types for directories and files when they can just be strings?On Fri, May 18, 2012 at 1:52 PM, Kevin Squire <kevin.squire-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
On Friday, May 18, 2012 5:52:37 AM UTC-7, J Luis wrote:Sexta-feira, 18 de Maio de 2012 12:22:12 UTC+1, John Myles White escreveu:I'd like cd() and cwd() or even pwd().and ls(), dir(). (with the wild cards)Joaquim+1 to all of the above. This is something that irks me about python (but the ipython shell got right).Kevin