Re: How to get self reference from within a module?

2007-01-22 Thread Gabriel Genellina
At Monday 22/1/2007 20:26, Lavoie Érick wrote: > i would like to now how to get a self > reference from within a module. The goal is to > be able to generate a list of all declared function within the module. From inside the module, use globals() - that includes all define

Re: How to get self reference from within a module?

2007-01-24 Thread Lavoie Érick
I finally found what I was searching for here: http://www.thescripts.com/forum/thread25264.html I wanted the reference to the current module and we can obtain it this way: sys.modules[__name__] so its property can be used. Thanks, Erick -- http://mail.python.org/mailman/listinfo/python

small inaccuracy in the logging module documentation (Python Library Reference)

2006-06-29 Thread Petr Jakeš
Hi, I have found some inaccuracy in the Python Library Reference 6.29.5.4 TimedRotatingFileHandler (http://docs.python.org/lib/node349.html) 1) it is not really obvious from the documentation the "when" value has to be in the format "w0", "w1" ... "w6" if

Re: Reference behavior through C (was: Lambda going out of fashion)

2004-12-28 Thread Craig Ringer
On Wed, 2004-12-29 at 02:08, Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Craig Ringer <[EMAIL PROTECTED]> wrote: > . > . > . > > IMO the reference behaviour of functions in the

Re: Why list.sort() don't return the list reference instead of None?

2006-05-07 Thread Robert Kern
[EMAIL PROTECTED] wrote: > L = [4,3,2,1] > L=L.sort() > L will refer to None, why L.sort() don't return the L? > I want to ask why the designer of Python do so? http://www.python.org/doc/faq/general/#why-doesn-t-list-sort-return-the-sorted-list -- Robert Kern "I have come to believe that the wh

Re: Why list.sort() don't return the list reference instead of None?

2006-05-07 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > L = [4,3,2,1] > L=L.sort() > L will refer to None, why L.sort() don't return the L? > I want to ask why the designer of Python do so? Because that's the convention that signifies that a Python method mutates the object rather than returns a new one. -- Erik Max Franc

Re: Why list.sort() don't return the list reference instead of None?

2006-05-07 Thread Lawrence Oluyede
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > I want to ask why the designer of Python do so? I'm not a Python core developer nor a designer but I've always known that sort() is a in-place sort and since the list is a mutable object it mutates the list sending the "sort()" message. If you wan

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread [EMAIL PROTECTED]
Thanks a lot! However, I wonder why L.sort() don't return the reference L, the performance of return L and None may be the same. If L.sort() return L, we shouldn't do the awful things such as: keys = dict.keys() keys.sort() for key in keys: ...do whatever with dict[key]... we can

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread Lawrence Oluyede
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > However, I wonder why L.sort() don't return the reference L, the > performance of return L and None may be the same. It's not "the same". sort() does not return anything. > Why? I've j

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread Sybren Stuvel
[EMAIL PROTECTED] enlightened us with: > However, I wonder why L.sort() don't return the reference L, the > performance of return L and None may be the same. It's probably because it would become confusing. Many people don't read the documentation. If L.sort() returns a sort

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread Tim N. van der Leeuw
So you write: for key in sorted(dict.iterkeys()): ... do it ... dict.iterkeys() returns an iterable which doesn't even have a sort-method; and somehow I find it unnatural to apply a 'sort' method to an iterator whereas I find it perfectly natural to feed an iterator to a function that does sor

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread [EMAIL PROTECTED]
Thank you! I got it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread vbgunz
to throw fire on the fuel (:P), you can get the value back to an in-place mutable change with a single expression... mylist = [2,3,4,1] print mylist.sort() or mylist might not be too pythonic or maybe it is. I guess depends on what side of the glass you might wish to view the solution :) -- htt

Re: Why list.sort() don't return the list reference instead of None?

2006-05-09 Thread bruno at modulix
Lawrence Oluyede wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > >>However, I wonder why L.sort() don't return the reference L, the >>performance of return L and None may be the same. > > > It's not "the same". s

