Re: Python development tools
> >> > 1. Automated Refactoring Tools > > >> I wish. > > > Why? I've never seen the appeal of these. I do plenty of refactoring. > > It's unclear to me what assistance an automated tool would provide. > I've often wanted something that would help globally change > things like function and method names including across multiple > files. Even variable names in large functions (ideally functions > should be small enough that this is not a problem but sometime > shit happens). I am not great at picking good names to begin > with and often code drift makes them even worse with time. > Editor search and replace doesn't cut it. I have occasionally used Bicycle Repair Man for this kind of thing. I don't actually know if it works across files, and I never quite convinced myself that it really works faithfully at all, but you could always try it (and even improve it if you can): http://bicyclerepair.sourceforge.net/#overallidea -- http://mail.python.org/mailman/listinfo/python-list
Re: Python development tools
On Sunday, June 23, 2013 4:40:07 PM UTC-4, cutems93 wrote: > Hello, > > > > I am new to python development and I want to know what kinds of tools people > use for python development. I went to Python website and found [12 different > types of] tools. > What else do I need? Also, which software is used in daily base? > Which software is used less often? It depends on what you want to do, but I myself would want at least an IDE. Of your list, I've only used 1,4,6 for a long time to make desktop applications. What do you want to do? > Also, I will use GUI interface for Python. What kind of widget toolkits do > you recommend? I know there are GTK+ and Qt. You can search the archives of this list for a lot of that question asked now and then. For me, wxPython. -- http://mail.python.org/mailman/listinfo/python-list
make sublists of a list broken at nth certain list items
I'm looking for a Pythonic way to do the following: I have data in the form of a long list of tuples. I would like to break that list into four sub-lists. The break points would be based on the nth occasion of a particular tuple. (The list represents behavioral data trials; the particular tuple represents the break between trials; I want to collect 20 trials at a time, so every 20th break between trials, start a new sublist). So say I have this data: data_list = [(0.0, 1.0), (1.0, 24.0), (24.0, 9.0), (9.0, 17.0), (17.0, 5.0), (5.0, 0.0), (5.0, 0.0), (5.0, 24.0), (24.0, 13.0), (13.0, 0.0), (13.0, 21.0), (21.0, 0.0), (21.0, 0.0), (21.0, 23.0), (23.0, 24.0), (24.0, 10.0), (10.0, 18.0), (18.0, 4.0), (4.0, 22.0), (22.0, 1.0), (1.0, 0.0), (1.0, 24.0), (24.0, 6.0), (6.0, 14.0), (14.0, 5.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 0.0), (5.0, 24.0), (24.0, 6.0), (6.0, 14.0), (14.0, 4.0), (4.0, 0.0), (4.0, 22.0), (22.0, 1.0), (1.0, 0.0), (1.0, 24.0), (24.0, 9.0), (9.0, 17.0), (17.0, 4.0), (4.0, 0.0), (4.0, 22.0), (22.0, 1.0), (1.0, 0.0), (1.0, 0.0), (1.0, 24.0), (24.0, 12.0), (12.0, 4.0), (4.0, 0.0), (4.0, 22.0)] #rest of data truncated... I'd like to break the list into sublists at the 20th, 40th, and 60th occasions of any tuple that begins with 1.0--so for example, (1.0, 0.0). This will produce four sub-lists, for trial 1-20, 21-40, 41-60, and 61-80. What I have, just to get the break points within the data_list, and which is not working is: trial_break_indexes_list = [] #needed to see where the sublists start trial_count = 0 #keep count of which trial we're on trial_break_indexes_list = [] #holds the index of the transitions_list for trials 1-20, 21-40, 41-60, and 61-80 trial_count = 0 for tup in data_list: if tup[0] == 1.0: #Therefore the start of a new trial #We have a match! Therefore get the index in the data_list data_list_index = data_list.index(tup) trial_count += 1 #update the trial count. if trial_count % 20 == 0: #this will match on 0, 20, 40, 60, 80 trial_break_indexes_list.append(data_list_index) print 'This is trial_break_indexes_list: ', trial_break_indexes_list Unfortunately, the final output here is: >>> This is trial_break_indexes_list: [1, 20, 20, 20, 20, 1, 20, 1] I sense there is a way more elegant/simpler/Pythonic way to approach this, let alone one that is actually correct, but I don't know of it. Suggestions appreciated! Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Monday, July 8, 2013 9:45:16 PM UTC-4, ajetr...@gmail.com wrote: > all, > > > > I am unhappy with the general Python documentation and tutorials. OK. Do you mean the official Python.org docs? Which tutorials? There's a ton out there. > I have worked with Python very little and I'm well aware of the fact that it > is a lower-level language that integrates with the shell. I thought it was a high level language. Integrates with the shell? Isn't it just simplest to think of it as a programming language and that's what you need to know? > I came from a VB legacy background and I've already "un-learned" everything > that I need to (I know, that language stinks, and isn't OOP or even useful!). On that last point, I think a quick Google search of job postings suggests otherwise. > I have to get back into writing Python but I'm lacking one thing ... I'm guessing it is probably more than *one* thing. But moving along... > So my issue is basically to understand how to go about writing programs and > compiling them so they can be deployed to less tech-savvy people. Here's > what I think I have to do, in a general sense: > > => Pick a GUI and just run through the tutorials to learn the interfaces as > fast as possible. Yes. > This is all fine and dandy, but more than likely when I do this the people > that I am sending solutions to will, if not receiving a simple .exe file, > receive the package from me and say to themselves "what in the world do I do > with this!?" Yes. If they are not Python users, that's right. > Is there anyway you guys would suggest that I fix this or help them deal with > complex languages like Python and programs written with it? Again, "complex language"? It's a programming language, that's it. Anyway, yes: read the first sentence after "Overview" here: https://us.pycon.org/2012/schedule/presentation/393/ The other respondents to your post have a good philosophical point, that it is kind of unfortunate to bundle up a Python program and the whole interpreter when you can just send a much smaller .py file, but in reality, there are a number of cases where doing it is preferred. First, your case with completely unPython-savvy users. Second, if you have a lot of dependencies and it would make it necessary for end users to install all of them for your program to work. In the end, I'm a fan of them. Couple of responses to others in that regard: > There are projects that "bundle" the CPython interpreter with your > project, but this makes those files really big. Maybe 5-20 MB. That's a lot bigger than a few hundred K, but it's not that important to keep size down, really. > Target the three most popular desktop platforms all at once, no > Linux/Windows/Mac OS versioning. Ehhh... There are differences, in, e.g., wxPython between the three platforms, and you can either do different versions or, more aptly, just fix these differences in your code with conditional statements ("if this is Win, do this, else do that"). -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Tuesday, July 9, 2013 1:03:14 AM UTC-4, Chris Angelico wrote: > On Tue, Jul 9, 2013 at 2:46 PM, CM wrote: > > >> Target the three most popular desktop platforms all at once, no > > >> Linux/Windows/Mac OS versioning. > > > Ehhh... There are differences, in, e.g., wxPython between the three > > platforms, and you can either do different versions or, more aptly, just > > fix these differences in your code with conditional statements ("if this is > > Win, do this, else do that"). > > > > Please watch your citations, you quoted several different people > without any hint as to who said what :) Uhp, sorry. I was just trimming for space, but good point. > Yes, there are a few differences. But a *lot* less than there are > differences between a Linux executable and a Windows one, or between > 32-bit and 64-bit binaries, or between Red Hat and Debian packages, > etc, etc, etc. Differences in windowing systems or newlines or pat > separators will need to be dealt with regardless of the app, but there > are a whole pile of additional differences when you distribute binary > executables. Agreed. That said, some of whether it is worth the trouble will depend on whether the OP (or whoever) is planning to deploy for all these platforms. If it is just the big three, then it will be some (significant) work at first to get the executables made, but then, with some luck, less work to maintain the various platform versions. But sure, I am not at all disputing the idea that if you have, say, a Python program with wxPython, and the user is easily willing to install (or already has) Python and wxPython, to just send the .py file. It would be ludicrous to not do that. -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Tuesday, July 9, 2013 5:13:17 PM UTC-4, Joshua Landau wrote: > On 9 July 2013 03:08, Adam Evanovich wrote: > > Can you wrap source code/libs/apps into an EXE and just > > send that to the end user? Or is it more complicated for them? > > Urm.. yes. But don't. That's the "nuclear" option and isn't a good > one. If you have a *really genuinely good reason* (you probably don't) > to do this, there are ways. I still think you are overstating it somewhat. Have a website on which you distribute your software to end users (and maybe even--gasp--charge them for it)? *That's* a good reason. And that's one of the top ways that users get software. Also, many programs rely on 2-3 dependencies, and sometimes that is asking a lot of the end user to install. (I know, I know, it shouldn't be...and with things like pip it really shouldn't be, but you know how it goes). I completely agree with you in Ideal World thinking, but in the gnarly one we actually have, .exe files *often* have their place. -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Tuesday, July 9, 2013 5:21:22 PM UTC-4, Joshua Landau wrote: > On 9 July 2013 05:46, CM wrote: > > Maybe 5-20 MB. That's a lot bigger than a few hundred K, but it's not that > > important to keep size down, really. > Fair enough. It's not something I'd EMail to a friend, though. Again, agreed. I can't even try to email that; Gmail won't let me. I've had to use Dropbox to transfer files to a client. At this point, I probably *should* have had them install Python and wxPython, but then again, I suspected that operation could have (somehow) gone awkwardly, and I know that packaging up my program for each new version takes about five minutes and one click of a button, then drag the .exe to Dropbox, so maybe not. -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Tuesday, July 9, 2013 8:14:44 PM UTC-4, Joshua Landau wrote: > > I still think you are overstating it somewhat. Have a website on which you > > distribute your software to end users (and maybe even--gasp--charge them > > for it)? *That's* a good reason. > Not really. It'd be a good reason if it disqualifies the other > options, but it doesn't. Just give them an archive. > If you're worried about keeping your code "safe" then: That's not what I was thinking in terms of, although it's fine to note that since people on this list occasionally think just that. What I was thinking of was that if you are going to sell software, you want to make it as easy as possible, and that includes not making the potential customer have to install anything, or even agree to allow you to "explicitly" install a runtime on their computer. If the potential customer just sees, clicks, and installs, that should be the most they ought to have to do. > > Also, many programs rely on 2-3 dependencies, and sometimes that is asking > > a lot of the end user to install. (I know, I know, it shouldn't be...and > > with things like pip it really shouldn't be, but you know how it goes). > > > But why do they need to install it at all? If you're not installing > the .py file, then just include those dependencies in the archive -- > .py files are tiny. If you are installing the .py with a setup.py > (like with the link I included), then just install them at the same > time. Maybe. I'll have to think about it. I'm referring to libaries as dependencies. So for example, though .py files are small, wxPython, for example, isn't tiny, nor are other libraries one might use. > Yeah, but not for Python :P. For Python .exe files are a rarity and > should be kept that way. That there is a significant interest in creating exe files suggest that not everyone feels that way. -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Wednesday, July 10, 2013 12:12:16 AM UTC-4, Joshua Landau wrote: > On , CM wrote: > > > What I was thinking of was that if you are going to sell software, you want > > to make it as easy as possible, and that includes not making the potential > > customer have to install anything, or even agree to allow you to > > "explicitly" install a runtime on their computer. If the potential > > customer just sees, clicks, and installs, that should be the most they > > ought to have to do. > I don't really get what you are saying. Do you, or do you not, want it > installed? I'm just saying that sometimes one goes to download new software and are met with a statement such as: "Installing Eclipse is relatively easy, but does involve a few steps and software from at least two different sources. Eclipse is a Java-based application and, as such, requires a Java runtime environment (JRE) in order to run. ...Regardless of your operating system, you will need to install some Java virtual machine (JVM). You may either install a Java Runtime Environment (JRE), or a Java Development Kit (JDK), depending on what you want to do with Eclipse." This is not always the type of thing you want your customers to encounter. Can all the installation of the runtimes be done with an installer that is itself an .exe, like with PyInstaller? If so, that's probably fine. > > Maybe. I'll have to think about it. I'm referring to libaries as > > dependencies. So for example, though .py files are small, wxPython, for > > example, isn't tiny, nor are other libraries one might use. > > Please excuse the fact I haven't done anything serious on Windows in > years so I'm not really sure what I'm saying. How does Windows deal > with dependencies? > > It's going to have to be fetched at one point anyway, so that's either > at download-time, install-time or run-time. The first lets you just > add it to the archive, the second lets you deal with it through a good > standard distribution manager thing, the third is potentially crazy. > Hence, wutz za probem bruv? I'm good with the first way, and I'm fine with Linux's package manager/whatever doing it the second. To simplify everything: sales require massive simplicity for (some) end users. You can get 1-2 clicks out of them before they drop dead as buyers. Furthermore, and I haven't mentioned this yet, an .exe file on Windows has the look of authenticity, whereas a .py file (which is a text file, really) doesn't, which might also matter to customer perceptions. This is all psychology. The ease of deployment side is up for grabs, but yes, potentially a hassle for cross platform deployment. I'm open to the idea of using an installer .exe to set up the user's computer with Python and all the libraries he needs to get going. I just haven't done that so far. -- http://mail.python.org/mailman/listinfo/python-list
Re: Beginner - GUI devlopment in Tkinter - Any IDE with drag and drop feature like Visual Studio?
On Tuesday, July 9, 2013 4:33:17 AM UTC-4, Aseem Bansal wrote: > Thanks @Dave Cook. > > > > I'll try wxPython. If so, the hoary but working Boa Constructor 0.7 is a drag and drop GUI builder for wxPython applications. Well, more like click and then click again, then drag around. It's also an IDE, so it also does a lot of other stuff. ("No one" likes it any more because it hasn't been updated in years, but I like it, but I also like the 1974 AMC Matador.) -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
> I was mainly talking in the context of the original post, where it > seems something slightly different was meant. If you're deploying to > customers, you'd want to offer them an installer. At least, I think > you would. That's different from packing Python into a .exe file and > pretending it's good-to-go. It depends. In some sense, probably an .exe is the very simplest thing you can provide a user: they download and move it to where they want, the click on it, it runs. It *is* good-to-go, isn't it? (btw, I know at least one person I've read on a forum who just won't use any installer--he feels it can put stuff on his computer where he doesn't have good easy control of it.) Sometimes an installer might be preferable, especially if there are data or image files or tutorials or something that go with the .exe (that weren't, for some reason, bundled inside it). > If they don't want it installed, again the best thing to do is an > archive with some "executable" (possibly a batch file or something -- > you Windows people would know better what you need) that just runs > "python main_file.py". Then get them to extract + click. That's 2 > operations, and a lot faster than some silly install process. But that's pretty much what the .exe that py2exe makes does anyway. It just kind of hides it all inside the .exe file. > There are a lot of ways of making an installer, and my current few > Googles have shown that distutils comes with a way of making .msi > files¹, and there's also http://wix.tramontana.co.hu/. Some random > internet guy reccomended https://code.google.com/p/omaha/, but I've no > idea if it's appropriate. There's also > http://nsis.sourceforge.net/Main_Page. Again, I'm no Windows user so > I'm talking by guessing. And InnoSetup, which I've used to good effect. > These are saner solutions because they focus on installing rather than > pretending that a .exe file with a packaged Python is anything like a > compiled C source. I don't think most informed users of, say, py2exe think that. I think they see it as "freezing" the application for single-file portability. The fact that people will refer to it as "compiling it to an exe" is unfortunate, yes. Again, for anyone selling software, just make as few steps as possible for the user. Using py2exe (which is easy to do) to freeze a lot of .py scripts into one easily deployed app passes that test. So does any simple method you mentioned, I'm sure. It all gets us to the same place, right? -- http://mail.python.org/mailman/listinfo/python-list
Re: Stack Overflow moder ator “animuson”
On Wednesday, July 10, 2013 11:01:26 AM UTC-4, Steven D'Aprano wrote: > Mats, I fear you have misunderstood. If the Python Secret Underground > existed, which it most certainly does not, it would absolutely not have > the power to censor people's emails or cut them off in the middle of > *That's* the Python Secret Underground's special power? That's it?! Cutting people off in the middle of an email? I mean how lame can -- http://mail.python.org/mailman/listinfo/python-list
Re: the general development using Python
On Wednesday, July 10, 2013 7:57:11 PM UTC-4, Joshua Landau wrote: > Yeah, but why keep shipping the Python interpreter? If you choose the > installer route, you don't have to keep shipping it -- it's only > downloaded if you need it. If not, then you don't download it again. I admit that not necessarily shipping the Python interpreter is much more efficient if your client base is expected to be a lot of people who already have Python and a lot of the common libraries (like wxPython). I have a fair number of Python 3rd party libraries already on my computer, so for me, it is preferable to just download the .py files the developer has made. For some of the things I have thought about doing, though, the majority of the clients would never even have heard of Python other than Monty or the constrictor. > But I still think my way is better. Perhaps I'm just too pragmatic > about these things. This was triggered by the OP's original request -- > he sounds very much like he doesn't actually want this -- and it seems > to have stuck. I don't know if being pragmatic is a bad thing, though. I'll definitely think about the business angle of doing it the way you suggest. For example, for consulting work where the end user is a technical worker who just need a script to automate some processes, and you expect to be providing a number of scripts over time in this way, a good way to install and setup a Python + GUI toolkit + other likely necessary libraries would be great. For more "product sales to the mass populous", I'm less sure. > In the end, something like this is best solved with a bit of A/B > testing¹. Sit a couple of your audience down, give them the best > implementation of each strategy (starting from the website) for some > trivialised module and see what they think. If it turns out that being > pragmatic does have compromises, I'm not going to argue with the data. > I'd still be grumpy, though. Makes sense. I'm dubious about the full validity of A/B testing data without large data sets, but yes, at least one would be getting a feel for it. I can also see what other projects/businesses are doing. Thanks for the input! -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding other people's code
> Basically the problem is I am new to the language and this was clearly > written by someone who at the moment is far better at it than I am! Sure, as a beginner, yes, but also it sounds like the programmer didn't document it much at all, and that doesn't help you. I bet s/he didn't always use very human readable names for objects/methods/classes, either, eh? > I'm starting to get pretty worried about my lack of overall progress and so I > wondered if anyone out there had some tips and techniques for understanding > other peoples code. There has to be 10/15 different scripts with at least 10 > functions in each file I would say. Unless the programmer was really super spaghetti coding, I would think that there would be some method to the madness, and that the 10-15 scripts each have some specific kind of purpose. The first thing, I'd think (and having not seen your codebase) would be to sketch out what those scripts do, and familiarize yourself with their names. Did the coder use this form for importing from modules? from client_utils import * If so, that's going to make your life much harder, because all of the names of the module will now be available to the script it was imported into, and yet they are not defined in that script. If s/he had written: import client_utils Than at least you would expect lines like this in the script you're looking at: customer_name = client_utils.GetClient() Or, if the naming is abstruse, at very least: cn = client_utils.GC() It's awful, but at least then you know that GC() is a function within the client_utils.py script and you don't have to go searching for it. If s/he did use "from module import *", then maybe it'd be worth it to re-do all the imports in the "import module" style, which will break everything, but then force you to go through all the errors and make the names like module.FunctionName() instead of just FunctionName(). Some of that depends on how big this project is, of course. > Literally any idea will help, pen and paper, printing off all the code and > doing some sort of highlighting session - anything! What tools are you using to work on this code? Do you have an IDE that has a "browse to" function that allows you to click on a name and see where in the code above it was defined? Or does it have UML or something like that? -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding other people's code
On Monday, July 15, 2013 6:02:30 AM UTC-4, Azureaus wrote: > To be fair to who programmed it, most functions are commented and I can't > complain about the messiness of the code, It's actually very tidy. (I suppose > Python forcing it's formatting is another reason it's an easily readable > language!) Luckily not blanked import * were used otherwise I really would be > up the creek without a paddle. Oh, good! OK, so then what you can think in terms of, in terms of a simple strategy for getting clear without any fancy tools: Learn what each module is for. In my own application programming, I don't just put random classes and functions in any old module--the modules have some order to them. So, for example, one module may represent one panel in the application, or all the database stuff, or all the graphing stuff, or some other set of logic, or whatever. One might be the main GUI frame. Etc. So I'd get a notebook or file and make notes for yourself about what each module is for, and the name. Even tack a piece of paper above your workstation with the module names and a one line note about what they do, like: MODULES: Map_panel: Displays a panel with the map of the city, with a few buttons. Dbases: Has all utility functions relevant to the database. Utils: Has a collection of utility functions to format time, i18n, etc. Now, there's a cheat sheet. So, if you come across a line in your code like: pretty_time = Utils.GetPrettyTime(datetime) You can quickly look at Utils module and read more about that function. Does this approach make sense to at least clear the cobwebs? -- http://mail.python.org/mailman/listinfo/python-list
SQLite logic error or missing database
(Posted to SQLite users list first; 3 views so far, and no answers, so trying here, thinking that perhaps a Python user would have some clues; I hope that is OK) I am using SQLite through either Python 2.5 or 2.7, which is the sqlite3 module. In a desktop application, every now and then, and in a fairly irreproducible way, when committing to the database I get this error: "sqlite3.OperationalError: SQL logic error or missing database" I thought this was a PySqlite generated error, but now I see the same error is seen with Ruby, PHP, C++ and other languages, so now I think it is generated by SQLite itself...but I really don't know. If I try additional commits in that same instance of my app being open, it gives me the same error every time. If I close the app and re-open it, it does not give me this error, with the same or very similar data being written in the same routines. So I "know" that the code as written is correct (a significant--greater than 90%?--of the time I don't see this error). In terms of what is causing this, I don't know. But I've noticed that on the occasions that this has happened my computer's RAM was pretty bogged down and my computer is pretty laggy. That said, I've had other times when my RAM was hogged just as much and it didn't do this. This error might go away if I used a newer/cleaner/more RAM computer, but I want to "stress test" my application for those who may be using similarly clunky computers--I want to try to avoid it even for older model computers. Any advice appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to package embedded python?
On Tuesday, July 30, 2013 4:23:06 PM UTC-4, David M. Cotter wrote: > yes, i've looked there, and all over google. i'm quite expert at embedding > at this point. > > > > however nowhere i have looked has had instructions for "this this is how you > package up your .exe with all the necessary python modules necessary to > actually run on a user's system that does not have python installed". > > > > on mac, it's trivial: all macs come with python, there is nothing i need to > include with my app and it "just works" > > > > on windows: if you don't include the proper DLLs and/or whatnot, then the app > will complain about missing DLLs on startup. > > > > What DLLs must i include? where are the instructions? I know nothing about embedding, but in terms of packaging up a Python interpreter with an application that needs it, could you use py2exe to do that? If, so is this helpful (gotten from Google's cache since page doesn't appear at the moment...later try embedded Python py2exe search)?: http://webcache.googleusercontent.com/search?q=cache:x3lrdFT5OF0J:www.py2exe.org/index.cgi/ShippingEmbedded+&cd=2&hl=en&ct=clnk&gl=us&client=firefox-a -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and Facebook
On Jun 24, 12:16 pm, Alec Taylor wrote: > This is the most active one, forked from the official facebook one > (when they used to maintain it > themselves):https://github.com/pythonforfacebook/facebook-sdk > > > > > > > > On Mon, Jun 25, 2012 at 1:35 AM, Chris Angelico wrote: > > On Mon, Jun 25, 2012 at 1:16 AM, Jerry Rocteur > > wrote: > > >> Hi, > > >> I posted this mail on Friday and received no replies.. > > >> I'm curious.. > > >> Is it because > > >> 1) Python is not the language to use for Facebook, use Javascript or XXX > >> ?? instead ? Please tell. > >> 2) I've missed the point and this is very well documented so RTFM (I > >> couldn't find it) > >> 3) You guys don't use Facebook, you have a life .. > > > I personally don't use Facebook, but I don't have much of a life > > either. But I've never heard of a specific Python-Facebook module, > > until just now when I googled it and found a couple of things. > > > Two points: > > > 1) Python's pretty good at networking. If all else fails, you can > > always just implement whatever Facebook's API is (the Google snippets > > suggest it's REST, ie all HTTP, which Python does admirably), and go > > from there. > > > 2) An active Python-Facebook module will have active developers who > > probably know far more about how to use their module than random > > people like me who happen to read all of python-list :) There may well > > be such people on this list, but since you've received no replies, > > it's possible there aren't. (It's also possible that they don't > > monitor this list on weekends, though. You never know.) > > > 3) What do Facebook think of you downloading all their content and > > viewing it without their ads? Not that I particularly care, but it may > > be something to consider, since you're effectively going to get > > everything that Facebook offers you (ie posts/pics/etc) without > > everything that Facebook steals from you and sells (page views, ad > > impressions, etc). > > > (Among our points are such diverse elements as... wrong Pythons, but > > whatever.) > > > There's no official Python-Facebook module (afaik!!), but a quick web > > search for 'python facebook' should get you to the couple that I saw, > > and possibly others. The next question is, do you trust any of them... > > Good luck with that one! :) > > > Chris Angelico > > -- > >http://mail.python.org/mailman/listinfo/python-list FWOW. I tried for about a week every Python Facebook module out there I could find (including that one), with Python 2.5 or 2.7, and for whatever reason was unsuccessful in uploading a photo and quit trying. Frustrating. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
> It would not be difficult to convince me to commit homicide for > a Delphi-like Python gui machine that runs on a Linux box. I > have played with many - Boa, WxDes, Glade, Tk, Dabo, QtDesigner, > Card, etc. Not sure whether you tried it enough on Linux, but Boa (which was intended to be kind of Delphi for Python) *almost* runs OK on Linux. There are a few workarounds to some of the problems and I have a list of the remaining issues. But yes, it's not ideal to use on Linux yet (I have done sort of OK with developing with it on Windows and then using it on Linux to tidy up cross platform incompatibilities in wxPython apps between Win and Linux). -- http://mail.python.org/mailman/listinfo/python-list
Python LOC, .exe size, and refactoring
I have an application that I was hoping to reduce a bit the size of its .exe when "packaged" with py2exe. I'm removing some Python modules such as Tkinter, etc., but now wonder how much I could size I could reduce by refactoring--and therefore shortening--my code. Is there a rule of thumb that predicts the relationship between the number of lines of Python code and the resultant size of the application (leaving aside the size of imported modules)? Or is there a way to roughly estimate how much would refactoring the code as much as I reasonably can help? (For example, in some cases there is some cut and paste coding...I know, it's bad). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python LOC, .exe size, and refactoring
On Feb 22, 12:29 am, Steven D'Aprano wrote: > On Tue, 21 Feb 2012 19:51:07 -0800, CM wrote: > > I have an application that I was hoping to reduce a bit the size of its > > .exe when "packaged" with py2exe. I'm removing some Python modules such > > as Tkinter, etc., but now wonder how much I could size I could reduce by > > refactoring--and therefore shortening--my code. > > Well that will depend on how much you refactor it, but frankly, unless > your code is truly awful, this will be a micro-optimization. py2exe > bundles a Python runtime environment plus your files into a single exe > file. Typically the runtime environment will be somewhere around 11MB for > wxPython GUI apps (or 4MB with compression turned on, which will slow > your application down). > > http://www.py2exe.org/index.cgi/SingleFileExecutable > > The runtime environment for Oracle's Java environment starts at 7MB and > is typically 15MB, plus whatever libraries your own code produces. For > dot-net applications, the framework can be up to 60MB. > > http://weblogs.java.net/blog/stanleyh/archive/2005/05/deployment_unde... > > http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramewor... > > While I think 60MB for a basic calculator app is taking the piss, this is > 2011 not 1987 and we don't have to support floppy disks any more. 11MB > for a GUI app is nothing to be worried about. That takes, what, 3 minutes > to download even on a 512 kbps link? > > > Is there a rule of thumb that predicts the relationship between the > > number of lines of Python code and the resultant size of the application > > (leaving aside the size of imported modules)? > > Yes. To a close approximation, for most applications: > > size of bundled application = ( > size of Python runtime environment + size of libraries used > ) > > Your code is most likely insignificant compared to the others. > > > Or is there a way to > > roughly estimate how much would refactoring the code as much as I > > reasonably can help? (For example, in some cases there is some cut and > > paste coding...I know, it's bad). > > Look at it this way: take the .pyc file from your code. How big is it? > Say, it's 200K. That's a BIG file -- the decimal module in the standard > library is only 152K. Suppose you could cut it in half -- you would save > 100K. Even if you could somehow cut it down to 1K, you've saved less than > 200K. Do you care? > > Refactoring your code is double-plus good for maintainability. You should > do it anyway. But don't do it to shrink an 11MB exe down to 10.8MB. > > -- > Steven Thanks. All helpful advice. I'm coming in around 14 MB when you count some libraries, image files, etc., and I think I can live with that, considering I was able to reduce it from about 20 MB at one point by some excluding. Che -- http://mail.python.org/mailman/listinfo/python-list
use Python to post image to Facebook
Shot in the dark here: has any who reads this group been successful with getting Python to programmatically post an image to Facebook? I've tried using fbconsole[1] and facepy[2], both of which apparently work fine for their authors and others and although I have an authorization code, publish permissions, a Facebook app, I get back these unhelpful errors when I try this (like "an unknown error occurred"). If anyone has been able to do this, maybe you can help me figure out what I am doing wrong. -- http://mail.python.org/mailman/listinfo/python-list
Re: use Python to post image to Facebook
> I've tried using fbconsole[1] and facepy[2], both of which apparently Forgot the refs: [1]https://github.com/facebook/fbconsole; http://blog.carduner.net/2011/09/06/easy-facebook-scripting-in-python/ [2]https://github.com/jgorset/facepy -- http://mail.python.org/mailman/listinfo/python-list
Re: Newby Python Programming Question
On May 11, 11:25 am, Coyote wrote: > Folks, > > I am migrating to Python after a 20+ year career writing IDL programs > exclusively. I have a really simple question that I can't find the answer to > in any of the books and tutorials I have been reading to get up to speed. > > I have two programs. The first is in a file I named file_utils.py: > > def pwd(): > import os > print os.getcwd() > > The second is in a file I named pwd.py: > > import os > print os.getcwd() > > Here is my question. I am using the Spyder IDE to run these programs. If I > type these commands, I get exactly what I want, the name of my current > directory: > > >>>from file_utils import pwd > >>>pwd() > C:\Users\coyote\pyscripts > > But, if I "run" the pwd.py script by selecting the "Run" option from the IDE > menu, the directory is printed *twice* in the output window. Why is that? I don't know Spyder IDE, but I don't think this should happen; could there just be a simple mistake? Because you first refer to the .py file as 'file_utils.py' but then you refer to the file as 'pwd.py'...which is also the name of your function. Room for confusion...so could you test this by saving only your one function (below), give the .py a new name to avoid confusion (like test_pwd.py) and then running *that* through Spyder IDE? def pwd(): import os print os.getcwd() -- http://mail.python.org/mailman/listinfo/python-list
Re: Are there any instrumentation widgets for wxpython or tkinter?
On May 17, 5:00 pm, Peter wrote: > Or wxPython is another good alternative. Download the demo and have a look at > the widgets people have already used/created. I think there are some good > choices for instrumentation (from memory). Yes, wxPython has some that are applicable: LEDNumberCtrl PeakMeter SpeedMeter KnobCtrl wxGauge wxSpinCtrl Slider And probably others. -- http://mail.python.org/mailman/listinfo/python-list
Re: what gui designer is everyone using
On Jun 5, 10:10 am, Mark R Rivet wrote: > I want a gui designer that writes the gui code for me. I don't want to > write gui code. what is the gui designer that is most popular? > I tried boa-constructor, and it works, but I am concerned about how > dated it seems to be with no updates in over six years. Boa Constructor. Very happy with it. Mostly use it for the IDE these days, as it already served to help build the GUI. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
On Jun 8, 8:27 am, Wolfgang Keller wrote: > > I want a gui designer that writes the gui code for me. I don't want to > > write gui code. what is the gui designer that is most popular? > > I tried boa-constructor, and it works, but I am concerned about how > > dated it seems to be with no updates in over six years. > > Sorry to "hijack" your thread, but since this is a very related > question... > > What "GUI designer" would come the closest to the way that Cocoa's > Interface Builder works? I.e. is there any one (cross-platform) that > allows to actually "connect" the GUI created directly to the code and > make it available "live" in an IDE? > > This whole cycle of "design GUI"->"generate code"->add own code to > generated code"->"run application with GUI" has always seemed very > un-pythonic to me. A dynamic, interpreted language should allow to work > in a more "lively", "direct" way to build a GUI. > > TIA, > > Sincerely, > > Wolfgang I'm curious about your point but I don't really understand it. Could you try again without using any scare-quoted words? Maybe given an example of creating a small text editor application with a GUI builder/ IDE in this Pythonic way you are hoping for. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
> I think that something in the style of Visual BASIC (version 6) is required > for either wxPython or PyQt/PySide (or both). > In the Visual BASIC editor you can e.g. add a GUI element > and directly go to the code editor to fill methods (e.g. an OnClick > method). You can do this for wxPython with Boa Constructor easily. You can bind an event handler for a wx.EVT_BUTTON to, e.g., "Button1" with Boa and it will add this code for you to the bottom of your code: def OnButton1Button(self,evt): evt.Skip() And you can than go in the code editor to that function and change the code to do whatever you want. > If you have not used VB before, you should just try it. You can create > GUIs within a few minutes even if you haven't used it before. Same with Boa. > Such an editor should support simple manual layouts without enforcing > the use of sizers (wx) or layout managers (Qt). > These add an additional level of complexity which is not required > for simple GUIs. Same with Boa, though it also has good support for sizers which generally should be required for anything other than the simplest GUIs. > data acquisition, but the lack of an easy-to-use GUI editor is > the blocking point. I can teach anyone how to create a program for data > acquisition, but I don't see how more than a few could create a GUI > without an easy-to-use tool. > There's still a lot of VB6 code around as there's no replacement and > this gap could well be filled by Python. In addition to Boa, I get the sense that the other tools mentioned here are also good, so is this "blocking point" real? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
On Jun 11, 6:55 pm, Dietmar Schwertberger wrote: > But then we're back to the initial point: As long as there's no GUI > builder for Python, most people will stick to Excel / VBA / VB. Then good thing there *are* GUI builder/IDEs for Python, one of which was good enough for me to take me from essentially zero modern programming experience to a sizable (> ~15k LOC) application. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
On Jun 14, 2:25Â pm, Wolfgang Keller wrote: > > What is needed for domain specialists are frameworks and related tools > such as GUI builders that allow them to write exclusively the > domain-specific code (this is where a domain specialist will always be > better than any software developer), layout the GUI as ergonomically > convenient (same) and then have the framework do all the rest. Above this you also mentioned a disdain for the need for "glue code", which in the context of your post seemed to be binding to event handlers. So is there a possible way for a GUI builder to *automatically* bind widgets to the appropriate functions in your domain-specific code? It's hard to see how this would be generally possible, even with an AI (maybe a mind-reading AI would work). Or maybe I'm misunderstanding something. -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)
Dietmar quotes: > With Python not having an easy-to-use GUI builder, > The point is, that if you want to promote Python as replacement > for e.g. VB, Labview etc., then an easy-to-use GUI builder is required. > The typical GUI programs will just have an input mask, a button and one > or two output fields. > On the other hand, I need to know wx very well to be able to create > a GUI using wxGlade as otherwise I will never find where to add > e.g. the handlers. > But when I know wx very well, then there's no point in using wxGlade. In response to all of these and the general heavily repeated mantra here that "there is no easy to use GUI builder for Python", OK, tell you what: describe what the "GUI that an engineer would want to make" should look like--give all widgets and their bindings--and I will see about making a video that shows how easy this is to do with a GUI builder, even with the user having a very rudimentary (or perhaps zero) knowledge of wxPython. And it will be timed. Let's test your idea for real. (I should note, I don't know what an "input mask" refers to above). -- http://mail.python.org/mailman/listinfo/python-list
Re: Wgy isn't there a good RAD Gui tool fo python
On Jul 10, 6:50 pm, Ivan Kljaic wrote: > Ok Guys. I know that most of us have been expiriencing the need for a > nice Gui builder tool for RAD and most of us have been googling for it > a lot of times. But seriously. Why is the not even one single RAD tool > for Python. I mean what happened to boa constructor that it stopped > developing. I simply do not see any reasons why there isn't anything. > Please help me understand it. Any insights? Just because Boa Constructor stopped (or lengthily paused?) development doesn't mean it doesn't exist. It does, and (at least on Windows), it is, IMO, really good. So why don't you use it? Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Wgy isn't there a good RAD Gui tool fo python
> > One reason there hasn't been much demand for a GUI builder is that, in > > many cases, it's just as simpler or simpler to code a GUI by hand. I use a GUI builder because I'd rather click less than type more. I just tried that in Boa Constructor; with ~10 mouse clicks I produced 964 characters of Python code. Now, sure, depending on how I wrote the code I could do better than that, but for me, I just find it more intuitive and easier to use a GUI to make a GUI. > Often a GUI builder is used as a bad replacement for sketch-pad and > pencil. I would use a sketch-pad and pencil and *then* use the GUI builder. What's nice about a builder is one can move things around quickly and see the results in the real application, which one can never really see well on a paper sketch. You could use a mock-up program of course, but I feel you might as well do it in the builder because when you're satisfied with it you have a real runnable application instead of just a picture. > Using a GUI builder with layout managers might actually > feel awkward. It takes some getting used to in Boa, in my experience, but then it feels intuitive and I really like using sizers with Boa. It helps if you give your sizers descriptive names. Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Wgy isn't there a good RAD Gui tool fo python
On Jul 12, 5:18 pm, rantingrick wrote: > On Jul 12, 1:43 pm, CM wrote: > > > > > One reason there hasn't been much demand for a GUI builder is that, in > > > > many cases, it's just as simpler or simpler to code a GUI by hand. > > > I use a GUI builder because I'd rather click less than > > type more. I just tried that in Boa Constructor; with ~10 > > mouse clicks I produced 964 characters of Python code. > > Remember, it's NOT the length of the code that matters, no, it's the > motion of the "sources" ocean. Did it produce rough seas full of > spaghetti monsters? Or tranquil fjords worth pining over (sadly to > death apparently?)? In my experience, the GUI builder I use creates reasonable code that deals with the GUI in a separate portion of the code. It does not strike me as spaghetti-ish (though it's not perfect). > Also, you MAY have created 964 chars of code with your ten or so > clicks HOWEVER that is just template code. You'll need to set many > attributes for the widgets before they are ready for prime time. Your > "supposed" ten or so click estimate is very naive. It takes MUCH more > to create even a simple GUI, because, we have NOT even discussed logic > yet! Sure. But my point was just that to even get as far as I did (which was just a frame and two unspecified widgets) takes 964+ keystrokes, but only ~10 clicks. So the pacing of keystrokes:clicks is favorable. If I built a small functioning GUI application, it might take 100 clicks and 9,640 keystrokes (very roughly). But it is the same point. > > I would use a sketch-pad and pencil and *then* use the GUI builder. > > But do you really? Your following statements lead me to believe that > you don't. > > > What's nice about a builder is one can move things around > > quickly and see the results in the real application, which > > one can never really see well on a paper sketch. I just meant that though I might start on paper, once it is on the screen I sometimes will shift things around a bit at that point to see how it looks. This is easily done with sizers and a sizer collection manager and an up/down arrow, so it is worth an extra minute to just see how it looks. > 1. GUI builders remove us from the initial "mental design phase" and > temp us to let our inner "click-ity-click" and "drag-ity-drag" child > loose. This inner child likes to play but he hates to plan. Very soon > he has the play room floor (source code) overflowing with toys (code) > arranged in a completely haphazard way. Unlike the child however, > there is no code mommy to spank this bad little boy when he is a > programmer. So he just keeps messing up play room after play room > making a complete fool of himself along the way. > > 2. GUI builders remove us from the source code. When you are playing > "clicky-click" with yourself you could be in the trenches fighting the > spaghetti code monster. Instead you are losing mental focus. Remember, > playing with yourself makes you lazy! I've certainly heard of others who feel that working with only code is "cleaner" for them, mentally speaking. I can understand that. I think it just depends on what one is used to. I don't find the GUI builder disrupts my ability to plan or keep things orderly. In fact, most of my disorder and spaghetti problems have been in the logic side of the applications, the part which the GUI builder doesn't have anything to do with. (That's my own issue to keep working on). > Kevin made the argument earlier that Tkinter (and others) are so easy > to use that they render needing a GUI builder useless -- and he is > correct! But did you know that there are GUI libraries EVEN more > highly abstracted than Tkinter? Oh yes! So your "OMG, this typing and > using my imagination is so difficult" *crap* is really making me > laugh. My attitude is, if I could speak in English to an AI to tell it what I'd like the program to do, I'd do it. Yes, since I can't do that, I inevitably do sometimes enjoy puzzling things out, but only because I have to. > PS: if you don't like to type, programming IS NOT the best career (or > hobby) choice for you. I guess it is not so much that I dislike typing, as I dislike having to switch from visual mode to code mode, remember the keywords and such for the widgets, rather than quickly clicking around. The keystroke count is really just a proxy for that sort of effort. CM -- http://mail.python.org/mailman/listinfo/python-list
Pythonic way with more than one max possible
I have three items in a dict, like this: the_dict = {'a':1, 'b':2, 'c':3} but the vals could be anything. I want to configure something else based on the "winner" of such a dict, with these rules: 1. In this dict, if there is a UNIQUE max value, that's the winner. 2. If there are any TIES for max value, b is the winner by default. The problem for me, as I see it, is I don't know any elegant ways to do this in Python. The max(dict) function doesn't distinguish between unique and non-unique maxes. I could go through and test the various possibilities (to see if the max value had any matches in the other values), but, knowing Python, there is probably something close to "one way to do it". Any suggestions? Thanks, Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way with more than one max possible
On Jul 19, 11:17 pm, CM wrote: > I have three items in a dict, like this: > > the_dict = {'a':1, 'b':2, 'c':3} > > but the vals could be anything. I want to configure something else > based on the "winner" of such a dict, with these rules: > > 1. In this dict, if there is a UNIQUE max value, that's the winner. > 2. If there are any TIES for max value, b is the winner by default. > Thank you to Steven and Chris for the answers. Very elegant. I realize, now though, (and Chris asked about this) that I was imprecise in my rules. They really should be stated as: 1. In this dict, if there is a UNIQUE max value, then its *key* is the winner. 2. If there are any TIES for max value, then the *key* 'b' is the winner by default. The point is, I am trying to determine the name of the winning category, either 'a', 'b', or 'c', not the value of its winning score. So in your solutions there is sorting by values, which makes sense. But how can I go back to keys from there? Sorry for the mistake (but even so, I learned something already). Thanks again, Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Pythonic way with more than one max possible
Thanks, everyone. Very helpful! Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice on how to get started with 2D-plotting ?
On Sep 6, 2:27 pm, Fred Pacquier wrote: > Hi, > > I'm a Python long-timer, but I've never had to use tools like Matplotlib & > others before. > > Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. > > This involves a graphic comparison of RFC1918 IP subnets allocation across > several networks. > > The idea is to draw parallel lines, with segments (subnets) coloured green, > yellow or red depending on the conflicts between the networks. > > What would be the simplest/fastest way of getting this done ? > (the graphic parts, the IP stuff I know how to handle) > Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. > > This involves a graphic comparison of RFC1918 IP subnets allocation across > several networks. > > The idea is to draw parallel lines, with segments (subnets) coloured green, > yellow or red depending on the conflicts between the networks. > > What would be the simplest/fastest way of getting this done ? > (the graphic parts, the IP stuff I know how to handle) One fairly simple way is with Matplotlib. Not sure what quite to imagine for your plot but below is code that makes an attempt at (maybe) something like you are describing, shown here: http://www.flickr.com/photos/67254913@N07/6123112552/in/photostream#/ There are fancier ways to do this in Matplotlib, but this is pretty quick and dirty--I'm just plotting lines over-top other lines. The pic I put is the plot as a .png, which matplotlib makes if you want, but you can also view it in a frame that matplotlib generates and then pan/zoom/etc... This is using the pylab module, but you could also embed your plots in a GUI if you prefer. from pylab import * #plot the parallel lines in green x = [1,2,3,4,5,6,7,8] y = [2 for num in x] for num in range(6): y = [num for item in x] plot(x,y,color='g',lw='4') #plot any conflict sections in red or yellow #...some data to give the idea: x2 = [3,4] y2 = [2 for num in x2] x3 = [5,6,7] y3 = [4 for num in x3] x4 = [2,3] y4 = [3 for num in x4] #plot three colored parts over the green lines plot(x2,y2,color='r',lw='12') plot(x3,y3,color='yellow',lw='12') plot(x4,y4,color='r',lw='12') #change y labels to meaningful labels pos = arange(6) yticks(pos, ('net1', 'net2', 'net3', 'net4', 'net5', 'net6')) show() #- Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Advice on how to get started with 2D-plotting ?
> Now, for my work, I would need to learn the basics fast, for a one-time > quick-n-dirty job. > > This involves a graphic comparison of RFC1918 IP subnets allocation across > several networks. > > The idea is to draw parallel lines, with segments (subnets) coloured green, > yellow or red depending on the conflicts between the networks. > > What would be the simplest/fastest way of getting this done ? > (the graphic parts, the IP stuff I know how to handle) AFAIK, probably Matplotlib. I'm not sure what quite to imagine for your plot but below is code that makes an attempt at (maybe) something like you are describing, shown here: http://www.flickr.com/photos/67254913@N07/6123112552/in/photostream#/ There are smarter ways to do this in matplotlib, but this is pretty quick and dirty. I'm just plotting lines over-top other lines. The pic I put is the plot as a .png, which matplotlib makes if you want, but you can also view it in a frame that matplotlib generates and then pan/zoom/etc... from pylab import * x = [1,2,3,4,5,6,7,8] y = [2 for num in x] #plot the parallel lines themselves in green for num in range(6): y = [num for item in x] plot(x,y,color='g',lw='4') #plot any conflict sections in red or yellow #some hard data to give the idea: x2 = [3,4] y2 = [2 for num in x2] x3 = [5,6,7] y3 = [4 for num in x3] x4 = [2,3] y4 = [3 for num in x4] #plot these three colored parts over the green lines plot(x2,y2,color='r',lw='12') plot(x3,y3,color='yellow',lw='12') plot(x4,y4,color='r',lw='12') pos = arange(6) yticks(pos, ('net1', 'net2', 'net3', 'net4', 'net5', 'net6')) show() #- Che -- http://mail.python.org/mailman/listinfo/python-list
Re: What do I need to know in order to write a web application in python?
On Mar 4, 5:07 pm, Corey Richardson wrote: > On 03/04/2011 04:48 PM, ErichCart ErichCart wrote: > > > In fact this doesn't necessary need to be web application. For example > > I have a friend who uses Delphi, and he can create all sorts of > > windows applications easily, like he can see the window on the screen > > and he can place buttons, text fields, radio buttons etc. wherever he > > wants and then program the actions of each element. I was able to do > > the same with visual basic in one of my university classes. > > > What do I need to know in order to be able to do the same with python? > > Which python modules/python development environments do I need to use? > > As far as I know, no tools exist to make developing desktop apps in > Python like there do VB. Boa Constructor is a visual GUI builder and IDE for desktop apps that was written to be a kind of Delphi for Python. I've used it happily for a long time. As the OP mentioned, it can allow visual designing of the GUI (like placing buttons, etc.), plus tons more. It's not actively developed anymore, though, and it is somewhat buggy on Linux (don't know on Mac). -- http://mail.python.org/mailman/listinfo/python-list
Re: What do I need to know in order to write a web application in python?
On Mar 4, 5:07 pm, Corey Richardson wrote: > On 03/04/2011 04:48 PM, ErichCart ErichCart wrote: > > > In fact this doesn't necessary need to be web application. For example > > I have a friend who uses Delphi, and he can create all sorts of > > windows applications easily, like he can see the window on the screen > > and he can place buttons, text fields, radio buttons etc. wherever he > > wants and then program the actions of each element. I was able to do > > the same with visual basic in one of my university classes. > > > What do I need to know in order to be able to do the same with python? > > Which python modules/python development environments do I need to use? > > As far as I know, no tools exist to make developing desktop apps in > Python like there do VB. Boa Constructor is a visual GUI builder and IDE for desktop apps that was written to be a kind of Delphi for Python. I've used it happily for a long time. Like the OP mentioned, it can allow visual designing of the GUI (like placing buttons, etc.), plus tons more. It's not actively developed anymore, though, and it is somewhat buggy on Linux (don't know on Mac). -- http://mail.python.org/mailman/listinfo/python-list
Re: What do I need to know in order to write a web application in python?
On Mar 4, 5:07 pm, Corey Richardson wrote: > On 03/04/2011 04:48 PM, ErichCart ErichCart wrote: > > > In fact this doesn't necessary need to be web application. For example > > I have a friend who uses Delphi, and he can create all sorts of > > windows applications easily, like he can see the window on the screen > > and he can place buttons, text fields, radio buttons etc. wherever he > > wants and then program the actions of each element. I was able to do > > the same with visual basic in one of my university classes. > > > What do I need to know in order to be able to do the same with python? > > Which python modules/python development environments do I need to use? > > As far as I know, no tools exist to make developing desktop apps in > Python like there do VB. For desktop applications that use the wxPython toolkit for the GUI, Boa Constructor is a visual GUI builder and IDE that was written to be a kind of Delphi for Python. I've used it happily for a long time. As the OP mentioned, it can allow visual designing of the GUI (like placing buttons, etc.), plus tons more. It's not actively developed anymore, though, and it is somewhat buggy on Linux (don't know on Mac). -- http://mail.python.org/mailman/listinfo/python-list
Re: What do I need to know in order to write a web application in python?
On Mar 5, 6:49 am, ErichCart ErichCart wrote: > Regarding Boa constructor, it is very old, isn't it? The latest news > from this project date to the end of 2006. I don't expect it to > support python 3 any time soon. The website is incredibly out of date, but the last major update was July 2007. So, yes. Like any snake, it could suddenly rear up and spring to life with a new version, but there is no way to know when or if that will happen. Even wxPython itself doesn't support Python 3 yet, so I'm not sure I'd let that deter you. It seems like many third party libraries haven't updated to Python 3 yet and may not for some time to come. All this said, one can build a toy GUI application using Boa, Python 2.5 or 2.6 and wxPython 2.8.x.x. in 5 minutes if you know what you're doing. And you can build a larger and real application that way, too. -- http://mail.python.org/mailman/listinfo/python-list
Re: Directly Executable Files in Python
> it has to be reproducing the byte code > interpreter in the code segment and the byte code in the data segment... > so that each .exe file created by said process is actually loading an > entire copy of at least the byte code interpreter with each program > "compiled" ... Yes, if you think of it as a handy packager and not a compiler, it makes sense. > can't be very efficient?? How do you define efficient? All I know is that it works well. You click on the .exe and a moment later you are running the application despite not having Python installed on your computer. I'm grateful for its existence. Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Directly Executable Files in Python
On Mar 29, 12:16 am, harrismh777 wrote: > Chris Rebert wrote: > > Yes. py2exe is a tool which generates such Windows executables: > >http://www.py2exe.org/ > > Interesting... but it can't possibly be creating .exe files > (compiling)... I don't buy it... it has to be reproducing the byte code > interpreter in the code segment and the byte code in the data segment... > so that each .exe file created by said process is actually loading an > entire copy of at least the byte code interpreter with each program > "compiled" ... Yes, if you think of it as a handy packager and not a compiler, it makes sense. > can't be very efficient?? How do you define efficient? All I know is that it works well. You click on the .exe and a moment later you are running the application despite not having Python or any of the third party libraries you've used installed on your computer. I'm grateful for its existence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
> I don't even know one person who has Win7 installed, running, and likes >it... > not even one. Hi, m harris, nice to meet you. Now you do. To the online community: Is there a name for trolling for A by advocating for not-A in a way that discredits your point of view an case so that A now seems much more reasonable? It's not really "concern trolling". What would this be called? -- http://mail.python.org/mailman/listinfo/python-list
Re: Free software versus software idea patents
On Apr 14, 1:50 am, harrismh777 wrote: > Westley Martínez wrote: > I don't even know one person who has Win7 installed, running, and > likes it... > > >> not even one. > > >>> > > Hi, m harris, nice to meet you. Now you do. > > >>> > > To the online community: Is there a name for trolling for A by > >>> > > advocating for not-A in a way that discredits your point of view an > >>> > > case so that A now seems much more reasonable? It's not really > >>> > > "concern trolling". What would this be called? > > >> > Harrisment. > > >> > /I'm sorry, this is abuse... > > >> > Geremy Condra > > That was harristerical. > > Actually, it is funny... and I love humor as much as I love mathematics, > software, and freedom. Truly harristerical... :) > > But on a serious note, I did wonder who would be the first jouster to > offer the argumentum ad hominem? ... ah, sticks and stones... I don't think there has been any argumentum ad hominem used here. No one besmirched you. What was criticized was your approach, which seemed counter-productive, and so much so that it seemed like you are "really" advocating FOR software patents by discrediting the position against them. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE/text-editor
On Apr 16, 1:43 am, Alec Taylor wrote: > Thanks, but non of the IDEs so far suggested have an embedded python > interpreter AND tabs... a few of the editors (such as Editra) have > really nice interfaces, however are missing the embedded > interpreter... emacs having the opposite problem, missing tabs (also, > selecting text with my mouse is something I do often). Boa Constructor has syntax-highlighting, code-completion, tabs, line numbers, and an embedded interpreter. It also does a lot of other IDEish stuff and it's a GUI builder, too. I've never tried to run it from a USB, though, and the interpreter (the "shell") is in a separate tab, not on the bottom as you've drawn it. You might want to just look at this page for other ideas: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments -- http://mail.python.org/mailman/listinfo/python-list
Re: De-tupleizing a list
On Apr 25, 11:28 pm, Gnarlodious wrote: > I have an SQLite query that returns a list of tuples: > > [('0A',), ('1B',), ('2C',), ('3D',),... > > What is the most Pythonic way to loop through the list returning a > list like this?: > > ['0A', '1B', '2C', '3D',... > > -- Gnarlie For just this case, if returned_list is your list above, how about?: flat_list = [item[0] for item in returned_list] -- http://mail.python.org/mailman/listinfo/python-list
Re: Development tools and practices for Pythonistas
On Apr 26, 10:39 am, snorble wrote: > I'm not a Pythonista, but I aspire to be. > > My current tools: > > Python, gvim, OS file system > > My current practices: > > When I write a Python app, I have several unorganized scripts in a > directory (usually with several named test1.py, test2.py, etc., from > random ideas I have tested), and maybe a todo.txt file. First, give your files meaningful names. test1.py, test2.py...no wonder you have to spend an hour just figuring out where you left off. Imagine instead if these were modules called DiskAccessUtilities.py and UserPreferencesPanel.py. You should also use highly descriptive names in naming classes and functions, too, with functions being verbs and don't be afraid of long(ish) function names like AddNewCustomerToDatabase() > Then I hack away, adding features in a semi-random order. I'd spend an hour with your TODO list and break it into priority categories, like High, Med, Low, and It Would Be Nice, and then take them strictly in that order. I'd also date the issues so you have a sense for how long something has been waiting to be fixed. > Then I get busy with other things. Maybe one week I spend 20 hours > on > development. The next week, no time on development. A few > weeks later when I have some time, I'm excited to get back to making > progress, only to find that I have to spend 30-60 minutes figuring out > where I left off. I would try to not stop in the middle of creating a new feature or fixing a bug, but try to finish it out before taking a week off. This way, when you come back, you can just tackle something from the High Priority stack and not have to figure out where you were. > The code is usually out of sync with todo.txt. That's just a matter of being disciplined. When I fix a bug, I simply cut the bug from the TODO part to the DONE part of the .txt file, nearly every time. It requires no effort compared to actually fixing the bug, yet it feels satisfying to get that text moved. > would help me to make more consistent progress, and spend less time > bringing myself up to speed after some time off. Are you documenting your code? That can help (I need to get better about that as well). Also, are things broken down into modules that are self-contained? That also can help much. Is the TODO.txt always open while you are working? It should be. Lastly, keeping some kind of notebook or even Post-Its or a bulletin board over your desk with notes as to what's next and where to hunt in your code to get at it should help. Imagine if you take two weeks off, come back, want to work on the project, and you find this note on your bulletin board: "In the CustomersPanel.py module, add support for a wxSearchCtrl (search bar) that searches the Former_Customers table in the main database..." Now you are ready to jump right in! > I really like the idea of having a list of features, and tackling > those features one at a time. I read about people who do this, and > each new features gets a new minor version number. Is that true? I'm under the impression that projects do a bunch of changes (bug fixes, and new features) and then release a new version that has a decent amount of changes. I don't think people want tons of versions of most projects around, but that each release should have an appreciable amount of good changes. > to concepts. Like, "each feature gets its own directory". I guess it depends on your project, but that sounds needlessly complex and way too tough with a VCS. I'd say just don't go there. Once you use a VCS you will probably settle into a better pattern, but things like good naming, documenting, notes, prioritizing features/ bugs, and roadmaps don't magically go away. Software development takes long range thinking and some organizational discipline. Che -- http://mail.python.org/mailman/listinfo/python-list
Re: Development tools and practices for Pythonistas
> I guess it depends on your project, but that sounds needlessly complex > and way too tough with a VCS. I'd say just don't go there. (Whoops, I meant way too tough *without* a VCS, not with) -- http://mail.python.org/mailman/listinfo/python-list
Re: Development tools and practices for Pythonistas
> A lone developer using such a VCS reaps the benefits of this by getting > good merging support. While we're on the topic, when should a lone developer bother to start using a VCS? At what point in the complexity of a project (say a hobby project, but a somewhat seriousish one, around ~5-9k LOC) is the added complexity of bringing a VCS into it worth it? I've been making changes to code and saving changes to the same files, but backing up on Dropbox, which keeps 30 days of previous saves. I've rarely had to resort to undoing code by calling up a previous save. I test each new change as it is made to see if it breaks anything (not automatic testing, though), and I don't collaborate with anyone else as yet. Should I bother to try a VCS? -- http://mail.python.org/mailman/listinfo/python-list
Can't match str/unicode
This is probably very simple but I get confused when it comes to encoding and am generally rusty. (What follows is in Python 2.7; I know.). I'm scraping a Word docx using win32com and am just trying to do some matching rules to find certain paragraphs that, for testing purposes, equal the word 'match', which I know exists as its own "paragraph" in the target document. First, this is at the top of the file: #!/usr/bin/env python # -*- coding: utf-8 -*- Then this is the relevant code: candidate_text = Paragraph.Range.Text.encode('utf-8') print 'This is candidate_text:', candidate_text print type(candidate_text) print type('match') print candidate_text == 'match' if candidate_text == 'match': # do something... And that section produces this: This is candidate_text: match False and, of course, doesn't enter that "do something" loop since apparently candidate_text != 'match'...even though it seems like it does. So what's going on here? Why isn't a string with the content 'match' equal to another string with the content 'match'? I've also tried it with removing that .encode part and the encoding part at the very top, but then the candidate_text is a unicode object that I also can't get to match to anything. What am I doing wrong? How should I approach this? Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't match str/unicode
On Saturday, January 7, 2017 at 6:42:25 PM UTC-5, Chris Angelico wrote: > What happens if you print the repr of each string? Or, if one of them > truly is a literal, just print the repr of the one you got from > win32com. > > ChrisA Yes, that did it. The repr of that one was, in fact: u'match /r' Thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't match str/unicode
On Saturday, January 7, 2017 at 7:59:01 PM UTC-5, Steve D'Aprano wrote: > On Sun, 8 Jan 2017 08:40 am, CM wrote: > > > So what's going on here? Why isn't a string with the content 'match' equal > > to another string with the content 'match'? > > You don't know that the content is 'match'. All you know is that when > printed, it *looks like* 'match'. > > Hint: > > s = 'match ' > print 'match', s # they look the same > print 'match' == s # but they aren't the same > > > Start by printing repr(candidate_text) and see what you really have. Yes, that did it. The repr of that one was, in fact: u'match /r' Thanks, that did it. Do you happen to know why that /r was appended to the unicode object in this case? -- https://mail.python.org/mailman/listinfo/python-list
What is PyOleMissing object? (win32com)
Trying to manipulate z-order for MSOffice with win32com and wasn't sure what argument was needed. Using help on that ZOrder method gives: >>> Help on method ZOrder in module win32com.client.dynamic: ZOrder(self, ZOrderCmd=) method of win32com.client.CDispatch instance So, what does " mean in this case? -- https://mail.python.org/mailman/listinfo/python-list
Re: Can't match str/unicode
On Sunday, January 8, 2017 at 1:17:56 AM UTC-5, Steven D'Aprano wrote: > On Sunday 08 January 2017 15:33, CM wrote: > > > On Saturday, January 7, 2017 at 7:59:01 PM UTC-5, Steve D'Aprano wrote: > [...] > >> Start by printing repr(candidate_text) and see what you really have. > > > > Yes, that did it. The repr of that one was, in fact: > > > > u'match /r' > > Are you sure it is a forward-slash /r rather than backslash \r? No, you're right, it was a backslash \r. Should have pasted it. Good catch. -- https://mail.python.org/mailman/listinfo/python-list
Scraping email to make invoice
I would like to write a Pythons script to automate a tedious process and could use some advice. The source content will be an email that has 5-10 PO (purchase order) numbers and information for freelance work done. The target content will be an invoice. (There will be an email like this every week). Right now, the "recommended" way to go (from the company) from source to target is manually copying and pasting all the tedious details of the work done into the invoice. But this is laborious, error-prone...and just begging for automation. There is no human judgment necessary whatsoever in this. I'm comfortable with "scraping" a text file and have written scripts for this, but could use some pointers on other parts of this operation. 1. INPUT: What's the best way to scrape an email like this? The email is to a Gmail account, and the content shows up in the email as a series of basically 6x7 tables (HTML?), one table per PO number/task. I know if the freelancer were to copy and paste the whole set of tables into a text file and save it as plain text, Python could easily scrape that file, but I'd much prefer to save the user those steps. Is there a relatively easy way to go from the Gmail email to generating the invoice directly? (I know there is, but wasn't sure what is state of the art these days). 2. OUPUT: The invoice will have boilerplate content on top and then an Excel table at bottom that is mostly the same information from the source content. Ideally, so that the invoice looks good, the invoice should be a Word document. For the first pass at this, it looked best by laying out the entire invoice in Excel and then copy and pasting it into a Word doc as an image (since otherwise the columns ran over for some reason). In any case, the goal is to create a single page invoice that looks like a clean, professional looking invoice. 3. UI: I am comfortable with making GUI apps, so could use this as the interface for the (somewhat computer-uncomfortable) user. But the less user actions necessary, the better. The emails always come from the same sender, and always have the same boilerplate language ("Below please find your Purchase Order (PO)"), so I'm envisioning a small GUI window with a single button that says "MAKE NEWEST INVOICE" and the user presses it and it automatically searches the user's email for PO # emails and creates the newest invoice. I'm guessing I could keep a sqlite database or flat file on the computer to just track what is meant by "newest", and then the output would have the date created in the file, so the user can be sure what has been invoiced. I'm hoping I can write this in a couple of days. Any suggestions welcome! Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: PEP 450 Adding a statistics module to Python
On Friday, August 9, 2013 9:10:18 PM UTC-4, Steven D'Aprano wrote: > I am seeking comments on PEP 450, Adding a statistics module to Python's > standard library: I just saw today that this will be included in Python 3.4. Congratulations, Steven, this is a nice addition. -- https://mail.python.org/mailman/listinfo/python-list
Re: Which python framework?
On Monday, January 6, 2014 12:02:31 PM UTC-5, blis...@gmail.com wrote: > I love programming in python but I'm having trouble deciding over a framework > for a single player MUD like game I'm making for fun. Ideally it's a > cross-platform free framework in case I want make it open source later with > good capabilities of customizing the GUI look/style. > > > > Currently I'm using wxpython which is great but I'm reading that if I want > more customization over the look (i.e. a frame being all black and not using > windows 7 blue borders) You can turn off some of the frame style flags and make the frame look a number of different ways, though the point in a frame in wxPython is *native*, and so will be limited in look to what the OS natively draws. (So, in a sense, don't blame wxPython, blame Windows, OS X, or Linux, if you want). You'd have to describe what you mean by "all black" more (I mean, do you want a top border at all? Do you want a gripper? Full screen? Etc), but I suggest you ask on the wxPython list and they can tell you best what is and what is not possible. My guess is that whatever you have in mind that is beyond wxPython's capabilities is going to fall into YAGNI territory (user-experience-wise) anyway. > Keep in mind this is only a text based game so 3D is not needed. Perhaps I > have to forgo my love of python for something else? I highly doubt that. I'm sure whatever you want to do is doable with Python. -- https://mail.python.org/mailman/listinfo/python-list
Re: django question
On Sunday, January 5, 2014 4:50:55 PM UTC-5, Roy Smith wrote: > One of the things we try to do is put as little in the views as > possible. Views should be all about accepting and validating request > parameters, and generating output (be that HTML via templates, or JSON, > or whatever). All the business logic should be kept isolated from the > views. The better (and more disciplined) you are about doing this, the > easier it will be to move your business logic to a different framework. I just started playing with Django and hadn't realized that yet. So, what, you have other modules that you import into Views that you call functions from to do the business logic? Do you just keep a modules folder in the Django project folder I guess? Thanks for the tip(s). > > > That's not to say it will be *easy*, but you can certainly make things > > harder on yourself than they need to be if you don't keep things > > distinct. > > > > Oh, and yes, the django team does a really amazing job on the docs. -- https://mail.python.org/mailman/listinfo/python-list
Re: django question
On Monday, January 6, 2014 8:57:22 PM UTC-5, Roy Smith wrote: > Yes, exactly. There's nothing magic about a django view. It's just a > function which is passed an instance of HttpRequest (and possibly a few > other things, depending on your url mapping), and which is expected to > return an instance of HttpResponse. Within that framework, it can call > any other functions it wants. > > For example, http://legalipsum.com/ is a silly little site I built in > django. Here's the view for the home page: Nice! > Notice how the view knows nothing about generating the actual markov > text. That's in another module, which lives somewhere on my PYTHONPATH. > ALso, the view knows nothing about how the page is laid out; only the > templates know that. If I decided to redo this in tornado or flask, > whatever, I would need to rewrite my view, but there's not much to > rewrite. Most of the logic is in the Markov chainer, and that would > cary over to the new implementation unchanged. > > BTW, my suggestion to keep business logic and presentation code distinct > isn't unique to django, it's a good idea in pretty much all systems. Thanks for these points, helpful to see in practice. I'm trying to be more mindful of good coding practices, and this will be helpful as I continue to learn Django and making web applications generally. -- https://mail.python.org/mailman/listinfo/python-list
how to avoid spaghetti in Python?
I've been learning and using Python for a number of years now but never really go particularly disciplined about all good coding practices. I've definitely learned *some*, but I'm hoping this year to take a good step up in terms of refactoring, maintainability, and mostly just "de-spaghettizing" my approach to writing Python programs. But I could use some pointers. Of course, many pointers will be general programming advice that is common to all languages, and I get that, but I also think that it's possible certain bits of advice are particularly relevant to Python coders, and so I ask here. (Also because I know there are some great community people here who I'd enjoy getting their take on this). A few specific questions in this area... 1) One of my main "spaghetti problems" is something I don't know what to ever call. Basically it is that I sometimes have a "chain" of functions or objects that get called in some order and these functions may live in different modules and the flow of information may jump around quite a bit, sometimes through 4-5 different parts of the code, and along the way variables get modified (and those variables might be child objects of the whole class, or they may just be objects that exist only within functions' namespaces, or both). This is hard to debug and maintain. What would people recommend to manage this? A system of notes? A way to simplify the flow? And what is this problem called (if something other than just spaghetti code) so I can Google more about it? 2) A related question: Often I find there are two ways to update the value of an object, and I don't know what's best in which circumstances... To begin to explain, let's say the code is within a class that represents a Frame object in a GUI, like wxPython. Now let's say ALL the code is within this wxFrame class object. So, any object that is named with "self." prepended, like self.panel, or self.current_customer, or self.current_date, will be a child object of that frame class, and therefore is sort of "global" to the whole frame's namespace and can therefore be accessed from within any function in the class. So let's say I have a function called self.GetCurrentCustomer(). To actually get the name of the current customer into RAM, it goes into the database and uses some rule to get the current customer. NOW, the question is, which of these should I do? This: def GetCurrentCustomer(self): self.current_customer = #do some database stuff here Or this: def GetCurrentCustomer(self): current_customer = #do some database stuff here return current_customer And what difference does it make? In the first case, I am just updating the "global" object of the current_customer, so that any function can then use it. In the second case, I am only returning the current_customer to whatever function(s) call this GetCurrentCustomer() function. My hunch is the first way leads to spaghetti problems. But I want to understand what the best practices are in this regard. I have found in some cases the first method seemed handy, but I'm not sure what the best way of thinking about this is. 3) Generally, what are other tools or approaches you would use to organize well a good-sized project so to avoid fighting yourself later when you don't understand your own code and the flow of information through it? By good sized, say about 20,000 lines of Python code, or something like that. This is the sort of question that would be rejected on Stack Overflow, so I hope you can excuse my fishing for insight in a somewhat open/vague way. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Statement evals as False in my IDE and True elsewhere
This is puzzling. (Using Python 2.5, WinXP, Boa Constructor 0.6.1 definitely running the code through Python 2.5) If I run these lines in my program, through my IDE (Boa Constructor), fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] fake_result = not all(i == '[omitted]' for i in fake_data) print 'This is fake result: ', fake_result I get this result: >>> This is fake result: False BUT, if I run those *exact same lines* (copied and pasted) in the Python 2.5 shell within Boa Constructor, or with IDLE with Python 2.5, I get: >>> This is fake result: True ...which is what it seems like it should evaluate to, right? What the heck is going on? How is this even possible? There is nothing that I know of in my code to cause this change, but perhaps there is. Otherwise I am at a total loss. Thanks, Che M -- https://mail.python.org/mailman/listinfo/python-list
Re: Statement evals as False in my IDE and True elsewhere
On Thursday, January 30, 2014 5:14:57 PM UTC-5, Peter Otten wrote: > Hint: > > >>> def demo(): > ... fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > ... fake_result = not all(i == '[omitted]' for i in fake_data) > ... print 'This is fake result: ', fake_result > > >>> demo() > This is fake result: True > > >>> from numpy import all > >>> demo() > This is fake result: False That's brilliant, thanks! Now I'm just a bit unsure of what to do about it. First, I don't actually have the line "from numpy import all" in that module's code, although I have imports of numpy; I think it is getting brought in through Matplotlib's pylab module, which I do import in that module. In any case, what's the most Pythonic way to deal with this? My first thought was to create the old all function and rename it so there would be no conflict: (both of what follows taken from answers here: http://stackoverflow.com/questions/18774388/re-import-aliased-shadowed-python-built-in-methods) builtin_all = __builtins__.all but I got the error: AttributeError: 'dict' object has no attribute 'all' So I wound up doing this: from __builtin__ import * which fixed the problem...but seems less than optimal, because what if I wanted to have numpy's all still in play? Again, thanks for restoring my faith in causality, Che M -- https://mail.python.org/mailman/listinfo/python-list
Re: Statement evals as False in my IDE and True elsewhere
> Try using square brackets notation instead. Apparently your > __builtins__ is a dictionary, not a module, though I don't know why > (probably something to do with numpy, which I've never actually used). > > But try this: > builtin_all = __builtins__["all"] > > It might work. Yes, it does. Thanks! Che M -- https://mail.python.org/mailman/listinfo/python-list
Re: Statement evals as False in my IDE and True elsewhere
On Thursday, January 30, 2014 5:25:31 PM UTC-5, Chris Angelico wrote: > On Fri, Jan 31, 2014 at 9:04 AM, CM wrote: > > > fake_data = ['n/a', 'n/a', 'n/a', 'n/a', '[omitted]', '12'] > > > fake_result = not all(i == '[omitted]' for i in fake_data) > > > print 'This is fake result: ', fake_result > > > > Trying to get my head around this. You want to see if all the values > in fake_data are '[omitted]' or not? That is to say, if there's > anything that isn't '[omitted]'? Not sure that that's a normal thing > to be asking, but that's what your code appears to do. That's what I want, yes. It probably sure isn't a normal thing to be asking, and I wouldn't be surprised if I am approaching it the wrong way. Essentially, if ALL the items in that list are '[omitted]', I must not process the list, but if even one of them is something other than '[omitted]', I need to process it. If there is a more Pythonic / better way to approach that, I'd like to know it. > In theory, that should do the exact same thing as your code (returning > True if there's anything in fake_data that is not '[omitted]'). Yes, as you saw and as Peter showed, that the builtin all was shadowed by numpy's all. I wouldn't have thought of that, but it makes sense now. These sorts of shadowing problems are so rare for me that I never think about that possibility. -- https://mail.python.org/mailman/listinfo/python-list
Re: What are the kinds of software that are not advisable to be developed using Python?
On Saturday, February 8, 2014 10:43:47 PM UTC-5, Steven D'Aprano wrote: > PyPy can generate code which is comparable to compiled C in speed. > Perhaps you mean, "if execution speed is the most important thing, using > a naive Python interpreter may not be fast enough". Given that the OP seems to be new enough to Python to not know what it is not as good for, my guess is that PyPy may not yet be "ready enough" to serve some/most of his needs. For example, if he wanted to write a GUI app, AFAIK he is, for now, limited to Tkinter and a constrained section of wxPython, and wxPython is dicey. I tend to see things through a desktop GUI application lens, so maybe this is just my bias. And I hope I am wrong. I am in no way trying to slight the PyPy efforts. Maybe he could somehow write the GUI part with CPython and the speed-critical parts with PyPy but I don't know if that is possible. (Is it?) -- https://mail.python.org/mailman/listinfo/python-list
Re: Hello World
On Saturday, December 20, 2014 7:57:19 AM UTC-5, Steven D'Aprano wrote: > Taken from Ben Kurtovic's blog: > > http://benkurtovic.com/2014/06/01/obfuscating-hello-world.html > > > > (lambda _, __, ___, , _, __, ___, : > getattr( > __import__(True.__class__.__name__[_] + [].__class__.__name__[__]), > ().__class__.__eq__.__class__.__name__[:__] + > ().__iter__().__class__.__name__[_:] > )( > _, (lambda _, __, ___: _(_, __, ___))( > lambda _, __, ___: > chr(___ % __) + _(_, __, ___ // __) if ___ else > (lambda: _).func_code.co_lnotab, > _ << , > (((_ << ) + _) << ((___ << _) - ___)) + (___ << > __) > - _) << ___) + _) << ((_ << ) + (_ << _))) + (((___ << > __) - _) << (_ << ___) + _)) << ___) + (_ << _))) + (((___ > << ___) + _) << ((_ << __) + _)) + (((___ << ) - _) << > ((___ << ___))) + (((_ << ) - _) << ___ << __) + _) << > __) - _)) - (___ << ___ << __) - _) << __) + _)) + > (___ > << (_ << ___) + _)) << __))) - ((_ << ___) + _)) << __) + > _) << ___ << __) + _) << _))) + (((___ << __) - _) << > (_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_ << > _))) + (_ << __) + (_ << ___) > ) > ) > )( > *(lambda _, __, ___: _(_, __, ___))( > (lambda _, __, ___: > [__(___[(lambda: _).func_code.co_nlocals])] + > _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else [] > ), > lambda _: _.func_code.co_argcount, > ( > lambda _: _, > lambda _, __: _, > lambda _, __, ___: _, > lambda _, __, ___, : _, > lambda _, __, ___, , _: _, > lambda _, __, ___, , _, __: _, > lambda _, __, ___, , _, __, ___: _, > lambda _, __, ___, , _, __, ___, : _ > ) > ) > ) > > > > I am in total awe. > > > > > -- > Steven I ran it in IDLE with Python 2.7.8 and got: Traceback (most recent call last): File "C:/Python27/helloworld.py", line 39, in lambda _, __, ___, , _, __, ___, : _ File "C:/Python27/helloworld.py", line 21, in _))) + (_ << __) + (_ << ___) OSError: [Errno 9] Bad file descriptor -- https://mail.python.org/mailman/listinfo/python-list
Re: Hello World
On Sunday, December 21, 2014 1:45:02 AM UTC-5, Chris Angelico wrote: > On Sun, Dec 21, 2014 at 5:31 PM, Terry Reedy wrote: > > Just to be clear, writing to sys.stdout works fine in Idle. > import sys; sys.stdout.write('hello ') > > hello #2.7 > > > > In 3.4, the number of chars? bytes? is returned and written also. > > > > Whether you mean something different by 'stdout' or not, I am not sure. The > > error is from writing to a non-existent file descriptor. > > That's because sys.stdout is replaced. But stdout itself, file > descriptor 1, is not available: > > >>> os.fdopen(1,"w").write("Hello, world\n") > Traceback (most recent call last): > File "", line 1, in > os.fdopen(1,"w").write("Hello, world\n") > OSError: [Errno 9] Bad file descriptor > > This works fine in command-line Python, just not in IDLE. It's not > Windows vs Unix, it's Idle vs terminal. > > ChrisA Yes, just tested it on the same machine in the terminal and it prints: Hello, world! 13 Not sure what the 13 is all about. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hello World
On Sunday, December 21, 2014 2:44:50 AM UTC-5, CM wrote: > On Sunday, December 21, 2014 1:45:02 AM UTC-5, Chris Angelico wrote: > > On Sun, Dec 21, 2014 at 5:31 PM, Terry Reedy wrote: > > > Just to be clear, writing to sys.stdout works fine in Idle. > > >>>> import sys; sys.stdout.write('hello ') > > > hello #2.7 > > > > > > In 3.4, the number of chars? bytes? is returned and written also. > > > > > > Whether you mean something different by 'stdout' or not, I am not sure. > > > The > > > error is from writing to a non-existent file descriptor. > > > > That's because sys.stdout is replaced. But stdout itself, file > > descriptor 1, is not available: > > > > >>> os.fdopen(1,"w").write("Hello, world\n") > > Traceback (most recent call last): > > File "", line 1, in > > os.fdopen(1,"w").write("Hello, world\n") > > OSError: [Errno 9] Bad file descriptor > > > > This works fine in command-line Python, just not in IDLE. It's not > > Windows vs Unix, it's Idle vs terminal. > > > > ChrisA > > Yes, just tested it on the same machine in the terminal and it prints: > > Hello, world! > 13 Actually, there is no comma after Hello. -- https://mail.python.org/mailman/listinfo/python-list
Re: python
On Monday, February 24, 2014 3:31:11 AM UTC-5, Karthik Reddy wrote: > I worked as a weblogic administrator and now i am changing to development and > i am very much interested in python . please suggest me what are the > things i need to learn more rather than python to get an I.T job. I came to > know about Django but i am in a confusion please help me . I recommend you look at job advertisements in areas you'd like to work (both areas of the world and areas within IT) and see what they seem to want. Also, consider more informative subject lines to future posts. :D -- https://mail.python.org/mailman/listinfo/python-list
Re: Examples of modern GUI python programms
On Sunday, March 30, 2014 7:16:07 PM UTC-4, D. Xenakis wrote: > Id like to ask.. do you know any modern looking GUI examples of windows > software written in python? Something like this maybe: > http://techreport.com/r.x/asus-x79deluxe/software-oc.jpg (or hopefully > something like this android look: > http://chromloop.com/wp-content/uploads/2013/07/Skype-4.0-Android-screenshot.jpg). > > What i need is to develop an android looking program (entirelly in python) > for windows, but dunno if this is possible (most propably is), and which tool > between those would help me most: tkinter - wxpython - pyqt - pygtk . > I just know wxPython, so I'll discuss that. I'm pretty sure you could achieve either of those with wxPython, but it isn't really set up to look like that ("modern looking" in your words) by default. wxPython is set up to look *native* for each platform it runs on. On WinXP, for example, toolbars and buttons generally have "system gray" backgrounds, but some widgets can be changed, some can't. There are custom widgets that are more flexible though are not native. You could cleverly simulate these sorts of looks with creative use of library-included custom widgets, a few of your own custom widgets possibly, black backgrounds, drawing on a DC directly to the screen, image backgrounds, and a few other things (basically creating your own "skin"). The harder one is probably the first one you linked--the other, Skype on Android, is mostly just big fluffy images. Probably the first 90% of that is pretty easy and the last 10% might be somewhat difficult, but not too bad. It would be fun to try. -- https://mail.python.org/mailman/listinfo/python-list
Re: python obfuscate
On Friday, April 11, 2014 12:13:47 PM UTC-4, Sturla Molden wrote: > Mark H Harris wrote: > > > Obfuscation (hiding) of your source is *bad*, usually done for one > > of the following reasons: > > > 1) Boss is paranoid and fears loss of revenues due to intellectual > > property theft. > > 2) Boss is ignorant of reverse engineering strategies available to > > folks who want to get to the heart of the matter. > > 3) Boss and|or coders are embarrassed for clients (or other coders) > > to see their art, or lack thereof. Sometimes this is also wanting to > > hide the fact that the product really isn't "worth" the price being > > charged for it?!? > > You can also add fear of patent trolls to this list. Particularly if you > are in a startup and cannot afford a long battle in court. You can quickly > go bankrupt on attorney fees. > > Sturla You're saying that fear of patent trolls is yet another bad reason to obfuscate your code? But then it almost sounds like you think it is a justifiable reason. So I don't think I understand your point. Whether a patent troll has your original code or not has no bearing on the patent infringement. -- https://mail.python.org/mailman/listinfo/python-list
Re: python obfuscate
On Saturday, April 12, 2014 8:07:57 AM UTC-4, Sturla Molden wrote: > CM wrote: > > > > > You're saying that fear of patent trolls is yet another bad reason to > > > obfuscate your code? But then it almost sounds like you think it is a > > > justifiable reason. So I don't think I understand your point. Whether a > > > patent troll has your original code or not has no bearing on the patent > > > infringement. > > > > There might be no infringment. Patent trolls usually possess invalid > patents, as they constitute no real invention. These are usually not > engineers who have invented something, but lawyers who have been granted > patent on vague thoughts for the purpose of "selling protection". The US > patent office has allowed this to happen, by believing that any invalid > patent can be challenged in court, so their review process is close to > non-existent. If patent trolls have your code they are in a better position > to blackmail. They can use your code to generate bogus "legal documents" in > the thousands, and thereby turn up your legal expenses. > > Sturla Ahh, I see. I suppose such an entity might try that. But I would hope it would not result in additional legal expenses, in that anyone with the smallest amount of legal understanding of patents knows that in doesn't matter in what way the invention is brought about in specific code, just that the *resulting invention* is similar enough to the claims of the patent. That is, the invention could be written in Python, or C, or COMAL, in whatever spaghetti the author wants, and none of that is pertinent to the issue of patent infringement (whereas it might very well be to the issue of copyright infringement). I would hope the defense lawyer(s) and judge struck that from the proceedings, but I am probably hoping for too rational an outcome. -- https://mail.python.org/mailman/listinfo/python-list
using a new computer and bringing needed libraries to it
If I want to switch my work from one computer to a new one, and I have lots of various libraries installed on the original computer, what's the best way to switch that all to the new computer? I'm hoping there is some simple way like just copying the Python/Lib/site-packages folder, but I'm also guessing this isn't sufficient. I was hoping I wouldn't have to just one-by-one install all of those libraries again on the newer computer. I probably want to develop on BOTH these computers for the time being, too. One is at home and one is at a "remote site"/secret lair. And then I'll be doing it again when I buy a newer computer at some point. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to package embedded python?
On Wednesday, July 31, 2013 11:47:19 AM UTC-4, David M. Cotter wrote: > okay, well that might turn out to be useful, except i don't quite know how to > use it, and there are no "from scratch" instructions. > > > > i managed to download "py2exe-0.6.9.zip" and unzip it, but how does one > "install" this package? (yes, still a newb at that) What's your OS? For Windows there is an exe that installs it. Did you download that? Or you could, in the command line, do: cd c:\some_folder\the_py2exe_folder python setup.py install (The Python site has a huge page of details on that route. http://docs.python.org/2/install/) Or you could probably get away with just moving the py2exe folder to Python27\site-packages (or whatever Python you have) Or you could first install pip (recommended!) and then just: pip install py2exe (http://dubroy.com/blog/so-you-want-to-install-a-python-package) > then, once installed, how do i say "include the entire world" instead of just > "mymodule" ? cuz the point of embedding python on my app is that the > end-user can run any script at all, not just one module. I don't know. As I understand it, py2exe will pull whatever is needed in Python to run your module. If your module requires all of Python, I guess that will work. I think regardless of the module, even if it is a "Hello, World" program, py2exe has to include the Python interpreter. Unfortunately, and surprisingly, the py2exe site is still down. Odd. If it returns, that should help. There is also a py2exe users mailing list that you could find by Googling for it. In terms of -- http://mail.python.org/mailman/listinfo/python-list
Does Python 'enable' poke and hope programming?
(My subject line is meant to be tongue and cheek inflammatory) I've been thinking about why programming for me often feels like ice skating uphill. I think part of the problem, maybe the biggest part, is what now strikes me as a Very Bad Habit, which is "poke and hope" (trial and error) programming (of several names this page provided, I kind of like that one): http://en.wikipedia.org/wiki/Programming_by_permutation It seems that if I can make a change to the code and then immediately test it by running the Python interpreter and finding out, in a few seconds, if it worked, I am going to be *much* more likely to use this trial-and-error approach than if I had to use a compiled language, since compiling takes so long. E.g. "Oh, that doesn't work? Maybe if I add this...no. OK, what about if I increment that? No...OK, wait, maybe this...AH! That worked." (obviously it is not quite that uninformed all the time). Instead, with a compiled language, because of the pain of having to wait for the newest version to compile, one would be encouraged to get the mechanism of how something works *clear* and robustly represented in one's mind (or on scrap paper/notes document) prior to testing through compiling and running. Basically this amounts to: with an interpreted language (so of course this is not really just about Python--I just think in terms of Python), it's easier to be mentally lazy. But, ironically, being lazy winds up creating *way* more work ultimately, since one winds up programming in this terribly inefficient way, and progress proceeds at an, at times, evolutionary (slow!) pace. And of course I am not really blaming it on Python or any interpreted language; I am blaming it fully on my own lame habits and attitude. I'm sick of this in my own work, and want to avoid this trap as much as I can from now on. Thoughts? -- http://mail.python.org/mailman/listinfo/python-list
Re: Minions are Python Powered!
On Saturday, August 3, 2013 6:16:09 AM UTC-4, Borja Morales wrote: > Everytime I watched the minions from Despicable Me something was hitting my > unconscious mind. Finally I figured it out... Minions are Python Powered! > > > > I couldn't resist to make an image :) I haven't even seen either of those movies (though have seen those characters in their advertising) and despite that, upon seeing your image, was unable to do anything but smile really hard. Killer job! Brightened my day. -- http://mail.python.org/mailman/listinfo/python-list
Re: Does Python 'enable' poke and hope programming?
Wayne, thanks for your thoughts. I am all for the scientific method--in understanding the natural world, which doesn't come with a manual. But Python is an artificial system designed by mere people (as well as Guido), and, as such, does have a manual. Ideally, there should be very little need for experimentation and "hypotheses". That said, yes, when learning the language a little experimentation along the way is fine, and error messages Python throws back to you or unexpected results can and should be a form of real time instruction. But what I meant is that if one is writing a program, there is a way to **know**--without experimentation--what a particular set of code is going to do. This is often cognitively demanding work, but it is possible. And my point is that it is, in the end, far more efficient to be disciplined and do that work rather than try to take shortcuts by simply trying a few things until one of them works. In sum: experimentation is for when you don't know what you're doing and there is no manual; but, after the initial learning time, you *should* know what you're doing and you should have the manual handy, and therefore the time for experimentation is largely over. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.
ave tried sql.learncodethehardway but it isn't complete yet. I tired looking on stackoverflow's sql tag also but nothing much there. Can someone suggest me better resources for learning sql/sqlite3? There are a lot of nice small tutorials out there found by Googling. One resource that you might not find easily, though, and that helped me a while back and I liked is: http://sqlzoo.net/howto/source/u.cgi/tip241028/sqlite The thing about that page is, if you go to the main site, sqlzoo.net, it seems that SQLite is no longer one of the options. But if you go through the link I gave above, you can find the older site that does treat SQLite. To find the other command examples, I guess use Google like so: sqlite zoo INSERT sqlite zoo UPDATE and others. I don't know why SQLite was dropped from the Zoo's roster; I really liked that format. -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP 450 Adding a statistics module to Python
On Friday, August 9, 2013 9:10:18 PM UTC-4, Steven D'Aprano wrote: > I am seeking comments on PEP 450, Adding a statistics module to Python's > standard library: I think it's a very good idea. Good PEP points, too. I hope it happens. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python GUI?
> Tkinter -- Simple to use, but limited > > PyQT -- You have a GUI designer, so I'm not going to count that As others have pointed out, that's nonsensical. If you don't like the GUI designer, just don't use it. > wxPython -- Very nice, very professional, approved by Python creator, but > alas hard to get started with Why is it hard to get started with? Download the installer, install, and: import wx app = wx.App(False) frame = wx.Frame(None, -1, "Hello World") frame.Show(True) app.MainLoop() -- https://mail.python.org/mailman/listinfo/python-list
Re: What minimum should a person know before saying "I know Python"
On Friday, September 20, 2013 5:58:00 AM UTC-4, Aseem Bansal wrote: > I started Python 4 months ago. Largely self-study with use of Python > documentation, stackoverflow and google. I was thinking what is the minimum > that I must know before I can say that I know Python? Seems to me a fuzzy boundary between "Not knowing" and "knowing". I prefer thinking in terms of a spectrum, from 0-10 or pick your scale. 0 - Person who has never heard of Python or has but that's the extent of it. 1 - Beginning installer / Hello Worlder! / clumsy dabbler / what is self? 2 - Underway in earnest, not yet making anything all that much 3 - Making stuff, but clunky 4 - Making stuff pretty well, but looking up 2/3rds of it on SE or equivalent. 5 - Making stuff pretty well, but looking up 1/3rds of it on SE or equivalent. 6 - Making stuff pretty well, occasionally consulting the Python.org docs 7 - Tim Chase's list level 8 - The guy who hired the guy at 7 (assuming he is even further on) 9 - Gurus of this list 10 - Uber-gurus 10^6 - Guido I feel like I'm about 5 maybe, with some embarrassing chinks in the armor? Draw the "know line" boundary wherever you want, but I'd think you'd probably want to be above 4. I know I'd feel more comfortable saying I know Python if I were at 7 (and thanks, Tim Chase; I saved that list a while back in my files to consult someday, maybe). That said, I've written 20k+ loc of (mostly?) working code in Python and have done some contracting work at my humble 5, so there's that. -- https://mail.python.org/mailman/listinfo/python-list
State of speeding up Python for full applications
I occasionally hear about performance improvements for Python by various projects like psyco (now old), ShedSkin, Cython, PyPy, Nuitka, Numba, and probably many others. The benchmarks are out there, and they do make a difference, and sometimes a difference on par with C, from what I've heard. What I have never quite been able to get is the degree to which one can currently use these approaches to speed up a Python application that uses 3rd party libraries...and that the approaches will "just work" without the developer having to know C or really do a lot of difficult under-the-hood sort of work. For examples, and considering an application written for Python 2.7, say, and using a GUI toolkit, and a handful of 3rd party libraries: - Can you realistically package up the PyPy interpreter and have the app run faster with PyPy? And can the application be released as a single file executable if you use PyPy? - Can you compile it with Nuitka to C? I've had the (perhaps overly pessimistic) sense that you still *can't* do these things, because these projects only work on pure Python, or if they do work with other libraries, it's always described with major caveats that "I wouldn't try this in production" or "this is just a test" sort of thing, such as PyPy and wxPython. I'd love to know what's possible, since getting some even modest performance gains would probably make apps feels snappier in some cases, and yet I am not up for the job of the traditional advice about "re-writing those parts in C". Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: State of speeding up Python for full applications
I'm reposting my question with, I hope, better formatting: I occasionally hear about performance improvements for Python by various projects like psyco (now old), ShedSkin, Cython, PyPy, Nuitka, Numba, and probably many others. The benchmarks are out there, and they do make a difference, and sometimes a difference on par with C, from what I've heard. What I have never quite been able to get is the degree to which one can currently use these approaches to speed up a Python application that uses 3rd party libraries...and that the approaches will "just work" without the developer having to know C or really do a lot of difficult under-the- hood sort of work. For examples, and considering an application written for Python 2.7, say, and using a GUI toolkit, and a handful of 3rd party libraries: - Can you realistically package up the PyPy interpreter and have the app run faster with PyPy? And can the application be released as a single file executable if you use PyPy? - Can you compile it with Nuitka to C? I've had the (perhaps overly pessimistic) sense that you still *can't* do these things, because these projects only work on pure Python, or if they do work with other libraries, it's always described with major caveats that "I wouldn't try this in production" or "this is just a test" sort of thing, such as PyPy and wxPython. I'd love to know what's possible, since getting some even modest performance gains would probably make apps feels snappier in some cases, and yet I am not up for the job of the traditional advice about "re-writing those parts in C". Thanks. -- https://mail.python.org/mailman/listinfo/python-list
print statements and profiling a function slowed performance
Huh. I learned two new Python facts this week: 1. print statements were slowing down my code enough to really notice a particular transition. It went from about 2-3 seconds to a bit under 1 second. What at first seemed unresponsive now seems almost snappy. The only difference was removing a lot of print statements I had used for debugging (Python 2.5, on a single core 1.97 Ghz machine). 2. Merely having a cPython decorator for profiling a function significantly slowed down performance...again, from a about 2 seconds to just under a second (~1 second doesn't seem much but these sorts of delays do affect user experience). There is something ironic or Heisenbergian about that. -- https://mail.python.org/mailman/listinfo/python-list
Re: print statements and profiling a function slowed performance
> Seems like over the years good old fashioned > debugging skills have been lost. In the earliest > days of IDEs (Turbo BASIC and QuickBASIC) I > regularly would employ debuggers with break > points, watches, and step through my code. I do also use a debugger, but lazily use print statements, too. When I use the debugger (in my case, in the IDE I use, Boa Constructor), I do use break points and step through my code, but I have never used watches. How do you use them? > Yes, it stands to reason that profiling code > is going to introduce a runtime cost. How else > would we expect profiling to work? I think I was hoping for magic. :D > What I do find Heisenbergian are bugs that show > up when debugging and profiling stuff are removed, > but completely gone when present. IE profiling and > debugging slow it down enough that often subtle race > conditions are masked. Would never have occurred to me. That *is* odd! -- https://mail.python.org/mailman/listinfo/python-list
Re: print statements and profiling a function slowed performance
On Thursday, June 26, 2014 3:27:48 PM UTC-4, Mark Lawrence wrote: > 3. use the logging module :) I've just never got around to it, but I guess I should. Thanks for the nudge. -- https://mail.python.org/mailman/listinfo/python-list
What can Nuitka do?
(Trying again, simpler and cleaner post) Can I use Nuitka to transform a wxPython GUI application in Python that uses several 3rd party modules into a small and faster compiled-to-C executable? -- https://mail.python.org/mailman/listinfo/python-list
What can PyPy do?
Can I use PyPy to transform a wxPython GUI application in Python that uses several 3rd party modules into a faster Python application that can be distributed as an exe? -- https://mail.python.org/mailman/listinfo/python-list
Re: What can Nuitka do?
On Friday, June 27, 2014 7:44:39 PM UTC-4, Paul Sokolovsky wrote: > Yes, you can. So, please try that, and report > how that went. We're eager to know how that would > go very much. But unlike you, we don't have need > to transform wxPython GUI application in Python into > an executable. So, you are in the best position to > answer your question. I downloaded and installed Nuitka 0.5.2 for Windows, but it seems like the entirety of the instructions for what I want to do, as shown on the Docs web page, is this: nuitka --recurse-all program.py I would need more help than that to try this. I've never even used MinGW, for example. -- https://mail.python.org/mailman/listinfo/python-list
Re: What can Nuitka do?
On Friday, June 27, 2014 11:09:11 PM UTC-4, Steven D'Aprano wrote: > Having said that, I think that the OP's question > is probably misguided. Thanks, Steven, for the input. It very well might be. I'll give a little more information. > He or she gives the impression of expecting PyPy > or Nuitka to be a magic button that will speed up > the user experience, like the Turbo button on > old PCs. (Remember them?) It's not likely to be > that easy. I'm sure it does give just that impression. I'll admit that if it *did* do something like that, I'd be pleased, of course. But I expected it not to work so well as that, or perhaps not work at all. Really, I asked more out of curiosity, since these projects keep staying out there but I rarely read about people actually using them. They seem more like proof of principle intellectual work, but I really know not of what I speak, and so was trying to get more understanding. I also thought it may be helpful in creating a standalone executable (instead of using the various ways to do that with Python, which I am familiar with and have done successfully), and wanted to see if there were any advantages to that (such as a smaller file size). > wxPython is a wrapper to a C GUI library, all the > work is done in C, not Python, There are some pure Python widgets in wxPython, such as many or perhaps all within the AGW subdirectory, which are some really nice contributions by Andrea Gavana. And I believe it's a C++ library, not C. > so moving to PyPy or Nuitka won't speed it up. It may not; I really wasn't sure and thought I'd give it a try and see what happened (if it wasn't a major undertaking to give it a try). > Additionally, in most GUI apps (although not all), > the main bottleneck is usually not the programming > language but the user. GUI apps tend to spend > 95% of their time idling, waiting for the user. Its > been a *long* time since the GUI framework itself > has lagged behind the user's input, except Although that is true, I have found that I have managed to get wxPython apps to feel laggy in certain parts, particularly on not-very-fast computers. I can see this in starting up the program and some other areas such as repainting damaged windows rapidly. It's not a huge effect, but it does influence the "look and feel" and I care about it. > except in cases of memory exhaustion. Maybe this is a key issue on one of the older laptops I was testing on. The thing is, though, there are still a lot of SLOW computers out there in userland, sadly, and doing what one can to mitigate the laggy UX by speeding up the program seems like a virtuous goal. > his or her application, the first thing to do is > to identify what parts of it are slow, identify > why they're slow, and concentrate on those parts. That's underway, and helping. I just idly thought about the state of compilers and JIT and such and wondered. -- https://mail.python.org/mailman/listinfo/python-list
Re: What can Nuitka do?
> I'm not a Windows user, so I can't give detailed > step-by-step "mouse over this menu, click this > button" instructions, but you need to open a > command line terminal. (command.com or cmd.exe, I'm not *quite* that at sea! :D Close, but I am used to using the command line in Windows. > Now type > nuitka --recurse-all something_or_other.py > and hit Enter. What happens? I did that and the message is: 'nuitka' is not recognized as an internal or external command, operable program or batch file. which makes sense because some kind of file called nuitka is not in my path. What I wasn't sure of is how to add it, because I looked in the nuitka folder in Python27/Lib/site-packages and there was no file called nuitka.py or nuitka.exe within that folder, and there were a lot of subfolders but I just didn't know what I should do. I have used Linux but not in a while and I can't recall how installing it is different in terms of the OS knowing what "nuitka" means in the command line. (I installed nuitka for Windows via an installer). Even once I do this, nuitka won't work until I get MingGW on here, too, but one step at a time. I'd like to get it to at least fail at that point first. But Rustom Mody's comment suggests this may turn out to be more work than I am willing to do right now...? > > > > (Don't be discouraged if there are a bunch of errors.) > > > > > > > > -- > > Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: What can Nuitka do?
On Saturday, June 28, 2014 12:23:03 AM UTC-4, Stefan Behnel wrote: > There should be a folder Python27/Scripts that > contains the executable programs that Python packages > install. Thank you, yes, it's there. But there are two files: nuitka (I don't see an extension and don't know the file type) and nuitka.bat. I added C:/Python27/Scripts/nuitka to the Windows path but it still doesn't recognize the name. -- https://mail.python.org/mailman/listinfo/python-list
Re: What can Nuitka do?
> Just add Scripts to path (not Scripts/nuitka), > and it should run nuitka.bat. I would guess that > the one without an extension is a Unix shell script > of some sort; have a look at it, see if it's a text > file that begins "#!/bin/sh" or similar. Most likely > the file sizes of nuitka and nuitka.bat will be > similar - of the order of hundreds of bytes, even, > as they're probably just invoking Python. I tried that, and it still gives me the same message. This is the Windows path, right? In it, among other paths, I have: C:\Python27\Scripts\ (or without the last "\" also, though it should not matter, right?) The nuitka file starts with #!C:\Python27_32\python.exe and is a Python script. It says in a docstring, This is the main program of Nuitka, it checks the options and then translates one or more modules to a C++ source code using Python C/API in a build directory compiles it to either an executable or an extension module that can contain other modules. """ I'm confused as to why it's not just a .py file. The nuitka.bat, aside from some remarks, is this: @echo off setlocal "%~dp0..\python" "%~dp0nuitka" %* endlocal -- https://mail.python.org/mailman/listinfo/python-list
Re: .Net Like Gui Builder for Python?
On Friday, July 25, 2014 10:55:44 AM UTC-4, Orochi wrote: > Hi, > > This Question may sound lame ,but I am searching for .Net Like Gui Builder > for Python. > > I tried PyQt Designer' and 'Glade', No doubt its great but it created only > interface. > > I have to code all the things in separate file. > > what I was searching for is Visual Studio .Net like Gui builder where you > > drag and drop widgets and just double click on the widget to edit code of > that widget.All other formalities of creating a function and class for the > main window and widget(e.g Button) is already done. > > > > So,Is there any Gui App builder like Visual Studio or having features like > Visual Studio for Python. There is Boa Constructor, targeting wxPython, but it hasn't been updated in ~7 years; it can run with Python 2.6. It's a GUI builder + IDE, and can do quite a bit (it's basically Delphi for Python). Really impressive. I wish it were able to work with 2.7 but there is no community helping it along at this point, and most seem to have let it go the way of the Palm Pilot. -- https://mail.python.org/mailman/listinfo/python-list
Re: Exploring Python for next desktop GUI Project
On Thursday, July 24, 2014 11:57:22 AM UTC-4, Noble Bell wrote: > I am exploring the idea of creating my next desktop GUI project in Python and > would like a little advice from you folks about a couple of requirements. > > > > My requirements will be: > > 1. Needs to be portable across platforms with native LAF (Windows,Linux,OSX) wxPython. > 2. Python 2 or 3? Which will serve me better in the future? Long term (7 years), 3. Middle-term, either, though you may need a library that is not yet ported to 3. wxPython Phoenix is available in a not-yet-completely-done way and people are reporting using it to make function GUIs. It is not done yet, though, and some/all of the wx.lib widgets are not available in it. If I were you I'd go with Python 2.7 and wxPython 2.9.x, but other options are reasonable too. > > > Thanks in advance. > > Noble -- https://mail.python.org/mailman/listinfo/python-list
Parse bug text file
I have a big text file of bugs that I want to use Python to parse such that the bugs can be neatly filed into a database. I can bumble toward a solution with looping but feel this is a classic example of reinventing the wheel, and yet I'm finding it hard to Google for. Basically the file is structured like this (silly examples, of course), with each of these three lets call a "bug block": - BUG 2.13.14 When you wear a purple hat, the application locks up. If you sing the theme to "The Love Boat", the application becomes available again. - ISSUE 2.13.14 During thunderstorms, the application runs backwards. - BUG/OPTIMIZE 11.12.12: Sometimes the application is really slow. That's too bad. Generally, every bug block starts with a "-" as the first character, then some words in all caps, a date in that format, and then the descriptive text. There is always a blank line in between bug blocks, but sometimes there may be a blank line within the bug description as well. The goal is to grab each bug block, clean up that text (there are CRs in it, etc., but I can do that), and dump it into a database record (the db stuff I can do). Grabbing the date along the way would be wonderful as well. I can go through it with opening the text file and reading in the lines, and if the first character is a "-" then count that as the start of a bug block, but I am not sure how to find the last line of a bug block...it would be the line before the first line of the next bug block, but not sure the best way to go about it. There must be a rather standard way to do something like this in Python, and I'm requesting pointers toward that standard way (or what this type of task is usually called). Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: Parse bug text file
Thank you, Chris, Terry, and jmf, for these pointers. Very helpful. -CM -- https://mail.python.org/mailman/listinfo/python-list