473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about shadowing built-in names

I understand that if you reassign a built-in name to your own variable,
such as:

str = 'hello'

then you lose the use of the built-in (in this case str()), but is this
also the case in terms of imported names? For example:

import MySQLdb

db = connect(blah blooh blee)
cursor = db.cursor()

Now, in the above, did I reassign the value of the cursor method, or is
this different?

Actually, now that I think about it, that's not exactly the same because
cursor is a method of a connection object, not simply a function. So I
suppose my real question is, does the 'shadowing' of built-in names also
happen when you import other names, whether they are functions,
methods or whatever else they could be?

Thanks.
May 23 '06 #1
1 2539
Dennis Lee Bieber wrote:
import MySQLdb

db = connect(blah blooh blee)
Actually, the above has already failed <G> Should be
MySQLdb.connect...


Heh heh, yeah, I totally meant to do that on purpose. ;)

Well, if you have a habit of doing
from module import *
and later rebind one of the imported names...


I see. So doing a regular import <name> statement keeps the namespace
confined to that module, right? So I would be able to create my own
variable with the same name as a name in the imported module, and this
wouldn't be a problem as long as I didn't import with *?
May 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Arthur J. O'Dwyer | last post by:
I was paging through Coplien's book "Advanced C++ Programming Styles and Idioms" this afternoon and found some code that looked something like void sort(vector<foo> a) { int flip; do { for...
10
by: deko | last post by:
I need to use Visual Basic to create an ActiveX DLL that subclasses an Access form (cf. Knowledge Base Article 278379). Should I use Visual Studio .NET --or-- regular Visual Basic 6 --or-- VS.NET...
18
by: No Such Luck | last post by:
Hi all: I have an unsigned char array (size 4): unsigned char array; array = 0x00; array = 0x00; array = 0x02; array = 0xe7;
2
by: Zoury | last post by:
Hi folks! :O) I've implemented a DateTimePickerEx with inherits from a DateTimePicker control. I've declared these properties in it : //** new public string Text {
3
by: Nick Stansbury | last post by:
Hi, Quick (and probably simple) question regarding shadowing and polymorphism. Problem is best explained by an example. Public Class A public CommonProperty as Integer end class Public...
5
by: iwdu15 | last post by:
i used regasm to make my vb.net control a tlb file...how can i add it to like my c++ form? i used regasm and made it to a .tlb file but when i try to add it to the toolbox it gives an error....what...
0
by: Flack | last post by:
Hello, Lets say I built my app on a machine that has Excel 2003 installed. So, the interop assembly created was built off of 2003. Now, I have a few questions on what would happen if I ran...
1
by: mitsura | last post by:
Hi, I just installed py2exe to create a binary of my Python script. However, py2exe does not seem to create a binary from my .py script. This is what I have done: I create a setup.py script: "...
3
by: Cartoper | last post by:
I really like the shadowing that this web site is using behind the images. I have tried to dig through their code to figure out how they did it, but it still eludes me. How do they do it? ...
9
by: Alexander Dong Back Kim | last post by:
Dear all, I want to create a method that return an element in a vector by selecting the element position by vector's at(). The method should be look like vector<Apple_appleBox; Apple &...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.