« first day (3405 days earlier)      last day (1768 days later) » 

00:30
Could somebody please explain the reason for having such a __init__.py file? github.com/soundcloud/soundcloud-python/blob/master/soundcloud/…
00:41
@jigglypuff This is how you define a package in Python. See docs.python.org/3/tutorial/modules.html#packages
Ok thanks
 
1 hour later…
02:05
Trailing delimiters on data rows in pandas.read_csv still broken... github.com/pandas-dev/pandas/issues/14124
Yesterday I started playing with tensorflow, today when I loaded pycharm up keras wouldn't import from tensorflow. Python 3.6 64bit. Any ideas why?
tensorflow is version 2.1.0 I should add
02:27
@テストやろう Perhaps you used a virtual environment which you haven't activated?
That was it. Thanks. Amazing how a nights sleep can set you back mentally.
wim
wim
02:49
pylint is 💩
don't even bother with it
@wim Which linter would you recommend?
wim
wim
03:02
none. I think they are too focussed on minor style details, and very seldom catch real issues that actually make any difference. many false positives.
PyCharm's built-in inspections are enough for the important ones (unused variables, possible name errors, unreachable code)
doesn't work too well if other developers don't use PyCharm, also that typically the enforcement may be done at the CI level and generally this means something needs to be used there to do the checking
I personally use flake8, with a configuration file that specifically omits problematic files (e.g. automatically generated files). For those special cases depending on how necessary the situation calls, a separate CI step may be done to verify them (such as stripping the top line before feeding them to flake8/pylint or whatever).
Actually it seems like flake8 supports per-file-ignores since 3.7.0 which was release a bit over a year ago, so I could actually start using that for the project that I had issues with.
 
