« first day (2499 days earlier)      last day (2453 days later) » 
00:00 - 19:0019:00 - 00:00

7:10 PM
cabbage
I have a basic file structure that looks like so:
I was wondering if there is anyway to iterate the top level package for all sub-packages. Iterate all sub-packages for even smaller package until we get to "childless" modules
 
"iterate" how?
 
From those modules I'd like to get all the classes
@AndrasDeak I've looked into inspect and pkgutil and I don't really see anything that resembles what I have in mind
Essentially I'd like to recursively traverse the tree
 
Something like stackoverflow.com/q/7584418/4464570 maybe? @MalikBrahimi
 
@ByteCommander I saw that post already but it looks single dimension to me
 
^ That combined with inspect.ismodule for a recursive solution.
 
7:18 PM
^ whatever he says, probably
 
For what its worth I'll explain a bit more
 
I'm trying to dynamically generate URLs for my django project
 
10000th time someone asks why he's not getting random numbers from random number generator in
I wish "LMGTFY" would be accepted again.
 
@MalikBrahimi I'm completely unfamiliar with your tools, but isn't there a more idiomatic solution for something like that?
 
7:19 PM
within the views folder are subfolders which may contain subfolders and so on
each init.py will contain a PATH variable which is joined to the PATH vars of its successive parent(s)
finally the recursion should reach the childless module which should find all the Class based views containing their own PATH variables
and that's where the recursion ends
so for example the customer folder would generate the following:
/customer/accept
/customer/detail
/customer/makerequest
/customer/requestlist
where customer is the PATH in __init__.py and the second parts are the PATHs of classes in the modules
Does that make sense?
 
47
Q: Why would a question that's normally too broad in *any* other language be okay if it's in Python?

MakotoIn keeping with a theme I've got nowadays - wondering about moderation and how consistent, even and fairly we apply it - I've run into this scenario enough times to warrant a Meta post. Take a question for example*: I have some data in a list that looks like this: [[12, 3, 0, 12], [9, 2, 0,...

 
@AnttiHaapala send them here fourmilab.ch/hotbits
 
@AndrasDeak Haven't found anything idiomatic that's the problem
 
@MalikBrahimi I see
 
I love the functionality of Django but not the structure at all of views/routers
Flask does a much better job with decorated views
I'm trying to recreate that with PATH vars of my own
 
user5969682
7:28 PM
At jupyter qtconsole, i am trying to make latex outputs bigger when using sympy and i tried this init_printing(fontsize='30', forecolor='White') (it also includes white fonts, i know.) But it doesn't do anything about font size. Is this a bug or am i missing something?
 
@MalikBrahimi use Pyramid instead ;)
 
@AnttiHaapala Lol
any ideas with my current setup?
 
no, I didn't care to read.
I just read a request like... "I don't have enough rope, quickly someone bring me some more rope" :D
 
at least you can't shoot yourself in the foot with rope
3
 
7:46 PM
any time someone says "modules" in conjunction with "paths", my brain automatically switches off itself in an effort to save it from damage.
 
@Rawing when you put it that way, I guess not. How much change woud be needed to the grammar and type structures, though? Presumably each unit would have to have an associated type?
 
@holdenweb Yes, I think each unit would be a type. And you'd probably need some more types to group the units into different categories - so that time.sleep(5 meters) throws a TypeError for example. No idea how much effort changing the grammar rules would be though. Maybe you could get away with modifying only the rules for numeric constants
 
8:03 PM
Normalized to the speed of light in a vacuum, 5 meters would be about 16.5 nanoseconds
 
8:19 PM
Oh-oh. Variable variable alert: stackoverflow.com/questions/45775851/…
 
Meta drama is meh
 
8:40 PM
Hey! Can anyone point me in the right direction on how to allow "Sign in with Google" on an android app (with django as backend)?
I'm trying to make a REST api for a image sharing website
 
Search for OpenID Connect and Django, to enable Google as an authentication provider for your Django app
 
@poke I believe OAuth is the standard now, my issue is mostly with the interaction with Android. Am I supposed to use my own OAuth server?
 
It’s OpenID Connect.
OAuth is for authorization. OpenID Connect is for authentication.
 
@poke recently I've got the feeling that every time I see a certain user ~ S\W{4}♦, I just want to flip some tables.
 
@Antti …4? Not 3? But he isn’t even involved there (albeit heavily quoted)
 
8:51 PM
@poke he's involved everywhere. The reason why that started...
 
true :P
 
basically he's all for "optimizing for sand"
 
lol
 
this must be the first time that I noticed DR using the hammer...
 
user8451312
Any idea why this code won't remove tokens with length less then 4?

def custom_tokenizer(text):
    #split- space
    tokens = nltk.tokenize.word_tokenize(text)
    #stem tokens
    for i, token in enumerate(tokens):
        for key, val in d.items():
            if re.match(key, token):
                tokens[i] = val
                break
    for i, token in enumerate(tokens):
        if len(tokens[i])<4:
            del tokens[i]

    return tokens
 
user8451312
8:58 PM
it returns tokens with length 1, 2, 3 and more
 
Never modify a list while you're iterating over it
Use a list comprehension instead of that 2nd loop: tokens = [token for token in tokens if len(token)>=4]
 
@hope94 What Rawing said. Please see sopython.com/canon/95/…
Removing items from a list that you're iterating over is generally unsafe, unless you iterate backwards. It's a lot like sawing off a tree branch that you're sitting on. ;)
 
user8451312
I read it. Good to know that. Thank u guys!
 
user8451312
It worked now!
 
@hope94 good old
 
9:11 PM
cbg all, hope your weekends are going well. Does anyone know any good references on how to read and understand tcpdump snippets?
 
@PM2Ring I feel stupid now
 
i,e. I have a snippet: pastebin.com/Tq1e2yfj
and I would like some sort of reference on how to read that :)
 
I came here to paste the canon page... and...
I had somehow skipped your lines there...
@Jfach that's useless... it is already "human readable" :D
what you want is raw packet dumps
@Jfach or... you mean... how to human-read that?
 
@AnttiHaapala yes, exactly :)
 
9:18 PM
ah nice, I'll go through that
 
hmm not much about reading there
wireshark would be more useful...
it can show the packets visually...
found it
@Jfach ^
 
oh, that looks perfect!
thanks
@AnttiHaapala this turned out to be just what I needed
 
user8451312
9:40 PM
Earlier, i used in RapidMiner classifier called 'Weka Random Forest', it worked much better then 'Random Forest' on my data set. It was from weka extension. Do u know how can i use it in Python?
 
user8451312
9:52 PM
I found it finally
 
@hope94 just curious, what was the solution?
 
user8451312
Install from this pypi.python.org/pypi/weka/0.1.3 and then you can call classifiers...
 
user8451312
But i can't find parameters for random forest
 
10:07 PM
(I'm sorry but the temptation is very strong to post a stock photo of a hill full of trees)
 
user8451312
10:33 PM
ImportError: cannot import name 'SPARSE'

import weka
from weka.classifiers import Classifier
dir(weka)
 
user8451312
why is that?
 
@hope94 mcve needed...
 
sounds like a missing dependency (assuming that the package is not broken)
 
user8451312
How i could know what to fix?
 
'SPARSE' is in arff in the same library
so it's not a dependency; it's a broken install or a broken library or user error
 
user8451312
10:41 PM
hm, i installed it with pip
 
user8451312
i don't know if it would be ok to uninstall?
 
user8451312
and then instal again
 
DSM
11:00 PM
Wouldn't change anything if the program was broken. Are you using Python 3?
 
user8451312
Yes, Py3
 
DSM
I suspect that Andras is right and the library itself is at fault. You could try replacing the two arff import lines in classifier.py with
from . import arff
from .arff import SPARSE, DENSE, Num, Nom, Int, Str
 
user8451312
Where exaactly should i place that in my code?
 
Om Num Nom
 
user8451312
oh, classifier.py
 
user8451312
11:06 PM
not working :(
 
DSM
Works for me:
In [3]: from weka.classifiers import Classifier

In [4]:
 
user8451312
so what's the problem here?
 
DSM
Apart from the fact you think that "not working" is a useful error report? I don't know -- re-read my first sentence. ;-)
 
user8451312
It means that i get the same error....
 
DSM
That seems a little unlikely but not impossible (I'd have guessed you'd have gotten a slightly different error instead). This package doesn't seem particularly well-maintained, though, as beginners shouldn't have to experiment with modifying its code.
 
user8451312
11:14 PM
from . import arff

ImportError: cannot import name 'arff'
 
user8451312
its the same, you see
 
you're not inside the package directory by any chance, are you?
 
user8451312
Well, it was opened in windows explorer, is that a problem?
 
user8451312
If that was what you asked.
 
we should go back to the part that "if the package doesn't work out of the box, postpone the problem since this is your sixth day programming"
 
DSM
11:19 PM
This is wise advice.
 
paraphrasing a wise man
 
user8451312
I don't understand what you want to say.
 
use a different package, one that works
or get more familiar with basic python so that you can fix the broken parts more easily
or at least to be more effective in asking for help to fix the broken parts
(going afk for a while)
 
DSM
Un(?)fortunately I don't use Windows and so I can't comment here. For my part, I installed the weka java library as well as libsvm, installed the github master version of weka from pip, modified the lines as I mentioned above, and then successfully imported the package. Beyond that I'm afraid I second Andras' recommendation to find something which works off the shelf -- life is too short.
 
user8451312
DSM thank you. You found a nice way to say what you think, i appreciate that. :)
 
11:31 PM
when introducing properties for a class, should (i.e convention) they also be used inside a class, or is it preferable to call the self._myproperty?
 
11:47 PM
@DSM wait, are your conda things on linux/mac?
I always thought you were one of the windows people
no offense
 
00:00 - 19:0019:00 - 00:00

« first day (2499 days earlier)      last day (2453 days later) »