« first day (2502 days earlier)      last day (2436 days later) » 

12:03 AM
exactly
that is the power of functions in python. You can assign them to variables and still execute them later
 
I think that would help me a lot in a near future...
I had a problem. I used to execute my server.py without a menu.py (double click), so server.py was the "main" and only file and the pathlib.Path(__file__).parent gave me the directory of that main file. Now, server.py is in a subfolder (a package) and it's executed from menu.py (the new "main" file) but the pathlib.Path(__file__).parent still give me the location of the server.py and now I want to get the location of the new main: menu.py. What can I do?
Is there a way to get the location of the main file from another file?
I can get the location from the main file and then send it to the server.py like an argument. Like: server.start(pathlib.Path(__file__).parent) from menu, but I think there must be another way, no?
 
12:22 AM
why do you need the directory? What are you using it for?
 
I am making a download folder.
Yes I know, I don't have to make a download folder "inside" the program... but I don't know how to go back.
pathlib.Path(path).parents[0] to go back, interesting...
 
 
2 hours later…
2:03 AM
@EnderLook I suggest a configuration file which sets the download folder. Do not rely on the location of the program.
Or you can use an environment variable
 
2:32 AM
@Code-Apprentice Ok, thanks.
 
2:45 AM
Guys, what's the different between
is vs ==
in python
 
3:31 AM
Hey guys quick pandas--python question here
I want my X value to read all rows but the last row.
X = dataset[:,0:59]
that is what I have right now and Ive tried X = dataset[0:-1,0:59]
but that doesnt work. Any ideas?
 
3:42 AM
or how do I just shift the last column up by one and delete the last row after
 
4:03 AM
@xion please create a minimal, complete example and post your question on the main site
You are more likely to get an answer there because many more people will sex your question.
 
@Code-Apprentice Was just about to do that. Thanks!
 
 
1 hour later…
5:14 AM
Morning cbg
 
 
1 hour later…
6:34 AM
Morning cbg
 
7:00 AM
2
Q: Python is vs ==

jb. Possible Duplicate: String comparison in Python: is vs. == When is the == operator not equivalent to the is operator? (Python) I'm pretty new to Python still. I heard someone say use is, not == because "this isn't C". But I had some code x is 5 and it was not working as expected. So...

@EnderLook If you don't want to pass it as a parameter, you can do this:
import __main__
pathlib.Path(__main__.__file__).parent
 
cbg-ning
 
I think I am about to cv as dupe a question I just answered. :|
Does this qualify as a dupe? stackoverflow.com/questions/45810719/…
 
7:18 AM
There ought to be a better target. The OP of that question wants his function to accept a dict as an argument, not **kwargs.
How about this?
 
Yeah, this seems much better. Kindly cv as dupe with that before my link gets more votes :|
 
To answer your question, I think it's fine to close that as a dupe - though you may want to leave a comment explaining exactly how that dupe relates to the OP's problem. Maybe convert your answer into a comment?
 
Yeah, will do that. Thanks
O' my, talk about python being sensitive to space - stackoverflow.com/questions/45811552/…
 
8:15 AM
Hi every body
TypeError: float() argument must be a string or a number, not 'datetime.datetime'
I get this error when I try to convert object to float
 
Oh nice, the answer here is a verbatim copy from here. At least they linked to their source.
 
df = pd.read_excel(r"Fish1GramDataSetAmend.xlsx")
data = df.values[:,1:-1].astype(float)
and I get this error:
TypeError: float() argument must be a string or a number, not 'datetime.datetime'
I dont have datetime in my excel file
I have just some numbers
float numbers
 
9:06 AM
You may find they make more sense if you format the column in date-time format
IIRC the format is something bizarre like a float of days since some epoch
 
9:33 AM
@Ahadaghapour excel internally stores datetimes as floats... so on reading the file... it's possible that floats in it have been converted to dts
check your columns types using df.columns.dtypes
 
10:11 AM
Morning cbg
 
@Withnail \o
how's the new gig?
 
start next Tues
This has dragggggggggggggggggggggggged
 
omg
 
So i'm mostly sitting about monitoring bugs, saying no to features, playing with my new place's code, and writing a betfair bot.
Seems legit. :/
 
