Can anyone answer a very basic python question. I used SublimeText to code Python. I just told my friend to download it. He is starting to learn Python. He was wondering why you can't run python programs within SublimeText. Is there an editor that allows you to also run your programs or no?
still trying to wake up... (long night and not enough coffee down my neck yet) but if you got to View -> Console - you should get a bottom bit of the screen for that stuff?
How to run a send exception mail whenever a exception occur ?
I have implemented a SendEmail() function so I want like to call
this function whenever any exception occur
in any of the project file
file1.py
try:
1/0
except Exception as e:
print(e)
file2.py
all script ok
file3.py
try:
some error
except Exception as e:
print(e)
Okay, I see beating around the bush won't get me anywhere, so I'm gonna have to say it: This is a terrible idea. Installing a hacky exception hook (nevermind that this probably isn't even possible) just so you can write pass instead of print_and_send_email(e) is a terrible idea.
^ if you catch the exception, its your responsibility, then and there, to do all the things you needed with said exception.
something else to consider, if it makes sense for your workflow, either 1. dont catch general exceptions this far low, and just let them get raised, catching them somewhere higher up or 2. re-raise all these exceptions if your code is capable of handling them higher up. Both will depend on whether your actual code logic allows this or not.
this is going to be a fun day... some client yamming about something that actually isn't who I need to calm down a bit, and a PCR home test and a box of LFT's turning up... (and with a bit of luck the booze I ordered in for xmas)
Hello, I have a simple question, maybe someone can help me? I am using a python code from a website (https://www.thepythoncode.com/article/redact-and-highlight-text-in-pdf-with-python) to highlight words in PDFs. However, I cannot see how I can enter several strings to search for at once. I tried something like this: python pdf_highlighter.py -i input.pdf -a Highlight -s ["one,"two","three"]
Just a note: Python 3.6 reaches end of life in 3 days. We've just had an error on AWS that might indicate that they've dropped botocore support for 3.6
hey guys, my aim is to fill an xml with some variables, <a><b>"1"</b><c>"2"</c></a> where 1 and 2 are values I get from variables, is there a better way than using format? '<a><b>{}</b><c>{}</c></a>'.format(1, 2)
if it were a python dict I can do something like {'a': {'b': variable_1, 'c': variable_2}}, is it possible to build the same with xml?
The core concept of "do different things depending on the argument's type, and sometimes recurse" pops up a lot when dealing with JSONy data. I just keep that basic structure in mind and fill in the blanks
Exponential growth is crazy. If you just put s = f'<foo>{s}</foo>' in an endless loop it easily runs for 100k iterations, so I was definitely worried over nothing there
I wonder if Python is doing some magic there to avoid allocating N distinct buffers of length zero through N. Maybe ropes are involved? I have never really understood ropes.
There is apparently some trickery in a few string operations that allow them to peek at the stack and just re-use the string if it's guaranteed to be unowned.
The += optimisation works that way. Wouldn't be surprised if f-strings knew similar tricks.
On a totally unrelated side note, I'm running out of synonyms for asyncio concepts with a bad interface. Current "Yuck!": asyncio.Future
@ansh1 My advice would be not to do any programming in bash. If you need to do anything more than run one or two commands, use a real programming language
When asking a question, it's good to trim out all the parts of the input files that aren't related to the problem... But you shouldn't trim out the parts that make the file syntactically valid
I notice that there's a Github footer underneath the code. I wish I had known it was on Github to begin with, you could have just posted a link to it. Like so: github.com/Gregory-Eales/crypto-pump/blob/main/run.py
@Randolp How do you know that? You haven't raised an issue on GitHub so it doesn't look like you've made an attempt. Also note the quote that Aran-Fey just linked in this chat
the modifications are the margin requirements as if the are not changed you dealing with 300 plus margin
simple math change the multiplication to division then margin is reasonable. its the retrieval of account data that is the problem from line 93 to line 111
Look. In all likelyhood, we won't rewrite someone else's program for you. But if you're feeling optimistic (or desperate), then you'll have to ask more specific questions. "its a problem" isn't gonna cut it
Oh wow, when I first looked at print("[{}] {}: failed to generate client".format(get_time(), error_txt)), I thought, "it's not a great idea to only show the error mesage and not the stack trace, but it's better than nothing". But now I see that error_txt is not the error message, but rather just the word "error"
You're going to want to get a proper stack trace so you can actuallys see what's failing. Change the return None inside the except block to raise. Then you should be able to see the exception's type and message, and the stack trace.
A traceback begins with Traceback (most recent call last):, if you're having trouble finding it. It won't be in the log file, but rather your command prompt or IDE's output window.
If you don't have either of those, it's possible to send the exception/traceback to the log file, but it's a relatively involved process
The function get_ticker (not to be confused with client.get_ticker) gets the value for tick from input("[{}] which ticker is being pumped: ".format(get_time())). In other words, the user is presumably typing something in using their keyboard. What do you type in when the program asks you this? If you're not typing anything, then you must be running code besides what we've been looking at, and we'll have to start over from the beginning
I think it's better that you don't. From this conversation, it's clear that you don't have a grasp on what the code you're running is actually doing so we're not going to get anywhere. I think you'll need to find another forum for which to ask your questions
In the last hour or so, my laptop has stopped sounding like it's about to take off, yet I'm still throwing it at the same problem in a loop every time something screws up. It seems like computers might now have gained rights to time off. We're doomed, but there's at least a telltale sign from their fans...
my desktop has 4 fans (meant to be a cooling chasis or something) - it's when they turn off for a moment and it doesn't sound like it's trying to take off is when I get worried...
Nah, I'm also watching the speed of the iterations, which crashes and burns with my custom class :) I've just discovered that I apparently don't know anything about threading in Java
Heh. Lack of fans --> just diagnosed a months-long problem with other parts of my code. It's the little details :D Merry Xmas, me (I guess? I'll have to overlook the Java part of the whole thing)
neither using a list(range(100)) or unpacking g into a list before creating the lambda doesn't solve the problem either.
The expected behavior is that each thread in the pool will receive non-overlapping chunks of size 30 which cover the range. The unexpected behavior is that some thread pools get the same chunk that another one got, and some are missing. And it changes on different invocations (for me)
If I use 10 and 3 instead of 100 and 30, I get output like this:
The only way to know whether it's not relevant is to first take it out of threaded code? for g in grouper(range(100), 30): should run independently of threading
In which case, can't you just batch things up before dispatch via threads? I'm not going to pretend to understand what's happening in that code (I suspect a few things but I'll need to check)
So, what must be happening is that inside of the lambda, g has a reference to the group. By the time a thread gets to using it, that name is bound to a different reference?
Who knows. Everyone has their own mental model and we could spend days arguing about what a "reference" is. But in essence, the lambdas are all referring to the same g variable, so if the loop assigns a new value to g before the lambda is executed, it'll print the new value
@alkasm lambdas in Python close over scopes of names, not values
@alkasm technically in CPython a local variable that is referred to by inside a closure is in a thing called cell... but that is CPython specific jargon
Just on that apology; since you don't have 10K rep, are you aware that everyone on the chat network that does gets notifications for flags btw?
I don't hang out in PHP, I just came back to this room and had 12 flags for abuse in a totally different channel to review (as did anyone else with 10K+ rep). That's the only reason I popped into the PHP channel
Anyone use aiohttp for servers? I'm wondering what happens to your handler coro if the client disconnects. Is there a hook for that where I can trigger something to happen in that case? Does aiohttp create a task to run my handler and then cancel it? Does it just let it continue running?
Actually now that I ask I realize this is probably not difficult to test manually.