|
is right -- for f's sake -- I picked lxml thinking it would be a stupidly simple test package! I'm torn between being happy it's not my fault and angry about the hoops I'm going to have to jump through.... I'll give the VS 2008 and "manually-copy-the-binary" methods a try.
|
# ? Dec 14, 2012 22:48 |
|
|
# ? May 31, 2024 01:09 |
|
onionradish posted:Following up on virtualenv, I'm having failures when trying to install packages, and I'm not sure what I'm doing wrong. Welcome to one of the large reasons I switched to linux on the desktop. Just got tired of trying to find windows binaries or getting VS2008 to compile stuff. VS2008 will work for some stuff and not for others, for reasons that I got tired of sussing out.
|
# ? Dec 14, 2012 23:53 |
|
Thermopyle posted:Welcome to one of the large reasons I switched to linux on the desktop. Just got tired of trying to find windows binaries or getting VS2008 to compile stuff. VS2008 will work for some stuff and not for others, for reasons that I got tired of sussing out. To be fair, the package managers are the saving grace for Linux when it comes to libraries. There are some libraries with really specific version requirements that need apt-pinning or other such juggling. Not going to deny it's a lot easier overall, though.
|
# ? Dec 15, 2012 00:28 |
|
I spent a few hours trying to compile PyCrypto on Windows before giving up and finding binaries. It was incredibly frustrating.
|
# ? Dec 15, 2012 04:11 |
|
BeefofAges posted:I spent a few hours trying to compile PyCrypto on Windows before giving up and finding binaries. It was incredibly frustrating. Why is everyones first instinct to try and compile it instead of just installing the binaries?
|
# ? Dec 15, 2012 17:01 |
|
Because "pip install pycrypto" is easier than Googling.
|
# ? Dec 15, 2012 17:31 |
|
Hard NOP Life posted:Why is everyones first instinct to try and compile it instead of just installing the binaries? edit: onionradish fucked around with this message at 18:51 on Dec 15, 2012 |
# ? Dec 15, 2012 18:29 |
|
Captain Capacitor posted:Because "pip install pycrypto" is easier than Googling. Except on windows which is what we're discussing.
|
# ? Dec 15, 2012 18:31 |
|
An update to my earlier post: the linked StackOverflow post was about using "easy_install" in a Windows virtualenv, but testing with binaries for PIL, it only appears to work, meaning it actually doesn't. The package only gets partially installed. The same SO post includes a suggestion to change the registry around, which seems really hacky.
onionradish fucked around with this message at 18:53 on Dec 15, 2012 |
# ? Dec 15, 2012 18:50 |
|
Captain Capacitor posted:Because "pip install pycrypto" is easier than Googling. Basically this. It works for almost everything else, so when you get to PyCrypto, you try to install it with pip and get errors. When you google the errors, you get various convoluted guides on how to make Windows compilation work instead of getting links to binaries. When you go to the PyCrypto homepage, there isn't even any mention of binaries. Basically it's a documentation issue.
|
# ? Dec 15, 2012 19:44 |
|
duck monster posted:Use this thing: http://kivy.org/
|
# ? Dec 15, 2012 21:13 |
|
BeefofAges posted:Basically this. It works for almost everything else, so when you get to PyCrypto, you try to install it with pip and get errors. When you google the errors, you get various convoluted guides on how to make Windows compilation work instead of getting links to binaries. When you go to the PyCrypto homepage, there isn't even any mention of binaries. I usually have it crop up as a nested requirement for some library (I'm looking at you, Twisted )
|
# ? Dec 15, 2012 22:16 |
|
Yeah, I needed it for paramiko.
|
# ? Dec 15, 2012 22:22 |
|
Python package distribution on Windows is just awful. I had to unzip some egg files in some magical location because the binary installer that had an InstallShield blue background and "PYTHON POWERED" in some dots text and told me that I had 205GB disk space free on C: couldn't find that I had Python 2.7. A part of it now is that MS's compiler suite is really awful and breaks between versions and isn't freely available without installing some monster Visual C++ IDE that I don't want and will never use, because the version bundled in the Windows 7 SDK is just flat broken. I don't know what the solution is, but they need to make "pip install pycrypto" just work.
|
# ? Dec 16, 2012 00:13 |
|
I haven't tested this, but it looks like distutils can use gcc via MinGW. It seems like MinGW is the preferred way to get a C compiler on Windows for open-source work, so that's probably your best option.
|
# ? Dec 16, 2012 00:24 |
|
I'm sure there's a great reason why this works the way it does, so I guess that's why I'm asking here. When making a simple dictionary, like this: code:
code:
So like if I tried: code:
I just don't understand why that would be...
|
# ? Dec 16, 2012 01:22 |
|
JetsGuy posted:However, if I move that line defining d_set OUTSIDE the loop to create the "master" dictionary, all of a sudden I can't add/edit the dictionary the way that makes sense to me. Because python likes to use references rather than copies for everything. You're saying master["set_1"], master["set_2"], and master["set_3"] are all set to the same instance of d_set, which means when you change one of them, all of them change. Python has a copy module, which you can use here. Python code:
code:
Python code:
Jewel fucked around with this message at 02:23 on Dec 16, 2012 |
# ? Dec 16, 2012 02:19 |
|
Jewel posted:Python has a copy module, which you can use here. You want to use deepcopy if you do it this way, otherwise: code:
|
# ? Dec 16, 2012 02:35 |
|
Jewel posted:Python has a copy module, which you can use here. If you want a shallow copy of a builtin type, create a new object with it as the parameter. code:
|
# ? Dec 16, 2012 02:49 |
|
PiotrLegnica posted:You want to use deepcopy if you do it this way, otherwise: I can never remember whether to use copy or deep copy. Bluh.
|
# ? Dec 16, 2012 03:43 |
|
Movac posted:I haven't tested this, but it looks like distutils can use gcc via MinGW. It seems like MinGW is the preferred way to get a C compiler on Windows for open-source work, so that's probably your best option. e; oh I guess it says that.
|
# ? Dec 16, 2012 05:06 |
|
What's the advantage of using deepcopy here, which has to go through a crazy pickle round-trip, rather than just keeping the line inside the for loop?
|
# ? Dec 16, 2012 05:25 |
|
Suspicious Dish posted:What's the advantage of using deepcopy here, which has to go through a crazy pickle round-trip, rather than just keeping the line inside the for loop? I guess it's more so semantics on why what happens, happens, and how to fix it, for a future reference.
|
# ? Dec 16, 2012 05:28 |
|
A rule of thumb for me is that importing the copy module means you're doing something wrong.
|
# ? Dec 16, 2012 05:42 |
|
Suspicious Dish posted:A rule of thumb for me is that importing the copy module means you're doing something wrong. Copy could be cool for stuff like, say, passing a default Particle type into a ParticleEmitter. Of course you could then argue that you should pass in settings to create a particle rather than passing in a pre-made particle, but it could be useful sometimes! Edit: Yeah nevermind that's a goddamn terrible example. I'm sure there's some reasons to use it though.
|
# ? Dec 16, 2012 05:51 |
|
Suspicious Dish posted:A rule of thumb for me is that importing the copy module means you're doing something wrong. Similarly, I don't use copy, but I use slices a lot. I often find myself doing foo = {}; foo.update(bar); ....
|
# ? Dec 16, 2012 06:24 |
|
tef posted:Similarly, I don't use copy, but I use slices a lot. Is foo = dict(bar) too non-obvious?
|
# ? Dec 16, 2012 06:57 |
|
Jewel posted:Copy could be cool for stuff like, say, passing a default Particle type into a ParticleEmitter. Of course you could then argue that you should pass in settings to create a particle rather than passing in a pre-made particle, but it could be useful sometimes! Pass in a factory function that creates a particle. This is a common pattern.
|
# ? Dec 16, 2012 06:59 |
|
Suspicious Dish posted:Is foo = dict(bar) too non-obvious? I do that a lot too. I use update when i'm adding things in an if-chain somewhere down the line. Edit: According to grep, I use foo = dict(bar) most of the time.
|
# ? Dec 16, 2012 07:12 |
|
Suspicious Dish posted:Pass in a factory function that creates a particle. This is a common pattern. For example, Python code:
|
# ? Dec 16, 2012 11:30 |
|
copy module is useful for two things: - generic code that wants to do copies while preserving types - deep copying, when it's actually needed (sometimes it is, but that's not very common use case) Using type constructor directly is better if the type is known upfront, or you want to copy and convert.
|
# ? Dec 16, 2012 17:38 |
|
I don't mind using copy or deepcopy when it's convenient, since the code I write is almost never a performance bottleneck. I mostly work in test automation, so the scripts I write usually spend most of their time waiting for other software to do stuff.
|
# ? Dec 16, 2012 21:05 |
|
It's not a performance issue. The code that copies custom classes that you write are copied in weird ways (it doesn't call your constructor) that can cause your code to suddenly break.
|
# ? Dec 16, 2012 21:08 |
|
Suspicious Dish posted:It's not a performance issue. The code that copies custom classes that you write are copied in weird ways (it doesn't call your constructor) that can cause your code to suddenly break. Oh, that makes sense. I've never actually used it on custom classes, just on dicts full of standard types.
|
# ? Dec 16, 2012 21:11 |
|
I recently interviewed for a python engineer position and got some questions that were a bit different from what I'm used to at programming interviews. Usually I get asked to write a sorting function, or a linked list implementation, or to find the bugs in a code snippet. I've even been asked to figure out what complexity class a given algorithm is in. However, at this interview, I got asked really specific things, like what the syntax is for list comprehensions, or how to write a generator, or what the difference is between '==' and 'is'. The only actual coding I was asked to do was to write a script that parses a given web page and makes its contents available through a REST API that serves JSON. They gave me a laptop and left me alone for an hour and said I could use whatever resources I wanted. I've never actually done any web development or HTML parsing or worked with REST or JSON, so I didn't actually get farther than some basic parsing using examples copied and pasted from stackoverflow. I'm still trying to decide whether the stuff they asked me is useful for separating good programmers from bad ones or not. Funny thing is, they offered me the job, but only offered about 2/3rds of what I earn now, even after I told them what I'm making right now. I ended up turning them down for reasons unrelated to the salary they offered.
|
# ? Dec 16, 2012 22:10 |
|
the == and 'is' difference is certainly important (all dynamic languages have their equivalent, and not knowing that there's a different is a big gotcha) and since a lot of python out there is for web server processes, I'm not surprised about the practical programming question. The other stuff seems aimed at identifying "python programmers" vs "dynamic language programmers" and although that's fine, hard to say if it's serving up better candidates. edit: I use a LOT of copy.deepcopy() in unittest code that wants to test nested dictionaries (e.g. JSON) with slight differences. code:
Lurchington fucked around with this message at 00:56 on Dec 17, 2012 |
# ? Dec 17, 2012 00:50 |
|
Now I'm wondering if there are dynamic languages with immutable values/purity a la Haskell so that you don't need to distinguish between == and is.
|
# ? Dec 17, 2012 01:12 |
|
yaoi prophet posted:Now I'm wondering if there are dynamic languages with immutable values/purity a la Haskell so that you don't need to distinguish between == and is. Lambda calculus.
|
# ? Dec 17, 2012 02:21 |
|
How do I use SQLAlchemy's declared_attr with Flask-SQLAlchemy? Specifically, I'm trying to implement this pattern (taken from this): Python code:
|
# ? Dec 17, 2012 02:37 |
|
|
# ? May 31, 2024 01:09 |
|
No, your question makes perfect sense. SQLalchemy's declarative bases are a really nice feature. Unfortunately, Flask-SQLalchemy appears to cover that feature up, to some extent. As far as what Flask-SQLalchemy offers, the relevant bit of documentation is refreshingly clear about that. Essentially it:
The Model class is where you'll run into trouble: the way it is generated makes it difficult to extend. Nonetheless, here's my hacky untested attempt at doing it anyway! Python code:
|
# ? Dec 17, 2012 05:11 |