« first day (1646 days earlier)      last day (3285 days later) » 

1:32 AM
reminds me of a few questions I've read...
So, I remember reading on Meta a while ago about some hack you could use to make very short comments, below the 15-character limit. It sounded cool, then I immediately forgot how to do it. Anyone know how? I tried <!-- --> but that didn't work...
 
@MattDMo I think you need to use Unicode zero-width characters.
 
2:41 AM
@Martijn that sounds about right - \uFEFF, \u200B, and the like? Thanks!
bother!
not working with \ufeff...
aha! \u200b worked:
​yup​​​​​​​​​​​​​​​​​​​​​​​​​​​ — MattDMo 41 secs ago
I'll leave it as an exercise to the reader to figure out how to actually do it...
 
3:24 AM
@MattDMo u'\u200byup\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u‌​200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u200‌​b\u200b\u200b'
 
I was thinking more along the lines of print("\u200b"*15), but that'll work, I guess. DRY, Martijn, DRY :)
 
@MattDMo I copied that from your comment quote..
Straight into a Python console.
then just have Python echo the resulting value.
Time to knock off, rhubarb!
 
Oh, I see. Well, I printed out a string, and must have only selected a few of them before I copied, so it ended up getting a little mangled. Effective, though...
rhubarb!
 
cbg, @Antti. How are things?
 
3:35 AM
I don't know, I am probably too tired to analyze anything
martijn just went to bed eh? :D
at 4:25? :D
 
It's only 20 of midnight here, and I'm contemplating my nice soft sheets as well. Long day...
 
good for you, I just woke up...
I'm now a panda-eyed energy drink zombie
I actually need to be working at 8 am :D:D on sunday
 
I'm sorry. What on earth requires you to a) be up that early and b) on a Sunday? Isn't that against the UN Convention on Human Rights?
reopen vote, please :)
OP changed the question and clarified the problem, now looks (somewhat) worthwhile to answer
 
4:00 AM
@MattDMo haha ok, lets have @AvinashRaj answer that
though I think it is still too localized
 
I'm actually working on it just for fun. I can't remember how to do named groups, though. "Regular Expressions Cookbook" to the rescue!
 
(?P<name>asasdasd)
IIRC
today we have parliamentary elections in Finland, I volunteered as a poll worker/election judge/whatever you might want to call it.
so 8 am - 10 pm today...
coding on breaks :d
 
Oh, well, I guess that's a good enough reason. I cannot wait for the day when the US decides to hold elections on weekends, but that probably won't be any time soon. You'll get too many hourly and low-wage workers showing up, and we all know who they vote for...
 
re regex: I remembered that bit, I'm just stuck on referencing the named group later. Do you just use (<name>)? I have a decent-enough capture group for ddMonyyyy(day), but I don't want to repeat it 3 times, with commas after two of them...
 
4:08 AM
even though the pay is not that high, this beats sitting in the office and saying "No, no, no, we can't do that, no, it is impossible, wowowo, who told you it is OK to sell that?"
so ...
it was... (?P=name)
A backreference to a named group; it matches whatever text was matched by the earlier group named name.
but it is not the same
this is for matching the same string
if you need to do the same pattern 3 times, you'd use {} or % formatting
needs more coffee
 
Oh, thanks, that helps
wait, so something like

    repeat = r"[\d]{1,2}[A-Z]{5,8}"
    r"^(foo|bar): %r,%r,%r$" % (repeat, repeat, repeat)
 
yah
except %s
 
4:24 AM
got it
and with that, I'm off to bed. Rhubarb, all!
 
 
2 hours later…
6:53 AM
for a perfect sunday:
@JohanLarsson deep from the south, eh?
 
ty checking it out
really nice!
 
pretty slick, sounds like it could fit on Select Ambient Works II
 
I already spammed wolf right?
 
7:05 AM
nice one, good ol' rythm'n'blues ;)
 
Hi. I am just learning with python, but i was wondering, is it some how possible to optimize my python version, as it is much slower than php
 
cbg
 
