« first day (2814 days earlier)      last day (2359 days later) » 

00:49
@MoxieBall shrug, I don't use pandas enough to make an informed decision, but __name__ should be used... sparingly
01:48
0/
 
3 hours later…
04:47
Can someone please explain this? Suppose I have a function like this
def test_var_args_call(arg1, arg2, arg3):
and I want to call it using kwargs
then the example I saw does this:
kwargs = {"arg3": 3, "arg2": "two"}
test_var_args_call(1, **kwargs)
so does this mean I need to know the variable names in the definition of test_var_args_call to use kwargs?
like I need to know arg3 and arg2 are the variables to use kwargs right?
 
1 hour later…
05:50
@farhana Yes, if you want each project in a separate Git repository, you must create a new Git repository for each project. — Code-Apprentice 25 secs ago
Is it just me or does this sound like a tautology
 
2 hours later…
07:38
What's a readable way to write a bunch of (nested) if statements and run a specific line of code if none of the ifs triggered? My current solution abomination:
for arg in sys.argv[1:]:
    if arg.startswith('-'):
        arg = arg.lstrip('-')
        if arg == 'foo':
            ...  # handle the argument
        elif arg == 'bar':
            ...  # handle the argument
        else:
            break
        continue
    else:
        ...  # handle the argument
        continue
else:
    return
raise Exception('Unknown argument: {}'.format(arg))
basically, I want to throw an exception if arg starts with - but isn't -foo or --foo or -bar or --bar
07:55
Hey all. I am new here
hello
08:50
cbg
@AlphaRomeo yes, that's how it works. But help(fun) will tell you the signature of fun.
@Aran-Fey I don't think that's too bad, though your continues are no-ops
Other option is toggle a sentinel boolean in the "execute line" case
@AndrasDeak D'oh!
I like the boolean idea. I knew there had to be a smart way to do this, thanks
No problem, I hope it's actually feasible
for arg in sys.argv[1:]:
    unrecognized_argument = False

    if arg.startswith('-'):
        arg = arg.lstrip('-')
        if arg == 'foo':
            ...  # handle the argument
        elif arg == 'bar':
            ...  # handle the argument
        else:
            unrecognized_argument = True
    else:
        video_directory = arg

    if unrecognized_argument:
        raise Exception('Unknown argument: {}'.format(arg))
^ couldn't ask for something more readable
In other news, I just realized that I'm a complete moron and I don't need any of this because there's only 1 place where an exception can be thrown
Is this why people drink coffee? I should probably try that sometime
09:19
It helps, and even tastes good ;)
Also you need to sleep until noon
10:04
Has anyone here got experience with the googlesearch package?
 
2 hours later…
12:11
Lunch-time cabbage
hello guys
hope you are all good
i need some help on this
Please do not ask for answers to recently posted questions in this room
Why did you use a different account to post that question?
12:39
because its the issue am having
cur.execute("INSERT INTO rides (name,details,price,driver) VALUES('"+ offer_name +"','"+offer_details+"','"+price+"','Huza')") ✝_(º_º) Begone, SQL injection demons
Huza, hooray
I'm sure this guy's question has been asked multiple times before, but I have no idea what to google
12:59
Do you think this error:
urllib.error.HTTPError: HTTP Error 503: Service Unavailable
for this code:
from googlesearch import search
b = search('how to')
print(list(b))
print("done")
is worth asking a question aboutif the other material on it does not help me?
 
3 hours later…
 
