« first day (3162 days earlier)      last day (1802 days later) » 
00:00 - 18:0018:00 - 00:00

12:32 AM
@roganjosh @Code-Apprentice @MarkTolonen Thank you all for the tips. I've pasted in my CSV now. I'm in no hurry to receive answers, but one commenter seemed dismissive when I was unable to edit my post immediately, so I'm anxious to pester them.
 
1:19 AM
# Get the bearer token - see https://dev.leanix.net/v4.0/docs/authentication

response = requests.post(auth_url, auth=('apitoken', api_token), data={'grant_type': 'client_credentials'})

response.raise_for_status()

access_token = response.json()['access_token']

auth_header = 'Bearer ' + access_token

header = {'Authorization': auth_header}

can anyone converts to c# this following code
 
 
3 hours later…
4:39 AM
sorry, converting code is out of scope for this room, since most of the people here know Python, you can try to put this on Stack Overflow as a question though
 
6:15 AM
@Code-Apprentice NIT: pip isn't a package manager, it's a package installer.
To answer the survey: I tried to use pipenv, didn't like it, and am now porting our companies libs to poetry
If your project is simple, managing dependencies by hand is ok. Write direct dependencies into a setup.py file, so that they will be installed along with the project. It's also a good idea to keep a lockfile around that can be used to replicate specific environments. That's what pip freeze puts out. Conflating the two is a bad idea that will turn dependency management into a major headache with no gain whatsoever.
 
6:59 AM
conflating a lockfile with direct dependencies, that is.
 
@Arne nit: nit isn't an acronym :P
 
Morning guys, how would you get the value(s) text with selenium chrome driver : <input type="text" value="NMZC3BW090" size="14"> ? The xpath is /html/body/form/table[2]/tbody/tr[3]/td[7]/
 
Like that, probably?
 
@AndrasDeak I thought about a good acronym for NIT for 5 minutes now, I give up
 
@DeveshKumarSingh that doesn't really answer the "why", now does it?
 
the questions was asking for pros and cons, which might be considered an opinion based question, the other question about what super does is addresses in the dupe
 
8:00 AM
cbg
 
stackoverflow.com/questions/56575351/… Typo, which the OP identified and self-answered
cbg
 
@DeveshKumarSingh Haha nice new reason
 
@DeveshKumarSingh That's not a typo. It's a slightly odd question, but I see no good reason to close it, at this stage.
 
@PM2Ring aah okay
 
Not a typo, but an awful question nonetheless. What are they even asking? There's no question, just an error message that's as clear as it possibly can be.
 
8:10 AM
@Aran-Fey My guess is that they want to convert strings in that field to int, and if they get an empty string it should be converted to zero. But yes, they should state that clearly in the question, and not expect people to be mind-readers.
@DeveshKumarSingh Typo questions get automatically deleted, if they don't have a positive scoring answer, or accepted answer. So telling the OP to accept their self-answer is counter-productive.
 
Then the question would basically be "How can I write an if statement?". I say nuke it from orbit
 
@DeveshKumarSingh As others have mentioned, it's great that you're looking for stuff to close, but you should consider joining SOCVR. We don't want room 6 to be dominated by close votes. We mostly concentrate on stuff that needs to be closed promptly so it doesn't attract a bunch of low quality FGITW answers / dupe answers. We also close typos so that they don't get answers which will block the auto-delete process.
 
@Aran-Fey erm, it might be an XY problem of the kind "How do I do what attrs does?"
 
Well, no point guessing
 
@Aran-Fey Well it's closed now. I guess his expectations are too high: "I'm trying to convert it correctly based on a typing.namedTuple". He just needs better conversion code that accepts default args. But he's not communicating well in the question or the comments, so I have no strong desire to help him. ;)
 
8:28 AM
melting cabbage
 
@DeveshKumarSingh BTW, I'm not asking you to stop participating in room 6, or to completely stop posting cv-pls requests here. I'm just asking you to post the more generic close requests to SOCVR. Stuff that fits with what I mentioned earlier is welcome here, especially if it requires Python knowledge to evaluate it correctly, or requires the dupe hammer.
 
8:43 AM
@PM2Ring so the more appropriate requests here will be dupe questions, and questions with a glaring typo although the rulings on sopython.com/wiki/cv-pls are somewhat broad, so sometimes i get confused what is relevant here to post as cv-pls or what's not
yes I did join SOCVR yesterday and posted few questions tehre
 
