|
It catches all exceptions. Including KeyboardInterrupt.
|
# ? Jan 8, 2014 07:45 |
|
|
# ? May 24, 2024 07:27 |
|
JOHN SKELETON posted:Care to elaborate? Why is hasattr bad? In 2.x it can return False when you might not expect it to. Some explanation here.
|
# ? Jan 8, 2014 07:46 |
|
Huh. That seems surprisingly dumb. Weird how quick Googling didn't give me anything on it either.
|
# ? Jan 8, 2014 08:05 |
|
I have a bunch of pure python data structures that will be wrapped in QObjects so they can play nicely with Qt models/views. Some of the objects only have attributes that are static strings. With these objects, how can I wrap their attributes dynamically without manually enumerating and decorating a bunch of getter methods? Python code:
|
# ? Jan 8, 2014 11:01 |
|
Suspicious Dish posted:I would never write or use this code ever,. Yeah, I wouldn't either. Sleepy posting is my version of drunk posting. I laughed when I read what I wrote last night. I don't know what I was thinking. In sane land, I'd probably just try/except, or if I was feeling lazy use basestring. edit: Upon further thought I think my idea was fine. The code is just kinda crap. Sometimes you need to make sure your objects have the behavior you want when you get them from third party libraries or APIs. You want to fail early instead of in 2 weeks at 2 AM when your server takes a rarely-used branch. I'd special-case a string check with isinstance(obj, basestring) and then try/except some sequence operations on the object to see if its a sequence unless you feel confident that you can assume if it's not a string then it's a list or tuple or whatever. I'm kind of ambivalent about checking for attributes like __getitem__ or __getslice__ or whatever, so I wouldn't yell at someone for doing that either. However, with regards to the original question about how to handle it when you might have a string or a list/tuple... Like I said in my sleepy post, its hard to say without knowing more about the API design, but in what my gut tells me is the most common case, I'd have a function with the basic functionality which is called by a function for a string and a function for a list/tuple where the string function makes a list/tuple out of the string. If the only difference between the two code paths is that you might get a list of strings or just one string, I might do away with two separate functions, check if it's a string or a list right off the bat and if so, put it in a list and then continue on with the rest of the function code assuming it's dealing with a list. Thermopyle fucked around with this message at 19:27 on Jan 8, 2014 |
# ? Jan 8, 2014 15:12 |
|
Anyone have experience working with shapefiles and numpy? I'd like to make a mask based on a shapefile, then analyze data using that mask. I'm really at a loss where to look. For example, if I have an array (gridded analysis) of current temperature across the CONUS, I'd like to take a shapefile of Texas and determine what the average temperature is in it based on the temperature array. I've tried to follow this example but just isn't clicking. Any suggestions?
|
# ? Jan 9, 2014 07:38 |
|
"Hi after spending nearly $30K on a 3 month long intranet development project written in Django, we cant afford to spend $70 a month on a decent server system and IT has deemed you have to use this lovely shonkyhost PHP3 cpanel account. What do you mean its not compatible? Our IT guy says it even supports squirrelmail so its plenty advanced, sorry its been decided". "Well it was in the loving spec document, and without it this can't be deployed, but you'll still be required to pay your loving bill. You cunts." I loving hate this industry with the fire of 1000 suns. edit: "And no you can't upload the ipad client that will be used by only 30 people all in your staff to the app store! Yes you can't refund the dev account, no I won't change my mind its not up to me" duck monster fucked around with this message at 08:12 on Jan 9, 2014 |
# ? Jan 9, 2014 08:08 |
|
Yes, hi mr. duck monster what is your question sir? You must please with asking the question.
|
# ? Jan 9, 2014 16:10 |
|
John DiFool posted:Yes, hi mr. duck monster what is your question sir? You must please with asking the question. I'm just venting dude. Feel the hateflames with me. Clients are hell.
|
# ? Jan 9, 2014 17:01 |
|
How strict are JetBrains with their open source licenses for PyCharm? I would love the remote interpreter feature. I have an open source project I'm actively developing, but their requirements include:JetBrains posted:
I'll hit the 3-month mark soon, so I'll apply then and find out what my chances are, but these two are serious hurdles. Maybe the second one if adding a "News" header to my readme on BitBucket counts, but the only other users so far are my colleagues. Maybe I can get someone to sign up for BitBucket and post an issue or something, and that will count as a "forum" post. SurgicalOntologist fucked around with this message at 17:32 on Jan 9, 2014 |
# ? Jan 9, 2014 17:30 |
|
John DiFool posted:Yes, hi mr. duck monster what is your question sir? You must please with asking the question.
|
# ? Jan 9, 2014 18:28 |
|
SurgicalOntologist posted:How strict are JetBrains with their open source licenses for PyCharm? I would love the remote interpreter feature. I have an open source project I'm actively developing, but their requirements include:
|
# ? Jan 9, 2014 18:29 |
|
Misogynist posted:Are you tracking bugs on BitBucket already? I'm pretty sure that counts. Nope, but that's doable. I'll find some bugs and post them as issues.
|
# ? Jan 9, 2014 19:18 |
|
SurgicalOntologist posted:How strict are JetBrains with their open source licenses for PyCharm? I would love the remote interpreter feature. I have an open source project I'm actively developing, but their requirements include: Extremely lenient. Have a repository with recent commits and a license file in the root directory. I filled out their little form and got my license within a day
|
# ? Jan 9, 2014 21:08 |
|
John DiFool posted:Yes, hi mr. duck monster what is your question sir? You must please with asking the question. Someday we will be able to harness Duck Monster's impotent rage into a source of energy for the entire planet.
|
# ? Jan 10, 2014 14:50 |
|
Lumpy posted:Someday we will be able to harness Duck Monster's impotent rage into a source of energy for the entire planet. Stay in this god forsaken industry long enough and you too will lie at wake imagining various ways to murder rich people using their neckties.
|
# ? Jan 11, 2014 07:28 |
|
Luckily, everyone in my generation already dreams of doing that very thing.
|
# ? Jan 11, 2014 08:05 |
|
Does anyone know how to make the python XML module not fill close tags with extraneous data? I'm recreating an XML file type that draws things on a map. Here's the output: XML code:
Code I used to generate the XML, with the bulk of the body removed: Python code:
|
# ? Jan 11, 2014 15:10 |
|
ElementTree thinks you're generating an XML element whose name is "event version...". You should be doing something likePython code:
|
# ? Jan 11, 2014 15:25 |
|
Thanks, that works. Apparently you can also append the attribute dictionary as an optional additional argument to SubElement and Element.
Dominoes fucked around with this message at 12:05 on Jan 12, 2014 |
# ? Jan 11, 2014 15:31 |
|
I need to read a bunch of excel files in python, just reading no writing/creation. It seems like there are a few packages, xlrd and openpyxl, before I dive in does anyone have opinions or advice for/against either of them?
|
# ? Jan 12, 2014 03:38 |
|
I'm looking for advice on how to store database information for a Django web app on RHCloud. I'm uploading raw text info of temporary flying restrictions, and want to store and reference them. Columns would be something like this: "id, start date, end date, category, min alt, max alt" etc. There would probably be a few thousand entries. The basic program's done; it parses the text from a webpage, sorts it out with regex, generates the required files etc. I want to store the data in a database to make sure that older info that isn't expired is still used, even if it's no longer present in the uploaded text. Should I try Django's models system? It uses databases, but the tutorials I've read are mostly about using it for an admin page, storing user logins etc. This is a webapp so it can run on work computers (RHCloud is miraculously not blocked), and interface with GMaps' JS API. I'm not sure the models system would be appropriate. Should I do the database manually? I've used sqlite before. I've read that you shouldn't use it for production use, but this would only be used by 1 person at a time, so it would probably work. Dominoes fucked around with this message at 12:57 on Jan 12, 2014 |
# ? Jan 12, 2014 12:19 |
|
Dominoes posted:I'm looking for advice on how to store database information for a Django web app on RHCloud. I'm uploading raw text info of temporary flying restrictions, and want to store and reference them. Columns would be something like this: "id, start date, end date, category, min alt, max alt" etc. There would probably be a few thousand entries. You can write your own ModelManager to handle hooking up the ORM to a remote DB. We are in the process of writing a Django app that uses a custom ModelManager coupled with SQLAlchemy to use a (*shudder*) Azure Cloud MSSQL store for our data.
|
# ? Jan 12, 2014 14:15 |
|
Do you guys think this would be a good interview question?code:
|
# ? Jan 12, 2014 18:05 |
|
No. I don't even know why that's allowed.
|
# ? Jan 12, 2014 18:33 |
|
why would it be disallowed? anyway, my intention was a short simple question that could demonstrate some knowledge of how python handles references and values
|
# ? Jan 12, 2014 18:43 |
|
evensevenone posted:No. Disallowing cyclic data structures in a language with mutation would be dumb and really slow.
|
# ? Jan 12, 2014 18:46 |
|
Pie Colony posted:Do you guys think this would be a good interview question? It's a very bad question. I had to think about this one for a bit, because the obvious answer (length=1) seemed so obvious that it was probably wrong. Also, arcane Python trivia is probably not going to get you the best-of-breed programmers who can build the things you want them to build.
|
# ? Jan 12, 2014 19:01 |
|
Plorkyeran posted:Disallowing cyclic data structures in a language with mutation would be dumb and really slow. Yeah, now that I think about, you're right. It still probably isn't a very good question.
|
# ? Jan 12, 2014 19:07 |
|
I wouldn't call it arcane, but yeah, if you're going to ask about Python gotchas, ask about the ones most people actually encounter, like mutable default arguments.
|
# ? Jan 12, 2014 19:13 |
|
I think it would be a decent interview question if instead of expecting them to know the answer and get it right, you just listen to their ideas on what might be the possible behaviors and why the different options would make sense or not. The answer wouldn't matter, just the thought process involved.
|
# ? Jan 12, 2014 21:02 |
|
Suspicious Dish posted:It's a very bad question. I had to think about this one for a bit, because the obvious answer (length=1) seemed so obvious that it was probably wrong. i won't ask it but knowing that x is a reference to an empty list instead of an empty list is hardly arcane
|
# ? Jan 12, 2014 21:23 |
|
I think it's such a weird edge case that it is trivia and therefore not worth asking in interviews. If you want to gauge someone's understanding that python is pass-by-reference ask them a more straightforward question. If you're asking it just to see their thought process in answering it then I guess it's ok.
|
# ? Jan 12, 2014 21:57 |
|
Pie Colony posted:i won't ask it but knowing that x is a reference to an empty list instead of an empty list is hardly arcane It's a bad question to prove that point, though.
|
# ? Jan 12, 2014 22:03 |
|
Now the question is, why do we get thiscode:
code:
|
# ? Jan 12, 2014 23:03 |
|
The list contains itself.
|
# ? Jan 12, 2014 23:10 |
|
So it's a recursive list...? What is that used for?
|
# ? Jan 12, 2014 23:18 |
|
Basically nothing, which is why it's a bit of a dumb question. Sometimes you do have hierarchical data structures where children have references to their parents, which means you have to be a little careful traversing them or copying then, but it's not that bad and this question doesn't really lead you to think about that anyway.
|
# ? Jan 12, 2014 23:25 |
|
What do the three dots inside the bracket mean?
|
# ? Jan 12, 2014 23:31 |
|
|
# ? May 24, 2024 07:27 |
|
It's the printer in the interpreter being smart and telling you that it spotted a circular reference.
|
# ? Jan 12, 2014 23:55 |