On Mon, Jan 9, 2012 at 7:35 PM, contro opinion wrote:
> code1:
>
> def FirstDeco(func):
> print 'haha'
> y=func()
> return y
> print y
Since there's a `return` right before it, the latter `print` here will
*never* be executed.
Cheers,
Chris
--
http://mail.python.org/mailman/listinf
code1:
def FirstDeco(func):
print 'haha'
y=func()
return y
print y
@FirstDeco
def test():
print 'asdf'
return 7
result :
haha
asdf
code2:
def FirstDeco(func):
print 'haha'
y=func()
#return y
print y
@FirstDeco
def test():
print 'asdf'
return 7
result :
h
On Jul 31, 10:22 pm, "Mark Tolonen" wrote:
> "legard_new" wrote in message
>
> news:70faf0b4-fead-49ac-bf18-e182fd63b...@j8g2000yqd.googlegroups.com...
>
>
>
>
>
> > Hello,
>
> > I have a problem with calling Callback function with Python. I have a
> > DLL file.
>
> > Below is a description in do
"legard_new" wrote in message
news:70faf0b4-fead-49ac-bf18-e182fd63b...@j8g2000yqd.googlegroups.com...
Hello,
I have a problem with calling Callback function with Python. I have a
DLL file.
Below is a description in documentation.
FUNCTION Callback
Arguments: Callback ID integer read-only, i
Hello,
I have a problem with calling Callback function with Python. I have a
DLL file.
Below is a description in documentation.
FUNCTION Callback
Arguments: Callback ID integer read-only, immediate value
CBackProc address read-only, immediate value
willie wrote:
My code:
from time import time
def leibniz(terms):
acc = 0.0
num = 4.0 # numerator value remains constant in the series
den = 1
count = 0
start_time = 0.0
for aterm in range(terms):
nextterm = num/den * (-1)**aterm # (-1) allows fractions to
alter
On Thu, 27 Nov 2008 11:17:04 -0800, willie wrote:
> My code:
>
> from time import time
> def leibniz(terms):
>
>
> acc = 0.0
> num = 4.0 # numerator value remains constant in the series den = 1
> count = 0
> start_time = 0.0
This line is wrong. You're starting your timer at the
willie wrote:
> My code:
>
> from time import time
> def leibniz(terms):
>
>
> acc = 0.0
> num = 4.0 # numerator value remains constant in the series
> den = 1
> count = 0
> start_time = 0.0
> for aterm in range(terms):
> nextterm = num/den * (-1)**aterm # (-1)
My code:
from time import time
def leibniz(terms):
acc = 0.0
num = 4.0 # numerator value remains constant in the series
den = 1
count = 0
start_time = 0.0
for aterm in range(terms):
nextterm = num/den * (-1)**aterm # (-1) allows fractions to
alternate
[EMAIL PROTECTED] wrote:
> I convert all to lowercase,
>
> import string
>
> small = string.lower(name)
> print "Here is the calculated value:"
>
> print small
> for ch in small:
> v = ord(ch)-96
> print v
>
I don't know if you are using an
[EMAIL PROTECTED] writes:
> for ch in small:
> v = ord(ch)-96
> print v
total = 0
for ch in small:
# the += below updates the value of total by adding (ord(ch) - 96)
total += (ord(ch) - 96)
print "ch:", ch, "total so far:", total
--
http://mail.python
print sum([ord(ch)-96 for ch in small])
On Mon, Mar 17, 2008 at 11:28 PM, <[EMAIL PROTECTED]> wrote:
> I'm trying to convert a name into a numerical value that is not
> consistent with ANSCII values. In my case, I convert all to lowercase,
> then try to sum the value of the letters entered by t
I'm trying to convert a name into a numerical value that is not
consistent with ANSCII values. In my case, I convert all to lowercase,
then try to sum the value of the letters entered by the user, can't
get it to add them. Here is what I have. By the way, the values I need
to use is: a=1, b=2, c=3,
Thanks so much! that did it!
you can tell I'm new with python.. lol...
thanks again..
Jonathan
--
http://mail.python.org/mailman/listinfo/python-list
At Thursday 25/1/2007 01:26, kevin wrote:
Hi... I'm having a few problems here...
I want to input in my function different values and then time each one
to see how long it took to run the function... so right now it doesn't
like the "i" inside my function fibonacci(i) but if I put a constant
it
Hi... I'm having a few problems here...
I want to input in my function different values and then time each one
to see how long it took to run the function... so right now it doesn't
like the "i" inside my function fibonacci(i) but if I put a constant
it's fine
any idea on how to approach this?
Carl Banks wrote:
> kelin,[EMAIL PROTECTED] wrote:
>> It says the __init__ is called immediately after an instance of the
>> class is created. What dose "immediately" mean?
>> And what is difference between the init method and the constructor in
>> Java?
>
> For all intents and purposes, __init__
Hi,
I've read all of this. And I am clear about it.
Thanks all.
Best Regards!
Gabriel Genellina wrote:
> At Tuesday 7/11/2006 21:47, Jia Lu wrote:
>
> > > In Python, the real constructor is called __new__, >
> > > Carl Banks
> >
> >But the code below won't invoke __new__:
>
> Is this a question, o
At Tuesday 7/11/2006 21:47, Jia Lu wrote:
> In Python, the real constructor is called __new__, >
> Carl Banks
But the code below won't invoke __new__:
Is this a question, or just for making things more and more confusing
to beginners?
class Test:
def __new__(self, value):
prin
> In Python, the real constructor is called __new__, >
> Carl Banks
But the code below won't invoke __new__:
[CODE]
class Test:
def __new__(self, value):
print "__new__",value
def __init__(self,value):
print "__init__",value
x = Test("testing")
[/CODE]
--
http://mail.p
kelin,[EMAIL PROTECTED] wrote:
> It says the __init__ is called immediately after an instance of the
> class is created. What dose "immediately" mean?
> And what is difference between the init method and the constructor in
> Java?
For all intents and purposes, __init__ is a constructor. It isn't
Steven D'Aprano ha escrit:
> Once the __new__ method creates the instance and returns, before anything
> else happens, the instance's __init__ method is called.
This only happens when the object created by __new__ isinstance of the
class invoked in the creation statement, that is:
s=MagicStr("l
On Tue, 07 Nov 2006 05:26:07 -0800, kelin,[EMAIL PROTECTED] wrote:
> Hi,
>
> Today I read the following sentences, but I can not understand what
> does the __init__ method of a class do?
Play around with this class and see if it helps:
class MagicStr(str):
"""Subclass of str with leadi
"kelin,[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Today I read the following sentences, but I can not understand what
> does the __init__ method of a class do?
> __init__ is called immediately after an instance of the class is
> created. It would be tempting but incorrect to call this the
> c
Hi,
Today I read the following sentences, but I can not understand what
does the __init__ method of a class do?
__init__ is called immediately after an instance of the class is
created. It would be tempting but incorrect to call this the
constructor of the class. It's tempting, because it looks li
[EMAIL PROTECTED] wrote:
> hello, recently i tried to use list.append() function in seemingly
> logical ways,
What seems logical and how it really works may not be the same... As a
general rule, for builtin types, destructive methods returns None. I
personnaly find it a wart, but what, it's the B
# Try This
seed = [2, 3, 4, 5]
next = [7]
seed1 = seed + next
[EMAIL PROTECTED] wrote:
> hello, recently i tried to use list.append() function in seemingly
> logical ways, however, i cannot get it to work, here is the test code:
>
seed = [2, 3, 4, 5]
next = 7
seed1 = seed.append(
seed = [1,2,3]
seed.append(4)
print seed # [1,2,3,4]
many of the list methods are in place methods on a mutable object. In
other words, doing the following results in None.
seed = [1,2,3]
seed = seed.append(4)
print seed # None
you also just wiped out your list... The append method like many o
On 28/04/2006 1:49 PM, [EMAIL PROTECTED] wrote:
> hello, recently i tried to use list.append() function in seemingly
> logical ways, however, i cannot get it to work, here is the test code:
>
seed = [2, 3, 4, 5]
next = 7
seed1 = seed.append(next)
seed1
print(str(seed1))
>
A typo here? seed v/s seed1.
Instead of "print(seed.append(5))", try "seed.append(5)" followed by
"print seed" -- "print(seed)" also works. The append method does not
return the appended value
(like many C functions).
- Murali
--
http://mail.python.org/mailman/listinfo/python-list
hello, recently i tried to use list.append() function in seemingly
logical ways, however, i cannot get it to work, here is the test code:
>>> seed = [2, 3, 4, 5]
>>> next = 7
>>> seed1 = seed.append(next)
>>> seed1
>>> print(str(seed1))
None
>>> def test(lst):
... print(str(lst))
...
>>> test(
On Tue, 06 Sep 2005 09:27:48 +0200, mg <[EMAIL PROTECTED]> wrote:
>Hi everybody...
>
>We try to white scripts with Pyrhon 2.4 for an acoustic simulation and
>we wrote these follow lines :
>
>
>c = 340
340 is an integer, which is different from 340.
>i =j=k= 1
>sum_ = 23
also an integer
>table = [
mg wrote:
> The problem is simple. The function 'round' allow to obtain the value
> with the specified number of digits after the ",". Then, when the
> variable 'freq' is printed, there is no problem; but when freq is set in
> the table and the table printed, all the digits are come back.
>
> I
mg wrote:
> Is it a bug or a control behavour ? I don't understand ?!?!?!?!...
It's a case of applying different float-to-text rounding in different
situations, on a variable that (even after round()) is not representable
in binary floatingpoint.
"print var" does one sort of string conversion
"mg" wrote:
> We try to white scripts with Pyrhon 2.4 for an acoustic simulation and
> we wrote these follow lines :
>
>
> c = 340
> i =j=k= 1
> sum_ = 23
> table = []
> freq = round((c/2*(sum_)**0.5),2)
> print freq
> table.append([freq,(i,j,k)])
> print i,j,k,' freq',freq
> for item in table: p
Hi everybody...
We try to white scripts with Pyrhon 2.4 for an acoustic simulation and
we wrote these follow lines :
c = 340
i =j=k= 1
sum_ = 23
table = []
freq = round((c/2*(sum_)**0.5),2)
print freq
table.append([freq,(i,j,k)])
print i,j,k,' freq',freq
for item in table: print item
The prob
On Tue, 16 Aug 2005 18:46:30 +0200, "wierus" <[EMAIL PROTECTED]> wrote:
>Hello, i have a problem. I write my first class in python so i'm not a
>experience user. I want to call a function in another function, i tried to
>do it in many ways, but i always failed:(
>I supposed it's sth very simple b
On Tue, 16 Aug 2005 18:45:51 +0200, wierus wrote:
> Hello, i have a problem. I write my first class in python so i'm not a
> experience user. I want to call a function in another function, i tried to
> do it in many ways, but i always failed:(
> I supposed it's sth very simple but i can't figu
Larry Bates wrote:
> def __init__(self, x=1, y=2)
[snip]
> self.x=x
> self.y=y
> self.a=0
> return
>
> def l(self):
[snip]
> self.a=self.x+self.y
> print "In ludzik.l a=',self.a
> return
>
> def ala(self):
[snip]
> self.l
wierus wrote:
> class ludzik:
> x=1
> y=2
> l=0
> def l(self):
> ludzik.l=ludzik.x+ludzik.y
> print ludzik.l
>
> def ala(self):
> print ludzik.x
> print ludzik.y
> ludzik.l()
Methods defined in a class expect an instance of that class as the first
argument. When you write:
l
Try something like:
class ludzik:
#
# Define an __init__ method that gets called when
# you instantiate the class. Notice also that I've
# allowed you to set x, and y parameters if you like.
# If you don't pass them they default to 1 and 2 as
# in your example.
#
Hello, i have a problem. I write my first class in python so i'm not a
experience user. I want to call a function in another function, i tried to
do it in many ways, but i always failed:(
I supposed it's sth very simple but i can't figure what it is:
==
class lud
Hello, i have a problem. I write my first class in python so i'm not a
experience user. I want to call a function in another function, i tried to
do it in many ways, but i always failed:(
I supposed it's sth very simple but i can't figure what it is:
==
class ludzik
43 matches
Mail list logo