« first day (2834 days earlier)      last day (2115 days later) » 
02:00 - 20:0020:00 - 23:00

2:55 AM
is there any website for sharing interactive python?
i am trying to use trinket but the sqlite table isn't working
 
3:11 AM
replit
 
 
3 hours later…
6:27 AM
Good morning :)
 
 
1 hour later…
7:47 AM
cbg
@MartijnPieters halp, is this really how Guido's name is pronounced? Is it really close to [Hido]?
 
8:03 AM
How should I name a method that changes an object's state if it isn't in that particular state yet? Like client.login_if_not_logged_in_yet(). Is client.assert_logged_in() ok?
Or maybe just client.login()?
 
8:31 AM
I would stick to client.login
 
I think .login() is fine but I'm not an authority
 
Alright, thanks
 
cbg
 
8:53 AM
Um, how is possible that an import statement fails in a script but works from the command line? Traceback here.
 
Print something about it to be sure?
 
C:\Users\Rawing>python -c "from gfycat import GfyCat; import sys; print(sys.modules['gfycat'].__file__)"
C:\Users\Rawing\Desktop\folder\coding\python\gfycat\gfycat\__init__.py
checks out
 
Cabbage
 
cbg
I can't work out why it's looking at python27.dll
 
Guys , we are trying to hire a good python dev , I am not in a position to be interviewing someone but since we do not have anyone else who is good in python ,Can you guys suggest some good practical python interview questions
like "can you modify a list inside a tuple.." This is a good question.
I mean if I take questions from the internet the candidates will probably also be reading those anyway.
 
9:02 AM
Well, asking about PEP 572 might be topical since it would show whether they follow the language
 
Hahaha
Too rough dont you think.
 
Well, I wouldn't expect them to be able to use the syntax but if they don't know about the latest development that has split the community then they're not really invested in the language
 
But , I think I will ask what is a " PEP"
Good point, Noted!
Guido will be missed! his tweets mainly but yes as BDFL too.
 
@roganjosh I had python 2.7 installed at some point, and somehow some python2.7 directories made it into my PYTHONPATH. I removed those, but for some reason it's still trying to load them
 
9:08 AM
cbg
 
9:19 AM
ok, well, for some reason I had a unicodedata.pyd file lying around in the same folder as my script... deleting that fixes the problem :/
 
@roganjosh are you sure that's a good measure of a good programmer?
I don't think most people actually using python live on the bleeding edge
 
jjj
but maybe they bleed on a living edge? who knows
 
I agree, most people I have worked with, don't even know the version of Python they have learnt :-/
 
@AndrasDeak I agree.. I think many dont care about it as much as a few of us do , just because of the love for the language.
 
And their fulltime role is as a python developer? They don't know what version they use?
 
9:30 AM
it's not like I'd expect a C++ dev to take the newest issue of the standard with them to the toilet (to read, I mean...)
 
Just recently, I was like yay guys python 3.6 is out and no one in the team cared.
 
now you can try again with 3.7 ;)
 
I guess it's very far removed from the engineering interviews I've had in the past where I absolutely had to be on top of latest developments
Then again, they had to find stuff to fill those 8 hour slogs of an interview :/
 
Hmm interesting , which tech were you into?
 
This was for Chemical Engineering
I had a past life :)
 
9:35 AM
Well, that field is not changing as much as tech I assume. so the requirement to know the latest would have been fairly justifiable?
@roganjosh your name resembles an Indian curry I once had. Exceptionally delicious
 
mm, debatable. But you had to be subscribed to various publications to keep on top. This was for consultancy and you really can't be seen to not know what you're talking about
 
Interesting.
 
I failed one 8 hour interview for putting my hands on my face and what's more, I knew it immediately, we could have just called it a day but they kept going
 
@roganjosh 8 Hour interview??? Holy mother of god. What kind of job is that?
 
I did hear of someone failing a PWC interview for shuffling their feet too much. It's a different world
Engineering contractor. If someone's going to give you £100m to build a plant, they kinda expect the people building it to get it right :)
 
9:43 AM
Eeesh, huge stakes..
must be nerve wrecking
 
It wasn't just an 8 hour discussion. I had to give a presentation, write an essay about centrifugal pumps (fun), some good-cop bad-cop questioning about what a section of legal jargon meant in one of their contracts (this is the part I failed)
Basically, the bad cop continually told me that I was wrong no matter what I said and then gave the "correct" answer which was often very similar to what I had just said, while the other guy was agreeing with me. I ended up losing my cool.
 