3 hours later…
06:28
cbg guys o/
07:02
Hi guys
07:45
@metatoaster As an additional data point regarding linting, I axed my flake8 config file about a year ago in favor of using black. We still have a black --check in our CI, but mostly because we're used to having that step.
Reason being the same as wim's, having people conform with the linting rules lead to a significant amount of work on their part, while retrospectively offering very little value - apart from avoiding discussion like "how should we format lists / how many characters per line", which black solves in a better way.
08:03
black is still wrong.
repr quotes forevah
That's one of the two options it provides
still means its default is wrong, but I'll take that over Yet Another Discussion about code formatting any day
it does have options?! now?
no, it just had "do not normalize quotes"
not good enough?
I do wonder though why Lukasz chose the wrong quotes
I guess it does help with a language like English that uses apostrophs in normal speech. Maybe convince cpython to change repr quotes to "? =D
08:40
I don't ever write contractions anywhere so it doesn't help me at all.
🤔🤔🤔
I have a doubt, but can't put my finger on it. So I'll just leave it be
Yeah, avoiding that discussion is worth the hassle of having to deal with collaborators that wouldn't agree - I want a specific look with code in my projects, and that shouldn't be too much to ask.
I will agree this is all extremely very opinionated and likewise I think black is wrong, but it isn't wrong that you or your project want to stay with and agree with choices black made. I wouldn't mind contributing to such a project either while also obeying the choices made, i.e. I've contributed to projects that have a coding style that I personally dislike while making sure my contributions stick with that.
the main appeal of black is still that conforming to a project's guidelines only requires you to run a tool instead of trying to interpret and apply stuff like D401: First line should be in imperative mood
5
Likewise with flake8, it is still a tool. As I said I dislike black's style.
but yeah, lots of python projects have the "should we use black" discussion right now, and people sure have opinions github.com/holoviz/panel/issues/693
08:51
In my projects I simply state that PEP8 is applied.
applied by hand?
even though PEP8 is deficient in some regards, and maybe even scorned.
No, there is a flake8 utility run as part of CI in all my projects.
@Arne does that not need NLP?
@AndrasDeak it does, which is why it often has false positives.
Also, with linting, there is also value weeding out contributors that may not wish to play nice with a particular codebase. I see no value in accepting contributions that stick to indents other than 4 spaces when the rest of the codebase has that as a consistent measure.
08:52
Ugh
@metatoaster but discrepancies have to be resolved by hand, no? I don't remember there being a flake8 autoformatter
Oh, that's what you mean. That's automatic code formatting
I don't find it too problematic for my own projects, but yeah sure there may be additional friction for potential contributors, but as I said I use this as a bit of a blunt tool.
cbg-morning
@AndrasDeak """Pass all turns and progress game state.""" -> "D401: ... should be 'turn', not 'turns'" 😕
08:56
a,b,c=foo()
what is better foo returning a list or returning a tuple
As I said, and I know I sound mean for saying it, if potential contributors don't want to follow the defined coding style, I'd rather cut them of quicker rather than dealing with other possibly more severe issues later.
@metatoaster that's fair. I guess black's main targets are big projects where manual maintenance of style is not feasible, or people like me who happen to like the style
@pythonRcpp doesn't matter
If all you do is unpack then a tuple makes more semantic sense, but any 3-length iterable will unpack
Yes, and that's perfectly fair, and very valid choices. Diversity is not necessarily a bad thing, just that it would be best if there is consistency within a single given project (or set of projects) and having the tooling to help with that goal is fine.
@Arne :/
Can it also do Hungarian?
09:01
@AndrasDeak thanks, yes i am only unpacking 10 varibles
@pythonRcpp noooo, that sounds bad
I hope they aren't column1 through column10
@AndrasDeak urgh, don't remind me about multilingual projects, they are not unusual in German corps. As long as it's coding, I'm all for "there is only English"
returning a namedtuple at that point would probably be better
Or just a list or dict to use down the line
Hey everyone, I have a question. I will attach below a sample of my data. I want to take the difference between arrival and departure time. Here is how my data is and the day number is an integer while the time is an object. I want to substract the arrival minus the departure and get the outcome in hours. Any ideas on how I should proceed?
departure_day        departure_time            arrival_day        arrival_time
1                    00:00:00                  3                  01:00:00
1                    10:00:00                  1                  02:00:00
6                    15:00:00                  1                  06:00:00
09:04
@Vasilis what is the departure date? Again, think of daylight saving.
Hi I am new here
hello guys!
It is an object
@KARSHILSHETH welcome
Here's an idea to help you start
>>> depart = datetime(1,1,1,0,0,0)
>>> arrive = datetime(1,1,3,1,0,0)
>>> arrive - depart
datetime.timedelta(2, 3600)
Thanks Andras!
09:07
@AndrasDeak I had 10 variables (mainly lists), which i need in a function, so I call foo to get all those 10 variables
I got that...
@metatoaster could you elaborate a bit?
@Vasilis what I did essentially constructed two datetime objects with year/month set to the minimum value, and then day and hour with the corresponding values from the table. Subtract one from the other returns a timedelta object. See the linked documentation for details and other examples.
The alternative is to convert everything manually to the same units (e.g. seconds) and do the appropriate arithmetic for unit conversion to display in whatever desired units.
09:24
thank you now it is much more clear!
 