In principle anything is fine but at one point you're becoming noise yourself.
> Avoid using scripts or bots that generate mass requests. Flooding the room with requests, especially ones that looks like a script generated them, does not leave a good impression for others joining the room.
sort of the same spirit
It's not explicitly in the rules because some things are left to everyone's best judgement. Obviously this is a mistake.
 
@AndrasDeak yes I got the corollary, this can be considering flooding with cv-pls requests, I will be more cognizant of what I tag in the future
 
9:26 AM
I need some help with plotting. say I have a list of characters char = ['A', 'C', 'C', 'T','G']. I also have a plot that contains peaks corresponding to the list. Is it possible to plot this list of chars above the given plot?
 
What do you mean exactly? Do you want to use the characters as "x" values?
Or do you just want to set these characters as ticks and ticklabels?
 
not as x values but something like this
 
@Starter Why are there 2 of 'C'?
 
there can be any number of those characters
it can be AAAACCGGGAATTTTAACCG
 
You have a lot of figures there, which ones do you mean?
the first one has a legend, the others are different
 
9:31 AM
the first one is my current plot. the other 2 is how I want the list at the top of the plot
 
good old DNA...
 
lol
 
if you don't want actual ticks you can probably hack it by using the letter positions as tick positions, disable the drawing of actual ticks, and setting the letters as ticklabels, on the top of the axes
 
hmm not sure how
 
have a look at the matplotlib text intro: matplotlib.org/3.1.0/tutorials/text/text_intro.html
 
9:34 AM
so setting the labels at the top of the plot?
 
yeah, either labels or free-floating text
using labels gives you alignment and such for free, but free text makes it easier to do custom formatting
 
awesome did not think about that. let me take a look
thank you
 
seeing how your spacing is not uniform, I recommend going for text
 
9:36 AM
>>> import matplotlib.pyplot as plt
...
... fig,ax = plt.subplots()
... ax.plot([1,2,3], [-4,5,-6])
... positions = [1.5, 2.7]
... chars = ['F', 'OO']
... ax.set_xticks(positions)
... ax.set_xticklabels(chars)
... #ax.xaxis.set_ticks_position('top')
... plt.tick_params(axis='x', top=True, labeltop=True, bottom=False, labelbottom=False, length=0)
...
... plt.show()
if you want to draw the actual ticks you can use the commented line rather than the tick_params line
 
oh okay nice. I am just getting into graphing with python
 
10:11 AM
I find dupes of these kind rather unsatisfying
copying mutable data structures is usually just the Y of the X people need solved
 
cart2sph(*-vecz) # kinky
@piRSquared I'm sure you'll appreciate this ^ short-hand
 
10:24 AM
@MisterMiyagi Agreed. I guess we could ask the OP why they want that very redundant list of dictionaries...
 
Welp, that didn't take long... It's only the 2nd time I'm actually writing a program as a job, and I've already been bitten in the butt by my lack of VCS usage
 
version control system, like git
 
oh
gotcha
 
Made a ton of changes only to undo half of them a day later... would be easier if I had made some commits :/
 
10:28 AM
or name them file1.py file1_backup.py etc
 
@Aran-Fey why don't you use git?
 
I am using it - I'm just not using it enough
 
ah
I've started gathering WIP commits with "squash me" messages just to be able to look back at previous non-working versions...
I don't even remember what those states were but it gives me comfort :D
 
My last commit was a week ago - the program only had half as many lines of code back then :D
 
10:46 AM
I'm looking for people that are willing to help out the PSF by reviewing submitted jobs that will appear (or not) on their official job list on python.org/jobs
9
 
pinning that for visibility
 
please ping me if interested, I can do a walk-through, provide necessary access to python.org and its related jobs mailing list. Thanks.
@Andras ty
 
11:12 AM
Hi there :)
someone working with pytorch and cuda?
RuntimeError: cublas runtime error : the GPU program failed to execute at C:/w/1/s/tmp_conda_3.7_044431/conda/conda-bld/pytorch_1556686009173/work/aten/src/THC/THCBlas.cu:259
I got installed cuda 10.1 and a Geforce GTX 1060
 
try looking at github.com/pytorch/pytorch/issues to see if someone faced this error before
 
thx, seems like a lot of people have this problem, but there is no solution
 