@makallio85 this has nothing to do with speed, but please for god's sake fromMixedCamelCase switch to words_separated_by_underscores => PEP8
(also one extra space after the #)
 
Oookay, I am used to do things in PHP way :D
But how, do you explain the speed difference?
 
good morning everybody, this is my first time here
 
7:09 AM
cbg all
@makallio85 what Python version are you using?
 
@makallio85 also, instead of this: "It took " + str(duration) + " milliseconds to run " + str(amount) + " rounds in Fizz buzz game."
you should do something like: "It took {} milliseconds to run {} rounds in Fizz buzz game.".format(duration, amount)
 
if i have a question, can i just post it here, or are there other rules?
 
3.4.3
 
@Stephan take a moment to read sopython.com/chatroom - should have everything you need to know :)
 
thanks :) seems i already violated the first suggestion :)
 
7:14 AM
:p
 
needed to write a little function to return the file type to me according to some rules, i am using sublime text 2, but i get indentation errors all the time pastebin.com/M8YiErXa
 
Yep, fixed those. Still greatly slower than PHP, not even sure were those supposed to increase speed or readability
 
@Stephan are you mixing tabs/spaces? Also - code seems a bit convoluted :)
 
Jon, i did not mention..i am a total beginner
so please don't scold me :)
i heard that before
mixing tabs and spaces
but i don't know exactly what that means, is there a difference between tab and 4 times the space bar ?
 
Yes there is :D
 
7:20 AM
also sublime text, has those vertical lines that as far as i can tell serve as an indicator that you are on the correct line.. and that looked ok
 
@Stephan well... you have to be consistent in using either tabs/spaces
 
Only by using spaces, you can ensure spaces behaves like same in every platform
 
so if you've got a tab on one line... then do 4 spaces to indent the next- it won't work
 
@makallio85 this is a slightly better version of yours:
# See about Fizz buzz game in here, en.wikipedia.org/wiki/Fizz_buzz
import time

# Whether to print each row result in iteration on not
PRINT_ROUNDS = False

# Run game with different amounts of rounds
amount = 10
while (amount <= 10000000):
    # Get time in milliseconds
    start = round(time.time()*1000)
    for x in range(1, amount + 1):
        if not x % 3:
            string = "Fizz"
        if not x % 5:
            string += "Buzz"
        if not string:
            string = x
        if PRINT_ROUNDS:
 
@Stephan oh - don't get me wrong - certainly not scolding you. Just a little baffled as to what you're doing :p
 
7:22 AM
I removed the unnecessary function calls, the unnecessary local variables
 
Does function calls may be costing extra time?
 
created module level constant, not comparing strictly, etc.
 
ok.. i am taking a udacity course.. and i need to program different things :)
 
I know they have cost, but actually I am more interested about reason of difference in performance
 
Take me down to the paradise city, cbg!
 
7:23 AM
cog means?
cbg
 
well @makallio85 how did you measure the times?
 
by running those scripts in my console after each other
 
@Stephan ahh.... just a little worried that you rarely need to do type checking in Python - so if you're starting - wouldn't like to see you getting started on the wrong foot as it were :)
 
I was actually interested (where this all started), that if I am doing something really stupid to cause the cap between scripts
 
I see.. if we want to test running times of python code, we use the timeit module
 
7:25 AM
I just read first lines of Python tutorial couple of hours ago, so I am not pro :D
 
@StephanKetterer sopython.com/salad
 
I know.. anyway, I found a bug in my snippet => you have initialized string to "" which I should do too
 
@Jon Thank you for your concern, but that is actually required in the assignment, but now it works, what i did was just move everything completely to the left, and then use tab and hit it 1 or 2 times..seems tab is quicker than spaces and less prone to error in my ind
 
(but since I've never run it..)
 
also you are missing end variable declaration :D
 
7:27 AM
@Stephan it won't hurt to make sure your editor is set to use spaces even when you use tab :)
 
@makallio85 that's also a possiblity..
I'm on mobile now, you see..
 
:D Yep, does not matter.
 
@Stephan watermelon :)
 
Aint it quite twisted to code with mobile?
 
7:29 AM
here people are very friendly it seems. in other places.. you get scolded for asking beginner questions pretty hard :)
 
@makallio85 have a phablet, or what do they call this one these days..
 
