Re: [Tutor] RE Embedding Python in C

2019-07-09 Thread Alan Gauld via Tutor
On 09/07/2019 15:13, Ibarra, Jesse wrote: Caveat: I'm no expert on embedding and indeed have only done it once using the examples in the docs. However, based on my general Python experience... > I then embedded the example using C/Python API: > https://docs.python.org/3.6/extending/embedding.html

Re: [Tutor] RE Embedding Python in C

2019-07-09 Thread Ibarra, Jesse
Sorry for the duplicate threads but the forwarded message did not send the original email. I apologize for any inconvenience. The file are below. I am running CentOS7: [jibarra@redsky ~]$ uname -a Linux redsky.lanl.gov 3.10.0-957.21.2.el7.x86_64 #1 SMP Wed Jun 5 14:26:44 UTC 2019 x86_64 x86_64

Re: [Tutor] Re Module

2018-12-27 Thread Avi Gross
nd perhaps doing a little debugging. -Original Message- From: Tutor On Behalf Of Asad Sent: Thursday, December 27, 2018 10:10 AM To: tutor@python.org Subject: [Tutor] Re Module Hi All , I trying find a solution for my script , I have two files : file1 - I need a search a error s

Re: [Tutor] Re Module

2018-12-27 Thread Steven D'Aprano
On Thu, Dec 27, 2018 at 08:40:12PM +0530, Asad wrote: > Hi All , > > I trying find a solution for my script , I have two files : > > file1 - I need a search a error say x if the error matches > > Look for the same error x in other file 2 > > Here is the code : > I have 10 different pa

Re: [Tutor] Re Module

2018-12-27 Thread Alan Gauld via Tutor
On 27/12/2018 15:10, Asad wrote: > file1 - I need a search a error say x if the error matches > > Look for the same error x in other file 2 > > Here is the code : > I have 10 different patterns therefore I used list comprehension and > compiling the pattern so I loop over and find the exact patt

[Tutor] Re Module

2018-12-27 Thread Asad
Hi All , I trying find a solution for my script , I have two files : file1 - I need a search a error say x if the error matches Look for the same error x in other file 2 Here is the code : I have 10 different patterns therefore I used list comprehension and compiling the pattern so I

Re: [Tutor] Re subprocess

2014-09-11 Thread jarod...@libero.it
Thanks for the suggestion and corrections. I don't put the else staement onf if log_file but now I realize my mistake I have 3 comand to do: step_1_out =["STAR --genomeDir /home/sbsuser/databases/Starhg19/GenomeDir/ -- runMode alignReads --readFilesIn %s %s --runThreadN 12 --readFilesCommand z

Re: [Tutor] Re subprocess

2014-09-10 Thread Steven D'Aprano
On Wed, Sep 10, 2014 at 11:20:38AM +0200, jarod...@libero.it wrote: > If I follow the exmple I have this type of error: > File "./RNA_prova.py", line 73, in run > for line in p1.stdout(): > TypeError: 'NoneType' object is not callable Somehow you have p1.stdout set to None. You can confirm thi

Re: [Tutor] Re subprocess

2014-09-10 Thread Wolfgang Maier
On 09/10/2014 11:20 AM, jarod...@libero.it wrote: If I follow the exmple I have this type of error: File "./RNA_prova.py", line 73, in run for line in p1.stdout(): TypeError: 'NoneType' object is not callable You have at least two errors in your script below: This time you're not piping

[Tutor] Re subprocess

2014-09-10 Thread jarod...@libero.it
If I follow the exmple I have this type of error: File "./RNA_prova.py", line 73, in run for line in p1.stdout(): TypeError: 'NoneType' object is not callable This is the class I use: def run(cmd,pi): import subprocess import time import logging

Re: [Tutor] re module

2014-08-19 Thread Sunil Tech
Hey thanks Danny Yoo, Chris “Kwpolska” Warrick, D.V.N Sarma ​. I will take all your inputs. Thanks a lot.​ On Fri, Aug 15, 2014 at 3:32 AM, Danny Yoo wrote: > On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ > wrote: > > I tested it on IDLE. It works. > > > Hi Sarma, > > > Followi

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
Hi Sunil, Don't use regular expressions for this task. Use something that knows about HTML structure. As others have noted, the Beautiful Soup or lxml libraries are probably a much better choice here. There are good reasons to avoid regexp for the task you're trying to do. For example, your re

Re: [Tutor] re module

2014-08-14 Thread Danny Yoo
On Thu, Aug 14, 2014 at 8:39 AM, D.V.N.Sarma డి.వి.ఎన్.శర్మ wrote: > I tested it on IDLE. It works. Hi Sarma, Following up on this one. I'm pretty sure that: print re.search("https://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy for why. ___

Re: [Tutor] re module

2014-08-14 Thread Albert-Jan Roskam
- On Thu, Aug 14, 2014 4:07 PM CEST Chris “Kwpolska” Warrick wrote: >On 14 Aug 2014 15:58 "Sunil Tech" wrote: >> >> Hi, >> >> I have string like >> stmt = 'Patient name: Upadhyay Shyamstyle="font-family: times new roman,times;">  Date of >birth:   08/08/1988 Issue(s)

Re: [Tutor] re module

2014-08-14 Thread D . V . N . Sarma డి . వి . ఎన్ . శర్మ
I tested it on IDLE. It works. regards, Sarma. On Thu, Aug 14, 2014 at 7:37 PM, Chris “Kwpolska” Warrick < kwpol...@gmail.com> wrote: > > On 14 Aug 2014 15:58 "Sunil Tech" wrote: > > > > Hi, > > > > I have string like > > stmt = 'Patient name: Upadhyay Shyam style="font-family: times new roman

Re: [Tutor] re module

2014-08-14 Thread Chris “Kwpolska” Warrick
On 14 Aug 2014 15:58 "Sunil Tech" wrote: > > Hi, > > I have string like > stmt = 'Patient name: Upadhyay Shyam  Date of birth:   08/08/1988 Issue(s) to be analyzed:  tesNurse Clinical summary:  test1 Date of injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3 - 780.50 - 724

[Tutor] re module

2014-08-14 Thread Sunil Tech
Hi, I have string like stmt = 'Patient name: Upadhyay Shyam  Date of birth:   08/08/1988 Issue(s) to be analyzed:  tesNurse Clinical summary:  test1 Date of injury:   12/14/2013Diagnoses:   723.4 - 300.02 - 298.3 - 780.50 - 724.4 Brachial neuritis or radiculitis nos - Generaliz

Re: [Tutor] [Re:] I need help with the following question

2013-09-11 Thread Steven D'Aprano
On Wed, Sep 11, 2013 at 11:15:26AM +0100, Oscar Benjamin wrote: > There is also the .format method. This was initially intended to > replace % formatting but it was ultimately decided that removing % > formatting was not necessary. Consequently there are now two ways of > doing advanced string for

Re: [Tutor] [Re:] I need help with the following question

2013-09-11 Thread Oscar Benjamin
I'm resending this to the list. Please reply to the tutor list rather than directly to me. Also please don't top-post. My answer is below. On 11 September 2013 10:47, Thabile Rampa wrote: > > On Tue, Sep 10, 2013 at 11:57 AM, Oscar Benjamin > wrote: >> >> On 10 September 2013 08:58, Thabile Ram

Re: [Tutor] [Re:] I need help with the following question

2013-09-10 Thread Dave Angel
On 10/9/2013 03:58, Thabile Rampa wrote: > > On Aug 27, 2013, at 3:40 AM, isaac Eric > wrote > > > print "For a circle of radius %s the area is > %s" % (radius,area) > > > Question: What is the purpose of %s ?I will > admit that this is homework for me. However, this is more for m

Re: [Tutor] [Re:] I need help with the following question

2013-09-10 Thread Alan Gauld
On 10/09/13 08:58, Thabile Rampa wrote: print "For a circle of radius %s the area is %s" % (radius,area) Question: What is the purpose of %s ? Oscar has answered your basic question but to add to his comments thee are other reasons for using the %s rather than str() or simply printing the

Re: [Tutor] [Re:] I need help with the following question

2013-09-10 Thread Oscar Benjamin
On 10 September 2013 08:58, Thabile Rampa wrote: > On Aug 27, 2013, at 3:40 AM, isaac Eric wrote > > > >> print "For a circle of radius %s the area is %s" % (radius,area) > >> Question: What is the purpose of %s ? > > I will admit that this is homework for me. However, this is more for my log >

[Tutor] [Re:] I need help with the following question

2013-09-10 Thread Thabile Rampa
On Aug 27, 2013, at 3:40 AM, isaac Eric wrote > print "For a circle of radius %s the area is %s" % (radius,area) > Question: What is the purpose of %s ? I will admit that this is homework for me. However, this is more for my log book and not for marks. According to my understanding, the purpose

Re: [Tutor] re module- puzzling results when matching money

2013-08-04 Thread Alan Gauld
On 04/08/13 08:45, Alex Kleider wrote: sorry, my bad. I forgot to delete that backslash, I meant re.findall(r"\be\b", "d e f"). Same with the other example. ..but the interesting thing is that the presence or absence of the spurious back slashes seems not to change the results. It wouldn't

Re: [Tutor] re module- puzzling results when matching money

2013-08-04 Thread Dominik George
Hi, not quite. The moral is to learn about greedy and non-greedy matching ;)! -nik Alex Kleider schrieb: >On 2013-08-03 13:38, Dominik George wrote: >> Hi, >> >> b is defined as all non-word characters, so it is the complement oft >> w. w is [A-Za-z0-9_-], so b includes $ and thus cuts off

Re: [Tutor] re module- puzzling results when matching money

2013-08-03 Thread Dominik George
Hi, \b is defined as all non-word characters, so it is the complement oft \w. \w is [A-Za-z0-9_-], so \b includes \$ and thus cuts off your group. -nik Alex Kleider schrieb: >#!/usr/bin/env python > >""" >I've been puzzling over the re module and have a couple of questions >regarding the be

Re: [Tutor] re 33.116

2012-07-19 Thread Emile van Sebille
On 7/19/2012 4:10 PM Emile van Sebille said... I found ~200k files in /var/log all but 227 look like: Sorry -- my bad. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/list

[Tutor] re 33.116

2012-07-19 Thread Emile van Sebille
I found ~200k files in /var/log all but 227 look like: list_boxes.day.1.gz.1.gz.1.gz.3.gz.1.gz.1.gz.2.gz.1.gz.1.gz.2.gz.1.gz list_boxes.day.1.gz.1.gz.1.gz.3.gz.1.gz.1.gz.2.gz.1.gz.1.gz.2.gz.1.gz.1.gz list_boxes.day.1.gz.1.gz.1.gz.3.gz.1.gz.1.gz.2.gz.1.gz.1.gz.2.gz.1.gz.1.gz.1.gz list_boxes.day.1.

Re: [Tutor] re module help

2012-01-09 Thread bodsda
: Mon, 9 Jan 2012 14:47:46 To: Subject: [Tutor] re module help ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor ___ Tutor

[Tutor] re module help

2012-01-09 Thread Ganesh Kumar
Hi Gurus, I have created regular expression with os modules, I have created file sdptool to match the regular expression pattern, will print the result. I want without creating file how to get required output, I tried but i didn't get output correctly, over stream. #! /usr/bin/python import os,re

[Tutor] Re : Python loop isn't working

2011-08-05 Thread kliat...@gmail.com
Can you try to split it into fonctions Because it is hard to read it. Envoyé depuis mon HTC - Reply message - De : "Susana Iraiis Delgado Rodriguez" Pour : Objet : [Tutor] Python loop isn't working Date : ven., août 5, 2011 18:14 Hello list! I have a python script which works with othe

Re: [Tutor] RE

2011-04-06 Thread Michiel Overtoom
On 2011-04-06 11:03, JOHN KELLY wrote: I need help. In that case, start with http://wiki.python.org/moin/BeginnersGuide -- "Lots of people have brilliant ideas every day, but they often disappear in the cacophony of life that we muddle through." - Evan Jenkins, http://arstechnica.com/aut

Re: [Tutor] RE

