« first day (3406 days earlier)      last day (1767 days later) » 

00:34
@smci Dormant? "Last seen Jan 27 at 7:41"
 
2 hours later…
02:28
@alkasm I was looking at last question from 2015. Anyway is that question too specific and not generaly-worded or clearly-stated?
 
2 hours later…
04:17
Since dict.update() returns None, how am I able to chain a bunch of function calls in my list comprehension? Or do I have to break it over a few lines?
wim
wim
04:36
May 16 '19 at 20:41, by wim
Feb 4 at 22:35, by wim
WRITE A FOR LOOP
hey i got a quick question, has anyone here worked with the twitter api?
 
1 hour later…
06:00
cbg guys o/
 
2 hours later…
07:34
Hi Guys, I am reading that Gunicorn does not support windows OS, and Waitress is OS independant. But on my windows VM I can install gunicorn so what exactly is not supported?
Gunicorn will not run on Windows for me
It is installed, but I think it relies on fork, which does not exist on Windows OS
Ok I am looking at waitress now. and see that it logs to logger called 'waitress'. How to I check the propagate property of this logger?
Check by using the usual pycharm debugger?
No idea sorry, I've never used waitress
It is OS independant but how do I check whether I can freely use it in my commercial product?
@variable FYI attempting to run on Windows throws an error on this import which is unix-only
The same as you would with any other package; check the license
07:58
That license looks like it is about modifying and redistributing. Where do I know if I can use it to run my commercial python flask api
By any chance does anyone know why waitress is not mentioned in the flask documentation: flask.palletsprojects.com/en/1.0.x/deploying (they do mention it in the tutorial, but not in the deployment section)
:/ It took me 10 seconds to research the license for commercial use. Please make sure you make some attempt to follow it up if that link didn't help; I'm swamped with work, I won't be chasing round these questions
08:19
Hey guys
I have a dataframe which has three column A, B,C whose column C contains list of [multiple dictionaries] and I want to search column B values in key--> value of Column C. can anyone suggest me a better way to do this in 50k+ rows?
I tried
```
next(item for index,item in df['C'].iteritems() if item['key'] ==df['B'].value)
is this the right way to get the rows A,B,C if any row from B matches in dictionary value C?
08:47
Doesn't look like it'll work...
Is C something like [{'key': 1}, {'key': 2}] @loving_guy
09:06
yeah
what to try @JonClements?
@loving_guy maybe something like: df[[any(b == d['key'] for d in c) for b, c in zip(df['B'], df['C'])]] ?
can you break it down than list comprehension, so that i can see the step wise step and if there will be any error in particular line i would able to see where exactly is the error?
I could but fairly busy... sounds like it might be a good idea to try it yourself though :)
09:21
ok
@JonClements sorry to bother you but looks like code throws error KeyError: key
Then one of your dictionaries doesn't have a key called "key"...
So you might want to check that eg: df[[any('key' in d and b == d['key'] for d in c) for b, c in zip(df['B'], df['C'])]]
for item in list1:
  if item="xyz":
    foo()
is there a onliner / better way to write this code
ignoring the syntax error - what's wrong with that ?
09:39
@JonClements it gives empty dataframe as if there is no match but there are many matches as i checked some manually
    for item in list1:
      if item="xyz":
        for i in list2:
          if i =="abc:
            foo()
this is the actual code which looks ugly due to nesting, if I could wrap for and if together it would look better
@loving_guy can't help you there... given what you described your data looks like and a mock dataframe - it works for me...
can there be issue if the column B and C contains strings and it isn't matching properly?
@pythonRcpp There are many more important things to think about than how to compress perfectly good Python code. Try not to obsess about layout, and investigate using black.
I don't know... like I said - you've got the data to work through it...
09:43
"Ugly" is a state of mind. To me, code I can instantly understand is far more beautiful that elegantly-crafted but obscure one-liners that I have to think about.
@pythonRcpp is that a representative example... I mean that does kinda come down to: for i in range(list1.count('xyz') * list2.count('abc')): foo()... which seems, umm, odd...
no i just gave an example
Okay... well - apart from the odd logic - there's nothing wrong with it as it is?
for _ in (None for i1 in list1 for i2 in list2 if i1 == 'xyz' and i2 == 'abc'):
    foo()
@pythonRcpp you can technically do ^^^ - but if I saw that in production code I'd be wanting to have a word with you :)
10:11
@pythonRcpp can those items appear multiple times? If not, then if 'xyz' in list1 and 'abc' in list2: foo(). Otherwise you can spare a level of indentation by for item in list1: if not condition: continue
AAB
AAB
Hi all,
AAB
AAB
I was wondering how Paywalls really work?
For eg a user is registered on a website but he needs to pay extra for some content
so he pays and has access for a period of like say 1 year etc
@AAB how is this python-related?
AAB
AAB
So how do this work
@AndrasDeak in general
10:13
@AAB please ask in the general room.
AAB
AAB
Is it as simple as a DB entry?
I suggest a bakery
AAB
AAB
Just wanted to know how complex paywall are :P
@AAB It would be different if you had any python score on main whatsoever. But as it stands you just walked into the first room you saw to ask about a problem that doesn't even involve programming. Please be more considerate toward room culture. Thank you.
AAB
AAB
@AndrasDeak sorry about that.
Sam
Sam
10:18
Having a bit of a brain block atm. Can I use map() to lowercase all words in a variable List[List[str]]? e.g. [['please', 'help'], ['me', 'room', '6']]. I know I can do it on a single list using map
Assuming my toy example above has uppercase words in it ;')
how to extract key value of list of [multiple dictionaries] from column and save it in another column in dataframe. column A has list of dictionaries like ["key1":"New York", "key2":"Cleveland","key1":"Sydney","key2":"France"]. I want key1 values in another column in list for every row in it's respective row of column A
@loving_guy welcome back, It's me
['New York', 'Sydney']
@AndrasDeak thanks bro
I hope I m asking questions properly
not really, because I can't see a small example dataframe and I can see syntax error in your "list of dictionaries"
given the example
^^^
10:25
you've hidden it well
can you help me here?
Not until you post an MCVE.
i have told how does list of dictionaries look like
you think it's my hobby to nag you with this, but you might eventually realize that this is the absolute minimum you have to do for others to be able to help you without using crystal balls
Sam
Sam
@AndrasDeak Have you miss-placed your crystal ball AGAIN?
10:27
absolutely not
@loving_guy exactly. We've told you before that "explaining" your code and data is insufficient. We need exact, runnable code with your example. And I'm getting tired of telling you the same thing over and over again, so I'll stop, and wait and only start helping you if you produce an MCVE. Consider this a warning.
let me try again
@loving_guy take your time. If what you post can not be copy-pasted into a python shell to make me see your data (i.e. make me have an actual dataframe), you're doing it wrong.
you need to produce 1. a small example dataframe that's like your own, and 2. a list of dicts you want to use, and preferably 3. what you want to end up with
@Sam You could using a map(map(...)) but ultimately... new_list = [[el.lower() for el in lst] for lst in your_list] is preferred
Sam
Sam
@JonClements Thanks for sharing the preference
The latter reads a little nicer than a nested map I guess.
10:39
[{'key1': 'sydney', 'key2': 'cleveland'}, {'key1': 'New York', 'key2': 'Los Angeles'}][{'key1': 'Chicago', 'key2': 'Houston'}, {'key1': 'San Diego', 'key2': 'Dallas'}] are rows in dataframe column A and i want to get ['sydney','New York'] and ['Chicago','San Diego'] in respective row in new column B.
got it never mind
i believe you should create a mcve by creating a dataframe first. like : df = pd.DataFrame(...your contents.....) followed by your expected dataframe expected_dataframe = pd.DataFrame(....expected content..) along with your explanation. the mcve should be such that we just copy paste the code in the console and the dataframe is created without us adding or deleting any line of code
@loving_guy please keep this in mind next time :) thanks
@loving_guy apparently you didn't get it
Also nice that when I tried to help you with this @loving_guy I tried to get you confirm what your list of dicts looked like, and now the example you've shown isn't actually what you said you had :)
10:56
Par for the course
Would appear so :)
I had a doubt regarding accessing instagram's api, don't know which room to talk
Can it be asked over here ?
just go ahead and ask, if you're unsure whether it's ok you can check up the room rules sopython.com/chatroom
@anon_143 you seem to be a python user and I've seen you around, I think this room will be fine (with Arne's suggestion)
11:16
Ya I code in Python only :). I had issues getting access to instagram api. I wanted to fetch details of my own instagram account using access token of instagram. But the documentation has no clear path of getting access tokens. It's a bit hazy. instagram.com/developer/clients/register this url says no new registrations are allowed.
But then there are apps like play.google.com/store/apps/… which are able to get follower details using I guess some api. But I am unable to figure it out how. One approach I thought was using selenium with python and crawl and extract data from instagram.com/accounts/access_tool but crawling once's own account is a foolish approach I feel.
especially since instagram doesn't want you to scrape it, apparently
> You can't attempt to create accounts or access or collect information in unauthorized ways.
This includes creating accounts or collecting information in an automated way without our express permission.
I'd definitely try to make the API play ball
@anon_143 the banner on the last link there says that since 2017 only "basic" permissions can be requested. On the "login permissions" page it says "basic - to read a user’s profile info and media". Which seems to be fine for your use case.
it wants to send you to instagram.com/accounts/login/?next=/developer/register in order to register for the API; did you try that?
@anon_143 I can see follower stats mentioned on instagram.com/developer/endpoints/users
Ya I did that but even after that the documentation redirects to facebook developers page when trying to get access tokens. For that one needs to have an fb account, but my insta isn't linked or rather I am not on fb.
@shad0w_wa1k3r Ya but the problem is getting access token
Then you have an issue in your authentication flow. Docs - instagram.com/developer/authentication
Ok I will check, but I feel I was trying correctly. Thanks will try again :)
11:28
You need to show us the code (redacted in places, where necessary) you're using for authentication so that someone can help pinpoint where you may be wrong.
Once authentication is done, it will only redirect to your URL, nowhere it should go back to FB developers page.
@anon_143 Also, as mentioned in the docs, user only needs an Instagram account that they will authorize for you to get an access token on their behalf. So I don't see why / where / how you will get the issues (need to have FB a/c, redirects to FB developers page) you're mentioning.
11:43
just make sure you don't actually post your access token here
12:07
Hello everyone, just discovered this room, happy to join, nice to meet you all!
@CeliusStingher hi there - welcome!
@CeliusStingher cbg welcome
12:28
hello
this is the strangest cbg train we've had in a while
user10984358
5.8k user just discovering chat O_0 shows how hidden it is to get here, I only found out about this cuz I got notified saying chat is available, also Hello :)
NGL I thought someone as having a stroke yesterday when I was in here when they said cbg... I have dug and now I understand. I was very concerned yesterday.
Except for those times comments were moved to chats, I never really investigated this side of SO. So much of a green bean here. Also, melon for cabbagging me peaches and pears :D
ha, I wonder how many regulars understood that sentence without looking up the salad translation page. It took me a minute
12:40
me getting better ;)
brb
@TheNamesAlc 6-month user is more relevant. But yeah, chat is very well hidden.
@Aran-Fey I understood that one, for a change
I got peaches and pears because I thought that was adorable when I was looking at it.
I still keeping saying - whoever came up with that "cbg" stuff needs professional help :)
yeah, what a lunatic
12:58
heaven forbid they ever got to be a mod or something - can you imagine? :p
/s all around
np.interp() is just for arrays correct? https://docs.scipy.org/doc/numpy/reference/generated/numpy.interp.html
says "array-like"
I would just hate to mix things up and end up telling the grocery-man he just kevin'd me.
You wouldn't be the first, plenty of people have accidentally used "cabbage" as a greeting in real life
13:16
@Pandasncode anything that can be converted to an array is fine when numpy says "array-like"
e.g. flat lists or tuples, nested lists with a rectangular shape, etc.
Otherwise it would say "ndarray"
13:29
@CeliusStingher :p
The grocery man will get the reference. He and I have... An understanding.
He doesn't try to get you committed as long as you spend at least N amount there? :p
I'll tell you when the NDA expires.
good thing you didn't sign an NDA about the NDA
In order to avoid garbage collection problems, I refuse to sign any NDA that refers to itself. I'll sign an NDA that says I can't disclose the details of a different NDA, though.
I got 99 NDAs but can only talk about one
14:01
guys, how do I download an image from http straight to an ftp folder ?
What's an ftp folder?
user10984358
You mean some location on the network you access by doing ‘secret’ and enter an username and password?
Hopefully not admin admin ;)
admin pass :)))
user10984358
I just found my phone doesn’t have the backtick and what I thought was a backtick was a single quote :/
14:05
I'm trying to suss out whether this is a two part question. Do you know how to download an image from http straight to an ordinary folder? Do you know how to create a text file in an ftp folder? I feel like if you know how to do both of these, then you can combine them to achieve your goal.
say I have www.example.com/image.jpg
i want to download it to my ftp://10.0.42/images/image.jpg
I'm pretty sure you can do the first one with requests.get
yeah, I can download images locally...but I'm building a flask app, and I need to save the files to an ftp instead :(
So you don't know how to create a text file in an ftp folder, then? Let's concentrate on that. No need to throw images into the mix just yet.
@Kevin :)) alrgith
*alright
14:09
cbg all
that's what I got for now ftp = FTP('10.2.0.42', 'admin', 'admin')

filehandle = urllib.request.urlopen('http://examples.com/image.jpg')

ftp.storbinary("STOR" + "/images", filehandle)
but it doesn't work
missing something small ?
docs.python.org/2/library/ftplib.html#ftplib.FTP.storbinary tells me that the storbinary argument should look like "STOR filename". But the string you're constructing looks more like "STOR/images".
Presumably you need a space, and a file name after the directory name
Also, don't you need to actually login?
>>> ftp.login()
e.g. "STOR /images/coolpicture.jpg"
>>> from ftplib import FTP
>>> ftp = FTP('ftp.debian.org')     # connect to host, default port
>>> ftp.login()                     # user anonymous, passwd anonymous@
'230 Login successful.'
14:14
@Kevin yaaaaaay !!! I knew I was missing something small !!!
10 demerits to google for pointing me to the Python 2.7 docs when I googled "storbinary"
thank you guys !!!
I should add a rule to my custom CSS that renders the 2.7 docs in Windows 3.1 Hot Dog Stand, so I stop making that mistake
Oh, I guess including the login info in the creation of the ftp object handles the login
Yup, "When user is given, additionally the method call login(user, passwd, acct) is made"
14:20
Hmm if I've got a domain (or range) for a function such that x: x > 40, x != 4.7, 2 < x < 15, x = 1.2, what are the individual components called? eg x != 4.7 or x > 40 by themselves?
If it were not for the "!=", I'd propose "interval" or "subdomain". But "x != 4.7" describes what isn't in the domain, rather than what is
I guess you could write it out as "x > 40 | 15 > x > 4.7 | 4.7 > x > 2 | x = 1.2" as a rather tortuous way of working around that
(no idea whether the pipe character there is an idiomatic way of expressing piecewise domains. Probably not.)
"subdomain" shows up a handful of times in en.wikipedia.org/wiki/Piecewise so it's got some precedent
I guess "x > 40" is arguably not an interval since it's not bounded by two real numbers
@toonarmycaptain your rules for x conflict with each other, how does that work?
@Kevin - that wasn't actual Python that toon posted, just the spec for his allowed range for some variable x. Though as I recall, these were usually enclosed in {} braces.
I'm trying to make a domain/range class such that I can query it. So for 1/x the domain would be x != 0, or possible x < 0 < x, but if there are special cases to a function's allowable domain they might be easier to modify by simply adding an x =/!= caveat rather than (re)defining a bunch of inequalities.
The range is the empty set.
When I have some arbitrary and varying number of filters (like when parsing and executing a WHERE clause), I've used a cascade of generators:
filters = [
    lambda x: x > 4.0,
    lambda x: x != 4.7,
    lambda x: 2 < x < 15,
    # lambda x: x == 1.2,
]

def filter_all(filters, seq):
    gen = iter(seq)
    for fn in filters:
        gen = filter(fn, gen)
    yield from gen

data = [x/10 for x in range(100)]
print(list(filter_all(filters, data)))
I tweaked your subranges so that something would print out.
14:34
Hmm, I think we're interpreting the range terminology differently. For example, I consider 3 to be in the range, because 2 < 3 < 15. It doesn't matter that 2 > 40 fails, because you should or them together rather than and.
... Except for the "!=" component, which I guess needs to be anded in, or else all real numbers other than 4.7 would be in the range.
Oops, I meant "It doesn't matter that 3 > 40 fails"
Its been a while since I did this, but yes, dealing with OR vs AND in a WHERE clause required different treatment. OR's had to chain the generators (to get all the values), AND's would cascade them.
@Dodge I was just imagining some arbitrary constraints, but a hypothetical example would be some constraints on some machinery that happened to generally work within a certain range, and above some extreme range, with some caveats that it does/doesn't work at due to the specific sizes of some of it's components (eg resonant frequencies - don't use it at a because it will explode, and it happens to work at b because some component resonates at that low freq and amplifies the signal. )
Maybe I need to think about this a bit more. I was just thinking along the lines of define a few constraints, then test against them to see if a value was in the valid set.
It may or may not make sense to invert the logic of the blacklist, e.g. lambda x: x == 4.7, and the logic of the in_range call, e.g. and not any(f(x) for f in blacklist), because it felt a little twisty when I wrote it this way
14:55
Unrelated topic. Python devs, please invent some kind of feature that prevents me from having to choose between these:
#option 1
if a:
    b()
    x()
    c()
else:
    x()


#option 2
if a:
    b()
x()
if a:
    c()
Proposal: the always block, which may only appear directly inside an if block. Its contents execute even if the rest of the if block doesn't.
if a:
    b()
    always:
        x()
    c()
@Kevin There's finally, but that wouldn't give you x() happening after b() and before c()
option 1 is the most visually appealing of the three to my eye
#in the actual problem I'm working on, the logic is:
if cond:
    self.foo += 1
    self.x()
    self.foo -= 1
else:
    self.x()

#... But in this specific case, I suppose I could do:
z = self.foo
if cond:
    self.foo += 1
self.x()
self.foo = z
This only works if c()'s only purpose is to undo whatever a() did
And if x is guaranteed to have no net impact on self.foo, which is the case in my case
My example FancyRange - this seems fairly straightforward to me, what am I missing?
@toonarmycaptain Virtually all numbers will satisfy the any, because virtually all numbers satisfy lambda x: x != 4.7
15:09
Except that it doesn't work for the ...yes I'm dumb
My prototype separates inclusion-based rules and exclusion-based rules, because I think it would be very hard to treat all rules the same way without some introspection voodoo
@Kevin Yup, what am I missing now, apart from having to define a lambda when adding a new constraint?
If you're asking "so why doesn't this return False for all my test cases, since "x < 60" is in my blacklist?", it will return False for all numbers that don't satisfy x < 60, i.e. all numbers greater than sixty.
If you find that kind of confusing, I did too, which is why I proposed inverting the logic of the blacklist in my prototype. If the conditions are worded as x == 4.2 and x >= 60, then you can more intuitively think of them as "exclude all values that satisfy any of these"
@Kevin Nah, I was just reworking my example and thinking, apart from specific values, why would you do this, and it occurred to me you might have a range lambda x: 0<x<100 (eg percent), but it breaks between 50 and 55%, so blacklist lambda x: 50<x<55.
15:25
I think exclusions need to be descriptive of what is not wanted (x == 4.7, x >= 60), and then change all to not any.
Which I find much clearer than just allow: lambda x: 0<x<50, lambda x: 55<x<100 - particularly if that inner excluded range I just described might change, I feel the first way is much clearer.
@PaulMcG I think you're right.
If using design #1 (i.e. the one in my prototype pastebin), I don't think it ever makes sense to put 0 < x < 50 in the blacklist. The blacklist should only contain "negative" conditions, IOW conditions using != or conditions starting with not
I don't see anything wrong with a 0 < x < 50 blacklist
(in concept, that is. I didn't actually look at your pastebin code)
If 0 < x < 50 is the one and only condition of your range, then putting it in the whitelist will have the same effect as putting it in the blacklist, so you might as well put it in the whitelist for clarity.
I was meaning generally a < x < b as a blacklist, not necessarily with a=0 and b=50, which would throw out most/all of toon's example range. Like 11 < x < 12 would be a valid blacklist range in his data example.
15:31
I was going to say "If you have other conditions that conflict with 0 < x < 50, then you could do some math on paper and rephrase the subdomains in a way that doesn't require any blacklist", but perhaps that proves too much. AFAICT, you can always eliminate the need for a blacklist with a little math.
Everything should be allowed in the blacklist, or we shouldn't have one
I'm starting to feel like there's a higher-level design problem here. I'm not sure what advantage any of this has over def __contains__(self, value): return 2 < x < 15 or x == 1.2 and x != 4.7
Does anyone know a good tutorial for building a (functional) DSL to Python compiler? The Python types are well suited, but the overhead of our interpreter is getting a tad much.
Without a compelling use-case this just feels like inventing a half-baked mini language
@Kevin Well I believe if you only have a blacklist constraint, you'd need a default lambda x: True otherwise everything will be False either way.
Hmm, right. any([]) returns False, after all.
@MisterMiyagi Sounds like uncharted territory to me, I'm afraid. Compiling a domain specific langauge to Python is a problem that is, itself, domain specific.
@Kevin The advantage is I don't want hard coded values, I want to be able to set an acceptable range for the solution to a word problem, define domains and ranges for basic functions, and set test for these. Ideally I'd like to not have a lot of lambdas, but writing something that can be passed to a lambda without using exec or some parser seems like overkill for the moment.
15:43
"Write a something-to-Python transpiler" has long been on my todo list, so I'd be quite keen to learn of useful resources on that front
Hi folks, is anyone in here familiar with the python-highcharts library ? I'm trying to run the drilldown example but the drilldown functionnality doesn't work for me.
I'd appreciate any pointers
@Kevin the language semantics are basically <functions, consts, names>, so it should cover most domains, actually.
@Kevin I'll let you know if I find something
I briefly toyed around with a KevinScript-to-Python transpiler and the biggest roadblock was properly scoping variables. You can probably avoid all the hard parts there if you don't have closures
If functions can't be defined inside functions, then life is good
Alternatively, if your name resolution rules are defined as "whatever Python does", then that's easy too
it's basically a single global namespace with fully qualified names, and externally defined functions
no closure or other such modern nonsense
good old 80's DSLs
👍
I suspect transpiling to Python is just a little harder than transpiling to a language that uses curly brackets around their blocks. It probably helps to output INDENT and DEDENT tokens, and then do another pass to calculate how many spaces each one of those should be. As opposed to explicitly keeping track of indentation level within the transpiler and emitting literal spaces in situ
16:01
oh, the language has only expressions, so no need to transpile to blocks either
it's the 80s, man
# like that
{
    b: 42 * a
    a: 12
    c: ifThenElse(a > 5, b, 1337)
}
Hmm, too bad there's no commas at the end of the key-value pairs, or else it would be syntactically valid Python already
Never mind that it's semantically invalid -- you'd still be able to use ast.parse to arrange the program in a convenient tree structure. That's half the work done right there.
@MisterMiyagi Gimme a BNF and I'll cook one up, or show you how to do for yourself. If it's just expressions, would plusminus get you close? Or am I misconstruing your problem description? (actually, I'm about to rbrb for a bit, pick up again later)
Give me a BNF and I'll excitedly play with it for twenty minutes, and ultimately produce nothing of value
@PaulMcG If you could make an example for some language with, say, +, -, references/names and functions, that'd probably be of help not just for me.
mind the Kevin
16:27
FWIW my domain and range class was inspired by python-ranges which lets you use their Range object as say a dict key, so my_range = {Range(0, 5): 'low', Range(5, 10): 'higher', Range(11, 5000000): 'extreme} -> my_range[8] >>> 'higher'
@MisterMiyagi Most likely I sanded off all the parts that would make the problem difficult in practice, but here's a transpiler prototype: pastebin.com/McFp0PEe
Hmm, give me ten minutes and I'll add in function definitions
@Kevin I'm wondering whether that would be more natural with OOP
instead of having one transpiler function, each semantic element would know what expression to transpile to
Certainly there's no need to smoosh everything into one monolithic function as I've done here.
Here I employ the "calculate number of spaces in situ" technique that I specifically said I didn't want to use
16:44
transpiling to lambda might be easier
But yeah, making each node type define its own transpile() logic is definitely a sensible design. The only reason I didn't do it here is because I couldn't be bothered to construct the dsl's AST out of anything other than a jsony data structure. If you've already got a nice classful representation, there's no reason to write a monolith.
@MisterMiyagi If all of your functions only contain one statement, and that statement is a return statement, then sure, you could transpile to lambda exclusively. You could also transpile to an indentless def, e.g. def IfThenElse(a,b,c): return lol_idk(). Either way, you wouldn't have to track indent levels.
@Kevin I have a proper OOP "AST" indeed. The main thing I'm struggling with right now is that the interpreter treats constants as values, whereas it seems a compiler should treat them as expressions as well.
or in other words: I messed up and didn't separate values from expressions.
@MisterMiyagi Ok, I'm back. So far, everything you describe is in plusminus, it has 5-function arithmetic, variable references, and user-definable functions and operators. If you don't want to just evaluate the expression, you can get the AST that is built for it, by calling parse() instead of evaluate().
Perhaps I've misunderstood what "const" means in this context. If b: 42 * a needs to be able to access the value of the a const, even when a's value is defined later in the dict, then my prototype is insufficient: actually running the program it outputs gives you a NameError.
wim
wim
what's the Python-2.7 compatible version of this? glob.glob("**/*.yaml", recursive=True)
stdlib only
16:57
@Kevin the 42 is a const, the a is a name
@wim looks like nothing direct?
os walk with fnmatch
@PaulMcG I'm looking for something like compile() which gives me a Python expression/code that evaluates to the result without depending on the interpreter.
Hmm. It's not immediately obvious to me why it's a practical problem that 42 is something like Value(42) in your ast rather than Expression(Value(42)). On a semantic level, I agree that it should be an expression. But it shouldn't impact the transpile logic much. Expression.transpile's definition would basically be return self.body.transpile(*args, **kwargs) anyway.
@Kevin The problem is that treating 42 as a value means it's a MyLangInt, which defines such operations as __eq__ and __add__.
Having it be also an Expression means it also defines operations such as transpile, which is super weird.
wim
wim
@ParitoshSingh sigh...lame
was hoping there might be something lying around in glob.glob0 or glob.glob1 or glob.iglob whatever
17:06
recursive argument came fairly late into python 3 development, im guessing it was never on high priority for a backport.
I agree that it's weird to define transpile and __add__ on the same type. Python avoids this by having an ast.Constant node, whose value attribute is an ordinary float. That way, Constant doesn't need to define any numeric methods, and float doesn't have to define any nodely methods.
So, I guess, do that.
do you happen to know which part compiles static expressions, such as 42 + 1337 to 1379?
I vaguely remember vaguely that the initial idea for "Values as Expressions" was that we wanted to re-use the value operators.
so "a + b" would not be parsed to a Plus(a, b) but actually evaluate something like a + b, which would either return a Plus expression or a value resulting from the operation.
I think fold_binop is responsible for combining 42 + 1337 into 1379. It happens after the ast is constructed but before the bytecode is constructed.
Calculating a + b at compile time, given that a and b's values are calculable at compile time, is a fun concept. I don't think Python goes that far but it seems tractable.
If your DSL isn't turing-complete then you can do lots of fun things that would ordinarily end with "oops, I'd have to solve the Halting Problem first"
17:23
I wouldn't mind having an infinite loop at compile time, as long as the alternative is having an infinite loop at runtime.
so just trying an operation is not out of the question for me.
my problem with self-evaluating expressions was that suddenly expressions and references were first-class and types had to be aware of them.
and now I remember why "compile DSL to Python, try 1" went to the garbage bin
17:40
hey has anyone here worked with the twitter api?
Not at the moment, apparently
17:57
@oso9817 you asked this earlier. It's far better to just ask your specific question and people will help out if/when they can. Perhaps it's not a problem specific to that API and others can help, or someone will see it later when you're not online (people review chat transcripts frequently)
Or if your question is not just general inquiry but a specific problem you are having, post a question on main SO
@ParitoshSingh was it you looking into making .exe's out of Flask ages ago? Did you ever flesh it out into a full work-flow for distribution?
@roganjosh hey! uh, the last 4 words sound really fancy, but uh, i was able to make an exe that worked i guess? :D
The main thing is, not all libraries get linked properly, so it really depends on the packages you're using. That can make it into a simple or semi complicated task
One of my friends is working at a place where IT is dragging its feet on a really simple package that I'm pretty confident could be built in a day. I was curious whether I just make a demo and ship it over to him to play with... keeping in mind that none of them are programmers. If you're regularly distributing your apps as exe's, you might know some pitfalls because I'd rather not send something that ends up being a pain for them to run
It might be an angle for some extra contract work... but not if it falls flat on its face
@roganjosh do they have python at least?
18:06
ah. Well, just run your exe after you make it, and honestly that should get you going. If it's a simple project with not too many "uncommon" libraries, it's pretty smooth
(and yes ofcourse, if they have python, no point getting into the exe nonsense.)
@AndrasDeak I'll go with "no". But that would be bundled as standard?
yes, the exe runs everything if you go that route.
And i can at least confirm it on windows, but it's my understanding you can make an executable for all 3 os, as long as you're on that same os
@roganjosh well, yeah, but if they do have python then you could just give them 1 line of pip install from github and it would Just Work
@ParitoshSingh barring flask, flask-login and flask-csrf, I'd probably able to get away with the standard library. I dont fancy re-implementing that in case someone tried to be smart from IT. Cool, thanks for your insight
@AndrasDeak now would be a good time for you to shake your head at the generic Windows user :P double-click and stuff happens, or forget it. These guys are manually typing 14 columns of vlookups. Why? Because computers are hard
^ oh gosh that manual typing comment...
18:15
Dont tell me you've not seen this stuff first-hand :P I just need a foot in the door and then make a proper job of it. It's a punt, but might pay off
@roganjosh you could give them a batch file that does pip install from github, that's not really an obstacle
Good point. Also, now that I think about it, their anti virus might have a fit with either approach (and that's probably a good thing for the company)
I had to stop myself from throwing a fit over someone bending over backwards to suggest manual work for a POC rather than trying to even come up with a potential solution first yesterday.
It is not a fun situation to be in. Smoke and mirrors, the whole lot, this industry. mumbles away to himself
Mar 13 '17 at 10:12, by PM 2Ring
It's scary to think how many office workers waste vast amounts of time manually doing stuff that could easily be automated, like manually transferring stuff from Excel spreadsheets into other software. I can understand doing it as a one-off or rare thing, but to spend hours on it every week is insane.
And manually transferring stuff from one Excel spreadsheet to another...
mb, was trying to see if anyone knew about it before i wasted time typing it
18:24
@PM2Ring what about the people who have two columns of values and they manually calculate each row sum on a calculator and then write the value back in?
@roganjosh picard_facepalm.png
I was wondering if theres a way to stop having to reverify everytime i launch the script, it always asks to open a browser and authenticate
My best mate is incredibly knowledgeable, far more so than me, but not technical. He's just told me that their spreadsheet is 700kb and that'why it keeps crashing. That's HUGE, seemingly. In reality I'm guessing their vlookups are a tangled mess. But 8 months waiting for IT to make a db of 7k records and some interface....
I've seen more than one story where the hotshot new guy comes up with a way to reduce manual data entry by 10,000% and he's about to tell the boss, and the jaded old timer intervenes and says "do you really think he'll be happy to hear that he has to fire 90% of his department because their jobs can be replaced with one script?"
It's the same at the current place I'm at. IT is very good at just telling people how complex things are and everyone just has to live with it
18:29
When business/political power is proportional to the number of people that report to you, the last thing you want is efficiency
There was a movie, main characters were two potheads I think, I remember they were scammers they really knew nothing but all they had to do was approach their potential customers and name the idea. When the customer asked them for more stuff in detail their answer was "It's complex" and that was enough for them to sell their idea ;'(
And when I say "story" I mean "a factual retelling of something that ostensibly actually happened"
@Kevin see latter part:
Jan 29 at 19:57, by roganjosh
<grumble grumble> I get asked to come to the pub with laptop to help someone put a CV together and they go to bed within the 10 minutes it took me to get here. The hermit lifestyle gets ever-more appealing. Today I had to spend 20 minutes pointing out to management that the factory is deliberately using my production plan to make the wrong items through the week so they can get ~£30k a week in overtime to make up for deficits... then blames my system
Such is the way of things.
I'm well-aware of the push backs. For IT, I find it kinda unacceptable, though. They were the authority on systems, and it's only through their deliberate inactivity that I can arrive on something unrelated and build something else
If they did their job, there wouldn't be someone choosing to trample over them. There was nothing stopping them skilling up or working on improving a legacy system. They just have a grip. I lack sympathy for those people vs. people who can be automated out of their job with no say because the role becomes obsolete
18:38
@oso9817 Sorry, I've never used the Twitter API, so I can't offer assistance. And there doesn't seem to be much in the way of existing Python Twitter questions related to your issue on the main site, apart from stackoverflow.com/q/48391733/4014959 But there are people here who know about OAuth, and I suspect that's at the heart of your problem.
 
2 hours later…
hammered
Cheers mate :)
 
1 hour later…
21:27
rbrb
21:39
This is not me, right?
@roganjosh this is a place to comment as you did (not just tech) - shutting people down is killing the viability of this website — Rafael Da Costa 2 mins ago
I think it's one of those "I'm being reprexed" woes, phrased weirdly
It always puts me on-edge when someone plays that card, and I've really tried to be level-headed recently.... but still they come.
@PaulMcG I'm honoured.
<disengage> I need to get better at that
@roganjosh YEah, walk away mate, life's too short.
21:49
@holdenweb Agreed :)
22:01
Nov 14 '17 at 16:11, by Kevin M Granger
A junior dev writes code that takes a senior dev to maintain. A senior dev writes code a junior dev could maintain.
Is that an original Kevin M quote? I wanna borrow that
Finally I figured out the way to get access token for instagram but sadly I had to use Facebook's developer account rather than just using instagram's developer account . Because I guess instagram isn't allowing normal api and has redirected everyone to it's graph api
Isn't instagram a subsidiary now?
Yes, it's owned by Facebook. It makes sense that they would consolidate their authentication IMO
22:16
Yes, initially I didn't think of using facebook's developer account but I had to
But after digging deeper into how instagram's api works, I found some private api's which are doing the work as expected without any hustle.
"Private"?
Basically not official, I don't know about how secure it is but as of now this looks promising for my use case github.com/LevPasha/Instagram-API-python
OK, so third-party
Yes I don't knew this term. And can these api's cause problem if fb decides to remove older versions of the api ?
If FB removes that API then of course it would; you're expecting a 3rd party to fix it for you, but you'd all suffer
22:25
Ya :(
Thanks for the help guys :) It's 3:57 am now gotta sleep XD.
Interesting. I could have sworn that FB had issues with their API that blocked out a lot of devs. I can't find news on it now in Google
Nope. I don't seem to be able to find it. They're good at making things go poof :)
perhaps they exercised their right to be forgotten
22:40
Hahaha. That's given me a genuine chuckle
22:52
I guess I'll leave on a nervous laugh. Rbrb

« first day (3406 days earlier)      last day (1767 days later) »