3

I read clobber in a sentence in book "Fluent Python"

you may clobber a global variable without knowing.

the complete context

This is not a bug, but a design choice: Python does not require you to declare variables, but assumes that a variable assigned in the body of a function is local. This is much better than the behavior of JavaScript, which does not require variable declarations either, but if you do forget to declare that a variable is local (with var), you may clobber a global variable without knowing.

clobber means hit hard in clobber | Definition of clobber in English by Oxford Dictionaries

Which seems not make sense here.

2

In computer-speak, the verb to clobber basically means to destroy data in some way. In the context of computer programming, I've heard it used to mean that a million times. For instance, if you have a piece of data stored in a variable and then you do something with that variable such that the data that's stored in the variable is now completely lost, the data is said to be clobbered. However, I believe that this is more of a slang term rather than well-established professional terminology.

Example sentence:

The reset command will flush the input buffer clobbering all the data currently stored in it.

4

It means in this case to accidentally overwrite a variable that had been declared in the global scope. To "clobber" means in the broadest sense to "knock out" and that is how you should view it. The global variable has been "knocked out" because it was overwritten.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.