« first day (1380 days earlier)      last day (3562 days later) » 
01:00 - 16:0016:00 - 00:00

1:23 AM
Hello
Back from a week trip!
:<
 
2:10 AM
Is it possible to have a variable named str, and use it in a way that does not conflict with the built-in function str(somevariableyouwanttocasttoastring)? I'm trying to debug stuff while working on this codingbat tutorial question with "str=" + str, but it's causing a TypeError: 'str' object is not callable.
I changed it to str2, but I'm curious if there's a way around this.
 
@aliteralmind it's never a good idea to mask a builtin's name with your own variable or function, and this is a great reason why - you're trying to have it both ways.
you can't have a variable called str and still use the builtin str() function
 
Got it. Shame on codingbat then ;)
@MattDMo Thanks.
 
no prob
 
Just beginning with Python, and I'm starting to have a little bit of fun :)
 
2:30 AM
cbg
 
Cabbage
 
cbg Ahmad. How goes it?
 
2:54 AM
good good and you?
Just a but tired. Pulling an all-nighter to get back to normal sleeping habits.
 
@Ahmad Isn't that contradictory?
 
not really, if I go to sleeping now (at 5am) I'll sleep until at least 1-2pm and won't be able to sleep until 2am
so I'm not sleeping so I'll be tired at 10pm
 
Ah. I'm in a different time zone. It's 11pm here.
 
this was I can wake up at ~5am
where are you from?
 
NJ, next to Philly.
 
2:58 AM
Ah cool
 
You are in Johannesberg, Prague, Rome, Oslo, Paris, Brussles, ...? It's 5am in all those places :)
 
I'm from Germany ;)
But yeah you basically had it with the european cities
 
5 a.m in Geneva too :)
 
You're from Switzerland?
 
@Ahmad You ever heard of PhraseExpress? It's a windows text-completion app made in Germany, that I use (not Python related).
 
3:04 AM
I love Switzerland.
@aliteralmind No sorry haven't heard of it before
 
@Ahmad Yup
and... I'm on night shift... :S
 
What dev job has night shifts?
(or is it even a dev job?)
 
no dev jov
I work in a hospital
 
Ah cool!
What do you do there, if you don't mind me asking?
 
anesthesiology
 
3:08 AM
nice! :)
 
it has it's nice sides yes...
 
@Ahmad That'd definitely help with your sleep schedule. :)
 
night shifts? :D
 
haha yeah I pretty much had the same sleeping nonhabits before
now all is well with night shifts
:-D
 
Anesthesia!
 
3:10 AM
hahah :D
 
best practices on installing scipy, numpy, pandas, etc, on Ubuntu 14.04? Use repos, debs, or build from scratch?
 
Is there an equivalent to this java code? I want to iterate something, but skip over every other item.
while(itr.hasNext())  {
   s += itr.next();
   itr.next();     //discard
}
 
Is it sliceable?
 
Just a string.
I want every other character.
 
yeah, s_new = s[1::2]
 
3:23 AM
^
 
So there's no way to do it without first duplicating it?
 
strings are immutable, you'll have to build a second string regardless.
 
Ohhhhhhhh....
Excellent!
Damn that's elegant!
Slicing is really sweet.
 
yeah. java is too bloated.
I was amazed by that simplicity in python as well
 
So anything that's iterable can be sliced?
 
3:25 AM
yes
 
I wrote a really sweet answer to an old slice question. I tried to give a better answer than the others.
1
A: Python's slice notation

Aaron HallI'm aiming for the complete canonical answer here. Python slicing is a computationally fast way to methodically access parts of your data. In my opinion, to be even an intermediate Python programmer, it's one aspect of the language that it is necessary to be familiar with. Important Definitions...

 
Is there any way to do it without slicing?
I mean, without duplicating it first?
 
I think an iterable is only sliceable if it takes a sliceobject to __getitem__
Of course, you can do it pretty much the same as above
it = iter(s)
 
It's a nice answer.
If you answered my question, I didn't understand. Is there a way to iterate every other object without duplicating it first (or at all)?
 
yeah, buffer or memoryview I think, but the slice doesn't duplicate the string, it creates a new string that is the slice of the old one. No redundancy.
StringIO works like a file object
You can also do itertools.islice(s, 1, None, 2)
which doesn't materialize the final string at all
it just provides an iterator over the string.
so you don't even make a second string in memory unless you want it. You'd do that with ''.join(itertools.islice(s, 1, None, 2) or equivalently, str.join('', itertools.islice(s, 1, None, 2))
 
3:40 AM
That's it!!
import  itertools
for  c in itertools.islice('ABCDEFG', 0, None, 2):
    print(c)
A
C
E
G
@AaronHall Thanks for the help. That's perfect.
 
Happy to help.
I should add that to my answer
 
That'd be an amazing addition. Starring it now. It should be part of an SO Python faq if it's not already.
Darn. You can't star an answer. Ah well.
 
It's already a big answer, but since slices typically generate a new object in memory, islice should be next thing after learnig slices.
 
@AaronHall That's not a big answer. Now that, that's a big answer ;)
 