you're leaving next Tuesday and they ask you for new features...? really
how do you spell dysfunctional?
 
10:21 AM
Hi,
Somebody knows why I getting: "'int' object is not callable" in function isPrime(n)
https://repl.it/KUF6/0
 
@KubaRonkiewicz You have count = 0 in your module scope code.
 
Ah know I see, thanks :)
*now :)
 
python is really going by baby steps. Before I was super super clueless
now, I'm just super clueless
 
10:49 AM
@AndyK Yep. Pretty much.
Sales Director said (jokingly) the other day 'Oh I hope you're not leaving because of anything to do with me', and I sort of shrugged and rolled my eyes.
Now a bunch of system stability stuff I've been banging on about for ages is coming back to bite them. 'I told you so' gets old fast though, even on the providing end. :(
 
11:09 AM
Just keep on smiling until they leave - what are they going to do, fire you?
 
@user76284 you probably have to do that yourself (unless you mean the axes itself), but there might be multiple ways.
@Code-Apprentice very bad advice, that's trivial
Two separate easily googlable steps
 
11:35 AM
well, exactly. :)
chance would be a fine thing, indeed. I'd be quite happy with that...
 
Any Alt-J fans here?
 
11:59 AM
> alt-J, stylised as ∆
much nonconformism. wow. :P
 
That's mean, Andras.
Not everyone's into your Eurodisco trash (tm)
 
@Withnail yes, the Laplacian typically averages the scalar field
 
This is a list of math rock groups: == # == 31Knots 5th PROJEKT 65daysofstatic 90 Day Men == A == Acidman Adebisi Shank Agent Fresco Ahleuchatistas Algernon Cadwallader American Football And So I Watch You From Afar Arcane Roots August Moon Autolux == B == Battles Bats Because of Ghosts Beekeeper Bellini Black Pus Blakfish Blind Idiot God Botch Braid Breadwinner By the End of Tonight == C == The Cancer Conspiracy Canvas Solaris The Cast of Cheers Chavez Cheer-Accident Chochukmo Chon Circus Lupus Collections of Colonies of Bees Colossamite Converge Crain Craw Crom-Tech == D == Dads...
Ooh, that expanded largely.
 
surprisingly long list :D
 
Indie is the new mainstream
 
12:45 PM
cbg
 
@holdenweb loool
 
1:20 PM
recbg
 
Hello
 
1:40 PM
@AshishNitinPatil self-hammered
 
*Bhargav puts on sunglasses* "hammered by MYSELF"
 
What is the point of floor division in python3 when just dividing seems to be more accurate?
What are the use cases for floored division?
 
indexing, off the top of my head
lst[len(lst)///2]
 
ahhh that makes sense
 
and if you have % it makes sense to have floordiv too, and also python2 compatibility is easier this way
 
1:51 PM
three slashes? What's that, ultra-floor-division? Rounds down to the nearest multiple of 10? :p
 
py2 compatibility is easiest when you use modulo?
or when you use floor division?
 
floordiv
if you want to reproduce py2 behaviour in py3 (or with from __future__ import division) you can always use //
 
ah okay cool, thanks m8
 
@BhargavRao yeah, didn't know that was a thing. Had asked the OP to close it.
 
jjj
cabbaggge
 
1:55 PM
sry to ping twice, edits are a mess, in this regards.
 
jjj
hey, so explicit realtive imports, good or bad?
 
should have just typed a new comment, like other regular chats, hmm.
 
@AshishNitinPatil Well, I can always take revenge. I can edit my messages for more than 2 mins ;)
 
#modAbuse :-p
 
cabbage all
 
1:58 PM
recbg
 
jjj
or maybe, the other way round, should I listen to this: youtube.com/watch?v=0oTh1CXRaQ0
 
cbg
 
cbg
 
how was the end of the world for our North American peers?
@Rawing ah... I see what you mean :P
it chooses the proper operator based on the python version?
 
@AndrasDeak January 20th was a while back, no? :p
 
2:01 PM
@JonClements I had this reply typed, but deleted it (political?) - The president didn't go blind, maybe not that great.
Not political, just some satire.
 
@JonClements *googles like crazy* I see what you did there
 
