« first day (1940 days earlier)      last day (3015 days later) » 

12:02 AM
@F4z You need to tell us the exact algorithm that you want - what does it actually do?
 
F4z
@OneRaynyDay Given a list which has lists inside like [1, 2, [3, 4, [5, 6]], 7, 8] it should recursively print each item so it will be something like [1, 2, 3, 4, 5, 6, 7, 8].
I just need to know how to do it recursively without code, like a simple walkthrough because I need to understand recursion fully
as its an assignment, i don't want any direct code or anything like that
 
12:19 AM
what's the base case: if there's no more layers right?
What do you do during the base case: you just print all the numbers in order, right?
how do you get to the base case: you go layers of lists down until you get to the list that has no nested lists right?
I think you knew that much, but it's really all you need to write this recursive function
If I said it in about 3 sentences you could probably do it in about 3 lines(especially in python lol)
 
F4z
well thats good to know, if i ever overcomplicate things i can just remember it can be done in fewer steps
 
F4z
12:37 AM
Suppose I had a nested list: [55, [24, [8, None, None], [51, [25, None, None], None]],[72, None, [78, None, None]]], this is my recursive function: pastebin.com/dWAfxZm0
I only get first 5 elements 55, 24, 8, None, None. Can someone tell me what i'm doing wrong?
 
 
2 hours later…
2:54 AM
@F4z Your function completes the processing of the list [8, None, None] which causes an empty list to meet the condition in your if statement and return "Done"
 
 
4 hours later…
7:03 AM
cbg
 
7:45 AM
:'( scipy is down?!
 
 
2 hours later…
10:13 AM
0
Q: Print Urdu/Arabic Language in Console (Python)

M Talha AfzalI am a newbie and i don't know how to set my console to print urdu / arabic characters i am using Wing IDE when i run this code print "طجکسعبکبطکسبطب" i get this on my console ╪╖╪¼┌⌐╪│╪╣╪¿┌⌐╪¿╪╖┌⌐╪│╪¿╪╖╪¿

sad but true
 
10:46 AM
CBG guys
Anyone here acquainted with PyQt?
 
user559633
Don't ask to ask, I believe you've been around here enough to know that
 
Actually I've been going and coming so I tend to forget stuff. sorry.
 
user559633
No need to apologize :)
 
I've found that trying to use PyQt QWebkit alongside concurrent.futures doesn't really work.
I'm using ProcessPoolExecutor on concurrent futures. I fork myself into a new process, create a new QWebBrowser and call some function belonging to it. I think this causes a deadlock, or something equally bad.
 
fork sounds like a very bad idea
 
10:58 AM
concurrent.futures uses fork as a default
were there an alternative I'd go with it anytime
 
yes, fork in threaded environment is a very bad idea
if you do not know what your state is
 
Do you know of any library other than concurrent futures? I need multiple processes, but I also need them to communicate with the main script that caused them to spawn
 
@GLaDOS the solution is to do fork+exec, not just fork. E.g. subprocess
 
Can you control that in pythons concurrent futures module? I didn't know that was possible
 
well, you can't
I guess
the solution would be to use ThreadPoolExecutor instead...
or prefork your processpool before you touch qt, if possible at all
 
11:03 AM
Please elaborate
 
in the beginning of your program you do pool = ProcessPoolExecutor(workers=10)
 
I can't use ThreadPoolExecutor. My implementation of Qt doesn't work well with multiple threads.
 
and only after then do your qt
 
Thats already something that's happening
 
but they're python threads
also naturally you cannot do any qt in the child processes, ever.
do not dream of it, not going to happen.
 
11:06 AM
Why is that?
 
because if the qt was initialized in the main process before the fork, it wouldn't work in child processes
 
What if I create a new Qt instance of my object in the child process
 
no
qt the library
 
So basically I need to find a way to detach the child processes from their parents or find a diffrent library to work with
 
no
threading does not work with fork-without-exec, period.
I'd instead work with completely separate subprocesses
(or not write python :D)
 
11:10 AM
like python multiprocess?
(I'm bound to write this in python, it's a very big infrastructure I need to use)
 
no, python multiprocessing is the root of all evil here.
 
When you say here you mean the earth or just this chat?
Good, I don't like that library. Any other libraries you recommend?
 
idk. 1 thing that is at problem here is Guido's insistence on that ~Python threading must not be fixed.
 
Well this will be painful.
 
errrm cough cough, sorry to butt in on the convo here but I've heard (as a complete noob to python's concurrency model) that threading in python is really tricky - is that true?
 