Understandable.
 
That was the point of the test, though :P
 
 
4 hours later…
1:22 PM
\o 4 hours later cbg.
 
My beautiful room sixers. Good day.
cabbage for all
 
I implemented two steps of this algorithm in the wrong order, and now it works wrong, but only 1% of the time, and only when the user passes in some truly weird input, and it would be a lot of work to fix it... I feel like this is how vertebrates got designed. "I could move the optic nerve so it doesn't occlude this bit... Meh, I'll ship this batch and implement that on the cephalopods"
 
The Blind Spot design principle
 
can you filter the user input so it wont accept truly weird ones?
 
1:34 PM
"Yeah, the laryngeal nerve hooks around this bit in the chest cavity, which is a bit roundabout. But that's fine as long as the client never requests, I don't know, an animal with a ten foot long neck. But who would ever need such a thing?"
@MooingRawr Yeah, actually. Maybe I better try to detect it and raise a ValueError or something.
 
giraffe owners would like to speak with you :D
 
And the FBI, exotic animal imports division, would like to speak with the giraffe owners.
(unless the owners are properly credentialed, or if they aren't in the U.S., or... This joke was funnier before I started looking up the actual details of giraffe ownership in the states)
(TL:DR it's pretty hard to get a giraffe, but zoos do it, so it can't be impossible)
 
1:50 PM
gosh darn now I'm curious about giraffe ownership up here.
huh seems like my area is pretty tam lame, here's a list of things that are prohibited. dpaste.com/3X8H3J6
 
Googling legal issues and always getting the reply "depends on which state you're in" with no additional information... #justUsaThings
 
due not that there's no giraffe on that list, unless it is listed because I don't know the scientific name of a giraffe
 
> Anseriformes (such as ducks, geese, swans, screamers)
Uh... What was that last one
 
The screamers are a small family, Anhimidae, of South American birds. For a long time, they were thought to be most closely related to the Galliformes because of similar bills, but they are instead more closely related to ducks (family Anatidae), most closely to the magpie goose (which some DNA evidence suggests are closer to screamers than to ducks). The clade is exceptional within the living birds in lacking uncinate processes of ribs. The screamers are represented by three species, the horned screamer (Anhima cornuta), the southern screamer or crested screamer (Chauna torquata) and the northern...
 
Let's see, the sciency name for giraffe is... "Giraffa". Ok then.
 
1:56 PM
not to be confused with my neighbours' kids.
Giraffa belongs to the Giraffldae family... :D
Nvm Artiodactyla are forbidden, Giraffes are an Artiodactyla :\ oh well. TIL
 
I think I just made an OP self-delete by pointing out that they could use json instead of writing their own parser. I'll count that as a good deed.
 
cbg all
 
DSM
Treasure-in-heaven cabbage for all!
 
2:13 PM
o/
how'd your talk go @DSM
 
DSM
@idjaw: well, but exhausting. :-)
 
I've come across an interesting problem in my workplace. We are in a situation where we do not want to use a database server to host some scripts. Instead, we would like to package the server as an executable that can trigger GET/POST locally on the system(localhost) by opening a port and run the scripts that have been packaged with our software. With my prior experience with Flask, I was wondering if it is even remotely possible to do this? Also, is it a good idea to implement in production?
 
stackoverflow.com/questions/28780920/… duplicate, answers are all outdated or redundant
 
I don't think there's anything inherently wrong in publishing software that runs entirely locally on the user's machine, yet uses a web browser as an interface.
... If that's what you're asking
 
I agree
as long as everything is well referenced in the app to navigate through the browser, then I don't see the problem with that.
 
2:18 PM
In my case, we want to interact with a desktop application and not a browser. The whole thing will be packaged as an msi.
 
it’s finally starting to feel like we about to live in the year 2020 https://t.co/8jJ2NXDL4y
The future is now
 
In that case, I question whether HTTP is the best way to communicate between client and server
 
So, buttons on the app will trigger these GET/POST events and run the scripts spread across different folders in the package.
 
What do you guys do for debugging a ResourceWarning: unclosed file? I've set gc.set_debug(DEBUG_LEAK), but the object being complained about doesn't show up in gc.garbage? Maybe I'm misunderstanding how it all works...
 
