Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Instance Names

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


timothywayne.cook at gmail

Jul 3, 2008, 11:26 AM

Post #1 of 4 (96 views)
Permalink
Instance Names

Hi All,

I have a need (if at all possible) to create instance names using '['
and ']', i.e. [at0000]=ClassA0(), [at0001]=ClassB2(), etc.

Of course Python tries to unpack a sequence when I do that. Is there
anyway to do this?

I do have a workaround but it is an ugly, nasty URL mangling thing. :-)

Cheers,
Tim



--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
**************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
Attachments: signature.asc (0.18 KB)


larry.bates at websafe

Jul 3, 2008, 12:20 PM

Post #2 of 4 (89 views)
Permalink
Re: Instance Names [In reply to]

Tim Cook wrote:
> Hi All,
>
> I have a need (if at all possible) to create instance names using '['
> and ']', i.e. [at0000]=ClassA0(), [at0001]=ClassB2(), etc.
>
> Of course Python tries to unpack a sequence when I do that. Is there
> anyway to do this?
>
> I do have a workaround but it is an ugly, nasty URL mangling thing. :-)
>
> Cheers,
> Tim
>
>
>

I suspect there is some "misunderstanding" here. Why exactly do you think you
need to have your instances named with [] characters in them?


You could put them in a dictionary:

instances = {}

instance['[at0000']] = ClassA0()


but that isn't really different than:

instance['at0000'] = ClassA0()

-Larry
--
http://mail.python.org/mailman/listinfo/python-list


timothywayne.cook at gmail

Jul 3, 2008, 1:05 PM

Post #3 of 4 (89 views)
Permalink
Re: Instance Names [In reply to]

On Thu, 2008-07-03 at 14:20 -0500, Larry Bates wrote:

> I suspect there is some "misunderstanding" here. Why exactly do you think you
> need to have your instances named with [] characters in them?
>

I often misunderstand. :-)

But, I am implementing specifications in Python that are already
implemented in other languages.

http://www.openehr.org/releases/1.0.1/roadmap.html

These specifications say that an archetype node id consists of
identifiers like [at0000] and [at0001]. Now these are valid URIs and
the associated query language (AQL) used by other services will send
queries with those characters in them.

For example:
FROM EHR [ehr_id/value=$ehrUid] CONTAINS COMPOSITION
[openEHR-EHR-COMPOSITION.encounter.v1]
CONTAINS OBSERVATION obs [openEHR-EHR-OBSERVATION.blood_pressure.v1]
WHERE
obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/value
>= 140

Since I am also using Zope3 it would be easier on me to name the
instances with those characters.

But my fall back is to set at0000.__name__='[at0000]' and manipulate the
query to match __name__ instead of the actual instance ID.

Thoughts?

--Tim



--
Timothy Cook, MSc
Health Informatics Research & Development Services
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
Skype ID == timothy.cook
**************************************************************
*You may get my Public GPG key from popular keyservers or *
*from this link http://timothywayne.cook.googlepages.com/home*
**************************************************************
Attachments: signature.asc (0.18 KB)


larry.bates at websafe

Jul 3, 2008, 1:14 PM

Post #4 of 4 (88 views)
Permalink
Re: Instance Names [In reply to]

Tim Cook wrote:
> On Thu, 2008-07-03 at 14:20 -0500, Larry Bates wrote:
>
>> I suspect there is some "misunderstanding" here. Why exactly do you think you
>> need to have your instances named with [] characters in them?
>>
>
> I often misunderstand. :-)
>
> But, I am implementing specifications in Python that are already
> implemented in other languages.
>
> http://www.openehr.org/releases/1.0.1/roadmap.html
>
> These specifications say that an archetype node id consists of
> identifiers like [at0000] and [at0001]. Now these are valid URIs and
> the associated query language (AQL) used by other services will send
> queries with those characters in them.
>
> For example:
> FROM EHR [ehr_id/value=$ehrUid] CONTAINS COMPOSITION
> [openEHR-EHR-COMPOSITION.encounter.v1]
> CONTAINS OBSERVATION obs [openEHR-EHR-OBSERVATION.blood_pressure.v1]
> WHERE
> obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/value
>> = 140
>
> Since I am also using Zope3 it would be easier on me to name the
> instances with those characters.
>
> But my fall back is to set at0000.__name__='[at0000]' and manipulate the
> query to match __name__ instead of the actual instance ID.
>
> Thoughts?
>
> --Tim
>
>
>

If these will be class attributes, I believe you can use setattr()

setattr('[at0000]') = ...

obj = getattr(self, '[at0000]')

-Larry
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.