3 hours later…
user10984358
12:52
No one has anything python related today?
user10984358
well that aside, should I resort to a method call of a library that returns me a number every time I call a method, or get that number once in the init method and +=1 every time?
user10984358
or they dont even matter and its just micro-optimization? the function I call is just going to return me the rows in a PyQt table, my insert function needs this row count
13:10
@TheNamesAlc I'd say it might also depend on how expensive that library call is
can you clarify what you mean by "+=1 every time"? do you mean every time you insert something, increase the counter appropriately?
did you profile it already?
I interpret this question as "is it expensive to call len() (or equivalent) on my data structure repeatedly, every time I add a new element to it?" Calculating the number of rows in a table can be pretty fast, depending on how the table is represented. lists/tuples/dicts/sets all have fast len calculation, for instance.
@TheNamesAlc If you've got the rows, will enumerate(rows)give you what you want?
I wondered about len, but decided an ordinal was required for each row.
If the function is not equivalent to len(), but rather returns the complete contents of the data structure, that may or may not be expensive depending on whether/how the data is being cached and transformed
re: "or they dont even matter and its just micro-optimization?". This is most easily determined empirically. First, assume it doesn't even matter, and continue working on your project. If you notice it becoming sluggish, then that is the time to revisit the question of optimization.
user10984358
13:28
@MisterMiyagi right now I call the library method to get the row count, and based on this I proceed, my other course of action could be to get this once and increment the counter whenever i call my insert method
are you the only one doing inserts?
are you absolutely positive that you will be the only one doing inserts, and doing so without concurrency?
did you profile it already?
I think this YAGNI attitude especially applies to GUI development, since you're much more likely to be dealing with a limited number of elements. It doesn't matter if your window slows down when you add the millionth button to it, because no well-designed GUI will ever have a million buttons.
basically, you have to answer two questions: A) Can you do it? B) Must you do it?
O(1) vs O(N^2) doesn't matter when N is about equal to 1
If either of them is answered with "No", don't do it
13:32
Another reason not to prematurely optimize here is data integrity. Ideally, each piece of information should exist in only one place in your program. If you create a counter that you manually increment, then the size of your table exists in two places. This substantially increases the potential surface area for bugs.
user10984358
I am only doing insert right now, but I have to later alter these values, for more context I am following this answer stackoverflow.com/a/24057575/10984358 to add rows, no I have not profiled it, but I will be using multiprocessing later and I will just update the column based on the results
"I will be using multiprocessing later" -> here be dragons
Multiprocessing multiplies the importance of data integrity a hundred fold
if you haven't profiled it, don't optimise it yet. if you are going to parallelise it, don't optimise it yet.
Even the library call can lead to race conditions if multiple processes want to mess at the same time
LBYL kind of problems
user10984358
13:40
maybe I am complicating this, but the only update I will be doing in this table is the second column, which is just going to show if my parallel process in running or completed, think of it like a "Status" column, all the inserts are done before the multiprocessing is started
If exactly one process is interacting with the GUI library, and that process has exactly one thread, then the chances of disaster are fairly limited
Tell that to the Iowa Dems
Sure, I'll just boot up their proprietary feedback app... Dang, connection error.
Has there been any further post-mortem on this? Or just general heckling and head-shaking?
13:45
I'm pessimistic that we'll get much transparency on the issue
user10984358
@Kevin there will be at most 4 process at an instance, but each will have one thread (no threading in this, just a cpu intensive task)
Dabeaz's tweet was pretty spot-on: A Perl CGI script from 1998 running on a single CPU computer could have handled that caucus.
True. This is one instance of a wider phenomenon I've noticed, where people observe that a recent application is inferior to something from years ago. e.g. "Why is Crysis still the best-looking game despite being ten years old?"
that's just millennials slowly turning into boomers
Most youngish adults grew up in a time where computer power would regularly double every 18 months, and now that it's plateauing, I predict we're going to see a lot of this kind of disbelief that things aren't automatically getting better any more
13:51
quantum computers to the rescue 💯
Some of this we can blame on nostalgia, but not all of it. "Why did [triple A game from 2005] have mirrors with accurate reflections, but [triple A game from 2019] just has a generic chrome-looking texture?" can't be attributed to rose-colored glasses
Hey, guys, I have a question, I want to take the difference between DateTime values. Here is what I do, but when departure has bigger values compared to arrival then it shows an incorrect value. How should I fix it? Here is my example data and my code.
Index   departure_time   arrival_time   diff
26      07:00             17:40   -1 days +13:20:00
27      07:00             17:40   -1 days +13:20:00
28      23:55             21:40            02:15:00
29      05:50             13:00   -1 days +16:50:00
arrival = pd.to_datetime(dff['arrival_time'])
dept = pd.to_datetime(dff['departure_time'])
diff = arrival - dept

