Re: __pycache__, one more good reason to stck with Python 2?

2011-01-17 Thread Flávio Lisbôa
That's why i disagree (and hate) the automatic compilation of code, my
project directory becomes full of object files, and then i need to either
delete everything manually or create a script to do the work (not in python,
because it'll dirt things even more :). Sometimes i notice python doesn't
recompile the .pyc in response to changes in .py (because i share my project
folders between computers using Dropbox).

Unless this is just a rant, maybe you could use the PYTHONDONTWRITEBYTECODE
environment flag or set the -B flag when executing the python interpreter.
This flag deactivates auto-compilation, and may also deactivate __pycache__
effects, but i'm not sure, i can't test it now. See
http://docs.python.org/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE .
The implications of deactivating this behaviour are somewhat obvious, and i
wonder what impacts it'd cause on your system (but i hardly expect it to be
anything serious).

After reading some articles about it, I've come to think python depends a
lot on bytecode writing on the filesystem. I wonder if it's good or bad. I
find it so invasive, and that it should not be the default behaviour. But
that's me, i'm sure most of python users don't mind at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: type(d) != type(d.copy()) when type(d).issubclass(dict)

2010-12-24 Thread Flávio Lisbôa

  copy, here, is a dict method. It will create a dict.
 If you really need it, you could try this:

 import copy
 class neodict(dict):
def copy(self):
return copy.copy(self)

 d = neodict()
 print type(d)
 dd = d.copy()
 print type(dd)


One more gotcha to python... OO in python is strange :p

IMO, if i subclass a class, all instance methods from a subclass instance
should work with the subclass. But i'm guessing python doesn't make this
distinction of instance/class methods like some other languages do (unless
one uses annotations, what appears to be not the case with the dict class).

Not that it inhibits me on using python in any way, in fact i do use python
for my projects. I'm new to it, and I like some of its features, but some
others are rather strange.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Map Linux locale codes to Windows locale codes?

2010-12-14 Thread Flávio Lisbôa
You could look into the windows registry, the key
HKLM\SYSTEM\CurrentControlSet\Control\Nls has all the supported LCID's
listed. If not, you could simply get the codepage provided by
locale.setlocale(), e.g.:

import locale
print(locale.setlocale(locale.LC_ALL, ))

prints Portuguese_Brazil.1252 for me. That codepage part is actually a
LCID, that you can then cross-reference with any LCID list on the net. I
guess there may be a way to look that up entirely from the registry,
including getting a short reference or ANSI codepage from the LCID, but i
doubt it'd be portable at all.

Maybe what you should do is to make up a dict with known LCID's and their
corresponding language codes. I don't know of any way to do this
automatically in python...

Take a look at http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx

2010/12/14 pyt...@bdurham.com

 Is there a way to map Linux locale codes to Windows locale codes?

 Windows has locale codes like 'Spanish_Mexico'. We would like to use the
 more ISO compliant 'es_MX' locale format under Windows.

 Is there a resource or API that might help us with this mapping?

 Babel is not an option for us since we're using Python 2.7.

 Thank you,
 Malcolm

 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list