11:15 AM
well strictly speaking, Guido does not say that threading must not be fixed. Instead he says "python threading must not be fixed in a way that would make the uniprocessing python take a performance hit", which to me is equal to saying that Python threading must not be fixed
@OneRaynyDay yes.
@OneRaynyDay python supports "temporal multithreading" but not multiprocessing or simultaneous multithreading
 
@AnttiHaapala As someone who's doing slight bits of data analysis (stanford class for cv applications), would this be really unnattractive in large scale processing?
Ah I see. So there's essentially only "one core"?
 
one core
except some C libraries do drop the GIL, so they're possibly multithreading
and sorry, in the discussion above, s/Python/CPython/
 
If I'm not mistaken, is this due to the nature of python's virtual environment preventing users from creating segfaults/etc such that would be produced in C's concurrency?
 
you're mistaken
this is due to the nature of CPython's simplicity
 
user559633
11:30 AM
Python supports multiprocessing...
 
CPython does not
see above^
what it does is it has a horrible hack to deceive people so that they think it would support multiprocessing
 
I see... so it's like a "stub"
 
user559633
I did see above. I know what you mean with the GIL, but it's kind of misleading to suggest you can't make child procs with their own gils
 
@tristan you cannot
if you have a threaded program
it isn't safe
I am not trolling here. I am using multiprocessing myself, and it is a PITA and pitiful and whatnot
 
interesting discussions here guys :^)
I'll leave you to it - rbrb!
 
user559633
11:37 AM
processing isn't the threading, as you know
 
user559633
i think we're coming down on different sides of the same meaning, but using actual different processes gives actual concurrency. if you're modifying a local in the parent proc, yes, of course the GIL still takes hold, but each child proc has its own gil and can do its on threading, so from the parent down, you have concurrency
 
I know. Python supports multithreading but it does not support multiprocessing
 
user559633
parent process can make child processes that can do things independently of each other. seems like multiprocessing to me.
 
the fact that you can have "multiple processes" does not really multiprocessing.
 
user559633
okay, so what's your definition of multiprocessing?
 
11:40 AM
and except that you cannot use the multiprocessing if you're doing a threaded program.
multiprocessing means the use of multiple CPU cores. the operating system is multiprocessing but python is not.
(because of gil)
 
user559633
>______________________________________________>
 
user559633
that's the case in any interpreted language
 
:D
it is not
don't you even try with me.
 
user559633
ruby can't multiprocess, but through the OS it can. much like python
 
this has nothing to do with being interpreted, but all with being a shitty implementation in C
 
user559633
11:41 AM
i'm not trying, i think you've moved the goalposts so you can say "well, the language's proven solution for getting new processes and doing multiprocessing doesn't work because X"
 
original question from GlaDOS was: "how can I multiprocess in a GUI program"
well it turns out, you cannot
because multiprocessing on Linux uses fork and fork is not safe if you're using threads which GlaDOS noticed.
 
user559633
Yeah, you have to fork out and handle the GUI in one proc and send date over to it from whatever other worker procs.
 
user559633
Disagree having done this in the past with tkinter of all things
 
you cannot use multiprocessing. You must exec the child program
 
11:48 AM
eats popcorn
 
@GLaDOS you could try the spawn start method docs.python.org/3/library/… - which would then mean that you do not have shared data.
though
it would mean that you need to wirte your own Executor me guesses
@tristan @GLaDOS even worse: bugs.python.org/issue6721
seems that even CPython/stdlib itself is b0rken, not just extensions
 
I'll probably resort to a small hack instead
something like using popen and bash
 
that's a better idea.
 
There need be a word for that procrastination you have before you resort to a solution you dont like.
 
@GLaDOS or you can use
@GLaDOS though...
you can still use the multiprocessing with spawn method,
it would work without issues, because it is share-zero (it does fork+exec)
marginally easier :D
though it would reimport all your modules the second time in the child process etc...
 
12:01 PM
Thats not much of a problem
I'm writing a test script, It's not going to be in production or anything
Atleast for the time being
 
12:14 PM
wait, theres still something I dont understand
I guess it's the difference between Linux and Windows...
When I fork, I stay under the same process?
 
user559633
12:32 PM
or you could if __name__ == "__main__" the thing and make yourself a worker proc.
 
user559633
iirc last time i did this, i just used a little queue to communicate with the worker proc
 
huh?
 
