#apache #archlinux #asterisk #centos #debian #gentoo #haskell #kde #kubuntu #lisp #math #mysql #perl #python #ruby-lang #rubyonrails #suse #ubuntu #vim #wikipedia 0 1 2 3 4 5 6 7 8 9 10 11
Top Prev 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 Next
#python
<bsmntbombdood> deltab: the closure has to preserve the creating function's enviroment
<deltab> def f(): locals()['x'] = 42; print x
<joe_k> bsmntbombdood: sorry, executed the wrong function when testing that theory... fat fingers
<deltab> bsmntbombdood: and it does that
<bsmntbombdood> no it doesn't
<ironfroggy> bsmntbombdood: the whole thing is a lost point tho, because the exec is wasted anyway. no reason not to use a normal import statement
<ironfroggy> bsmntbombdood: does too
<bsmntbombdood> ironfroggy: in the app, there is
<bsmntbombdood> locals() is part of the creating function's enviroment
<bsmntbombdood> it has to be preserved
<deltab> bsmntbombdood: I've simplified your example, above; does it still show what you meant?
<ironfroggy> bsmntbombdood: ok but locals() only reutrns a _copy_ of the locals
<ironfroggy> bsmntbombdood: the locals dont actual exist in a dictionary, so changing it doesnt affect them
<ironfroggy> bsmntbombdood: that is well known
<bsmntbombdood> in the actual code, locals() isn't used
<deltab> so what is?
<bsmntbombdood> it's a regular dictionary
<bsmntbombdood> is there a way to specify the enviroment for a closure?
<ironfroggy> why dont you just use d['sys'].stdout.write or whateve then? if its in a dictionary, use the dictionary
<ironfroggy> does sys.stdout.write even matter for your actual usecase?
<ironfroggy> or just in your example of it?
<arkanes> bsmntbombdood: by definition, the environment of a closer is where its created
<arkanes> closure, too
<deltab> bsmntbombdood: yes, the 5th argument to the function constructor
<deltab> "The optional closure tuple supplies the bindings for free variables."
<TMH_> Does anyone know anything about paramiko? I am trying to write a multi-threaded SSH port forwarder, but whenver I try to call my port_forward function from a thread, it doesn't work.
<TMH_> When I'm calling the function through normal method, I get this: <paramiko.Transport at 0xB7A6F88CL (cipher aes128-cbc, 128 bits) (active; 0 open channels)>
<evilx> TMH_, what happends?
<TMH_> but through thread, my transport is this: <paramiko.Transport at 0xB7A6F88CL (unconnected)>
<evilx> hum
<TMH_> I really, really don't want to run about 20 of these applications, and there's really no reason to.
<puffy-san> Which do you people use? IDE or just a text editor for your projects?
<evilx> vim
<TMH_> I use vim.
<bsmntbombdood> puffy-san: emacs
<deltab> gedit and vim
<Twey> vim here.
<TMH_> I can't find a great deal of documentation for paramiko on the internet
<TMH_> but I thought I'd figured it out. Evidently not, as it apparently conflicts with threads.
<evilx> so when you run it in without a thread it works, but when you do it in a function it doesnt.
<TMH_> when I run it in the run() function of the thread, it doesn't.
<TMH_> also, it's worth noting that when I actually call thread.run() it works perfectly
<TMH_> thread.start() causes it to become unconnected.
<evilx> can i see the code?
<TMH_> certainly, one second.
<arkanes> TMH_: you have may better luck with twisted.conch
<evilx> im installing paramiko right now.
<evilx> ok installed
<TMH_> evilx: http://pastebin.ca/370629
<TMH_> arkanes: in searching for paramiko documentation, I found out about twisted.conch but the documentation seems extremely sparse, unless I've missed something.
Previous Page Next Page