3:50 AM
Yeah, but that's Java, so.
 
Why was my message flagged? Can someone please explain what is wrong with that?
 
I just wish islice took negative indexes...
 
@thefourtheye I saw the article, saw it was unrelated to Python, and assumed you were a new user spamming the forum. Then I looked at your profile, and realized you know what you're doing. I'm trying to figure out how to unflag, but don't know how to.
Should I post something on meta?
Had an experience on another forum with a spammer, so I overreacted.
 
@aliteralmind No problem :) I had adblocker installed in my browser, so I was worried if the link has any disgusting material, apart from the science stuff.
 
0
Q: Incorrectly flagged a chat comment. Can't unflag it

aliteralmindI incorrectly flagged this comment on Python chat, but I can't unflag it. I just want to alert the moderators. Thank you.

;)
 
3:57 AM
Oh you didn't have to :) If the content is okay, other reviewers would have rejected it anyway
 
You should flag my post then :D
 
There, I updated my answer.
 
Goodnight all. Thanks again for the help. Looking forward to seeing the updated answer @AaronHall
 
It now references islice
 
@aliteralmind Just made it as a feature request, please check :)
 
4:02 AM
@thefourtheye Looks good. Goodnight!
 
@aliteralmind rbrb :)
 
It should be exactly the same as up-voting a comment (a comment, not a question or answer). You should be able to flag a chat message, and then un-flag it, but then you can't flag it again. — aliteralmind 1 min ago
 
4:15 AM
@AaronHall I'm running 14.04 (albeit in a VM), and initially I just installed everything from the standard repos, which were more-or-less up to date. I just updated pandas using pip, since the installed version was 0.13.1, and 0.14.1 has been out for a little while. Numpy and scipy, I'm not so sure about. I've tried building them using the Intel compiler and the MKL, just to try to get some extra performance out of them
but I've never had much success.
I don't know if just using the standard gcc/gfortran compilers would help, I've just never gotten around to it before.
At any rate, on OS X (the platform upon which I run my VMs) I use MacPorts, and they update their builds for numpy and scipy pretty frequently, unlike Ubuntu, which is still on 1.7.0b1 I think...
 
thanks, Matt.
 
oops, never mind. Looks like numpy is 1.8.1. How'd that get there? :)
 
4:30 AM
nice
 
4:43 AM
Cbg
 
Greetings Python!
 
qwr
Python what a beautiful language
 
Yeah, if only there wasn't a snake named like it.
 
qwr
5:00 AM
I see no problem with that
 
5:13 AM
cbg Vaultah. And the rest of you, I suppose...
@vaultah I've been meaning to ask you - what is your avatar an image of?
 
Looks like it's from rainymood.com
 
6:15 AM
cbg again
 
6:28 AM
cbg
2
A: Imports in __init__.py and `import as` statement

Antti HaapalaYou incorrectly assume that one cannot have an alias with from ... import, as from ... import ... as has been there since Python 2.0. The import ... as is the obscure syntax that not many know about, but which you use by accident in your code. PEP 0221 claims that the following 2 are "effectivel...

pfft
 
6:42 AM
@MattDMo A piece of the background from callofduty.com/mw3
 
why are images inverted for example while binarizing ? background as black and letters as white?
 
I think this deserves to be reopened
-8
Q: Create and test a Set class to represent a classical set. Your sets should support the following methods

user3822016 Create and test a Set class to represent a classical set. Your sets should support the following methods: Set(elements): Create a set (elements is the initial list of items in the set). addElement(x): Adds x to the set. deleteElement(x): Removes x from the set. member(x): Returns...

The OP has provided the code after the question was closed; His question is still off topic though
 
7:04 AM
oh, OK. I'm a scientist, and it looks very similar to growing cells observed under a microscope. COD is cool, though...
 
I'm a big fan of COD, but its quality is declining :( Hope the next game will be good
 
7:38 AM
Cbg all
 
cbg
 
cbg
 
8:39 AM
cbg there
 
cbg @sevenforce
 
cbg
 
