|
I don't use pylint, only the linter that's built in to PyCharm -- does pylint flag implicit string concatenation? At first glance it seems tricky to figure out when it might be intentional, since I relatively commonly doPython code:
Python code:
|
# ¿ Mar 6, 2017 17:10 |
|
|
# ¿ Apr 29, 2024 09:47 |
|
HardDiskD posted:It's throwing a syntax error because it's missing the except clause. except clauses are not required if there's a finally. code:
|
# ¿ Mar 24, 2017 00:51 |
|
This message is almost certainly not from the Python interpreter itself:rt4 posted:
It's more likely that somewhere in the code, there's a try/except block that's catching an exception and only printing out the exception's message, like: Python code:
|
# ¿ May 9, 2017 16:17 |
|
huhu posted:
1. Use pathlib: Python code:
3. To find any file in any subdir, use os.walk and use fnmatch to check whether you're interested in it based on the filename.
|
# ¿ May 17, 2017 22:03 |
|
Dominoes posted:If you haven't tried Pipenv, give it a shot: It elegantly combines virtualenvs with pip, and has simplified my workflow. It's been hard-broken with two distinct bugs until a few days ago, but the latest version is good-to-go. Does pipenv still insist on using the deprecated virtualenv tool on all versions of Python, instead of using the venv standard library module when it's available? That was definitely the case when I checked last, and was a no-go for me to try out pipenv.
|
# ¿ Dec 20, 2017 19:50 |
|
Sockser posted:When building out some code last week, I accidentally used {} to make an array instead of () No, this creates a set object: https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset Sets are unordered collections of distinct objects, so the order you see is arbitrary, and duplicate elements are only stored once: code:
e: wow beaten twice, that was fast Lysidas fucked around with this message at 20:14 on Dec 20, 2017 |
# ¿ Dec 20, 2017 20:12 |
|
Are you absolutely certain that you are communicating with a different server when you access (e.g.) https://www.company.com/some-path vs. https://www.company.com/? That is generally not how DNS, TCP/IP, TLS/SSL, and HTTP work -- one cannot have a specific URL path served by a different publicly accessible web server, with a different certificate, from the same hostname. When you connect to https://www.company.com/some-path, the following happens, more or less:
(Note that SNI alters this process a bit, allowing server software to return different certificates when different hostnames are requested, but this doesn't help you. This only applies when you have multiple hostnames mapping to the same IP address, not the same hostname apparently referencing different machines.) If you're absolutely sure that a different machine is responsible for the path https://www.company.com/some-path vs. https://www.company.com/, that doesn't mean you can directly connect to that machine to obtain its certificate. One can configure a reverse proxy like nginx to route requests for certain paths to different internal or even external servers, but in this case you are not communicating with that other server to get the content for https://www.company.com/some-path -- the server software for https://www.company.com/ is making this connection, presumably validating the other system's certificate if connecting over HTTPS, and then relaying the data to you. In this situation, you never directly connect to the other server, and even if it's publicly accessible, you have no way of knowing its hostname/IP address/anything about it. e: and of course someone can set up https://www.company.com/some-path to redirect to a different hostname/path altogether, in which case it should be pretty trivial to parse that reply in your software to connect to that other host instead Lysidas fucked around with this message at 22:34 on May 12, 2018 |
# ¿ May 12, 2018 22:29 |
|
QuarkJets posted:I agree, this seems convoluted and bad. I assume (hope?) that people here aren't using it that way This specific case of "fixed path / string / string" does seem convoluted and bad, but I've never really seen anyone do that in practice. I use pathlib very extensively, and I use the overloaded / operator extremely often. It's really nice when having a Path representing a user-supplied or dynamic directory and wanting to refer to some hardcoded filename in that directory. pathlib became much nicer to use in 3.6 also, since builtin IO functions now support path-like objects in addition to string paths. This means you can now do: Python code:
Python code:
|
# ¿ May 17, 2018 12:37 |
|
|
# ¿ Apr 29, 2024 09:47 |
|
As time goes on, I'm getting less and less happy with the pyplot API in matplotlib. I'd prefer to use the object-oriented API in new code, but I always find it hard to prioritize learning a new API over creating the plot that I need at any given moment. I remember seeing a document (maybe part of the matplotlib documentation) that was something like a side-by-side description of how to perform common operations with the two APIs. For example, "this is how you instantiate a figure, and the axes, and select the artist" for the OO method, vs. "call pyplot.figure" for the stateful Matlab-like API. I'm having a hard time finding this, though; does anyone know of any documentation like this?
|
# ¿ Jun 29, 2018 15:54 |