DjangoCon 2015

Lightning Talks (Segunda parte)

Varios autores  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

I'm so excited to be here today and opening this lighting talk session I bellucci filippov by Sean product manager and in this talk I'm going to show you some of the essential Python features that make many jungle developers more productive so here

i have a very simple django poles project opened in PyCharm and very first feature i wanted to show you is Django managed by console you can get it by eating control out there here's it you can just start typing the task name it autocompletes everything

it also provides you the options you have for this task here is it an app name so our application oh it also supports the fazi search in completion so you can just type their middle part of the task name and it will also be completed you can also get control

Q and it will give you a quick documentation for that task so here we have Django okay one two three one two three and hear how it works another cool thing about PyCharm is that it has really reached navigational capabilities so you can go to everywhere go

to in search for any file or model or method just by clicking double shift for example let's go to the detail view we can also go to the team played by just clicking this small icon here we can go back by clicking this one searching yep choosing the right

one we can go to the URLs by clicking ctrl be going back and this is really useful to go around your code another great thing and a great feature in pycharm that many Jago developers like the most from the feedback that I've got is a Python debugger it

can be used to debug the Python code without node up but it also can be used to debug Django team plays so just let's go to the team played put some break points right inside the editor here here and here and run the Django server in the debug mode pycharm

automatically opens the browser so we go here and this is the point when PyCharm debugger stop the execution and we have everything here you can inspect your variables you can move them to watches you can even set values for them like well here too k and do

other ordinary things like stepping through your cold navigating to the next breakpoint all the usual stuff so here how it works and the last but not the least thing I wanted to show you is how I run my tests so I'm navigating with search everywhere to

my test file you can see the bunch of tests here I'm just creating new run configuration it would be Django test configuration give it a name test by Chum recognizes all the tests in your file and in your project actually you can run it and you can see

that all tests are pests you can see the problems here the test results here you can navigate to any test right from here break it run it results pot failed fix it buy it again and now we are all set so this was just a quick demo of Python capabilities please

feel free to I know widen doesn't work okay please feel free to visit our website to learn more follow us on twitter if you have any questions I will be around and please feel free to request any features you might have in mind they are very welcome so

thank you very much ok my name is paul bailey and i'm going to talk about ending the holy wars of formatting so i know this was mentioned at least in one other talk and we had two talks about style but if you never seen the beyond pepe video from PI con

2008 it's great by raymond heading juror he talks about you know going beyond just format spacing and going into better architecture decisions and things that you should do to make your code better and one of the great quotes from the talk is Pepe unto

thyself and not unto others so use it as a tool to make your code better but not necessarily the beat other people down but there's a problem with this we're Python the ESA's I mean one of the big reasons we get in the Python is because we love

elegant code some of us are probably OCD and like to like have everything lined up exactly we get kind of mad when things go over 80 characters and so we are wasting mental energy and as developers a lot of times we're fighting styles in code reviews maybe

we're spending too much energy on spacing and things that don't mean as much you know like the naming talk was great today that's definitely something you want to focus more energy on then some of your just trivial formatting things and then also

we have developers that are maybe doing python that are coming from another background they have different sense of style you know older newer developers different languages and styles change over time also I kinda have to use this to basically say like I

have a secret confession i like to space indentations of the four yes but exactly Wow at least it's not three space invitation I think that's like the worst yes I know it's it's awful but there is a solution we don't have to waste our time

and our mental energy on just trivial formatting issues we can autoformat our code and have a consistent style throughout our whole code base with not much work so this was actually popularized by the go format tool written for go and there's actually

tool for python that was released in March by Google it's called a yet another Python formatting actually they don't have that anywhere in there I'm assuming that's what it means so there's a link to the github you can also pip install

it and also you know we're web developers so we're probably doing JavaScript formatting there's a JavaScript formatting tool by our do called j/s format and so just to kind of run through a little example here I'm the web chair for pi Texas

so I went ahead and ran this on the PI Texas code and it is a newer newer tool like I said so um you know some of the options or the features aren't there yet so I wrote a little script that basically lets me you know I don't want to run formatting

on migrations that's generate a code so let's just skip some of that so you know I put a few options in there that aren't in the default tool when made this little script you can copy this and kind of you know use it to your own risk but there's

three different styles of coding that come with the tool by default there's a google there's a Pepe and there's a chromium style which all have their own default configurations there's a million different options that you can kind of style

with it and i know there you go i set my two spaces so what's it sure um i guess i don't know the mac command there we go yeah so I mean you can pass it like a JSON or a dictionary type object and it has you know hundreds of little tweaks that you

can do to it to get the style that you want and all of your formatting will then all of your code base will be on that formatting so this is fairly boring but here you go have it come up here this is all of the kind of whitespace changes that did to the PI

Texas code base so if you're in Texas on the twenty-fifth through 27th come to PI Texas it's in college station and that's the end of my talk my name is Trey I'm going to show you how javascript is becoming a little bit more like Python a word

of warning i will be going very quickly and there are code examples on almost every slide so ekman script is the language specification that javascript is based on in this presentation I'm going to show off features that were added in equus script 6 which

is also known as xmas script 2015 ekta script 6 isn't yet supported by any browsers but you can start using it today you just need to use bable bable allows you to compile your xmas crypt 6 code down to xmas crypt 5 code which is understood by all modern

web browsers this pre compilation process is kind of like the pre compilation step that's necessary for something like coffee script so our first new feature is fat arrows fat arrows are a new shortened function syntax fat arrows can be used kind of like

lambda functions in Python they also have a longer syntax but i'm going to only show off the short syntax of my slides today we don't use lambdas very often in Python partially because we don't use callbacks very often in JavaScript callbacks are

used all the time so fat error functions are actually really useful when you combine fat error functions with JavaScript array methods they can serve a similar purpose to list comprehensions in Python in addition to being easier on the eyes fat arrow functions

inherit the this binding of their outer scope for anyone who is wrestled with javascript function binding that's a really big deal with template strings you can now do string interpolation in JavaScript so this is kind of like Python strings format method

except that string template strings in Java Script interpolate using the current scope automatically unlike Python string.format template strings also allow you to make multi-line strings so this is kind of like pythons triple quoted strings you Candice triple

a shin at the same time as well javascript did not use to have a class in tax it does now is what it looks like of course no class implementation is complete without a properly loaded foot gun so JavaScript also supports inheritance actually think the super

syntax is a little bit more elegant in JavaScript that it is in Python you can see that in both of those methods there I realize this is a lot of code you can look at the slides afterwards JavaScript now has a spread operator this is similar to pythons argument

on packing operator and Python it's the asterisk symbol in java script we use three dots you can use this to unpack an array into the arguments of a function call you can also use the spread operator to unpack one array inside of another array and this

example combined would be the array one two three four the rest operator is basically the opposite of the spread operator again instead of an asterisk this uses three dots in JavaScript this allows us to make a function that can take a variable number of arguments

so for example our most difference function here takes any number of arguments in this code example we're using the rest operator once and the spread operator twice JavaScript now allows you to specify default parameter values this does not mean that script

[ ... ]

Nota: se han omitido las otras 5.141 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.