1 hour later…
16:47
TIL sieve may be pronounced as "civ" with a short i (/sɪv/ rather than /siːv/)
17:14
I will give credit for this answer if someone gives credit for my question but not before. My question's score is 0 currently. Thanks! — Geoffrey Anderson 2 mins ago
Needs some credit
@DSM was missing examples for "python pandas" with other libraries. Well this OP delivered "numpy python"
@vaultah laurel. What are they complaining about? They have already been given credit with a -2 score ;)
flagged OP for good measure
18:01
reject that edit please
morning, room 6
18:19
cbg
Hey guys, how's it going? I've been teaching myself how to program for a little bit over a year now, and I'm about 5 months into what I'd call my first large project (over 1000 lines of code and counting), and I had a bit of a weird question. Where and when do I write tests?
I haven't written a single one for the past five months, and debugging my code has been a bit of a nightmare, but I just don't know where to start. Do I begin testing code I already wrote? Do I write tests before or after I write some new code? Should I test every feature and module in isolation, or should I string them together in logical ways and work from there? Do I need to randomize data each time, or should I stick to the same cases I know are going to be a problem each time?
Should all tests be contained in the same file, or should they be in the file where the actual code was written?
Sorry about the wall of text, I'm just really confused as to where to start. A lot of sites explain how to write tests, but not when and where.
Welcome :)
Thank you.
As I understand there are multiple approaches to the problem, but the general consensus is "tests are good, have more of those". Some people will even vouch for writing tests before you write code, as a form of test-driven development
I believe there are various paradigms and kinds of tests (unit vs integration, for instance), and I don't personally test my code so I only have vague generic guidance :P But this has come up several times in the room
18:38
If you don't want to retroactively add tests to your code, at the very least add a relevant test case every time you find a bug.
I'm not against retroactively testing my code, I was just wondering if that was an option in the first place. Glad to know that it is :). I'll try out test driven development
Adding more tests is always an option, regardless of circumstances (:
for the feature I'm currently working on, and see how that goes. I'll also start adding tests in for the more bug-prone areas of my code, and work from there to cover the whole codebase.
So would they go in a seperate folder called tests?
Or would I run them whole my code was running?
*while
Not sure what you mean. How could your program and the tests run at the same time?
If they were within the same file, then each time that module was called, all the code inside of would execute, including the tests within. Sorry if that doesn't make sense, I am quite new to this.
If I import foo.py, and I have a function called foo_test() that I call in foo.py, then importing foo.py would test it at the same time.
18:43
Nah, you don't want to do it like that. Testing is done at development time, not at run time.
Make a tests folder in your project directory and run the tests every time you commit or merge or release
A good test suite takes a while to run. That's not something you want to do while the actual program is running; that'd infuriate the users :P
It is a game, which would especially infuriate users if their fps dropped because tests were running in the middle of gameplay.
testing is for development
it helps you only distribute code that works
What you can/should do at run time is logging
testing frameworks and the corresponding logistics are separate subjects of their own
Tests are the first end users of your code.
18:49
so "where do I put the tests and when do I run them" is a very optimistic question :)
@coldspeed And you want to keep your end users fit by making them run a lot (:
I think I mostly hear pytest being praised here, then again wim is very vocal in the matter ;)
I like pytest, but I have to admit that I haven't bothered checking out any other frameworks ¯\_(ツ)_/¯
It depends. I've come to understand pytest is the quickest to get tests off the ground, but unittest is a part of the standard library, so there's better support for it (?).
What kind of "support" does a testing framework need?
18:59
I do use a lot of logging during runtime, and in my case, considering how I use said logs, a good rule of thumb would be to write a test for every log message :). Scrolling through the log and checking every message making sure nothing is out of the ordinary can get tedious sometimes.
Thanks so much for all the help by the way, your answers really cleared things up for me.
@Aran-Fey support for different versions of python?
May 29 at 6:05, by wim
there's literally nothing I can think of that unittest does better than pytest
and wim probably writes more test than non-test for work
Well, any good test code will typically be larger than the code it tests
but yeah
my point is that his strong opinion is relevant in this matter
I'm not saying pytest isn't better, I'm just saying pytest being good isn't a reason to throw out unittest
19:09
How so? You can only use the one, and you should use the better.
Perhaps not everyone wants to install a library for test?
I would, but some would not
@coldspeed Oh. True, I guess it's possible that pytest magic doesn't work in some python versions
cabbage
19:35
@AnttiHaapala Yum! Where do I register my address? :-D
20:26
Interesting profile of the day: stackoverflow.com/users/1459669/…
20:42
"10 years of experience breathing"
they used to visit here
20:55
does someone know anything about neural nets?
who's asking?
In that case, take a look at the room rules: sopython.com/chatroom
You shouldn't have to ask to ask a question
Just ask
how do you create a "quote - generator"
- i +/- know how a NN works, but I cannot figure out how you can receive an quote without any input X
e.g. i take a text, create a word_int_dictionary and a int_word_dictionary
secondly, i convert my text to integers
third, i create input data, e.g. 5 words and for the output (y) i take the 6th word ( and shift to the next data input etc...)

then, i create a NN, with maybe a wordembedding + LSTM + dense end try to predict the next word (y)
--- no problems so far ---
but then i want to use, my network, to generate some text...
but at this moment, i don't have anything .... no 5 words wich can predicht me the 6the
- does anyone has an idea how? or what i can do?
are you sure you need a neural net rather than a Markov Chain model?
21:02
i know a markov chain, can also solve it, (and probably much easier)
but for the sake of practise, i would like to use a NN
maybe i should start each 'document' with
[ 0,9,3,7,4,0,3 ] <-- a random combination of numbers with size N (whereby N is the size of my training length )
(in this case 7)
and after the last Number, he might have learned the start of the real sentence?
and if i want to have a random quote i only have to doe something like
model.predict([7,9,3,9,2,1,0,3,2], verbose=0)
maybe i don't even need digits from 0 to 9,
0 to 1 should also be fine, and i can tokenize them as special so that a 0 or 1 in the text, is not the same as this one
i might have answered my own question
I've found success with a Bidirectional RNN.
 
1 hour later…
22:32
Huh, just got my 3rd Yearling badge
curious how I registered at half past midnight
There's some lag between when you complete a year and when they mint that badge, I think.
22:44
I suspected that, but I checked my profile for the registration date. Turns out the badges are pretty accurate.
rhubarb
23:39
nice :)
hi guys can you tell me is there anybetter library to extract info from pdf
23:54
@RakshithaMurangaRodrigo github.com/Coldsp33d/python-pdfbox
This is used by content extraction tools like Apache Tika. The existing distro is outdated, so I've forked and added in a change to fix it. Steps to install can be found here.
Well, guess they didn't want any.

« first day (2814 days earlier)      last day (2359 days later) »