12:05 PM
@Arne @Arne thanks, but i use windows :)
 
12:19 PM
@JonClements vaguely interested, please
 
12:34 PM
maybe add the guideline link here too wiki.python.org/moin/PSF%20Python%20Job%20Board/Reviewers
 
12:49 PM
Question. According to the docs,
> A class definition is an executable statement that may use and define names. These references follow the normal rules for name resolution with an exception that unbound local variables are looked up in the global namespace.
Why is this useful? I'm struggling to think of a practical use for this quirk in the name lookup logic.
 
What would the behaviour be without that quirk?
I can't tell how that's different from the lookup of global names in a function
 
Without the quirk I would expect it to raise an UnboundLocalError, the same as when you try to use an unbound local variable in any non-class context.
 
@Kevin what will be an example of an unbound local variable inside the class
 
oh, so it allows print(x); x = 3 when x wasn't locally defined yet?
 
    x = 1
    class Foo:
        x = x + 1

    print(Foo.x)
 
12:53 PM
As an example, compare these two blocks:
a = 1
def foo():
    a = 2
    class Bar:
        print(a)
        a = 3
foo() #prints `1`

z = 4
def qux():
    z = 5
    def troz():
        print(z)
        z = 6
    troz()
qux() #crashes with `UnboundLocalError`
 
hmm
 
@Kevin I have a hunch the answer is "historical reasons"
 
The answer is probably obvious, if you're Dutch. ;)
Pity Martijn isn't around much these days.
 
1:08 PM
Strangely, I don't see this behavior mentioned in the 2.7 docs. But my example produces the same output in 2.7 and 3.X.
 
A slightly facile answer is that during the definition of a class, the class doesn't exist yet, so it can't have a local scope, and so locals() falls back to being a reference to globals(), just like it is in the module-level scope.
 
Well, it's possible to have x = 1; y = x + 1 inside a class body, so I don't think it's literally true that a class' locals() is identical to globals(). But I do think it may be a productive avenue of inquiry to consider the other ways that class scopes behave differently from ordinary scopes
 
the class' locals is its namespace from __prepare__
 
IIRC, abarnert wrote an answer on the topic, but it focuses on how scope works in a class definition, rather than on the rationale of why it works that way.
 
@Tweakimp my condolences ^^
 
1:25 PM
I suppose this is the canonical scope question, but some of the info is out of date, and the answers don't really go into the rationale.
 
Rationale might be opinionated
 
@AndrasDeak True, and speculative, unless it comes from a core dev, or quotes the relevant PEP.
 
Currently trying to determine whether the pdf linked by stackoverflow.com/a/56581444/953482 has any useful information about my query. I'm not too hopeful because I think the author is making up their own definition of "frame"
 
"the parent of an object has to be an object frame"
making up definitions might be an understatement
 
@AndrasDeak cute. way to splat your vector.
 
1:45 PM
I would like to get a better understanding of how actual execution frames work. I don't think the docs go into much detail though. Too much of a Cptython implementation detail maybe?
 
Probably easiest to tinker with inspect.stack() and dir
 
woo hoo - off to see Billy Joel on the 22nd - brother managed to get some tickets - so woot
happy puppy
 
user10984358
heya, where would you suggest (docs or links) where one can read to perform video detection using opencv ??
 
user10984358
from live feed (webcam) and training model from scratch
 
@TheNamesAlc pyimagesearch.com
 
user10984358
1:56 PM
thanks @Dodge , do you have any first hand experience of said concepts??
 
class test():
    def __init__(self, some_bool=False):
        self.do_extra_work = some_bool
    def work(self, extras=self.do_extra_work):
        if extras is None:
            extras = self.do_extra_work
        print("work")
        if extras:
            print("extra work")

obj = test()
obj.work()
obj.do_extra_work = True
obj.work()
 
user10984358
not too fancy just to point me on where to go further
 
the above was not valid syntax, but i just wanted to understand why i couldn't pass an arg in this manner?
i settled for this for now:
class test():
    def __init__(self, some_bool=False):
        self.do_extra_work = some_bool
    def work(self, extras=None):
        if extras is None:
            extras = self.do_extra_work
        print("work")
        if extras:
            print("extra work")
is there something i missed?
 
Default arguments are evaluated at function definition time - self doesn't exist yet at that point
 
1:59 PM
@TheNamesAlc For videos, no. Everything I've done centers around photogrammetry in still images or large composited orthomaps.
 
