Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

What I normally do is type out my longass string and then find spots in it that make sense to break it up. Then I put the cursor there and press enter and PyCharm moves it all to the next line while taking care of quotes.

Also, for whatever reason I find myself using long strings as function params (logging usually) more often which doesn't require the extra set of parentheses which is nice.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

QuarkJets posted:

So anaconda comes with an assload of its own libraries and binaries, and sometimes this causes problems for me. For instance, I can't just set my PATH to the anaconda/bin folder because then I'm overriding the default path for various tools in a build environment where the versioning is actually pretty important.

The only solution to this is to manually downgrade anaconda packages one at a time to match the system configuration. This isn't easy or convenient. I wish there was a way to tell anaconda that I want it to use and link against the system libraries for everything that it can find

I'm not really asking a question, just venting over some issues that I've been having lately

I'm having difficulty picturing your exact problem, but the general idea is why I always use miniconda...have you looked at using that?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

huhu posted:

I'm reading about RESTful web services as they relate to Flask. In the introduction, It talks about how you might need to have multiple versions of your website because not everyone can access the new version immediately (i.e. a smartphone app won't be up to the newest version until the user downloads the new version). The smartphone app was the only example given and I'm struggling to understand what else would justify having separate versions of a website with Flask?

Edit: Perhaps a better question, is there a good article/resource that explains RESTful web services well?

If you're providing an API for consumption by third parties you need a versioning and deprecation policy.

If you're providing an API for consumption only by yourself, you should probably version it because it's easy to do and will help you in the future if your project grows or you open it up to others or whatever. Any decent REST API will make versioning a simple matter of setting a config variable to True.


It seems a little odd to word it as having different versions of a website...I've never heard of that. Only different versions of the API.

Though, with modern web development, your website is often just another consumer of your API.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I switched to PyCharm EAP (basically jetbrains beta program) today just for the hell of it.

The first thing I've noticed is this goddamn amazing "zero latency typing" thing. I've had zero issues with typing latency in PyCharm, but its amazing how great it feels now.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

IAmKale posted:

That's Python type annotations, available since 3.5. It doesn't activate strong typing or anything, it's just a way to add in expected inputs and outputs to method definitions. The part after -> is the method's return value type.

And by "expected" he means expected by Python tools. For example IDE's can use it as hints to highlight when you're trying to pass an int to a function expecting a tuple or whatever. Also, you can use MyPy to do static typing on your code.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

dougdrums posted:

- Is there an advantage to annotating my function definitions beyond having some documentation?

Thermopyle posted:

And by "expected" he means expected by Python tools. For example IDE's can use it as hints to highlight when you're trying to pass an int to a function expecting a tuple or whatever. Also, you can use MyPy to do static typing on your code.

For example, PyCharm uses type annotations to save you from yourself.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The one thing I don't like about more advanced typing annotations is that they can make the signature too long and noisy and those are the signatures they're most useful with. Syntax highlighting and other IDE features help with that, though.

