Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47574
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-06-10 08:37 -0700 |
| Message-ID | <c854d114-bcfa-4491-8a4a-a377998bdf0e@googlegroups.com> (permalink) |
| Subject | Questions on "import" and "datetime" |
| From | Yunfei Dai <yunfei.dai.sigma@gmail.com> |
Hi all, I have some questions on "import": 1."from datetime import datetime" works well. But I am confused why "import datetime.datetime" leads to importerror. "from xlrd import open_workbook" could be replaced by "from xlrd.open_workbook" without any problem. The only difference here is that if "from xlrd import open_workbook" is used we do not have to write "xlrd.open_workbook" in the following code but just "open_workbook". So my understanding of the difference is "from...import..." shortens the code (just like "using namespace std" in C++) but maybe leads to name clash. But what is the problem of datetime? 2.I am also comfused that "datetime.datetime" is a function but whithin "datetime.datetime" there are lots of other functions. So what is the type of "datetime.datetime" on earth? is it a function, or a class or a folder(library) here? Thanks very much in advance! Very looking forward to your answers. Best, Yunfei
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Questions on "import" and "datetime" Yunfei Dai <yunfei.dai.sigma@gmail.com> - 2013-06-10 08:37 -0700
Re: Questions on "import" and "datetime" Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-06-10 12:01 -0500
Re: Questions on "import" and "datetime" Yunfei Dai <yunfei.dai.sigma@gmail.com> - 2013-06-12 03:29 -0700
Re: Questions on "import" and "datetime" Dave Angel <davea@davea.name> - 2013-06-10 15:10 -0400
Re: Questions on "import" and "datetime" Yunfei Dai <yunfei.dai.sigma@gmail.com> - 2013-06-12 03:41 -0700
csiph-web