I don't understand what you mean by "package the server as an executable"
you want to trigger GET/POST calls to communicate with some backend hosted
that would be the server. You are still making a client. No?
 
2:26 PM
morning cabbage
 
yo
 
I'm not well versed in the technicals but I suspect using Flask to get two local programs to talk to one another, is not the easiest way to get two local programs to talk to one another
4
 
@idjaw, this means all my Flask routes will be in one .py file which will be compiled as an *.exe and packaged along with the software. So my server is localhost:port(defined in the Flask exe) and the client is a desktop app triggering the exe routes on button clicks.
 
friday cabbage
 
@Kevin I'm pretty sure that's how jupyter notebooks work
@davidism done
 
2:37 PM
@AndrasDeak, yes I agree, jupyter is exactly like this
 
@MooingRawr magpie goose
 
except it talks to a browser
 
@user8212173 So, you want to make local HTTP calls to your service, and that Flask-based service will process everything locally? Or will it make external calls as well?
 
@idjaw, yes only local calls. This will save us configuring the db and the frontend will be language independent. No external calls will be made to the internet.
 
@AndrasDeak I wonder what they sound like
anyways TIL some coworkers don't share the same love of knowing information. something something about useless information... :\ I don't think there's useless information, just some arent as important to one as to another.
 
2:43 PM
You can't hear it from all your dying
@MooingRawr the shoe size of my neighbour? Useful to you? :P
 
That information will be useful when we do casting/costumes for the role of your neighbor in Andras! The Musical
 
Last 10 digits of pi
 
All zeroes.
 
Last digit of pi base pi is 1
 
How many digits of pi really are practical, when you get down to it? You need like 200 to find the ratio of the diameter and circumference of a circle the size of the observable universe, down to the accuracy of a Planck length. Are there applications outside of simple geometry where it's useful to have more than that?
 
2:50 PM
Honestly it's just more data, if everyone in this room sent me their neighbour's shoe size, I would have a decent party starting line that would include the shoe size of neighbours of room 6
 
@Kevin pi digit world record contests
 
ಠ_ಠ
 
If we convert pi into binary data and see what comes out, I'm sure more length = more things to see , assuming we only view certain section of it
 
you probably know about them, but still
 
That person's coolness level is inspiring
 
2:54 PM
I have already won that competition. I can print every digit of pi to any number of digits. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
The pursuit of some goal "just because" is a very admirable trait of humanity, in my eyes. But I wouldn't consider it "practical" for the purposes of this conversation
 
Goalpost moving alarm!
 
Fight me irl, I'm ripped from moving goalposts all day
 
I want to hear something like "Actually, you need at least 500 digits of pi if you want to use Henderson's Method to find the integral of reticulated splines in 5 dimensions"
Never mind that reticulating 5d splines probably has as much practical utility as tricking out your PC for a pi calculating contest
 
3:01 PM
^ which makes me mine bitcoins faster
 
reading some answers on the [performance] tag makes me very confused on some of the terms, maybe I should go look up a book to learn...
 
Update: I wrote a simple Flask route:
`from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/')
def index():
return jsonify({'result':'Hello World'})


app.run(host='0.0.0.0', port=81, debug=True)`

I packaged this as an exe and ran again, but this did not start the server. Any thoughts?
the indentation is correct as I ran this successfully on my localhost as a py file.
 
what do you mean by "this did not start the server" what happen? errors?
 
The file flask_test.exe ran for a few seconds with a command prompt and then disappeared. No errors at all.
 
cabbage
 
3:15 PM
cabbage
 
cbg
Well, I've misread a question twice in a row. I think it's time to tiptoe back out of that one :P
 
cbg
 
cbg
 
Are all the answer stating "key order in dict doesn't matter" obsolete now with the python3.7?
 
I honestly don't know what he wants as an answer. His code works fine, and if he looked at the documentation it's expected behavior
 
3:23 PM
@T.Nel Pretty much.
 
Well, on the second misread I suggested the approach which would work and then noticed it was already in the question, so at that point I decided I also don't understand what they want
 
> Changed in version 3.7: Dictionary order is guaranteed to be insertion order. This behavior was implementation detail of CPython from 3.6.
From the 3.7 docs. This is tantamount to saying that it's not an implementation detail any more; in other words, you can depend on it acting this way for the indefinite future
 
