|
Plorkyeran posted:What makes you think that? I'm not sure what made me think that, and I realized after I made the post that that part didn't make sense, which is why I edited it out.
|
# ? Nov 19, 2013 01:59 |
|
|
# ? May 9, 2024 16:12 |
My IDE suggested I rewrite my conditionalcode:
code:
|
|
# ? Nov 19, 2013 02:39 |
|
fletcher posted:
|
# ? Nov 19, 2013 02:46 |
|
fletcher posted:My IDE suggested I rewrite my conditional Should be fine. When the key is not in the dictionary, then .get() returns None, which is treated the same as False for the conditional.
|
# ? Nov 19, 2013 02:50 |
|
My Rhythmic Crotch posted:That's generally the recommended way. I'd change the variable name to active instead of is_active, though. "If not active: do stuff" - it may as well be English. But that has different behavior if key is not in mydict. fletcher, maybe you should use a set of active (or inactive) things and do if 'key' not in actives? It depends on what you're trying to do, what the 'default' semantics are, etc.
|
# ? Nov 19, 2013 02:52 |
|
Opinion Haver posted:But that has different behavior if key is not in mydict.
|
# ? Nov 19, 2013 02:58 |
|
My Rhythmic Crotch posted:I'm just going to quote this page, replacing PHP with PML. And exactly the same thing could be said about templates in any language.
|
# ? Nov 19, 2013 03:01 |
Opinion Haver posted:But that has different behavior if key is not in mydict. It's a boolean, doesn't always have to be in mydict though. Variable name corresponds to a field on a REST API. If it's not specified (key does not exist in mydict), I don't want it to # do stuff. From the replies it sounds like the IDE is suggesting something that is not a logic neutral change.
|
|
# ? Nov 19, 2013 03:02 |
|
If you want to compare against a boolean explicitly, always use foo is False, as lots of things can compare to False that aren't actually False.
|
# ? Nov 19, 2013 03:08 |
|
Thermopyle posted:And exactly the same thing could be said about templates in any language. No? The issue here is that the entry point is a file on disk inside your htdocs: foo.php. In contrast, most Python frameworks are deployed so that the code and templates are entirely divorced from the resources you access with GET, and it's rare that somebody will have Apache configured so that foo.py will spawn off a Python instance.
|
# ? Nov 19, 2013 03:10 |
Suspicious Dish posted:If you want to compare against a boolean explicitly, always use foo is False, as lots of things can compare to False that aren't actually False. Ahh that makes sense, thanks!
|
|
# ? Nov 19, 2013 03:12 |
|
Suspicious Dish posted:The issue here is that the entry point is a file on disk inside your htdocs Why are we assuming that is what we're talking about? I mean why would we assume that some company some where wanted to do something like PML as something that would be directly served by Apache or something. That doesn't seem like a reasonable assumption to me, but maybe I'm missing something.
|
# ? Nov 19, 2013 03:28 |
|
You embed the code directly into the HTML precisely because you want Apache to just serve it. Basically, gently caress anybody who tries to PHP-ize Python, which is exactly what that PML stuff appears to be.
|
# ? Nov 19, 2013 04:38 |
|
Please god don't PHPize anything. I don't know poo poo about web dev or programming and even I have heard how much PHP sucks.
|
# ? Nov 19, 2013 04:41 |
|
My Rhythmic Crotch posted:You embed the code directly into the HTML precisely because you want Apache to just serve it. I don't see how one follows from the other. My Rhythmic Crotch posted:Basically, gently caress anybody who tries to PHP-ize Python, which is exactly what that PML stuff appears to be. Agreed. I just don't see why anyone would assume the point of this hypothetical PML was to PHP-ize python. It seems like a simplistic attempt to create a out of band templating system to me. I mean, there's already templating systems out there that use python in html exactly as I'm suggesting was the obvious intention. Anyway, its just a dumb job interview question and there's no reason to read more in to it than that. If we're going to argue about it, we're just arguing about the hypothetical intentions of hypothetical people.
|
# ? Nov 19, 2013 04:57 |
|
the posted:
I don't think that your solution satisfies the problem's constraints, and you should probably redesign it anyway. Here are some vague comments: A) You don't need two opposite-value bools B) You don't have any comments anywhere C) You definitely shouldn't use a chown and a static file name. D) Your employer would probably be more impressed if you put this script in a function, and the function could be activated if you called this file from the command line. This gives the script a bit more versatility. E) What happens when a line has multiple instances of <pml> and/or </pml>? I mean something like: <pml>print "This code will run"</pml><pml>print "This code will never run"</pml> F) You're explicitly calling tmp.py every time that you read a </pml>, and you are continuously appending to tmp.py. This allows you to have access to variables defined in earlier pml blocks, but it also means that all of the code in earlier pml blocks is going to rerun every time. I doubt that this is the behavior that they want. G) Their instructions explicitly state that your interpreter "should be able to handle indentation dependent upon the first non-whitespace line of python code." That means handling the initial indentation too, even if you think that it's pointless. QuarkJets fucked around with this message at 07:58 on Nov 19, 2013 |
# ? Nov 19, 2013 07:56 |
|
I took a crack at that PML problem for fun. It only handles documents with pml tags that exist on their own lines, but I wanted to keep the implementation fairly simple. Here is what I did:Python code:
XML code:
XML code:
|
# ? Nov 19, 2013 17:28 |
|
Dominoes posted:QT issue - I'm trying to make doubleclicking items in a tree widget do things. Solution: Python code:
Dominoes fucked around with this message at 18:03 on Nov 19, 2013 |
# ? Nov 19, 2013 17:44 |
|
Hey guys I just wanted to mention that we released Bokeh 0.3 today. It is easily installable via conda or pip. This particular release was mostly an internal refractor to put us on better footing for additional features coming down the road. But we did add lots of new examples, improve the docs, and squash several bugs.
|
# ? Nov 20, 2013 04:11 |
|
I'm currently using matplotlib for plotting rather than d3.js primarily because I can generate a bunch of svg/png/whatever files with matplotlib and ship them off somewhere. As far as I can tell, d3.js needs the browser in order to render. Is bokeh able to render directly to disk?
|
# ? Nov 20, 2013 16:01 |
|
'ST posted:I took a crack at that PML problem for fun. It only handles documents with pml tags that exist on their own lines, but I wanted to keep the implementation fairly simple. Here is what I did: This will break horribly if you have quoted <pml> in say JS, embedded in a script tag. I wouldn't handroll a parser here, HTML parsers will likely treat the pml tag as an unknown and will keep it around. XML parsers will be stricter. Maybe I'm misunderstanding what they want.
|
# ? Nov 20, 2013 16:29 |
|
Malcolm XML posted:This will break horribly if you have quoted <pml> in say JS, embedded in a script tag.
|
# ? Nov 20, 2013 16:36 |
|
Malcolm XML posted:This will break horribly if you have quoted <pml> in say JS, embedded in a script tag. document.write('<p' + 'ml>');
|
# ? Nov 20, 2013 16:37 |
|
Dren posted:I'm currently using matplotlib for plotting rather than d3.js primarily because I can generate a bunch of svg/png/whatever files with matplotlib and ship them off somewhere. As far as I can tell, d3.js needs the browser in order to render. Not currently. Our emphasis is really on interactive plots as well as plots that can be created and updated in-browser from python. That said, I would like to see better facilities for saving static plots, it's just a matter of prioritizing. Or finding interested new devs. Edit: I should say there is an old, out-of date, beginning of a chaco backend that was used for some prototyping. If that could be cleaned up and made to work again with the new glyph types then it would be possible. My personal plan though, is to try browser-less plot generation with phantomJS. But that won't be until sometime into 2014 unless a someone new decides to get involved. BigRedDot fucked around with this message at 17:17 on Nov 20, 2013 |
# ? Nov 20, 2013 16:57 |
|
BigRedDot posted:Hey guys I just wanted to mention that we released Bokeh 0.3 today. It is easily installable via conda or pip. This particular release was mostly an internal refractor to put us on better footing for additional features coming down the road. But we did add lots of new examples, improve the docs, and squash several bugs. Congrats on hitting top 10 on HN -- the project looks cool, I might mess around with it at some point.
|
# ? Nov 20, 2013 19:22 |
I have nearly 0 coding experience. I've done a fair bit of HTML, some CSS, and basic batch file scripting. Dabbled with PowerShell. Is Python a good first language?
|
|
# ? Nov 21, 2013 07:42 |
Red Robin Hood posted:I have nearly 0 coding experience. I've done a fair bit of HTML, some CSS, and basic batch file scripting. Dabbled with PowerShell. Yes, definitely!
|
|
# ? Nov 21, 2013 07:48 |
fletcher posted:Yes, definitely! Out of all the links and tutorials in the OP can you recommend one or a few that teaches you a few basics, sets goals for you, gives you think to do, etc?
|
|
# ? Nov 21, 2013 08:21 |
|
I don't know your background but there is some decent info in the readings here through MIT. http://ocw.mit.edu/courses/electric...-2011/index.htm
|
# ? Nov 21, 2013 13:18 |
|
Red Robin Hood posted:I have nearly 0 coding experience. I've done a fair bit of HTML, some CSS, and basic batch file scripting. Dabbled with PowerShell. I love Python and I think it's a great first language but I am surprised you are interested in it over Javascript given your background w/ HTML and CSS.
|
# ? Nov 21, 2013 16:08 |
|
Dren posted:I love Python and I think it's a great first language but I am surprised you are interested in it over Javascript given your background w/ HTML and CSS. While JavaScript is a language thats got so much growth now (as a front end dev it encompasses most of my work these days), however Python is a good language for experiencing what a generally mature server side eco system is supposed to look like. You'll be working with well tested and documented libraries most of time, where as Node and the front end in general has so much experimental kit out there at the moment, that its much harder as a beginner to separate the wheat from the chaff.
|
# ? Nov 21, 2013 18:34 |
I guess what I'm really hunting for is how to build a really basic spreadsheet pretty much exactly like Google Spreadsheet on Drive. Problem is my job is pretty paranoid about the information we would be putting in it so they want to keep it internal only. Right now we're using an Excel spreadsheet that gets locked down when one person is in it. I want to create an internal web page that can be edited by multiple users at once. I thought this would be a good chance to get some experience in and was hoping it could be easily accomplish with Python. I know this could probably be easily done with Access but I'd rather learn something in the process. Should I take this to the general questions megathread?
|
|
# ? Nov 21, 2013 18:37 |
|
Red Robin Hood posted:I guess what I'm really hunting for is how to build a really basic spreadsheet pretty much exactly like Google Spreadsheet on Drive. Concurrent editing is no trivial problem, and is essentially front end work. That said though, it really depends on what you're actually building. Is an excel sheet what you need, or is it more like data with rows & fields. If its the latter then check out Django and its automatic admin. You might get something built quicker than you realise.
|
# ? Nov 21, 2013 18:48 |
Maluco Marinero posted:Concurrent editing is no trivial problem, and is essentially front end work. That said though, it really depends on what you're actually building. Is an excel sheet what you need, or is it more like data with rows & fields. If its the latter then check out Django and its automatic admin. You might get something built quicker than you realise. I don't need any "e7+e8=e10" poo poo. I really only need editable rows and columns. Something like: Server # VHOST location recent changes change history Still think Django is a good route?
|
|
# ? Nov 21, 2013 19:12 |
|
Red Robin Hood posted:I don't need any "e7+e8=e10" poo poo. I really only need editable rows and columns. Something like: Django is, in my opinion, not a particular good route for that. Django is really designed about the server keeping a copy of the information and rendering the template that it sends back to the user. That being said, Django is so widely used you're going to get a lot more documentation for it relative to alternatives, that I won't dissuade you. * To say another way, this kind of thing will be extremely front-end javascript heavy. As a result, Django will be a lot more heavyweight than you really need (and once you know what you're doing might actually get in the way a bit). * for example, searching "django spreadsheet" actually returns relevant links: http://www.ibm.com/developerworks/library/wa-django/
|
# ? Nov 21, 2013 19:18 |
|
Red Robin Hood posted:I guess what I'm really hunting for is how to build a really basic spreadsheet pretty much exactly like Google Spreadsheet on Drive. Not to dissuade you but this seems like a fairly large undertaking. Perhaps there is a web spreadsheet product with group editing available that you could set up for your company? I know you said you have privacy concerns but perhaps google apps for business could work.
|
# ? Nov 21, 2013 21:39 |
|
Is there a trick to getting matplotlib plots to not freeze the GUI? Threading doesn’t work. I can't get plt.draw() to work. (still freezes the GUI) plt.ion() prevents the freezing, but also prevents me from closing the plot window, or opening additional ones. I'm also looking for info on changing the plot window size (without having to adjust it with the mouse after it opens). The guides show using figure() objects, but I'm trying to use a plot. Nonworking example code demonstrating some troubleshooting. Python code:
Dominoes fucked around with this message at 23:18 on Nov 21, 2013 |
# ? Nov 21, 2013 21:47 |
|
One of you is saying on the new OP document to not suggest Windows users download the python.org Windows version but to instead download a Windows-specific distribution like...well like, I don't know what. But anyway... My personal feelings on it are that when I was doing dev work on Windows I always preferred to use the official distribution and install whatever packages I wanted or needed. However, I must say that I didn't spend a lot of time evaluating other options as the whole idea of it just rubbed me the wrong way. Does anyone have any thoughts about whether recommending Windows users use something other than the official distribution is a good idea? In particular I'd like some thoughts from non-scientific users whom I think probably have different requirements than your average beginner. They're almost always whom I see talking about alternative distributions...
|
# ? Nov 21, 2013 22:02 |
Dren posted:Not to dissuade you but this seems like a fairly large undertaking. Perhaps there is a web spreadsheet product with group editing available that you could set up for your company? I know you said you have privacy concerns but perhaps google apps for business could work. I think you're right. I spoke with one of our developers and he started talking about a lot of things I didn't understand. Thanks for the suggestion!
|
|
# ? Nov 21, 2013 22:07 |
|
|
# ? May 9, 2024 16:12 |
|
I prefer the official version on Windows by default, from the perspective of a beginner with no interest in scientific computing, and later, as someone who uses it. There's no need to add scientific packages by default if you have no intention of using them. If you need them, the LFCI website makes installing them very easy. I get the impression that the target market for pre-packaged versions are scientists who have no interest in learning more programming concepts than they need to. What's the deal with @property? PyCharm suggests adding this decorator to methods that have no arguments other than 'self'. As a result, the method names are then called as class variables instead of methods, ie without the (). So, it's a way of saying "this is a class variable that changes automatically". For example: Python code:
Python code:
Dominoes fucked around with this message at 02:50 on Nov 22, 2013 |
# ? Nov 21, 2013 22:07 |