473,704 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1746
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__(sel f, 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__(sel f, 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_co m 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__(sel f, 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__(sel f, 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_c om wrote:
>>>Georg Brandl wrote:

lazaridis_c om 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__(sel f, name):
return sys._getframe(1 ).f_globals['__%s__' % name]
identifie r = _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

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

Similar topics

6
4653
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 at this grounp I suspect. So the question is: How does a std::vector construct and destruct the elements in it? I know it has something to do with an allocator... Suppose I wrote:
2
1731
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 have to question. Some of the code I'm compiling places labels at the end of a construct, either as the destination of a goto or even something as benign as a default: label in a switch statement. starting with 3.4.3 (but not before) I'm...
0
985
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" subexpression). The subexpression is fully matched once, and then does not participate piecemeal in backtracking. (That is, the subexpression matches only strings that would
12
2662
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: Nonbacktracking subexpression (also known as a "greedy" subexpression). The subexpression is fully matched once, and then does not participate piecemeal
17
2312
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# and I absolutely *love* it. It makes me think more about what I'm doing it before I just spew code into the editor. I'm writing better code than ever. The only thing so far that I don't like about it is the switch construct. I can't do this:
2
1345
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 edit) so now we have one place where people can share inventory constructs, questions-and-answers, patches, documentation and more. enjoy.
4
24133
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 data structures like linked list, binary-tree and hash table are closely linked with dynamic memory technology. Any help that can be provided would be greatly appreciated. Thanks in advance
16
2048
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 problems (that I do not see as a newcomer):
11
1668
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 singleton instance which would keep th something like
27
2831
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></ tr></table> Would you please tell me the right construct (clearly must be functionally equivalent).
0
8766
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8684
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9134
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8975
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7887
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6604
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5930
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4438
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2078
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.