hi,
i have a sampledata as below. Pls refer to output, if found -1, how to list out
all the Lane number? And if there is no -1, print PASS. My code is as below
section.
thanks
tcl76
sampledata
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
port, channel, lane, eyvt = line.split()
pls advise.
thanks
tcl76
> Date: Sun, 9 Jan 2011 17:44:58 +1100
> From: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
> Please excuse the double post, I had a pr
-0500
> From: kb1...@aim.com
> To: tutor@python.org
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
> On 01/09/2011 01:25 AM, tee chwee liong wrote:
> > hi,
> >
> > i have a sampledata as below. Pls refer to output, if found -1, how to
&
#x27;, '3', '-1']
['0', '1', '4', '-1']
['0', '1', '5', '10']
['+']
['Time:', '20s']
that's why port, channel, lane, eyv
t; From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:07:39 +
> Subject: Re: [Tutor] Open a text file, read and print pattern matching
>
>
> "tee chwee liong" wrote
>
> > i got syntax error when running this line:
> > data = for line in o
teral for int() with base 10: 'EyVt'
pls help to advise. don't understand int() with base 10 mean?
thanks
tcl76
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:14:17 +
> Subject: Re: [Tutor] Open a text file, read and prin
failure=True
print 'Lane', search.split()[2], 'Fail'
if not failure:
print "All Lanes Pass"
thanks
tcl76
> To: tutor@python.org
> From: alan.ga...@btinternet.com
> Date: Sun, 9 Jan 2011 14:14:17 +
> Subject: Re: [Tutor] Open a
hi,
When I do print "Hello World", it will print to the cmd window with the
standard font size. Is there a way we can increase the font size to larger when
print out to the cmd window?
thanks
tcl76 ___
Tutor ma
tim, you are right. i'm using Windows XP and Python 2.5.
thanks
tcl76
> Date: Tue, 11 Jan 2011 09:21:26 +
> From: m...@timgolden.me.uk
> CC: tutor@python.org
> Subject: Re: [Tutor] Change Font Size when print to screen
>
> On 11/01/2011 09:03, tee chwee liong wro
hi all,
i'm new to python and this is advanced for me. is there a way to plot data with
python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis as
attached or below.
currently i'm using Python2.5 and Win XP. thanks a lot.
Eg:
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
+
utor@python.org
On Tue, Jan 18, 2011 at 4:30 AM, tee chwee liong wrote:
hi all,
i'm new to python and this is advanced for me. is there a way to plot data with
python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis as
attached or below.
currently i'm using Pyth
To: tutor@python.org
> Subject: Re: [Tutor] How to plot graph?
>
> tee chwee liong wrote:
> > hi all,
> >
> > i installed matplotlib, numpy and scipy. i tried to run attached script to
> > learn how it plot a grph but got error as below:
>
> If you're having
hi,
i'm using python 2.5 and windows xp.
my sample data is as below. i intend to plot EyVt and EyHt on the Y-axis and
Lane as the X-axis.
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
+
Port Chnl Lane EyVt EyHt
+
hi,
i have a set of data and using re to extract it into array. however i only get
positive value, how to extract the whole value including the -ve sign?
For eg:
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
+
Port Chnl Lane EyVt EyHt
+
>
> On Sat, Jan 22, 2011 at 7:38 PM, tee chwee liong wrote:
> > hi,
> >
> > i have a set of data and using re to extract it into array. however i only
> > get positive value, how to extract the whole value including the -ve sign?
1 at 12:38:10AM +, tee chwee liong wrote:
> > i have a set of data and using re to extract it into array. however i only
> > get positive value, how to extract the whole value including the -ve sign?
> > numbers = re.findall("\d+", line)
>
> The \d matches
elegant. :)
simple yet elegant.
> Date: Sun, 23 Jan 2011 14:10:35 +1100
> From: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] Help on RE
>
> tee chwee liong wrote:
> > thanks for making me understand more on re. re is a confusing topic as i
maybe you can use raw_input?
Date: Tue, 25 Jan 2011 19:51:28 -0700
From: i.eat.brain...@gmail.com
To: tutor@python.org
Subject: [Tutor] Shuts down when asking user for info
Please help , run the script and see that once you press enter after
entering name it just shuts it down, help.
hi,
i'm confuse on how does ^ and | mean. When i tried |, i thought it is addition
but 4|4 also give 4?
>>> 4|2
6
>>> 4|1
5
>>> 4|3
7
>>> 4|4
4
When i tried ^, looks like subtraction but 2^4 gives 6?
>>> 2^3
1
>>> 2^2
0
>>> 2^4
6
Pls help to clear my confusion. thanks.
thanks for showing the path.. :)
From: waynejwer...@gmail.com
Date: Fri, 28 Jan 2011 09:17:36 -0600
Subject: Re: [Tutor] What does ^ and | mean?
To: tc...@hotmail.com
CC: tutor@python.org
On Fri, Jan 28, 2011 at 9:09 AM, tee chwee liong wrote:
hi,
i'm confuse on how does ^ and |
hi all,
i have a function which returns a string. for eg: X='101110'. i want to search
for 0 and highlight the location.
i am thinking of defining X as a list. but how can i split 101110 as there are
no spaces in between? i'm thinking if i can put it into a list:
X=['1','0','1','1','1','0'],
hi all,
thanks for the advice. i modified my code to be:
c=('01101')
i=-1
try:
while 1:
i=c.index('0',i+1)
print "Lane fail",i
except ValueError:
print "All Lanes PASS"
pass
when i run, the result is:
>>>
Lane fail 0
Lane fail 3
All Lanes PASS
Qu
> I'm not sure what you mean by highlight the location.
> Is it a GUI? Are you colour coding the characters?
>
hi,
no it is not GUI. i just want to know where is the location of the 0 in the
returned string. For eg: 10111, i want to say 0 is at lane 3 (calculating
location from right to le
> `while i < len(c)` instead of `while 1`
>
hi,
i modified codes to be i>>
Lane fail 0
Lane fail 3
All Lanes PASS
>>>
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options
hi all,
the code works:
s='00101'
found = False
for i,c in enumerate(s):
if c == '0':
print 'Lane fail',i
found = True
if not found: print 'All lanes PASS
#
Result:
>>>
Lane fail 0
Lane fail 1
Lane fail 3
>>>
the enumerate is checking from left to right. is
> No, it doesn't work. You haven't sufficiently tested it. It tells lies:
>
>
> >>> s='11100101'
> >>> found = False
> >>> for i,c in enumerate(s):
> ... if c == '0':
> ... print 'Lane fail',i
> ... found = True
> ... if not found: print 'All lanes PASS'
> ...
> All lanes PASS
> All lanes PASS
>
hi,
i'm using Python 2.5 and Win XP.
i want to extract the last column of the attached text file and group 128
characters to each row. want the result to look like:
Row1=X.1XXX (total of 128 char)
Row2=11XX...X1XX (total of 128 char)
> for i in range(0, len(values), 128):
> # Step through the list of values, starting at 0,
> # taking 128 items at a time.
> temp = values[i:i+128]
> # Join the values into a string.
> s = ''.join(temp)
> # And make a row with a label.
> row = "Row" + str(counter) + " = " + s
> print row
> rows.ap
> How about some clues as to what you're trying to accomplish? This code
> is surprisingly verbose, and probably totally wrong. Anyway, each time
> you pop an item from the list, all the following ones change their
> index. So presumably there weren't still 79 items in the list by the
> time y
thanks everyone for the advice.
my code looks very messy... needs more practise.
From: waynejwer...@gmail.com
Date: Mon, 14 Feb 2011 05:15:26 -0600
Subject: Re: [Tutor] How to group data?
To: tc...@hotmail.com
CC: da...@ieee.org; tutor@python.org
On Sun, Feb 13, 2011 at 6:03 PM, tee chwee
hi all,
pls advise on:
Can Python 2.6.6 scripts be converted to .dll and read by C sharp?
Can Python 2.6.6 scripts be converted to .exe and read by C sharp?
thanks
tcl
___
Tutor maillist - Tutor@python.
any major differences using Iron Python vs Python 2.6.6? tq
From: waynejwer...@gmail.com
Date: Mon, 14 Feb 2011 23:58:44 -0600
Subject: Re: [Tutor] Py script conversion to .dll or .exe
To: tc...@hotmail.com
CC: tutor@python.org
On Mon, Feb 14, 2011 at 11:40 PM, tee chwee liong wrote:
hi
hi,
>>> bin(0xff0)
''
>>> bin(0xff1)
'0001'
>>> a=bin(0xff0)+bin(0xff1)
>>> a
'0001'
>>> b=0xff0
>>> c=0xff1
>>> d=b+c
>>> d
8161
>>> bin(d)
'1'
question:
1) why is it that a and d values are different? i'm using Python 2.5.
2) how to conv
hi,
i dont know why when i re-run bin(0xff0) today at IDLE Python 2.5, it gives me
traceback error.
>>> bin(0xff0)
Traceback (most recent call last):
File "", line 1, in
bin(0xff0)
NameError: name 'bin' is not defined
i guess Python 2.5 doesn't support binary conversion of hex. con
hi Francesco,
couldnt get hex of bin working on IDLE Python 2.5 when i type:
>>> hex(0b1001001001001001001)
SyntaxError: invalid syntax
>>> bin(0x49249)
Traceback (most recent call last):
File "", line 1, in
bin(0x49249)
NameError: name 'bin' is not defined
pls advise.
thanks
tcl
> The interesting questions are:
> 1- are you SURE you were using 2.5 yesterday?
> If so:
> 2- did you import some modules? Which ones?
> On my phone I have Python 2.5 too, and it gives the same errors to me.
>
> Is it possible that you upgrade to 2.6 or 2.7 ?
>
hi,
yes i'm sure using Python
hi,
i have a script that converts hex to bin and bin to hex back. however, when
converting back to hex the leading 0s are truncated. how to maintain the
leading 0s? tq
import binascii
import string
def byte_to_binary(n):
return ''.join(str((n & (1 << i)) and 1) for i in reversed(range(
hi,
is there a way to convert from string to long? for eg: i want to concatenate
all the arrays into data and make it same type (long) as data1.
code:
a='0x'
array0 = '00180400'
array1 = ''
array2 = 'fe0
> int(s,16) for a hex string
>
great but the leading zeroes are being truncated.
i want it to be:
0x00180400L
>>> array0='00180400'
>>> array1=''
>>> array=array0+array1
>>> a=int(a
>>> '0x' + hex(543)[2:].zfill(5)
'0x0021f'
this is a good way but it's still in string format. but if i convert it to
long, then the leading 0s will be truncated. i guess can't have it both way.
___ Tutor maillist -
Tutor@python.org To un
hi,
i'm confused with & and AND. for eg:
>>> 1110 & 0110
64
>>> 1110 and 0110
72
i'm expecting if 1110 and with 0110 will get 0110 or 6.
pls advise.
thanks
tcl
___
Tutor maillist - Tutor@python.org
To
> Binary (leading with '0b'):
> >>> 0b1110 & 0b0110
> 6
>
> Good luck,
>
> -Martin
>
my IDLE seems to be giving me some funny error. i'm using Python 2.5 and Win
XP. pls advise.
>>> a=0b110010
SyntaxError: invalid syntax
>>> 0b1110 & 0b0110
SyntaxError: invalid syntax
>>> 0b10
SyntaxErr
hi,
i found a module called xlwt (http://www.python-excel.org/) that can write to
Excel. i want the code to read from a file (robert.txt) and then write to excel
in a column. for eg:
cell col0, row0 = 0
cell col0, row1 = 0
cell col0, row2 = 0
cell col0, row3 = 1
cell col0, row4 = 0
cell col0,
> What does this comment mean? You don't have any commas in the file
> "robert.txt", and you don't actually do anything with or to commas in
> your code. I think that comment is false.
>
> > L = line.strip()
> > sheet.write(row,0,L)
>
> Here you write the entire contents of the file into one
thanks Steven, i get what you mean now. final code works:
import xlwt
"""Reads robert.txt"""
# Create workbook and worksheet
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('python')
row = 0 # row counter
f = open('robert.txt')
L = line.strip()
for c in L:
sheet.write(row,0,c)
bug in the previous code so the final code should be:
import xlwt
"""Reads robert.txt
This is the final script that writes by incrementing each row but maintain
one column"""
# Create workbook and worksheet
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('python')
row = 0 # row counter
f = ope
hi,
i would like to know the time taken to execute a certain task in python. i used
time.time and time.clock and i see the time taken is different? what is the
right method to use?
import time
def testtime(num):
start=time.time()
#print start
for n in range(num):
#print
hi,
i used profiler. but it gives 0 sec? is this expected? tq
>>> profile.run('import math')
3 function calls in 0.000 CPU seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
10.0000.0000.0000.000 :0(set
hi,
i want to read from a file which will indicate which operation to execute. so
i'm using configparser module. i want one.py to read a configuration file and
executes two.py and three.py. however, it only executes two.py and not three.py
codes. pls help advise.
thanks
tcl
+
as >>>.
i tried putting sys.exit().
thanks
cltee
Date: Mon, 4 Apr 2011 00:29:19 -0400
From: bgai...@gmail.com
To: tutor@python.org
Subject: Re: [Tutor] Calling another script
On 4/3/2011 11:58 PM, tee chwee liong wrote:
hi,
i want to read from a file which will indicate which
sys.exit().
thanks
cltee
Date: Mon, 4 Apr 2011 00:29:19 -0400
From: bgai...@gmail.com
To: tutor@python.org
Subject: Re: [Tutor] Calling another script
On 4/3/2011 11:58 PM, tee chwee liong wrote:
hi,
i want to read from a file which will indicate which operation to execute. so
i'm usin
thanks all for your advice. ___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
hi,
i just started to learn xml using python and i'm getting error when opening the
output xml. it doesnt give error when running.
i also tried to use python to output to a text file and it works without any
error. Pls advise me how i can rectify the error when opening the output xml.
attach
hi,
i'm using python to generate xml with elementtree api. and i'm getting error
when opening the output xml. it doesnt give error when running.
i also tried to use python to output to a text file and it works without any
error. Pls advise me how i can rectify the error when opening the out
hi Peter,
thanks for your reply. seems that xml doesnt accept a space in between.
anyway, the output generated is:
-
-
2
3
it overwrites every time the port number is incremented and only capture the
last iteration number. how can i modify it to capture all the iteration
011 10:39:48 +0200
> Subject: Re: [Tutor] Generating XML using Python
>
> tee chwee liong wrote:
>
> > thanks for your reply. seems that xml doesnt accept a space in between.
> > anyway, the output generated is:
> >
> > -
> >
> >
> > -
&g
> Do you want them all in one file? Move the code to create the root element
> and the code to write the file out of the loop.
>
> Do you want to write multiple files? Use a different name from every file.
>
yes i would like to generate 1 xml file by incrementing the port number in the
range
hi peter,
yes it worked after i moved the root outside the for loop.
code:
import elementtree.ElementTree as ET
lspeed=2
tspeed=3
f=open("out.txt", "w")
root = ET.Element("Test")
for port in range (1,9):
print "Port %d" %port
#root = ET.Element("Test")
f.write("Port %d\n" %port)
hi,
i'm a bit stuck here. i have a code dict1.py that writes to an xml and another
script parsedict1.py to parse the content of the xml.
when i write it to the xml i wrote it as dictionary but since it can't accept
dict format i convert it to string.
below is output of the parsedict1.py wh
hi Ron,
this is great for beginners like me. Could you pls provide the link. tq
Date: Wed, 20 Apr 2011 21:16:16 +0300
From: ron.rei...@gmail.com
To: tutor@python.org
Subject: [Tutor] learnpython.org - Free Interactive Python Tutorial
Hey.
I've created a website for learning Python inter
hi all,
thanks for this sharing. when i copy and run this code, i got this error:
Traceback (most recent call last):
File "C:/Python25/myscript/excel/sampleexcel.py", line 1, in
import csv
File "C:/Python25/myscript/excel\csv.py", line 3, in
w=csv.writer(open('output.csv','w'))
excellent it works. tq
Date: Wed, 11 May 2011 14:58:39 +0100
Subject: Re: [Tutor] create an xls file using data from a txt file
From: wpr...@gmail.com
To: tc...@hotmail.com
CC: taxbot...@gmail.com; tutor@python.org
On 11 May 2011 14:34, tee chwee liong wrote:
hi all,
thanks for this
hi all,
i just started python but i'm hearing there is cpython. what is it different
from python? is there any tutorials i can refer.
thanks
tcl ___
Tutor maillist - Tutor@python.org
To unsubscribe or change
is a rather advanced topic, however. If you nevertheless want to delve into
it, it might be a good idea to check out www.cython.org first.
2011/5/12 tee chwee liong
hi all,
i just started python but i'm hearing there is cpython. what is it different
from python? is there any tutori
64 matches
Mail list logo