|
Gothmog1065 posted:I'm not waiting to wait for the command to fully open. Basically my "script" is going to open a few different programs, and leave them open, but I didn't want to slam the computer all at once. But I know some programs take longer than others to open (IE takes forever compared to notepad). If there's not a simpler way to do this, then I'll wait for now. Ah, right. There's no good generic definition of "done loading" you can wait for, really - so you'll probably have to settle for sleeping a second or some such. If you feel fancy you could monitor CPU and disk activity and launch the next app when it dips? edit: Never mind, I can't find an easy way to do that on Windows. Computer viking fucked around with this message at 17:22 on Jan 25, 2012 |
# ? Jan 25, 2012 17:15 |
|
|
# ? May 9, 2024 15:44 |
|
Computer viking posted:Ah, right. There's no good generic definition of "done loading" you can wait for, really - so you'll probably have to settle for sleeping a second or some such. If you feel fancy you could monitor CPU and disk activity and launch the next app when it dips? That's probably why I didn't find much, as there's not much there. Thanks.
|
# ? Jan 25, 2012 17:16 |
|
Actually, I've monitored both CPU and disk activity in Windows using the Python WMI library. It's not incredibly painful to use, but it might be more than you're looking for. http://timgolden.me.uk/python/wmi/index.html
|
# ? Jan 25, 2012 18:26 |
|
BeefofAges posted:Actually, I've monitored both CPU and disk activity in Windows using the Python WMI library. It's not incredibly painful to use, but it might be more than you're looking for. Ah, nice - thanks. I don't do much python on windows, but at some point it might be useful.
|
# ? Jan 26, 2012 15:07 |
|
I'd just like to put in my official thank you. I've asked some really loving stupid questions, but you guys were pretty good about working with me and explaining poo poo. I still don't understand certain things, but after stepping through commands and seeing how they work, I've learned a lot. I actually have a script that works. Whether or not it is properly "scripted" is moot, it works. I still have other things to work on, but again. Thank you! More stupid loving questions to come!
|
# ? Jan 26, 2012 20:37 |
|
Computer viking posted:...you could monitor CPU and disk activity and launch the next app when it dips?
|
# ? Jan 26, 2012 20:40 |
|
Back to the dumb questions! Okay, I'm opening a program, say notepad. I want to use %systemroot%\system32 for obvious reasons rather than c:\Windows\System32. The problem is that when it tries to change to that directory, it doesn't exist. Is there a simple way around this?
|
# ? Jan 27, 2012 07:30 |
|
Gothmog1065 posted:I'd just like to put in my official thank you. I've asked some really loving stupid questions, but you guys were pretty good about working with me and explaining poo poo. I still don't understand certain things, but after stepping through commands and seeing how they work, I've learned a lot. I actually have a script that works. Whether or not it is properly "scripted" is moot, it works. I still have other things to work on, but again. Thank you! Theres no such thing as stupid questions, just easy and hard ones. Its the only way to learn.
|
# ? Jan 27, 2012 10:15 |
|
duck monster posted:Theres no such thing as stupid questions Except for all the ones where a simple search would lead to the answer in the first hit.
|
# ? Jan 27, 2012 12:11 |
|
Gothmog1065 posted:Back to the dumb questions!
|
# ? Jan 27, 2012 18:06 |
|
If you really are running notepad, subprocess.call('notepad.exe') should just work. Windows has a path environment variable, too.
|
# ? Jan 27, 2012 19:00 |
|
I'm thinking about using Mark Summerfield's Rapid GUI Programming With Python and Qt (because I have a copy of it for some reason) to learn PyQt and GUI programming. Well, actually I'm learning PySide, but from looking over PySide's site, there's not much difference. My main questions are: 1. Given that the book was written a few years ago on PyQt 4.2, are there enough differences between 4.2 and modern PyQt (and by extension, PySide) to make this book worthless? 2. If it's not worthless, what are some changes that I should look out for? 3. Is there a book that's better that I should give a try?
|
# ? Jan 29, 2012 22:56 |
|
I'm looking for some general advice on getting a Python REPL working in a GUI. I am doing some stuff with 3d, and kind of want a Python console to plop down when I hit tilde, like one would expect a console generally to be for stuff like that. Is there any existing stuff to do that in Python? I was hoping for some helpers for things like history and getting all the tab indent prompts correct. I had been through doing this somewhat manually in C# before, and found it to be really tedious. So I want to avoid having to start from scratch.
|
# ? Jan 30, 2012 16:35 |
|
Rocko Bonaparte posted:I'm looking for some general advice on getting a Python REPL working in a GUI. I am doing some stuff with 3d, and kind of want a Python console to plop down when I hit tilde, like one would expect a console generally to be for stuff like that. Is there any existing stuff to do that in Python? I was hoping for some helpers for things like history and getting all the tab indent prompts correct. I had been through doing this somewhat manually in C# before, and found it to be really tedious. So I want to avoid having to start from scratch. I did a little bit of Googling and if you can throw twisted in there you can use twisted.conch.stdio. Either python -m twisted.conch.stdio or just from twisted.conch import stdio; stdio.main() and you get a nice REPL (it even had syntax coloring for me!)
|
# ? Jan 30, 2012 17:01 |
|
twisted.conch.stdio is really designed for a remote Python prompt. So if you're trying to debug your server from your client and want a Python prompt for that, you should probably use it (of course, that somewhat relies on you having your networking already done through Twisted, but you should already be doing that). The code module is just the thing if you just want a REPL. You probably want to create a new subclass of InteractiveInterpreter and implement the write method. Because Python acts the way it usually does, you may need to replace sys.stdout and sys.stderr so that something like print "Foo!" works in your console: code:
Suspicious Dish fucked around with this message at 17:49 on Jan 30, 2012 |
# ? Jan 30, 2012 17:46 |
|
Odd question: I've been looking into learning python in my free time, its tangentially related to my job but I'm not in IT or development. I majored in MIS in college, so I had basic exposure to coding, CS101 stuff (using java primarily). I am finding that the basic resources like "Learning Python the Hard way" is pretty simple for me, not trivial but pretty easy to understand and put together. It mostly feels like I'm learning syntax for the logic functions I already know. However, when I look at real code like what is posted around here, my head spins. All the different modules, interfacing with email servers, and talk of multithreaded hyperdrive cores. How do you jump from "this is a loop, here is a variable, can you make the turtle draw a square?" to: quote:twisted.conch.stdio is really designed for a remote Python prompt. So if you're trying to debug your server from your client and want a Python prompt for that, you should probably use it (of course, that somewhat relies on you having your networking already done through Twisted, but you should already be doing that).
|
# ? Jan 30, 2012 18:36 |
|
Just gently caress around with the standard modules , or a system like Django until you feel your sea-legs for more complex python kicking in. Really the only places python gets "hard" is when people use the lambda stuff (which incidently Guido van rossen really dislikes but feels its too hard to replace) because of its goofy syntax, and some of the plumbing methods (setter/getter type stuff, etc) in the object model. All of which are handy to know, but completely optional.
|
# ? Jan 30, 2012 19:01 |
|
Xguard86 posted:Odd question: I've been looking into learning python in my free time, its tangentially related to my job but I'm not in IT or development. I majored in MIS in college, so I had basic exposure to coding, CS101 stuff (using java primarily). Most of the stuff you quoted and most of the stuff that you will find confusing comes from 3rd party libraries. The only way to figure that poo poo out is to try using them to solve a problem. FWIW, I've never been able to understand a thing about Twisted, so you're not alone there. I've started to try to learn it a few times but got a bit into the documentation and just said "gently caress it" and found another, smaller, more-focused library to do what I want.
|
# ? Jan 30, 2012 20:20 |
|
Xguard86 posted:Odd question: I've been looking into learning python in my free time, its tangentially related to my job but I'm not in IT or development. I majored in MIS in college, so I had basic exposure to coding, CS101 stuff (using java primarily). There's a lot of things that make sense if you know why it's doing what it does (threading for example) that come across as gibberish to someone that hasn't learned about it in general, regardless of language. Then there are things like Twisted that are on the other side, where the difficulty is that you need to learn Twisted specifically to know what the gently caress is going on because a lot of the more obvious parts are hidden behind reactors and factories (which are named that way by Twisted, not Python). In short: third party library = learning curve for the library, multithreaded hyperdrive = learning curve for the feature (independent of language). Edit; ^^^^ exactly how I feel about Twisted, and I've tried a few times to learn it but it gets to a point where the learning curve turns from "oh yeah this makes sense" to "HOLY GOD WHAT WHY". The Gripper fucked around with this message at 20:38 on Jan 30, 2012 |
# ? Jan 30, 2012 20:35 |
|
I figured out Twisted a couple years ago, and then wanted to drag up an old IRC bot I wrote in it but no matter what I did Twisted wouldn't work on my computer anymore. It was the exact same windows XP computer and I just had errors on imports forever no matter what I tried and then I just gave up too.
|
# ? Jan 30, 2012 20:45 |
|
Twisted only started to make sense to me after I found myself reinventing it (badly). This has been the case for most complex frameworks I've used.
|
# ? Jan 30, 2012 20:46 |
|
well, that actually makes me feel better: knowing its not all common knowledge when people are discussing these libraries. I guess its just like Plorkyeran above me said, I'll figure it out whenever it becomes something I need.
|
# ? Jan 30, 2012 21:40 |
|
I'm teaching myself Python and have a pretty basic question (that I am having trouble describing generically, so I'll use an example). I have a game with a variable number of players (2-8). Each player has different characteristics (for the example, let's just use name). I want to set it up so that each player is attached to a variable (player_1, player_2, ... player_n). I can think of one way to actually do this, and one way to do something close enough, but I'm wondering which is more pythonic, or if there is a better way in general to do this. I have essentially no past programming experience, so coding horrors probably follow. First, use exec, but I have heard people say using exec is a horror (obviously this is a snippet for an example. The class would be more than that, and num_players would be defined somewhere else). code:
code:
|
# ? Jan 30, 2012 21:51 |
|
Option two is definitely the way to go. Dynamically created variables are a pain in the rear end to deal with.
|
# ? Jan 30, 2012 22:31 |
|
Never use eval() unless you fully intend to actually execute code because you're, say, writing an IRC bot that can load plugins on the fly.
|
# ? Jan 30, 2012 22:33 |
|
yaoi prophet posted:Never use eval() unless you fully intend to actually execute code because you're, say, writing an IRC bot that can load plugins on the fly. Even then don't use it. Use something like imp
|
# ? Jan 30, 2012 22:40 |
|
Not My Leg posted:Is one of these more "correct" or is there a better way to do this in general? I think I prefer method 2, because it's a little more transparent as to what is going on, but no strong opinion. If I did, for some reason, actually need to assign variable names, would method 1 be "correct"? A better way of dealing with this might be to define a dictionary holding the player objects, with player designation as the key ('player_1' for instance). You could pull the necessary objects from the list, and use it like a variable anyway. You could even have different referral names for the same object if necessary (it's not). Also, try to avoid user interaction in the constructor - just have a function do the user interaction and then create the object from whatever is input. You can check for validity (length, symbols, etc.) before creating the actual object that way. code:
Edit: Changed things around to remain in their own scope. Eliza fucked around with this message at 23:03 on Jan 30, 2012 |
# ? Jan 30, 2012 22:41 |
|
Eliza posted:A better way of dealing with this might be to define a dictionary holding the player objects, with player designation as the key ('player_1' for instance). You could pull the necessary objects from the list, and use it like a variable anyway. You could even have different referral names for the same object if necessary (it's not). Completely agree about using the function to get the user input, rather sticking it in the constructor. As for the dict, would this be the best way to do that for multiple players (obviously I would want each player to be indexed under the proper player number)? code:
|
# ? Jan 30, 2012 23:01 |
|
Suspicious Dish posted:The code module is just the thing if you just want a REPL. You probably want to create a new subclass of InteractiveInterpreter and implement the write method.
|
# ? Jan 31, 2012 00:34 |
|
haha I don't mean to be mean because I think I did something like this before too, but code:
|
# ? Jan 31, 2012 00:55 |
|
MeramJert posted:haha I don't mean to be mean because I think I did something like this before too, but Oh, I take no offense, I have literally no idea what I am doing and still knew enough to think that was probably horrifying. I had just seen someone (no idea where, probably stack overflow) suggest that was the correct solution, and I thought "that works, but can't be right."
|
# ? Jan 31, 2012 01:21 |
|
Plorkyeran posted:Twisted only started to make sense to me after I found myself reinventing it (badly). twisted I find is more an abstraction around an event loop over an abstraction useful for writing event driven code -- i.e it is more convenient for the twisted maintainers than the users. I find myself more attached to the co-routine style (PEP-342) things which have started to appear (monocle, bluelet and even in twisted (but undocumented, of course)). as for reinventing things - it reminds me of jwz's rant on mail summary files http://www.jwz.org/doc/mailsum.html Xguard86 posted:How do you jump from "this is a loop, here is a variable, can you make the turtle draw a square?" to: You don't jump, you crawl. You can pick up python quickly, but understanding the mechanics takes much longer. Much of the more in-depth features are ways of exposing a simpler interface to library users - you don't need to understand the descriptor protocol or other special methods to use objects that use them. My suggestion would not be to try and write python that takes advantages of these things, but to read python that uses them. You will learn a lot from taking apart existing code and understanding how it works, as opposed to slowly repeating the mistakes others have made, documented and tested before you.
|
# ? Jan 31, 2012 01:35 |
|
Eliza posted:
What does the ! prefix on validate mean? vvvv Thanks! FoiledAgain fucked around with this message at 02:39 on Jan 31, 2012 |
# ? Jan 31, 2012 01:39 |
|
FoiledAgain posted:What does the ! prefix on validate mean?
|
# ? Jan 31, 2012 01:59 |
|
tef posted:twisted I find is more an abstraction around an event loop over an abstraction useful for writing event driven code -- i.e it is more convenient for the twisted maintainers than the users. I find myself more attached to the co-routine style (PEP-342) things which have started to appear (monocle, bluelet and even in twisted (but undocumented, of course)). Yes, co-routines are where I sometimes end up after deciding Twisted is too magical for me. It's been awhile since I needed anything co-routiney, but when I did I liked Eventlet.
|
# ? Jan 31, 2012 02:22 |
|
tef posted:twisted I find is more an abstraction around an event loop over an abstraction useful for writing event driven code -- i.e it is more convenient for the twisted maintainers than the users. There are lots of random things in Twisted. It's a large library with lots of random things. You can make an ssh server really quickly. There's code for an SFTP server, and an IRC server. They have their own authentication framework. It uses zope.interface. tef posted:I find myself more attached to the co-routine style (PEP-342) things which have started to appear (monocle, bluelet and even in twisted (but undocumented, of course)). Once you understand things like Deferreds and the techniques that you can use with those, it becomes a lot easier. If you're having trouble understanding them, it's not you: async programming is confusing. I started but never finished a bunch of tutorials on Deferreds a little while ago: DeferHowTo-Fixup (and its older cousin DeferHowTo-Fixup-1), and DeferHowTo-Rewrite. They're nowhere near perfect, but hopefully they clear up the motivation there. I also use the cooking metaphor somewhere in those documents because it's a pretty excellent metaphor for asynchronous and parallel tasks: preheat the oven, do other things in the mean time, respond when the timer dings, etc. If you've never done asynchronous programming, go read Eric Lippert's post on it, and then read the introduction to part two where he explains that this is orthogonal to threading. Asynchronity, concurrency, parallelism and threading are all separate, but related things. Of course, Twisted also has things like monocle, bluelet, etc. It's called inlineCallbacks, and the wonder of it is that it's just a giant magic wrapper around Deferreds. The encapsulation is only to that function - to the rest of the world, it's just another Deferred. Oh, and in case you need to deal with blocking code (like DBAPI), Twisted has a deferToThread method that will stick that call on its own thread and provide you with a Deferred that you can attach your own callbacks to. Suspicious Dish fucked around with this message at 15:41 on Jan 31, 2012 |
# ? Jan 31, 2012 03:58 |
|
ufarn posted:not; if validates True, you get False. Not to be pedantic, but Python has no "!" operator. He wants the "not" keyword instead.
|
# ? Jan 31, 2012 05:39 |
|
tef posted:twisted I find is more an abstraction around an event loop over an abstraction useful for writing event driven code -- i.e it is more convenient for the twisted maintainers than the users. I find myself more attached to the co-routine style (PEP-342) things which have started to appear (monocle, bluelet and even in twisted (but undocumented, of course)). I don't know if that's how it's supposed to work though, since it makes the scheme://host:port explode in HttpClient.request() pointless, as you need to pass a pre-split host and port (and scheme though it defaults to 'http') to connect() anyway (which assigns them to self.host, port, scheme). You can then just use resp = yield client.request("/path/to/doc") rather than resp = yield client.request("http://127.0.0.1/path/to/doc:8088"). Is this right? It might just be that the HTTP module isn't fully fleshed out for all I know. The Gripper fucked around with this message at 08:39 on Jan 31, 2012 |
# ? Jan 31, 2012 08:37 |
|
Comrade Gritty fucked around with this message at 00:45 on May 17, 2014 |
# ? Jan 31, 2012 11:34 |
|
|
# ? May 9, 2024 15:44 |
|
The Gripper posted:I checked out Monocle a few weeks back and while it looked great (and actually more suitable than Twisted would be for me) I couldn't figure out how to get it working on any of my machines. The http module seems to mostly be complete for abstracting around tornado or twisted. From what I saw the monocle http code itself wasn't very complete
|
# ? Jan 31, 2012 15:02 |