import sqlite3

W

willgun

Hi,everyone!
When i run the following in IDLE:
IDLE 2.6.1everything 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 <module>
import sqlite3
File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in <module>
con=sqlite3.connect(r'g:\db1')
AttributeError: 'module' object has no attribute 'connect'

Anyone can tell me why?
Thanks first!
 
G

Gabriel Genellina

Traceback (most recent call last):
File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 2, in <module>
import sqlite3
File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in <module>
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...
 
A

Andrew McNamara

When i run the following in IDLE:
IDLE 2.6.1
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 <module>
import sqlite3
File "C:\Users\hp\Desktop\SQLite3\sqlite3.py", line 3, in <module>
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. :cool:

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

willgun

Andrew McNamara 写é“:
What did you call the .py file? sqlite3.py? If so, you've just imported
your own module again. :cool:

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.
 
A

Andrew McNamara

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).
 
W

willgun

Andrew McNamara 写é“:
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.
 
A

Andrew McNamara

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

The correspondent is wishing you well. You'll also see things like
"kind regards", "best wishes" and so on. "Regard" essentially means
respect.
 
P

pdpi

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

"regard" means roughly "care".

Its use as "best regards" closing a letter (or, in this case, email),
means that you care for the person you're saying goodbye to. It's just
a polite way to end a letter :)
 
P

Philip Semanchuk

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

"regards" is just respectful (and slightly formal) goodbye. Have a
look at the definition:
http://dictionary.reference.com/search?q=regards

It's used much more in written communication than in spoken.

At the end of a letter (or email), you might also see simply
"regards", or "warm regards" (which is especially friendly) or "kind
regards".

At the end of a meeting of two friends A and B, A might say to B,
"Give my regards to X" where X is a person that both A and B know that
B will soon see. A is asking B to "carry" good wishes to X. Instead, A
could have said to B, "When you see X, please tell her I'm thinking of
her fondly".

One can also say, "I hold him in high regard", meaning, "I respect and
admire him".

I'm in the USA; other English speakers might see this differently.

bye
Philip
 
M

MRAB

Andrew said:
The correspondent is wishing you well. You'll also see things like "kind
regards", "best wishes" and so on. "Regard" essentially means respect.

There's also "high regard", which means "much admiration or respect",
and the phrase "to hold someone in high regard" means to admire and
respect that person greatly, for example, "we hold Guido in high
regard". :)
 
G

Gabriel Genellina

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,138
Latest member
NevilleLam
Top