1:51 PM
That actually worked pretty well!
Thanks a lot!
                context = multiprocessing.get_context('spawn')
                pool = multiprocessing.pool.Pool(
                    processes=self.max_workers,
                    context=context,
                )

                async_results = []

                for provider in self.provider_suites[suite]:
                    async_result = pool.apply_async(
                        func=self.run_test_on_provider,
                        args=(test, provider),
                    )
                    async_results.append(async_result)
 
2:12 PM
@GLaDOS kewl
@GLaDOS now, if Python did support parallel execution = multiprocessing in Python = simultaneous multithreading, then you'd need none of this trouble
you'd do threads exactly like in a C++ Qt program...
and get your parallel processing
 
2:46 PM
cbg
 
3:20 PM
Cbg
 
cbg
@Robert how's your sleeping going Bobby G? :p
 
3:37 PM
Not amazing last night :)
 
cbg Rob and Jon o/
 
I called it around 2am, wife stayed up later
 
3:48 PM
Sainsbury's are advertising Go positions - crazy.
 
@Robert I had an interview with Tesco for their data science department before accepting with FizzyCorp.
 
4:16 PM
Also crazy
People are building little in-house Nielsons
Pretty cool
 
4:51 PM
Any Alembicers know the proper way to truncate a table in a downgrade migration?
 
5:15 PM
hello everybody
i know i can get out of a loop with break, and out of a function with return, but what if i want both ? i am in a loop of a function and i want out of it completely?
oh, seems just return works
 
5:41 PM
Already hate it.
 
Hello, Robert
 
i have a program that takes in input in a loop, inside i call a function that returns something, now the problem is, that my code always takes that function return as input into the program
 
That doesn't sound like a problem... yet.
Please continue.
 
oh, the problem is, i check in the loop for wrong inputs
and since what is returned from the inner function counts as a "wrong input" i always get a bogus "invalid command" print statement in there
 
I guess you'd better debug your program.
 
5:52 PM
was my question as bad as "it does not work" ?
 
Pretty much.
I hesitate to encourage you to paste code in here, but there's really nothing we can do without looking at it.
 
mhmh made a pastebin, the error is that i get invalid command , everytime i end a hand
 
@hmmmbob what's the specific error?
 
that it always produces "Invalid command" after a an execution
mhhm is that understandable in english ?
 
Oh I see the Python isn't exceptioning out, just not producing what you expect?
 
6:01 PM
like i play a hand, i am done and i just wanna be back to the input prompt, instead i get the "Invalid command" and then the input prompt
yes, i am sorry that i did not make this clear, i dont get an error
 
re-cbg
 
i tried to print out the userinput, and its type... and there is just nothing... a ghost must print out the Invalid command statement
 
@hmmmbob I can see your issue, or at least one of them.
if interinput !=('e','r','n'):
    print "Invalid Command"
That does not do what you think it does.
 
6:16 PM
if interinput not in ('e','r','n')
 
It asks if the variable interinput is unequal to the tuple ('e', 'r', 'n')
 
yeah that was stupid, because that would mean only if ('e','r','n')
yes i fixed that
but thank you, that was clearly wrong
when you were learning this stuff, did you sometimes sit for hours on something that was fixed with a single line ?
 
No, that's just you, you're the only one.
 
i am beautiful unicorn
 
(Sarcasm, of course, I once spent 3 days debugging a single number)
 
6:21 PM
You're the chosen one
 
it works... iam so happy :)
 
Nice.
 
sometimes I feel like all I am doing is chasing unicorns
he says as he readies his net to catch the unicorn in the room
 
i have seen posters all over town of one unicorn mountin another under a rainbow titled "karma for days" , dont even know what it is for
 
7:18 PM
Question that will expose my lack of understanding: if I want SQLAlchemy to insert a unicode character into a db (e.g. "€") then how do I create a string out of that character that python won't I JUST FIGURED IT OUT!
Finally.
 
user559633
8:04 PM
:) Be mindful of the target DB encoding as well Bobby
 
8:17 PM
It's utf8_general_ci in MySQL; should be fine?
 
user559633
should be good unless you're storing some arabic and asian languages
 
user559633
keep in mind that there are DB-default, table, and column encodings in mysql
 
user559633
though if you just want to store that strange E character and you're putting and getting it, you're probably fine. further caution that utf8 general ci is case insensitive on select/compares, in case this is important for you
 
Thanks, it's not for that, but I'll bear it in mind!
 
arabic or any other Semitic language even :)
 
8:24 PM
Hm i set default and table encodings. Will check column
 
cbg, database heroes
 
user559633
Cheers :) Literally just did a 1,000 line migration to go from latin1_swedish_ci to utf8mb4 for my primary employer's flagship DB
 