@AndrasDeak Well, I didn't have to google. Was quite sure of it for some reason :-p
 
well I was googling election dates :P
 
exactly what I meant?
 
no?
 
2:04 PM
Anyway, this pic was by far the coolest - reddit.com/r/pics/comments/6v6y1k/…
 
2:20 PM
@AndrasDeak :)
 
2:36 PM
cbg
 
guys what's a good variable name for something that's a specialized subset of messages?
As in, some boolean type property
 
ssom
 
cabbage everybody! laurel :-D
 
As a programmer, I really shouldn't be asking this question but... will we ever have reliable (and good) software?... deep sigh
I've been trying to change my default keyboard layout for 2 hours but gdm doesn't care
 
Yes, once the singularity hits
 
2:40 PM
isnt that around 2040 for singularity?
 
yeah, by ray kurzweil
read his book
The Singularity Is Near: When Humans Transcend Biology is a 2005 non-fiction book about artificial intelligence and the future of humanity by inventor and futurist Ray Kurzweil. The book builds on the ideas introduced in Kurzweil's previous books, The Age of Intelligent Machines (1990) and The Age of Spiritual Machines (1999). This time, however, Kurzweil embraces the term the Singularity, which was popularized by Vernor Vinge in his 1993 essay "The Coming Technological Singularity" more than a decade earlier. Kurzweil describes his law of accelerating returns which predicts an exponential increase...
 
We all die! But, ... software should be reliable
 
Worth it
 
To paraphrase the BOFH: It's the users that cause problems, not the software. No users = no complaints = no problems. QED.
 
2:48 PM
Ok, serious question? I'm not a programmer. I've been a financial researcher my whole career. However, I want to take on a more developer centric role. With that as my goal, I need to bone up on enterprise type coding skills. Anyone have any tips on how to give myself a crash course in enterprise/corporate coding practices? Is that what I should really be doing? What other advice might some of you have?
 
@piRSquared learn to write 5% code and 95% unit tests
That's all I've learned :P
 
I can't be certain if you're joking about percentages, but that sounds like good advice
 
I'm actually not :P You go through several stages of code review, push your program from dev->beta->alpha->prod, which takes a long time
but then again I'm sure a lot of ppl here have more experience than me, but that's my 2c
 
I appreciate it.
 
@Rawing via dconf?
that's the one (well, dconf-tools or something?) that usually sticks for me
 
3:04 PM
I tried a lot of things, but dconf wasn't one of them. What setting do I need to change?
 
lemme see
 
@faceless tbh, I was fond of Kurzweill before but when I saw how he was distorting his "visions" when it did not fit his schedule, there was a tiny bulb light which highlight the sentence "isn't he another false prophet?"
 
@Rawing actually, it's dconf-editor, and mostly org.gnome.desktop.wm.keybindings therein
I can't see the keyboard layout there after a quick glance but it should be close
assuming gnome, I guess...
 
Yeah that's only for hotkeys I think, not the keyboard layout itself
 
I'll take a closer look after lunch
 
3:09 PM
cbg
 
Maybe I'll just throw wayland overboard and go back to X
 
@idjaw \o
 
o/
 
@AndrasDeak Thanks for the help. If you're really gonna spend your time on this, know two things: 1) When I'm logged in, the keyboard layout is correct. The problem is the gnome login screen, which uses a different layout for some reason. 2) I'm on wayland, not X.
 
DSM
3:31 PM
Tuesday morning cabbage.
 
digestive recbg
@Rawing thanks, I'll try to look into it
 
rbrb
 
3:50 PM
import hog from skimage
...
...
fd, hog_image = hog(img, orientations = 8, pixels_per_cell = (8, 8), cells_per_block = (1, 1), visualise = True)
...
...
x.append(fd)

I'm getting numpy.ndarray does not have append attribute. Any resolution to this? Got the code from a Master paper, did not specify which version of Python nor Numpy used...
 
that's because numpy ndarrays don't have an append attribute
they also have fixed size
x probably has to be a list
 
DSM
@AndrasDeak: numpy arrays aren't mutable? ;-)
 