Python code:
def hi(foo: Union[Callable[str, bool], MyOwnType]], bar: Sequence[Callable[[Union[str, int], Tuple[str, str], bool):

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Tigren posted:

I know you know better, but one might suggest you could either get rid of the type hints or clean up that signature with a better function name.

Yes, it was just an example of what can happen.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

dougdrums posted:

I've just been doing like:
code:
def hi(
    name : str,
    punc : str):
    print('hello %s%s' % (name, punc))

Yeah, that's basically what I do

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

Because it was just an example.

e: And also because I come from a procedural/imperative programming background (my first language was Fortran back when it was still FORTRAN [77]) and I've never learned anything else other than modern versions of Fortran and MATLAB so honestly I have no clue what the point of objects are or when and why I should use them.

I just think it's pretty neat to be able to do:

code:
new_tensor = old_tensor.rotate()
Instead of

code:
new_tensor = rotate_tensor(old_tensor, rotation_matrix)
But honestly the only reason I think the first one is neat is because it looks better to me. I really wasn't joking when I said I liked "foo.thing" better than "foo.thing()" because it looks better without the parenthesis (but mostly because I don't think it's semantically correct to call a function to return a value that I've already computed).

I agree that property accesses are more "pleasant" to type and look at than function calls.

Anyway, do you ever split your code into different files for reasons other than language-mandated reasons? The general reason you'd do that is one of the general reasons you'd use objects.

Of course, OOP is full of stupid ideas as well. It's a good idea to become familiar with different paradigms like OOP, functional, etc so you don't end up just using what you know and missing out on better ways to solve problems.

You talking about your background makes me think you might like learning Elm, as it's completely different from what you'res used to for completely different purposes, and it'll really expand your mind about what you can do with Python as you can implement a lot of the same functional ideas in Python.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

Yep of course. I split my code/functions into separate files/modules in a way that makes sense (e.g., functions that act on tensors go in tensors.py). I'm just having a hard time seeing the practical difference between these two though:

code:
def rotate_tensor(tensor, rotation_matrix):
    A = tensor
    Q = rotation_matrix
    return Q*A*transpose(Q)

new_tensor = rotate_tensor(old_tensor, some_matrix)
vs

code:
class Tensor(object):

    def __init__(self, tensor, rotation_matrix):
    self.A = tensor
    self.Q = rotation_matrix

    def rotate(self, rotation_matrix=None):
    Q = rotation_matrix or self.Q
    return Q*self.A*transpose(Q)

old_tensor = Tensor(a_numpy_ndarray, rotmat)
new_tensor = old_tensor.rotate()
They both do the same thing. It's just more elegant looking to be able to call a rotate() method I think, but at the end of the day all I really care about is that the rotate method or rotate_tensor function gives me back a properly rotated tensor. Plus it's neat that I can assign the rotation matrix to the object already and not have to worry about passing the rotation matrix around anymore. That's the really cool part for me.
Yeah, they do the same thing, and I'd say someone was drinking the OOP koolaid if they implemented the OOP version in isolation.

You'll often see classes used in python to lump logically-related code together, so in just that sense you can see them as another unit of subdivision. You have packages (directories with a __init__.py) file, modules (.py files), and classes, all that help you organize code.

That being said, classes are more than just a way to group logically-related code together.

It's hard to describe a slam-dunk case for objects because everything you can do with objects you can do with functions. Objects are for helping you reason about your code, they don't make your code able to do new things.

I think the best you can do is understand how objects work and be aware of them. Try to use them even when you don't think you need them. It'll help you get a feel for them so that when you do encounter problems that would benefit from an OOP approach, you'll know to use them.

There's a not-entirely-unjustified school of thought in python-land that too many developers pull out classes unnecessarily.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I always use the one I stole from django.

Python code:
class lazy_property(property):
    """
    A property that works with subclasses by wrapping the decorated
    functions of the base class.
    """
    def __new__(cls, fget=None, fset=None, fdel=None, doc=None):
        if fget is not None:
            @wraps(fget)
            def fget(instance, instance_type=None, name=fget.__name__):
                return getattr(instance, name)()
        if fset is not None:
            @wraps(fset)
            def fset(instance, value, name=fset.__name__):
                return getattr(instance, name)(value)
        if fdel is not None:
            @wraps(fdel)
            def fdel(instance, name=fdel.__name__):
                return getattr(instance, name)()
        return property(fget, fset, fdel, doc)

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

e: vvv What's the proper way to do it then?

Maybe just a regular function or a classmethod on Beer.

Python code:
@classmethod
def get_beer_by_type(cls, type, *args, **kwargs):
   ...

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Gunslinger posted:

Haha holy poo poo I hope it's that simple, just got into work but I'll RDP into my machine later and check. Thanks man.

This is probably it. I've been writing python for a decade and this will still occasionally trip me up...particularly when it's a large project and I've been doing lots of refactoring.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

a witch posted:

What's the current hotness for type annotations and checking? Mypy or something else?

mypy

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

vikingstrike posted:

Does mypy have support for pandas objects? So I could set the return/input type to be pd.Series or pd.DataFrame?

https://github.com/pandas-dev/pandas/issues/14468

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Baby Babbeh posted:

Thanks for inadvertently bringing f-strings to my attention. I always use str.format() but that seems like a better way to do that...

They're the best.

It's weird that .format() has always bothered me as much as it has, but dang it sucks.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Django thread barely gets enough traffic to justify its existence. You may be better off just talking Flask in here?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

funny Star Wars parody posted:

Ok here's a dumb question: I want to make a unicornhat (which uses a Python library) on a raspberry pi do something when a new order is placed, and according to the Shopify API, you would use their webhook to do it and you supply them with the URL for the webhook to deliver a HTTP POST payload to in json format.

I understand the concept of json stuff after working with the discord API but I've never worked with webhooks before, so correct me if I'm wrong but does that mean I have to have my own server running and listening for the HTTP POST payload? Since it's a raspberry pi would it be easier to try to sniff for like an email notification to trigger the light_sign action?

Any pointers would be great, I'm doing this for a friend's company in exchange for some of the neat t-shirts that he sells so I'd really like to find a way to make it work that doesn't take me a million years to figure out

Yeah, you need a server running. Basically shopify will call an url on a server you control when orders are placed. Then your code does something when that happens. It will work fine on a raspberry pi.

Flask and Django both are both capable of doing this is like 20 lines of code or something. The hardest part will be learning how to do it because for some reason understanding how the web works is not easy despite it being pretty simple.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Tigren posted:

This is the perfect use case for Flask. You don't need the bells and whistles of Django.

Python code:
from flask import Flask, request

from raspberry_pi_funcs import blink_bright_light() # I don't know how the raspberry pi functions work

app = Flask(__name__)

@app.route('/', methods=['POST'])
def index():
        data = request.get_json()
	if data['total_line_items_price'] > 100:
		blink_bright_light()
	return "Success"

FWIW, it's about the same in Django. Flask is fine and there's a 50/50 chance I'd use it for the project myself, but occasionally I like to point out that people have this idea that Django is really complicated or something. It includes a lot more "in the box" than Flask, but it'd work basically just like Flask in this case. Single file, basically same # lines of code, etc.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Thanks for reminding me about Zappa. I keep meaning to try it out on my next project and then forget.

edit: oh yeah now I remember why I really haven't tried it. No Python 3 support. :(

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Foxfire_ posted:

Huh, I was expecting the pandas overhead to be much smaller. Some testing shows that it goes:

vectorized numpy > vectorized pandas >> iterative numpy >>> iterative pandas

An iterative solution in something with known types (C/Fortran/Java/numba/Julia/whatever) will still be faster for complicated calculations than the vectorized versions since the vectorized ones destroy all cache locality once the dataset is big enough (by the time you go back to do operation 2 on item 1, it's been booted out of the cache), but you can still get enough speedup to move some algorithms from unworkable to useable.

Python's speed problems mostly don't have to do with it being compiled in advance or not. They're consequences of how it works with types and the stuff it lets you change. It's basically impossible to JIT compile stuff like you would in Java because you can't prove that a loop isn't doing things like monkey patching functions or operators at some random loop iteration in the middle. The interpreter has to execute what you put down naively since it can't prove that it's safe to take any shortcuts.

Timing results:
code:
import numpy as np
import pandas as pd

numpy_array1 = np.random.rand(100000)
numpy_array2 = np.random.rand(100000)

print("Vectorized numpy")
%timeit  out = numpy_array + numpy_array2

print("Iterative numpy")
out = np.empty(100000, dtype=np.float64)
%timeit for i in np.arange(100000): out[i] = numpy_array1[i] + numpy_array2[i]

pandas_dataframe = pd.DataFrame({'A': numpy_array1, 'B': numpy_array2})
print("Vectorized pandas")
%timeit out = pandas_dataframe.A + pandas_dataframe.B

print("Iterative pandas")
out = np.empty(100000, dtype=np.float64)
%timeit for i in np.arange(100000): out[i] = pandas_dataframe.A.iloc[i] + pandas_dataframe.B.iloc[i]
code:
Vectorized numpy
10000 loops, best of 3: 150 µs per loop
Iterative numpy
10 loops, best of 3: 52.1 ms per loop
Vectorized pandas
10000 loops, best of 3: 181 µs per loop
Iterative pandas
1 loop, best of 3: 4.3 s per loop

Have you tried with Cython? (no clue if it works with pandas or numpy)

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

oliveoil posted:

The Python documentation says "Long integers are now stored internally either in base 2**15 or in base 2**30": https://docs.python.org/2.7/whatsnew/2.7.html#optimizations

What does that mean? I have never seen "base 2 to some power" used before. 2**15 = 32,768 and I really doubt this means that Python uses a base-32,768 number representation.

The general programming thread is a better place to ask this probably.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Temperature and humidity tracking automatically makes me think of a time series database.

I haven't used it but I've heard of opentsdb. Or even good old RRDTool. You could probably set up your own service for either of those on a 5/month DigitalOcean server.

But then again, maybe a time series database isn't what you want, it's hard to say without knowing what you'll do with the data. No matter what you do I bet the DigitalOcean server idea would serve you well if you're really wanting a cloud/remote thingy.

InfluxDB is another good option, I'm pretty sure there's hosted versions of that out there if you didn't want to set up your own server. Then you could do sweet visualizations with Grafana.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

huhu posted:

I started developing with Sublime Text and then switched to PyCharm since I've been working mostly with Python. However, my new job has me focusing on Flask apps and PyCharm seems to be a bit lacking when it comes to dealing with HTML, CSS, and JS. I miss all the awesome plugins that come with Sublime Text as well. Am I missing something or should I be looking at something else to be developing Flask stuff?

What?

PyCharm is amazing for HTML/CSS/JS. It's basically a superset of Webstorm which is already widely liked for webdev stuff. I often use PyCharm for projects that are only HTML/CSS/JS.

Maybe ask about some specific things you're missing and I bet you'll find that most of them are supported.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

QuarkJets posted:

I'm not sure that it has ever mattered to me; I just kind of assumed that the last value of the comprehension variable would be available in the local scope and didn't realize that this was actually undesired behavior.

This is exactly right. It was just the way it was. It was never a problem.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Right, I got that from your first post. I'm asking like what?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

funny Star Wars parody posted:

Jetbrains makes a lot of really nice stuff and I really like IntelliJ for Java and JavaScript. I found Pycharm to be frustrating to use because most small Python apps aren't organized the way Pycharm seems to try to organize them

What does this mean exactly? AFAIK, PyCharm doesn't care how your projects are organized.

I often go through a lot of different structures on a project. It starts out small with a few files just right next to each other, them I move stuff into packages then I move stuff into a full-blown thjngamajig with a setup.py, etc...

PyCharm doesn't seem to give a crap and in fact helps with that since it does a fine job with automatic refactoring.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

IMO, typing.NamedTuple is also better than collections.namedtuple with no extra dependency. I haven't used attrs, though.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I think the continued existence of whatever packaging system or repository is a hard problem.

Continuum is just one company.

PyPI (where your packages come from when you pip install something) is basically developed by one guy. Last I heard, it's infrastructure would cost 40 grand/month if Rackspace wasn't donating it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Epsilon Plus posted:

As a relative newbie, if dependency injection is less popular in Python than it is in other languages, how do you handle cases in Python that you'd typically use dependency injection for in, say, Java?

DI isn't exactly uncommon in Python. It's just that because of Python's dynamic nature you don't really need a lot of scaffolding that you need in other languages so it often doesn't go by the Official Pattern Name Dependency Injection. You just write stuff in Python in a pythonic way and then later someone is talking about Python and DI and you go "you know I guess I just did use DI!"

edit: Forgot to add that super() is an effective and easy way of doing DI in python.

Thermopyle fucked around with this message at 21:51 on Apr 20, 2017

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

KernelSlanders posted:

I don't know what your specific application is but nine times out of ten when someone is asking for a GUI toolkit the right answer for their use case is HTTP.

I assume you mean HTML. And I agree with you.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

ButtWolf posted:

Hey, hopefully easy question for ya'll: I wrote a webscrapey thing last year w BeautifulSoup. I changed variable names to get the new data (new <tr> headings). Nothing works now. I'm out of practice and wasn't good to begin with. Can anyone help. BTW, it worked perfectly last year.

code:
import sys
import time
from bs4 import BeautifulSoup
from urllib2 import urlopen  # for Python 3: from urllib.request import urlopen

url_test = open('txt_files/url_list.txt', 'r')

f = open('txt_files/scraped_final.txt', 'w')

for line in url_test:

#html_doc = 'http://www.basketball-reference.com/players/a/arizatr01.html?lid=carousel_player'
	html_doc = line

	soup = BeautifulSoup(urlopen(html_doc, "html.parser"))

#This works do not touch
	name_tag = soup.find("h1")
	player_name = name_tag.string
#This works do not touch
	per36_line_2016 = soup.find("tr", id="per_minute.2016")
	per36_line_2017 = soup.find("tr", id="per_minute.2017")
	adv_line_2016 = soup.find("tr", id="advanced.2016")
	adv_line_2017 = soup.find("tr", id="advanced.2017")
	per_game_line_2016 = soup.find("tr", id="per_game.2016")
	per_game_line_2017 = soup.find("tr", id="per_game.2017")
	f.write("Name: " + player_name + "\n")


	for string in per36_line_2016:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")
	for string in per36_line_2017:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")
	for string in adv_line_2016:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")
	for string in adv_line_2017:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")
	for string in per_game_line_2016:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")
	for string in per_game_line_2017:
		f.write(string.encode('ascii', 'ignore') + " ")
	f.write("\n")

#This works do not touch
	print player_name
	time.sleep(1.0)
It gives me nonetype errors. I changed the for strings and wrote straight, it of course did not strip all of the html tags, but also only two of the six were written, the others were None. I'm not sure what has changed. The site looks like it's the same. Any ideas?

You should give us the actual error stacktraces so we don't have to go through your code line by line to figure out whats what.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

This is a nice library that I use fairly often. backoff.

When working with external APIs over the network you have to handle the stuff that happens when you're dealing with networks and other network devices. This library helps with that. Amazon has a good post on their architecture blog about the best algorithms for choosing a time to wait between retrying failed requests if you want to read about it.

Anyway, it's pretty simple to use...you just decorate the function that might fail and the decorator retries the function until its successful.

Simple example that backs off each request by an exponential amount of time:
Python code:
@backoff.on_exception(backoff.expo,
                      requests.exceptions.RequestException,
                      max_tries=8)
def get_url(url):
    return requests.get(url)
Complex example using multiple decorators to catch different types of stuff:
Python code:
@backoff.on_predicate(backoff.fibo, max_value=13)
@backoff.on_exception(backoff.expo,
                      requests.exceptions.HTTPError,
                      max_tries=4)
@backoff.on_exception(backoff.expo,
                      requests.exceptions.TimeoutError,
                      max_tries=8)
def poll_for_message(queue):
    return queue.get()
Anyway, I thought I'd share this as beginners often get into python wanting to scrape websites or download some sort of data. This is a good thing to implement if you're doing that!

There's another, more popular, library called Retrying that you can take a look at as well. The reason I don't use it is that it doesn't support the recommended algorithm in that Amazon blog post, but you might be interested in looking at it as well.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

PyCon 2017 videos are up.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Loezi posted:

I'm doing something relatively simple and Bottle seems like it's fully adequate for my uses. Is there some reason for using Flask over it if I don't need authentication or anything like that? In practice, I only need to serve an API with three distinct endpoints, one of which takes query parameters.

Bottle is fine.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

huhu posted:

I would like to debug JavaScript inside a PyCharm for Flask projects. I see that I can set breakpoints in the JS code but PyCharm always skips over them. The only tutorial I can find online involves debugging static HTML and not Jinja2 templates.

I haven't debugged JS in a jetbrains IDE in years, but I seem to recall it was easier if I used an external js file included in my templates via a script tag.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell


You'll probably get more help on StackOverflow. I will say this...the reason I haven't used the JetBrains JS debugger in years is that the chrome devtools debugger is superior in every way that I can think of. Depending on what you're doing you might be better off just using that.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Rocko Bonaparte posted:

Has anybody dabbled with dependency injection with Python? I have reason to implement something like an API for getting implementations of APIs, and DI sounds like the way to go. I especially think back to how Angular managed stuff like this.

I've done some experiments in this direction, similar-ish to what Tom Christie talks about in that video MonkeyMaker just posted.

I think it has a lot of potential.

You'll find that a lot of DI/IoC stuff in Python is never called that because DI/IoC just comes naturally to python due to its dynamic nature with first class everything.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

This isn't going to be too helpful, but that's not exactly a Python issue. Your computer can't find the ip for the hostname that's configured somewhere in that app.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply