Re: OT: Code Examples
On 01/03/2011 09:24, Richard Dobson wrote: But - I am ~still~ caught out by the semantic significance of indenting. Looks OK enough on paper, but doing it interactively is another matter. I still don't fully understand this argument. With Python, I am still doing indentation almost exactly the same way I was in any other language (and should be - I haven't ever seen any arguments for not indenting logical blocks). The only difference is, I don't need to put a block-end-identifier. I suppose I see how one could argue that this could potentially cause *mildly* confusing code, but only in extreme examples, and mainly only for multi-screen functions, that should rarely exist (and these are confusing even with bracketed blocks). -- http://mail.python.org/mailman/listinfo/python-list
Re: Fun with 'str' and 'bytes'
On 04/03/2011 16:40, nn wrote: As far as I know, that is pretty much it. Also see: http://bugs.python.org/issue3982 That is a depressing bug report, and really comes across as people who don't use networking commenting on the requirements of people who write networking code. It's good to see that the idea was getting a bit more treatment last yeat. -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the best book to learn Python from Perl and C++ background
On 04/03/2011 17:49, Ignoramus20691 wrote: I bought a "Hello World!" book for my 9 year old son. The book teached "programming for kids" and it does it in Python. I do not know any Python, but I am very comfortable with C++ and perl. I wrote a little over 100k lines of perl. I want to learn Python quickly to help him with his studies/fun. I would prefer a "no shit" book that quickly teaches a language to programmers. I moved to python after a heavy C++ background - I boosted myself to self-supporting status with OReilleys "Learning Python" on and off over the course of a weekend, skipping the parts that looked familiar. For some reason I didn't use the official python tutorial, though I have used it as a semi-reference on occasion since - it might be a good idea to start with that and see if it is efficient enough for you. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Hi Adam, I'm still learning my way around wxPython and gui programming, been mostly linux and CLI since Visual Basic 5, and only recently started learning it. On 23/01/2011 18:09, Adam Skutt wrote: 1. There's a bug related to loading of your resources. 2. There's a bug related to when file I/O is performed. 3/4. There's at least two bugs related to handling of a specific mouse event. 5. There's a bug related to reporting errors to the user. All of these bugs, except one[1], show a grave misunderstanding about how GUI toolkits operate and/or how the underlying operating systems behave. > [1] Which is only because wxWidgets has a bug in this regard. That being said, a workaround exists and trivial to find online. I'd be curious as to what these bugs are, as a learning exercise, if you don't mind. I don't mind a direct mail if you wish not to subject yourself to any more abuse on the list, as would almost certainly come. I'd especially like to be pointed at the error you refer to in [1]. On to the topic of the program direct, the 'List view' button doesn't seem to work on my platform, showing a blank folder icon and nothing else, but I don't know if that is related to any of these bugs. I actually looked around when I wanted to start learning gui programming, and chose wxPython because it seemed to use 'native' controls on all of the platforms. This file viewer just looks awful (is it supposed to flicker so much when I try to change the column size?) so I'm not exactly sure what it is supposed to prove. Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 25/01/2011 14:11, Littlefield, Tyler wrote: My preaching done with, I'd like to urge everyone to put this in a bit of perspective; essentially, what I don't want is someone walking away with Octavian's attitude as a stariotype for us all. I can't speak for everyone (I don't have that presumption), but to me, given the two data points, you are certainly coming across as more level-headed, and thus representative. Octavians posts sound more and more like rantingricks as time goes on, which is not a good thing. This entire debate is silly, anyway; wx is doing perfectly well as a separate, but easily installed library, and I can't forsee a situation where it's inclusion in the standard library would happen. Even if a python newbie does start with TK, learning a second GUI toolkit shouldn't be that much of a struggle for them. I think even more damaging to any python newcomers than choosing the 'wrong' gui toolkit would be stumbling across this thread whilst looking for a toolkit; and thinking some of the behaviour here was representative of the python (or wx) community as a whole, which couldn't be further from the truth. I know that if I had found this thread when looking around I would certainly have been put off of wx (which is the toolkit I decided on when looking around). Perhaps there is room for a balanced, adult discussion on the future of GUI toolkits in python; But I don't believe that this can happen here without substantial changes to a certain persons attitudes (or other peoples kill files). -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy/matlab compatibility
On 25/01/2011 20:13, Matt Funk wrote: 1) a = rand(10,1) 2) Y = a 3) mask = Y> 100; 4) Y(mask) = 100; 5) a = a+Y Basically i am getting stuck on line 4). I was wondering if it is possible or not with python? (The above is working matlab code) I don't understand this matlab code completely (I would expect rand to return in the range 0-1, so would expect (Y > 100) to match nothing). Nonetheless, to achieve line 4 I believe you are looking for: >>> Y[mask] = 100 However, you can also do directly: >>> Y[Y>100] = 100 This won't work exactly as you anticipate, because presumably in matlab the line 'Y = a' makes a copy of 'a' (it has been a long time since I used matlab). In python, Y and a will still refer to the same object, so altering Y will also alter a. The *most literal* translation to python of your sample is probably: >> import numpy >> a = numpy.random.rand(10,1) >> Y = a.copy() >> mask = Y > 100 >> Y[mask] = 100 >> a = a + Y -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 25/01/2011 19:24, Octavian Rasnita wrote: Can you tell why? Because you probably don't care about those who can't use the programs made with Tkinter or because you consider the discrimination something normal, right? And you said that it is not a good thing. Good thing for whom? For the blind people Tkinter is the worst thing possible. Or do you want to say that it is not true? No, it shouldn't be, but I see that you don't understand after this long thread why Tkinter should be avoided. WxPython shouldn't be the second choice. WxPython shouldn't be the first choice or the single choice. The single choices should be always only those who don't introduce discrimination. Don't you agree with this? Well, for the moment only WxPython doesn't include discrimination if we are talking about portable GUIs. Please tell me if I wasn't clear enough or what you don't agree with. The atitude that needs to be changed is the one that considerates the majority more important than a minority which is a minority because of health problems, a minority that is a minority without its will. In my country there is a law that says that the society should adapt to the people with disabilities (and not viceversa), and that law is probably copied from the legislation of other european countries. That law is a very good one, but the problem is that nobody cares to respect it, because most of the people have Tyler's opinion. Yes, I know, that's life, which is not right, that's faith, bla bla, but it doesn't mean that my atitude need to be changed. The atitude that needs to be changed is the one that considers the discrimination something normal and the one that considers that the disabled people should adapt to the society even though most of them can't do that because of their health problems. Octavian, we get it - you are on the warpath about accessibility. And this is, in a way, a good thing, because, yes, programmers should in general think more about accessibility when designing their programs. But nobody was ever persuaded to consider a complicated and subtle issue by hostile holier-than-thou arrogance, which is what rantingricks posts started out with, and what your posts have been slowly turning into. This is what is 'not a good thing', in case you genuinely didn't understand the context of my previous message. Look at the response your earlier posts got, with experienced developers showing an interest in actually trying out accessibility tools. Compare this with the defensive replies you have been getting more recently. But this thread is not about that, and the accessibility issue is mostly a red herring that rantingrick has grabbed hold of to swing around like a battleaxe, because nobody is going to say that accessibility doesn't matter. Discrimination in many forms, is a real problem in our societies, and one that is not going to be solved overnight, much as you might wish it. Stigmatizing perfectly repectful people who haven't encountered your needs before, or don't agree that accessibility is the only thing that matters, is not going to solve any issues. -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 25/01/2011 19:16, CM wrote: On Jan 25, 10:13 am, Nicholas Devenish wrote: I don't know--you sound too reasonable to extrapolate from this goofy thread to a huge toolkit project that has been around for years and is used in project such as Audacity (that's the wxWidgets version, but close enough). But yes, it almost at times seemed like--from what I could manage to read--this thread was a "psy-ops" (psychological operations) trick to turn off wxPython adopters by associating it with juvenile nonsense, and yes, on a quick scan it could turn people off. Personally, no, it probably wouldn't have caused me not to use wx. But it certainly would have put a mental tick in the against box, because a frameworks community matters. As a little aside, a personal example is Django, whose tutorial contained what to my un-django-trained eye looked like an inconsistency bug, without explanation. I filed a bug report, and apparently many other people have had the same misassumption (indicating a problem with the tutorial). The bug was closed with words effectively equivalent to "Stupid newbie". Ignoring the fact that documentation being consistently misinterpreted should indicate a real problem, why should I put my time and effort into learning a framework with a community that is so hostile, when there are plenty of alternatives? Which would be a shame, because, as you, Andrea, and others have noted, wxPython is a nice toolkit. For those interested, download it and make sure to download the Demo, that shows what can be done with it. (Very early in this discussion the screenshots on the website came up; they are horrifically out of date and wxPython deserves better and looks great on, say, Windows 7 or Ubuntuwell, it looks native, and that's the point). I actually chose wxPython partly on the strength of it's native-ness - it looks like other mac applications, and doesn't run through X11, but I was also extremely impressed by the comprehensive wxPython demo. That, and installation seemed to be pretty easy, whereas GTK looked a little like a minefield (QT I have a personal bias against, because for whatever reason I associate it with KDE and in general dislike kde's 'look' and design philosopy). But what I would enjoy is a discussion about GUIs in terms of "develop once, deploy many". For example, pyjamas, since I think being able to develop one GUI that works as desktop or web-based is kind of exciting. Unfortunately, it seems it is far off from anything easily usable at this point. Part of that might be it doesn't have a big enough community of developers yet. It's also just really difficult, I'm sure. I was only aware of pyjamas as a "Python to Javascript" compiler, and didn't know you could write desktop applications in it too. One to watch! -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter
On 26/01/2011 00:40, Ian wrote: Are you referring to ticket #14081? I expect the reason this hasn't been addressed is because nobody has submitted a patch or suggested an improved wording. If you were to make a suggestion, I doubt that anybody would be hostile to the idea of improving the tutorial. Actually, it was that ticket, good hunting. It's not so much that it was marked as duplicate, but that the bug it's marked "Yet another" duplicate of is marked 'invalid', implying that the Django developers consider it not a bug (i.e. user error, and not something to be patched or reworded). If it was open, even as a long-term low-priority documentation bug, then closing and marking the duplicate report wouldn't have felt prickly at all. I did some digging at the time, and there were indeed several more instances of this confusion arising (that I failed to find in my cursory search before posting the report); if intelligent people are getting confused over the tutorial, (a document specifically designed for people unfamiliar with the framework), then it sure sounds like a documentation bug. Especially as, in some of the tickets, the responder explained the issue (so, a need to explain) before closing the ticket. Essentially, if people are hostile to the idea of accepting a documentation problem, surely they might react the same way to a patch for it. And this is the first impression I got of the django community; because I am only a casual user, I subsequently didn't feel any need to potentially 'fight against the system' over the issue. I'll take your encouraging comments on the general friend-and-helpful-ness of the Django community onboard. Thanks, Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 26/01/2011 18:19, rantingrick wrote: SUMMARY: We create an abstraction API atop "Robin's WxPython". We include only the API in the stdlib at this time and we keep Tkinter in maintenance. Then over the next few years we start a fresh wxPython project that will be acceptable for the stdlib. Something that we can plug our API into. We steal as much from Robin as we can (or get him to cooperate). Then when the time is right, we dump Tkinter and integrate the new Wxpy module into the stdlib. Then we will be back on track. I look forward to reading your PEP and initial design documents, though I suspect you would need the latter and to get some a decent portion of work done before it would even be considered as an inclusion into the standard library. I strongly suspect that your response to this suggestion would be the ironic "more talk and no action from X". Many capable developers have their own occupations and might not have the spare time or desire to spend on a project where all evidence suggests would be a (non-benevolent) dictatorship where they would be endlessly browbeaten. You have continuously tried to outright present yourself as a 'visionary' and speaker for the python community and then asked why people don't take you seriously. People would take you a lot more seriously if you showed that you had the vision and capability to drive development of such a serious undertaking, and manage such a team of developers, whom you have first managed to attract to the project. If you actually seriously believe this should happen and that you are the best person to drive it, the way to go about it is probably: - Write some design documents, or even code, laying out what you think the interface should be. - Put it out to the community, listen to advice, make changes (it will NOT be perfect) and gather support. - Provide an initial implementation Somebody in the old thread said something which made sense, which I paraphrase as: "Only idiots think they can command communities of equals." This is something to keep closely in mind in your continuing, what can only be described as 'crusades'. This, along with the fact that people remember first impressions, and are usually cautious about reversing opinions developed through many examples of uncivility. Heck, I am probably wasting my time with this post; but you come across as genuine in your held central beliefs, and so either serious or the most dedicated and adept troll I have ever encountered. In the case of the former, I hold an optimistic view that most people are capable of self-asessment. In the case of the latter, consider me successfully trolled. Nick -- http://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
On 28/01/2011 00:54, rantingrick AKA "Brian" wrote: Yes the minor details have been evolving over the course of this and another thread. We have been floating new ideas all along the way in an effort to get the best result. In the very beginning because we all know that wxPython IS HUGE i offered a divide and conquer approach... In other, greater words: "He's making it up as he goes along." -- http://mail.python.org/mailman/listinfo/python-list
Re: Easy function, please help.
On 09/02/2011 14:27, RJB wrote: What operator should I use if I want integer division? Ada and Pascal used "div" if I recall rightly. The operator for integer division is // -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a dict based on such a file?
On 14/02/2011 19:25, Dan Stromberg wrote: pyparsing should be able to make pretty short work of exactly the format you want. FWIW, the creator of the many .ini format(s), Microsoft, no longer recommends using .ini files. I don't know what Microsoft uses now, but it seemed their immediate successor was the windows registry, which wasn't exactly fun. INI-style files are extremely simple, very easy to parse (if you don't have a handy parsing library for it, which is rare) and very human-readable and modifyable. *If* your configuration data doesn't get more complex than an optionally sectioned flat-file, then it can seem like the right tool for the job. Especially if you need people who aren't exactly programmers to be able to configure and understand the file. As for JSON, another that it seems is often mentioned around such things; I like it, but find it a little verbose for such simple flat configuration files. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
On 19/02/2011 07:41, Westley Martínez wrote: Simply remove 'dvorak-' to get qwerty. It allows you to use the right Alt key as AltGr. For example: AltGr+' i = í AltGr+c = ç AltGr+s = ß I don't work on Windows or Mac enough to have figured out how to do on those platforms, but I'm sure there's a simple way. Again, it's the funky symbols that would be difficult to input. On mac, the acute accent is Alt-e + vowel, so Alt-e i. This seems to work universally, regardless of gui application or terminal. I don't work with X applications enough to know if they work there, however. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
On 18/02/2011 10:26, Steven D'Aprano wrote: Agreed. I'd like Python to support proper mathematical symbols like ∞ for float('inf'), ≠ for not-equal, ≤ for greater-than-or-equal, and ≥ for less-than-or-equal. This would be joyful! At least with the subset of operations that already exist/exist as operators, the possibility of using these wouldn't affect anyone not using them (like the set/intersection notation mentioned in another post). I'm not very optimistic about anything like this ever being accepted into python main, however (I can't imagine it being terribly complicated to add to the accepted language, though). -- http://mail.python.org/mailman/listinfo/python-list