Re: Why list.sort() don't return the list reference instead of None?

2006-05-09 Thread bruno at modulix
vbgunz wrote: > to throw fire on the fuel (:P), you can get the value back to an > in-place mutable change with a single expression... > > mylist = [2,3,4,1] > print mylist.sort() or mylist > > might not be too pythonic or maybe it is. I guess depends on what side > of the glass you might wish to

[ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-04-30 Thread Laurent Pointal
PQRC (Python Quick Reference Card) is a condensed documentation for Python and its main libraries, targetting production of printed quick reference cards. Its available as OpenDocument .odt files and as A4 and USLetter formatted PDF files ready to print. Its distributed under a Creative Commons

Re: Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-04-30 Thread kyosohma
On Apr 30, 7:42 am, Laurent Pointal <[EMAIL PROTECTED]> wrote: > PQRC (Python Quick Reference Card) is a condensed documentation for > Python and its main libraries, targetting production of printed quick > reference cards. > Its available as OpenDocument .odt files and

Embedding python: GCC gives errors of "undefined reference" to Py_* functions.

2006-08-19 Thread Shuaib
Hey! I am trying to embedd python into a C programe of mine. But when I try to compile the C code, gcc gives errors like "undefined reference to `Py_Finalize'" and the same kind for all the other functions. I have incuded "Python.h". Any idea what might be

Can I reference 1 instance of an object by more names ?

2007-05-22 Thread Stef Mientki
hello, I'm trying to build a simple functional simulator for JAL (a Pascal-like language for PICs). My first action is to translate the JAL code into Python code. The reason for this approach is that it simplifies the simulator very much. In this translation I want to keep the JAL-syntax as much

Zope: Adding a layer causes valid output to become an object reference?

2005-02-10 Thread Junkmail
a while. I'd bet I'm not groking something here. So if I call /home I get the proper HTML output: "What I am looking for" but when in another object I reference I get: "". Any thoughts are appreciated. Mike PS: Yes it is a wrapper for Textile ver 2 and I plan on

Instead of obsessing over the library *reference*, why not use other documentation?

2005-11-06 Thread Fredrik Lundh
ar aspects of the > framework, available with full source code. There is no shortage of code examples for Python modules either, thanks to people who've worked hard to prepare cookbooks and example collections. If people began using those instead of complaining about the library reference

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-04-30 Thread Stef Mientki
hi Laurent, this is really a work of Art, thank you very much !! Oh, wouldn't it be nice to have reference cards of all library packages ;-) cheers Stef Mientki Laurent Pointal wrote: > PQRC (Python Quick Reference Card) is a condensed documentation for > Python and its mai

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-02 Thread Casey Hawthorne
PC-cillin flagged this as a dangerous web site. Laurent Pointal <[EMAIL PROTECTED]> wrote: >PQRC (Python Quick Reference Card) is a condensed documentation for >Python and its main libraries, targetting production of printed quick >http://www.limsi.fr/Individu/poin

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-02 Thread Laurent Pointal
Casey Hawthorne wrote: > PC-cillin flagged this as a dangerous web site. Maybe PC-cillin tag as dangerous all sites about Python, the famous snake. PS. And why does it tag my laboratory work page as dangerous ? It's pure HTML, I worked to have even no javascript, readable with lynx. -- http:

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-02 Thread Alex Martelli
s dangerous ? It's pure > HTML, I worked to have even no javascript, readable with lynx. It's an excellent quick-reference card, BTW (though I don't quite understand why even-numbered pages are flipped upside-down). Alex -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-03 Thread Laurent Pointal
; >> >> PS. And why does it tag my laboratory work page as dangerous ? It's pure >> HTML, I worked to have even no javascript, readable with lynx. > > It's an excellent quick-reference card, BTW (though I don't quite > understand why even-numbered pages

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-03 Thread Alex Martelli
Laurent Pointal <[EMAIL PROTECTED]> wrote: ... > > It's an excellent quick-reference card, BTW (though I don't quite > > understand why even-numbered pages are flipped upside-down). > > At work I print it on horizontal A4/USLetter, with recto-back, and wit

Re: Embedding python: GCC gives errors of "undefined reference" to Py_* functions.

2006-08-19 Thread Shuaib
> > I am trying to embedd python into a C programe of mine. But when I try > to compile the C code, gcc gives errors like "undefined reference to > `Py_Finalize'" and the same kind for all the other functions. I have > incuded "Python.h". > > Any idea what mi

When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread John Henry
w that the answere will be 0. In this case, aref is really a reference. But what if the right hand side is a simple variable (say an int)? Can I "reference" it somehow? Should I assume that: aref = _any_type_other_than_simple_one be a reference, and not a copy? Thanks, -- http://mai

Re: [ANN] Update to Python Quick Reference Card (for Python 2.4) (v0.67)

2007-05-15 Thread jean-michel bain-cornu
> PC-cillin flagged this as a dangerous web site. An explanation would be fine about *why* the web site is flagged as dangerous... -- http://mail.python.org/mailman/listinfo/python-list

Re: Can I reference 1 instance of an object by more names ?

2007-05-22 Thread Brian van den Broek
Stef Mientki said unto the world upon 05/22/2007 07:44 PM: > hello, > > I'm trying to build a simple functional simulator for JAL (a Pascal-like > language for PICs). > My first action is to translate the JAL code into Python code. > The reason for this approach is that it simplifies the simulato

Re: Can I reference 1 instance of an object by more names ?

2007-05-22 Thread Terry Reedy
"Stef Mientki" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | port_D = IO_port('D') | | Now I want to assign a more logical name to that port, | (In JAL: "var byte My_New_Name IS port_D") | | Is that possible ? | | I think the answer is "no", | because the object itself is not

Re: Can I reference 1 instance of an object by more names ?

2007-05-22 Thread Steven D'Aprano
On Wed, 23 May 2007 01:44:22 +0200, Stef Mientki wrote: > Now I want to assign a more logical name to that port, (In JAL: "var > byte My_New_Name IS port_D") > > Is that possible ? > > I think the answer is "no", > because the object itself is not mutable. Am I right ? > > But I read: "An objec

Re: Can I reference 1 instance of an object by more names ?

2007-05-23 Thread Bruno Desthuilliers
Stef Mientki a écrit : > hello, > > I'm trying to build a simple functional simulator for JAL (a Pascal-like > language for PICs). > My first action is to translate the JAL code into Python code. > The reason for this approach is that it simplifies the simulator very much. > In this translation I

Re: Can I reference 1 instance of an object by more names ?

2007-05-23 Thread Eric Yaeger
Perhaps Stef Mientki, you might be interested in copy.copy( ) and copy.deepcopy( ) ! Please see the info I have put below. On May 23, 12:44 am, Stef Mientki <[EMAIL PROTECTED]> wrote: > One of the problems is the alias statement, assigning a second name to an > object. > I've defined a class IO_

Re: Zope: Adding a layer causes valid output to become an object reference?

2005-02-13 Thread Dieter Maurer
tances (that's what you see). > The fact that > the < and > surround the output make it invisible in the browser and > had me chasing ghosts for a while. I'd bet I'm not groking something > here. This should not happen in ZPT (unless you use "structure&

Re: Zope: Adding a layer causes valid output to become an object reference?

2005-02-15 Thread Junkmail
and I have to explicitly reference the method I want to call, the DTML namespace gets shipped to my external method instead of the namespace of my called object. I read "groking acquisition" 4 times before I groked it. To fix that I changed the index_html of my zclass to a python script

Re: Instead of obsessing over the library *reference*, why not use other documentation?

2005-11-06 Thread Steven D'Aprano
t; the same search today, you'll still find examples, but 5 of the top 10 > hits are references to Xah's problems with the library reference. A > few more rounds, and people will have to start adding -xah to their > Python searches to get quality results.) People are link

Re: Instead of obsessing over the library *reference*, why not use other documentation?

2005-11-06 Thread Diez B. Roggisch
> People are linking to Xah??? Or he is google-bombing? I guess /F meant the results on google that show this very NG/ML. Diez -- http://mail.python.org/mailman/listinfo/python-list

Determining method type given its string name presentation and its corresponding object reference.

2005-07-31 Thread Apple
Hi I am a bit new to python. I was wondering if there is a way to determine whether or not a given string is a member method of a given object: def is_a_method(self, attr_name): 'returns True if attr_name is an instance method of self; false otherwise' The problem is that I have overridden

Re: Determining method type given its string name presentation and itscorresponding object reference.

2005-07-31 Thread Terry Reedy
"Apple" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi I am a bit new to python. I was wondering if there is a way to > determine whether or not a given string is a member method of a given > object: Does callable(cls.attr) fit your needs? Terry J. Reedy -- http://mail.py

Re: Determining method type given its string name presentation and itscorresponding object reference.

2005-07-31 Thread John Machin
Terry Reedy wrote: > "Apple" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Hi I am a bit new to python. I was wondering if there is a way to >>determine whether or not a given string is a member method of a given >>object: > > > Does callable(cls.attr) fit your needs? > o

Re: Determining method type given its string name presentation and itscorresponding object reference.

2005-07-31 Thread Apple
"or perhaps callable(getattr(obj, strg, None)) if the need is related to an unknown string which may be a callable attribute of an object whose class is unknown ..." Hm.. the problem is I cannot call getattr() at all. Because getattr() will call my __repr__() which will call another m() that will

testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread alf
Hi, I have a reference to certain objects. What is the most pythonic way to test for valid reference: if obj: if None!=obs: if obj is not None: -- alfz1 -- http://mail.python.org/mailman/listinfo/python-list

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread Laszlo Nagy
ref = some_huge_list >aref[0]=0 >print some_huge_list[0] > > we know that the answere will be 0. In this case, aref is really a > reference. > > But what if the right hand side is a simple variable (say an int)? Can > I "reference" it somehow? Should I as

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread Steve Holden
1 >aref = some_huge_list >aref[0]=0 >print some_huge_list[0] > > we know that the answere will be 0. In this case, aref is really a > reference. > > But what if the right hand side is a simple variable (say an int)? Can > I "reference" it somehow?

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread John Henry
print i and you get 1 printed. So, if I understand you correctly, I must make the reference to a more elaborate representation. Like: i=[1,] j=i j[0]=2 print i in order to get 2 printed. Correct? Steve Holden wrote: > John Henry wrote: > > Hi list, > > >

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread Grant Edwards
. Because you've changed neither the object to which "i" is bound nor the value of that object (you can't change the values of integer objects). > So, if I understand you correctly, I must make the reference > to a more elaborate representation. Like: > >i=[1,] &

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread John Henry
may or may not be the same object to which > "i" is bound. > > >j=2 > > Now the name "j" is bound to an immutable integer object who's > value is 2. Rebinding the name "j" to a different object has > no effect on the object to

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread George Sakkis
Grant Edwards wrote: > On 2006-09-13, John Henry <[EMAIL PROTECTED]> wrote: > > So, if I understand you correctly, I must make the reference > > to a more elaborate representation. Like: > > > >i=[1,] > >j=i > >j[0]=2 > >print i

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-14 Thread Fredrik Lundh
Dennis Lee Bieber wrote: > References to lists, dictionaries, and class instances (which are, > in a way, just an expanded dictionary) are "mutable" careful: it's not the *reference* that's mutable, it's the object. the *only* difference between mutable an

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-14 Thread Christophe
1 >aref = some_huge_list >aref[0]=0 >print some_huge_list[0] > > we know that the answere will be 0. In this case, aref is really a > reference. > > But what if the right hand side is a simple variable (say an int)? Can > I "reference" it somehow?

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-14 Thread Bruno Desthuilliers
1 >aref = some_huge_list >aref[0]=0 >print some_huge_list[0] > > we know that the answere will be 0. In this case, aref is really a > reference. > > But what if the right hand side is a simple variable (say an int)? Can > I "reference" it somehow?

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-19 Thread Magnus Lycka
Fredrik Lundh wrote: > this article > > http://effbot.org/zone/python-objects.htm > > may be useful for those who haven't already seen it. I don't know how many times I've referred to, or paraphrased, that article. Shouldn't it be incorporated into the standard tutorial? I think it's very he

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-19 Thread GHUM
Magnus Lycka schrieb: > > http://effbot.org/zone/python-objects.htm > > may be useful for those who haven't already seen it. > >Shouldn't it be incorporated into the standard tutorial? >I think it's very helpful for people who are used > to the way C etc handles variables. That would also be

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-19 Thread Simon Brunning
On 9/19/06, Magnus Lycka <[EMAIL PROTECTED]> wrote: > Fredrik Lundh wrote: > > this article > > > > http://effbot.org/zone/python-objects.htm > > > > may be useful for those who haven't already seen it. > > I don't know how many times I've referred to, or paraphrased, > that article. Shouldn't

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread stef
, name2 # both references are OK name2[0] = 26 # assign another value through the other name print name1, name2 # both reference are OK name2[0] = name1[0] + 13 # use both names at either side of an assignment print name1, name2# both references still OK --

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread Bruno Desthuilliers
cpu_ports() # create an instance > name2 = name1# refer with a second name to the same instance > print name1, name2 # test ok > > name1[0] = 25 # assign a value to the instance > print name1, name2 # both references are OK > > name2[

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread stef
instance >> print name1, name2 # test ok >> >> name1[0] = 25 # assign a value to the instance >> print name1, name2 # both references are OK >> >> name2[0] = 26 # assign another value through the other >> name >> pri

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread Carsten Haese
# refer with a second name to the same instance > print name1, name2 # test ok > > name1[0] = 25 # assign a value to the instance > print name1, name2 # both references are OK > > name2[0] = 26 # assign another value through the ot

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread Stef Mientki
hi Bruno, after study it carefully, it's much more complex than I thought (I can't understand it completely, which is of less importance). Your solution works great, but I need one little extension, which I can create, but just at the cost of a lot of code. Maybe you can give me another hint. > I

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-23 Thread Maric Michaud
Stef Mientki a écrit : > hi Bruno, > > after study it carefully, > it's much more complex than I thought > (I can't understand it completely, which is of less importance). > Your solution works great, > but I need one little extension, > which I can create, but just at the cost of a lot of code. >

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-24 Thread Bruno Desthuilliers
Maric Michaud a écrit : > Stef Mientki a écrit : (snip) >> # I need to read and write the individual bits of the byte object >> # so I can create 8 blocks of code like this, one for each bit position >> # I use it, like this >> #name1 = cpu_ports() >> #name1.p5 = True >> # or >> #name1.

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-24 Thread Stef Mientki
Maric Michaud wrote: > def bit(): > def fset(self, value): > index= 5 > value= ( value & 1L ) << index > mask = ( 1L ) << index > self._d = ( self._d & ~mask ) | value > def fget(self): > index= 5 > return ( self._d >> index

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-24 Thread Peter Otten
Stef Mientki wrote: > Maric Michaud wrote: def bit(index): >> def fset(self, value): >> value= ( value & 1L ) << index >> mask = ( 1L ) << index >> self._d = ( self._d & ~mask ) | value >> def fget(self): >> return ( self._d >> index ) & 1 >>

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-24 Thread Stef Mientki
Peter Otten wrote: > Stef Mientki wrote: > >> Maric Michaud wrote: > >def bit(index): >>> def fset(self, value): > >>> value= ( value & 1L ) << index >>> mask = ( 1L ) << index >>> self._d = ( self._d & ~mask ) | value >>> def fget(self): > >>>

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-24 Thread Peter Otten
Stef Mientki wrote: > Peter Otten wrote: >> Stef Mientki wrote: >> >>> Maric Michaud wrote: >> >>def bit(index): def fset(self, value): >> value= ( value & 1L ) << index mask = ( 1L ) << index self._d = ( self._d & ~mask ) | value >>>

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-25 Thread Stef Mientki
> Again, I'm confident, again I didn't test. I did, ... ... and unfortunately it still gave errors. So for the moment I'll just stick to my "lots of code solution", and I'll try again, when I've some more understanding of these Python "internals". Anyway, thank you all for your assistance. che

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-25 Thread Peter Otten
Stef Mientki wrote: >> Again, I'm confident, again I didn't test. > > I did, ... > ... and unfortunately it still gave errors. Strange. > So for the moment I'll just stick to my "lots of code solution", > and I'll try again, when I've some more understanding of these Python > "internals". Anyw

Re: Can I reference 1 instance of an object by more names ? rephrase

2007-05-25 Thread Stef Mientki
Peter Otten wrote: > Stef Mientki wrote: > >>> Again, I'm confident, again I didn't test. >> I did, ... >> ... and unfortunately it still gave errors. > > Strange. indeed .. > >> So for the moment I'll just stick to my "lots of code solution", >> and I'll try again, when I've some more understan

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-12-08 Thread alf
alf wrote: > Hi, > > I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: > > if None!=obs: > > if obj is not None: > thx for all answers - now "if obj is not None:" in an ob

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Carl Banks
alf wrote: > Hi, > > I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: > > if None!=obs: > > if obj is not None: If you're checking whether an object is None or not, the third is t

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Bruno Desthuilliers
alf a écrit : > Hi, > > I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: Don't do this: for o in [0, '', [], {}, ()]: print obj, bool(obj), obj is None > if None!=obs: In python

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread BJörn Lindqvist
> I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: > > if None!=obs: > > if obj is not None: The third way is the most precise way. It is often used in combination with default argum

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Sandra-24
alf wrote: > Hi, > > I have a reference to certain objects. What is the most pythonic way to > test for valid reference: > > if obj: > > if None!=obs: > > if obj is not None: I like this way the most. I used timeit to benchmark this against the

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Carl Banks
Bruno Desthuilliers wrote: > In python, assignement is a statement, not an expression, so there's no > way you could write 'if obj = None' by mistake (-> syntax error). So > this style is unpythonic. Also, None is a singleton, and identity test > is way faster than equality test. Playing Devil's a

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-04 Thread Paul Rubin
alf <[EMAIL PROTECTED]> writes: > I have a reference to certain objects. What is the most pythonic way > to test for valid reference: If you're intending to use None as a sentinel for an invalid reference, then use > if obj is not None: You could also ma

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-05 Thread Bruno Desthuilliers
Carl Banks wrote: > Bruno Desthuilliers wrote: >> In python, assignement is a statement, not an expression, so there's no >> way you could write 'if obj = None' by mistake (-> syntax error). So >> this style is unpythonic. Also, None is a singleton, and identity test >> is way faster than equality

Re: testing for valid reference: obj vs. None!=obs vs. obj is not None

2006-09-11 Thread Gabriel Genellina
At Monday 4/9/2006 17:02, alf wrote: I have a reference to certain objects. What is the most pythonic way to test for valid reference: By "valid reference" you mean, you have initially: obj = None and you want to detect whether obj is bound to another, different, object, right?

how can I create/set a 'file' reference in a attribute of a class

2007-02-26 Thread ken
Hi, i have a class: class LogHandler(ContentHandler): # a reference to a file open by some other function/class outputFile; def endElement(self, name): doSomething(self, "GroupResultList", self.text, outputFile) First, I get an error saying 'NameErr

Re: how can I create/set a 'file' reference in a attribute of a class

2007-02-26 Thread Larry Bates
ken wrote: > Hi, > i have a class: > > class LogHandler(ContentHandler): > # a reference to a file open by some other function/class > outputFile; > > > def endElement(self, name): > doSomething(self, "GroupResultList", self.text, o

Re: how can I create/set a 'file' reference in a attribute of a class

2007-02-26 Thread Bjoern Schliessmann
ken wrote: > Hi, > i have a class: > > class LogHandler(ContentHandler): > # a reference to a file open by some other function/class > outputFile; What do you intend to achieve with this last line, and what's the ';' for? > First, I get an

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Wildemar Wildenburger
Bruno Desthuilliers wrote: > here's an example using a property: > > class cpu_ports(object): > def __init__(self, value=0): > self._d = value > @apply > def value(): > def fset(self, value): > print 'vv' > self._d = value > def fget(self)

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Diez B. Roggisch
Wildemar Wildenburger wrote: > Bruno Desthuilliers wrote: >> here's an example using a property: >> >> class cpu_ports(object): >> def __init__(self, value=0): >> self._d = value >> @apply >> def value(): >> def fset(self, value): >> print 'vv' >>

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Brian van den Broek
Wildemar Wildenburger said unto the world upon 05/23/2007 08:43 AM: > Bruno Desthuilliers wrote: >> here's an example using a property: >> >> class cpu_ports(object): >> def __init__(self, value=0): >> self._d = value >> @apply >> def value(): >> def fset(self, value): >

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Peter Otten
Brian van den Broek wrote: > I had the same sort of question as Wildemar and I set about > investigating as any good pythonista would by typing help(apply) at > the interactive prompt. That produced a help text that started: > > Help on built-in function apply in module __builtin__: > > But: >

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Brian van den Broek
Peter Otten said unto the world upon 05/23/2007 01:32 PM: > Brian van den Broek wrote: >> Help on built-in function apply in module __builtin__: >> >> But: >> >> >>> [x for x in dir('__builtin__') if 'apply' in x] >> [] >> >> ? If apply is in the __builtin__ module, why doesn't >> dir('__built

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Wildemar Wildenburger
Diez B. Roggisch wrote: > It is that very apply. > > And apply takes a function as argument + additional arguments, and executes > that function, returning the result of that function-call. It was used > before the > > f(*args, **kwargs) > > notation was introduced. > > Now what we have here is "v

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Diez B. Roggisch
Wildemar Wildenburger schrieb: > Diez B. Roggisch wrote: >> It is that very apply. >> >> And apply takes a function as argument + additional arguments, and >> executes >> that function, returning the result of that function-call. It was used >> before the >> f(*args, **kwargs) >> >> notation was i

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread George Sakkis
On May 23, 6:22 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > > It is that very apply. > > > And apply takes a function as argument + additional arguments, and executes > > that function, returning the result of that function-call. It was used > > before the > > >

Re: Properties/Decorators [WAS: Can I reference 1 instance of an object by more names ? rephrase]

2007-05-23 Thread Wildemar Wildenburger
Diez B. Roggisch wrote: > Deprecated doesn't mean it's not available. Is that so? ;) But it certainly means that some time in the not-too-distant future "apply" will vanish. > And even if it goes away, > you can simply write it yourself: > > def apply(f, *args, **kwargs): > return f(*args,

Python 2.3.5 make: *** [Parser/pgen] Error 1 Parser/grammar.o: I n function `translabel': undefined reference to `__ctype_b'

2005-04-14 Thread Karalius, Joseph
pec/Parser/grammar.c:183: undefined reference to `__ctype_b' Parser/tokenizer_pgen.o: In function `tok_get': itimerspec/Parser/tokenizer.c:1150: undefined reference to `__ctype_b' itimerspec/Parser/tokenizer.c:1262: undefined reference to `__ctype_b' itimerspec/Parser/tokenizer.

Re: Python 2.3.5 make: *** [Parser/pgen] Error 1 Parser/grammar.o: I n function `translabel': undefined reference to `__ctype_b'

2005-04-14 Thread Diez B. Roggisch
Karalius, Joseph wrote: > Can anyone explain what is happening here? I haven't found any useful > info on Google yet. What have you been googling? I found this: http://lists.debian.org/debian-glibc/2002/10/msg00093.html Basically it seems that it's a problem with libc in general, not with pyth

<    1   2   3   4