Giter VIP home page Giter VIP logo

pcc_2e's Introduction

pcc_2e's People

Contributors

ericwlange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcc_2e's Issues

ValueError, need assistance

I am receiving a ValueError when I click the "Add Entry" button after adding an entry to a topic. Below is the information that is coming back regarding the error.

I am a beginner but I believe that this has something to do with line 53 in views.py which reads:

return redirect(request, 'learning_logs:topic', topic_id='topic_id')

For some reason I don't think it likes the "topic_id=topic_id" portion of the arguments.

I have retyped everything and copied code from the repositories to ensure that I have entered everything correctly.

Any help would be appreciated.

-Ben

Request Method: POST
http://127.0.0.1:8000/new_entry/1/
3.0.4
ValueError
Don't mix *args and **kwargs in call to reverse()!
/Users/Ben/Desktop/learning_log/ll_env/lib/python3.8/site-packages/django/urls/resolvers.py in _reverse_with_prefix, line 614
/Users/Ben/Desktop/learning_log/ll_env/bin/python
3.8.2
['/Users/Ben/Desktop/learning_log', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8', '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload', '/Users/Ben/Desktop/learning_log/ll_env/lib/python3.8/site-packages']
Mon, 30 Mar 2020 17:27:23 +0000

Typo infinite skills

In the LeanPub version of the Python Cheat sheet (all) the infinite skills sidebar has an extra 4th sentence which contains the text "mall sprograms".

IMG_20211110_092017

User login does not show username password boxes to enter in credentials

I'm not sure what I may be missing, I'm on page 424 on second edition and have my urls.py (both root and users), login.html, and base.html files all modified/created as in the book and this repo, but when I refresh the web page and click on the login link, I see the login button only, with no text boxes for username or password, so you cannot enter in credentials. Am I missing something here?

Python version 3.8.6
Django version 3.1.2

AttributeError: 'pygame.Surface' object has no attribute 'centerx'

I am facing this issue in the Alien Invasion project. It is the ship.py project.

import pygame

class Ship:
    def __init__(self, screen):
        self.screen = screen

        # load ship and get its rect
        self.image = pygame.image.load('images/ship.bmp')
        self.rect = self.image.get_rect()
        self.screen_rect = screen.get_rect()

        # start each new ship at the bottom center of the screen
        self.rect.centerx = self.screen.centerx
        self.rect.bottom = self.screen.bottom

    def blitme(self):
        # draw the ship at its current location
        self.screen.blit(self.image, self.rect)

But it shows this error

AttributeError: 'pygame.Surface' object has no attribute 'centerx'

Usages of self.rect.x in chapter 12

Hi Eric,

I'm building the game with MacOS.

In ship.py, page 242, chapter 12 is stated to:

# Update rect object from self.x. self.rect.x = self.x
self.rect.x = self.x

Although if I do write this in my codebase, I'm not able to move the ship.
I've already checked for relevant updates but the issue is not solved by using the summoned pygame version.

Thanks!

How do I stop the ship from moving off the bottom of the screen?

import pygame

class Shiptot:
"""A class for the testing_my_skills game program."""

def __init__(self, ai_game):
	"""Initalize the settings for the player controled ship."""
	self.screen = ai_game.screen
	self.settings = ai_game.settings
	self.screen_rect = ai_game.screen.get_rect()

	# Load ShipTwo image and get its rect.
	self.image = pygame.image.load('images/ship_two.bmp')
	self.rect = self.image.get_rect()
	


	# Start in the midddle of the screen.
	self.rect.center = self.screen_rect.center

	# store the ships position.
	self.x = float(self.rect.x)
	self.y = float(self.rect.y)


	# Movement flag
	self.moving_right = False
	self.moving_left = False
	self.moving_up = False
	self.moving_down = False


def update(self):
	"""Update the ships position based on the movement of the flag."""
	# Update ships x value not it rect value.
	if self.moving_right and self.rect.right < self.screen_rect.right:
		self.x += self.settings.shiptot_speed
	if self.moving_left and self.rect.left > 0:
		self.x -= self.settings.shiptot_speed

	# Update ships y value not its rect value.
	if self.moving_up and self.rect.top > self.screen_rect.top:
		self.y -= self.settings.shiptot_speed
	if self.moving_down and self.rect.bottom > 0:
		self.y += self.settings.shiptot_speed

	

	# Update rect objects x and y value
	self.rect.x = self.x
	self.rect.y = self.y
	

def blitme(self):
	"""draw the ship in the current locations."""
	self.screen.blit(self.image, self.rect)

Regarding Documentation

Hey Eric, Thanks for such an awesome and worthwhile resource. I was hoping if you could add information that the image size (in pixels) of the alien ship should be taken care of beforehand. Could be confusing for many beginners like me. Thanks again and best wishes!

Project 3, Ch 19 Allowing users to enter data; AttributeError at /new_topic/

After completing the section 'Allowing Users to Enter Data (p410-414)', when I attempt to add a new topic using the field, I get an attribute error from the new_topic page.

'TopicForm' object has no attribute 'is_vaild'

I restarted the server but same issue. I've reviewed my code but can't find the bug. I did some research on the Django is_valid() attribute for ModelForm, but didn't see anything that would cause this issue. I'm running macOS Big Sur, terminal with bash, python v 3.7 and Django v 2.2. I'm not sure exactly which files to look at at this point, but here are the ones I'm guessing you want to look at.

I ran through all my code and couldn't find the problem. I actually started over from the beginning, when I got to this point, I had the same issue.

forms.py

from django import forms

from .models import Topic

class TopicForm(forms.ModelForm):
    class Meta:
        model = Topic
        fields = ['text']
        labels = {'text': ''}

urls.py

from django.urls import path

from . import views

app_name = 'learning_logs'
urlpatterns = [
    # Home page.
    path('', views.index, name='index'),
    # Page that shoes all topics.
    path('topics/', views.topics, name='topics'),
    # Detail page for a single topic.
    path('topics/<int:topic_id>/', views.topic, name='topic'),
    # Page for adding a new topic
    path('new_topic/', views.new_topic, name='new_topic'),
]

views.py

from django.shortcuts import render, redirect

from .models import Topic
from .forms import TopicForm

def index(request):
    """The home page for Learning Log."""
    return render(request, 'learning_logs/index.html')

def topics(request):
    """Show all topics."""
    topics = Topic.objects.order_by('date_added')
    context = {'topics': topics}
    return render(request, 'learning_logs/topics.html', context)

def topic(request, topic_id):
    """Show a single topic and all its entries."""
    topic = Topic.objects.get(id=topic_id)
    entries = topic.entry_set.order_by('-date_added')
    context = {'topic' : topic, 'entries': entries}
    return render(request, 'learning_logs/topic.html', context)

def new_topic(request):
    """Add a new topic."""
    if request.method != 'POST':
        # No data submitted; create a blank form
        form = TopicForm()
    else:
        # POST data submitted; process data.
        form = TopicForm(data=request.POST)
        if form.is_vaild():
            form.save()
            return redirect('learning_logs:topics')

    # Display a blank or invalid form.
    context = {'form': form}
    return render(request, 'learning_logs/new_topic.html', context)

new_topic.html

{% extends "learning_logs/base.html" %}

{% block content %}
  <p>Add a new topic</p>

  <form action="{% url 'learning_logs:new_topic' %}" method='post'>
    {% csrf_token %}
    {{ form.as_p }}
    <button name="submit">Add topic</button>
  </form>

{% endblock content %}

topics.html

{% extends 'learning_logs/base.html' %}

{% block content %}

<p>Topic: {{ topic }}</p>

<p>Entries</p>
<ul>
{% for entry in entries %}
  <li>
    <p>{{ entry.date_added|date:'M d, Y H:i' }}</p>
    <p>{{ entry.text|linebreaks }}</p>
  </li>
{% empty %}
  <li>There are no entries for this topic yet.</li>
{% endfor %}
</ul>

{% endblock content %}

Alien Invasion game - _create_alien() method simplification

Hi ๐Ÿ‘‹

Chapter 13 "Aliens", "Building the Alien Fleet" section and the following sections

def _create_alien(self, alien_number, row_number):
"""Create an alien and place it in the row."""
alien = Alien(self)
alien_width, alien_height = alien.rect.size
alien.x = alien_width + 2 * alien_width * alien_number
alien.rect.x = alien.x
alien.rect.y = alien.rect.height + 2 * alien.rect.height * row_number
self.aliens.add(alien)

I think the following line:
alien.rect.y = alien.rect.height + 2 * alien.rect.height * row_number
could be simplified into:
alien.rect.y = alien_height + 2 * alien_height * row_number
because we already have declared alien_height variable a few lines earlier (and it's not used):
alien_width, alien_height = alien.rect.size

Status code: 422 when making GitHub API call in Ch. 17.

Code from python_repos.py:

import requests

# Make an API call and store the response.
url = 'https://api.github.com/search/repositories?=language:python&sort=stars'

# headers = {'Accept': 'application/vnd.github.v3+json'}
r = requests.get(url)
print(f"Status code: {r.status_code}")

# Store API response as a variable.
response_dict = r.json()

# Process results.
print(response_dict.keys())

Response when making the call:
Status code: 422
dict_keys(['message', 'errors', 'documentation_url'])

Any thoughts about potential fixes on this?

self.text is unscriptable

from django.db import models

Create your models here.

class Topic(models.Model):
"""A topic the user is learning about"""
texts = models.CharField(max_length=200)
date_added = models.DateTimeField(auto_now_add=True)

def __str__(self):
    """Return a string representation of the model"""
    return self.texts

class Entry(models.Model):
"""Something specific learned about a topic"""
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
text = models.TextField
date_added =models.DateTimeField(auto_now_add=True)

class Meta:
    verbose_name_plural = 'entries'

def __str__(self):
    """Return a string representation of the model"""
    return f"{self.text[:50]}..."

Problem installing pygame on Mac OSX Mojave

Hi

I am tracking chapter 12 of Python Crash Course Ed 2 and hit an issue trying to install pygame under Python3.

Appreciate any insight into how i can get past this so I can continue with Project 1.

Here is the log:

Anthonys-MBP:~ anthonyohara$ python3 -m pip install --user pygame
Collecting pygame
Using cached https://files.pythonhosted.org/packages/0f/9c/78626be04e193c0624842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz
Installing collected packages: pygame
Running setup.py install for pygame ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-install-_4hdahx3/pygame/setup.py'"'"'; file='"'"'/private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-install-_4hdahx3/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-record-3xmsyh79/install-record.txt --single-version-externally-managed --compile --user --prefix=
cwd: /private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-install-_4hdahx3/pygame/
Complete output (218 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/surfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/sysfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_camera_vidcapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/sndarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/version.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/compat.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/draw_py.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/colordict.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/ftfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/midi.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_numpysndarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/sprite.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/macosx.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_numpysurfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/camera.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/freetype.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_camera_opencv_highgui.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/pkgdata.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/locals.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/dummybackend.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
creating build/lib.macosx-10.9-x86_64-3.8/pygame/threads
copying src_py/threads/Py25Queue.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/threads
copying src_py/threads/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/threads
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/base_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/font_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mixer_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/rwobject_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/pixelcopy_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/overlay_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/scrap_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/touch_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/imageext_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/pixelarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/draw_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/transform_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/blit_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/bufferproxy_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/surfarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mouse_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/surfarray_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/event_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/imageext_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/sprite_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/touch_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/gfxdraw_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/rect_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/scrap_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/overlay_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/color_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/camera_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/surflock_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/key_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/sysfont_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/font_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mixer_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/constants_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mixer_music_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/sndarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/image_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/version_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/freetype_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/joystick_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/midi_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/ftfont_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/image__save_gl_surface_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/cdrom_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/cursors_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/fastevent_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/display_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/fastevent_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/compat_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/ftfont_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/cdrom_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mask_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/midi_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/freetype_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/math_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/time_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/image_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/threads_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/main.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/mixer_music_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/sndarray_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/test_test
.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
copying test/surface_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/run_tests.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/endian.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/test_machinery.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/png.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/test_runner.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/arrinter.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/buftools.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
copying test/test_utils/async_sub.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
copying test/run_tests__tests/run_tests__test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
copying test/run_tests__tests/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_5_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/no_assertions__ret_code_of_1__test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/zero_tests_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
copying test/run_tests__tests/all_ok/fake_6_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
copying test/run_tests__tests/failures1/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
copying test/run_tests__tests/incomplete/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/fake_1_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
copying test/run_tests__tests/infinite_loop/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
copying test/run_tests__tests/print_stderr/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
copying test/run_tests__tests/print_stdout/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
copying test/run_tests__tests/incomplete_todo/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/magic_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
copying test/run_tests__tests/exclude/invisible_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/sleep_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
copying test/run_tests__tests/timeout/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/sleep_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/magic_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/incomplete_todo_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
copying test/run_tests__tests/everything/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
creating build/lib.macosx-10.9-x86_64-3.8/pygame/docs
copying docs/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/docs
copying docs/main.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/docs
creating build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/playmus.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/mask.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/sound.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/overlay.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/aacircle.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/chimp.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/liquid.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/audiocapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/sound_array_demos.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/midi.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/scroll.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/moveit.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/init.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/blit_blends.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/testsprite.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/textinput.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/vgrade.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/arraydemo.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/stars.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/camera.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/blend_fill.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/fonty.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/headless_no_windows_needed.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/fastevents.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/prevent_display_stretching.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/glcube.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/aliens.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/freetype_misc.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/scaletest.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/video.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/eventlist.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/scrap_clipboard.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/oldalien.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/pixelarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/dropevent.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
running build_ext
building 'pygame.gfxdraw' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/src_c
creating build/temp.macosx-10.9-x86_64-3.8/src_c/SDL_gfx
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src_c/gfxdraw.c -o build/temp.macosx-10.9-x86_64-3.8/src_c/gfxdraw.o
In file included from src_c/gfxdraw.c:33:
In file included from src_c/pygame.h:32:
src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^~~~~~~
1 error generated.
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-install-_4hdahx3/pygame/setup.py'"'"'; file='"'"'/private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-install-_4hdahx3/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/py/g052chcn2nl2ny_rgsbhds2c0000gn/T/pip-record-3xmsyh79/install-record.txt --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Anthonys-MBP:~ anthonyohara$

Regards

Defining Entry Model Error

Hi Eric!
I hope you and your family are well!

I tried to execute makemigrations for Entry model described on page 518 (Second Edition) and Django return an error:

TypeError: init() missing 1 required positional argument: 'on_delete'

I discoverd on Stackoverflow that since Django 2.0 the ForeignKey field requires two positional arguments and I made the modification below, after this makemigrations works fine!

topic = models.ForeignKey(Topic, on_delete=models.CASCADE)

Best Regards!
Nei Freitas

Issues while working with Hackernews API

Hi,

First of all I love this book, this is my first time learning to program in any language and I'm having so much fun.

I am currently working on API's and got to the final assignment, while working on the hackernews API I ran into two issues.

The first had a pretty clear cause; while calling for the topstories and listing them I got a KeyError for 'descendants'-key. This was caused by items of the type 'job' (example), which doesn't have that key. I was able to overcome this issue by putting in a try-except statement.

For the second issue I got I was not able to find an answer so far; when the items are printed my titles are returned as tuples. The raw data doesn't have any brackets nor did I add them anywhere.

final code:

from operator import itemgetter

import requests

# Make an API call and store the response.
url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url)
print(f"Status Code: {r.status_code}")

# Process information about each submission.
submission_ids = r.json()
submission_dicts = []
for submission_id in submission_ids[:10]:
    # Make a separate API call for each submission.
    url = f'https://hacker-news.firebaseio.com/v0/item/{submission_id}.json'
    r = requests.get(url)
    print(f"id: {submission_id}\tStatus Code: {r.status_code}")
    response_dict = r.json()

    # Build a dictionary for each article.
    submission_dict = {}
    submission_dict['title'] = response_dict['title'],
    submission_dict['hn_link'] = f"http://news.ycombinator.com/item?id={submission_id}"
    try:
        submission_dict['comments'] = response_dict['descendants']
    except KeyError:
        submission_dict['comments'] = 0

    submission_dicts.append(submission_dict)

submission_dicts = sorted(submission_dicts, key=itemgetter('comments'),
                            reverse=True)

for submission_dict in submission_dicts:
    print(f"\nTitle: {submission_dict['title']}")
    print(f"Discussion link: {submission_dict['hn_link']}")
    print(f"Comments: {submission_dict['comments']}")

example output:

Title: ('How to Think for Yourself',)
Discussion link: http://news.ycombinator.com/item?id=25227651
Comments: 612

The only thing I've changed compared to the code in the book is the way the submission_dict is constructed. This was to make it more readable with the try-except statement.

Hope someone can help me clarify the cause of this issue, thanks in advance!

Chapter 11 Testing a function

Hi Eric,

I came across an error when running the test_name_function.py. While I've figured it out, I feel it would be good to tell you this in case for the updating of the book. Btw, I'm a fresh learner on Python and I really like your book!

Here is the case:

import unittest
from name_function import get_formatted_name

class NameTestCase(unittest.TestCase):
    """Tests for 'name_function.py'."""

    def test_first_last_name(self):
        """Do names like 'Janis Joplin' work?"""
        formatted_name = get_formatted_name('janis', 'joplin')
        self.assertEqual(formatted_name, 'Janis Joplin')

if __name__ == '__main__':
    unittest.main()

The traceback shows that there is an error like this:

AttributeError: module 'main' has no attribute

So I googled it and I got the solution from the Medium and the StackOverflow

import unittest
from name_function import get_formatted_name

class NameTestCase(unittest.TestCase):
    """Tests for 'name_function.py'."""

    def test_first_last_name(self):
        """Do names like 'Janis Joplin' work?"""
        formatted_name = get_formatted_name('janis', 'joplin')
        self.assertEqual(formatted_name, 'Janis Joplin')

if __name__ == '__main__':
    unittest.main(argv=['first-arg-is-ignored'], exit=False)

Thank you!

help wanted

Screenshot at 2020-06-30 01-24-07
Screenshot at 2020-06-30 01-24-54
#13 whenever i register a user it ain't taking me back to the login page

Chapter 15: die.visual.py Issue with Plotly Version

Hello all,

There's an issue with the written code that causes it to not work with the newest plotly version. It took me a couple hours to find an explanation, but it seems like the best thing is to just downgrade plotly. Here's a link to a page with a more thorough description.

https://www.reddit.com/r/learnpython/comments/10cnbrd/pcc_2nd_edition_plotly_unicodeencodeerror/

If you're using windows and the command prompt terminal, the code to downgrade plotly to the cited version is:

python -m pip install --user plotly==5.1.0

Best to you all,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.