cabbage people! Can someone please fix my post? I am writing from mobile and can't fix it up as of now and have a strict char limit. Thanks!
 
(ot) I would like to have a hierarchy of sets where parent set contains all element from the child - so like a tree in which each node contains all elements of its children. Is there a term for that?
I can try it, Hakan. Which post?
Found it, will try.
 
Oh thank you sevenforce! Got a downvote because they may have seen the state in which it was in but who cares, I got my answer :D
 
8:57 AM
np, watermelone
 
9:10 AM
cbg
 
cbg puppy
 
@Ffisegydd STEWIE!!!!!!!!!!!
 
@Jon BRIIIIIIIIIIIIIIIIAN!!!!!!!
 
Must be Sunday - either that, or the church bells have got the wrong day to be going mad with
 
are you guys always like this?: )
 
9:15 AM
Yep.
 
would be cooler if you maintained that same number of exclamations too : )
 
Consistency is over-rated.
 
hehe
 
cbg
 
how is your lab today?
 
9:16 AM
@tilaprimera depends what day it is, and how enthusiastic we feel... gotta go with the flow now and again :)
 
My lab is far, far away.
 
ohhh, when is your lab time?
@JonClements i imagine you guys hi-fiving and jumping when you guys are in that flow
 
Not during the weekend...
 
@tilaprimera Stewie might do... I'm always too bloody tired to even contemplate it though :)
 
it is a weekend, right, here it is the first day of the week.
: /
 
9:21 AM
Well, technically Sunday is the first day of the week... it's just not a normal working day in the UK :)
cbg @StefanoSanfilippo
 
i mean first day of work!: )
 
@JonClements what?
I don't understand :)
 
What was this one about? Surely, that's just a bool_whatever = then copy and paste the python code... :)
 
9:25 AM
or... Melon! :D
 
watermelon :)
 
I really cannot understand what the question is
I think it's an assignment and the guy skimmed the Python slides deck a bit too fast
 
By the looks of it, "How do I assign a variable" :)
It looks familiar from somewhere
I think it's from codeacademy
 
Ummm..... If you want to write a comment across multiple lines, you can include the whole block in a set of triple quotation marks
not sure that's a good recommendation
 
9:33 AM
My friend (fellow PhD student) was the teaching assistant for a maths professor who was teaching computational mathematics using Python. My friend had to do the workshop with the students doing the coursework. He says the Python examples and tests that the professor wrote were some of the worst Python examples he's ever seen in his life.
He then sent the code to me, and I can verify it that it was truly disgusting.
Not only was it bad Python but it was just wrong.
 
@Ffisegydd I've taken a 3000 line "Python" program, and reduced it to about ~100 lines
 
My friend is working on this python package he's got and is using numpy. I've reduced some of his 20 line functions down to one-liners.
It's just learning the tricks.
 
@Ffisegydd I have seen a lot of people complaining about Python being sluggish and cumbersome. Truth is that they keep using it as if it were Java or C
 
@Stefano exactly.
 
@Ffisegydd To be fair - there's a lot of tricks to know :)
 
9:36 AM
I reduced his run-time from 9s to 0.02s using vectorisation.
 
@Ffisegydd when people are using numpy etc... I do get annoyed when I see lots of for loops :)
 
@Ffisegydd maybe you are the guy i am looking for! i am trying to reduce computational time on my code. time -critical!
 
@tila I'll help if I can
 
but i am using opencv function mostly, and they are computationally inexpensive.
 
9:38 AM
My knowledge of numpy isn't as good as I'd like it to be, but I suppose I do know a few tricks :P
 
i am trying to get brightest pixel from an image, and getting an bounding rectangle on that brightest pixel area. for this i am using opencv functions, could using just numpy simplify this?
 
No idea sorry. I don't know how opencv does it so don't know if numpy would be quicker.
 
in opencv, in one of its functions, it said 40* faster than numpy
but could be in only one of the functions.
 
IIRC - opencv stuff is convertible to numpy arrays
 
yea it is... : ) that is the whole point me putting this question forward
the image is a numpy array
 
9:41 AM
Whether that's convertible or accessible as ... I'm not sure
 
too scared to do all those stuff myself and mess it up, when opencv does it in 2 lines of code.
will start the work next week..and barge in here with my bugs ...
 
@tilaprimera if you do, remember to feed Stewie scrumpy cider :)
 
wondering what's that..
does he love that ?
he is right here!:D
 
it's very tasty - and yes, I believe he enjoys it :)
 
i would love to try them myself, might need to import
 
9:46 AM
Awww noooo..... England are 2nd in the games... bloomin' Australia :(
 
import scrumpy as cider
 
