Re: [Tutor] how to convert '\xf0' to 0xf0?

2008-12-11 Thread Steve Willoughby
ord('\xf0') ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] how to convert '\xf0' to 0xf0?

2008-12-11 Thread Chen Gang (Nokia-D/Beijing)
___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread bob gailer
Ravi Kondamuru wrote: Reasons for C: 1. The log files I am working are 60-100MB files. I *assumed* using C will reduce the parse time. 2. The records themselves are variable length and hence was concerned about the complexity for implementation in python. 3. Since I am not using a database, eac

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread spir
Ravi Kondamuru a écrit : I am trying to read a binary log file to extract system counters. These counters will then be used to generate web-based graphs using the chart-director api in python. For extracting the counters I planning to write a program in C to read and give the output as lists for

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread Serdar Tumgoren
Thanks to all for the replies! The FeedParser example is mind-bending (at least for this noob), but of course looks very powerful. And thanks for the tips on cleaning up the appearance of the code with sup-patterns. Those regex's can get hairy pretty fast.

Re: [Tutor] no attribute

2008-12-11 Thread Lie Ryan
On Thu, 11 Dec 2008 21:56:19 +, Alan Gauld wrote: > "Bryan Fodness" wrote > >>I am trying to change values in a file. The following code does not >>seem to >> find the attribute. >> >> def anonymize(obj, attr): >>try: >>obj.attr = 'Anonymize' >>except AttributeError: >>

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Eike Welk
On Thursday 11 December 2008, Ravi Kondamuru wrote: > This was a great info exchange for me. > I am going to try out the all-python solution and see how it works > out. thank you all, You could try to optimize slow parts with the compiled Cython language. Nearly all Python code is legal Cython; b

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread John Fouhy
On 12/12/2008, spir wrote: > I just found a simple, but nice, trick to make regexes less unlegible. > Using substrings to represent sub-patterns. E.g. instead of: [...] Another option is to use the re.VERBOSE flag. This allows you to put comments in your regular expression and use whitespace fo

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread spir
Serdar Tumgoren a écrit : Hey everyone, I was wondering if there is a way to use the datetime module to check for variations on a month name when performing a regex match? In the script below, I created a regex pattern that checks for dates in the following pattern: "August 31, 2007". If there

Re: [Tutor] no attribute

2008-12-11 Thread Alan Gauld
"Bryan Fodness" wrote I am trying to change values in a file. The following code does not seem to find the attribute. def anonymize(obj, attr): try: obj.attr = 'Anonymize' except AttributeError: pass This code is looking for an attribute of obj called attr It is not us

[Tutor] no attribute

2008-12-11 Thread Bryan Fodness
I am trying to change values in a file. The following code does not seem to find the attribute. def anonymize(obj, attr): try: obj.attr = 'Anonymize' except AttributeError: pass for fname in os.listdir(os.curdir): plan=ReadFile(fname) anonymize(plan, 'Name') It s

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Ravi Kondamuru
This was a great info exchange for me. I am going to try out the all-python solution and see how it works out. thank you all, Ravi. On Thu, Dec 11, 2008 at 10:59 AM, Ravi Kondamuru wrote: > Reasons for C: > 1. The log files I am working are 60-100MB files. I *assumed* using C will > reduce the pa

Re: [Tutor] MIME parser

2008-12-11 Thread Asif Iqbal
On Thu, Dec 11, 2008 at 11:49:16AM, Asif Iqbal wrote: > I am looking for a way to feed a message from stdin to a python based > mime parser, detach all attachments and drop them to a dir, and then > send the email to the recipient. The attachment(s) will be replaced > by an URL to a link. > > So

Re: [Tutor] advice on regex matching for dates?

2008-12-11 Thread Kent Johnson
On Thu, Dec 11, 2008 at 2:31 PM, Serdar Tumgoren wrote: > Hey everyone, > > I was wondering if there is a way to use the datetime module to check for > variations on a month name when performing a regex match? Parsing arbitrary dates is hard, in fact the most general case is not solvable since 7/

