""" Regex lookup..."""
return RegexBuilder.lookup_table[match.group()]
> 2009/2/3 andrew cooke
>>
>> > > ValueError: unconverted data remains: this is the remainder of the
>> > > log
>> > > line
>> > > that I do not care about
>>
>> you could catch the ValueError and split at the ':' in the .args
>> attribute to find the extra data. you could then find the extra data
>> in the original string, use the index to remove it, and re-parse the
>> time.
>>
>> ugly, but should work.
>> andrew
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
> Simon Mullis
> _
> si...@mullis.co.uk
>
--
http://mail.python.org/mailman/listinfo/python-list
On 11 November 2010 09:07, John Nagle wrote:
>>> Am 10.11.2010 18:56, schrieb Simon Mullis:
>>> Yes, eval is evil, may lead to security issues and it's unnecessary
>>> slow, too.
>
> If you have to use "eval", use the 2 or 3 argument form with a
Hi All,
I'm writing a Django App to webify a Python script I wrote that parses
some big XML docs and summarizes certain data contained within. This
app will be used by a closed group of people, all with their own login
credentials to the system (backed off to the corp SSO system). I've
already got
May I be the first to say "Doh!"
Problem solved, many thanks to both Carsten and Diez!
SM
2009/11/4 Carsten Haese :
> Simon Mullis wrote:
>> def main():
>> stats_obj = Statistic()
>> name = re.sub("[^A-Za-z]", "", sys.argv[0])
>&
Hi All,
I'm collating a bunch of my utility scripts into one, creating a
single script to which I will symbolic link multiple times. This way
I only have to write code for error checking, output-formatting etc a
single time.
So, I have
~/bin/foo -> ~/Code/python/mother_of_all_utility_scripts.
Forget it all... I was being very very daft!
The "default = 'False'" in the options for stdin was not being
evaluated as I thought, so the script was waiting for stdin even when
there was the glob switch was used...No stdin equals the script
seeming to "hang".
Ah well.
SM
--
http://mail.python.o
Last try at getting the indenting to appear correctly..
#!/usr/bin/env python
import glob, os, sys
class TestParse(object):
def __init__(self):
if options.stdin:
self.scan_data(sys.stdin)
if options.glob:
self.files = glob.glob(options.glob)
Hi Chris
2009/2/5 Chris Rebert
>
> I'd add some print()s in the above loop (and also the 'for f in files'
> loop) to make sure the part of the code you didn't want to share ("do
> stuff with the line") works correctly, and that nothing is improperly
> looping in some unexpected way.
The point is
h.py", line 35, in
main()
File "./test_fh.py", line 26, in main
T = TestParse()
File "./test_fh.py", line 8, in __init__
self.scan_data(sys.stdin)
File "./test_fh.py", line 18, in scan_data
for line in fileobject:
KeyboardInterrupt
# echo $?
1
So, what am I doing wrong?
Thanks in advance
SM
--
Simon Mullis
_
si...@mullis.co.uk
--
http://mail.python.org/mailman/listinfo/python-list
n the .args
> attribute to find the extra data. you could then find the extra data
> in the original string, use the index to remove it, and re-parse the
> time.
>
> ugly, but should work.
> andrew
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Si
Hi All
I'm writing a script to help with analyzing log files timestamps and have a
very specific question on which I'm momentarily stumped
I'd like the script to support multiple log file types, so allow a strftime
format to be passed in as a cli switch (default is %Y-%m-%d %H:%M:%S).
When i
Haha!
Thanks for all of the suggestions... (I love this list!)
SM
2008/9/18 <[EMAIL PROTECTED]>:
> On Sep 18, 10:54 am, "Simon Mullis" <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> Let's say I have an arbitrary list of minor software versions of an
>
unt", as I cannot do x += 1
or x++ as x may or may not yet exist, and I haven't found a way to
create default values.
I'm most probably not thinking pythonically enough... (I know I could
do this pretty easily with a couple more lines, but I'd like to
understand if there's a way to use a dict generator for this).
Thanks in advance
SM
--
Simon Mullis
--
http://mail.python.org/mailman/listinfo/python-list
Normally I would use a Ruby symbol as a hash key:
h = { :key1 => "val1", :key2 => "val2" }
>From the stdlib docs:
"The same Symbol object will be created for a given name or string for
the duration of a program's execution, regardless of the context or
meaning of that name. Thus if Fred is a constant in one context, a
method in another, and a class in a third, the Symbol :Fred will be
the same object in all three contexts. "
There is no equivalent in Python (as far as I know, and I'm only in my
second week of Python so I'm more than likely incorrect!).
If you're interested:
http://www.randomhacks.net/articles/2007/01/20/13-ways-of-looking-at-a-ruby-symbol
Thanks again for the pointers.
--
Simon Mullis
_
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
I ask is that I have some fairly complex data-structures
and this would make my code alot cleaner... If this is not an accepted
and pythonic way of doing things then please let me know... and I'll
stop!
Thanks in advance
SM
--
Simon Mullis
_
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
In case anyone else has the same question:
This has been very useful: http://www.poromenos.org/tutorials/python
Short, concise. Enough to get me going.
SM
2008/8/13 Simon Mullis <[EMAIL PROTECTED]>
> Hi All,
>
> I just finally found 30 minutes to try and write some cod
Hi there,
This works (but bear in mind I'm about only 30 minutes into my Python
adventure...):
--
def connect(host):
tn = telnetlib.Telnet(host)
return tn
def login(session,user,password):
session.write("\n")
session.read_until("Login: ")
sessi
Hi All,
I just finally found 30 minutes to try and write some code in Python and
realized after a couple of minor syntactic false starts that I'd finished my
initial attempt without needing to refer to any documention... And after the
first few minutes I stopped noticing the whitespace thing that
18 matches
Mail list logo