Basically what ls() does in r is that it is used to list the names of all the objects that are present in the working directory. I want to do the same in python, could someone please help me with this ? I'm a python newbie ;-;
            Asked
            
        
        
            Active
            
        
            Viewed 376 times
        
    1
            
            
        - 
                    `ls()` lists the objects in its current *environment*. Unless specified otherwise this is your "workspace". It does *not* list the *working directory*, for which you use `dir()`. Do you want a Python equivalent for the former or latter method (the latter being `dir()` in Python AFAIK). – May 07 '22 at 17:12
- 
                    I'd like a python code for the former please – kabir123123123 May 07 '22 at 20:51
- 
                    That should be `dir()` or some object-specific approaches: https://stackoverflow.com/questions/62686644/python-find-current-objects-in-memory#62686771 – May 08 '22 at 06:18
1 Answers
1
            
            
        you can use os.listdir()
import os
print(os.listdir('.')) # here '.' for current directory.
 
    
    
        codester_09
        
- 5,622
- 2
- 5
- 27