@Kevin Yes I read that, that's why I asked it. But since I understood it as a consequence of the new implementation of the dict() for performance more than for this behavior, I still use and see dict() as before.
Which is of course wrong, since they added it to the specs
But if i'm not wrong, __eq__ wasn't changed to look at this order right?
 
DSM
Correct.
 
hello, is someone online and willing to help please?
 
3:37 PM
Willing but possibly not able. What is your question?
 
I hope it won't be confusing for future python beginners. Anyway, I guess I won't modify my answer then
 
@T.Nel It probably will be a bit confusing for beginners who see all the old SO answers (and other Python resources) that categorical state that a dict is an unordered collection. And it makes those of us who said that dicts are unordered for performance reasons look a bit silly since the new dicts are both smaller & faster. Damn you, Python core devs. :)
 
@Elimination Welcome, feel free to ask question you have, if someone can/willing to help they will, (as noted in our room "rules" which you can find at the top left) hope you find what you are looking for.
 
@PM2Ring you only have 1690 answers to check and add caveats to :P
 
Rogan are you generalizing again or are you saying PM has 1690 answers with dictionaries in them. :P
 
3:46 PM
It's not like everyone's already using 3.6, anyway
 
Just for anyone trying to compile a Flask server in an exe, use pyinstaller. It works. It runs a local server on the user's machine. cx_freeze and py2exe does not work.
 
Well, unless he can remember the contents of every answer, I'm pretty sure he's gonna have to check quite a lot of them :)
 
@user8212173 good to know, i've seen it work but couldnt help you :P sorry
 
I thought it might be a problem with the py-to-executable library, but I didn't want to bash it without credible evidence
Anecdotally, I've found executable makers to be pretty flaky in general
 
@roganjosh something something SO provides an SQL query, I'm pretty sure we can do something like if answer like '%dict%' or answer like '%{%:%}%' we can find out
 
3:48 PM
@roganjosh Yeah. I thought about doing that, and decided it was just too much work. And my answers are just a drop in the bucket of all dict answers.
 
We room 6 should go through the bucket of answers and edit in the caveats
 
Too complicated, Mooing. I just want to click things with my mouse
 
k so if we write a script that you click to add it will you :D ?
 
Oh for sure. Who's writing the codez?
... kindly respond.
 
"dicts are unordered in Python" is no longer true, but "dicts are not always ordered in Python" is still true, because "Python" encompasses previous versions too
 
3:52 PM
Option2 : We automatically remove every question with tags "python" (elif python-3.7 is also in the tag) if their is an occurence of "dict" in the question or any answer/comment
 
I will write up a burninate-request for
 
In some cases, it would be as simple as just adding a line at the end which says something like: "In python 3.6+ a plain dict does retain insertion order". But in other cases, it will make the answer irrelevant, since the question only exists because the OP assumed that dicts were ordered and their code broke because dicts weren't ordered.
 
I kinda shrugged the idea off because all new (decent) answers are making the distinction but I guess page hits and upvotes for the old answers will still dominate searches
The worst case, though, is that people don't rely on dictionary order, and that doesn't leave them any worse off than we have been for all these years
 
About the __eq__, for which reasons isn't it looking at the order now ? It is looking at it in collections.OrderedDict and seems more reasonnable if you specify that order does matters. (I know it can't be or it would be a mess for old code, it wouldn't be compatible with other versions, but appart from that ?)
 
"wouldn't be compatible with other versions" is a big one. Breaking compatibility is not something the dev team wants to do, after having such a rough time with it during the 2 to 3 migration
 
3:59 PM
Yes of course, but I wonder if we have other reason than practicality
 
In the last couple of weeks I've seen questions from two people (eg stackoverflow.com/q/51386698/4014959) working in the Visual Effects industry. These people are forced to use Python 2 because the industry isn't planning to shift to Python 3 until 2020. See the VFX Reference Platform.
So well-known programs like Maya that have a Python interface still only support Python 2. Some programs are starting to add Python 3 support, but they definitely can't get rid of Python 2 support until 2020.
 
If you think of dicts in the abstract sense of a mathematical mapping between two sets, I'd say it makes sense that their insertion order doesn't matter when it comes to equality comparison
 
Because if it is the only justification, I kind of see it as a roting that can't be fixed
 
@AndrasDeak Yes, in the southern parts of the Netherlands that's a valid pronunciation. I use a harder 'G', and Guido would too, because we are not from those more southernly areas of the country.
 