otherwise np.append can combine arrays for you but that's not efficient if you keep doing that in a loop
@DSM what are you talking about? :P
(thanks)
 
DSM
 
@AndrasDeak anyway that i can work around it? I've tried to do

xCopy = numpy.empty_like (x)
xCopy[:] = x

xApp_fd = np.append(xCopy, fd)
x = xApp_fd

but down the implementation, i'm getting the error that the dimension (which is 1 by using the code above) is incorrect (implying it is multidim)
 
3:57 PM
cbg
 
@NickyHFE your first two lines should probably be xCopy = x.copy() (if that's really what you want)
and if your arrays are 1d, their appended output will also be 1d
so you need to actually think about your code and see what the shape is of the objects and you need to figure out what you actually want to do with them, and do that
 
@AndrasDeak yeah i want to make a 1:1 copy...noted and thanks for the explanation and help :)
 
what you wrote there is a bit weird, I think
"copy x, append fd to that, then rebind the result to x" -> so why copy x in the first place?
that looks a lot like x = np.append(x,fd)
and as I said, if you do that a lot of times you should consider gathering those arrays to a list and creating the result in one step
 
@AndrasDeak I have never touched Numpy before and I made the code on the fly as i read the paper and docs for numpy...helping my friend to figure out the code he found on a master paper he's working on (involving image analysis)...
 
OK
btw if you want to use : with an implied number of dimensions, there's x[...] (Ellipsis)
 
4:08 PM
@AndrasDeak in practice I haven't used it even though I know it exists; in what cases do you deal with 3/4-d arrays other than discrete convolutions?
 
I just re-read the error, it expected 2D
 
And like RNN's
 
when someone posts such a trivial question that you can't even find a dupe target...
we have "round up", "round down", "round to nearest ten", "round to quarters", "round to first non-zero digit", but no "round normally"
 
@OneRaynyDay I wrote a Monte Carlo program lasy week that hac a bunch of 3d and 4d arrays
don't let your experiences limit your imagination
 
@AndrasDeak so better alternative to np.append(x,fd) is np.append(x,fd, axis=0) since the result of this append is expected to be a 2D array later?
 
4:11 PM
only you can figure that out, seeing your data and your code
 
@AndrasDeak nice; what was your monte carlo simulations for?
or is this some private deets
 
@Rawing I usually close those as unclear. "This can't be your actual question"
 
Heh. Good idea.
 
@OneRaynyDay just some spin model simulations. Half fun, half work.
 
He probably needed help dividing by 60 to turn his seconds into minutes.
 
4:13 PM
:|
@NickyHFE there's also np.concatenate and np.stack/vstack/hstack/dstack with slightly different syntax
 
@Rawing wat!? You mean there isn't 100 seconds in a minute...? Who the heck decided on 60! :p
 
the last 40 are zero-width
 
@AndrasDeak Interesting :) haven't really played around with physics simulations too much myself
 
I have :P
 
wim
Decimal time was unfortunately a failure.
the french attempted it a few times
 
4:25 PM
@Rawing Well, I must admit that I was too lazy to look for a suitable dupe target. OTOH, that question also wants localised output, so I figure it's not too evil to give it an answer. ;) stackoverflow.com/questions/45822430/…
 
fair enough
 
Apparently someone disagrees, I just scored a downvote. :(
 
wasn't me
 
I have my suspicions, but I won't spell it out in black & white...
 
wim
your code has a bug
 
4:31 PM
@wim What was it?
 
@PM2Ring <span font-color=gray>It was ???</span>
 
to unlock this feature you must subscribe to our premium wim service
 
wim
oh, not yours sorry
the accepted answer (which I downvoted) has the bug
yours is ok
 
@Rawing No, not you.
@wim I can't see a bug there. FWIW, I was originally just going to leave that comment on the question. I only posted an answer after the other guy posted code that didn't do the rounding.
 
wim
You can't see a bug there?
 
4:38 PM
No, I can't.
 
wim
Well, that's why you're 20k and I'm 100k (smugface.jpg)
If you start a process, recording the time at start, and then subtract the time at finish, if the process has run over a DST transition then that calculation will be wrong
 
@wim Nope. From time.time docs. "Return the time as a floating point number expressed in seconds since the epoch, in UTC."
smuggerface.jpg
 
wim
keep reading
 
Of course, in Python 3.3+ we should probably be using time.perf_counter
@wim Ok
 
wim
this one is safe: t0 = datetime.now(pytz.utc); delta = (datetime.now(pytz.utc) - t0).total_seconds()
 
4:45 PM
@wim I can't see any mention of DST there, only of leap seconds (which aren't counted) and "The specific date of the epoch and the handling of leap seconds is platform dependent. " Ok, I guess some platforms may not return the true Unix epoch time.
But I try to avoid coding for Windows. I never really got into Windows, I tried using it a little while after migrating from Amiga, but I hated it, and soon migrated to Linux.
The only coding I've ever done on Windows was a little bit of batch file stuff, and JavaScript, where I was really running in the browser, not on Windows itself. Oh, and POV-Ray, where my code was being run by the POV-Ray engine.
@wim Thanks.
 