@Jon haha :P
 
Scotland are doing well though in 3rd, good for them
surprised Canada isn't doing better
brb
 
we do get the usual, australian berri
this is an approach related problem.
 
Wow... England have 6 gold medals in Judo... that's awesome
So do Scotland...
 
9:56 AM
trying to run a script on a file once it is present on a certain directory.
 
Rugby Sevens - I think we know who's going to win that...
 
whenever a new file is kept in that directory, the file should be processed and output must be saved up too. saving part is not the problem. just the part about sensing new files present in the directory.
 
@tilaprimera have a look at the watchdog module
 
thanks
 
10:27 AM
The first time I saw my mom use Google was like watching a velociraptor use a doorknob.
 
10:51 AM
Hi, Im new to python in webprogramming can anybody give me good resource for learning web programming in python. and which framework is better to use
 
@ManojKumar all depends what you're after - I recommend you start by reading wiki.python.org/moin/WebProgramming
 
my friends told me to use Django frame work. is it good to learn?
 
I don't like Django :|
 
@vaultah then which framework you suggest?
 
Flask, Bottle
These are the most popular ones
 
10:59 AM
@ManojKumar I suggest pyramid, bc it is not as popular, but it is the bestest
 
Yeah, Pyramid is sweet
 
though
one does not understand it without trying django first :D
and banging head against the wall hard enough
 
(ot) I am searching for a set hierarchy where each parent set contains all element from its child set - so like a tree in which each node contains all elements of its children. Is there a special term for such a tree?
 
Found the old CSS I've written 2 years ago or so
.hud-like-overlay .gray {
    color: #fff;
}
 
@vaultah ahhh... the white coloured gray class ?
 
11:06 AM
yep
Only noticed this during the refactoring
 
LOL
I think production code out there still has a function called "tuna_sandwich" because I couldn't think of a suitable name, so just put down what I was eating with a "TODO: change function name"...
 
@JonClements have you used watchdog?
i dont know what to do with it
it gives the modified statuses on the directory but how to know if it is "deleted" or "modified"
 
@tilaprimera have you read pythonhosted.org/watchdog/api.html
 
stupid of me : ) i was in that website but i was looking at a different page
thanks!
 
11:24 AM
Hola seems to be working. It's ridiculous the amount of extra stuff there is in "US" Netflix
 
@Ffisegydd I know... the UK one is a rip-off :(
At the moment, I'm watching a TV series I missed called "Cuckoo" on iPlayer
 
11:44 AM
i added the hola plugin
but i cant access abc.com 's videos
 
Wow... 46 users have registered with the sopython.com app - how cool is that :)
 
12:01 PM
Hm, can the str() function in Python 3.x take an encoding argument?
 
yes IIRC
 
Yeah
 
@Iplodman did you bother reading the documentation available before asking?
 
@JonClements Fair play.
 
 
1 hour later…
1:31 PM
Hey all,
I checked the documentation but to no avail, looked through a couple of questions here too but still cant find an answer.
How can I make one script call another one? (If they are in the same directory or not)
Right now i'm running the main script through the Windows CMD.
 
17
Q: How can I make one python file run another?

Nathan TornquistHow I can make one python file run the other? For example I have to two .py files. I want one file to be run, and then have it run the other .py file.

 
Sorry, missed that one :/ thanks!
About this import option, if my script is supposed to receive parameters do I do something like import scriptName vars?
 
@Tomer.Z not sure what you mean ?
 
I want my script to call another, I saw that one option is to import the script, lets say his name is t.py then I should write something like
import t.py
but my script expects parameters so how can I import it properly because when it gets to the import line it tries to run the script (as expected) but fails since it doesnt have the parameters it needs
 
1:47 PM
Probably the best way is to put an if __name__ == '__main__' in t which means it can stand alone as a "script", but otherwise, upon an import t still makes t. access available
 
I dont need ant functions from t, its just a basic script the gets something and prints it (im new to python) so I dont think what you said is releveant to my question, unless I misunderstood you.
any functions*
 
2:04 PM
subprocess.check_output(["C:\\Tomer\\t.py", "2"])
it says %1 is not a valid Win32 Application...
 
What's inside t.py?
 
import sys
print("Script name is ", sys.argv[0])
print("And its input is ", sys.argv[1])
 
And that's the whole point of t.py ?
 
thats the entire contents of the file
 
Wait
You can't run Python scripts like this
 
2:15 PM
what do you mean "like this"?
 
The first element of the first argument of check_output should be a path to the interpreter
 