The earlier one is here. That OP is writing new library code for Python 2.
 
4:05 PM
@Kevin I'm probably just too used to think with collections.OrderedDict as a reference for dict with order and accepted it's behavior as the reference
 
At an extreme level of abstraction, a dict is a function. Consider two functions: f and g. f(1) == 23, and f(2) == 42, and g(2) == 42, and g(1) == 23, and they're both undefined for all other inputs. It seems reasonable to say that f is equal to g. This is equivalent to saying that {1:23, 2:42} == {2:42, 1:23}
 
@MartijnPieters Is it even possible for people who didn't grow up speaking Dutch to pronounce the Dutch "G" sounds correctly? I think I can get pretty close, after much coaching from Dutch friends, but I don't know whether my efforts are accurate, or they're merely close enough and my friends are just humoring me. :)
 
cbg
 
cbg
 
@MooingRawr I think I've just had a better idea. If we make a Meta post asking for a gigantic "FIX INCORRECT STATEMENTS ABOUT DICTIONARIES" right in the middle of the main Python feed, the UI guys will write the code for us just so they can make the button
 
4:13 PM
We could just remove the word 'not' from all sentences that contain at least one word of which 'dict' is a substring and one word of which 'order' is a substring
 
Well, that doesn't leave us with a horrible UI relic, so I guess we could do that too...
 
@Simon Cheers. Yes, moving slowly, but moving. Embryonic pdf output. Need to work on database and gui.
 
Yeah, you've been busy though. I've had notifications ;)
Cabbage all o/
 
cbg
 
@Simon Cool :) feels like I've done little, apart from yesterday, since May. Summer started and...I get more time and mind space at work than at home with my sons!
 
4:25 PM
Laurel.
 
@MartijnPieters interesting, thank you! I'll try to find the other pronunciation :)
 
@Kevin Oh ok, thanks for the clarification !
 
Question on PyGoogleVoice. Im trying to get this example working for making calls However it does not work after installing
 
@Simon Reading in this room, and the thread after Guido stated intent to retire, in comparison with current US and international politics, makes me think the wrong people run the world.
 
It took Guido stepping down to realise that?
 
4:33 PM
@roganjosh No not really, just made me think.
 
First it fails in "from googlevoice.util import input" because input is not in the module. But I have not found any examples that differ from the one in the link. Wondering if anyone has used this module?
 
wim
it looks like the fast OrderedDict went in in Python 3.5.0 and was not backported to 2.7 branch at all, can anyone confirm?
 
Or if anyone knows of another way to make phone calls for free from python that would be cool.
 
wim
or, if there is a 3rd party 2.7 OrderedDict to install, link for that?
 
And anyway, everything is peachy in the UK. Soon Boris Johnson will be PM and all our problems will be fixed.
Our national BDFL
 
4:43 PM
If someone's here is experienced with TLS and scapy I'd be glad if you could help me with some problem I'm stuck with (extracting certificate data)

https://stackoverflow.com/questions/51423507/how-to-extract-an-ssl-tls-message-using-scapy-and-python
 
5:05 PM
Hi all, how can I customize .map() in python ?
Should I pass key-value pairs to .map() ?
 
If you want.
 
From curiosity: is there a method of indentation that's invalid in python?
 
Kevin without that how can I use customize map() ? I want to create new column based on given column in a datafra,e
*dataframe
 
Oh, is this a pandas question? I don't know much about pandas.
 
@roganjosh The one that raises the IndentationError exception
 
5:08 PM
Ok
 
😛
 
I know about mixing tabs and spaces etc. but I'm curious if there is a way of indenting code that uses neither of those that I know nothing about
 
?
I'm not sure I follow what you mean? You either use spaces or tabs. You just have to be consistent with the right type of "space" given for your code to abide by the syntax rules
e.g.
 
You can write a fully-tab-indented program can't you?
 
yes
 
5:09 PM
So my question was whether there was a third method of indentation I'm unaware of other than spaces and tabs
 
newlines
 
Only so I have confidence when I make assertions
(assertions to people asking questions, not programming assert)
 
docs.python.org/3/reference/lexical_analysis.html#indentation says: Leading whitespace (spaces and tabs) at the beginning of a logical line is used to compute the indentation level of the line, which in turn is used to determine the grouping of statements.
 
Newlines result in indentation how?
 
One might interpret this to mean that spaces and tabs are the only characters considered whitespace in this context
 
