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
Asad, After reading replies to you by Alan and Steven I want to ask you if you can first tell us in normal words what the exact outline of the program does. If you only want help on one small part, tell us about that. I was first fooled into thinking you wanted to show us how you solve the major

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

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

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

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 >

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

Re: [Tutor] re module help

2012-01-09 Thread bodsda
You could use read directly on the popen call to negate having to write to a file output = os.popen(“sdptool -i hci0 search OPUSH“).read() Bodsda Sent from my BlackBerry® wireless device -Original Message- From: Ganesh Kumar Sender: tutor-bounces+bodsda=googlemail@python.org Date:

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

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

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

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

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) > ?

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)

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

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

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

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 =

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(

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

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

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.

Re: [Tutor] re adlines, read, and my own get_contents()

2008-06-19 Thread Kent Johnson
On Thu, Jun 19, 2008 at 2:44 AM, John [H2O] <[EMAIL PROTECTED]> wrote: > > I've defined: > > def get_contents(infile=file_object): > """ return a list of lines from a file """ > contents=infile.read() > contents = contents.strip().split('\n') > return contents > I think I understand the di

Re: [Tutor] re-initialising shells

2007-12-21 Thread Alan Gauld
"Jim Morcombe" <[EMAIL PROTECTED]> wrote > I have changed qwerty and saved it away. > I have then run my program (F5) and the program acts as > if it is using an old version of qwerty. You need to "reload" the module to pick up the changes. >>> help(reload) Help on built-in function reload in m

Re: [Tutor] Re-Naming an existent file

2007-10-10 Thread Bill Campbell
On Wed, Oct 10, 2007, Ed Goulart wrote: > > Hello! > > Though I've tried very hard, I couldn't find in the WEB the needed > help; so, if you can help me, please...!!! import os os.rename(old, new) Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC URL: http://www.c

Re: [Tutor] re and MULTILINE

2007-02-20 Thread Marilyn Davis
On Tue, 20 Feb 2007, Kent Johnson wrote: > Marilyn Davis wrote: > > Hello Tutors, > > > > I'm trying to get a grip on MULTILINE and I guess I don't have it. > > > > Here's some code: > > > > #!/usr/bin/env python > > import re > > > > def sub_it(mo): > > return 'xxx' > > > > def test(re_str, d

Re: [Tutor] re and MULTILINE

2007-02-20 Thread Kent Johnson
Marilyn Davis wrote: > Hello Tutors, > > I'm trying to get a grip on MULTILINE and I guess I don't have it. > > Here's some code: > > #!/usr/bin/env python > import re > > def sub_it(mo): > return 'xxx' > > def test(re_str, data): > return re.sub(re_str, sub_it, data, re.MULTILINE) > The

Re: [Tutor] re-import

2006-10-30 Thread Kent Johnson
Glenn T Norton wrote: > jhl wrote: > >> Hi- >> >> How is the 1st import of a module removed so that new edits on the >> module can be re-imported? >> > Read about reload here: > http://docs.python.org/lib/built-in-funcs.html Make sure you understand the limitations of reload(). In particular, n

Re: [Tutor] re-import

2006-10-29 Thread jhl
Thanks again!That is just what I need.-JOn 10/29/06, Glenn T Norton <[EMAIL PROTECTED] > wrote:jhl wrote:> Hi->> How is the 1st import of a module removed so that new edits on the > module can be re-imported?>> DETAIL:>> I am working on a module/file and importing it into a python shell,> trying it

Re: [Tutor] re-import

2006-10-29 Thread johnf
On Sunday 29 October 2006 18:25, jhl wrote: > Hi- > > How is the 1st import of a module removed so that new edits on the module > can be re-imported? > > DETAIL: > > I am working on a module/file and importing it into a python shell, trying > it out and then tweaking/editing the module. Then to se

Re: [Tutor] re-import

2006-10-29 Thread Glenn T Norton
jhl wrote: > Hi- > > How is the 1st import of a module removed so that new edits on the > module can be re-imported? > > DETAIL: > > I am working on a module/file and importing it into a python shell, > trying it out and then tweaking/editing the module. Then to see the > effects of the edits,

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > I'm afraid I don't fully understand file objects. I thought I could use it > just as a file: if I have one, and I want several copies, I just save it with > several names. So, if Popen.stdout already is a file object, I thought the > easier way would be to save it with anot

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Alan Gauld
> For this simple example, this solution is fine, and I think the > solution > proposed by Alan (StringIO) is not going to add anything. Would it > be faster? Probably not, the StringIO solution is just closer to how you described the problem, but also provides a fuller set of file-like method

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Tiago Saboga
Em Segunda 09 Outubro 2006 10:41, Kent Johnson escreveu: > Tiago Saboga wrote: > > Hi! > > > > I have a problem with file-like objects for months now, and I hoped I > > could cope with it, but I keep using what seems to me like a newbie > > workaround... > > > > The question is: how can I read a fi

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Alan Gauld
> because it reads the file with read() method, which can only be used > once. If > it's a real file, on disk, I agree it would not be a clever > strategy, reading > it once for each copy, and I would be happy keeping its content in a > variable. But if the file is in memory, why can't I simply r

Re: [Tutor] re-reading file-like objects (SOLVED?)

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > But I strip the code, and post a new one. The solution I found is in the > seek() method of the file object. And the problem I had is that not all the > file-like objects have a functional seek() method. It's not the case for the > object referenced by the stdout attribute

Re: [Tutor] re-reading file-like objects

2006-10-09 Thread Kent Johnson
Tiago Saboga wrote: > Hi! > > I have a problem with file-like objects for months now, and I hoped I could > cope with it, but I keep using what seems to me like a newbie workaround... > > The question is: how can I read a file (more precisely, a file-like object) > more than one single time? >

Re: [Tutor] re-reading file-like objects (SOLVED?)

2006-10-09 Thread Tiago Saboga
I keep the original question: Em Segunda 09 Outubro 2006 09:21, Tiago Saboga escreveu: > Hi! > > I have a problem with file-like objects for months now, and I hoped I could > cope with it, but I keep using what seems to me like a newbie workaround... > > The question is: how can I read a file (mor

Re: [Tutor] re syntax

2006-08-29 Thread Tiago Saboga
Em Segunda 28 Agosto 2006 15:54, Kent Johnson escreveu: > A 'space character' is the single character \x20. A 'whitespace > character' is any character in a some set of non-printing (white) > characters. I guess it is a subtle distinction but it's common usage, > not just Python; it even has a Wiki

Re: [Tutor] re syntax

2006-08-28 Thread ORIE HURST
>From: Kent Johnson <[EMAIL PROTECTED]> >CC: [EMAIL PROTECTED] txtx back> >> > > > > It's easy ;-) It's the "whitespace" part. I read it as the space >character, > > not as any blank character. I should have noted that new lines are >ignored > > too, but I didn't. > > > > (I just looked a litt

Re: [Tutor] re syntax

2006-08-28 Thread Kent Johnson
Tiago Saboga wrote: > Em Segunda 28 Agosto 2006 11:12, Kent Johnson escreveu: > >> Ahem. Which part of "Whitespace within the pattern is ignored" do you >> not understand? :-) >> > > It's easy ;-) It's the "whitespace" part. I read it as the space character, > not as any blank character. I

Re: [Tutor] re syntax

2006-08-28 Thread Tiago Saboga
Em Segunda 28 Agosto 2006 11:12, Kent Johnson escreveu: > Ahem. Which part of "Whitespace within the pattern is ignored" do you > not understand? :-) It's easy ;-) It's the "whitespace" part. I read it as the space character, not as any blank character. I should have noted that new lines are igno

Re: [Tutor] re syntax

2006-08-28 Thread Kent Johnson
Tiago Saboga wrote: > The problem is: why the hell do I need > to escape special caracters when in verbose mode? And why isn't it made clear > on the re module doc page ( http://docs.python.org/lib/module-re.html ). > > I'll just paste below (or above? I never know how to say this in english) my

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Danny Yoo
> I tried: > > class Omega: >def Display(self): >print self > > class Alpha(Omega): >def __init__(self): >self = Beta() > > class Beta(Omega): >def __init__(self): >pass > > objectus = Alpha() > objectus.Display() > > which prints > > <__main__.Alpha instance at

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Alan Gauld
> is it correct that an object cannot be re-instantiated within it's > __init__ method? There are some tricks you can pull but the object is actually instantiated before the init gets called. Really init is for initialisation of the instance, it's not a true constructor. > Background: I need to

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Kent Johnson
Jan Eden wrote: > Hi, > > is it correct that an object cannot be re-instantiated within it's __init__ > method? > > I tried: > > class Omega: > def Display(self): > print self > > class Alpha(Omega): > def __init__(self): > self = Beta() > > class Beta(

  1   2   3   >