Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Noah Fleiszig Newsgroups: comp.lang.python Subject: Re: Python-list Digest, Vol 152, Issue 40 Date: Thu, 26 May 2016 15:06:36 +1000 Lines: 1064 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de tJ+4e00MgnxMl2mqhYbO5w2wsXmFbREwOAvEO7pn/T6w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'static': 0.03; 'value,': 0.03; 'resulting': 0.04; 'subject:Python': 0.05; 'cpython': 0.05; 'that?': 0.05; 'used.': 0.05; '"the': 0.07; '(using': 0.07; '*not*': 0.07; 'exception.': 0.07; 'extends': 0.07; 'indices': 0.07; 'interpreter.': 0.07; 'permissions': 0.07; 'skip:% 20': 0.07; 'valueerror:': 0.07; '"if': 0.09; 'core,': 0.09; 'endif': 0.09; 'file"': 0.09; 'longs': 0.09; 'models.': 0.09; 'namespace': 0.09; 'runtime': 0.09; 'slices': 0.09; 'sub': 0.09; 'throw': 0.09; 'tuple': 0.09; 'unicode,': 0.09; 'url:github': 0.09; 'variants': 0.09; 'wrong,': 0.09; 'yeah,': 0.09; 'bug': 0.10; 'email addr:python.org>': 0.10; 'thread': 0.10; 'url:blog': 0.10; 'python': 0.10; 'template': 0.11; '(at': 0.13; 'causing': 0.13; 'exception': 0.13; 'def': 0.13; 'wed,': 0.15; 'interpreter': 0.15; 'server,': 0.15; "skip:' 30": 0.15; 'skip:f 30': 0.15; 'subject:Issue': 0.15; 'thu,': 0.15; 'value.': 0.15; '<div': 0.16; '(3,': 0.16; '(around': 0.16; '+0300': 0.16; '2016': 0.16; '255': 0.16; '8-bit': 0.16; 'ascii,': 0.16; 'boolean': 0.16; 'caveats': 0.16; 'code?': 0.16; 'col': 0.16; 'columns': 0.16; 'dictionary,': 0.16; 'django.conf': 0.16; 'django.db': 0.16; 'django.http': 0.16; 'ellipsis': 0.16; 'endblock': 0.16; 'entonces': 0.16; 'expression"': 0.16; 'false:': 0.16; 'helps.': 0.16; 'in-line': 0.16; 'indexerror:': 0.16; 'indications': 0.16; 'integers,': 0.16; 'justin': 0.16; 'low-level': 0.16; 'magic': 0.16; 'matters,': 0.16; 'mean,': 0.16; 'meta:': 0.16; 'nodes.': 0.16; 'numpy': 0.16; 'originally,': 0.16; 'processors': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reproduce': 0.16; 'skip:q 30': 0.16; 'skip:} 10': 0.16; 'snippets': 0.16; 'something.': 0.16; 'spurious': 0.16; 'tjg': 0.16; "ubuntu's": 0.16; 'unicode.': 0.16; "url(r'',": 0.16; "url(r'^$',": 0.16; 'url:iso': 0.16; 'urlpatterns': 0.16; 'variations': 0.16; '\xc2\xa0if': 0.16; 'wrote:': 0.16; 'later': 0.16; '</p>': 0.84; '<img': 0.84; '(global': 0.84; "1980's.": 0.84; '19:12': 0.84; '8bit%:82': 0.84; 'adoption': 0.84; 'chrisa': 0.84; 'email name:steve': 0.84; 'embraced': 0.84; 'etc),': 0.84; 'fat': 0.84; 'fearing': 0.84; 'fortunately': 0.84; 'friendship': 0.84; 'hardly': 0.84; 'off,': 0.84; 'seen.': 0.84; 'subject:152': 0.84; 'suspecting': 0.84; 'url:business': 0.84; 'url:pk': 0.84; 'walters': 0.84; '<a': 0.91; '+1000': 0.91; '-0000': 0.91; '8bit%:83': 0.91; 'angelico)': 0.91; 'demand.': 0.91; 'do:': 0.91; 'email addr:python.org"': 0.91; 'grew': 0.91; 'hyperlinks': 0.91; 'joel': 0.91; 'relate': 0.91; 'to:\xc2\xa0': 0.91; 'email name:python-list-owner': 0.93; 'email name:python-list-request': 0.93; 'good,': 0.93; 'have.': 0.93; 'regions': 0.93; 'email addr:gmail.com)': 0.95 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kds.vic.edu.au; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=myI24ZxCuOmIfDMjCwCkcxHwmWbf27vwQhmlctIh4is=; b=B9vADrDVf7ELpi3kAlBciIlIJmQrveheAyTUhFNSiVB/iBKafcgenM1chtPcRDAjIl XmW8NADl1DxF3QD8pV3FLtFjdumwSXC5qLVeZ+4s7IhkbebGMVi9pklK2c3V4sgw21GR NbDwXn/nv48U4KxwM4rlVdSDdRTs1y8EK+Aiw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=myI24ZxCuOmIfDMjCwCkcxHwmWbf27vwQhmlctIh4is=; b=JayXlKijDjV9R33WwC6UAxrXNvmRCvZrY4J+of5leTVwib9xGKOuw6YjUgupbgeSnW dCnieYd5tumdtjNQoJyLaBzrkPerMqNw5jrtivamvM6LKOdGFwYKGDGo4+abofPJE6JO +QDRnFL2IU3w8qOsi8zlwycMSDjP3PMICqhxj7W3kSUPYVA0oQR4mlWclnLwLgDfukNZ t9oTcpgKoeHHXDwpM0uPwRZBO7sjKW1IWN7gAfEJr0KZY4A21XQRJFWD4YHJvwpuJwKd JbEtdVH/ueWCIYvHLwIJSg7itW+4Z57Y+3ngZTXp+pZjkovqHRFKlzUTI2XzKgoReJ70 yebA== X-Gm-Message-State: ALyK8tJ/hNiB0IqA2e0Piy6lv/oGgkWodv6I1XOKzqcjNmJKUpeQ2FwTFiYNmGQ9u9QT2eDvDNo9Y2OUs+VGbxrr X-Received: by 10.36.155.132 with SMTP id o126mr1455560itd.95.1464239196746; Wed, 25 May 2016 22:06:36 -0700 (PDT) In-Reply-To: X-Mailman-Approved-At: Thu, 26 May 2016 08:06:39 -0400 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: Xref: csiph.com comp.lang.python:109151 thank you On Thu, May 26, 2016 at 2:00 AM, wrote: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/python-list > or, via email, send a message with subject or body 'help' to > python-list-request@python.org > > You can reach the person managing the list at > python-list-owner@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Python-list digest..." > > Today's Topics: > > 1. html & python connection problem with hyperlinks > (litssa2005@gmail.com) > 2. Re: Exended ASCII and code pages [was Re: for / while else > doesn't make sense] (Chris Angelico) > 3. Re: for / while else doesn't make sense (Marko Rauhamaa) > 4. Re: Spurious issue in CPython 2.7.5 (thomas povtal.org) > 5. Re: Spurious issue in CPython 2.7.5 (Tim Golden) > 6. Re: for / while else doesn't make sense (Christopher Reimer) > 7. Re: Spurious issue in CPython 2.7.5 (thomas povtal.org) > 8. ValueError: I/O operation on closed file (San) > 9. Re: ValueError: I/O operation on closed file (Joel Goldstick) > 10. Find the max number of elements in lists as value in a > dictionary (Daiyue Weng) > 11. Re: ValueError: I/O operation on closed file (alister) > 12. IndexError for using pandas dataframe values (Daiyue Weng) > 13. Re: Find the max number of elements in lists as value in a > dictionary (Jussi Piitulainen) > 14. Re: Find the max number of elements in lists as value in a > dictionary (Jon Ribbens) > 15. Re: html & python connection problem with hyperlinks > (justin walters) > > > ---------- Forwarded message ---------- > From: litssa2005@gmail.com > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 03:24:30 -0700 (PDT) > Subject: html & python connection problem with hyperlinks > Why not created the field title, that located on the template > BusinessList.html as a link to go to Business_Detail.html..? please check > > Code: > > models. py: > > from django.db import models > > > REGIONS =3D ( > ('=CE=98=CE=95=CE=A3', '=CE=98=CE=95=CE=A3=CE=A3=CE=91=CE=9B=CE=9F=CE=9D= =CE=99=CE=9A=CE=97'), > ('=CE=A3=CE=95=CE=A1', '=CE=A3=CE=95=CE=A1=CE=A1=CE=95=CE=A3'), > ( '=CE=91=CE=98=CE=97', '=CE=91=CE=98=CE=97=CE=9D=CE=91'), > > > > TYPEOFBUSINESS =3D ( > ('=CE=95=CE=A3=CE=A4', '=CE=95=CE=A3=CE=A4=CE=99=CE=91=CE=A4=CE=9F=CE=A1= =CE=99=CE=91'), > ('=CE=A6=CE=91=CE=A1', '=CE=A6=CE=91=CE=A1=CE=9C=CE=91=CE=9A=CE=95=CE=99= =CE=91'), > ('=CE=92=CE=99=CE=92', '=CE=92=CE=99=CE=92=CE=9B=CE=99=CE=9F=CE=A0=CE=A9= =CE=9B=CE=95=CE=99=CE=91'), > ( '=CE=9A=CE=9F=CE=9C', '=CE=9A=CE=9F=CE=9C=CE=9C=CE=A9=CE=A4=CE=97=CE=A1= =CE=99=CE=91'), > ('=CE=A3=CE=99=CE=9D', '=CE=A3=CE=99=CE=9D=CE=95=CE=9C=CE=91') > > ) > > class Business(models.Model): > created_Date =3D models.DateTimeField(auto_now_add=3DTrue) > owner =3D models.ForeignKey('auth.User', related_name=3D'snippets', null= =3DTrue) > title =3D models.CharField(max_length=3D100, blank=3DTrue, default=3D'') > Type_of_Business =3D models.CharField(max_length=3D3, choices=3DTYPEOFBUS= INESS) > region =3D models.CharField(max_length=3D3, choices=3DREGIONS) > address =3D models.CharField(max_length=3D100, blank=3DTrue, default=3D''= ) > phone =3D models.CharField(max_length=3D15, blank=3DTrue, default=3D'') > image =3D models.ImageField(null=3DTrue) > > > def __str__(self): > return str(self.title) > > views.py > > from django.contrib.auth.models import User > from django.http import HttpResponse > from django.shortcuts import render, get_object_or_404 > from rest_framework import filters > from rest_framework import generics > from rest_framework import permissions > from snippets.permissions import IsOwnerOrReadOnly > from snippets.serializers import SnippetSerializer > from snippets.serializers import UserSerializer > from .models import Business > > > > class UserList(generics.ListAPIView): > queryset =3D User.objects.all() > serializer_class =3D UserSerializer > > > class UserDetail(generics.RetrieveAPIView): > queryset =3D User.objects.all() > serializer_class =3D UserSerializer > > class BusinessList(generics.ListCreateAPIView): > > permission_classes =3D (permissions.IsAuthenticatedOrReadOnly,) > queryset =3D Business.objects.all() > serializer_class =3D SnippetSerializer > filter_backends =3D (filters.DjangoFilterBackend,filters.SearchFilter, > filters.OrderingFilter,) > filter_fields =3D ('Type_of_Business', 'region') > search_fields =3D ('Type_of_Business', 'region') > ordering_fields =3D ('Type_of_Business','title', 'region') > > > def BusinessList(request): > business =3D Business.objects.all(); > return render(request, 'snippets/BusinessList.html' {'business':business}= ) > > def perform_create(self, serializer): > serializer.save(owner=3Dself.request.user) > > > > class Business_Detail(generics.RetrieveUpdateDestroyAPIView): > permission_classes =3D (permissions.IsAuthenticatedOrReadOnly, > IsOwnerOrReadOnly,) > queryset =3D Business.objects.all() > serializer_class =3D SnippetSerializer > > > def Business_Detail(request, pk): > business =3D get_object_or_404(Business, pk=3Dpk) > return render(request, 'snippets/Business_Detail.html', {'business': > business}) > > serializers.py > > from rest_framework import serializers > from snippets.models import Business > from django.contrib.auth.models import User > > > class SnippetSerializer(serializers.HyperlinkedModelSerializer): > owner =3D serializers.ReadOnlyField(source=3D'owner.username') > > class Meta: > model =3D Business > fields =3D ('created_Date', 'owner', 'title','Type_of_Business', 'region'= , > 'address', 'phone', 'image') > > > class UserSerializer(serializers.ModelSerializer): > snippets =3D serializers.PrimaryKeyRelatedField(many=3DTrue, > queryset=3DBusiness.objects.all()) > > class Meta: > model =3D User > fields =3D ('id', 'username', 'snippets') > > BusinessList.html > > {% extends 'snippets/base.html' %} > > {% block content %} > {% for business in business%} >
>
> {{ business.created_Date }} #=CF=84=CF=85=CF=80=CF=89=CF=83=CE=B5 =CE=B7= =CE=BC=CE=B5=CF=81.=CE=B4=CE=B7=CE=BC=CE=B9=CE=BF=CF=85=CF=81=CE=B3=CE=B9= =CE=B1=CF=82 =CF=84=CE=BF=CF=85 Business >
>

{{ > business.title }}

>

{{business.Type_of_Business }}

>

{{ business.region }}

>

{{ business.address }}

>

{{ business.phone }}

> {% if business.image %} > > {% endif %} >
> {% endfor %} > {% endblock %} > > Business_Detail.html > > {% extends 'snippets/base.html' %}' %} > > {% block content %} >
> {% if business.created_Date %} # =CE=B1=CE=BD =CF=85=CF=80=CE=B1=CF=81=CF= =87=CE=B5=CE=B9 =CE=B7=CE=BC=CE=B5=CF=81=CE=BF=CE=BC=CE=B7=CE=BD=CE=B9=CE= =B1 =CE=B4=CE=B7=CE=BC=CE=B9=CE=BF=CF=85=CF=81=CE=B3=CE=AF=CE=B1=CF=82 >
> {{ business.created_Date }} >
> {% endif %} >

{{ business.title }}

>

{{ business.region }}

>

{{ business.Type_of_Business}}

>

{{ business.phone }}

>

> {% if business.image %} # =CE=B1=CE=BD =CF=85=CF=80=CE=B1=CF=81=CF=87=CE= =B5=CE=B9 =CE=B5=CE=B9=CE=BA=CE=BF=CE=BD=CE=B1 > # =CF=80=CE=B1=CF=81=CE=B5 =CE=B5= =CE=B9=CE=BA=CE=BF=CE=BD=CE=B1 =CE=B1=CF=80=CE=BF =CF=84=CE=BF =CE=B1=CE=BD= =CF=84=CE=B9=CF=83=CF=84=CE=BF=CE=B9=CF=87=CE=BF url > {% endif %} >

>
> {% endblock %} > > tutorial/snippets/urls.py > > from django.conf.urls import url, include > from django.contrib import admin > from rest_framework.urlpatterns import format_suffix_patterns > from django.contrib.staticfiles.urls import staticfiles_urlpatterns > from django.conf.urls import include > > from . import views > > urlpatterns =3D [ > url(r'^admin/', include(admin.site.urls)), > url(r'^$', views.BusinessList.as_view()), > url(r'^business/(?P[0-9]+)/$', views.Business_Detail.as_view()), > url(r'^users/$', views.UserList.as_view()), > url(r'^users/(?P[0-9]+)/$', views.UserDetail.as_view()), > url(r'^api-auth/', include('rest_framework.urls', > namespace=3D'rest_framework')), > > ] > > urlpatterns =3D format_suffix_patterns(urlpatterns) > urlpatterns +=3D staticfiles_urlpatterns() > > tutorial/urls.py > > from django.conf.urls import include, url > from django.contrib import admin > from django.conf import settings > from django.contrib.staticfiles.urls import staticfiles_urlpatterns > from django.conf.urls.static import static > > > > urlpatterns =3D [ > url(r'^admin/', include(admin.site.urls)), > url(r'', include('snippets.urls')), > > ] > > urlpatterns +=3D staticfiles_urlpatterns() > urlpatterns +=3D static(settings.PHOTO_URL, > document_root=3Dsettings.PHOTO_ROOT) > > > > ---------- Forwarded message ---------- > From: Chris Angelico > To: > Cc: "python-list@python.org" > Date: Wed, 25 May 2016 20:30:55 +1000 > Subject: Re: Exended ASCII and code pages [was Re: for / while else > doesn't make sense] > On Wed, May 25, 2016 at 8:19 PM, Steven D'Aprano > wrote: > > While the code page system was necessary at > > the time, the legacy of them today continues to plague computer users, > causing > > moji-bake, errors on file systems[1], and holding back the adoption of > Unicode. > > > > [1] I'm speaking from experience there. Take files created on a Windows > machine > > using some legacy code page, and try to copy them to another server usi= ng > > Unicode, and depending on the intelligence of the server, you may not b= e > able > > to copy them. On the flip side, there are many file names I can easily > create > > on Linux but cannot copy to a FAT file system. > > And getting a .zip file from a Windows user that had a file in it > called "Caf=C3=A9 Sounds.something", extracting it on Linux, and finding = it > called "Caf\xe9" or something. Very annoying. Fortunately it was only > the one file in a large directory. > > ChrisA > > > > ---------- Forwarded message ---------- > From: Marko Rauhamaa > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 13:47:46 +0300 > Subject: Re: for / while else doesn't make sense > Christopher Reimer : > > > Back in the early 1980's, I grew up on 8-bit processors and latin-1 was > > all we had for ASCII. > > You really were very advanced. According to https://en.wikipedia.org/wiki/ISO/IEC_8859-1#History>, ISO 8859-1 was > standardized in 1985. "Eight-bit-cleanness" became a thing in the early > 1990's. > > Where I was in late 1980's, the terminals were still 7-bit, and > instead of ASCII, national 7-bit character set variants were being used. > For example, you might see Pascal code like this: > > =C3=A4 return the net =C3=A5 > ret :=3D gross=C3=84unit=C3=85 * grossRate > > > > > Over the last several days from reading this thread (and variations > > thereof), l've seen several extended characters that I have no clue on > > how to reproduce on my keyboard. I haven't embraced extended character > > sets yet, which means I still think of ASCII characters as being 0 > > through 255 (8-bit). > > But Latin-1 is on your fingertips? =C2=A1Qu=C3=A9 bueno! Entonces sabes d= =C3=B3nde > est=C3=A1n las teclas espa=C3=B1olas, =C2=BFno? > > > Marko > > > > ---------- Forwarded message ---------- > From: "thomas povtal.org" > To: python-list > Cc: > Date: Wed, 25 May 2016 14:04:12 +0200 (CEST) > Subject: Re: Spurious issue in CPython 2.7.5 > Hi! > > Thanks. Replies in-line > > Den 24. maj 2016 klokken 19:12 skrev Steven D'Aprano < > steve@pearwood.info>: > > > > On Tue, 24 May 2016 08:22 pm, thomas povtal.org wrote: > > > > > Hi, > > > > > > Please excuse me if this is not the right place, but I have some issu= es > > > with CPython on a NUMA machine. > > > > Do you mean a Non-Uniform Memory Access machine? > > > > Can you be more specific about the actual machine and OS used? > > It's Ubuntu 12.04 LTS. It appears as a NUMA machine with two nodes. > However, I > later learned that it's (probably?) not a real NUMA but just Ubuntu's way > of > representing two socktets for CPUs. I'm not very skilled in such low-leve= l > matters, unfortunately. > > > 1: I get "RuntimeWarning: tp_compare didn't return -1 or -2 for > > > exception". It's a line like: > > > > > > "if Foo =3D False:" where Foo is a global variable (global Foo). > > > > What is the type and value of Foo? > > global Foo =3D False > > > Now, I've searched somewhat on google for indications on when this > > > warning can be seen. However, I haven't really been able to understan= d > > > why and even if it's significant or not. (At face value I'm nervous t= he > > > Python runtime environment is corrupted for that process). > > > > At face value, that RuntimeWarning seems to indicate a bug in the > > interpreter. > > Ok. I was fearing this. > > > 2: In my process later on I get: "OverflowError: long too big to > > > convert". > > > > Can you copy and paste the actual traceback rather than retyping it fro= m > > memory? I think you're missing something, namely what the long is being > > converted to. The rest of the traceback will help too. > > 2016-05-24_08:15:40.84187 File "checkrc.pxd", line 14, in > zmq.core.checkrc._check_rc (zmq/core/socket.c:5932) > 2016-05-24_08:15:40.84187 OverflowError: long too big to convert > > I agree it looks like cut off, but it isn't... > > > This happens in different places and seems to always relate to > > > obtaining a length of something (dict or list created by list > > > comprehension). Fx > > > > > > "for i in xrange(0, len_of_stuff, max_section_size):" > > > > > > en_of_stuff is always less than the max long (around 600). > > > > What do you mean, "the max long"? Longs do not have a max value. The on= ly > > limit is the amount of memory you have. > > > > What about max_section_size? How big is that? > > 30 > > > We're using gevent and I'm suspecting some "threading" could cause > > > this, as I'm able to replicate it locally with the same data. > > > > Typo: you said later that you are *not* able to replicate it. > > > > You're using a global variable with threaded code? You're a brave (or > > foolhardy) man... > > Yeah, I didn't write the code originally, but that's not an excuse. The > greenlets involved doesn't appear to be mulithreaded in this case, though= . > Even > if it was, could that miss with the interpreter to give these sporious > messages? > > -- > > Steven > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > ---------- Forwarded message ---------- > From: Tim Golden > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 13:13:49 +0100 > Subject: Re: Spurious issue in CPython 2.7.5 > On 25/05/2016 13:04, thomas povtal.org wrote: > > 2016-05-24_08:15:40.84187 File "checkrc.pxd", line 14, in > > zmq.core.checkrc._check_rc (zmq/core/socket.c:5932) > > 2016-05-24_08:15:40.84187 OverflowError: long too big to convert > > That exception is arising from ZeroMQ's own code, by the look of it. (Or > perhaps pyzmq). > > It's not impossible that it's arising ultimately from Python's > interpreter core, but you'd want to take that up with the ZeroMQ guys > first to see what checks they're doing which might raise that exception. > > https://github.com/zeromq > > TJG > > > > ---------- Forwarded message ---------- > From: Christopher Reimer > To: Marko Rauhamaa > Cc: python-list@python.org > Date: Wed, 25 May 2016 05:19:01 -0700 > Subject: Re: for / while else doesn't make sense > > On May 25, 2016, at 3:47 AM, Marko Rauhamaa wrote: > > > > Christopher Reimer : > > > >> Back in the early 1980's, I grew up on 8-bit processors and latin-1 wa= s > >> all we had for ASCII. > > > > You really were very advanced. According to > https://en.wikipedia.org/wiki/ISO/IEC_8859-1#History>, ISO 8859-1 was > > standardized in 1985. "Eight-bit-cleanness" became a thing in the early > > 1990's. > > Apparently, I wasn't. According to the Internet, which can't be wrong, > many of the 8-bit computers in the early 1980's were based on 1960's ASCI= I > with some non-standard characters tossed in. Latin-1 probably came during > my DOS days in the 1990's. > > As for ISO 8859-1, the standard was approved in 1985 but it was based on > the character set for the first ANSI standard terminal, DEC VT-2200, that > came out in 1983. Still early 1980's. ;) > > Thank you, > > Chris R. > > > ---------- Forwarded message ---------- > From: "thomas povtal.org" > To: Tim Golden , python-list > > Cc: > Date: Wed, 25 May 2016 14:26:33 +0200 (CEST) > Subject: Re: Spurious issue in CPython 2.7.5 > Hi! > > Thanks. It was an example... I get the very same exception text (the o= ne > that appears to be cut off) in this line in our own code: > > if Foo =3D=3D False: > > (where Foo is global Foo =3D False.) > > :) T > > Den 25. maj 2016 klokken 14:13 skrev Tim Golden >: > > On 25/05/2016 13:04, thomas povtal.org wrote: > > 2016-05-24_08:15:40.84187 File "checkrc.pxd", line 14, in > > zmq.core.checkrc._check_rc (zmq/core/socket.c:5932) > > 2016-05-24_08:15:40.84187 OverflowError: long too big to convert > > That exception is arising from ZeroMQ's own code, by the look of it. > (Or > perhaps pyzmq). > > It's not impossible that it's arising ultimately from Python's > interpreter core, but you'd want to take that up with the ZeroMQ guy= s > first to see what checks they're doing which might raise that > exception. > > https://github.com/zeromq > > TJG > -- > https://mail.python.org/mailman/listinfo/python-list > > > > ---------- Forwarded message ---------- > From: San > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 05:29:53 -0700 (PDT) > Subject: ValueError: I/O operation on closed file > Hi Gorup, > > why i am getting "ValueError: I/O operation on closed file" this error. > Pls let me know. > > Thanks in Advance. > san > > > > ---------- Forwarded message ---------- > From: Joel Goldstick > To: > Cc: "python-list@python.org" > Date: Wed, 25 May 2016 09:12:33 -0400 > Subject: Re: ValueError: I/O operation on closed file > On Wed, May 25, 2016 at 8:29 AM, San wrote: > > Hi Gorup, > > > > why i am getting "ValueError: I/O operation on closed file" this error. > > Pls let me know. > > Because your program is incorrect? > > Why not list your code, so that someone might be able to help you? > > > > > > Thanks in Advance. > > san > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > -- > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays > > > > ---------- Forwarded message ---------- > From: Daiyue Weng > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 14:32:34 +0100 > Subject: Find the max number of elements in lists as value in a dictionar= y > I want to find the maximal number of elements contained in a nested > dictionary, e.g. > > data =3D { > 'violations': > { > 'col1': {'err': [elem1, elem2, elem3]}, > 'col2': {'err': [elem1, elem2]} > } > } > > so to find the maximal number of elements in the lists for key 'err' in k= ey > 'col1' and 'col2'. Also key 'violations' may contain many keys (e.g. 'col= 1' > , 'col2', 'col3' etc), so what's the best way to do this (using a loop)? > > max =3D 0for col in data.violations: > if max < len(data.violations.col.err): > max =3D len(data.violations.col.err) > > > cheers > > > > ---------- Forwarded message ---------- > From: alister > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 14:03:17 GMT > Subject: Re: ValueError: I/O operation on closed file > On Wed, 25 May 2016 05:29:53 -0700, San wrote: > > > Hi Gorup, > > > > why i am getting "ValueError: I/O operation on closed file" this error. > > Pls let me know. > > > > Thanks in Advance. > > san > > because you are trying to do something with a file that has been closed > > the error message is quite explanatory > > > -- > One friend in a lifetime is much; two are many; three are hardly possible= . > Friendship needs a certain parallelism of life, a community of thought, > a rivalry of aim. > -- Henry Brook Adams > > > > ---------- Forwarded message ---------- > From: Daiyue Weng > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 15:19:13 +0100 > Subject: IndexError for using pandas dataframe values > Hi, I tried to use DataFrame.values to convert a list of columns in a > dataframe to a numpy ndarray/matrix, > > matrix =3D df.values[:, list_of_cols] > > but got an error, > > IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis > (None) and integer or boolean arrays are valid indices > > so what's the problem with the list of columns I passed in? > > many thanks > > > > ---------- Forwarded message ---------- > From: Jussi Piitulainen > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 17:24:10 +0300 > Subject: Re: Find the max number of elements in lists as value in a > dictionary > Daiyue Weng writes: > > > I want to find the maximal number of elements contained in a nested > > dictionary, e.g. > > > > data =3D { > > 'violations': > > { > > 'col1': {'err': [elem1, elem2, elem3]}, > > 'col2': {'err': [elem1, elem2]} > > } > > } > > > > so to find the maximal number of elements in the lists for key 'err' in > key > > 'col1' and 'col2'. Also key 'violations' may contain many keys (e.g. > 'col1' > > , 'col2', 'col3' etc), so what's the best way to do this (using a loop)= ? > > > > max =3D 0for col in data.violations: > > if max < len(data.violations.col.err): > > max =3D len(data.violations.col.err) > > Write a generator function that produces an object that generates the > lengths. The magic word is the "yield" which is used like "return" but > makes it so that the resulting objects yields each value on demand. For > greater magic, make it yield the path to each list together with the > length (length first, for easy max): > > def errcounts(data): > for top, sub in data.items(): > for mid, wev in sub.items(): > if 'err' in wev: > yield (len(wev['err']), top, mid) > > With that, Python's max does it all: > > max(errcounts(data)) =3D> (3, 'violations', 'col1') > > This anticipated a next question; tuple comparison is overly specific; > use a key function to max to not overspecify if you care; max needs a > default in case there is no data; this same thing can be done with a > single "generator expression" and that might be good, depending on the > actual details and taste. Many other caveats apply. > > > > ---------- Forwarded message ---------- > From: Jon Ribbens > To: python-list@python.org > Cc: > Date: Wed, 25 May 2016 14:28:42 -0000 (UTC) > Subject: Re: Find the max number of elements in lists as value in a > dictionary > On 2016-05-25, Daiyue Weng wrote: > > I want to find the maximal number of elements contained in a nested > > dictionary, e.g. > > > > data =3D { > > 'violations': > > { > > 'col1': {'err': [elem1, elem2, elem3]}, > > 'col2': {'err': [elem1, elem2]} > > } > > } > > > > so to find the maximal number of elements in the lists for key 'err' in > key > > 'col1' and 'col2'. Also key 'violations' may contain many keys (e.g. > 'col1' > > , 'col2', 'col3' etc), so what's the best way to do this (using a loop)= ? > > > > max =3D 0for col in data.violations: > > if max < len(data.violations.col.err): > > max =3D len(data.violations.col.err) > > In Python 3 you could do: > > max((len(col["err"]) for col in data["violations"].values()), default= =3D0) > > In Python 2 you can do the same but you can't specify "default=3D0" and > so it will throw an exception if there are no lists found, so you > could use something like: > > max_errs =3D 0 > if data["violations"]: > max_errs =3D max(len(col["err"]) for col in > data["violations"].values()) > > > > ---------- Forwarded message ---------- > From: justin walters > To: litssa2005@gmail.com > Cc: python-list@python.org > Date: Wed, 25 May 2016 08:06:27 -0700 > Subject: Re: html & python connection problem with hyperlinks > On Wed, May 25, 2016 at 3:24 AM, wrote: > > > Why not created the field title, that located on the template > > BusinessList.html as a link to go to Business_Detail.html..? please che= ck > > > > Code: > > > > models. py: > > > > from django.db import models > > > > > > REGIONS =3D ( > > ('=CE=98=CE=95=CE=A3', '=CE=98=CE=95=CE=A3=CE=A3=CE=91=CE=9B=CE=9F=CE= =9D=CE=99=CE=9A=CE=97'), > > ('=CE=A3=CE=95=CE=A1', '=CE=A3=CE=95=CE=A1=CE=A1=CE=95=CE=A3'), > > ( '=CE=91=CE=98=CE=97', '=CE=91=CE=98=CE=97=CE=9D=CE=91'), > > > > > > > > TYPEOFBUSINESS =3D ( > > ('=CE=95=CE=A3=CE=A4', '=CE=95=CE=A3=CE=A4=CE=99=CE=91=CE=A4=CE=9F=CE= =A1=CE=99=CE=91'), > > ('=CE=A6=CE=91=CE=A1', '=CE=A6=CE=91=CE=A1=CE=9C=CE=91=CE=9A=CE=95=CE= =99=CE=91'), > > ('=CE=92=CE=99=CE=92', '=CE=92=CE=99=CE=92=CE=9B=CE=99=CE=9F=CE=A0=CE= =A9=CE=9B=CE=95=CE=99=CE=91'), > > ( '=CE=9A=CE=9F=CE=9C', '=CE=9A=CE=9F=CE=9C=CE=9C=CE=A9=CE=A4=CE=97=CE= =A1=CE=99=CE=91'), > > ('=CE=A3=CE=99=CE=9D', '=CE=A3=CE=99=CE=9D=CE=95=CE=9C=CE=91') > > > > ) > > > > class Business(models.Model): > > created_Date =3D models.DateTimeField(auto_now_add=3DTrue) > > owner =3D models.ForeignKey('auth.User', related_name=3D'snippets', > null=3DTrue) > > title =3D models.CharField(max_length=3D100, blank=3DTrue, default=3D''= ) > > Type_of_Business =3D models.CharField(max_length=3D3, choices=3DTYPEOFB= USINESS) > > region =3D models.CharField(max_length=3D3, choices=3DREGIONS) > > address =3D models.CharField(max_length=3D100, blank=3DTrue, default=3D= '') > > phone =3D models.CharField(max_length=3D15, blank=3DTrue, default=3D'') > > image =3D models.ImageField(null=3DTrue) > > > > > > def __str__(self): > > return str(self.title) > > > > views.py > > > > from django.contrib.auth.models import User > > from django.http import HttpResponse > > from django.shortcuts import render, get_object_or_404 > > from rest_framework import filters > > from rest_framework import generics > > from rest_framework import permissions > > from snippets.permissions import IsOwnerOrReadOnly > > from snippets.serializers import SnippetSerializer > > from snippets.serializers import UserSerializer > > from .models import Business > > > > > > > > class UserList(generics.ListAPIView): > > queryset =3D User.objects.all() > > serializer_class =3D UserSerializer > > > > > > class UserDetail(generics.RetrieveAPIView): > > queryset =3D User.objects.all() > > serializer_class =3D UserSerializer > > > > class BusinessList(generics.ListCreateAPIView): > > > > permission_classes =3D (permissions.IsAuthenticatedOrReadOnly,) > > queryset =3D Business.objects.all() > > serializer_class =3D SnippetSerializer > > filter_backends =3D (filters.DjangoFilterBackend,filters.SearchFilter, > > filters.OrderingFilter,) > > filter_fields =3D ('Type_of_Business', 'region') > > search_fields =3D ('Type_of_Business', 'region') > > ordering_fields =3D ('Type_of_Business','title', 'region') > > > > > > def BusinessList(request): > > business =3D Business.objects.all(); > > return render(request, 'snippets/BusinessList.html' > {'business':business}) > > > > def perform_create(self, serializer): > > serializer.save(owner=3Dself.request.user) > > > > > > > > class Business_Detail(generics.RetrieveUpdateDestroyAPIView): > > permission_classes =3D (permissions.IsAuthenticatedOrReadOnly, > > IsOwnerOrReadOnly,) > > queryset =3D Business.objects.all() > > serializer_class =3D SnippetSerializer > > > > > > def Business_Detail(request, pk): > > business =3D get_object_or_404(Business, pk=3Dpk) > > return render(request, 'snippets/Business_Detail.html', {'business': > > business}) > > > > serializers.py > > > > from rest_framework import serializers > > from snippets.models import Business > > from django.contrib.auth.models import User > > > > > > class SnippetSerializer(serializers.HyperlinkedModelSerializer): > > owner =3D serializers.ReadOnlyField(source=3D'owner.username') > > > > class Meta: > > model =3D Business > > fields =3D ('created_Date', 'owner', 'title','Type_of_Business', 'regio= n', > > 'address', 'phone', 'image') > > > > > > class UserSerializer(serializers.ModelSerializer): > > snippets =3D serializers.PrimaryKeyRelatedField(many=3DTrue, > > queryset=3DBusiness.objects.all()) > > > > class Meta: > > model =3D User > > fields =3D ('id', 'username', 'snippets') > > > > BusinessList.html > > > > {% extends 'snippets/base.html' %} > > > > {% block content %} > > {% for business in business%} > >
> >
> > {{ business.created_Date }} #=CF=84=CF=85=CF=80=CF=89=CF=83=CE=B5 =CE= =B7=CE=BC=CE=B5=CF=81.=CE=B4=CE=B7=CE=BC=CE=B9=CE=BF=CF=85=CF=81=CE=B3=CE= =B9=CE=B1=CF=82 =CF=84=CE=BF=CF=85 Business > >
> >

{{ > > business.title }}

> >

{{business.Type_of_Business }}

> >

{{ business.region }}

> >

{{ business.address }}

> >

{{ business.phone }}

> > {% if business.image %} > > > > {% endif %} > >
> > {% endfor %} > > {% endblock %} > > > > Business_Detail.html > > > > {% extends 'snippets/base.html' %}' %} > > > > {% block content %} > >
> > {% if business.created_Date %} # =CE=B1=CE=BD =CF=85=CF=80=CE=B1=CF=81= =CF=87=CE=B5=CE=B9 =CE=B7=CE=BC=CE=B5=CF=81=CE=BF=CE=BC=CE=B7=CE=BD=CE=B9= =CE=B1 =CE=B4=CE=B7=CE=BC=CE=B9=CE=BF=CF=85=CF=81=CE=B3=CE=AF=CE=B1=CF=82 > >
> > {{ business.created_Date }} > >
> > {% endif %} > >

{{ business.title }}

> >

{{ business.region }}

> >

{{ business.Type_of_Business}}

> >

{{ business.phone }}

> >

> > {% if business.image %} # =CE=B1=CE=BD =CF=85=CF=80=CE=B1=CF=81=CF=87= =CE=B5=CE=B9 =CE=B5=CE=B9=CE=BA=CE=BF=CE=BD=CE=B1 > > # =CF=80=CE=B1=CF=81=CE=B5 =CE= =B5=CE=B9=CE=BA=CE=BF=CE=BD=CE=B1 =CE=B1=CF=80=CE=BF =CF=84=CE=BF =CE=B1=CE= =BD=CF=84=CE=B9=CF=83=CF=84=CE=BF=CE=B9=CF=87=CE=BF url > > {% endif %} > >

> >
> > {% endblock %} > > > > tutorial/snippets/urls.py > > > > from django.conf.urls import url, include > > from django.contrib import admin > > from rest_framework.urlpatterns import format_suffix_patterns > > from django.contrib.staticfiles.urls import staticfiles_urlpatterns > > from django.conf.urls import include > > > > from . import views > > > > urlpatterns =3D [ > > url(r'^admin/', include(admin.site.urls)), > > url(r'^$', views.BusinessList.as_view()), > > url(r'^business/(?P[0-9]+)/$', views.Business_Detail.as_view()), > > url(r'^users/$', views.UserList.as_view()), > > url(r'^users/(?P[0-9]+)/$', views.UserDetail.as_view()), > > url(r'^api-auth/', include('rest_framework.urls', > > namespace=3D'rest_framework')), > > > > ] > > > > urlpatterns =3D format_suffix_patterns(urlpatterns) > > urlpatterns +=3D staticfiles_urlpatterns() > > > > tutorial/urls.py > > > > from django.conf.urls import include, url > > from django.contrib import admin > > from django.conf import settings > > from django.contrib.staticfiles.urls import staticfiles_urlpatterns > > from django.conf.urls.static import static > > > > > > > > urlpatterns =3D [ > > url(r'^admin/', include(admin.site.urls)), > > url(r'', include('snippets.urls')), > > > > ] > > > > urlpatterns +=3D staticfiles_urlpatterns() > > urlpatterns +=3D static(settings.PHOTO_URL, > > document_root=3Dsettings.PHOTO_ROOT) > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > > > There are two problems here. You need to define a namespace for > snippets.urls in tutorials/urls.py: > > url(r'', include('snippets.urls', namespace=3D'snippets')) > > You also need to give a name to your detail view in snippets/urls.py. Als= o, > you do not need to call 'as_view() on function based views like business > detail: > > url(r'^business/(?P[0-9]+)/$, views.business_detail, > name=3D'business_detail') > > Then, in your list template you can do the following: > >

%}">{{business.title}}

> > This will create a linked h1 tag that links to the business detail page. > > Hope this helps. > > > -- > https://mail.python.org/mailman/listinfo/python-list >