5:12 PM
most of these will look okay but won't work
 
Huh. It looks like the lexical analysis docs haven't been updated since they changed the tab handling.
 
(not counting the "A formfeed character may be present at the start of the line" stipulation, since you can't just sprinkle that wherever)
... They changed the tab handling?
 
Yeah, tabs aren't converted to any number of spaces now, but the lexical analysis docs still describe the old rules.
 
Anyone have a solution to displaying as binary in matplotlib/mplot3d for the y-axis. When I wrote this question I only wrote it in 2d and when applying the proposed solutions to my 3d problem I continue to get the error "ValueError: Unknown format code 'b' for object of type 'float'". My question "https://stackoverflow.com/questions/51446033/matplotlib-display-axis-as-binary/‌​‌​51446275#51446275"
 
are you also setting integer ticks along the corresponding axes?
 
5:17 PM
correct using "plt.locator_params(axis='y',nbins=number_ticks)"
 
@Number1: Your x axis ticks are floats.
 
You say "I'm attempting to label the x-axis of my graph in binary instead of integer values", but you're not working with integers at all. 1.1 isn't an integer.
 
@Number1 you mean "incorrect"
 
Oops. Honestly didn't notice that.
@user2357112 So then I could just convert them to integers and that would solve the problem?
 
5:23 PM
eh, you should think about you're doing first
you want binaries for a reason, so think about what makes sense in the first place
 
@Number1: I think you need to get a more solid grasp on the mathematical concepts involved first.
 
@AndrasDeak Correct. The funny thing is they are originally strings when checked with type(). So I'm not sure why it's calling them floats in the formatter.
 
tgif cbg to room 6!
 
cabbage to you, @coldspeed
 
cabbage
 
5:35 PM
cbg @coldspeed and to everyone
 
@AndrasDeak the thing I don't get is that I can convert to hex and octal no problem but when it comes to binary it throws errors
 
surely you can prepare an MCVE for such a confounding situation
 
mm tasty MCVEs
 
sure thing :) Create new question about it?
 
When I get an MCVE, the Popeye theme song plays and I punch the problem into the sun
6
@Number1 Yeah, sure
 
5:39 PM
@Kevin noooo hold on
@Number1 Not necessarily, it would be pretty identical to the existing one. We discourage asking for help with fresh questions, and the reason I didn't say anything was that it was either that or you asking a pretty-much-duplicate-with-no-additional-info question on main. So I suggest putting together an MCVE which we can look at. If we're stuck or nobody is around to help you can still ask on main afterwards.
 
@AndrasDeak sounds good. It'll be a minute. Thanks!
 
take your time
 
That works too
I'm pretty forgiving of questions that are only a little different from the previous question the OP asked, because the alternative is typically having one question, where you keep adding "one more thing..." at the end, which isn't a lot of fun for the answerers
Of course, the question still needs to be good on its own merits
 
this is pretty much the same question, I suspect (i.e. an XY problem)
 
@AndrasDeak that's my thought as well as that's why I wrote it only in 2d the first time.
 
5:44 PM
well your question, while as simple as possible, should still reflect the difficulty of your real problem :P
 
5:55 PM
Post code here or ?
 
only if it's a few lines long, otherwise use a code paste service
this is also covered by the room rules, so please read sopython.com/chatroom while we're at it ;)
 
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import StrMethodFormatter

xaxis, yaxis, zaxis = [0,1,2,3,4,5,6,7,8], [0,1,2,3,4,5,6,7,8], [0,1,2,3,4,5,6,7,8]

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

plt.locator_params(nbins=4)

length = 4
ax.xaxis.set_major_formatter(StrMethodFormatter("{x:07b}"))
ax.yaxis.set_major_formatter(StrMethodFormatter("{x:'length'b}"))

ax.bar3d(xaxis, yaxis, zaxis, xaxis, yaxis, zaxis, color='b', zsort='average')
 
OK, I can repro the error
 
Say I look at a user's profile, and browse through some of their answers, and a lot of them are deserving of a downvote. Is it abuse to downvote all of them? OOH, they all deserve a downvote. OTOH, it seems especially targeted, and I'm in a bit of a bad mood because they got rather defensive about some pretty bad code
 
@Number1 which part do you think sets integer ticks?
 
6:01 PM
@MoxieBall I think that kind of thing usually gets reverted by the mods
 
