« first day (4084 days earlier)      last day (1089 days later) » 

05:33
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?
you have to install python and use a environment
?
Not at all what I asked.
it is
editors cannot run python directly
Sublime does't allow you to run your program. Is their a text editor that allows you to write your code and also run your pgorgam.
it just links to the python Repl
05:38
is that what an IDE
is an IDE a text editor with the ability to run your program?
So the answer to my questions is use Pycharm or Viual Basic Studio??
Thanks!
your preferences
there are many IDEs that will be able to do what you want
06:11
@CarsonForeman umm.. fairly sure sublime lets you "run" what you've got loaded if configured correctly
(it just doesn't have all the debugger luxuries of a full blown IDE)
i mean yea I can run code like prints
just if i do like name = input("What is your name"?) it will just get stuck there because you cant type input in.
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?
06:45
    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)
Replace print(e) with SendEmail(e)?
No I print(e) also required to print msg in console and sendmail() function to notify us through emial
Then add SendEmail(e) after the print?
but its like i want to automate bec try exception is used in so many places.

I want to import SendEmail(e) after print in automated way. whenever any exception occour this SendEmail(e) will be called from sendmail.py file
Are you sure you want to be notified about every exception? What if the code catches and handles the exception?
try:
    with open(config_path) as config_file:
        config = json.load(config_file)
except FileNotFoundError:
    config = default_config.copy()
You want to get an email for ^ that ?
07:02
only in these case

try:
    some error
except Exception as e:
    print(e)
So... what exactly do you intend to automate there?
whenever except Exception as e is called then sendEmail() function should also trigger to notify us in email
and I not want to add this function in 100+ except Exception as e cases file. this need to be automate
So to clarify, instead of writing
try:
    ...
except Exception as e:
    print_and_send_email(e)
you want to write sys.my_exception_hook = print_and_send_email followed by a bunch of
try:
    ...
except Exception:
    pass
yes
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.
07:15
^ 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.
try:
    ...
except Exception:
    print(e)
 sendmail()

instead adding sendmail after every except it should be called automatically
If you want to reduce boilerplate code, you can do that with a context manager like:
with notify_me_about_exceptions():
    ...
Well, clearly the message that this is a bad move isn't getting through, so here's a better argument against "automating" this: It's not possible.
 
1 hour later…
08:31
except Exception always makes me shiver
08:46
It could be worse...
Jun 7 '18 at 13:13, by PM 2Ring
Bare except is bad enough, but except: pass is the Python equivalent of sticking your fingers in your ears and shouting "La la la, I can't hear you".
09:06
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)
...and someone replacing the boiler
09:20
@PM2Ring yeah... :(
@JonClements "LFT's" != "Liver Function Tests", I take it
09:53
@smci haha... I presume you did realise I was talking about Lateral Flow Tests re: covid?
ahh... apparently should keep it out of the reach of animals and pets... that's me yammed then :p
10:16
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"]
thats when you start reading the code, and potentially modifying it as need be.
trace back this -s parameter, see what datatype it accepts, and how you could modify it to behave as you want
It's a regex pattern, so do -s "one|two|three"
Oh man, that code... people come up with the craziest ways to write bad code
oh?
what did you see
def func(**kwargs):
    foo = kwargs.get('foo')
    bar = kwargs.get('bar')
    ...  # repeat 3 more times
The cherry on top would've been a type annotation with typing.TypedDict
10:33
Thank you for the help! It worked :)
10:45
@Aran-Fey Isn't there a way to deconstruct it into a tuple instead ?
What, the kwargs dict? Sure, but why would you do that?
Because I forgot that it's actually a dict
My bad
11:42
@Aran-Fey Ugh. I see that one way too often. Almost every new student we had in recent years did it at some point...
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
ha, 3 days? I thought it lasted until end of year. It's like a christmas present
That moment when 3.6.15 goes EOL, but yum insists 3.6.8 is the newest version available...
11:59
Feels like just yesterday we were answering questions about the 2.7-only unicode type... Wait, that was yesterday.
12:11
Time travel may not be real, but some people still live in the past ¯\_(ツ)_/¯
12:22
That's because time travel isn't real and we're stuck here.
Plot twist: Time travel is indeed real, but it requires Python 4.
woah, i saw you travelled back in time and changed the requirement from 3 to 4
thus creating a rip in the fabric of time itself.
That's why they don't let me use the nice toys. D:
Because you can't sew?
Actually I can sew decently well, but most of my skill points went into pottery.
12:59
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?
actual xml is larger than just a b c
Python has a handful of XML-related libraries that might be helpful
thanks Kevin let me search for libraries
format is fine as long as you escape the values first
so creating a "placecholder xml" with {} and then using format to populate at one go is normal?
Note that your format approach doesn't create the quote marks you want
13:04
I did not notice that, but yes I would ideally want those to be taken care of
anything more than just this toy example, and i'd say using an xml parsing library is ideal
Working with xml is not normal at all, with the notable exception of html :P
need to use a soap api, so I need to build the body
I guess library is my answer, lxml keeps showing up, so I am guessing its good
Quick dict-to-xml prototype:
def xmlify(x):
    if isinstance(x, dict):
        nodes = []
        for key, value in x.items():
            value = xmlify(value)
            nodes.append(f"<{key}>{value}</{key}>")
        return "".join(nodes)
    else:
        return repr(str(x))

