Code Monkey home page Code Monkey logo

practices-of-the-python-pro's Introduction

Dane Hillard

GitHub follow Twitter follow Mastodon follow

I'm a software engineer and web developer interested in education, biotechnology, and open source.

Publishing Python Packages: Test, share, and automate your projects

The life of a maintainer can be hard. Beyond writing working code, you have to triage issues, review pull requests, and create releases regularly. Don't let the logistics of package management get in your way. Publishing Python Packages: Test, share, and automate your projects is a book about creating and streamlining a repeatable process for authoring and maintaining Python packages. Whether you're looking to create your first published Python package or trying to reduce the maintenance burden of the packages you already work on, Publishing Python Packages: Test, share, and automate your projects has something for you. Check out daneah/publishing-python-packages for the accompanying code samples.

Publishing Python Packages, a Manning book by Dane Hillard

Practices of the Python Pro

If you're new to the software development industry, consider checking out my book, Practices of the Python Pro. It provides broad introductory coverage of software design, maintenance, and testing. You might also want to check out daneah/practices-of-the-python-pro for the accompanying code samples.

Practices of the Python Pro, a Manning book by Dane Hillard

Exploring Software Extensibility

With two chapters from Practices of the Python Pro and one chapter each from Object Design Style Guide and The Design of Web APIs, Exploring Software Extensibility is a great entrypoint into the ideas that make software live a long life. Software is rarely complete, so building it to last by being open to future requirements and change is a must.

Exploring Software Extensibility, a Manning resource with chapter selections by Dane Hillard

practices-of-the-python-pro's People

Contributors

daneah 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

practices-of-the-python-pro's Issues

Inheritance V Composition in chapter 8.2.2

Thanks for this great work.

In chapter 8.2.2 (Substitutability), you gave the following example,

class Slug:
def __init__(self, name):
self.name = name
def crawl(self):
print('slime trail!')
class Snail(Slug): # <1>
def __init__(self, name, shell_size): # <2>
super().__init__(name)
self.name = name
self.shell_size = shell_size
def race(gastropod_one, gastropod_two):
gastropod_one.crawl()
gastropod_two.crawl()
race(Slug('Geoffrey'), Slug('Ramona')) # <3>
race(Snail('Geoffrey'), Snail('Ramona')) # <4>

and further noted the following words:

You could pull more tricks out of your sleeve to make this work,
but consider that this might be a better case for composition.
A snail *has-a* shell, after all. 

Is this code below along the lines of what you were thinking?
Instead of making Snail inherit from Slug, the shell
behavior should be composed into the snail class, and there
shouldn't be any need for inheritance.

class Shell:
    size = None

class Snail:
    def __init__(self, name, shell):
        self.name = name
        self.shell_size = shell.size

Snail("Hafsoh", Shell())

Issue in Ch06, database.py

In method select the query never gets a closing ;
The query works but you should always add the semicolon.
To fix it, add this right before the return statement:
query += ';'

Bug in Ch2, rock_paper_scissors.py function

The function print_options() should start the enumeration with 1 to match the choices (fixed code shown below), otherwise it's a bug.

def print_options():
    print('\n'.join(f'({i}) {option.title()}' for i, option in enumerate(OPTIONS, 1)))

Issue in Ch04, timing.py

The timing module by default executes the statement for 1 million times (link): timeit.timeit(stmt='pass', setup='pass', timer=<default timer>, number=1000000)

So the output of this line in the timing.py module should be in us not ms:

result = timeit(setup=setup, stmt=statement)
print(f'Took an average of {result}ms')

Issue in Ch03 greeter.py

Why is the Greeter class including an init with name? The specification of the Greeter class in the text above does not say to include Hi, my name is <name>... but it says Hi, welcome to <store>...

Ch8 question: LSP for `AddBookmarkCommand.execute`

In chapter 8 we introduce the Command abstract base class and add data=None args to some of the execute methods (e.g. CreateBookmarksTableCommand.execute) to satisfy LSP.

However, AddBookmarkCommand.execute still has an additional timestamp arg.

class AddBookmarkCommand(Command): # <6>
def execute(self, data, timestamp=None):
data['date_added'] = timestamp or datetime.utcnow().isoformat()
db.add('bookmarks', data)
return 'Bookmark added!'

Should timestamp also be passed in as part of the data dict to keep the method signature consistent with the base?

class AddBookmarkCommand(Command):
    def execute(self, data):
        data["date_added"] = data.get("date_added") or datetime.utcnow().isoformat()
        db.add("bookmarks", data)
        return "Bookmark added!"

Thanks!

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.