#module a.py
	import sys
	import t
	t.print_args(sys.argv)

	#module t.py
	import sys
	def print_args(*args):
		print('Script name is', args[0])
		print('And its first input is', args[1])

	if __name__ == '__main__':
		print_args(sys.argv)
oh screw it... not sure why that isn't working
that's the way it should be structured*
 
tabs :P
 
bloody editor keeps resetting itself to something weird
except I mean "args" not - "*args"
 
Thank you very much @JonClements but that is not what I am trying to practice, I am trying to practice call other scripts from a given script not proper structuring
 
2:19 PM
I hate looking for places to move.
 
calling other*
 
@Tomer.Z print(subprocess.check_output(['python', 't.py', 'something here']))
adjust paths accordingly for the interpreter and script
@Ffisegydd wassup ?
 
Need somewhere to move, and I hate moving (and searching for places)
 
Why? What's wrong with where you are?
 
Thank you very much Jon! fixed it with subprocess.call, I was missing that 'python' at start
by the way, does it matter if it is 'pyhton' or "python", I keep seeing both ways in tutorials
 
2:25 PM
Yup... one's incorrect :)
 
Haha, so that's why so many posters here use pyhton and phyton
 
lol, ops
but you understood my question :)
 
Not sure of the rationale behind the question really, but glad you're got it sorted now :)
 
You can use any quotes you want
 
@Jon contract runs out end of August.
 
2:30 PM
Ok thanks again, last question, can a python script open a WORD file for example? not create one just open a new WORD window with an existing WORD file in it
 
@Ffisegydd ugh... you not willing to renew that contract, or are they not?
 
I was living in a house for 2 years but they decided to sell so they gave me the notice to leave. I left but the only place I could find on short notice was this place which will have new tenants in from September
So I've been here from March to September but knew I'd need to leave
 
@Jon
you are the bomb!
thanks :)
 
wow - I'm a "bomb" now... better not try to explode, as I think I'd do a rather good job at it :)
100
99
98
err....
what's the next one?
 
2:46 PM
2
 
2 billion - got ya
I'll start the count down again
too many zeroes, overflow error
 
3:07 PM
hehe :P
 
oh, wait, I'm meant to be counting up ?
 
puppy has 3 legs and thus 15 toes, can count from 32767 only.
 
oh wait, I got this now then
1
2
3
more than 3
even more than 3
 
Greetings, vegetable people.
 
we'll sorted
 
3:09 PM
And cabbage to you.
Or should that be lettuce?
 
wb @FaheemMitha
 
No, cabbage to you
 
@Ahmad Well, the more cabbage the merrier.
 
definitely
 
So, freaking pickle is crapping out (again) in multiprocessing. Apparently dill is better, but they don't use it. Do you think death threats would have any effect?
@JonClements Hi
 
3:12 PM
Anyway, back in a bit... gotta get ready for a birthday party meal, brb
 
There is this pathos fork of multiprocessing, but not packaged for debian, it seems.
I don't have anything constructive to say, just wanted to vent...
 
if one is in really sour mood, is it appropriate to greet with kimchi?
 
@AnttiHaapala I don't see why not.
Antti seems like a distinctively FInnish name. Does it mean anything?
I've got a C++ function (wrapped via Boost Python) a couple of levels down in the function that is being passed to multiprocessing. Could that be causing problems. I've dealt with these issues, but it has been a while.
 
3:28 PM
@FaheemMitha you are wrong about finnish names, half of them are foreign of origin, so is Antti
 
@AnttiHaapala Oh. Where is it from?
Somewhere else in Scandinavia.
 
Greece
Antti is a Finnish masculine given name derived from the Greek name Andreas. In Estonia, the variant Anti is more common. It is uncommon as a surname. People with the name include: Antti Autti (born 1985), Finnish snowboarder Antti Juntumaa (born 1959), Finnish boxer Antti Hyyrynen (born 1980), Finnish musician Antti Kalliomäki (born 1947), Finnish athlete and Minister of Education Antti Kasvio (born 1973), Finnish swimmer Antti Laaksonen (born 1973), Finnish ice hockey player Antti Niemi (footballer) (born 1972), Finnish football goalkeeper Antti Niemi (ice hockey) (born 1983), Finnish ice hockey...
 
@AnttiHaapala Well, it does say Finnish, derived from Greek.
Andreas really isn't that similar.
Any comments/hate about multiprocessing?
 
3:44 PM
My take: Multiprocessing is not so great because it uses a full python process for each process.
 
3:58 PM
@AaronHall Burn.
 
01:00 - 16:0016:00 - 00:00

« first day (1380 days earlier)      last day (3562 days later) »