Quantcast
Channel: User Arminius - Stack Overflow
Browsing latest articles
Browse All 28 View Live

Comment by Arminius on How does an exception know if it's being handled?

@Dschoni I am asking how the exception knows if it's being handled and can change behavior based on that. I am not asking about how to handle an exception. My SystemExit example demonstrates that it's...

View Article



Comment by Arminius on How to delete repeating letters in a string?

Your example currently has a syntax error at the for loop.

View Article

Comment by Arminius on Python Actions during an input()

@crazicrafter1 Do you mean it prints "waiting" before it asks for input?

View Article

Comment by Arminius on Is it possible to include subdirectories using dist...

Be careful here, because you might accidentally include test directories, etc. unless you explicitly exclude=... these.

View Article

Comment by Arminius on Running pytest repeatedly on changed test files

@hoefling Thanks, I am not really looking for a solution in the interactive shell. I simply have a Python script that repeatedly runs tests and should be able to pick up when the tests change.

View Article


Comment by Arminius on What are these extra symbols in a comprehension's...

@MartijnPieters Thanks for your insightful answer and digging so deep. Now I feel sorry I didn't think of at least disassembling the bytecode myself.

View Article

Comment by Arminius on Accessing the AST used for building a symtable

@AnthonySottile Any idea if I could maybe use some C extension magic to get a reference to the AST object?

View Article

Comment by Arminius on Python eval: is it still dangerous if I disable...

While it doesn't show up with the stdlib's tokenize module, the expression inside an f-string will show up in the AST when parsing f"{some code}".

View Article


Comment by Arminius on Ubuntu hotkeys with X11/xlib, X error: BadAccess

Maybe that thread helps: unix.stackexchange.com/questions/261371/…

View Article


Comment by Arminius on When I use positional-only arguments with annotations...

@MSeifert Will do.

View Article

Comment by Arminius on Keeping an object static in python

It seems you want to copy the list before appending. You can use I.copy() or I[:] for that.

View Article

Comment by Arminius on What is an alternative to execfile in Python 3?

@gerrit Thanks! I added a note. (It's (re-)executed on every call as the name of loader.exec_module() somewhat suggests.)

View Article

Comment by Arminius on Unrecognized or unpermitted key(s) in configuration...

Could you mark your answer as the accepted answer then?

View Article


Answer by Arminius for What does the tag

This notation is used for templates in the source code of Kirki, a Wordpress tool. You might be familiar with other template tag variations such as <% %> (Rails).I assume that the snippet from...

View Article

Answer by Arminius for Give params to a div created via document.createElement

Use setAttribute() instead:divs.setAttribute('data-id' , data[i].id); Also note that hyphens are not allowed in Javascript identifiers, they would be parsed as substraction.

View Article


Answer by Arminius for Class Method missing one positional argument

If you're calling Material.newMaterial(...) directly, self is not bound, so you're missing a mandatory argument. (You're trying to call newMaterial with self='elastic', etc.)Either remove the parameter...

View Article

Answer by Arminius for How to load custom plugin in py.test

If you want to load a plugin from the current directory, you can also just invoke pytest with python -m instead:python -m pytest -p mypluginThis way you don't need to set PYTHONPATH explicitly. From...

View Article


What are these extra symbols in a comprehension's symtable?

I'm using symtable to get the symbol tables of a piece of code. Curiously, when using a comprehension (listcomp, setcomp, etc.), there are some extra symbols I didn't define.Reproduction (using CPython...

View Article

Answer by Arminius for Name resolution for class definition blocks and...

Take this example:x = 1def foo(): x = 2 class Bar: print(x) x = 3foo()# Output: 1When print() is called, x is local (because it's assigned in the next line), but still unbound because it's used before...

View Article

How to develop legacy Firefox add-ons in the future?

Firefox is moving towards the WebExtensions standard which promises improvements in stability, cross-browser compatibility, and more security. At the same time they're gradually dropping support for...

View Article

Answer by Arminius for Add HTML5 sandbox attribute to an iframe using Javascript

While you can set the iframe.sandbox property as a string, it's technically a DOMTokenList interface, so you can also add() and remove() single tokens:let myIframe =...

View Article


Answer by Arminius for How do I get the full path of the current file's...

In Python 3.x I do:from pathlib import Pathpath = Path(__file__).parent.absolute()Explanation:Path(__file__) is the path to the current file..parent gives you the directory the file is in..absolute()...

View Article


Answer by Arminius for Substring in vim script

The VimL expression mystring[a:b] returns a substring from byte index a up to (and including) b.But be aware that the semantics are different from Python's subscript notation or Javascript's...

View Article

Answer by Arminius for Bash: echo string that starts with "-"

In zsh, you can use a single dash (-) before your arguments. This ensures that no following arguments are interpreted as options.% VAR="-e xyz"% echo - $VAR-e xyzFrom the zsh docs: echo [ -neE ] [ arg...

View Article

Answer by Arminius for Removing csrf_token before inserting into MongoDB

This is a quirk/bug that can be solved as follows.Option 1Pass an instance of your model (Study) to the form constructor. You can just pass an empty instance which will get filled with the form values...

View Article


Answer by Arminius for How to increment version number in a shell script?

For the common use case to increase just the patch version, keep it clear and simple:$ awk -vFS=. -vOFS=. '{$NF++;print}'<<<1.2.991.2.100Explanation-vFS=.Set Field Separator to .-vOFS=.Set...

View Article

Answer by Arminius for How do I write standard error to a file while using...

If you're using Z shell (zsh), you can use multiple redirections, so you don't even need tee:./cmd 1>&1 2>&2 1>out_file 2>err_fileHere you're simply redirecting each stream to...

View Article

Answer by Arminius for Flake8: Ignore specific warning for entire file

Before version 3.7.0, ignoring specific errors was only implemented per-line but not per-file.The feature was discussed in issue #324 and the project chose not to implement. An implementation was...

View Article
Browsing latest articles
Browse All 28 View Live




Latest Images