Re: [Python-Dev] Issue #25256: Add sys.debug_build?

2015-10-02 Thread Nir Soffer
Whats wrong with:

>>> sysconfig.get_config_var('Py_DEBUG')
0

Nir

On Fri, Oct 2, 2015 at 10:18 AM, Victor Stinner 
wrote:

> Hi,
>
> I created the issue "Add sys.debug_build public variable to check if
> Python was compiled in debug mode": http://bugs.python.org/issue25256
>
> I would like to add an obvious way to check if Python was compiled in
> debug mode, instead of having hacks/tips to check it. On the Internet,
> I found various recipes to check if Python is compiled is debug mode.
> Sadly, some of them are not portable. For example, 3 different checks
> are proposed on StackOverflow but 2 of them are specific to Windows:
>
> http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter
>
>  Even if the exact impact of a debug build depends on the Python
> implementation and the Python version, we can use it to have the same
> behaviour on all Python implementations. For example, the warnings
> module shows warnings by default if Python is compiled in debug mode:
> Extract of my patch:
>
> -if hasattr(sys, 'gettotalrefcount'):
> +if sys.debug_build:
>  resource_action = "always"
>  else:
>  resource_action = "ignore"
>
> Alternative: Add a new sys.implementation.debug_build flag. Problem:
> extending sys.implementation requires a new PEP, and I don't think
> that debug_build fits into this object.
>
> Berker Peksag likes the idea.
>
> Serhiy Storchaka dislike the new flag: "I don't like this. The sys
> module is one of most used module, but it has too many members, and
> adding yet one makes the situation worse." (sys has 81 symbols)
> "Checking for debug mode is not often needed, and mainly in tests.
> Current way ``hasattr(sys, 'gettotalrefcount')`` works good. You also
> can check ``'d' in sys.abiflags`` if it looks cleaner to you. Or add a
> member to test.support."
>
> The name "debug_build" comes from the existing
> sysconfig.is_python_build() function. There is a sys.flags.debug flag,
> so "sys.debug" can be confusing. I prefer to attach the "build"
> suffix.
>
> First I proposed a function sys.is_debug_build(), but a flag is
> simpler than a function. There is not need to compute a version it's
> known at build time.
>
> What do you think? Should we add sys.debug_build?
>
> Victor
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/nirsof%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Translate Python language

2015-11-11 Thread Nir Soffer
On Wed, Nov 11, 2015 at 5:13 PM, Christophe Bal  wrote:

> Hello.
>
> I'm a french teacher and I would like to use Python with young child but
> I've a big problem. All the keyword are in english. So I would like to know
> if there is a way to hack the AST tools such as to use french keywords and
> then translate a list of french keywords to their english regular version.
>
> Where should I start ? My idea is not to build a new language but simply
> translate words using an hacked version of the AST tools.
>
> Hoping to be clear and I do not pollute the message in this list.
>

I did this in 2006 for Hebrew - we had Hebrew Python dialect, with
Hebrew turtle module and interactive shell.

You can try to reuse this:
https://github.com/nirs/hpy

Nir


>
>
> *Christophe BAL*
> *Enseignant de mathématiques en Lycée **et développeur Python amateur*
> *---*
> *French math teacher in a "Lycée" **and **Python **amateur developer*
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/nirsof%40gmail.com
>
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] os.path.normcase rationale?

2010-10-02 Thread Nir Soffer
On Sat, Sep 25, 2010 at 1:36 AM, James Y Knight  wrote:
>
> An OSX code sketch is available here (summary: call FSPathMakeRef to get an
> FSRef from a path string, then FSRefMakePath to make it back into a path,
> which will then have the correct case). And note that it only works if the
> file actually exists.
>
>
> http://stackoverflow.com/questions/370186/how-do-i-find-the-correct-case-of-a-filename
>
> It would indeed be useful to have that be available in Python.
>

There is a much simpler way:

>>> from Carbon import File
>>> File.FSRef('/tmp/foo').as_pathname()
'/private/tmp/Foo'

Note that this is much slower compared to os.path.exists.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] os.normpath may change the meaning of the path if it contains symbolic links?

2005-12-02 Thread Nir Soffer
I'm working on  
<https://sourceforge.net/tracker/index.php? 
func=detail&aid=1239890&group_id=5470&atid=305470>

My patch uses os.path.normpath to simplify the path sent to makedirs as  
first step. This eliminates the need to check for os.currdir or other  
special case, because normpath already handle all those ugly spacial  
cases (and hopefully tested). And of course eliminate possible  
pointless system calls.

For example (on Mac OS X):

 >>> os.path.normpath('a/./b/c')
'a/b/c'
 >>> os.path.normpath('a/b/c/.')
'a/b/c'
 >>> os.path.normpath('./a/b')
'a/b'
 >>> os.path.normpath('a/b/')
'a/b'

However, I found this alarming note in the docs:

normpath(path)
...
"It should be understood that this may change the meaning of the path  
if it contains symbolic links!"

The function docstring does not contain this note:

"""Normalize path, eliminating double slashes, etc."""

And finally, there is no test for this symbolic link problem.

Anyone has a clue about this?


Best Regards,

Nir Soffer

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com