Prev: Struggling to convert a mysql datetime object to a python stringof a different format
Next: How to read large amounts of output via popen
From: Navkirat Singh on 6 Aug 2010 01:14 Hi guys, I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? Regards, Nav
From: Navkirat Singh on 6 Aug 2010 01:41 On 06-Aug-2010, at 10:44 AM, Navkirat Singh wrote: > Hi guys, > > I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? > > Regards, > Nav Thanks. I got it. I just put an empty __init__.py file in the subdirectories and it worked.
From: Ralf Schoenian on 6 Aug 2010 02:05 Navkirat Singh wrote: > Hi guys, > > I am new to python and would like to import certain classes in sub-directories of the working directory. I was wondering how will I be able to achieve this? > > Regards, > Nav Hi, put an empty file with the name __init__.py in your subdirectory. I call it sub1 here. Assuming your filename is importme.py and your classname is Test you can do the following imports: from sub1.importme import Test import sub1.importme You can find further explainations in the official tutorial http://docs.python.org/tutorial/modules.html Regards, Ralf
From: 夏震 on 6 Aug 2010 03:43 > Hi guys, > > I am new to python and would like to import certain classes in sub-directories of the > working directory. I was wondering how will I be able to achieve this? > > Regards, > Nav > -- > http://mail.python.org/mailman/listinfo/python-list > Please try "touch __init__.py" in sub-directories.
From: Navkirat Singh on 6 Aug 2010 09:15
On 06-Aug-2010, at 1:13 PM, å¤é wrote: > > >> Hi guys, >> >> I am new to python and would like to import certain classes in sub-directories of the >> working directory. I was wondering how will I be able to achieve this? >> >> Regards, >> Nav >> -- >> http://mail.python.org/mailman/listinfo/python-list > >> > > Please try "touch __init__.py" in sub-directories. > > > -- > http://mail.python.org/mailman/listinfo/python-list Thanks, that worked : ) |