searching structures

A

Alberto Vera

Hello:

I have next structures:

A[1,2,3]
AB[4,5,6]
ABC[7,8,9]
ABCD[1,2,3]
ABCDE[4,5,6]
ABCDEF[7,8,9]

I'd like to know how many 'arrays' start with ABCD like ABCD*
(ABCD,ABCDE,ABCDEF)

Is it possible to do it using Python?

Regards
 
A

Alan Kennedy

[Alberto Vera]
I have next structures:

A[1,2,3]
AB[4,5,6]
ABC[7,8,9]
ABCD[1,2,3]
ABCDE[4,5,6]
ABCDEF[7,8,9]
I'd like to know how many 'arrays' start with ABCD like ABCD*
(ABCD,ABCDE,ABCDEF)

Is it possible to do it using Python?

That depends on how they are stored. Are they stored in some form of
data structure? Or in a file?

More details required.
 
D

Dave Kuhlman

Alberto said:
Hello:

I have next structures:

A[1,2,3]
AB[4,5,6]
ABC[7,8,9]
ABCD[1,2,3]
ABCDE[4,5,6]
ABCDEF[7,8,9]

I'd like to know how many 'arrays' start with ABCD like ABCD*
(ABCD,ABCDE,ABCDEF)

Is it possible to do it using Python?

Sounds like you want to filter on the *name* of the the array. If
so, think about doing something like the following:
['__builtins__', '__doc__', '__file__', '__name__', 'aa', 'aab',
'bb'] ... if x[:2] == 'aa':
... print 'yes', x
... else:
... print 'no', x
...
no __builtins__
no __doc__
no __file__
no __name__
yes aa
yes aab
no bb

And if you need to distinguish the *type* of the value of the
variable, consider using type().

The built-in functions globals() and locals() give dictionaries
that contain variable name-value pairs.

These built-in functions are described at:

http://www.python.org/doc/current/lib/built-in-funcs.html

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,918
Members
47,458
Latest member
Chris#

Latest Threads

Top