If you downvote enough of them, it will probably get voting corrected.
 
Okay, I figured that was probably the SO MO there.
 
@MoxieBall ask and be answered meta.stackoverflow.com/questions/260840/…
yes, it's OK as long as you really really vote on crap each time; yes, it will probably get reversed anyway because the reversal script can't judge quality
 
I should start asking meta these questions first, mb
 
that one is pretty hard to find, for what it's worth
 
6:04 PM
@AndrasDeak My understanding is that the formatting is happening under the line with "length = 4" and that integer values are set in the lists.
 
@Number1 the formatting happens on the tick values, whatever those are. You need to specify integer ticks first, just like Importance* did in their answer. What you need is a locator
 
@AndrasDeak I'm not exactly following you. I'm not seeing what the locator function provides.
 
Put plt.show() before length=4 and see what tick values you see. Those will get fed to StrMethodFormatter
 
@AndrasDeak Hmm. So it looks like its being fed floats.
 
My point exactly. Not merely floats: 0.5
That locator can give you integers which are the multiples of 1
hmm, but now that I'm testing it I seem to get the same error still...
 
6:18 PM
@roganjosh spoke like a true delegater
 
@AndrasDeak Hmm. I'm seeing the same thing.
 
What does the person who asks the 1,000,000th question tagged get? Running out of time to figure that out.
 
Statistically speaking, a close vote
8
 
hehehe
 
DSM
@Kevin: it's all about whether the OP cares if the numbers are uniform with respect to some distribution, and what that distribution is..
 
6:21 PM
Yeah, I think we're short a couple of pieces of information
 
@MooingRawr I'd have used "manipulator" but, meh :P
 
@DSM If that's for me. Its a distribution of 2^power on the x and y axis.
 
DSM
@Number1: nope, that was about a random number question Kevin was commenting on which I spotted. :-)
 
@Number1 OK, so MultipleLocator sets float tick values, unfortunately. And the rest of the locators seem to return floats. So you might have to convert your ticks to ints yourself :/
perhaps the nicest way is to subclass MultipleLocator...
 
I have a newfound appreciation for the infrequency with which I encounter people who insist that code that doesn't work "really does work, believe me"
 
6:29 PM
@AndrasDeak I've tried that by doing "for i in zaxis: i = int(i)" but then again that might be wrong as it's still seeing floats
 
@MooingRawr It's a technique you can pick up from academia. If you're young and pose a problem as "I couldn't possibly do this without your help" to a professor, you're likely to get the information you need and more.
 
@Number1 because that won't change your values in python
 
>>> x = [1,2,3]
>>> for i in x:
...     i = i * 2
...
>>> x
[1, 2, 3]
Reassigning the target of a loop does very little
 
ax.xaxis.set_xticks(ax.xaxis.get_xticks().astype(int))
class IntegerLocator(MultipleLocator):
    def __call__(*args, **kwargs):
        return MultipleLocator.__call__(*args, **kwargs).astype(int)

xaxis, yaxis, zaxis = [0,1,2,3,4,5,6,7,8], [0,1,2,3,4,5,6,7,8], [0,1,2,3,4,5,6,7,8]

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

locator = IntegerLocator()
ax.xaxis.set_major_locator(locator)
ax.yaxis.set_major_locator(locator)

length = 4
ax.xaxis.set_major_formatter(StrMethodFormatter("{x:07b}"))
ax.yaxis.set_major_formatter(StrMethodFormatter("{{x:{}b}}".format(length)))
I suspect that the locator could be defined much better...but I'm not sure how
it's a bit superfluous to have to use MultipleLocator twice, but I also want to inherit from MultipleLocator in order to define a proper locator
and I also don't want to use super() :P (I don't even know if that works in pythoff)
 
@AndrasDeak Alrighty thanks! So then at least from past experience setting the number of ticks could be done with "plt.locator_params(axis='x',nbins=4)" but now it doesn't do that?
 
6:40 PM
Huh?
 
limiting the number of ticks on an axis
 
if you want to set the number of ticks use a MaxNLocator with integer=True, perhaps. But then override the same way
you have all the resources you need to figure out which combination of locators and formatters you'll want to use
also note that your second formatter was broken, because you need to properly create a string with the value of length inside
you should switch to python 3.6 where you have f-strings
In [54]: length = 3; f'{2.5:.{length}f}'
Out[54]: '2.500'
 
