Re: Python benefits over Cobra
> On 05-Apr-11 06:22 AM, Brendan Simon (eTRIX) wrote: >> >> Any other arguments where Python has benefits over Cobra ?? >> >> Cheers, Brendan. >> > Two questions: > 1. Is Cobra Open Source? > 2. The blog ended on October, did he run out of steam? > > I liked the '.', in place of '.self', but that's been rejected for Python. "Cobra is an open source project under the MIT license." according to the web site. It seems that it mostly, if not all, the work of one person. All code commits seem to be from Charles Esterbrook. It seems the latest release is Oct 2010, but I can see posts in the forum for April 2011, March, Feb, . I too like the '.' in place of self :) However, I don't like _ as line continuation :( Life is tough, eh ?? It also looks like there is work to have it run in a JVM. I presume that means that no .NET/Mono framework is required ?? -- http://mail.python.org/mailman/listinfo/python-list
Python benefits over Cobra
I just came across the Cobra language, which appears to be heavily influenced by Python (and other languages). The pitch sounds great. It's supposed to have: 1. Quick, expressive coding 2. Fast execution 3. Static and dynamic binding 4. Language level support for quality http://cobra-language.com/docs/why/ http://cobra-language.com/docs/python/ I was wondering what advantages Python has over Cobra. I know it's probably a difficult question to answer and depends on specific requirements. All I can think of is: * Maturity of language o Robust and tested. o availability of modules (standard and built-in). o large community support (commercial and non-commercial). * No dependence of .NET/Mono o I don't know if this is an pro or con as I don't know .NET. Presumably the maturity argument would be less significant over time. I'm not sure about the .NET/Mono framework, whether that is good or bad. Sounds good in some situations at least. Any other arguments where Python has benefits over Cobra ?? Cheers, Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Python3 "designed right" (was: PYTHONPATH)
On 19/04/2011 2:15 AM, python-list-requ...@python.org wrote: Subject: Re: PYTHONPATH From: MRAB Date: Mon, 18 Apr 2011 16:31:31 +0100 To: python-list@python.org On 18/04/2011 05:37, harrismh777 wrote: [snip] In retrospect, in many ways this is why I am relatively patient with the Python3 development direction. While I think its non-compatibility may hurt in the short term, the long term goal of stream-lining the language will make for a much better Python future. Essentially, the python team said, "Look, python2 sucks... ," and then they went about figuring out what Python would look like had it been "designed" right in the first place. Whalla, Python3. So after years and years of practical experience with the language Python is getting the face lift it deserves, and is going to be one gorgeous lady when finished. Personally, I really hope Python3 (or 3+) would have some of the features that Cobra has built into the language. * dynamic/late binding (like Python) for flexibility _and_ static/early binding for fast execution and error checking. * inbuilt support for quality - compile time "None Error" tracking# I have experienced this a lot and it's a real pain :( - inbuilt unit testing - inbuilt "contracts" to ensure conditions are met when calling functions. * no "self" * no ":" after if/else statements. My main gripe with Cobra is that it requires the .NET framework (or Mono), though the web pages do suggest they are also working on a version that runs on JVM. Also third party libraries (e.g GUIs like wx) may not be as good or available (yet) ?? http://cobra-language.com/docs/python/ http://cobra-language.com/docs/why/ -- Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] Python 2.5.6 Release Candidate 1
On 19/04/2011 9:05 AM, python-list-requ...@python.org wrote: Am 18.04.2011 09:59, schrieb Werner F. Bruhin: > On 04/17/2011 11:57 PM, "Martin v. Löwis" wrote: >>http://www.python.org/2.5.6 If there is an official release of source (e.g. 2.5.5 and 2.5.6) why aren't binaries produced (other than to make it really hard for users and force them to upgrade to a later major revision -- 2.6, 2.7, etc) ?? It's ok for Linux distros as they tend to build from sources, and test, and produce their own binary packages. But for OS X and MSW users it's not quite like that. I'd like to upgrade to 2.5.6 (for one particular mature application), but unfortunately I'm stuck with 2.5.4 as I don't really want to have to build (and hopefully get it right) on my OS X box. Cheers, Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Abandoning Python
On 23/05/11 7:17 AM, python-list-requ...@python.org wrote: > Subject: > Re: Abandoning Python > From: > John Lee > Date: > Sun, 22 May 2011 21:13:44 + (UTC) > > >> > >> > Have you looked at Falcon (http://www.falconpl.org/)? It seems to have a >> > lot >> > of what you are looking for. > I'm more interested in other people's opinions than my own "looking for"s. > > What *should* I be looking for (other than Python itself)? What's > interesting, > widely applicable, and new(ish)? > > Falcon fails my personal book-by-its-cover test. There are too many languages > to do without that test, unfortunately. Take a look at Cobra. http://cobra-language.com/docs/python/ http://cobra-language.com/ It is similar to Python, but with a quite a few nice extras and few improved things (eg. no "self", no ":", ...) Possible negatives are: * Requires either .NET or Mono frameworks. * lack of 3rd party libraries ?? Cheers, Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Help using Thread (or other method)
Hi. Need some urgent help. I have a python app that uses `select` to wait for data from an arm embedded linux kernel interrupt (every second). The mainloop of the app then grabs data from some memory mapped area, processes it and then does a http post to a server. The problem is the http post can take multiple seconds to respond and blocks (using the requests module). So I've put the posting in a separate thread (using Thread module) and send data to it via a queue (using the Queue module). The http post can send multiple records by pulling multiple items off the queue. Sounds good so far, right? This seems to work ok, but I also need to grab data from some other serial devices (gps, weather station) to put in the post. Various sample apps on the web use Threads to do this, so I am doing the same. One of the threads uses `select` (see below), following by readlines() on the device. def __init__(self): select_timeout = 1 serial_timeout = 0.1 def wait_and_process(self): '''wait for data and process it.''' r = select.select([self.serial_dev], [], [], self.select_timeout) if not r[0]: #print("DEBUG: TIMEOUT: wait_and_process") return #print("DEBUG: Weather Data Captured") for s in self.serial_dev.readlines(): #print("INFO: Data: {}".format(s)) temperature = extract_temperature(s) Is using `select` here redundant? It's used to block the thread until the first character is ready to be read from the serial device? Then I use serial_dev.readlines() to read the stream of chars from the weather station. Is that ok? Does readline block until it sees an end-of-line char? i.e. does it only wake up the thread when it has a _complete string_ or a timeout of 0.1 seconds? or will the process block other threads from running while it is gathering the chars until the newline? I'm assuming the gathering of chars will happen in the background and allow my main thread to run, correct? My application mainloop (not the threads) needs to be high priority and always process as soon as it gets an interrupt. Is using select a good way of doing this? How can I ensure that no other threads are utilizing the CPU, etc? I'm worried about the GIL (I'm using CPython 2.7). Is there a better way of structuring this to ensure I process the interrupt and not get interrupt overrun? Is using select only in the mainloop, with multiple file descriptors, a better way of doing things, so that I can process the file descriptor of interest first, before any others if set? Is using the multiprocessing module a better option? Thanks for any advice, Brendan. -- https://mail.python.org/mailman/listinfo/python-list
Re: WxPython versus Tkinter.
Since it seems the python motto is "Batteries included", then it would seem to me that wxPython is the natural fit as it also has "Batteries included" (e.g. accessibility, native look-n-feel, mature and evolving, can produce simple or complex gui programs, etc, etc). -- Brendan Simon www.etrix.com.au -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPython in the context of Eclipse
On 20/02/2011 10:00 PM, python-list-requ...@python.org wrote: Subject: wxPython in the context of Eclipse From: Fred Marshall Date: Sat, 19 Feb 2011 23:22:44 -0800 To: python-list@python.org I asked earlier: How do I use wxPython or wxGlade in the context of Eclipse? A link to a howto would be great! I guess nobody knows or cares to answer? Have you tried the wxPython mailing list. You will probably have more wxPython users to draw upon than this list ;-) I use Eclipse with wxPython and it works fine. You need to install the Eclipse PyDev module (which I presume you have already done). If I recall correctly, I had to specify the python interpreter to use. It added a whole lot of paths to the PYTHONPATH variable which caused me some grief. I ended up removing them all (or most of them) and it worked fine after that. Cheers, Brendan. -- Brendan Simon www.etrix.com.au -- http://mail.python.org/mailman/listinfo/python-list
Can't find elements using ElementTree find method
I am trying to use ElementTree (with Python 2.7) and can't seem to find elements at the top level. The find() and findall() methods seem to find elements within the top level, but not if it the elements are at the top level. How do I find top level elements ?? Here is my code. import xml.etree.ElementTree as ET xml = '''\ Fred Australia ''' root = ET.fromstring( xml ) ### This pattern is not found :( comps = root.find( './/components' ) ### These patterns are found ok :) comp = root.find( './/component' ) name = root.find( './/name' ) print 'comps =', comps print 'comp =', comp print 'name =', name Thanks, Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't find elements using ElementTree find method
I can't use getroot() when using fromstring() -- as fromstring() returns an Element, not an ElementTree object. Yes, my root is the 'components' element, but find() seems to insist on searching for sub-elements. Ideally, I would like root.find('components') or root.find('./components') to find the components element at the top-level. I'd also like to be able to do root.find('./components/component') or root.find('./components/component/name') and so on. I guess I just have to check that root.tag == 'components' first, then search for './component', './component/name' and so on. It's a bit ugly, but heaps better than using minidom :) Cheers, Brendan. On 31/08/10 6:57 PM, Nitin Pawar wrote: > Try using getroot() > > I think your root is components so its searching in root > > On Tue, Aug 31, 2010 at 2:19 PM, Brendan Simon (eTRIX) > mailto:brendan.si...@etrix.com.au>> wrote: > > I am trying to use ElementTree (with Python 2.7) and can't seem to > find elements at the top level. The find() and findall() methods > seem to find elements within the top level, but not if it the > elements are at the top level. > > How do I find top level elements ?? > Here is my code. > > import xml.etree.ElementTree as ET > > xml = '''\ > > > > Fred > Australia > > > ''' > > root = ET.fromstring( xml ) > > ### This pattern is not found :( > comps = root.find( './/components' ) > > ### These patterns are found ok :) > comp = root.find( './/component' ) > name = root.find( './/name' ) > > print 'comps =', comps > print 'comp =', comp > print 'name =', name > > > Thanks, Brendan. > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > Nitin Pawar > -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-list] if the else short form
On 29/09/10 9:20 PM, python-list-requ...@python.org wrote: > Subject: > if the else short form > From: > Tracubik > Date: > 29 Sep 2010 10:42:37 GMT > > To: > python-list@python.org > > > Hi all, > I'm studying PyGTK tutorial and i've found this strange form: > > button = gtk.Button(("False,", "True,")[fill==True]) > > the label of button is True if fill==True, is False otherwise. > > i have googled for this form but i haven't found nothing, so can any of > you pass me any reference/link to this particular if/then/else form? > As others have pointed out, a tuple with two items is created and then indexed by the integer conversion of conditional. It is "creative" coding but I wouldn't recommend using it either. For this particular case you may achieve the same thing with: button = gtk.Button(str(fill==True)) or possibly just: button = gtk.Button(fill==True) It's a little better but still not great. A verbose form of something more generic may be: if fill: label = 'True' else: label = 'False' button = gtk.Button(label) or possibly: label = 'True' if fill else 'False' button = gtk.Button(label) or using a dict for label lookup: label = { True : 'True', False : 'False' } button = gtk.Button(label[fill]) Cheers, Brendan. -- http://mail.python.org/mailman/listinfo/python-list
Re: Whining about "struct"
On 14/10/10 5:17 PM, python-list-requ...@python.org wrote: > Subject: > Whining about "struct" > From: > Tim Roberts > Date: > Wed, 13 Oct 2010 21:30:38 -0700 > > To: > python-list@python.org > > > I have a bad memory. I admit it. Because of that, the Python "help" > system is invaluable to me. Up through Python 2.5, I could get a quick > reference to the format specifiers for the struct module via > import struct; help(struct) > > I used that a LOT. > > But in Python 2.6, the struct module moved from Python code to C code, and > that helpful help string was removed. > > Is that still gone in Python 3.1? What are the chances of reinstating that > helpful chart? It works ok for me on Mac OS X for both Python 2.6.5 (python.org) and Python 2.6.1 (Apple) installations. -- http://mail.python.org/mailman/listinfo/python-list