Easy questions from a python beginner

Carl Banks pavlovevidence at gmail.com
Fri Jul 23 02:26:57 EDT 2010


On Jul 22, 7:47 pm, wheres pythonmonks <wherespythonmo... at gmail.com>
wrote:
> Thanks for pointing out that swap (and my swap2) don't work everywhere
> -- is there a way to get it to work inside functions?

Impossible without hacking the interpreter.


> "No offense, but you seem like you're still tying to be a hacker.  If
> that's what you want, fine, but generally speaking (and particularly
> for Python), you are going to have a better experience if you do it
> the language's way."
>
> None taken, but I always think that it is the language's job to
> express my thoughts...

I don't.  In fact whenever I investigate new languages I make an
effort to accommodate its thinking, I find I learn a lot more than I
would by  it into my preconceived thinking.  YMMV.


> I don't like to think that my thoughts are
> somehow constrained by the language.

And yet your previous thoughts seem oddly constrained by Perl....


If you really want a language that can accommodate any thought you
could possibly have, you should check out Lisp.

(defmacro swap (a b)
  '(let ((t1 ,a)
         (t2 ,b))
     (setq ,b t1)
     (setq ,a t2)))

hygiene-left-as-an-exercise-ly yr's,


Carl Banks



More information about the Python-list mailing list