« first day (3091 days earlier)      last day (2079 days later) » 

00:28
@PawelFlajszer do you like to break stuff? You'll be trying to do that a lot as a tester
Some people really enjoy it
It's a bit like lightweight hacking, sometimes
@AlexanderReynolds You mean, writing a package so you can pip install it? github.com/waynew/simplest-python-package is a really simple example I wrote that you may find useful
@WayneWerner I'm aware of that but I'm wondering if there is a way (within Python itself) to be able to run this program without the user activating the virtual environment.
I guess that's what pyinstaller does
didn't really realize that my question was "how do I make my CLI an executable" but I guess it is, which makes the answers obvious. But, thanks for the suggestion, that's a handy thing to have around to point people to anyways
@AlexanderReynolds btw, found out how to do this with asyncio.wait_for with a timeout---the async method just processes the data so the timeout just stops it running.
00:52
@AlexanderReynolds You could create a virtualenv for the user and then install your package in it. All they need is ~/.local/bin, or equivalent on their path
@WayneWerner But then they need to have that virtual environment active every time they want to run said app, right?
try it: python3 -m venv ~/.virtualenvs/pymato && ~/.virtualenvs/pymato/python -m pip install pymato && ~/.local/bin/pymato
pretty sure that should do it
(it's a CLI pomodoro timer)
missed a /bin in the second path
oops, yep
cant find where pymato is installed to
Yeah, that doesn't work like I'm asking---you have to activate the .virtualenvs/pymato venv to have pymato on your PATH
I want someone to be able to do something like pip install <some github repo>/mytool and then just go mytool option1 option2 and be done with it. Which just means to create an executable, I guess. I mean, I know how to do it now that I've phrased it right (at least, with other tools, dunno how to do this myself)
01:03
mmmm. might need a --user flag on the pip install
but wont that then install the packages into a global space?
If you create a package (source, or preferably wheel), like my sample app, and upload it to pypi you can have them simply do python -m pip install --user <yourpackage>
that's only a problem if you have pinned dependencies that conflict with others they have installed.
Yeah but I just feel like it's yucky to pollute a user's system site packages
Though if you really wanted to ensure isolation you could create an installer packages with no deps that creates the virtualenv and installs your "real" app there
Or maybe just vendor everything into a zip? I have some kind of recollection that that might be a thing someone can do, if they were so inclined ;)
anyway... I'm off for dinner, rbrb
Yeah I mean I think the simplest thing to do what I want is...just make it so that when it's installed it gets a venv created in its directory and the shebang for the python file just points there
thanks for the chat!
rbrb
01:56
hi
wim
wim
hello
@wim respect, yo.
wim
wim
going to PyCon?
I... just don't have the time.
I feel like my travel budget and time off needs to go to me going back to see my family.
wim
wim
@AlexanderReynolds check out pipsi
(seems to be exactly what you're describing)
02:05
@wim Ah I've heard of that on one of the python podcasts, good call! Ty.
 
1 hour later…
03:30
It's weird that there's an emacs SE but only a Vim beta
Does this prove vim < emacs? :D
 
1 hour later…
user11093202
04:52
lol
07:41
hi, cabbage, how is everyone today?
cbg, banana
What's up @ParitoshSingh, any interesting code today?
hey, sadly nope. Dealing with the "overhead" today.
I figured out something weird today. Apparently, my graphs can have backgrounds.
In business, overhead or overhead expense refers to an ongoing expense of operating a business. Overheads are the expenditure which cannot be conveniently traced to or identified with any particular cost unit, unlike operating expenses such as raw material and labor. Therefore, overheads cannot be immediately associated with the products or services being offered, thus do not directly generate profits. However, overheads are still vital to business operations as they provide critical support for the business to carry out profit making activities. For example, overhead costs such as the rent for...
this overhead?
or this one?
either way, I like reading dilbert :D
07:56
@Aran-Fey Thanks for the -1, improved it a bit, along with docs references.
oh, that question. I didn't realize that was your answer :D
eh, bad answers are bad answers, doesn't matter who wrote it :-p
and you get a badge!
I'm not a fan of the word in listOfWords[0] thing, because if the OP really has a list with only 1 element, there's something fundamentally wrong... pretty sure they actually need any(...) there
Yeah, realized that, so added another recommendation for the function case (& not just special case)
08:02
then again, the question is pretty unclear... if it wasn't for the accepted answer, I wouldn't even be sure what the OP wants
yep, 2013, I was a little hungry for rep back then :-p
weren't we all
And now I'm gonna get a badge for this... (score of 10)
Glad it's for the improved one though :-p
08:17
@Aran-Fey no
not even a little?
...hold on, let me clarify: weren't all of us who already had an account in 2013 a little hungry for rep :P
Andras has had no time for silly internet points :-p
@Aran-Fey ah! :P
^ Seems like a useful question to me. Only needs a minor edit.
Better get rid of this one:
stackoverflow.com/q/28210333/1222951 no MCVE / umpteenth "I shadowed a builtin" question
oof, I was in the middle of editing that
@coldspeed I deleted it..
@Aran-Fey closed
09:45
@U9-Forward please abide by sopython.com/wiki/cv-pls and respect the 10-minute grace period
it's fine in the SOCVR room though
@AndrasDeak Sprouts, i shouldn't do that again, it's okay in SOCVR right?
I told you once
Is there a way to use Pandas insert using the header like df['header'] instead of the integer location of a column?
Turns out there is a get_loc funtion
10:02
@mtbrands Yeah
@mtbrands
df = pd.DataFrame({'header':[1,2,3]})
df.insert(df.columns.get_loc('header'), 'a', [4, 5, 6])
print(df)
10:25
 hello

    x = [url1,url2,url3,url4,....url50]

t2 = datetime.time(datetime.now())
    print("before : ",t2)

    for key in x:

            y = test1.query.filter(test1.url == key).all()
            if y:
       	    print('----i got it')
            else:
                print('no')
t3 = datetime.time(datetime.now())
    print("after forloop  : ",t3)

    >>>> this process take 5 Seconds on LOCALHOST with 1 client where my Database have 1 entire only ( postgreSQL )
x = [url1,url2,url3,url4,....url50]

    t2 = datetime.time(datetime.now())
    print("before : ",t2)

    for key in x:

            y = test1.query.filter(test1.url == key).all()
            if y:
       	    print('----i got it')
            else:
                print('no')
    t3 = datetime.time(datetime.now())
    print("after forloop  : ",t3)

    >>>> this process take 5 Seconds on LOCALHOST with 1 client where my Database have 1 entire only ( postgreSQL )
sorry couldnt edit the first one and i cant delete it now
what is the best way to optimize this process
@za001a making the query faster, but you are not showing us that code
@tripleee that is the exact code as i have it
when i do read the t2 and t3 , the difference is about 5 s
but the part which is taking time is test1.query.filter() which we can only speculate about ... how are you connecting, are you using an ORM, how is the database configured?
10:41
from flask_sqlalchemy import SQLAlchemy

class test1(db.Model):
        id = db.Column(db.Integer, primary_key = True)
        url = db.Column(db.String(255))
        code = db.Column(db.String(255))


        def __init__ (self,url,code):
            self.url = url
            self.code = code
@MartijnPieters sorry for pinging here, did you see my request to reopen over on meta? (maybe follow up in SOCVR)
how are you connecting, <del>are you using an ORM,</del> how is the database configured?
10:55
@tripleee huh ?
@za001a you have now revealed that you are using SQL Alchemy, but the other questions are still open
11:18
@tripleee i'm not sure what do u mean ?

all i do in the front end is just a simple AJAX
on the backend's code , i have added above
11:51
@za001a I'm no DBA but for anyone to say anything meaningful about this, we would need to know more details. For example, are you connecting to a database on localhost with low latency, or is the one-second turnaround an amazing performance against a remote database in Australia with poor connectivity?
(replace Australia with Svalbard if you are in Australia)
12:02
@tripleee i think localhost is always "low latency" .. the database itself is on Heroku's server.
free account of course as it's a test
"Free account" sounds like "a remote database in Australia with poor connectivity"
@AndrasDeak so you are suggesting that the python code itself is not usually that slow " i shouldn't worry about it and it will be fixed right after i setup up my system on USA/UK server ?
there is no guarantee but the code you posted cannot be usefully optimized, it's the database which is or isn't slow
@tripleee so you are saying the code is at it's best shape right now ?
12:18
@za001a yes, the only thing which can be optimized is the query which we don't have the code for still, nor do we still know how you are connecting to the database or what sort of latency to expect
@tripleee
app.config['SQLALCHEMY_DATABASE_URI'] = "postgres://***"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = "True"
db = SQLAlchemy(app,session_options={"autoflush": False})
i think that is everything that is related to the db
I would say go run it in production and see if it's still too slow; then maybe think about how to optimize; but then it's probably more of a Postgres topic than a Python topic (and like I said, I'm no Postgres expert)
unless you can demonstrate that SQL Alchemy has bugs and creates suboptimal queries
 
1 hour later…
13:44
cabbage
@toonarmycaptain Read that you were going to PyTexas, have you been before?
@Dodge No, why?
I'm considering making the drive from the panhandle and wondering if it is worth it.
@Dodge Apart from my presence I have no metric by which to recommend. I'd like to think that was plenty, but that opinion might be contested.
13:53
laurel
Haha, my wife went to school in College Station so she has tons of friends she wants to see and is actually encouraging me to go. The other bonus is that I'm in my last semester of grad school so I could still get a student discount.
m8_
m8_
Morning! In pandas, is it possible to do something like df.loc[df['colA'] % 1 == 0, 'colA'] = df['colA'] / 100?
That exact statement returns TypeError: unsupported operand type(s) for /: 'str' and 'int'
well, the datatypes inside df['colA'] seem to be strings.
m8_
m8_
yeah, some are. some aren't
but I have to leave the strings
but you can't do arithmetic on string
14:02
df['colA'] / 100 So, this statement isnt leaving strings out. it tries to divide every value it sees.
m8_
m8_
right, so is there a way to ignore the strings?
idr the syntax off the top of my head, but yes
m8_
m8_
or only perform the operation on numerics
a quick search should get you what you need
m8_
m8_
haven't been able to find anything. I'll try looking again
14:03
what are the strings?
m8_
m8_
sometimes 'NA', sometimes 'greater than 30%' or some other %
maybe I could wrap that statement in an if and check if it's a number?
before performing the calc?
Can you create a new column where you have converted to numeric and all of the strings will be NaN and then fill NaN with zero and then divide?
m8_
m8_
hm, that's an idea. I just have to then put the strings back somehow
instead of doing it that way, your idea of some kind of "if"/condition was close.
only select the relevant columns, and do calculations on them.
m8_
m8_
ok, thanks. let me try that
14:12
I though you had a single column with mixed data types?
When text preprocessing is there a way to separate combination of letters followed by a number without a whitespace?
import pandas as pd

data = {'a':[1,2,3, 'four', 5],'b':[1,2,'three',4,5]}
df = pd.DataFrame(data)

df.loc[:, 'data'] = df.loc[:, 'a'].apply(lambda x: x/100 if isinstance(x, int) else x)

print(df)
     a      b  data
0     1      1  0.01
1     2      2  0.02
2     3  three  0.03
3  four      4  four
4     5      5  0.05
@Dodge Sounds like a plan to me. I literally know noone IRL in this hemisphere who knows Python/codes professionally, so I'm hoping to meet some folks :)
@mtbrands yes, if you can figure out what criteria you're segregating on, you can write it. is it segregation whenever the number appears?
m8_
m8_
@Dodge, yes, one column with mix types.
14:17
@toonarmycaptain Cool, I'll make sure to ping you if I am there and we can grab a coffee or something
m8_
m8_
I'm trying to understand your code...what is col B for?
@m8_ nothing, it could be removed actually, I was just trying to show how you can check dtype with a lambda
@ParitoshSingh It is, but it can be any letter and any number. If possible also lowercase letters followed by uppercase letters. I know how to do it for specific letters and numbers but not for unspecified ones
@Dodge Sounds good :)
m8_
m8_
gotcha, it works with my data. thanks!
I need to learn lambda...
14:19
they're just functions really.
@mtbrands yep, that is no issue. Regex provides one way, and python contains many string checks such as isdigit or isalpha for another route as well.
yeah just an unnamed throw-away function
@ParitoshSingh Ill check it out thank you
Sam
Sam
I've instantiated an object in my script a = SomeObject() .. Inside PDB, is it possible to run something like a.someObjectMethod() exclusively in the command line and step into that function with the debugger at the same time?
Something like this works for example. @mtbrands but you may want to refine it based on your needs
import re
test = "abcABC123"
result = re.findall(r"[a-z]+|[A-Z]+|\d+", test)
print(result)
#['abc', 'ABC', '123']
@Sam I've never tried, but if you put breakpoint() in the method, it might work?
Sam
Sam
14:30
@toonarmycaptain The method call isnt actually inside the script, I just wanted to step through it in a virtual debugging envrionment, its straight forward enough in PyCharm... but I'm trying to use the CLI
i love regex101 for writing and understanding regexes, its pretty handy.
@Sam I read somewhere that hitting breakpoint() will drop you into pdb? So if you put it in the method definition, and you trigger the method call in the console/CLI, it might work how you want?
Sam
Sam
That makes sense I guess, thanks
15:06
breakpoint() is 3.7 or later
Interesting, type(mod.myclass) != type(app.mod.myclass) even though they are the same class just imported via from app.mod import myclass and from mod import myclass.
wim
wim
MCVE
that should never happen for class objects
(it can happen, in theory, but doesn't happens in practice due to the way the import system works)
PyDev console: starting.
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
>>> from student import Student
>>> plain_student = Student('plain')
>>> from dionysus_app.student import Student
>>> full_student = Student('full import')
>>> type(plain_student) == type(full_student)
False
NB This is in pycharm's python console, but I don't see how that would change things too much..
That's odd. Shouldn't Python be raising an ImportError?
>>> type(plain_student), type(full_student), please
15:44
>>> type(plain_student), type(full_student)
(<class 'student.Student'>, <class 'dionysus_app.student.Student'>)
Peas.
Oh okay, I get why there wasn't an ImportError.
is it possible that BeautifulSoup doesn't return all the html?
I'm searching manually within the code and there's no class, nor tag I'm looking for, and it definitely exists on the page
My issue was that I have a class Class with add_student method that can either take a Student object or instantiate one from parameters. And it wasn't adding to the class.
>>> from dionysus_app.class_ import Class
>>> d = Class('d')
>>> d.add_student(plain_student)
>>> d.students
[]
>>> d.add_student(plain_student)
>>> d.students
[]
>>> d.add_student(full_student)
>>> d.students
[dionysus_app.student.Student(name='full import', avatar_path=None)]
@PawelFlajszer, it is possible. What parser are you using?
15:56
@SeanFrancisN.Ballais tried html5lib, lxml, html.parser
doesn't make any difference
Maybe it's with the tags you've passed to BS4.
there's a big chunk of html missing, for sure
url = []
for i in range(0,1):
    url.append(f'https://www.filmweb.pl/user/pflajszer/films?page={i+1}')
    req = requests.get(url[i])
    soup = BeautifulSoup(req.content, 'lxml').prettify()```
Hmm I guess this is part of Pycharm's I-know-about-your-project magic, because from the same cwd in cmd I do get a ModuleNotFoundError when I try to plain from student import Student
same with urllib.request
 
1 hour later…
17:26
I thought LBYL stood for "leap before you look"
well that changes the concept entirely
cabagge
I have a simple question about mutable objects, like list
why does the id change in x=[1,2] and x=[3,4] but not in x.append(4)
the id of x?
It seems the list can be mutable and immutable depending on how you update it, even though the end results are the same
x = [1, 2] assigns to x an object that gets an id
17:36
@piRSquared id(x) sorry
x = [3, 4] assigns to x a new object that gets a new id
x.append(4) means "add 4 to this existing list". x = [3,4] means "create a new list and assign it to x".
x.append(4) takes the existing object that already has an id and appends another element.
@samayo see nedbatchelder.com/text/names.html for an explanation of how variable names work in python
hmm...
Thanks all
@Arne Nice guide
17:41
You're welcome =)
the += operator might be of use to you as well
 x = [1, 2]

print(id(x))
x += [3, 4]
print(id(x))

# 139781992342280
# 139781992342280
I'm pretty sure that'll only confuse them more...
lol, maybe (-:
Could anyone suggest a good way to learn object oriented Python?
🤔 imo Python and Object Oriented Python are one and the same
wim
wim
17:48
how do dumbass answers like this get so popular stackoverflow.com/a/5790954/674039
Because 170 dumbasses like me searched, found and upvoted it
wim
wim
the question literally didn't say anything about performance, and the timeit is the only content in the answer, and 171 people found that useful?
There is no mystery to it
There is no way 171 people found it useful. More like most of those 171 people found it entertaining.
17:59
I see. I just try to write a program that search optimal solution to one problem.
@wim huh, TIL {*()} will make an empty set.
If I have a CLI and need to take an arbitrary number of pairs as input...e.g., (ipaddress, filename) pairs...what do y'all find more common/natural: script.py ip1 fn1 ip2 fn2 ... or script.py ip1 ip2 ... fn1 fn2 ... ?
I saw this ad and thought it said "JUPYTER NOTEBOOK LOL"
wim
wim
that's exactly what it says
I read it 3 times now it still says the same
LOL
<redacted>
18:04
the text outside of the picture says "Jupyter Notebook 101"
i finally got it. had to read 4 times
wim
wim
text outside pic is wrong
@AlexanderReynolds are you using argparse? or just trawling sys.argv like an animal
@wim what do I look like, a heathen? argparse
oh!
You can use nargs='*' with optionals!
That's probably best eh? script.py --ips ip1 ip2 ... --filenames fn1 fn2 ...
@AlexanderReynolds The 1st way. The 2nd way is too fragile: it's too easy to mess up the input in undetectable ways.
wim
wim
18:08
either way you're gonna need post-processing
to make sure they zip up
wim
wim
nargs="+" better for nonempty btw
probably for this case I would consider loading from a config file
yeah thats right, i always have to refer to the docs to remember whether + or * is the one that raises an error when nothing is provided
I know not argparse... but could you specify an even number of arguments and take them in pairs
wim
wim
there is no good argparse story for "load in something like a python dict"
18:11
@piRSquared I don't believe so. I mean I'll just have to manually parse that.
which I mean, it's two lines of code so w/e.
Your data consists of (ip, fn) pairs, so read it that way. Having 2 separate lists that have to be synchronised exactly is just asking for something to go wrong.
Cool, thanks y'all for opinions. That's kinda what I figured originally, but wasn't sure.
does click or any of the other CLI tools do this I wonder?
doesn't look like click does.
idk but I was thinking --ips ip1=fn1 ip2=fn2 ...
yea can use = or : and parse that out. I think I just like spaces tho.
wim
wim
I thought of that but ip:something looks to me like something should be a port not a filename
wim
wim
and your users have to remember if it's ip=fn or fn=ip
annoying
also 192.168.1.1=data.csv just looks weird to me lol
@wim I mean that's going to be the case anyways, still going to need to know the order
wim
wim
and it's not unthinkable that you might want to use hostnames or aliases instead of ipv4, when you won't be able to distinguish them from files
if you use spaces --ips ip1 fn1 ip2 fn2 ip3 Note the extra ip3
args = 'ip1 fn1 ip2 fn2 ip3'.split()
[*zip(*[iter(args)]*2)]

# [('ip1', 'fn1'), ('ip2', 'fn2')]
@piRSquared yea I plan to check the lengths.
or use zip_longest and error on a None.
....eh no, that seems dumb in hindsight. I'll check the lengths lol
@wim not possible for what I'm doing
Will be easy to raise ConnectionError though as I am making a web request to said IPs when the program starts up.
wim
wim
18:40
programs that insist on ipv4 annoy me
usually I should be able to use aliases from my hosts file or ipv6 without your program caring
I mean, unless your program is something doing the DNS management and has a good reason to care :P
Well, my program doesn't care
but it's a lightweight websocket server that's running on an embedded device
so it can call itself whatever it wants. just I'm not going to alias it.
wim
wim
my point is if you think you can distinguish filenames and ip addresses, you shouldn't, so try to think of an interface where you don't need to do that at all
I don't think that I can?
I never said I was going to try and figure that out from the args.
wim
wim
true
anyway there is no particularly good argparse story for "list of pairs" either (which is even weaker than "something like a dict")
yeah. kinda meh. I could do a config file but.................................
nah
I mean this is a tool for maybe 1 or 2 other devs to use. If they call it wrong when the argparse help is clear, not my problem. lol
19:34
o/ @coldspeed
Short question. I have a file containing a couple of classes. I import it via from folder.file import classes. Now I'd like to asign one of the classes based on previous inputs. Currently I'm using globals()[input] but it feels somewhat clunky. I probably should redesign but still wanted to figure a neat way to implement it that way. Any suggestions to do it less "clunky"? or is that pretty much it.
use a dictionary of your own instead of globals
wim
wim
@Kevin would you prefer I edit your answer directly or add late answer?
@ParitoshSingh not that memory is a big concern but wouldn't that basically mean I have the same object loaded twice? But yeah that would probably the easiest solution. While designing I had something reflection like in mind but I feel like that's not really a thing in python?
@wim I think your answer is sufficiently different from Kevin's to warrant being its own post rather than an edit
wim
wim
19:40
@Vulpex no it wouldn't mean the same object loaded twice
OP probably didn't realize they asked 2 fairly different questions
@wim once from the imports and once from the dictionary or am I having a wrong thought here.
wim
wim
@Vulpex wrong - only once from the import
assignment makes references to the same object. thats the python way.
Ah okay. Then having a dict will probably be the best solution.
I think we need more context here... I'm not sure what that dict has to do with your imports. Are you planning to store imported modules/classes/functions in that dict?
19:42
thanks :)
Also, reflection sounds like a bad drug :P Im not familiar with it sorry. sounds like one of those monkey see monkey patch enabling things.
Well I'm more experienced in C# and reflections is a rather common solution there so I thought to access the object based on the input via reflection. @Aran-Fey I was trying to get rid of a `globals()[index] do access a class I used within an import. meaning I don't know which class exactly I need until it's being input by a user.
okay cool. so python has introspection, allowing you to examine. similar to reflection, except no modification
never realised ive been using it. essentially dir exposes all attributes of an object in python.
anyways, thats a bit of a tangent
you're asking the user for a class name, and then importing that class?
In that case I'd say using globals()[index] is... fine, as long as you're sure the user can't gain access to something they're not supposed to have access to. Like, if the user somehow manages to instantiate an AngryDinosaur instead of a FluffyTeddybear, you might have a problem
I've all classes imported in the beginning, during the user is able to configure his own instance and depending on his configs I need to access a different class @ParitoshSingh
19:47
On the other hand, if you use a dict then you can be 100% certain that the user can only access the stuff you put into that dict, so it's more secure
@Aran-Fey the userinput is defined by an array of valid inputs, so no chance to have him input something wrong.
wim
wim
smells like probably a "keep data out of your variable (class) names" thing
To be honest I should just redesign that part of the code entirely but well, wanted to have it get done the way I started for some stubborn reason.
instead of an array of valid inputs, perhaps a dictionary of valid inputs?
expose the key names to user
would be easier to maintain i imagine. (disclaimer, i dont quite get the whole picture yet)
but, if you start from there, you already have the correct classes tied to the key names in the dict itself
Well it's basically a discord bot, user's are able to set up specifics in an config, stored in an MySQL DB. Depending on the settings stored there I need to access a specific class. It's not well designed. That project is from the beginning of my python experience. Many .NET influences there :/
@wim don't quite get it, can you explain what you mean?
19:52
ah. Well, frankly either ways that sounds good, its great to build something and get it up and running. As you go along, im sure you can probably refactor things that you end up disliking.
I have many applications where I need to select a class from among many candidates. Usually I create a registry of some sort so that I can find the class by some sort of tag, or by iterating over a list of candidate classes and testing each for a match based on some context criteria against class-level match values in each candidate class.
Having the user specify an actual class name feels weird on several levels.
Hi all. Yesterday I posted a question, and I was able to come up with a solution. Is it possible for you guys to have a look at it and give some feedback? Any feedback is welcome. As a beginner I'm looking to learn as much as possible.
https://stackoverflow.com/questions/55468376/how-do-i-change-using-for-loops-to-call-multiple-functions-into-using-a-pi

This is the question I made
Well I define the names, he just has to select the one that fits. The idea was to implement it like an interface to enforce specific properties that have to be available. Then have classes implement that interface and from there be able to provide a selection. Didn't quite get the interface part to work though. But the idea has been to write the method just once and get the results I need.
But yeah I guess having a dict with the classes would be the "most elegant" solution for this. Or refactor :)
@scientific_explorer We generally avoid very recent questions in chat here. sopython.com/chatroom <- rules. Having said that, that question doesnt really fit SO, but perhaps you may want to try codereview.stackexchange.com sister site if you have working code.
@ParitoshSingh Thank you for that. I apologize. I will cross post there.
19:58
cls = next(_cls for _cls in list_of_possible_classes if _cls.__name__ == what_the_user_asked_for)
If you want the users to think in class names. Personally I dislike this, as it prevents me from changing the names to something else later.
wim
wim
nice one, you just implemented a dict with O(n) lookup
@PaulMcG that's an interesting solution. Well as said, I define the list of names, they just get to choose one so no headache for me on the user define class names part.
yeah, making the user "select" is definitely better than asking them to input a string that has to be inferred or linked
They have to "write" it in the discord chat but only the ones I defined are accepted and replaced with the string I defined in code, that should avoid all sneaky ways.
@wim When n is small, who cares? I don't expect the users will be choosing one of 2 million class names.
20:02
@PaulMcG less than 10 ;) O(n) is more than fine.
It was a little scary but ok
First a real python then master the programming language!
Someone should teach a python to program a python bot in python python
@piRSquared cbg! Been a while :)
Do you like flask or django better
I vote flask but haven't done much with django
both are good, and have their uses. i prefer flask too, similar story.
20:13
Flask just seems more fun to use
@scitronboy PYRAMID
@wim ah you asked about the crud frameworks, none actually, I've often reimplemented them from scratch for each use. Easy to do with traversal.
TIL raise <new exception>('new error message') from <old exception>
>>> try:
...   [][0]
... except IndexError as e:
...   raise IndexError('new error message') from e
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
IndexError: list index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
IndexError: new error message
20:28
cbg
@AlexanderReynolds also from None
What's the point of from None? Is it different from just raise <new exception>('message')?
@AlexanderReynolds it removes the traceback
@AlexanderReynolds @poke invented that ;)
thank goodness poke
28
A: Python print last traceback only?