I see that too
 
anyway, I finally arrived to the meeting I was headed to..
this is where I leave you @HarryPotter @makallio85
rhubarb later!
 
@Stephan we firmly believe in the be nice principle :)
 
thank you.. because programming seems so nice.. i really want to learn it :).. did not learn it getting my degree at all :(
 
7:41 AM
programming is funny stuff
 
@Stephan well... I've managed to stick with it for over 20 years... so it's not that bad :p
 
after 12 years I now have feeling that I know what am I doing :D
 
yeah but i think it might be something like language learning.. there is a hump.. and you get better from there.. but if you are over the hump.. you know how to help yourself
 
I've only learned from examples... I remember that when I was writing my first php+mysql thing I only knew conditions in php and I didn't know mysql "and" syntax :D so I wrote select which selected all rows from database with one condition (out of 4) and the rest was filtered by script :D
 
@Stephan just out of curiosity - what's the function you've shown used for?
 
7:46 AM
hey guys
@JonClements Downloading the data takes a long time :-)
 
@PascalvKooten what data, sorry?
 
the "kesh"
 
@Jon.. my assignment is, to take columns out a .csv file that i know names of.. look at the datatypes.. put them into a set.. then write it into a dictionary where the column name is the key, and the set is the value ( that is what i have to do as far as i can tell ) it is a little over my head and i have been sitting on it for a few days
 
@Pascal oh - you're downloading the data dump? :)
(yeah... isn't exactly small - even when compressed)
 
@JonClements Yea, not sure if it is needed right away, but it shouldn't hurt
 
7:49 AM
Well... we already the latest loaded on the server :)
(and subsetted I believed for just Python stuff)
 
@JonClements Yea, I think so... and wow I'm so not used to "official" structures heh
 
this is what i have thus far.. please don't laugh :)
 
@Pascal huh... sorry - don't get you about "official" structures - but then I haven't had my normal copious amounts of tea just yet...
 
@StephanKetterer Perhaps you don't have to get the type of every row?
 
the problem is.. the data is like a wild mix
so in one column there might be entries with very different datatypes
i think that is the purpose of the assignment
 
7:52 AM
@JonClements Haha, I mean to jump into a package to work on it rather than to "consume" it merely
 
Ahhh.... I see where you're going with this... @Stephan - let's have a looksie :)
 
oh and just fyi.. even though i don't get an error.. all my print statements don't give me any output( i have no idea why )
 
@StephanKetterer You know indentation is important right?
 
yes
and i get no errors
 
The snippet you posted is not correctly indented
 
7:54 AM
i highlighted the text and everywhere where it was a mix of dots and tabs... i replaced it with tabs
oh i see.. for example after "try"
yes but that is correctly on my machine, unfortunately i don't know why pastebin did not do that correctly
 
Do you mix tabs and spaces in your code?
 
@Stephan also note that you need audit_file() - notice the () to actually call your function - otherwise it's not going to do anything...
 
Ah it's tabs. You might want to change settings to make them spaces (4 spaces a tab)
 
@Pascal i am a beginner.. i don't really understand how that can be advantages, if i use tabs, i can just press one button, spaces is 4 times the button, and the chance of me miscounting... don't wanna offend you.. i am just clueless
 
@StephanKetterer No worries. In your IDE there should be a way to make tabs insert 4 spaces.
 
7:58 AM
ok i wil look for it
i use sublime text 2
 
It's more of a convention, sorry to distract from the problem
 
i liked that better than just a plain white window
 
Sublime is great
In Python there are only 4 options, sublime, emacs, vim and pycharm :P
 
lol... changed things and got output it seems...it says "finished in 39.5s" mhm i guess the file is big and my apple laptop is not that fast
 
How many lines?
 