print(diff)
The short answer being "because they didn't program in the accurate reflections". The bottle neck is not processor power, but developer ability and time.
@Vasilis your data already has a diff column, why don't you use that?
@Kevin ... and give-a-yam-ness
13:56
And the same is true for the Iowa debacle. A Perl CGI script from 1998 could have handled the caucus... if and only if the team developing it had the time / ability / resources necessary to do a good job. It is also possible to make terrible Perl CGI scripts.
@MisterMiyagi I just made it like that to look neat but I dont have it actually
@Kevin the short answer is "EGA ought to be enough for anybody."
I am having a hard time dealing with datetime values and taking differences
@Vasilis Btw, most airline departure and arrival times I've seen are always local time - are your times in local time, or are they normalized to UTC?
@Vasilis do you have the column that says "-1 days"?
13:58
@MisterMiyagi I could make one I think, the output is together so, "-1 days +13:20:00" is one value i get back
I think "-1 days" is part of the diff - we just aren't seeing the tabs - also looks like the diff is subtracting arrival from departure, instead of the other way around.
when I do the other way around it also gets mistakes
I have tried both
then Index 28 is wrong because I take it the other way around
I'm not sure they are mistakes, so much as unhandled cases that cross day boundary
@Vasilis Hang on. Are they DateTimes, or just Times? You can't subtract, say, 9:00 PM and 3 AM and get a single objective answer, but you can subtract Feb 13 9:00 AM and Feb 11 3 AM.
Generally, if I want the elapsed time of a flight(?) I subtract the departure time from the arrival time.
elapsed = end_time - start_time
14:01
You know what would be really really really good here? An MCVE.
Okay will do one, I first have to figure it out
^^ I starred that, and I would do it again if I could
I did a fun parsing project last night, while my wife was watching UT lose in basketball. I watched a YouTube video on a proposed graph algebraic notation, and it looked like a slam-dunk infix notation parsing problem. I watched the video during the first half, then did this parser in the second half. gist.github.com/ptmcg/4a4b523006f18e2f09829970335030c4
The premise that it is easier to specify a graph using a notation rather than just making calls to construct an object, since the object constructor may not validate things like, are there edges specified to nodes that don't exist?
I got two very nice tweets this morning, one from the presenter in London, another from a colleague of the presenter in Berlin.
I think a sufficiently clever constructor could figure out that sort of thing, but even so, the custom language probably wins the concision competition simply because it doesn't need to put every node name inside quote marks.
Or have to choose between single quotes or double quotes.
tl;dr the notation presentation: '+' means create a new graph that is the union of the set of nodes and the set of edges from each operand graph. '->' means create a new graph that is the union of the set of nodes and all edges between the product of the nodes (including self-edges if a node exists in both operand graphs).
14:20
Ok, with you so far. What's the notation for edges? For example, how do I create a graph with nodes A and B, with one edge going from A to B?
Hmm, maybe that's just <A> -> <B>?
Then "A,B,C,D in a line" would be (<A> → <B>) + (<B> → <C>) + (<C> → <D>)... Or is there a shorter version?
No that's it as far as I can tell. And op precedence will evaluate -> before +, so your parens would not be necessary.
A, B, and C all pointing to D is <A B C> -> <D>
I thought that might be the case, but I'm forever stricken with precedence paranoia
The presenter said that -> is "sort of" like multiplication
Current peeve: imagemagick downsamples an 11MB pdf into a 58MB one when I reduce the density and resolution. Doing the same thing into a jpg, then trivially converting the jpg to a pdf, leads to an actual decrease in size. I know I'm probably missing one of three dozen command line args, but argh.
I might do another "hack my repl" web page for this, it looks kind of neat. Esp. if I can get networkx and/or matplotlib to actually show the graph.
14:32
I can see how → can be powerful when you're able to use it on arguments that have a size greater than one node. You can specify a lot of edges with just one operation. My specific toy example isn't amenable to that, since every node points to one other node.
Exercise: given an arbitrary directed graph, determine the smallest possible representation of that graph in algebraic notation.
(disclaimer: may or may not be NP hard)
I was also surprised that the empty graph <> is the identity for both + and ->. Given the conceptual similarity of -> and multiplication, I thought a -> <> would yield <>, but it gives a.
Yeah the multiplication metaphor falls apart a bit when you consider the fact that you can never make a graph that's smaller than the components you started with
Btw, thanks everyone for hacking on my arithmetic repl page the other day. I've added some guardrails to factorial, exponentiation and multiplication to try to limit DoS-ability or memory gluttony. And Ned B had a tweet the other day about sys.getsizeof() that was very timely in this, I need to revisit how I'm using it.
One interesting bit was that I prohibit 1000000**1000000 (which I believe was Kevin's first entry the other day), but I accept 0**1000000**1000000 and 1**1000000**1000000 and handle them without doing any actual exponentiation operations. Also 1000000**0**1000000**1000000.
If you are looking for an interesting puzzle, I needed to write an operand collapser for a sequence of non-negative ints [n0, n1, n2,...] representing n0**n1**n2**... evaluated right-to-left, to simplify in the presence of 0's and 1's in the sequence.
Bonus points for handling negative values.
15:05
Tricky, since X ^ 0 almost always equals 1, and 0 ^ X almost always equals 0, which makes 0 ^ 0 something of a train wreck
Even if you declare by fiat that it equals 1, it adds an additional corner case you have to account for in your solver
Yes, I went with the prevailing convention that 0^0 is 1. It makes the combinatoric calcs easier.
No wait, that's 0! = 1
Well anyway, 0^0 is 1
If Python says 0**0 == 1, that's good enough for me
I also did some prettyfying, so that -1**(0.5) gives 1j, not 0.6139832497e-16+1j and sin(rad(30)) gives 0.5, not 0.499999999996, and use math.isclose() when evaluating numeric comparisons.
15:21
@PaulMcG does it handle 30/2^n and 45/2^n degrees?
I wonder if Python has any good real number libraries that would do that kind of thing for you
(not a rhetorical question)
SymPy, maybe?
@AndrasDeak Try it and see, except use '**' for exponent, not '^'
To answer my own question, yes it can
Integrating this into a solver left as an exercise for the reader
(30/2**10)°
0.000511326929295
15:38
@PaulMcG I meant exact trigonometric functions
Where is PaulMcG's link?
to this repl I can mash on
@piRSquared are you on a phone or a system with a full screen? Display on a phone is kind of ugly
work comp
That should be okay then. Use the on-screen keys or keyboard. Don't judge me on my Javascript.
16:09
@PaulMcG why the funky accented chars?
Why not? They are used in some countries, I'm told
And math types use those Greek letters, so I threw those in too.
@PaulMcG Touché.
16:46
hello peeps what's the best way to catch Java Exceptions in Python? using databricks
googling the Q gave me this A stackoverflow.com/questions/52939187/… but it wasn't that comprehensive
Can you clarify what the answer is lacking?
Can't say I'm very familiar with databricks. If databricks doesn't use jython, I expect that Q you've linked won't be very useful.
Note that Jython is very dated and not exactly widely used by people frequenting this room.
Did you mean jython?
i guess :)
16:50
Wikipedia tells me that databricks uses Scala. How does Java factor in here?
well the error i get is java.io.FileNotFoundException i assume this is java no ?
Scala is built using java, bdw you can use java, scala,r and python
Hmm, ok
@PaulMcG yes, my autocorrect really is a noob when it comes to Python implementations
@Datanovice do you get the error in Python?
^ I was about to say. Even if java.io.FileNotFoundException is being printed to stdout/stderr, that doesn't necessarily mean that it's being raised in a way that Python can catch it.
16:54
yes it's a mix between the Databricks API and Python the Python error is listed as an ExecutionError
ah that makes sense, strangely I can use a blanket try except and it catches the error but i wanted to be more explicit
As a simpler example, imagine you're using Python's subprocess.run to execute a Java .jar file as if you were running it from the command line. The subprocess might display a stack trace and exit with a -1 return code, but Python won't natively understand that it's an exception.
Perhaps you could bridge that gap by watching for negative return codes and parsing the output streams for error-like output, and raising an appropriate exception. But you don't get that functionality out of the box.
... All that said, maybe databricks does bridge that gap. I wouldn't know.
I'll ask on the databricks forum thanks Kevin really insightful
If a blanket try-except catches the error, that's a good sign.
if a blanket <anything> solves your problem, your problem was probably that you were too cold to begin with
@Datanovice does an except ExecutionError: work?
17:04
@PaulMcG How about parsing 1j as (-1) ** .5?
@inspectorG4dget i doff my hat to you king of puns
@MisterMiyagi it does not, that was my first port of call
@Datanovice does that mean I'm pun-king you?
you must be the life of the office @inspectorG4dget
did you mean ddof :)
@piRSquared I wasn't planning on dealing with complex values, it just sort of cropped up when I tried (-1)**0.5 expecting an error, forgetting that Python groks the complexness. What if you did j=(-1)**0.5? You couldn't write 1j, you would have to write 1*j. But you should be able to do something like (3+j)**2.
17:09
don't worry about it @MisterMiyagi I'll chase with databricks team invite me to a room in a week or so if you're interested in the result
@Datanovice oh gosh! people groan so hard
Laurel
rb-ning folks
Oh my god. Someone is actually recommending using ctypes to map id() (memory address) results of Django objects, stored in a session, back to the object.
That is peak StackOverflow
17:21
What do you think will happen when they try to, say, use a WSGI server configured to use multiple processes? Or separate machines and a load balancer? Or if they let the object get garbage collected?
Sounds like a problem for my replacement after I retire with the stock options I got for having a very impressive and very unscalable demo B-)
They'll post a question on SO asking why their code doesn't work
or if an attacker got hold of the session singing key or got access to the database and altered the id value..
So the moment Python executes ctypes.cast(id_value_from_session, ctypes.py_object).value, a write takes place to that memory area, to update the increment the reference count.
But.. id_value_from_session now points to memory that something completely unrelated is using. Chances are your Django process is now hosed, or you have really really weird heisenbugs and plain old memory corruption issues.
I'll not point directly to the answer, but I can't rename ctypes.cast or ctypes.py_object or hide that this is a Django answer..
So NamedTuples no longer need __slots__ = () to prevent __dict__ instantiation? I'm testing out 3.7...
oh wait that was for subclasses...
Idea: Print out a Python2 binary on punchcards. Have a funeral pyre at PyCon.
17:36
plays gentle taps on his laptop using Python 3
Yes, subclasses would still need __slots__, but you're not really supposed to subclass namedtuples anyways (except to add functionality, I think...)
If you follow the rules that you can only add functionality and restrict values in subclasses, I wonder if you could subclass NamedTuples worry free...
@AaronHall same with tuple subclasses. Or any subclass of a type without __dict__, really.
I may do this occasionally. Why shouldn't you?
17:59
@MartijnPieters I got confusaled with the new subclassing syntax/usage.
Apparently it gives you __slots__ automatically when you subclass NamedTuple:
>>> from typing import NamedTuple
>>> class MyNT(NamedTuple):
...     foo: str
>>> mynt = MyNT('foo')
>>> mynt.__slots__
()
Subsequent subclasses would require it, I presume seem to have demonstrated...
"are you sure the metaclass doesn't do that for subclasses as well?"
- Looks like it does in Python 3.8. but perhaps not in 3.7?
doesn't seem to be the case in 3.7
it just has the inherited __slots__, not a new, empty one
>>> class AnotherNT(MyNT): pass
...
>>> ant = AnotherNT('foo')
>>> ant.__slots__
()
>>> ant.foo='foo'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: can't set attribute
I guess I should update my answer that talks about this...
@AaronHall that's because typing.NamedTuple uses metaclass magic.
18:17
Hi folks, Would you know of a good source for a Python programmer to learn C++? I found one - runestone.academy/runestone/books/published/cpp4python/… - but this seems incomplete
A book, if not a website would also do. Thank you!
None come to mind. I think you'd be better off looking for good C++ books that aren't specifically targeted at Python programmers.
I have total submission count and each options total submission count. I need the submission percentage for each option. Ex: option_count * (total_count / 100). How can I do this inside django template?
in 10 years "better update all my answers that treat Python as an interpreted language now that print('hello world') compiles down to a 1 kb exe..."
18:32
I'm hoping we reach the state of "computers have been designing computers for the last ten generations, and no human knows how any of it works" before Python becomes a compiled language
At which point my answers will be nothing more of a historical curiosity, and so may as well stay un-edited
18:47
aside from the keys, values, items situation, did Python 3 dicts get any new methods? I'm not recalling any at the moment...
Let's see. I just subtracted the respective dir()s, and I got: ['__init_subclass__', '__reversed__', '__dir__']
For completeness, methods that have been lost since 2.7: ['viewitems', 'viewvalues', '__cmp__', 'has_key', 'viewkeys', 'itervalues', 'iteritems', 'iterkeys']
nice, thanks Kevin.
@PaulMcG but I didn't see single or double quotes, so why text?
You can still use your keyboard
I thought "You " + coinflip? "win" : "lose" might be interesting
NameError: variable 'coinflip' not known :(
ah, it's an interactive repl, not just single expressions. I somehow missed that, sorry
18:58
coinflip @= rnd() < 0.5
and are C-style conditional expressions supposed to work?
Yes - plus a few others. I think there are Help and Examples buttons...
PaulScript coming along nicely
The "@=" does deferred eval, so it's kinda lambda-ish
@PaulMcG fair enough, thanks. I just can't read, apparently
19:00
Off to meeting-land, rbrb
Couple hours late, but I have to deny responsibility for 1000000**1000000. It looks like all my attempts to break the repl are still present in the browser autocomplete box, and 1000000**1000000 is not among them.
@PaulMcG Can we avoid nitpicking about minor details, please? (Except when it's funny ...)
unless you yourself were joking :P
@AndrasDeak So, reassuringly, people are not nitpicking about minor details. Thanks for the steer.
19:15
Yeah, just an auto"correct" mishap. Which reminds me of dawizard that I learned about yesterday :)
19:38
Cbg, back from meeting-land. Thanks @AndrasDeak for clearing up the confusion on the picking of nits. @holdenweb, you're on my list... (of people I could never get mad at).
What are your favorite hidden gems that are new in Python 3?
@PaulMcG 99**99 doesn't crash your repl, 99**99**4 is too large, 99**99**2 returns a long number, but also freezes it, as I can't get it to load to try 99**99**3.
19:55
Appears to be working now, yes?
@PaulMcG It loaded, and I repeated my steps. With the same result..
Oh no, now it's good. Took it a long while.
Ooh trailing ... fancy.
try 99**99**4 with concurrent.futures.ThreadPoolExecutor. That miiiiiiight not-crash
20:11
But it might take awhile to return a page.
Nope, 3 works, 4 overflows.
Ok, I'll look at 99**99**3, it looks like it is just getting past my exponentiation constraints, so I might need to tighten them up.
99**99**3.000000001 has an overflow, but 3 gives a long decimal followed by ...
It's interesting how Python treats int**float differently from int**int. 99**99**3 eventually does complete, but 99**99**2.1 complains immediately of an overflow.
Until they invent unlimited size floats, we'll just have to be happy with unlimited size ints
20:29
I have what I think is a pretty quick question and can't find it in the search:
I'm subtracting the difference between 2 lists using numpy and the printed result is this:
[0. 0. 0. ... 0. 0. 0.] <<< what is that? I attempted to use the convert from numpy array to list to see if that worked but it looked the same still.
@Pandasncode MCVE, please. You're probably subtracting numpy arrays, which work elementwise. And what you have is the str of a numpy array.
@PaulMcG That is a point, I thought there was some sort of inconsistency there.
and if you use arr.tolist() it will return a new list, so you have to bind it to a name if you want to print it later...
>>> arr = np.arange(3.0) - np.arange(3)
... print(arr)
... print(arr.tolist())
[0. 0. 0.]
[0.0, 0.0, 0.0]
and the ... means that the array is too large considering the settings in np.get_printoptions(), so the values are truncated
I attempted the .tolist() and still got the [0. 0. 0.]
@Pandasncode as I said, "attempting" is not enough. You have to store the result.
existing numpy arrays can't magically turn into lists
if you think you tried it correctly, we're back to square 1
20:34
gotcha.
Thank you
no problem
What does MCVE mean?
Gotcha. Sorry!
It's alright, it may have been renamed by the time you registered on SO :)
much longer-time users can also be unaware of the concept
20:38
cbg
I think I'll turn it into a question with all the code. Difficult for me to put it in here. But I think you're original assumption is definitely correct.
@Pandasncode if you don't want to ask on main you can put your problem in a pastebin/gist/etc. and link it here. If you ask on the main site we'll ask you not to ask here too for 2 days.
there's probably just some misunderstanding here and I'm certain I can help
In my experience, the average amount of time between "querent provides an MCVE for their numpy question" and "someone in here solves it" is thirty seconds.
Ha so you know that awful thing where in python if you have an empty array and you set it (newarra) = (thing you're doing) It just turns everything to nothing or 0s ect
That's what I was doing
That's what they are 0
20:50
I do not know that thing, actually.
I'm not confident that I understand, but I guess if it's fixed it's great? :P
@Kevin 75% chance for a vectorized assignment of the form arr[:] = 0 or arr = arr * 0 or something like that
and 90% chance for a not-native-python-but-in-fact-numpy thing
File under "the language is doing exactly what you're asking it to do"
I don't ask
I did it about an hour ago too. my empty list was set as a range of 183001 with everything as floaters 0.0. Trying to avoid having to interpolate the list out to 183001. where I ended up having to interpolating anyway.
I code with my eyes closed and my mind empty, so no matter what the outcome is, it doesn't violate my expectations
20:53
@Pandasncode make sure you distinguish lists (native python objects) and arrays (numpy objects in your case).
Yeap ^^^^ Thanks!
People usually say arrays and mean lists. This direction is a refreshing change ;)
hi guys, I am using curl in a python script to access API
Is there anyway to add OR statements in the URL something like this:
curl -k site.com/api/v1/data/HostDetails ipAddress+hostName+macAddress="10.10.10.1"
so user can either enter IP, MAC or name and the API still works
If you're asking about the legal syntax of the curl command, that's not really a Python question.
I know each three individually work fine
I am using curl for testing but will be using python requests
21:00
Ok, let us know when you get to that point and we'll help you with your requests question at that time.
url = "https://site.com/api/v1/data/HostDetails?ipAddress+hostName+macAddress="10.10.10.1""
resp = sess.get(url, auth=(username, password), headers=headers, verify=False)
url = 'https://site.com/api/v1/data/HostDetails?ipAddress+hostName+macAddress="10.10.10.1"'
you already posted that URL
fixed " with '
Ah. You can edit/delete messages for 2 minutes.
21:15
hi
Try: url = 'https://site.com/api/v1/data/HostDetails?ipAddress=&hostName=&macAddress="10.10.10.1"' This will get processed on the server side as ipAddress=None, hostName=None, and macAddress="10.10.10.1".
When you use requests, you won't build up those query arguments manually, but wlll pass a params dict argument to requests.get.
So just populate the params arg with the field you want to send, and leave out or set to None the other two.
@bulletvz hello
the url did not work with curl but will try in requests
Bad or missing filter property value [] for property [ipAddress] on entity [HostDetails].-PRS-113
hello guys
that my ask in stackoverflow "https://stackoverflow.com/questions/60142740/how-that-code-of-javascript-work-with-slice" , can someone explain to me how i can tranfaster that sample script to python?
21:43
Asking all your opinion of Assign values to the groups of a groupby in pandas. The question statement is very vague, both re output format and what the op wants to do. Hence the question is not a reusable resource, and arguably doesn't allow an objectively best answer. Also the OP is dormant, a) Does this rise to the level of delv-pls? b) If not, we're not allowed comment on it?
> CPUs contained in recent USB-C wall chargers
am I old/naive that I find that off-putting?
22:26
looked up the actual product on amazon. What does it need a CPU for? "At volume, the chips are cheaper than fuses"?
wim
wim
23:16
it's probably to sends your phone's data to CIA in case the facebook app was not installed
I'd never use a random charger without a USB condom

« first day (3405 days earlier)      last day (1768 days later) »