cool, that makes sense. Thanks
that makes me realise i'd have had another issue even if it worked. the default args would be "set in stone" so to speak
 
Re: class-scoped name resolution wackiness. Maybe it has something to do with the fact that class scopes are the only scopes where the name of a local variable "matters". For normal scopes such as functions, you can change the name of a (non-parameter) local variable and the function's public interface will remain exactly the same. But if you change the name of a variable local to a class block, that class' interface does change.
Suppose a programmer is writing a function and thinks, "I want to define a local variable with the same name as a nonlocal variable. But I also want to be able to access the value of the nonlocal. How can I accomplish both?". The language replies "you can't. Suck it up and choose a different local name". This is fine because the programmer's code will definitely still work, it will just be a little uglier.
 
user10984358
@Dodge appreciate the help, thanks again!
 
Meanwhile a second programmer is writing a class and has the same problem. He thinks "I can't suck it up, because my variable has to have this name in order to conform to a particular interface, which I have no control over". So the language replies "well... OK. Just this once, you can define a local variable while still being able to access the value of a global with that same name. Since there's no other way."
 
Sounds reasonable, although it's not like it would be impossible to create a class attribute with the same name as a global
locals()['x'] = x
MyClass.x = x
 
2:06 PM
But even then, this would only partially explain the quirk. It explains why a lookup is performed on the unbound local, but it doesn't explain why it only looks in the global scope, instead of climbing up the chain of enclosing scopes like normal.
 
2:23 PM
Hmm, I wonder if you could do x = 0; class Foo: x = (lambda: x + 1)() if the lookup quirk didn't exist. Lambdas get their own scope, right?
 
Yeah
 
So in a quirkless alternate universe, x would be local to Foo, but lambda: x+1 would still look up the global x because a class' locals are invisible to scopes enclosed by that class.
 
Also local x isn't bound yet?
 
Yeah, although that doesn't change what scopes get looked at
 
yeah, I realized it's probably weird
Have to check
x = -1
def foo():
    def bar():
        print(x)
    x = 42
later to see if it errors (after calling everything of course)
 
2:32 PM
That code runs without crashing, but compare to:
>>> x = -1
>>> def foo():
...     def bar():
...         print(x)
...     bar()
...     x = 42
...
>>> foo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in foo
  File "<stdin>", line 3, in bar
NameError: free variable 'x' referenced before assignment in enclosing scope
 
I'm just lazy on mobile
 
Yeah, I figured you didn't have a REPL handy.
 
Re: class-scoped name resolution wackiness. Perhaps looking at why classes behave differently is the wrong approach. Instead, the question is why *functions* behave differently.
Which is mostly "function locals are a hack to be fast so name lookups avoid slow corner case". That one does not apply to class locals, which are expected to be horribly slow to begin with.
 
Yeah, thanks, Kevin
 
@MisterMiyagi im curious why you paraphrase to a "hack"?
 
2:44 PM
IIRC function local behaviour emerged from an optimisation in CPython
other implementations could do well without it
 
Times like this I wish I understood how closures actually work.
 
very well, thanks for asking
joking aside, what parts do you need help with?
 
I understand them as well as I understand my car. I know how to work the buttons to make it do things, but if i look under the hood I'll probably burn my hand and get bitten by a racoon.
 
@MisterMiyagi on the other hand, you might be right with the paraphrasing. I sometimes struggle with Kevin's mental dialogues :P
 
@Kevin did you ever fiddle around with func.__closure__?
 
2:47 PM
Yes, but not with any confidence that I knew what it was doing.
Half-baked idea: class body scopes don't get "real" closures because they're executed immediately after being defined. Compare to functions, which may execute at some unspecified point in the future.
There are other scopes that execute right away, for example list comps, but none of those scopes can contain assignment statements, so it doesn't really matter how they handle unbound local lookups.
 
Hi guys is there any room for discussing about the IDE Atom?
 
@Kevin IIRC := is allowed in comprehensions
 
Hmm, yeah.
 
???
 
@RaphX ??
 
2:56 PM
@RaphX I don't think there are any rooms specifically about discussing IDEs. But I expect that the typical room would tolerate discussion of IDEs if the IDE is popularly used during development of that language.
In other words, if Atom is a popular choice for Python development, you could probably talk about it in the Python room.
Compare to, say, Visual Studio, which is not a popular choice for Python development.
 
