Re: Idenfity numbers in variables

2008-10-20 Thread Duncan Booth
Lie Ryan <[EMAIL PROTECTED]> wrote: > That's the job of regular expression: 'import re' > > numbered_atom = re.compile('[A-Z][a-z]?[0-9]+') > if numbered_atom.match('C10'): > # this is a numbered atom > if numbered_atom.match('C'): > # this WON'T match > > read more about regular express

Re: Idenfity numbers in variables

2008-10-20 Thread Lie Ryan
On Mon, 20 Oct 2008 13:16:48 +0200, Alfons Nonell-Canals wrote: > Hello, > I have a trouble and I don't know how to solve it. I am working with > molecules and each molecule has a number of atoms. I obtain each atom > spliting the molecule. > > Ok. It is fine and I have no problem with it. > > T

Re: Idenfity numbers in variables

2008-10-20 Thread Paul McGuire
On Oct 20, 7:07 am, Peter Otten <[EMAIL PROTECTED]> wrote: > Alfons Nonell-Canals wrote: > > I have a trouble and I don't know how to solve it. I am working with > > molecules and each molecule has a number of atoms. I obtain each atom > > spliting the molecule. > > > Ok. It is fine and I have no p

Re: Idenfity numbers in variables

2008-10-20 Thread Tim Chase
atom = 'C1' if '1' in atom: print 'kk' But, how can I do to identify in '1' all possibilities from 1-9, I tried: if '[1-9]', \d,... You're reaching in the right direction (regexps), so just use Python's "re" module: import re digit = re.compile(r'\d') # or "[0-9]" for test in

Re: Idenfity numbers in variables

2008-10-20 Thread Peter Otten
Alfons Nonell-Canals wrote: > I have a trouble and I don't know how to solve it. I am working with > molecules and each molecule has a number of atoms. I obtain each atom > spliting the molecule. > > Ok. It is fine and I have no problem with it. > > The problem is when I have to work with these

Re: Idenfity numbers in variables

2008-10-20 Thread John Machin
On Oct 20, 10:16 pm, Alfons Nonell-Canals <[EMAIL PROTECTED]> wrote: > Hello, > I have a trouble and I don't know how to solve it. I am working with > molecules and each molecule has a number of atoms. I obtain each atom > spliting the molecule. > > Ok. It is fine and I have no problem with it. > >

Idenfity numbers in variables

2008-10-20 Thread Alfons Nonell-Canals
Hello, I have a trouble and I don't know how to solve it. I am working with molecules and each molecule has a number of atoms. I obtain each atom spliting the molecule. Ok. It is fine and I have no problem with it. The problem is when I have to work with these atoms. These atoms usually are only