469,271 Members | 1,343 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

CONSTRUCT -

I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.

-

What I would need to know is:

a) what would be the correct term for "identifier"?

b) is there a standard way to implement such an access mechanism in an
generic way?

c) is there an advanced mechanism available, which would allow to
implement a prefix (e.g. %name)

-

Context:
http://case.lazaridis.com/wiki/Lang
http://case.lazaridis.com/ticket/6

Sep 2 '06 #1
13 1559
lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.

-

What I would need to know is:

a) what would be the correct term for "identifier"?

b) is there a standard way to implement such an access mechanism in an
generic way?

c) is there an advanced mechanism available, which would allow to
implement a prefix (e.g. %name)

-

Context:
http://case.lazaridis.com/wiki/Lang
http://case.lazaridis.com/ticket/6
I'm sorry, you post makes very little sense. If all you want to do is
implement a less "ugly" verision of "if __name__ == '__main__':", a
quick search on google should turn up several ways.

Peace,
~Simon

Sep 2 '06 #2
lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.

-

What I would need to know is:

a) what would be the correct term for "identifier"?
import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()

Georg
Sep 3 '06 #3
Simon Forman wrote:
I'm sorry, your post makes very little sense.
you're somewhat new here, right ? ;-)

</F>

Sep 3 '06 #4
Georg Brandl wrote:
lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.
....
import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()
ok, I understand.

this one would work with modules.

but how would look a more general solution, which would work with
objects too?

..

--
http://lazaridis.com

Sep 3 '06 #5

Simon Forman wrote:
lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':
....
Context:
http://case.lazaridis.com/wiki/Lang
http://case.lazaridis.com/ticket/6

I'm sorry, you post makes very little sense. If all you want to do is
implement a less "ugly" verision of "if __name__ == '__main__':", a
quick search on google should turn up several ways.
this happend already within another thread/ticket:

http://case.lazaridis.com/changeset/45

this here is aboute the underscores in "__name__".

-

search engines are full of information, but when looking for standard
constructs and ways to do something, I rely on feedback from domain
experts.

some search-engine hits:

http://aspn.activestate.com/ASPN/Mai...on-list/830424
http://aspn.activestate.com/ASPN/Coo.../Recipe/496930
http://aspn.activestate.com/ASPN/Coo.../Recipe/496920

Sep 3 '06 #6
lazaridis_com wrote:
Georg Brandl wrote:
>lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.
...
>import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()

ok, I understand.

this one would work with modules.

but how would look a more general solution, which would work with
objects too?
Why can't you try to come up with something yourself? You should have
had enough exposure to the Python language by now.

Georg
Sep 4 '06 #7
Georg Brandl wrote:
lazaridis_com wrote:
Georg Brandl wrote:
lazaridis_com wrote:
I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.
...
import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()
ok, I understand.

this one would work with modules.

but how would look a more general solution, which would work with
objects too?

Why can't you try to come up with something yourself? You should have
had enough exposure to the Python language by now.

Georg
I am not a (python) domain expert.

Thus I am asking here for available standard-solutions, before I
implement an own solution.

Sep 5 '06 #8
lazaridis_com wrote:
Georg Brandl wrote:
>>lazaridis_com wrote:
>>>Georg Brandl wrote:

lazaridis_com wrote:

>I would like to fulfill the following task:
>
>The construct:
>
>if __name__ == '__main__':
>
>should be changed to something like:
>
>if identifier.name == '__main__':
>
>The term "identifier" should be selected based on the meaning of the
>__double-underscore-enclosure__ of the entities.

...
import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()

ok, I understand.

this one would work with modules.

but how would look a more general solution, which would work with
objects too?

Why can't you try to come up with something yourself? You should have
had enough exposure to the Python language by now.

Georg


I am not a (python) domain expert.

Thus I am asking here for available standard-solutions, before I
implement an own solution.
There is no standard solution for the problem you mention.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 5 '06 #9
Fredrik Lundh wrote:
Simon Forman wrote:
I'm sorry, your post makes very little sense.

you're somewhat new here, right ? ;-)

</F>

Yah, I've been posting here about three months now. Why, did I miss
something? :-)

Peace,
~Simon

Sep 6 '06 #10
Simon Forman wrote:
Fredrik Lundh wrote:
>>Simon Forman wrote:

>>>I'm sorry, your post makes very little sense.

you're somewhat new here, right ? ;-)

</F>

Yah, I've been posting here about three months now. Why, did I miss
something? :-)
Yes: the previous posts from the same poster. Ilias Lazaridis'
communications can be a little obscure, to say the least, and it's
apparent that his approach to language evaluaation doesn't emphasize
community experience too heavily. Still, it takes all sorts to make a
newsgroup ...

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 6 '06 #11
Steve Holden wrote:
lazaridis_com wrote:
Georg Brandl wrote:
>lazaridis_com wrote:
Georg Brandl wrote:
lazaridis_com wrote:

I would like to fulfill the following task:

The construct:

if __name__ == '__main__':

should be changed to something like:

if identifier.name == '__main__':

The term "identifier" should be selected based on the meaning of the
__double-underscore-enclosure__ of the entities.

import sys
class _identifier:
def __getattr__(self, name):
return sys._getframe(1).f_globals['__%s__' % name]
identifier = _identifier()

ok, I understand.

this one would work with modules.

but how would look a more general solution, which would work with
objects too?

Why can't you try to come up with something yourself? You should have
had enough exposure to the Python language by now.
I am not a (python) domain expert.

Thus I am asking here for available standard-solutions, before I
implement an own solution.
There is no standard solution for the problem you mention.
I see.

Can one point me to the relevant documentation?

Or at least give me the relevant key-words / Search Phrases?

I remember to have located a relevant PEP, but I cannot find it again.

..

Sep 6 '06 #12
Steve Holden wrote:
>I am not a (python) domain expert.

Thus I am asking here for available standard-solutions, before I
implement an own solution.
There is no standard solution for the problem you mention.
Because it's not a problem for most people ;)

Georg
Sep 7 '06 #13
Steve Holden wrote:
Simon Forman wrote:
Fredrik Lundh wrote:
>Simon Forman wrote:

I'm sorry, your post makes very little sense.

you're somewhat new here, right ? ;-)
Yah, I've been posting here about three months now. Why, did I miss
something? :-)
Yes: the previous posts from the same poster. Ilias Lazaridis'
communications can be a little obscure, to say the least, and it's
apparent that his approach to language evaluaation doesn't emphasize
community experience too heavily. Still, it takes all sorts to make a
newsgroup ...
I'm not evaluation python anymore, I've selected it:

http://case.lazaridis.com/wiki/Lang

At this point, I just try to make it fit my personal requirements:

http://case.lazaridis.com/ticket/6

As a flexible dynamic language, python should allow me to change it a
little.

but, as said:

"
What I would need to know is:

a) what would be the correct term for "identifier"?

b) is there a standard way to implement such an access mechanism in an
generic way?

c) is there an advanced mechanism available, which would allow to
implement a prefix (e.g. %name)
"

You've anwered question b).

Additionally, I had read an PEP which referenced this case, but cannot
find it again. It would be nice to have some answers to the topic, thus
this thread has at least some value for people finding it in archives
(those which agree with me that __name__ has a low readability).

..

Sep 13 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Lasse Skyum | last post: by
2 posts views Thread by Wiseguy | last post: by
2 posts views Thread by gangesmaster | last post: by
4 posts views Thread by hankssong | last post: by
16 posts views Thread by Ilias Lazaridis | last post: by
11 posts views Thread by lazaridis_com | last post: by
27 posts views Thread by pamela fluente | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.