|
Sublime Text 2 looks pretty awesome, but it seems pretty expensive for a text editor.
|
# ? May 3, 2013 22:00 |
|
|
# ? May 9, 2024 02:17 |
|
If you like the idea of Eclipse+PyDev, give that up and get PyCharm instead. It's not free, but it's pretty frickin' great. ST2 is also awesome, and is what I usually use when working on simple projects.
|
# ? May 3, 2013 22:02 |
|
deimos posted:This is multi-selection editing: That looks like the column editing mode (cua-mode) in emacs. (Which I use all the time)
|
# ? May 3, 2013 22:04 |
|
Dren posted:That looks like the column editing mode (cua-mode) in emacs. (Which I use all the time)
|
# ? May 3, 2013 22:07 |
|
Dren posted:That looks like the column editing mode (cua-mode) in emacs. (Which I use all the time) The way it's used is like column mode, but understand multi-selection are entirely arbitrary cursor positions, does NOT have to be the same column everywhere, the example on https://www.sublimetext.com makes it clearer.
|
# ? May 3, 2013 22:16 |
|
deimos posted:This is multi-selection editing: I knew about Smart Rearrange, but that multi-selection editing
|
# ? May 3, 2013 22:30 |
|
Dren posted:That looks like the column editing mode (cua-mode) in emacs. (Which I use all the time) Somebody implemented it in emacs, of course. It's a bit buggy, though.
|
# ? May 3, 2013 23:20 |
|
deimos posted:This is multi-selection editing: Someone pointed out to me that multi-selection editing is in almost every text editor other than notepad. Just hold alt and highlight stuff in notepad++ (and I think it's just alt in Visual Studio too) and there you go, multi-selection editing. I use it all the time.
|
# ? May 4, 2013 08:19 |
|
Solution to a question I posted a month ago:Dominoes posted:Another CSV / memory vs drive write question. If I want to download a CSV from a url, is there a way I can put the file information directly into a variable in memory? I've tried many combinations using list(), read(), csv.reader() etc, but can't find a working solution that skips writing the csv to disk, and reading it. Got it working by 1: Using Requests instead of urllib.request, and 2: using splitlines(). Here's what the working code looks like: Python code:
Dominoes fucked around with this message at 22:15 on May 4, 2013 |
# ? May 4, 2013 21:39 |
|
I like requests because it just works and I don't have to think about dealing with setting up urllib correctly. It's pretty nice.
|
# ? May 5, 2013 03:54 |
|
requests is so good that it should be part of the standard library.
|
# ? May 5, 2013 04:07 |
|
Quick python question. I've been tinkering with a game in Panda3D but hit a performance wall (I should have known better than use a 3D engine for a 2D game), but what's done is done and I've found the only critical thing I was using panda3D for was the perlin noise generation. Usage was basically:code:
e: This also allowed for 3 and 4D perlin noise so that I can do further generation; such as time based or layer based. e2: I just installed the python noise plug-in. I tried the example 2dtexture.py, but am not sure how the hell to re-use the pgm format it saves the output to. Ideally, I'd like to use it the exact same way I used the panda3D implementation. Anyone able to help clarify my stupidity with a small example? Winkle-Daddy fucked around with this message at 19:09 on May 6, 2013 |
# ? May 6, 2013 18:41 |
|
I feel like this is the sort of thing I'm going to slap myself on the forehead for not remembering by myself, but suppose I have a dictionary and I want to transform the values of that dictionary in some way while keeping their keys the same... how do I do that? I mean, obviously I can come up with a way to do that using a loop, but what's the idiomatic way? What I want to do is make a dictionary whose values are tuples to be passed to a class constructor, and I then want to run the class constructor across the dictionary so as to produce a dictionary of objects of the class. Python 3 if it matters. Python code:
|
# ? May 7, 2013 03:19 |
|
You could use a dictionary comprehension:Python code:
|
# ? May 7, 2013 03:30 |
|
How aboutPython code:
|
# ? May 7, 2013 03:35 |
|
I see, I felt sure there must be a builtin that does this, but I guess I was mistaken. The following is what I have: Python code:
Python code:
edit: less misleading variable names Python code:
Hammerite fucked around with this message at 04:01 on May 7, 2013 |
# ? May 7, 2013 03:46 |
|
This seems like a very weird problem to have. Where does the dictionary come from?
|
# ? May 7, 2013 04:19 |
|
I am very confused by your example code. Could you show sample input and output data that is correct?
|
# ? May 7, 2013 04:52 |
|
If I understand you correctly, you want to initialize class instances where the arguments passed to the constructors are the values in the dictionary? That should be relatively easy:code:
|
# ? May 7, 2013 05:30 |
|
The Insect Court posted:If I understand you correctly, you want to initialize class instances where the arguments passed to the constructors are the values in the dictionary? That should be relatively easy: This is less readable and idiomatic than the dict comprehension that Dren posted (though of course dict.iteritems no longer exists in Python 3). Hammerite, if you want to update your dict in place there probably isn't much room for improvement in your functions/loops. A few suggestions though: you may as well directly loop over key, value in my_dict.items() and you should check for isinstance(value, collections.abc.Mapping) instead of dict. If you want a new dict with instances instead of parameters, then Dren's dict comprehension is great.
|
# ? May 7, 2013 05:48 |
|
Lysidas posted:Hammerite, if you want to update your dict in place there probably isn't much room for improvement in your functions/loops. A few suggestions though: you may as well directly loop over key, value in my_dict.items() and you should check for isinstance(value, collections.abc.Mapping) instead of dict. I concluded that I had no need to update the dict in place after all. So I ended up with more or less what Dren suggested in the first place. I also decided I don't really need that code to cope with dictionaries right now, so it's out. Python code:
Python code:
|
# ? May 7, 2013 08:43 |
|
Hammerite posted:I'm confused about this collections.abc business though. This module has a dot in the name?? Python 3.2 seemed to find this very confusing, but I installed 3.3 and it loves it. "This filename has a / in the name". Collections is a module. abc is a module that lives inside collections.
|
# ? May 7, 2013 10:38 |
|
Winkle-Daddy posted:e2: I'm still trying to use this drat noise module, but I'm not getting any value out of it except 0. If anyone has used this before, can you tell me what I'm doing wrong? code:
code:
Please help me with my dumb.
|
# ? May 7, 2013 16:15 |
|
Does anyone have any idea on how to get the state of a ttk button? I have code that button A calls, based on the state of button B, button A will change button B's state and set a variable. However I cannot figure out how to determine button B's state with an if statement. code:
In frustration with how annoying it was to find the answer, I tried to install PyQt and decided I was just going to use that. Well installing PyQt failed me for some reason so I went back to tkinter and figured it out! code:
Well that works in getting me what I want in terms of return but not the expected results The below function does nothing: code:
code:
n0manarmy fucked around with this message at 18:58 on May 7, 2013 |
# ? May 7, 2013 16:23 |
|
code:
This way probably doesn't work that well, and your way looks more python-ish. E2: ^^^ If you're not tied to the idea of using tkinter, have you considered wxPython? I've been using it for a couple of months now and it is by far the easiest GUI dev work I've done, especially once combined with the power of wxGlade (once you get over it's quirkyness.) Winkle-Daddy fucked around with this message at 19:00 on May 7, 2013 |
# ? May 7, 2013 18:44 |
|
Winkle-Daddy posted:
how is wxPython with python3? I see on their site that they specifically show 2.6 and 2.7 as the versions available with their compiled download?
|
# ? May 7, 2013 19:15 |
|
n0manarmy posted:how is wxPython with python3? I see on their site that they specifically show 2.6 and 2.7 as the versions available with their compiled download? I'm not sure, I've been tied to a game engine (two of them actually) which both conveniently work perfectly with Python 2.7. However, doing some looking around I did find this. So, the binaries exist for it under 3.0-3.3, how well they work with wxGlade, I'm just not sure. My issue with tkinter is exclusively cosmetic; to me, it just "feels" like Windows 3.1, while QT and wxWidgets both hook into the native OS UI API, so it just "looks right" on whatever system it's targeted for. e: VVV not sure how helpful this will be as I've not used that before, but I had a very similar issue in Aptana Studio where it would only see some of my modules. It turned out that I had two versions of python installed and I was pointing to the wrong one in the PyDev config. I didn't want to make a new post to reply as I have a feeling you've already ruled this possibility out. But if you're on a unix-like system, I'd start with which python, followed by seeing if there are multiple versions installed (or if which python returns a file path which is symlinked to another version, had problems with that, too!). Winkle-Daddy fucked around with this message at 20:55 on May 7, 2013 |
# ? May 7, 2013 19:18 |
|
I've got a problem that isn't really a problem but it's irritating the hell out of me. ipython and pycharm can no longer "see" some python modules like, for example, datetime. PyCharm gives me the red squiggly saying it's an unrecognized package: ipython won't tab-complete datetime when I type datet<TAB>. Everything works fine when I actually use the import, but for some reason ipython and pycharm can't see that it's a real thingy I can import. I'm using a virtualenv and if I switch to the system python it works fine. It's just when using the virtualenv that I have a problem. Like I said, things work, but this is just irritating me. I tried deleting the virtualenv and recreating it, but it still didn't work.
|
# ? May 7, 2013 20:45 |
|
Did you tell PyCharm to use the virtualenv interpreter? It won't see packages installed for the virtualenv if you don't do that. You have to add it in Project Settings > Project Interpreter > Python Interpreters.
|
# ? May 7, 2013 21:10 |
|
Thern posted:Did you tell PyCharm to use the virtualenv interpreter? It won't see packages installed for the virtualenv if you don't do that. Yeah, I did that.
|
# ? May 7, 2013 21:15 |
|
I have a crazy emulator written in python, where i have register data stored as ints. Registers are limited to 32bit values, and depending on the operations performed can be treated as single precision floats. I need to convert the integer value to what it's binary data interpreted as floating point would represent. So 0x3F800000 would convert to 1.0 etc. http://www.binaryconvert.com/result_float.html?decimal=049 Is there some way to do this? peepsalot fucked around with this message at 21:20 on May 7, 2013 |
# ? May 7, 2013 21:15 |
|
What kind of virtualenv? One created by the old virtualenv or pyvenv in 3.3? For 3.3 native virtualenvs I've always had to manually add $VIRTUAL_ENV/lib/python3.3/site-packages to the paths for that interpreter.
|
# ? May 7, 2013 21:24 |
|
peepsalot posted:I have a crazy emulator written in python, where i have register data stored as ints. Registers are limited to 32bit values, and depending on the operations performed can be treated as single precision floats. I need to convert the integer value to what it's binary data interpreted as floating point would represent. Python code:
|
# ? May 7, 2013 21:28 |
|
Lysidas posted:
|
# ? May 7, 2013 21:31 |
|
struct.pack
|
# ? May 7, 2013 21:33 |
|
oh, right. I feel a little silly now. Still seems a bit convoluted but I guess that will work.
|
# ? May 7, 2013 21:35 |
|
I wouldn't consider this to be very convoluted. When your task is "take the underlying bytes that make up this integer, and interpret them as a float", I think it's reasonable to have to use an actual byte string as an intermediate value. Python's type system doesn't natively allow this kind of casting. You can drop the endianness specification since you already have an integer: Python code:
|
# ? May 7, 2013 21:44 |
|
Lysidas posted:What kind of virtualenv? One created by the old virtualenv or pyvenv in 3.3? For 3.3 native virtualenvs I've always had to manually add $VIRTUAL_ENV/lib/python3.3/site-packages to the paths for that interpreter. I'm using 2.7, so the old virtualenv.
|
# ? May 7, 2013 21:46 |
|
When you go into Settings | Project Interpreter > Python Interpreters is your system python's lib folder included in the paths tab?
|
# ? May 7, 2013 22:00 |
|
|
# ? May 9, 2024 02:17 |
|
Lysidas posted:You can drop the endianness specification since you already have an integer Note that there exist platforms where the endianness of integers is not the same as the endianness of floats, because the FPU and the ALU were made as separate units by different teams and cobbled together at the last minute or something.
|
# ? May 7, 2013 22:11 |