I'm trying to generate an HTML table, from multiple lists.
There are 4 lists total, each of which *may* have a different length from
the other lists.
Each list has been stored in a master dictionary.
North=[Bill, Bob, Sue, Mary]
South=['Tim', ''Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
etc
Hi,
I do see a problem.
The script is fine, the problem lies else where.
Your script is trying to write log.bak to log, it
should b other way round.
i.e
srcfile = open('/var/log/httpd-access.log', 'r')
dstfile = open('/var/log/httpd-access.log.bak', 'w')
hope that fixes it.
About the
Hi,
My solution might raise purist's eyebrows but here it
goes...
How about using a try loop every time you read from
the list.
try:
x=list[someno]
except:
x=nothing(or whatever)
This goes on till the all lists start returning none.
for shorter lists try throws an index out of range
On Mon, 7 Feb 2005, Tony Cappellini wrote:
There are 4 lists total, each of which *may* have a different length
from the other lists. Each list has been stored in a master dictionary.
North=[Bill, Bob, Sue, Mary]
South=['Tim', ''Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
etc
I want to
Tony Cappellini wrote:
I'm trying to generate an HTML table, from multiple lists.
There are 4 lists total, each of which *may* have a different length
from the other lists.
Each list has been stored in a master dictionary.
North=[Bill, Bob, Sue, Mary]
South=['Tim', ''Tom', 'Jim', 'John',
I completely understood what is acquisition. Now can
some one explain me where it is useful and give some
contextual examples where we can see the power of
acquisition.
regards
chandu.
__
Do you Yahoo!?
Yahoo! Mail - Helps protect you from
chandrasekhar cherukuri wrote:
I completely understood what is acquisition.
I don't :-)
Can you tell us what you mean by acquisition? I see Zope has something called acquisition; I can't
think of anything by that name in standard Python...
Kent
Now can
some one explain me where it is useful and
chandrasekhar cherukuri wrote:
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/ScriptingZope.stx/Acquisition.stx
http://zope.org/Members/crazybrett/acquisition
Hope there is no sarcasm in this.
No, none at all. A light irony, maybe. When I first read your post, I thought, I have no idea
Hello,
I've been writing some small python programs that basically do function
analysis on the (x,y) output of a fortran code called COBRA.
The COBRA output (basin.out) is the shape of a flexed beam, of which I
calculate the 0-crossing, x and y of max. amplitude, and cross sectional
area
Hi Karen,
if I have a file called foo.py =
def la()
return la
x = 15
I can do the following in bar.py =
import foo#Notice there's no .py extension!
j = foo.la()
print j
print foo.x
la
15
Hope that helps
Liam Clarke
On Mon, 07 Feb 2005 14:40:06 +0100, Karen Leever
[EMAIL
Actually, if I may rewrite some sections of your code -
example of (1):
-
#this part of the program reads the file basin.out (the data we want to
analyze) and changes its contents to the array arr_xy
#layout of basin.out:
#1
Hello All,
I've been trying to find more resources/documentation about how to
convert python lists to C arrays (and vice versa) when writing a python
extension. Surprisingly, there's very little one can find about this
even though it must be a fairly common procedure. I looked through
official
Liam Clarke wrote:
example of (1):
-
#this part of the program reads the file basin.out (the data we want to
analyze) and changes its contents to the array arr_xy
#layout of basin.out:
#1 -950.0010.00 200 this line contains
At 07:14 AM 2/7/2005, Smith, Jeff wrote:
Alan,
No use beating this dead horse...I guess that's why there are so many
languages in the first place. Different people are comfortable with
different things. (I did warn you that I like both Lisp and Prolog and
only wish I had more of a reason to use
That's kinda what I thought but a couple of people suggested that I used
lambdas to make it clearer that I figured I was doing something wrong...
Jeff
-Original Message-
From: Bob Gailer [mailto:[EMAIL PROTECTED]
Sent: Monday, February 07, 2005 9:48 AM
To: Smith, Jeff; tutor@python.org
At 07:43 AM 2/7/2005, Smith, Jeff wrote:
That's kinda what I thought but a couple of people suggested that I used
lambdas to make it clearer that I figured I was doing something wrong...
Well you can use lambdas. Have them return an expression which you print
after retrieving:
ftable = { 'a' :
Bob,
Unfortunately, that doesn't do the same thing. In the 'd' case, you get
a print rather than a pass for instance. It was also just happenstance
that I chose to print on each switch rather than do something like
increment a counter.
Jeff
-Original Message-
From: Bob Gailer
Bob Gailer wrote:
At 07:14 AM 2/7/2005, Smith, Jeff wrote:
Alan,
No use beating this dead horse...I guess that's why there are so many
languages in the first place. Different people are comfortable with
different things. (I did warn you that I like both Lisp and Prolog and
only wish I had more
[Reposting. Didnt make it the first time - Sandip]
Forwarded Message
From: Sandip Bhattacharya [EMAIL PROTECTED]
To: Python Tutor Mailing List tutor@python.org
Subject: want recommendations for interfacing with postgresql
Date: Mon, 07 Feb 2005 20:39:27 +0530
Hi!
I am planning
Out of curiosity, if it's not possible to run zip() directly on the lists
that you have, can you bend the lists so that zip() will fit?
It is possible, however zip() truncates the longer list, based on the size
of the smaller list, so it's just not feasible in my case.
Here's a quick function
As an aside, I did try to create a lambda based solution but was
unable.
Let me know what's wrong:
ftable = { 'a' : lambda: print 'a',
SyntaxError: invalid syntax
I did say if Python had *proper* lambdas...
Unfortunately Python insists on only having *expressions* as
lambdas and since print
running the following with print i uncommented does print each line
to
stdout. but it doesn't write to the appropriate file...
Does it do anything?
BTW YOu don;t need to touch a file, the 'w' parameter will
create a new file if one doesn't exist.
c) I originally wanted to delete lines over
-Original Message-
From: Alan Gauld [mailto:[EMAIL PROTECTED]
Sent: Monday, February 07, 2005 2:49 PM
To: Reed L. O'Brien; tutor@python.org
Subject: Re: [Tutor] manipulating a file
You should add a newline character otherwise you will just
get one enormously long line!
That's kinda what I thought but a couple of people suggested
that I used lambdas to make it clearer
I suggested that if we had proper lambdas we could use 'em...
But of course you can still use lambdas just put the print
at the client side:
def p(): pass
ftable = { 'a' : lambda: 'a',
Well you can use lambdas. Have them return an expression which you
print
after retrieving:
ftable = { 'a' : lambda: 'a',
'b' : lambda: 'b or c',
But it would be clearer to store just the expressions:
ftable = { 'a' : 'a',
'b' : 'b or c',
True for this special
Alan,
That's actually worse than you might think. Try this:
var = 'd'
def p(): pass
ftable = { 'a' : lambda: 'a',
'b' : lambda: 'b or c',
'c' : lambda: 'b or c',
'd' : lambda: p}
print ftable.get(var, lambda: 'default case')()
And what you get is:
function p
Hi Chandu,
Ah, so you're looking into environmental acquisition. I think the
reason you're asking about on Tutor is because one of the most visible
deployments of acquisition has been in the Zope web framework.
But just because Zope is written in Python doesn't mean that acquisition
is a
How about
cat log|grep -v -E [[:alnum]]'{2096}' log.bak
The issue is - will unix shell command be any more
efficient than a python script??
Also i used append because i gathered that the user
will not want to erase the previous logs. He is free
to use a single if he does.
--- Alan Gauld
Liam Clarke wrote:
oh? Is is the negative?
No, the decimal fraction. It's easy enough to try it:
int('950')
950
int('-950')
-950
int('950.00')
Traceback (most recent call last):
File stdin, line 1, in ?
ValueError: invalid literal for int(): 950.00
int('-950.00')
Traceback (most recent
On Mon, Feb 07, 2005 at 01:01:29PM -0800, Shitiz Bansal wrote:
How about
cat log|grep -v -E [[:alnum]]'{2096}' log.bak
UUOC (Useless Use Of Cat)
SCNR
Jo!
--
You're at the end of the road again.
___
Tutor maillist - Tutor@python.org
without the explicit newlines in file.write(i), could it be that the
file was closed before the write buffer was ever flushed?
mike
On Mon, 7 Feb 2005 14:58:03 -0500, Smith, Jeff [EMAIL PROTECTED] wrote:
-Original Message-
From: Alan Gauld [mailto:[EMAIL PROTECTED]
Sent: Monday,
On Mon, 7 Feb 2005, Viktor Hornak wrote:
I've been trying to find more resources/documentation about how to
convert python lists to C arrays (and vice versa) when writing a python
extension.
Hi Viktor,
There was a post back in 1999 that might be useful for you:
Reed L. O'Brien wrote:
I want to read the httpd-access.log and remove any oversized log records
I quickly tossed this script together. I manually mv-ed log to log.bak
and touched a new logfile.
running the following with print i uncommented does print each line to
stdout. but it doesn't write
That's actually worse than you might think. Try this:
def p(): pass
ftable = { 'a' : lambda: 'a',
'd' : lambda: p}
That should be:
'd': p}
ie No lambda used at all.
I wish Python had real lambdas!
And what you get is:
function p at 0x009BDFB0
Yep, coz the lambda
without the explicit newlines in file.write(i), could it be that the
file was closed before the write buffer was ever flushed?
No because close() was called explicitly, which does a flush first...
Alan G.
___
Tutor maillist - Tutor@python.org
Alan Gauld wrote:
ie No lambda used at all.
I wish Python had real lambdas!
If python had real lambda's then it would be lisp or schema.
__
Do you Yahoo!?
Yahoo! Mail - now with 250MB free storage. Learn more.
I aplogise for a typo...
Please read the command as:
cat log|grep -v -E [[:alnum]]'{2096,}' log.bak
note the missing comma in the previous command.
--- Shitiz Bansal [EMAIL PROTECTED] wrote:
How about
cat log|grep -v -E [[:alnum]]'{2096}' log.bak
The issue is - will unix shell
Alan Gauld wrote:
As an aside, I did try to create a lambda based solution but was
unable. Let me know what's wrong:
ftable = { 'a' : lambda: print 'a',
SyntaxError: invalid syntax
I did say if Python had *proper* lambdas...
Unfortunately Python insists on only having *expressions* as
lambdas and
map(None, North, South, East West) does exactly what you want:
North=['Bill', 'Bob', 'Sue', 'Mary']
South=['Tim', 'Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
map(None, North, South)
[('Bill', 'Tim'), ('Bob', 'Tom'), ('Sue', 'Jim'), ('Mary', 'John'), (None,
'Carl'), (None, 'Evan'),
Hi everybody,
I have a data packet in Hex values and need to determine how to calculate the CRC-16 bit checksum for these values.
Eg.:
0x55,0x00,0x0A,0x01,0x01, 0x01,0xFF,0x00,0xDC,0xCC
Sync| Lenght |source addr|dest. adr |Data| CRC check|
This example shows me the CRC chechsum, but if I
40 matches
Mail list logo