user559633
cbg jrs
 
user559633
@JGreenwell heh something something utf8_general_ci is anti-semitic
 
cbg Prof
How ya doin these days?
 
8:26 PM
lol
 
hi bhargav. Sh1tting myself as my PhD viva is in a few (fails to specify count) days.
 
@JRichardSnape Best of Luck! (Did you read that paper by any chance)
 
user559633
not my best work; pretty crude, but it's 2330 and i was out all day
 
I had a few reports I had to parse and store in MySQL that used Slavic languages....oy vey
 
user559633
when you get your phd, are you going to immediately start building your volcano lair or are you going to wait a few years?
 
8:27 PM
I guess he has to focus on creating a volcano in Washington DC first
Baby steps
 
@BhargavRao I had a quick read, but need to read it in more detail to give any useful comments. At first pass, it looks an interesting idea and you've obviously put a lot of work into getting the tool functional.
 
Good luck JRichardSnape
 
@JRichardSnape Thanks. :-)
 
I was thinking a radar invisible hydrofoil super yacht was my first task.
 
Also ping me back after your viva :D
 
user559633
8:29 PM
@JGreenwell heh, i'm doing that in my startup -- comparing data across russian/spanish/german/english. it's "fun"
 
so basically every language family in Europe?...oh, yeah that sounds super fun! >.<
....actually, it does found fun at that
what is wrong with me o.O
 
user559633
yeah, it's effort, but interesting/challenging. going to be a hiring nightmare down the line though
 
in the We are looking for people who speak nearly every language in Europe, if you are a linguist please apply way?
natural language processing is always funner when you have no idea how to speak/read/write/otherwise understand the language you're processing :)
 
user559633
Yeah, "please speak one of the following languages, have a skill that's not present on the team, and be willing to join a startup"
 
Bagsy English
 
8:36 PM
Ah, foiled!
 
user559633
yeah, i can mostly do russian and english mappings, but my ringer is my girlfriend (she's way smarter and better at languages than i am)
 
de dhíth ort irish?
;) That's all I got apart from counting in Irish gaelic.
Oh, and getting a pint of guiness, which could be useful once you get the load-bearing drones going.
 
user559633
i grew up speaking a little, but i'm pretty sure i'd launch, try to do some gaelic translations, and someone would walk up and tell me that while i have the look of an irishman (in that i look like i'm smuggling a slightly larger version of myself under my skin), i'm an embarrassment
 
Ola falo unha lingua estraña
 
user559633
[that joke is a paraphrased version of a dylan moran joke. i won't link it because you should watch all of his material]
 
8:41 PM
Google informs me that is Galician. Impressive stuff.
 
Wow, some Who fan obviously got them to add that!
 
You are correct sir! :). Though I am only so-so anymore (used to speak fluently with Grandmother and Grandfather but after they passed, years ago, I've fallen out of practice)
 
user559633
I couldn't even point to Galicia on a map :/
 
its right above Portugal
 
Wave over Spain with a knowing look
 
8:44 PM
next to Spain
 
Rhubarb
 
user559633
Okay then where's Spain
 
kinda attached to Spain
but not really or like the Scots are attached to the Brits
 
Scots are Brits
 
ducks
 
user559633
8:45 PM
@RobertGrant How can two things be one thing Robert? Stop speaking nonsense
 
Sorry. I've disappointed everyone!
 
user559633
Get it together mate
 
user559633
Also, Scotland drinks Scotch. England drinks Gin. Ever mix scotch and gin? Demonstrably distinct heritage and people.
 
@tristan sobs DOES THIS MEAN I'M OUT OF THE STARTUP?
 
I remember my Uncle seeing Jessica Alba for the first time and being very confused because she didn't look Scottish
 
user559633
8:49 PM
@RobertGrant lol if you want to come be poor with me, be my guest
 
user559633
there's an ergonomic kitchen chair with your name on it
 
I was hoping to keep my day job and then just cash in on your IPO
Wow, interesting censor :)
 
user559633
ha ha jokes that can kill a company. 2 real 2 furious
 
Yeah spose. You never know.
@tristan as a devops guy, are you as scared as I am about running ORM migrations like Alembic's in prod?
 
user559633
@RobertGrant is your resume up to date?
 
9:04 PM
Haha not for my job :)
Just a side thing
 
Can someone help me better undersatnd virtual envs? Is there anything wrong with having two activated in two different cmds?
 
@clickhere that's fine
 
user559633
Joking aside, review what Alembic generates, but it's generally very sane.
 
