|
Stabby McDamage posted:I just noticed that I can do "a not in b" just as well as "not a in b". That's cool, but weird to me. "not" can modify "in", but not other comparators...I can't say "a not > b". Is there a name for this behavior? Essentially, there is an "in" operator, and a "not in" operator. There are also "is" and "is not" operators. (although a similar thing is the notion of 'adverb methods' in ruby http://weblog.raganwald.com/2008/07/that-not-is-not-not-i-meant.html )
|
# ? Apr 2, 2010 20:41 |
|
|
# ? Jun 12, 2024 12:32 |
|
tripwire posted:not doesn't modify an operator, it modifies a boolean. I know that, but that doesn't explain "a not in b", because by your definition "in b" is a boolean being modified by "not". tef posted:Essentially, there is an "in" operator, and a "not in" operator. There are also "is" and "is not" operators. That explains it. I wonder if "not in" is its own token in the Python lexer?
|
# ? Apr 2, 2010 20:55 |
|
"not in" is an operator itself. http://docs.python.org/reference/expressions.html#notin
|
# ? Apr 2, 2010 21:12 |
|
haywire posted:Has anyone checked out gevent or denied yet? I've been playing around with Denied, it seems very nice - it isn't in that extensive server benchmark yet, but it's been getting people talking. I've been messing around with Eventlet (AFAICT, comprable to gevent) and really like it.
|
# ? Apr 2, 2010 22:44 |
|
What is the best python equivalent of: someVar = !someVar Google is just turning up a lot of things that aren't helping. They either seem excessively long or not applicable to the question.
|
# ? Apr 2, 2010 23:43 |
|
Khorne posted:What is the best python equivalent of: someVar = not someVar
|
# ? Apr 2, 2010 23:45 |
|
Does anyone know what can be causing duplicate logging messages to be outputted?code:
code:
Ive checked and all the loggers use, __name__ to get the logger. Is there anyway to check this?
|
# ? Apr 3, 2010 02:12 |
|
UberJumper posted:Does anyone know what can be causing duplicate logging messages to be outputted? Try checking how many handlers that logger has. Each handler will do its own log output. You can try printing _logger.handlers
|
# ? Apr 3, 2010 02:28 |
|
BeefofAges posted:Try checking how many handlers that logger has. Each handler will do its own log output. You can try printing _logger.handlers Bah. i found it, i was calling logging.debug instead of _logger.debug. Why would they make logging like that
|
# ? Apr 3, 2010 02:33 |
|
I haven't had this much fun programming in awhile. I've got a basic web app going where it'll list directories and files. If you want to download whole directories, it zips it up and gives it to you. I've made it so it only zips the files in the immediate directory and not include any sub-directories. I don't want anyone to go zipping my whole music directory by accident. I've also added a flash mp3 streamer that checks each directory to see if there are mp3 files, if there are, it'll generate a playlist for the streamer. Then embed the player into the page with the file list. It's all very hastily put together, but it works. I'll probably start the bittorrent stuff next. I know I'm probably doing things inefficiently or improperly so I'll probably put the code up some where to get some feedback. Crazak P fucked around with this message at 10:20 on Apr 3, 2010 |
# ? Apr 3, 2010 10:15 |
|
I've been trying to install lxml properly for 3 days now and I really can just not make it work properly. I keep getting this error:code:
edit: oh right, I use Debian 4.0
|
# ? Apr 4, 2010 16:35 |
|
Try using pip, it's less retarded than easy_install.
|
# ? Apr 4, 2010 16:53 |
|
deimos posted:Try using pip, it's less retarded than easy_install. I got rid of the egg easy_install created and then I installed pip, and then tried installing lxml again and tried testing lxml, which gave me the same error as the one before. So I uninstalled lxml again and installed Cython because I was getting warnings about etree needing to be present and without Cython pip wouldn't automatically create it. So I did that, then I installed lxml - Same error. I do agree though, pip is less retarded than easy_install. It still doesn't work though. Ghetto Wizard fucked around with this message at 17:30 on Apr 4, 2010 |
# ? Apr 4, 2010 17:24 |
|
Ghetto Wizard posted:I've been trying to install lxml properly for 3 days now and I really can just not make it work properly. I keep getting this error:
|
# ? Apr 4, 2010 17:47 |
|
tripwire posted:Are you installing lxml from the debian package repo or are you building from source? Pip finds packages automatically and builds them using that, but I'm not manually building it from source, though it is apparently possible. Here's the pip install process of lxml: code:
Ghetto Wizard fucked around with this message at 18:07 on Apr 4, 2010 |
# ? Apr 4, 2010 18:03 |
|
Ghetto Wizard posted:Pip finds packages automatically and builds them using that, but I'm not manually building it from source, though it is apparently possible. If that doesn't work maybe try the stable version from lenny (2.1.1)?
|
# ? Apr 4, 2010 18:14 |
|
Ghetto Wizard posted:I've been trying to install lxml properly for 3 days now and I really can just not make it work properly. I keep getting this error:
|
# ? Apr 5, 2010 21:22 |
|
I have a module that uses telnetlib to talk to Cisco MDS switches. I need to add support for SSH now. However, Cisco's SSH implementation sucks -- it closes the SSH channel after every write, and I need execute a sequence of commands that have state, so connecting once per command is out. I'm thinking of using pexpect, but before I get my hands dirty, is this the best way to go about this? Given that I already have telnetlib working, I'm wondering if there's a shim layer or recipe out there for adding SSH support in a simple way. EDIT: I solved it...wasn't that hard. I wrote a shim class that inherits pexpect but provides the functions that I care about from telnetlib, so I can just use it as a drop-in replacement. In case anyone cares: code:
Stabby McDamage fucked around with this message at 23:28 on Apr 5, 2010 |
# ? Apr 5, 2010 22:39 |
|
I'm reading a bunch of values from a file using ConfigParser, and when converting from str to float there's a really small error being added to the values ('0.1' becomes 0.10000000000000001). Is there a standard way of avoiding this?code:
|
# ? Apr 6, 2010 03:06 |
|
Spime Wrangler posted:Is there a standard way of avoiding this? Stop using floats.
|
# ? Apr 6, 2010 03:20 |
|
Then what should I be using if the numbers aren't integers?
|
# ? Apr 6, 2010 03:23 |
|
Since you haven't told us why this precision matters, I couldn't say. (It's going to boil down to fixed-point or arbitrary precision though. Or changing your expectations.)
|
# ? Apr 6, 2010 03:26 |
|
For purely functional reasons, it doesn't really. Just annoying when values are displayed everywhere to ridiculous precisions for no apparent reason. It just seemed like there should be a way to go from a string to a decimal value without something like this happening. Nevermind, I guess.
|
# ? Apr 6, 2010 03:31 |
|
Then your problem is the precision that you use to print values. If you're actually printing the string version of the float it won't do this (it will when you print the repr of a float for obvious reasons). You can also manually specify precision with the string format specifiers. By way of example: code:
|
# ? Apr 6, 2010 03:33 |
|
Awesome. Thanks.
|
# ? Apr 6, 2010 03:37 |
|
You could also just round the numbers off. http://function.name/in/Python/round/
|
# ? Apr 6, 2010 05:47 |
|
BeefofAges posted:You could also just round the numbers off.
|
# ? Apr 6, 2010 06:36 |
|
Decimal module?
|
# ? Apr 6, 2010 06:38 |
|
I suppose I should have clarified that as rounding them before printing. It's possible that he could end up with some number that wasn't nice and round, like .387453876583456 or whatever, and want to round it to just a few digits. Of course, since he's taking values in from a config file, that isn't all that likely. I don't know where I'm going with this. Whatever.
|
# ? Apr 6, 2010 07:15 |
|
BeefofAges posted:I suppose I should have clarified that as rounding them before printing. It's possible that he could end up with some number that wasn't nice and round, like .387453876583456 or whatever, and want to round it to just a few digits. Of course, since he's taking values in from a config file, that isn't all that likely. I don't know where I'm going with this. Whatever. Avenging Dentist posted:
|
# ? Apr 6, 2010 07:44 |
|
BeefofAges posted:I suppose I should have clarified that as rounding them before printing. It's possible that he could end up with some number that wasn't nice and round, like .387453876583456 or whatever, and want to round it to just a few digits. Of course, since he's taking values in from a config file, that isn't all that likely. I don't know where I'm going with this. Whatever. >>> round(0.1, 3) 0.10000000000000001
|
# ? Apr 6, 2010 07:49 |
|
shhhhh Here's where instead of admitting I was wrong I keep making excuses for the next page and a half:
|
# ? Apr 6, 2010 07:54 |
|
I'm surprised nobody's posted the underlying problem. It's common to all floating-point arithmetic. Basically, as with integers, the number is stored using a binary representation. The form is: mantissa × 2exponent Where mantissa and exponent are integers. Negative numbers are those with negative mantissas, numbers less than 1 are expressed with negative exponents. Just as you can't represent 1/3 as a non-repeating decimal in base 10, you can't represent 1/10 as a non-repeating value in base 2. That's why you get small errors when the value is converted back to base 10 for printing. There are a heap of other caveats with using floating point math, too. In many cases, fixed point math can be used to sidestep this if you're doing simple operations. For example, you can store an integer number of pennies instead of a floating point number of dollars.
|
# ? Apr 6, 2010 13:56 |
|
His problem wasn't the precision but the display. Your explanation is fine, but it really doesn't help since he doesn't care about the precision. To just print the number up to 3 decimal places use something like this: code:
|
# ? Apr 6, 2010 14:44 |
|
Aaaaaaaaaa gently caress you NumPycode:
|
# ? Apr 6, 2010 18:25 |
|
Avenging Dentist posted:Aaaaaaaaaa gently caress you NumPy I guess they don't make a copy of a before referencing. Is the best solution: code:
|
# ? Apr 6, 2010 20:38 |
|
Modern Pragmatist posted:I guess they don't make a copy of a before referencing. I know why it's that way but it's beyond retarded that they don't check for it in the assignment, especially since it's trivially easy (A[3::-1].base is A). Modern Pragmatist posted:Is the best solution: Actually it'd be better to put the copy at the end so you aren't copying the whole array. Mostly I was just complaining though.
|
# ? Apr 6, 2010 20:39 |
|
Avenging Dentist posted:I know why it's that way but it's beyond retarded that they don't check for it in the assignment, especially since it's trivially easy (A[3::-1].base is A). So file a bug, or ask on their mailing list. It may be that it's intentional.
|
# ? Apr 6, 2010 22:18 |
|
king_kilr posted:So file a bug, or ask on their mailing list. It may be that it's intentional. Actually I'm probably going to write a patch for it. It's just stupid that something like that slipped through.
|
# ? Apr 6, 2010 23:23 |
|
|
# ? Jun 12, 2024 12:32 |
|
Okay so i am more or less wondering about something. For my final Geomatics project, we were tasked with basically creating something to add functionality to the ArcGIS tool suite, or improve on something. E.g. basically ether make a cool tool or write a library. I ended up going a completely different route and basically have been working on porting making ArcObjects work decently from within python through comtypes. (i've done alot of arcobjects programming and using their geoprocessor pains me greatly). However since ESRI's COM library is buggy as gently caress / broken / for certain things. Comtypes runs into a lot of issues with properly generating modules for ArcObjects, e.g. iterable interfaces are not being treated as iterable, even though ESRI says they should be. So its a pretty big mishmash of stuff. Now to top it off, comtypes is not very customizable, and basically doesn't allow you to externally modify certain things. So what i was wondering, is it a bad pratice to basically copy the comtypes package, rename it so something like _comtypes, update all references within that package and merge it into a larger package? Then just edit the living hell out of it directly, and make it more or less work only for ArcObjects? A few people have approached or messaged me about being interested in getting a copy of when i get it into a workable state. So i was thinking of just putting it up on google code or codeplex. I have tried contacting the comtypes dev's a few times about asking them if i can just modify comtypes. I only got one response, which was basically "uhmm no". My duedate is coming up, and i pretty much am just going to go ahead with it. So basically what i am asking is, if i did the above would: a. comtypes people get pissy, and can they basically tell me to take it down? b. I am not giving out the com type libs, since you need a valid arc install to generate the bindings. Does this really count as reverse engineering? c. In the TOS ESRI States that you cannot use ArcObjects from any non ESRI approved languages. However ESRI gives users a python library, just a very limited one. Is there anything i really should be weary of doing?
|
# ? Apr 7, 2010 02:30 |