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
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
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
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
[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
[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
"[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
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
"[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
[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
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
Thank you!
I got it.
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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
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
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
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
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
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
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
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:
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
;
>>
>> 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
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
>
> 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
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
> 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
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
"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
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
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
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_
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&
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
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
> 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
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
"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
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
"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
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
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
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?
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,
> >
>
.
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,]
&
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
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
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
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?
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?
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
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
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
, 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
--
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[
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
# 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
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
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.
>
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.
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
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
>>
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):
>
>>>
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
>>>
> 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
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
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
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
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
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
> 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
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
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
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
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
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?
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
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
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
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)
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'
>>
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):
>
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:
>
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
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
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
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
>
> >
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,
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.
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
301 - 393 of 393 matches
Mail list logo