Re: [Tutor] [Fwd: Re: reading output from a c executable.]

2008-12-11 Thread Steve Willoughby
With the amount of information provided so far, I'd say you need to step back and question your initial assumptions. Python shouldn't have a great deal of trouble reading variable-length binary data blocks, and the overhead of doing that is probably a lot less than it would be to have another

[Tutor] advice on regex matching for dates?

2008-12-11 Thread Serdar Tumgoren
Hey everyone, I was wondering if there is a way to use the datetime module to check for variations on a month name when performing a regex match? In the script below, I created a regex pattern that checks for dates in the following pattern: "August 31, 2007". If there's a match, I can then print

[Tutor] [Fwd: Re: reading output from a c executable.]

2008-12-11 Thread spir
Ravi Kondamuru a écrit : I am trying to read a binary log file to extract system counters. These counters will then be used to generate web-based graphs using the chart-director api in python. For extracting the counters I planning to write a program in C to read and give the output as lists for

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Ravi Kondamuru
Reasons for C: 1. The log files I am working are 60-100MB files. I *assumed* using C will reduce the parse time. 2. The records themselves are variable length and hence was concerned about the complexity for implementation in python. 3. Since I am not using a database, each request to refresh the g

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Steve Willoughby
Ravi Kondamuru wrote: I am trying to read a binary log file to extract system counters. These counters will then be used to generate web-based graphs using the chart-director api in python. For extracting the counters I planning to write a program in C to read and give the output as lists for u

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Steve Willoughby
Ravi Kondamuru wrote: I am expecting these lists to be huge and was hoping to avoid re-parsing in python. Any way for the c program to return a list that python can Mind if I ask the obvious question here? Why are you wanting to avoid parsing in Python? Any time you have one program (in any

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread bob gailer
Ravi Kondamuru wrote: I am trying to read a binary log file to extract system counters. These counters will then be used to generate web-based graphs using the chart-director api in python. For extracting the counters I planning to write a program in C to read and give the output as lists for

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread bob gailer
Ravi Kondamuru wrote: I am expecting these lists to be huge and was hoping to avoid re-parsing in python. Any way for the c program to return a list that python can directly use. Not as far as I know. Lists in Python are internal objects. If you were able to package the C and Python programs

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Ravi Kondamuru
I am trying to read a binary log file to extract system counters. These counters will then be used to generate web-based graphs using the chart-director api in python. For extracting the counters I planning to write a program in C to read and give the output as lists for use by chart-director. If p

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Ravi Kondamuru
I am expecting these lists to be huge and was hoping to avoid re-parsing in python. Any way for the c program to return a list that python can directly use. Thanks for the pointer to json :) I am going to explore and evaluate re-parsing overhead. thanks, Ravi. On Thu, Dec 11, 2008 at 10:19 AM, bob

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread Steve Willoughby
Ravi Kondamuru wrote: Hi, I am writing a script to read list output from a C executable. How should c program be written so that python can read the output as a list? Any pointers to info on this appreciated. The possibilities are truly wide open on this. Python can read a variety of standa

Re: [Tutor] reading output from a c executable.

2008-12-11 Thread bob gailer
Ravi Kondamuru wrote: Hi, I am writing a script to read list output from a C executable. How should c program be written so that python can read the output as a list? Any pointers to info on this appreciated. Funny that a C programmer is asking for pointers, when C has lots of pointers and P

[Tutor] reading output from a c executable.

2008-12-11 Thread Ravi Kondamuru
Hi, I am writing a script to read list output from a C executable. How should c program be written so that python can read the output as a list? Any pointers to info on this appreciated. thanks, Ravi. ___ Tutor maillist - Tutor@python.org http://mail.py

[Tutor] MIME parser

2008-12-11 Thread Asif Iqbal
I am looking for a way to feed a message from stdin to a python based mime parser, detach all attachments and drop them to a dir, and then send the email to the recipient. The attachment(s) will be replaced by an URL to a link. So basically decouple the attachments (>1MB in size) and modify the b