d = {'a': {'b': 1, 'c': 2}}
print(xmlify(d)) #output: <a><b>'1'</b><c>'2'</c></a>
recursion strikes again
13:08
Odds are pretty good that this breaks if any dict key/value contains slashes or angle brackets etc. Test thoroughly
I'll write you a nonrecursive one for $40
did you have this in some sort of "code stash" or you just write this? if so its mad
lol, I will pass on that
kevin is himself a walking stash of wisdom.
with what I saw just now, I would agree with that
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
the "fill in the blanks" is the hard part lol
13:13
I wonder how many nested tags it takes to make that code's runtime explode due to excessive string copying
Probably too many to be worth worrying about, but I'm still curious
same an any recursion? the 1000 limit?
I am aware there is some line you can add to change it, but the default is around 1000 from what I last saw
Yeah, it will crash at 1000ish. But perhaps you could build a nested dict whose maximum depth is 999, and fill every level with a bunch of keys/values
If the dict can have duplicate references, it wouldn't be too hard to execute a billion laughs attack
d = {}
for i in range(12):
    d = {'h': d, 'a': d}
result = xmlify(d)
print(len(result)) #57330
Change the range argument to 100 and there goes all your RAM
was 12 some carefully thought out number or just trial and error?
Trial and error. I picked it because print(result) outputs half a monitor's worth of xml when range's argument is 12.
Big enough to make the exponential growth fairly evident, small enough that it won't lock up your console while it prints a ton of text
the element tree library in python is not what I expected it to be
13:24
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
do anyone can help me with this .


how import env variables from Json to bash?

file1.json
env.email_user="[email protected],[email protected]"