2011-04-06 Thread Steve Willoughby
On 06-Apr-11 02:03, JOHN KELLY wrote: I need help. Can you be a little more specific? :) -- Steve Willoughby / st...@alchemy.com "A ship in harbor is safe, but that is not what ships are built for." PGP Fingerprint 48A3 2621 E72C 31D9 2928 2E8F 6506 DB29 54F7 0F53 _

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
By the way with your helper function algorithm Steven and Peter comments you made me think of this change: karim@Requiem4Dream:~$ echo 'prima " "' | sed -e 's/""/\\"\\"/g;s/\([^\]\)"/\1\\"/g' prima \" \" karim@Requiem4Dream:~$ echo 'prima ""' | sed -e 's/""/\\"\\"/g;s/\([^\]\)"/\1\\"/g' pr

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 11:26 AM, Peter Otten wrote: Karim wrote: That is not the thing I want. I want to escape any " which are not already escaped. The sed regex '/\([^\\]\)\?"/\1\\"/g' is exactly what I need (I have made regex on unix since 15 years). Can the backslash be escaped, too? If so I don't

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 02:36 AM, Steven D'Aprano wrote: Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said, "

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: > That is not the thing I want. I want to escape any " which are not > already escaped. > The sed regex '/\([^\\]\)\?"/\1\\"/g' is exactly what I need (I have > made regex on unix since 15 years). Can the backslash be escaped, too? If so I don't think your regex does what you think

Re: [Tutor] RE module is working ?

2011-02-04 Thread Peter Otten
Karim wrote: > Recall: > > >>> re.subn(r'([^\\])?"', r'\1\\"', expression) > > Traceback (most recent call last): > File "", line 1, in > File "/home/karim/build/python/install/lib/python2.7/re.py", line > 162, in subn >return _compile(pattern, flags).subn(repl, string, count)

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said, "Doctor, every time I do this, it hurts. What sh

Re: [Tutor] RE module is working ?

2011-02-03 Thread Alan Gauld
"Karim" wrote Because expression = *' "" '* is in fact fact expression = ' "" '. The bold appear as stars I don't know why. Because in the days when email was always sent in plain ASCII text the way to show "bold" was to put asterisks around it. Underlining used _underscores_ like so...

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 07:47 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 11:20 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip> *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (ap

Re: [Tutor] RE module is working ?

2011-02-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip> *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright",

Re: [Tutor] RE module is working ?

2011-02-03 Thread Peter Otten
Karim wrote: > I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 > consecutives double quotes: > > * *In Python interpreter:* > > $ python > Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for m

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
I forget something. There is no issue with python and double quotes. But I need to give it to TCL script but as TCL is shit string is only delimited by double quotes. Thus I need to escape it to not have syntax error whith nested double quotes. Regards The poor tradesman On 02/03/2011 12:45

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello Steven, I am perhaps a poor tradesman but I have to blame my thunderbird tool :-P . Because expression = *' "" '* is in fact fact expression = ' "" '. The bold appear as stars I don't know why. I need to have escapes for passing it to another language (TCL interpreter). So I will rewrit

Re: [Tutor] RE module is working ?

2011-02-03 Thread Steven D'Aprano
Karim wrote: Hello, I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: You don't have to escape quotes. Just use the other sort of quote: >>> print '""' "" * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:5

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello, Any news on this topic?O:-) Regards Karim On 02/02/2011 08:21 PM, Karim wrote: Hello, I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC

[Tutor] RE module is working ?

2011-02-02 Thread Karim
Hello, I am trying to subsitute a '""' pattern in '\"\"' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>

Re: [Tutor] Re Problems with creating XML-documents

2010-04-15 Thread Lie Ryan
On 04/15/10 16:03, Karjer Jdfjdf wrote: > When I try to parse the outputfile it creates different errors such as: >* ExpatError: not well-formed (invalid token): That error message is telling you that you're not parsing an XML file, merely an XML-like file. > Basically it ususally has somethi

[Tutor] Re Problems with creating XML-documents

2010-04-14 Thread Karjer Jdfjdf
>> I'm having problems with creating XML-documents, >> because I don't seem to write it to a document correctly. >Is that because you don't understand XML or because the >output is not what you expect? How is the data being generated? >Are you parsing an existing XML source or creating the XML

Re: [Tutor] Re ading List from File