wim
8 mins ago, by PM 2Ring
@wim Nope. From time.time docs. "Return the time as a floating point number expressed in seconds since the epoch, in UTC."
^ do you have a reference link for that?
I'm surprised to see it mention UTC
I know for a fact that time.time can return local time
 
wim
I see there "Return the time in seconds since the epoch as a floating point number."
where's the ", in UTC." part?
 
@wim I giuess it could, if the OS time setting is borked, but that would be weird on a machine that can get the time from the Net.
@wim Well, it says it uses Unix time
 
does anyone know a good place to get one of those computer system diagrams creators?
By that I mean a little DB storage can-looking thing, connected to some server icon, etc, connecting to some desktop looking things as hosts
 
4:52 PM
Dia, OO Draw, Google Docs?
 
I have no idea what they're called but I see them in literature and other places
 
draw.io is FOSS and good
 
@wim I must confess that I originally referred to the 2.5 docs, since I have them on my HD. docs.python.org/release/2.5/lib/module-time.html "Return the time as a floating point number expressed in seconds since the epoch, in UTC."
 
Oh wow these are pretty cool, pretty much what I wanted. Thanks @Jon and @Kevin :)
 
@OneRaynyDay it is called a flow chart
 
4:56 PM
@Code-Apprentice not exactly, I wouldn't call this a flow chart: netlab.ulusofona.pt/rc/book/1-introduction/1_01/01-01.jpg
(Although I'm not making a networking diagram exactly, but you get the point)
 
Why do I have the 2.5 docs, you may ask? Because I downloaded them ages ago and never bothered upgrading them when my distro upgraded to 2.6, and it never upgraded to 2.7. So I went straight from 2.6.6 to 3.6. And I haven't bothered downloading 3.6 docs yet.
I might have an old plastic flowcharting template hiding somewhere... or it might've gotten tossed some time in the last 35+ years since I bought it.
 
wim
@PM2Ring Unix time is different from UTC
 
Unix time is commonly said as "seconds since 1970" but it's not actually, since it doesn't consider leap seconds :(
 
wim
and please don't reference Python 2.5 docs. That is more than 10 years old now !!!
 
@wim Yes, it's "the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970,[1][note 1] minus the number of leap seconds that have taken place since then". UTC does not observe daylight saving time.
 
5:03 PM
Is it somehow possible to run my python scripts in kernel space rather than userspace?
 
@wim I only did it because they were there and I knew the behaviour of time.time hasn't changed, even if the wording in the docs may have changed slightly.
 
@LandonZeKepitelOfGreytBritn psh, who needs a kernel?
 
user8451312
Is there an instant tokenizer to tokenize a list of sentences like this:
sent=['i am hungry', 'i wanna eat']
and to get output like this words=['i','am','hungry','i','wanna','eat']?
I dont want to get a list of 2 lists
 
wim
@PM2Ring the wording in the docs changed because the wording in the docs was wrong bugs.python.org/issue12758
 
Oh, ok.
One comment on that bugs pages says "By the way, help(time.time) correctly says about localtime.". That's odd, I see no mention of localtime when I run help(time.time) in the REPL on 2.6.6 or 3.6.0
 
wim
5:12 PM
probably changed since
 
@hope94 Does your tokenizer accept a single string? If so, you can pass it a single string like this: ' '.join(sent)
 
@KevinMGranger would that mean I can run all my python code in kernelspace?
as long as I don t use a gui or smth like that
 
user8451312
@PM2Ring Not sure i understand :(
 
>>> sent=['i am hungry', 'i wanna eat']
>>> ' '.join(sent)
'i am hungry i wanna eat'
 
wim
[word for sentence in sent for word in sentence.split()]
 
5:16 PM
>>> sent=['i am hungry', 'i wanna eat']
>>> ' '.join(sent).split()
['i', 'am', 'hungry', 'i', 'wanna', 'eat']
 
@LandonZeKepitelOfGreytBritn Firstly, what are you really trying to do? Secondly, no, you probably don't want to do that, regardless of your answer to the first question.
 
user8451312
@PM2Ring that's it, thanks!!!
 
@KevinMGranger run python code on another OS. Only common point between both OS's is the kernel
 
@hope94 Or here's a more efficient way that Wim will hate. ;)
 
so rather than running it in userspace why not run it in kernel space
 
5:19 PM
>>> from itertools import chain
>>> sent=['i am hungry', 'i wanna eat']
>>> list(chain.from_iterable(map(str.split, sent)))
['i', 'am', 'hungry', 'i', 'wanna', 'eat']
 
@LandonZeKepitelOfGreytBritn: That doesn't make sense.
 
@user2357112 plz elaborate
 
@LandonZeKepitelOfGreytBritn You first.
 
wim
I will be surprised if that is more efficient than a list comprehension
 
Running in kernelspace wouldn't do anything to alleviate whatever compatibility problems you're having.
 
5:21 PM
@wim So would I. OTOH, map is pretty good if you pass it a C function.
 
@PM2Ring My python code runs on Ubuntu. I'd like to migrate my code to Android (please don t speak to me about Kivy...). The only common ground between both os's is their kernel space
 
wim
map is cruft
 
@LandonZeKepitelOfGreytBritn generally speaking it's hardly worth dignifying the micropython environment with the title "operating system," since it typically won't have any ability to (e.g.) run parallel processes, and there might not even be a command line interface.
 
Kernel space is a memory protection thing.
 
But on the bright (?) side, you are allowed to do pretty much whatever the hardware is capable of!
 
5:24 PM
@LandonZeKepitelOfGreytBritn That's like saying "This plane won't let me store more than 10kg of luggage in the overhead rack, so I want to sit on the pilot's lap".
 
What prohibits me of getting my code to run in KS?
@PM2Ring lol
 
wim
@LandonZeKepitelOfGreytBritn KevinScript? ;)
 
@wim kernelspace...
 
@LandonZeKepitelOfGreytBritn Yes, it's supposed to be humorous. But kernel space is like the cockpit of the OS, special, important things happen in there, and user programs aren't supposed to be in there.
 
If you're relying on anything Ubuntu-specific, running in kernel space won't make those things you're relying on not Ubuntu-specific. If you're not relying on anything Ubuntu-specific, running in kernel space still won't do anything to help you.
(Also, it's not even the same kernel.)
 
5:28 PM
@PM2Ring Don t get me wrong I laughed at that joke :). I am into embedded software so I know what kernel space is, I am just new to python and am worndering hy it would be impossible to inoterprete python code in the kernelspace and send back some results of the process to userspace.
*wondering why it would be impossible to interprete
 
It's not impossible, just like it's not impossible to sit on the pilot's lap, depending on how much you want to screw with the OS/violate federal aviation regulations, but it wouldn't help you.
 
@user2357112 how much effort do you think something like that would take?
I have no freaking idea about how to get python into kernel space
 
mmm... you'd probably want to charter a private flight, and hope you have a fairly small figure. I don't know how much space there is between the pilot and the flight controls.
 
@user2357112 queue joke about air stewardess running to the cabin and some guy yelling "don't forget the coffee!" :p
 
@KevinMGranger the endgoal is to be able to run this: cmusatyalab.github.io/openface
and it states " includes a small subset of the Python standard library"
@user2357112 has this already been done before?
I couldn t find any info about smth like this online
 

« first day (2502 days earlier)      last day (2436 days later) »