So I can?
 
It's fine with me, unless the conversation derails into "so, how do I enable this C# feature in Atom..."
 
So I was setting a keybinding for executing line by code in atom using platformio ide terminal
 
@Kevin closures work like a mixture of function locals, but with an additional indirection. They reference not the value, but a container for the value. Multiple functions can have different references to the same container.
 
After setting the keybinding its working as expected except that its executing twice additionally(empty lines of code)
It doesn't really create any issue at the moment but it would be good if anybody know about this
 
3:00 PM
def foo():
    x = 3
    def bar1():
        print(x)
    def bar2():
        print(x)
    return bar1, bar2

a, b = foo()
print(a.__closure__ is b.__closure__)  # False
print(a.__closure__[0] is b.__closure__[0])  # True
 
I made the keybinding change in keymap.cson file
 
@MisterMiyagi Makes sense. I did notice some kind of weakref-like behavior the last time I poked around with this.
def qux():
    x = 1
    def frob():
        print(x)
    print(frob.__closure__) #(<cell at 0x01290490: int object at 0x0F9A6460>,)
    del x
    print(frob.__closure__) #(<cell at 0x01290490: empty>,)
qux()
 
You can think of del x as translated to __closure__[index_of['x']].cell_value = empty
the index_of['x'] is done by the bytecode compiler
setting the cell_value to empty is a single Bytecode instruction
 
@RaphX Hmm, can't say I know anything about that. Maybe it's worth asking a question on the main site. It should be considered on-topic there because questions about programming tools are allowed.
 