2009-11-11 Thread Shashwat Anand
Samir-16 wrote: > > > > Hi Everyone, > > > > I am trying to read a comma-delimitted list ("aaa","bbb","ccc") from a > > text > > file and assign those values to a list, x, such that: > > > > x = ["aaa", "bbb", "ccc"] > > > > The code that I have come up with looks like this: > > > x = [] >

Re: [Tutor] Re ading List from File

2009-11-11 Thread furblender
Hello everyone, I to had the same problem and it pestered me to the nth degree. I had that many problems I went to the python site and copied an example and used that to test why it wasn't working -see below example and traceback report. I wasted a lot of time trying to figure my issue out. Then

Re: [Tutor] re module / separator

2009-06-25 Thread Tiago Saboga
Thanks Kent! Once more you go straight to the point! Kent Johnson writes: > On Wed, Jun 24, 2009 at 2:24 PM, Tiago Saboga wrote: >> In [33]: re.search("(a[^.]*?b\.\s?){2}", text).group(0) >> Out[33]: 'a45453b. a325643b. ' > > group(0) is the entire match so this returns what you expect. But what

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
Ok -- realized my "solution" incorrectly strips white space from multiword strings: > Out[92]: ['a2345b.', 'a45453b.a325643b.a435643b.'] > So here are some more gymnastics to get the correct result: In [105]: newlist Out[105]: ['a2345b.', '|', 'a45453b.', 'a325643b.', 'a435643b.', '|'] In [109]

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
As usual, Kent Johnson has swooped in an untangled the mess with a clear explanation. By the time a regex gets this complicated, I typically start thinking of ways to simplify or avoid them altogether. Below is the code I came up with. It goes through some gymnastics and can surely stand improvem

Re: [Tutor] re module / separator

2009-06-24 Thread Kent Johnson
On Wed, Jun 24, 2009 at 2:24 PM, Tiago Saboga wrote: > Hi! > > I am trying to split some lists out of a single text file, and I am > having a hard time. I have reduced the problem to the following one: > > text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b." > > Of this line of text, I wan