8:00 AM
@Stephan do you mean this literally: elif (value=="{"): - or is it a list if it starts with a { rather than the entire column being an { ?
 
And also, doing the checks for every cell is going to take a while
 
oh, yeah changed the code so much , was supposed to be value[0]
 
@Stephan you can be more explicit and say if value.startswith('{') instead...
 
oh.. thank you .. honestly, did not know that :)
 
Btw Jon, how can we remember how to spell ffisegydd?
what's the story lol?
 
8:04 AM
like of of the values in FIELDS is areaUrban, so in theory the dict should give me like a pair of areaUrban as key and a set as the value that contains all the different datatypes that occur in that column in the document
 
@Pascal it's welsh for physicist :p
 
could as well have been jibberish for SOPythonMaintainer haha ;P
 
cbg
 
I spoke to a Welsh guy once, he told me my english is better than his haha
no one understood him here haha
 
@StephanKetterer what you want is your field_types to have a set per each column... at the moment, you've got a single set that's shared by all columns
 
8:07 AM
Do we really need yet another "how do I factorial" question? stackoverflow.com/questions/29727244/…
 
@JonClements Hmm i am sorry to ask.. i thought i get a set called helper.. stuff the datatypes in, then save it as the value of my key to the dict,, and then iterate further
 
Yup... but each key has the same helper object ...
In effect, you're doing the following
>>> helper = set()
>>> field_types = {'a': helper, 'b': helper}
>>> helper.add(None)
>>> field_types
{'b': {None}, 'a': {None}}
 
@JonClements I'm a bit confused how to combine nibada with the data
What I'm guessing now is that I should use kesh for an active connection rather than to work on the data dumps, and then use nibada on the kesh data?
 
@Pascal it's 9am on a Sunday morning - I haven't had enough tea... don't ask me to remember a discussion we had about stuff last year! :)
 
so... hm so maybe after i do fieldtypes[col]=helper , i have to reset the set, like helper=set() ?
 
8:11 AM
@JonClements Ah, it's an hour earlier there :P
I have the clear advantage. I'd also say coffee gives the advantage, but hey, I'm Dutch
 
@Stephan use a dict-comp to create a preinitialised dict of field->empty set, eg: fieldtypes = {k:set() for k in FIELDS}
Then your try/except becomes: fieldtypes[col].add(get_the_type(row[col]))
cbg @Ffisegydd - say hi to @Pascal :p
 
Hey physicist haha
 
mh that sounds very complicated for my beginner brain:) i am sure it is an awesome counstruct, i am not sure what it does, fieldtypes = {k:set() for k in FIELDS} i guess that replaces the empty dict definition.. it has a "for" in it which makes me believe it is some kind of loop, which i don't understand in a variable declaration
 
Stepham, prepare to be really happy with python.....
Stephan*
 
is that sarcasm ? :)
 
8:18 AM
it's a comprehension
no, im serious haha, I would never insult python
 
i am sure there was a point where you also where clueless in some aspects :)
 
the comprehensions allow you to write a single line instead of a longer loop
 
@Stephan it iterates over the contents of FIELDS
 
so compared to my code,, i don't no longer have any helper variable that stores the set
 
for example ['my_prefix_' + x for x in FIELDS]
it would give you fields back as a list with 'my_prefix_' in front of all the field names
 
8:20 AM
i create the dict, and then just stuff it with values "on the fly"
 
@Stephan you need a set for each column, not one set for all columns...
Simplified example:
>>> FIELDS = ['one', 'two', 'three']
>>> fieldtypes = {k:set() for k in FIELDS}
>>> fieldtypes
{'one': set(), 'three': set(), 'two': set()}
 
That one liner can also be written as:
fieldtypes = {}
for k in fields:
fieldstypes[k] = set()
 
oh so the second one means, the values are all sets, but not the same exact set ?
 
@Stephan also csv.DictReader always returns strings... so the following won't do what you think it's doing: elif isinstance(value,(int))
 
i already wondered why i never got strings or floats or anything in my outpot
 
8:23 AM
@Stephan yes... so at the moment, you've got one helper shared by all columns... that's presumably not what you want... you wants each column to have it's own set of types... not the total amount of types found across all columns...
 
yes, just out of curiousity... because i think i used that in the past. that you take a variable in a loop, then maybe append a dict with it.. then "reset" the variable and use it again and again ... kind of as a shovel ?!
 
Hey up all
 
fieldtypes = {}
for k in fields:
    fieldstypes[k] = set()
 
On my phone and just been going back through the transcript
 
