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 1622
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...
|
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...
|
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:
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| |