Re: [Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
Serdar Tumgoren writes: > Hey Tiago, > >> text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b." >> >> Of this line of text, I want to take out strings where all words start >> with a, end with "b.". But I don't want a list of words. I want that: >> >> ["a2345b.", "a45453b. a325643b. a4356

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
apologies -- I just reread your post and appears you also want to capture the dot after each "b" ( "b." ) In that case, you need to update the pattern to match for the dot. But because the dot is itself a metacharacter, you have to escape it with a backslash: In [23]: re.findall(r'a\w+b\.',text)

Re: [Tutor] re module / separator

2009-06-24 Thread Serdar Tumgoren
Hey Tiago, > text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b." > > Of this line of text, I want to take out strings where all words start > with a, end with "b.". But I don't want a list of words. I want that: > > ["a2345b.", "a45453b. a325643b. a435643b."] > Are you saying you want a

[Tutor] re module / separator

2009-06-24 Thread Tiago Saboga
Hi! I am trying to split some lists out of a single text file, and I am having a hard time. I have reduced the problem to the following one: text = "a2345b. f325. a45453b. a325643b. a435643b. g234324b." Of this line of text, I want to take out strings where all words start with a, end with "b.".

[Tutor] re Format a file

2009-02-28 Thread prasad rao
Hello >> for line in so: >> if len(line)<70:de.write(line+'\n') >> if len(line)>70: >> da=textwrap.fill(line,width=60) >> de.write(da+'\n') >What happens if the line is exactly 70 characters long? >I think you want an else instead of the second i

Re: [Tutor] re Format a file

2009-02-27 Thread Kent Johnson
On Fri, Feb 27, 2009 at 5:09 AM, prasad rao wrote: > Hello > Finally I  managed to writ a function to format a file. > Thank to everybody for their tips. > > def mmm(a): > import os,textwrap > so=open(a) > d=os.path.dirname(a)+os.sep+'temp.txt' > de=open(d,'w') > import te

Re: [Tutor] re Format a file

2009-02-27 Thread Alan Gauld
"prasad rao" wrote for line in so: if len(line)<70:de.write(line+'\n') if len(line)>70: da=textwrap.fill(line,width=60) de.write(da+'\n') What happens if the line is exactly 70 characters long? I think you want an else instead of the second

[Tutor] re Format a file

2009-02-27 Thread prasad rao
HelloFinally I managed to writ a function to format a file. Thank to everybody for their tips. def mmm(a): import os,textwrap so=open(a) d=os.path.dirname(a)+os.sep+'temp.txt' de=open(d,'w') import textwrap for line in so: if len(line)<70:de.write(line+'\n'

Re: [Tutor] re Format a file

2009-02-26 Thread Lie Ryan
On Fri, 27 Feb 2009 09:59:40 +0530, prasad rao wrote: > def myform(s): > import os > so=open(s) > d=os.path.dirname(s)+os.sep+'temp.txt' > de=open(d,'w') > for line in so: > while len(line)>60: > item=line[60:] > try: > a

Re: [Tutor] re Format a file

2009-02-26 Thread John Fouhy
2009/2/27 prasad rao : > Hello > I don't know why, but this I think going into infinite loop. > I cant see anything wrong in it. > Please show me where  the problem is. [...] > while len(line)>60: > tem=line[60:] > try: > ??? a,b=tem.split(' ',1) > ?

[Tutor] re Format a file

2009-02-26 Thread prasad rao
HelloI don't know why, but this I think going into infinite loop. I cant see anything wrong in it. Please show me where the problem is. def myform(s): import os so=open(s) d=os.path.dirname(s)+os.sep+'temp.txt' de=open(d,'w') for line in so: while len(line)>60: ?

Re: [Tutor] re Formating

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 7:46 AM, prasad rao wrote: > hi licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?') for license in licenses: >       m = licenseRe.search(license) >       print m.group(1, 3) > > Traceback (most recent call last): >   File "", line 3, in >     print m.group(1, 3)

[Tutor] re Formating

2009-02-25 Thread prasad rao
hi >>> licenseRe = re.compile(r'\(([A-Z]+)\)\s*(No.\d+)?') >>> for license in licenses: m = licenseRe.search(license) print m.group(1, 3) Traceback (most recent call last): File "", line 3, in print m.group(1, 3) IndexError: no such group Something wrong with this code. _

Re: [Tutor] re Binding Event

2009-02-10 Thread Alan Gauld
"prasad rao" wrote HelloI changed the code as follows.But still the callback function is not working. The he() is working well but clicking on the frame has no result. class app: def __init__(self,root): frame=Frame(root) frame.bind("", callback) Should this not be self.callback? def

[Tutor] re Binding Event

2009-02-10 Thread prasad rao
HelloI changed the code as follows.But still the callback function is not working. The he() is working well but clicking on the frame has no result. class app: def __init__(self,root): frame=Frame(root) frame.bind("", callback) frame.pack() self.button=Button(root,text='quit',fg='red',command=f

[Tutor] re division problem

2009-02-04 Thread prasad rao
hi I modified my function ' vertical' by adding a few characters to eliminate the division problem. def vertical(columns): if columns>7: columns=7 import string v=string.printable v=v.replace('\n','') v=v.replace('\t','') if len(v)%columns !=0:

Re: [Tutor] re weird bool

2009-02-03 Thread Alan Gauld
"prasad rao" wrote 2==True False It is an unexpected result to me. I thought any value other than 0 is True. Any value of non zero is treated as True in a boolean context. But aq test of equality with a boolean value is not a boolean context. For equiality you have to compare like with lik

Re: [Tutor] re division problem

2009-02-03 Thread Andre Engels
On Tue, Feb 3, 2009 at 2:46 PM, prasad rao wrote: > hi >>Right now you skip by x+((len(v))/columns) >>which will be different for each row. > How is it possible. len(v)=98.A constant. > Is it not. > Does len(v) changes with each iteration? No, but x does. -- André Engels, andreeng...@gmail.com

[Tutor] re division problem

2009-02-03 Thread prasad rao
hi>Right now you skip by x+((len(v))/columns) >which will be different for each row. How is it possible. len(v)=98.A constant. Is it not. Does len(v) changes with each iteration? Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailm

Re: [Tutor] re division problem

2009-02-03 Thread Kent Johnson
On Tue, Feb 3, 2009 at 8:24 AM, prasad rao wrote: >> I wrote a function named vertical to print string .printable characters >> and > .>> ASCII values in a table. >>> 1)It is swallowing some characters. >>> 2)It output some characters 2 or 3 times. >>> 3)It prints one column more than what I aske

[Tutor] re weird bool

2009-02-03 Thread prasad rao
helloyes.you are right. >>> 2==True False It is an unexpected result to me. I thought any value other than 0 is True. And the solution provided by you(bool(a/1)) is useful to me. Thank you Prasad ___ Tutor maillist - Tutor@python.org http://mail.pytho

[Tutor] re division problem

2009-02-03 Thread prasad rao
> I wrote a function named vertical to print string .printable characters and .>> ASCII values in a table. >> 1)It is swallowing some characters. >> 2)It output some characters 2 or 3 times. >> 3)It prints one column more than what I asked for. >> def vertical(columns): >> import string >

Re: [Tutor] Re : Is instance of what?

2009-02-01 Thread spir
Le Sat, 31 Jan 2009 15:00:02 -0500, Kent Johnson a écrit : > On Sat, Jan 31, 2009 at 2:47 PM, spir wrote: > > >> > o.__class__ (or rather o.__class__.__name__) will work. > >> Understood. Thank you. > >> tj > > > > type(a) has been changed (since 2.2?) to return the same value as > > a.__class

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread Kent Johnson
On Sat, Jan 31, 2009 at 2:47 PM, spir wrote: >> > o.__class__ (or rather o.__class__.__name__) will work. >> Understood. Thank you. >> tj > > type(a) has been changed (since 2.2?) to return the same value as a.__class__ I think you mean type(o) (type of the instance) rather than type(a) (type of

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread spir
Le Sat, 31 Jan 2009 09:54:24 -0900, Tim Johnson a écrit : > On Saturday 31 January 2009, Andre Engels wrote: > <...> > > > o=a > <> > > Actually, it is false. To make it true, you have to do o=a() rather than > > o=a > You're correct. That was my typo. > > > Is there a function that takes

Re: [Tutor] Re : Is instance of what?

2009-01-31 Thread Tim Johnson
On Saturday 31 January 2009, Andre Engels wrote: <...> > > o=a <> > Actually, it is false. To make it true, you have to do o=a() rather than > o=a You're correct. That was my typo. > > Is there a function that takes one > > > > argument and returns the class? > > > > Example: > > > > class =

[Tutor] Re : Is instance of what?

2009-01-31 Thread Andre Engels
On Sat, Jan 31, 2009 at 5:57 PM, Tim Johnson wrote: > Using python 2.5.1 > > If I create a class a > > class a: > > pass > > initialize o as: > > o=a > > and call > > isinstance(o,a) > > the return value is True. Actually, it is false. To make it true, you have to do o=a() rather than o=a > Is t

Re: [Tutor] re

2009-01-07 Thread Andre Engels
On Wed, Jan 7, 2009 at 10:57 AM, prasad rao wrote: > Hello > I am trying to get a value as integer and a string. class Value: > def __init__(self,inte='',stri=''): > self.inte=inte > self.stri=stri > def setvalue(self,inte='',stri=''): > self.stri=str(

[Tutor] re

2009-01-07 Thread prasad rao
Hello I am trying to get a value as integer and a string. >>> class Value: def __init__(self,inte='',stri=''): self.inte=inte self.stri=stri def setvalue(self,inte='',stri=''): self.stri=str(self.inte) self.inte=int(self.stri) >>> v=Value(45) >>>

Re: [Tutor] RE Silliness

2009-01-05 Thread bob gailer
Omer wrote: Bob, I tried your way. >>> import re >>> urlMask = r"http://[\w\Q./\?=\R]+()?" >>> text=u"Not working examplehttp://this.is.a/url?header=nullAnd another linehttp://and.another.url"; >>> re.findall(urlMask,text) [u'', u''] Oops I failed to notice you were using findall. Kent expl

Re: [Tutor] RE Silliness

2009-01-05 Thread Kent Johnson
On Mon, Jan 5, 2009 at 11:16 AM, Omer wrote: > Bob, I tried your way. > import re urlMask = r"http://[\w\Q./\?=\R]+()?" text=u"Not working examplehttp://this.is.a/url?header=nullAnd another linehttp://and.another.url"; re.findall(urlMask,text) > [u'', u''] > > spir, I did

Re: [Tutor] RE Silliness

2009-01-05 Thread Omer
Bob, I tried your way. >>> import re >>> urlMask = r"http://[\w\Q./\?=\R]+()?" >>> text=u"Not working examplehttp://this.is.a/url?header=nullAnd another linehttp://and.another.url"; >>> re.findall(urlMask,text) [u'', u''] spir, I did understand it. What I'm not understanding is why isn't this wor

Re: [Tutor] RE Silliness

2009-01-04 Thread spir
On Sun, 04 Jan 2009 14:09:53 -0500 bob gailer wrote: > Omer wrote: > > I'm sorry, burrowed into the reference until my eyes bled. > > > > What I want is to have a regular expression with an optional ending of > > "" > > > > (For those interested, > > urlMask = r"http://[\w\Q./\?=\R]+"; > > is th

Re: [Tutor] RE Silliness

2009-01-04 Thread bob gailer
Omer wrote: I'm sorry, burrowed into the reference until my eyes bled. What I want is to have a regular expression with an optional ending of "" (For those interested, urlMask = r"http://[\w\Q./\?=\R]+"; is ther version w/o the optional ending.) I can't seem to make a string optional- only

[Tutor] RE Silliness

2009-01-04 Thread Omer
I'm sorry, burrowed into the reference until my eyes bled. What I want is to have a regular expression with an optional ending of "" (For those interested, urlMask = r"http://[\w\Q./\?=\R]+"; is ther version w/o the optional ending.) I can't seem to make a string optional- only a single charact

Re: [Tutor] [Re: class/type methods/functions]

2008-11-23 Thread Eike Welk
Hey Spir! Maybe you should read the book "Design Patterns" from Erich Gamma and the rest of "the gang of four". (A.T.Hofkamp, mentioning its terminology, got me thinking.) You ask complicated questions that normal newbies don't ask, so you should maybe read an advanced book. The book's idea is

Re: [Tutor] [Re: class/type methods/functions]

2008-11-01 Thread spir
Thank you for this relevant & precise review, Albert. I will answer specific topic, then give a overall introduction of the problem(s) adressed by this project, that may clarify a bit some topics. A.T.Hofkamp a écrit : > However, by moving the 'type' information to a seperate object, your

Re: [Tutor] [Re: class/type methods/functions]

2008-10-31 Thread A.T.Hofkamp
spir wrote: After reading your mail, I cannot help wondering that something crucial seems to be missing in your class structure. (I get the impression that you are trying to squeeze object information and object meta information together in one class definition.) Yes. This is a consequence of

[Tutor] [Re: class/type methods/functions]

2008-10-30 Thread spir
[forwarded, only A.T.Hofkamp got this answer] A.T.Hofkamp a écrit : spir wrote: Q: Is there a way to write /type/ (class) functions, meaning methods not bound to an instance, in python? As Bob Gailer already said, staticmethod seems to do what you want. Thank you for you answers about static

Re: [Tutor] RE expressions

2008-08-15 Thread Steve Willoughby
Steve Willoughby wrote: Johan Nilsson wrote: In [74]: p.findall('asdsa"123abc\123"jggfds') Out[74]: ['"123abcS"'] By the way, you're confusing the use of \ in strings in general with the use of \ in regular expressions and the appearance of \ as a character in data strings encountered by you

Re: [Tutor] RE expressions

2008-08-15 Thread Steve Willoughby
Johan Nilsson wrote: 'text "http:\123\interesting_adress\etc\etc\" more text' Does this really use backslashes in the text? The standard for URLs (if that's what it is) is to use forward slashes. For your RE, though, you can always use [...] to specify a range including whatever you like.

[Tutor] RE expressions

2008-08-15 Thread Johan Nilsson
Hi all python experts I am trying to work with BeautifulSoup and re and running into one problem. What I want to do is open a webpage and get some information. This is working fine I then want to follow some of links on this page and proces them. I manage to get links that I am interested

  1   2   3   4   5   6   >