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 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
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
Simon Forman wrote:
I'm sorry, your post makes very little sense.
you're somewhat new here, right ? ;-)
</F>
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
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
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.
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
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
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
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.
..
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
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).
.. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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"...
|
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:
...
|
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#...
|
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...
|
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...
|
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...
|
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...
|
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></...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |