import sqlite3

2009-06-03 Thread willgun
Hi,everyone!
When i run the following in IDLE:
IDLE 2.6.1
>>> import sqlite3
>>> con =sqlite3.connect (r'g:\db1')
>>>
everything goes well,but when i save these to a .py file and run it:

>>>
Traceback (most recent call last):
  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 2, in 
import sqlite3
  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in 
con=sqlite3.connect(r'g:\db1')
AttributeError: 'module' object has no attribute 'connect'

Anyone can tell me why?
Thanks first!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-03 Thread willgun

Gabriel Genellina 写道:

En Thu, 04 Jun 2009 02:15:39 -0300, willgun  escribió:


Traceback (most recent call last):
  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 2, in 
import sqlite3
  File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in 
con=sqlite3.connect(r'g:\db1')
AttributeError: 'module' object has no attribute 'connect'

Anyone can tell me why?


Your own script is named sqlite3, right? When you execute "import 
sqlite3" you end up importing your own script, not the library module...



Thanks,I am quiet surprised to be applied so soon.
--
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-03 Thread willgun

Andrew McNamara 写道:


On 04/06/2009, at 3:15 PM, willgun wrote:


When i run the following in IDLE:
IDLE 2.6.1

import sqlite3
con =sqlite3.connect (r'g:\db1')


everything goes well,but when i save these to a .py file and run it:




Traceback (most recent call last):
 File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 2, in 
   import sqlite3
 File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in 
   con=sqlite3.connect(r'g:\db1')
AttributeError: 'module' object has no attribute 'connect'

Anyone can tell me why?


What did you call the .py file? sqlite3.py? If so, you've just imported 
your own module again. 8-)


After the import, try "print sqlite3.__file__", which will tell you 
where the module came from.

Thank you all the same.
I'm a student from China.It's painful for us to read python 
documentation entirely due to poor english.So I often make these mistakes.

--
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-04 Thread willgun

Andrew McNamara 写道:


On 04/06/2009, at 4:14 PM, willgun wrote:

What did you call the .py file? sqlite3.py? If so, you've just 
imported your own module again. 8-)
After the import, try "print sqlite3.__file__", which will tell you 
where the module came from.



Thank you all the same.
I'm a student from China.It's painful for us to read python 
documentation entirely due to poor english.So I often make these 
mistakes.


Don't worry - even experienced Python coders get caught by this one. 
Just remember the "print module.__file__" trick for next time something 
odd happens.


When you import a module in python, it is only imported the first time 
you request it (which is why your import did not become recursive and 
raise an error).
I know it well now.Thanks.It seems that the mailing list is much greater 
than most forums in China.

--
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-04 Thread willgun

By the way ,what does 'best regards' means at the end of a mail?
--
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-05 Thread willgun

Mark Tolonen 写道:


"willgun"  wrote in message 
news:[email protected]...

By the way ,what does 'best regards' means at the end of a mail?


I think 恭祝 may be a good translation.

-Mark



O(∩_∩)O谢谢
Glad to meet a foreigner know Chinese, :-) .
But in my opinion,恭祝 means congratulation,while 恭 means best regards.
--
http://mail.python.org/mailman/listinfo/python-list


Re: import sqlite3

2009-06-05 Thread willgun

Gabriel Genellina 写道:

En Thu, 04 Jun 2009 03:14:18 -0300, willgun  escribió:

I'm a student from China.It's painful for us to read python 
documentation entirely due to poor english.So I often make these 
mistakes.


Try "chinese python group" at Google - I see some promising results at 
least...



Good idea.
But I try to improve my english via visiting english ones.
15 days later,I'll go up for my english examination.
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the total size of a local hard disk?

2009-06-15 Thread willgun

Unfortunately,I'm on win32.
Actually,I prefer a cross-platform method.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


How to get the total size of a local hard disk?

2009-06-15 Thread willgun
Hi,everyone!

How to get the total size of a local hard disk?
I mean total size,not free space.

Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list