473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 1731
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Lasse Skyum | last post by:
I'm currently learning STL and I hate not knowing what is gooing on "inside" STL... not because I really _need_ to know it to develop my game project, but that's just my nature... like most of you...
2
by: Wiseguy | last post by:
I'm in the process of trying to create my own lean, mean, uber linux distro and have bootstrapped a prototype system to build upon. I'm using the gcc 3.4.3 compiler and am getting an error that I...
0
by: Laser Lu | last post by:
Hi, all, Does any body know how to use this Grouping Construct? (?> ) The following is its description in the MSDN reference: Nonbacktracking subexpression (also known as a "greedy"...
12
by: Laser Lu | last post by:
Hello, everybody, do you know how to use this Grouping Construct? (?> ) I've found its reference on MSDN, but still can not understand it totally. The following is its description: ...
17
by: Mike Hofer | last post by:
While I'd toyed with C, C++, and Java over the last 20 years or so, my principal language has been BASIC, QBASIC, then Visual Basic, and finally Visual Basic .NET. But lately, I've been using C#...
2
by: gangesmaster | last post by:
finally, i opened a wiki for Construct, the "parsing made fun" library. the project's page: http://pyconstruct.sourceforge.net/ the project's wiki: http://pyconstruct.wikispaces.com/ (anyone can...
4
by: hankssong | last post by:
Hi everyone, I'm wondering whether it's possible to construct a binary-tree using python. Since python don't have pointer, it can't dynamically allocate memory like C language. But some important...
16
by: Ilias Lazaridis | last post by:
I have a few small questions subjecting python functionality, most importantly the "alias_method". - *IMPORT* I would like to know, if this construct is valid, or if it can result in...
11
by: lazaridis_com | last post by:
I would like to change the construct: if __name__ == '__main__': to something like: if exec.isMain(): My (OO thought) is to place a class in an separate code module and to instantiate an...
27
by: pamela fluente | last post by:
Hello, for the following code, VS suggests that construct (width= height= ) is out of date and a newer one is recommended: <table><tr><td width="92" height="38" valign="middle">AnyThing</td></...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.