pokeThe perfect question for me. You can suppress the exception context, that is the first part of the traceback, by explicitly raising the exception from None: >>> try: raise KeyboardInterrupt except: raise Exception from None Traceback (most recent call last): File "<pyshell#4

"bug request", to quote the man himself :D
@AlexanderReynolds bugs.python.org/issue6210
@AlexanderReynolds so we can all blame poke'
cool.
learning new stuff every day!
20:37
the exception chaining is very kool. Python 2 sucked so bad because it lacked the implicit chaining
@AlexanderReynolds always use python -mpip ...
well the right Python versions weren't even being run even when specifying the full path to the Python executable
i have no idea what was going on.
his point is that you messed up earlier during install
yeah, probably. not even sure what I did
21:01
It's a historic day today: I posted my first eval answer
hi guys, is there a faster algorithm of sorting a stack than O(N**2) ?
easy O(n log n) by turning the stack into a list, sorting that, then turning it back into a stack
looooooool
thanks
brain is fried
excuses
@wim I don't really love how the help messages for my address, filename pairs on the CLI...blah
positional arguments:
  ADDR FILENAME pairs  IP:PORT FILENAME pairs (optional PORT); e.g.
                       192.168.2.1 data1.csv 192.168.2.2 data2.csv
wim
wim
21:21
@AnttiHaapala none actually is what I feared :(
One problem I've hit with the exception chaining thing is it uses new syntax
so it's impossible to use in cross-compat code
@AnttiHaapala I haven't tried pyramid. I'll have to try it. I like their "Start small, finish big, stay finished" tagline.
wim
wim
I would have preferred the feature was added in such a way that libraries which support 2.7 as well could have actually used it too
instead, you have 2 choices, both bad: 1) use the exception chaining in your_mod3.py and duplicate your code in your_mod2.py, conditionally importing one module or the other. 2) generate the code string and exec it.
22:09
cbg
python needs math.aleph_0 as well as math.inf
math.inf's been added in 3.5
wim
wim
22:25
ℵ₀ is almost a valid identifier
ALEF SYMBOL is ok but the SUBSCRIPT ZERO ruins it
23:11
@AnttiHaapala Yes, blame me!!
@wim it also needs the special meaning that math people will associate with it, and not used as a random var name.
wim
wim
23:48
user screwed their system python so bad that pip list output is corrupted

« first day (3091 days earlier)      last day (2079 days later) »