file2.sh
echo $email_user
"SettableValueOrException" lacks the certain something...
ah
could call it Enum or something if that was your only peeve.
well..but that would be a lie
13:33
Hm, I could live with AsyncResult[T, E] for sure...
Maybe CallResult, although that doesn't entirely do it justice because the result/exception don't actually have to come from a function call
@ansh1 Sorry, I don't think any of us know bash.
@Kevin ohh okay , Thanks
@Kevin How I wish that were true...
@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
13:37
I will note that env.email_user="[email protected],[email protected]" is not valid json
Whatever your file1.json is, it's not JSON, by the way. ^Kevin'd
@Kevin Its stored in Json format only I just pasted the line which i need to use in bash file
Pretty sure that line you posted can't ever be a part of a valid json file. Not even inside a string.
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
:53690956
{
    "env.master_name":"admin",
    "env.user_emails":"[email protected],[email protected]"
}
13:46
Ok, I'm guessing you didn't "trim down" the file exactly, because there's no "=" in there, but there was in your earlier message
In want to print user_emails in a bash file
@Kevin sorry
It's fine to try to write a compact example file from scratch, but, again, it needs to be syntactically correct
By asking for help in the bash room, probably. Definitely not by asking for help here, though
"but nobody is in the bash room :-(" is not a good reason to ask bash questions in here, btw
@Aran-Fey I already asked but not got any response
13:51
got em
@ansh1 These should be of more help than what we can provide here: stackoverflow.com/questions/1955505/…
Bonus points for the top answer invoking Python from bash. 🥳
@MisterMiyagi Thanks I am checking it
cbg-afternoon
hello I have a major coding issue.. can anybody assist me here?
13:59
If it's a Python question, sure
its a python issue in combination with binance how can I get the code over to you to have a look see?
pastebin is a popular approach
right walk me through it. do you want the entire code or just the section that is error prone
An MCVE is best, but if I have to choose, I'd prefer the entire code
so be it ? give me the pastebin link i send the entire code
14:07
Ok. pastebin.com. It's going to be visible to everybody, btw
no worries
just want the darn thing working and those that know what to do with it good on em
ok iv pasted it to paste bin whats the next thing i do ?
hello a little help here never used paste bin before
post the link to your pastebin here
all i did was paste the code so how do i post the link please
I suspect you are playing a prank on us, because this has never happened before
no pranks here i have never used past bin
14:20
I assume the same is true of hundreds of people that have come in here, and figured it out anyway
do i have to login in register etc ???
After submitting your code, just copy the URL from your browser's address bar
give me a while i need to work this out
the url is so short i dont think its even linked to my code
14:39
If it has some random letters and numbers at the end then it is
14:50
see this is why the rep limit should be a 100
finally guys think i got it?????
Yeah ok, that's way too much code. You're gonna have to trim that down, and also explain what your problem is
Ok. I'm guessing your code doen't really start with "Skip to content" but I'll ignore that for now. What problem are you having with your code?
the problem area is from 93 to 111. I can successfully connect my account... how ever
when trying to fetch account info its a problem
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
14:57
opps
the guy is hard to get in contact with
but as i was saying the code is refusing to retrieve and display the amount of BTC within the account. thus the rest of the code falls apart.
> only use this code if you know what your doing modification required
ain't that the truth
@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
Show us error messages.
15:09
i dont want a rewrite i just like to know why Im having this issue
let me boot up and provide some error messages
Make sure it's a useful error message and not some rubbish like "failed to fetch info"
generating binance client... success: generated binance client
really?
fetching account info.. error: failed to fetch info
15:28
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"
I guess it does what it says on the tin... kinda?
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.
That isn't a traceback @Randolp. You're not making this easy for people to help you here
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
15:39
im screwed my heads hurting already
Log file? What log file?
Pain is weakness leaving the body :^)
I admire your patience Kevin, but sometimes I also wonder if it is not wasted effort
@Aran-Fey Oops, I misread the code. I thought some of the print statements were being redirected. But no.
@Hakaishin I wonder that quite often, myself.
15:43
IDE traceback coming up
Does your output have "ticker is set to <something>" anywhere? If so, what is it set to?
Umm, that traceback doesn't match the code on github. I don't see run.py anywhere in there.
changed the name.py
trying understand the Does your output have "ticker is set to <something>" anywhere? If so, what is it set to?
Part of the traceback says info = client.get_ticker(symbol=tick+"BTC") in pump.py
what is tick defined to
It's also on line orig_value, precision = get_ticker_info(client, tick) in pump.py
let me boot up and search
15:59
It's already in your code, @Randolp. I can't link a specific line from your pastebin but all you did was copy the source code: github.com/Gregory-Eales/crypto-pump/blob/…
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
Are we starting over from the beginning?
I don't feel like we're going to make progress on this one
It's almost lunchtime so I'm more likely to simply give up
do you think using the pretty tables effected the process
Please answer my question before asking questions
16:03
in the example it shows it working perfectly for George however .....
I see, you're ignoring me. I guess I'll go to lunch then.
sorry i was loading up the code
go for lunch then come back I be waiting sorry
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
thanks for knocking all hope and potential out of the box
17:23
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...
17:36
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...
That's exactly my situation. I've made a really small change, the run time has exploded and it's not taking off any more. <hits the panic button>
Have you checked the gyroscope?
Ahh, of course... Gimbal lock. Genius!
amdgpu-pci-0008
Adapter: PCI adapter
vddgfx:      875.00 mV
vddnb:         1.10 V
edge:         +26.0°C  (crit =  +1.0°C, hyst = -273.1°C)
and still never quite worked out what that's showing me... mind you - looking to buy a new not rubbish computer in the new year anyway...
and I certainly wouldn't be worrying about that 0 Kelvins was bad for it as I'd be an icicle anyway...
Nah, you still have 0.05 to play with. You'd be running on a dream machine
You might have liquid helium crawling up the sides of the case due to superfluidity, but that's a feature. Just make sure it's lit up in blue
17:59
so a semi-transparent chasis that has glowing red lights around the fans and blinking orange lights on the mother board... not good? :p
I mean, red is good... it's just not blue-good
Laptop back to taking off again by turning off my new feature. Curious...
sounds like "fun"
Do you have a tool to monitor your fan's RPM? Noise doesn't necessarily correspond to speed
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
18:36
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)
 
