Code Monkey home page Code Monkey logo

python-is-cool's Issues

List indexing

Hi! Super useful compilation - some of these took me years to discover. I'll certainly be directing people here, so thanks for taking the time.

I believe there may be a small issue with the text in section 2.2, this bit:

The syntax [x:y:z] means "take every zth element of a list from index x to index y", with 0 being the default value of x and -1 being the default value of y. When z is negative, it means going backwards. So if we want to take every 2th element of a list, we use [::2], which is the same as [0:-1:2].

My understanding is that -1 isn't the default value of y, and [::2] is different to [0:-1:2]. Specifically, [x:y] means 'start at index x, stop before index y'. The default value of y is kind-of -0 (although that would be bad syntax), and using [:-1] will drop the last element.

Concretely (I tried it with python 3.6):

k = [0, 1, 2, 3, 4, 5, 6, 7, 8] # odd number of elements
a = k[::2]    # a <- [0, 2, 4, 6, 8]
b = k[0:-1:2] # b <- [0, 2, 4, 6]

In the second case the indexing starts at 0, ends before 8, and strides by 2.

Hope this is a useful contribution!

forced named arguements

Will it be cool to add forced-named arguments to this list?

def foo(pos, *, forcenamed):
     print(pos, forcenamed)
>>> foo(pos=10, forcenamed=20)
10 20
>>> foo(10, forcenamed=20)
10 20

Minor Typo

Thank you for this guide.

In section 5 I think:

If we intend that only Endoer, Decoder, and Loss are ever to be imported and used in another module, we should specify that in parts.py using the all keyword.

was intended to be:

If we intend that only Encoder, Decoder, and Loss are ever to be imported and used in another module, we should specify that in parts.py using the all keyword.

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.