if I have a virtual env activate, and if I type 'python', is it running the python version and modules for that virtualenv?
 
user559633
@clickhere which python for unix/linux/os x
 
9:06 PM
Windows
 
ducks
 
user559633
but yes, it should be, that's how virtualenv mostly works -- it changes your paths
 
So I don't even have to update my paths? By creating a virtual env it takes care of that for me?
 
Yes
Activating a venv just sorts out paths
 
ah ok, ty
 
9:11 PM
@tristan thanks, makes sense
 
user559633
@RobertGrant more elaborate answer, for my personal stuff, i stop my async workers, temporarily disable new accounts (and shhhh don't increment failed password count), make sure replication is up to date, take one of the read boxes out of the rep pool (in case the migration blows stuff up), then run the migration
 
Well sure, when it's personal stuff you can take shortcuts
don't understand around 30% of that...bluffing...
 
user559633
at work, i/we just run them :)
 
I'm not used to replication, and now that you say all that I realise I should be.
 
user559633
eh, you're probably fine. basically, i take a read-slave out of the pool so it's a "hot backup" of my application state data
 
9:20 PM
Yeah that makes sense
Although I find your terminology highly offensive
Because I... hate slaves?
 
user559633
so if i run the up-migration and things break, and the down-migration doesn't work, i can promote the slave to the master, then create new DBs to become slaves
 
Yeah sorry I do get it, I'm just trying to be funny
 
user559633
@RobertGrant lol, me too bro, me too slides fist across table for bumping purposes
 
I just don't know the details of making DBs do that - never done it
High-fives fist by accident
 
user559633
Haha, been there bro.
 
user559633
9:25 PM
 
Okay. I've eaten half a tub of ice cream. It's dev time.
3
 
DSM
9:57 PM
Pre-SB cabbage for all.
 
user559633
SB? Super Bros? The non-italian nintendo hit of the 1980s?
 
DSM
I lasted ten seconds listening to that.
 
Brolling - the new rick rolling. Go on - who clicked it?
Ah, DSM is victim 1 Bwah ha ha ha ha
I hope you noted the apt title "Too much (extended version)"
 
DSM
I'm gullible that way. I once crashed my computer trying a forkbomb someone posted as a joke.
 
10:04 PM
Note to self God - I hope none of my students ever alight in here
 
One day - they will
 
@DSM I'm actually laughing aloud in an internet cafe at that one
@JGreenwell Yeah - hence my lack of extreme profanity or compromising anecdotes that I couldn't laugh off...
 
user559633
real-talk: sometimes I think I should do an infosuicide because I'm getting to the real part of my career and my internet-history is littered with extreme hyperbole, trolling, and talking trash because I get bored
 
I once typed in that thing you could type into mIRC to make it crash your pc
@tristan yeah I wonder about that sort of thing
 
I was lucky that my Dad was an engineer and (eventually) IT manager for a corporation so he taught me early to watch what I say online or anywhere else that can be recorded - really thankful for that now :)
 
10:11 PM
What's sad is that that sort of thing has a bearing on some careers
Like how politicians aren't allowed to change their minds about things
 
user559633
Unfortunately/fortunately, I'm not capable of putting on a different persona -- I am who I am in here/at work/at home. I'm more vitriolic online than "irl" because it's otherwise boring to agree about things online.
 
I used to teach that class (Information Security in light of Social Media) to new Marines too - used to scare the ...pants... off them how much information, videos, and posts I could find that they thought were private
 
user559633
This is my social media :)
 
"the real part of my career"
 
user559633
10:29 PM
@paul23 it might come as a shock, but i don't take things particularly seriously :)
 
Except the menace of continued Windows usage
 
DSM
Okay, time to prepare for some sportsball. Was hoping to gun an answer but no interesting questions showed up. :-(
 
Okay, tiny amount of dev done. Sleep time!
 
Hello @everyone
 
Rbrb
 
DSM
10:31 PM
Rhubarb for all!
 
Can someone give me a hint on how to optimise this snippet of code, please
(i for i in x if ( (isinstance(i, int) and i % 2 != 0) or x.index(i) % 2 == 0))
 
@paul23, Do you mind helping, please? :)
 
user559633
@BernardOjengwa Please check out the room rules. Specifically, don't ping people for help unless they've said it's alright.
 
user559633
10:49 PM
I'd profile your code though as it's hard to objectively improve something you haven't measured docs.python.org/2.7/library/profile.html
 

« first day (1940 days earlier)      last day (3015 days later) »