1 hour later…
19:47
been awhile, cabbage folks
this is puzzling me, not sure why this doesn't work as expected (using the itertools grouper recipe):
ex = ThreadPoolExecutor()
for g in grouper(range(100), 30):
    ex.submit(lambda: print(g))
ex.shutdown(wait=True)
What is the expected/unexpected behaviour?
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:
(0, 1, 2)
(3, 4, 5)
(9, None, None)
(9, None, None)
then at a different time I see maybe
(0, 1, 2)
(6, 7, 8)
(6, 7, 8)
(9, None, None)
(multiple threads printing is not the issue here btw, same happens if I print with a lock)
it's something weird about iterables and closures
Rewinding a bit, I don't see threads in the itertools recipes
ah, I meant the grouper() function is from itertools recipes
Ok, so now we're purely at the mercy of threads. That narrows down the search a bit; why are you threading this?
19:59
not really relevant, but I'm batching things into separate network requests which run in the pool
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
yeah---its definitely threading that is the issue, the grouper recipe of course works fine.
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)
yes. I'm not having trouble coming up with a solution to the problem, I'm struggling to understand what the actual problem is
My guess; you're submitting every chunk to every thread and it's just a race to see which replies first and gets its stdout medal
20:03
omg the lambda binding
I TOTALLY forgot about that
As did I :/
carp, I didn't mean to delete that
lol
well, at least not the 2nd half. I was wrong about the tuple(g)
Yeah that part seems unnecessary
20:06
/r/confidentlyincorrect
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?
what is the right terminology here?
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
@AnttiHaapala that summary works for me!
thanks everyone
@alkasm technically it is true for any functions inside functions.
20:13
Right, I could have bound the value with a default arg in an inner def f(g=g)
that works for lambda too, one common trick.
you can even use named-only args for that...
but yea I think it is somewhat of a deficiency...
why not just have a specific way of binding "this 'argument' is not an argument at all"
@AnttiHaapala you mean like CPP's capture list?
20:36
@alkasm sorta yes
 
2 hours later…
22:23
@FélixAdriyelGagnon-Grenier some fun in PHP there :P 12 flags is the most I've seen to date! :P
yeah... apologies for the noise.
Meh, it's not for you to apologise. I just sensed gossip, if anything
Hopefully a part of communication did reach them, and next time will be better :)
hmmmyeah, I do like me some gossip from time to time :D
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
huh, I have partial bits of knowledge about that but wasn't even aware of the flags, in fact.
I do think I know that if, as a RO, I do flag it will insta ping every diamond moderator in the network
22:30
Huh, then you know the reverse process of what I know :)
:)
... that being said, I'll need to work a bit and go get that 10k...
But, yeah, that's the only reason I went to PHP to get the goss - the flags gets distributed everywhere
huh. I wonder what room has the more such drama. My money's on Android, or like, the lounge ducks
C++ lounge, probably, but without it getting flagged
23:06
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.
23:20
confirmed, it does cancel the task

« first day (4084 days earlier)      last day (1089 days later) »