@AndrasDeak I think I can..... That would be nice but a few of the modules I'm using aren't working in 3.6 yet.
 
ditch them :P python 2 loses all support in 2020, some third-party libraries earlier
 
Into the fiery orb with ye, outdated modules
 
6:46 PM
numpy: "Starting on January 1, 2019, any new feature releases will support only Python3" docs.scipy.org/doc/numpy/neps/dropping-python2.7-proposal.html
 
@AndrasDeak ... then an ancient order of Python 2 fanatics gather together and rise up against Python 3, bringing about code obscurity and confusion...
 
Pretty sure they moved on to add their backing to Phyton
 
As Grand Vezier for All Time of Phyton, I welcome the fanatics, while twirling my goatee and murmuring about consolidating power bases
 
I think it's about time you made a tag
 
Soon... Soon. [the rubies in the eye sockets of my snake scepter glow ominously]
 
6:56 PM
cbg
 
cbg
 
Who am I to disagree with mysticism? Where do we direct those posts in the meantime?
 
@AndrasDeak Possibly. I'm not sure though as "plt.locator_params(nbins=4)" works and only sets the z axis but when specifying an axis like "plt.locator_params(axis='x',nbins=4)" it doesn't. Also I'm not sure why what it needs would change....
 
@Number1 I don't think I understand what you're saying. What I'm saying is to change from MultipleLocator to MaxNLocator and your problems will go away
 
7:04 PM
@AndrasDeak Ahhhh. That makes sense. Thanks!
 
Is discussing design patterns / solutions something y'all do sometimes? For instance, how to reason about a tree-like repository, what would its api be, or how would one add a child to an entity nested in the tree?
 
7:16 PM
When doing "ax.yaxis.set_major_formatter(StrMethodFormatter("{{x:{}b}}".format(length)))" It doesn't seem to be setting the length of the value. IE padding 0's to the left of it.
 
>>> '{:4b}'.format(1)
'   1'
>>> '{:04b}'.format(1)
'0001'
use the format you actually mean to use...
 
sP_
Is there a way to bump up old unanswered questions?
 
@sP_ You can either edit them if they have something to improve, or add a bounty
 
sP_
Thanks, I'll try editing the question,
.
 
@AndrasDeak Correct. I'm trying to supply a variable that contains the length to set each to
 
7:22 PM
yes, so do what I just did there...
the argument of the StrMethodFormatter is a formatted string itself; print it separately if you have a hard time understanding what its value is
 
So I see ''{:04b}'.format(1)' but I'm not seeing how to change the 04 to a variable.
 
read my last message again
 
When I do that I get <matplotlib.ticker.StrMethodFormatter object at 0x7f72d2f15e90>
 
> the argument of the StrMethodFormatter
 
{x:2b}
 
7:29 PM
yup
and instead you want {x:02b}
hint: you only need to add a single character
 
7:45 PM
okay, I'm trying to wrap my head around the multiprocessing library
right now, I have this lineconcurrent.futures.ThreadPoolExecutor(max_workers=30) as sql_executor
and i have a n array called copy_futures, and I do copy_futures.append(sql_executor.submit)
afterwards, i do for copy_future in concurrent.futures.as_completed(copy_futures):
is there a way to do the same thing with multiprocessing library? I'm thinking of having a pool with a number of workers, and then I get stuck there
 
@AndrasDeak That doesn't make sense as I want to do something along the lines of length=10 and then pass length to that
 
*sigh*
ax.yaxis.set_major_formatter(StrMethodFormatter("{{x:0{}b}}".format(length)))
please see this for code formatting in chat
 
@AndrasDeak I was missing the 0 as I had the .format(length) already there. Stupid me.
 
jeez I can't go back and edit it
 
@CBredlow Yup. Want to try again?
 
7:55 PM
    copy_process = Process(<stuff passed to sql_executor.submit>)
    copy_future.append(copy_process)
    copy_process.start()

    for copy_process in copy_futures:
        copy_process.join()
 
(you have 2 minutes to edit/delete messages after posting)
first text, then code, separately (yes, it's a kludgy system)
 
with a editing window that really can't be adjusted
but basically, use pool.processes(x) and add the result to the copy_futures list
 
well 2 minutes is more than enough to realize that you messed up
 
02:00 - 20:0020:00 - 23:00

« first day (2834 days earlier)      last day (2115 days later) »