473,467 Members | 1,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

namespace curiosity

I just noticed something that may well have an obvious explanation (apologies
in advance if so).

Little demo illustrates:
>>def x(y = {1:1}):
.... y[1] = y[1] + 1
.... print y[1]
....
>>x()
2
>>x()
3

and so on; y continues to be updated rather than reset each call to x().
dir() suggests that y did _not_ somehow get into the global namespace, nor do
I see anything else that explains the behavior obviously. This only occurs
with dicts (or rather, possibly with any object that is merely updated within
x(), rather than reassigned within x()... I haven't tested).

I've been pythoning for a little while now, but haven't participated in this
usenet; you're welcome to consider me a newbie and be gentle with any
explanation of my oversight or whatever. The nature of this problem made it
difficult for me to investigate - to see if anyone else has reported or
explained it.

TIA.
Nov 25 '06 #1
1 1020
On Friday 24 November 2006 17:45, Dennis Lee Bieber wrote:
About once a week... It's a FAQ entry!
Wonderful! Missed that. Thanks for humoring me.
Very satisfying explanation, too... but what else is one to expect from
Python? :)
Nov 25 '06 #2

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

Similar topics

1
by: John L. Clark | last post by:
I am curious as to the rationale, and effect, of having default namespaces not applying (directly) to attributes (see http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute without a...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
8
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
7
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; ...
11
by: Sensei | last post by:
Hi again! I have still curiosity about the reason of some C constructs/keywords... The first is about static functions. What was the reason of restricting a function to be visible just in a...
7
by: Bilal | last post by:
Hello all, I came across this problem while working out the bugs in my identity trasnformation stylesheets but sidestepped it for later to see if there is an easier/better solution. This is...
5
by: gauravbjain | last post by:
I am planning to move from ‘static’ keyword to anonymous namespace for variables/functions which are local to a translation unit. This is to move code closer to C++, since static for file level...
3
by: Henri.Chinasque | last post by:
Hi all, Just from a pure curiosity standpoint, would it be possible to have an assembly with both c++ and c#? Google searches seem to hint at a "yes" but I'm not so sure. thanks, HC
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.