Idenfity numbers in variables

Peter Otten __peter__ at web.de
Mon Oct 20 08:07:56 EDT 2008


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 atoms. These atoms usually
> are only a letter but, sometimes it can also contain one o more numbers.
> If they contein a number I have to manipulate them separately.
> 
> If the number was allways the same I know how to identify them, for
> example, 1:
> 
> 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,...
> 
> Any comments, please?

http://mail.python.org/pipermail/tutor/1999-March/000083.html

Peter



More information about the Python-list mailing list