hi I am getting [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions error in pycharm on Windows. How can I ensure pycharms executes python scripts with admin rights?
 
3:16 PM
@Mahesha999 The first thing I'd try is: right-click pycharm's icon in the file explorer and choose "run as administrator"
That's what I have to do to get Visual Studio to run my C# programs as administrator, so maybe it works the same way for pycharm
 
yeahh
thanks for that quick reply...
I just solved the problem...it was trying to bind to socket localhost:8080
which was used by other process
terminated that process and it ran
but running pycharm as admin will make its venv python.exe also run as admin?
 
If pycharm behaves like Visual Studio, yes. But I don't know if pycharm behaves like Visual Studio.
This advice is more "try this and see if it works" than "do this because it will definitely work"
 
3:36 PM
@Arne thanks for the info
 
I could use some advice on improving an old answer of mine. stackoverflow.com/a/22084672/1394393 I've noticed that the accepted answer is still gaining upvotes much more quickly than mine, but I'm pretty sure that nontransaction database access is ill advised, meaning that my answer should be the correct one in a lot more situations. (There's even a later answer about enabling auto-commit with the accepted answer. Yuck.)
Am I overestimating the importance of using transactions? Is there some way I could improve my answer? I'm concerned that readers are being misled into writing poor code.
Or maybe "unsafe" or "risky" or "not future proof" would be better terms than "poor." I don't know. I've just made a habit of always using transactions with databases, and I thought that was the normal way of doing it.
 
I recommend having a TLDR section for the people looking for just the answer
 
I have a theory that the rate at which an answer receives upvotes is largely determined by its position relative to other answers on the page. You could write an answer one hundred times more correct and useful than the current accepted and most upvoted answer, and you'll still never overtake it despite having truth on your side.
It doesn't matter if your post is a heartbreaking work of staggering genius if the average reader never scrolls down far enough to see it
 
@Kevin I'm not saying that the position on the page isn't important, but I've seen answers overtake accepted ones that recommend bad practice, especially when you're talking about something popular enough where a 6 month late answer can garner over a hundred upvotes despite there being 3 or 4 older competing ones.
 
True, I have seen that happen too. I will backpedal a bit and say that the default state is for the accepted answer to dominate, but this can be subverted in exceptional cases.
 
3:46 PM
Your answer does not deal with flask-sqlalchemy
 
@roganjosh I don't think the question or the original answer does, either. Do either of them work with it?
 
That's why it doesn't have the majority of upvotes. db. is for a database registered on the app
Your scoped session is abstracted away with flask-sqlalchemy. result = db.engine.execute("<sql here>") is implicitly using the flask-sqlalchemy wrapper
 
@roganjosh That would certainly explain it. Thanks. I've never used it.
 
If an accepted answer is actively wrong or un-idiomatic, then it can be toppled. But a merely mediocre accepted answer is hard to unseat.
 
hey, jpmc26
 
3:50 PM
Hello.
 
@jpmc26 mega brief overview: dev.to/nestedsoftware/…
 
I guess my bottom line is, don't feel bad if your answer can't keep pace upvote-wise with the accepted answer, since it doesn't necessarily mean your answer is flawed in any way.
At the same time, striving to improve your answer is a worthwhile goal even if your upvote rate won't climb as a result
If I had a nickel for every time I got four upvotes for posting a subtly wrong answer, and then got zero additional upvotes after I corrected it... I'd have like 30 cents at least
 
Are you addressing somebody, or just the room in general?
 
I'd add that you can always link to your answers when closing duplicates at a later time
 
3:56 PM
This is in relation to jpmc26's problem but it's something that any SO participant could keep in mind
 
The reward function is delayed, but it is there
 
I'm not sure why this discussion keeps going when I pointed out the reason for the discrepancy in upvotes :/
But I'd like to join in too. Upvotes seem to be inversely proportional to the effort I put in on a problem
 
@roganjosh This is especially true when you consider the amount of effort that goes into closing a question you don't answer.
 
@roganjosh It's because my train of thought doesn't change directions easily ;-)
 
@roganjosh but usually directly proportional to the effort readers have to put into your answer
 
3:59 PM
If you ever feel like you have to sneeze, and then you don't sneeze, and you feel disappointed over your unsneezed sneeze... I have that, except for ideas.
 
unsneezed ideas? sounds messy
 
Ok @Kevin
 
4:54 PM
Updated. stackoverflow.com/a/22084672/1394393 I also included a section explicitly emphasizing the importance of using a session/transaction this time. Thoughts? Further suggestions? Should I bring back any of the content that I removed?
 
I had an "incident" when I was in high school where I sneezed in class and a globular mass of snot landed on my desk. I was mortified and ever since by body refuses to let a sneeze go. Consequently, I hold back my sneezes and have done so for the past 26 years.

You can make an argument that I do the same thing with ideas. @Kevin #KevinsFaultForBringingItUp
 
@piRSquared A less extreme response might have been to start keeping tissues handy. lol.
 
@jpmc26 where were you 26 years ago!
 
Apparently holding in sneezes can, in rare cases, cause harm to your respiratory tract. Since I learned this I've taken to sneezing into the crook of my elbow.
I'm a pretty dry sneezer though so I don't have to worry about globs of anything going places they shouldn't
 
in other news, looks like PCG got a new makeover
 
4:58 PM
For anyone what joined the conversation about dependency management yesterday, I found pipdeptree that seems to be a good solution for my purposes. It can output a requirements.txt file that is indented to show the tree structure of dependencies. So I have a lock file and can easily determine my top-level deps.
 
@jpmc26 I've edited the question title. I think your answer is good.
 
Has PCG changed their policies at all, in addition to their visual update? I heard some grumbling to that effect.
 
Second Law of SO: Post Score ~ 1 / Poster's Pride in Post
 
Question asker last seen in 2015. Guess there's no point in pinging them to reconsider their accept.
 
Hey! nice use of last_valid_index stackoverflow.com/a/56585093/2336654
 
5:05 PM
@jpmc26 I wouldn't bother tbh. Half of me expects my edit to end in a Meta post due to the popularity of the post, despite actually correcting the ordering of the title
@jpmc26 Oh! I just realised the top answer is by Miguel. He's the author of the Flask Mega Tutorial. That easily swings votes in his favour, he's possibly directing people to that post.
 
That would not bother me if the answer were good advice. The fact it's not makes this situation bother me even more. I left a comment pointing out the transactional issue on the answer some years ago. I don't know for sure if he ever saw it, but nothing ever came of it.
 
@piRSquared a prev answer of yours reminded me of its existence :P
@jpmc26 a technique I see lot of answerers use to good effect (but that I don't condone) is using your answer to explain why another answer should not be used. Your answer only seems to dive into something but it isn't apparently obvious why I should choose yours over the accepted answer. But that might be my ignorance in the tag showing.
note that "personal preferences" are usually taken with a grain of salt by anyone reading them
 
5:20 PM
@cs95 it goes by many names but PCG is not one
it used to be PPCG, now it's CGCC
 
I know it by "PCG" because those were the letters inscribed on the site icon as I saw it whenever it popped up on the HNQ list
but noted, ty
 
@cs95 Even after my edit? The paragraph after the first block of text explicitly calls out the other two answers (via links) and expounds on the importance of transactions. Granted, I'm not spending a lot of words saying exactly, "These answers are wrong!" But I'm definitely explaining why this one is preferable.
 
Hmm, that sounds more like a good word of advice, rather than a critique of the other two.
I would leave it at that but if you really want to take swings at the other answer, you'd need to call them out more explicitly
following a discussion I had on meta about posting comments under the question, you may also consider leaving one explaining that the accepted answer has a critical flaw that your answer <insert link here> addresses.
 
No, I don't really want to. I think pointing out the problem is important, but I don't want it to make it that personal when I can avoid it.
I'll give it a couple years and see what happens.
 
@cs95 I added my own answer... I'M DONE SOing FOR TODAY! I SWEAR! stackoverflow.com/a/56585711/2336654
 
5:27 PM
careful, I can feel disapproving stares burning into your messages :p
 
Thanks for the help all.
 
@Kevin your last example for unbound local class variable confuses me: stackoverflow.com/a/56580571/5349916
it seems that del is trying to delete the global name a
the error for deleting an unbound local variable would be a regular UnboundLocalError
 
That is indeed strange. I was under the impression that del can't delete nonlocal/global variables unless you explicitly mark them as such with the global or nonlocal statement. I need to look into this further.
The somewhat unsatisfying explanation is that docs.python.org/3/reference/simple_stmts.html#the-del-statement declares by fiat that a NameError should be raised if the variable is unbound. If this rule is followed strictly, a NameError ought to occur regardless of whether the unbound variable is local or global.
This does not explain why it's being declared by fiat, but it seems like a lot of that is going around lately.
On second thought... This fiat isn't obeyed in all contexts. For example, this code raises an UnboundLocalError and not a NameError:
def f():
    del x
    x = 1
f()
 
5:45 PM
hello can anyone help me with an issue in python and flask
 
Hello. What is the problem?
And I immediately realise I sound like a help-desk :/
 
when I run the sudo python __init__.py I get this
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
but when I go to 0.0.0.0:5000 it shows site cant be reached
I am a noob to python and flask
 
Because it's on your actual IP address
You're serving it over the local network. To access it, you need to find your own network IP address and substitute that for 0.0.0.0
 
how can i do that?
 
ipconfig in Windows cmd or ifconfig in Linux.
 
5:48 PM
for mac ?
 
I don't talk about macs
But you need to find your local IP address
 
ok i got my ip address what command should i run ? my ip is 54.606.8.2
 
I notice that DELETE_FAST can raise a PyExc_UnboundLocalError, whereas DELETE_NAME can raise a PyExc_NameError. The code example I just gave uses DELETE_FAST, and the del-within-a-class example I gave in my answer uses DELETE_NAME.
Currently trying to make sense of the distinction between these opcodes with the help of docs.python.org/3/library/dis.html
 
That seems unlikely. 192.168.x.y or 10.some_stuff_here
But, in any case, you open your browser and go to 54.606.8.2:5000
The :5000 indicating the port. The default for Flask is 5000
 
DELETE_NAME deletes the_code_object.co_names[some_idx], and DELETE_FAST deletes co_varnames[var_num]. Unclear to me how that's meaningful since neither example uses arguments so I'd expect co_names and co_varnames to be the same.
 
5:54 PM
this is my local ip 192.168.0.202
 
so open a browser, not IE because that's poop, and go to 192.168.0.202:5000
 
now when i run it like this 192.168.0.202:5000 i am still getting the same error
 
... But now that I actually look at the co_names and co_varnames of my functions' code objects, I see that they are actually different. I am baffled.
 
What error?
 
my server is running on digital ocean
i am getting site cant be reached
 
5:56 PM
That.... would have been useful info to start with
 
what should i do now @roganjosh
 
Well, I don't really know because you clearly haven't explained the issue very well
Have you ever tested the app locally?
 
locally it is working fine
 
Ah, apparently co_names is not a tuple of local variable names as the documentation suggests, and this is a known issue that has been very slowly undergoing the PR approval process for the last two years
 
Ok, and what server are you using for your app on digital ocean?
 
00:00 - 18:0018:00 - 00:00

« first day (3162 days earlier)      last day (1802 days later) »