Is equivalent to {k:set() for k in FIELDS}
(Except the one-liner is even faster)
 
8:25 AM
i got that :)
yeah but i am sure you understand.. for a beginner the one liner is a bit more cryptic
 
sure, but once you get it, it is really nice
did you try the python tutorial?
 
i watched a bunch.. or is there "the tutorial"
 
I've literally just woken up though :p I'm going to be travelling for a bit but when I get home I can ping you to discuss things properly if you want @Pascal? Until then my responses will be sadly intermittent.
 
honestly.. maybe because i am stupid.. or maybe because english is not my first language... i have problems with understanding the documentation sometimes
 
@Ffisegydd That's a very long response haha. Sure, no worries
@StephanKetterer It'll get easier over time. But you could also for example try codecademy.com/tracks/python
 
8:28 AM
oh thanks will do it !
 
@Stephan you want something like:
def get_the_type(value):
    if value in ('', 'NULL'):
        return None
    elif value.startswith('{'}):
        return list
    for T in (int, float, str):
        try:
            return type(T(value))
        except ValueError:
            pass
 
also it was mentioned that DictReader is not helping me since i will get strings
Jon, yours look indefinitely better ! but i was just happy for a moment that mine worked.. even though its clumsy.. writing a function that seems to do what want was good :)
 
So - you know value is always going to be of type str
 
@StephanKetterer Your main problem is going to be that when you solve one problem, you'll see others appear, because there are multiple things wrong with the code.
That's just how it is when you just start
 
Check for an empty string or NULL.... check if it starts with a {... otherwise.... try seeing if you can convert it to other types
 
8:31 AM
Best remedy is to start simple
Try to break up your goal (reading that file and doing the types) by subgoals
 
ok, i wrote my get_the_type function on its own and it worked when i tested it with print statements
 
@StephanKetterer Yes, there's the official Python tutorial "This tutorial does not attempt to be comprehensive and cover every single feature, or even every commonly used feature. Instead, it introduces many of Python’s most noteworthy features, and will give you a good idea of the language’s flavor and style."
 
i will try :)
so what am hearing is that i am worlds away from my goal of getting the code what want it to do :)
 
@Stephan you want to end up with something like gist.github.com/joncle/8c580b781bdbd93d60ca
 
That official tutorial is not aimed at total beginners to programming. It was originally written as an introduction to Python for people who were already competent programmers in one or more other languages. However, there are various core things that Python does differently to many other common languages, so if you already know how to program in C/C++, JavaScript, or PHP, you may find some Python things a bit alien at first.
 
8:40 AM
Jon, missing and missing_cols
missing'll be undefined
 
cbg
 
cbg @Avinash :)
 
return col_types, missing <---
 
cbg to the regex maharaja
 
@Pascal errr.... yeah.... that was not intentional... obviously changed my mind after a couple of lines ;)
 
8:41 AM
hehe yep
 
and colname vs name.... sheesh
 
@PM2Ring lol ...
maharaja? how you know this name?
is fourtheye told you?
 
Hah
 
@AvinashRaj Well, I just expanded "Raj".
 
@PM2Ring did you know the meaning of the above text?
don't use google..
:-)
 
8:48 AM
Cabbage boys
 
cbg Puppy!
 
Did a lot of dance last night... Legs are aching... :(
lol
 
Not sure I want to click on that or not :p
 
@AvinashRaj: FWIW, I know a little bit about Indian culture, especially Vaishnava culture & beliefs. I've read Bhagavad Gita a few times, plus various bits & pieces from the Ramayana and Bhagavata Purana, etc. A few decades ago I learned a tiny bit of Sanskrit and how to read & write Devanagari (very slowly), but most of that knowledge has faded from lack of practice.
 
Hey, what graph lib would you recommend to get started with some basic program like calculator or something
 
8:52 AM
tkinter
@makallio85 tkinter
 
cbg, 4theye
 
Cabbage @PM2Ring :-)
 
@PM2Ring fantastic.
 
@PM2Ring I am an Indian and I have never done any of them :(
 
i read things about being pythonic
 

« first day (1646 days earlier)      last day (3285 days later) »