On 1/9/2011 4:42 PM, Alan Gauld wrote:
"Corey Richardson" wrote
Do all classes need an __init__() method? I have classes that look much
like this one starts out:
No, init() is only for initialising the object instance.
If you have no local instance spwecific initialisation
you can leave it
Hey I write this code up
from Tkinter import *
root=Tk()
var=StringVar()
c=Checkbutton(root,text="hello",variable=var,onvalue="",offvalue="")
c.pack()
root.mainloop()
and i got the output as -
[image: Screenshot.png]
When i take the var as of string variable type i am unable to edit the
"Karim" wrote
I am using more and more try except statement. But I discussed with
a very experienced C++ programmer.
And he told me that at least in C++ using too many try -catch
statements are making the code slower.
That's true, but Bjarne Stroustrup put them in for a reason - and they
are
On 1/9/11, Karim wrote:
>
> Hello all,
>
> I am using more and more try except statement. But I discussed with a
> very experienced C++ programmer.
> And he told me that at least in C++ using too many try -catch statements
> are making the code slower. And it should
> does the same for python (C i
Karim wrote:
Hello all,
I am using more and more try except statement. But I discussed with a
very experienced C++ programmer.
And he told me that at least in C++ using too many try -catch statements
are making the code slower. And it should
does the same for python (C implementation).
He
* Steven D'Aprano [110109 13:23]:
> Tim Johnson wrote:
<...>
>>> Are you aware that this is non-portable and subject to change without
>>> notice?
>> No! 1)Can you explain further?
<.>
Wow! You've given me a huge amount of technical information. I can't
thank you enough for the time and
Hello all,
I am using more and more try except statement. But I discussed with a
very experienced C++ programmer.
And he told me that at least in C++ using too many try -catch statements
are making the code slower. And it should
does the same for python (C implementation). My simple question:
Tim Johnson wrote:
* Steven D'Aprano [110108 19:46]:
A more detailed response.
Dear me... messing with globals and locals. That's always a bad sign.
But let's assume this is that one time in 100 that it is actually
justified...
if localvals is None: self.locals =
sys
"Corey Richardson" wrote
Do all classes need an __init__() method? I have classes that look
much
like this one starts out:
No, init() is only for initialising the object instance.
If you have no local instance spwecific initialisation
you can leave it to the inherited init() aor have no ini
Corey Richardson wrote:
Do all classes need an __init__() method? I have classes that look much
like this one starts out:
class GenerateXML(object):
"""Defines methods to be inherited for StaticXML and AnimationXML"""
def __init__(self):
pass
I would rather not do that. Code wit
(Don't top-post. You keep putting your responses out of order.)
On 01/-10/-28163 02:59 PM, tee chwee liong wrote:
i modified the code to be:
fname = "sampledata.txt"
pattern = "-1"
failed = False
for line in open(fname):
data=line.split()
if len(data)==4:
port, channel, lane
Do all classes need an __init__() method? I have classes that look much
like this one starts out:
class GenerateXML(object):
"""Defines methods to be inherited for StaticXML and AnimationXML"""
def __init__(self):
pass
I would rather not do that. Code without it runs fine, but wil
* Steven D'Aprano [110108 19:46]:
> A more detailed response.
>
> Dear me... messing with globals and locals. That's always a bad sign.
> But let's assume this is that one time in 100 that it is actually
> justified...
>
>> if localvals is None: self.locals =
>> sys._getfr
hi all,
thanks for all your advice, i really learn a lot.
finally i modified the code to be working as:
fname = "sampledata.txt"
pattern = "-1"
failure = False
for search in open(fname):
if pattern in search:
#print search
#print failure
failure=True
prin
i modified the code to be:
fname = "sampledata.txt"
pattern = "-1"
failed = False
for line in open(fname):
data=line.split()
if len(data)==4:
port, channel, lane, eyvt = data
else:
if int(eyvt) == -1:
failed = True
print "Lane %s failed."
> thanks this solve the error but running the code produces another error ie
>index out of range.
> if line[3] == pattern:
> IndexError: list index out of range
So you need to check that there are at least 4 elements in the line before
trying to access it. Or else catch the exception (see my
thanks this solve the error but running the code produces another error ie
index out of range.
Traceback (most recent call last):
File "C:\Python25\myscript\log\readfile9.py", line 22, in
if line[3] == pattern:
IndexError: list index out of range
> To: tutor@python.org
> From: alan.ga...
"tee chwee liong" wrote
File "C:/Python25/myscript/log/readfile9.py", line 5, in
port, channel, lane, eyvt = line.split()
ValueError: need more than 2 values to unpack
So you need to ensure that you unpack when you have the right
number of fields:
either:
data = line.split()
if len(dat
hi,
thanks for the explanation. if i print out line=line.split(), below is the
result:
['Platform:', 'PC']
['Tempt', ':', '25']
['TAP0', ':0']
['TAP1', ':1']
[]
['+']
['Port', 'Chnl', 'Lane', 'EyVt']
['+']
> The following line is what I mean by calling a command line from within the
>app
> using subprocess.
>
> self.espeak = subprocess.Popen(['espeak', word],stdout =
> subprocess.PIPE).communicate()[0]
OK, Now I understand.
You want to call an external application from within your code
via
"tee chwee liong" wrote
i got syntax error when running this line:
data = for line in open(filename) if not line.startswith("#")
Should be:
data = [ line for line in open(filename) if not line.startswith("#") ]
Notice the extra line at the beginning and the fact that it is
surrounded by []
hi,
yes you are right, the output below is my desired outcome. the sampledata i
have can't be added with #.
i got syntax error when running this line:
data = for line in open(filename) if not line.startswith("#")
pls advise.
thanks
tcl76
> Date: Sun, 9 Jan 2011 01:41:43 -0500
> From: kb1..
tee chwee liong wrote:
hi,
there is error when running the code:
Traceback (most recent call last):
File "C:/Python25/myscript/log/readfile9.py", line 5, in
port, channel, lane, eyvt = line.split()
ValueError: need more than 2 values to unpack
the error is due to below line code:
port, cha
hi,
there is error when running the code:
> Traceback (most recent call last):
> File "C:/Python25/myscript/log/readfile9.py", line 5, in
> port, channel, lane, eyvt = line.split()
> ValueError: need more than 2 values to unpack
the error is due to below line code:
>port, channel, lane, eyvt =
On Sat, Jan 8, 2011 at 9:10 AM, Alan Gauld wrote:
> "David Hutto" wrote
>
>> If I use as command line script, is there any disruption in the
>> execution of the code using wxpython.
>
> I don't understand the question.
> wxPython is a GUI toolkit so how would you have a command
> line script usin
25 matches
Mail list logo