Re: [Python-Dev] Adding syntax for units of measure
Tobias C. Rittweiler wrote: Has anyone added special syntax to allow writing numeric literals with physical units? So you can write 12m + 34cm, and would get 12.34m. Python-dev is for concrete discussion of development of the next versions. Questions and speculative discussion should generally be directed to python-list and concrete proposals to python-ideas. There have been posts on this subject on python-list and you can search the archive. That list is mirrored as newsgroup gmane.comp.python.general at news.gmane.org, which I believe has its own searchable archive. tjr ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 376
2009/6/22 P.J. Eby : > At 05:42 PM 6/22/2009 +0200, Tarek Ziadé wrote: >> >> Wouldn't it be better to use the native line terminator on the current >> platform? (someone might want to edit or at least view the file) >> >> >> Good idea, I'll change that, >> > > As long as the file is always *read* with "U" mode, so that you can't mess > it up, especially if the install is to a directory shared between platforms. Adding that too, thanks; > > >> The idea of this API is to find out of a distribution "owns" a file, e.g. >> is the only distribution >> that uses it, so it can be safely removed. > > This could equally well be done by ``owners(path)``, returning a sequence of > zero or more items. Any length <> 1 means the file can't be safely removed. > Meanwhile, having the data about all the owners of a file would also be > useful for tools that just want to inspect a directory's contents, for > example, or to detect conflicts and overwrites. that's basically what "get_file_users" does except it's an iterator, roughly that would be : def get_file_owners(path): return list(get_file_users(paths)) So I am wondering if it worth having it -- Tarek Ziadé | http://ziade.org ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 376
On Tue, Jun 23, 2009 at 3:41 AM, Kevin Teague wrote: >> >> >> A plural class name looks strange (I think it's the first time I see one >> in >> the CPython codebase). How about another name? (DistributionPool, >> DistributionMap, WorkingSet etc.). >> >> Sure, WorkingSet is nice, it's the name used in setuptools, >> > > A WorkingSet and a DistributionDirectories (or whatever it gets named to) > are different things though, no? > > A WorkingSet is "a collection of active distributions", where each > distribution might come from different distribution directories: > > http://peak.telecommunity.com/DevCenter/PkgResources#workingset-objects > > Where as DistributionDirectories is a dictionary of locations where > distributions are installed. The WorkingSet may be comprised of > distributions from several different locations, and each location may > contain the same or different versions of the same distribution. DistributionDirectories can contain directories that are not located in the same parent directory, so I find it rather similar besides the "active" feature in Python doesn't exist (yet) In any case, maybe picking up a name that is not from setuptools will be less confusing for people that uses WorkingSet classes nowadays. What about using the same names used in Python's site module: "sitedir" is the name used for a directory we named DistributionDirectory. So what about : DistributionDirectory -> SiteDir DistributionDirectories -> SiteDirMap ++ Tarek ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 376
Tarek Ziadé wrote: > So what about : > > DistributionDirectory -> SiteDir > DistributionDirectories -> SiteDirMap 'site' has too many connections to existing concepts for my liking (site.py, sitesetup.py, site-packages). Something like DistributionDirectoryMap should cover it. You could probably get away with shortening "Directory" to "Dir" in the class names though: - Distribution - ZippedDistribution - DistributionDir - ZippedDistributionDir - DistributionDirMap (Shortening Distribution to Dist might also be a possibility, but I don't think that works well for the two basic classes, and if those use the long form then shortening it for the *Dir and *DirMap classes would just look odd) Cheers, Nick. -- Nick Coghlan | [email protected] | Brisbane, Australia --- ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Adding syntax for units of measure
Tobias C. Rittweiler schrieb: > Hi! > > Has anyone added special syntax to allow writing numeric literals with > physical units? So you can write 12m + 34cm, and would get 12.34m. > > My question is how would you modify the BNF the most sensible way to > allow for this? The above example is simple, but think of 42 km/h. You don't need special syntax in order to work with units. You just need to normalize all input to SI units like meter, second and meter per second: km=1000. m=1. dm=0.1 cm=0.01 mm=0.001 s= 1. h = 3600. m_s=m/s km_h=km/h length_in_mm = (12*m + 34*cm)/mm speed = 5*km_h For what purpose do you want to have physical units in Python syntax? Do you need to verify your formulas? Christian ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Adding syntax for units of measure
Tobias C. Rittweiler schrieb: > Hi! > > Has anyone added special syntax to allow writing numeric literals with > physical units? So you can write 12m + 34cm, and would get 12.34m. > > My question is how would you modify the BNF the most sensible way to > allow for this? The above example is simple, but think of 42 km/h. > > (For my purposes, modifying the BNF is perfectly reasonable, but if you > can depict a good, and convenient!, way that would not result in > modifying it, I'd like to hear it, too.) Hi, normally you wouldn't add units to the language itself. When using them programmatically, it should be no effort to use a class that represents a quantity with unit. This can be made as easy as making "m" an object of that type, so that you only need to type "2*m" to get two meters. For the interactive shell, using a wrapper that allows simplified input is also a possibility, like IPython's "-profile physics" mode, or something like http://bitbucket.org/birkenfeld/phsh/ which allows you to write >>> `1 m` + `12 cm` 1.12 m cheers, Georg ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Python 3.0.1 and mingw
Hi, I wanted to know if you have some patch to compile python 3.x on mingw platform because I found some but doesn't work very well : > make gcc -o python.exe \ Modules/python.o \ libpython3.0.a-lm Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: can't initialize sys standard streams ImportError: No module named encodings.utf_8 I have some questions about posixmodule.c, config.c and makesetup, I can see in posixmodule that you define a INITFUNC like this : #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__)) && !defined(__QNX__) #define INITFUNC PyInit_nt #define MODNAME "nt" #elif defined(PYOS_OS2) #define INITFUNC PyInit_os2 #define MODNAME "os2" #else #define INITFUNC PyInit_posix #define MODNAME "posix" #endif So first I tried to add || defined(MINGW32) to declare a PyInit_nt but after config.c was still using PyInit_posix. How does makesetup choose to include one function or another ? So finally python is using PyInit_posix... Any idea why I got this compilation error ? And after ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Python 3.0.1 and mingw
On Tue, Jun 23, 2009, Vincent R. wrote: > > I wanted to know if you have some patch to compile python 3.x on mingw > platform because I found some but doesn't work very well : This question belongs on comp.lang.python, please re-post there. -- Aahz ([email protected]) <*> http://www.pythoncraft.com/ "as long as we like the same operating system, things are cool." --piranha ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 376
On 09-06-23 02:57 AM, Nick Coghlan wrote: Something like DistributionDirectoryMap should cover it. You could probably get away with shortening "Directory" to "Dir" in the class names though: - Distribution - ZippedDistribution - DistributionDir - ZippedDistributionDir - DistributionDirMap 'Map' reminds me of an associated hash (or is it the actual map?). Hence I suggest: DistributionSet -srid ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Adding syntax for units of measure
>> Has anyone added special syntax to allow writing numeric literals with >> physical units? So you can write 12m + 34cm, and would get 12.34m. ... Georg> normally you wouldn't add units to the language itself. ... Georg> For the interactive shell, using a wrapper that allows simplified Georg> input is also a possibility, like IPython's "-profile physics" Georg> mode, or something like http://bitbucket.org/birkenfeld/phsh/ Georg> which allows you to write `1 m` + `12 cm` Georg> 1.12 m Also, check out the magnitude module (in PyPI). I use it to specify the units of the computation but allow users to input values using units which are meaningful to them. So, for example, if a value has units of time they could enter 1m or 60s and get the same internal value. Skip ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] PEP 376
At 10:38 AM 6/23/2009 +0200, Tarek Ziadé wrote: What about using the same names used in Python's site module: "sitedir" is the name used for a directory we named DistributionDirectory. No, a site dir is a Python-defined directory for site-installed packages, and/or a directory where .pth files are processed. Wrong connotations entirely, since packages may be installed to other directories, and typically are in e.g. shared hosting environments. DistributionDirectory is fine by me. DistributionDirectories sounds like what setuptools calls an Environment. ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
