Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Jonas H.
On 10/03/2010 01:16 AM, Antoine Pitrou wrote: You should check that you aren't doing anything wrong with "env" and "start_response" (like deallocate them forcefully). I commented out the `Py_DECREF(start_response)` after the `app` call and the crash was gone. `start_response` is created via `P

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-02 Thread Antoine Pitrou
, the stack trace being: > >#1 frame_clear () >#2 collect () >#3 _PyObject_GC_Malloc () [...] > > Now that is weird. The only difference between the two functions is that > the second one (with the assignment) keeps a reference to the exc_info > tuple in the

[C-API] Weird sys.exc_info reference segfault

2010-10-02 Thread Jonas H.
Hello list, I have a really weird reference problem with `sys.exc_info`, and, if I'm right, function frames. The software in question is bjoern, a WSGI web server written in C, which you can find at http://github.com/jonashaag/bjoern. This WSGI application: def app(env, start_res

Re: Sphinx cross reference question

2010-08-23 Thread Chris Withers
Laszlo Nagy wrote: In my shopzeus.db.pivot.convert.py file, in the run() method of my Data2Facts class, I can write this into the docstring: ...you may have more joy asking about this on the Sphinx list: http://groups.google.com/group/sphinx-dev cheers, Chris -- http://mail.python.org/mai

Sphinx cross reference question

2010-08-22 Thread Laszlo Nagy
In my shopzeus.db.pivot.convert.py file, in the run() method of my Data2Facts class, I can write this into the docstring: class Data2Facts(threading.Thread): # code here... def prepare(self,*args): # code here... # more code here def run(self): """ Star

Re: The untimely dimise of a weak-reference

2010-08-03 Thread Gregory Ewing
Bruno Desthuilliers wrote: Would be better with : return self.func(obj, *args, *kwds) Thanks -- well spotted! -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: The untimely dimise of a weak-reference

2010-08-02 Thread Bruno Desthuilliers
Gregory Ewing a écrit : (snip) import weakref class weakmethod(object): def __init__(self, bm): self.ref = weakref.ref(bm.im_self) self.func = bm.im_func def __call__(self, *args, **kwds): obj = self.ref() if obj is None: raise ValueError("Calling dead weak method")

RE: The untimely dimise of a weak-reference

2010-08-01 Thread Vincent van Beveren
Hi Christiaan, > Instances of a class have no means of storing the bound method object. > The or unbound bound method is a simple and small wrapper that keeps a > reference to the class, "self" and the function object. Python keeps a > pool of empty method objects in a f

RE: The untimely dimise of a weak-reference

2010-08-01 Thread Vincent van Beveren
Hi Gregory, > You can create your own wrapper that keeps a weak reference to > the underlying object. Here's an example. > [...] Thanks for the code! Regards, Vincent -- http://mail.python.org/mailman/listinfo/python-list

Re: The untimely dimise of a weak-reference

2010-07-30 Thread Gregory Ewing
Vincent van Beveren wrote: I was working with weak references in Python, and noticed that it > was impossible to create a weak-reference of bound methods. > is there anything I can do about it? You can create your own wrapper that keeps a weak reference to the underlying object. Her

Re: The untimely dimise of a weak-reference

2010-07-30 Thread Christian Heimes
the bound method object. The or unbound bound method is a simple and small wrapper that keeps a reference to the class, "self" and the function object. Python keeps a pool of empty method objects in a free list. The creation of a new bound method just takes a few pointer assignment

RE: The untimely dimise of a weak-reference

2010-07-30 Thread Peter Otten
Vincent van Beveren wrote: > I did not know the object did not keep track of its bound methods. What > advantage is there in creating a new bound method object each time its > referenced? It seems kind of expensive. While I didn't measure it I suppose that it saves a lot of memory. Peter -- htt

RE: The untimely dimise of a weak-reference

2010-07-30 Thread Vincent van Beveren
: vrijdag 30 juli 2010 15:06 To: python-list@python.org Subject: Re: The untimely dimise of a weak-reference Vincent van Beveren wrote: > Hi everyone, > > I was working with weak references in Python, and noticed that it was > impossible to create a weak-reference of bound methods. Here

Re: The untimely dimise of a weak-reference

2010-07-30 Thread Peter Otten
Vincent van Beveren wrote: > Hi everyone, > > I was working with weak references in Python, and noticed that it was > impossible to create a weak-reference of bound methods. Here is a little > python 3.0 program to prove my point: > > import weakref > > print(&quo

The untimely dimise of a weak-reference

2010-07-30 Thread Vincent van Beveren
Hi everyone, I was working with weak references in Python, and noticed that it was impossible to create a weak-reference of bound methods. Here is a little python 3.0 program to prove my point: import weakref print("Creating object...") class A(object): def b(self):

Re: Is there a reference manual for "pyparsing"?

2010-07-01 Thread Chris Rebert
On Thu, Jul 1, 2010 at 10:08 PM, John Nagle wrote: > On 7/1/2010 10:02 PM, Chris Rebert wrote: >> On Thu, Jul 1, 2010 at 9:50 PM, John Nagle  wrote: >>>  Is there a reference manual for "pyparsing"?  Not a tutorial.  Not a >>> wiki. >>> Not a

Re: Is there a reference manual for "pyparsing"?

2010-07-01 Thread John Nagle
On 7/1/2010 10:02 PM, Chris Rebert wrote: On Thu, Jul 1, 2010 at 9:50 PM, John Nagle wrote: Is there a reference manual for "pyparsing"? Not a tutorial. Not a wiki. Not a set of examples. Not a "getting started guide". Something that actually documents what each pr

Re: Is there a reference manual for "pyparsing"?

2010-07-01 Thread Chris Rebert
On Thu, Jul 1, 2010 at 9:50 PM, John Nagle wrote: >  Is there a reference manual for "pyparsing"?  Not a tutorial.  Not a wiki. > Not a set of examples.  Not a "getting started guide". > Something that actually documents what each primitive does? http://pyparsi

Is there a reference manual for "pyparsing"?

2010-07-01 Thread John Nagle
Is there a reference manual for "pyparsing"? Not a tutorial. Not a wiki. Not a set of examples. Not a "getting started guide". Something that actually documents what each primitive does? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Wrong reference

2010-06-27 Thread Jimmy
ft.com/en-us/library/system.windows.controls.stackpanel.aspx StackPanel is in the System.Windows.Controls Namespace When I try and set up a reference to that Namespace I get a "Could not add reference to assembly System.Windows.Controls" error on the line that reads clr.AddReference('System.Window

Re: how to get a reference to the "__main__" module

2010-06-13 Thread Aahz
In article , WH wrote: > >'x' in getattr() should be a reference to the "__main__" module, right? >How to get it? Just for the record, the best way to get a reference to __main__ is to import it: import __main__ -- Aahz (a...@pythoncraft.com) <*>

Re: how to get a reference to the "__main__" module

2010-06-08 Thread Steven D'Aprano
On Tue, 08 Jun 2010 22:29:04 -0700, WH wrote: > Hi, > > I want to use one of two functions in a script: > > def func_one(): pass > def func_two(): pass > > func = getattr(x, 'func_'+number) > func() > > 'x' in getattr() should be a refere

Re: how to get a reference to the "__main__" module

2010-06-08 Thread Chris Rebert
On Tue, Jun 8, 2010 at 10:29 PM, WH wrote: > Hi, > > I want to use one of two functions in a script: > > def func_one(): pass > def func_two(): pass > > func = getattr(x, 'func_'+number) > func() > > 'x' in getattr() should be a reference to

how to get a reference to the "__main__" module

2010-06-08 Thread WH
Hi, I want to use one of two functions in a script: def func_one(): pass def func_two(): pass func = getattr(x, 'func_'+number) func() 'x' in getattr() should be a reference to the "__main__" module, right? How to get it? The 'if' clause should work he

Re: Tkinter library reference

2010-05-31 Thread Pradeep B
On Mon, May 31, 2010 at 2:46 PM, eb303 wrote: > On May 29, 3:11 pm, Pradeep B wrote: >> Do we have a standard reference library for Tkinter available? >> >> -- >> Pradeep > > Short answer: no, at least not a complete one for Tkinter itself. > > However, t

Re: Tkinter library reference

2010-05-31 Thread eb303
On May 29, 3:11 pm, Pradeep B wrote: > Do we have a standard reference library for Tkinter available? > > -- > Pradeep Short answer: no, at least not a complete one for Tkinter itself. However, there is a complete reference for tcl/tk here: http://www.tcl.tk/man/tcl8.5/ Once yo

Re: Tkinter library reference

2010-05-29 Thread Godson Gera
Do you mean Tkinter API reference documentation ? If so, this is what I've used years back http://www.nmt.edu/tcc/help/pubs/tkinter.pdf you can also get some info from http://effbot.org/tkinterbook On Sat, May 29, 2010 at 6:41 PM, Pradeep B wrote: > Do we have a standard reference lib

Tkinter library reference

2010-05-29 Thread Pradeep B
Do we have a standard reference library for Tkinter available? -- Pradeep -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
On Apr 27, 11:45 pm, Michal M wrote: > I've just found out that one of objects is not destroyed when it > should be. This means that something was holding reference to this > object or part of it (i.e. method). Is there any way to check what > holds that reference? I am unabl

Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
On Apr 28, 3:59 pm, Christian Heimes wrote: > The trick works only for objects that are tracked by CPython's garbage > collector. Simple and non-containerish objects like str, int, unicode > and some other types aren't tracked by the gc. Yes they are -- have you ever tried >>> import gc >>>

Re: How to check what is holding reference to object

2010-04-28 Thread Christian Heimes
Almar Klein wrote: Ah, it does exist! I wish I knew that two months ago, it would've saved me some precious time ;) The trick works only for objects that are tracked by CPython's garbage collector. Simple and non-containerish objects like str, int, unicode and some other types aren't tracked

Re: How to check what is holding reference to object

2010-04-28 Thread Almar Klein
On 27 April 2010 23:08, Chris Rebert wrote: > On Tue, Apr 27, 2010 at 1:45 PM, Michal M > wrote: > > I've just found out that one of objects is not destroyed when it > > should be. This means that something was holding reference to this > > object or part of it (i

Re: How to check what is holding reference to object

2010-04-28 Thread Michal M
t found out that one of objects is not destroyed when it > >>> > should be. This means that something was holding reference to this > >>> > object or part of it (i.e. method). Is there any way to check what > >>> > holds that reference? I am unable to do

Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
hould be. This means that something was holding reference to this >>> > object or part of it (i.e. method). Is there any way to check what >>> > holds that reference? I am unable to do that just looking to the code >>> > or debugging it because it is pretty compli

Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 2:42 PM, Michal M wrote: > On 27 Kwi, 23:21, Duncan Booth wrote: >> Michal M wrote: >> > I've just found out that one of objects is not destroyed when it >> > should be. This means that something was holding reference to this >> &g

Re: How to check what is holding reference to object

2010-04-27 Thread Michal M
On 27 Kwi, 23:21, Duncan Booth wrote: > Michal M wrote: > > Hi > > > I've just found out that one of objects is not destroyed when it > > should be. This means that something was holding reference to this > > object or part of it (i.e. method). Is there a

Re: How to check what is holding reference to object

2010-04-27 Thread Duncan Booth
Michal M wrote: > Hi > > I've just found out that one of objects is not destroyed when it > should be. This means that something was holding reference to this > object or part of it (i.e. method). Is there any way to check what > holds that reference? I am unable to do t

Re: How to check what is holding reference to object

2010-04-27 Thread Chris Rebert
On Tue, Apr 27, 2010 at 1:45 PM, Michal M wrote: > I've just found out that one of objects is not destroyed when it > should be. This means that something was holding reference to this > object or part of it (i.e. method). Is there any way to check what > holds that reference?

Re: How to check what is holding reference to object

2010-04-27 Thread Almar Klein
> I've just found out that one of objects is not destroyed when it > should be. This means that something was holding reference to this > object or part of it (i.e. method). Is there any way to check what > holds that reference? I am unable to do that just looking to the code

Re: How to check what is holding reference to object

2010-04-27 Thread Xavier Ho
Michal, May I ask why do you care about the object's management? Let Python worry about that. What's your use case? -- http://mail.python.org/mailman/listinfo/python-list

How to check what is holding reference to object

2010-04-27 Thread Michal M
Hi I've just found out that one of objects is not destroyed when it should be. This means that something was holding reference to this object or part of it (i.e. method). Is there any way to check what holds that reference? I am unable to do that just looking to the code or debugging it be

Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
On Apr 12, 4:27 pm, Gerhard Häring wrote: > Maybe somebody can enlighten me here. I can't figure out why doing a > rich comparison on my object decreases the total reference count by 1. [...] Doh! It turned out the strange effect was due to my particular build process. My Python

Re: rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Can be run like this: ghaer...@ws124~/src/gh/test$ python3 setup.py build_ext --inplace running build_ext building 'foo' extension gcc -fno-strict-aliasing -g -fwrapv -O0 -Wall -Wstrict-prototypes - arch i386 -m32 -I/opt/jetstream/include/python3.1 -c foo.c -o build/ temp.macosx-10.4-i386-3.1-pyde

rich comparison fscks up reference count?

2010-04-12 Thread Gerhard Häring
Maybe somebody can enlighten me here. I can't figure out why doing a rich comparison on my object decreases the total reference count by 1. Linked is the minimal test case with a C exension that compiles under both Python 2.6 and 3.1. No external dependencies, except a DEBUG build of Pyth

Re: Where can i reference the "regular expressions"

2010-03-24 Thread Andre Engels
On Wed, Mar 24, 2010 at 10:34 AM, John Smithury wrote: > ==source > the > is > name > ==source end= > > First, get the word only(discard the "" and ""), it can use > regular expression, right? > > the > is > name > Second, get a charactor in each word an

Re: Where can i reference the "regular expressions"

2010-03-24 Thread Andre Engels
On Wed, Mar 24, 2010 at 10:07 AM, John Smithury wrote: > Dear pythoners, > > I'm a new member to studay the python, i wan't to studay the "regular > expressions" handle like below: > > ==source > the > is > name > ==source end= > > > after convert, the r

Where can i reference the "regular expressions"

2010-03-24 Thread John Smithury
Dear pythoners, I'm a new member to studay the python, i wan't to studay the "regular expressions" handle like below: ==source the is name ==source end= after convert, the result like below: -result {'t

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-05 Thread Steven D'Aprano
On Fri, 05 Feb 2010 09:53:33 -0600, David Thole wrote: > I read thisand am a tiny bit confused about the actual problem. > > It's not exactly complex to realize that something like: a = b = array > that a and b both point to the array. > > Logically speaking, I'm not sure how one could assum

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-05 Thread Tad McClellan
["Followup-To:" header set to comp.lang.perl.misc.] Jürgen Exner wrote: > David Thole wrote in comp.lang.perl.misc: >>I read thisand am a tiny bit confused about the actual problem. >> >>It's not exactly complex to realize that something like: >>a = b = array >>that a and b both point to th

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-05 Thread J�rgen Exner
want two additional references to the same array insted then you have to create that reference first and assign that reference to $a and $b instead of copying the array, see "perldoc perlref" for details. And remember, references are scalars, no matter if they reference other scalars or ar

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-05 Thread David Thole
I read thisand am a tiny bit confused about the actual problem. It's not exactly complex to realize that something like: a = b = array that a and b both point to the array. Logically speaking, I'm not sure how one could assume that the same assignment would yield a and b point to the same dup

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Gib Bogle
Paul Rubin wrote: Ryan Kelly writes: I know, I know, do not feed the trolls. But this is just so *wrong* that I can't help myself. See: http://xkcd.com/386/ :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Xah Lee
()On Feb 2, 6:46 pm, Ryan Kelly wrote: > > On Tue, 2010-02-02 at 17:28 -0800, Xah Lee wrote: > > I know, I know, do not feed the trolls.  But this is just so *wrong* > that I can't help myself. > > > In Python, there are 2 ways to clear a hash: > > No, no there's not.  There's one way to clear

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Paul Rubin
Ryan Kelly writes: > I know, I know, do not feed the trolls. But this is just so *wrong* > that I can't help myself. See: http://xkcd.com/386/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Ryan Kelly
> On Tue, 2010-02-02 at 17:28 -0800, Xah Lee wrote: I know, I know, do not feed the trolls. But this is just so *wrong* that I can't help myself. > In Python, there are 2 ways to clear a hash: No, no there's not. There's one way to clear a hash and there's one way to assign a new object to a

Python's Reference And Internal Model Of Computing Languages

2010-02-02 Thread Xah Lee
just wrote this essay. Comment & feedback very welcome. Python's Reference And Internal Model Of Computing Languages Xah Lee, 2010-02-02 In Python, there are 2 ways to clear a hash: “myHash = {}” and “myHash.clear()”. What is the difference? ↓ The difference is that “m

Re: getting name of passed reference

2009-12-30 Thread Tim Roberts
Joel Davis wrote: > >Emile, essentially, the situation is that I'm trying to create an API >for consumption scripting. As it stands now, in initial development >they can pass callback function. The idea was to enable them to pass >variables and have the handling function determine the type and jus

Re: getting name of passed reference

2009-12-29 Thread Dave Angel
, are they Python programmers, are they scientists? Presumably you're trying to define a language (not Python) that these users can program in, where you want to achieve call by reference. I'm sure you have some good reason for that, but could we hear it? When you need to do something

Re: getting name of passed reference

2009-12-29 Thread Martin P. Hellwig
Joel Davis wrote: I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. Put another way, in the example: def MyFunc ( varPassed ): print varPassed; MyFunc(nwVar) how would I get the string "nwVar" from inside of

Re: getting name of passed reference

2009-12-29 Thread MRAB
Joel Davis wrote: On Dec 29, 11:21 am, Emile van Sebille wrote: On 12/29/2009 7:02 AM Joel Davis said... On Dec 29, 2:29 am, "Gabriel Genellina" wrote: I'm sure other limitations apply too -- don't rely on this technique for anything critical. -- Gabriel Genellina Gabriel, thanks for your i

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 11:21 am, Emile van Sebille wrote: > On 12/29/2009 7:02 AM Joel Davis said... > > > On Dec 29, 2:29 am, "Gabriel Genellina" > > wrote: > >> I'm sure other limitations apply too -- don't rely on this technique for > >> anything critical. > > >> -- > >> Gabriel Genellina > > > Gabriel, >

Re: getting name of passed reference

2009-12-29 Thread Stephen Hansen
On Tue, Dec 29, 2009 at 8:17 AM, Joel Davis wrote: > did set the tone and I think I've been more than a little tolerant on > this. Someone posts a question, responds back with a "n/m I found the > solution, here it is" and his response is essentially to berate them, > telling them how crappy their

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
ot;123") >>>> None >>>>>>> x = "123" >>>>>>> testing(x) >>>> None >>>> When a "solution" doesn't work under some circumstances (in this case, >>>> when run in the interactive interpre

Re: getting name of passed reference

2009-12-29 Thread Emile van Sebille
On 12/29/2009 7:02 AM Joel Davis said... On Dec 29, 2:29 am, "Gabriel Genellina" wrote: I'm sure other limitations apply too -- don't rely on this technique for anything critical. -- Gabriel Genellina Gabriel, thanks for your input, I had no idea that did that and it could have been deployed

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
>>>> testing(x) > >> None > > >> When a "solution" doesn't work under some circumstances (in this case, > >> when run in the interactive interpreter) that's a warning that you need > >> to understand when and where it will work bef

Re: getting name of passed reference

2009-12-29 Thread Steve Holden
[0][3] >> ... >> >>>>> testing("123") >> None >>>>> x = "123" >>>>> testing(x) >> None >> >> When a "solution" doesn't work under some circumstances (in this case, >> when run

Re: getting name of passed reference

2009-12-29 Thread Francesco Bochicchio
On 29 Dic, 00:54, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of > a reference passed to the function. > > Put another way, in the example: > >   def MyFunc ( varPassed ): >      print varPassed; > >   MyFunc(nwVar) >

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
On Dec 29, 2:29 am, "Gabriel Genellina" wrote: > En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis   > escribió: > > > > > On Dec 28, 9:37 pm, Joel Davis wrote: > > my thanks go out to Emile and Mr Hanson for their responses, I think > > I've found the solution, much shorter as well: > > >     > #!

Re: getting name of passed reference

2009-12-29 Thread Joel Davis
t;123") > None > >>> x = "123" > >>> testing(x) > > None > > When a "solution" doesn't work under some circumstances (in this case, > when run in the interactive interpreter) that's a warning that you need > to understand

Re: getting name of passed reference

2009-12-28 Thread Gabriel Genellina
En Tue, 29 Dec 2009 00:28:32 -0300, Joel Davis escribió: On Dec 28, 9:37 pm, Joel Davis wrote: my thanks go out to Emile and Mr Hanson for their responses, I think I've found the solution, much shorter as well: > #!/usr/bin/python > import traceback > def testing ( varPassed

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
ances (in this case, when run in the interactive interpreter) that's a warning that you need to understand when and where it will work before using it in production. Otherwise, how do you know that it will work under other circumstances? Or, find an alternative. What are you actually trying to do? "Get the name of a passed reference" is a means to an end. What are you expecting to do with it? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 9:37 pm, Joel Davis wrote: > As far as more positive things are concerned, is anyone aware of what > the support for _getframe(1) the way I used it is? Does steven have a > newer (or older) version than me, maybe? (2.6.2) it seems like the > sort of thing that ought to have pretty unifo

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
As far as more positive things are concerned, is anyone aware of what the support for _getframe(1) the way I used it is? Does steven have a newer (or older) version than me, maybe? (2.6.2) it seems like the sort of thing that ought to have pretty uniform behavior, but are their certain calls it var

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
On Dec 28, 8:40 pm, Steven D'Aprano wrote: > On Mon, 28 Dec 2009 17:27:21 -0800, Joel Davis wrote: > > For posterity, I figured out a solution: > > >  > #!/usr/bin/python > > >  > import sys > >  > from traceback import extract_stack > > >  > varPassed="varName get" > > >  > def MyFunc(varPassed):

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
On Mon, 28 Dec 2009 17:27:21 -0800, Joel Davis wrote: > For posterity, I figured out a solution: > > > #!/usr/bin/python > > > import sys > > from traceback import extract_stack > > > varPassed="varName get" > > > def MyFunc(varPassed): > > try: > > raise None >

Re: getting name of passed reference

2009-12-28 Thread Steven D'Aprano
On Mon, 28 Dec 2009 15:54:04 -0800, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of a > reference passed to the function. > > Put another way, in the example: > > def MyFunc ( varPassed ): > print varPassed; > >

Re: getting name of passed reference

2009-12-28 Thread Joel Davis
2009 3:54 PM Joel Davis said... > > > I'm just curious if anyone knows of a way to get the variable name of > > a reference passed to the function. > > For curiosity, sure -- but it's real weak... > > > Put another way, in the example: > > >    def My

Re: getting name of passed reference

2009-12-28 Thread Emile van Sebille
On 12/28/2009 3:54 PM Joel Davis said... I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. For curiosity, sure -- but it's real weak... Put another way, in the example: def MyFunc ( varPassed ): print varPassed;

Re: getting name of passed reference

2009-12-28 Thread Stephen Hansen
On Mon, Dec 28, 2009 at 3:54 PM, Joel Davis wrote: > I'm just curious if anyone knows of a way to get the variable name of > a reference passed to the function. > > Put another way, in the example: > > def MyFunc ( varPassed ): > print varPassed; > > MyFun

getting name of passed reference

2009-12-28 Thread Joel Davis
I'm just curious if anyone knows of a way to get the variable name of a reference passed to the function. Put another way, in the example: def MyFunc ( varPassed ): print varPassed; MyFunc(nwVar) how would I get the string "nwVar" from inside of "MyFunc"?

Re: Create object from variable indirect reference?

2009-11-17 Thread jhermann
On 10 Nov., 17:03, NickC wrote: > Many thanks for the replies.  getattr() works great: You can get a little more versatile and even specify the location of the name (i.e. the module / package name) without pre-importing it, like this... def importName(modulename, name=None): """ Import ident

Re: Simple object reference

2009-11-14 Thread Chris Rebert
On Sat, Nov 14, 2009 at 6:53 PM, Terry Reedy wrote: > Chris Rebert wrote: >> On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: >>> Hi, I have some problem with object reference >>> Say I have this code >>> >>> a = b = c = None >>> sl

Re: Simple object reference

2009-11-14 Thread Terry Reedy
Chris Rebert wrote: On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: Hi, I have some problem with object reference Say I have this code a = b = c = None slist = [a,b,c] Values are stored in the list, not references to names. That is not right either, or else newbies would not be

Re: Simple object reference

2009-11-14 Thread Ben Finney
Chris Rebert writes: > On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: > > Hi, I have some problem with object reference > > Say I have this code > > > > a = b = c = None > > slist = [a,b,c] > > Values are stored in the list, not references to names. Mo

Re: Simple object reference

2009-11-14 Thread Chris Rebert
On Sat, Nov 14, 2009 at 3:25 PM, AON LAZIO wrote: > Hi, I have some problem with object reference > Say I have this code > > a = b = c = None > slist = [a,b,c] Values are stored in the list, not references to names. Modifying the list does not change what values the names a, b, an

Simple object reference

2009-11-14 Thread AON LAZIO
Hi, I have some problem with object reference Say I have this code a = b = c = None slist = [a,b,c] for i in range(len(slist)): slist[i] = 5 print slist print a,b,c I got this [5, 5, 5] None None None Question is how can I got all a,b,c variable to have value 5 also? Thanks in advance

Re: Create object from variable indirect reference?

2009-11-10 Thread Hrvoje Niksic
NickC writes: > moon2 = ephem.${!options.body}() moon2 = getattr(ephem, options.body)() -- http://mail.python.org/mailman/listinfo/python-list

Re: Create object from variable indirect reference?

2009-11-10 Thread NickC
Many thanks for the replies. getattr() works great: >>> name='Moon' >>> m2 = getattr(ephem,name)() >>> m2.compute(home) >>> print ephem.localtime(m2.rise_time) 2009-11-11 01:30:36.02 shows the moon will rise at 1:30am localtime tonight at my home location. Excellent. -- NickC -- http://

Re: Create object from variable indirect reference?

2009-11-10 Thread Rami Chowdhury
On Tue, 10 Nov 2009 06:59:25 -0800, NickC wrote: I can't seem to find a way to do something that seems straighforward, so I must have a mental block. I want to reference an object indirectly through a variable's value. Using a library that returns all sorts of informa

Re: Create object from variable indirect reference?

2009-11-10 Thread Jon Clements
On Nov 10, 2:59 pm, NickC wrote: > I can't seem to find a way to do something that seems straighforward, so I > must have a mental block.  I want to reference an object indirectly > through a variable's value. > > Using a library that returns all sorts of information ab

Create object from variable indirect reference?

2009-11-10 Thread NickC
I can't seem to find a way to do something that seems straighforward, so I must have a mental block. I want to reference an object indirectly through a variable's value. Using a library that returns all sorts of information about "something", I want to provide the na

Re: Strange behavior related to value / reference

2009-10-30 Thread Aahz
In article <626f24e5-4d8e-416c-b3ed-dc56a88dc...@s21g2000prm.googlegroups.com>, Lambda wrote: > >def matrix_power(m, n): > result = m[:] > print result is m Use copy.deepcopy() -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "You could make Eskimos emigrate t

Re: Reference values for exec

2009-10-28 Thread Garito
ow can I use a common stack for them? >> >> Thanks >> >> 2009/10/28 Dave Angel >> >> >> >>> Garito wrote: >>> >>> >>> >>>> Hi! >>>> I'm trying to use exec in a recursive way but I have a problem >>

Re: Reference values for exec

2009-10-28 Thread Dave Angel
Dave Angel Garito wrote: Hi! I'm trying to use exec in a recursive way but I have a problem When I read the manual I understand that the globals and the locals are passed by reference but if I try to use it in a recursive way the new values added in a step are not passed to the next one

Re: Reference values for exec

2009-10-28 Thread Garito
stack for them? Thanks 2009/10/28 Dave Angel > Garito wrote: > >> Hi! >> I'm trying to use exec in a recursive way but I have a problem >> >> When I read the manual I understand that the globals and the locals are >> passed by reference but if I try to us

Re: Reference values for exec

2009-10-28 Thread Dave Angel
Garito wrote: Hi! I'm trying to use exec in a recursive way but I have a problem When I read the manual I understand that the globals and the locals are passed by reference but if I try to use it in a recursive way the new values added in a step are not passed to the next one Could so

Re: Strange behavior related to value / reference

2009-10-28 Thread Dave Angel
Mark Dickinson wrote: On Oct 28, 8:24 am, Lambda wrote: Thank you! Following is my final code: Looks good, but are you sure about that word 'final'? ;-) def matrix_power(m, n): """ Raise 2x2 matrix m to nth power. """ if n =0: return [[1, 0], [0, 1]] x =atrix_power(m,

Re: Strange behavior related to value / reference

2009-10-28 Thread Peter Otten
Lambda wrote: > I defined a function to raise a 2x2 matrix to nth power: > BTW, numpy has such a function, but it doesn't support really large > number. > Does numpy has some functions that support arbitrarily large number? You can tell it to use Python instead of C integers: >>> import numpy >

Re: Strange behavior related to value / reference

2009-10-28 Thread Mark Dickinson
On Oct 28, 8:24 am, Lambda wrote: > Thank you! > Following is my final code: Looks good, but are you sure about that word 'final'? ;-) > > def matrix_power(m, n): >   """ >   Raise 2x2 matrix m to nth power. >   """ >   if n == 0: return [[1, 0], [0, 1]] > >   x = matrix_power(m, n / 2) I sugg

Reference values for exec

2009-10-28 Thread Garito
Hi! I'm trying to use exec in a recursive way but I have a problem When I read the manual I understand that the globals and the locals are passed by reference but if I try to use it in a recursive way the new values added in a step are not passed to the next one Could someone point me how

<    3   4   5   6   7   8   9   10   11   12   >