Re: python file API
On Mon, Sep 24, 2012 at 5:55 PM, Oscar Benjamin
wrote:
> There are many situations where a little bit of attribute access magic is a
> good thing. However, operations that involve the underlying OS and that are
> prone to raising exceptions even in bug free code should not be performed
> implicitly like this. I find the following a little cryptic:
> try:
> f.pos = 256
> except IOError:
> print('Unseekable file')
Well it might be that the coupling between the python interpreter and
the operating system should be more direct and there should be a
special exception class that bypasses the normal overhead in the
CPython implementation so that error can be caught in the code without
breaking syntax. But I don't think I'm ready to argue that point
markj
--
http://mail.python.org/mailman/listinfo/python-list
Re: Are ABCs an anti-pattern?
On Tue, Oct 2, 2012 at 9:23 AM, Demian Brecht wrote:
> I don't use them anymore, but I'm curious about others opinions on this
> list...
>
Interesting question. I think they haven't been useful for representing
the real world as everyone hoped, but are pretty good for organizing
structures within the Python universe (like "object "collections" -->
{'list','set','dict'...}, for example).
mark
--
http://mail.python.org/mailman/listinfo/python-list
Re: Emulating C++ namespaces with ChainMap and metaclass trickery
On Wed, Oct 3, 2012 at 1:26 PM, Steven D'Aprano < [email protected]> wrote: > C++ namespaces are useful for encapsulating related objects within a > single file, subdividing the global namespace without using classes. > Python has modules, but they come in separate files. > > Using Python 3.3's ChainMap type, and some metaclass trickery, I abuse > the class keyword to (almost) emulate C++ namespaces: > Very interesting. I like the idea of continuing the namespace meme. My idea of using the builtins (in the prior list thread of "namespaces and modules"), is that if we overhaul the builtins, a unified data model could emerge to incorporate whatever ideas one may have for namespaces (i.e. "enclosures with a name"). My idea was to introduce the compound data type (using a ":" colon to separate two sides), whereby one associates a (*hashable*) "name" with an object ("meals":{"breakfast","lunch","dinner"}) . This has the extra advantage of killing two warts in Python with one stone: {} now is the empty set literal like people are taught, and a set of compounds makes a dictionary (dict now has set operations available), something which, in theory, should simply CPython implementation AND the python environment/API. "expose name" put the dictionary (or whatever type is decided for the rhs) into the builtin/global namespace. I have further thoughts, but that's all I have at the moment markj gothenburg, nebraska -- http://mail.python.org/mailman/listinfo/python-list
Re: a.index(float('nan')) fails
On Thu, Oct 25, 2012 at 9:04 PM, Terry Reedy wrote: > On 10/25/2012 9:46 PM, [email protected] wrote: > > a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > a >> >> [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > a.index(float('nan')) >> >> Traceback (most recent call last): >>File "", line 1, in >> ValueError: list.index(x): x not in list >> >> That means, the function .index() cannot detect nan values. >> It happens on both Python 2.6 and Python 3.1 >> >> Is this a bug? Or I am not using .index() correctly? > > > It is a consequence of the following, which some people (but not all) > believe is mandated by the IEEE standard. > nan = float('nan') nan is nan > True It should be noted, for the record, that "nan is nan" returning True has nothing to do with the concept of numbers or the IEEE standard and is purely a consequence that Python runs on hardware with memory addresses and such. nan == nan > False Here, equality, IS about number and this is appropriate and conforms to the IEEE standard. nanlist = [nan] nan in nanlist > True nanlist.index(nan) > 0 Here you just see an phenomenon with the python object/reference model, which, being as it is, has nothing to do with numbers. This is an area which, potentially could be changed in Python without violating the IEEE standard whatsoever. Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: Paid Python work for 30mins - 1 hour
On Mon, Nov 19, 2012 at 10:14 AM, wrote: > I have three scripts that I would like written, they are designed to do the > following: > > Backup.py – Zip a folder and store it on amazon S3 using BOTO with the date > and time as the folder name. > > Restore.py – Grab a file from S3 and download it and then unzip it in the > right location with two commandline parameters (1 = Get most recent, 2 = Get > specific file) > > Import.py – Check that I have done this correctly and add command line > parameter for changing the command > > This code is probably 50% completed already and if someone knows what they > are doing, could be completed in a very short time. It is really basic Python > code, I just dont know python myself. > > If you are interested get in touch! You might consider putting your request on elance.com or guru.com where you can hire programmers for small projects like this. Good luck, mark -- http://mail.python.org/mailman/listinfo/python-list
