473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*
************************************************** ************

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBIbRng2TFRV0OoZwMRAn0SAJ96xhkrV7zj0+Ye2Eq+rd rLgjY6nwCfeTqT
P5oaIq2LQwriyebsgCA4sWM=
=DUrE
-----END PGP SIGNATURE-----

Jul 3 '08 #1
3 942
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
Jul 3 '08 #2

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*
************************************************** ************

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBIbTEL2TFRV0OoZwMRAuPfAJwK96yGuQsGKwxffjXZ7m DTv03C5wCfaRMb
w1HGHkN4g0ptY1z/eC2ISqg=
=IPQm
-----END PGP SIGNATURE-----

Jul 3 '08 #3
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
Jul 3 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2026
by: Ken Godee | last post by:
I'm using the python Queue module, but since I can not find anyway to clear the Queue, I thought I would try to reassign ie...... q1 = Queue.Queue() q1.put('test1') q1.put('test2') q1.qsize()...
6
1437
by: Balaji | last post by:
Hello eveybody.... Suppose there is a class A: I want to generate say 100 random instance of it... How can I do that.... I want the instance name to be like a1, a2, a3...
7
2409
by: max(01)* | last post by:
hi. is there a way to define a class method which prints the instance name? e.g.: >>> class class_1: .... def myName(self): .... ????what should i do here???? ....
3
1602
by: Angelos Karantzalis | last post by:
Hi y'all ... I've just come across a rather weird problem. i'm using the following code to get the names of the public properties of an object: public static string GetPropertyNames(object...
3
1573
by: John | last post by:
Hi, I have a ToolbarButton and I want to print out the instance name. This is easy to do with objects that inherit from Control because there is a .Name property. However, with other objects...
8
1653
by: Li Pang | last post by:
Hi I want to run my app only one instance, i.e. only one session is allowed to display Thank
20
27729
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of...
14
9901
by: Jordan Marr | last post by:
I have the following class: class ProvisionCollection { ... private int m_VarianceCount; public int VarianceCount { get { return m_VarianceCount; }
28
2150
by: Stef Mientki | last post by:
hello, I'm trying to build a simple functional simulator for JAL (a Pascal-like language for PICs). My first action is to translate the JAL code into Python code. The reason for this approach is...
0
1138
by: Chris O | last post by:
"Larry Lowe" <llowejr@usa.netwrote in message news:ad17577.0308140714.1b14d778@posting.google.com... Hi Larry. Some responses aren't very helpful. I'll try to do a little better. The first...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7537
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.