|
Which of the recommended IDE's tend to use the fewest resources? I'm on a 6 or 7 year old laptop with a whopping gig of ram and 1.6 GHz CPU, which really puts eclipse right out of the picture. I currently use VIM/ST2, but would love to try something new.
|
# ? Aug 3, 2013 13:40 |
|
|
# ? May 9, 2024 10:16 |
|
So a side-project at work may end up being deployed into a production environment in a hospital and I'm a little worried as I've never deployed anything in my life before. I've read around a bit and figured throwing together some unit tests, a binary and setting up a Windows service installer if I end up deploying to a win machine. A few questions though: Binary distribution: - py2exe used to be the goto, now it looks like PyInstaller is the new thing. An .MSI installer would be up to me still though. - Is there any benefit to deploying with ActivePython rather than CPython? Licensing: - Twisted - MIT, all good - PIL - Permissive software license - Could be an issue as we wouldn't be selling the software directly but included as part of a bundled tender. Switching to something like pymaging seems like a decent alternative if that's the case.
|
# ? Aug 4, 2013 02:44 |
|
ahmeni posted:So a side-project at work may end up being deployed into a production environment in a hospital and I'm a little worried as I've never deployed anything in my life before. I've read around a bit and figured throwing together some unit tests, a binary and setting up a Windows service installer if I end up deploying to a win machine.
|
# ? Aug 4, 2013 03:03 |
|
Dominoes posted:AFAIK, cx_freeze is the only current way to make binaries. Py2exe and PyInstaller are legacy. When you say legacy, do you just mean 2.X? It seems to be receiving active updates
|
# ? Aug 4, 2013 06:19 |
|
(Sorry for being a bit late with this reply; I'm at a conference right now and the internet is p. bad)The March Hare posted:On ctrl+c I want it to take the data currently in the clip board and blip it on over to the django app, and then on a separate keypress (not actually ctrl+v) I would like it to pull down the most recent entry under a certain user from the django app and store that information to the clipboard. No, you don't want to do this on Ctrl+C. What you want is to hook into the native X11 system of "when the clipboard changes". This is actually a bit complicated. Let me explain very basically how this works on X11. X11 was designed during the 80s when a megabyte of RAM cost a thousand dollars. Thus, when you press Ctrl+C in an application, the selected data actually isn't copied anywhere. Instead, the app says "I have the clipboard now". When you press Ctrl+V, the app you pressed Ctrl+V in contacts the app that has the clipboard and says "what's the clipboard contents? Please tell me." That sounds all nice and neat and conveniently sidesteps storing the memory anywhere, but there's one problem: I copy some text, close the app, and try to paste. There's no app to talk to to get the data! So, we invented this special app called a "clipboard manager". If an app has the clipboard, when it exits, it tells the clipboard manager to please take its clipboard data and store it, and thus it's around after the application is gone. The technical documentation for this can be found in the Xlib manual and ICCCM. Now, if you read all of that (you didn't, but play along), you might notice that there's no native X11 system of "when the clipboard changes". The flow is Set/Get on Ctrl+C/Ctrl+V, along with this magical clipboard manager that happens on app exit so we don't lose data. But fear not; although it is undocumented in those manuals, we added this as part of the amazing XFixes extension with selection events. I don't know how it works in Python, but in C, you call XFixesSelectSelectionInput to retrieve events for the SetSelectionOwner event, then respond to that event like any other event The March Hare posted:I had found some code that used xlib that seems like it might work, but if you are saying that it can't hook globally then I guess I should ask for an opinion on a solution that will work. You can implement global keybindings, but I wanted to make sure you knew what you were doing. Hooking into Ctrl+C isn't the correct way to do it (you could use Edit->Copy or a right-click menu or something else like that), and it's difficult if you want to do something when the key is pressed, and also deliver it to the window normally. You would do this with XGrabKey on the root window, then listen for KeyPress/KeyRelease events. To also send it to the application as a pass-through, you need to use GrabSync, then from within the handler use XAllowEvents with ReplayKeyboard. When you retrieve this, you want to take the clipboard for yourself, so you want to XSetSelectionOwner and then respond to the SelectionNotify/SelectionRequest events like a normal conforming client. I'm not exactly sure how the Python Xlib bindings work, though; I'm used to the C API. Oh, and if you have any questions, feel free to ask, as it's probably going to look like a monumental task at first, and the ICCCM and Xlib manuals aren't the easiest reading material if you don't understand the core concepts. Even if it seems like the dumbest question in the world, I've asked much dumber to understand this stuff. As some advice on how to start, I'd make a simple app that uses the low-level Xlib to implement a simple thing that copies/pastes correctly with gedit. That should get you familiar enough with how X selections and events work, enough to go from there to implementing the XFixes events so you know when another app copies something to the clipboard, and then from there to "pasting" into the web service whenever the selection changes, and from there implementing the key press to "copy" it back into the local machine. It seems like a cool project, so I'd be interesting in hearing your progress, too!
|
# ? Aug 4, 2013 07:27 |
|
QuarkJets posted:When you say legacy, do you just mean 2.X? It seems to be receiving active updates
|
# ? Aug 4, 2013 15:04 |
|
Thanks to the person who mentioned Chaco. It works well and produces nice and fast graphs. There's just one problem. Does anyone have experience building an exe with Chaco? Before switching from matplotlib to Chaco, I could build with PyInstaller. Cannot do the same with Chaco. I've tried bbfreeze, cz_freeze, pyInstaller and pyInstaller dev build. They all either have issues with DLLs or when trying to run the executable get an "ImportError: No module named init" or a variation of it. Here's an example that runs with the Anaconda distribution + wx installed. But none of the exe compilers work. code:
|
# ? Aug 5, 2013 02:56 |
|
Suspicious Dish posted:(Sorry for being a bit late with this reply; I'm at a conference right now and the internet is p. bad) Boooooooooom thank you so much, it has been extremely difficult to find information on this anywhere -- I was about to stumble into IRC and try to pull teeth from some dudes. I will almost certainly be back with questions, thanks for the tips.
|
# ? Aug 5, 2013 12:13 |
|
MeruFM posted:Does anyone have experience building an exe with Chaco? Nevermind again. Found the issue. There's some dynamic imports that the builders cannot detect. For anyone interested, I had to include in the build script: pyface pyface.ui.wx enable enable.wx traitsui
|
# ? Aug 6, 2013 07:06 |
|
Python code:
This works: Python code:
Dominoes fucked around with this message at 01:10 on Aug 7, 2013 |
# ? Aug 7, 2013 01:06 |
|
You could try just using ast.literal_eval(). There's also the decimal module. BeefofAges fucked around with this message at 01:21 on Aug 7, 2013 |
# ? Aug 7, 2013 01:19 |
|
E: misread post WeezerToon fucked around with this message at 01:57 on Aug 7, 2013 |
# ? Aug 7, 2013 01:26 |
|
WeezerToon posted:Does x = float("10.0") not work for the same job?
|
# ? Aug 7, 2013 01:38 |
|
Dominoes posted:I feel like not requiring this extra step would be Pythonic / duck typing.
|
# ? Aug 7, 2013 01:40 |
|
10.0 isn't an integer. To coerce it would be implicit rather than explicit.
|
# ? Aug 7, 2013 01:49 |
|
xtal posted:10.0 isn't an integer. To coerce it would be implicit rather than explicit.
|
# ? Aug 7, 2013 01:51 |
|
Dominoes posted:int(10.0) works though. That's very slightly more explicit.
|
# ? Aug 7, 2013 01:58 |
|
Dominoes posted:
That's just how the builtin int() function works, according to the documentation. You can give it an integer, a float, or a string representing an integer, but not a string representing a float.
|
# ? Aug 7, 2013 02:02 |
|
I'm sure I'm not reading my code correctly and have something where it should be but can't seem to figure out what's wrong with it. code:
Using codecademy for this program and the things is it didn't say anything was wrong with my code.
|
# ? Aug 7, 2013 02:13 |
|
digitalcamo posted:I'm sure I'm not reading my code correctly and have something where it should be but can't seem to figure out what's wrong with it. I am not a Python genius, but I suspect that python is treating "a, e, i, o, u" as a single string, not as a series of possible values. I changed the code a little bit and it works for me. code:
Enter a word:apple vowel Got bored, here is the oneliner for this: [('vowel' if x in 'aeiou' else 'consonant' if x not in "aeiou" else 'empty') if x.isalpha() == True and len(x) != 0 else Pass for x in raw_input('Enter a word:').lower()[0]][0] Dies if you give it nothing, but I am too lazy to fix that now. dagonis fucked around with this message at 03:13 on Aug 7, 2013 |
# ? Aug 7, 2013 02:41 |
|
if first in ['a', 'e', 'i', 'o', 'u']: or if first in "aeiou": Also, instead of if len(original) != 0 and original.isalpha() == True: just do if len(original) and original.isalpha(): or alternatively, don't check the length or whether it's an alphabetic character, just assume that it is and catch the exception if it isn't. BeefofAges fucked around with this message at 02:44 on Aug 7, 2013 |
# ? Aug 7, 2013 02:41 |
|
digitalcamo posted:I'm sure I'm not reading my code correctly and have something where it should be but can't seem to figure out what's wrong with it. In your comparison you are making two mistakes that jump out right away: 1) Testing equivalency when you intend to be testing membership. 2) Using a string to hold a list. One way to do it: code:
code:
Here we use pythons in keyword to test membership of first in the list vowels.
|
# ? Aug 7, 2013 02:42 |
|
dagonis posted:I changed the code a little bit and it works for me. This worked for you because 'apple' starts with 'a'. Python code:
|
# ? Aug 7, 2013 03:11 |
|
Lysidas posted:This worked for you because 'apple' starts with 'a'. Looking at it now, the problem is pretty obvious, thanks for pointing that out. My ugly oneliner seems to work [('vowel' if x in 'aeiou' else 'consonant' if x not in "aeiou" else 'empty') if x.isalpha() == True and len(x) != 0 else 'Invalid Input' for x in raw_input('Enter a word:').lower()[0]][0] dagonis fucked around with this message at 03:24 on Aug 7, 2013 |
# ? Aug 7, 2013 03:13 |
|
Ok thanks I got it working.code:
|
# ? Aug 7, 2013 03:40 |
|
in is a keyword, much like if, for, def, etc. It tests if the element on the left is contained within a sequence to the right. Since python treats strings as sequences, you can use in to see if a substring is in another string. Thus:Python code:
|
# ? Aug 7, 2013 03:57 |
|
Ah I see, simple enough. When I read Python code it sometimes seems as though I'm reading English. However, I only get that feeling when I actually understand the code I'm reading.
|
# ? Aug 7, 2013 04:13 |
|
On the topic of if x in y, would there happen to be an anagram library of some sort that can take strings from a list, then mutate the input string to see if it matches the list string? To give a context, I'm trying to do a trigram search on a string in an attempt to find a match and suggest a working decryption key.
|
# ? Aug 7, 2013 05:34 |
|
ATM Machine posted:On the topic of if x in y, would there happen to be an anagram library of some sort that can take strings from a list, then mutate the input string to see if it matches the list string? I don't know if I actually understand what you're asking, but can't you just sort the letters in all the strings and then compare normally?
|
# ? Aug 7, 2013 05:51 |
|
Write your mutator function as a generator function that takes a string as input. Then you can use "in" with it.
|
# ? Aug 7, 2013 06:04 |
|
BeefofAges posted:Also, instead of
|
# ? Aug 8, 2013 16:06 |
|
Dominoes posted:if original and original.isalpha(): I'd avoid doing this. Using the plain if statement on variables that aren't a bool strikes me as a hideous pattern despite it being perfectly legal for strings/dicts/lists/etc. You'll occasionally get nasty unexpected behaviour, not to mention it's very un-pythonic in terms of explicity. I dislike the "if len()" one too, however you'll never convince people not take shortcuts like this with dynamic-typed languages. NtotheTC fucked around with this message at 16:33 on Aug 8, 2013 |
# ? Aug 8, 2013 16:16 |
|
NtotheTC posted:I'd avoid doing this. Using the plain if statement on variables that aren't a bool strikes me as a hideous pattern despite it being perfectly legal for strings/dicts/lists/etc. You'll occasionally get nasty unexpected behaviour, not to mention it's very un-pythonic in terms of explicity. I dislike the "if len()" one too, however you'll never convince people not take shortcuts like this with dynamic-typed languages. This is only true if you don't know the side effects of your statements or the definition of what is False
|
# ? Aug 8, 2013 16:40 |
|
deimos posted:This is only true if you don't know the side effects of your statements or the definition of what is False Well quite, and wouldn't the world be a nice place if we all understood the side effects at every stage of our writing/maintaining code. My feeling is that if you're trying to test for something being greater than 0 (in this case the length of a string) then it's more pythonic to say so directly with: code:
Again, I'm all about the readability with this. Your way isn't going to cause the sky to fall, and 9 times out of 10 it will never cause a problem. But why leave it open and sacrifice (in my opinion) prettiness/readability just so you can type 5 less characters? NtotheTC fucked around with this message at 17:04 on Aug 8, 2013 |
# ? Aug 8, 2013 17:01 |
|
NtotheTC posted:Well quite, and wouldn't the world be a nice place if we all understood the side effects at every stage of our writing/maintaining code. My feeling is that if you're trying to test for something being greater than 0 (in this case the length of a string) then it's more pythonic to say so directly with: code:
deimos fucked around with this message at 17:16 on Aug 8, 2013 |
# ? Aug 8, 2013 17:14 |
|
code:
|
# ? Aug 8, 2013 17:15 |
|
deimos posted:
code:
code:
|
# ? Aug 8, 2013 17:18 |
|
NtotheTC posted:If you're worried about a string being None use Or just do it the way the whole Python community does.
|
# ? Aug 8, 2013 17:19 |
|
I'm not going to get into a community best practice slap fight. I just view this in a similar light to:code:
You're more than welcome to overrule me on this as I imagine you're more experienced with python than I am. I don't think verboseness is a bad thing to learn when it enhances readability though. NtotheTC fucked around with this message at 17:30 on Aug 8, 2013 |
# ? Aug 8, 2013 17:26 |
|
|
# ? May 9, 2024 10:16 |
|
NtotheTC posted:I'm not going to get into a community best practice slap fight. I just view this in a similar light to: The argument you're making makes it so that you have to check at least twice to see if something has content: Python code:
|
# ? Aug 8, 2013 17:35 |