From jason at powerpull.net Wed Feb 1 00:53:28 2012 From: jason at powerpull.net (Jason Friedman) Date: Wed, 1 Feb 2012 05:53:28 +0000 Subject: Installing pypi package twice Message-ID: My system's default python is 2.6.5. I have separately installed 3.2.2 at /opt/python. I downloaded python-daemon-1.5.5 and installed with: $ tar xzf python-daemon-1.5.5 $ cd python-daemon-1.5.5 $ python setup.py build $ sudo python setup.py install How would I also install this package for 3.2.2? (I am assuming that python-daemon-1.5.5 is either version3-compatible or I can make it so). From jason at powerpull.net Wed Feb 1 01:04:31 2012 From: jason at powerpull.net (Jason Friedman) Date: Wed, 1 Feb 2012 06:04:31 +0000 Subject: Installing pypi package twice Message-ID: My system's default python is 2.6.5. I have also installed python3.2 at /opt/python. I installed a pypi package for 2.6.5 with: $ tar xzf package.tar.gz $ cd package $ python setup.py build $ sudo python setup.py install How can I also install this same package for 3.2? (I am assuming this package works with 3.2 or that I can make it work.) From huayanghao at gmail.com Wed Feb 1 01:41:27 2012 From: huayanghao at gmail.com (Hua Yanghao) Date: Wed, 1 Feb 2012 14:41:27 +0800 Subject: Python Descriptor as Instance Attribute In-Reply-To: References: Message-ID: Thanks Ian for the explanation. Please see my comments below: > The behavior is by design. ?First, keeping object behavior in the > class definition simplifies the implementation and also makes instance > checks more meaningful. ?To borrow your Register example, if the "M" > descriptor is defined by some instances rather than by the class, then > knowing that the object "reg" is an instance of Register does not tell > me anything about whether "reg.M" is a valid attribute or an error. > As a result, I'll need to guard virtually every access of "reg.M" with > a try-except construct just in case "reg" is the wrong kind of > register. I don't quite understand the above explanation. Sorry I'm not very familiar with the low level details, but from a user's point of view, if I defined reg.M, then it should be a valid access later on.... somehow. :-) > Second, the separation of class from instance also helps you keep > object behavior separate from object data. ?Consider the following > class: > > class ObjectHolder(object): > ? ?def __init__(self, obj): > ? ? ? ?self.obj = obj > > Don't worry about what this class might be useful for. ?Just know that > it's meant to hold and provide unrestricted access to arbitrary Python > objects: > >>>> holder = ObjectHolder(42) >>>> print(holder.obj) > 42 >>>> holder.obj = range(5) >>>> print(holder.obj) > [0, 1, 2, 3, 4] > > Since the class is meant to hold arbitrary objects, it's even valid > that somebody might want to store a descriptor object there: > >>>> holder.obj = property(lambda x: x.foo) >>>> print(holder.obj) > > > Now suppose that Python invoked the descriptor protocol for > descriptors stored in instance attributes: > >>>> holder = ObjectHolder(None) >>>> holder.obj = property(lambda x: x.foo) >>>> print(holder.obj) > Traceback (most recent call last): > ?File "", line 1, in > AttributeError: 'ObjectHolder' object has no attribute 'foo' > > In this case, the ObjectHolder would fail to simply hold the property > object as data. ?The mere act of assigning the property object, a > descriptor, to an instance attribute would *change the behavior* of > the ObjectHolder. ?Instead of treating "holder.obj" as a simple data > attribute, it would start invoking the descriptor protocol on accesses > to "holder.obj" and ultimately redirect them to the non-existent and > meaningless "holder.foo" attribute, which is certainly not what the > author of the class intended. OK I see some fundamental problems here now. And I think that's actually one of the limitations of descriptor: A descriptor only works when it is defined as class attribute and accessed from the instance. It really can be much more powerful if there can be a general way to define an attribute on either a class or an instance, but the access to it (either directly from class or from its instance) actually calls a function. It will make some kind of abstraction much more clean and simple in concept, like my example above, I have one class called register, and all of its instance represent different registers with different field, and assignment to its field automatically checks for validations, and read automatically fetches the value from the hardware. > For the above reasons, I would probably implement your Register class > as a set of related class sharing a common metaclass. ?The solution > you came up with is probably fine to solve your specific problem, > though. this like I said before is not conceptually simple enough, and it can confuses end user if they're not python expert. For years I loved python is because I can always figure out a best way to abstract a problem, and make end-user interface as simple as possible, I never failed before with python, but this time it seems python indeed have limitations here, or does there exist a better solution? To make you understand the problem I'm facing, I'd like to elaborate a bit more here. Registers in SoC peripherals have different field, and each field have different number of bits, different access capabilities (read only, write only, read write, ...), but all registers share some common attribute, like they're all 32 bits long. Also some common operations is shared, like distribute a value to each bit field, meaning that set the value of a register as a whole will automatically update each field. The definition of each register is in an XML file with all attribute for each field. And the preferred way to generate an "representation" of a register is to instantiate the Register class with its definition read from the xml file. This is the natural design, all register representation is an instance of Register class. So now the problem is, how can I have such a simple class with all its instance have different fields, which can be written and read directly (like reg.M = '101', or x = reg.M) with automated validation check and value fetch? Define a separate class for each register doesn't sounds feasible because there's hundreds of registers. Using metaclass to generate a class for each register also doesn't feel good, because you still need to instantiate them *once again* to get the instance that actually invokes the descriptor protocols ... Your input is highly appreciated. Best Regards, Yanghao From arnodel at gmail.com Wed Feb 1 02:09:35 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 07:09:35 +0000 Subject: Iterate from 2nd element of a huge list In-Reply-To: References: Message-ID: On 1 February 2012 03:16, Paulo da Silva wrote: > Em 01-02-2012 01:39, Paulo da Silva escreveu: >> Hi! >> >> What is the best way to iterate thru a huge list having the 1st element >> a different process? I.e.: >> >> process1(mylist[0]) >> for el in mylist[1:]: >> ? ? ? process2(el) >> >> This way mylist is almost duplicated, isn't it? >> >> Thanks. > > > I think iter is nice for what I need. > Thank you very much to all who responded. Nobody mentioned itertools.islice, which can be handy, especially if you weren't interested in the first element of the list: from itertools import islice: for el in islice(mylist, 1): process2(el) -- Arnaud From arnodel at gmail.com Wed Feb 1 02:17:10 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 07:17:10 +0000 Subject: 'class' named tuple In-Reply-To: References: Message-ID: On 1 February 2012 00:54, Emmanuel Mayssat wrote: > I have the following program. > I am trying to have index the attributes of an object using __getitem__. > Reading them this way works great, but assigning them a value doesn't > Is there a way to do such a thing? > (Almost like a named tuple, but with custom methods) > > class LIter(object): > ? ?def __init__(self,parent=None): > ? ? ? ?super(LIter, self).__init__() > ? ? ? ?self.toto = 3 > ? ? ? ?self.tata = 'terto' > Add _attrs = 'toto', 'tata' def __getitem__(self, index): return getattr(self, _attrs[index]) def __setitem__(self, index, value) setattr(self, _attrs[index], value) -- Arnaud From __peter__ at web.de Wed Feb 1 03:11:44 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Feb 2012 09:11:44 +0100 Subject: Iterate from 2nd element of a huge list References: Message-ID: Arnaud Delobelle wrote: >> Em 01-02-2012 01:39, Paulo da Silva escreveu: >>> What is the best way to iterate thru a huge list having the 1st element >>> a different process? I.e.: > Nobody mentioned itertools.islice, which can be handy, especially if > you weren't interested in the first element of the list: Also, skipping two or seven or ... items is just as easy. The example should be > from itertools import islice: for el in islice(mylist, 1, None): > process2(el) From ben+python at benfinney.id.au Wed Feb 1 03:18:20 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 01 Feb 2012 19:18:20 +1100 Subject: Installing pypi package twice References: Message-ID: <87sjivvuer.fsf@benfinney.id.au> Jason Friedman writes: > How would I also install this package for 3.2.2? (I am assuming that > python-daemon-1.5.5 is either version3-compatible or I can make it > so). I am the primary developer of ?python-daemon?. It is an explicit goal of this library to target Python 3, but that has not been achieved yet. I welcome discussion on the new forum for development discussion . -- \ ?Science is a way of trying not to fool yourself. The first | `\ principle is that you must not fool yourself, and you are the | _o__) easiest person to fool.? ?Richard P. Feynman, 1964 | Ben Finney From stefan_ml at behnel.de Wed Feb 1 03:26:15 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 01 Feb 2012 09:26:15 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Tim Arnold, 31.01.2012 19:09: > I have to follow a specification for producing xhtml files. > The original files are in cp1252 encoding and I must reencode them to utf-8. > Also, I have to replace certain characters with html entities. > > I think I've got this right, but I'd like to hear if there's something I'm > doing that is dangerous or wrong. > > Please see the appended code, and thanks for any comments or suggestions. > > I have two functions, translate (replaces high characters with entities) > and reencode (um, reencodes): > --------------------------------- > import codecs, StringIO > from lxml import etree > high_chars = { > 0x2014:'—', # 'EM DASH', > 0x2013:'–', # 'EN DASH', > 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', > 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', > 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', > 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', > 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', > 0x2122:'™', # 'TRADE MARK SIGN', > 0x00A9:'©', # 'COPYRIGHT SYMBOL', > } > def translate(string): > s = '' > for c in string: > if ord(c) in high_chars: > c = high_chars.get(ord(c)) > s += c > return s I hope you are aware that this is about the slowest possible algorithm (well, the slowest one that doesn't do anything unnecessary). Since none of this is required when parsing or generating XHTML, I assume your spec tells you that you should do these replacements? > def reencode(filename, in_encoding='cp1252',out_encoding='utf-8'): > with codecs.open(filename,encoding=in_encoding) as f: > s = f.read() > sio = StringIO.StringIO(translate(s)) > parser = etree.HTMLParser(encoding=in_encoding) > tree = etree.parse(sio, parser) Yes, you are doing something dangerous and wrong here. For one, you are decoding the data twice. Then, didn't you say XHTML? Why do you use the HTML parser to parse XML? > result = etree.tostring(tree.getroot(), method='html', > pretty_print=True, > encoding=out_encoding) > with open(filename,'wb') as f: > f.write(result) Use tree.write(f, ...) Assuming you really meant XHTML and not HTML, I'd just drop your entire code and do this instead: tree = etree.parse(in_path) tree.write(out_path, encoding='utf8', pretty_print=True) Note that I didn't provide an input encoding. XML is safe in that regard. Stefan From ulrich.eckhardt at dominolaser.com Wed Feb 1 03:39:08 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 01 Feb 2012 09:39:08 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Am 31.01.2012 19:09, schrieb Tim Arnold: > high_chars = { > 0x2014:'—', # 'EM DASH', > 0x2013:'–', # 'EN DASH', > 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', > 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', > 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', > 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', > 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', > 0x2122:'™', # 'TRADE MARK SIGN', > 0x00A9:'©', # 'COPYRIGHT SYMBOL', > } You could use Unicode string literals directly instead of using the codepoint, making it a bit more self-documenting and saving you the later call to ord(): high_chars = { u'\u2014': '—', u'\u2013': '–', ... } > for c in string: > if ord(c) in high_chars: > c = high_chars.get(ord(c)) > s += c > return s Instead of checking if there is a replacement and then looking up the replacement again, just use the default: for c in string: s += high_chars.get(c, c) Alternatively, if you find that clearer, you could also check if the returnvalue of get() is None to find out if there is a replacement: for c in string: r = high_chars.get(c) if r is None: s += c else: s += r Uli From no.email at nospam.invalid Wed Feb 1 04:25:05 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 01 Feb 2012 01:25:05 -0800 Subject: Iterate from 2nd element of a huge list References: Message-ID: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> Paulo da Silva writes: > process1(mylist[0]) > for el in mylist[1:]: > process2(el) > > This way mylist is almost duplicated, isn't it? I think it's cleanest to use itertools.islice to get the big sublist (not tested): from itertools import islice process1 (mylist[0]) for el in islice(mylist, 1, None): process2 (el) The islice has a small, constant amount of storage overhead instead of duplicating almost the whole list. From __peter__ at web.de Wed Feb 1 04:32:52 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Feb 2012 10:32:52 +0100 Subject: xhtml encoding question References: Message-ID: Ulrich Eckhardt wrote: > Am 31.01.2012 19:09, schrieb Tim Arnold: >> high_chars = { >> 0x2014:'—', # 'EM DASH', >> 0x2013:'–', # 'EN DASH', >> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >> 0x2122:'™', # 'TRADE MARK SIGN', >> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >> } > > You could use Unicode string literals directly instead of using the > codepoint, making it a bit more self-documenting and saving you the > later call to ord(): > > high_chars = { > u'\u2014': '—', > u'\u2013': '–', > ... > } > >> for c in string: >> if ord(c) in high_chars: >> c = high_chars.get(ord(c)) >> s += c >> return s > > Instead of checking if there is a replacement and then looking up the > replacement again, just use the default: > > for c in string: > s += high_chars.get(c, c) > > Alternatively, if you find that clearer, you could also check if the > returnvalue of get() is None to find out if there is a replacement: > > for c in string: > r = high_chars.get(c) > if r is None: > s += c > else: > s += r It doesn't matter for the OP (see Stefan Behnel's post), but If you want to replace characters in a unicode string the best way is probably the translate() method: >>> print u"\xa9\u2122" ?? >>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) u'©™' From rosuav at gmail.com Wed Feb 1 04:48:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 1 Feb 2012 20:48:50 +1100 Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com> References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com> Message-ID: On Wed, Feb 1, 2012 at 12:11 PM, Andres Soto wrote: > > okok, my mistake is that I was using string in place of str. Thank you!! > regards Tip: In the interactive interpreter, enter: >>> type("spam") In Python 2, it'll say "type" not "class", but same diff. It tells you there what the type is. Same can be used for any other literal, name, or other object. Can be quite handy at times. ChrisA From jeanmichel at sequans.com Wed Feb 1 05:12:02 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 01 Feb 2012 11:12:02 +0100 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: <4F290FF2.9030907@sequans.com> Terry Reedy wrote: > On 1/31/2012 9:19 AM, Jean-Michel Pichavant wrote: > >> A: "My wheel is flat" >> B: "Buy a new car" > > A better analogy would be > > Q. "How do I make my old model car do something (it cannot do)?" > A. "Get the free new model that has that feature added." > > Of course, there is a cost to giving up the old and familiar and > learning and adjusting to the new, even when it is available gratis. A > husband wearing an old sweater after his wife gives him a new one, and > even retrieving it from the trash when she tosses it out, is a classic > (and true) cartoon joke. > > But I am sure that 95% of readers here will be using 3.x withing 10 > years. The only question for them is "When?". This not-well-known new > feature is one straw that some will put on the 'sooner' side of the > balance. > A simple solution to that problem has been provided by Miki. Someone should read at least http://wiki.python.org/moin/Python2orPython3 before migrating to python 3. Speaking for myself, I'm stuck with python 2.5 :-/ JM From tjreedy at udel.edu Wed Feb 1 05:28:27 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 05:28:27 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 1/31/2012 11:14 PM, Roy Smith wrote: > We would love to move to 3.x, for the better unicode support, if nothing > else. What's keeping us from doing so is the host of third-party > modules and tools we depend on that don't yet support 3.x. Tell that to the authors of packages you use so they no longer say that they have not converted for lack of demand ;-) -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Wed Feb 1 05:34:23 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 10:34:23 +0000 Subject: configobj In-Reply-To: References: <4F281178.70508@gmail.com> Message-ID: <4F29152F.6030702@gmail.com> On 02/01/2012 12:21 AM, Terry Reedy wrote: > On 1/31/2012 11:06 AM, Andrea Crotti wrote: >> I have a couple of questions about configobj, which I'm happily trying >> to use for this project. > > When asking about 3rd party modules, please include a url, so we can > be sure of what you mean and even take a look. Is > www.voidspace.org.uk/python/configobj.html > what you mean? Yes I meant that sorry. > >> which looked less complete and more cumbersome (to me at least) > > Does ConfigParser have the same problems you found with ConfigObj. > Well no, but also because it just gets raw strings, and doesn't do any validation. With ConfigObj I can do simply a spec file skip_pesky_pyc_paths = string_list include_extra_paths = string_list use_real_dependencies = bool(default=False) compute_dependencies_recursively = bool(default=False) And the options which are not declared will default automatically to that value. And also I never really liked the ConfigParser API.. Anyway I solved just leaving these long lists somewhere else, but otherwise I think a better solution would be YAML in general (which doesn't have much validation either apparently). From arnodel at gmail.com Wed Feb 1 05:54:56 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 10:54:56 +0000 Subject: Iterate from 2nd element of a huge list In-Reply-To: References: Message-ID: On 1 February 2012 08:11, Peter Otten <__peter__ at web.de> wrote: > Arnaud Delobelle wrote: > The example should be > >> from itertools import islice: > > for el in islice(mylist, 1, None): >> ? ? process2(el) Oops! -- Arnaud From jeanpierreda at gmail.com Wed Feb 1 06:14:48 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 1 Feb 2012 06:14:48 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On Tue, Jan 31, 2012 at 6:55 PM, Terry Reedy wrote: > Q. "How do I make my old model car do something (it cannot do)?" > A. "Get the free new model that has that feature added." > > Of course, there is a cost to giving up the old and familiar and learning > and adjusting to the new, even when it is available gratis. A husband > wearing an old sweater after his wife gives him a new one, and even > retrieving it from the trash when she tosses it out, is a classic (and true) > cartoon joke. It really bothers me that you imagine that there are no other problems than the newness. It's disheartening, because the problems are not that trivial and the world would be better if people were less callous about it, and realized that they exist. Python 3 is not very different from Python 2, as far as humans are concerned semantically/syntactically -- but, hell, just pick any project that uses PyPy, or Jython, or IronPython, or Twisted, or Zope, etc. -- it can be a lot of effort (sometimes infeasibly much) to port something dependent on these things, and it's taken years to get the (smallish) set of dependencies ported that we have now [and we literally paid people to do it, too!], and still many large projects haven't made the transition, and many small projects never will. Anyone that relies on those projects is stuck, and your "free car" metaphor completely ignores the true cost of wasting that much time porting everything for a tiny little feature. Evaluating only the monetary amounts can be misleading as to what the rational decision is (in particular when there are no monetary amounts). The only true notion of cost is the alternatives you sacrifice in making a decision: opportunity cost. The car is not free. -- Devin From stefan_ml at behnel.de Wed Feb 1 06:28:33 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 01 Feb 2012 12:28:33 +0100 Subject: Iterate from 2nd element of a huge list In-Reply-To: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> References: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin, 01.02.2012 10:25: > Paulo da Silva writes: >> process1(mylist[0]) >> for el in mylist[1:]: >> process2(el) >> >> This way mylist is almost duplicated, isn't it? > > I think it's cleanest to use itertools.islice to get the big sublist > (not tested): > > from itertools import islice > > process1 (mylist[0]) > for el in islice(mylist, 1, None): > process2 (el) > > The islice has a small, constant amount of storage overhead instead of > duplicating almost the whole list. It also has a tiny runtime overhead, though. So, if your code is totally performance critical and you really just want to strip off the first element and then run through all the rest, it may still be better to go the iter() + next() route. python3.3 -m timeit -s 'l=list(range(100000))' \ 'it = iter(l); next(it); all(it)' 1000 loops, best of 3: 935 usec per loop python3.3 -m timeit -s 'l=list(range(100000))' \ -s 'from itertools import islice' \ 'all(islice(l, 1, None))' 1000 loops, best of 3: 1.63 msec per loop Stefan From anais.conijn at skillsmatter.com Wed Feb 1 06:33:51 2012 From: anais.conijn at skillsmatter.com (=?ISO-8859-1?Q?Ana=EFs?=) Date: Wed, 1 Feb 2012 03:33:51 -0800 (PST) Subject: Russel Winder's Python Workshop in London Message-ID: Python-expert Russel Winder will be hosting a 4-day intensive Python workshop at the Skills Matter eXchange, London's meetup space for the developer community. Read all about it here: http://bit.ly/RWPythonWorkshopFEB13 And, to get a taste of Russel in action, you can watch a skillscast video of his January 31st talk on high performance python right here: http://bit.ly/RWPythonWorkshopFEB13 Hope this is of interest to you. Kind regards. From jason at founderdating.com Wed Feb 1 07:20:37 2012 From: jason at founderdating.com (Jason Demant) Date: Wed, 1 Feb 2012 04:20:37 -0800 (PST) Subject: FounderDating - Helping entrepreneurs find their co-founder & start companies! Message-ID: <52aa9bbc-e5da-4b14-b7e9-762ef3fed7d4@n8g2000pbc.googlegroups.com> Looking for your co-founder? FounderDating is back in San Francisco on March 1st (Apply by February 20th), in Seattle on March 6th (Apply by February 26th) and NY on February 21st (Apply by February 16th) at http://members.founderdating.com/application/. What is FounderDating? A great team is the best predictor of a new venture's success. Great teams are composed of high caliber people with complementary skills, this is where FounderDating comes in. FounderDating brings together super talented, handpicked entrepreneurs with different backgrounds and skill sets who want to start companies. We help them find the right match by giving them access to invitation- only events and an online member network. What differentiates FounderDating is the extreme quality of its members and their commitment to start something now! Apply now! -- http://members.founderdating.com/application/. Thanks! Jason http://www.FounderDating.com From johnroth1 at gmail.com Wed Feb 1 08:11:05 2012 From: johnroth1 at gmail.com (John Roth) Date: Wed, 1 Feb 2012 05:11:05 -0800 (PST) Subject: Disable use of pyc file with no matching py file References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> Message-ID: <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> On Jan 31, 4:43?pm, Terry Reedy wrote: > On 1/31/2012 3:20 PM, John Roth wrote: > > > On Jan 30, 3:43 pm, Terry Reedy ?wrote: > >> On 1/30/2012 4:30 PM, Roy Smith wrote: > > >>> Every so often (typically when refactoring), I'll remove a .py file > >>> and forget to remove the corresponding .pyc file. ?If I then import > >>> the module, python finds the orphaned .pyc and happily imports it. > >>> Usually leading to confusing and hard to debug failures. > > >>> Is there some way to globally tell python, "Never import a .pyc > >>> unless the corresponding .py file exits"? > > >> Upgrade to 3.2. > > I tested before writing this. The caveat is that x.pyc in the same > directly as x.py will not be ignored (for back compatibility). However, > this only happens intentionally as .pyc files are put in __pycache__/ > with name x..pyc, where is 'cpython-32' or something > similar for another version or implementation. > > > I've noticed that the tutorial (section 6.1.3) hasn't been updated for > > PEP 3147; there's no way of telling that this is the behavior from > > reading the tutorial. The development doc for 3.3 hasn't been updated > > either. > > You are right. An oversight. Thanks for noticing.http://bugs.python.org/issue13915 > Suggested rewrites are welcome. > > -- > Terry Jan Reedy I'll see if I can put a suggestion in the bug report. One other point: I'm unclear if a compiled module in the source directory would be named spam.pyc or spam.cpython-32.pyc. I'd think the latter to allow two versions of a compiled-only distribution. John Roth From void.of.time at gmail.com Wed Feb 1 09:15:22 2012 From: void.of.time at gmail.com (oleg korenevich) Date: Wed, 1 Feb 2012 06:15:22 -0800 (PST) Subject: python reliability with EINTR handling in general modules Message-ID: I have linux board on samsung SoC s3c6410 (ARM11). I build rootfs with buildroot: Python 2.7.1, uClibc-0.9.31. Linux kernel: Linux buildroot 2.6.28.6 #177 Mon Oct 3 12:50:57 EEST 2011 armv6l GNU/Linux My app, written on python, in some mysterios conditons raise this exceptions: 1) exception: File "./dfbUtils.py", line 3209, in setItemData ValueError: (4, 'Interrupted system call') code: currentPage=int(math.floor(float(rowId)/ self.pageSize))==self.selectedPage 2) exception: File "./terminalGlobals.py", line 943, in getFirmawareName OSError: [Errno 4] Interrupted system call: 'firmware' code: for fileName in os.listdir('firmware'): Some info about app: it have 3-7 threads, listen serial ports via 'serial' module, use gui implemented via c extension that wrap directfb, i can't reproduce this exceptions, they are not predictable. I googled for EINTR exceptions in python, but only found that EINTR can occur only on slow system calls and python's modules socket, subprocess and another one is already process EINTR. So what happens in my app? Why simple call of math function can interrupt program at any time, it's not reliable at all. I have only suggestions: ulibc bug, kernel/hw handling bug. But this suggestions don't show me solution. Now i created wrap functions (that restart opertion in case of EINTR) around some functions from os module, but wrapping math module will increase execution time in 2 times. There another question: if math can be interrutped than other module also can and how to get reliability? From trustsolutionsteam at gmail.com Wed Feb 1 09:22:31 2012 From: trustsolutionsteam at gmail.com (solutions team) Date: Wed, 1 Feb 2012 06:22:31 -0800 (PST) Subject: solutions manual books Message-ID: trust solutions team trustsolutionsteam(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: t r u s t s o l u t i o n s t e a m @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on trustsolutionsteam at hotmail.com From p.f.moore at gmail.com Wed Feb 1 10:09:02 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 1 Feb 2012 07:09:02 -0800 (PST) Subject: Registry entries set up by the Windows installer Message-ID: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> I'm trying to get information on what registry entries are set up by the Python Windows installer, and what variations exist. I don't know enough about MSI to easily read the source, so I'm hoping someone who knows can help :-) As far as I can see on my PC, the installer puts entries HKLM\Software\Python\PythonCore\x.y with various bits underneath. I think I've seen indications that sometimes these are in HKCU, presumably for a "per user" install? If I manually hack around in the registry, and have both HKLM and HKCU, which one will Python use? Furthermore, more of a Windows question than Python, but there's a similar question with regard to the .py and .pyw file associations - they can be in HKLM\Software\Classes or HKCU\Software\Classes. Which takes precedence? I assume that the installer writes to HKLM for all users and HKCU for per-user installs. Is there anything else I've missed? The reason I ask, is that I'm starting to work with virtualenv, and I want to see what would be involved in (re-)setting the registry entries to match the currently active virtualenv. virtualenvwrapper- powershell seems to only deal with HKCU (which is a big plus on Windows 7, as it avoids endless elevation requests :-)) but that doesn't work completely cleanly with my all-users install. (Note: I'm not entirely sure that changing global settings like this to patch a per-console virtualenv is a good idea, but I'd like to know how hard it is before dismissing it...) Thanks, Paul. From franck at ditter.org Wed Feb 1 10:17:39 2012 From: franck at ditter.org (Franck Ditter) Date: Wed, 01 Feb 2012 16:17:39 +0100 Subject: Buffering in Wing and IDLE 3 Message-ID: Hi, I'm using Python 3.2.x with beginners. If I try the following in IDLE 3, it works as expected : from time import sleep import sys for i in range(4) : sys.stdout.write(str(i)) sys.stdout.flush() sleep(1) but with Wing-101, it write 0123 after the total sleep time. Why ??? I would prefer to use IDLE but as we are in France, the Python team does not seem to be aware that the ~ and others are not available on MacOS-X here (probably the same in Europe)... franck From torriem at gmail.com Wed Feb 1 10:46:34 2012 From: torriem at gmail.com (Michael Torrie) Date: Wed, 01 Feb 2012 08:46:34 -0700 Subject: python zipfile v. native unzip In-Reply-To: References: Message-ID: <4F295E5A.8010807@gmail.com> On 01/31/2012 06:41 AM, Jason Friedman wrote: > Does Python 2.7's zipfile module use its own algorithm or does it > leverage the zip/unzip libraries that exist on the host? I ask > because my host's native unzip program cannot handle files that, when > unzipped, are larger than 2GB. Will using Python 2.7 get around this > limitation? What operating system and file system? From ulrich.eckhardt at dominolaser.com Wed Feb 1 11:03:19 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 01 Feb 2012 17:03:19 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Am 01.02.2012 10:32, schrieb Peter Otten: > It doesn't matter for the OP (see Stefan Behnel's post), but If you want to > replace characters in a unicode string the best way is probably the > translate() method: > >>>> print u"\xa9\u2122" > ?? >>>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) > u'©™' > Yes, this is both more expressive and at the same time probably even more efficient. Question though: >>> u'abc'.translate({u'a': u'A'}) u'abc' I would call this a chance to improve Python. According to the documentation, using a string is invalid, but it neither raises an exception nor does it do the obvious and accept single-character strings as keys. Thoughts? Uli From andrea.crotti.0 at gmail.com Wed Feb 1 11:15:05 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 16:15:05 +0000 Subject: changing sys.path Message-ID: <4F296509.60607@gmail.com> So suppose I want to modify the sys.path on the fly before running some code which imports from one of the modules added. at run time I do sys.path.extend(paths_to_add) but it still doesn't work and I get an import error. If I take these paths and add them to site-packages/my_paths.pth everything works, but at run-time the paths which I actually see before importing are exactly the same. So there is something I guess that depends on the order, but what can I reset/reload to make these paths available (I thought I didn't need anything in theory)? From hansmu at xs4all.nl Wed Feb 1 11:49:57 2012 From: hansmu at xs4all.nl (Hans Mulder) Date: Wed, 01 Feb 2012 17:49:57 +0100 Subject: Installing pypi package twice In-Reply-To: References: Message-ID: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> On 1/02/12 07:04:31, Jason Friedman wrote: > My system's default python is 2.6.5. I have also installed python3.2 > at /opt/python. > I installed a pypi package for 2.6.5 with: > $ tar xzf package.tar.gz > $ cd package > $ python setup.py build > $ sudo python setup.py install > > How can I also install this same package for 3.2? (I am assuming this > package works with 3.2 or that I can make it work.) How about (in another directory): $ tar xzf package.tar.gz $ cd package $ /opt/python/bin/python setup.py build $ sudo /opt/python/bin/python setup.py install This assumes that /opt/python/bin/python is your python3.2 executable. You may want to insert some testing between the 'build' and 'install' steps. Or you could try: $ /opt/python/bin/python -m compileall build/lib That would try to compile all Python files in the subdirectory to byte code. That's likely to fail if the Python code is not valid Python 3. If it compiles, you may still want to do some testing. Hope this helps, -- HansM From katie.clark at yale.edu Wed Feb 1 11:53:41 2012 From: katie.clark at yale.edu (Clark, Kathleen) Date: Wed, 1 Feb 2012 16:53:41 +0000 Subject: TypeError Message-ID: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Hello, I am new to python and am trying to correct the follow error: TypeError: sequence item 1: expected string, NoneType found The error message is referencing line 86 of my code: ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) If I'm understanding this correctly, the code is expecting a string, but not finding it. I'm wondering, what is meant by a "string" and also how I can figure out the problem and correct it. If anyone could help me understand what the error is and needs to be done to correct it, I think I might be able to fill in the blanks. Thanks, Katie ______________________________________________________________________ [logo for email] Katie Clark Research Assistant SHARRPP 60 Temple Street, Suite 4D New Haven, CT 06510 203-737-7425 katie.clark at yale.edu www.sharrpp.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 3264 bytes Desc: image002.jpg URL: From andrea.crotti.0 at gmail.com Wed Feb 1 11:54:52 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 16:54:52 +0000 Subject: Installing pypi package twice In-Reply-To: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> References: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> Message-ID: <4F296E5C.8000103@gmail.com> On 02/01/2012 04:49 PM, Hans Mulder wrote: > > How about (in another directory): > > $ tar xzf package.tar.gz > $ cd package > $ /opt/python/bin/python setup.py build > $ sudo /opt/python/bin/python setup.py install > > This assumes that /opt/python/bin/python is your python3.2 executable. > > You may want to insert some testing between the 'build' and 'install' > steps. Or you could try: > > $ /opt/python/bin/python -m compileall build/lib > > That would try to compile all Python files in the subdirectory to byte > code. That's likely to fail if the Python code is not valid Python 3. > If it compiles, you may still want to do some testing. > > Hope this helps, > > -- HansM That works, but it's probably easier to (depending on your needs): - install easy_install / pip for that python version - use virtualenv From wxjmfauth at gmail.com Wed Feb 1 12:06:40 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 1 Feb 2012 09:06:40 -0800 (PST) Subject: changing sys.path References: Message-ID: <5b9ced23-b316-44d1-9d69-b12643a873da@c6g2000vbk.googlegroups.com> On 1 f?v, 17:15, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these paths and add them to site-packages/my_paths.pth > everything works, but at run-time the paths which I actually see before > importing are exactly the same. > > So there is something I guess that depends on the order, but what can I > reset/reload to make these paths available (I thought I didn't need > anything in theory)? >>> import mod Traceback (most recent call last): File "", line 1, in ImportError: No module named mod >>> sys.path.append(r'd:\\jm\\junk') >>> import mod >>> mod >>> mod.hello() fct hello in mod.py sys.path? Probably, the most genious Python idea. jmf From diolu at bigfoot.com Wed Feb 1 12:11:17 2012 From: diolu at bigfoot.com (Olive) Date: Wed, 1 Feb 2012 18:11:17 +0100 Subject: Question about name scope Message-ID: <20120201181117.5d35dddc@bigfoot.com> I am learning python and maybe this is obvious but I have not been able to see a solution. What I would like to do is to be able to execute a function within the namespace I would have obtained with from import * For example if I write: def f(a): return sin(a)+cos(a) I could then do: from math import * f(5) But I have polluted my global namespace with all what's defined in math. I would like to be able to do something like "from math import *" at the f level alone. The main reason for this is the sympy module for CAS (computer algebra). It reimplement a lot of functions and define all the letters as symbolic variables. Writing sympy. everywhere is inconvenient. Importing all the symbols in the global namespace would lead to name clash. It would be nice if I could import all the sympy names but for a given function only. Olive From d at davea.name Wed Feb 1 12:15:18 2012 From: d at davea.name (Dave Angel) Date: Wed, 01 Feb 2012 12:15:18 -0500 Subject: TypeError In-Reply-To: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> References: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Message-ID: <4F297326.9060907@davea.name> On 02/01/2012 11:53 AM, Clark, Kathleen wrote: > Hello, Which python version, what operating system. Doesn't cost much to specify, and can frequently be relevant. > > I am new to python and am trying to correct the follow error: > > TypeError: sequence item 1: expected string, NoneType found > That's not an error message, it's just the last line of one. Please use copy/paste to post the entire traceback into your query. > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) > And this couldn't be simplified? The sample is not runnable, so we have to make up a wrapper program to define at least 6 variables, and then execute this line? > If I'm understanding this correctly, the code Which code? > is expecting a string, but not finding it. I'm wondering, what is meant by a "string" and also how I can figure out the problem and correct it. > > If anyone could help me understand what the error is and needs to be done to correct it, I think I might be able to fill in the blanks. > > Thanks, > > Katie > > If I guess you're running Python 2.7 on Linux 11.04, I could try the following: >>> ino = 4 >>> fn = None >>> ln = 12 >>> sdobj = object() >>> '.'.join([str(ino), fn, ln, sdobj) File "", line 1 '.'.join([str(ino), fn, ln, sdobj) ^ SyntaxError: invalid syntax >>> '.'.join([str(ino), fn, ln, sdobj]) Traceback (most recent call last): File "", line 1, in TypeError: sequence item 1: expected string, NoneType found >>> If this matches your circumstance, the problem is that fn has a value of None. You could have guessed this by simply tucking some print statements right in front of the offending line, displaying all six variables, and seeing which is of type NoneType. So now you have to figure out how fn got that value. (please don't post graphic attachments to your message, this is a text mailing list) -- DaveA From rantingrickjohnson at gmail.com Wed Feb 1 12:17:04 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 09:17:04 -0800 (PST) Subject: changing sys.path References: Message-ID: On Feb 1, 10:15?am, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these paths and add them to site-packages/my_paths.pth > everything works, but at run-time the paths which I actually see before > importing are exactly the same. 1. Is paths_to_add a nested list? 2. Have you tried inspecting the contents of sys.path AFTER calling extend method? Consider: py> sys.path.__len__() 14 py> sys.path.extend([[1,2,3]]) py> sys.path.__len__() 15 From rantingrickjohnson at gmail.com Wed Feb 1 12:21:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 09:21:22 -0800 (PST) Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <2f7095cd-12ad-4031-9ebe-0c54ee3ad9c9@p13g2000yqd.googlegroups.com> On Feb 1, 11:11?am, Olive wrote: > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. Seeing is believing! >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> from math import * >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc'] >>> ================================ RESTART ================================ >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> from math import sin, cos >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'cos', 'sin'] >>> From nicholas.dokos at hp.com Wed Feb 1 12:27:47 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Wed, 01 Feb 2012 12:27:47 -0500 Subject: TypeError In-Reply-To: Message from "Clark\, Kathleen" of "Wed\, 01 Feb 2012 16\:53\:41 GMT." <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> References: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Message-ID: <2584.1328117267@alphaville> Clark, Kathleen wrote: > TypeError: sequence item 1: expected string, NoneType found > > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) > > If I?m understanding this correctly, the code is expecting a string, but not finding it. I?m > wondering, what is meant by a ?string? and also how I can figure out the problem and correct it. I'd guess that the sequence in question is the list that's the argument of join(), in which case item 1 is fn: it should be a string but for some reason, it is a None value: ,---- | >>> ','.join([str(45), None, "bar", "foo"]) | Traceback (most recent call last): | File "", line 1, in | TypeError: sequence item 1: expected string, NoneType found |>>> ','.join([str(45), "a string", "bar", "foo"]) |'45,a string,bar,foo' `---- Nick From ckaynor at zindagigames.com Wed Feb 1 12:28:06 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 1 Feb 2012 09:28:06 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 9:11 AM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. > The standard way would be to just do: import math def f(a): return math.sin(a)+math.cos(a) What this does is import the module math into the current module namespace, then access attributes on that module. > > Olive > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Wed Feb 1 12:36:36 2012 From: d at davea.name (Dave Angel) Date: Wed, 01 Feb 2012 12:36:36 -0500 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F297824.1000202@davea.name> On 02/01/2012 12:11 PM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. > > Olive > > Start by specifying python version and operating system. I tried your experiment using Python 2.7 and Linux 11.04 def f(a): from math import sin, cos return sin(a) + cos(a) print f(45) Does what you needed, and neatly. The only name added to the global namspace is f, of type function. I was a bit surprised that using from math import * inside the function worked, but it generates a warning: olive.py:2: SyntaxWarning: import * only allowed at module level def f(a): I normally avoid any use of the "from XX import *" form, as it pollutes the global name space. The only exception is when a library writer documents that this is the "normal" way to interface to it. In this case, he usually defines just a few things that are visible this way) What I do is put a single import math at the top of my source file, and use math.sin, and math.cos where needed. Occasionally, I'll use something like: from math import sin,cos at the top, so I know just which symbols I'm defining. How about: import math def f(a): sin = math.sin cos = math.cos return sin(a) + cos(a) print f(45) This lets you explicitly use the sin and cos names inside the function, by defining them at entry to the function. -- DaveA From clp2 at rebertia.com Wed Feb 1 12:38:59 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 1 Feb 2012 09:38:59 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 9:11 AM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with ?from > import * > > For example if I write: > > def f(a): > ? ? ? ?return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. Don't think that's possible. Best alternative I can think of would be: import sympy as s def f(a): return s.sin(a) + s.cos(a) Cheers, Chris From ethan at stoneleaf.us Wed Feb 1 12:43:14 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 09:43:14 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F2979B2.6070804@stoneleaf.us> Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. If you are using Python 2.x you can do: def f(a): from sympy import * return a(a) + d(a) Python 3 does not allow * imports in functions, however, so you would need to do: def f(a): from sympy import a,b,c,d,e,f,g,h,i,j,k,l,m from sympy import n,o,p,q,r,s,t,u,v,w,x,y,z return z(a) / f(a) + o(a) Obviously, only import the functions you are actually going to use. ;) ~Ethan~ From andrea.crotti.0 at gmail.com Wed Feb 1 12:47:22 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 17:47:22 +0000 Subject: changing sys.path In-Reply-To: References: <4F296509.60607@gmail.com> Message-ID: <4F297AAA.8090600@gmail.com> On 02/01/2012 05:13 PM, Eric Snow wrote: > On Wed, Feb 1, 2012 at 9:15 AM, Andrea Crotti wrote: >> So suppose I want to modify the sys.path on the fly before running some code >> which imports from one of the modules added. >> >> at run time I do >> sys.path.extend(paths_to_add) >> >> but it still doesn't work and I get an import error. > Make sure you are adding to sys.path the directories that your > packages/modules are in, and not the actual package directories. > During import Python looks for modules/packages _in_ each of the > directories on sys.path, but not _at_ those directories. Yes sure I do this.. > >> If I take these paths and add them to site-packages/my_paths.pth >> everything works, but at run-time the paths which I actually see before >> importing are exactly the same. > You mean sys.path looks exactly the same in the two cases? > > -eric Yes they are exactly the same, because in that file I just write exactly the same list, but when modifying it at run-time it doesn't work, while if at the application start there is this file everything works correctly... That's what really puzzles me.. What could that be then? From lists at cheimes.de Wed Feb 1 12:50:53 2012 From: lists at cheimes.de (Christian Heimes) Date: Wed, 01 Feb 2012 18:50:53 +0100 Subject: Question about name scope In-Reply-To: <4F297824.1000202@davea.name> References: <20120201181117.5d35dddc@bigfoot.com> <4F297824.1000202@davea.name> Message-ID: Am 01.02.2012 18:36, schrieb Dave Angel: > def f(a): > from math import sin, cos > return sin(a) + cos(a) > > print f(45) > > Does what you needed, and neatly. The only name added to the global > namspace is f, of type function. I recommend against this approach. It's slightly slower and the global import lock will cause trouble if you start using threads. Christian From python.list at tim.thechases.com Wed Feb 1 13:03:38 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 01 Feb 2012 12:03:38 -0600 Subject: python zipfile v. native unzip In-Reply-To: References: Message-ID: <4F297E7A.6040808@tim.thechases.com> On 01/31/12 07:41, Jason Friedman wrote: > Does Python 2.7's zipfile module use its own algorithm or does it > leverage the zip/unzip libraries that exist on the host? I ask > because my host's native unzip program cannot handle files that, when > unzipped, are larger than 2GB. Will using Python 2.7 get around this > limitation? According to: http://hg.python.org/cpython/file/5395f96588d4/Lib/zipfile.py#l669 I'm guessing that the ZIP64_LIMIT references the 2GB limit, and Python's zipfile module requires you to instantiate with zf = ZipFile(..., allosZip64=True) The ZIP64_LIMIT = (1 << 31) - 1 which is 2GB. It appears this was added in revision fd412a00a07d: Patch #1446489 (zipfile: support for ZIP64) which seems to have been implemented back in at least Python 2.5. -tkc From Tim.Arnold at sas.com Wed Feb 1 13:15:09 2012 From: Tim.Arnold at sas.com (Tim Arnold) Date: Wed, 01 Feb 2012 13:15:09 -0500 Subject: xhtml encoding question In-Reply-To: References: Message-ID: On 2/1/2012 3:26 AM, Stefan Behnel wrote: > Tim Arnold, 31.01.2012 19:09: >> I have to follow a specification for producing xhtml files. >> The original files are in cp1252 encoding and I must reencode them to utf-8. >> Also, I have to replace certain characters with html entities. >> --------------------------------- >> import codecs, StringIO >> from lxml import etree >> high_chars = { >> 0x2014:'—', # 'EM DASH', >> 0x2013:'–', # 'EN DASH', >> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >> 0x2122:'™', # 'TRADE MARK SIGN', >> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >> } >> def translate(string): >> s = '' >> for c in string: >> if ord(c) in high_chars: >> c = high_chars.get(ord(c)) >> s += c >> return s > > I hope you are aware that this is about the slowest possible algorithm > (well, the slowest one that doesn't do anything unnecessary). Since none of > this is required when parsing or generating XHTML, I assume your spec tells > you that you should do these replacements? > I wasn't aware of it, but I am now--code's embarassing now. The spec I must follow forces me to do the translation. I am actually working with html not xhtml; which makes a huge difference, sorry for that. Ulrich's line of code for translate is elegant. for c in string: s += high_chars.get(c,c) > >> def reencode(filename, in_encoding='cp1252',out_encoding='utf-8'): >> with codecs.open(filename,encoding=in_encoding) as f: >> s = f.read() >> sio = StringIO.StringIO(translate(s)) >> parser = etree.HTMLParser(encoding=in_encoding) >> tree = etree.parse(sio, parser) > > Yes, you are doing something dangerous and wrong here. For one, you are > decoding the data twice. Then, didn't you say XHTML? Why do you use the > HTML parser to parse XML? > I see that I'm decoding twice now, thanks. Also, I now see that when lxml writes the result back out the entities I got from my translate function are resolved, which defeats the whole purpose. > >> result = etree.tostring(tree.getroot(), method='html', >> pretty_print=True, >> encoding=out_encoding) >> with open(filename,'wb') as f: >> f.write(result) > > Use tree.write(f, ...) From the all the info I've received on this thread, plus some additional reading, I think I need the following code. Use the HTMLParser because the source files are actually HTML, and use output from etree.tostring() as input to translate() as the very last step. def reencode(filename, in_encoding='cp1252', out_encoding='utf-8'): parser = etree.HTMLParser(encoding=in_encoding) tree = etree.parse(filename, parser) result = etree.tostring(tree.getroot(), method='html', pretty_print=True, encoding=out_encoding) with open(filename, 'wb') as f: f.write(translate(result)) not simply tree.write(f...) because I have to do the translation at the end, so I get the entities instead of the resolved entities from lxml. Again, it would be simpler if this was xhtml, but I misspoke (mis-wrote?) when I said xhtml; this is for html. > Assuming you really meant XHTML and not HTML, I'd just drop your entire > code and do this instead: > > tree = etree.parse(in_path) > tree.write(out_path, encoding='utf8', pretty_print=True) > > Note that I didn't provide an input encoding. XML is safe in that regard. > > Stefan > thanks everyone for the help. --Tim Arnold From jenn.turliuk at gmail.com Wed Feb 1 13:38:05 2012 From: jenn.turliuk at gmail.com (Jennifer Turliuk) Date: Wed, 1 Feb 2012 10:38:05 -0800 (PST) Subject: Startup Chile Company Looking For Founding Developer/CTO Message-ID: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> Hi everyone, My name is Jennifer Turliuk. I'm currently in Santiago, Chile for the next 6 months as part of the Startup Chile program. I think you may be able to help me out. We are looking to bring on a developer ASAP (see description below). If you are interested, we'd love to hear from you. Or, if you know of anyone that may be interested, we'd be very grateful if you would pass this along. Thanks in advance, and I look forward to hearing from you. Regards, Jenn *Startup Chile Company Looking for Founding Developer/CTO* We?re building a highly curated online marketplace where people can find others to exchange skills with on a one-to-one, offline basis. We?re looking for a full-time founding developer/CTO to join us, starting with the first 6 months in Santiago, Chile as part of the Startup Chile program. *About Us*: - Selected for Startup Chile program (alumni: Cruisewise, Gym-pact) - Secured seed funding - Finalist in competition to shadow Dave McClure (500 Startups) - Spoke on stage with Peter Thiel - First website was featured in magazine at age 13 - Top sales associate in one of N.A.?s most aggressive sales environments - Publicity stunt garnered $4MM in media coverage in 24hrs - Attended the Oscars & Grammys - Member of exclusive kiteboarding group with CEOs of Dropbox, Scribd, Gowalla, etc. *About the Role*: - Build an AirBnB for skills-exchanges, where people can list skills that they can offer and want to learn (e.g. if they want to learn Spanish and can teach programming, they can find people to exchange with via trade or money) - Create a new sharing economy where time is the currency - Join a tight team that is serious about winning but also has a great time - Opportunity to build a team and manage others as we grow - Flexible compensation includes flights to South America, accommodation, salary, and equity. *About You*: - Comfortable with backend work, particularly working with databases and keeping an eye on application performance - Excited by challenges and the flexibility of a consumer-facing web startup - A deep-seated love of efficient/elegant Python, Ruby, Node.js or Django (front-end knowledge is also helpful) - Passionate about the business idea - Able to relocate to Santiago, Chile for 6 months fairly quickly. Contact us at jenn.turliuk at gmail.com by February 1st. From katie.clark at yale.edu Wed Feb 1 13:46:51 2012 From: katie.clark at yale.edu (Clark, Kathleen) Date: Wed, 1 Feb 2012 18:46:51 +0000 Subject: TypeError Message-ID: <0610E9FC98B37742AD184612801101F834B100@x10-mbx4.yu.yale.edu> Hello and thank you for all responses. I have resolved my problem. Turned out that one of the files was missing "fn" and after deleting the record, the program ran just fine. Thanks again, Katie -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwilson at the-wire.com Wed Feb 1 13:47:57 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Wed, 01 Feb 2012 13:47:57 -0500 Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: Dave Angel wrote: > I tried your experiment using Python 2.7 and Linux 11.04 > > > def f(a): > from math import sin, cos > return sin(a) + cos(a) > > print f(45) > > Does what you needed, and neatly. The only name added to the global > namspace is f, of type function. > > I was a bit surprised that using from math import * inside the > function worked, but it generates a warning: > olive.py:2: SyntaxWarning: import * only allowed at module level > def f(a): I guess they want local symbols in functions to be pre-compiled. Similar to the way you can't usefully update the dict returned by locals(). Strangely, I notice that Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(x): ... exec x ... exec 'print a' ... >>> f('a=4') 4 >>> works, but I really cannot explain why. Mel. From fabiofz at gmail.com Wed Feb 1 14:43:12 2012 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 1 Feb 2012 17:43:12 -0200 Subject: PyDev 2.4.0 Released Message-ID: Hi All, PyDev 2.4.0 has been released Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- PyDev is now faster and uses less memory (many performance and memory improvements were done)! The contents of the homepage are now migrated to a wiki at https://wiki.appcelerator.org/display/tis/Python+Development ... (later most of the homepage will become a mirror of the wiki). Others * Organize imports: Fixed issue where other statements in a commit line got lost (now such a line is ignored). * PyDev Package Explorer: closed project no longer remains with old icons. * Fixed deadlock when setting project as Django. * Fixed issue in code formatting *args on lambda statement. * TODO tags: only searched now in a string/comment partition. * Fixed issue when saving empty document (bad location on code-formatter). * Fixed issue removing comments from document. * Applied patch for internal Jython 2.2.1 to fix list.sort (http://bugs.jython.org/issue1835099). * Fixed resolution of template variable prev_class_or_method and next_class_or_method. What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Appcelerator http://appcelerator.com/ Aptana http://aptana.com/ PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From tjreedy at udel.edu Wed Feb 1 14:53:39 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 14:53:39 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/1/2012 6:14 AM, Devin Jeanpierre wrote: > It really bothers me that you imagine that there are no other problems > than the newness. And it bothers me that you imput such ignorance to me. You made what I think was a bad analogy and I made a better one of the same type, though still imperfect. I acknowledged that the transition will take years. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 1 14:57:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 14:57:11 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> Message-ID: On 2/1/2012 8:11 AM, John Roth wrote: > One other point: I'm unclear if a compiled module in the source > directory would be named spam.pyc or spam.cpython-32.pyc. I'd think > the latter to allow two versions of a compiled-only distribution. By test, it has to be spam.pyc, as before. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 1 15:01:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 15:01:40 -0500 Subject: Buffering in Wing and IDLE 3 In-Reply-To: References: Message-ID: On 2/1/2012 10:17 AM, Franck Ditter wrote: > I would prefer to use IDLE but as we are in France, the Python team > does not seem to be aware that the ~ and others are not available > on MacOS-X here (probably the same in Europe)... We are quite aware of the problem but cannot directly do anything about it as the problem is with tcl/tk and Apple. A couple of days ago, Kevin Walzer wrote on an IDLE-sig post "I'm currently reviewing an updated patch to address the problem. When I commit the patch, it will go into both Tk's trunk and in the Cocoa 8.5 backport, and eventually be available through ActiveState's distribution." -- Terry Jan Reedy From timothy.c.delaney at gmail.com Wed Feb 1 15:24:07 2012 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Thu, 2 Feb 2012 07:24:07 +1100 Subject: changing sys.path In-Reply-To: <4F297AAA.8090600@gmail.com> References: <4F296509.60607@gmail.com> <4F297AAA.8090600@gmail.com> Message-ID: On 2 February 2012 04:47, Andrea Crotti wrote: > > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That's what really puzzles me.. What could that be then? Post the actual code, plus traceback. We cannot help you without it. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From rowen at uw.edu Wed Feb 1 16:00:39 2012 From: rowen at uw.edu (Russell E. Owen) Date: Wed, 01 Feb 2012 13:00:39 -0800 Subject: Generator problem: parent class not seen Message-ID: I have an odd and very intermittent problem in Python script. Occasionally it fails with this error: Traceback (most recent call last): File "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas eFocusScript.py", line 884, in run File "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas eFocusScript.py", line 1690, in initAll TypeError: unbound method initAll() must be called with BaseFocusScript instance as first argument (got ScriptClass instance instead) self=; class hierarchy=[(, (,)), [(, (,))]] The code looks like this: def run(self, sr): try: self.initAll() .... except Exception: traceback.print_exc(file=sys.stderr) sys.stderr.write("self=%r; class hierarchy=%s\n" % (self, inspect.getclasstree([type(self)]))) raise As a detail that may be important: the code is a generator that is being run by a script runner class (an instance of which is passed into the run function as argument sr). When the user starts a script the script runner calls the script's "run" generator. The script runner calls the run generator again later when conditions are right (e.g. data that is being waited for arrives, a time limit is reached...). In this case the failure occurs at the very start of the script, so a yield has not yet executed. I am puzzled why Python thinks the class type is wrong, given the output of inspect.getclasstree. Any ideas on what might be wrong and how to track it down (and why it would be so intermittent)? -- Russell From isaacrc82 at gmail.com Wed Feb 1 16:24:25 2012 From: isaacrc82 at gmail.com (Ariel) Date: Wed, 1 Feb 2012 16:24:25 -0500 Subject: Problem sending an email in html with mime image Message-ID: Hi everybody I have a question, here is my problem I want to send an email with content in html with an image embed so I converted the image binary in mime text and then I put the mime code inside the src attribute of the html like this: Then I send the email, here is my code: from django.template.loader import render_to_string from django.core.mail.message import EmailMultiAlternatives contextcopy = {} message = render_to_string('bulletin.html', contextcopy) subject = "TEST" msg = EmailMultiAlternatives(subject, message, from_email,['myemail at gmail.com'']) msg.attach_alternative(message, "text/html") msg.send() The problem is that if I don't put the image mime code inside the src the email is sent but when I put the code then the email is not send and I don't get any error message. Could somebody please, help me ??? Why the email is not send when I put the mime code of the image in the html ??? Regards, Ariel From gafunchal at gmail.com Wed Feb 1 16:24:44 2012 From: gafunchal at gmail.com (Giovanni Funchal) Date: Wed, 1 Feb 2012 21:24:44 +0000 Subject: Patching CGIHTTPServer.py In-Reply-To: <30772597.282.1327766678735.JavaMail.geo-discussion-forums@yqjk7> References: <30772597.282.1327766678735.JavaMail.geo-discussion-forums@yqjk7> Message-ID: Wow, that's very flattering :-) I've opened an item in the python bug tracker for this enhancement and attached my patch, let's see how it goes. Thanks, -- Giovanni On Sat, Jan 28, 2012 at 4:04 PM, Miki Tebeka wrote: > IMO the code is good enough to submit a patch. > -- > http://mail.python.org/mailman/listinfo/python-list From businessmother at hotmail.com Wed Feb 1 16:41:04 2012 From: businessmother at hotmail.com (businessmother at hotmail.com) Date: Wed, 1 Feb 2012 13:41:04 -0800 (PST) Subject: Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Message-ID: <749d23dc-49f4-4248-a57e-2a372813cf3e@b23g2000yqn.googlegroups.com> Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Wanted Online Internet job workers. Job is only through Internet. Work from home part time jobs. You can earn $1500-2500/month working 1-2 hours/day, no matter where you live. These are genuine Data entry jobs & Internet jobs. No Investment required. Only serious enquires please. For more details visit http://www.earnparttimejobs.com/index.php?id=3677959 From businessmother at hotmail.com Wed Feb 1 16:45:01 2012 From: businessmother at hotmail.com (businessmother at hotmail.com) Date: Wed, 1 Feb 2012 13:45:01 -0800 (PST) Subject: Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Message-ID: <2faaf440-f89a-4121-a3f5-d8ea0d8f0f74@o20g2000yqh.googlegroups.com> Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Wanted Online Internet job workers. Job is only through Internet. Work from home part time jobs. You can earn $1500-2500/month working 1-2 hours/day, no matter where you live. These are genuine Data entry jobs & Internet jobs. No Investment required. Only serious enquires please. For more details visit http://www.earnparttimejobs.com/index.php?id=3677959 From ian.g.kelly at gmail.com Wed Feb 1 16:49:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 14:49:52 -0700 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 11:47 AM, Mel Wilson wrote: > I guess they want local symbols in functions to be pre-compiled. ?Similar to > the way you can't usefully update the dict returned by locals(). ?Strangely, > I notice that > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(x): > ... ? exec x > ... ? exec 'print a' > ... >>>> f('a=4') > 4 >>>> > > works, but I really cannot explain why. I am not a dev, but I believe it works because assigning to locals() and assigning via exec are not the same thing. The problem with assigning to locals() is that you're fundamentally just setting a value in a dictionary, and even though it happens to be the locals dict for the stack frame, Python can't figure out that it should go and update the value of the optimized local to match. exec, on the other hand, compiles and executes an actual STORE_NAME operation. Of course, if the particular local variable hasn't been optimized by the compiler, then updating locals() works just fine (although you probably should not rely on this): >>> def f(x, y): ... locals()[x] = y ... print locals()[x] ... exec 'print ' + x ... >>> f('a', 42) 42 42 Another interesting thing to note is that the print in your example doesn't even need to be in a second exec, which I believe works because the presence of any exec statement disables global variable optimizations for the function. Compare: >>> def f(x): ... locals()['a'] = 4 ... print a ... >>> f('pass') Traceback (most recent call last): File "", line 1, in File "", line 3, in f NameError: global name 'a' is not defined >>> def f(x): ... locals()['a'] = 4 ... print a ... exec x ... >>> f('pass') 4 And while we're on the subject, here's a nicely obscure syntax error: >>> def f(x): ... def g(): ... print x ... exec x ... File "", line 4 SyntaxError: unqualified exec is not allowed in function 'f' it contains a nested function with free variables Cheers, Ian From ethan at stoneleaf.us Wed Feb 1 17:24:28 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 14:24:28 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F29BB9C.70405@stoneleaf.us> Ian Kelly wrote: > I am not a dev, but I believe it works because assigning to locals() > and assigning via exec are not the same thing. The problem with > assigning to locals() is that you're fundamentally just setting a > value in a dictionary, and even though it happens to be the locals > dict for the stack frame, Python can't figure out that it should go > and update the value of the optimized local to match. exec, on the > other hand, compiles and executes an actual STORE_NAME operation. Of > course, if the particular local variable hasn't been optimized by the > compiler, then updating locals() works just fine (although you > probably should not rely on this): > >>>> def f(x, y): > ... locals()[x] = y > ... print locals()[x] > ... exec 'print ' + x > ... >>>> f('a', 42) > 42 > 42 Definitely should rely on it, because in CPython 3 exec does not un-optimize the function and assigning to locals() will not actually change the functions variables. ~Ethan~ From crebert at ucsd.edu Wed Feb 1 17:34:45 2012 From: crebert at ucsd.edu (Chris Rebert) Date: Wed, 1 Feb 2012 14:34:45 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen wrote: > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > ?File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > ?File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > The code looks like this: > > ? ?def run(self, sr): > ? ? ? ?try: > ? ? ? ? ? ?self.initAll() > I am puzzled why Python thinks the class type is wrong, given the output > of inspect.getclasstree. Any ideas on what might be wrong and how to > track it down (and why it would be so intermittent)? What's the offending line of initAll() [#1690 in BaseFocusScript.py] look like? The lines preceding it would also be helpful for context. Cheers, Chris From ian.g.kelly at gmail.com Wed Feb 1 17:38:17 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 15:38:17 -0700 Subject: Question about name scope In-Reply-To: <4F29BB9C.70405@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote: > Definitely should rely on it, because in CPython 3 exec does not un-optimize > the function and assigning to locals() will not actually change the > functions variables. Well, the former is not surprising, since exec was changed from a statement to a built-in. I don't see any difference in the way locals() behaves, though: Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(x, y): ... locals()[x] = y ... print(vars()) ... exec('print(' + x + ')') ... >>> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} 42 That still seems to work as I described it. You couldn't directly reference it as 'a', though, since the result would be either that it would try to look up a global with that name, or the compiler would consider it a local, optimize it, and then you could no longer assign it via locals(). Cheers, Ian From rowen at uw.edu Wed Feb 1 17:50:19 2012 From: rowen at uw.edu (Russell Owen) Date: Wed, 1 Feb 2012 14:50:19 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: <88469DEB-CF59-4C76-91DA-B056D68BAC09@uw.edu> On Feb 1, 2012, at 2:34 PM, Chris Rebert wrote: > On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen wrote: >> I have an odd and very intermittent problem in Python script. >> Occasionally it fails with this error: >> >> Traceback (most recent call last): >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 884, in run >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 1690, in initAll >> TypeError: unbound method initAll() must be called with BaseFocusScript >> instance as first argument (got ScriptClass instance instead) > >> The code looks like this: >> >> def run(self, sr): >> try: >> self.initAll() > >> I am puzzled why Python thinks the class type is wrong, given the output >> of inspect.getclasstree. Any ideas on what might be wrong and how to >> track it down (and why it would be so intermittent)? > > What's the offending line of initAll() [#1690 in BaseFocusScript.py] > look like? The lines preceding it would also be helpful for context. Here you go. The offending line #169 is marked with *** -- Russell class ImagerFocusScript(BaseFocusScript): """...""" def __init__(self, sr, instName, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, maxFindAmpl = None, doWindow = False, windowOrigin = 1, windowIsInclusive = True, doZeroOverscan = False, helpURL = None, debug = False, ): ... BaseFocusScript.__init__(self, sr = sr, gcamActor = gcamActor, instName = instName, imageViewerTLName = imageViewerTLName, defRadius = defRadius, defBinFactor = defBinFactor, maxFindAmpl = maxFindAmpl, doWindow = doWindow, windowOrigin = windowOrigin, windowIsInclusive = windowIsInclusive, helpURL = helpURL, debug = debug, ) self.doZeroOverscan = bool(doZeroOverscan) .... def initAll(self): """Override the default initAll to record initial bin factor, if relevant """ *** BaseFocusScript.initAll(self) if self.exposeModel.instInfo.numBin > 0: self.finalBinFactor = self.exposeModel.bin.getInd(0)[0] Also, here is BaseFocusScript: class BaseFocusScript(object): """Basic focus script object. This is a virtual base class. The inheritor must: - Provide widgets - Provide a "run" method """ cmd_Find = "find" cmd_Measure = "measure" cmd_Sweep = "sweep" # constants #DefRadius = 5.0 # centroid radius, in arcsec #NewStarRad = 2.0 # amount of star position change to be considered a new star DefFocusNPos = 5 # number of focus positions DefFocusRange = 200 # default focus range around current focus FocusWaitMS = 1000 # time to wait after every focus adjustment (ms) BacklashComp = 0 # amount of backlash compensation, in microns (0 for none) WinSizeMult = 2.5 # window radius = centroid radius * WinSizeMult FocGraphMargin = 5 # margin on graph for x axis limits, in um MaxFocSigmaFac = 0.5 # maximum allowed sigma of best fit focus as a multiple of focus range MinFocusIncr = 10 # minimum focus increment, in um def __init__(self, sr, gcamActor, instName, tccInstPrefix = None, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, finalBinFactor = None, canSetStarPos = True, maxFindAmpl = None, doWindow = True, windowOrigin = 0, windowIsInclusive = True, helpURL = None, debug = False, ): """....""" self.sr = sr self.sr.debug = bool(debug) self.gcamActor = gcamActor .... def initAll(self): """Initialize variables, table and graph. """ # initialize shared variables self.doTakeFinalImage = False self.focDir = None self.currBoreXYDeg = None self.begBoreXYDeg = None self.instScale = None self.arcsecPerPixel = None self.instCtr = None self.instLim = None self.cmdMode = None self.focPosToRestore = None self.expTime = None self.absStarPos = None self.relStarPos = None self.binFactor = None self.window = None # LL pixel is 0, UR pixel is included self.enableCmdBtns(False) From ethan at stoneleaf.us Wed Feb 1 17:53:09 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 14:53:09 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4F29C255.1050009@stoneleaf.us> Ian Kelly wrote: > On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote: >> Definitely should rely on it, because in CPython 3 exec does not un-optimize >> the function and assigning to locals() will not actually change the >> functions variables. > > Well, the former is not surprising, since exec was changed from a > statement to a built-in. I don't see any difference in the way > locals() behaves, though: > > Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(x, y): > ... locals()[x] = y > ... print(vars()) > ... exec('print(' + x + ')') > ... >>>> f('a', 42) > {'y': 42, 'x': 'a', 'a': 42} > 42 > > That still seems to work as I described it. You couldn't directly > reference it as 'a', though, since the result would be either that it > would try to look up a global with that name, or the compiler would > consider it a local, optimize it, and then you could no longer assign > it via locals(). > > Cheers, > Ian --> def f(x, y): ... locals()[x] = y ... print(vars()) ... exec('print (' + x + ')') ... print(x) ... --> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} 42 a Indeed -- the point to keep in mind is that locals() can become out of sync with the functions actual variables. Definitely falls in the camp of "if you don't know *exactly* what you are doing, do not play this way!" ~Ethan~ From ian.g.kelly at gmail.com Wed Feb 1 18:00:02 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 16:00:02 -0700 Subject: Question about name scope In-Reply-To: <4F29C255.1050009@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 3:53 PM, Ethan Furman wrote: > --> def f(x, y): > > ... ? ? locals()[x] = y > ... ? ? print(vars()) > ... ? ? exec('print (' + x + ')') > ... ? ? print(x) > ... > --> f('a', 42) > > {'y': 42, 'x': 'a', 'a': 42} > 42 > a > > Indeed -- the point to keep in mind is that locals() can become out of sync > with the functions actual variables. ?Definitely falls in the camp of "if > you don't know *exactly* what you are doing, do not play this way!" Sure, but that's not actually out of sync. The argument of your exec evaluates to 'print (a)'. You get two different results because you're actually printing two different variables. You can get the dict temporarily out of sync: >>> def f(x, y): ... frob = None ... loc = locals() ... loc[x] = y ... print(loc) ... print(locals()) ... print(loc) ... >>> f('frob', 42) {'y': 42, 'x': 'frob', 'frob': 42, 'loc': {...}} {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} In this case, 'frob' is updated to 42 in the dict, but the optimized local is not updated. Calling locals() again refreshes the dict. From ethan at stoneleaf.us Wed Feb 1 18:08:24 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:08:24 -0800 Subject: Question about name scope In-Reply-To: <4F29BB9C.70405@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4F29C5E8.6000504@stoneleaf.us> Ethan Furman wrote: > Ian Kelly wrote: >> I am not a dev, but I believe it works because assigning to locals() >> and assigning via exec are not the same thing. The problem with >> assigning to locals() is that you're fundamentally just setting a >> value in a dictionary, and even though it happens to be the locals >> dict for the stack frame, Python can't figure out that it should go >> and update the value of the optimized local to match. exec, on the >> other hand, compiles and executes an actual STORE_NAME operation. Of >> course, if the particular local variable hasn't been optimized by the >> compiler, then updating locals() works just fine (although you >> probably should not rely on this): >> >>>>> def f(x, y): >> ... locals()[x] = y >> ... print locals()[x] >> ... exec 'print ' + x >> ... >>>>> f('a', 42) >> 42 >> 42 > > Definitely should rely on it, because in CPython 3 exec does not > un-optimize the function and assigning to locals() will not actually > change the functions variables. Ouch, that should have been *not* rely on it; not because it doesn't work (exec uses locals() if one is not specified), but because it is easy for the names in the function to get out of sync with the names in the functions locals() (or __dict__). ~Ethan~ From __peter__ at web.de Wed Feb 1 18:15:01 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Feb 2012 00:15:01 +0100 Subject: Generator problem: parent class not seen References: Message-ID: Russell E. Owen wrote: > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > self=; class hierarchy=[( 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > (,))]] > > The code looks like this: > > def run(self, sr): > try: > self.initAll() > .... > except Exception: > traceback.print_exc(file=sys.stderr) > sys.stderr.write("self=%r; class hierarchy=%s\n" % (self, > inspect.getclasstree([type(self)]))) > raise > > As a detail that may be important: the code is a generator that is being > run by a script runner class (an instance of which is passed into the > run function as argument sr). When the user starts a script the script > runner calls the script's "run" generator. The script runner calls the > run generator again later when conditions are right (e.g. data that is > being waited for arrives, a time limit is reached...). In this case the > failure occurs at the very start of the script, so a yield has not yet > executed. > > I am puzzled why Python thinks the class type is wrong, given the output > of inspect.getclasstree. Any ideas on what might be wrong and how to > track it down (and why it would be so intermittent)? Do you reload()? From arnodel at gmail.com Wed Feb 1 18:35:46 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 23:35:46 +0000 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: On Feb 1, 2012 9:01 PM, "Russell E. Owen" wrote: > > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > self=; class hierarchy=[( 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > (,))]] > Looks like you have loaded the same module twice. So you have two versions of your class hierarchies. You can check by printing the ids of your classes. You will get classes with the same name but different ids. Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Wed Feb 1 18:41:59 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:41:59 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> Message-ID: <4F29CDC7.2000104@stoneleaf.us> Ian Kelly wrote: > Sure, but that's not actually out of sync. The argument of your exec > evaluates to 'print (a)'. You get two different results because > you're actually printing two different variables. Ah -- thanks, I missed that. > You can get the dict temporarily out of sync: > >>>> def f(x, y): > ... frob = None > ... loc = locals() > ... loc[x] = y > ... print(loc) > ... print(locals()) > ... print(loc) > ... >>>> f('frob', 42) > {'y': 42, 'x': 'frob', 'frob': 42, 'loc': {...}} > {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} > > In this case, 'frob' is updated to 42 in the dict, but the optimized > local is not updated. Calling locals() again refreshes the dict. I'm not sure what you mean by temporary: --> def f(x, y): ... frob = None ... loc = locals() ... loc[x] = y ... print(loc) ... print(locals()) ... print(loc) ... print(locals()) ... --> --> f('frob', 19) {'y': 19, 'x': 'frob', 'frob': 19} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} Seems to be stuck that way. Here is a better example I was thinking of: --> def f(x, y): ... locals()[x] = y ... locals()['x'] = 17 ... print(locals()) ... print(x) ... print(y) ... --> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} a 42 So locals() was updated with 'a', but not with the assignment to 'x'. And of course, if we tried to 'print(a)' we'd get a NameError. ~Ethan~ From kw at codebykevin.com Wed Feb 1 18:42:08 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 01 Feb 2012 18:42:08 -0500 Subject: Buffering in Wing and IDLE 3 In-Reply-To: References: Message-ID: On 2/1/12 3:01 PM, Terry Reedy wrote: > On 2/1/2012 10:17 AM, Franck Ditter wrote: > >> I would prefer to use IDLE but as we are in France, the Python team >> does not seem to be aware that the ~ and others are not available >> on MacOS-X here (probably the same in Europe)... > > We are quite aware of the problem but cannot directly do anything about > it as the problem is with tcl/tk and Apple. A couple of days ago, Kevin > Walzer wrote on an IDLE-sig post "I'm currently reviewing an updated > patch to address the problem. When I commit the patch, it will go into > both Tk's trunk and in the Cocoa 8.5 backport, and eventually be > available through ActiveState's distribution." > And it's been committed: http://core.tcl.tk/tk/info/9844fe10b9 --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From solutions.for.student at gmail.com Wed Feb 1 18:42:48 2012 From: solutions.for.student at gmail.com (solutions for student) Date: Wed, 1 Feb 2012 15:42:48 -0800 (PST) Subject: solutions manual Message-ID: <41f0b5f7-9c50-4a25-b4ce-8a4bb60c40fe@kn4g2000pbc.googlegroups.com> solutions for student solutions(dot)for(dot)student(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on solutions.for.student at hotmail.com From solutions.for.student at gmail.com Wed Feb 1 18:45:35 2012 From: solutions.for.student at gmail.com (solutions for student) Date: Wed, 1 Feb 2012 15:45:35 -0800 (PST) Subject: solutions books Message-ID: solutions for student solutions(dot)for(dot)student(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on solutions.for.student at hotmail.com From ian.g.kelly at gmail.com Wed Feb 1 18:47:53 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 16:47:53 -0700 Subject: Question about name scope In-Reply-To: <4F29CDC7.2000104@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> <4F29CDC7.2000104@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote: > I'm not sure what you mean by temporary: > > --> def f(x, y): > > ... ? ? frob = None > ... ? ? loc = locals() > ... ? ? loc[x] = y > ... ? ? print(loc) > ... ? ? print(locals()) > ... ? ? print(loc) > ... ? ? print(locals()) > ... > --> > --> f('frob', 19) > {'y': 19, 'x': 'frob', 'frob': 19} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > > Seems to be stuck that way. The first print is the one that is incorrect. It suggests that the local 'frob' has been changed to 19 as it has in the dict, but the actual value of the local is still None. The second print on accurately reflect that. From ethan at stoneleaf.us Wed Feb 1 18:51:20 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:51:20 -0800 Subject: Question about name scope In-Reply-To: <4F29C5E8.6000504@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C5E8.6000504@stoneleaf.us> Message-ID: <4F29CFF8.6090502@stoneleaf.us> Ethan Furman wrote: > Ethan Furman wrote: >> Ian Kelly wrote: >>> I am not a dev, but I believe it works because assigning to locals() >>> and assigning via exec are not the same thing. The problem with >>> assigning to locals() is that you're fundamentally just setting a >>> value in a dictionary, and even though it happens to be the locals >>> dict for the stack frame, Python can't figure out that it should go >>> and update the value of the optimized local to match. exec, on the >>> other hand, compiles and executes an actual STORE_NAME operation. Of >>> course, if the particular local variable hasn't been optimized by the >>> compiler, then updating locals() works just fine (although you >>> probably should not rely on this): >>> >>>>>> def f(x, y): >>> ... locals()[x] = y >>> ... print locals()[x] >>> ... exec 'print ' + x >>> ... >>>>>> f('a', 42) >>> 42 >>> 42 >> >> Definitely should rely on it, because in CPython 3 exec does not >> un-optimize the function and assigning to locals() will not actually >> change the functions variables. > > > Ouch, that should have been *not* rely on it; not because it doesn't > work (exec uses locals() if one is not specified), but because it is > easy for the names in the function to get out of sync with the names in > the functions locals() (or __dict__). I should stop answering now :( Ignore the __dict__ comment, it is incorrect. ~Ethan~ From ethan at stoneleaf.us Wed Feb 1 18:59:37 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:59:37 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> <4F29CDC7.2000104@stoneleaf.us> Message-ID: <4F29D1E9.7050304@stoneleaf.us> Ian Kelly wrote: > On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote: >> I'm not sure what you mean by temporary: >> >> --> def f(x, y): >> >> ... frob = None >> ... loc = locals() >> ... loc[x] = y >> ... print(loc) >> ... print(locals()) >> ... print(loc) >> ... print(locals()) >> ... >> --> >> --> f('frob', 19) >> {'y': 19, 'x': 'frob', 'frob': 19} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> >> Seems to be stuck that way. > > The first print is the one that is incorrect. It suggests that the > local 'frob' has been changed to 19 as it has in the dict, but the > actual value of the local is still None. The second print on > accurately reflect that. Ah. Thanks for the explanations. ~Ethan~ From rowen at uw.edu Wed Feb 1 19:19:51 2012 From: rowen at uw.edu (Russell Owen) Date: Wed, 1 Feb 2012 16:19:51 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: <2E3D1C43-6C0F-4A2D-9D90-6C5BD1B61D64@uw.edu> On Feb 1, 2012, at 3:35 PM, Arnaud Delobelle wrote: > On Feb 1, 2012 9:01 PM, "Russell E. Owen" wrote: > > > > I have an odd and very intermittent problem in Python script. > > Occasionally it fails with this error: > > > > Traceback (most recent call last): > > File > > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > > eFocusScript.py", line 884, in run > > File > > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > > eFocusScript.py", line 1690, in initAll > > TypeError: unbound method initAll() must be called with BaseFocusScript > > instance as first argument (got ScriptClass instance instead) > > self=; class hierarchy=[( > 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( > 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > > (,))]] > > > > Looks like you have loaded the same module twice. So you have two versions of your class hierarchies. You can check by printing the ids of your classes. You will get classes with the same name but different ids. > > Arnaud > Yes! I was reloading BaseFocusScript. Oops. In detail: script files are dynamically loaded when first requested and can be reloaded for debugging. I think that's safe because script files are self-contained (e.g. the classes in them are never subclassed or anything like that). But I went too far: I had my focus scripts reload BaseFocusScript, which is shared code, so that I could tweak BaseFocusScript while debugging focus scripts. Thank you very much! -- Russell -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Feb 1 19:28:12 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 02 Feb 2012 11:28:12 +1100 Subject: Registry entries set up by the Windows installer In-Reply-To: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> References: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> Message-ID: <4F29D89C.30708@gmail.com> On 2/02/2012 2:09 AM, Paul Moore wrote: > I'm trying to get information on what registry entries are set up by > the Python Windows installer, and what variations exist. I don't know > enough about MSI to easily read the source, so I'm hoping someone who > knows can help :-) > > As far as I can see on my PC, the installer puts entries > > HKLM\Software\Python\PythonCore\x.y > > with various bits underneath. I think I've seen indications that > sometimes these are in HKCU, presumably for a "per user" install? If I > manually hack around in the registry, and have both HKLM and HKCU, > which one will Python use? For setting PYTHONPATH it uses both - HKEY_CURRENT_USER is added before HKEY_LOCAL_MACHINE. I can't recall which one distutils generated (bdist_wininst) installers will use - it may even offer the choice. > Furthermore, more of a Windows question than Python, but there's a > similar question with regard to the .py and .pyw file associations - > they can be in HKLM\Software\Classes or HKCU\Software\Classes. Which > takes precedence? No idea I'm afraid, but I'd expect it to use HKCU > I assume that the installer writes to HKLM for all > users and HKCU for per-user installs. Yep, I think that is correct. > Is there anything else I've missed? I'm also not sure which one the pylauncher project will prefer, which may become relevant should that get rolled into Python itself. > The reason I ask, is that I'm starting to work with virtualenv, and I > want to see what would be involved in (re-)setting the registry > entries to match the currently active virtualenv. virtualenvwrapper- > powershell seems to only deal with HKCU (which is a big plus on > Windows 7, as it avoids endless elevation requests :-)) but that > doesn't work completely cleanly with my all-users install. (Note: I'm > not entirely sure that changing global settings like this to patch a > per-console virtualenv is a good idea, but I'd like to know how hard > it is before dismissing it...) Out of interest, what is the reason forcing you to look at that - bdist_wininst installers? FWIW, my encounters with virtualenv haven't forced me to hack the registry - I just install bdist_wininst packages into the "parent" Python which isn't ideal but works fine for me. This was a year or so ago, so the world might have changed since then. Mark From steve+comp.lang.python at pearwood.info Wed Feb 1 19:32:42 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:32:42 GMT Subject: TypeError References: Message-ID: <4f29d9a9$0$29989$c3e8da3$5496439d@news.astraweb.com> Hello Katie, When posting to technical news groups like this, can you please send plain text emails rather than so-called "rich text" (actually HTML code) email? Or at least, don't use Microsoft Word as your email editor. Many people will be reading your posts using text applications and will see line after line of very bad HTML like this: >

Hello,

class="MsoNormal"> 

I am new to > python and am trying to correct the follow error:

class="MsoNormal"> 

class="MsoNormal">TypeError: sequence item 1: expected string, > NoneType found

[...] and that's the sort of thing that makes programmers grumpy and less inclined to help. To answer your question: On Wed, 01 Feb 2012 16:53:41 +0000, Clark, Kathleen wrote: > I am new to python and am trying to correct the follow error: > > TypeError: sequence item 1: expected string, NoneType found It is best, if possible, to post the entire traceback starting with the line "Traceback (most recent call last)" rather than just the last line. In this case, the error is simple enough to work out that it may not matter, but in general it often does matter. > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) In this case, one of the variables fn, ln and sdob is None instead of a string. > If I'm understanding this correctly, the code is expecting a string, but > not finding it. I'm wondering, what is meant by a "string" and also how > I can figure out the problem and correct it. If you are new enough to programming that you need to ask what is a string, you might find the Python tutor mailing list a more useful place than here. http://mail.python.org/mailman/listinfo/tutor "String" is short for "string of characters", that is, text, and in Python strings are created with quotation marks or the str() function. So: a = "this is a string" b = 'so is this' c = str(some_variable) # and so is this To fix the problem, there is a quick and dirty way, and the proper way. The quick and dirty way is to just force all items in the list to be strings, regardless of what they currently are. Your line: ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) becomes: ws.cell(row=row, column=1).value = ','.join( [str(ino), str(fn), str(ln), str(sdob)]) While this might work, the fact that one or more of fn, ln and sdob is None may be a bug in your code, and converting to a string may very well just obscure the source of the bug and make it harder to solve in the long run. So the proper way to fix the problem is: (1) Identify which variable is not a string. (2) Find out why it becomes set to None. (3) Fix it. The first part is easy: insert this line before line 86: print("fn, ln, sdob:", fn, ln, sdob) and see what it says. Fixing it means working backwards from that point, finding out where the variable gets set to None, and fixing that bug. Good luck! -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 1 19:34:56 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:34:56 GMT Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4f29da30$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 14:53:09 -0800, Ethan Furman wrote: > Indeed -- the point to keep in mind is that locals() can become out of > sync with the functions actual variables. Definitely falls in the camp > of "if you don't know *exactly* what you are doing, do not play this > way!" And if you *do* know exactly what you are doing, you will probably decide not to play this way also! -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 1 19:51:34 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:51:34 GMT Subject: changing sys.path References: <4F296509.60607@gmail.com> Message-ID: <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That's what really puzzles me.. What could that be then? Are you using IDLE or WingIDE or some other IDE which may not be honouring sys.path? If so, that's a BAD bug in the IDE. Are you changing the working directory manually, by calling os.chdir? If so, that could be interfering with the import somehow. It shouldn't, but you never know... Are you adding absolute paths or relative paths? You say that you get an ImportError, but that covers a lot of things going wrong. Here's a story. Could it be correct? I can't tell because you haven't posted the traceback. When you set site-packages/my_paths.pth you get a sys path that looks like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" which locates b/spam.py and everything works. But when you call sys.path.extend(['a', 'b']) you get a path that looks like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't import, and you get an ImportError. -- Steven From dg.gmane at thesamovar.net Wed Feb 1 20:14:20 2012 From: dg.gmane at thesamovar.net (Dan Goodman) Date: Thu, 02 Feb 2012 02:14:20 +0100 Subject: simple system for building packages for multiple platforms? Message-ID: Hi all, Until recently, our package has been pure Python, so distributing it has been straightforward. Now, however, we want to add some extension modules in C++. We're happy to provide source only distributions on Linux because almost all Linux users will have all the required compilers and so forth already installed. But we also want to support Windows users who may not have C++ compilers available, which means providing built distributions. But, we're faced with this problem, there are three versions of Python we're supporting (2.5-2.7) and two architectures (32 and 64 bit), which means 6 possible platforms to build for (and maybe more in future if we upgrade to Python 3). Is there a straightforward way to set up a semi-automated build system for this? At the moment, I'm thinking about either having a bunch of virtual machines or Amazon EC2 instances and submitting build jobs to these, but setting that up looks to be a lot of work and I guess many people have had this problem before. So, what do other people do? Also, once we have a build system up, I guess it can also be used for a more extensive testing system on these multiple platforms? Dan From research at johnohagan.com Wed Feb 1 22:18:12 2012 From: research at johnohagan.com (John O'Hagan) Date: Thu, 2 Feb 2012 14:18:12 +1100 Subject: copy on write In-Reply-To: <4F107AAF.5000600@stoneleaf.us> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> Message-ID: <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> On Fri, 13 Jan 2012 10:40:47 -0800 Ethan Furman wrote: > Steven D'Aprano wrote: > > Normally this is harmless, but there is one interesting little > > glitch you can get: > > > >>>> t = ('a', [23]) > >>>> t[1] += [42] > > Traceback (most recent call last): > > File "", line 1, in > > TypeError: 'tuple' object does not support item assignment > >>>> t > > ('a', [23, 42]) IMHO, this is worthy of bug-hood: shouldn't we be able to conclude from the TypeError that the assignment failed? > There is one other glitch, and possibly my only complaint: > > --> a = [1, 2, 3] > --> b = 'hello, world' > --> a = a + b > Traceback (most recent call last): > File "", line 1, in > TypeError: can only concatenate list (not "str") to list > --> a += b > --> a > [1, 2, 3, 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] > > IMO, either both + and += should succeed, or both should fail. > > ~Ethan~ This also happens for tuples, sets, generators and range objects (probably any iterable), AFAIK only when the left operand is a list. Do lists get special treatment in terms of implicitly converting the right-hand operand? The behaviour of the "in-place" operator could be more consistent across types: >>> a=[1,2] >>> a+=(3,4) >>> a [1, 2, 3, 4] >>> a=(1,2) >>> a+=(3,4) >>> a (1, 2, 3, 4) >>> a=(1,2) >>> a+=[3,4] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple John From rantingrickjohnson at gmail.com Wed Feb 1 22:51:13 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 19:51:13 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 13, 10:48?am, Devin Jeanpierre wrote: > On Fri, Jan 13, 2012 at 10:13 AM, Grant Edwards wrote: > > On 2012-01-13, Devin Jeanpierre wrote: > >> On Fri, Jan 13, 2012 at 7:30 AM, Chris Angelico wrote: > There's a bit of a feeling > that code should "do what it looks like" and be sort of understandable > without exactly understanding everything. Yeah there's a word for that; INTUITIVE, And I've been preaching its virtues (sadly in vain it seems!) to these folks for some time now. From steve+comp.lang.python at pearwood.info Thu Feb 2 00:31:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 05:31:03 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2a1f96$0$29895$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 19:51:13 -0800, Rick Johnson wrote: > Yeah there's a word for that; INTUITIVE, And I've been preaching its > virtues (sadly in vain it seems!) to these folks for some time now. Intuitive to whom? Expert Python programmers? VB coders? Perl hackers? School children who have never programmed before? Mathematicians? Babies? Rocket scientists? Hunter-gatherers from the Kalahari desert? My intuition tells me you have never even considered that intuition depends on who is doing the intuiting. -- Steven From jeanpierreda at gmail.com Thu Feb 2 01:34:48 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 01:34:48 -0500 Subject: copy on write In-Reply-To: <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: On Wed, Feb 1, 2012 at 10:18 PM, John O'Hagan wrote: > On Fri, 13 Jan 2012 10:40:47 -0800 > Ethan Furman wrote: > >> Steven D'Aprano wrote: >> > Normally this is harmless, but there is one interesting little >> > glitch you can get: >> > >> >>>> t = ('a', [23]) >> >>>> t[1] += [42] >> > Traceback (most recent call last): >> > ? File "", line 1, in >> > TypeError: 'tuple' object does not support item assignment >> >>>> t >> > ('a', [23, 42]) > > IMHO, this is worthy of bug-hood: shouldn't we be able to conclude from the TypeError that the assignment failed? It did fail. The mutation did not. I can't think of any way out of this misleadingness, although if you can that would be pretty awesome. -- Devin From jeanpierreda at gmail.com Thu Feb 2 01:42:54 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 01:42:54 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: > And it bothers me that you imput such ignorance to me. You made what I think > was a bad analogy and I made a better one of the same type, though still > imperfect. I acknowledged that the transition will take years. Ah. It is a common attitude among those that make these sorts of comments about Python 3, and I hadn't read anything in what you said that made me think that you were considering more than the superficial costs of moving. I am sorry that I did not give you the benefit of the doubt. -- Devin From stefan_ml at behnel.de Thu Feb 2 02:02:06 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 02 Feb 2012 08:02:06 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Tim Arnold, 01.02.2012 19:15: > On 2/1/2012 3:26 AM, Stefan Behnel wrote: >> Tim Arnold, 31.01.2012 19:09: >>> I have to follow a specification for producing xhtml files. >>> The original files are in cp1252 encoding and I must reencode them to >>> utf-8. >>> Also, I have to replace certain characters with html entities. >>> --------------------------------- >>> import codecs, StringIO >>> from lxml import etree >>> high_chars = { >>> 0x2014:'—', # 'EM DASH', >>> 0x2013:'–', # 'EN DASH', >>> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >>> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >>> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >>> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >>> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >>> 0x2122:'™', # 'TRADE MARK SIGN', >>> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >>> } >>> def translate(string): >>> s = '' >>> for c in string: >>> if ord(c) in high_chars: >>> c = high_chars.get(ord(c)) >>> s += c >>> return s >> >> I hope you are aware that this is about the slowest possible algorithm >> (well, the slowest one that doesn't do anything unnecessary). Since none of >> this is required when parsing or generating XHTML, I assume your spec tells >> you that you should do these replacements? > > I wasn't aware of it, but I am now--code's embarassing now. > The spec I must follow forces me to do the translation. > > I am actually working with html not xhtml; which makes a huge difference, We all learn. > Ulrich's line of code for translate is elegant. > for c in string: > s += high_chars.get(c,c) Still not efficient because it builds the string one character at a time and needs to reallocate (and potentially copy) the string buffer quite frequently in order to do that. You are lucky with CPython, because it has an internal optimisation that mitigates this overhead on some platforms. Other Python implementations don't have that, and even the optimisation in CPython is platform specific (works well on Linux, for example). Peter Otten presented the a better way of doing it. > From the all the info I've received on this thread, plus some additional > reading, I think I need the following code. > > Use the HTMLParser because the source files are actually HTML, and use > output from etree.tostring() as input to translate() as the very last step. > > def reencode(filename, in_encoding='cp1252', out_encoding='utf-8'): > parser = etree.HTMLParser(encoding=in_encoding) > tree = etree.parse(filename, parser) > result = etree.tostring(tree.getroot(), method='html', > pretty_print=True, > encoding=out_encoding) > with open(filename, 'wb') as f: > f.write(translate(result)) > > not simply tree.write(f...) because I have to do the translation at the > end, so I get the entities instead of the resolved entities from lxml. Yes, that's better. Still one thing (since you didn't show us your final translate() function): you do the character escaping on a UTF-8 encoded string and made the encoding configurable. That means that the characters you are looking for must also be encoded with the same encoding in order to find matches. However, if you ever choose a different target encoding that doesn't have the nice properties of UTF-8's byte sequences, you may end up with ambiguous byte sequences in the output that your translate() function accidentally matches on, thus potentially corrupting your data. Assuming that you are using Python 2, you may even be accidentally doing the replacement using Unicode character strings, which then only happens to work on systems that use UTF-8 as their default encoding. Python 3 has fixed this trap, but you have to take care to avoid it in Python 2. I'd prefer serialising the documents into a unicode string (encoding='unicode'), then post-processing that and finally encoding it to the target encoding when writing it out. But you'll have to see how that works out together with your escaping step, and also how it impacts the HTML tag that states the document encoding. Stefan From r.grimm at science-computing.de Thu Feb 2 02:19:57 2012 From: r.grimm at science-computing.de (Rainer Grimm) Date: Wed, 1 Feb 2012 23:19:57 -0800 (PST) Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> Message-ID: <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> You can do it more concise. >>> def isListOrString(p): ... return any((isinstance(p,list),isinstance(p,str))) ... >>> listOrString("string") True >>> listOrString([1,2,3]) True >>> listOrString(2) False >>> listOrString(False) False Rainer From r.grimm at science-computing.de Thu Feb 2 02:19:57 2012 From: r.grimm at science-computing.de (Rainer Grimm) Date: Wed, 1 Feb 2012 23:19:57 -0800 (PST) Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> Message-ID: <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> You can do it more concise. >>> def isListOrString(p): ... return any((isinstance(p,list),isinstance(p,str))) ... >>> listOrString("string") True >>> listOrString([1,2,3]) True >>> listOrString(2) False >>> listOrString(False) False Rainer From p_s_d_a_s_i_l_v_a at netcabo.pt Thu Feb 2 02:23:04 2012 From: p_s_d_a_s_i_l_v_a at netcabo.pt (Paulo da Silva) Date: Thu, 02 Feb 2012 07:23:04 +0000 Subject: Iterate from 2nd element of a huge list References: Message-ID: Em 01-02-2012 04:55, Cameron Simpson escreveu: > On 01Feb2012 03:34, Paulo da Silva wrote: > | BTW, iter seems faster than iterating thru mylist[1:]! > > I would hope the difference can be attributed to the cost of copying > mylist[1:]. I don't think so. I tried several times and the differences were almost always consistent. I put mylist1=mylist[1:] outside the time control. iter still seems a little bit faster. Running both programs several times (10000000 elements list) I only got iter being slower once! But, of course, most of the difference comes from the copy. From void.of.time at gmail.com Thu Feb 2 02:25:36 2012 From: void.of.time at gmail.com (oleg korenevich) Date: Wed, 1 Feb 2012 23:25:36 -0800 (PST) Subject: python reliability with EINTR handling in general modules References: Message-ID: On Feb 1, 6:07?pm, Dennis Lee Bieber wrote: > On Wed, 1 Feb 2012 06:15:22 -0800 (PST), oleg korenevich > > > > > > > > > > wrote: > >I have linux board on samsung SoC s3c6410 (ARM11). I build rootfs with > >buildroot: Python 2.7.1, uClibc-0.9.31. Linux kernel: Linux buildroot > >2.6.28.6 #177 Mon Oct 3 12:50:57 EEST 2011 armv6l GNU/Linux > > >My app, written on python, in some mysterios conditons raise this > >exceptions: > > >1) exception: > > > File "./dfbUtils.py", line 3209, in setItemData > >ValueError: (4, 'Interrupted system call') > >code: > > >currentPage=int(math.floor(float(rowId)/ > >self.pageSize))==self.selectedPage > >2) exception: > > >File "./terminalGlobals.py", line 943, in getFirmawareName > >OSError: [Errno 4] Interrupted system call: 'firmware' > >code: > > >for fileName in os.listdir('firmware'): > >Some info about app: it have 3-7 threads, listen serial ports via > >'serial' module, use gui implemented via c extension that wrap > >directfb, i can't reproduce this exceptions, they are not predictable. > > >I googled for EINTR exceptions in python, but only found that EINTR > >can occur only on slow system calls and python's modules socket, > >subprocess and another one is already process EINTR. So what happens > >in my app? Why simple call of math function can interrupt program at > >any time, it's not reliable at all. I have only suggestions: ulibc > >bug, kernel/hw handling bug. But this suggestions don't show me > >solution. > > ? ? ? ? I see nothing in your traceback that indicates that the interrupt > occurred in the math library call -- unless you deleted that line. In > the first one, I'd be more likely to suspect your C extension/wrapper... > (are the fields .pageSize and .selectedPage coming from an object > implemented in C?) > > ? ? ? ? As for the math stuff... I presume both rowID and .pageSize are > constrained to be 0 or positive integers. If that is the case, invoking > math.floor() is just redundant overhead as the documented behavior of > int() is to truncate towards 0, which for a positive value, is the same > as floor() > > > > >>> neg = -3.141592654 > >>> pos = 3.141592654 > >>> int(neg) > -3 > >>> math.floor(neg) > -4.0 > >>> int(pos) > 3 > >>> math.floor(pos) > 3.0 > > ? ? ? ? In the second case... Well, os.listdir() is most likely translated > into some operating system call. > > http://www.gnu.org/software/libc/manual/html_node/Interrupted-Primiti... > > And, while that call is waiting for I/O to complete, some sort of signal > is being received. > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ Thanks for help. In first case all vars is python integers, maybe math.floor is redundant, but i'm afraid that same error with math module call will occur in other places of app, where math is needed. Strange thing here is that math library call is not a system call, and strange exception ValueError (all values have right values) and why in braces i have (4, Interruted system call). For second case: if python really does some slow system call from module os, why it doesn't handle EINTR and not restart call. Is SA_RESTART flag in signal can be solution? But how i can set this flag? By placing flag for signal handler in c extension (or ctypes manipulation)? From steve+comp.lang.python at pearwood.info Thu Feb 2 02:31:16 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 07:31:16 GMT Subject: How can I verify if the content of a variable is a list or a string? References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> Message-ID: <4f2a3bc4$0$29895$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 23:19:57 -0800, Rainer Grimm wrote: > You can do it more concise. > >>>> def isListOrString(p): > ... return any((isinstance(p,list),isinstance(p,str))) Or even more concisely still: isinstance(p, (list, str)) -- Steven From steve+comp.lang.python at pearwood.info Thu Feb 2 02:38:53 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 07:38:53 GMT Subject: Iterate from 2nd element of a huge list References: Message-ID: <4f2a3d8d$0$29895$c3e8da3$5496439d@news.astraweb.com> On Thu, 02 Feb 2012 07:23:04 +0000, Paulo da Silva wrote: > Em 01-02-2012 04:55, Cameron Simpson escreveu: >> On 01Feb2012 03:34, Paulo da Silva >> wrote: > >> | BTW, iter seems faster than iterating thru mylist[1:]! >> >> I would hope the difference can be attributed to the cost of copying >> mylist[1:]. > I don't think so. I tried several times and the differences were almost > always consistent. Yes, actually iterating over a list-iterator appears to be trivially faster (although this may not apply to arbitrary iterators): steve at runes:~$ python -m timeit -s "L=range(10000)" "for x in L: pass" 1000 loops, best of 3: 280 usec per loop steve at runes:~$ python -m timeit -s "L=range(10000)" "for x in iter(L): pass" 1000 loops, best of 3: 274 usec per loop The difference of 6 microseconds would be lost in the noise if the loops actually did something useful. Also keep in mind that for tiny lists, the overhead of creating the iterator is probably much greater than the time of iterating over the list: steve at runes:~$ python -m timeit -s "L=range(3)" "for x in L: pass" 1000000 loops, best of 3: 0.238 usec per loop steve at runes:~$ python -m timeit -s "L=range(3)" "for x in iter(L): pass" 1000000 loops, best of 3: 0.393 usec per loop But of course the difference is only relatively significant, in absolute terms nobody is going to notice an extra 0.1 or 0.2 microseconds. -- Steven From p.f.moore at gmail.com Thu Feb 2 03:09:55 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:09:55 +0000 Subject: Registry entries set up by the Windows installer In-Reply-To: <4F29D89C.30708@gmail.com> References: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> <4F29D89C.30708@gmail.com> Message-ID: On 2 February 2012 00:28, Mark Hammond wrote: > For setting PYTHONPATH it uses both - HKEY_CURRENT_USER is added before > HKEY_LOCAL_MACHINE. ?I can't recall which one distutils generated > (bdist_wininst) installers will use - it may even offer the choice. [...] > Yep, I think that is correct. Thanks for the information. >> Is there anything else I've missed? > > I'm also not sure which one the pylauncher project will prefer, which may > become relevant should that get rolled into Python itself. Good point - I can look in the source for that, if I need to. >> The reason I ask, is that I'm starting to work with virtualenv, and I >> want to see what would be involved in (re-)setting the registry >> entries to match the currently active virtualenv. virtualenvwrapper- >> powershell seems to only deal with HKCU (which is a big plus on >> Windows 7, as it avoids endless elevation requests :-)) but that >> doesn't work completely cleanly with my all-users install. (Note: I'm >> not entirely sure that changing global settings like this to patch a >> per-console virtualenv is a good idea, but I'd like to know how hard >> it is before dismissing it...) > > > Out of interest, what is the reason forcing you to look at that - > bdist_wininst installers? ?FWIW, my encounters with virtualenv haven't > forced me to hack the registry - I just install bdist_wininst packages into > the "parent" Python which isn't ideal but works fine for me. ?This was a > year or so ago, so the world might have changed since then. It's bdist_msi.rather than bdist_wininst. I want to avoid putting packages into the "main" Python - at least, from my limited experiments the virtual environment doesn't see them (I may be wrong about this, I only did a very limited test and I want to do some more detailed testing before I decide). For bdist_wininst packages, I can install using easy_install - this will unpack and install bdist_wininst installers. (I don't actually like easy_install that much, but if it works...). But easy_install won't deal with MSI installers, and you can't force them to install in an unregistered Python. The only way I can think of is to do an "admin install" to unpack them, and put the various bits in place manually... The other reason for changing the registry is the .py file associations. But as I said, I'm not yet convinced that this is a good idea in any case... Thanks for the help, Paul. From research at johnohagan.com Thu Feb 2 03:11:53 2012 From: research at johnohagan.com (John O'Hagan) Date: Thu, 2 Feb 2012 19:11:53 +1100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: <20120202191153.64036e9eb3655bceaedd7def@johnohagan.com> On Thu, 2 Feb 2012 01:34:48 -0500 Devin Jeanpierre wrote: > On Wed, Feb 1, 2012 at 10:18 PM, John O'Hagan > wrote: > > On Fri, 13 Jan 2012 10:40:47 -0800 > > Ethan Furman wrote: > > > >> Steven D'Aprano wrote: > >> > Normally this is harmless, but there is one interesting little > >> > glitch you can get: > >> > > >> >>>> t = ('a', [23]) > >> >>>> t[1] += [42] > >> > Traceback (most recent call last): > >> > ? File "", line 1, in > >> > TypeError: 'tuple' object does not support item assignment > >> >>>> t > >> > ('a', [23, 42]) > > > > IMHO, this is worthy of bug-hood: shouldn't we be able to conclude > > from the TypeError that the assignment failed? > > It did fail. The mutation did not. You're right, in fact, for me the surprise is that "t[1] +=" is interpreted as an assignment at all, given that for lists (and other mutable objects which use "+=") it is a mutation. Although as Steven says elsewhere, it actually is an assignment, but one which ends up reassigning to the same object. But it shouldn't be both. I can't think of another example of (what appears to be but is not) a single operation failing with an exception, but still doing exactly what you intended. > > I can't think of any way out of this misleadingness, although if you > can that would be pretty awesome. In the case above, the failure of the assignment is of no consequence. I think it would make more sense if applying "+=" to a tuple element were treated (by the interpreter I suppose) only on the merits of the element, and not as an assignment to the tuple. John From devipriya0010 at gmail.com Thu Feb 2 03:14:39 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Thu, 2 Feb 2012 00:14:39 -0800 (PST) Subject: Signup and get starts to earn..... Message-ID: <90370acf-4afc-47e1-84da-5db1b19acd43@h6g2000yqk.googlegroups.com> http://123maza.com/46/dos754/ From steve+comp.lang.python at pearwood.info Thu Feb 2 04:16:40 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 09:16:40 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote: > You're right, in fact, for me the surprise is that "t[1] +=" is > interpreted as an assignment at all, given that for lists (and other > mutable objects which use "+=") it is a mutation. Although as Steven > says elsewhere, it actually is an assignment, but one which ends up > reassigning to the same object. > > But it shouldn't be both. Do you expect that x += 1 should succeed? After all, "increment and decrement numbers" is practically THE use-case for the augmented assignment operators. How can you expect x += 1 to succeed without an assignment? Numbers in Python are immutable, and they have to stay immutable. It would cause chaos and much gnashing of teeth if you did this: x = 2 y = 7 - 5 x += 1 print y * 100 => prints 300 So if you want x += 1 to succeed, += must do an assignment. Perhaps you are thinking that Python could determine ahead of time whether x[1] += y involved a list or a tuple, and not perform the finally assignment if x was a tuple. Well, maybe, but such an approach (if possible!) is fraught with danger and mysterious errors even harder to debug than the current situation. And besides, what should Python do about non-built-in types? There is no way in general to predict whether x[1] = something will succeed except to actually try it. > I can't think of another example of (what > appears to be but is not) a single operation failing with an exception, > but still doing exactly what you intended. Neither can I, but that doesn't mean that the current situation is not the least-worst alternative. >> I can't think of any way out of this misleadingness, although if you >> can that would be pretty awesome. > > In the case above, the failure of the assignment is of no consequence. I > think it would make more sense if applying "+=" to a tuple element were > treated (by the interpreter I suppose) only on the merits of the > element, and not as an assignment to the tuple. How should the interpreter deal with other objects which happen to raise TypeError? By always ignoring it? x = [1, None, 3] x[1] += 2 # apparently succeeds Or perhaps by hard-coding tuples and only ignoring errors for tuples? So now you disguise one error but not others? -- Steven From tjreedy at udel.edu Thu Feb 2 04:21:59 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 04:21:59 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: > On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: >> And it bothers me that you imput such ignorance to me. You made what I think >> was a bad analogy and I made a better one of the same type, though still >> imperfect. I acknowledged that the transition will take years. > > Ah. It is a common attitude among those that make these sorts of > comments about Python 3, and I hadn't read anything in what you said > that made me think that you were considering more than the superficial > costs of moving. I thought '95% in 10 years' would be a hint that I know upgrading is not trivial for every one ;-). > I am sorry that I did not give you the benefit of the doubt. Apology accepted. -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Thu Feb 2 05:03:42 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 02 Feb 2012 10:03:42 +0000 Subject: changing sys.path In-Reply-To: <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4F296509.60607@gmail.com> <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2A5F7E.7000805@gmail.com> On 02/02/2012 12:51 AM, Steven D'Aprano wrote: > On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > >> Yes they are exactly the same, because in that file I just write exactly >> the same list, >> but when modifying it at run-time it doesn't work, while if at the >> application start >> there is this file everything works correctly... >> >> That's what really puzzles me.. What could that be then? > > Are you using IDLE or WingIDE or some other IDE which may not be > honouring sys.path? If so, that's a BAD bug in the IDE. > Are you changing the working directory manually, by calling os.chdir? If > so, that could be interfering with the import somehow. It shouldn't, but > you never know... > > Are you adding absolute paths or relative paths? No, no and absolute paths.. > > You say that you get an ImportError, but that covers a lot of things > going wrong. Here's a story. Could it be correct? I can't tell because > you haven't posted the traceback. > > When you set site-packages/my_paths.pth you get a sys path that looks > like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" > which locates b/spam.py and everything works. > > But when you call sys.path.extend(['a', 'b']) you get a path that looks > like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates > some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't > import, and you get an ImportError. > > And no the problem is not that I already checked inspecting at run-time.. This is the traceback and it might be related to the fact that it runs from the .exe wrapper generated by setuptools: Traceback (most recent call last): File "c:\python25\scripts\dev_main-script.py", line 8, in load_entry_point('psi.devsonly==0.1', 'console_scripts', 'dev_main')() File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", line 152, in main Develer(ns).full_run() File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", line 86, in full_run run(project_name, test_only=self.ns.test_only) File "h:\git_projs\psi\psi.devsonly\psi\devsonly\environment.py", line 277, in run from psi.devsonly.run import Runner File "h:\git_projs\psi\psi.devsonly\psi\devsonly\run.py", line 7, in from psi.workbench.api import Workbench, set_new_dev_main ImportError: No module named workbench.api Another thing which might matter is that I'm launching Envisage applications, which heavily rely on the use of entry points, so I guess that if something is not in the path the entry point is not loaded automatically (but it can be forced I guess somehow). I solved in another way now, since I also need to keep a dev_main.pth in site-packages to make Eclipse happy, just respawning the same process on ImportError works already perfectly.. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Thu Feb 2 05:42:01 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Thu, 02 Feb 2012 11:42:01 +0100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 13.01.2012 13:30 schrieb Chris Angelico: > It seems there's a distinct difference between a+=b (in-place > addition/concatenation) and a=a+b (always rebinding), There is indeed. a = a + b is a = a.__add__(b), while a += b is a = a.__iadd__(b). __add__() is supposed to leave the original object intact and return a new one, while __iadd__() is free to modify (preference, to be done if possible) or return a new one. A immutable object can only return a new one, and its __iadd__() behaviour is the same as __add__(). A mutable object, however, is free to and supposed to modify itself and then return self. Thomas From hniksic at xemacs.org Thu Feb 2 05:53:34 2012 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 02 Feb 2012 11:53:34 +0100 Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87haz9o6a9.fsf@xemacs.org> Steven D'Aprano writes: > Perhaps you are thinking that Python could determine ahead of time > whether x[1] += y involved a list or a tuple, and not perform the > finally assignment if x was a tuple. Well, maybe, but such an approach > (if possible!) is fraught with danger and mysterious errors even > harder to debug than the current situation. And besides, what should > Python do about non-built-in types? There is no way in general to > predict whether x[1] = something will succeed except to actually try > it. An alternative approach is to simply not perform the final assignment if the in-place method is available on the contained object. No prediction is needed to do it, because the contained object has to be examined anyway. No prediction is needed, just don't. Currently, lhs[ind] += rhs is implemented like this: item = lhs[ind] if hasattr(item, '__iadd__'): lhs.__setitem__(ind, item.__iadd__(rhs)) else: lhs.__setitem__(ind, item + rhs) # (Note item assignment in both "if" branches.) It could, however, be implemented like this: item = lhs[ind] if hasattr(item, '__iadd__'): item += rhs # no assignment, item supports in-place change else: lhs.__setitem__(ind, lhs[ind] + rhs) This would raise the exact same exception in the tuple case, but without executing the in-place assignment. On the other hand, some_list[ind] += 1 would continue working exactly the same as it does now. In the same vein, in-place methods should not have a return value (i.e. they should return None), as per Python convention that functions called for side effect don't return values. The alternative behavior is unfortunately not backward-compatible (it ignores the return value of augmented methods), so I'm not seriously proposing it, but I believe it would have been a better implementation of augmented assignments than the current one. The present interface doesn't just bite those who try to use augmented assignment on tuples holding mutable objects, but also those who do the same with read-only properties, which is even more reasonable. For example, obj.list_attr being a list, one would expect that obj.list_attr += [1, 2, 3] does the same thing as obj.list_attr.extend([1, 2, 3]). And it almost does, except it also follows up with an assignment after the list has already been changed, and the assignment to a read-only property raises an exception. Refusing to modify the list would have been fine, modifying it without raising an exception (as described above) would have been better, but modifying it and *then* raising an exception is a surprise that takes some getting used to. From __peter__ at web.de Thu Feb 2 06:02:21 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Feb 2012 12:02:21 +0100 Subject: xhtml encoding question References: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Message-ID: Ulrich Eckhardt wrote: > Am 01.02.2012 10:32, schrieb Peter Otten: >> It doesn't matter for the OP (see Stefan Behnel's post), but If you want >> to replace characters in a unicode string the best way is probably the >> translate() method: >> >>>>> print u"\xa9\u2122" >> ?? >>>>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) >> u'©™' >> > > Yes, this is both more expressive and at the same time probably even > more efficient. > > > Question though: > > >>> u'abc'.translate({u'a': u'A'}) > u'abc' > > I would call this a chance to improve Python. According to the > documentation, using a string is invalid, but it neither raises an > exception nor does it do the obvious and accept single-character strings > as keys. > > > Thoughts? How could this raise an exception? You'd either need a typed dictionary (int --> unicode) or translate() would have to verify that all keys are indeed integers. The former would go against the grain of Python, the latter would make the method less flexible as the set of keys currently need not be predefined: >>> class A(object): ... def __getitem__(self, key): ... return unichr(key).upper() ... >>> u"alpha".translate(A()) u'ALPHA' Using unicode instead of integer keys would be nice but breaks backwards compatibility, using both could double the number of dictionary lookups. From ulrich.eckhardt at dominolaser.com Thu Feb 2 07:40:22 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 02 Feb 2012 13:40:22 +0100 Subject: xhtml encoding question In-Reply-To: References: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Message-ID: Am 02.02.2012 12:02, schrieb Peter Otten: > Ulrich Eckhardt wrote: >> >> >>> u'abc'.translate({u'a': u'A'}) >> u'abc' >> >> I would call this a chance to improve Python. According to the >> documentation, using a string [as key] is invalid, but it neither raises >> an exception nor does it do the obvious and accept single-character >> strings as keys. >> >> >> Thoughts? > > How could this raise an exception? You'd either need a typed dictionary (int > --> unicode) or translate() would have to verify that all keys are indeed > integers. The latter is exactly what I would have done, i.e. scan the dictionary for invalid values, in the spirit of not letting errors pass unnoticed. > The former would go against the grain of Python, the latter would > make the method less flexible as the set of keys currently need not be > predefined: > >>>> class A(object): > ... def __getitem__(self, key): > ... return unichr(key).upper() > ... >>>> u"alpha".translate(A()) > u'ALPHA' Working with __getitem__ is a point. I'm not sure if it is reasonable to expect this to work though. I'm -0 on that. I could also imagine a completely separate path for iterable and non-iterable mappings. > Using unicode instead of integer keys would be nice but breaks backwards > compatibility, using both could double the number of dictionary lookups. Dictionary lookups are constant time and well-optimized, so I'd actually go for allowing both and paying that price. I could even imagine preprocessing the supplied dictionary while checking for invalid values. The result could be a structure that makes use of the fact that Unicode codepoints are < 22 bits and that makes the way from the elements of the source sequence to the according map entry as short as possible (I'm not sure if using codepoints or single-character strings is faster). However, those are early optimizations of which I'm not sure if they are worth it. Anyway, thanks for your thoughts, they are always appreciated! Uli From breamoreboy at yahoo.co.uk Thu Feb 2 07:52:40 2012 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Thu, 02 Feb 2012 12:52:40 +0000 Subject: CTRL-Z on windows for 2.7 and 3.2 Message-ID: Not that I'll lose any sleep over it, but section 2.1 of the tutorial for both versions doesn't reflect the minor difference between the behavior shown below. Which is correct, the docs or what actually happens? c:\Users\Mark\Sudoku>c:\Python27\python.exe Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> # you don't need to hit ENTER c:\Users\Mark\Sudoku>c:\Python32\python.exe Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^Z # you do need to hit ENTER c:\Users\Mark\Sudoku> -- Cheers. Mark Lawrence. From dihedral88888 at googlemail.com Thu Feb 2 08:33:17 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 2 Feb 2012 05:33:17 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. > > I was talking about the combination of + and =, since the discussion is > about 'a = a + b' vs 'a += b', not 'a + b' vs 'a += b' (where the > differences are obvious). > > And I stand by my statement. In 'a = a + b', operator+ obviously returns > a new object, but operator= should then go and assign the result to and > return a reference to 'a', just like how 'a += b' will return a > reference to 'a'. > The operation a+b means add(a,b) and returns a result instance, furthermore a and b can't be modified. The expression a = a+b are two operations not one. But in C or C++ the problem is mixing operations and expressions in a free style allowed. The operation a+=b means a modified by b and b can't be changed. Note that no new instance is necessary in a+=b. > If you're working in C++ and overload your operators so that 'a += b' > and 'a = a + b' have different observable behaviors (besides perhaps > time), then either your implementation is buggy or your design is very > bad-mannered. > > Evan Do you mean the result instances after 'a+=b' and 'a=a+b' or the actions of behaviors of instances involved in performing 'a+=b' and 'a=a+b'? From dihedral88888 at googlemail.com Thu Feb 2 08:33:17 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 2 Feb 2012 05:33:17 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. > > I was talking about the combination of + and =, since the discussion is > about 'a = a + b' vs 'a += b', not 'a + b' vs 'a += b' (where the > differences are obvious). > > And I stand by my statement. In 'a = a + b', operator+ obviously returns > a new object, but operator= should then go and assign the result to and > return a reference to 'a', just like how 'a += b' will return a > reference to 'a'. > The operation a+b means add(a,b) and returns a result instance, furthermore a and b can't be modified. The expression a = a+b are two operations not one. But in C or C++ the problem is mixing operations and expressions in a free style allowed. The operation a+=b means a modified by b and b can't be changed. Note that no new instance is necessary in a+=b. > If you're working in C++ and overload your operators so that 'a += b' > and 'a = a + b' have different observable behaviors (besides perhaps > time), then either your implementation is buggy or your design is very > bad-mannered. > > Evan Do you mean the result instances after 'a+=b' and 'a=a+b' or the actions of behaviors of instances involved in performing 'a+=b' and 'a=a+b'? From wxjmfauth at gmail.com Thu Feb 2 08:45:23 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 2 Feb 2012 05:45:23 -0800 (PST) Subject: changing sys.path References: <4F296509.60607@gmail.com> <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7a534ec4-3836-4460-af48-205170ebc37e@c20g2000vbb.googlegroups.com> On 2 f?v, 11:03, Andrea Crotti wrote: > On 02/02/2012 12:51 AM, Steven D'Aprano wrote: > > > > > On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > > >> Yes they are exactly the same, because in that file I just write exactly > >> the same list, > >> but when modifying it at run-time it doesn't work, while if at the > >> application start > >> there is this file everything works correctly... > > >> That's what really puzzles me.. What could that be then? > > > Are you using IDLE or WingIDE or some other IDE which may not be > > honouring sys.path? If so, that's a BAD bug in the IDE. > > Are you changing the working directory manually, by calling os.chdir? If > > so, that could be interfering with the import somehow. It shouldn't, but > > you never know... > > > Are you adding absolute paths or relative paths? > > No, no and absolute paths.. > > > > > You say that you get an ImportError, but that covers a lot of things > > going wrong. Here's a story. Could it be correct? I can't tell because > > you haven't posted the traceback. > > > When you set site-packages/my_paths.pth you get a sys path that looks > > like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" > > which locates b/spam.py and everything works. > > > But when you call sys.path.extend(['a', 'b']) you get a path that looks > > like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates > > some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't > > import, and you get an ImportError. > > And no the problem is not that I already checked inspecting at run-time.. > This is the traceback and it might be related to the fact that it runs > from the > .exe wrapper generated by setuptools: > > Traceback (most recent call last): > ? ?File "c:\python25\scripts\dev_main-script.py", line 8, in > ? ? ?load_entry_point('psi.devsonly==0.1', 'console_scripts', 'dev_main')() > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", > line 152, in main > ? ? ?Develer(ns).full_run() > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", > line 86, in full_run > ? ? ?run(project_name, test_only=self.ns.test_only) > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\environment.py", > line 277, in run > ? ? ?from psi.devsonly.run import Runner > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\run.py", line 7, in > > ? ? ?from psi.workbench.api import Workbench, set_new_dev_main > ImportError: No module named workbench.api > > Another thing which might matter is that I'm launching Envisage > applications, which > heavily rely on the use of entry points, so I guess that if something is > not in the path > the entry point is not loaded automatically (but it can be forced I > guess somehow). > > I solved in another way now, since I also need to keep a dev_main.pth in > site-packages > to make Eclipse happy, just respawning the same process on ImportError works > already perfectly.. There is something strange here. I can not figure out how correct code will fail with the sys.path. It seems to me, the lib you are using is somehow not able to recognize its own structure ("his own sys.path"). Idea. Are you sure you are modifying the sys.path at the right place, understand at the right time when Python processes? I'm using this sys.path tweaking at run time very often; eg to test or to run different versions of the same lib residing in different dirs, and this, in *any* dir and independently of *any* .pth file. jmf From jldunn2000 at gmail.com Thu Feb 2 08:53:22 2012 From: jldunn2000 at gmail.com (loial) Date: Thu, 2 Feb 2012 05:53:22 -0800 (PST) Subject: newbie socket help Message-ID: <4e70f47b-89e4-46bb-929e-9b7db20e7bcc@l16g2000vbl.googlegroups.com> I am trying to write a python script to read data from a printer port using python sockets, but it seems I am locking up the port. Is there a way to ensure that I do not block the port to other applications? My knowledge of python sockets is minimal, so any help would be appreciated. From michal.hantl at gmail.com Thu Feb 2 09:09:13 2012 From: michal.hantl at gmail.com (Michal Hantl) Date: Thu, 2 Feb 2012 06:09:13 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) Message-ID: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Hello, I've been looking for something similar to CoffeeScript, but for python. Does anyone know of such project? So far I haven't found any attempt to do this, so I took few regular expressions and hacked this: https://plus.google.com/116702779841286800811/posts/56sBdwiZ4fT Any advice on what parses to use for the CoffeeScript-like syntaxe? I would like to use parser written in Python so I don't introduce dependencies. Any advice from Python gurus / language experimentators? From research at johnohagan.com Thu Feb 2 09:17:48 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 01:17:48 +1100 Subject: copy on write In-Reply-To: <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> On 02 Feb 2012 09:16:40 GMT Steven D'Aprano wrote: > On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote: > > > You're right, in fact, for me the surprise is that "t[1] +=" is > > interpreted as an assignment at all, given that for lists (and other > > mutable objects which use "+=") it is a mutation. Although as Steven > > says elsewhere, it actually is an assignment, but one which ends up > > reassigning to the same object. > > > > But it shouldn't be both. > > Do you expect that x += 1 should succeed? After all, "increment and > decrement numbers" is practically THE use-case for the augmented > assignment operators. > > How can you expect x += 1 to succeed without an assignment? I don't; obviously, for immutable objects assignment is the only possibility. [...] > > Perhaps you are thinking that Python could determine ahead of time > whether x[1] += y involved a list or a tuple, and not perform the > finally assignment if x was a tuple. Well, maybe, but such an > approach (if possible!) is fraught with danger and mysterious errors > even harder to debug than the current situation. And besides, what > should Python do about non-built-in types? There is no way in general > to predict whether x[1] = something will succeed except to actually > try it. It's not so much about the type of x but that of x[1]. Wouldn't it be possible to omit the assignment simply if the object referred to by x[1] uses "+=" without creating a new object? That way, some_tuple[i] += y will succeed if some_tuple[i] is a list but not with, say, an int. That seems reasonable to me. [...] > > > > In the case above, the failure of the assignment is of no > > consequence. I think it would make more sense if applying "+=" to a > > tuple element were treated (by the interpreter I suppose) only on > > the merits of the element, and not as an assignment to the tuple. > > How should the interpreter deal with other objects which happen to > raise TypeError? By always ignoring it? > > x = [1, None, 3] > x[1] += 2 # apparently succeeds > > Or perhaps by hard-coding tuples and only ignoring errors for tuples? > So now you disguise one error but not others? I'm not suggesting either of those. None can't be modified in place. But for objects which can, wouldn't omitting the final assignment prevent the TypeError in the first place? John From bv5bv5bv5 at yahoo.com Thu Feb 2 09:43:07 2012 From: bv5bv5bv5 at yahoo.com (BV) Date: Thu, 2 Feb 2012 06:43:07 -0800 (PST) Subject: =?windows-1252?B?RVhBTVBMRVMgT0YgUFJPUEhFVJJTIE1FUkNZIFVQT04gTk9OIE1VU0xJTVMgICEhISE=?= =?windows-1252?B?ISEhISEhISEhISE=?= Message-ID: <688d3849-b9ad-43d7-a8ad-100e29c3d0a5@o14g2000vbo.googlegroups.com> EXAMPLES OF PROPHET?S MERCY UPON NON MUSLIMS Ex. No. (1) It was narrated that ?Aisha, May Allah be pleased with her, said to the Prophet, Peace be upon him: "Have you ever come across a day harder than the day ofUhod (one of the battles with the polytheists, in which Muslims were defeated failing to comply with the Prophet's instructions)?" He replied: "I have suffered from your people a lot. The hardest I suffered was on the day of Akaba (a place name). I brought out my message to Abd Yaleil bin Abd Kalal. He did not respond positively to what I called him for. I left there with a grief- stricken face. I did not wake up from that feeling, until I was near Karn-Ath-Tha-aleb (a place name). I raised my head, where I found a cloud casting its shadow over me. Upon looking, I saw Jibril (the angel) into it. He called upon me: Allah (the Almighty) has heard the saying of your people, and what kind of reply they gave to you. Allah has sent the angel of the mountains for you ready to do with them whatever you ask. The angel of the mountains called, and saluted me saying: "Oh Muhammad, what I do will be as you request. If you want, I close the two mountains on them?" The Prophet, Peace be upon him, replied: "Instead of that, I am hoping that Allah (the Al mighty) will create from their offspring people who worship Allah alone, without ascribing partners unto Him" narrated by Al Bukhari. Ex. No. (2): It was narrated that Ibn-Omar (the son of Omar), May Allah be pleased with both of them, said that after one of the battles of the Prophet PBUH, a woman was found killed. In response, the Prophet PBUH prohibited the killing of women and children. Narrated by Al Bukhari. Ex. No. (3): Anas-bin-Malek, May Allah be pleased with him, said: A Jewish youth who served the Prophet, Peace be upon him, became ill, and the Prophet paid him a visit. The Prophet, peace be upon him, sat near the youth's head, and he spoke to him saying: "Embrace Islam". The youth averted his eyes towards his father, who was also beside him. The father told his son: "ObeyAbal-Kassem (one of the common names of the Prophet PBUH)". The youth embraced Islam (before dying), and the Prophet, peace be upon him, went out saying: "Thanks to Allah (the Almighty) Who rescued him from hellfire." narrated by Al Bukhari. Ex. No. (4): Abdullah Ibn-Amr, May Allah be pleased with both, reported that the Prophet, peace be upon him, said: "He who kills a promisor (a non-Muslim living among Muslims where he is promised to have protection, and he promises not to help enemies against Muslims, hence, he is called 'a promisor'), will not smell the fragrance of paradise, though its fragrance is recognizable from a distance of forty years." narrated by Al Bukhari. Ex. No. (5): Boraida-bin-Al-Hosaib reported that when the Prophet, peace be upon him, delegated a prince to lead an army or a small army, he advised him, and Muslims with him, to be devoted to Allah, and to act to the common good. Then, he said: "Your battle should be in the name of Allah, and for His sake. Fight disbelievers. Fight, but don't exaggerate, don't cheat, don't mutilate, don't kill a new-born child. If you meet your enemies of polytheists call them for one of three options. Whatever they take, you must accept, and stop fighting them. Call them to Islam. If they take it, accept, and stop fighting them. Then call them to transfer from their home to the home of immigrants (Al Madina, or Hijra house, where all Muslims, at the start of Islam gathered). Tell them if they do so, they will have the same rights and duties of the immigrants. If, however, their choice was not to transfer from home, their status will be the same as the Muslim Bedouins (away in the desert), by the command of Allah not having the right for spoils or almsgiving unless they join holy war (Jihad) beside other Muslims. If they refused (Islam) ask them to pay the tribute (tax taken from non-Muslims for protection). If they gave a positive reply, accept that, and stop fighting them. If they refused, seek the help of Allah, and fight them. If you lay a siege around a fortress, and they ask to have the warranty of Allah and the warranty of his Messenger, do not give them the warranty of Allah and the warranty of his Messenger. But give them your warranty and the warranty of your companions. Observing your warranty and the warranty of your companions will be easier than observing the warranty of Allah and the warranty of his Messenger. If you lay a siege around a fortress, and its people ask to be brought down to thejudgement of Allah, don't bring them down to the judgement of Allah. But, bring them down to your own judgement, since; you never know whether yourjudgement will be the same as the right judgement of Allah about them or not." narrated by Muslim. Ex. No. (6): Abu Huraira, May Allah be pleased with him, reported that the Prophet, Peace be upon him, delegated some horsemen to a place called Najd . The horsemen captured a man from the tribe of Bani-Hanifa called Thomama-bin-Athal. They tied the captive to one of the posts in the mosque. The Prophet, Peace be upon him, came out to him saying: "How do you find yourself Thomama?" Thomama replied: "Good, Muhammad. If you kill me, you shed (retaliatory) blood. If you pardon me, you do a favour to an appreciative person. If you are seeking money, ask whatever amount you want." He was left until the next day. The Prophet, Peace be upon him, asked him the same question (the next day), and he replied "The same like yesterday, if you pardon me, you do a favour to an appreciative person". The Third day, The Prophet, Peace be upon him, asked him the same question, and the captive gave the same reply. The Prophet, Peace be upon him, said" "Set Thomama free!". Thomama went to a place near the mosque where he washed (did ablution; Wudu?), and came back to the mosque giving the testimony "I bear witness that there is no God but Allah, and Muhammad is the Messenger of Allah". Then, he added: "I swear by Allah, that on earth no face was more hateful to me than your face. Now, your face is the one I love most. I swear by Allah, your religion was the one I disliked most. Now, it is the religion I like most. I swear by Allah, your city was the worst place for me. Now, it is your city which I like most. Your horsemen took me, when I was going for Omra (a smaller pilgrimage out of the normal time of Haj that was also practiced by polytheists before Islam imitating the monotheist religion of Abraham, PBUH). So, what is your decision?" The Prophet, Peace be upon him, announced him and ordered him to go for Omra. When he went toMakkah, somebody there said to him: "You have changed your religion!" (a shameful accusation for them) "No." he replied, "But I joined Islam with Muhammad, Peace be upon him. From now on, you will not receive even one grain of wheat from (my land) Al-Yamama, unless by the permission of the Prophet, Peace be upon him." narrated by Al Bukhari. Ex. No. (7): Khalid-bin-Al-Walid, May Allah be pleased with him, said: "I joined the Prophet, Peace be upon him, at the battle of Kheibar, where the Jews came complaining that people were harrying to their warehouses." (In response), the Prophet, Peace be upon him, said: "The possessions of promisors are not permissible unless by a rightful claim". Narrated by Abu-Dawood with a sound reference. Ex. No. (8): Sahel-bin-Saad-As-Sa?edi, May Allah be pleased with him, reported that he heard the Prophet, Peace be upon him, saying on the day of Kheibar battle: "I will give the flag to the man that Allah brings victory through him" The companions stood up to see which of them will be given the flag. Then, he said: "Where is Ali?" He was given the answer that Ali, May Allah be pleased with him, was suffering from pain in his eyes. He called Ali, supplicated Allah (the Almighty) for Ali's cure, spitting in Ali's eyes. Ali was cured on the spot, as if he suffered no pain. Ali, May Allah be pleased with him, said: "We fight them until they are (Muslims) like us"? The Prophet, Peace be upon him, replied "Wait until you are on their land. Then, call them to Islam, and tell them their duties, I swear, that if Allah guided even a single man through you, will be better for you than getting the most expensive livestock." narrated by Al Bukhari, and Muslim. Ex. No. (9): It was reported that Abu Huraira, May Allah be pleased with him, said that the Prophet, Peace be upon him, was asked to invoke Allah (the Almighty) against polytheists. He replied: "I was not sent out for cursing, I was sent out as a mercy" narrated by Muslim. Ex. No. (10): It was reported that Abu Huraira, May Allah be pleased with him, said: "I called my mother for Islam, when she was still a polytheist. One day, upon calling her, she said to me words about the Prophet,Peace be upon him that I hate. I went to the Prophet, Peace be upon him, crying. I said: "Messenger of Allah! I was calling my mother to Islam, but she was refusing. Today, I called her, but she said to me words about you that I hate. Supplicate that Allah (the Almighty) guide mother of Abu Huraira to Islam". At that the Prophet, Peace be upon him, said: "Oh Allah! I call upon you to guide the mother ofAbu Huraira". I went out very happy at the supplication of the Prophet, Peace be upon him. Going back home, when I was near the door, my mother heard my steps. "Stay where you are Abu Huraira!" she shouted. I heard the sound of pouring water. Then, after washing, dressing, and putting on her veil, she opened the door, and said: "AbuHuraira, I bear witness that there is no God but Allah, and thatMuhammad (PBUH) is His Slave and His Messenger" I went back to the Prophet, Peace be upon him, crying this time out of joy, and I said to him: "Oh Messenger of Allah! I have the good news that Allah (the Almighty) responded to your supplication, and guided the mother of Abu Huraira". The Prophet,Peace be upon him, thanked Allah, and praised Him, and said good words. Then, I said: "Oh, Messenger of Allah! Supplicate Allah that His slaves and believers love both me and my mother, and make us love believers. The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to make this little slave of yours ? he means Abu Huraira ? and his mother, beloved to your slaves and believers, and make your slaves and believers beloved to them." No believer on earth who heard of me or saw me, but he loved me" narrated by Muslim. Ex. No. (11): It was reported that Abu Huraira, May Allah be pleased with him, said: "Tofail-bin-Amr-Ad-Dawsi and his companions, came to the Prophet, Peace be upon him, and said: "Messenger of Allah! Daws (a tribe name) disobeyed and revolted against us, invoke Allah (the Almighty) against them. Thinking that the Prophet PBUH would do that, the people said: "Aws has perished". The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to favour Awas with your guidance, and bring them". Narrated by Bukhary Ex. No. (12): It was reported that Jabir-bin-Abdullah, May Allah be pleased with both of them said: "Oh! "Messenger of Allah, we have been hit severely by the fire arrows of Thakif (a tribe name), invoke Allah (the Almighty) against them. The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to favour Thakif with your guidance" narrated by Al-Tirmizi with a sound reference. From:http://www.rasoulallah.net/v2/index.aspx?lang=en From chris at simplistix.co.uk Thu Feb 2 11:17:49 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 02 Feb 2012 16:17:49 +0000 Subject: Startup Chile Company Looking For Founding Developer/CTO In-Reply-To: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> References: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> Message-ID: <4F2AB72D.4030605@simplistix.co.uk> On 01/02/2012 18:38, Jennifer Turliuk wrote: > My name is Jennifer Turliuk. I'm currently in Santiago, Chile for the > next 6 months as part of the Startup Chile program. I think you may be > able to help me out. We are looking to bring on a developer ASAP (see > description below). Please don't spam the list with job adverts, please use the job board instead: http://www.python.org/community/jobs/howto/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From p.f.moore at gmail.com Thu Feb 2 11:27:27 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:27:27 -0800 (PST) Subject: Windows: How do I copy a custom build of Python into a directory structure matching an MSI install? Message-ID: <34779f70-4709-4a31-b2f9-9ae5aca5e118@y10g2000vbn.googlegroups.com> I've got a build of Python (3.3) on my Windows PC. Everything is built, I believe (core, all modules, HTML help, etc). I want to "install" it on my PC (because tools like virtualenv expect a standard install layout, and the checkout basically isn't). I tried using Tools/msi/msi.py to build an installer, but it's making lots of assumptions and it's just becoming a pain (it's started asking me for certificates, and I need cabarc.exe). So I'm giving up on that approach, and just want to move the files into the right places. I can probably just copy stuff around till it works. I might even be able to decipher msi.py and work out how the installer lays things out. But I'm lazy, and I'm hoping that someone already knows and can tell me, or point me to some documentation that I've missed. In return, I'm willing to share the script I write to do the copying :-) Can anyone help? Thanks, Paul. From python at mrabarnett.plus.com Thu Feb 2 11:28:28 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 02 Feb 2012 16:28:28 +0000 Subject: copy on write In-Reply-To: <87haz9o6a9.fsf@xemacs.org> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <87haz9o6a9.fsf@xemacs.org> Message-ID: <4F2AB9AC.3050608@mrabarnett.plus.com> On 02/02/2012 10:53, Hrvoje Niksic wrote: > Steven D'Aprano writes: > >> Perhaps you are thinking that Python could determine ahead of time >> whether x[1] += y involved a list or a tuple, and not perform the >> finally assignment if x was a tuple. Well, maybe, but such an approach >> (if possible!) is fraught with danger and mysterious errors even >> harder to debug than the current situation. And besides, what should >> Python do about non-built-in types? There is no way in general to >> predict whether x[1] = something will succeed except to actually try >> it. > > An alternative approach is to simply not perform the final assignment if > the in-place method is available on the contained object. No prediction > is needed to do it, because the contained object has to be examined > anyway. No prediction is needed, just don't. Currently, > lhs[ind] += rhs is implemented like this: > > item = lhs[ind] > if hasattr(item, '__iadd__'): > lhs.__setitem__(ind, item.__iadd__(rhs)) > else: > lhs.__setitem__(ind, item + rhs) > # (Note item assignment in both "if" branches.) > > It could, however, be implemented like this: > > item = lhs[ind] > if hasattr(item, '__iadd__'): > item += rhs # no assignment, item supports in-place change > else: > lhs.__setitem__(ind, lhs[ind] + rhs) > > This would raise the exact same exception in the tuple case, but without > executing the in-place assignment. On the other hand, some_list[ind] += 1 > would continue working exactly the same as it does now. > > In the same vein, in-place methods should not have a return value > (i.e. they should return None), as per Python convention that functions > called for side effect don't return values. > > The alternative behavior is unfortunately not backward-compatible (it > ignores the return value of augmented methods), so I'm not seriously > proposing it, but I believe it would have been a better implementation > of augmented assignments than the current one. > [snip] Could it not perform the assignment if the reference returned by __iadd__ is the same as the current reference? For example: t[0] += x would do: r = t[0].__iadd__(x) if t[0] is not r: t[0] = r Should failed assignment be raising TypeError? Is it really a type error? From p.f.moore at gmail.com Thu Feb 2 11:30:10 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:30:10 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Feb 2, 2:09?pm, Michal Hantl wrote: > ?I've been looking for something similar to CoffeeScript, but for python. > > Does anyone know of such project? Isn't CoffeeScript just a compiler to convert a cleaner syntax into Javascript? If so, why would you need such a thing for Python, where the syntax is already clean and simple? :-) Paul. From jeanpierreda at gmail.com Thu Feb 2 12:12:33 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 12:12:33 -0500 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Thu, Feb 2, 2012 at 11:30 AM, Paul Moore wrote: > Isn't CoffeeScript just a compiler to convert a cleaner syntax into > Javascript? If so, why would you need such a thing for Python, where > the syntax is already clean and simple? :-) Coffeescript is a more functional syntax. On that note, Python isn't as functional as it could be. e.g. the "Python Coffeescript" could add pattern matching or TCO or something. -- Devin From jeanpierreda at gmail.com Thu Feb 2 12:21:37 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 12:21:37 -0500 Subject: copy on write In-Reply-To: <4F2AB9AC.3050608@mrabarnett.plus.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <87haz9o6a9.fsf@xemacs.org> <4F2AB9AC.3050608@mrabarnett.plus.com> Message-ID: On Thu, Feb 2, 2012 at 11:28 AM, MRAB wrote: > Should failed assignment be raising TypeError? Is it really a type > error? A failed setitem should be a TypeError as much as a failed getitem should. Should 1[0] be a TypeError? -- Devin From tjreedy at udel.edu Thu Feb 2 12:25:00 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 12:25:00 -0500 Subject: copy on write In-Reply-To: <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: On 2/2/2012 9:17 AM, John O'Hagan wrote: > It's not so much about the type of x but that of x[1]. Wouldn't it be > possible to omit the assignment simply if the object referred to by > x[1] uses "+=" without creating a new object? That way, some_tuple[i] > += y will succeed if some_tuple[i] is a list but not with, say, an > int. That seems reasonable to me. There was considerable discussion of the exact semantics of augmented operations when they were introduced. I do not remember if that particular idea was suggested (and rejected) or not. You could try to look at the PEP, if there is one, or the dicussion ( probably on pydev list). -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Thu Feb 2 12:56:54 2012 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Thu, 02 Feb 2012 17:56:54 +0000 Subject: Python book reviews Message-ID: There are several at www.accu.org and select (strangely enough :) book reviews for anyone who may be interested. -- Cheers. Mark Lawrence. From amirouche.boubekki at gmail.com Thu Feb 2 13:17:13 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Thu, 2 Feb 2012 19:17:13 +0100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: They are solution to write Python code that translates to javascript see this thread http://mail.python.org/pipermail/python-list/2011-November/1283110.html 2012/2/2 Michal Hantl > Hello, > I've been looking for something similar to CoffeeScript, but for python. > > Does anyone know of such project? > > > So far I haven't found any attempt to do this, so I took few regular > expressions and hacked this: > https://plus.google.com/116702779841286800811/posts/56sBdwiZ4fT > > Any advice on what parses to use for the CoffeeScript-like syntaxe? I > would like to use parser written in Python so I don't introduce > dependencies. > > Any advice from Python gurus / language experimentators? > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincenzo.forgetta at mail.mcgill.ca Thu Feb 2 13:42:44 2012 From: vincenzo.forgetta at mail.mcgill.ca (Vince Forgetta) Date: Thu, 2 Feb 2012 13:42:44 -0500 Subject: distribute and reference static content in a python package Message-ID: <1328208164.15687.17.camel@muon> Hi, I have developed a python program that contains multiple python modules and static content in the form of fonts (pil,pbm and tff files), html, images, css and javascript. I want to share the program with others as a python package. I have followed the instructions at http://guide.python-distribute.org/creation.html I have created an identical structure (apart from directory naming) as specified in the link, with the exception of a "static" directory within the module directory (towelstuff in the example). Within this directory are sub-directories named "css", "html", "images", "fonts" and "js". TowelStuff/ bin/ run.py CHANGES.txt docs/ LICENSE.txt MANIFEST.in README.txt setup.py towelstuff/ __init__.py module1.py module2.py static/ images/someimage.png css/ html/ js/ fonts/ When the user install the program using "python setup.py install", the modules (in towelstuff) are copied to the common python library path (e.g. /usr/lib/python2.7/site-packages/), but the static content is not (understandably). What is common method to distribute static content, and how to I make reference to it in my python program? For programs in TowelStuff/bin (i.e. run.py), I currently make reference to the static content like so: sys.path[0] + "../towelstuff/static/images/someimage.png" I am sure there is a more pythonic way of doing this ... Thanks in advance for the help. Vince From forgetta at gmail.com Thu Feb 2 14:09:26 2012 From: forgetta at gmail.com (Vince Forgetta) Date: Thu, 02 Feb 2012 14:09:26 -0500 Subject: distribute and reference static content in a python package In-Reply-To: <1328208164.15687.17.camel@muon> References: <1328208164.15687.17.camel@muon> Message-ID: <1328209766.15687.20.camel@muon> I assume this is an appropriate solution to my problem: http://docs.python.org/distutils/setupscript.html#installing-additional-files On Thu, 2012-02-02 at 13:42 -0500, Vince Forgetta wrote: > Hi, > > I have developed a python program that contains multiple python modules > and static content in the form of fonts (pil,pbm and tff files), html, > images, css and javascript. > > I want to share the program with others as a python package. I have > followed the instructions at > > http://guide.python-distribute.org/creation.html > > I have created an identical structure (apart from directory naming) as > specified in the link, with the exception of a "static" directory within > the module directory (towelstuff in the example). Within this directory > are sub-directories named "css", "html", "images", "fonts" and "js". > > TowelStuff/ > bin/ > run.py > CHANGES.txt > docs/ > LICENSE.txt > MANIFEST.in > README.txt > setup.py > towelstuff/ > __init__.py > module1.py > module2.py > static/ > images/someimage.png > css/ > html/ > js/ > fonts/ > > > When the user install the program using "python setup.py install", the > modules (in towelstuff) are copied to the common python library path > (e.g. /usr/lib/python2.7/site-packages/), but the static content is not > (understandably). > > What is common method to distribute static content, and how to I make > reference to it in my python program? > > For programs in TowelStuff/bin (i.e. run.py), I currently make reference > to the static content like so: > > sys.path[0] + "../towelstuff/static/images/someimage.png" > > I am sure there is a more pythonic way of doing this ... > > Thanks in advance for the help. > > Vince From mwilson at the-wire.com Thu Feb 2 14:42:15 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Thu, 02 Feb 2012 14:42:15 -0500 Subject: python reliability with EINTR handling in general modules References: Message-ID: Dennis Lee Bieber wrote: > On Wed, 1 Feb 2012 23:25:36 -0800 (PST), oleg korenevich > wrote: > > >>Thanks for help. In first case all vars is python integers, maybe >>math.floor is redundant, but i'm afraid that same error with math >>module call will occur in other places of app, where math is needed. >>Strange thing here is that math library call is not a system call, and >>strange exception ValueError (all values have right values) and why in >>braces i have (4, Interruted system call). >> > math.floor() may still be a system call of some sort if access to > the math processor requires synchronization between processes (that is, > the math processor/registers are maintained as a separate structure > apart from the task status during process switches). {Yes -- that is a > wild hypothesis} One thing to remember about errno is that C library code will set it to a non-zero value when an error is encountered, but (I believe) there's no requirement to clear it in the absence of an error. EINTR might just be left over from some long-gone I/O call, then reported "just in case" in handling an exception that didn't involve the C library at all. As a C coder there are times when it's wise to clear errno yourself to make sure your code doesn't get fooled. Mel. From michal.hantl at gmail.com Thu Feb 2 15:23:16 2012 From: michal.hantl at gmail.com (Michal Hantl) Date: Thu, 2 Feb 2012 12:23:16 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: <13539673.900.1328214196126.JavaMail.geo-discussion-forums@vbhn11> See the link I attached. Ruby-like blocks would be nice too. Implicit returns. Better strings like """My name is #{name}""". From stefan at bytereef.org Thu Feb 2 15:54:04 2012 From: stefan at bytereef.org (Stefan Krah) Date: Thu, 2 Feb 2012 21:54:04 +0100 Subject: [ANN] cdecimal-2.3 released Message-ID: <20120202205404.GA18353@sleipnir.bytereef.org> Hi, I'm pleased to announce the release of cdecimal-2.3. cdecimal is a fast drop-in replacement for the decimal module in Python's standard library. Blurb ===== cdecimal is a complete implementation of IBM's General Decimal Arithmetic Specification. With the appropriate context parameters, cdecimal will also conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Typical performance gains over decimal.py are between 30x for I/O heavy benchmarks and 80x for numerical programs. In a PostgreSQL database benchmark, the speedup is 12x. +---------+-------------+--------------+-------------+ | | decimal | cdecimal | speedup | +=========+=============+==============+=============+ | pi | 42.75s | 0.58s | 74x | +---------+-------------+--------------+-------------+ | telco | 172.19s | 5.68s | 30x | +---------+-------------+--------------+-------------+ | psycopg | 3.57s | 0.29s | 12x | +---------+-------------+--------------+-------------+ In the pi benchmark, cdecimal often performs better than Java's BigDecimal running on Java HotSpot(TM) 64-Bit Server VM. What's New ========== o The underlying library - libmpdec - now has a very comprehensive test suite against decNumber. o libmpdec now has full support for compilers without uint64_t. o Code coverage of cdecimal has been increased to 100%. Now both libmpdec and cdecimal have 100% coverage. o Improved code for conversion of small Python integers to Decimals leads to a performance gain of around 15%. o Added real(), imag(), conjugate(), __complex__() methods. o Add Fraction and complex comparisons (enabled for Python 3.2). o Support for DecimalTuple output. Stability ========= Both cdecimal and libmpdec have an extremely conservative release policy. When new features are added, the complete test suite is run both with and without Valgrind on many different platforms. With the added tests against decNumber, this takes around 8 months on four cores. Install ======= Since cdecimal is listed on PyPI, it can be installed using pip: pip install cdecimal Windows installers are available at: http://www.bytereef.org/mpdecimal/download.html Links ===== http://www.bytereef.org/mpdecimal/index.html http://www.bytereef.org/mpdecimal/changelog.html http://www.bytereef.org/mpdecimal/download.html Checksums of the released packages ================================== 03f76f4acbb6e7f648c6efc6e424bbc1b4afb5632dac5196f840e71f603a2b4a mpdecimal-2.3.tar.gz b0fd5bec2cc6a6035bc406339d020d2f4200a7dce8e8136a2850612a06508ed1 mpdecimal-2.3.zip d737cbe43ed1f6ad9874fb86c3db1e9bbe20c0c750868fde5be3f379ade83d8b cdecimal-2.3.tar.gz 84afd94126549a3c67c3bab7437d085347f9d05c cdecimal-2.3.win-amd64-py2.6.msi ba0fbb1f9314dcef29481414a5c3496ec159df2e cdecimal-2.3.win-amd64-py2.7.msi d11bbd560e9cb9d34b0e7a068ac1c1eac5371428 cdecimal-2.3.win-amd64-py3.1.msi d024148ea603dc8e82f8371ebdfaa0e65f5a9945 cdecimal-2.3.win-amd64-py3.2.msi d196a9e0b44dcb75bbf4eda44078b766e6113f72 cdecimal-2.3.win32-py2.6.msi e2b044da6c241df0911059216821c9865cb9e4f0 cdecimal-2.3.win32-py2.7.msi 7e8b47eb3a2f50191e76f981fbe55050f13495e8 cdecimal-2.3.win32-py3.1.msi 61be767b91aab0ba0d602fb2b23f6d882cafec05 cdecimal-2.3.win32-py3.2.msi a2278910a5b447af963e1d427dbeb48f49e377be cdecimal-2.3-no-thread.win-amd64-py2.6.msi 8da96d2f1ab1a98062cd43cb4f381b47309d8c22 cdecimal-2.3-no-thread.win-amd64-py2.7.msi 85cd3ff4496aa7e0d0979d1695eef27cc7735c28 cdecimal-2.3-no-thread.win-amd64-py3.1.msi 6c179a1284aceb3a7bfc481daae1d7d60359d487 cdecimal-2.3-no-thread.win-amd64-py3.2.msi 40f245e907512c5d3602ba5993755a0b4b67ca80 cdecimal-2.3-no-thread.win32-py2.6.msi 960eb9bfd9fcf0faee6493506c1917d46536193a cdecimal-2.3-no-thread.win32-py2.7.msi 42b651ee1bf4c94611c43522d69f1965515949b8 cdecimal-2.3-no-thread.win32-py3.1.msi ec26f14c35502d1d5488d440d7bc22ad41e9ac65 cdecimal-2.3-no-thread.win32-py3.2.msi From jeandupont115 at gmail.com Thu Feb 2 15:57:55 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Thu, 2 Feb 2012 12:57:55 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] Message-ID: I'd like to read in the output of a voltcraft vc960 voltmeter connected to a usb-port. I found the perl-script below but I'd like to accomplish the same with python: I guess I have to use the module serial but I don't know how I should set the serial parameters so they are the same as in the perl-script. Could someone supply me the command for setting the serial-parameters correctly in Python? thanks Jean #!/usr/bin/perl use strict; use warnings; use Device::SerialPort; die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; my ($devicepath) = @ARGV; my $port = new Device::SerialPort($devicepath); die "Couldn't open serial port" if ! defined $port; $port->baudrate(2400); $port->databits(8); $port->parity("none"); $port->stopbits(1); $port->handshake("none"); $port->rts_active(0); $port->dtr_active(1); #$port->read_char_time(5); # wait 5ms per character $port->read_const_time(200); # 0.2 second per unfulfilled "read" call $| = 1; # autoflush STDOUT while(1) { my ($nin, $in) = $port->read(255); print $in; } $port->close; From edriscoll at wisc.edu Thu Feb 2 16:20:48 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Thu, 02 Feb 2012 15:20:48 -0600 Subject: copy on write In-Reply-To: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> Message-ID: <4F2AFE30.80203@wisc.edu> On 01/-10/-28163 01:59 PM, 88888 Dihedral wrote: >> If you're working in C++ and overload your operators so that 'a +=' >> and 'a = + b' have different observable behaviors (besides perhaps >> time), then either your implementation is buggy or your design is very >> bad-mannered. >> >> Evan > > Do you mean the result instances after 'a+= and 'a=a+b' or > the actions of behaviors of instances involved in performing 'a+= and 'a=a+b'? > I mean "if which operation you called is distinguishable in any way besides the time it takes to run or by tracing it through in a debugger" That means: 1. The value of 'a' should be the same after executing 'a+=b' and 'a=a+b' 2. The actual result of the expression should be the same in both cases (in both cases it should be a reference to a) 3. Any additional side effects performed (ew!) should be the same in both cases Evan From miki.tebeka at gmail.com Thu Feb 2 16:55:45 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 2 Feb 2012 13:55:45 -0800 (PST) Subject: simple system for building packages for multiple platforms? In-Reply-To: References: Message-ID: <27818322.1316.1328219745948.JavaMail.geo-discussion-forums@yqtt30> IMO you can have different versions of Python on the same machine. So it's two windows machines. (Assuming you're going with *one* OS version :) Also note there is some legal mambo jumbo around distributing MSVC DLLs (unless you plan to use mingw). From miki.tebeka at gmail.com Thu Feb 2 16:55:45 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 2 Feb 2012 13:55:45 -0800 (PST) Subject: simple system for building packages for multiple platforms? In-Reply-To: References: Message-ID: <27818322.1316.1328219745948.JavaMail.geo-discussion-forums@yqtt30> IMO you can have different versions of Python on the same machine. So it's two windows machines. (Assuming you're going with *one* OS version :) Also note there is some legal mambo jumbo around distributing MSVC DLLs (unless you plan to use mingw). From andrea.crotti.0 at gmail.com Thu Feb 2 17:53:21 2012 From: andrea.crotti.0 at gmail.com (andrea crotti) Date: Thu, 2 Feb 2012 22:53:21 +0000 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: 2012/2/2 Amirouche Boubekki : > They are solution to write Python code that translates to javascript see > this thread > http://mail.python.org/pipermail/python-list/2011-November/1283110.html > Mm I don't think it's what the OP is asking (unless I misunderstood...). I think he wants to compile some syntax TO Python. But I don't really see why you would something like this (if not for fun). Then how are you going to maintain the code? Maintain the compiled code or the source? And proving that your translator is always correct I think it's quite a hard task too... From ivanov161 at gmail.com Thu Feb 2 18:37:03 2012 From: ivanov161 at gmail.com (=?KOI8-U?B?88XSx8XKIPfMwcTJzcnSz9fJ3g==?=) Date: Fri, 3 Feb 2012 01:37:03 +0200 Subject: Python embeded in c++ application. Can't load python module if application is placed in folder with unicode chars. Message-ID: Hello. Please help me to import python module in my application that has python 2.7.2 embeded. I tried example from this link http://docs.python.org/extending/embedding.html#embedding-python-in-c paragraph 5.3. If i place program in folder D:\temp\test_python\test_python?vnes p?\Debug I will get error - Failed to load "multiply". My localization settings (system language) don't correspond the chars' language used in path. From tjreedy at udel.edu Thu Feb 2 19:26:27 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 19:26:27 -0500 Subject: Python embeded in c++ application. Can't load python module if application is placed in folder with unicode chars. In-Reply-To: References: Message-ID: On 2/2/2012 6:37 PM, ?????? ???????????? wrote: > Hello. Please help me to import python module in my application that > has python 2.7.2 embeded. > I tried example from this link > http://docs.python.org/extending/embedding.html#embedding-python-in-c > paragraph 5.3. > If i place program in folder D:\temp\test_python\test_python?vnes > p?\Debug I will get error - Failed to load "multiply". > My localization settings (system language) don't correspond the chars' > language used in path. Easiest is to change your folder name to all ascii. This sort of thing will work better in future 3.x, but even then, a mismatch between encodings is a problem. -- Terry Jan Reedy From ramit.prasad at jpmorgan.com Thu Feb 2 19:53:38 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Fri, 3 Feb 2012 00:53:38 +0000 Subject: unzip function? In-Reply-To: <4f1753cc$0$29987$c3e8da3$5496439d@news.astraweb.com> References: <4f16e4e7$0$29994$c3e8da3$5496439d@news.astraweb.com> <4f1753cc$0$29987$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF47410D75F@SCACMX008.exchad.jpmchase.net> >>> If you understand what zip does, it should be obvious. >> >> Nobody likes to be told the thing they're confused about is trivial. >Nobody likes to be told to brush their teeth, eat their vegetables or clean their room. Then they grow up and learn that life is full of things that you do because you have to, not because you want to. >Learning that some things that they are confused about are trivial is one of those things. Normally, I agree with you, but I think it's less about the truth and how it is stated. "You are wrong, it is like..." VS. "You are a grade-A moron, it is like..." They both teach; one just does it less offensively. What is obvious to one person is not always obvious to everyone. :) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From jason at powerpull.net Thu Feb 2 20:04:32 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 3 Feb 2012 01:04:32 +0000 Subject: Use logging level across application and modules Message-ID: Base module: http://pastebin.com/nQCG5CRC Another module: http://pastebin.com/FFzCCjwG Application: http://pastebin.com/370cWJtT I have a module that will provide base functionality, such as logging and authentication. I have other specialized modules that provide additional functionality. One module will provide database connections, another information about users and groups, etc. I have an application script that uses the base module and one or more specialized modules. I want to allow the user to select a preferred logging level. That is easy to do by passing that level as an argument to base.get_logger(). However, the application also uses the other module; how do I set the logging level there to match the user's preference? From emayssat at gmail.com Thu Feb 2 20:09:15 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Thu, 2 Feb 2012 17:09:15 -0800 Subject: multiple constructor __init__ Message-ID: Hello all, I would like to instantiate my class as follow QObject(, ) QObject() an example would be http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html How can I do this without have to specify parent= in the second version (I always need to supply the parent parameter, but I would like to supply it last) I have read this http://stackoverflow.com/questions/356718/how-to-handle-constructors-or-methods-with-a-different-set-or-type-of-argument but all the suggested methods do not work as I want Any idea? -- Emmanuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 2 20:19:22 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 2 Feb 2012 18:19:22 -0700 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Thu, Feb 2, 2012 at 3:53 PM, andrea crotti wrote: > 2012/2/2 Amirouche Boubekki : >> They are solution to write Python code that translates to javascript see >> this thread >> http://mail.python.org/pipermail/python-list/2011-November/1283110.html >> > > Mm I don't think it's what the OP is asking (unless I misunderstood...). > I think he wants to compile some syntax TO Python. > But I don't really see why you would something like this (if not for fun). Maybe because you think that Python syntax could be improved upon -- for instance, Python with pattern-matching would be freaking awesome -- but at the same time you want to leverage Python's extensive ecosystem of libraries. So instead of creating your own brand-new language with no third party libraries whatsoever, you create one that just compiles down to regular Python. > Then how are you going to maintain the code? Maintain the compiled > code or the source? As with all compiled software, you maintain the input, not the output. > And proving that your translator is always correct That's what unit tests are for. Cheers, Ian From clp2 at rebertia.com Thu Feb 2 20:24:23 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 2 Feb 2012 17:24:23 -0800 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: On Thu, Feb 2, 2012 at 5:09 PM, Emmanuel Mayssat wrote: > Hello all, > > I would like to instantiate my class as follow > > QObject(, ) > QObject() > > an example would be > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html > > How can I do this without have to specify parent= in the second > version > (I always need to supply the parent parameter, but I would like to supply it > last) > > I have read this > http://stackoverflow.com/questions/356718/how-to-handle-constructors-or-methods-with-a-different-set-or-type-of-argument > but all the suggested methods do not work as I want > > Any idea? I believe you can approximate that using a keyword-only argument without a default value: # Untested! # Requires Python 3.x class QObject(object): def __init__(self, param1=some_default, *, parent): # ? obj1 = QObject(parent=daddy) obj2 = QObject(arg1, parent=daddy) obj3 = QObject(daddy) # ERROR obj4 = QObject(arg1, daddy) # ERROR obj5 = QObject() # ERROR Cheers, Chris -- Using names instead of some arbitrary ordering makes much more sense. http://rebertia.com From rosuav at gmail.com Thu Feb 2 21:51:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Feb 2012 13:51:49 +1100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Fri, Feb 3, 2012 at 9:53 AM, andrea crotti wrote: > Mm I don't think it's what the OP is asking (unless I misunderstood...). > I think he wants to compile some syntax TO Python. > But I don't really see why you would something like this (if not for fun). > > Then how are you going to maintain the code? Maintain the compiled > code or the source? And proving that your translator is always correct > I think it's quite a hard task too... There's two similar concepts here. 1) Skeleton codegens. You do up some kind of template, run it through a program, and get a ready-to-fill-in code structure. In this case, you don't care so much about the translator's quality (if there's bugs/limitations, you fix 'em after codegenning), and will maintain the compiled code. 2) Compilation to Python. You write your program in some other language, run it through a program, and get executable code out of it. You want the translator to be perfect (so that you don't have to edit the resulting code), and will maintain the original source. I think the OP is looking for #2. I've used that sort of technique a number of times (not with Python specifically, but with other languages that lack certain handy features); usually the source is trivially translateable into the output, with 99% of syntax identical (for instance, one oft-wanted feature is a C-like #include - I've written .php.m4 files that get processed through M4 to become PHP files). ChrisA From research at johnohagan.com Thu Feb 2 22:08:06 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 14:08:06 +1100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: <20120203140806.ffd1f99f8613ac438b8df719@johnohagan.com> On Thu, 02 Feb 2012 12:25:00 -0500 Terry Reedy wrote: > On 2/2/2012 9:17 AM, John O'Hagan wrote: > > > It's not so much about the type of x but that of x[1]. Wouldn't it > > be possible to omit the assignment simply if the object referred to > > by x[1] uses "+=" without creating a new object? That way, > > some_tuple[i] += y will succeed if some_tuple[i] is a list but not > > with, say, an int. That seems reasonable to me. > > There was considerable discussion of the exact semantics of augmented > operations when they were introduced. I do not remember if that > particular idea was suggested (and rejected) or not. You could try to > look at the PEP, if there is one, or the dicussion ( probably on > pydev list). > I think we're 12 years late on this one. It's PEP 203 from 2000 and the key phrase was: "The in-place function should always return a new reference, either to the old `x' object if the operation was indeed performed in-place, or to a new object." If this had read: "The in-place function should return a reference to a new object if the operation was not performed in-place." or something like that, we wouldn't be discussing this. The discussion on py-dev at the time was quite limited but there was some lively debate on this list the following year (in the context of widespread controversy over new-fangled features which also included list comprehensions and generators), to which the BDFL's response was: "You shouldn't think "+= is confusing because sometimes it modifies an object and sometimes it does". Gee, there are lots of places where something that's *spelled* the same has a different effect depending on the object types involved." That's true, but I don't think there should be a different effect depending on what _name_ we use for an operand: >>> t=([],) >>> l=t[0] >>> l is t[0] True >>> l+=[1] >>> t ([1],) >>> t[0]+=[1] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> t ([1, 1],) >>> l is t[0] True Same object, same operator, different name, different outcome. Maybe that was obvious from the foregoing discussion, but it shocked me when put that way. John From tjreedy at udel.edu Thu Feb 2 22:43:16 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 22:43:16 -0500 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote: > Hello all, > > I would like to instantiate my class as follow > > > QObject(, ) > QObject() > > an example would be > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html > > How can I do this without have to specify parent= in the second > version > (I always need to supply the parent parameter, but I would like to > supply it last) The same way range(stop) versus range(start,stop) works. But I really recommend against that api. It makes both doc and code messy. You need a really good reason to not use the obvious def __init__(self, parent, param=default):... -- Terry Jan Reedy From teddy.toyama at gmail.com Thu Feb 2 23:13:25 2012 From: teddy.toyama at gmail.com (Teddy Toyama) Date: Thu, 2 Feb 2012 20:13:25 -0800 Subject: python CPU usage 99% on ubuntu aws instance using eventlet Message-ID: Okay, I am crossposting this from the eventlet dev mailing list since I am in urgent need of some help. I am running eventlet 0.9.16 on a Small (not micro) reserved ubuntu 11.10 aws instance. I have a socketserver that is similar to the echo server from the examples in the eventlet documentation. When I first start running the code, everything seems fine, but I have been noticing that after 10 or 15 hours the cpu usage goes from about 1% to 99+%. At that point I am unable to make further connections to the socketserver. This is the important (hopefully) parts of the code that I'm running: # the part of the code that listens for incoming connections def socket_listener(self, port, socket_type): L.LOGG(self._CONN, 0, H.func(), 'Action:Starting|SocketType:%s' % socket_type) listener = eventlet.listen((self._host, port)) listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) pool = eventlet.GreenPool(20000) while True: connection, address = listener.accept() connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) """ I want this loop to run as fast as possible. I previously grabbed the first message that a plug/device sent here and used that information to add a new object to the socket_hash. Instead of doing that here I've relocated that logic to the spawned object so that this loop is doing as little work as possible. """ L.LOGG(self._CONN, 0, H.func(), 'IPAddress:%s|GreenthreadsFree:%s|GreenthreadsRunning:%s' % (str(address[0]), str(pool.free()),str(pool.running()))) pool.spawn_n(self.spawn_socketobject, connection, address, socket_type) listener.shutdown(socket.SHUT_RDWR) listener.close() The L.LOGG method simply logs the supplied parameters to a mysql table. I am running the socket_listener in a thread like so: def listen_phones(self): self.socket_listener(self._port_phone, 'phone') t_phones = Thread(target = self.listen_phones) t_phones.start() >From my initial google searches I thought the issue might be similar to the bug reported at https://lists.secondlife.com/pipermail/eventletdev/2008-October/000140.html but I am using a new version of eventlet so surely that cannot be it? Is there any additional information I can provide to help further troubleshoot the issue? Teddy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason at powerpull.net Thu Feb 2 23:50:29 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 3 Feb 2012 04:50:29 +0000 Subject: Use logging level across application and modules In-Reply-To: References: Message-ID: > Base module: ?http://pastebin.com/nQCG5CRC > Another module: ?http://pastebin.com/FFzCCjwG > Application: ?http://pastebin.com/370cWJtT > > I have a module that will provide base functionality, such as logging > and authentication. > I have other specialized modules that provide additional > functionality. ?One module will provide database connections, another > information about users and groups, etc. > I have an application script that uses the base module and one or more > specialized modules. > > I want to allow the user to select a preferred logging level. ?That is > easy to do by passing that level as an argument to base.get_logger(). > However, the application also uses the other module; how do I set the > logging level there to match the user's preference? I figured a way to do this. In the base module I created a global variable loglevel. I set the logging level according to that value. I set the variable from my application script. Because of the memoization of the get_logger() call, the other modules get that same loglevel value. From steve+comp.lang.python at pearwood.info Fri Feb 3 00:04:39 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 05:04:39 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 14:08:06 +1100, John O'Hagan wrote: > I think we're 12 years late on this one. It's PEP 203 from 2000 and the > key phrase was: > > "The in-place function should always return a new reference, either to > the old `x' object if the operation was indeed performed in-place, or to > a new object." > > If this had read: > > "The in-place function should return a reference to a new object if the > operation was not performed in-place." > > or something like that, we wouldn't be discussing this. And what should it return if the operation *is* performed in-place? "Don't return anything" is not an option, Python doesn't have procedures. That implies that __iadd__ etc. should return None. But two problems come to mind: 1) Using None as an out-of-band signal to the interpreter to say "don't perform the assignment" makes it impossible for the augmented assignment method to return None as the result. If we only think about numeric operations like x += 1 then we might not care, but once you consider the situation more widely the problem is clear: x = Fact(foo) y = Fact(bar) x & y # Returns a composite Fact, or None if they are contradictory With your suggestion, x &= y fails to work, but only sometimes. And when it fails, it doesn't fail with an explicit exception, but silently fails and then does the wrong thing. This makes debugging a horror. 2) And speaking of debugging, sometimes people forget to include the return statement in methods. Normally, the left hand side of the assignment then gets set to None, and the error is pretty obvious as soon as you try to do something with it. But with your suggestion, instead of getting an exception, it silently fails, and your code does the wrong thing. I suppose that they could have invented a new sentinel, or a special exception to be raised as a signal, but that's piling complication on top of complication, and it isn't clear to me that it's worth it for an obscure corner case. Yes, the current behaviour is a Gotcha, but it's a Gotcha that makes good sense compared to the alternatives. Ultimately, augmented assignment is *assignment*, just like it says on the tin. t[1] += x is syntactic sugar for t[1] = t[1].__iadd__(x). It can't and shouldn't fail to raise an exception if t is a tuple, because tuple item assignment *must* fail. The problem is that lists treat __iadd__ as an in-place optimization, and this clashes with tuple immutability. But if lists *didn't* treat __iadd__ as in-place, people would complain when they used it directly without a tuple wrapper. Perhaps lists shouldn't define += at all, but then people will complain that mylist += another_list is slow. Telling them to use mylist.extend instead just makes them cranky. After all, mylist + another_list works, so why shouldn't += work? Ultimately, there is no right answer, because the multitude of requirements are contradictory. No matter what Python did, somebody would complain. -- Steven From timr at probo.com Fri Feb 3 00:10:12 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Feb 2012 21:10:12 -0800 Subject: changing sys.path References: Message-ID: Andrea Crotti wrote: > >So suppose I want to modify the sys.path on the fly before running some code >which imports from one of the modules added. > >at run time I do >sys.path.extend(paths_to_add) > >but it still doesn't work and I get an import error. Are you actually adding multiple paths? One possible cause for error would be this: sys.path.extend( '/usr/local/lib' ) That succeeds, but it doesn't do what you meant. It adds "/" as a path, then "u", then "s", then "r", and so on. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Feb 3 00:14:52 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Feb 2012 21:14:52 -0800 Subject: Problem sending an email in html with mime image References: Message-ID: <87rmi7pc0b3g2f901re67v6vkb0f0ro0lp@4ax.com> Ariel wrote: > >Hi everybody I have a question, here is my problem I want to send an >email with content in html with an image embed so I converted the >image binary in mime text and then I put the mime code inside the src >attribute of the html like this: > > Do email readers actually implement the data: scheme in tags? >The problem is that if I don't put the image mime code inside the src >the email is sent but when I put the code then the email is not send >and I don't get any error message. There must be something else going on. The content of the message is irrelevant to the sending process, unless it makes your message way too big. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rosuav at gmail.com Fri Feb 3 00:28:05 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Feb 2012 16:28:05 +1100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano wrote: > No matter what Python did, somebody would complain. +1 This is, I think, the ultimate truth of the matter. ChrisA From no.email at nospam.invalid Fri Feb 3 02:33:00 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 02 Feb 2012 23:33:00 -0800 Subject: [ANN] cdecimal-2.3 released References: Message-ID: <7xfwespe1f.fsf@ruckus.brouhaha.com> Stefan Krah writes: > cdecimal is a complete implementation of IBM's General Decimal Arithmetic > Specification. With the appropriate context parameters, cdecimal will also > conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Cool. I wonder when we'll start seeing this in non-IBM hardware CPU's. > Both cdecimal and libmpdec have an extremely conservative release policy. > When new features are added, the complete test suite is run both with and > without Valgrind on many different platforms. With the added tests against > decNumber, this takes around 8 months on four cores. Wow. I wonder whether it's worth looking into some formal verification if the required level of confidence is that high. From nagle at animats.com Fri Feb 3 03:14:33 2012 From: nagle at animats.com (John Nagle) Date: Fri, 03 Feb 2012 00:14:33 -0800 Subject: Killing threads, and os.system() In-Reply-To: References: Message-ID: <4f2b976a$0$78773$742ec2ed@news.sonic.net> On 1/31/2012 8:04 AM, Dennis Lee Bieber wrote: > ({muse: who do we have to kill > to persuade OS designers to incorporate something like the Amiga ARexx > "rexxport" system}). QNX, which is a real-time microkernel which looks like POSIX to applications. actually got interprocess communication right. It has to; everything in QNX is done by interprocess communication, including all I/O. File systems and drivers are ordinary programs. The kernel just handles message passing, CPU dispatching, and timers. QNX's message passing looks more like a subroutine call than an I/O operation, and this has important implications for efficient CPU dispatching. Any QNX system call that can block is really a message pass. Message passes can be given a timeout, and they can be canceled from another thread. The "system call" then returns with an error status. This provides a way to keep threads from getting "stuck" in a system call. (Unfortunately, QNX, which survived as a separate company for decades, sold out to Harmon (car audio) a few years ago. They had no clue what to do with an OS. They sold it to Research In Motion, the Blackberry company, which is in the process of tanking.) Python's thread model is unusually dumb. You can't send signals to other threads, you can't force an exception in another thread, and I won't even get into the appalling mess around the Global Interpreter Lock. This has forced the use of subprocesses where, in other languages, you'd use threads. Of course, you load a new copy of the interpreter in each thread, so this bloats memory usage. John Nagle From antoon.pardon at rece.vub.ac.be Fri Feb 3 04:08:19 2012 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 03 Feb 2012 10:08:19 +0100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2BA403.2020309@rece.vub.ac.be> On 02/03/2012 06:04 AM, Steven D'Aprano wrote: > Ultimately, there is no right answer, because the multitude of > requirements are contradictory. No matter what Python did, somebody would > complain. Which makes me wonder why it was introduced at all, or at least so fast If you see the difference in speed in introducing augmented assignment vs how long it took to get conditional expression I start thinking of a bikeshed. In the first case we have something that raises semantic questions that are difficult to resolve, in the second case the semantics were clear, the big problem that delayed introduction was what syntax to use. But the second took a lot longer to become part of the language than the first, which seems very odd to me. -- Antoon Pardon From steve+comp.lang.python at pearwood.info Fri Feb 3 04:25:36 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 09:25:36 GMT Subject: Killing threads, and os.system() References: <4f2b976a$0$78773$742ec2ed@news.sonic.net> Message-ID: <4f2ba810$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 00:14:33 -0800, John Nagle wrote: > I won't even get into the appalling mess around the Global Interpreter > Lock. You know full well that IronPython and Jython don't have a GIL. If the GIL was as harmful as you repeatedly tell us, why haven't you, and everyone else, migrated to IronPython and Jython? Oh yeah, maybe it's because CPython, even with the GIL, is significantly faster than the two implementations without a GIL. Go figure. But never mind the facts, spreading the FUD about Python is much more fun. Hey, I hear that Python 3 is tanking too, and millions of Python developers are rushing, rushing I say, to port their code to Go. Or was it Ruby? Possibly Lua. Maybe VBScript. > This has forced the use of subprocesses where, in other > languages, you'd use threads. Only if by "forced" you mean "not forced at all". http://docs.python.org/library/multiprocessing.html http://www.stackless.com/ http://pypi.python.org/pypi/greenlet/ http://twistedmatrix.com/trac/ http://www.gevent.org/ http://code.google.com/p/cogen/ http://www.kamaelia.org/Home http://code.google.com/p/syncless/ http://opensource.hyves.org/concurrence/ http://www.tornadoweb.org/ http://docs.python.org/library/asyncore.html http://pyro.sourceforge.net/ http://wiki.python.org/moin/ParallelProcessing -- Steven From mcepl at redhat.com Fri Feb 3 05:42:47 2012 From: mcepl at redhat.com (Matej Cepl) Date: Fri, 03 Feb 2012 11:42:47 +0100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On 3.2.2012 02:19, Ian Kelly wrote: >> Then how are you going to maintain the code? Maintain the compiled >> code or the source? > > As with all compiled software, you maintain the input, not the output. I don't think that's what was the question. CoffeeScript is a hopeless hack in the hopeless situation of Javascript world where no language development is available (meaning, time between filing a bug to the moment the change is useful in The Real World? is many many years). Ask anybody developing in CoffeeScript/Vala how much they love debugging when they have to go through different styles of errors, bugs in the intermediate processes, etc. In the end all these languages IMHO either develop a new frontend for gcc/clang/PyPy (or fork of CPython) or die, because the former is not that much more difficult than writing your preprocessor, I believe. Best, Mat?j From research at johnohagan.com Fri Feb 3 05:47:50 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 21:47:50 +1100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20120203214750.021fe45bdf8c823755b31613@johnohagan.com> On 03 Feb 2012 05:04:39 GMT Steven D'Aprano wrote: > On Fri, 03 Feb 2012 14:08:06 +1100, John O'Hagan wrote: > > > I think we're 12 years late on this one. It's PEP 203 from 2000 and > > the key phrase was: > > > > "The in-place function should always return a new reference, either > > to the old `x' object if the operation was indeed performed > > in-place, or to a new object." > > > > If this had read: > > > > "The in-place function should return a reference to a new object if > > the operation was not performed in-place." > > > > or something like that, we wouldn't be discussing this. > > And what should it return if the operation *is* performed in-place? Not knowing anything about the inner workings of the interpreter, I'm agnostic on that as long as it's not "a new reference". Perhaps the old reference? [...snip undoubted reasons why returning None wouldn't work...] I don't know what would work. Maybe it is insoluble. But didn't Hrvoje Niksic's post in this thread suggest it could have been implemented to work the way I'm saying, even supplying code to demonstrate it? All I'm saying is that however it's implemented, x[i] += y should simply mutate x[i] in-place if x[i] implements that, otherwise it should do x[i] = x[i] + y. If I can say it under 25 words, surely it's implementable? (Whether it's practical to do so is another question.) The x[i] in x[i] += y can be seen as a reference to an object to be incremented rather than an assignment (despite the name). In that view, whether the name x[i] needs to be rebound to a new object, resulting in an assignment, depends on the capabilities of x[i], not x. > > Yes, the current behaviour is a Gotcha, but it's a Gotcha that makes > good sense compared to the alternatives. I think it's worse than a Gotcha. IMHO a Gothcha is, for example, the mutable default arguments thing, which makes sense once you get it. This one has the bizarre consequence that what happens when you operate on an object depends on which name you use for the object. Not to mention that it succeeds after raising an exception. > Ultimately, augmented assignment is *assignment*, just like it says > on the tin. t[1] += x is syntactic sugar for t[1] = t[1].__iadd__(x). > It can't and shouldn't fail to raise an exception if t is a tuple, > because tuple item assignment *must* fail. That makes sense if we view it strictly as assignment (but in that case the mutation of t[1] should not occur either). But isn't it equally true if we say that z = t[1], then t[1] += x is syntactic sugar for z = z.__iadd__(x)? Why should that fail, if z can handle it? [...] > > Ultimately, there is no right answer, because the multitude of > requirements are contradictory. No matter what Python did, somebody > would complain. > Not complaining, just trying to contribute to the best of my ability. :) John From bruno.desthuilliers at gmail.com Fri Feb 3 07:03:32 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Fri, 3 Feb 2012 04:03:32 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> <13539673.900.1328214196126.JavaMail.geo-discussion-forums@vbhn11> Message-ID: <22f59e96-fcad-4127-ac0d-3476a1147588@e27g2000vbu.googlegroups.com> On Feb 2, 9:23?pm, Michal Hantl wrote: > See the link I attached. > Ruby-like blocks would be nice too. > Implicit returns. > Better strings like """My name is #{name}""". Uhu... Looks like you want Ruby, not Python From johnphilliplay at gmail.com Fri Feb 3 08:10:11 2012 From: johnphilliplay at gmail.com (John Lay) Date: Fri, 3 Feb 2012 05:10:11 -0800 (PST) Subject: Help with COM_error Message-ID: I am not a programmer, but this past week I have had a crash course in python scripting am have been rather impressed with myself for having written a fairly complicated script that among many other processes reads a database table via SearchCursor, populates a word template via Bookmarks, then saves the document out as a PDF. The only problem is that it only works on my computer. When I move the script to another computer with the same setup, I continue to receive a Com_error. The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) statement. I have tried both win32com.client and comtypes.client and receive a similar error for both. win32.client: com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ \1033\\WDMAIN11.CHM', 36966, ), None) comtypes.client: COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', 36966, None)) It has been suggested that I try python-docx, but I have not been able to get the module to work for me and I have been unable to find any documentation on it. Can anyone help with the com errors? What do they mean? How do I resolve them? Any help would be appreciated. John From jeandupont115 at gmail.com Fri Feb 3 08:11:54 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Fri, 3 Feb 2012 05:11:54 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: Message-ID: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> As my request might have been too much asked, I have started doing some coding myself. I'm in doubt about the readline statement -which doesn't show anything received- as the meter sends continuously streams of 11 bytes Is there a way to just monitor with python what is arriving at a serial port? #!/usr/bin/python #version 1-2-2012, script to read data from voltcraft vc940-meter import serial, time, os voltport='/dev/ttyUSB2' print "Be sure the Voltcraft is connected to ttyUSB2" print "Enter a filename:", filename = raw_input() voltdata = open(filename,'w') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, timeout=15) print "rs-232 parameters of Voltcraft: ", ser2 print "Opening " + ser2.portstr received=ser2.readline() print received print "Goodbye, data logged in file:" print filename ser2.close() # Close file voltdata.close() On 2 feb, 21:57, Jean Dupont wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly > in Python? > > thanks > Jean > > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); ? ? # wait 5ms per character > $port->read_const_time(200); ? # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > ? ? ? ? my ($nin, $in) = $port->read(255); > ? ? ? ? print $in; > > } > > $port->close; From nathan.alexander.rice at gmail.com Fri Feb 3 09:08:51 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 3 Feb 2012 09:08:51 -0500 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: >> Mm I don't think it's what the OP is asking (unless I misunderstood...). >> I think he wants to compile some syntax TO Python. >> But I don't really see why you would something like this (if not for fun). > > Maybe because you think that Python syntax could be improved upon -- > for instance, Python with pattern-matching would be freaking awesome > -- but at the same time you want to leverage Python's extensive > ecosystem of libraries. ?So instead of creating your own brand-new > language with no third party libraries whatsoever, you create one that > just compiles down to regular Python. You can generalize the dictionary based dispatch used for "case" statements to do this. The main downsides are: 1.) You have to define your functions ahead of time or use lambdas 2.) The syntax is not quite as nice as it could be (e.g.) foo = DispatchDict({ Pattern1: f1, Pattern2: f2, etc... }) Reminds me more of javascript than I would like. >> Then how are you going to maintain the code? Maintain the compiled >> code or the source? > > As with all compiled software, you maintain the input, not the output. I think maintaining the output can be valuable. There are going to be things that can be expressed in the more verbose expanded form that will not be easily expressible in the terse pre-translated macro. Unfortunately, most macro writers don't put much time into making sure their macro produces concise code. >> And proving that your translator is always correct > > That's what unit tests are for. I have a love hate affair with unit tests. You need them, but I'd really rather analytically prove that my software is correct under some set of assumptions. Cheers, Nathan From rjngrj2010 at gmail.com Fri Feb 3 10:23:36 2012 From: rjngrj2010 at gmail.com (gujax) Date: Fri, 3 Feb 2012 07:23:36 -0800 (PST) Subject: IDLE not setting current directory in its path References: Message-ID: On Jan 31, 6:12?pm, Terry Reedy wrote: > On 1/31/2012 11:27 AM,gujaxwrote: > > > Thanks Terry, > > I see that the issue has been closed by you. > > However, I do not know how to run the patch on my Windows. Do I > > reinstall IDLE? > > Please suggest. I am using Python2.7 > Hi Terry, I changed the two files as suggested in your patch and it worked. Thank you, gujax > Choices: > 1. Wait for the next 2.7 release, which should be within a month. > Easiest ;-). Will get you all other patches too. > 2. Edit the files by hand, deleting lines marked - in the patch and > adding lines marked +. Or change lines so they match the + lines. > Harder, but you get the one change now instead of later. > 3. Download and install TortoiseHG, turn your python installation (or > just the idlelib directory) into a repository, apply the patch (or an > edited version thereof), and perhaps delete the repository stuff. I > would only do this if you want to learn to use (Tortoise)HG anyway, > perhaps so you can apply other patches too, without waiting. > > -- > Terry Jan Reedy From rjngrj2010 at gmail.com Fri Feb 3 10:31:03 2012 From: rjngrj2010 at gmail.com (gujax) Date: Fri, 3 Feb 2012 07:31:03 -0800 (PST) Subject: IDLE not setting current directory in its path References: Message-ID: <64b8a37e-bcba-4812-a819-d90f2e02e2e0@q8g2000pbb.googlegroups.com> On Jan 31, 6:12?pm, Terry Reedy wrote: > On 1/31/2012 11:27 AM, gujax wrote: > > > Thanks Terry, > > I see that the issue has been closed by you. > > However, I do not know how to run the patch on my Windows. Do I > > reinstall IDLE? > > Please suggest. I am using Python2.7 > Thank you Terry, The patch suggested by you has worked for me, gujax > Choices: > 1. Wait for the next 2.7 release, which should be within a month. > Easiest ;-). Will get you all other patches too. > 2. Edit the files by hand, deleting lines marked - in the patch and > adding lines marked +. Or change lines so they match the + lines. > Harder, but you get the one change now instead of later. > 3. Download and install TortoiseHG, turn your python installation (or > just the idlelib directory) into a repository, apply the patch (or an > edited version thereof), and perhaps delete the repository stuff. I > would only do this if you want to learn to use (Tortoise)HG anyway, > perhaps so you can apply other patches too, without waiting. > > -- > Terry Jan Reedy From rantingrickjohnson at gmail.com Fri Feb 3 10:35:25 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 3 Feb 2012 07:35:25 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9f5fbe2b-8278-4cc6-b0cb-e2acb39101c2@pk8g2000pbb.googlegroups.com> On Feb 2, 11:28?pm, Chris Angelico wrote: > On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano > > wrote: > > No matter what Python did, somebody would complain. > > +1 > > This is, I think, the ultimate truth of the matter. People would not complain if they did not care. The only useless complaint is people complaining about other people complaining. And the only thing worse than that is rabid fanboi brown-nosing! From devipriya0010 at gmail.com Fri Feb 3 11:12:07 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Fri, 3 Feb 2012 08:12:07 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... Message-ID: <989f9f0a-78fe-4638-a822-a1e6189651e5@n7g2000pbd.googlegroups.com> http://123maza.com/46/dos754/ From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Feb 3 11:15:40 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 3 Feb 2012 16:15:40 +0000 (UTC) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > Perhaps lists shouldn't define += at all, but then people will > complain that mylist += another_list is slow. Telling them to use > mylist.extend instead just makes them cranky. After all, mylist + > another_list works, so why shouldn't += work? It would work, it just wouldn't work in-place. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From emayssat at gmail.com Fri Feb 3 11:30:50 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Fri, 3 Feb 2012 08:30:50 -0800 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: Yes, exactly like range .... http://coverage.livinglogic.de/Demo/classes/Range.py.html see handleargs function. Well that's short, but that's still too much code for what I want to do ;-) On Thu, Feb 2, 2012 at 7:43 PM, Terry Reedy wrote: > On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote: > >> Hello all, >> >> I would like to instantiate my class as follow >> >> >> QObject(, ) >> QObject() >> >> an example would be >> http://www.riverbankcomputing.**co.uk/static/Docs/PyQt4/html/**qmenu.html >> >> How can I do this without have to specify parent= in the second >> version >> (I always need to supply the parent parameter, but I would like to >> supply it last) >> > > The same way range(stop) versus range(start,stop) works. > But I really recommend against that api. > It makes both doc and code messy. > You need a really good reason to not use the obvious > def __init__(self, parent, param=default):... > > -- > Terry Jan Reedy > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Fri Feb 3 12:24:54 2012 From: andrea.crotti.0 at gmail.com (andrea crotti) Date: Fri, 3 Feb 2012 17:24:54 +0000 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: 2012/2/3 Dennis Lee Bieber : > On Thu, 2 Feb 2012 18:19:22 -0700, Ian Kelly > ? ? ? ? > > ? ? ? ?I spent nearly 20 years having to maintain the /output/ of such a > translator. > Yes I think that is the point, if the code you maintain and the code which you have to debug differ because there is a translator in the middle you're going to be in trouble before or later. Moreover, unless you only work alone (which is very unlikely) I think you should agree with everyone else in such a decision.. And if you really miss so much features that are not in Python at all, why not just use another programming language which has them then? From alec.taylor6 at gmail.com Fri Feb 3 13:33:54 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sat, 4 Feb 2012 05:33:54 +1100 Subject: Linker errors when attempting to install PyCrypto Message-ID: I'm getting linker errors when trying to install PyCrypto on Windows: C:\libraries\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win-amd64-2.7\Release\src\winrand.o build\temp.win-amd64-2.7\Release\src\winrandom.def -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lws2_32 -ladvapi32 -lpython27 -lmsvcr90 -o "C:\Projects\satchmo_test\Prototype\src\pycrypto\lib\Crypto\Random\OSRNG\winrandom.pyd" Full output: http://pastebin.com/SYBkFt3h How can I resolve installation issues to get PyCrypto install properly on Python 2.7.2 x64? Thanks for all suggestions, Alec Taylor From silideba at gmail.com Fri Feb 3 15:06:48 2012 From: silideba at gmail.com (Debashish Saha) Date: Sat, 4 Feb 2012 01:36:48 +0530 Subject: No subject Message-ID: would u like to help me by answering some vbasic questions about python? -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Fri Feb 3 15:14:42 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 3 Feb 2012 12:14:42 -0800 Subject: No subject In-Reply-To: References: Message-ID: On Fri, Feb 3, 2012 at 12:06 PM, Debashish Saha wrote: > would u like to help me by answering some vbasic questions about python? You might prefer to ask such questions on the tutor mailing list instead: http://mail.python.org/mailman/listinfo/tutor Cheers, Chris From a.france.mailinglists at gmail.com Fri Feb 3 15:14:49 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Fri, 03 Feb 2012 21:14:49 +0100 Subject: No subject In-Reply-To: References: Message-ID: <4F2C4039.6030704@gmail.com> On 02/03/2012 09:14 PM, Chris Rebert wrote: > On Fri, Feb 3, 2012 at 12:06 PM, Debashish Saha wrote: >> would u like to help me by answering some vbasic questions about python? > You might prefer to ask such questions on the tutor mailing list instead: > http://mail.python.org/mailman/listinfo/tutor > > Cheers, > Chris Sounds like this one is gonna be on the lines of: Will you do the needful and write my application for me for the tracker actions? Thanking in advances Sanjay From bahamutzero8825 at gmail.com Fri Feb 3 15:14:57 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 03 Feb 2012 14:14:57 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback Message-ID: <4F2C4041.5030300@gmail.com> It's a rare occurrence, but sometimes my script will terminate and I get this: Traceback (most recent call last): File "C:\path\to\script\script.py", line 992, in That's it. And the line number is always the last line of the file (which in my case is a blank line). I have not seen this on Linux (where my script can run for days or weeks on a remote server), but only on Windows where I do most of my testing (and it typically only runs for minutes at a time). There may be bugs in my program, but I don't see how Python should ever print a traceback like this. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From tolidtm at gmail.com Fri Feb 3 15:27:48 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Fri, 3 Feb 2012 21:27:48 +0100 Subject: Help writelines Message-ID: Hi everyone, I`m totaly new in python and trying to figure out - how to write a list to a file with a newline at the end of each object. I tried alot of combinations :) like: users = ['toli','didi'] fob=open('c:/Python27/Toli/username','w') fob.writelines(users) + '%s\N' fob.close() or fob.writelines('\N' % users) or fob.writelines('%s\N' % users) but nothing of dose works... Could you help me find out the right syntaxes? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From markus.rother at web.de Fri Feb 3 15:41:54 2012 From: markus.rother at web.de (Markus Rother) Date: Fri, 03 Feb 2012 21:41:54 +0100 Subject: Help writelines In-Reply-To: References: Message-ID: <4F2C4692.2040005@web.de> Hi, You have to iterate. Either with for u in users: fob.write( u + '\n' ) or with a lambda function. always a good call: http://python.org/ greets, M. On 02/03/2012 09:27 PM, Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a > list to a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > or fob.writelines('\N' % users) > or fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > > Thanks > > > From nicholas.dokos at hp.com Fri Feb 3 15:47:37 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Fri, 03 Feb 2012 15:47:37 -0500 Subject: Help writelines In-Reply-To: Message from Anatoli Hristov of "Fri\, 03 Feb 2012 21\:27\:48 +0100." References: Message-ID: <9328.1328302057@alphaville> Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a list to a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > ?or?fob.writelines('\N' % users)? > or?fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > >From the docs: | writelines(...) | writelines(sequence_of_strings) -> None. Write the strings to the file. | | Note that newlines are not added. The sequence can be any iterable object | producing strings. This is equivalent to calling write() for each string. So *you* need to add the newlines, e.g. you can use a list comprehension: fob.writelines(["%s\n" % (x) for x in users]) or write in a loop: for u in users: fob.write("%s\n" % (u)) or join the list elements together with a newline separator (but you'll need to add a final newline by hand): fob.writelines("\n".join(users) + "\n") or ... Nick From d at davea.name Fri Feb 3 15:56:29 2012 From: d at davea.name (Dave Angel) Date: Fri, 03 Feb 2012 15:56:29 -0500 Subject: Help writelines In-Reply-To: References: Message-ID: <4F2C49FD.9000200@davea.name> On 02/03/2012 03:27 PM, Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a list to > a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > or fob.writelines('\N' % users) > or fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > > Thanks > mylist.writelines() is a shorthand for a loop of writes, once per list item. It does not append a newline, since if the list had come from readlines(), it would already have the linefeed on each line. So you have a few choices. You could add a newline to each list item before issuing the writelines(), or write your own loop. I vote for writing your own loop, since there may be other things you want to change on each line. 1) users = [item+"\n" for item in users] # add a newline to each item 2) for line in users: fob.write(line + "\n") fob.close() There are other possibilities, such as contents = "\n".join(mylist) #make a single string out of it fob.write(contents + "\n") #note we had to add one at the very end, #because join just puts the separator between items, not after them. -- DaveA From tolidtm at gmail.com Fri Feb 3 16:03:04 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Fri, 3 Feb 2012 22:03:04 +0100 Subject: Help writelines In-Reply-To: <4F2C49FD.9000200@davea.name> References: <4F2C49FD.9000200@davea.name> Message-ID: Thanks guys that was fast: I used for line in users: fob.write(line + "\n") fob.close() and that works Excuse me for the stupid questions, but since one week I read alot of python and I`m confused :p the only program language I knew in the time was Pascal, but i forgot all of it cheers Anatoli On Fri, Feb 3, 2012 at 9:56 PM, Dave Angel wrote: > On 02/03/2012 03:27 PM, Anatoli Hristov wrote: > >> Hi everyone, >> >> I`m totaly new in python and trying to figure out - how to write a list to >> a file with a newline at the end of each object. >> I tried alot of combinations :) like: >> users = ['toli','didi'] >> fob=open('c:/Python27/Toli/**username','w') >> fob.writelines(users) + '%s\N' >> fob.close() >> or fob.writelines('\N' % users) >> or fob.writelines('%s\N' % users) >> but nothing of dose works... >> >> Could you help me find out the right syntaxes? >> >> Thanks >> >> mylist.writelines() is a shorthand for a loop of writes, once per list > item. It does not append a newline, since if the list had come from > readlines(), it would already have the linefeed on each line. > > So you have a few choices. You could add a newline to each list item > before issuing the writelines(), or write your own loop. I vote for > writing your own loop, since there may be other things you want to change > on each line. > > 1) > users = [item+"\n" for item in users] # add a newline to each item > > 2) > for line in users: > fob.write(line + "\n") > fob.close() > > There are other possibilities, such as > contents = "\n".join(mylist) #make a single string out of it > fob.write(contents + "\n") #note we had to add one at the very > end, > #because join just puts the separator between items, not after > them. > > > > > -- > > DaveA > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan-usenet at bytereef.org Fri Feb 3 16:11:09 2012 From: stefan-usenet at bytereef.org (Stefan Krah) Date: Fri, 3 Feb 2012 22:11:09 +0100 Subject: [ANN] cdecimal-2.3 released In-Reply-To: <7xfwespe1f.fsf@ruckus.brouhaha.com> References: <7xfwespe1f.fsf@ruckus.brouhaha.com> Message-ID: <20120203211109.GA24815@sleipnir.bytereef.org> Paul Rubin wrote: > > Both cdecimal and libmpdec have an extremely conservative release policy. > > When new features are added, the complete test suite is run both with and > > without Valgrind on many different platforms. With the added tests against > > decNumber, this takes around 8 months on four cores. > > Wow. I wonder whether it's worth looking into some formal verification > if the required level of confidence is that high. Currently four of the main algorithms (newton-div, inv-sqrt, sqrt, log) and a couple of auxiliary functions have proofs in ACL2. The results are mechanically verified Lisp forms that are guaranteed to produce results *within correct error bounds* in a conforming Lisp implementation. Proving full conformance to the specification including all rounding modes, Overflow etc. would be quite a bit of additional work. For C, I think the why3 tool should be a good approach: http://why3.lri.fr/ The verification of the L4 kernel allegedly took 30 man-years, so it might take a while... Stefan Krah From dihedral88888 at googlemail.com Fri Feb 3 17:16:45 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 3 Feb 2012 14:16:45 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <7136289.998.1328307405342.JavaMail.geo-discussion-forums@prhq15> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. Well, in any associative operation with an identity implemented in a computer language personally I believe the operator overloading part in C++ is another teasing trick. Do we have to work out the algebra here? From dihedral88888 at googlemail.com Fri Feb 3 17:16:45 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 3 Feb 2012 14:16:45 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <7136289.998.1328307405342.JavaMail.geo-discussion-forums@prhq15> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. Well, in any associative operation with an identity implemented in a computer language personally I believe the operator overloading part in C++ is another teasing trick. Do we have to work out the algebra here? From steve+comp.lang.python at pearwood.info Fri Feb 3 18:25:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 23:25:32 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: Message-ID: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote: > It's a rare occurrence, but sometimes my script will terminate and I get > this: > > Traceback (most recent call last): > File "C:\path\to\script\script.py", line 992, in > > That's it. And the line number is always the last line of the file > (which in my case is a blank line). Is it reproducible? That is, can you demonstrate a script which will *always* show this failure? > I have not seen this on Linux (where > my script can run for days or weeks on a remote server), but only on > Windows where I do most of my testing (and it typically only runs for > minutes at a time). There may be bugs in my program, but I don't see how > Python should ever print a traceback like this. Which version of Python, which version of Windows? If you upgrade Python, does the problem go away? If you perturb your script (add a few blank lines at the end, or a comment), does it go away? -- Steven From no.email at nospam.invalid Fri Feb 3 18:42:01 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 03 Feb 2012 15:42:01 -0800 Subject: Killing threads, and os.system() References: <4f2b976a$0$78773$742ec2ed@news.sonic.net> Message-ID: <7xwr835vsm.fsf@ruckus.brouhaha.com> John Nagle writes: > QNX's message passing looks more like a subroutine call than an > I/O operation, How do they enforce process isolation, or do they decide they don't need to? From inq1ltd at inqvista.com Fri Feb 3 19:15:30 2012 From: inq1ltd at inqvista.com (inq1ltd) Date: Fri, 03 Feb 2012 19:15:30 -0500 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7879610.izLzYB4Oqi@mach-114-20> Check your code in that module for open parenthesis something like below.. Most likely your code is looking for the closing parenthesis. Start at the bottom and move up. pink = str(self.RecordKey[2] <--missing ")" jimonlinux > On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote: > > It's a rare occurrence, but sometimes my script will terminate and I get > > this: > > > > Traceback (most recent call last): > > File "C:\path\to\script\script.py", line 992, in > > > > That's it. And the line number is always the last line of the file > > (which in my case is a blank line). From antti.ylikoski at tkk.fi Fri Feb 3 19:27:56 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 02:27:56 +0200 Subject: Common LISP-style closures with Python Message-ID: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: ------------------------------------- # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1(): n = 0 def f2(): nonlocal n n += 1 return n return f2 ------------------------------------- and now we can do: ------------------------------------- >>> >>> a=f1() >>> b=f1() >>> a() 1 >>> a() 2 >>> a() 3 >>> a() 4 >>> b() 1 >>> b() 2 >>> a() 5 >>> b() 3 >>> b() 4 >>> ------------------------------------- i. e. we can have several functions with private local states which are kept between function calls, in other words we can have Common LISP-like closures. yours, Antti J Ylikoski Helsinki, Finland, the EU From clp2 at rebertia.com Fri Feb 3 21:47:20 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 3 Feb 2012 18:47:20 -0800 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. ?It > is done as follows: > > ------------------------------------- > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > ? ?n = 0 > ? ?def f2(): > ? ? ? ?nonlocal n > ? ? ? ?n += 1 > ? ? ? ?return n > ? ?return f2 > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. Out of curiosity, what would be non-Common-Lisp-style closures? Cheers, Chris From steve+comp.lang.python at pearwood.info Fri Feb 3 21:47:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Feb 2012 02:47:49 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2c9c55$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 19:15:30 -0500, inq1ltd wrote: > Check your code in that module for open parenthesis something like > below.. Most likely your code is looking for the closing parenthesis. > Start at the bottom and move up. > > pink = str(self.RecordKey[2] <--missing ")" If that were the case, the module wouldn't run at all, it would consistently raise SyntaxError before running. -- Steven From rosuav at gmail.com Fri Feb 3 22:15:18 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 4 Feb 2012 14:15:18 +1100 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4F2C4041.5030300@gmail.com> References: <4F2C4041.5030300@gmail.com> Message-ID: On Sat, Feb 4, 2012 at 7:14 AM, Andrew Berg wrote: > It's a rare occurrence, but sometimes my script will terminate and I get > this: > > Traceback (most recent call last): > ?File "C:\path\to\script\script.py", line 992, in Do you call on potentially-buggy external modules? I'd be curious to see if this can happen if a module somehow sets an "error state" in the interpreter, without actually raising an error - or, alternatively, if a module has some kind of cleanup code that returns failure. Unfortunately I don't have facilities for testing that, at the moment. ChrisA From dgcoventry at gmail.com Sat Feb 4 02:02:28 2012 From: dgcoventry at gmail.com (Cov) Date: Fri, 3 Feb 2012 23:02:28 -0800 (PST) Subject: undefined symbol: PyUnicodeUCS4_AsUTF8String Message-ID: I'm attempting to run a python script in Blender (blender3d.org) which is generating an error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ File "/home/dave/Apps/blender-2.49b-linux-glibc236-py26- x86_64/.blender/scripts/pantographLib.py", line 1941, in Pen MITER = cairo.LINE_JOIN_MITER NameError: name 'cairo' is not defined ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ When I type "import cairo" from within the blender python console, I get the following error which (I am presuming) is why the Cairo libraries are not being loaded. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ : /usr/lib/python2.6/dist-packages/ cairo/_cairo.so: undefined symbol: PyUnicodeUCS4_AsUTF8String ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ The machine has three versions of python installed, 2.6 (which is the version that Blender has been compiled against and is using), 2.7 and 3.2. Presumably, there is an unicode conflict which needs to be resolved. Can anyone offer any suggestions on resolving this? Kind regards, Dave Coventry From austinbaiy at gmail.com Sat Feb 4 04:35:06 2012 From: austinbaiy at gmail.com (austinbaiy) Date: Sat, 4 Feb 2012 01:35:06 -0800 (PST) Subject: Open Source Customization Message-ID: <13055537-a91b-42bf-a81a-72e74175f085@og8g2000pbb.googlegroups.com> Searching for Best Web Design, Development or Affordable SEO Service in USA? Bestwebsol.com provides professional full-cycle services: web development, custom web design & Best SEO services with guaranteed traffic increase and higher ranking. http://www.bestwebsol.com From antti.ylikoski at tkk.fi Sat Feb 4 05:14:59 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 12:14:59 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 4:47, Chris Rebert wrote: > On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: >> >> In Python textbooks that I have read, it is usually not mentioned that >> we can very easily program Common LISP-style closures with Python. It >> is done as follows: >> >> ------------------------------------- >> >> # Make a Common LISP-like closure with Python. >> # >> # Antti J Ylikoski 02-03-2012. >> >> def f1(): >> n = 0 >> def f2(): >> nonlocal n >> n += 1 >> return n >> return f2 > >> i. e. we can have several functions with private local states which >> are kept between function calls, in other words we can have Common >> LISP-like closures. > > Out of curiosity, what would be non-Common-Lisp-style closures? > > Cheers, > Chris I understand that a "closure" is something which is typical of functional programming languages. -- Scheme-style closures, for example. I don't know Haskell, ML etc. but I do suspect that we could create closures in those languages as well. Maybe someone more expert than me can help? regards, Andy From antti.ylikoski at tkk.fi Sat Feb 4 05:23:47 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 12:23:47 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 12:14, Antti J Ylikoski wrote: > On 4.2.2012 4:47, Chris Rebert wrote: >> On Fri, Feb 3, 2012 at 4:27 PM, Antti J >> Ylikoski wrote: >>> >>> In Python textbooks that I have read, it is usually not mentioned that >>> we can very easily program Common LISP-style closures with Python. It >>> is done as follows: >>> >>> ------------------------------------- >>> >>> # Make a Common LISP-like closure with Python. >>> # >>> # Antti J Ylikoski 02-03-2012. >>> >>> def f1(): >>> n = 0 >>> def f2(): >>> nonlocal n >>> n += 1 >>> return n >>> return f2 >> >>> i. e. we can have several functions with private local states which >>> are kept between function calls, in other words we can have Common >>> LISP-like closures. >> >> Out of curiosity, what would be non-Common-Lisp-style closures? >> >> Cheers, >> Chris > > I understand that a "closure" is something which is typical of > functional programming languages. -- Scheme-style closures, for example. > > I don't know Haskell, ML etc. but I do suspect that we could create > closures in those languages as well. Maybe someone more expert than me > can help? > > regards, Andy > This is how it is done in standard Common LISP: ----------------------------------------- ;;; Closure with Common LISP. ;;; ;;; Antti J Ylikoski 02-03-2012. (defun mak-1 () (let ((n 0)) #'(lambda () (incf n)))) ----------------------------------------- kind regards, Andy From arnodel at gmail.com Sat Feb 4 05:58:49 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sat, 4 Feb 2012 10:58:49 +0000 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4 February 2012 10:14, Antti J Ylikoski wrote: > On 4.2.2012 4:47, Chris Rebert wrote: >> Out of curiosity, what would be non-Common-Lisp-style closures? >> >> Cheers, >> Chris > > > I understand that a "closure" is something which is typical of functional > programming languages. ?-- Scheme-style closures, for example. > > I don't know Haskell, ML etc. but I do suspect that we could create closures > in those languages as well. ?Maybe someone more expert than me can help? I think what Chris asking is: what is the feature of Common-Lisp closures that Python closures share but other languages don't? I think what he is implying is that there is no such feature. Python closures are no more "Common-Lisp-style" than they are "Scheme-style" or "Smalltalk-like" or any other language-like. -- Arnaud From jeandupont115 at gmail.com Sat Feb 4 07:47:17 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Sat, 4 Feb 2012 04:47:17 -0800 (PST) Subject: pySerial question, setting certain serial parameters [newbie] Message-ID: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): $port->handshake("none"); $port->rts_active(0); $port->dtr_active(1); I have thus far the following statements but I think it does not set the above parameters correctly: import serial voltport='/dev/ttyUSB2' ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) thanks Jean From antti.ylikoski at tkk.fi Sat Feb 4 08:09:14 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 15:09:14 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 12:58, Arnaud Delobelle wrote: > On 4 February 2012 10:14, Antti J Ylikoski wrote: >> On 4.2.2012 4:47, Chris Rebert wrote: >>> Out of curiosity, what would be non-Common-Lisp-style closures? >>> >>> Cheers, >>> Chris >> >> >> I understand that a "closure" is something which is typical of functional >> programming languages. -- Scheme-style closures, for example. >> >> I don't know Haskell, ML etc. but I do suspect that we could create closures >> in those languages as well. Maybe someone more expert than me can help? > > I think what Chris asking is: what is the feature of Common-Lisp > closures that Python closures share but other languages don't? > > I think what he is implying is that there is no such feature. Python > closures are no more "Common-Lisp-style" than they are "Scheme-style" > or "Smalltalk-like" or any other language-like. > I would say that Python closures are equivalent with Common LISP closures (except that LAMBDA is more limited in Python, which is a feature which I don't like.) Do you maybe mean non-Common-LISP-style closures in Python? I cannot think of any ones. kind regards, Andy From bahamutzero8825 at gmail.com Sat Feb 4 11:32:25 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 04 Feb 2012 10:32:25 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2D5D99.4030808@gmail.com> On 2/3/2012 5:25 PM, Steven D'Aprano wrote: > Which version of Python, which version of Windows? I keep that information in my signature for every post I make to this list. CPython 3.2.2 | Windows NT 6.1.7601.17640 > If you upgrade Python, does the problem go away? I use the most recent stable version. It would be hard to say if the problem went away since it's rare and random AFAICT. On 2/3/2012 9:15 PM, Chris Angelico wrote: > Do you call on potentially-buggy external modules? It imports one module that does little more than define a few simple functions. There's certainly no (intentional) interpreter hackery at work. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From steve+comp.lang.python at pearwood.info Sat Feb 4 12:06:14 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Feb 2012 17:06:14 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 04 Feb 2012 10:32:25 -0600, Andrew Berg wrote: > On 2/3/2012 5:25 PM, Steven D'Aprano wrote: >> Which version of Python, which version of Windows? > I keep that information in my signature for every post I make to this > list. CPython 3.2.2 | Windows NT 6.1.7601.17640 Why so you do. Did you expect that people would read it? As a rule, sigs fade into the background -- my mail client colours it grey, my news client colours it light blue, and I generally don't even notice it. The Zen of Python applies here: explicit is better than implicit. >> If you upgrade Python, does the problem go away? > I use the most recent stable version. It would be hard to say if the > problem went away since it's rare and random AFAICT. I suggest you raise an issue on the bug tracker. If you can't reproduce the bug, it's unlikely to be fixed, but you might get lucky. -- Steven From vinay_sajip at yahoo.co.uk Sat Feb 4 12:09:32 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 4 Feb 2012 09:09:32 -0800 (PST) Subject: PythonWin debugger holds onto global logging objects too long References: Message-ID: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> On Jan 24, 2:52?pm, Rob Richardson wrote: > I use PythonWin to debug the Python scripts we write. ?Our scripts often use the log2pyloggingpackage. ?When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. ?The result is that after running the script five times, the log file contains five copies of every message. ?The only way I know to clean this up and get only a single copy of each message is to close PythonWin and restart it. > > What do I have to do in my scripts to clean up theloggingobjects so that I never get more than one copy of each message in my log files? > I don't know what log2py is - Google didn't show up anything that looked relevant. If you're talking about the logging package in the Python standard library, I may be able to help: but a simple script that I ran in PythonWin didn't show any problems, so you'll probably need to post a short script which demonstrates the problem when run in PythonWin. Regards, Vinay Sajip From rtomek at ceti.pl Sat Feb 4 12:42:03 2012 From: rtomek at ceti.pl (Tomasz Rola) Date: Sat, 4 Feb 2012 18:42:03 +0100 (CET) Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, 4 Feb 2012, Antti J Ylikoski wrote: > On 4.2.2012 12:58, Arnaud Delobelle wrote: > > On 4 February 2012 10:14, Antti J Ylikoski wrote: > > > On 4.2.2012 4:47, Chris Rebert wrote: > > > > Out of curiosity, what would be non-Common-Lisp-style closures? > > > > > > > > Cheers, > > > > Chris > > > > > > > > > I understand that a "closure" is something which is typical of functional > > > programming languages. -- Scheme-style closures, for example. > > > > > > I don't know Haskell, ML etc. but I do suspect that we could create > > > closures > > > in those languages as well. Maybe someone more expert than me can help? > > > > I think what Chris asking is: what is the feature of Common-Lisp > > closures that Python closures share but other languages don't? > > > > I think what he is implying is that there is no such feature. Python > > closures are no more "Common-Lisp-style" than they are "Scheme-style" > > or "Smalltalk-like" or any other language-like. > > > > I would say that Python closures are equivalent with Common LISP closures > (except that LAMBDA is more limited in Python, which is a feature which I > don't like.) > > Do you maybe mean non-Common-LISP-style closures in Python? I cannot > think of any ones. > > kind regards, Andy AFAIK there is only one style for closure, similar to one style for square. There are quite a lot languages implementing closures, and quite a lot try to imitate them, including C with non-standard extension (without using those imitations I cannot say if they are good enough). http://en.wikipedia.org/wiki/Closure_(computer_science) Wrt lambdas, I really like blocks from Ruby (which AFAIK stem from blocks in Smalltalk, not sure if they call them "blocks"). http://lesscode.org/2005/07/12/ruby-colored-blocks-in-python/ http://railsguru.org/2010/03/learn-ruby-procs-blocks-lambda/ I mean, myself I am ok with lambdas (using them in languages where lambda is welcomed and contributing citizen) but blocks in place of lambdas would be nice to have in Python. Introduction of "with" construct was good IMHO, but if one likes coding style relying on passing anonymous pieces of code then Python might not be good choice for this. On the other hand, one can argue that using anonymous code too much is not the best style. I am not sure if extensive use of blocks/lambdas really helps, or if it contributes to "clever" hacks and a source of maintainance pain. So, perhaps it is good to have it in a few different ways - like, Ruby, Python and CL - and experiment with them all. In other words, rather than talking about making Python more like some other language(s) I think it is much better to learn those other language(s). If you'd like to try "unlimited" lambda, you might want to play with Racket, a Scheme superset. Or any other Scheme - it's simple enough to start coding after a day or two of learning (I mean Fibonaccis and Erastotenes sieves, not implementing database or web server). Myself, I would rather have blocks/lambdas and not need them rather than the other way, but that's just me. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From bahamutzero8825 at gmail.com Sat Feb 4 13:13:02 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 04 Feb 2012 12:13:02 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2D752E.4030400@gmail.com> On 2/4/2012 11:06 AM, Steven D'Aprano wrote: > I suggest you raise an issue on the bug tracker. If you can't reproduce > the bug, it's unlikely to be fixed, but you might get lucky. Since I can't narrow it down to any specific circumstance or code, I'll gather information from a build of the interpreter with debugging enabled first. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From jenn.duerr at gmail.com Sat Feb 4 13:13:06 2012 From: jenn.duerr at gmail.com (noydb) Date: Sat, 4 Feb 2012 10:13:06 -0800 (PST) Subject: building a dictionary dynamically Message-ID: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy = module for interacting with gis data) >>> inDict = {} >>> for inFC in inFClist: >>> print inFC >>> inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, ....} How do I build this??? And, is dictionaries the best route go about doing a comparison, such that in the end I will have two dictionaries, one for IN and one for OUT, as in I'm moving data files and want to verify that the count in each file matches between IN and OUT. Thanks for any help! From rosuav at gmail.com Sat Feb 4 15:43:51 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Feb 2012 07:43:51 +1100 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4F2D5D99.4030808@gmail.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> Message-ID: On Sun, Feb 5, 2012 at 3:32 AM, Andrew Berg wrote: > On 2/3/2012 9:15 PM, Chris Angelico wrote: >> Do you call on potentially-buggy external modules? > It imports one module that does little more than define a few simple > functions. There's certainly no (intentional) interpreter hackery at work. If it's safe for you to do so (copyright/licence etc), it may be worth posting the code along with your bug report, just in case. I had some REALLY weird issues from embedding Python that derived, ultimately, from buggy ref management - one such case came from forgetting to incref None; it took me a long time to track it down, because the problem didn't actually surface until the interpreter was shutting down. ChrisA From software.buy.design at gmail.com Sat Feb 4 16:33:32 2012 From: software.buy.design at gmail.com (Python_Junkie) Date: Sat, 4 Feb 2012 13:33:32 -0800 (PST) Subject: os.stat last accessed attribute updating last accessed value Message-ID: <660c3625-b27c-42a0-b85b-bcd3047eb6fc@t30g2000vbx.googlegroups.com> I am trying to obtain the last accessed date. About 50% of the files' attributes were updated such that the file was last accessed when this script touches the file. I was not opening the files Anyone have a thought of why this happened. Python 2.6 on windows xp From jeanpierreda at gmail.com Sat Feb 4 17:52:45 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 4 Feb 2012 17:52:45 -0500 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, Feb 4, 2012 at 5:58 AM, Arnaud Delobelle wrote: > I think what Chris asking is: what is the feature of Common-Lisp > closures that Python closures share but other languages don't? > > I think what he is implying is that there is no such feature. ?Python > closures are no more "Common-Lisp-style" than they are "Scheme-style" > or "Smalltalk-like" or any other language-like. "No such feature"? What's that nonlocal thing then? The above function could not be written that way in Python 2. Of course maybe we want to put this feature in another category, but anyway, the function couldn't be written in some languages, even though they have closures. -- Devin From research at johnohagan.com Sat Feb 4 20:31:12 2012 From: research at johnohagan.com (John O'Hagan) Date: Sun, 5 Feb 2012 12:31:12 +1100 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <20120205123112.373fcc7448af003660548cdd@johnohagan.com> On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > [...] > > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. > I'm not sure how naughty this is, but the same thing can be done without using nonlocal by storing the local state as an attribute of the enclosed function object: >>> def f(): ... def g(): ... g.count += 1 ... return g.count ... g.count = 0 ... return g ... >>> h = f() >>> j = f() >>> h() 1 >>> h() 2 >>> h() 3 >>> j() 1 >>> j() 2 >>> j() 3 This way, you can also write to the attribute: >>> j.count = 0 >>> j() 1 John From chardster at gmail.com Sat Feb 4 21:18:30 2012 From: chardster at gmail.com (Richard Thomas) Date: Sat, 4 Feb 2012 18:18:30 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: On Feb 4, 6:13?pm, noydb wrote: > How do you build a dictionary dynamically? ?Doesn't seem to be an > insert object or anything. ?So I need an empty dictionary that I then > want to populate with values I get from looping through a list and > grabbing some properties. ?So simply, I have (fyi, arcpy = module for > interacting with gis data) > > >>> inDict = {} > >>> for inFC in inFClist: > >>> ? ? print inFC > >>> ? ? inCount = ?int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? > > And, is dictionaries the best route go about doing a comparison, such > that in the end I will have two dictionaries, one for IN and one for > OUT, as in I'm moving data files and want to verify that the count in > each file matches between IN and OUT. > > Thanks for any help! Dictionaries are mutable, you can modify them in place: >>> myDict = {} >>> for myKey in myList: ... myDict[myKey] = doSomething(myKey) Dictionaries sound like a good way to go. You only need the one dictionary though, the IN one. When processing the outCount values you can just check them against the inDict at that point. Regards, Chard. From antti.ylikoski at tkk.fi Sat Feb 4 23:19:40 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sun, 05 Feb 2012 06:19:40 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 5.2.2012 3:31, John O'Hagan wrote: > On Sat, 04 Feb 2012 02:27:56 +0200 > Antti J Ylikoski wrote: > > [...] > > >> >> # Make a Common LISP-like closure with Python. >> # >> # Antti J Ylikoski 02-03-2012. >> >> def f1(): >> n = 0 >> def f2(): >> nonlocal n >> n += 1 >> return n >> return f2 >> > > [...] > >> >> i. e. we can have several functions with private local states which >> are kept between function calls, in other words we can have Common >> LISP-like closures. >> > > I'm not sure how naughty this is, but the same thing can be done without using > nonlocal by storing the local state as an attribute of the enclosed function > object: > >>>> def f(): > ... def g(): > ... g.count += 1 > ... return g.count > ... g.count = 0 > ... return g > ... >>>> h = f() >>>> j = f() >>>> h() > 1 >>>> h() > 2 >>>> h() > 3 >>>> j() > 1 >>>> j() > 2 >>>> j() > 3 > > This way, you can also write to the attribute: > >>>> j.count = 0 >>>> j() > 1 > > > John Yes, I do know that, but then it would not be a closure :-))))))))) Andy From alec.taylor6 at gmail.com Sun Feb 5 06:49:43 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 5 Feb 2012 22:49:43 +1100 Subject: [Perl Golf] Round 1 Message-ID: One sentence can contain one or more strings next to each-other, which can be joined to make another word. e.g.: "to get her" == "together" "an other" == "another" "where about" == "whereabouts" &etc Solve this problem using as few lines of code as possible[1]. Good luck! [1] Don't use external non-default libraries; non-custom word-lists excepted From wolfram.hinderer at googlemail.com Sun Feb 5 09:09:50 2012 From: wolfram.hinderer at googlemail.com (Wolfram Hinderer) Date: Sun, 5 Feb 2012 06:09:50 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 3 Feb., 11:47, John O'Hagan wrote: > But isn't it equally true if we say that z = t[1], then t[1] += x is syntactic sugar for z = z.__iadd__(x)? Why should that fail, if z can handle it? It's more like syntactic sugar for y = t; z = y.__getitem__(1); z.__iadd__(x); y.__setitem__(1, z) It's clear that only the last expression fails, after the mutation has taken place. Just in case you wonder about the y: you need it for more complicated cases. t[1][1] += [4] is syntactic sugar for y = t.__getitem__(1); z = y.__getitem__(1); z.__iadd__([4]); y.__setitem__(1, z) That makes clear why there's no exception in this code: >>> t = (0, [1, [2, 3]]) >>> t[1][1] += [4] >>> t (0, [1, [2, 3, 4]]) From alec.taylor6 at gmail.com Sun Feb 5 09:37:14 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 5 Feb 2012 06:37:14 -0800 (PST) Subject: Visual Studio 2010 Support Message-ID: <8830893.1884.1328452634877.JavaMail.geo-discussion-forums@prj1> PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycrypto>vcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycrypto>python setup.py build --compiler msvc http://pastebin.com/nBsuXDGg Error output from G:\pycrypto>python setup.py build --compiler mingw32 1> log1 2> log2 Log1: http://pastebin.com/yG3cbdZv Log2: http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor From alec.taylor6 at gmail.com Sun Feb 5 09:40:31 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 6 Feb 2012 01:40:31 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycrypto>vcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycrypto>python setup.py build --compiler msvc http://pastebin.com/nBsuXDGg Error output from G:\pycrypto>python setup.py build --compiler mingw32 1> log1 2> log2 Log1: http://pastebin.com/yG3cbdZv Log2: http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor From joncle at googlemail.com Sun Feb 5 09:52:23 2012 From: joncle at googlemail.com (Jon Clements) Date: Sun, 5 Feb 2012 06:52:23 -0800 (PST) Subject: os.stat last accessed attribute updating last accessed value References: <660c3625-b27c-42a0-b85b-bcd3047eb6fc@t30g2000vbx.googlegroups.com> Message-ID: <5278aa1d-bddc-4fbf-be6d-5b30407c701f@s7g2000vby.googlegroups.com> On Feb 4, 9:33?pm, Python_Junkie wrote: > I am trying to obtain the last accessed date. ?About 50% of the files' > attributes were updated such that the file was last accessed when this > script touches the file. > I was not opening the files > > Anyone have a thought of why this happened. > > Python 2.6 on windows xp Read up on NTFS - but on some file systems - to check a file access time is, well umm, is accessing it. Also possible that listing a directory is considered an access. It's the least useful of all records - I've only ever possibly wanted modification or creation times. hth, Jon. From tolidtm at gmail.com Sun Feb 5 10:13:39 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Sun, 5 Feb 2012 16:13:39 +0100 Subject: Help about dictionary append Message-ID: Hi there, I`m again confused and its the dictionary. As dictionary does not support append I create a variable list with dictionary key values and want to add new values to it and then copy it again to the dictionary as I dont know other methods. mydict = {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} Then I use the key "Name" from the dict name = mydict['Name'] and tel = mydict['Tel'] then I want to add at the end new values and doing: name.append('Name4') and I get and error that TUPLE object has no attribute Append !!! But how to add new Values to a dictionary then ? I know its kind of basics in python, but I was seeking in the python website and even google and could not realise that. Thank you for your suggestions A.H -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sun Feb 5 10:20:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 02:20:50 +1100 Subject: Help about dictionary append In-Reply-To: References: Message-ID: On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov wrote: > Hi there, > > I`m again confused and its the dictionary. As dictionary does not support > append I create a variable list with dictionary key values and want to add > new values to it and then copy it again to the dictionary as I dont know > other methods. A dictionary maps a key to exactly one value. If you want multiples, you do pretty much what you've done here... > mydict = > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} >... > and I get and error that TUPLE object has no attribute Append !!! > > But how to add new Values to a dictionary then ? ... but instead of using parentheses and creating a Tuple, use square brackets and create a List: mydict = {'Name':['Name1','Name2','Name3'],'Tel':['023333','037777','049999']} Then you can append to it, and it will work just fine! Chris Angelico From jamesbroadhead at gmail.com Sun Feb 5 10:21:18 2012 From: jamesbroadhead at gmail.com (James Broadhead) Date: Sun, 5 Feb 2012 15:21:18 +0000 Subject: Help about dictionary append In-Reply-To: References: Message-ID: On 5 February 2012 15:13, Anatoli Hristov wrote: > Hi there, > > I`m again confused and its the dictionary. As dictionary does not support > append I create a variable list with dictionary key values and want to add > new values to it and then copy it again to the dictionary as I dont know > other methods. > > mydict = > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} > dicts are intended to be used differently from this; more like: name_tel = {} name_tel['Name1'] = 023333 name_tel['Name2'] = 037777 print name_tel['Name1'] ... where Name is the key used to retrieve the value (the telephone number). From lists at cheimes.de Sun Feb 5 10:23:29 2012 From: lists at cheimes.de (Christian Heimes) Date: Sun, 05 Feb 2012 16:23:29 +0100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: Am 05.02.2012 15:40, schrieb Alec Taylor: > PIL, PyCrypto and many other modules require a C compiler and linker. > > Unfortunately neither install on my computer, with a PATH with the following: > > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC > C:\libraries\MinGW\msys\1.0\bin > C:\libraries\MinGW > C:\Python27\Scripts MSVC 10 is not supported, you need VC 9 (2008). Christian From bahamutzero8825 at gmail.com Sun Feb 5 10:29:40 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 05 Feb 2012 09:29:40 -0600 Subject: Help about dictionary append In-Reply-To: References: Message-ID: <4F2EA064.9060502@gmail.com> On 2/5/2012 9:13 AM, Anatoli Hristov wrote: > and I get and error that TUPLE object has no attribute Append !!! You defined mydict['name'] as a tuple, and tuples are immutable. Using a tuple means that you don't ever want the values to change. > But how to add new Values to a dictionary then ? This has nothing to do with dictionaries. If you want to add, delete, or change items, use a list (or a set if there aren't supposed to be any duplicates). Information on built-in types is here: http://docs.python.org/library/stdtypes.html (2.7) http://docs.python.org/py3k/library/stdtypes.html (3.2) -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From alan.ristow at gmail.com Sun Feb 5 10:56:44 2012 From: alan.ristow at gmail.com (Alan Ristow) Date: Sun, 05 Feb 2012 16:56:44 +0100 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <4F2EA6BC.40108@gmail.com> On 02/05/2012 05:19 AM, Antti J Ylikoski wrote: > > Yes, I do know that, but then it would not be a closure :-))))))))) Forgive me if this is terribly naive, but what is the advantage of using a closure as opposed to, say, some other function that returns the same value in the same context, but is not a closure? Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Sun Feb 5 11:42:08 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 6 Feb 2012 03:42:08 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: A 4 year old compiler? I also have MSVC11 installed. Can the python project add support for that so that we aren't waiting 5 years between compiler support? On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes wrote: > Am 05.02.2012 15:40, schrieb Alec Taylor: >> PIL, PyCrypto and many other modules require a C compiler and linker. >> >> Unfortunately neither install on my computer, with a PATH with the following: >> >> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC >> C:\libraries\MinGW\msys\1.0\bin >> C:\libraries\MinGW >> C:\Python27\Scripts > > MSVC 10 is not supported, you need VC 9 (2008). > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list From steve+comp.lang.python at pearwood.info Sun Feb 5 11:55:52 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 05 Feb 2012 16:55:52 GMT Subject: PyCrypto builds neither with MSVC nor MinGW References: Message-ID: <4f2eb498$0$29965$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 03:42:08 +1100, Alec Taylor wrote: > A 4 year old compiler? Compilers aren't like milk. They don't go off after a few weeks. A good compiler/operating system combination should still be usable after 4 or 14 years. The compiler I'm using is six years old, and I expect that it will continue to get patches and upgrades without breaking backwards compatibility for the next six years. > I also have MSVC11 installed. Can the python project add support for > that so that we aren't waiting 5 years between compiler support? Are you volunteering to provide that support? I'm sure it would be appreciated. P.S. Please don't top-post. > On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes > wrote: >> Am 05.02.2012 15:40, schrieb Alec Taylor: >>> PIL, PyCrypto and many other modules require a C compiler and linker. >>> >>> Unfortunately neither install on my computer, with a PATH with the >>> following: >>> >>> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC >>> C:\libraries\MinGW\msys\1.0\bin >>> C:\libraries\MinGW >>> C:\Python27\Scripts >> >> MSVC 10 is not supported, you need VC 9 (2008). >> >> Christian -- Steven From modelnine at modelnine.org Sun Feb 5 12:13:00 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Sun, 05 Feb 2012 18:13:00 +0100 Subject: [Perl Golf] Round 1 In-Reply-To: References: Message-ID: <4F2EB89C.9080801@modelnine.org> Am 05.02.2012 12:49, schrieb Alec Taylor: > Solve this problem using as few lines of code as possible[1]. Pardon me, but where's "the problem"? If your intention is to propose "a challenge", say so, and state the associated problem clearly. -- --- Heiko. From tolidtm at gmail.com Sun Feb 5 15:12:48 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Sun, 5 Feb 2012 21:12:48 +0100 Subject: Help about dictionary append In-Reply-To: References: Message-ID: Thanks Chris, It works fine, I see it will take time till I understand all the syntax :( A.H On Sun, Feb 5, 2012 at 4:20 PM, Chris Angelico wrote: > On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov wrote: > > Hi there, > > > > I`m again confused and its the dictionary. As dictionary does not support > > append I create a variable list with dictionary key values and want to > add > > new values to it and then copy it again to the dictionary as I dont know > > other methods. > > A dictionary maps a key to exactly one value. If you want multiples, > you do pretty much what you've done here... > > > mydict = > > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} > >... > > and I get and error that TUPLE object has no attribute Append !!! > > > > But how to add new Values to a dictionary then ? > > ... but instead of using parentheses and creating a Tuple, use square > brackets and create a List: > > mydict = > {'Name':['Name1','Name2','Name3'],'Tel':['023333','037777','049999']} > > Then you can append to it, and it will work just fine! > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Sun Feb 5 15:58:31 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 5 Feb 2012 13:58:31 -0700 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: >> I'm not sure how naughty this is, but the same thing can be done without >> using >> nonlocal by storing the local state as an attribute of the enclosed >> function >> object: >> >> ... > > Yes, I do know that, but then it would not be a closure :-))))))))) Sure it is. Where do you think it looks up the function object? Cheers, Ian From jenn.duerr at gmail.com Sun Feb 5 16:10:45 2012 From: jenn.duerr at gmail.com (noydb) Date: Sun, 5 Feb 2012 13:10:45 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> Ahh, I see now, thanks! From ben+python at benfinney.id.au Sun Feb 5 16:15:21 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 06 Feb 2012 08:15:21 +1100 Subject: [Perl Golf] Round 1 References: Message-ID: <87r4y93rti.fsf@benfinney.id.au> Alec Taylor writes: > One sentence can contain one or more strings next to each-other, which > can be joined to make another word. > > e.g.: > > "to get her" == "together" > "an other" == "another" > "where about" == "whereabouts" > > &etc Yes, that's true. > Solve this problem using as few lines of code as possible[1]. Easy:: True > Good luck! What do I win? -- \ ?All opinions are not equal. Some are a very great deal more | `\ robust, sophisticated, and well supported in logic and argument | _o__) than others.? ?Douglas Adams | Ben Finney From ndbecker2 at gmail.com Sun Feb 5 17:15:10 2012 From: ndbecker2 at gmail.com (Neal Becker) Date: Sun, 05 Feb 2012 17:15:10 -0500 Subject: [Perl Golf] Round 1 References: <4F2EB89C.9080801@modelnine.org> Message-ID: Heiko Wundram wrote: > Am 05.02.2012 12:49, schrieb Alec Taylor: >> Solve this problem using as few lines of code as possible[1]. > > Pardon me, but where's "the problem"? If your intention is to propose "a > challenge", say so, and state the associated problem clearly. > But this really misses the point. Python is not about coming up with some clever, cryptic, one-liner to solve some problem. It's about clear code. If you want clever, cryptic, one-liner's stick with perl. From emekamicro at gmail.com Sun Feb 5 17:41:24 2012 From: emekamicro at gmail.com (Emeka) Date: Mon, 6 Feb 2012 00:41:24 +0200 Subject: MySQLdb not allowing hyphen Message-ID: Hello All, I noticed that MySQLdb not allowing hyphen may be way to prevent injection attack. I have something like below: "insert into reviews(message, title)values('%s', '%s')" %( "We don't know where to go","We can't wait till morrow" ) ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't know where to go. How do I work around this error? Regards, Emeka -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sun Feb 5 17:46:36 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 5 Feb 2012 14:46:36 -0800 Subject: MySQLdb not allowing hyphen In-Reply-To: References: Message-ID: On Sun, Feb 5, 2012 at 2:41 PM, Emeka wrote: > > Hello All, > > I noticed that?MySQLdb not allowing hyphen may be way to prevent injection > attack. > I have something like below: > > "insert into reviews(message, title)values('%s', '%s')" %( "We don't know > where to go","We can't wait till morrow"?) > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > manual that corresponds to your MySQL server version for the right syntax to > use near 't know where to go. > > How do I work around this error? Don't use raw SQL strings in the first place. Use a proper parameterized query, e.g.: cursor.execute("insert into reviews(message, title) values (%s, %s)", ("We don't know where to go", "We can't wait till morrow")) Cheers, Chris From modelnine at modelnine.org Sun Feb 5 18:03:33 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Mon, 06 Feb 2012 00:03:33 +0100 Subject: [Perl Golf] Round 1 In-Reply-To: References: <4F2EB89C.9080801@modelnine.org> Message-ID: <4F2F0AC5.1060908@modelnine.org> Am 05.02.2012 23:15, schrieb Neal Becker: > Heiko Wundram wrote: >> Am 05.02.2012 12:49, schrieb Alec Taylor: >>> Solve this problem using as few lines of code as possible[1]. >> >> Pardon me, but where's "the problem"? If your intention is to propose "a >> challenge", say so, and state the associated problem clearly. > > But this really misses the point. Python is not about coming up with some > clever, cryptic, one-liner to solve some problem. It's about clear code. If > you want clever, cryptic, one-liner's stick with perl. You're only allowed to bash him for one-liners as soon as he formulates something that in some way or another resembles a programming challenge, and not some incoherent listing of words without actual intent... ;-) -- --- Heiko. From rantingrickjohnson at gmail.com Sun Feb 5 18:29:35 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 5 Feb 2012 15:29:35 -0800 (PST) Subject: Common LISP-style closures with Python References: Message-ID: <6abce3f9-808a-4642-9a24-24951230e825@h3g2000yqe.googlegroups.com> On Feb 3, 6:27?pm, Antti J Ylikoski wrote: > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. ?It > is done as follows: > [...] do my eyes not see nor my ears not hear? a thread about common Lisp and Xan Lee is not near? would someone please him wake up and tell him all about, the thread titled "Common LISP-style closures with Python" and that he has been left out! From emekamicro at gmail.com Sun Feb 5 18:52:28 2012 From: emekamicro at gmail.com (Emeka) Date: Mon, 6 Feb 2012 01:52:28 +0200 Subject: MySQLdb not allowing hyphen In-Reply-To: <3a3ui7hmkbq7op1b2m2tvsmee6aimaelkh@4ax.com> References: <3a3ui7hmkbq7op1b2m2tvsmee6aimaelkh@4ax.com> Message-ID: Dennis , Chris Thanks so much! On Mon, Feb 6, 2012 at 1:23 AM, Dennis Lee Bieber wrote: > On Mon, 6 Feb 2012 00:41:24 +0200, Emeka wrote: > > >Hello All, > > > >I noticed that MySQLdb not allowing hyphen may be way to prevent injection > >attack. > > What hyphen? > > >I have something like below: > > > >"insert into reviews(message, title)values('%s', '%s')" %( "We don't know > >where to go","We can't wait till morrow" ) > > > > >How do I work around this error? > > Very simple... DON'T QUOTE PLACEHOLDERS AND USE MySQLdb > parameterized queries. > > csr.execute("insert into reviews (message, title) values (%s, %s)", > ( "We don't know where to go", > "We can't wait till morrow" ) ) > > The whole purpose of parameterized queries is that the .execute() > logic will SAFELY wrap the supplied values with quotes AND escape any > problem characters within the value. > > The reason you got an error was not a hyphen (there are no hyphens > in your example) but rather that you closed the quote. Your generated > SQL was: > > insert into reviews (message, title) values ('We don't know where to > go', 'We can't wait till morrow') > > which means a string of: > "We don" > SQL garbage > t know where to go > string > ", " > SQL garbage > We can > and another string > "t wait till morrow" > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcepl at redhat.com Sun Feb 5 19:58:32 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 01:58:32 +0100 Subject: Python and TAP Message-ID: I have just finished listening to the FLOSS Weekly podcast #200 (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned about the existence of TAP (http://testanything.org/). A standardization of testing seems to be so obviously The Right Thing?, that it is strange that I don't see much related movement in the Python world (I know only about http://git.codesimply.com/?p=PyTAP.git;a=summary or git://git.codesimply.com/PyTAP.git, which seems to be very very simple and only producer). What am I missing? Why nobody seems to care about joining TAP standard? Best, Mat?j From tjreedy at udel.edu Sun Feb 5 20:26:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 05 Feb 2012 20:26:40 -0500 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: > On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor > wrote: > >> A 4 year old compiler? >> >> I also have MSVC11 installed. Can the python project add support for >> that so that we aren't waiting 5 years between compiler support? 3.3 will almost certainly be built with VS2010. -- Terry Jan Reedy From mcepl at redhat.com Sun Feb 5 20:27:38 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 02:27:38 +0100 Subject: difference between random module in python 2.6 and 3.2? Message-ID: Hi, I have this working function: def as_xml(self): out = etree.Element("or") for k in sorted(self.keys()): out.append(etree.Element("hostname", attrib={'op': '=', 'value': random.choice(self[k])})) # ... return somehow string representing XML and this unit test def test_XML_print(self): random.seed(1) expected = ... # expected XML observed = self.data.as_xml() self.assertEqual(observed, expected, "Verbose print (including PCI IDs)") Strange thing is that this unit tests correctly with python3, but fails with python2. The problem is that apparently python3 random.choice picks different element of self[k] than the one python2 (at least, both of them are constant in their choice). Is it known that there is this difference? Is there a way how to make both random.choice select the same? Best, Mat?j From steve+comp.lang.python at pearwood.info Sun Feb 5 23:01:05 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 04:01:05 GMT Subject: difference between random module in python 2.6 and 3.2? References: Message-ID: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote: > Strange thing is that this unit tests correctly with python3, but fails > with python2. The problem is that apparently python3 random.choice picks > different element of self[k] than the one python2 (at least, both of > them are constant in their choice). Confirmed: steve at runes:~$ python2.6 -c "from random import choice, seed; seed(1); print choice(range(1000))" 134 steve at runes:~$ python3.2 -c "from random import choice, seed; seed(1); print(choice(list(range(1000))))" 137 steve at runes:~$ python2.6 -c "from random import choice, seed; seed(42); print choice(range(1000))" 639 steve at runes:~$ python3.2 -c "from random import choice, seed; seed(42); print(choice(list(range(1000))))" 654 > Is it known that there is this difference? Is there a way how to make > both random.choice select the same? Reading the docs, I would expect that when using an int as seed, you should get identical results. There is no mention that the PRNG has changed between 2.6 and 3.2; both should use the given int as seed. There is a change of behaviour when using strings/bytes/bytearrays, and Python3.2 provides a "version=N" argument to seed to set the old behaviour. But this doesn't apply to integer seeds. I call this a bug. It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6: steve at runes:~$ python3.1 -c "from random import choice, seed; seed(42); print(choice(list(range(1000))))" 639 steve at runes:~$ python3.1 -c "from random import choice, seed; seed(1); print(choice(list(range(1000))))" 134 -- Steven From tjreedy at udel.edu Mon Feb 6 00:07:04 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 00:07:04 -0500 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > Reading the docs, I would expect that when using an int as seed, you > should get identical results. That is similar to expecting hash to be consistent from version to version. > There is no mention that the PRNG has changed between 2.6 and 3.2; There is at best an informal policy. This was discussed in http://bugs.python.org/issue9025 Antoine argued that if there were a written policy, it should be limited to bug-fix releases within a version. I agree. > It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6: This change is a side effect of fixing the bug of non-uniformity discussed in that issue. In any case, in 2.7 and probably 3.1: def choice(self, seq): """Choose a random element from a non-empty sequence.""" return seq[int(self.random() * len(seq))] # raises IndexError whereas in 3.2: def choice(self, seq): """Choose a random element from a non-empty sequence.""" try: i = self._randbelow(len(seq)) except ValueError: raise IndexError('Cannot choose from an empty sequence') return seq[i] The change was announced in What's New in 3.2 random The integer methods in the random module now do a better job of producing uniform distributions. Previously, they computed selections with int(n*random()) which had a slight bias whenever n was not a power of two. Now, multiple selections are made from a range up to the next power of two and a selection is kept only when it falls within the range 0 <= x < n. The functions and methods affected are randrange(), randint(), choice(), shuffle() and sample(). -- Terry Jan Reedy From mohsen at pahlevanzadeh.org Mon Feb 6 00:48:02 2012 From: mohsen at pahlevanzadeh.org (Mohsen Pahlevanzadeh) Date: Mon, 06 Feb 2012 09:18:02 +0330 Subject: help function and operetors overloading Message-ID: <1328507282.11367.40.camel@debian> Dear all, You know python has many functions for operators overloading such as __add__, __radd__, __invert__, __eq__ and so on. How i see the complete list of them with help function? Yours, Mohsen -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 316 bytes Desc: This is a digitally signed message part URL: From antti.ylikoski at tkk.fi Mon Feb 6 00:55:50 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Mon, 06 Feb 2012 07:55:50 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 5.2.2012 22:58, Ian Kelly wrote: > On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: >>> I'm not sure how naughty this is, but the same thing can be done without >>> using >>> nonlocal by storing the local state as an attribute of the enclosed >>> function >>> object: >>> >>> ... >> >> Yes, I do know that, but then it would not be a closure :-))))))))) > > Sure it is. Where do you think it looks up the function object? > > Cheers, > Ian OK, thank you for correcting me. Andy From steve+comp.lang.python at pearwood.info Mon Feb 6 00:56:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 05:56:23 GMT Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > >> Reading the docs, I would expect that when using an int as seed, you >> should get identical results. > > That is similar to expecting hash to be consistent from version to > version. No. hash is not intended to be consistent across versions, or even across runs of the interpreter. Of course it may be, but that's not an implicit or explicit promise. Seeding a pseudo-random number generator, on the other hand, is explicitly for generating the same repeatable, consistent set of results. That's what seed is *for*. It is even documented that way: http://docs.python.org/py3k/library/random.html#notes-on-reproducibility although the docs weasel out of promising anything other than random.random() will be predictable. When the Mersenne Twister was introduced, the old Wichman-Hill PRNG was provided for those who needed repeatability. (I see it's gone now, but if people haven't migrated their code from 2.3 yet, shame on them.) >> There is no mention that the PRNG has changed between 2.6 and 3.2; > > There is at best an informal policy. This was discussed in > http://bugs.python.org/issue9025 > Antoine argued that if there were a written policy, it should be limited > to bug-fix releases within a version. I agree. I think this thread demonstrates that there are people who depend on repeatability of the random number routines, and not just for random.random(). I think it is ironic (and annoying) that the same release of Python that introduced a version argument to seed() to provide a backward compatible seeding algorithm, also introduced a backward incompatible change to choice(). This, plus Raymond Hettinger's comments on the bug report, make me think that the change in behaviour of randrange and choice is not deliberate and should be treated as a bug. Raymond made a strong case arguing for repeatability, and then approved a bug fix that broke repeatability. I doubt that was deliberate. -- Steven From clp2 at rebertia.com Mon Feb 6 01:00:14 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 5 Feb 2012 22:00:14 -0800 Subject: help function and operetors overloading In-Reply-To: <1328507282.11367.40.camel@debian> References: <1328507282.11367.40.camel@debian> Message-ID: On Sun, Feb 5, 2012 at 9:48 PM, Mohsen Pahlevanzadeh wrote: > Dear all, > > You know python has many functions for operators overloading such as > __add__, __radd__, __invert__, __eq__ and so on. > How i see the complete list of them with help function? I don't know if there's a help() entry for them. The docs have a full list of those "special method names": http://docs.python.org/reference/datamodel.html#special-method-names Cheers, Chris From rosuav at gmail.com Mon Feb 6 01:49:20 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 17:49:20 +1100 Subject: [Perl Golf] Round 1 In-Reply-To: <4F2F0AC5.1060908@modelnine.org> References: <4F2EB89C.9080801@modelnine.org> <4F2F0AC5.1060908@modelnine.org> Message-ID: On Mon, Feb 6, 2012 at 10:03 AM, Heiko Wundram wrote: > You're only allowed to bash him for one-liners as soon as he formulates > something that in some way or another resembles a programming challenge, and > not some incoherent listing of words without actual intent... ;-) Nah, one-liners are fun. Look, here's a Python one-liner that generates a month's worth of emails: t = ('a', [23]); t[1] += [42] *ducks for cover* ChrisA From rosuav at gmail.com Mon Feb 6 01:53:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 17:53:50 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy wrote: > On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: >> >> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor >> wrote: >> >>> A 4 year old compiler? >>> >>> I also have MSVC11 installed. Can the python project add support for >>> that so that we aren't waiting 5 years between compiler support? > > > 3.3 will almost certainly be built with VS2010. I suppose there's no chance of moving to a free compiler? For my Windows work, I've generally used the Open Watcom compiler; that's not to say it's the best, but it does the job, and it's free software. But no, I'm not offering. Way way too many jobs that I already have queued, sorry! ChrisA From tjreedy at udel.edu Mon Feb 6 02:27:14 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:27:14 -0500 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/6/2012 12:56 AM, Steven D'Aprano wrote: > On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > >> On 2/5/2012 11:01 PM, Steven D'Aprano wrote: >> >>> Reading the docs, I would expect that when using an int as seed, you >>> should get identical results. >> >> That is similar to expecting hash to be consistent from version to >> version. > > No. hash is not intended to be consistent across versions, or even across Oh, but it was. Changing it will break tests, including some in the Python test suite. ... > This, plus Raymond Hettinger's comments on the bug report, make me think > that the change in behaviour of randrange and choice is not deliberate As I said, it was a necessary consequence of a bug fix. > and should be treated as a bug. Raymond made a strong case arguing for > repeatability, and then approved a bug fix that broke repeatability. I > doubt that was deliberate. It was deliberate that randrange was changed to an even distribution from a slightly uneven distribute. That implies a change in the pattern. That was known and the main subject of discussion. As Antoine said, making functions exactly repeatable across versions means not fixing bugs or otherwise improving them. This statement is not limited to the random module. You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improvements are needed or thought sufficiently desirable. -- Terry Jan Reedy From tjreedy at udel.edu Mon Feb 6 02:28:52 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:28:52 -0500 Subject: help function and operetors overloading In-Reply-To: <1328507282.11367.40.camel@debian> References: <1328507282.11367.40.camel@debian> Message-ID: On 2/6/2012 12:48 AM, Mohsen Pahlevanzadeh wrote: > Dear all, > > You know python has many functions for operators overloading such as > __add__, __radd__, __invert__, __eq__ and so on. > How i see the complete list of them with help function? >>> import operator >>> help(operator) Help on built-in module operator: ... -- Terry Jan Reedy From tjreedy at udel.edu Mon Feb 6 02:39:32 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:39:32 -0500 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On 2/6/2012 1:53 AM, Chris Angelico wrote: > On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy wrote: >> On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: >>> >>> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor >>> wrote: >>> >>>> A 4 year old compiler? >>>> >>>> I also have MSVC11 installed. Can the python project add support for >>>> that so that we aren't waiting 5 years between compiler support? >> >> >> 3.3 will almost certainly be built with VS2010. > > I suppose there's no chance of moving to a free compiler? VC express is free-as-in-beer. The whole V. Studio is free to core developers. MS may not *like* open-source software, but they have decided they would like it even less if everyone compiled it with non-MS compilers. > Windows work, I've generally used the Open Watcom compiler; that's not > to say it's the best, but it does the job, and it's free software. Would it build CPython, including the +- dependent libraries like tcl/tk? How would the speed compare? > But no, I'm not offering. Way way too many jobs that I already have > queued, sorry! I guess the answer will have to wait ;-). -- Terry Jan Reedy From steve+comp.lang.python at pearwood.info Mon Feb 6 03:05:43 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 08:05:43 GMT Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote: [...] >> and should be treated as a bug. Raymond made a strong case arguing for >> repeatability, and then approved a bug fix that broke repeatability. I >> doubt that was deliberate. > > It was deliberate that randrange was changed to an even distribution > from a slightly uneven distribute. That implies a change in the pattern. Okay, granted. > That was known and the main subject of discussion. As Antoine said, > making functions exactly repeatable across versions means not fixing > bugs or otherwise improving them. This statement is not limited to the > random module. > > You have persuaded me that the doc should be more explicit that while > the basic random.random sequence will be kept repeatable with seed set > (except perhaps after a changeover of several releases), the convenience > transformations can be changed if improvements are needed or thought > sufficiently desirable. A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed without warning? -- Steven From bruno.desthuilliers at gmail.com Mon Feb 6 03:26:14 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 6 Feb 2012 00:26:14 -0800 (PST) Subject: Help about dictionary append References: Message-ID: <8017354d-3766-4c20-96f0-259b9b1a7274@f30g2000yqh.googlegroups.com> On Feb 5, 4:29?pm, Andrew Berg wrote: > This has nothing to do with dictionaries. If you want to add, delete, or > change items, use a list (or a set if there aren't supposed to be any > duplicates). AND you don't care about ordering... From mcepl at redhat.com Mon Feb 6 03:45:30 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 09:45:30 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 6.2.2012 09:05, Steven D'Aprano wrote: >> You have persuaded me that the doc should be more explicit that while >> the basic random.random sequence will be kept repeatable with seed set >> (except perhaps after a changeover of several releases), the convenience >> transformations can be changed if improvements are needed or thought >> sufficiently desirable. > > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Could we get some hint in the release notes? Thanks for the help, Mat?j From mcepl at redhat.com Mon Feb 6 03:57:04 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 09:57:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 6.2.2012 09:45, Matej Cepl wrote: > Also, how could I write a re-implementation of random.choice which would > work same on python 2.6 and python 3.2? It is not only matter of unit > tests, but I would really welcome if the results on both versions > produce the same results. Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Mat?j From rosuav at gmail.com Mon Feb 6 03:57:10 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 19:57:10 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On Mon, Feb 6, 2012 at 6:39 PM, Terry Reedy wrote: > On 2/6/2012 1:53 AM, Chris Angelico wrote: >> I suppose there's no chance of moving to a free compiler? > > VC express is free-as-in-beer. The whole V. Studio is free to core > developers. MS may not *like* open-source software, but they have decided > they would like it even less if everyone compiled it with non-MS compilers. Oh, that's something at least. I wasn't aware of what exactly they charge for and what they don't. >> Windows work, I've generally used the Open Watcom compiler; that's not >> to say it's the best, but it does the job, and it's free software. > > Would it build CPython, including the +- dependent libraries like tcl/tk? > How would the speed compare? I can't answer that question without grabbing the sources, going through the whole work of porting makefiles etc, and finding out whether there's failures - in other words, doing the whole job. It's entirely possible that there'll be some dependency failure; but I would posit that, on balance, it's more likely there won't be. As to speed - I've not done a lot of compiler benchmarking. (Not sure whether you mean compilation speed or the efficiency of the resulting code; either way, I've not tried.) Never actually had multiple compilers on any one platform for long enough to do serious testing. It's hardly fair to compare Borland C++ for Windows 3.1, icc on OS/2 32-bit, Open Watcom on XP, and gcc on Debian 64-bit! It's probably not worth the hassle of changing compilers, although I do wonder whether changing compiler _versions_ isn't sometimes nearly as much work. ("What? All that legacy code doesn't compile any more? Ohh... it doesn't like #include any more...") ChrisA From jldunn2000 at gmail.com Mon Feb 6 04:23:41 2012 From: jldunn2000 at gmail.com (loial) Date: Mon, 6 Feb 2012 01:23:41 -0800 (PST) Subject: newbie socket help References: <4e70f47b-89e4-46bb-929e-9b7db20e7bcc@l16g2000vbl.googlegroups.com> Message-ID: <5563be07-e64f-497e-81a4-23bd3cb0eda5@bs8g2000vbb.googlegroups.com> OS is Red hat enterprise linux 5.5 and python version is 2.6 On Feb 2, 4:34?pm, Dennis Lee Bieber wrote: > On Thu, 2 Feb 2012 05:53:22 -0800 (PST), loial > wrote: > > >I am trying to write a python script to read data from a printer port > >using python sockets, but it seems I am locking up the port. > > >Is there a way to ensure that I do not block the port to other > >applications? > > >My knowledge of python sockets is minimal, so any help would be > >appreciated. > > ? ? ? ? OS and Python version might be of interest... > > ? ? ? ? However, parallel ports are typically unshared devices (which is why > any multitasking system has things like print spooling -- so multiple > tasks and "print" to the spool, and the spool driver is the only process > actually accessing the printer port). > > ? ? ? ? I still have nightmares over one assignment I had some 8 years ago: > Reading a clock signal (square wave) on one of the parallel port's > signal pins, in order to time a three-bit /balanced/ (using 6-pins of > the output) data stream. Done on a W98 laptop (since W98 didn't have the > protected ports of WinXP) using Visual C++ ?-- and on the laptop as the > eventual plan had been to send "red" GPS decryption keys to satellites; > contact with "red" keys makes the hardware it passes through highly > classified, and the main hardware had to stay "open" for uncleared > developers working on flight software. > > ? ? ? ? Unfortunately, even with the program running at the highest > available Windows priority, the OS still did every few > milliseconds, which led to glitches in the output stream. (The good > news: by the time the DTD with the keys became available, the CONOPS had > changed to use "black" keys, which did not "infect" the computer system > -- so the regular command formatter could be used for uploading). > > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ From fb at alien8.de Mon Feb 6 07:24:23 2012 From: fb at alien8.de (Frank Becker) Date: Mon, 06 Feb 2012 13:24:23 +0100 Subject: Python and TAP In-Reply-To: References: Message-ID: <4F2FC677.7020606@alien8.de> On 06.02.12 01:58, Matej Cepl wrote: Hi, > I have just finished listening to the FLOSS Weekly podcast #200 > (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned > about the existence of TAP (http://testanything.org/). A standardization > of testing seems to be so obviously The Right Thing?, that it is strange > that I don't see much related movement in the Python world (I know only > about http://git.codesimply.com/?p=PyTAP.git;a=summary or > git://git.codesimply.com/PyTAP.git, which seems to be very very simple > and only producer). > > What am I missing? Why nobody seems to care about joining TAP standard? Not sure. Probably it comes down to what you need depending on your tool chain. But there are alternatives. Most prominent to my knowledge is subunit [0]. Here is a comparison between the two [1]. One warning when you jump on the TAP train: Using the Python YAML module PyYAML you will have to find out that TAP uses a YAML subset called YAMLish [3]. It's not the same and pretty much defined by the Perl implementation. [0] https://launchpad.net/subunit [1] http://www.kinoshita.eti.br/2011/06/04/a-comparison-of-tap-test-anything-protocol-and-subunit/ [2] http://pyyaml.org/ [3] http://testanything.org/wiki/index.php/YAMLish Bye, Frank -- Frank Becker (jabber|mail) | http://twitter.com/41i3n8 GnuPG: 0xADC29ECD | F01B 5E9C 1D09 981B 5B40 50D3 C80F 7459 ADC2 9ECD -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 307 bytes Desc: OpenPGP digital signature URL: From info at egenix.com Mon Feb 6 08:46:47 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 06 Feb 2012 14:46:47 +0100 Subject: ANN: eGenix mx Base Distribution 3.2.3 (mxDateTime, mxTextTools, etc.) Message-ID: <4F2FD9C7.50101@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mx Base Distribution Version 3.2.3 for Python 2.4 - 2.7 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.3-GA.html ________________________________________________________________________ ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Easy to use Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python The package also include a number of helpful smaller modules in the mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing or mx.Misc.CommandLine to quickly write command line applications in Python. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. For more information, please see the distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ NEWS The 3.2.3 release of the eGenix mx Base Distribution is the latest release of our open-source Python extensions. The new patch-level version includes a few important fixes: * Fixed a possible segfault when using the .pydate(), .pydatetime() and .pytime() methods. Thanks to Daniel Szoska for reporting this. If you are upgrading from eGenix mx Base 3.1.x, please also see the eGenix mx Base Distribution 3.2.0 release notes for details on what has changed and which new features are available: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on all other Python platforms, such as Solaris, AIX, HP-UX, etc. To simplify installation in Zope/Plone and other egg-based systems, we have also precompiled egg distributions for all platforms. These are available on our own PyPI-style index server for easy and automatic download. Whether you are using a pre-built package or the source distribution, installation is a simple "python setup.py install" command in all cases. The only difference is that the pre-built packages do not require a compiler or the Python development packages to be installed. For a full list of changes, please refer to the eGenix mx Base Distribution change log at http://www.egenix.com/products/python/mxBase/changelog.html and the change logs of the various included Python packages. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use the packages in both commercial and non-commercial settings without fee or charge. The package comes with full source code ________________________________________________________________________ SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 06 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From eric.frederich at gmail.com Mon Feb 6 09:39:21 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Mon, 6 Feb 2012 09:39:21 -0500 Subject: nested embedding of interpreter Message-ID: Hello, I work with a 3rd party tool that provides a C API for customization. I created Python bindings for this C API so my customizations are nothing more than this example wrapper code almost verbatim: http://docs.python.org/extending/embedding.html#pure-embedding I have many .c files just like that only differing by the module and function that they load and execute. This has been working fine for a long time. Now, as we add more and more customizations that get triggered at various events we have come to a problem. If some of the Python customization code gets triggered from inside another Python customization I get a segfault. I thought this might have something to do with the nesting which is the equivalent of calling Py_Initialize() twice followed by Py_Finalize() twice. I went into the C wrapper code for the inner-most customization and commented out the Py_Initialize and Py_Finalize calls and it worked nicely. Further testing showed that I only needed to remove the Py_Finalize call and that calling Py_Initialize twice didn't cause a segfault. So, now that I think I verified that this is what was causing the segfault, I'd like to ask some questions. 1) Is calling Py_Initialize twice correct, or will I run into other problems down the road? 2) Another option I have is that I can remove all Py_Initialize / Py_Finalize calls from the individual customizations and just call Py_Initialize once when a user first starts the program. I am not sure if there is a mechanism to get something called at the end of the user's session with the program though, so is it a problem if I don't call Py_Finalize at the end? 3) Is there a proper way to nest these things? I imagine not since Py_Finalize doesn't take any arguments. If I could do... int session = Py_Initialize() Py_Finalize(session) But obviously, CPython is not coded that way so it is not supported. Thanks, ~Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwilson at the-wire.com Mon Feb 6 10:20:31 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 06 Feb 2012 10:20:31 -0500 Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control. Jon Bentley somewhere, sometime, published a portable PRNG for that exact reason. (I wish I could find that article.) Specifically he wanted portability across various manufacturer's O/Ss. Mel. From jenn.duerr at gmail.com Mon Feb 6 11:10:33 2012 From: jenn.duerr at gmail.com (noydb) Date: Mon, 6 Feb 2012 08:10:33 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> Message-ID: <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> Adding to dictionaries just isn't obvious... if it's not dict.Add or dict.Appaned or the like, not obvious to inexperienced me! From miki.tebeka at gmail.com Mon Feb 6 13:01:07 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 6 Feb 2012 10:01:07 -0800 (PST) Subject: undefined symbol: PyUnicodeUCS4_AsUTF8String In-Reply-To: References: Message-ID: <11079676.854.1328551268243.JavaMail.geo-discussion-forums@yqia35> IIRC it means that cairo was compiled against a Python compiled with --enable-unicode=ucs4. But the version of Python you have was not (default is ucs2). Maybe you can find a different version/packaging of cairo that matches this. From a.france.mailinglists at gmail.com Mon Feb 6 13:48:40 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Mon, 06 Feb 2012 19:48:40 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F302088.8010901@gmail.com> On 02/06/2012 09:57 AM, Matej Cepl wrote: > On 6.2.2012 09:45, Matej Cepl wrote: >> Also, how could I write a re-implementation of random.choice which would >> work same on python 2.6 and python 3.2? It is not only matter of unit >> tests, but I would really welcome if the results on both versions >> produce the same results. > > Silly, of course, the solution is obvious ... I have just embedded > random.choice from 2.6 to my code. > > Mat?j Is the above actually a good idea though? What I understand you're doing is embedding the source from the Python2.6 random.py file, /into/ your project files? Regards, A -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Mon Feb 6 14:26:42 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 06 Feb 2012 13:26:42 -0600 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4F302088.8010901@gmail.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: <4F302972.4010607@tim.thechases.com> On 02/06/12 12:48, Aaron France wrote: > On 02/06/2012 09:57 AM, Matej Cepl wrote: >> Silly, of course, the solution is obvious ... I have just >> embedded random.choice from 2.6 to my code. >> >> Mat?j > Is the above actually a good idea though? > > What I understand you're doing is embedding the source from > the Python2.6 random.py file, /into/ your project files? In an ideal world, the code wouldn't have broken backwards compat. However, given the conditions, if Matej is willing to forgo bug-fixes, it's a reasonable solution. The alternate might be to try moving the recent/fixed version into the old project and updating tests/data to work with it. I have some 2.4 production code in which I've pulled 2.6's zipfile module in to give access to the iterator access (rather than the .read() method which tries to read in umpteen gigs of data that I just want to spool out to a file on disk). -tkc From solipsis at pitrou.net Mon Feb 6 14:59:24 2012 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 6 Feb 2012 19:59:24 +0000 (UTC) Subject: nested embedding of interpreter References: Message-ID: Hello, Eric Frederich gmail.com> writes: > > 1)Is calling Py_Initialize twice correct, or will I run into other problems > down the road? It's fine in practice (spurious calls are ignored). > I am not sure if there is a mechanism to get something called at the end of the > user's session with the program though, so is it a problem if I don't call > Py_Finalize at the end? Yes, it's a problem. If you don't call Py_Finalize, atexit handlers, object destructors and the like will not be called. These include destructors of file objects (including stdout): any buffering in a still-open file opened for writing can be lost. Regards Antoine. From tjreedy at udel.edu Mon Feb 6 15:51:54 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 15:51:54 -0500 Subject: Python and TAP In-Reply-To: <4F2FC677.7020606@alien8.de> References: <4F2FC677.7020606@alien8.de> Message-ID: On 2/6/2012 7:24 AM, Frank Becker wrote: > On 06.02.12 01:58, Matej Cepl wrote: >> I have just finished listening to the FLOSS Weekly podcast #200 >> (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned >> about the existence of TAP (http://testanything.org/). A standardization >> of testing seems to be so obviously The Right Thing?, that it is strange >> that I don't see much related movement in the Python world (I know only TAP is not about 'standardization of testing' but standardized communication of test results between test modules and test harness. Python's two stdlib test packages include both test-writing methods and a test harness. They are compatible in the sense that doctests can be run within the unittest framework. >> about http://git.codesimply.com/?p=PyTAP.git;a=summary or >> git://git.codesimply.com/PyTAP.git, which seems to be very very simple >> and only producer). I presume PyTAP does something like converting (or rather, wrapping) output from unittests to (or rather, within) the TAP format, which includes wrapping in YAMLish. Or it provides alternate versions of the numerous AssertXxx functions in unittest. This is useful for someone running Python tests within a TAP harness, but not otherwise. >> What am I missing? Why nobody seems to care about joining TAP standard? The 'TAP standard' is what the Perl TAP module does. There is a pre-draft for an IETF standard. You could ask why Perl people don't care about joining the unittest 'standard'. -- Terry Jan Reedy From nedimmuminovic at gmail.com Mon Feb 6 16:18:15 2012 From: nedimmuminovic at gmail.com (n3d!m) Date: Mon, 6 Feb 2012 13:18:15 -0800 (PST) Subject: Http post and http get In-Reply-To: <26848894.3029.1327530209876.JavaMail.geo-discussion-forums@vbxy22> References: <26848894.3029.1327530209876.JavaMail.geo-discussion-forums@vbxy22> Message-ID: <31716695.3432.1328563095624.JavaMail.geo-discussion-forums@vbek1> Cookies work because I am able to login on website and GET other pages. From jeandupont115 at gmail.com Mon Feb 6 16:40:35 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Mon, 6 Feb 2012 13:40:35 -0800 (PST) Subject: how to read serial stream of data [newbie] Message-ID: I'd like to read in a stream of data which looks like this: the device sends out a byte-string of 11 bytes roughly every second: B0B0B0B0B03131B0B50D8A B0B0B0B0B03131B0B50D8A B0B0B031B63131B0310D8A B0B034B3323432B3310D8A B0B03237B53432B3310D8A . . . As you see every string is ended by 0D8A How can this be accomplished in Python? thanks Jean From mcepl at redhat.com Mon Feb 6 17:03:09 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 23:03:09 +0100 Subject: Python and TAP In-Reply-To: References: <4F2FC677.7020606@alien8.de> Message-ID: On 6.2.2012 21:51, Terry Reedy wrote: > The 'TAP standard' is what the Perl TAP module does. There is a > pre-draft for an IETF standard. You could ask why Perl people don't care > about joining the unittest 'standard'. I don't think it is fair: http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links (or http://testanything.org/wiki/index.php/TAP_Producers and http://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of producers and consumers in various programming languages. Mat?j From mcepl at redhat.com Mon Feb 6 17:06:04 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 23:06:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: On 6.2.2012 20:26, Tim Chase wrote: > In an ideal world, the code wouldn't have broken backwards compat. > However, given the conditions, if Matej is willing to forgo bug-fixes, > it's a reasonable solution. The alternate might be to try moving the > recent/fixed version into the old project and updating tests/data to > work with it. I have some 2.4 production code in which I've pulled 2.6's > zipfile module in to give access to the iterator access (rather than the > .read() method which tries to read in umpteen gigs of data that I just > want to spool out to a file on disk). Given I really don't care that much about distribution of my choice, this function def _choice(self, seq): """Choose a random element from a non-empty sequence. Embedding random.choice from 2.6 in order to get an uniform results between 2.6 and 3.2, where random module has been changed because of http://bugs.python.org/issue9025. See also http://groups.google.com/group/comp.lang.python\ /browse_thread/thread/2b000b8ca8c5e98e Raises IndexError if seq is empty """ return seq[int(random.random() * len(seq))] doesn't seem like something so terrible (and maintenance intense). :) Thanks for the help though Mat?j From casevh at gmail.com Mon Feb 6 18:27:17 2012 From: casevh at gmail.com (casevh) Date: Mon, 6 Feb 2012 15:27:17 -0800 (PST) Subject: PyCrypto builds neither with MSVC nor MinGW References: Message-ID: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> On Feb 5, 6:40?am, Alec Taylor wrote: > PIL, PyCrypto and many other modules require a C compiler and linker. > > Unfortunately neither install on my computer, with a PATH with the following: > > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC > C:\libraries\MinGW\msys\1.0\bin > C:\libraries\MinGW > C:\Python27\Scripts > > Output from G:\pycrypto>vcvarsall.bat > Setting environment for using Microsoft Visual Studio 2010 x86 tools. > > Error output from G:\pycrypto>python setup.py build --compiler msvc > http://pastebin.com/nBsuXDGg A couple of comments. You will need to complile either GMP or MPIR first. MPIR is a windows friendly fork of GMP and I use it create Windows binaries for gmpy. > > Error output from G:\pycrypto>python setup.py build --compiler mingw32 > 1> log1 2> log2 > Log1:http://pastebin.com/yG3cbdZv > Log2:http://pastebin.com/qvnshPeh > > Will there ever be support for newer MSVC versions? - Also, why Python 2.7 uses VS2008. I use the command line compiler included with in Microsoft's SDK 7.0 which is still available for download. I have step- by-step build instructions included in gmpy's source download. I would try to build MPIR and gmpy first and then adapt/modify the process for PyCrypto. MPIR home page: www.mpir.org gmpy source: gmpy.googlecode.com/files/gmpy-1.15.zip > doesn't even MinGW install PyCrypto for me? > > Thanks for all suggestions, > > Alec Taylor Hope these comments help... casevh From nitinbhargava74 at hotmail.com Mon Feb 6 21:12:08 2012 From: nitinbhargava74 at hotmail.com (Nitin Bhargava) Date: Tue, 7 Feb 2012 02:12:08 +0000 Subject: ctypes pointer Message-ID: Hi, I wish to call a function in c++ dll which returns a unicode array from python. extern "c" { __declspec(dllexport) int test(wchar_t** ppText) { *ppText = new wchar_t[30]; wcscpy(*ppText, L"this is a test"); return 0; } __declspec(dllexport) int FreeString(wchar_t** ppText) { delete [] *ppText; return 0; } } In python I'm doing this import ctypes dll = ctypes.cdll.LoadLibrary(r"x") func = dll.test func.argtypes = [ ctypes.POINTER(ctypes.c_wchar_p)] funcDel = dll.FreeString funcDel.argtypes = [ctypes.POINTER(ctypes.c_wchar_p)] a = ctypes.c_wchar_p('') z = ctypes.pointer(a) n= func(z) print a /* displays "this is a test" */ /* is this correct way to return charater array */ /* will memory allocated in c++ function be freed by python */ /* or should I call */ n = funcDel(z) thanks, Nitin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wuwei23 at gmail.com Mon Feb 6 22:21:08 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:21:08 -0800 (PST) Subject: Python and TAP References: <4F2FC677.7020606@alien8.de> Message-ID: <8fcb166f-71b1-4024-9158-aa1b9ca29f9c@v6g2000pba.googlegroups.com> On Feb 7, 8:03?am, Matej Cepl wrote: > On 6.2.2012 21:51, Terry Reedy wrote: > > The 'TAP standard' is what the Perl TAP module does. There is a > > pre-draft for an IETF standard. You could ask why Perl people don't care > > about joining the unittest 'standard'. > > I don't think it is fair:http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links(orhttp://testanything.org/wiki/index.php/TAP_Producersandhttp://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of > producers and consumers in various programming languages. That doesn't really disprove Terry's point. A lot of languages support Perl's regular expression syntax too: http://en.wikipedia.org/wiki/Regular_expression#Perl-derived_regular_expressions From wuwei23 at gmail.com Mon Feb 6 22:24:17 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:24:17 -0800 (PST) Subject: Python and TAP References: Message-ID: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> On Feb 6, 10:58?am, Matej Cepl wrote: > I have just finished listening to the FLOSS Weekly podcast #200 > (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned > about the existence of TAP (http://testanything.org/). [...] > What am I missing? Experience? Are you seriously advocating something for which you've done nothing more than watch a podcast? > Why nobody seems to care about joining TAP standard? You just discovered it, why do you assume that everyone else is familiar with it? Use it, document your successes and failures, and then if it _has value to you_ come back and tell us about your experiences. From wuwei23 at gmail.com Mon Feb 6 22:38:15 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:38:15 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <6e10da9a-a4e2-4531-8272-5f4fc4a592b9@g4g2000pbi.googlegroups.com> On Feb 5, 4:13?am, noydb wrote: > How do you build a dictionary dynamically? > >>> inDict = {} > >>> for inFC in inFClist: > >>> ? ? print inFC > >>> ? ? inCount = ?int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? The easiest way is to use the standard dictionary constructor. dict() can accept a list of key/value pairs: >>> pairs = [('a',1), ('b',2), ('c',3)] >>> dict(pairs) {'a': 1, 'c': 3, 'b': 2} And one way to build a list is with a list comprehension: >>> pairs = [(key, i+1) for i, key in enumerate(['a','b','c'])] >>> pairs [('a', 1), ('b', 2), ('c', 3)] So you can combine the two, using a list comprehension to build the list that is passed into dict(): >>> dict([(key, i+1) for i, key in enumerate(['a','b','c'])]) {'a': 1, 'c': 3, 'b': 2} As a convenience, you don't need the square brackets: >>> dict((key, i+1) for i, key in enumerate(['a','b','c'])) {'a': 1, 'c': 3, 'b': 2} For your example, I'd go with something like this: getCount = lambda x: int(arcpy.GetCount_management(x).getOutput(0)) inDict = dict( (inFC, getCount(inFC)) for inFC in inFClist ) Hope this helps. From wuwei23 at gmail.com Mon Feb 6 22:52:49 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:52:49 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: <34adb528-f190-4d3a-b5ac-92aa826aadfe@iu7g2000pbc.googlegroups.com> On Feb 3, 8:42?pm, Matej Cepl wrote: > Ask anybody developing in CoffeeScript/Vala how much they love debugging > when they have to go through different styles of errors, bugs in the > intermediate processes, etc. I develop in CoffeeScript. I love debugging it because _it's just javascript_. CS doesn't replace JS in any way. It just provides some convenience to cover a lot of the regular heavy lifting. If you're trying to write CS without any understanding of JS at all, well, I can see how that might be a problem, but that's hardly CoffeeScript's failing. From tjreedy at udel.edu Mon Feb 6 23:21:24 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 23:21:24 -0500 Subject: convert perl-script for voltcraft voltmeter to python [newbie] In-Reply-To: References: Message-ID: On 2/2/2012 3:57 PM, Jean Dupont wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: The script below is for an old-fashioned, slow, multiple-pin serial port, not usb. I don't know anything about interfacing through usb. Recheck what the voltmeter actually connects to. > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly in Python? Last I know, pyserial is also for old serial ports. Setting the properties should be pretty obvious from the manual or code. There are also python usb modules. http://sourceforge.net/projects/mysql-python/?source=directory > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); # wait 5ms per character > $port->read_const_time(200); # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > my ($nin, $in) = $port->read(255); > print $in; > } > > $port->close; -- Terry Jan Reedy From d at davea.name Mon Feb 6 23:43:36 2012 From: d at davea.name (Dave Angel) Date: Mon, 06 Feb 2012 23:43:36 -0500 Subject: building a dictionary dynamically In-Reply-To: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <4F30ABF8.8010202@davea.name> On 02/04/2012 01:13 PM, noydb wrote: > How do you build a dictionary dynamically? Doesn't seem to be an > insert object or anything. So I need an empty dictionary that I then > want to populate with values I get from looping through a list and > grabbing some properties. So simply, I have (fyi, arcpy = module for > interacting with gis data) > >>>> inDict = {} >>>> for inFC in inFClist: >>>> print inFC >>>> inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? > > And, is dictionaries the best route go about doing a comparison, such > that in the end I will have two dictionaries, one for IN and one for > OUT, as in I'm moving data files and want to verify that the count in > each file matches between IN and OUT. > > Thanks for any help! A dictionary is a mapping from key to value. So each entry consists of a key and a value, where the key is unique. As soon as you add another item with the same key, it overwrites the earlier one. The only other important constraint is that the key has to be of an immutable type, such as int or string. So you want to add the current inFC:inCount as an item in the dictionary? Put the following in your loop. inDict[inFC] = inCount You might also want to check if the key is a duplicate, so you could warn your user, or something. Easiest way to do that is if inFC in inDict: -- DaveA From clp2 at rebertia.com Mon Feb 6 23:48:54 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 6 Feb 2012 20:48:54 -0800 Subject: pySerial question, setting certain serial parameters [newbie] In-Reply-To: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> References: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> Message-ID: On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont wrote: > I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): > > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > I have thus far the following ?statements but I think it does not set the above parameters correctly: > import serial > voltport='/dev/ttyUSB2' > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) A link to the Perl library's documentation would be helpful. Cheers, Chris From skippy.hammond at gmail.com Mon Feb 6 23:56:45 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Feb 2012 15:56:45 +1100 Subject: Help with COM_error In-Reply-To: References: Message-ID: <4F30AF0D.2000606@gmail.com> Unfortunately this just means that Word threw an error and it's not giving many details about what that might be. Are you sure out_TOC is valid on the other computer? eg, http://stackoverflow.com/questions/3730428/why-cant-i-save-as-an-excel-file-from-my-python-code indicates Office fails in that way when the path isn't valid... Mark On 4/02/2012 12:10 AM, John Lay wrote: > I am not a programmer, but this past week I have had a crash course in > python scripting am have been rather impressed with myself for having > written a fairly complicated script that among many other processes > reads a database table via SearchCursor, populates a word template via > Bookmarks, then saves the document out as a PDF. > > The only problem is that it only works on my computer. When I move the > script to another computer with the same setup, I continue to receive > a Com_error. > > The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) > statement. I have tried both win32com.client and comtypes.client and > receive a similar error for both. > > win32.client: > com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', > u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ > \1033\\WDMAIN11.CHM', 36966, ), None) > > comtypes.client: > COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', > u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', > 36966, None)) > > It has been suggested that I try python-docx, but I have not been able > to get the module to work for me and I have been unable to find any > documentation on it. > > Can anyone help with the com errors? What do they mean? How do I > resolve them? > > Any help would be appreciated. > > John From roy at panix.com Tue Feb 7 00:07:36 2012 From: roy at panix.com (Roy Smith) Date: Tue, 07 Feb 2012 00:07:36 -0500 Subject: how to read serial stream of data [newbie] References: Message-ID: In article , Jean Dupont wrote: > I'd like to read in a stream of data which looks like this: > the device sends out a byte-string of 11 bytes roughly every second: > > B0B0B0B0B03131B0B50D8A > B0B0B0B0B03131B0B50D8A > B0B0B031B63131B0310D8A > B0B034B3323432B3310D8A > B0B03237B53432B3310D8A > . > . > . > > As you see every string is ended by 0D8A > How can this be accomplished in Python? The basic idea would be to open your datastream in binary mode (http://docs.python.org/library/functions.html#open), then use read(11) to read exactly 11 bytes into a string. Depending on what the 11 bytes are, you might want to use the struct module (http://docs.python.org/library/struct.html) to extract the data in a more useful form. From tjreedy at udel.edu Tue Feb 7 02:03:41 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 07 Feb 2012 02:03:41 -0500 Subject: building a dictionary dynamically In-Reply-To: <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> Message-ID: On 2/6/2012 11:10 AM, noydb wrote: > Adding to dictionaries just isn't obvious... if it's not dict.Add or > dict.Appaned or the like, not obvious to inexperienced me! Have you read section 4.8-mapping types, of the library manual? Or help(dict) at the interactive prompt? -- Terry Jan Reedy From mcepl at redhat.com Tue Feb 7 03:21:05 2012 From: mcepl at redhat.com (Matej Cepl) Date: Tue, 07 Feb 2012 09:21:05 +0100 Subject: Python and TAP In-Reply-To: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> References: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> Message-ID: On 7.2.2012 04:24, alex23 wrote: > Experience? > > Are you seriously advocating something for which you've done nothing > more than watch a podcast? No, I am not. If you reread my original post, you may find that I was asking exactly for experience and explanation why something which seems to me obvious is not done. I guess there must be some hook somewhere, right? Which is what I was asking for. One hook I've got (YAMLish is really ... well, let's keep this group G rated), others may yet to follow. Mat?j From silentquote at gmail.com Tue Feb 7 04:33:21 2012 From: silentquote at gmail.com (silentnights) Date: Tue, 7 Feb 2012 01:33:21 -0800 (PST) Subject: python file synchronization Message-ID: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> Hi All, I have the following problem, I have an appliance (A) which generates records and write them into file (X), the appliance is accessible throw ftp from a server (B). I have another central server (C) that runs a Django App, that I need to get continuously the records from file (A). The problems are as follows: 1. (A) is heavily writing to the file, so copying the file will result of uncompleted line at the end. 2. I have many (A)s and (B)s that I need to get the data from. 3. I can't afford losing any records from file (X) My current implementation is as follows: 1. Server (B) copy the file (X) throw FTP. 2. Server (B) make a copy of file (X) to file (Y.time_stamp) ignoring the last line to avoid incomplete lines. 3. Server (B) periodically make copies of file (X) and copy the lines starting from previous ignored line to file (Y.time_stamp) 4. Server (C) mounts the diffs_dir locally. 5. Server (C) create file (Y.time_stamp.lock) on target_dir then copy file (Y.time_stamp) to local target_dir then delete (Y.time_stamp.lock) 6. A deamon running in Server (C) read file list from the target_dir, and process those file that doesn't have a matching *.lock file, this procedure to avoid reading the file until It's completely copied. The above is implemented and working, the problem is that It required so many syncs and has a high overhead and It's hard to debug. I greatly appreciate your thoughts and suggestions. Lastly I want to note that am not a programming guru, still a noob, but I am trying to learn from the experts. :-) From storchaka at gmail.com Tue Feb 7 05:05:35 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 07 Feb 2012 12:05:35 +0200 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: 07.02.12 00:06, Matej Cepl ???????(??): > return seq[int(random.random() * len(seq))] > > doesn't seem like something so terrible (and maintenance intense). :) _choice('abc') returns 'a' with probability P('a') = 1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with probability P('b') = 3002399751580331/9007199254740992 = 1/3 + 1/27021597764222976. P('b') - P('a') = 1/9007199254740992. This may be acceptable for your application, but for applications that are concerned not only about the repeatability of results, but the accuracy and consistency with the results obtained by other (not Python) applications, it is better to get rid of such a notorious bias. From jeanmichel at sequans.com Tue Feb 7 05:48:04 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 07 Feb 2012 11:48:04 +0100 Subject: PythonWin debugger holds onto global logging objects too long In-Reply-To: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> References: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> Message-ID: <4F310164.3070606@sequans.com> Vinay Sajip wrote: > On Jan 24, 2:52 pm, Rob Richardson wrote: > >> I use PythonWin to debug the Python scripts we write. Our scripts often use the log2pyloggingpackage. When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. The result is that after running the script five times, the log file contains five copies of every message. The only way I know to clean this up and get only a single copy of each message is to close PythonWin and restart it. >> >> What do I have to do in my scripts to clean up theloggingobjects so that I never get more than one copy of each message in my log files? >> >> > > I don't know what log2py is - Google didn't show up anything that > looked relevant. If you're talking about the logging package in the > Python standard library, I may be able to help: but a simple script > that I ran in PythonWin didn't show any problems, so you'll probably > need to post a short script which demonstrates the problem when run in > PythonWin. > > Regards, > > Vinay Sajip > Same here, can't find anything about log2py. Anyway it's possible that your pythonwin does not spawn a clean python interpreter for every run, keeping the same one. So you could possibly keep adding log handlers to your loggers because they may be static objects (like for the standard logging module). One solution would be to empty your logger handler list before adding any. I'm just guessing though, difficult to know without any info on log2py. JM From fw at deneb.enyo.de Tue Feb 7 07:11:12 2012 From: fw at deneb.enyo.de (Florian Weimer) Date: Tue, 07 Feb 2012 13:11:12 +0100 Subject: Static HTML documentation from docstrings Message-ID: <87zkcu4zdr.fsf@mid.deneb.enyo.de> I'm slightly confused about docstrings and HTML documentation. I used to think that the library reference was (in part) generated from the source code, but this does not seem to be the case. Is there any tool support for keeping documentation and code in sync? From jeandupont115 at gmail.com Tue Feb 7 07:13:39 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 04:13:39 -0800 (PST) Subject: how to read serial stream of data [newbie] References: Message-ID: On 7 feb, 06:07, Roy Smith wrote: > In article > , > ?Jean Dupont wrote: > > > I'd like to read in a stream of data which looks like this: > > the device sends out a byte-string of 11 bytes roughly every second: > > > ? ? B0B0B0B0B03131B0B50D8A > > ? ? B0B0B0B0B03131B0B50D8A > > ? ? B0B0B031B63131B0310D8A > > ? ? B0B034B3323432B3310D8A > > ? ? B0B03237B53432B3310D8A > > . > > . > > . > > > As you see every string is ended by 0D8A > > How can this be accomplished in Python? > > The basic idea would be to open your datastream in binary mode > (http://docs.python.org/library/functions.html#open), then use read(11) > to read exactly 11 bytes into a string. > > Depending on what the 11 bytes are, you might want to use the struct > module (http://docs.python.org/library/struct.html) to extract the data > in a more useful form. Thank you very much for taking the time to reply. I'm really completely new to python and all help is really very welcome. In the documentation I read that to open the datastream binary I need to add the option b this is how far I got until now: #!/usr/bin/python import serial, time, os voltport='/dev/ttyUSB2' print "Enter a filename:", filename = raw_input() voltdata = open(filename,'wb') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) ser2.setDTR(level=True) print "State of DSR-line: ", ser2.getDSR() #the following line was added because I want to be sure that all parameters are set the same as under a working application for the same device os.system("stty -F31:0:bbb: 0:0:0:0:0:0:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0") print "Opening " + ser2.portstr s =ser2.read(11) #read up to 11bytes voltdata.write(s) ser2.close() voltdata.close() However the above code doesn't fill my file with data, I guess the data should also be flushed somewhere in the code but I'm unsure where to do that. A futher consideration: because the device sends its data continuously I guess I'd have to use the byte sequence 0D8A of the previously sent data string as an indicator that the next 9 bytes are those I really want and put those in a string which than coudl be written to the file all help welcome Jean From samdansobe at yahoo.com Tue Feb 7 07:27:25 2012 From: samdansobe at yahoo.com (Sammy Danso) Date: Tue, 7 Feb 2012 04:27:25 -0800 (PST) Subject: iterating over list with one mising value Message-ID: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Hello experts, I am having trouble accessing the content of my list. my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] ? I am unable to iterate through list to access invidual value pairs ? I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? ? Your help would be much appreciated. ? Thanks Sammy ___________________________________ http://www.comp.leeds.ac.uk/scsod/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Tue Feb 7 07:33:32 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 7 Feb 2012 04:33:32 -0800 Subject: Static HTML documentation from docstrings In-Reply-To: <87zkcu4zdr.fsf@mid.deneb.enyo.de> References: <87zkcu4zdr.fsf@mid.deneb.enyo.de> Message-ID: On Tue, Feb 7, 2012 at 4:11 AM, Florian Weimer wrote: > I'm slightly confused about docstrings and HTML documentation. ?I used > to think that the library reference was (in part) generated from the > source code, but this does not seem to be the case. > > Is there any tool support for keeping documentation and code in sync? Yes. Sphinx's "autodoc" extension allows the placement of API documentation directly in docstrings and comments: http://sphinx.pocoo.org/ext/autodoc.html Cheers, Chris From antti.ylikoski at tkk.fi Tue Feb 7 08:48:07 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Tue, 07 Feb 2012 15:48:07 +0200 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: On 7.2.2012 14:13, Jean Dupont wrote: > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > rtscts=0, dsrdtr=0, timeout=15) In Python, if you want to continue the source line into the next text line, you must end the line to be continued with a backslash '\'. So you should write: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ rtscts=0, dsrdtr=0, timeout=15) and analogously. Hope that this will help. Andy. From __peter__ at web.de Tue Feb 7 09:02:33 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 15:02:33 +0100 Subject: how to read serial stream of data [newbie] References: Message-ID: Antti J Ylikoski wrote: > On 7.2.2012 14:13, Jean Dupont wrote: >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >> rtscts=0, dsrdtr=0, timeout=15) > > In Python, if you want to continue the source line into the next text > line, you must end the line to be continued with a backslash '\'. > > So you should write: > > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ > rtscts=0, dsrdtr=0, timeout=15) > > and analogously. > > Hope that this will help. Andy. This is wrong. A line with an open parenthesis is continued automatically: >>> zip("abc", ... "def") [('a', 'd'), ('b', 'e'), ('c', 'f')] >>> ("abc" ... "def") 'abcdef' >>> 1 + 2 + ( ... 3) 6 From modelnine at modelnine.org Tue Feb 7 09:04:39 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Tue, 07 Feb 2012 15:04:39 +0100 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: <4F312F77.2000203@modelnine.org> Am 07.02.2012 14:48, schrieb Antti J Ylikoski: > On 7.2.2012 14:13, Jean Dupont wrote: >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >> rtscts=0, dsrdtr=0, timeout=15) > > In Python, if you want to continue the source line into the next text > line, you must end the line to be continued with a backslash '\'. Absolutely not true, and this is bad advice (stylistically). When (any form of) brackets are open at the end of a line, Python does not start a new command on the next line but rather continues the backeted content. So: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) is perfectly fine and certainly the recommended way of putting this. Adding the backslash-continuation is always _possible_, but only _required_ when there are no open brackets. So: x = "hello" \ " test" is equivalent to: x = ("hello" " test") in assigning: x = "hello test" -- --- Heiko. From d at davea.name Tue Feb 7 09:46:12 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 09:46:12 -0500 Subject: iterating over list with one mising value In-Reply-To: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4F313934.9000502@davea.name> On 02/07/2012 07:27 AM, Sammy Danso wrote: > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example ['a', 1, 'b', 1, 'c', 3, 'd'] > > I am unable to iterate through list to access invidual value pairs > > I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? > > Your help would be much appreciated. > > Thanks > Sammy The real answer is to figure out how it gets into that state. Is the input file invalid? Or you have a device that sometimes skips one? But if you're stuck with the data in that list: If the list is of odd size, truncate it. Then your loop should not run into an uneven pair. Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions. -- DaveA From jeandupont115 at gmail.com Tue Feb 7 09:46:28 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 06:46:28 -0800 (PST) Subject: how to read serial stream of data [newbie] References: Message-ID: <97e03762-e7b7-4202-a0b8-51ff579c5066@l14g2000vbe.googlegroups.com> On 7 feb, 15:04, Heiko Wundram wrote: > Am 07.02.2012 14:48, schrieb Antti J Ylikoski: > > > On 7.2.2012 14:13, Jean Dupont wrote: > >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > >> rtscts=0, dsrdtr=0, timeout=15) > > > In Python, if you want to continue the source line into the next text > > line, you must end the line to be continued with a backslash '\'. > > Absolutely not true, and this is bad advice (stylistically). > > When (any form of) brackets are open at the end of a line, Python does > not start a new command on the next line but rather continues the > backeted content. > > So: > > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > ? ? ? ? ? ? ? ? ? ? ? rtscts=0, dsrdtr=0, timeout=15) > > is perfectly fine and certainly the recommended way of putting this. > > Adding the backslash-continuation is always _possible_, but only > _required_ when there are no open brackets. > > So: > > x = "hello" \ > ? ? ?" test" > > is equivalent to: > > x = ("hello" > ? ? ? " test") > > in assigning: > > x = "hello test" > > -- > --- Heiko. Hello to all who gave advice concerning the line continuation, in fact this was not a real problem but happened by accident copying and pasting my program lines. Advice concerning the empty file would of course also be very much appreciated. thanks, Jean From waqif at smartbaba.com Tue Feb 7 10:00:43 2012 From: waqif at smartbaba.com (Smart Baba) Date: Tue, 7 Feb 2012 07:00:43 -0800 (PST) Subject: smart baba new year special offer Message-ID: <4091ec8b-7253-43c0-a32f-adff9ad5544c@q8g2000pbb.googlegroups.com> Smart Baba special limited offer. We are the only world lowest-cost, yet professional and elegant-designing website developing company. Follow us for further details: www.websitedeals.com From ulrich.eckhardt at dominolaser.com Tue Feb 7 10:11:04 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 07 Feb 2012 16:11:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9hr709-i9c.ln1@satorlaser.homedns.org> Am 06.02.2012 09:45, schrieb Matej Cepl: > Also, how could I write a re-implementation of random.choice which would > work same on python 2.6 and python 3.2? It is not only matter of unit > tests, but I would really welcome if the results on both versions > produce the same results. Two approaches come to mind: 1. make two runs and verify that they differ This is a bit problematic, because there is a small but nonzero chance that two runs don't differ. Random numbers are just not random enough. Anyhow, afterwards, sort the results again and verify that it was just the order that differs. 2. hack the random module into something nonrandom I think you can "import debug_random as random" and then have your testee automatically pick up that module instead of the real one. Since you already hardcoded the results to check against ("expected = ..." in your code), you can also hard-code the sequence of random numbers corresponding to that. This is even cleaner, as you don't rely on something being deterministic that is supposed to be random, which is not totally surprising but still somehow paradox. Uli From rantingrickjohnson at gmail.com Tue Feb 7 10:34:14 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 7 Feb 2012 07:34:14 -0800 (PST) Subject: iterating over list with one mising value References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: On Feb 7, 8:46?am, Dave Angel wrote: > On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, > > I am having trouble accessing the content of my list. > > my list content has 2-pair value with the exception of one which has single value. here is an example ?['a', 1, 'b', 1, 'c', 3, 'd'] First you need to explain why you're using a flat list when a number of other structures would be the better choice; like a list of tuples or a dict. From ian.g.kelly at gmail.com Tue Feb 7 11:03:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 7 Feb 2012 09:03:52 -0700 Subject: iterating over list with one mising value In-Reply-To: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso wrote: > > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] > > I am unable to iterate through list to access invidual value pairs > > I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? What are you using to iterate through pairs instead of individual elements? It sounds like it is not very flexible. I would recommend instead using the "grouper" recipe from the itertools documentation: http://docs.python.org/library/itertools.html#recipes Cheers, Ian From python.list at tim.thechases.com Tue Feb 7 11:34:32 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 07 Feb 2012 10:34:32 -0600 Subject: iterating over list with one mising value In-Reply-To: References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4F315298.9030204@tim.thechases.com> On 02/07/12 09:34, Rick Johnson wrote: > On Feb 7, 8:46 am, Dave Angel wrote: >> On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, >>> I am having trouble accessing the content of my list. my >>> list content has 2-pair value with the exception of one >>> which has single value. here is an example ['a', 1, 'b', >>> 1, 'c', 3, 'd'] > > First you need to explain why you're using a flat list when a > number of other structures would be the better choice; like a > list of tuples or a dict. I'm not sure there's really a need for the OP to explain why...perhaps the data comes from an untrusted (or incompetent) source and the routine the OP is asking about is to *create* such a list-of-tuples or a dict. The more important question is what the user/app wants to do when such a case is encountered: do they want to ignore the unpaired value, or do they want to pad it with a default value? -tkc From antti.ylikoski at tkk.fi Tue Feb 7 12:44:59 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Tue, 07 Feb 2012 19:44:59 +0200 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: On 7.2.2012 16:02, Peter Otten wrote: > Antti J Ylikoski wrote: > >> On 7.2.2012 14:13, Jean Dupont wrote: >>> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >>> rtscts=0, dsrdtr=0, timeout=15) >> >> In Python, if you want to continue the source line into the next text >> line, you must end the line to be continued with a backslash '\'. >> >> So you should write: >> >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ >> rtscts=0, dsrdtr=0, timeout=15) >> >> and analogously. >> >> Hope that this will help. Andy. > > This is wrong. A line with an open parenthesis is continued automatically: > >>>> zip("abc", > ... "def") > [('a', 'd'), ('b', 'e'), ('c', 'f')] >>>> ("abc" > ... "def") > 'abcdef' >>>> 1 + 2 + ( > ... 3) > 6 > > Thank you for correcting me. Andy. From SMac2347 at comcast.net Tue Feb 7 13:14:28 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 10:14:28 -0800 (PST) Subject: Reading files in from the proper directory Message-ID: Hello. I am admittedly a Python novice, and ran into some trouble trying to write a program that will pull multiple excel files all into one file, with each file on a different sheet. I am confident most of the code is correct, as the program runs without any errors and I found the base of it online, making changes as necessary for my own purposes. However, I am having trouble specifying the exact directory where my code should be pulling the files from. All the files are in the same folder, and I have put the folder on my desktop. Am I correct in thinking that I need to change the current working directory to this folder in order for Python to read in these files, then generate my output? Or should I be doing something else? Any and all help is appreciated, thanks! From d at davea.name Tue Feb 7 13:40:10 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 13:40:10 -0500 Subject: Reading files in from the proper directory In-Reply-To: References: Message-ID: <4F31700A.8050905@davea.name> On 02/07/2012 01:14 PM, SMac2347 at comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without any errors and I found the base of it online, making changes > as necessary for my own purposes. However, I am having trouble > specifying the exact directory where my code should be pulling the > files from. All the files are in the same folder, and I have put the > folder on my desktop. Am I correct in thinking that I need to change > the current working directory to this folder in order for Python to > read in these files, No, Python certainly does not constrain you to working with files only in the current working directory. My rule of thumb is never to change the cwd in a Python program. You can use relative paths to open files, or you can use absolute paths. There is even a library function os.path.abspath() for converting a relative path to an absolute one. If you do change cwd during the running of a program, then relative filenames that worked earlier might no longer work. You could convert them all to absolute paths, but that's more work. You can piece together path strings using os.path.join(). It's smart enough to know the path separator for your particular platform. Check out this page: http://docs.python.org/library/os.path.html > then generate my output? Or should I be doing > something else? > > Any and all help is appreciated, thanks! > -- DaveA From tyler at tysdomain.com Tue Feb 7 13:41:57 2012 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 07 Feb 2012 11:41:57 -0700 Subject: keeping twisted and wxPython in sync Message-ID: <4F317075.40209@tysdomain.com> Hello all: I have a couple questions. First, is there a way to know if connectTCP failed? I am writing a client with Twisted and would like to be able to notify the user if they couldn't connect. Second, I set the protocol on my factory after a connection has been made. So when I send my user and password, that is when I connect. Is there a way to handle waiting for the connection to complete? -- Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud Sent from my toaster. From __peter__ at web.de Tue Feb 7 13:59:05 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 19:59:05 +0100 Subject: Reading files in from the proper directory References: Message-ID: SMac2347 at comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without any errors and I found the base of it online, making changes > as necessary for my own purposes. That confidence usually evaporates once you write the first unit test ;) > However, I am having trouble > specifying the exact directory where my code should be pulling the > files from. All the files are in the same folder, and I have put the > folder on my desktop. Am I correct in thinking that I need to change > the current working directory to this folder in order for Python to > read in these files, then generate my output? Or should I be doing > something else? Do it properly, allow specifying the files on the commandline: import argparse def process_files(files, destfile): # put your real code here print "merge " + "\n ".join(files) print "into " + destfile if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("files", metavar="file", nargs="+") parser.add_argument("destfile") args = parser.parse_args() process_files(args.files, args.destfile) If you have standard locations for sources and destination you can wrap your python script into a little batch file containing something like python \source\path\*.xls \dest\path\merged.xls and invoke that to get both flexibility and convenience. From SMac2347 at comcast.net Tue Feb 7 14:03:11 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 11:03:11 -0800 (PST) Subject: Reading files in from the proper directory References: Message-ID: <6fc4ebfa-6607-4af7-83d7-65c61408a6ac@m24g2000yqb.googlegroups.com> On Feb 7, 1:40?pm, Dave Angel wrote: > On 02/07/2012 01:14 PM, SMac2... at comcast.net wrote:> Hello. I am admittedly a Python novice, and ran into some trouble > > trying to write a program that will pull multiple excel files all into > > one file, with each file on a different sheet. > > > I am confident most of the code is correct, as the program runs > > without any errors and I found the base of it online, making changes > > as necessary for my own purposes. However, I am having trouble > > specifying the exact directory where my code should be pulling the > > files from. All the files are in the same folder, and I have put the > > folder on my desktop. Am I correct in thinking that I need to change > > the current working directory to this folder in order for Python to > > read in these files, > > No, Python certainly does not constrain you to working with files only > in the current working directory. ?My rule of thumb is never to change > the cwd in a Python program. ?You can use relative paths to open files, > or you can use absolute paths. ?There is even a library function > os.path.abspath() for converting a relative path to an absolute one. > > If you do change cwd during the running of a program, then relative > filenames that worked earlier might no longer work. ?You could convert > them all to absolute paths, but that's more work. > > You can piece together path strings using os.path.join(). ?It's smart > enough to know the path separator for your particular platform. > > Check out this page:http://docs.python.org/library/os.path.html > > > then generate my output? Or should I be doing > > something else? > > > Any and all help is appreciated, thanks! > > -- > > DaveA Thanks Dave. I am a bit lost as to what the problem is then - the program runs glitch free, but then only prints: "NOTE *** No xls files in C:/Documents and Settings/smacdon/." as specified below by my program. Any idea what the issue might be (my code is below): import xlrd, xlwt import glob, os.path def merge_xls (in_dir, out_file="C:\Documents and Settings\smacdon \Desktop\09 Aggregate JWS\09_merged_data.xls"): xls_files = glob.glob(in_dir + "*.xls") sheet_names = [os.path.basename(v)[:-4] for v in xls_files] sheet_excl = [os.path.basename(v)[:-4] for v in xls_files if len (os.path.basename(v)[:-4]) > 29] merged_book = xlwt.Workbook() if in_dir[-1:] != "/": in_dir = in_dir + "/" xls_files.sort() if xls_files: for k, xls_file in enumerate(xls_files): print "---> Processing file %s" % (xls_file) if len (sheet_names[k]) <= 29: book = xlrd.open_workbook(xls_file) if book.nsheets == 1: ws = merged_book.add_sheet(sheet_names[k]) sheet = book.sheet_by_index(0) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) elif book.nsheets in range(2, 100): for sheetx in range(book.nsheets): sheet0n = sheet_names[k]+str(sheetx +1).zfill(2) ws = merged_book.add_sheet(sheet0n) sheet = book.sheet_by_index(sheetx) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) else: print "ERROR *** File %s has %s sheets (maximum is 99)" % (xls_file, book.nsheets) raise else: print "WARNING *** File name too long: <%s.xls> (maximum is 29 chars) " % (sheet_names[k]) print "WARNING *** File <%s.xls> was skipped." % (sheet_names[k]) merged_book.save(out_file) print print "---> Merged xls file written to %s using the following source files: " % (out_file) for k, v in enumerate(sheet_names): if len(v) <= 29: print "\t", str(k+1).zfill(3), "%s.xls" % (v) print if sheet_excl: print "--> The following files were skipped because the file name exceeds 29 characters: " for k, v in enumerate(sheet_excl): print "\t", str(k+1).zfill(3), v else: print "NOTE *** No xls files in %s." % (in_dir) merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" From SMac2347 at comcast.net Tue Feb 7 14:13:26 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 11:13:26 -0800 (PST) Subject: Reading files in from the proper directory References: Message-ID: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Thanks for the responses. Below is the code I have thus far. while the program runs glitch-free, it only results in the printing of the message: "NOTE *** No xls files in C:/Documents and Settings/smacdon/." as specified by my code. Any idea as to why it might be unable to find the .xls documents (yes they are .xls documents and not .xlsx). Thanks! import xlrd, xlwt import glob, os.path def merge_xls (in_dir, out_file="C:\Documents and Settings\smacdon \Desktop\09 Aggregate JWS\09_merged_data.xls"): xls_files = glob.glob(in_dir + "*.xls") sheet_names = [os.path.basename(v)[:-4] for v in xls_files] sheet_excl = [os.path.basename(v)[:-4] for v in xls_files if len (os.path.basename(v)[:-4]) > 29] merged_book = xlwt.Workbook() if in_dir[-1:] != "/": in_dir = in_dir + "/" xls_files.sort() if xls_files: for k, xls_file in enumerate(xls_files): print "---> Processing file %s" % (xls_file) if len (sheet_names[k]) <= 29: book = xlrd.open_workbook(xls_file) if book.nsheets == 1: ws = merged_book.add_sheet(sheet_names[k]) sheet = book.sheet_by_index(0) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) elif book.nsheets in range(2, 100): for sheetx in range(book.nsheets): sheet0n = sheet_names[k]+str(sheetx +1).zfill(2) ws = merged_book.add_sheet(sheet0n) sheet = book.sheet_by_index(sheetx) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) else: print "ERROR *** File %s has %s sheets (maximum is 99)" % (xls_file, book.nsheets) raise else: print "WARNING *** File name too long: <%s.xls> (maximum is 29 chars) " % (sheet_names[k]) print "WARNING *** File <%s.xls> was skipped." % (sheet_names[k]) merged_book.save(out_file) print print "---> Merged xls file written to %s using the following source files: " % (out_file) for k, v in enumerate(sheet_names): if len(v) <= 29: print "\t", str(k+1).zfill(3), "%s.xls" % (v) print if sheet_excl: print "--> The following files were skipped because the file name exceeds 29 characters: " for k, v in enumerate(sheet_excl): print "\t", str(k+1).zfill(3), v else: print "NOTE *** No xls files in %s." % (in_dir) merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" From jeandupont115 at gmail.com Tue Feb 7 14:44:40 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 11:44:40 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: Message-ID: On 7 feb, 05:21, Terry Reedy wrote: > On 2/2/2012 3:57 PM, Jean Dupont wrote: > > > I'd like to read in the output of a voltcraft vc960 voltmeter > > connected to a usb-port. > > I found the perl-script below but I'd like to accomplish the same with > > python: > > The script below is for an old-fashioned, slow, multiple-pin serial > port, not usb. I don't know anything about interfacing through usb. > Recheck what the voltmeter actually connects to. The voltmeter uses an optical rs232-connection, that is "good enough technology" for this purpose. But as I don't have a computer with real rs232 ports I use a rs232toUSB adapter which presents itself to the linux-computer as /dev/ttyUSBx. > > > I guess I have to use the module serial but I don't know how I should > > set the serial parameters so they are the same as in the perl-script. > > Could someone supply me the command for setting the serial-parameters > > correctly in Python? > > Last I know, pyserial is also for old serial ports. Setting the > properties should be pretty obvious from the manual or code. > It is not so obvious as you might think, one reason being the handshake line(s?) are used in an unconvential way to supply power to the rs232-optical interface > There are also python usb modules.http://sourceforge.net/projects/mysql-python/?source=directory I followed this link but all I found was something concerning mysql...??? > anyway, thanks for trying to help Jean > > > > > > > > #!/usr/bin/perl > > > use strict; > > use warnings; > > > use Device::SerialPort; > > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > > my ($devicepath) = @ARGV; > > > my $port = new Device::SerialPort($devicepath); > > die "Couldn't open serial port" if ! defined $port; > > > $port->baudrate(2400); > > $port->databits(8); > > $port->parity("none"); > > $port->stopbits(1); > > $port->handshake("none"); > > $port->rts_active(0); > > $port->dtr_active(1); > > > #$port->read_char_time(5); ? ? # wait 5ms per character > > $port->read_const_time(200); ? # 0.2 second per unfulfilled "read" > > call > > $| = 1; # autoflush STDOUT > > while(1) { > > ? ? ? ? ?my ($nin, $in) = $port->read(255); > > ? ? ? ? ?print $in; > > } > > > $port->close; > > -- > Terry Jan Reedy From gordon at panix.com Tue Feb 7 14:46:42 2012 From: gordon at panix.com (John Gordon) Date: Tue, 7 Feb 2012 19:46:42 +0000 (UTC) Subject: Reading files in from the proper directory References: Message-ID: In SMac2347 at comcast.net writes: > Am I correct in thinking that I need to change the current working > directory to this folder in order for Python to read in these files, > then generate my output? You don't have to do it that way, no. In general, when opening a file, you can do it two ways: Either provide a full pathname, or provide a relative pathname. If you provide a full pathname (for example "/usr/home/smith/myfile.txt"), that file will be opened and it does not matter what the current working directory is. If you provide a relative pathname (for example "myfile.txt"), python will attempt to open that file starting from the current working dir. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From rantingrickjohnson at gmail.com Tue Feb 7 14:47:31 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 7 Feb 2012 11:47:31 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: <46cb8864-dd45-482a-b0b0-ccf20ce3638b@f14g2000yqe.googlegroups.com> On Feb 7, 11:44?am, Dennis Lee Bieber wrote: > > [...] > > ? ? ? ? Well, since readline() pretty much by definition wants a line-ending > character before returning, it obviously won't work. (Side comment: > readline() isn't even shown as part of the basic Serial class -- it is > in a class FileLike:http://pyserial.sourceforge.net/pyserial_api.html > -- oh wait.. fine print says that is a base class for Serial on non-io > module systems). > > ? ? ? ? What is the boundary marker for your 11-byte chunks? You may need to > do a synchronization loop using > > [...] > > ? ? ? ? Your timeout is FIFTEEN SECONDS! > > ? ? ? ? Suspect you want something like Why do you have this unnatural penchant for superfluous eight space indention? I always thought that indenting the first sentence of a paragraph was quite ridiculous anyhow, however, i cannot even fathom any need to indent a single sentence! Are you purposely injecting this noise or is this some automated behavior of your broken mail client? Either way, i find it annoying and unreadable. Could you please rectify this issue and bring signal to noise ratio back to reasonable levels? From gordon at panix.com Tue Feb 7 15:00:34 2012 From: gordon at panix.com (John Gordon) Date: Tue, 7 Feb 2012 20:00:34 +0000 (UTC) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: In <9bfb3e39-2bc6-4399-90cc-1c53aa06265e at h6g2000yqk.googlegroups.com> SMac2347 at comcast.net writes: > xls_files = glob.glob(in_dir + "*.xls") You may want to put a directory separator character in between the directory name and the filename glob pattern. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From __peter__ at web.de Tue Feb 7 15:16:57 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 21:16:57 +0100 Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: SMac2347 at comcast.net wrote: > xls_files = glob.glob(in_dir + "*.xls") Try changing that to pattern = os.path.join(in_dir, "*.xls") xls_files = glob.glob(pattern) os.path.join() inserts a (back)slash between directory and filename if necessary. > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") If you paste the directory name literal into the interactive interpreter you'll be surprised: >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' "\09" is intrpreted as chr(9). Use a raw string to prevent Python from interpreting a backslash as the start of an escape sequence >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' or use forward slashes as directory separators. From samdansobe at yahoo.com Tue Feb 7 15:23:09 2012 From: samdansobe at yahoo.com (Sammy Danso) Date: Tue, 7 Feb 2012 12:23:09 -0800 (PST) Subject: iterating over list with one mising value Message-ID: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Hi Expert, Thanks for your responses and help. thought I should provide more information for clarity. ? Please find the error message below for more information ? ???for (key, value) in wordFreq2: ValueError: need more than 1 value to unpack ? this is a sample of my data ? ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] ? What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully ? my desired ouput is the format?below in a text file. with 3 which 3 were 2 .. . . other ? Thanks again. Sammy --- On Tue, 2/7/12, Dave Angel wrote: From: Dave Angel Subject: Re: iterating over list with one mising value To: "Sammy Danso" Cc: python-list at python.org Date: Tuesday, February 7, 2012, 2:46 PM On 02/07/2012 07:27 AM, Sammy Danso wrote: > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] >???I am unable to iterate through list to access invidual value pairs >???I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? >???Your help would be much appreciated. >???Thanks > Sammy The real answer is to figure out how it gets into that state.? Is the input file invalid?? Or you have a device that sometimes skips one? But if you're stuck with the data in that list: If the list is of odd size, truncate it.? Then your loop should not run into an uneven pair. Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions. -- DaveA -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Feb 7 15:58:25 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 15:58:25 -0500 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319071.1080402@davea.name> On 02/07/2012 03:23 PM, Sammy Danso wrote: > Please don't top-post. It hopelessly mixes responses out of order. > > Hi Expert, > Thanks for your responses and help. thought I should provide more information for clarity. > > Please find the error message below for more information > > for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack That's not the complete error message; it's missing the call stack. And also missing the line that's getting the ValueError. > > this is a sample of my data > > ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', > 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully OK, good. If you know your error is always at the end, and you know the data to be padded, then just do it: if len(mylist) % 2 > 0: mylist.append(0) > > my desired ouput is the format below in a text file. > with 3 > which 3 > were 2 > .. > . > . > other > > > Thanks again. > Sammy My guess is that you have an entirely different problem, unrelated to the missing value at the end. But you don't show us enough code to help you. How many items of the list are processed before the exception happens? -- DaveA From python at mrabarnett.plus.com Tue Feb 7 16:13:42 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 07 Feb 2012 21:13:42 +0000 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319406.8060206@mrabarnett.plus.com> On 07/02/2012 20:23, Sammy Danso wrote: > Hi Expert, > Thanks for your responses and help. thought I should provide more > information for clarity. > > Please find the error message below for more information > > for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack > > this is a sample of my data > > ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, > 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, > 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, > 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, > 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, > 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, > 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, > 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', > 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, > 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, > 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, > 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, > 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', > 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, > 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', > 1, '600am', 1, '100pm', 1, '', 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default > so I can iterate sucessfully > > my desired ouput is the format below in a text file. > with 3 > which 3 > were 2 > .. > . > . > other > The line: for (key, value) in wordFreq2: attempts to iterate through the list wordFreq2, where each item in the list is a _pair_ of values. However, what you have is a list of _single_ values, alternating string and number. That's why it's complaining that it can't unpack. From a.france.mailinglists at gmail.com Tue Feb 7 16:25:13 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 07 Feb 2012 22:25:13 +0100 Subject: iterating over list with one mising value In-Reply-To: <4F319406.8060206@mrabarnett.plus.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> Message-ID: <4F3196B9.8080109@gmail.com> On 02/07/2012 10:13 PM, MRAB wrote: > On 07/02/2012 20:23, Sammy Danso wrote: >> Hi Expert, >> Thanks for your responses and help. thought I should provide more >> information for clarity. > > >> Please find the error message below for more information >> > >> for (key, value) in wordFreq2: >> ValueError: need more than 1 value to unpack >> >> this is a sample of my data >> >> ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, >> 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, >> 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, >> 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, >> 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, >> 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, >> 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, >> 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', >> 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, >> 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, >> 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, >> 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, >> 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', >> 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, >> 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', >> 1, '600am', 1, '100pm', 1, '', 3, 'other'] >> >> What I would like to do is to pad the last value 'other' with a default >> so I can iterate sucessfully >> >> my desired ouput is the format below in a text file. >> with 3 >> which 3 >> were 2 >> .. >> . >> . >> other >> > The line: > > for (key, value) in wordFreq2: > > attempts to iterate through the list wordFreq2, where each item in the > list is a _pair_ of values. > > However, what you have is a list of _single_ values, alternating string > and number. > > That's why it's complaining that it can't unpack. for i in range(0, len(x), 2): print x[i-1], x[i] From python.list at tim.thechases.com Tue Feb 7 16:31:49 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 07 Feb 2012 15:31:49 -0600 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319845.10301@tim.thechases.com> > Thanks for your responses and help. thought I should provide > more information for clarity. It sounds like you want the "grouper" function as defined here: http://docs.python.org/library/itertools.html#recipes which does what you describe. -tkc From rosuav at gmail.com Tue Feb 7 16:37:14 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Feb 2012 08:37:14 +1100 Subject: iterating over list with one mising value In-Reply-To: <4F3196B9.8080109@gmail.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: On Wed, Feb 8, 2012 at 8:25 AM, Aaron France wrote: > for i in range(0, len(x), 2): > ? ?print x[i-1], x[i] I think you want x[i], x[i+1] here, but in any case, this is a fairly standard non-Python way to do this sort of thing. There's a variety of more Pythonic ways to loop, but every now and then, the old C habits still come in handy! ChrisA From arnodel at gmail.com Tue Feb 7 16:37:20 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 7 Feb 2012 21:37:20 +0000 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: On 7 February 2012 20:23, Sammy Danso wrote: > > Hi Expert, > Thanks for your responses and help. thought I should provide more information for clarity. Please don't top-post. > Please find the error message below for more information > > ???for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack > > this is a sample of my data > > ['with', 3, 'which', 1, [...] , 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully * It would be better if you provided the code that produces the error, rather than just the error. This would allow others to diagnose your problem without having to guess what you're really doing (see my guess below) * Also, don't truncate the traceback. My guess: you're running a loop like this, where each item is unpacked: for (key, value) in wordFreq2: print key, value on data like that: wordFreq2 = ['with', 3, 'which', 1, 'were', 2, 'well', 1] Your list is flat so the unpacking fails. For it to work, you need your list to be of the form: wordFreq2 = [('with', 3), ('which', 1), ('were', 2), ('well', 1)] Then it will work. The quickest way to transform your list to the required form is something like this: def pairs(seq, fillvalue): it = iter(seq) return list(izip_longest(it, it, fillvalue=fillvalue) so you can do: word_freq_pairs = pairs(wordFreq2) -- Arnaud From breamoreboy at yahoo.co.uk Tue Feb 7 17:09:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 07 Feb 2012 22:09:39 +0000 Subject: iterating over list with one mising value In-Reply-To: <4F3196B9.8080109@gmail.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: On 07/02/2012 21:25, Aaron France wrote: > for i in range(0, len(x), 2): > print x[i-1], x[i] x = ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] for i in range(0, len(x), 2): print x[i-1], x[i] other with 3 which ... 1 3 other Houston, we've got a problem:) -- Cheers. Mark Lawrence. From a.france.mailinglists at gmail.com Tue Feb 7 17:30:30 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 07 Feb 2012 23:30:30 +0100 Subject: iterating over list with one mising value In-Reply-To: References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: <4F31A606.6040609@gmail.com> On 02/07/2012 11:09 PM, Mark Lawrence wrote: > On 07/02/2012 21:25, Aaron France wrote: >> for i in range(0, len(x), 2): >> print x[i-1], x[i] > x = ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, > 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, > 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, > 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, > 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, > 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, > 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, > 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', > 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, > 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, > 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, > 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, > 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', > 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, > 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', > 1, '600am', 1, '100pm', 1, '', 3, 'other'] > for i in range(0, len(x), 2): > print x[i-1], x[i] > > other with > 3 which > ... > 1 > 3 other > > Houston, we've got a problem:) > Yupp. The real problem is that there's been over 20 messages about this 'problem'. From arnodel at gmail.com Tue Feb 7 18:03:51 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 7 Feb 2012 23:03:51 +0000 Subject: iterating over list with one mising value In-Reply-To: <9na3j751i8q3ks75sda28edig2qclghfht@4ax.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <9na3j751i8q3ks75sda28edig2qclghfht@4ax.com> Message-ID: On 7 February 2012 22:57, Dennis Lee Bieber wrote: > On Tue, 7 Feb 2012 21:37:20 +0000, Arnaud Delobelle > wrote: > > >> >>Your list is flat so the unpacking fails. ?For it to work, you need >>your list to be of the form: >> >> ? ?wordFreq2 = [('with', 3), ('which', 1), ('were', 2), ('well', 1)] >> >>Then it will work. ?The quickest way to transform your list to the >>required form is something like this: >> > ? ? ? ?Well... From my viewpoint, the quickest way is to load the list > correctly in the first place... Where does this list come from? If it's > a file of Of course, but how much guessing can you do in a reply? The OP provided a Python list, that's what I used. -- Arnaud From skippy.hammond at gmail.com Tue Feb 7 18:04:29 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 08 Feb 2012 10:04:29 +1100 Subject: PythonWin debugger holds onto global logging objects too long In-Reply-To: <4F310164.3070606@sequans.com> References: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> <4F310164.3070606@sequans.com> Message-ID: <4F31ADFD.3050006@gmail.com> On 7/02/2012 9:48 PM, Jean-Michel Pichavant wrote: > Vinay Sajip wrote: >> On Jan 24, 2:52 pm, Rob Richardson wrote: >>> I use PythonWin to debug the Python scripts we write. Our scripts >>> often use the log2pyloggingpackage. When running the scripts inside >>> the debugger, we seem to get oneloggingobject for every time we run >>> the script. The result is that after running the script five times, >>> the log file contains five copies of every message. The only way I >>> know to clean this up and get only a single copy of each message is >>> to close PythonWin and restart it. >>> >>> What do I have to do in my scripts to clean up theloggingobjects so >>> that I never get more than one copy of each message in my log files? >>> >> >> I don't know what log2py is - Google didn't show up anything that >> looked relevant. If you're talking about the logging package in the >> Python standard library, I may be able to help: but a simple script >> that I ran in PythonWin didn't show any problems, so you'll probably >> need to post a short script which demonstrates the problem when run in >> PythonWin. >> >> Regards, >> >> Vinay Sajip > Same here, can't find anything about log2py. > Anyway it's possible that your pythonwin does not spawn a clean python > interpreter for every run, keeping the same one. That is what everyone's pythonwin does :) It always works "in process" - not ideal, but also likely to not change. Cheers, Mark > > So you could possibly keep adding log handlers to your loggers because > they may be static objects (like for the standard logging module). > One solution would be to empty your logger handler list before adding any. > > I'm just guessing though, difficult to know without any info on log2py. > > JM From peter.milliken at gmail.com Tue Feb 7 19:16:51 2012 From: peter.milliken at gmail.com (Peter) Date: Tue, 7 Feb 2012 16:16:51 -0800 (PST) Subject: pySerial question, setting certain serial parameters [newbie] References: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> Message-ID: <22a9c96e-60a2-4c03-b80e-954c30ea6872@g4g2000pbi.googlegroups.com> On Feb 4, 11:47?pm, Jean Dupont wrote: > I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): > > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > I have thus far the following ?statements but I think it does not set the above parameters correctly: > import serial > voltport='/dev/ttyUSB2' > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) > > thanks > Jean My reading of the __init__ method documentations shows you should have: ser2 = serial.Serial(voltport, 2400, dsrdtr=True, timeout=15) since the defaults for bytesize are EIGHTBITS (for which you use 8 - wrong), parity is already default to PARITY_NONE (so this isn't needed), stopbits defaults to STOPBITS_ONE (for which you use 1 - wrong) and (assuming the Perl code "1" is to enable) dsrdtr=True (xonxoff and rtscts both default to False). Try that. From news at schwertberger.de Tue Feb 7 19:26:48 2012 From: news at schwertberger.de (Dietmar Schwertberger) Date: Wed, 08 Feb 2012 01:26:48 +0100 Subject: convert perl-script for voltcraft voltmeter to python [newbie] In-Reply-To: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: Am 03.02.2012 14:11, schrieb Jean Dupont: > As my request might have been too much asked, I have started doing > some coding myself. > I'm in doubt about the readline statement -which doesn't show anything > received- as the meter sends continuously streams of 11 bytes > Is there a way to just monitor with python what is arriving at a > serial port? Some time ago I started working on reading data from a VC940. I would assume that the protocol is the same. Please find below the code that will return the raw values from a VC940 (tested on a classical RS232 port, but probably will work on USB-RS232 converters as well). If you don't get anything, then you should check whether your USB converter is supplying voltage on the DTR pin once you have called self.serial.setDTR(1). You have the description how to decode the values? E.g. the string "0003:1401" translates to 0.3 Ohms. I did not implement anything else, as I just wanted to be sure that I could read the values, but I never needed to... Regards, Dietmar import serial import time class VC940(object): def __init__(self, port="COM3"): self.port = port self.serial=serial.Serial(port,2400, bytesize=7, parity="N", stopbits=1, timeout=1.5, xonxoff=0, rtscts=0, dsrdtr=None) self.serial.setRTS(0) self.serial.setDTR(0) def _read_raw_value(self): timeout = True for n in range(5): self.serial.flushInput() self.serial.setDTR(1) data = self.serial.read(11) self.serial.setDTR(0) if data.endswith("\r\n") and len(data)==11: return data if not data: raise ValueError, "communication timeout" raise ValueError, "could not read data from port" if __name__=="__main__": vc = VC940() while True: print vc._read_raw_value() From breamoreboy at yahoo.co.uk Tue Feb 7 20:10:28 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 01:10:28 +0000 Subject: Cycle around a sequence Message-ID: I'm looking at a way of cycling around a sequence i.e. starting at some given location in the middle of a sequence and running to the end before coming back to the beginning and running to the start place. About the best I could come up with is the following, any better ideas for some definition of better? PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> from itertools import chain >>> a=range(10) >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) >>> for x in g: print x, ... 4 5 6 7 8 9 0 1 2 3 >>> -- Cheers. Mark Lawrence. From wentlv at gmail.com Tue Feb 7 20:13:23 2012 From: wentlv at gmail.com (crow) Date: Tue, 7 Feb 2012 17:13:23 -0800 (PST) Subject: keeping twisted and wxPython in sync References: Message-ID: On Feb 8, 2:41?am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory after a connection has been > made. So when I send my user and password, that is when I connect. Is > there a way to handle waiting for the connection to complete? > > -- > > Take care, > Ty > Web:http://tds-solutions.net > The Aspen project: a light-weight barebones mud enginehttp://code.google.com/p/aspenmud > > Sent from my toaster. You can send your user & password in connectionMade() method, I think. From wentlv at gmail.com Tue Feb 7 20:15:02 2012 From: wentlv at gmail.com (crow) Date: Tue, 7 Feb 2012 17:15:02 -0800 (PST) Subject: keeping twisted and wxPython in sync References: Message-ID: <1eccf21e-25bf-4e1c-8b44-18b6997e6f80@3g2000pbd.googlegroups.com> On Feb 8, 2:41?am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory after a connection has been > made. So when I send my user and password, that is when I connect. Is > there a way to handle waiting for the connection to complete? > > -- > > Take care, > Ty > Web:http://tds-solutions.net > The Aspen project: a light-weight barebones mud enginehttp://code.google.com/p/aspenmud > > Sent from my toaster. And for connection failed, you can write some hook code in connectionLost() method, this method will be called when connection failed. From tjreedy at udel.edu Tue Feb 7 20:41:01 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 07 Feb 2012 20:41:01 -0500 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: On 2/7/2012 8:10 PM, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? > > PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit > (Intel)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. > >>> from itertools import chain > >>> a=range(10) > >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) > >>> for x in g: print x, > ... > 4 5 6 7 8 9 0 1 2 3 a=range(10) n = len(a) off = 4 for k in (a[(i+off) % n] for i in range(n)): print(a[k], end = ' ') -- Terry Jan Reedy From pat.inside at gmail.com Tue Feb 7 20:48:10 2012 From: pat.inside at gmail.com (Lei Cheng) Date: Wed, 8 Feb 2012 09:48:10 +0800 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? Message-ID: Hi all, In a py file, when to use import statements in the header, when to use import statements in the blocks where they are used? What are the best practices? Thanks! Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Feb 7 20:50:56 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Feb 2012 01:50:56 GMT Subject: iterating over list with one mising value References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4f31d500$0$29992$c3e8da3$5496439d@news.astraweb.com> (Apologies in advance for breaking threading, but the original post in this thread doesn't appear for me.) > On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso > wrote: >> >> Hello experts, >> I am having trouble accessing the content of my list. my list content >> has 2-pair value with the exception of one which has single value. here >> is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] >> >> I am unable to iterate through list to access invidual value pairs Here's a recipe to collate a sequence of interleaved items. It collects every nth item: from itertools import islice, tee def collate(iterable, n): t = tee(iter(iterable), n) slices = (islice(it, i, None, n) for (i, it) in enumerate(t)) return [list(slice) for slice in slices] And here it is in use: >>> seq = [1, 'a', 'A', 2, 'b', 'B', 3, 'c', 'C', 4, 'd', 'D', 5, 'e'] >>> collate(seq, 3) [[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e'], ['A', 'B', 'C', 'D']] >>> collate(seq, 2) [[1, 'A', 'b', 3, 'C', 'd', 5], ['a', 2, 'B', 'c', 4, 'D', 'e']] >>> collate(seq, 9) [[1, 4], ['a', 'd'], ['A', 'D'], [2, 5], ['b', 'e'], ['B'], [3], ['c'], ['C']] -- Steven From ch at radamanthys.de Tue Feb 7 21:01:37 2012 From: ch at radamanthys.de (Christoph Hansen) Date: Wed, 08 Feb 2012 03:01:37 +0100 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: Mark Lawrence schrieb: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? # quick&dirty seq=range(10) for x in seq[4:]+seq[:4]: print x # or def oneround(seq, start=0): i=start l=len(seq) while True: yield seq[i] i = (i+1) % l if i==start: break for x in oneround(range(50), 4): print x From d at davea.name Tue Feb 7 21:05:15 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 21:05:15 -0500 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: Message-ID: <4F31D85B.4040406@davea.name> On 02/07/2012 08:48 PM, Lei Cheng wrote: > Hi all, > > In a py file, when to use import statements in the header, when to use > import statements in the blocks where they are used? > What are the best practices? > Thanks! > > Pat > Best practice is to put all the imports at the beginning of the module, so they are easy to spot. If you put an import inside a function, it gets re-executed each time the function is called, which is a waste of time. Not too much, since import first checks sys.modules to see if it's already loaded. Also, avoid the from xxx import * form, as it pollutes the namespace. And it makes it hard to figure out where a particular name is declared. I believe these and other best practices can be found in pep8. http://www.python.org/dev/peps/pep-0008/ -- DaveA From pat.inside at gmail.com Tue Feb 7 21:38:08 2012 From: pat.inside at gmail.com (Patto) Date: Wed, 8 Feb 2012 10:38:08 +0800 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: <4F31D85B.4040406@davea.name> Message-ID: Dave Angel? On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: > On 02/07/2012 08:48 PM, Lei Cheng wrote: > >> Hi all, >> >> In a py file, when to use import statements in the header, when to use >> import statements in the blocks where they are used? >> What are the best practices? >> Thanks! >> >> Pat >> >> Best practice is to put all the imports at the beginning of the module, > so they are easy to spot. > > If you put an import inside a function, it gets re-executed each time the > function is called, which is a waste of time. Not too much, since import > first checks sys.modules to see if it's already loaded. > > Also, avoid the from xxx import * form, as it pollutes the > namespace. And it makes it hard to figure out where a particular name is > declared. > > I believe these and other best practices can be found in pep8. > > http://www.python.org/dev/**peps/pep-0008/ > > -- > > DaveA > > yeah, I read pep8. However I find in the file path/to/djcelery/loaders.py from django-celery source, there are so many import/from statements used inside functions, I do not know why the author coded like this. Are there any special facts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Feb 7 21:41:49 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 21:41:49 -0500 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: <4F31D85B.4040406@davea.name> Message-ID: <4F31E0ED.30908@davea.name> You forgot to include the list in your reply, so I'm forwarding it for you. One way you could have done it was to reply-all. On 02/07/2012 09:32 PM, Patto wrote: > Dave Angel? > > On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: > >> On 02/07/2012 08:48 PM, Lei Cheng wrote: >> >>> Hi all, >>> >>> In a py file, when to use import statements in the header, when to use >>> import statements in the blocks where they are used? >>> What are the best practices? >>> Thanks! >>> >>> Pat >>> >>> Best practice is to put all the imports at the beginning of the module, >> so they are easy to spot. >> >> If you put an import inside a function, it gets re-executed each time the >> function is called, which is a waste of time. Not too much, since import >> first checks sys.modules to see if it's already loaded. >> >> Also, avoid the from xxx import * form, as it pollutes the >> namespace. And it makes it hard to figure out where a particular name is >> declared. >> >> I believe these and other best practices can be found in pep8. >> >> http://www.python.org/dev/**peps/pep-0008/ >> >> -- >> >> DaveA >> >> > yeah, I read pep8. > However I find in the file path/to/djcelery/loaders.py from django-celery > source, there are so many import/from statements used inside functions, I > do not know why the author coded like this. Are there any special facts? > I can't speak for django or django-celery. There are people that disagree on this, and there are some reasons to override the ones I mentioned. One would be large modules that are not used in most circumstances, or not used till the program has run for a while. If you put the import inside a function, you can save on startup time by deferring some of the logic till later. And if there's a module that probably won't be used at all (eg. an error handler), perhaps you can avoid loading it at all. I still think readability trumps all the other reasons, for nearly all programs. Only once you decide you have a performance problem should you change that. -- DaveA From cs at zip.com.au Tue Feb 7 22:40:25 2012 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 8 Feb 2012 14:40:25 +1100 Subject: python file synchronization In-Reply-To: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> References: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> Message-ID: <20120208034025.GA14347@cskk.homeip.net> On 07Feb2012 01:33, silentnights wrote: | I have the following problem, I have an appliance (A) which generates | records and write them into file (X), the appliance is accessible | throw ftp from a server (B). I have another central server (C) that | runs a Django App, that I need to get continuously the records from | file (A). | | The problems are as follows: | 1. (A) is heavily writing to the file, so copying the file will result | of uncompleted line at the end. | 2. I have many (A)s and (B)s that I need to get the data from. | 3. I can't afford losing any records from file (X) [...] | The above is implemented and working, the problem is that It required | so many syncs and has a high overhead and It's hard to debug. Yep. I would change the file discipline. Accept that FTP is slow and has no locking. Accept that reading records from an actively growing file is often tricky and sometimes impossible depending on the record format. So don't. Hand off completed files regularly and keep the incomplete file small. Have (A) write records to a file whose name clearly shows the file to be incomplete. Eg "data.new". Every so often (even once a second), _if_ the file is not empty: close it, _rename_ to "data.timestamp" or "data.sequence-number", open a new "data.new" for new records. Have the FTP client fetch only the completed files. You can perform a similar effort for the socket daemon: look only for completed data files. Reading the filenames from a directory is very fast if you don't stat() them (i.e. just os.listdir). Just open and scan any new files that appear. That would be my first cut. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Performing random acts of moral ambiguity. - Jeff Miller From anonhung at gmail.com Wed Feb 8 00:17:17 2012 From: anonhung at gmail.com (anon hung) Date: Wed, 8 Feb 2012 06:17:17 +0100 Subject: turbogears 1 Message-ID: Hey guys, someone asked me to maintain his old website, trouble is, it's in python, more trouble is it's in turbogears 1. I'm not fluent in python but all right, I can learn, but this turbogears thing.......... First of all, is it still alive? Looks like turbogears 2 is the most recent version but even that is being abandoned. Am I basically given vaporware? Does anyone have any up to date info? Best, Hung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From saibabagod1 at gmail.com Wed Feb 8 00:32:53 2012 From: saibabagod1 at gmail.com (VICKY) Date: Tue, 7 Feb 2012 21:32:53 -0800 (PST) Subject: MEGA INFO SYSTEMS Message-ID: Lead Generation Database scrubbing Debt Collection Services available here http://megainfosystems.yolasite.com From roy at panix.com Wed Feb 8 00:33:55 2012 From: roy at panix.com (Roy Smith) Date: Wed, 08 Feb 2012 00:33:55 -0500 Subject: turbogears 1 References: Message-ID: In article , anon hung wrote: > Hey guys, someone asked me to maintain his old website, trouble is, > it's in python, more trouble is it's in turbogears 1. I'm not fluent > in python but all right, I can learn, but this turbogears > thing.......... > > First of all, is it still alive? Looks like turbogears 2 is the most > recent version but even that is being abandoned. Yup, looks dead to me. Hasn't had a release in almost 2 months or a commit to the GIT repo in 2 days. Must be nailed to its perch or something. http://turbogears.org/en/current-status http://sourceforge.net/p/turbogears2/tg2/commit_browser > Am I basically given vaporware? Does anyone have any up to date info? Have you considered Ruby on Rails? From alec.taylor6 at gmail.com Wed Feb 8 00:37:01 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 8 Feb 2012 16:37:01 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: Thanks all for your replies. I have now installed MSVC8 and YASM. I was able to successfully run configure.bat and make.bat (including make.bat check). However, I'm unsure what to do about install, since there is no install arg. Do I copy it across to my VC\bin folder, or does it need it's own place in PATH + system variables? I am asking because I don't know where it is looking for the MPIR library. Thanks for all suggestions, Alec Taylor From jenichristy23 at gmail.com Wed Feb 8 00:57:25 2012 From: jenichristy23 at gmail.com (christy jenifer) Date: Tue, 7 Feb 2012 21:57:25 -0800 (PST) Subject: Wanted Professionals Message-ID: <7d861a84-586a-4b12-8cac-c3fb768bd2d2@ir9g2000pbc.googlegroups.com> Do you want to be a professional with more than 1000 dollars, Want to do shopping, want to book for hotel ......for everything Click on below link http://entertainmentgallexy.tripod.com/home.html From prakashsco71 at gmail.com Wed Feb 8 01:01:46 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Tue, 7 Feb 2012 22:01:46 -0800 (PST) Subject: hardware service required. Message-ID: hardware service required here. http://megainfosystems.yolasite.com From steve+comp.lang.python at pearwood.info Wed Feb 8 01:03:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Feb 2012 06:03:32 GMT Subject: turbogears 1 References: Message-ID: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 00:33:55 -0500, Roy Smith wrote: > In article , > anon hung wrote: > >> Hey guys, someone asked me to maintain his old website, trouble is, >> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >> python but all right, I can learn, but this turbogears thing.......... >> >> First of all, is it still alive? Looks like turbogears 2 is the most >> recent version but even that is being abandoned. > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > commit to the GIT repo in 2 days. Must be nailed to its perch or > something. > > http://turbogears.org/en/current-status > http://sourceforge.net/p/turbogears2/tg2/commit_browser Ohhh, sarcasm... To the original poster: what makes you think that Turbogears 2 is abandoned? >> Am I basically given vaporware? Does anyone have any up to date info? > > Have you considered Ruby on Rails? Now that's just cruel. -- Steven From prakashsco71 at gmail.com Wed Feb 8 01:05:06 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Tue, 7 Feb 2012 22:05:06 -0800 (PST) Subject: hardware service required. Message-ID: <5883e1e8-725c-417b-a531-67ace32bc607@4g2000pbz.googlegroups.com> hardware service required here. http://megainfosystems.yolasite.com From abhi.forall at gmail.com Wed Feb 8 01:36:17 2012 From: abhi.forall at gmail.com (abhijeet mahagaonkar) Date: Wed, 8 Feb 2012 12:06:17 +0530 Subject: Issue with Scrapping Data from a webpage- Noob Question Message-ID: Hi Fellow Pythoners, I'm trying to collect table data from an authenticated webpage (Tool) to which I have access. I will have the required data after 'click'ing a submit button on the tool homepage. When I inspect the submit button i see
Thus the tool's homepage is of the form www.example.com/Tool and on clicking the submit button the data I need will be at www.example.com/Tool/index.do The problem that I'm running into is in my below code is giving me the source of homepage(www.example.com/Tool) and not the of the submitted page( www.example.com/Tool/index.do) url="www.example.com/Tool/index.do" request = urllib2.Request(url, data, {'Authorization': "Basic " + base64.b64encode("%s:%s" % (username, password))}) Response_Page=urllib2.urlopen(request).read() Is there a way I can access the source of the submitted page? PS: Sorry for laying out very tiny details on what I'm trying to do, I just wanted to explain myself clearly :) Thanks in advance for your time on this one. Warm Regards, Abhi -------------- next part -------------- An HTML attachment was scrubbed... URL: From silentquote at gmail.com Wed Feb 8 01:57:43 2012 From: silentquote at gmail.com (Sherif Shehab Aldin) Date: Wed, 8 Feb 2012 08:57:43 +0200 Subject: python file synchronization In-Reply-To: <20120208034025.GA14347@cskk.homeip.net> References: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> <20120208034025.GA14347@cskk.homeip.net> Message-ID: Hi Cameron, Thanks a lot for your help, I just forgot to state that the FTP server is not under my command, I can't control how the file grow, or how the records are added, I can only login to It, copy the whole file. The reason why I am parsing the file and trying to get the diffs between the new file and the old one, and copy it to new_file.time_stamp is that I need to cut down the file size so when server (C) grabs the file, It grabs only new data, also to cut down the network bandwidth. One of my problems was after mounting server (B) diffs_dir into Server (A) throw NFS, I used to create filename.lock first into server (B) local file then start copy filename to server (B) then remove filename.lock, so when the daemon running on server (C) parses the files in the local_diffs dir, ignores the files that are still being copied, After searching more yesterday, I found that local mv is atomic, so instead of creating the lock files, I will copy the new diffs to tmp dir, and after the copy is over, mv it to actual diffs dir, that will avoid reading It while It's still being copied. Sorry if the above is bit confusing, the system is bit complex. Also there is one more factor that confuses me, I am so bad in testing, and I am trying to start actually implement unit testing to test my code, what I find hard is how to test code like the one that do the copy, mv and so, also the code that fetch data from the web. On Wed, Feb 8, 2012 at 5:40 AM, Cameron Simpson wrote: > On 07Feb2012 01:33, silentnights wrote: > | I have the following problem, I have an appliance (A) which generates > | records and write them into file (X), the appliance is accessible > | throw ftp from a server (B). I have another central server (C) that > | runs a Django App, that I need to get continuously the records from > | file (A). > | > | The problems are as follows: > | 1. (A) is heavily writing to the file, so copying the file will result > | of uncompleted line at the end. > | 2. I have many (A)s and (B)s that I need to get the data from. > | 3. I can't afford losing any records from file (X) > [...] > | The above is implemented and working, the problem is that It required > | so many syncs and has a high overhead and It's hard to debug. > > Yep. > > I would change the file discipline. Accept that FTP is slow and has no > locking. Accept that reading records from an actively growing file is > often tricky and sometimes impossible depending on the record format. > So don't. Hand off completed files regularly and keep the incomplete > file small. > > Have (A) write records to a file whose name clearly shows the file to be > incomplete. Eg "data.new". Every so often (even once a second), _if_ the > file is not empty: close it, _rename_ to "data.timestamp" or > "data.sequence-number", open a new "data.new" for new records. > > Have the FTP client fetch only the completed files. > > You can perform a similar effort for the socket daemon: look only for > completed data files. Reading the filenames from a directory is very > fast if you don't stat() them (i.e. just os.listdir). Just open and scan > any new files that appear. > > That would be my first cut. > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Performing random acts of moral ambiguity. > - Jeff Miller > -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Wed Feb 8 03:17:59 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 08:17:59 +0000 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: <4F31E0ED.30908@davea.name> References: <4F31D85B.4040406@davea.name> <4F31E0ED.30908@davea.name> Message-ID: On 08/02/2012 02:41, Dave Angel wrote: > You forgot to include the list in your reply, so I'm forwarding it for > you. One way you could have done it was to reply-all. > > > On 02/07/2012 09:32 PM, Patto wrote: >> Dave Angel? >> >> On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: >> >>> On 02/07/2012 08:48 PM, Lei Cheng wrote: >>> >>>> Hi all, >>>> >>>> In a py file, when to use import statements in the header, when to use >>>> import statements in the blocks where they are used? >>>> What are the best practices? >>>> Thanks! >>>> >>>> Pat >>>> >>>> Best practice is to put all the imports at the beginning of the module, >>> so they are easy to spot. >>> >>> If you put an import inside a function, it gets re-executed each time >>> the >>> function is called, which is a waste of time. Not too much, since import >>> first checks sys.modules to see if it's already loaded. >>> >>> Also, avoid the from xxx import * form, as it pollutes the >>> namespace. And it makes it hard to figure out where a particular name is >>> declared. >>> >>> I believe these and other best practices can be found in pep8. >>> >>> http://www.python.org/dev/**peps/pep-0008/ >>> >>> >>> -- >>> >>> DaveA >>> >>> >> yeah, I read pep8. >> However I find in the file path/to/djcelery/loaders.py from django-celery >> source, there are so many import/from statements used inside functions, I >> do not know why the author coded like this. Are there any special facts? >> > > I can't speak for django or django-celery. There are people that > disagree on this, and there are some reasons to override the ones I > mentioned. One would be large modules that are not used in most > circumstances, or not used till the program has run for a while. > > If you put the import inside a function, you can save on startup time by > deferring some of the logic till later. And if there's a module that > probably won't be used at all (eg. an error handler), perhaps you can > avoid loading it at all. > > I still think readability trumps all the other reasons, for nearly all > programs. Only once you decide you have a performance problem should you > change that. > There's a thread on the dev ml about imports that also discusses startup times for anyone who's interested. -- Cheers. Mark Lawrence. From breamoreboy at yahoo.co.uk Wed Feb 8 03:26:33 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 08:26:33 +0000 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: On 08/02/2012 01:26, Dennis Lee Bieber wrote: > On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence > wrote: > >> I'm looking at a way of cycling around a sequence i.e. starting at some >> given location in the middle of a sequence and running to the end before >> coming back to the beginning and running to the start place. About the >> best I could come up with is the following, any better ideas for some >> definition of better? >> >> PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit >> (Intel)] on win32. >> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' >> for further copyright information. >>>>> from itertools import chain >>>>> a=range(10) >>>>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) >>>>> for x in g: print x, >> ... >> 4 5 6 7 8 9 0 1 2 3 >>>>> > > How large a sequence and, more important, is it fully known at the > start... > >>>> a = range(20) >>>> a > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>>> a_shift = a[5:] + a[:5] >>>> a_shift > [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] >>>> > > IOWs, just slice and join: tail first, then front-end. > The sequences are small and the start is always known but the function that uses this is called thousands of times so I was trying to avoid building lists if at all possible. -- Cheers. Mark Lawrence. From mail at timgolden.me.uk Wed Feb 8 03:36:16 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 08 Feb 2012 08:36:16 +0000 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: <4F323400.7050506@timgolden.me.uk> On 08/02/2012 08:26, Mark Lawrence wrote: > On 08/02/2012 01:26, Dennis Lee Bieber wrote: >> On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence >> wrote: >> >>> I'm looking at a way of cycling around a sequence i.e. starting at some >>> given location in the middle of a sequence and running to the end before >>> coming back to the beginning and running to the start place. About the >>> best I could come up with is the following, any better ideas for some >>> definition of better? >>> >>> PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit >>> (Intel)] on win32. >>> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' >>> for further copyright information. >>>>>> from itertools import chain >>>>>> a=range(10) >>>>>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in >>>>>> xrange(4))) >>>>>> for x in g: print x, >>> ... >>> 4 5 6 7 8 9 0 1 2 3 >>>>>> >> >> How large a sequence and, more important, is it fully known at the >> start... >> >>>>> a = range(20) >>>>> a >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>>>> a_shift = a[5:] + a[:5] >>>>> a_shift >> [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] >>>>> >> >> IOWs, just slice and join: tail first, then front-end. >> > > The sequences are small and the start is always known but the function > that uses this is called thousands of times so I was trying to avoid > building lists if at all possible. > I'm not an itertools expert, but does this do what you want? (Untested - I might well be off by one) import itertools sequence = range (100) split = 70 rslice = itertools.islice (sequence, split, len (sequence)) lslice = itertools.islice (sequence, split) repeater = itertools.cycle (itertools.chain (rslice, lslice)) TJG From vetrivijay09 at gmail.com Wed Feb 8 03:57:06 2012 From: vetrivijay09 at gmail.com (vetri vijay) Date: Wed, 8 Feb 2012 00:57:06 -0800 (PST) Subject: would u wanna details about ur life partner.click here free registration. Message-ID: <8fec2774-d3fc-436f-a410-fa60f68c28b7@v6g2000pba.googlegroups.com> http://123maza.com/46/river834/ From cs at zip.com.au Wed Feb 8 04:59:36 2012 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 8 Feb 2012 20:59:36 +1100 Subject: python file synchronization In-Reply-To: References: Message-ID: <20120208095936.GA31545@cskk.homeip.net> [ Please reply inline; it makes the discussion read like a converation, with context. - Cameron ] On 08Feb2012 08:57, Sherif Shehab Aldin wrote: | Thanks a lot for your help, I just forgot to state that the FTP server is | not under my command, I can't control how the file grow, or how the records | are added, I can only login to It, copy the whole file. Oh. That's a pity. | The reason why I am parsing the file and trying to get the diffs between | the new file and the old one, and copy it to new_file.time_stamp is that I | need to cut down the file size so when server (C) grabs the file, It grabs | only new data, also to cut down the network bandwidth. Can a simple byte count help here? Copy the whole file with FTP. From the new copy, extract the bytes from the last byte count offset onward. Then parse the smaller file, extracting whole records for use by (C). That way you can just keep the unparsed tail (partial record I imagine) around for the next fetch. Looking at RFC959 (the FTP protocol): http://www.w3.org/Protocols/rfc959/4_FileTransfer.html it looks like you can do a partial file fetch, also, by issuing a REST (restart) command to set a file offset and then issuing a RETR (retrieve) command to get the rest of the file. These all need to be in binary mode of course. So in principle you could track the byte offset of what you have fetched with FTP so far, and fetch only what is new. | One of my problems was after mounting server (B) diffs_dir into Server (A) | throw NFS, I used to create filename.lock first into server (B) local file | then start copy filename to server (B) then remove filename.lock, so when | the daemon running on server (C) parses the files in the local_diffs dir, | ignores the files that are still being copied, | | After searching more yesterday, I found that local mv is atomic, so instead | of creating the lock files, I will copy the new diffs to tmp dir, and after | the copy is over, mv it to actual diffs dir, that will avoid reading It | while It's still being copied. Yes, this sounds good. Provided the mv is on the same filesystem. For example: "mv /tmp/foo /home/username/foo" is actually a copy and not a rename because /tmp is normally a different filesystem from /home. | Sorry if the above is bit confusing, the system is bit complex. Complex systems often need fiddly solutions. | Also there is one more factor that confuses me, I am so bad in testing, and | I am trying to start actually implement unit testing to test my code, what | I find hard is how to test code like the one that do the copy, mv and so, | also the code that fetch data from the web. Ha. I used to be very bad at testing, now I am improving and am merely weak. One approach to testing is to make a mock up of the other half of the system, and test against the mockup. For example, you have code to FTP new data and then feed it to (C). You don't control the server side of the FTP. So you might make a small mock up program that writes valid (but fictitious) data records progressively to a local data file (write record, flush, pause briefly, etc). If you can FTP to your own test machine you could then treat _that_ growing file as the remote server's data file. Then you could copy it progressively using a byte count to keep track of the bits you have seen to skip them, and the the If you can't FTP to your test system, you could abstract out the "fetch part of this file by FTP" into its own function. Write an equivalent function that fetches part of a local file just by opening it. Then you could use the local file version in a test that doesn't actually do the FTP, but could exercise the rest of it. It is also useful to make simple tests of small pieces of the code. So make the code to get part of the data a simple function, and write tests to execute it in a few ways (no new data, part of a record, several records etc). There are many people better than I to teach testing. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Testing can show the presence of bugs, but not their absence. - Dijkstra From casevh at gmail.com Wed Feb 8 05:48:30 2012 From: casevh at gmail.com (Case Van Horsen) Date: Wed, 8 Feb 2012 02:48:30 -0800 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: > Thanks all for your replies. > > I have now installed MSVC8 and YASM. I assume you installed Visual Studio. I've omitted the commands to use the SDK compiler below. > > I was able to successfully run configure.bat and make.bat (including > make.bat check). > > However, I'm unsure what to do about install, since there is no > install arg. Do I copy it across to my VC\bin folder, or does it need > it's own place in PATH + system variables? The following is just a guess. I copy the files to a convenient location and then specify that location to setup.py. Below is an excerpt from my build process. mkdir c:\src\lib mkdir c:\src\include xcopy /Y mpir.h c:\src\include\*.* xcopy /Y win\mpir.lib c:\src\lib\*.* python setup.py build_ext -Ic:\src\include -Lc:\src\lib install > > I am asking because I don't know where it is looking for the MPIR library. > > Thanks for all suggestions, > > Alec Taylor From jeandupont115 at gmail.com Wed Feb 8 07:24:12 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Wed, 8 Feb 2012 04:24:12 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: On 8 feb, 01:26, Dietmar Schwertberger wrote: > Am 03.02.2012 14:11, schrieb Jean Dupont:> As my request might have been too much asked, I have started doing > > some coding myself. > > I'm in doubt about the readline statement -which doesn't show anything > > received- as the meter sends continuously streams of 11 bytes > > Is there a way to just monitor with python what is arriving at a > > serial port? > > Some time ago I started working on reading data from a VC940. > I would assume that the protocol is the same. > > Please find below the code that will return the raw values from > a VC940 (tested on a classical RS232 port, but probably > will work on USB-RS232 converters as well). > > If you don't get anything, then you should check whether your > USB converter is supplying voltage on the DTR pin once you have called > self.serial.setDTR(1). > > You have the description how to decode the values? > E.g. the string "0003:1401" translates to 0.3 Ohms. > > I did not implement anything else, as I just wanted to be sure > that I could read the values, but I never needed to... > > Regards, > > Dietmar > > import serial > import time > > class VC940(object): > ? ? ?def __init__(self, port="COM3"): > ? ? ? ? ?self.port = port > ? ? ? ? ?self.serial=serial.Serial(port,2400, bytesize=7, parity="N", > stopbits=1, timeout=1.5, xonxoff=0, rtscts=0, dsrdtr=None) > ? ? ? ? ?self.serial.setRTS(0) > ? ? ? ? ?self.serial.setDTR(0) > ? ? ?def _read_raw_value(self): > ? ? ? ? ?timeout = True > ? ? ? ? ?for n in range(5): > ? ? ? ? ? ? ?self.serial.flushInput() > ? ? ? ? ? ? ?self.serial.setDTR(1) > ? ? ? ? ? ? ?data = self.serial.read(11) > ? ? ? ? ? ? ?self.serial.setDTR(0) > ? ? ? ? ? ? ?if data.endswith("\r\n") and len(data)==11: > ? ? ? ? ? ? ? ? ?return data > ? ? ? ? ? ? ?if not data: > ? ? ? ? ? ? ? ? ?raise ValueError, "communication timeout" > ? ? ? ? ?raise ValueError, "could not read data from port" > > if __name__=="__main__": > ? ? ?vc = VC940() > ? ? ?while True: > ? ? ? ? ?print vc._read_raw_value() Wow, this is great, it works like a charm. Thanks a lot! Jean From alec.taylor6 at gmail.com Wed Feb 8 07:24:18 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 8 Feb 2012 23:24:18 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: Thanks, but to get it to work with pip, wouldn't I need to add it to PATH? - Or can I just add those library args to pip? On Wed, Feb 8, 2012 at 9:48 PM, Case Van Horsen wrote: > On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: >> Thanks all for your replies. >> >> I have now installed MSVC8 and YASM. > I assume you installed Visual Studio. I've omitted the commands to use > the SDK compiler below. >> >> I was able to successfully run configure.bat and make.bat (including >> make.bat check). >> >> However, I'm unsure what to do about install, since there is no >> install arg. Do I copy it across to my VC\bin folder, or does it need >> it's own place in PATH + system variables? > > The following is just a guess. > > I copy the files to a convenient location and then specify that > location to setup.py. Below is an excerpt from my build process. > > mkdir c:\src\lib > mkdir c:\src\include > xcopy /Y mpir.h c:\src\include\*.* > xcopy /Y win\mpir.lib c:\src\lib\*.* > > python setup.py build_ext -Ic:\src\include -Lc:\src\lib install > >> >> I am asking because I don't know where it is looking for the MPIR library. >> >> Thanks for all suggestions, >> >> Alec Taylor From casevh at gmail.com Wed Feb 8 07:31:34 2012 From: casevh at gmail.com (Case Van Horsen) Date: Wed, 8 Feb 2012 04:31:34 -0800 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: On Wed, Feb 8, 2012 at 4:24 AM, Alec Taylor wrote: > Thanks, but to get it to work with pip, wouldn't I need to add it to > PATH? - Or can I just add those library args to pip? I don't think so. pyCrypto probably builds a single DLL so the MPIR library is statically linked into that DLL. Only the innvocation of setup.py should need to refer to the MPIR library locations. I don't use pip so I'm not sure how to get pip to install the resulting DLL, etc. > > On Wed, Feb 8, 2012 at 9:48 PM, Case Van Horsen wrote: >> On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: >>> Thanks all for your replies. >>> >>> I have now installed MSVC8 and YASM. >> I assume you installed Visual Studio. I've omitted the commands to use >> the SDK compiler below. >>> >>> I was able to successfully run configure.bat and make.bat (including >>> make.bat check). >>> >>> However, I'm unsure what to do about install, since there is no >>> install arg. Do I copy it across to my VC\bin folder, or does it need >>> it's own place in PATH + system variables? >> >> The following is just a guess. >> >> I copy the files to a convenient location and then specify that >> location to setup.py. Below is an excerpt from my build process. >> >> mkdir c:\src\lib >> mkdir c:\src\include >> xcopy /Y mpir.h c:\src\include\*.* >> xcopy /Y win\mpir.lib c:\src\lib\*.* >> >> python setup.py build_ext -Ic:\src\include -Lc:\src\lib install >> >>> >>> I am asking because I don't know where it is looking for the MPIR library. >>> >>> Thanks for all suggestions, >>> >>> Alec Taylor From neilc at norwich.edu Wed Feb 8 09:25:33 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 8 Feb 2012 14:25:33 GMT Subject: Cycle around a sequence References: Message-ID: <9pfeutFtjiU2@mid.individual.net> On 2012-02-08, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting > at some given location in the middle of a sequence and running > to the end before coming back to the beginning and running to > the start place. About the best I could come up with is the > following, any better ideas for some definition of better? Python's indices were designed for these kinds of shenanigans. def rotated(seq, n): """Iterate through all of seq, but starting from index n. >>> ", ".join(str(n) for n in rotated(range(5), 3)) '3, 4, 0, 1, 2' """ i = n - len(seq) while i < n: yield seq[i] i += 1 if __name__ == "__main__": import doctest doctest.testmod() If you have merely an iterable instead of a sequence, then look to some of the other clever stuff already posted. -- Neil Cerutti From wanderer at dialup4less.com Wed Feb 8 10:36:15 2012 From: wanderer at dialup4less.com (Wanderer) Date: Wed, 8 Feb 2012 07:36:15 -0800 (PST) Subject: PyDev not saving Ipython History between sessions Message-ID: <1dbd178b-f96b-4709-8c9d-b17959f6269a@kn4g2000pbc.googlegroups.com> One feature I like about Ipython is that it saves the history between sessions. The history isn't saved if you close Ipython with the corner X, but if you type 'exit()' it is saved. This doesn't work when using Ipython as the console in Pydev. Do I have something setup wrong? Is there a different command than exit() I should use before closing a session in PyDev. Is there a command to load the history when I start a session? Thanks From nathan.alexander.rice at gmail.com Wed Feb 8 11:54:38 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 8 Feb 2012 11:54:38 -0500 Subject: Looking for PyPi 2.0... Message-ID: As a user: * Finding the right module in PyPi is a pain because there is limited, low quality semantic information, and there is no code indexing. * I have to install the module to examine it; I don't need to look at docs all the time, sometimes I just want a package/class/function/method breakdown. * Given the previous point, having in-line documentation would be nice (for instance, just the output of .. automodule::) * Package usage/modification stats are not well exposed * No code metrics are available * I would like some kind of social service integration, for tagging and +1/likes. I know ratings were scrapped (and they weren't that useful anyhow), but for example, if Armin Ronacher or Robert Kern thumbs up a module there is a pretty good chance I will be interested in it. As a developer: * I don't want to have to maintain my code repository and my package releases separately. I want to let module repository know that my code repository exists, and that branches tagged as "release" should be made available. * I want to maintain one README. I don't like "someone needs to do this now" type posts but every time I use PyPi it infuratiates me. I usually end up finding modules via Stack Overflow, which seems silly to me. Nathan From someone at someplace.invalid Wed Feb 8 12:15:23 2012 From: someone at someplace.invalid (HoneyMonster) Date: Wed, 8 Feb 2012 17:15:23 +0000 (UTC) Subject: Naming convention for in-house modules (Newbie question) Message-ID: I am quite new to Python (2.7 on Linux), and have built a few modules using wxPython/wxGlade for GUI elements and Psycopg2 for database access. I adhere mostly to the PEP8 guidelines, and use Pylint to help with quality control. So far I have been *very* impressed. Due to Python's straightforwardness and the wealth of documentation, results have been excellent. Here is my question: I would like to start an in-house library of small modules to import, for things like error handling/logging. That's easy enough, but is there a recommended way of naming such modules? I am concerned about avoiding name clashes with standard modules and site packages. Thanks. From clp2 at rebertia.com Wed Feb 8 12:47:34 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 8 Feb 2012 09:47:34 -0800 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice wrote: > As a user: > * Finding the right module in PyPi is a pain because there is limited, > low quality semantic information, and there is no code indexing. > * I have to install the module to examine it; ?I don't need to look at > docs all the time, sometimes I just want a > package/class/function/method breakdown. > * Given the previous point, having in-line documentation would be nice > (for instance, just the output of .. automodule::) > * Package usage/modification stats are not well exposed > * No code metrics are available > * I would like some kind of social service integration, for tagging > and +1/likes. ?I know ratings were scrapped (and they weren't that > useful anyhow), but for example, if Armin Ronacher or Robert Kern > thumbs up a module there is a pretty good chance I will be interested > in it. > > As a developer: > * I don't want to have to maintain my code repository and my package > releases separately. ?I want to let module repository know that my > code repository exists, and that branches tagged as "release" should > be made available. > * I want to maintain one README. > > > I don't like "someone needs to do this now" type posts but every time > I use PyPi it infuratiates me. ?I usually end up finding modules via > Stack Overflow, which seems silly to me. They don't have all the features you're looking for, but at least they seem to be working on the problem: http://crate.io Cheers, Chris From amirouche.boubekki at gmail.com Wed Feb 8 12:47:54 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Wed, 8 Feb 2012 18:47:54 +0100 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: H?llo Nathan, See below, 2012/2/8 Nathan Rice > As a user: > * Finding the right module in PyPi is a pain because there is limited, > low quality semantic information, and there is no code indexing. > * I have to install the module to examine it; I don't need to look at > docs all the time, sometimes I just want a > package/class/function/method breakdown. > * Given the previous point, having in-line documentation would be nice > (for instance, just the output of .. automodule::) > * Package usage/modification stats are not well exposed > * No code metrics are available > * I would like some kind of social service integration, for tagging > and +1/likes. I know ratings were scrapped (and they weren't that > useful anyhow), but for example, if Armin Ronacher or Robert Kern > thumbs up a module there is a pretty good chance I will be interested > in it. > > As a developer: > * I don't want to have to maintain my code repository and my package > releases separately. I want to let module repository know that my > code repository exists, and that branches tagged as "release" should > be made available. > * I want to maintain one README. > > > I don't like "someone needs to do this now" type posts but every time > I use PyPi it infuratiates me. I usually end up finding modules via > Stack Overflow, which seems silly to me. > > Let me do a recap with application analogies: You want a combination of - github / bitbucket for source management *et ce terra* - http://readthedocs.org/ for documentation and search - http://nullege.com for code search - http://repos.io/ for the social features I think it's not enough for fully integrated project management solution, I will add this features: - Paragraph level and document level comments for documentation like http://djangobook.com/ - Matrix comparaisons : grid feature of http://djangopackages.com/ - Dependency tracking, library usage in a nice visual way - Ask for review thingy - Buildbot et all - Q/A system - Mailling lis - Bounties - Agenda because time lapse - Blogs because it's all the rage - CLI interface so that hipsters can hypergrep all the way - A big fat red button to promote good libraries into the standard lib - A specialized reader UI for hypernerds so that they can cope with that much information while still pretending to be human And when the Python WAR-like format is done, automatic deployement of web application on the Python.org cloud powered by machines using a pure Python implemention of the HURD on top a green chips running PyPy. HTH, Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Feb 8 12:49:31 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 8 Feb 2012 09:49:31 -0800 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: On Wed, Feb 8, 2012 at 9:15 AM, HoneyMonster wrote: > I am quite new to Python (2.7 on Linux), and have built a few modules > using wxPython/wxGlade for GUI elements and Psycopg2 for database access. > I adhere mostly to the PEP8 guidelines, and use Pylint to help with > quality control. > > So far I have been *very* impressed. Due to Python's straightforwardness > and the wealth of documentation, results have been excellent. > > Here is my question: I would like to start an in-house library of small > modules to import, for things like error handling/logging. That's easy > enough, but is there a recommended way of naming such modules? I am > concerned about avoiding name clashes with standard modules and site > packages. You could put all the modules under a single package; then you only need to worry about avoiding 1 name conflict. Cheers, Chris From nagle at animats.com Wed Feb 8 14:41:44 2012 From: nagle at animats.com (John Nagle) Date: Wed, 08 Feb 2012 11:41:44 -0800 Subject: MySQLdb not allowing hyphen In-Reply-To: References: Message-ID: <4f32cff3$0$12030$742ec2ed@news.sonic.net> On 2/5/2012 2:46 PM, Chris Rebert wrote: > On Sun, Feb 5, 2012 at 2:41 PM, Emeka wrote: >> >> Hello All, >> >> I noticed that MySQLdb not allowing hyphen may be way to prevent injection >> attack. >> I have something like below: >> >> "insert into reviews(message, title)values('%s', '%s')" %( "We don't know >> where to go","We can't wait till morrow" ) >> >> ProgrammingError(1064, "You have an error in your SQL syntax; check the >> manual that corresponds to your MySQL server version for the right syntax to >> use near 't know where to go. >> >> How do I work around this error? > > Don't use raw SQL strings in the first place. Use a proper > parameterized query, e.g.: > > cursor.execute("insert into reviews(message, title) values (%s, %s)", > ("We don't know where to go", "We can't wait till morrow")) Yes. You are doing it wrong. Do NOT use the "%" operator when putting SQL queries together. Let "cursor.execute" fill them in. It knows how to escape special characters in the input fields, which will fix your bug and prevent SQL injection. John Nagle From toddw at activestate.com Wed Feb 8 15:14:13 2012 From: toddw at activestate.com (Todd Whiteman) Date: Wed, 08 Feb 2012 12:14:13 -0800 Subject: Komodo 7 release (Python development tools) Message-ID: <4F32D795.2040702@activestate.com> Hello, My name is Todd. I'm the lead developer for Komodo IDE (Interactive Development Environment) and Komodo Edit (a free, open-source editor) at ActiveState. I wanted to announce that the newest version, Komodo 7, has been released: http://www.activestate.com/komodo-ide Python has long been one of the main languages supported by Komodo, so we're always getting useful feedback and suggestions. For Komodo 7, we've incorporated a lot of this feedback into enhancing our Python features. * Python Code Profiling (IDE only) Users have asked if there is a way to find out why their programs are taking so long to run. Komodo IDE 7 can show a graph of the methods and calls made by your program, so that you can detect where your CPU is being taken up. * Sophisticated Syntax Checking Choose between multiple syntax checkers like PyLint, PyFlakes and PyChecker. Provides language-specific syntax checking for CSS/JavaScript/Django inside HTML template languages like Django. * Code Collaboration (IDE only) We wanted to make pair programming easier. With the collaboration feature, multiple users can edit a document at the same time. It's kind of like Google Docs, but for code editing! * Speed With Komodo 7 you'll notice a lot snappier Komodo start-up time, lower CPU utilization - particularly when idle, and lower memory usage for large projects. * Even more... There are way more features in Komodo 7 than I can outline in a single post, so check out the online web pages for more Komodo 7 enhancements: http://www.activestate.com/komodo-ide/python-editor Again, note that Komodo comes in two different flavours: 1) Komodo Edit - completely free and fully open-source editor, offering smart code completions, syntax checking, code colorizing, sophisticated editing and more. 2) Komodo IDE - a full featured IDE, offering advanced debugging, interactive shells, code browsing, source code control, database integration, unit testing, regular expression tools and more. Try out Komodo 7 and let me know what you think. We really appreciate the support and feedback! Cheers, Todd From tjreedy at udel.edu Wed Feb 8 15:15:59 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 15:15:59 -0500 Subject: Cycle around a sequence In-Reply-To: <9pfeutFtjiU2@mid.individual.net> References: <9pfeutFtjiU2@mid.individual.net> Message-ID: On 2/8/2012 9:25 AM, Neil Cerutti wrote: > On 2012-02-08, Mark Lawrence wrote: >> I'm looking at a way of cycling around a sequence i.e. starting >> at some given location in the middle of a sequence and running >> to the end before coming back to the beginning and running to >> the start place. About the best I could come up with is the >> following, any better ideas for some definition of better? > > Python's indices were designed for these kinds of shenanigans. > > def rotated(seq, n): > """Iterate through all of seq, but starting from index n. > > >>> ", ".join(str(n) for n in rotated(range(5), 3)) > '3, 4, 0, 1, 2' > """ > > i = n - len(seq) > while i< n: > yield seq[i] > i += 1 This is really nice, in the category of "Why didn't I think of that?" (Probably because I knew the % mod solution from C and never 'updated'!) > if __name__ == "__main__": > import doctest > doctest.testmod() > > If you have merely an iterable instead of a sequence, then look > to some of the other clever stuff already posted. To make a repeating rotator is only a slight adjustment: k = n - len(seq) while True: i = k while i < n: yield seq[i] i += 1 -- Terry Jan Reedy From nagle at animats.com Wed Feb 8 16:43:11 2012 From: nagle at animats.com (John Nagle) Date: Wed, 08 Feb 2012 13:43:11 -0800 Subject: changing sys.path In-Reply-To: References: Message-ID: <4f32ec6a$0$11980$742ec2ed@news.sonic.net> On 2/1/2012 8:15 AM, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some > code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. Do import sys first. John Nagle From tjreedy at udel.edu Wed Feb 8 16:52:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 16:52:50 -0500 Subject: Komodo 7 release (Python development tools) In-Reply-To: <4F32D795.2040702@activestate.com> References: <4F32D795.2040702@activestate.com> Message-ID: On 2/8/2012 3:14 PM, Todd Whiteman wrote: > My name is Todd. I'm the lead developer for Komodo IDE (Interactive > Development Environment) and Komodo Edit (a free, open-source editor) at > ActiveState. I wanted to announce that the newest version, Komodo 7, has > been released: This is a pretty good release announcement, but a few questions. ... > http://www.activestate.com/komodo-ide/python-editor It would seem that the Professional Python Editor is the same as Komodo Edit, but it is unclear why only Python editing would be featured for Komodo IDE. http://www.activestate.com/komodo-edit is the page with the link people need to download just the editor. Does K.Edit let me run a program with one key, like F5 in IDLE? If so, does it leave me in interactive mode (python -i) as IDLE does? -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Wed Feb 8 17:47:04 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 22:47:04 +0000 Subject: Cycle around a sequence In-Reply-To: <9pfeutFtjiU2@mid.individual.net> References: <9pfeutFtjiU2@mid.individual.net> Message-ID: On 08/02/2012 14:25, Neil Cerutti wrote: > On 2012-02-08, Mark Lawrence wrote: >> I'm looking at a way of cycling around a sequence i.e. starting >> at some given location in the middle of a sequence and running >> to the end before coming back to the beginning and running to >> the start place. About the best I could come up with is the >> following, any better ideas for some definition of better? > > Python's indices were designed for these kinds of shenanigans. > > def rotated(seq, n): > """Iterate through all of seq, but starting from index n. > > >>> ", ".join(str(n) for n in rotated(range(5), 3)) > '3, 4, 0, 1, 2' > """ > > i = n - len(seq) > while i< n: > yield seq[i] > i += 1 > > if __name__ == "__main__": > import doctest > doctest.testmod() > > If you have merely an iterable instead of a sequence, then look > to some of the other clever stuff already posted. > The winner :) -- Cheers. Mark Lawrence. From azandi at adconion.com Wed Feb 8 19:15:03 2012 From: azandi at adconion.com (Ali Zandi) Date: Wed, 8 Feb 2012 16:15:03 -0800 (PST) Subject: How to make PyDev pep8 friendly? Message-ID: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> Hi, I was trying to find a way to configure PyDev e.g. in Eclipse to be pep8 friendly. There are a few configurations like right trim lines, use space after commas, use space before and after operators, add new line at the end of file which can be configured via Eclipse -> Window -> Preferences - > PyDev -> Editor -> Code Style -> Code Formatter. But these are not enough; for example I couldn't find a way to configure double line spacing between function definitions. So is there any way to configure eclipse or PyDev to apply pep8 rules e.g. on each save? Thanks, From edriscoll at wisc.edu Wed Feb 8 20:23:19 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 19:23:19 -0600 Subject: frozendict Message-ID: <4F332007.9080800@wisc.edu> Hi all, I've been trying for a few days (only a little bit at a time) to come up with a way of implementing a frozendict that doesn't suck. I'm gradually converging to a solution, but I can't help but think that there's some subtlety that I'm probably missing which is why it's not already provided. Does anyone know why Python doesn't already come with a frozendict, or why there seem to only be a couple attempts to write one? Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From steve+comp.lang.python at pearwood.info Wed Feb 8 21:01:40 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 02:01:40 GMT Subject: frozendict References: Message-ID: <4f332903$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 19:23:19 -0600, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already > provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Because there is no way to implement one that doesn't suck? Because it's a solution in search of a problem? Actually, that's unfair. A write-once dict would be awesome for providing read-only constants, if only there were some way to set a namespace to using non-builtin dicts. -- Steven From tjreedy at udel.edu Wed Feb 8 21:07:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 21:07:40 -0500 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: On 2/8/2012 8:23 PM, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Turn the question around: why should there be? Python is intentionally parsimonious in adding builtins. -- Terry Jan Reedy From ian.g.kelly at gmail.com Wed Feb 8 21:13:10 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 8 Feb 2012 19:13:10 -0700 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: On Wed, Feb 8, 2012 at 6:23 PM, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Define "doesn't suck". If I were to hack one up, it would look something like this: from collections import Mapping, Hashable class frozendict(Mapping, Hashable): def __init__(self, *args, **kwargs): self.__dict = dict(*args, **kwargs) def __len__(self): return len(self.__dict) def __iter__(self): return iter(self.__dict) def __getitem__(self, key): return self.__dict[key] def __hash__(self): return hash(frozenset(self.__dict.iteritems())) def __repr__(self): return 'frozendict(%r)' % (self.__dict,) Not extensively tested, but it seems to work pretty well for me. Cheers, Ian From steve+comp.lang.python at pearwood.info Wed Feb 8 22:32:02 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 03:32:02 GMT Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? References: <4F31D85B.4040406@davea.name> Message-ID: <4f333e32$0$1615$c3e8da3$76491128@news.astraweb.com> On Tue, 07 Feb 2012 21:41:49 -0500, Dave Angel wrote: > On 02/07/2012 09:32 PM, Patto wrote: >> However I find in the file path/to/djcelery/loaders.py from >> django-celery source, there are so many import/from statements used >> inside functions, I do not know why the author coded like this. Are >> there any special facts? >> >> > I can't speak for django or django-celery. There are people that > disagree on this, and there are some reasons to override the ones I > mentioned. One would be large modules that are not used in most > circumstances, or not used till the program has run for a while. > > If you put the import inside a function, you can save on startup time by > deferring some of the logic till later. And if there's a module that > probably won't be used at all (eg. an error handler), perhaps you can > avoid loading it at all. Yes, the idea is "lazy importing" -- add the module name to the namespace, but don't actually load it until necessary. Apparently it is used heavily in Django and by PyPy. Interestingly, the CPython developers are currently migrating the low- level import machinery from C to pure Python (or at least mostly pure Python), because (1) the C code is a mess and practically nobody understands it; (2) the exact import behaviour is very hard to explain; (3) consequently Jython, IronPython etc. may behave slightly differently; (4) and they'd like to share the same code base as CPython; and (5) it's really hard to write custom importers. Moving to a pure Python implementation should fix these problems, provided that the speed hit isn't too big. http://sayspy.blogspot.com.au/2012/02/how-i-bootstrapped-importlib.html One suggestion made is that Python should support lazy imports out of the box. Another reason for putting imports inside a function is that global imports are, well, global. If you only need access to a module from one function, why pollute the global namespace? A reason for *not* importing inside a function is that there can sometimes be strange effects with threads, or so I've been told, but I couldn't begin to explain exactly what (allegedly) can go wrong. > I still think readability trumps all the other reasons, for nearly all > programs. Which is a good reason for importing inside a function: why confuse the reader with a global import if it isn't needed globally? -- Steven From nathan.alexander.rice at gmail.com Wed Feb 8 22:43:33 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 8 Feb 2012 22:43:33 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: > Turn the question around: why should there be? > Python is intentionally parsimonious in adding builtins. For the same reason there are frozensets? I put dicts in sets all the time. I just tuple the items, but that means you have to re-dict it on the way out to do anything useful with it. I am too lazy to write a frozendict or import one, but I would use it if it was a builtin. Nathan From emekamicro at gmail.com Wed Feb 8 22:48:25 2012 From: emekamicro at gmail.com (Emeka) Date: Thu, 9 Feb 2012 05:48:25 +0200 Subject: Id of methods Message-ID: Hell All, I am trying to see if I could get more of Python without being insane. class Boo(object): def __init__(self , moon, sun): self.moon = moon self.sun = sun def daf(self): return self.sun + self.moon def ball(self): return self.sun * self.moon print Boo.__dict__ {'__module__': '__main__', 'ball': , 'daf': , '__dict__ ......} print hex(id(Boo.daf)) 0x27de5a0 My question is why is it that the id of Boo.daf is different from daf's hex value in the above dict? Regards, \Emeka *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Wed Feb 8 22:55:30 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 03:55:30 GMT Subject: Cycle around a sequence References: Message-ID: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. If you have a sequence, and don't mind copying it, the easiest way is just to slice and join: >>> a = range(20) >>> b = a[5:] + a[:5] >>> print b [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] Short, sweet, easy and simple. What's not to like about it? For small (say, less than a few thousand of items) sequences, this probably is the fastest way to do it. Handling this lazily is trickier than it seems, because you have to store the first N items somewhere until you get to the rest of the iterable. There is no Right Way to do it, since the best solution will depend on how many items you have and how large N is. Here's one way with itertools: >>> from itertools import islice, chain, tee >>> a = iter(range(20)) >>> t1, t2 = tee(a) >>> b = chain(islice(t1, 5, None), islice(t2, None, 5)) >>> print list(b) [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] But read the docs for tee first: it may be that converting to a list is faster and more memory efficient. http://docs.python.org/library/itertools.html#itertools.tee Using tee may be overkill. Here's a simpler way: >>> a = iter(range(20)) >>> t = list(islice(a, 5)) >>> b = chain(a, t) >>> list(b) [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] If your data is truly humongous, already stored in a list, and you don't want to make a copy, then I recommend your trick of generating the indexes: def cycle(seq, n): for indexes in (xrange(n, len(seq)), xrange(n)): for i in indexes: yield seq[i] If your data is humongous but only available lazily, buy more memory :) -- Steven From rmorgan466 at gmail.com Wed Feb 8 23:01:08 2012 From: rmorgan466 at gmail.com (Rita) Date: Wed, 8 Feb 2012 23:01:08 -0500 Subject: standalone python web server Message-ID: I am building a small intranet website and I would like to use Python. I was wondering if there was a easy and medium performance python based web server available. I would like to run it on port :8080 since I wont have root access also I prefer something easy to deploy meaning I would like to move the server from one physical host to another without too much fuss. Currently, I am using flask (development server) and everything is ok but the performance is really bad. -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Feb 8 23:06:21 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 15:06:21 +1100 Subject: Id of methods In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > I am trying to see if I could get more of Python without being insane. Oh, I thought insanity was a prerequisite... anyway. > print Boo.__dict__ > > {'__module__': '__main__', 'ball': , 'daf': > , '__dict__ ......} > > print ?hex(id(Boo.daf)) > 0x27de5a0 > > My question is why is it that the id of Boo.daf ?is different from daf's hex > value in the above dict? Take no notice of the exact value of id(). It is an opaque value that shouldn't be relied upon for anything. That said, though, I tried your example in my two Windows Pythons, 2.6.5 and 3.2; in 3.2, the behavior is most like what you seem to be accepting: >>> Boo.__dict__ dict_proxy({'__module__': '__main__', 'ball': , 'daf': , '__dict__': , '__weakref__': , '__doc__': None, '__init__': }) >>> hex(id(Boo.daf)) '0xfcbc90' >>> Boo.daf Same number everywhere. But 2.6.5 has a difference that might give you a hint: >>> print Boo.__dict__ {'__module__': '__main__', 'ball': , 'daf': , '__dict__': , '__weakref__': , '__doc__': None, '__init__': } >>> Boo.daf daf is not a function, it's a special object for an unbound method. The exact identity of it is not necessarily useful; and buried inside it is the actual function that you defined: >>> hex(id(Boo.daf)) '0x11b5c10' >>> hex(id(Boo.daf.im_func)) '0x11bdc30' And that seems to be the number that's given in the repr(). But mainly, don't rely on id() for anything beyond uniqueness against all current objects. ChrisA From tjreedy at udel.edu Wed Feb 8 23:08:36 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 23:08:36 -0500 Subject: Id of methods In-Reply-To: References: Message-ID: On 2/8/2012 10:48 PM, Emeka wrote: >class Boo(object): > > def __init__(self , moon, sun): > self.moon = moon > self.sun = sun > def daf(self): > return self.sun + self.moon > def ball(self): > return self.sun * self.moon > > > print Boo.__dict__ > > {'__module__': '__main__', 'ball': , 'daf': > , '__dict__ ......} > > print hex(id(Boo.daf)) > 0x27de5a0 > My question is why is it that the id of Boo.daf is different from daf's > hex value in the above dict? Because you are using Python 2. Just print Boo.daf and you will see that it is not a 'function'. In Python 3, it will be, and have the same address. -- Terry Jan Reedy From rodrick.brown at gmail.com Wed Feb 8 23:12:04 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Wed, 8 Feb 2012 23:12:04 -0500 Subject: standalone python web server In-Reply-To: References: Message-ID: <5D252A02-CE40-4944-8A20-1AAB9F2FC2A3@gmail.com> On Feb 8, 2012, at 11:01 PM, Rita wrote: > I am building a small intranet website and I would like to use Python. I was wondering if there was a easy and medium performance python based web server available. I would like to run it on port :8080 since I wont have root access also I prefer something easy to deploy meaning I would like to move the server from one physical host to another without too much fuss. > > Currently, I am using flask (development server) and everything is ok but the performance is really bad. > Checkout TwistedWeb it's an HTTP server that can be used as a library or standalone server. $ twistd web --path . --port 8080 > > > -- > --- Get your facts first, then you can distort them as you please.-- > -- > http://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Feb 8 23:16:43 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 15:16:43 +1100 Subject: Cycle around a sequence In-Reply-To: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano wrote: > If your data is humongous but only available lazily, buy more memory :) Or if you have a huge iterable and only need a small index into it, snag those first few entries into a list, then yield everything else, then yield the saved ones: def cycle(seq,n): seq=iter(seq) lst=[next(seq) for i in range(n)] try: while True: yield next(seq) except StopIteration: for i in lst: yield i >>> list(cycle(range(10,20),2)) [12, 13, 14, 15, 16, 17, 18, 19, 10, 11] Requires storage space relative to n, regardless of the length of the iterator. ChrisA From roy at panix.com Wed Feb 8 23:31:55 2012 From: roy at panix.com (Roy Smith) Date: Wed, 08 Feb 2012 23:31:55 -0500 Subject: standalone python web server References: Message-ID: In article , Rodrick Brown wrote: > On Feb 8, 2012, at 11:01 PM, Rita wrote: > > > I am building a small intranet website and I would like to use Python. I > > was wondering if there was a easy and medium performance python based web > > server available. I would like to run it on port :8080 since I wont have > > root access also I prefer something easy to deploy meaning I would like to > > move the server from one physical host to another without too much fuss. > > > > Currently, I am using flask (development server) and everything is ok but > > the performance is really bad. > > > > Checkout TwistedWeb it's an HTTP server that can be used as a library or > standalone server. > > $ twistd web --path . --port 8080 > Another one to look at is gunicorn. From anonhung at gmail.com Wed Feb 8 23:50:42 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:50:42 +0100 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: >> My name is Todd. I'm the lead developer for Komodo IDE (Interactive >> Development Environment) and Komodo Edit (a free, open-source editor) at >> ActiveState. I wanted to announce that the newest version, Komodo 7, has >> been released: > > This is a pretty good release announcement, but a few questions. > ... > > http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as Komodo > Edit, but it is unclear why only Python editing would be featured for > Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. > > Does K.Edit let me run a program with one key, like F5 in IDLE? AFAIK it sure does! > If so, does it leave me in interactive mode (python -i) as IDLE does? Hmmm, I don't know about that. Best, anonhung -- Viktor Orban Prime minister of Hungary From anonhung at gmail.com Wed Feb 8 23:53:38 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:53:38 +0100 Subject: turbogears 1 In-Reply-To: References: Message-ID: >> Hey guys, someone asked me to maintain his old website, trouble is, >> it's in python, more trouble is it's in turbogears 1. I'm not fluent >> in python but all right, I can learn, but this turbogears >> thing.......... >> >> First of all, is it still alive? Looks like turbogears 2 is the most >> recent version but even that is being abandoned. > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > commit to the GIT repo in 2 days. Must be nailed to its perch or > something. > > http://turbogears.org/en/current-status > http://sourceforge.net/p/turbogears2/tg2/commit_browser All right, what I got confused about is that they talk about pyramid these days which will not be turbogears 2 based. >> Am I basically given vaporware? Does anyone have any up to date info? > > Have you considered Ruby on Rails? This is joke, right? :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Wed Feb 8 23:55:22 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:55:22 +0100 Subject: turbogears 1 In-Reply-To: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> References: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: >>> Hey guys, someone asked me to maintain his old website, trouble is, >>> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >>> python but all right, I can learn, but this turbogears thing.......... >>> >>> First of all, is it still alive? Looks like turbogears 2 is the most >>> recent version but even that is being abandoned. >> >> Yup, looks dead to me. Hasn't had a release in almost 2 months or a >> commit to the GIT repo in 2 days. Must be nailed to its perch or >> something. >> >> http://turbogears.org/en/current-status >> http://sourceforge.net/p/turbogears2/tg2/commit_browser > > Ohhh, sarcasm... > > To the original poster: what makes you think that Turbogears 2 is > abandoned? As I've said in another reply they keep talking about pyramid as if that will be a totally new framework. I'm not saying I know things definitely but surely my impression was that the team is out for something new not based on turbogears 2. >>> Am I basically given vaporware? Does anyone have any up to date info? >> >> Have you considered Ruby on Rails? > > Now that's just cruel. Yep, it is :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Wed Feb 8 23:59:17 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:59:17 +0100 Subject: Fwd: turbogears 1 In-Reply-To: References: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: >>> Hey guys, someone asked me to maintain his old website, trouble is, >>> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >>> python but all right, I can learn, but this turbogears thing.......... >>> >>> First of all, is it still alive? Looks like turbogears 2 is the most >>> recent version but even that is being abandoned. >> >> Yup, looks dead to me. Hasn't had a release in almost 2 months or a >> commit to the GIT repo in 2 days. Must be nailed to its perch or >> something. >> >> http://turbogears.org/en/current-status >> http://sourceforge.net/p/turbogears2/tg2/commit_browser > > Ohhh, sarcasm... > > To the original poster: what makes you think that Turbogears 2 is > abandoned? The development team keeps talking about pyramid which is supposed to be a totally new framework. I don't pretend to understand the work flow but surely they got me confused about switching gears (no pun intended!). >>> Am I basically given vaporware? Does anyone have any up to date info? >> >> Have you considered Ruby on Rails? > > Now that's just cruel. Yep, it is :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Thu Feb 9 00:05:35 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 06:05:35 +0100 Subject: standalone python web server In-Reply-To: References: Message-ID: >> I am building a small intranet website and I would like to use Python. I >> was wondering if there was a easy and medium performance python based web >> server available. I would like to run it on port :8080 since I wont have >> root access also I prefer something easy to deploy meaning I would like >> to >> move the server from one physical host to another without too much fuss. >> >> Currently, I am using flask (development server) and everything is ok but >> the performance is really bad. How about cherrypy? Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Thu Feb 9 00:07:42 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 06:07:42 +0100 Subject: Issue with Scrapping Data from a webpage- Noob Question In-Reply-To: References: Message-ID: > Hi Fellow Pythoners, > > I'm trying to collect table data from an authenticated webpage (Tool) to > which I have access. > > I will have the required data after 'click'ing a submit button on the tool > homepage. > When I inspect the submit button i see > > > Thus the tool's homepage is of the form www.example.com/Tool and on > clicking the submit button the data I need will be at > www.example.com/Tool/index.do > > The problem that I'm running into is in my below code is giving me the > source of homepage(www.example.com/Tool) and not the of the submitted page( > www.example.com/Tool/index.do) > > url="www.example.com/Tool/index.do" > request = urllib2.Request(url, data, {'Authorization': "Basic " + > base64.b64encode("%s:%s" % (username, password))}) > Response_Page=urllib2.urlopen(request).read() > > Is there a way I can access the source of the submitted page? > > PS: Sorry for laying out very tiny details on what I'm trying to do, I just > wanted to explain myself clearly :) > > Thanks in advance for your time on this one. Have you checked beautifulsoup? Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From driscoll at cs.wisc.edu Thu Feb 9 00:33:23 2012 From: driscoll at cs.wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 23:33:23 -0600 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: <4F335AA3.4010707@cs.wisc.edu> On 13:59, Nathan Rice wrote: >> Turn the question around: why should there be? >> Python is intentionally parsimonious in adding builtins. > > For the same reason there are frozensets? > > I put dicts in sets all the time. I just tuple the items, but that > means you have to re-dict it on the way out to do anything useful with > it. I am too lazy to write a frozendict or import one, but I would > use it if it was a builtin. I've wanted to do that as well. My current use case is I want to have a dict as an attribute of another object, and I want to use that object as a key in a dictionary. That means that the outer object has to be immutable (an obnoxious enough task on its own, BTW) and that either the dict itself has to be excluded from computing the hash or the dict also has to be immutable. Also, it's not like it has to be a builtin, per se. I know how to spell 'import'. :-) Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From edriscoll at wisc.edu Thu Feb 9 00:40:55 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 23:40:55 -0600 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: <4F335C67.3050703@wisc.edu> On 13:59, Ian Kelly wrote: > > Define "doesn't suck". If I were to hack one up, it would look > something like this: > > > from collections import Mapping, Hashable So part of my objection was that I wanted to make sure I got all of the expected functionality, and that takes a bunch of functions. I didn't know about the ABTs in 'collections' though, so that helps a bit. However, I'd still prefer something that guaranteed immutability better than that. I might just be fighting the language too much at that point though... Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From amarjeet.java at gmail.com Thu Feb 9 02:04:25 2012 From: amarjeet.java at gmail.com (amarjeet yadav) Date: Thu, 9 Feb 2012 12:34:25 +0530 Subject: Can not get the result of query in pymssql module of python... Message-ID: Hi All, This is my first post to any mailing group. I am QA engg and using python for testing automation. I need to connect with Mysql (2008) and mssql databases for executing some queries. I have installed following modules & softwares in python 2.7 : python 2.7.2 setuptools MySQLdb Module pymssql module yum install mysql msql-devel freetdf I have installed freetds 0.9version. After installation of all the above components, I have done following things Python 2.6 (r26:66714, Apr 8 2010, 08:46:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pymssql >>> conn = pymssql.connect(host='mssql_server', user='_username', password='_password', database='_db',as_dict=True) >>> cur = conn.cursor() >>> cur.execute('select count(*) from D2.dbo.abc (nolock)') >>> print cur.fetchall() [] >>> cur.rowcount -1 >>> exit() I am expecting that the result of the query will be 16. But it is not retuning any data from query with no error at any place. On execting the same query in tsql, I got result as 16. freetds.log file : ############################################################################ mem.c:615:tds_free_all_results() util.c:156:Changed query state from IDLE to QUERYING write.c:140:tds_put_string converting 50 bytes of "select count(*) from D2.dbo.abc (nolock)" write.c:168:tds_put_string wrote 100 bytes util.c:156:Changed query state from QUERYING to PENDING net.c:741:Sending packet 0000 01 01 00 6c 00 00 01 00-73 00 65 00 6c 00 65 00 |...l.... s.e.l.e.| 0010 63 00 74 00 20 00 63 00-6f 00 75 00 6e 00 74 00 |c.t. .c. o.u.n.t.| 0020 28 00 2a 00 29 00 20 00-66 00 72 00 6f 00 6d 00 |(.*.). . f.r.o.m.| 0030 20 00 44 00 32 00 2e 00-64 00 62 00 6f 00 2e 00 | .D.2... d.b.o...| 0040 61 00 63 00 74 00 69 00-76 00 65 00 5f 00 61 00 |a.c.t.i. v.e._.a.| 0050 67 00 65 00 6e 00 74 00-73 00 20 00 28 00 6e 00 |g.e.n.t. s. .(.n.| 0060 6f 00 6c 00 6f 00 63 00-6b 00 29 00 |o.l.o.c. k.).| dblib.c:4639:dbsqlok(0x99d1148) dblib.c:4669:dbsqlok() not done, calling tds_process_tokens() token.c:540:tds_process_tokens(0x998ff70, 0xbff42098, 0xbff42094, 0x6914) util.c:156:Changed query state from PENDING to READING net.c:555:Received header 0000 04 01 00 21 00 46 01 00- |...!.F..| net.c:609:Received packet 0000 04 01 00 21 00 46 01 00-81 01 00 00 00 01 00 26 |...!.F.. .......&| 0010 04 00 d1 04 10 00 00 00-fd 10 00 c1 00 01 00 00 |........ ........| 0020 00 - |.| token.c:555:processing result tokens. marker is 81(TDS7_RESULT) token.c:1515:processing TDS7 result metadata. mem.c:615:tds_free_all_results() token.c:1540:set current_results (1 column) to tds->res_info token.c:1547:setting up 1 columns token.c:1486:tds7_get_data_info: colname = (0 bytes) type = 38 (integer-null) server's type = 38 (integer-null) column_varint_size = 1 column_size = 4 (4 on server) token.c:1556: name size/wsize type/wtype utype token.c:1557: -------------------- --------------- --------------- ------- token.c:1567: 4/4 38/38 0 util.c:156:Changed query state from READING to PENDING dblib.c:4700:dbsqlok() found result token dblib.c:1813:dbnumcols(0x99d1148) dblib.c:2761:dbcount(0x99d1148) dblib.c:1813:dbnumcols(0x99d1148) dblib.c:1839:dbcolname(0x99d1148, 1) dblib.c:2831:dbcoltype(0x99d1148, 1) dblib.c:2018:dbnextrow(0x99d1148) dblib.c:2031:dbnextrow() dbresults_state = 1 (_DB_RES_RESULTSET_EMPTY) dblib.c:2036:leaving dbnextrow() returning -2 (NO_MORE_ROWS) dblib.c:2761:dbcount(0x99d1148) dblib.c:1443:dbclose(0x99d1148) dblib.c:258:dblib_del_connection(0xeff460, 0x998ff70) mem.c:615:tds_free_all_results() util.c:156:Changed query state from PENDING to DEAD dblib.c:305:dblib_release_tds_ctx(1) dblib.c:5882:dbfreebuf(0x99d1148) #################################################################################### Please let me know what could be the issue? Am I forgettting to set any variable ot conf file change. Is anyone has faced the same problem. Thanks in Advance for your help.... -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 9 03:33:13 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 09:33:13 +0100 Subject: Cycle around a sequence References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano > wrote: >> If your data is humongous but only available lazily, buy more memory :) > > Or if you have a huge iterable and only need a small index into it, > snag those first few entries into a list, then yield everything else, > then yield the saved ones: > def cycle(seq,n): > seq=iter(seq) > lst=[next(seq) for i in range(n)] > try: > while True: yield next(seq) > except StopIteration: > for i in lst: yield i I think that should be spelt def cycle2(seq, n): seq = iter(seq) head = [next(seq) for i in range(n)] for item in seq: yield item for item in head: yield item or, if you are into itertools, def cycle3(seq, n): seq = iter(seq) return chain(seq, list(islice(seq, n))) $ python -m timeit -s'from tmp import cycle; data = range(1000); start=10' 'for item in cycle(data, 10): pass' 1000 loops, best of 3: 358 usec per loop $ python -m timeit -s'from tmp import cycle2; data = range(1000); start=10' 'for item in cycle2(data, 10): pass' 1000 loops, best of 3: 172 usec per loop $ python -m timeit -s'from tmp import cycle3; data = range(1000); start=10' 'for item in cycle3(data, 10): pass' 10000 loops, best of 3: 56.5 usec per loop For reference: $ python -m timeit -s'data = range(1000); start=10' 'for item in data[start:] + data[:start]: pass' 10000 loops, best of 3: 56.4 usec per loop From __peter__ at web.de Thu Feb 9 03:36:30 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 09:36:30 +0100 Subject: Cycle around a sequence References: Message-ID: Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? You could use a deque instead of a list and .rotate() that: >>> from collections import deque >>> d = deque(range(10)) >>> d.rotate(-4) >>> d deque([4, 5, 6, 7, 8, 9, 0, 1, 2, 3]) > > PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit > (Intel)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. > >>> from itertools import chain > >>> a=range(10) > >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in > >>> xrange(4))) for x in g: print x, > ... > 4 5 6 7 8 9 0 1 2 3 > >>> From dllizheng at gmail.com Thu Feb 9 03:49:10 2012 From: dllizheng at gmail.com (newme) Date: Thu, 9 Feb 2012 00:49:10 -0800 (PST) Subject: what is the difference between @property and method Message-ID: <0c959426-d6a5-42ac-a869-e2a4edba1655@v6g2000pba.googlegroups.com> class A(object): @properymethod def value1(self): return 'value1' def value2(self): return 'value2' what is the difference between value1 and value2. From dllizheng at gmail.com Thu Feb 9 03:50:38 2012 From: dllizheng at gmail.com (Zheng Li) Date: Thu, 9 Feb 2012 17:50:38 +0900 Subject: what is the difference between @property and method Message-ID: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> class A(object): @properymethod def value1(self): return 'value1' def value2(self): return 'value2' what is the difference between value1 and value2. From jeanpierreda at gmail.com Thu Feb 9 04:05:06 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 9 Feb 2012 04:05:06 -0500 Subject: what is the difference between @property and method In-Reply-To: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> Message-ID: On Thu, Feb 9, 2012 at 3:50 AM, Zheng Li wrote: > class A(object): > @properymethod > def value1(self): > return 'value1' > > def value2(self): > return 'value2' > > what is the difference between value1 and value2. There is no such thing as @properymethod After you change the code to use @property, try writing it in the interactive interpreter and calling A().value2(). Then try calling A().value1() . Or maybe try googling for it. The fourth result for "property python" for me is http://adam.gomaa.us/blog/2008/aug/11/the-python-property-builtin/ -- It is kind of funny that the docs don't ever explicitly say what a property is. http://docs.python.org/library/functions.html#property -- Devin From storchaka at gmail.com Thu Feb 9 05:10:41 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Thu, 09 Feb 2012 12:10:41 +0200 Subject: Cycle around a sequence In-Reply-To: References: <9pfeutFtjiU2@mid.individual.net> Message-ID: 08.02.12 22:15, Terry Reedy ???????(??): > To make a repeating rotator is only a slight adjustment: > > k = n - len(seq) > while True: > i = k > while i < n: > yield seq[i] > i += 1 for i in range(n, len(seq)): yield seq[i] while True: for x in seq: yield x From duncan.booth at invalid.invalid Thu Feb 9 05:33:58 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 10:33:58 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > I put dicts in sets all the time. I just tuple the items, but that > means you have to re-dict it on the way out to do anything useful with > it. I am too lazy to write a frozendict or import one, but I would > use it if it was a builtin. > I hope you sort the items before putting them in a tuple, otherwise how do you handle two identical dicts that return their items in a different order? -- Duncan Booth http://kupuguy.blogspot.com From rosuav at gmail.com Thu Feb 9 05:34:45 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 21:34:45 +1100 Subject: Cycle around a sequence In-Reply-To: References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 7:33 PM, Peter Otten <__peter__ at web.de> wrote: > Chris Angelico wrote: > >> def cycle(seq,n): >> ? ? ? ? seq=iter(seq) >> ? ? ? ? lst=[next(seq) for i in range(n)] >> ? ? ? ? try: >> ? ? ? ? ? ? ? ? while True: yield next(seq) >> ? ? ? ? except StopIteration: >> ? ? ? ? ? ? ? ? for i in lst: yield i > > I think that should be spelt > > def cycle2(seq, n): > ? ?seq = iter(seq) > ? ?head = [next(seq) for i in range(n)] > ? ?for item in seq: > ? ? ? ?yield item > ? ?for item in head: > ? ? ? ?yield item Thanks, yeah, don't know what I was thinking :) Too much C work lately! ChrisA From phil at freehackers.org Thu Feb 9 05:46:46 2012 From: phil at freehackers.org (BlueBird) Date: Thu, 9 Feb 2012 02:46:46 -0800 (PST) Subject: unicode printing on Windows Message-ID: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Hi, The question is not totally related to Python but there is a strong connection. Everytime that I try to debug some python programs under Windows, I encounter the issue that things printed on the console simply break the program because : 1. My windows console does not support UTF8 2. Things printed by the program on the stdout / stderr do not necessarily use sys.getpreferredencoding() so break with UnicodeError. Does anybody know how to fix problem 1 ? That way, I could at least deal with programs that print UTF8 on stdout. Regarding point 2, I must admit even when I am the author of the program, printing debug information (in unicode) on the stdout is a really really tricky thing. Is there a recommendation on how to do that properly ? Important information : I am using Python 2.5 cheers, Philippe From bahamutzero8825 at gmail.com Thu Feb 9 06:19:10 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 09 Feb 2012 05:19:10 -0600 Subject: unicode printing on Windows In-Reply-To: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> References: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Message-ID: <4F33ABAE.9050804@gmail.com> On 2/9/2012 4:46 AM, BlueBird wrote: > Does anybody know how to fix problem 1 ? That way, I could at least > deal with programs that print UTF8 on stdout. I'm pretty sure there isn't a way. cp65001 is supposed to be UTF-8, but it doesn't work in my experience (I fed it some UTF-8 demo text and I got garbage and beeping). Python 3.3 will support cp65001, 3.2 and below do not. > Regarding point 2, I must admit even when I am the author of the > program, printing debug information (in unicode) on the stdout is a > really really tricky thing. Is there a recommendation on how to do > that properly ? Use the logging module, perhaps? It has handled encoding issues automatically, at least in my experience. In Python 3, you can convert a string to bytes from one encoding, then convert to another encoding, but Python 2 has things set up very differently (and my experience is with py3k, so I can't help much). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From thbach at students.uni-mainz.de Thu Feb 9 06:28:21 2012 From: thbach at students.uni-mainz.de (Thomas Bach) Date: Thu, 9 Feb 2012 12:28:21 +0100 Subject: standalone python web server In-Reply-To: (Rita's message of "Wed, 8 Feb 2012 23:01:08 -0500") References: Message-ID: <87pqdoutyi.fsf@jubold.box> Rita writes: > I am building a small intranet website and I would like to use > Python. I was wondering if there was a easy and medium performance > python based web server available. Are you going to use a framework? Most of these ship with a light web server implementation? You probably want to check these out too? I got a pretty robust setup via + nginx, + supervisord, + the web server shipped with Pyramid If you want to use the WSGI standard I'd recommend to read http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/deployment.html This document describes several possible set ups to serve an WSGI application? Regards, vince From mateusz at loskot.net Thu Feb 9 06:43:44 2012 From: mateusz at loskot.net (Mateusz Loskot) Date: Thu, 9 Feb 2012 11:43:44 +0000 Subject: Read-only attribute in module Message-ID: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the following import xyz print(xyz.flag) # OK xyz.flag = 0 # error due to no write access Best regards, -- Mateusz Loskot, http://mateusz.loskot.net From rodperson at rodperson.com Thu Feb 9 07:31:56 2012 From: rodperson at rodperson.com (Rod Person) Date: Thu, 9 Feb 2012 07:31:56 -0500 Subject: Can not get the result of query in pymssql module of python... In-Reply-To: References: Message-ID: <20120209073156.000012b2@unknown> On Thu, 9 Feb 2012 12:34:25 +0530 amarjeet yadav wrote: > Hi All, > This is my first post to any mailing group. I am QA engg > and using python for testing automation. I need to connect with Mysql > (2008) and mssql databases for executing some queries. > > I have installed following modules & softwares in python 2.7 : > > python 2.7.2 > setuptools > MySQLdb Module > pymssql module > yum install mysql msql-devel freetdf > > I have installed freetds 0.9version. After installation of all the > above components, I have done following things > > Python 2.6 (r26:66714, Apr 8 2010, 08:46:35) > [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import pymssql > >>> conn = pymssql.connect(host='mssql_server', user='_username', > password='_password', database='_db',as_dict=True) > >>> cur = conn.cursor() > >>> cur.execute('select count(*) from D2.dbo.abc (nolock)') > >>> print cur.fetchall() What if you change this to print cur.fetchone() About 95% of my python database work is with MS SQL. I use fetchone when as_dict is True and it seems to work better for me. > [] > >>> cur.rowcount > -1 > >>> exit() > > I am expecting that the result of the query will be 16. But it is not > retuning any data from query with no error at any place. On execting > the same query in tsql, I got result as 16. > -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From ben+python at benfinney.id.au Thu Feb 9 07:32:59 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 09 Feb 2012 23:32:59 +1100 Subject: Read-only attribute in module References: Message-ID: <878vkc426c.fsf@benfinney.id.au> Mateusz Loskot writes: > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Python is designed by and for consenting adults. Rather than restricting, instead use conventions to make your intent clear to the user of your library. > So, the following > > import xyz > print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access PEP 8 gives the style guide for Python code (strictly for the standard library, but it is recommended for all Python code). If you want a module attribute that is intended to remain bound to the same value, use PEP 8's recommendation and name the attribute in ?ALL_UPPER_CASE?. If you want an attribute that is intended only for internal use (an implementation detail that should not be relied upon outside the library), use PEP 8's recommendation and name the attribute with a ?_single_leading_underscore?. -- \ ?We jealously reserve the right to be mistaken in our view of | `\ what exists, given that theories often change under pressure | _o__) from further investigation.? ?Thomas W. Clark, 2009 | Ben Finney From rmorgan466 at gmail.com Thu Feb 9 07:41:26 2012 From: rmorgan466 at gmail.com (Rita) Date: Thu, 9 Feb 2012 07:41:26 -0500 Subject: standalone python web server In-Reply-To: <87pqdoutyi.fsf@jubold.box> References: <87pqdoutyi.fsf@jubold.box> Message-ID: yes, I would like to use a framework. I like the twisted method the user posted. Are there any examples of it using a framework, get/post, etc..? On Thu, Feb 9, 2012 at 6:28 AM, Thomas Bach wrote: > Rita writes: > > > I am building a small intranet website and I would like to use > > Python. I was wondering if there was a easy and medium performance > > python based web server available. > > Are you going to use a framework? Most of these ship with a light > web server implementation? You probably want to check these out too? > > I got a pretty robust setup via > + nginx, > + supervisord, > + the web server shipped with Pyramid > > If you want to use the WSGI standard I'd recommend to read > > > http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/deployment.html > > This document describes several possible set ups to serve an WSGI > application? > > > Regards, > vince > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodperson at rodperson.com Thu Feb 9 07:45:56 2012 From: rodperson at rodperson.com (Rod Person) Date: Thu, 9 Feb 2012 07:45:56 -0500 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: <20120209074556.00006c72@unknown> On Wed, 08 Feb 2012 16:52:50 -0500 Terry Reedy wrote: > On 2/8/2012 3:14 PM, Todd Whiteman wrote: > > > My name is Todd. I'm the lead developer for Komodo IDE (Interactive > > Development Environment) and Komodo Edit (a free, open-source > > editor) at ActiveState. I wanted to announce that the newest > > version, Komodo 7, has been released: > > This is a pretty good release announcement, but a few questions. > ... > > http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as > Komodo Edit, but it is unclear why only Python editing would be > featured for Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. > > Does K.Edit let me run a program with one key, like F5 in IDLE? > If so, does it leave me in interactive mode (python -i) as IDLE does? > I'm not an ActiveState employee, but I have used Komodo IDE since version 4, on FreeBSD and Windows. The selling point of the IDE is definitely the interactive python debugger which isn't in the editor. It also supports more than python, just in case for some old reason you'd find the need to write Perl, Ruby or TCL code. -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From bruno.desthuilliers at gmail.com Thu Feb 9 07:59:17 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 9 Feb 2012 04:59:17 -0800 (PST) Subject: Id of methods References: Message-ID: <779734b6-4f0a-488f-8a0f-75d79aac9e31@ge5g2000vbb.googlegroups.com> On Feb 9, 5:06?am, Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > > > My question is why is it that the id of Boo.daf ?is different from daf's hex > > value in the above dict? > > > daf is not a function, it's a special object for an unbound method. http://wiki.python.org/moin/FromFunctionToMethod From johnoksz at gmail.com Thu Feb 9 08:19:06 2012 From: johnoksz at gmail.com (John Oksz) Date: Thu, 9 Feb 2012 05:19:06 -0800 (PST) Subject: Software tool for stochastic simulation as well as for the stochastic optimization Message-ID: Hello Python World, I am starting work on stochastic approach. I plan to work in decision support field in environmental engineering so I will use both the stochastic simulation as well as the stochastic optimization. I would like to select the best for both approaches software tool. what you suggest ... Matlab ... python ... something else? Any thoughts would be appreciated, John From moky.math at gmail.com Thu Feb 9 09:00:38 2012 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 09 Feb 2012 15:00:38 +0100 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: > Here is my question: I would like to start an in-house library of small > modules to import, for things like error handling/logging. That's easy > enough, but is there a recommended way of naming such modules? I am > concerned about avoiding name clashes with standard modules and site > packages. > > Thanks. > This is not 100% an answer to the question, but you should read that : http://www.python.org/dev/peps/pep-0008/ This explain you WhatCaseToChoose for_naming youVariables. Laurent From roy at panix.com Thu Feb 9 09:01:42 2012 From: roy at panix.com (Roy Smith) Date: Thu, 09 Feb 2012 09:01:42 -0500 Subject: turbogears 1 References: Message-ID: In article , anon hung wrote: > >> Hey guys, someone asked me to maintain his old website, trouble is, > >> it's in python, more trouble is it's in turbogears 1. I'm not fluent > >> in python but all right, I can learn, but this turbogears > >> thing.......... > >> > >> First of all, is it still alive? Looks like turbogears 2 is the most > >> recent version but even that is being abandoned. > > > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > > commit to the GIT repo in 2 days. Must be nailed to its perch or > > something. > > > > http://turbogears.org/en/current-status > > http://sourceforge.net/p/turbogears2/tg2/commit_browser > > All right, what I got confused about is that they talk about pyramid > these days which will not be turbogears 2 based. > > >> Am I basically given vaporware? Does anyone have any up to date info? > > > > Have you considered Ruby on Rails? > > This is joke, right? :) Yes. From sales at smartbaba.com Thu Feb 9 09:28:28 2012 From: sales at smartbaba.com (Smart Baba Sales) Date: Thu, 9 Feb 2012 06:28:28 -0800 (PST) Subject: Have your own business web Message-ID: Do you know about Smart Baba new offer? Now get your own business customized professional website and start promoting your business. For further details, Follow us at: www.websitedeals.in From nathan.alexander.rice at gmail.com Thu Feb 9 09:36:12 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 09:36:12 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth wrote: > Nathan Rice wrote: > >> I put dicts in sets all the time. ?I just tuple the items, but that >> means you have to re-dict it on the way out to do anything useful with >> it. ?I am too lazy to write a frozendict or import one, but I would >> use it if it was a builtin. >> > I hope you sort the items before putting them in a tuple, otherwise how do > you handle two identical dicts that return their items in a different > order? Two dicts created from the same inputs will return items in the same arbitrary order. As long as you don't insert or delete a key you're fine. Nathan From arnodel at gmail.com Thu Feb 9 09:36:52 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 9 Feb 2012 14:36:52 +0000 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: On 9 February 2012 14:00, Laurent Claessens wrote: > >> Here is my question: I would like to start an in-house library of small >> modules to import, for things like error handling/logging. That's easy >> enough, but is there a recommended way of naming such modules? I am >> concerned about avoiding name clashes with standard modules and site >> packages. >> >> Thanks. >> > > This is not 100% an answer to the question, but you should read that : > http://www.python.org/dev/peps/pep-0008/ The OP mentions PEP 8 in the bit of his message that you *don't* quote. -- Arnaud From duncan.booth at invalid.invalid Thu Feb 9 09:52:17 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 14:52:17 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth > wrote: >> Nathan Rice wrote: >> >>> I put dicts in sets all the time. ?I just tuple the items, but that >>> means you have to re-dict it on the way out to do anything useful >>> with it. ?I am too lazy to write a frozendict or import one, but I >>> would use it if it was a builtin. >>> >> I hope you sort the items before putting them in a tuple, otherwise >> how d > o >> you handle two identical dicts that return their items in a different >> order? > > Two dicts created from the same inputs will return items in the same > arbitrary order. As long as you don't insert or delete a key you're > fine. > Two dicts that contain the same keys and values may or may not return them in the same order: >>> dict.fromkeys('ia') {'i': None, 'a': None} >>> dict.fromkeys('ai') {'a': None, 'i': None} Would your system count those two dicts as the same? If the sequence in which the keys were added to the dict (and deleted if appropriate) is exactly the same then it is likely but still not guaranteed that they will have the same order. The only ordering guarantee is that within a single dict keys and values will appear in a consistent order so long as you don't add/delete keys between calls. -- Duncan Booth http://kupuguy.blogspot.com From info at egenix.com Thu Feb 9 10:16:59 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu, 09 Feb 2012 16:16:59 +0100 Subject: ANN: eGenix mxODBC Zope Database Adapter 2.0.2 Message-ID: <4F33E36B.40001@egenix.com> ________________________________________________________________________ ANNOUNCEMENT mxODBC Zope Database Adapter Version 2.0.2 for Zope and the Plone CMS Available for Zope 2.10 and later on Windows, Linux, Mac OS X, FreeBSD and other platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.0.2-GA.html ________________________________________________________________________ INTRODUCTION The eGenix mxODBC Zope Database Adapter allows you to easily connect your Zope or Plone installation to just about any database backend on the market today, giving you the reliability of the commercially supported eGenix product mxODBC and the flexibility of the ODBC standard as middle-tier architecture. The mxODBC Zope Database Adapter is highly portable, just like Zope itself and provides a high performance interface to all your ODBC data sources, using a single well-supported interface on Windows, Linux, Mac OS X, FreeBSD and other platforms. This makes it ideal for deployment in ZEO Clusters and Zope hosting environments where stability and high performance are a top priority, establishing an excellent basis and scalable solution for your Plone CMS. Product page: http://www.egenix.com/products/zope/mxODBCZopeDA/ ________________________________________________________________________ NEWS We are pleased to announce a new version 2.0.2 of our mxODBC Zope DA product. With the patch level 2.0.2 release we have updated the integrated mxODBC Python Extension to the latest 3.1.1 release, which includes a number of important workarounds for these ODBC drivers: * Oracle 10gR1 and 10gR2 * Oracle 11gR1 and 11gR2 * Teradata 13 * Netezza Due to popular demand, we have also added instructions on how to install mxODBC Zope DA 2.0 with Plone 4.1 and Zope 2.13 - even though this combination is not officially supported by the mxODBC Zope DA 2.0 series: http://www.egenix.com/products/zope/mxODBCZopeDA/#Installation ________________________________________________________________________ UPGRADING Licenses purchased for version 2.0.x of the mxODBC Zope DA will continue to work with the 2.0.2 patch level release. Licenses purchased for version 1.0.x of the mxODBC Zope DA will not work with version 2.0. More information about available licenses is available on the product page: http://www.egenix.com/products/zope/mxODBCZopeDA/#Licensing Compared to the popular mxODBC Zope DA 1.0, version 2.0 offers these enhancements: * Includes mxODBC 3.1 with updated support for many current ODBC drivers, giving you more portability and features for a wider range of database backends. * Mac OS X 10.6 (Snow Leopard) support. * Plone 3.2, 3.3, 4.0 support. Plone 4.1 works as well. * Zope 2.10, 2.11, 2.12 support. Zope 2.13 works as well. * Python 2.4 - 2.6 support. * Zero maintenance support to automatically reconnect the Zope connection after a network or database problem. * More flexible Unicode support with options to work with pure Unicode, plain strings or mixed setups - even for databases that don't support Unicode * Automatic and transparent text encoding and decoding * More flexible date/time support including options to work with Python datetime objects, mxDateTime, strings or tuples * New decimal support to have the Zope DA return decimal column values using Python's decimal objects. * Fully eggified to simplify easy_install and zc.buildout based installation ________________________________________________________________________ MORE INFORMATION For more information on the mxODBC Zope Database Adapter, licensing and download instructions, please visit our web-site: http://www.egenix.com/products/zope/mxODBCZopeDA/ You can buy mxODBC Zope DA licenses online from the eGenix.com shop at: http://shop.egenix.com/ ________________________________________________________________________ Thank you, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 09 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From nathan.alexander.rice at gmail.com Thu Feb 9 10:19:46 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 10:19:46 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: >> Two dicts created from the same inputs will return items in the same >> arbitrary order. ?As long as you don't insert or delete a key you're >> fine. >> > Two dicts that contain the same keys and values may or may not return them > in the same order: > >>>> dict.fromkeys('ia') > {'i': None, 'a': None} >>>> dict.fromkeys('ai') > {'a': None, 'i': None} > > Would your system count those two dicts as the same? > > If the sequence in which the keys were added to the dict (and deleted if > appropriate) is exactly the same then it is likely but still not guaranteed > that they will have the same order. The only ordering guarantee is that > within a single dict keys and values will appear in a consistent order so > long as you don't add/delete keys between calls. As I said, two dictionaries created from the same input will be the same... 'ai' != 'ia'. If I need to hash a dict that I don't know was created in a deterministic order, I'd frozenset(thedict.items()). Nathan From jjposner at optimum.net Thu Feb 9 10:36:38 2012 From: jjposner at optimum.net (John Posner) Date: Thu, 09 Feb 2012 10:36:38 -0500 Subject: what is the difference between @property and method In-Reply-To: References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> Message-ID: <4F33E806.8070700@optimum.net> On 2:59 PM, Devin Jeanpierre wrote: > It is kind of funny that the docs don't ever explicitly say what a > property is. http://docs.python.org/library/functions.html#property -- > Devin Here's a writeup that does: http://wiki.python.org/moin/AlternativeDescriptionOfProperty -John From feliphil at gmx.net Thu Feb 9 11:24:09 2012 From: feliphil at gmx.net (Wolfgang Keller) Date: Thu, 9 Feb 2012 17:24:09 +0100 Subject: Software tool for stochastic simulation as well as for the stochastic optimization References: Message-ID: <20120209172409.19a887eb.feliphil@gmx.net> > I plan to work in decision support field in environmental engineering > so I will use both the stochastic simulation as well as the stochastic > optimization. > I would like to select the best for both approaches software tool. > > what you suggest ... Matlab ... python ... something else? I have no clue whether it does stochastic simulation and optimisation, but R is THE free open-source statistic analysis tool. It does have a Python interface, RPy. And there's a free open-source replacement for Matlab, Scilab. Which has a Python interface as well. Sincerely, Wolfgang -- HOMO HOMINI HOSTIS IN FELIBUS FELICITAS From ian.g.kelly at gmail.com Thu Feb 9 11:35:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 09:35:52 -0700 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... That's an implementation detail, not a guarantee. It will hold for current versions of CPython but not necessarily for other Python implementations. From mateusz at loskot.net Thu Feb 9 11:44:33 2012 From: mateusz at loskot.net (mloskot) Date: Thu, 9 Feb 2012 08:44:33 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: <878vkc426c.fsf@benfinney.id.au> References: <878vkc426c.fsf@benfinney.id.au> Message-ID: <1328805873302-4380150.post@n6.nabble.com> Ben Finney-10 wrote > > Mateusz Loskot <mateusz@> writes: > >> So, the following >> >> import xyz >> print(xyz.flag) # OK >> xyz.flag = 0 # error due to no write access > > PEP 8 <URL:http://www.python.org/dev/peps/pep-0008/> gives the style > guide for Python code (strictly for the standard library, but it is > recommended for all Python code). > Ben, That's what I thought really. Thank you for confirming the sanity of the style-powered conventions. Best regards, ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4380150.html Sent from the Python - python-list mailing list archive at Nabble.com. From nathan.alexander.rice at gmail.com Thu Feb 9 11:50:51 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 11:50:51 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 11:35 AM, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee. ?It will hold for > current versions of CPython but not necessarily for other Python > implementations. That is true. The implications of the function that creates dictionaries being non-deterministic are a little scary though, so I suspect that it will hold :) Nathan From moky.math at gmail.com Thu Feb 9 12:42:40 2012 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 09 Feb 2012 18:42:40 +0100 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: <4F340590.6090503@gmail.com> >> This is not 100% an answer to the question, but you should read that : >> http://www.python.org/dev/peps/pep-0008/ > > The OP mentions PEP 8 in the bit of his message that you *don't* quote. Well... I've to sleep. Sorry :( Laurent From sajuptpm at gmail.com Thu Feb 9 12:56:36 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Thu, 9 Feb 2012 09:56:36 -0800 (PST) Subject: Guide to: Learning Python Decorators Message-ID: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Guide to: Learning Python Decorators New Book http://tinyurl.com/python-decorartor From tjreedy at udel.edu Thu Feb 9 13:21:53 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 13:21:53 -0500 Subject: unicode printing on Windows In-Reply-To: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> References: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Message-ID: On 2/9/2012 5:46 AM, BlueBird wrote: > Hi, > > The question is not totally related to Python but there is a strong > connection. Everytime that I try to debug some python programs under > Windows, I encounter the issue that things printed on the console > simply break the program because : > 1. My windows console does not support UTF8 The IDLE shell (now) is friendlier to unicode, supporting the entire BMP. So you may have more success loading into an IDLE editor and running from there with F5. Or perhaps execfile in the shell (I never tried this). Of course, import and pdb in the shell work. This all depends on what 'debugging' means to you. > Important information : I am using Python 2.5 I don't know if IDLE was different then. -- Terry Jan Reedy From jkn_gg at nicorp.f9.co.uk Thu Feb 9 13:32:35 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Thu, 9 Feb 2012 10:32:35 -0800 (PST) Subject: multiple namespaces within a single module? Message-ID: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Hello there is it possible to have multiple namespaces within a single python module? I have a small app which is in three or four .py files. For various reasons I would like to (perhaps optionally) combine these into one file. I was hoping that there might be a simple mechanism that would let me do this and maintain the namespaces referred to: so that the 'combined' file would look something like # # not real python # # originally from a.py with namespace a: def function(): pass # ... # originally from b.py with namespace b: def function(): pass # originally from main module a.function() b.function() etc. Is there anything like this available? Thanks J^n From duncan.booth at invalid.invalid Thu Feb 9 13:47:20 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 18:47:20 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... 'ai' != 'ia'. If I need to hash a dict that I don't know was > created in a deterministic order, I'd frozenset(thedict.items()). > Fair enough, the idea scares me, but it's your code and your risk. BTW, make sure that if you ever copy any of those dictionaries they all get copied the same number of times as simply copying a dict can change the key order. >>> dict.fromkeys('me') {'e': None, 'm': None} >>> dict(dict.fromkeys('me')) {'m': None, 'e': None} >>> dict(dict(dict.fromkeys('me'))) {'e': None, 'm': None} -- Duncan Booth http://kupuguy.blogspot.com From someone at someplace.invalid Thu Feb 9 13:53:54 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 18:53:54 +0000 (UTC) Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) References: Message-ID: On Thu, 09 Feb 2012 14:36:52 +0000, Arnaud Delobelle wrote: > On 9 February 2012 14:00, Laurent Claessens wrote: >> >>> Here is my question: I would like to start an in-house library of >>> small modules to import, for things like error handling/logging. >>> That's easy enough, but is there a recommended way of naming such >>> modules? I am concerned about avoiding name clashes with standard >>> modules and site packages. >>> >>> Thanks. >>> >>> >> This is not 100% an answer to the question, but you should read that : >> http://www.python.org/dev/peps/pep-0008/ > > The OP mentions PEP 8 in the bit of his message that you *don't* quote. Thank you for that Arnaud, and thanks to Chris R. I'm going along with Chris's suggestion for the moment. One issue I have run into, which may or may not be a problem: I am finding that modules in the in-house "library" package sometimes have to import modules like sys and os, which are also imported by the "calling" module. Is this a problem or an overhead, or does it just result in two names for the same object? Thanks again. From arnodel at gmail.com Thu Feb 9 13:55:53 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 9 Feb 2012 18:55:53 +0000 Subject: Guide to: Learning Python Decorators In-Reply-To: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: On Feb 9, 2012 6:00 PM, "sajuptpm" wrote: > > Guide to: Learning Python Decorators > New Book http://tinyurl.com/python-decorartor A whole book about decorators? Cool. I'm going to start writing books to. I'll start with 'The Python print statement'. Then to be cutting edge I'll follow with 'The Python print function'. -- Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 9 14:02:03 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 12:02:03 -0700 Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote: > One issue I have run into, which may or may not be a problem: I am > finding that modules in the in-house "library" package sometimes have to > import modules like sys and os, which are also imported by the "calling" > module. Is this a problem or an overhead, or does it just result in two > names for the same object? Two names for the same object. When a module is imported, the module object is stored in the sys.modules dict. Further imports of the same module just return the same module object from sys.modules. From tjreedy at udel.edu Thu Feb 9 14:15:45 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 14:15:45 -0500 Subject: Read-only attribute in module In-Reply-To: References: Message-ID: On 2/9/2012 6:43 AM, Mateusz Loskot wrote: > Hi, > > I'm implementing Python 3 extension using the Python C API. I am > familiar with defining new types, implementing get/set for > attributes, etc. > > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Not that I know of. Python intentionally leaves modules mutable even after the code has executed so they can be monkey-patched from outside. The argument for is that it is unusual to do so but sometimes very useful and necessary. The main argument against is that it prevents optimizations that would make code in modules run faster. > import xyz print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access Why prevent that? If you called it 'FLAG', that would indicate that it is a constant that should not be changed. While Python make some effort to prevent bugs, it is generally a 'consenting adults' language. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 14:18:33 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 14:18:33 -0500 Subject: what is the difference between @property and method In-Reply-To: <4F33E806.8070700@optimum.net> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> <4F33E806.8070700@optimum.net> Message-ID: On 2/9/2012 10:36 AM, John Posner wrote: > On 2:59 PM, Devin Jeanpierre wrote: > > >> It is kind of funny that the docs don't ever explicitly say what a >> property is. http://docs.python.org/library/functions.html#property -- >> Devin > > Here's a writeup that does: > http://wiki.python.org/moin/AlternativeDescriptionOfProperty Suggested doc changes on the tracker get reviewed, and often applied. -- Terry Jan Reedy From __peter__ at web.de Thu Feb 9 14:33:27 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 20:33:27 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: jkn wrote: > is it possible to have multiple namespaces within a single python > module? Unless you are abusing classes I don't think so. > I have a small app which is in three or four .py files. For various > reasons I would like to (perhaps optionally) combine these into one > file. Rename your main script into __main__.py, put it into a zip file together with the other modules and run that. From breamoreboy at yahoo.co.uk Thu Feb 9 14:35:13 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 09 Feb 2012 19:35:13 +0000 Subject: Read-only attribute in module In-Reply-To: References: Message-ID: On 09/02/2012 11:43, Mateusz Loskot wrote: > Hi, > > I'm implementing Python 3 extension using the Python C API. > I am familiar with defining new types, implementing get/set for attributes, etc. > > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? > > So, the following > > import xyz > print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access > > Best regards, There's a recipe by Alex Martelli here http://code.activestate.com/recipes/65207-constants-in-python/ but most people wouldn't bother with it. As others have said simply use THIS_IS_A_CONSTANT. -- Cheers. Mark Lawrence. From someone at someplace.invalid Thu Feb 9 14:40:41 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 19:40:41 +0000 (UTC) Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) References: Message-ID: On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster > wrote: >> One issue I have run into, which may or may not be a problem: I am >> finding that modules in the in-house "library" package sometimes have >> to import modules like sys and os, which are also imported by the >> "calling" >> module. Is this a problem or an overhead, or does it just result in two >> names for the same object? > > Two names for the same object. When a module is imported, the module > object is stored in the sys.modules dict. Further imports of the same > module just return the same module object from sys.modules. Excellent! It seems it is not a problem at all, then. Thank you. From d at davea.name Thu Feb 9 15:05:52 2012 From: d at davea.name (Dave Angel) Date: Thu, 09 Feb 2012 15:05:52 -0500 Subject: Apparent "double imports" In-Reply-To: References: Message-ID: <4F342720.1050601@davea.name> On 02/09/2012 02:40 PM, HoneyMonster wrote: > On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster >> wrote: >>> One issue I have run into, which may or may not be a problem: I am >>> finding that modules in the in-house "library" package sometimes have >>> to import modules like sys and os, which are also imported by the >>> "calling" >>> module. Is this a problem or an overhead, or does it just result in two >>> names for the same object? >> Two names for the same object. When a module is imported, the module >> object is stored in the sys.modules dict. Further imports of the same >> module just return the same module object from sys.modules. > Excellent! It seems it is not a problem at all, then. Thank you. Just to add a little subtlety, there is a problem with mutually recursive imports. If module aaa imports module bbb, and modole bbb imports aaa, there can be some problems. Most can be avoided by putting the imports right at the beginning of each file, so no work has been done before doing the imports. Then by the time some code tries to use them, they're all resolved. One exception is if you try to import the file that is your script file. This one is made into a module by the special name of __main__, and if you import it using the original name, you'll have two copies around. That can lead to some very interesting anomalies. Better is to make sure no loops exist in the importing tree, which is a desirable structuring goal anyway. When two modules need each other, try to either move the common stuff to a 3rd module they each import, or do something with callbacks or other mechanism that reflects what's really going on. Of cours that last paragraph is strictly my own opinion. -- DaveA From jenn.duerr at gmail.com Thu Feb 9 15:08:41 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 12:08:41 -0800 (PST) Subject: Formate a number with commas Message-ID: How do you format a number to print with commas? Some quick searching, i came up with: >>> import locale >>> locale.setlocale(locale.LC_ALL, "") >>> locale.format('%d', 2348721, True) '2,348,721' I'm a perpetual novice, so just looking for better, slicker, more proper, pythonic ways to do this. Thanks! From neilc at norwich.edu Thu Feb 9 15:17:38 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 9 Feb 2012 20:17:38 GMT Subject: Formate a number with commas References: Message-ID: <9pinv2F5hpU2@mid.individual.net> On 2012-02-09, noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") >>>> locale.format('%d', 2348721, True) > '2,348,721' > > I'm a perpetual novice, so just looking for better, slicker, > more proper, pythonic ways to do this. I think you've found an excellent way to do it. -- Neil Cerutti From tjreedy at udel.edu Thu Feb 9 15:28:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 15:28:40 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: On 2/9/2012 1:55 PM, Arnaud Delobelle wrote: > > On Feb 9, 2012 6:00 PM, "sajuptpm" > wrote: > > > > Guide to: Learning Python Decorators > > New Book http://tinyurl.com/python-decorartor Which goes to Amazon, perhaps with an Amazon Associate id embedded. > A whole book about decorators? Cool. I'm going to start writing books > to. I'll start with 'The Python print statement'. Then to be cutting > edge I'll follow with 'The Python print function'. Sarcasm aside, it is a small (200K) digital book at a small price ($4). According to the 5-star reviews, it is not as trivial as the title indicates. It starts with explaining functions, scope, parameters, nesting, *args, **kwds, and nesting. In other words, everything one needs to know to understand decorators. It is based on tutorials given at PyCon and elsewhere. I plan to borrow it and take a look. A book on Printing with Python that clearly explained everything one needs to know about characters, glyphs, fonts, bytes, unicode, encodings, and serialization in order to print would also be worthwhile. For a bonus, add in something about console windows, OS differences, and printers. -- Terry Jan Reedy From SMac2347 at comcast.net Thu Feb 9 15:32:35 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Thu, 9 Feb 2012 12:32:35 -0800 (PST) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: <10d15214-1fd8-4b80-8384-c0b291c6976d@h3g2000yqe.googlegroups.com> On Feb 7, 3:16?pm, Peter Otten <__pete... at web.de> wrote: > SMac2... at comcast.net wrote: > > xls_files ? = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and filename if > necessary. > > > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") > > If you paste the directory name literal into the interactive interpreter > you'll be surprised: > > >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' > > "\09" is intrpreted as chr(9). Use a raw string to prevent Python from > interpreting a backslash as the start of an escape sequence > > >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' > > or use forward slashes as directory separators. Peter, thanks so much for your help, your suggestions were spot on. So now my program runs and is able to find and process the files correctly, but I end up getting the following message: Traceback (most recent call last): File "C:/Documents and Settings/smacdon/My Documents/ excel_merge_files_indirectory v2.py", line 49, in merge_xls(in_dir=r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") File "C:/Documents and Settings/smacdon/My Documents/ excel_merge_files_indirectory v2.py", line 36, in merge_xls merged_book.save(out_file) File "C:\Python27\lib\site-packages\xlwt\Workbook.py", line 634, in save doc.save(filename, self.get_biff_data()) File "C:\Python27\lib\site-packages\xlwt\CompoundDoc.py", line 507, in save f = open(file_name_or_filelike_obj, 'wb') TypeError: file() argument 1 must be encoded string without NULL bytes, not str If I am interpreting correctly, am I to understand that it would appear the issue is tracing back to functions in the xlwt module? If so, what can I do to fix this? Again, any and all help is appreciated! From SMac2347 at comcast.net Thu Feb 9 15:36:45 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Thu, 9 Feb 2012 12:36:45 -0800 (PST) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: On Feb 7, 3:16?pm, Peter Otten <__pete... at web.de> wrote: > SMac2... at comcast.net wrote: > > xls_files ? = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and filename if > necessary. > > > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") > > If you paste the directory name literal into the interactive interpreter > you'll be surprised: > > >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' > > "\09" is intrpreted as chr(9). Use a raw string to prevent Python from > interpreting a backslash as the start of an escape sequence > > >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' > > or use forward slashes as directory separators. Disregard my last post, I was able to figure it out, I also had to cover the out_file file name into a raw string as well. Thanks again for all the help!!! From __peter__ at web.de Thu Feb 9 15:39:00 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 21:39 +0100 Subject: Formate a number with commas References: Message-ID: noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") >>>> locale.format('%d', 2348721, True) > '2,348,721' > > > I'm a perpetual novice, so just looking for better, slicker, more > proper, pythonic ways to do this. >>> import locale >>> locale.setlocale(locale.LC_ALL, "") 'de_DE.UTF-8' >>> "{:n}".format(1234) # locale-aware '1.234' >>> "{:,d}".format(1234) # always a comma '1,234' From clp2 at rebertia.com Thu Feb 9 15:51:58 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 12:51:58 -0800 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: > noydb wrote: > >> How do you format a number to print with commas? >> >> Some quick searching, i came up with: >> >>>>> import locale >>>>> locale.setlocale(locale.LC_ALL, "") >>>>> locale.format('%d', 2348721, True) >> '2,348,721' >> >> >> I'm a perpetual novice, so just looking for better, slicker, more >> proper, pythonic ways to do this. > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") > 'de_DE.UTF-8' >>>> "{:n}".format(1234) # locale-aware > '1.234' >>>> "{:,d}".format(1234) # always a comma > '1,234' The latter requires Python 3.1+ and is courtesy PEP 378 (http://www.python.org/dev/peps/pep-0378/ ). Cheers, Chris From __peter__ at web.de Thu Feb 9 16:07:58 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:07:58 +0100 Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> <10d15214-1fd8-4b80-8384-c0b291c6976d@h3g2000yqe.googlegroups.com> Message-ID: SMac2347 at comcast.net wrote: > On Feb 7, 3:16 pm, Peter Otten <__pete... at web.de> wrote: >> SMac2... at comcast.net wrote: >> > xls_files = glob.glob(in_dir + "*.xls") >> >> Try changing that to >> >> pattern = os.path.join(in_dir, "*.xls") >> xls_files = glob.glob(pattern) >> >> os.path.join() inserts a (back)slash between directory and filename if >> necessary. >> >> > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 >> > Aggregate JWS") >> >> If you paste the directory name literal into the interactive interpreter >> you'll be surprised: >> >> >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" >> >> 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' >> >> "\09" is intrpreted as chr(9). Use a raw string to prevent Python from Sorry, I was wrong here. "\09" is actually "\0" (i. e. chr(0)) followed by "9". Escape sequences starting with 0 are octal numbers in Python 2 and thus may never contain digits > 7. >> interpreting a backslash as the start of an escape sequence >> >> >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" >> >> 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' >> >> or use forward slashes as directory separators. > > Peter, thanks so much for your help, your suggestions were spot on. So > now my program runs and is able to find and process the files > correctly, but I end up getting the following message: > > Traceback (most recent call last): > File "C:/Documents and Settings/smacdon/My Documents/ > excel_merge_files_indirectory v2.py", line 49, in > merge_xls(in_dir=r"C:\Documents and Settings\smacdon\Desktop\09 > Aggregate JWS") > File "C:/Documents and Settings/smacdon/My Documents/ > excel_merge_files_indirectory v2.py", line 36, in merge_xls > merged_book.save(out_file) > File "C:\Python27\lib\site-packages\xlwt\Workbook.py", line 634, in > save > doc.save(filename, self.get_biff_data()) > File "C:\Python27\lib\site-packages\xlwt\CompoundDoc.py", line 507, > in save > f = open(file_name_or_filelike_obj, 'wb') > TypeError: file() argument 1 must be encoded string without NULL > bytes, not str > > > If I am interpreting correctly, am I to understand that it would > appear the issue is tracing back to functions in the xlwt module? If > so, what can I do to fix this? Again, any and all help is appreciated! You probably forgot to convert the default value for out_file into a raw string: def merge_xls(in_dir, out_file= r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS\09_merged_data.xls"): "\0" is therefore interpreted as chr(0) which marks the end of a C string and may not occur in a file name. chr(0) is called "NULL byte" in the error message you get. From ethan at stoneleaf.us Thu Feb 9 16:12:42 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 13:12:42 -0800 Subject: multiple namespaces within a single module? In-Reply-To: References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: <4F3436CA.2020800@stoneleaf.us> Peter Otten wrote: > jkn wrote: > >> is it possible to have multiple namespaces within a single python >> module? > > Unless you are abusing classes I don't think so. Speaking of... class NameSpace(object): def __init__(self, globals): self.globals = globals self.current_keys = list(globals.keys()) def __enter__(self): return self def __exit__(self, *args): new_items = [] for key, value in self.globals.items(): if key not in self.current_keys and value is not self: new_items.append((key, value)) for key, value in new_items: setattr(self, key, value) del self.globals[key] if __name__ == '__main__': with NameSpace(globals()) as a: def function(): print('inside a!') with NameSpace(globals()) as b: def function(): print('inside b!') a.function() b.function() print(vars()) The NameSpace objects do *not* get their own copy of globals(), but for functions, etc., it should work fine. As a bonus the above code works for both 2.x and 3.x. ~Ethan~ From alain at dpt-info.u-strasbg.fr Thu Feb 9 16:13:10 2012 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 09 Feb 2012 22:13:10 +0100 Subject: Formate a number with commas References: Message-ID: <87wr7v1zix.fsf@dpt-info.u-strasbg.fr> noydb writes: > How do you format a number to print with commas? >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") This sets the locale according to the environment (typically LANG---I'm talking about linux, don't know others). >>>> locale.format('%d', 2348721, True) > '2,348,721' This would not give the same result in environments with other locales (typically de or fr or ...) Anyway, it's probably the right thing to do: the user will get numbers written according to its own locale. If you really want commas whatever locale you're running in, you will need to use setlocale to change number formatting to a locale that uses commas. For instance: locale.setlocale(LC_NUMERIC,"en_US.utf8") locale.format('%d', 2348721, True) -- Alain. From __peter__ at web.de Thu Feb 9 16:16:03 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:16:03 +0100 Subject: Formate a number with commas References: Message-ID: Chris Rebert wrote: > On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: >>>>> import locale >>>>> locale.setlocale(locale.LC_ALL, "") >> 'de_DE.UTF-8' >>>>> "{:n}".format(1234) # locale-aware >> '1.234' >>>>> "{:,d}".format(1234) # always a comma >> '1,234' > > The latter requires Python 3.1+ and is courtesy PEP 378 > (http://www.python.org/dev/peps/pep-0378/ ). I actually ran the above session in 2.7, so that should do, too. http://docs.python.org/whatsnew/2.7.html#pep-378-format-specifier-for- thousands-separator From a.france.mailinglists at gmail.com Thu Feb 9 16:41:12 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Thu, 09 Feb 2012 22:41:12 +0100 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <4F343D78.1010800@gmail.com> On 02/09/2012 07:55 PM, Arnaud Delobelle wrote: > > > On Feb 9, 2012 6:00 PM, "sajuptpm" > wrote: > > > > Guide to: Learning Python Decorators > > New Book http://tinyurl.com/python-decorartor > > A whole book about decorators? Cool. I'm going to start writing books > to. I'll start with 'The Python print statement'. Then to be cutting > edge I'll follow with 'The Python print function'. > > -- > Arnaud > > > How many pages is that? The amazon page conveniently left that off. -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 9 16:53:16 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:53:16 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> Message-ID: Ethan Furman wrote: > Peter Otten wrote: >> jkn wrote: >> >>> is it possible to have multiple namespaces within a single python >>> module? >> >> Unless you are abusing classes I don't think so. > > > Speaking of... > > > class NameSpace(object): > def __init__(self, globals): > self.globals = globals > self.current_keys = list(globals.keys()) > def __enter__(self): > return self > def __exit__(self, *args): > new_items = [] > for key, value in self.globals.items(): > if key not in self.current_keys and value is not self: > new_items.append((key, value)) > for key, value in new_items: > setattr(self, key, value) > del self.globals[key] > > if __name__ == '__main__': > with NameSpace(globals()) as a: > def function(): > print('inside a!') > with NameSpace(globals()) as b: > def function(): > print('inside b!') > > a.function() > b.function() > print(vars()) > > > The NameSpace objects do *not* get their own copy of globals(), but for > functions, etc., it should work fine. As a bonus the above code works > for both 2.x and 3.x. Hm, what about with NameSpace(globals()) as a: x = "inside a!" def function(): print(x) with NameSpace(globals()) as b: x = "inside b!" def function(): print(x) x = "inside main!" a.function() b.function() From someone at someplace.invalid Thu Feb 9 16:57:09 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 21:57:09 +0000 (UTC) Subject: Apparent "double imports" References: Message-ID: On Thu, 09 Feb 2012 15:05:52 -0500, Dave Angel wrote: > On 02/09/2012 02:40 PM, HoneyMonster wrote: >> On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: >> >>> On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster >>> wrote: >>>> One issue I have run into, which may or may not be a problem: I am >>>> finding that modules in the in-house "library" package sometimes have >>>> to import modules like sys and os, which are also imported by the >>>> "calling" >>>> module. Is this a problem or an overhead, or does it just result in >>>> two names for the same object? >>> Two names for the same object. When a module is imported, the module >>> object is stored in the sys.modules dict. Further imports of the same >>> module just return the same module object from sys.modules. >> Excellent! It seems it is not a problem at all, then. Thank you. > Just to add a little subtlety, there is a problem with mutually > recursive imports. If module aaa imports module bbb, and modole bbb > imports aaa, there can be some problems. Most can be avoided by putting > the imports right at the beginning of each file, so no work has been > done before doing the imports. Then by the time some code tries to use > them, they're all resolved. One exception is if you try to import the > file that is your script file. This one is made into a module by the > special name of __main__, and if you import it using the original name, > you'll have two copies around. That can lead to some very interesting > anomalies. > > Better is to make sure no loops exist in the importing tree, which is a > desirable structuring goal anyway. When two modules need each other, > try to either move the common stuff to a 3rd module they each import, or > do something with callbacks or other mechanism that reflects what's > really going on. > > Of cours that last paragraph is strictly my own opinion. Thanks, Dave. I'm sure I won't have a problem with circular imports. The structure I have in mind is: A package (say ihlib) consisting of in-house "library" routines for local use. The directory above ihlib will be added to PYTHONPATH, so that imports can find ihlib. "Top level" modules will import ihlib.blah as necessary in order to avoid code duplication amongst them. From clp2 at rebertia.com Thu Feb 9 17:12:35 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 14:12:35 -0800 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 1:16 PM, Peter Otten <__peter__ at web.de> wrote: > Chris Rebert wrote: >> On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: >>>>>> import locale >>>>>> locale.setlocale(locale.LC_ALL, "") >>> 'de_DE.UTF-8' >>>>>> "{:n}".format(1234) # locale-aware >>> '1.234' >>>>>> "{:,d}".format(1234) # always a comma >>> '1,234' >> >> The latter requires Python 3.1+ and is courtesy PEP 378 >> (http://www.python.org/dev/peps/pep-0378/ ). > > I actually ran the above session in 2.7, so that should do, too. > > http://docs.python.org/whatsnew/2.7.html#pep-378-format-specifier-for- > thousands-separator Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it was added in 3.1 (Guido's backporting time machine messes with "causality"). Both statements are completely technically correct, but misleading when not taken together. Cheers, Chris From ethan at stoneleaf.us Thu Feb 9 17:25:46 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 14:25:46 -0800 Subject: multiple namespaces within a single module? In-Reply-To: References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> Message-ID: <4F3447EA.6070601@stoneleaf.us> Peter Otten wrote: > Hm, what about > > with NameSpace(globals()) as a: > x = "inside a!" > def function(): > print(x) > with NameSpace(globals()) as b: > x = "inside b!" > def function(): > print(x) > > x = "inside main!" > a.function() > b.function() > > It would have to be `a.x = ...` and `b.x = ...` with corresponding `print(a.x)` and `print(b.x)`. Hrm -- and functions/classes/etc would have to refer to each other that way as well inside the namespace... not sure I'm in love with that... ~Ethan~ From hobson42 at gmail.com Thu Feb 9 17:43:09 2012 From: hobson42 at gmail.com (Ian) Date: Thu, 09 Feb 2012 22:43:09 +0000 Subject: Guide to: Learning Python Decorators In-Reply-To: <4F343D78.1010800@gmail.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> Message-ID: <4F344BFD.9050200@gmail.com> On 09/02/2012 21:41, Aaron France wrote: > How many pages is that? The amazon page conveniently left that off. There is an average of 5.1 chars per word in English, and usually about 350 words an A4 page. The 215K file is a) Compressed - typically by 60% b) Contains simple html and images as its source. c) Must contain the cover image. As a *very* rough guess, that means the files expands to 344K. Remove the cover image at 250-300kb leaves 44 to 94KB That is 8700 words to 18400 words or approx 25 to 50 pages. But that is *very* *very* rough. Regards Ian From jjposner at optimum.net Thu Feb 9 17:57:42 2012 From: jjposner at optimum.net (John Posner) Date: Thu, 09 Feb 2012 17:57:42 -0500 Subject: Formate a number with commas In-Reply-To: References: Message-ID: <4F344F66.7040206@optimum.net> On 2:59 PM, noydb wrote: > How do you format a number to print with commas? I would readily admit that both the "locale" module and "format" method are preferable to this regular expression, which certainly violates the "readability counts" dictum: r"(?<=\d)(?=(\d\d\d)+$)" # python 2.6.6 import re find_blocks = re.compile(r"(?<=\d)(?=(\d\d\d)+$)") for numstr in "1 12 123 1234 12345 123456 1234567 12345678".split(): print find_blocks.sub("," , numstr) output is: 1 12 123 1,234 12,345 123,456 1,234,567 12,345,678 -John From hobson42 at gmail.com Thu Feb 9 18:09:07 2012 From: hobson42 at gmail.com (Ian) Date: Thu, 09 Feb 2012 23:09:07 +0000 Subject: Want to improve my code. Message-ID: <4F345213.8060807@gmail.com> Hi all, I'm using lxml etree, and have written a routine to remove nodes in the parsed tree. Typically, I load html, and remove tags, so I am moving the font tags children up and moving the text and tail data about. The code of the deleteElem routine is here http://snipt.org/GSoo0 It troubles me that there is so much repetition in the lines that call joiner. How can I improve the code? Regards Ian From jkn_gg at nicorp.f9.co.uk Thu Feb 9 18:24:58 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Thu, 9 Feb 2012 15:24:58 -0800 (PST) Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Hi Peter On Feb 9, 7:33?pm, Peter Otten <__pete... at web.de> wrote: > jkn wrote: > > ? ? is it possible to have multiple namespaces within a single python > > module? > > Unless you are abusing classes I don't think so. > > > I have a small app which is in three or four .py files. For various > > reasons I would like to (perhaps optionally) combine these into one > > file. > > Rename your main script into __main__.py, put it into a zip file together > with the other modules and run that. Hmm ... thanks for mentioning this feature, I didn't know of it before. Sounds great, except that I gather it needs Python >2.5? I'm stuck with v2.4 at the moment unfortunately... J^n From ethan at stoneleaf.us Thu Feb 9 19:05:41 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 16:05:41 -0800 Subject: multiple namespaces within a single module? In-Reply-To: <4F3447EA.6070601@stoneleaf.us> References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> <4F3447EA.6070601@stoneleaf.us> Message-ID: <4F345F55.8050300@stoneleaf.us> Ethan Furman wrote: > Hrm -- and functions/classes/etc would have to refer to each other that > way as well inside the namespace... not sure I'm in love with that... Not sure I hate it, either. ;) Slightly more sophisticated code: class NameSpace(object): def __init__(self, current_globals): self.globals = current_globals self.saved_globals = current_globals.copy() def __enter__(self): return self def __exit__(self, *args): new_items = [] for key, value in self.globals.items(): if (key not in self.saved_globals and value is not self or key in self.saved_globals and value != self.saved_globals[key]): new_items.append((key, value)) for key, value in new_items: setattr(self, key, value) del self.globals[key] self.globals.update(self.saved_globals) if __name__ == '__main__': x = 'inside main!' with NameSpace(globals()) as a: x = 'inside a?' def fn1(): print(a.x) with NameSpace(globals()) as b: x = 'inside b?' def fn1(): print(b.x) def fn2(): print('hello!') b.fn1() y = 'still inside main' a.fn1() b.fn1() print(x) print(y) ~Ethan~ From jenn.duerr at gmail.com Thu Feb 9 19:30:53 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 16:30:53 -0800 (PST) Subject: round down to nearest number Message-ID: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> How do you round down ALWAYS to nearest 100? Like, if I have number 3268, I want that rounded down to 3200. I'm doing my rounding like >>> round(3268, -2) But, how to round DOWN? From ian.g.kelly at gmail.com Thu Feb 9 19:47:09 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 17:47:09 -0700 Subject: round down to nearest number In-Reply-To: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:30 PM, noydb wrote: > How do you round down ALWAYS to nearest 100? ?Like, if I have number > 3268, I want that rounded down to 3200. ?I'm doing my rounding like >>>> round(3268, -2) > But, how to round DOWN? >>> 3268 // 100 * 100 3200 For more complicated cases, Decimal objects allow you to specify alternate rounding modes. From steve+comp.lang.python at pearwood.info Thu Feb 9 20:04:41 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 01:04:41 GMT Subject: Read-only attribute in module References: <878vkc426c.fsf@benfinney.id.au> Message-ID: <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 23:32:59 +1100, Ben Finney wrote: > Mateusz Loskot writes: > >> I'm wondering, is there any mean to implement attribute in module scope >> which is read-only? > > Python is designed by and for consenting adults. Rather than > restricting, instead use conventions to make your intent clear to the > user of your library. Oh I agree. The convention I want to use to make my intent clear is the same convention used for the rest of Python: a runtime exception. I find this "consenting adults" argument less than convincing. We already have constants in Python -- every int and float and string is a constant. You can't modify the object 1 to have the value 42, and for very good reason, "consenting adults" be damned. What we don't have is *named* constants. Python has no shortage of read-only values and members, e.g.: >>> class A(object): ... pass ... >>> A.__dict__ = {} Traceback (most recent call last): File "", line 1, in AttributeError: attribute '__dict__' of 'type' objects is not writable Consider this: If you pass an int to len(), you get a runtime error telling you that you did something wrong. Does this violate "consenting adults"? No, if you want to, you can monkey-patch len to accept ints, but you have to work at it. The normal behaviour is to get an error, not some arbitrary but meaningless behaviour. You certainly don't get told to use a naming convention (Hungarian notation, perhaps) to avoid passing the wrong value to len(). If you assign to something which is intended to be constant, you don't get an exception telling you that you made a mistake. Instead, you get unspecified (but almost certainly incorrect) behaviour in the module, and told to use a naming convention to remind you not to screw up. The excuse given is that Python is for "consenting adults", but I don't believe it. I believe that the real reason is that it is hard to introduce named constants to Python, and rather than solve that hard problem, people just whitewash the issue and pretend that it's a feature. It's not a feature, it's a wart. There is no conceivable use-case for allowing math.pi = 2.5 to succeed. Python happily violates "consenting adults" all over the place. We have properties, which can easily create read-only and write-once attributes. We have descriptors which can be used for the same. We have immutable types, and constant values, but not constant names. Python can enforce all common software contracts I can think of, except the contract that a name will be set to a specific value. And that is, in my opinion, a weakness in Python. -- Steven From jenn.duerr at gmail.com Thu Feb 9 20:23:46 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 17:23:46 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: hmmm, okay. So how would you round UP always? Say the number is 3219, so you want 3300 returned. From steve+comp.lang.python at pearwood.info Thu Feb 9 20:24:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 01:24:57 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee. It will hold for > current versions of CPython but not necessarily for other Python > implementations. That day may be sooner than you think. It is very likely that in Python 3.3, dict order will be randomized on creation as a side-effect of adding a random salt to hashes to prevent a serious vulnerability in dicts. http://securitytracker.com/id/1026478 http://bugs.python.org/issue13703 If there is anyone still assuming that dicts have a predictable order, they're going to be in for a nasty surprise one of these days. -- Steven From ckaynor at zindagigames.com Thu Feb 9 20:40:12 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 9 Feb 2012 17:40:12 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always? Say the number is 3219, so you want > 3300 returned. > You may want to look into the mathematical floor and ceiling functions[1]. Python exposes them in the math module as floor and ceil[2]. [1] http://en.wikipedia.org/wiki/Floor_and_ceiling_functions [2] http://docs.python.org/library/math.html#math.floor and http://docs.python.org/library/math.html#math.ceil > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Thu Feb 9 20:41:51 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 9 Feb 2012 17:41:51 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:40 PM, Chris Kaynor wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > >> hmmm, okay. >> >> So how would you round UP always? Say the number is 3219, so you want >> 3300 returned. >> > > You may want to look into the mathematical floor and ceiling functions[1]. > Python exposes them in the math module as floor and ceil[2]. > > [1] http://en.wikipedia.org/wiki/Floor_and_ceiling_functions > [2] http://docs.python.org/library/math.html#math.floor and > http://docs.python.org/library/math.html#math.ceil > > I should have added, you can use multiplication and division to apply those functions to other digits rather than the base one. For example, multiply by 10, floor, divide by ten, will floor to one decimal point. > -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Feb 9 20:43:58 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 17:43:58 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always? ?Say the number is 3219, so you want > 3300 returned. http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 Thus: (3219 + 99) // 100 Slight tangent: Beware negative numbers when using // or %. Cheers, Chris From ian.g.kelly at gmail.com Thu Feb 9 21:00:37 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 19:00:37 -0700 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 6:43 PM, Chris Rebert wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: >> hmmm, okay. >> >> So how would you round UP always? ?Say the number is 3219, so you want >> 3300 returned. > > http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 > > Thus: (3219 + 99) // 100 > > Slight tangent: Beware negative numbers when using // or %. There's no problem with negative numbers here, as long as you actually want to round *up* or *down*, as opposed to away from zero or toward zero. From jenn.duerr at gmail.com Thu Feb 9 21:25:56 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 18:25:56 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: That {>>> (3219 + 99) // 100} doesnt work if the number is other then 4 digits. (for rounding up to nearest 100): >>> (3219 + 99)//100 33 >>> (3289 + 99)//100 33 >>> (328678 + 99)//100 3287 >>> (328 + 99)//100 4 From nathan.alexander.rice at gmail.com Thu Feb 9 21:30:46 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 21:30:46 -0500 Subject: frozendict In-Reply-To: <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 8:24 PM, Steven D'Aprano wrote: > On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice >> wrote: >>> As I said, two dictionaries created from the same input will be the >>> same... >> >> That's an implementation detail, not a guarantee. ?It will hold for >> current versions of CPython but not necessarily for other Python >> implementations. > > That day may be sooner than you think. It is very likely that in Python > 3.3, dict order will be randomized on creation as a side-effect of adding > a random salt to hashes to prevent a serious vulnerability in dicts. > > http://securitytracker.com/id/1026478 > > http://bugs.python.org/issue13703 > > > If there is anyone still assuming that dicts have a predictable order, > they're going to be in for a nasty surprise one of these days. The only thing needed to avoid the hash collision is that your hash function is not not 100% predictable just by looking at the python source code. I don't see why every dict would have to be created differently. I would think having the most ubiquitous data structure in your language be more predictable would be a priority. Oh well.... Nathan From tjreedy at udel.edu Thu Feb 9 22:06:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:06:02 -0500 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On 2/9/2012 5:12 PM, Chris Rebert wrote: > Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it > was added in 3.1 (Guido's backporting time machine messes with > "causality"). Python 2 docs refer to Python 2. Python 3 docs refer to Python 3. So 'it' was in neither 2.6 nor 3.1. > Both statements are completely technically correct, but misleading > when not taken together. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:22:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:22:44 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: <4F344BFD.9050200@gmail.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> <4F344BFD.9050200@gmail.com> Message-ID: On 2/9/2012 5:43 PM, Ian wrote: > On 09/02/2012 21:41, Aaron France wrote: >> How many pages is that? The amazon page conveniently left that off. > There is an average of 5.1 chars per word in English, and usually about > 350 words an A4 page. > > The 215K file is > a) Compressed - typically by 60% > b) Contains simple html and images as its source. > c) Must contain the cover image. > > As a *very* rough guess, that means the files expands to 344K. > Remove the cover image at 250-300kb leaves 44 to 94KB > That is 8700 words to 18400 words or approx 25 to 50 pages. > But that is *very* *very* rough. The file is about 500 'locations'. The Kindle Users Guide, 3rd Ed., has 1300, Lao Tza, the Art of War, (project Gutenberg), aaabut 2100. I read about half in an hour. Even knowing the material, it is slower than a novel. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:27:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:27:50 -0500 Subject: Read-only attribute in module In-Reply-To: <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > Python happily violates "consenting adults" all over the place. We have > properties, which can easily create read-only and write-once attributes. So propose that propery() work at module level, for module attributes, as well as for class attributes. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:29:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:29:05 -0500 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On 2/9/2012 8:23 PM, noydb wrote: > So how would you round UP always? Say the number is 3219, so you want >>> (3333//100+1)*100 3400 -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:33:16 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:33:16 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/9/2012 9:30 PM, Nathan Rice wrote: >> That day may be sooner than you think. It is very likely that in Python >> 3.3, dict order will be randomized on creation as a side-effect of adding >> a random salt to hashes to prevent a serious vulnerability in dicts. >> >> http://securitytracker.com/id/1026478 >> >> http://bugs.python.org/issue13703 >> >> >> If there is anyone still assuming that dicts have a predictable order, >> they're going to be in for a nasty surprise one of these days. > > The only thing needed to avoid the hash collision is that your hash > function is not not 100% predictable just by looking at the python > source code. I don't see why every dict would have to be created > differently. I would think having the most ubiquitous data structure > in your language be more predictable would be a priority. Oh well.... I believe 'on creation' means 'on process startup', not on dict creation. There have, however, been several variants suggested, and the focus has been on choosing one first for past and current versions. 3.3 is about 6 months off and hash for it may still be debated. -- Terry Jan Reedy From python at mrabarnett.plus.com Thu Feb 9 22:36:11 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 03:36:11 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <4F3490AB.7080701@mrabarnett.plus.com> On 10/02/2012 02:25, noydb wrote: > That {>>> (3219 + 99) // 100} doesnt work if the number is other then > 4 digits. > > > (for rounding up to nearest 100): >>>> (3219 + 99)//100 > 33 >>>> (3289 + 99)//100 > 33 >>>> (328678 + 99)//100 > 3287 >>>> (328 + 99)//100 > 4 >>> (3219 + 99) // 100 * 100 3300 >>> (3289 + 99) // 100 * 100 3300 >>> (328678 + 99) // 100 * 100 328700 >>> (328 + 99) // 100 * 100 400 Those are all rounded up to the nearest 100 correctly. From python at mrabarnett.plus.com Thu Feb 9 22:39:08 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 03:39:08 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <4F34915C.3080007@mrabarnett.plus.com> On 10/02/2012 03:29, Terry Reedy wrote: > On 2/9/2012 8:23 PM, noydb wrote: >> So how would you round UP always? Say the number is 3219, so you want > >>> (3333//100+1)*100 > 3400 > Doing it that way doesn't always work. For example: >>> (3400 // 100 + 1) * 100 3500 However: >>> (3400 + 99) // 100 * 100 3400 From hitlarmamu at gmail.com Fri Feb 10 01:13:10 2012 From: hitlarmamu at gmail.com (Hitlar mamu) Date: Thu, 9 Feb 2012 22:13:10 -0800 (PST) Subject: mega soft info systems Message-ID: mega soft info systems available here http://win-con.blogspot.in/ From sajuptpm at gmail.com Fri Feb 10 01:20:57 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Thu, 9 Feb 2012 22:20:57 -0800 (PST) Subject: Guide to: Learning Python Decorators References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> <4F344BFD.9050200@gmail.com> Message-ID: Hi, Thanks for replay, I am looking for PDF version of same book. Please share if you can. http://www.amazon.com/gp/product/B006ZHJSIM/ref=as_li_tf_tl?ie=UTF8&tag=8012-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B006ZHJSIM From ian.g.kelly at gmail.com Fri Feb 10 01:21:31 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 23:21:31 -0700 Subject: round down to nearest number In-Reply-To: <4F3490AB.7080701@mrabarnett.plus.com> References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On Thu, Feb 9, 2012 at 8:36 PM, MRAB wrote: > On 10/02/2012 02:25, noydb wrote: >> >> That {>>> ?(3219 + 99) // 100} doesnt work if the number is other then >> 4 digits. >> >> >> (for rounding up to nearest 100): >>>>> >>>>> ?(3219 + 99)//100 >> >> 33 >>>>> >>>>> ?(3289 + 99)//100 >> >> 33 >>>>> >>>>> ?(328678 + 99)//100 >> >> 3287 >>>>> >>>>> ?(328 + 99)//100 >> >> 4 > > >>>> (3219 + 99) // 100 * 100 > 3300 >>>> (3289 + 99) // 100 * 100 > 3300 >>>> (328678 + 99) // 100 * 100 > 328700 >>>> (328 + 99) // 100 * 100 > 400 > > Those are all rounded up to the nearest 100 correctly. One thing to be aware of though is that while the "round down" formula works interchangeably for ints and floats, the "round up" formula does not. >>> (3300.5 + 99) // 100 * 100 3300.0 A more consistent alternative is to negate the number, round down, and then negate again. >>> -(-(3300.5) // 100 * 100) 3400.0 Cheers, Ian From nagle at animats.com Fri Feb 10 01:26:04 2012 From: nagle at animats.com (John Nagle) Date: Thu, 09 Feb 2012 22:26:04 -0800 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <4f34b876$0$12004$742ec2ed@news.sonic.net> On 2/3/2012 4:27 PM, Antti J Ylikoski wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: Most dynamic languages have closures. Even Perl and Javascript have closures. Javascript really needs them, because the "callback" orientation of Javascript means you often need to package up state and pass it into a callback. It really has very little to do with functional programming. If you want to see a different style of closure, check out Rust, Mozilla's new language. Rust doesn't have the "spaghetti stack" needed to implement closures, so it has more limited closure semantics. It's more like some of the C add-ons for closures, but sounder. John Nagle From anonhung at gmail.com Fri Feb 10 01:32:09 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:32:09 +0100 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: >> Guide to: Learning Python Decorators >> New Book http://tinyurl.com/python-decorartor > > A whole book about decorators? Cool. I'm going to start writing books to. > I'll start with 'The Python print statement'. Then to be cutting edge I'll > follow with 'The Python print function'. How about 'Tips and tricks about python loops'? :) -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Fri Feb 10 01:35:17 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:35:17 +0100 Subject: ANN: eGenix mxODBC Zope Database Adapter 2.0.2 In-Reply-To: <4F33E36B.40001@egenix.com> References: <4F33E36B.40001@egenix.com> Message-ID: Thanks a bunch for the whole team! Best, anonhung On 2/9/12, eGenix Team: M.-A. Lemburg wrote: > ________________________________________________________________________ > ANNOUNCEMENT > > mxODBC Zope Database Adapter > > Version 2.0.2 > > for Zope and the Plone CMS > > Available for Zope 2.10 and later on > Windows, Linux, Mac OS X, FreeBSD and other platforms > > This announcement is also available on our web-site for online reading: > http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.0.2-GA.html > > ________________________________________________________________________ > INTRODUCTION > > The eGenix mxODBC Zope Database Adapter allows you to easily connect > your Zope or Plone installation to just about any database backend on > the market today, giving you the reliability of the commercially > supported eGenix product mxODBC and the flexibility of the ODBC > standard as middle-tier architecture. > > The mxODBC Zope Database Adapter is highly portable, just like Zope > itself and provides a high performance interface to all your ODBC data > sources, using a single well-supported interface on Windows, Linux, > Mac OS X, FreeBSD and other platforms. > > This makes it ideal for deployment in ZEO Clusters and Zope hosting > environments where stability and high performance are a top priority, > establishing an excellent basis and scalable solution for your Plone > CMS. > > Product page: > > http://www.egenix.com/products/zope/mxODBCZopeDA/ > > ________________________________________________________________________ > NEWS > > We are pleased to announce a new version 2.0.2 of our mxODBC Zope DA > product. > > With the patch level 2.0.2 release we have updated the integrated > mxODBC Python Extension to the latest 3.1.1 release, which > includes a number of important workarounds for these ODBC drivers: > > * Oracle 10gR1 and 10gR2 > * Oracle 11gR1 and 11gR2 > * Teradata 13 > * Netezza > > Due to popular demand, we have also added instructions on how to > install mxODBC Zope DA 2.0 with Plone 4.1 and Zope 2.13 - even though > this combination is not officially supported by the mxODBC Zope DA 2.0 > series: > > http://www.egenix.com/products/zope/mxODBCZopeDA/#Installation > > ________________________________________________________________________ > UPGRADING > > Licenses purchased for version 2.0.x of the mxODBC Zope DA will continue > to work with the 2.0.2 patch level release. > > Licenses purchased for version 1.0.x of the mxODBC Zope DA will not > work with version 2.0. More information about available licenses > is available on the product page: > > http://www.egenix.com/products/zope/mxODBCZopeDA/#Licensing > > Compared to the popular mxODBC Zope DA 1.0, version 2.0 offers > these enhancements: > > * Includes mxODBC 3.1 with updated support for many current ODBC > drivers, giving you more portability and features for a wider > range of database backends. > > * Mac OS X 10.6 (Snow Leopard) support. > > * Plone 3.2, 3.3, 4.0 support. Plone 4.1 works as well. > > * Zope 2.10, 2.11, 2.12 support. Zope 2.13 works as well. > > * Python 2.4 - 2.6 support. > > * Zero maintenance support to automatically reconnect the > Zope connection after a network or database problem. > > * More flexible Unicode support with options to work with > pure Unicode, plain strings or mixed setups - even for > databases that don't support Unicode > > * Automatic and transparent text encoding and decoding > > * More flexible date/time support including options to work > with Python datetime objects, mxDateTime, strings or tuples > > * New decimal support to have the Zope DA return decimal > column values using Python's decimal objects. > > * Fully eggified to simplify easy_install and zc.buildout based > installation > > ________________________________________________________________________ > MORE INFORMATION > > For more information on the mxODBC Zope Database Adapter, licensing > and download instructions, please visit our web-site: > > http://www.egenix.com/products/zope/mxODBCZopeDA/ > > You can buy mxODBC Zope DA licenses online from the eGenix.com shop at: > > http://shop.egenix.com/ > > ________________________________________________________________________ > > Thank you, > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Feb 09 2012) >>>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > > ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: > > > eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 > D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg > Registered at Amtsgericht Duesseldorf: HRB 46611 > http://www.egenix.com/company/contact/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Fri Feb 10 01:38:43 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:38:43 +0100 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. The freezing temperature of typical dicts is around - 10 Celsius. HTH, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From dihedral88888 at googlemail.com Fri Feb 10 02:55:23 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 9 Feb 2012 23:55:23 -0800 (PST) Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <14449658.339.1328860523539.JavaMail.geo-discussion-forums@prly15> ? 2012?2?4????UTC+8??8?27?56??Antti J Ylikoski??? > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: > > ------------------------------------- > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > > ------------------------------------- > > and now we can do: > > ------------------------------------- > > >>> > >>> a=f1() > >>> b=f1() > >>> a() > 1 > >>> a() > 2 > >>> a() > 3 > >>> a() > 4 > >>> b() > 1 > >>> b() > 2 > >>> a() > 5 > >>> b() > 3 > >>> b() > 4 > >>> > > ------------------------------------- > > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. > > yours, Antti J Ylikoski > Helsinki, Finland, the EU We are not in the 1990's now. A descent CAD or internet application now should be able to support users with at least one or more script languages easily. Whether it's javascript or java or flash in the browser-based applications, or go, python in the google desktop API, commercial SW applications to be able to evolve in the long run are not jobs from the publishers and the original writers of the SW packages only. I don't want to include a big fat compiler in my software, what else can I do ? LISP is too fat, too. From dllizheng at gmail.com Fri Feb 10 02:57:26 2012 From: dllizheng at gmail.com (Zheng Li) Date: Fri, 10 Feb 2012 16:57:26 +0900 Subject: what is the difference between @property and method In-Reply-To: <4F33E806.8070700@optimum.net> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> <4F33E806.8070700@optimum.net> Message-ID: <13BD6C0A-27B5-4D2D-8E2B-FA84FBAA4CB2@gmail.com> Thank you On 2012/02/10, at 0:36, John Posner wrote: > On 2:59 PM, Devin Jeanpierre wrote: > > >> It is kind of funny that the docs don't ever explicitly say what a >> property is. http://docs.python.org/library/functions.html#property -- >> Devin > > Here's a writeup that does: > http://wiki.python.org/moin/AlternativeDescriptionOfProperty > > -John > From dihedral88888 at googlemail.com Fri Feb 10 03:11:13 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 10 Feb 2012 00:11:13 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> I prefer to decorate a function not a method. I prefer to decorate an object to own a new method from the existed ones inherited in all the class levels. I do not decorate a class if not necessary. I believe this is more pythonic to add functionalities to objects in classes by aggregated scripts that use similar modules over a period of time. From arnodel at gmail.com Fri Feb 10 04:58:35 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 09:58:35 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On 10 February 2012 06:21, Ian Kelly wrote: >>>>> (3219 + 99) // 100 * 100 >> 3300 >>>>> (3289 + 99) // 100 * 100 >> 3300 >>>>> (328678 + 99) // 100 * 100 >> 328700 >>>>> (328 + 99) // 100 * 100 >> 400 >> >> Those are all rounded up to the nearest 100 correctly. > > One thing to be aware of though is that while the "round down" formula > works interchangeably for ints and floats, the "round up" formula does > not. > >>>> (3300.5 + 99) // 100 * 100 > 3300.0 > I'm surprised I haven't seen: >>> 212 - (212 % -100) 300 Here's a function that: * rounds up and down * works for both integers and floats * is only two operations (as opposed to 3 in the solutions given above) >>> def round(n, k): ... return n - n%k ... >>> # Round down with a positive k: ... round(167, 100) 100 >>> round(-233, 100 ... ) -300 >>> # Round up with a negative k: ... round(167, -100) 200 >>> round(-233, -100) -200 >>> # Edge cases ... round(500, -100) 500 >>> round(500, 100) 500 >>> # Floats ... round(100.5, -100) 200.0 >>> round(199.5, 100) 100.0 -- Arnaud From rosuav at gmail.com Fri Feb 10 05:08:04 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Feb 2012 21:08:04 +1100 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice wrote: > The only thing needed to avoid the hash collision is that your hash > function is not not 100% predictable just by looking at the python > source code. ?I don't see why every dict would have to be created > differently. ?I would think having the most ubiquitous data structure > in your language be more predictable would be a priority. ?Oh well.... It's perfectly predictable. If you put a series of keys into it, you get those same keys back. Nobody ever promised anything about order. If your hash function is not 100% predictable, that means it varies on the basis of something that isn't part of either the Python interpreter or the script being run. That means that, from one execution to another of the exact same code, the results could be different. The keys will come out in different orders. ChrisA From arnodel at gmail.com Fri Feb 10 05:09:24 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:09:24 +0000 Subject: Read-only attribute in module In-Reply-To: References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 10 February 2012 03:27, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once attributes. > > > So propose that propery() work at module level, for module attributes, as > well as for class attributes. I think Steven would like something else: bare names that cannot be rebound. E.g. something like: >>> const a = 42 >>> a = 7 Would raise an exception. Is that right? -- Arnaud From python at borja.fagorederlan.es Fri Feb 10 05:10:59 2012 From: python at borja.fagorederlan.es (sisifus) Date: Fri, 10 Feb 2012 11:10:59 +0100 Subject: Any idea for build code bars??? Message-ID: Hello all, I new in python but i want to practice very much. In interesting in build an application which read a text file, translate the information in 128 bar code format and print all the information in a printer. File text content: 123456 123456 Where each line mean: 1? --> Print in text format (Ej: 123456) 2? --> Print in bar code format (Ej: |||||||||||) With this information my script hast to build a documento (pdf, html, etc) and send it to the printer. Can any one say me what python modules i could use? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Fri Feb 10 05:28:27 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Feb 2012 10:28:27 +0000 Subject: Any idea for build code bars??? In-Reply-To: References: Message-ID: On 10/02/2012 10:10, sisifus wrote: > Hello all, > > I new in python but i want to practice very much. > > In interesting in build an application which read a text file, translate > the information in 128 bar code format and print all the information in a > printer. > > File text content: > 123456 > 123456 > > Where each line mean: > 1? --> Print in text format (Ej: 123456) > 2? --> Print in bar code format (Ej: |||||||||||) > > With this information my script hast to build a documento (pdf, html, etc) > and send it to the printer. > > Can any one say me what python modules i could use? > > > Regards > Studying this should give you some ideas. http://pypi.python.org/pypi/pyBarcode -- Cheers. Mark Lawrence. From arnodel at gmail.com Fri Feb 10 05:41:06 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:41:06 +0000 Subject: multiple namespaces within a single module? In-Reply-To: <4F345F55.8050300@stoneleaf.us> References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> <4F3447EA.6070601@stoneleaf.us> <4F345F55.8050300@stoneleaf.us> Message-ID: On 10 February 2012 00:05, Ethan Furman wrote: > Ethan Furman wrote: >> >> Hrm -- and functions/classes/etc would have to refer to each other that >> way as well inside the namespace... not sure I'm in love with that... > > > > Not sure I hate it, either. ?;) > > Slightly more sophisticated code: > > > class NameSpace(object): > ? ?def __init__(self, current_globals): > ? ? ? ?self.globals = current_globals > ? ? ? ?self.saved_globals = current_globals.copy() > > ? ?def __enter__(self): > ? ? ? ?return self > ? ?def __exit__(self, *args): > ? ? ? ?new_items = [] > ? ? ? ?for key, value in self.globals.items(): > ? ? ? ? ? ?if (key not in self.saved_globals and value is not self > ? ? ? ? ? ? ? ? ? ?or key in self.saved_globals > ? ? ? ? ? ? ? ? ? ?and value != self.saved_globals[key]): > > ? ? ? ? ? ? ? ?new_items.append((key, value)) > ? ? ? ?for key, value in new_items: > ? ? ? ? ? ?setattr(self, key, value) > ? ? ? ? ? ?del self.globals[key] > ? ? ? ?self.globals.update(self.saved_globals) > > if __name__ == '__main__': > ? ?x = 'inside main!' > ? ?with NameSpace(globals()) as a: > ? ? ? ?x = 'inside a?' > ? ? ? ?def fn1(): > ? ? ? ? ? ?print(a.x) > ? ?with NameSpace(globals()) as b: > ? ? ? ?x = 'inside b?' > ? ? ? ?def fn1(): > ? ? ? ? ? ?print(b.x) > ? ? ? ?def fn2(): > ? ? ? ? ? ?print('hello!') > ? ? ? ? ? ?b.fn1() > ? ?y = 'still inside main' > ? ?a.fn1() > ? ?b.fn1() > ? ?print(x) > ? ?print(y) > Please! Metaclasses are the obvious way to proceed here :) Then there is no need for the 'a.x' and 'b.x' cruft. marigold:junk arno$ cat namespace.py function = type(lambda:0) def change_globals(f, g): return function(f.__code__, g, f.__name__, f.__defaults__, f.__closure__) class MetaNamespace(type): def __new__(self, name, bases, attrs): attrs['__builtins__'] = __builtins__ for name, value in attrs.items(): if isinstance(value, function): attrs[name] = change_globals(value, attrs) return type.__new__(self, name, bases, attrs) class Namespace(metaclass=MetaNamespace): pass x = "inside main" class a(Namespace): x = "inside a" def fn1(): print(x) class b(Namespace): x = "inside b" def fn1(): print(x) def fn2(): print("hello") fn1() y = "inside main" a.fn1() b.fn1() b.fn2() print(x) print(y) marigold:junk arno$ python3 namespace.py inside a inside b hello inside b inside main inside main A bit more work would be needed to support nested functions and closures... -- Arnaud From arnodel at gmail.com Fri Feb 10 05:46:41 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:46:41 +0000 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: Message-ID: On 8 February 2012 01:48, Lei Cheng wrote: > Hi all, > > ? ?In a py file, when to use import statements in the header, when to use > import statements in the blocks where they are used? > ? ?What are the best practices? > ? ?Thanks! Aside from other answers: in some rare cases, importing within a function can avoid circularity problems (e.g. A imports B which tries itself to import A) -- Arnaud From alec.taylor6 at gmail.com Fri Feb 10 06:05:39 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Fri, 10 Feb 2012 22:05:39 +1100 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: o.O Very nice On Fri, Feb 10, 2012 at 8:58 PM, Arnaud Delobelle wrote: > On 10 February 2012 06:21, Ian Kelly wrote: >>>>>> (3219 + 99) // 100 * 100 >>> 3300 >>>>>> (3289 + 99) // 100 * 100 >>> 3300 >>>>>> (328678 + 99) // 100 * 100 >>> 328700 >>>>>> (328 + 99) // 100 * 100 >>> 400 >>> >>> Those are all rounded up to the nearest 100 correctly. >> >> One thing to be aware of though is that while the "round down" formula >> works interchangeably for ints and floats, the "round up" formula does >> not. >> >>>>> (3300.5 + 99) // 100 * 100 >> 3300.0 >> > > I'm surprised I haven't seen: > >>>> 212 - (212 % -100) > 300 > > Here's a function that: > * rounds up and down > * works for both integers and floats > * is only two operations (as opposed to 3 in the solutions given above) > >>>> def round(n, k): > ... ? ? return n - n%k > ... >>>> # Round down with a positive k: > ... round(167, 100) > 100 >>>> round(-233, 100 > ... ) > -300 >>>> # Round up with a negative k: > ... round(167, -100) > 200 >>>> round(-233, -100) > -200 >>>> # Edge cases > ... round(500, -100) > 500 >>>> round(500, 100) > 500 >>>> # Floats > ... round(100.5, -100) > 200.0 >>>> round(199.5, 100) > 100.0 > > -- > Arnaud > -- > http://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Fri Feb 10 06:10:33 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 12:10:33 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Message-ID: jkn wrote: > Hi Peter > > On Feb 9, 7:33 pm, Peter Otten <__pete... at web.de> wrote: >> jkn wrote: >> > is it possible to have multiple namespaces within a single python >> > module? >> >> Unless you are abusing classes I don't think so. >> >> > I have a small app which is in three or four .py files. For various >> > reasons I would like to (perhaps optionally) combine these into one >> > file. >> >> Rename your main script into __main__.py, put it into a zip file together >> with the other modules and run that. > > Hmm ... thanks for mentioning this feature, I didn't know of it > before. Sounds great, except that I gather it needs Python >2.5? I'm > stuck with v2.4 at the moment unfortunately... You can import and run explicitly, $ PYTHONPATH mylib.zip python -c'import mainmod; mainmod.main()' assuming you have a module mainmod.py containing a function main() in mylib.zip. From mateusz at loskot.net Fri Feb 10 06:11:52 2012 From: mateusz at loskot.net (mloskot) Date: Fri, 10 Feb 2012 03:11:52 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: References: Message-ID: <1328872312611-4382967.post@n6.nabble.com> Terry Reedy wrote > > On 2/9/2012 6:43 AM, Mateusz Loskot wrote: >> import xyz print(xyz.flag) # OK >> xyz.flag = 0 # error due to no write access > > Why prevent that? If you called it 'FLAG', that would indicate that it > is a constant that should not be changed. While Python make some effort > to prevent bugs, it is generally a 'consenting adults' language. > Terry, The intent of xyz.flag is that it is a value set by the module internally. xyz is a module wrapping a C library. The C library defines concept of a global flag set by the C functions at some events, so user can check value of this flag. I can provide access to it with function: xyz.get_flag() But, I thought it would be more convenient to have a read-only property in scope of the module. Sometimes, especially when wrapping C code, it is not possible to map C API semantics to Python concepts as 1:1. ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4382967.html Sent from the Python - python-list mailing list archive at Nabble.com. From sajuptpm at gmail.com Fri Feb 10 07:30:27 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 04:30:27 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. Message-ID: Hi, I want to log time taken to complete database requests inside a method/ function using decorator . is it possible ???? I think, i have to inject log code inside the method/fuctions or modify it. I wrote a decorator to log taken by a method/function to complete it execution and its working well. My requirement : log everything and figure out what bits are slow and optimize them. What are your suggestions ?? From arnodel at gmail.com Fri Feb 10 07:38:34 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 12:38:34 +0000 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: On 10 February 2012 12:30, sajuptpm wrote: > Hi, > > I want to log time taken to complete database requests inside a method/ > function using decorator . ?is it possible ???? > I think, i have to inject log code inside the method/fuctions or > modify it. > I wrote a decorator to log taken by a method/function to complete it > execution and its working well. > > My requirement : log everything and figure out what bits are slow and > optimize them. > > What are your suggestions ?? Are you familiar with this? http://docs.python.org/library/profile.html -- Arnaud From sajuptpm at gmail.com Fri Feb 10 07:42:56 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:12:56 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Hi, Yes i saw profile module, I think i have to do function call via cProfile.run('foo()') I know, we can debug this way. But i need a fixed logging system .. On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: > On 10 February 2012 12:30, sajuptpm wrote: > > Hi, > > > > I want to log time taken to complete database requests inside a method/ > > function using decorator . is it possible ???? > > I think, i have to inject log code inside the method/fuctions or > > modify it. > > I wrote a decorator to log taken by a method/function to complete it > > execution and its working well. > > > > My requirement : log everything and figure out what bits are slow and > > optimize them. > > > > What are your suggestions ?? > > Are you familiar with this? > > http://docs.python.org/library/profile.html > > -- > Arnaud > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From sajuptpm at gmail.com Fri Feb 10 07:48:33 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:18:33 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 6:12 PM, Saju M wrote: > Hi, > > Yes i saw profile module, > I think i have to do function call via > > cProfile.run('foo()') > > I know, we can debug this way. > > But i need a fixed logging system .. > > > > On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: > >> On 10 February 2012 12:30, sajuptpm wrote: >> > Hi, >> > >> > I want to log time taken to complete database requests inside a method/ >> > function using decorator . is it possible ???? >> > I think, i have to inject log code inside the method/fuctions or >> > modify it. >> > I wrote a decorator to log taken by a method/function to complete it >> > execution and its working well. >> > >> > My requirement : log everything and figure out what bits are slow and >> > optimize them. >> > >> > What are your suggestions ?? >> >> Are you familiar with this? >> >> http://docs.python.org/library/profile.html >> > I need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? > -- >> Arnaud >> > > > > -- > Regards > Saju Madhavan > +91 09535134654 > > Anyone who has never made a mistake has never tried anything new -- Albert > Einstein > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From sajuptpm at gmail.com Fri Feb 10 07:56:17 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 04:56:17 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: Hi, Yes i saw profile module, I think i have to do function call via cProfile.run('foo()') I know, we can debug this way. But, i need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? From sajuptpm at gmail.com Fri Feb 10 07:59:51 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:29:51 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Yes i saw profile module, I think, i have to do function call via cProfile.run('foo()') I know, we can debug this way. But, I need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? On Fri, Feb 10, 2012 at 6:18 PM, Saju M wrote: > > > On Fri, Feb 10, 2012 at 6:12 PM, Saju M wrote: > >> Hi, >> >> Yes i saw profile module, >> I think i have to do function call via >> >> cProfile.run('foo()') >> >> I know, we can debug this way. >> >> But i need a fixed logging system .. >> >> >> >> On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: >> >>> On 10 February 2012 12:30, sajuptpm wrote: >>> > Hi, >>> > >>> > I want to log time taken to complete database requests inside a method/ >>> > function using decorator . is it possible ???? >>> > I think, i have to inject log code inside the method/fuctions or >>> > modify it. >>> > I wrote a decorator to log taken by a method/function to complete it >>> > execution and its working well. >>> > >>> > My requirement : log everything and figure out what bits are slow and >>> > optimize them. >>> > >>> > What are your suggestions ?? >>> >>> Are you familiar with this? >>> >>> http://docs.python.org/library/profile.html >>> >> > > > I need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code in > source code, > will cause any performance issue ?? > > > > >> -- >>> Arnaud >>> >> >> >> >> -- >> Regards >> Saju Madhavan >> +91 09535134654 >> >> Anyone who has never made a mistake has never tried anything new -- >> Albert Einstein >> > > > > -- > Regards > Saju Madhavan > +91 09535134654 > > Anyone who has never made a mistake has never tried anything new -- Albert > Einstein > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Fri Feb 10 08:08:28 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 13:08:28 +0000 Subject: changing sys.path In-Reply-To: References: Message-ID: <4F3516CC.1070401@gmail.com> I think I finally located the issue with the sys.path extension. The problem is that I have many namespace directories, for example lib: - sub1 - sub2 lib: - sub3 - sub4 But to have everything working I had lib.sub3 in easy-install.pth. Now if I try to add something else to the path it doesn't take care of the namespace declaration (every __init__.py in the packages contains: __import__('pkg_resources').declare_namespace(__name__)) and just doesn't find the other submodules.. If I try to add manually lib.sub1, lib.sub2 changing the sys.path the imports will only work for the first one. Strangely if I just create a dev_main.pth in site-packages containing the same paths, everything works perfectly. Any suggestions now that the problem is more clear? Thanks, Andrea From d at davea.name Fri Feb 10 09:24:50 2012 From: d at davea.name (Dave Angel) Date: Fri, 10 Feb 2012 09:24:50 -0500 Subject: changing sys.path In-Reply-To: <4F3516CC.1070401@gmail.com> References: <4F3516CC.1070401@gmail.com> Message-ID: <4F3528B2.3050806@davea.name> On 02/10/2012 08:08 AM, Andrea Crotti wrote: > I think I finally located the issue with the sys.path extension. > > The problem is that I have many namespace directories, for example > > lib: > - sub1 > - sub2 > > lib: > - sub3 > - sub4 > > But to have everything working I had lib.sub3 in easy-install.pth. > Now if I try to add something else to the path it doesn't take care of > the namespace > declaration > (every __init__.py in the packages contains: > __import__('pkg_resources').declare_namespace(__name__)) > and just doesn't find the other submodules.. > > If I try to add manually lib.sub1, lib.sub2 changing the sys.path the > imports will only work for the first one. > > Strangely if I just create a dev_main.pth in site-packages containing > the same paths, everything works perfectly. > > Any suggestions now that the problem is more clear? > Thanks, > Andrea The only code I saw in this thread was: sys.path.extend(paths_to_add) Can you add a print of paths_to_add, and of sys.path after you execute it? If there's only one path, are you putting it in a list anyway? If not then it won't do what you expect. -- DaveA From breamoreboy at yahoo.co.uk Fri Feb 10 09:25:10 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Feb 2012 14:25:10 +0000 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Please don't top post. On 10/02/2012 12:59, Saju M wrote: > Yes i saw profile module, > I think, i have to do function call via > cProfile.run('foo()') > I know, we can debug this way. > But, I need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code in > source code, > will cause any performance issue ?? > How about http://docs.python.org/library/logging.html ? -- Cheers. Mark Lawrence. From andrea.crotti.0 at gmail.com Fri Feb 10 09:51:20 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 14:51:20 +0000 Subject: changing sys.path In-Reply-To: <4F3528B2.3050806@davea.name> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> Message-ID: <4F352EE8.1030101@gmail.com> Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 5655372 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py /home/andrea/test_ns/a.b: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a/b: total 12 -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a/c: total 12 -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py So this test.py works perfectly: import sys sys.path.insert(0, 'a.c') sys.path.insert(0, 'a.b') from a.b import api as api_ab from a.c import api as api_ac While just mixing the order: import sys sys.path.insert(0, 'a.b') from a.b import api as api_ab sys.path.insert(0, 'a.c') from a.c import api as api_ac Doesn't work anymore [andrea at precision test_ns]$ python2 test.py Traceback (most recent call last): File "test.py", line 7, in from a.c import api as api_ac ImportError: No module named c Am I missing something/doing something stupid? From d at davea.name Fri Feb 10 10:06:28 2012 From: d at davea.name (Dave Angel) Date: Fri, 10 Feb 2012 10:06:28 -0500 Subject: changing sys.path In-Reply-To: <4F352EE8.1030101@gmail.com> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: <4F353274.704@davea.name> On 02/10/2012 09:51 AM, Andrea Crotti wrote: > Ok now it's getting really confusing, I tried a small example to see > what is the real behaviour, > so I created some package namespaces (where the __init__.py declare the > namespace package). > > /home/andrea/test_ns: > total used in directory 12 available 5655372 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c > -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py > > /home/andrea/test_ns/a.b: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a/b: > total 12 > -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a/c: > total 12 > -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > > So this test.py works perfectly: > import sys > sys.path.insert(0, 'a.c') > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > from a.c import api as api_ac > > While just mixing the order: > import sys > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > sys.path.insert(0, 'a.c') > from a.c import api as api_ac > > Doesn't work anymore > > [andrea at precision test_ns]$ python2 test.py > Traceback (most recent call last): > File "test.py", line 7, in > from a.c import api as api_ac > ImportError: No module named c > > > > Am I missing something/doing something stupid? Yes, you've got periods in your directory names. A period means something special within python, and specifically within the import. When you say from a.c import api You're telling it: from package a get module c, and from there impoort the symbol api But package a has no module c, so it complains. In an earlier message you asserted you were using all absolute paths in your additions to sys.path. Here you're inserting relative ones. How come? -- DaveA From andrea.crotti.0 at gmail.com Fri Feb 10 10:14:23 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 15:14:23 +0000 Subject: changing sys.path In-Reply-To: <4F353274.704@davea.name> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F353274.704@davea.name> Message-ID: <4F35344F.7040308@gmail.com> On 02/10/2012 03:06 PM, Dave Angel wrote: > > Yes, you've got periods in your directory names. A period means > something special within python, and specifically within the import. > > When you say from a.c import api > > You're telling it: from package a get module c, and from there > impoort the symbol api > > But package a has no module c, so it complains. > > > In an earlier message you asserted you were using all absolute paths > in your additions to sys.path. Here you're inserting relative ones. > How come? > Well yes I have periods, but that's also the real-world situation. We have many directories that are contributing to the same namespace in the same superdirectory which should not interfere, so it was decided to give this naming. It would be quite hard to change I guess and I have to prove that this is problem. I renamed everything and this import sys from os import path sys.path.insert(0, path.abspath('ab')) from a.b import api as api_ab sys.path.insert(0, path.abspath('ac')) from a.c import api as api_ac still fails, so the period in the name is not the problem. Also absolute or relative paths in this small example doesn't make any difference. Adding all the paths in one go works perfectly fine anyway, so I probably have to make sure I add them *all* before anything is imported. If there are better solutions I would like to hear them :) From __peter__ at web.de Fri Feb 10 10:27:24 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 16:27:24 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: Andrea Crotti wrote: > Ok now it's getting really confusing, I tried a small example to see > what is the real behaviour, > so I created some package namespaces (where the __init__.py declare the > namespace package). > > /home/andrea/test_ns: > total used in directory 12 available 5655372 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c > -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py > > /home/andrea/test_ns/a.b: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a/b: > total 12 > -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a/c: > total 12 > -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > > So this test.py works perfectly: > import sys > sys.path.insert(0, 'a.c') > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > from a.c import api as api_ac > > While just mixing the order: > import sys > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > sys.path.insert(0, 'a.c') > from a.c import api as api_ac > > Doesn't work anymore > > [andrea at precision test_ns]$ python2 test.py > Traceback (most recent call last): > File "test.py", line 7, in > from a.c import api as api_ac > ImportError: No module named c > > > > Am I missing something/doing something stupid? The package a will be either a.c/a/ or a.b/a/ depending on whether a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not contain a c submodule or subpackage. From andrea.crotti.0 at gmail.com Fri Feb 10 10:38:18 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 15:38:18 +0000 Subject: changing sys.path In-Reply-To: References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: <4F3539EA.80004@gmail.com> On 02/10/2012 03:27 PM, Peter Otten wrote: > The package a will be either a.c/a/ or a.b/a/ depending on whether > a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not > contain a c submodule or subpackage. I would agree if I didn't have this declaration __import__('pkg_resources').declare_namespace(__name__) in each subdirectory. And how do you explain the fact that changing the order everything works? Namespace packages are supposed to work exactly like this, if it doesn't resolve the "c" instead of raising an Exception it goes forward in the sys.path and try again, which is what actually happens when I do this sys.path.append(path.abspath('ab')) sys.path.append(path.abspath('ac')) from a.b import api as api_ab from a.c import api as api_ac Maybe this: Definition: pkgutil.extend_path(path, name) Docstring: Extend a package's path. Intended use is to place the following code in a package's __init__.py: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) might come handy, from what I'm gathering is the only way to have a more dynamic path manipulation with namespace packages.. From __peter__ at web.de Fri Feb 10 10:40:52 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 16:40:52 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: Peter Otten wrote: > If it's a.c/a, that does not contain a c submodule or subpackage. Sorry, I meant a.b/a From __peter__ at web.de Fri Feb 10 11:00:39 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 17:00:39 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F3539EA.80004@gmail.com> Message-ID: Andrea Crotti wrote: > On 02/10/2012 03:27 PM, Peter Otten wrote: >> The package a will be either a.c/a/ or a.b/a/ depending on whether >> a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not >> contain a c submodule or subpackage. > > > I would agree if I didn't have this declaration > __import__('pkg_resources').declare_namespace(__name__) > in each subdirectory. Sorry, you didn't mention that in the post I responded to and I didn't follow the thread closely. I found a description for declare_namespace() at http://peak.telecommunity.com/DevCenter/PkgResources but the text explaining the function is completely unintelligible to me, so I cannot contribute anything helpful here :( From technovegas at gmail.com Fri Feb 10 11:04:05 2012 From: technovegas at gmail.com (Fabric Paul) Date: Fri, 10 Feb 2012 08:04:05 -0800 (PST) Subject: Fabric Engine + Python benchmarks Message-ID: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Hi all - just letting you know that we recently integrated Fabric with Python. Fabric is a high-performance multi-threading engine that integrates with dynamic languages. We're releasing soon (probably under AGPL), and we just released these benchmarks. http://fabric-engine.com/2012/02/fabric-engine-python-value-at-risk-benchmark/ Before anyone starts attacking the vanilla python :), the point we want to make is that our Python integration performs just as well as our Node.js implementation (benchmarks found at http://fabric-engine.com/tag/benchmarks/). Obviously, it's pretty trivial to compile Python to byte code, and present multi-threaded versions of the program - however, the goal of Fabric is to handle that side of things automatically (that's what the engine does). This means we take care of threading, dynamic compilation, memory management etc Interested to get your feedback. Kind regards, Paul (I work at Fabric) From jkn_gg at nicorp.f9.co.uk Fri Feb 10 11:28:50 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Fri, 10 Feb 2012 08:28:50 -0800 (PST) Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Message-ID: Hi Peter On Feb 10, 11:10?am, Peter Otten <__pete... at web.de> wrote: [...] > > Hmm ... thanks for mentioning this feature, I didn't know of it > > before. Sounds great, except that I gather it needs Python >2.5? I'm > > stuck with v2.4 at the moment unfortunately... > > You can import and run explicitly, > > $ PYTHONPATH mylib.zip python -c'import mainmod; mainmod.main()' > > assuming you have a module mainmod.py containing a function main() in > mylib.zip. That looks very useful -thanks for the tip! J^n From nathan.alexander.rice at gmail.com Fri Feb 10 11:53:08 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 10 Feb 2012 11:53:08 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 5:08 AM, Chris Angelico wrote: > On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice > wrote: >> The only thing needed to avoid the hash collision is that your hash >> function is not not 100% predictable just by looking at the python >> source code. ?I don't see why every dict would have to be created >> differently. ?I would think having the most ubiquitous data structure >> in your language be more predictable would be a priority. ?Oh well.... > > It's perfectly predictable. If you put a series of keys into it, you > get those same keys back. Nobody ever promised anything about order. > > If your hash function is not 100% predictable, that means it varies on > the basis of something that isn't part of either the Python > interpreter or the script being run. That means that, from one > execution to another of the exact same code, the results could be > different. The keys will come out in different orders. I think having a hash function that is not referentially transparent is a bad thing. Basing your language on a non-deterministic function? Yeah... A type factory that produces the dict type on interpreter initialization (or, replaces the hash function, rather), and uses time/system information/etc would solve the problem, while limiting the introduced non-determinism. I don't care if the order of iteration for keys is different from interpreter run to run. I have used frozenset(mydict.items()) when my requirements dictated. It is a minor performance hit. Lets also not forget that knowing an object is immutable lets you do a lot of optimizations; it can be inlined, it is safe to convert to a contiguous block of memory and stuff in cache, etc. If you know the input to a function is guaranteed to be frozen you can just go crazy. Being able to freeze(anyobject) seems like a pretty clear win. Whether or not it is pythonic is debatable. I'd argue if the meaning of pythonic in some context is limiting, we should consider updating the term rather than being dogmatic. Just my 2 cents... Nathan From clp2 at rebertia.com Fri Feb 10 12:00:55 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 09:00:55 -0800 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 8:53 AM, Nathan Rice wrote: > Lets also not forget that knowing an object is immutable lets you do a > lot of optimizations; it can be inlined, it is safe to convert to a > contiguous block of memory and stuff in cache, etc. ?If you know the > input to a function is guaranteed to be frozen you can just go crazy. > Being able to freeze(anyobject) seems like a pretty clear win. > Whether or not it is pythonic is debatable. ?I'd argue if the meaning > of pythonic in some context is limiting, we should consider updating > the term rather than being dogmatic. It's been proposed previously and rejected: PEP 351 -- The freeze protocol http://www.python.org/dev/peps/pep-0351/ Cheers, Chris From stefan_ml at behnel.de Fri Feb 10 12:21:23 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 10 Feb 2012 18:21:23 +0100 Subject: Fabric Engine + Python benchmarks In-Reply-To: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Message-ID: Fabric Paul, 10.02.2012 17:04: > Fabric is a high-performance multi-threading engine that > integrates with dynamic languages. Hmm, first of all, fabric is a tool for automating admin/deployment/whatever tasks: http://pypi.python.org/pypi/Fabric/1.3.4 http://docs.fabfile.org/en/1.3.4/index.html Not sure which went first, but since you mentioned that you're "releasing soon", you may want to stop the engines for a moment and reconsider the name. Stefan From jenn.duerr at gmail.com Fri Feb 10 12:23:21 2012 From: jenn.duerr at gmail.com (noydb) Date: Fri, 10 Feb 2012 09:23:21 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On Feb 10, 4:58?am, Arnaud Delobelle wrote: > On 10 February 2012 06:21, Ian Kelly wrote: > > > > > > >>>>> (3219 + 99) // 100 * 100 > >> 3300 > >>>>> (3289 + 99) // 100 * 100 > >> 3300 > >>>>> (328678 + 99) // 100 * 100 > >> 328700 > >>>>> (328 + 99) // 100 * 100 > >> 400 > > >> Those are all rounded up to the nearest 100 correctly. > > > One thing to be aware of though is that while the "round down" formula > > works interchangeably for ints and floats, the "round up" formula does > > not. > > >>>> (3300.5 + 99) // 100 * 100 > > 3300.0 > > I'm surprised I haven't seen: > > >>> 212 - (212 % -100) > > 300 > > Here's a function that: > * rounds up and down > * works for both integers and floats > * is only two operations (as opposed to 3 in the solutions given above) > > >>> def round(n, k): > > ... ? ? return n - n%k > ...>>> # Round down with a positive k: > > ... round(167, 100) > 100>>> round(-233, 100 > > ... ) > -300>>> # Round up with a negative k: > > ... round(167, -100) > 200>>> round(-233, -100) > -200 > >>> # Edge cases > > ... round(500, -100) > 500>>> round(500, 100) > 500 > >>> # Floats > > ... round(100.5, -100) > 200.0>>> round(199.5, 100) > > 100.0 > > -- > Arnaud- Hide quoted text - > > - Show quoted text - Thanks! Covers all bases, good. From technovegas at gmail.com Fri Feb 10 12:27:31 2012 From: technovegas at gmail.com (Fabric Paul) Date: Fri, 10 Feb 2012 09:27:31 -0800 (PST) Subject: Fabric Engine + Python benchmarks References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Message-ID: <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> On Feb 10, 12:21?pm, Stefan Behnel wrote: > Fabric Paul, 10.02.2012 17:04: > > > Fabric is a high-performance multi-threading engine that > > integrates with dynamic languages. > > Hmm, first of all, fabric is a tool for automating > admin/deployment/whatever tasks: > > http://pypi.python.org/pypi/Fabric/1.3.4 > > http://docs.fabfile.org/en/1.3.4/index.html > > Not sure which went first, but since you mentioned that you're "releasing > soon", you may want to stop the engines for a moment and reconsider the name. > > Stefan Hi Stefan - Thanks for the heads up. Fabric Engine has been going for about 2 years now. Registered company etc. I'll be sure to refer to it as Fabric Engine so there's no confusion. We were unaware there was a python tool called Fabric. Thanks, Paul From nathan.alexander.rice at gmail.com Fri Feb 10 13:14:26 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 10 Feb 2012 13:14:26 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: >> Lets also not forget that knowing an object is immutable lets you do a >> lot of optimizations; it can be inlined, it is safe to convert to a >> contiguous block of memory and stuff in cache, etc. ?If you know the >> input to a function is guaranteed to be frozen you can just go crazy. >> Being able to freeze(anyobject) seems like a pretty clear win. >> Whether or not it is pythonic is debatable. ?I'd argue if the meaning >> of pythonic in some context is limiting, we should consider updating >> the term rather than being dogmatic. Sweet, looking at the reason for rejection: 1. How dicts (and multiply nested objects) should be frozen was not completely obvious 2. "frozen()" implies in place, thus confusing users 3. freezing something like a list is confusing because some list methods would disappear or cause errors 4. Because automatic conversion in the proposal was seen as too involved to be so magical 5. Because frozendicts are the main end user benefit, and using dicts as keys was seen as "suspect" Honestly, as far as #1, we already have copy and deepcopy, the can of worms is already opened (and necessarily so). For 2, choose a better name? For 3, we have abstract base classes now, which make a nice distinction between mutable and immutable sequences; nominal types are a crutch, thinking in terms of structure is much more powerful. I agree with point 4, if magic does anything besides make the code conform to what an informed user would expect, it should be considered heretical. As for #5, I feel using a collection of key value relations as a key in another collection is not inherently bad, it just depends on the context... The mutability is the rub. Also, immutability provides scaffolding to improve performance and concurrency (both of which are top tier language features). I understand that this is one of those cases where Guido has a strong "bad feeling" about something, and I think a consequence of that is people tread lightly. Perhaps I'm a bit of a language communist in that regard (historically a dangerous philosophy :) As an aside, I find it kind of schizophrenic how on one hand Python is billed as a language for consenting adults (see duck typing, no data hiding, etc) and on the other hand users need to be protected from themselves. Better to serve just one flavor of kool-aid imo. Nathan From nagle at animats.com Fri Feb 10 13:57:34 2012 From: nagle at animats.com (John Nagle) Date: Fri, 10 Feb 2012 10:57:34 -0800 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f356898$0$11996$742ec2ed@news.sonic.net> On 2/10/2012 10:14 AM, Nathan Rice wrote: >>> Lets also not forget that knowing an object is immutable lets you do a >>> lot of optimizations; it can be inlined, it is safe to convert to a >>> contiguous block of memory and stuff in cache, etc. If you know the >>> input to a function is guaranteed to be frozen you can just go crazy. >>> Being able to freeze(anyobject) seems like a pretty clear win. >>> Whether or not it is pythonic is debatable. I'd argue if the meaning >>> of pythonic in some context is limiting, we should consider updating >>> the term rather than being dogmatic. A real justification for the ability to make anything immutable is to make it safely shareable between threads. If it's immutable, it doesn't have to be locked for access. Mozilla's new "Rust" language takes advantage of this. Take a look at Rust's concurrency semantics. They've made some progress. John Nagle From vinay_sajip at yahoo.co.uk Fri Feb 10 14:28:52 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Fri, 10 Feb 2012 11:28:52 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. Message-ID: Sarge, a cross-platform library which wraps the subprocess module in the standard library, has been released. What does it do? ---------------- Sarge tries to make interfacing with external programs from your Python applications easier than just using subprocess alone. Sarge offers the following features: * A simple way to run command lines which allows a rich subset of Bash- style shell command syntax, but parsed and run by sarge so that you can run on Windows without cygwin (subject to having those commands available): >>> from sarge import capture_stdout >>> p = capture_stdout('echo foo | cat; echo bar') >>> for line in p.stdout: print(repr(line)) ... 'foo\n' 'bar\n' * The ability to format shell commands with placeholders, such that variables are quoted to prevent shell injection attacks. * The ability to capture output streams without requiring you to program your own threads. You just use a Capture object and then you can read from it as and when you want. Advantages over subprocess --------------------------- Sarge offers the following benefits compared to using subprocess: * The API is very simple. * It's easier to use command pipelines - using subprocess out of the box often leads to deadlocks because pipe buffers get filled up. * It would be nice to use Bash-style pipe syntax on Windows, but Windows shells don't support some of the syntax which is useful, like &&, ||, |& and so on. Sarge gives you that functionality on Windows, without cygwin. * Sometimes, subprocess.Popen.communicate() is not flexible enough for one's needs - for example, when one needs to process output a line at a time without buffering the entire output in memory. * It's desirable to avoid shell injection problems by having the ability to quote command arguments safely. * subprocess allows you to let stderr be the same as stdout, but not the other way around - and sometimes, you need to do that. Python version and platform compatibility ----------------------------------------- Sarge is intended to be used on any Python version >= 2.6 and is tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, Windows, and Mac OS X (not all versions are tested on all platforms, but sarge is expected to work correctly on all these versions on all these platforms). Finding out more ---------------- You can read the documentation at http://sarge.readthedocs.org/ There's a lot more information, with examples, than I can put into this post. You can install Sarge using "pip install sarge" to try it out. The project is hosted on BitBucket at https://bitbucket.org/vinay.sajip/sarge/ And you can leave feedback on the issue tracker there. I hope you find Sarge useful! Regards, Vinay Sajip From tkpmep at gmail.com Fri Feb 10 15:04:34 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 10 Feb 2012 12:04:34 -0800 (PST) Subject: Removing items from a list Message-ID: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> In the past, when deleting items from a list, I looped through the list in reverse to avoid accidentally deleting items I wanted to keep. I tried something different today, and, to my surprise, was able to delete items correctly, regardless of the direction in which I looped, in both Python 3.2.2. and 2..1 - does the remove() function somehow allow the iteration to continue correctly even when items are removed from the midde of the list? >>> x = list(range(10)) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> for i in x: if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> x = list(range(10)) >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] Sincerely Thomas Philips From ian.g.kelly at gmail.com Fri Feb 10 15:22:47 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 10 Feb 2012 13:22:47 -0700 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: On Fri, Feb 10, 2012 at 1:04 PM, Thomas Philips wrote: > In the past, when deleting items from a list, I looped through the > list in reverse to avoid accidentally deleting items I wanted to keep. > I tried something different today, and, to my surprise, was able to > delete items correctly, regardless of the direction in which I looped, > in both Python 3.2.2. and 2..1 - ?does the remove() function somehow > allow the iteration to continue correctly even when items are removed > from the midde of the list? No. Your test works because you never attempt to remove two adjacent items, so the skipping of items doesn't end up mattering. Try the same thing, but print out the values as you iterate over them: >>> x = list(range(10)) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> for i in x: ... print(i) ... if i % 2 == 0: ... x.remove(i) ... 0 2 4 6 8 >>> x [1, 3, 5, 7, 9] Had you attempted to remove any of the odd numbers as well, it would have failed. Cheers, Ian From python at mrabarnett.plus.com Fri Feb 10 15:26:26 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 20:26:26 +0000 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <4F357D72.8050107@mrabarnett.plus.com> On 10/02/2012 20:04, Thomas Philips wrote: > In the past, when deleting items from a list, I looped through the > list in reverse to avoid accidentally deleting items I wanted to keep. > I tried something different today, and, to my surprise, was able to > delete items correctly, regardless of the direction in which I looped, > in both Python 3.2.2. and 2..1 - does the remove() function somehow > allow the iteration to continue correctly even when items are removed > from the midde of the list? > >>>> x = list(range(10)) >>>> x > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>> for i in x: > if i % 2 == 0: > x.remove(i) > >>>> x > [1, 3, 5, 7, 9] >>>> for i in reversed(x): > if i % 2 == 0: > x.remove(i) > >>>> x > [1, 3, 5, 7, 9] >>>> x = list(range(10)) >>>> for i in reversed(x): > if i % 2 == 0: > x.remove(i) > > >>>> x > [1, 3, 5, 7, 9] > The answer is no. For example: >>> for i in x: print("i is", i) if i % 2 == 0: x.remove(i) i is 0 i is 1 i is 2 i is 4 >>> x [0, 1, 3, 5] From amirouche.boubekki at gmail.com Fri Feb 10 15:27:54 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Fri, 10 Feb 2012 21:27:54 +0100 Subject: Forking simplejson In-Reply-To: References: Message-ID: H?llo, I did it, it wasn't that difficult actually. the source is available @ https://github.com/amirouche/jsonir there is example : https://github.com/amirouche/jsonir/blob/master/example.py What makes the implementation of __json__ awkward is the iterencode support of simplejson that I kept. I'm wondering if it makes sens to have such a feature, what do you think ? I does not support multiple json representation of an object out-of-the-box, one solution is to "__json__" hook a parameter of the encoder. I did not test it. Cheers, Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From tkpmep at gmail.com Fri Feb 10 15:48:49 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 10 Feb 2012 12:48:49 -0800 (PST) Subject: Removing items from a list References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> Thanks for the insight. I saw the behavious as soon as I extended x with a bunch of 0's >>> x = list(range(10)) >>> x.extend([0]*10) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> x = list(range(10)) >>> x.extend([0]*10) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> for i in x: if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9, 0, 0, 0, 0, 0] From diolu at bigfoot.com Fri Feb 10 15:56:44 2012 From: diolu at bigfoot.com (Olive) Date: Fri, 10 Feb 2012 21:56:44 +0100 Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <20120210215644.6d865482@bigfoot.com> On Thu, 9 Feb 2012 17:43:58 -0800 Chris Rebert wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > > hmmm, okay. > > > > So how would you round UP always? ?Say the number is 3219, so you > > want 3300 returned. > > http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 > > Thus: (3219 + 99) // 100 > > Slight tangent: Beware negative numbers when using // or %. This trick work always (even if the entry is a float): -(-a//100)*100 >>> -(-3219//100)*100 3300 >>> -(-3200.1//100)*100 3300.0 From andrea.crotti.0 at gmail.com Fri Feb 10 15:58:35 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 20:58:35 +0000 Subject: changing sys.path In-Reply-To: References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F3539EA.80004@gmail.com> Message-ID: <4F3584FB.7050005@gmail.com> On 02/10/2012 04:00 PM, Peter Otten wrote: > Sorry, you didn't mention that in the post I responded to and I didn't > follow the thread closely. > > I found a description for declare_namespace() at > http://peak.telecommunity.com/DevCenter/PkgResources > > but the text explaining the function is completely unintelligible to me, so > I cannot contribute anything helpful here :( > Well in the end I submitted a bug report http://bugs.python.org/issue13991 I'm not sure it's really a bug and maybe I'm just doing something wrong, but to me the behavior is at least unexpected.. From gordon at panix.com Fri Feb 10 16:06:58 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 21:06:58 +0000 (UTC) Subject: How can I catch misnamed variables? Message-ID: Recently I was been bitten by some stupid errors in my code, and I'm wondering if there's a simple way to catch them. One error was of the form: my_object.some_function() .. when I hadn't declared an object named "my_object". The other error was similar: x = my_module.CONSTANT .. when I hadn't imported my_module. Of course both of these errors were deep inside a long-running function call, so it took a while for them to crop up. Is there an automated way to catch errors like these? I'm using the compileall module to build my program and it does catch some errors such as incorrect indentation, but not errors like the above. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From arnodel at gmail.com Fri Feb 10 16:17:02 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 21:17:02 +0000 Subject: How can I catch misnamed variables? In-Reply-To: References: Message-ID: On 10 February 2012 21:06, John Gordon wrote: > Recently I was been bitten by some stupid errors in my code, and I'm > wondering if there's a simple way to catch them. > > One error was of the form: > > ?my_object.some_function() > > .. when I hadn't declared an object named "my_object". > > The other error was similar: > > ?x = my_module.CONSTANT > > .. when I hadn't imported my_module. > > Of course both of these errors were deep inside a long-running function > call, so it took a while for them to crop up. > > Is there an automated way to catch errors like these? ?I'm using the > compileall module to build my program and it does catch some errors > such as incorrect indentation, but not errors like the above. There's pychecker and pylint -- Arnaud From kevin.p.dwyer at gmail.com Fri Feb 10 16:22:32 2012 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Fri, 10 Feb 2012 21:22:32 +0000 Subject: How can I catch misnamed variables? References: Message-ID: John Gordon wrote: > Recently I was been bitten by some stupid errors in my code, and I'm > wondering if there's a simple way to catch them. > Pyflakes is another static checker that can catch these sorts of errors. Cheers, Kev From diolu at bigfoot.com Fri Feb 10 16:25:45 2012 From: diolu at bigfoot.com (Olive) Date: Fri, 10 Feb 2012 22:25:45 +0100 Subject: datetime module and timezone Message-ID: <20120210222545.4cbe6924@bigfoot.com> In the datetime module, it has support for a notion of timezone but is it possible to use one of the available timezone (I am on Linux). Linux has a notion of timezone (in my distribution, they are stored in /usr/share/zoneinfo). I would like to be able 1) to know the current timezone and 2) to be able to use the timezone available on the system. How can I do that? Olive From ben+python at benfinney.id.au Fri Feb 10 16:26:01 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 11 Feb 2012 08:26:01 +1100 Subject: How can I catch misnamed variables? References: Message-ID: <87vcne2xee.fsf@benfinney.id.au> John Gordon writes: > Is there an automated way to catch errors like these? Use a static code checker, such as ?pyflakes? (simple but limited) or ?pylint? (complex but highly configurable) to catch these and many other problems in Python code. -- \ ?It's a terrible paradox that most charities are driven by | `\ religious belief.? if you think altruism without Jesus is not | _o__) altruism, then you're a dick.? ?Tim Minchin, 2010-11-28 | Ben Finney From gordon at panix.com Fri Feb 10 16:30:07 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 21:30:07 +0000 (UTC) Subject: datetime module and timezone References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: In <20120210222545.4cbe6924 at bigfoot.com> Olive writes: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/share/zoneinfo). I would like to be able 1) to know the current > timezone and 2) to be able to use the timezone available on the system. > How can I do that? I believe the current user's timezone is stored in the TZ environment variable. I don't understand your second question. Are you asking for a list of of all the possible timezone choices? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ethan at stoneleaf.us Fri Feb 10 16:56:38 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 10 Feb 2012 13:56:38 -0800 Subject: OT (waaaayyyyyyyyy off-topic) [was Re: How can I catch misnamed variables?] In-Reply-To: <87vcne2xee.fsf@benfinney.id.au> References: <87vcne2xee.fsf@benfinney.id.au> Message-ID: <4F359296.9090905@stoneleaf.us> Ben Finney wrote (from signature): > ?It's a terrible paradox that most charities are driven by religious > belief. . . . if you think altruism without Jesus is not altruism, > then you're a dick.? ?Tim Minchin, 2010-11-28 1) Why is it paradoxical? If anything it's a sad commentary on those who don't ascribe to a religion, as it would appear that they care less for their society. 2) altruism: unselfish regard for or devotion to the welfare of others... no mention of religion of any kind, or Jesus in particular. Altruistic-yet-paradoxically-religious-ly yours, ~Ethan~ From rosuav at gmail.com Fri Feb 10 16:58:55 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Feb 2012 08:58:55 +1100 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 7:04 AM, Thomas Philips wrote: > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>> for i in x: > ? ? ? ?if i % 2 == 0: > ? ? ? ? ? ? ? ?x.remove(i) Just a quickie, is there a reason you can't use a list comprehension? x = [i for i in x if i % 2] ChrisA From clp2 at rebertia.com Fri Feb 10 17:00:16 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 14:00:16 -0800 Subject: datetime module and timezone In-Reply-To: <20120210222545.4cbe6924@bigfoot.com> References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: On Fri, Feb 10, 2012 at 1:25 PM, Olive wrote: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/share/zoneinfo). I would like to be able 1) to know the current > timezone time.tzname gives the zone names (plural due to DST); time.timezone and time.altzone gives their UTC offsets. > and 2) to be able to use the timezone available on the system. You can use the name to look it up in pytz (http://pypi.python.org/pypi/pytz/ ). And python-dateutil (http://labix.org/python-dateutil ) can apparently parse zoneinfo files, if that's what you mean. Cheers, Chris From umedoblock at gmail.com Fri Feb 10 17:06:22 2012 From: umedoblock at gmail.com (umedoblock) Date: Sat, 11 Feb 2012 07:06:22 +0900 Subject: why does subtype_dict() and getset_get() makes infinite loop ? Message-ID: <4F3594DE.206@gmail.com> Hi, everyone. I'm umedoblock. now, I wrote a below sentence. But I cannot debug below infinite loop. Do I mistake when I write a c exetension ? I attached sample code. Please help me. ========================================== Python 3.2.2 (default, Jan 27 2012, 03:19:53) [GCC 4.6.1] on linux2 class Bar_abstract(metaclass=ABCMeta): pass # c extension # class Bar_base(Bar_abstract): # pass class Bar(Bar_base): pass ========================================== but do this bar = Bar() dir(bar) then python3.2.2 generates a core. Because subtype_dict() and getset_get() makes infinite loop. I checked stack with GDB. ================================================================== #130948 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130949 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 #130950 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130951 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 #130952 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130953 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 ================================================================== GDB show me above code. Now, I suspect below point PyObject_GetAttrString(). But I cannot debug this infinite loop. Do I mistake when I write a c exetension ? I attached sample code. Please help me. ojects/object.c:1325 static PyObject * _generic_dir(PyObject *obj) { PyObject *result = NULL; PyObject *dict = NULL; PyObject *itsclass = NULL; /* Get __dict__ (which may or may not be a real dict...) */ >>> dict = PyObject_GetAttrString(obj, "__dict__"); -------------- next part -------------- A non-text attachment was scrubbed... Name: bar_ext.zip Type: application/zip Size: 3156 bytes Desc: not available URL: From steve+comp.lang.python at pearwood.info Fri Feb 10 17:23:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 22:23:55 GMT Subject: Read-only attribute in module References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3598fb$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once >> attributes. > > So propose that propery() work at module level, for module attributes, > as well as for class attributes. I'm not wedded to a specific implementation. Besides, it's not just a matter of saying "property should work in modules" -- that would require the entire descriptor protocol work for module lookups, and I don't know how big a can of worms that is. Constant names is a lot more constrained than computed name lookups. -- Steven From tjreedy at udel.edu Fri Feb 10 17:29:36 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 10 Feb 2012 17:29:36 -0500 Subject: Read-only attribute in module In-Reply-To: <1328872312611-4382967.post@n6.nabble.com> References: <1328872312611-4382967.post@n6.nabble.com> Message-ID: On 2/10/2012 6:11 AM, mloskot wrote: > The intent of xyz.flag is that it is a value set by the module internally. > xyz is a module wrapping a C library. > The C library defines concept of a global flag set by the C functions at > some events, > so user can check value of this flag. > I can provide access to it with function: xyz.get_flag() If the value of the flag can change during a run, I would do that. Otherwise, you have to make sure the local copy keeps in sync. Users might also think that it is a true constant that they could read once. I understand that you might be concerned that one person in a multi-programmer project might decide to rebind xyz.flag and mess up everyone else. I think the real solution might be an option to freeze an entire module. -- Terry Jan Reedy From kevin.p.dwyer at gmail.com Fri Feb 10 17:37:18 2012 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Fri, 10 Feb 2012 22:37:18 +0000 Subject: log and figure out what bits are slow and optimize them. References: Message-ID: sajuptpm wrote: > Hi, > > Yes i saw profile module, > I think i have to do function call via > > cProfile.run('foo()') > > I know, we can debug this way. > > But, i need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code > in source code, > will cause any performance issue ?? *Any* instrumentation code is going to affect performance. It's a trade-off that you need to analyse and manage in the context of your application. From ben+python at benfinney.id.au Fri Feb 10 17:45:28 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 11 Feb 2012 09:45:28 +1100 Subject: OT (waaaayyyyyyyyy off-topic) References: <87vcne2xee.fsf@benfinney.id.au> Message-ID: <87mx8q2tpz.fsf@benfinney.id.au> Thanks for responding. Rather than take this discussion too far where it's quite off-topic, I'll respond briefly and ask for a change of forum if we want to continue. Ethan Furman writes: > Ben Finney wrote (from signature): > > ?It's a terrible paradox that most charities are driven by religious > > belief. . . . if you think altruism without Jesus is not altruism, > > then you're a dick.? ?Tim Minchin, 2010-11-28 The quote is from an interview with Tim Minchin . > 1) Why is it paradoxical? If anything it's a sad commentary on those > who don't ascribe to a religion, as it would appear that they care > less for their society. It's an outcome of history that religious institutions have historically been well-situated to be the facilitators of charitable work (and much other work) simply because they have been ubiquitous in most societies. The paradox is that they spend much of their resources away from the worldly, i.e. secular, work of charity. But charitable work is not dependent on religious belief, and indeed in recent decades there are now a great many wholly secular charities (e.g. International Red Cross and Oxfam) which do not divert their resources from addressing the real world. > 2) altruism: unselfish regard for or devotion to the welfare of > others... no mention of religion of any kind, or Jesus in particular. Yes, that's the point. Altruism is a human activity independent of religious belief, yet the default assumption of too many is that they are somehow necessarily connected. > Altruistic-yet-paradoxically-religious-ly yours, As you rightly point out, this discussion is off-topic here. So while I'm open to discussion on this topic, we should move it to some other forum. -- \ ?Most people, I think, don't even know what a rootkit is, so | `\ why should they care about it?? ?Thomas Hesse, Sony BMG, 2006 | _o__) | Ben Finney From no.email at nospam.invalid Fri Feb 10 17:52:34 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 10 Feb 2012 14:52:34 -0800 Subject: Fabric Engine + Python benchmarks References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> Message-ID: <7xhayy9u8d.fsf@ruckus.brouhaha.com> Fabric Paul writes: > Hi Stefan - Thanks for the heads up. Fabric Engine has been going for > about 2 years now. Registered company etc. I'll be sure to refer to it > as Fabric Engine so there's no confusion. We were unaware there was a > python tool called Fabric. There will still be confusion. The Fabric configuration tool is quite well known in the python and sysadmin communities, so it will be the first thing people will think of. If you weren't already aware of it, I'd guess you're pretty far out of contact with Python's existing user population, so there may be further sources of mismatch between your product and what else is out there (I'm thinking of Stackless, PyPy, etc.) Still, yoour product sounds pretty cool. From vincent.vandevyvre at swing.be Fri Feb 10 17:54:12 2012 From: vincent.vandevyvre at swing.be (Vincent Vande Vyvre) Date: Fri, 10 Feb 2012 23:54:12 +0100 Subject: Removing items from a list In-Reply-To: <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> Message-ID: <4F35A014.1050700@swing.be> An HTML attachment was scrubbed... URL: From pluijzer at gmail.com Fri Feb 10 18:01:52 2012 From: pluijzer at gmail.com (Righard van Roy) Date: Sat, 11 Feb 2012 00:01:52 +0100 Subject: Postpone evaluation of argument Message-ID: Hello, I want to add an item to a list, except if the evaluation of that item results in an exception. I could do that like this: def r(x): if x > 3: raise(ValueError) try: list.append(r(1)) except: pass try: list.append(r(5)) except: pass This looks rather clumbsy though, and it does not work with i.e. list comprehensions. I was thinking of writing a decorator like this: def tryAppendDecorator(fn): def new(*args): try: fn(*args) except: pass return new @tryAppendDecorator def tryAppend(list, item): list.append(item) tryAppend(list, r(1)) tryAppend(list, r(5)) This does not work however because the 'item' argument gets evaluated before the decorator does it's magic. Is there a way to postpone the evaluation of 'item' till it gets used inside the decorator. Like it is possible to quote a form in Lisp. Thank you, Righard From gordon at panix.com Fri Feb 10 18:06:52 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 23:06:52 +0000 (UTC) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: In Kev Dwyer writes: > *Any* instrumentation code is going to affect performance. Funny story about that... I wanted to profile some code of mine, and a colleague recommended the 'hotshot' module. It's pretty easy to use: there are functions to start profiling, stop profiling and print results. So I added the function calls and ran my code.... and it took a really long time. I mean a REALLY long time. In fact I eventually had to kill the process. I briefly wondered if my coworker was playing a prank on me... then I realized that I had neglected to call the function to stop profiling! So when I went to print the results, it was still profiling... endlessly. (Okay, maybe it wasn't that funny.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From clp2 at rebertia.com Fri Feb 10 18:12:38 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 15:12:38 -0800 Subject: Postpone evaluation of argument In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 3:01 PM, Righard van Roy wrote: > Hello, > > I want to add an item to a list, except if the evaluation of that item > results in an exception. > I could do that like this: > > def r(x): > ? ?if x > 3: > ? ? ? ?raise(ValueError) > > try: > ? ?list.append(r(1)) > except: > ? ?pass > try: > ? ?list.append(r(5)) > except: > ? ?pass > > This looks rather clumbsy though, and it does not work with i.e. list > comprehensions. > > I was thinking of writing a decorator like this: > > def tryAppendDecorator(fn): > ? ?def new(*args): > ? ? ? ?try: > ? ? ? ? ? ?fn(*args) > ? ? ? ?except: > ? ? ? ? ? ?pass > ? ?return new > > @tryAppendDecorator > def tryAppend(list, item): > ? ?list.append(item) > > tryAppend(list, r(1)) > tryAppend(list, r(5)) > > This does not work however because the 'item' argument gets evaluated > before the decorator does it's magic. > > Is there a way to postpone the evaluation of 'item' till it gets used > inside the decorator. Like it is possible to quote a form in Lisp. Nope. All arguments always get evaluated before control passes to the callee. You'd have to "quote" the arguments manually by putting them in lambdas, thus explicitly delaying their evaluation. Cheers, Chris -- http://rebertia.com From lists at cheimes.de Fri Feb 10 18:21:11 2012 From: lists at cheimes.de (Christian Heimes) Date: Sat, 11 Feb 2012 00:21:11 +0100 Subject: How can I catch misnamed variables? In-Reply-To: References: Message-ID: Am 10.02.2012 22:06, schrieb John Gordon: > Is there an automated way to catch errors like these? I'm using the > compileall module to build my program and it does catch some errors > such as incorrect indentation, but not errors like the above. Write unit tests and use coverage to aim for 100% code and branch coverage. If you want to write high quality code and avoid problems like misnamed variables then you have to write unit tests and functional tests for your program. I'm well aware that it's hard and requires time. But in the long run it will *save* lots of time. From no.email at nospam.invalid Fri Feb 10 18:57:56 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 10 Feb 2012 15:57:56 -0800 Subject: Postpone evaluation of argument References: Message-ID: <7xsjii2qd7.fsf@ruckus.brouhaha.com> Righard van Roy writes: > I want to add an item to a list, except if the evaluation of that item > results in an exception. This may be overkill and probably slow, but perhaps most in the spirit that you're asking. from itertools import chain def r(x): if x > 3: raise(ValueError) return x def maybe(func): try: yield func() except: return def p(i): return maybe(lambda: r(i)) your_list = list(chain(p(1), p(5))) print your_list From marduk at letterboxes.org Fri Feb 10 18:59:35 2012 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Fri, 10 Feb 2012 18:59:35 -0500 Subject: Fabric Engine + Python benchmarks In-Reply-To: <7xhayy9u8d.fsf@ruckus.brouhaha.com> References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> <7xhayy9u8d.fsf@ruckus.brouhaha.com> Message-ID: <1328918375.151158.3.camel@stretch.local> On Fri, 2012-02-10 at 14:52 -0800, Paul Rubin wrote: > Fabric Paul writes: > > Hi Stefan - Thanks for the heads up. Fabric Engine has been going for > > about 2 years now. Registered company etc. I'll be sure to refer to it > > as Fabric Engine so there's no confusion. We were unaware there was a > > python tool called Fabric. > > There will still be confusion. The Fabric configuration tool is quite > well known in the python and sysadmin communities, so it will be the > first thing people will think of. If you weren't already aware of it, > I'd guess you're pretty far out of contact with Python's existing user > population, so there may be further sources of mismatch between your > product and what else is out there (I'm thinking of Stackless, PyPy, > etc.) Still, yoour product sounds pretty cool. > Indeed. When I first saw the subject header I thought it was referring to the Python-based deployment tool. It's just going to confuse people. It's enough already that we have a bunch of stuff with "pi" and "py" in the name :| Does the OSS community *really* need another "Firebird" incident? -a From ethan at stoneleaf.us Fri Feb 10 19:38:41 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 10 Feb 2012 16:38:41 -0800 Subject: ANN: dbf.py 0.90.001 Message-ID: <4F35B891.5010701@stoneleaf.us> Still messing with .dbf files? Somebody brought you a 15 year old floppy, which still luckily (?) worked, and now wants that ancient data? dbf to the rescue! Supported tables/features ========================= - dBase III - FoxPro - Visual FoxPro supported - Null value Supported field types ===================== - Char - Date - Logical - Memo - Numeric - Currency (returns Decimal) - DateTime - Double - Float (same as Numeric) - General - Integer - Picture Still to come (or, Not Yet Working ;) ===================================== - Index files (although you can create temporary memory indices) - auto incrementing fields Latest version can be found on PyPI at http://pypi.python.org/pypi/dbf. Comments, bug reports, etc, appreciated! ~Ethan~ From 7stud at excite.com Fri Feb 10 21:48:10 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 18:48:10 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self Message-ID: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> The following code demonstrates that a collections.defaultdict is shelve worthy: import shelve import collections as c dd = c.defaultdict(int) dd["Joe"] = 3 print(dd) my_shelve = shelve.open('data.shelve') my_shelve['strike_record'] = dd my_shelve.close() my_shelve = shelve.open('data.shelve') data = my_shelve['strike_record'] my_shelve.close() dd.clear() dd.update(data) print(dd) --output:-- defaultdict(, {'Joe': 3}) defaultdict(, {'Joe': 3}) And the following code demonstrates that a class that inherits from dict can shelve itself: import collections as c import shelve class Dog(dict): def __init__(self): super().__init__(Joe=1) print('****', self) def save(self): my_shelve = shelve.open('data22.shelve') my_shelve['x'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.shelve') data = my_shelve['x'] my_shelve.close() print(data) d = Dog() d.save() d.load() --output:-- **** {'Joe': 1} {'Joe': 1} But I cannot get a class that inherits from collections.defaultdict to shelve itself: import collections as c import shelve class Dog(c.defaultdict): def __init__(self): super().__init__(int, Joe=0) print('****', self) def save(self): my_shelve = shelve.open('data22.shelve') my_shelve['dd'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.shelve') data = my_shelve['dd'] my_shelve.close() print(data) d = Dog() d.save() d.load() --output:-- **** defaultdict(, {'Joe': 30}) Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 111, in __getitem__ value = self.cache[key] KeyError: 'dd' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "3.py", line 95, in d.load() File "3.py", line 87, in load data = my_shelve['dd'] File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 114, in __getitem__ value = Unpickler(f).load() TypeError: __init__() takes exactly 1 positional argument (2 given) I deleted all *.shelve.db files between program runs. I can't figure out what I'm doing wrong. From 7stud at excite.com Fri Feb 10 21:52:08 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 18:52:08 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: <18ac41a4-4afa-472d-99fa-b60185d12943@m5g2000yqk.googlegroups.com> On Feb 10, 7:48?pm, 7stud <7s... at excite.com> wrote: > > But I cannot get a class that inherits from collections.defaultdict to > shelve itself: > > import collections as c > import shelve > > class Dog(c.defaultdict): > ? ? def __init__(self): > ? ? ? ? super().__init__(int, Joe=0) > ? ? ? ? print('****', self) Whoops. I changed: super().__init__(int, Joe=0) to: super().__init__(int, Joe=30) hence this output.. > --output:-- > > **** defaultdict(, {'Joe': 30}) From 7stud at excite.com Fri Feb 10 22:30:47 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 19:30:47 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> <18ac41a4-4afa-472d-99fa-b60185d12943@m5g2000yqk.googlegroups.com> Message-ID: <9258636e-b975-4f7b-8c52-57d089e832c2@c21g2000yqi.googlegroups.com> On Feb 10, 7:52?pm, 7stud <7s... at excite.com> wrote: I don't know if this helps, but I notice when I initially do this: shelve.open('data22') the file is saved as 'data22.db'. But on subsequent calls to shelve.open(), if I use the file name 'data22.db', I get a different error: --output:-- **** defaultdict(, {'Joe': 30}) Traceback (most recent call last): File "3.py", line 95, in d.load() File "3.py", line 86, in load my_shelve = shelve.open('data22.db') File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 232, in open return DbfilenameShelf(filename, flag, protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 216, in __init__ Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/dbm/__init__.py", line 83, in open raise error[0]("db type could not be determined") dbm.error: db type could not be determined The code that produced that error: import collections as c import shelve class Dog(c.defaultdict): def __init__(self): super().__init__(int, Joe=30) print('****', self) def save(self): my_shelve = shelve.open('data22') my_shelve['dd'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.db') data = my_shelve['dd'] my_shelve.close() print(data) d = Dog() d.save() d.load() I'm using python 3.2.2. From dihedral88888 at googlemail.com Sat Feb 11 00:52:59 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 10 Feb 2012 21:52:59 -0800 (PST) Subject: frozendict In-Reply-To: <4f356898$0$11996$742ec2ed@news.sonic.net> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f356898$0$11996$742ec2ed@news.sonic.net> Message-ID: <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?11????UTC+8??2?57?34??John Nagle??? > On 2/10/2012 10:14 AM, Nathan Rice wrote: > >>> Lets also not forget that knowing an object is immutable lets you do a > >>> lot of optimizations; it can be inlined, it is safe to convert to a > >>> contiguous block of memory and stuff in cache, etc. If you know the > >>> input to a function is guaranteed to be frozen you can just go crazy. > >>> Being able to freeze(anyobject) seems like a pretty clear win. > >>> Whether or not it is pythonic is debatable. I'd argue if the meaning > >>> of pythonic in some context is limiting, we should consider updating > >>> the term rather than being dogmatic. > > A real justification for the ability to make anything immutable is > to make it safely shareable between threads. If it's immutable, it > doesn't have to be locked for access. Mozilla's new "Rust" > language takes advantage of this. Take a look at Rust's concurrency > semantics. They've made some progress. > > John Nagl Lets model the system as an asynchronous set of objects with multiple threads performing operatons on objects as in the above. This reminds me the old problem solved before in the digital hardware. From bob.martin at excite.com Sat Feb 11 02:05:21 2012 From: bob.martin at excite.com (Bob Martin) Date: Sat, 11 Feb 2012 07:05:21 GMT Subject: datetime module and timezone References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: <9pmi9iFufgU1@mid.individual.net> in 671891 20120210 212545 Olive wrote: >In the datetime module, it has support for a notion of timezone but is >it possible to use one of the available timezone (I am on Linux). Linux >has a notion of timezone (in my distribution, they are stored >in /usr/share/zoneinfo). I would like to be able 1) to know the current >timezone and 2) to be able to use the timezone available on the system. >How can I do that? For 1) just type "date" on the command line. From sajuptpm at gmail.com Sat Feb 11 02:27:31 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 23:27:31 -0800 (PST) Subject: ldap proxy user bind Message-ID: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> I have developed a LDAP auth system using python-ldap module. Using that i can validate username and password, fetch user and groups info from LDAP directory. Now i want to implement ldap proxy user bind to the ldap server. I googled and find this http://ldapwiki.willeke.com/wiki/LDAPProxyUser But i don't have any idea about how implement it usng python-ldap. My existing LDAP settings at client side ldap_enabled = True ldap_host = your_ldap_server ldap_port = 389 ldap_basedn = o=My_omain ldap_user_key = cn ldap_group_key = groupMembership ldap_email_key = mail ldap_user_search = ou=Users ldap_group_search = ou=Groups ldap_group_objectclass = groupOfNames I want to add following 2 new flags ldap_proxy_user = ldap_proxy ldap_proxy_pwd = secret I don't know how this ldapproxy system would works. Could you please point me to an python article/example ?? From sajuptpm at gmail.com Sat Feb 11 02:53:42 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 23:53:42 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: I decided to create a decorator like. import cProfile def debug_time(method): def timed(*args, **kw): prof = cProfile.Profile() prof.enable(subcalls=False, builtins=False) result = prof.runcall(method, *args, **kw) #prof.print_stats() msg = "\n\n\n\n#######################################" msg += "\n\nURL : %s" %(tg.request.url) msg += "\nMethod: %r" %(method.__name__) print "--ddd--------", type(prof.getstats()) msg += "\n\nStatus : %s" %(prof.print_stats()) msg += "\n\n#######################################" print msg LOGGER.info(msg) return result return timed Ref : http://stackoverflow.com/questions/5375624/a-decorator-that-profiles-a-method-call-and-logs-the-profiling-result I want to log it in existing log file in my project, so i tried prof.print_stats() and prof.getstats(). prof.getstats() will need extra loop for fetch data. prof.print_stats() will log library calls also. Please suggest a better way to log profiler output. From jpiitula at ling.helsinki.fi Sat Feb 11 03:54:10 2012 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: 11 Feb 2012 10:54:10 +0200 Subject: Postpone evaluation of argument References: Message-ID: Righard van Roy writes: > Hello, > > I want to add an item to a list, except if the evaluation of that item > results in an exception. > I could do that like this: > > def r(x): > if x > 3: > raise(ValueError) > > try: > list.append(r(1)) > except: > pass > try: > list.append(r(5)) > except: > pass > > This looks rather clumbsy though, and it does not work with i.e. list > comprehensions. > > I was thinking of writing a decorator like this: > > def tryAppendDecorator(fn): > def new(*args): > try: > fn(*args) > except: > pass > return new > > @tryAppendDecorator > def tryAppend(list, item): > list.append(item) > > tryAppend(list, r(1)) > tryAppend(list, r(5)) > > This does not work however because the 'item' argument gets evaluated > before the decorator does it's magic. > > Is there a way to postpone the evaluation of 'item' till it gets used > inside the decorator. Like it is possible to quote a form in Lisp. That's not considered good practice in Lisp either. One would use a lambda expression to delay the computation, as others have suggested. You might be able to arrange your program so that tryAppend is called with the error-raising function and its arguments separately. I mean like this: def r(x): if x > 3: raise(ValueError) return x def tryAppendDecorator(fn): def new(xs, f, *args): try: fn(xs, f(*args)) except: pass return new @tryAppendDecorator def tryAppend(items, item): items.append(item) sub3 = [] tryAppend(sub3, r, 3) tryAppend(sub3, r, 1) tryAppend(sub3, r, 4) tryAppend(sub3, r, 1) tryAppend(sub3, r, 5) Maybe you should only ignore some specific type of exception, like ValueError if you are specifically using r as a filter whose task it is to raise a ValueError. From jeyamithraj at gmail.com Sat Feb 11 04:22:23 2012 From: jeyamithraj at gmail.com (Jeya Mithra Jeyandran) Date: Sat, 11 Feb 2012 01:22:23 -0800 (PST) Subject: Orphanage Funds Message-ID: <5ca1f5eb-ba92-4b73-a9b3-f4a772c6902b@sw7g2000pbc.googlegroups.com> Hi, I am Mithra. Me and my friends joined together ti help the orphanage people after visiting their home once. There are nearly 100 students interested in studies but they dont have enough fund to be provided for their studies. Please help them by donating as much as you can. Thanks for your help. Please forward this mail for your friends. Please click the following link to donate : http://www.gofundme.com/dij30 Thanks in Advance From hniksic at xemacs.org Sat Feb 11 05:26:08 2012 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sat, 11 Feb 2012 11:26:08 +0100 Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <878vk93bun.fsf@xemacs.org> Terry Reedy writes: > On 2/9/2012 8:23 PM, noydb wrote: >> So how would you round UP always? Say the number is 3219, so you want >>>> (3333//100+1)*100 > 3400 Note that that doesn't work for numbers that are already round: >>> (3300//100+1)*100 3400 # 3300 would be correct I'd go with Chris Rebert's (x + 99) // 100. From dihedral88888 at googlemail.com Sat Feb 11 06:16:39 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 11 Feb 2012 03:16:39 -0800 (PST) Subject: Postpone evaluation of argument In-Reply-To: <7xsjii2qd7.fsf@ruckus.brouhaha.com> References: <7xsjii2qd7.fsf@ruckus.brouhaha.com> Message-ID: <412049.429.1328958999552.JavaMail.geo-discussion-forums@pbctz8> ? 2012?2?11????UTC+8??7?57?56??Paul Rubin??? > Righard van Roy > writes: > > I want to add an item to a list, except if the evaluation of that item > > results in an exception. > > This may be overkill and probably slow, but perhaps most in the spirit > that you're asking. > > from itertools import chain > > def r(x): > if x > 3: > raise(ValueError) > return x > > def maybe(func): > try: > yield func() > except: > return > I am wondering at which level to yield in a nested decorated function is more controllable. It is definitely wrong to yield in manny levels decorated. > def p(i): return maybe(lambda: r(i)) > > your_list = list(chain(p(1), p(5))) > print your_list From waqif at smartbaba.com Sat Feb 11 08:34:50 2012 From: waqif at smartbaba.com (Smart Baba) Date: Sat, 11 Feb 2012 05:34:50 -0800 (PST) Subject: Have your own business web Message-ID: <7f4fd3ba-fc17-4ad9-8564-d5faca19a336@q8g2000pbb.googlegroups.com> Smart Baba new year special price offer, Basic website = 132 $ only, Standard website = 271 $ and Dynamic website = 408 $. Now have your own business customized professional website and start promoting your business. For further details, Follow us at: www.websitedeals.in From therve at free.fr Sat Feb 11 08:35:15 2012 From: therve at free.fr (=?UTF-8?B?VGhvbWFzIEhlcnbDqQ==?=) Date: Sat, 11 Feb 2012 14:35:15 +0100 Subject: Twisted 12.0.0 released Message-ID: <4F366E93.80804@free.fr> On behalf of Twisted Matrix Laboratories, I am honored to announce the release of Twisted 12.0. 47 tickets are closed by this release, among them: * A fix to the GTK2 reactor preventing unnecessary wake-ups * Preliminary support of IPV6 on the server side * Several fixes to the new protocol-based TLS implementation * Improved core documentation's main page Twisted no longer supports Python 2.4, the latest supported version is 2.5. For more information, see the NEWS file here: http://twistedmatrix.com/Releases/Twisted/12.0/NEWS.txt Download it now from: http://pypi.python.org/packages/source/T/Twisted/Twisted-12.0.0.tar.bz2 or http://pypi.python.org/packages/2.5/T/Twisted/Twisted-12.0.0.win32-py2.5.msi or http://pypi.python.org/packages/2.6/T/Twisted/Twisted-12.0.0.win32-py2.6.msi or http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.0.0.win32-py2.7.msi Thanks to the supporters of the Twisted Software Foundation and to the many contributors for this release. -- Thomas From rodrick.brown at gmail.com Sat Feb 11 12:37:40 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Sat, 11 Feb 2012 12:37:40 -0500 Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 2:28 PM, Vinay Sajip wrote: > Sarge, a cross-platform library which wraps the subprocess module in > the standard library, has been released. > > What does it do? > ---------------- > > Sarge tries to make interfacing with external programs from your > Python applications easier than just using subprocess alone. > > Sarge offers the following features: > > * A simple way to run command lines which allows a rich subset of Bash- > style shell command syntax, but parsed and run by sarge so that you > can run on Windows without cygwin (subject to having those commands > available): > > >>> from sarge import capture_stdout > >>> p = capture_stdout('echo foo | cat; echo bar') > >>> for line in p.stdout: print(repr(line)) > ... > 'foo\n' > 'bar\n' > > * The ability to format shell commands with placeholders, such that > variables are quoted to prevent shell injection attacks. > > * The ability to capture output streams without requiring you to > program your own threads. You just use a Capture object and then you > can read from it as and when you want. > > Advantages over subprocess > --------------------------- > > Sarge offers the following benefits compared to using subprocess: > > * The API is very simple. > > * It's easier to use command pipelines - using subprocess out of the > box often leads to deadlocks because pipe buffers get filled up. > > * It would be nice to use Bash-style pipe syntax on Windows, but > Windows shells don't support some of the syntax which is useful, like > &&, ||, |& and so on. Sarge gives you that functionality on Windows, > without cygwin. > > * Sometimes, subprocess.Popen.communicate() is not flexible enough for > one's needs - for example, when one needs to process output a line at > a time without buffering the entire output in memory. > > * It's desirable to avoid shell injection problems by having the > ability to quote command arguments safely. > > * subprocess allows you to let stderr be the same as stdout, but not > the other way around - and sometimes, you need to do that. > > Python version and platform compatibility > ----------------------------------------- > > Sarge is intended to be used on any Python version >= 2.6 and is > tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, > Windows, and Mac OS X (not all versions are tested on all platforms, > but sarge is expected to work correctly on all these versions on all > these platforms). > > Finding out more > ---------------- > > You can read the documentation at > > http://sarge.readthedocs.org/ > > There's a lot more information, with examples, than I can put into > this post. > > You can install Sarge using "pip install sarge" to try it out. The > project is hosted on BitBucket at > > https://bitbucket.org/vinay.sajip/sarge/ > > And you can leave feedback on the issue tracker there. > > I hope you find Sarge useful! > > Regards, > > This is pretty cool I think ill check it out! I really hate working with subprocess it just seems a bit too low level for my taste. > > Vinay Sajip > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevinmurphy9999 at gmail.com Sat Feb 11 12:40:09 2012 From: kevinmurphy9999 at gmail.com (Kevin Murphy) Date: Sat, 11 Feb 2012 09:40:09 -0800 (PST) Subject: MySQL: AttributeError: cursor Message-ID: Hi All, I'm using Python 2.7 and having a problem creating the cursor below. Any suggestions would be appreciated! import sys import _mysql print "cursor test" db = _mysql.connect(host="localhost",user="root",passwd="mypw",db="python- test") cursor = db.cursor() >>> cursor test Traceback (most recent call last): File "C:\Python27\dbconnect.py", line 8, in cursor = db.cursor() AttributeError: cursor From ian.g.kelly at gmail.com Sat Feb 11 12:46:00 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:46:00 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Fri, Feb 10, 2012 at 7:48 PM, 7stud <7stud at excite.com> wrote: > But I cannot get a class that inherits from collections.defaultdict to > shelve itself: > > > import collections as c > import shelve > > class Dog(c.defaultdict): > ? ?def __init__(self): > ? ? ? ?super().__init__(int, Joe=0) > ? ? ? ?print('****', self) > > ? ?def save(self): > ? ? ? ?my_shelve = shelve.open('data22.shelve') > ? ? ? ?my_shelve['dd'] = self > ? ? ? ?my_shelve.close() > > ? ?def load(self): > ? ? ? ?my_shelve = shelve.open('data22.shelve') > ? ? ? ?data = my_shelve['dd'] > ? ? ? ?my_shelve.close() > > ? ? ? ?print(data) > > > d = Dog() > d.save() > d.load() > > --output:-- > > **** defaultdict(, {'Joe': 30}) > Traceback (most recent call last): > ?File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ > python3.2/shelve.py", line 111, in __getitem__ > ? ?value = self.cache[key] > KeyError: 'dd' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > ?File "3.py", line 95, in > ? ?d.load() > ?File "3.py", line 87, in load > ? ?data = my_shelve['dd'] > ?File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ > python3.2/shelve.py", line 114, in __getitem__ > ? ?value = Unpickler(f).load() > TypeError: __init__() takes exactly 1 positional argument (2 given) > > > > I deleted all *.shelve.db files between program runs. ?I can't figure > out what I'm doing wrong. The problem is that defaultdict defines a custom __reduce__ method which is used by the pickle protocol to determine how the object should be reconstructed. It uses this to reconstruct the defaultdict with the same default factory, by calling the type with a single argument of the default factory. Since your subclass's __init__ method takes no arguments, this results in the error you see. There are a couple of ways you could fix this. The first would be to change the signature of the __init__ method to take an optional argument accepting the default factory instead of hard-coding it, like this: def __init__(self, default_factory=int): super().__init__(default_factory, Joe=0) The other would be to just fix the __reduce__ method to not pass the default factory to your initializer, since it is hard-coded. That would look like this: def __reduce__(self): return (type(self), ()) Cheers, Ian From ian.g.kelly at gmail.com Sat Feb 11 12:54:58 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:54:58 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 10:46 AM, Ian Kelly wrote: > The problem is that defaultdict defines a custom __reduce__ method > which is used by the pickle protocol to determine how the object > should be reconstructed. ?It uses this to reconstruct the defaultdict > with the same default factory, by calling the type with a single > argument of the default factory. ?Since your subclass's __init__ > method takes no arguments, this results in the error you see. > > There are a couple of ways you could fix this. ?The first would be to > change the signature of the __init__ method to take an optional > argument accepting the default factory instead of hard-coding it, like > this: > > ? ?def __init__(self, default_factory=int): > ? ? ? ?super().__init__(default_factory, Joe=0) > > The other would be to just fix the __reduce__ method to not pass the > default factory to your initializer, since it is hard-coded. ?That > would look like this: > > ? ?def __reduce__(self): > ? ? ? ?return (type(self), ()) It occurs to me that there's also an option 3: you don't really need a defaultdict to do what you're trying to do here. You just need a dict with a custom __missing__ method. That could look something like this: class Dog(dict): def __missing__(self): return 0 And then you don't have to worry about the weird pickle behavior of defaultdict at all. Cheers, Ian From ian.g.kelly at gmail.com Sat Feb 11 12:56:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:56:12 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote: > class Dog(dict): > > ? ?def __missing__(self): > ? ? ? ?return 0 Sorry, that should have been: class Dog(dict): def __missing__(self, key): return 0 Cheers, Ian From marduk at letterboxes.org Sat Feb 11 13:07:25 2012 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Sat, 11 Feb 2012 13:07:25 -0500 Subject: MySQL: AttributeError: cursor In-Reply-To: References: Message-ID: <1328983645.608779.3.camel@stretch.local> On Sat, 2012-02-11 at 09:40 -0800, Kevin Murphy wrote: > Hi All, > I'm using Python 2.7 and having a problem creating the cursor below. > Any suggestions would be appreciated! > > import sys > import _mysql > > print "cursor test" > > db = > _mysql.connect(host="localhost",user="root",passwd="mypw",db="python- > test") > > cursor = db.cursor() > > >>> > cursor test > > Traceback (most recent call last): > File "C:\Python27\dbconnect.py", line 8, in > cursor = db.cursor() > AttributeError: cursor You are using the low-level C API wrapper (not sure why). Most people, I believe, would use the pythonic API: >>> import MySQLdb >>> db = MySQLdb.connect(host='localhost', user='root', passwd='mypw', db='python-test') >>> cursor = db.cursor() The low-level API is... well.. for when you want to do low-level stuff. You probably want the pythonic API. -a From franck at ditter.org Sat Feb 11 13:15:24 2012 From: franck at ditter.org (Franck Ditter) Date: Sat, 11 Feb 2012 19:15:24 +0100 Subject: Stopping a looping computation in IDLE 3.2.x Message-ID: How do you stop a looping computation with IDLE 3.2.x on MacOS-X Lion ? It hangs with the colored wheel... Ctl-C does not work. Thanks, franck From 7stud at excite.com Sat Feb 11 14:22:14 2012 From: 7stud at excite.com (7stud) Date: Sat, 11 Feb 2012 11:22:14 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Feb 11, 10:56?am, Ian Kelly wrote: > On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote: > > class Dog(dict): > > > ? ?def __missing__(self): > > ? ? ? ?return 0 > > Sorry, that should have been: > > class Dog(dict): > > ? ? def __missing__(self, key): > ? ? ? ? return 0 > > Cheers, > Ian Thanks Ian! From bahamutzero8825 at gmail.com Sat Feb 11 15:02:08 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 14:02:08 -0600 Subject: Building a debug version of Python 3.2.2 under Windows Message-ID: <4F36C940.8020009@gmail.com> I tried to build Python 3.2.2 with VS 2008, but it seems I'm missing some header files (e.g. sqlite3, openssl). Is there a nice little package with all the dependencies, or do I need to grab source code packages for each program from their respective websites, or something else entirely? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From michael at stroeder.com Sat Feb 11 15:22:45 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Sat, 11 Feb 2012 21:22:45 +0100 Subject: ldap proxy user bind In-Reply-To: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> Message-ID: sajuptpm wrote: > I have developed a LDAP auth system using python-ldap module. > Using that i can validate username and password, fetch user and > groups info from LDAP directory. > Now i want to implement ldap proxy user bind to the ldap server. What do you mean exactly? Are you talking about LDAPv3 proxy authorization (see http://tools.ietf.org/html/rfc4370)? If yes, then pass an instance of class ldap.controls.simple.ProxyAuthzControl to the LDAPObject methods when sending your LDAP requests. This is usable no matter how your proxy user has bound the directory. Another option is to send a SASL authz-ID along with the initial SASL bind request of your proxy user. No matter what you have to get your LDAP server configuration right for this to work. Which LDAP server is it? > I googled and find this http://ldapwiki.willeke.com/wiki/LDAPProxyUser AFAICS this web page talks about the proxy user for eDirectory's LDAP gateway to NDS. It's unlikely that this is relevant to your needs. > But i don't have any idea about how implement it usng python-ldap. > [..] > I want to add following 2 new flags > > ldap_proxy_user = ldap_proxy > ldap_proxy_pwd = secret Hmm, please don't take it personally but my impression is that you're not totally clear on what you need. Could you please try to explain what you want to achieve? Ciao, Michael. From mlortiz at uci.cu Sat Feb 11 15:32:14 2012 From: mlortiz at uci.cu (Marcos Ortiz Valmaseda) Date: Sat, 11 Feb 2012 16:02:14 -0430 Subject: Can anyone send me the last version of psycopg2 by email? In-Reply-To: <4F366E93.80804@free.fr> References: <4F366E93.80804@free.fr> Message-ID: <4F36D04E.90002@uci.cu> I have a minor trouble here with my Internet connection. Can anyone send me the last version of psycopg2 to this email? Thanks a lot for the help. Regards and best wishes -- Marcos Luis Ort?z Valmaseda Sr. Software Engineer (UCI) http://marcosluis2186.posterous.com http://www.linkedin.com/in/marcosluis2186 Twitter: @marcosluis2186 Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com From ralf at systemexit.de Sat Feb 11 15:44:02 2012 From: ralf at systemexit.de (Ralf Schmitt) Date: Sat, 11 Feb 2012 21:44:02 +0100 Subject: [ANNOUNCE] greenlet 0.3.4 Message-ID: <87ty2xgkx9.fsf@myhost.localnet> Hi, I have uploaded greenlet 0.3.4 to PyPI: http://pypi.python.org/pypi/greenlet What is it? ----------- The greenlet module provides coroutines for python. coroutines allow suspending and resuming execution at certain locations. concurrence[1], eventlet[2] and gevent[3] use the greenlet module in order to implement concurrent network applications. Documentation can be found here: http://greenlet.readthedocs.org The code is hosted on github: https://github.com/python-greenlet/greenlet Changes in version 0.3.4 ------------------------ The NEWS file lists these changes for release 0.3.4: * Use plain distutils for install command, this fixes installation of the greenlet.h header. * Enhanced arm32 support * Fix support for Linux/S390 zSeries * Workaround compiler bug on RHEL 3 / CentOS 3 [1] http://opensource.hyves.org/concurrence/ [2] http://eventlet.net/ [3] http://www.gevent.org/ -- Cheers Ralf Schmitt From tjreedy at udel.edu Sat Feb 11 16:01:52 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 11 Feb 2012 16:01:52 -0500 Subject: Building a debug version of Python 3.2.2 under Windows In-Reply-To: <4F36C940.8020009@gmail.com> References: <4F36C940.8020009@gmail.com> Message-ID: On 2/11/2012 3:02 PM, Andrew Berg wrote: > I tried to build Python 3.2.2 with VS 2008, but it seems I'm missing > some header files (e.g. sqlite3, openssl). Is there a nice little > package with all the dependencies, or do I need to grab source code > packages for each program from their respective websites, or something > else entirely? The readme file in PCBuild supposedly has all the info needed, though I know one thing out of date. Trying to follow the instructions is on my todo list ;-). -- Terry Jan Reedy From ericsnowcurrently at gmail.com Sat Feb 11 16:02:47 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 14:02:47 -0700 Subject: Python usage numbers Message-ID: Does anyone have (or know of) accurate totals and percentages on how Python is used? I'm particularly interested in the following groupings: - new development vs. stable code-bases - categories (web, scripts, "big data", computation, etc.) - "bare metal" vs. on top of some framework - regional usage I'm thinking about this partly because of the discussion on python-ideas about the perceived challenges of Unicode in Python 3. All the rhetoric, anecdotal evidence, and use-cases there have little meaning to me, in regards to Python as a whole, without an understanding of who is actually affected. For instance, if frameworks (like django and numpy) could completely hide the arguable challenges of Unicode in Python 3--and most projects were built on top of frameworks--then general efforts for making Unicode easier in Python 3 should go toward helping framework writers. Not only are such usage numbers useful for the Unicode discussion (which I wish would get resolved and die so we could move on to more interesting stuff :) ). They help us know where efforts could be focused in general to make Python more powerful and easier to use where it's already used extensively. They can show us the areas that Python isn't used much, thus exposing a targeted opportunity to change that. Realistically, it's not entirely feasible to compile such information at a comprehensive level, but even generally accurate numbers would be a valuable resource. If the numbers aren't out there, what would some good approaches to discovering them? Thanks! -eric From sajuptpm at gmail.com Sat Feb 11 16:19:49 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Sat, 11 Feb 2012 13:19:49 -0800 (PST) Subject: ldap proxy user bind References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> Message-ID: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Hi Michael Str?der, Thanks for replay Yea i am not totally clear about that Client's Requirement is option to have a ldap proxy user bind to the ldap server if it needs more directory rights than an anonymous bind. option to use a ldap proxy user when searching. From bahamutzero8825 at gmail.com Sat Feb 11 16:21:21 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 15:21:21 -0600 Subject: Building a debug version of Python 3.2.2 under Windows In-Reply-To: References: <4F36C940.8020009@gmail.com> Message-ID: <4F36DBD1.4080704@gmail.com> On 2/11/2012 3:01 PM, Terry Reedy wrote: > The readme file in PCBuild supposedly has all the info needed, though I > know one thing out of date. Trying to follow the instructions is on my > todo list ;-). > I didn't notice the readme in there. I was following instructions from here: http://docs.python.org/devguide/ Looks like the build process is a bit more complicated than just "Build Solution". Thanks. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From stefan_ml at behnel.de Sat Feb 11 16:28:01 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 11 Feb 2012 22:28:01 +0100 Subject: Python usage numbers In-Reply-To: References: Message-ID: Eric Snow, 11.02.2012 22:02: > - categories (web, scripts, "big data", computation, etc.) No numbers, but from my stance, the four largest areas where Python is used appear to be (in increasing line length order): a) web applications b) scripting and tooling c) high-performance computation d) testing (non-Python/embedded/whatever code) I'm sure others will manage to remind me of the one or two I forgot... Stefan From bahamutzero8825 at gmail.com Sat Feb 11 16:51:49 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 15:51:49 -0600 Subject: Python usage numbers In-Reply-To: References: Message-ID: <4F36E2F5.9000505@gmail.com> On 2/11/2012 3:02 PM, Eric Snow wrote: > I'm thinking about this partly because of the discussion on > python-ideas about the perceived challenges of Unicode in Python 3. > For instance, if frameworks (like django and numpy) could completely > hide the arguable challenges of Unicode in Python 3--and most projects > were built on top of frameworks--then general efforts for making > Unicode easier in Python 3 should go toward helping framework writers. Huh? I'll admit I'm a novice, but isn't Unicode mostly trivial in py3k compared to 2.x? Or are you referring to porting 2.x to 3.x? I've been under the impression that Unicode in 2.x can be painful at times, but easy in 3.x. I've been using 3.2 and Unicode hasn't been much of an issue. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From breamoreboy at yahoo.co.uk Sat Feb 11 17:17:20 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 22:17:20 +0000 Subject: Python usage numbers In-Reply-To: References: Message-ID: On 11/02/2012 21:02, Eric Snow wrote: > Does anyone have (or know of) accurate totals and percentages on how > Python is used? I'm particularly interested in the following > groupings: > > - new development vs. stable code-bases > - categories (web, scripts, "big data", computation, etc.) > - "bare metal" vs. on top of some framework > - regional usage > > I'm thinking about this partly because of the discussion on > python-ideas about the perceived challenges of Unicode in Python 3. > All the rhetoric, anecdotal evidence, and use-cases there have little > meaning to me, in regards to Python as a whole, without an > understanding of who is actually affected. > > For instance, if frameworks (like django and numpy) could completely > hide the arguable challenges of Unicode in Python 3--and most projects > were built on top of frameworks--then general efforts for making > Unicode easier in Python 3 should go toward helping framework writers. > > Not only are such usage numbers useful for the Unicode discussion > (which I wish would get resolved and die so we could move on to more > interesting stuff :) ). They help us know where efforts could be > focused in general to make Python more powerful and easier to use > where it's already used extensively. They can show us the areas that > Python isn't used much, thus exposing a targeted opportunity to change > that. > > Realistically, it's not entirely feasible to compile such information > at a comprehensive level, but even generally accurate numbers would be > a valuable resource. If the numbers aren't out there, what would some > good approaches to discovering them? Thanks! > > -eric As others have said on other Python newsgroups it ain't a problem. The only time I've ever had a problem was with matplotlib which couldn't print a ? sign. I used a U to enforce unicode job done. If I had a major problem I reckon that a search on c.l.p would give me an answer easy peasy. -- Cheers. Mark Lawrence. From ericsnowcurrently at gmail.com Sat Feb 11 20:21:01 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 18:21:01 -0700 Subject: Python usage numbers In-Reply-To: <4F36E2F5.9000505@gmail.com> References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sat, Feb 11, 2012 at 2:51 PM, Andrew Berg wrote: > On 2/11/2012 3:02 PM, Eric Snow wrote: >> I'm thinking about this partly because of the discussion on >> python-ideas about the perceived challenges of Unicode in Python 3. > >> For instance, if frameworks (like django and numpy) could completely >> hide the arguable challenges of Unicode in Python 3--and most projects >> were built on top of frameworks--then general efforts for making >> Unicode easier in Python 3 should go toward helping framework writers. > Huh? I'll admit I'm a novice, but isn't Unicode mostly trivial in py3k > compared to 2.x? Or are you referring to porting 2.x to 3.x? I've been > under the impression that Unicode in 2.x can be painful at times, but > easy in 3.x. > I've been using 3.2 and Unicode hasn't been much of an issue. My expectation is that yours is the common experience. However, in at least one current thread (on python-ideas) and at a variety of times in the past, _some_ people have found Unicode in Python 3 to make more work. So that got me to thinking about who's experience is the general case, and if any concerns broadly apply to more that framework/library writers (like django, jinja, twisted, etc.). Having usage statistics would be helpful in identifying the impact of things like Unicode in Python 3. -eric From rosuav at gmail.com Sat Feb 11 20:28:30 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 12:28:30 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow wrote: > However, in at > least one current thread (on python-ideas) and at a variety of times > in the past, _some_ people have found Unicode in Python 3 to make more > work. If Unicode in Python is causing you more work, isn't it most likely that the issue would have come up anyway? For instance, suppose you have a web form and you accept customer names, which you then store in a database. You could assume that the browser submits it in UTF-8 and that your database back-end can accept UTF-8, and then pretend that it's all ASCII, but if you then want to upper-case the name for a heading, somewhere you're going to needto deal with Unicode; and when your programming language has facilities like str.upper(), that's going to make it easier, not later. Sure, the simple case is easier if you pretend it's all ASCII, but it's still better to have language facilities. ChrisA From ericsnowcurrently at gmail.com Sat Feb 11 20:38:53 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 18:38:53 -0700 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sat, Feb 11, 2012 at 6:28 PM, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow wrote: >> However, in at >> least one current thread (on python-ideas) and at a variety of times >> in the past, _some_ people have found Unicode in Python 3 to make more >> work. > > If Unicode in Python is causing you more work, isn't it most likely > that the issue would have come up anyway? For instance, suppose you > have a web form and you accept customer names, which you then store in > a database. You could assume that the browser submits it in UTF-8 and > that your database back-end can accept UTF-8, and then pretend that > it's all ASCII, but if you then want to upper-case the name for a > heading, somewhere you're going to needto deal with Unicode; and when > your programming language has facilities like str.upper(), that's > going to make it easier, not later. Sure, the simple case is easier if > you pretend it's all ASCII, but it's still better to have language > facilities. Yeah, that's how I see it too. However, my sample size is much too small to have any sense of the broader Python 3 experience. That's what I'm going for with those Python usage statistics (if it's even feasible). -eric From steve+comp.lang.python at pearwood.info Sat Feb 11 21:23:24 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 02:23:24 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> Message-ID: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:28:30 +1100, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > wrote: >> However, in at >> least one current thread (on python-ideas) and at a variety of times in >> the past, _some_ people have found Unicode in Python 3 to make more >> work. > > If Unicode in Python is causing you more work, isn't it most likely that > the issue would have come up anyway? The argument being made is that in Python 2, if you try to read a file that contains Unicode characters encoded with some unknown codec, you don't have to think about it. Sure, you get moji-bake rubbish in your database, but that's the fault of people who insist on not being American. Or who spell Zoe with an umlaut. In Python 3, if you try the same thing, you get an error. Fixing the error requires thought, and even if that is only a minuscule amount of thought, that's too much for some developers who are scared of Unicode. Hence the FUD that Python 3 is too hard because it makes you learn Unicode. I know this isn't exactly helpful, but I wish they'd just HTFU. I'm with Joel Spolsky on this one: if you're a programmer in 2003 who doesn't have at least a basic working knowledge of Unicode, you're the equivalent of a doctor who doesn't believe in germs. http://www.joelonsoftware.com/articles/Unicode.html Learning a basic working knowledge of Unicode is not that hard. You don't need to be an expert, and it's just not that scary. The use-case given is: "I have a file containing text. I can open it in an editor and see it's nearly all ASCII text, except for a few weird and bizarre characters like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an error. What should I do that requires no thought?" Obvious answers: - Try decoding with UTF8 or Latin1. Even if you don't get the right characters, you'll get *something*. - Use open(filename, encoding='ascii', errors='surrogateescape') (Or possibly errors='ignore'.) -- Steven From rantingrickjohnson at gmail.com Sat Feb 11 21:36:52 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 11 Feb 2012 18:36:52 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 11, 8:23?pm, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 12:28:30 +1100, Chris Angelico wrote: > > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > > wrote: > >> However, in at > >> least one current thread (on python-ideas) and at a variety of times in > >> the past, _some_ people have found Unicode in Python 3 to make more > >> work. > > > If Unicode in Python is causing you more work, isn't it most likely that > > the issue would have come up anyway? > > The argument being made is that in Python 2, if you try to read a file > that contains Unicode characters encoded with some unknown codec, you > don't have to think about it. Sure, you get moji-bake rubbish in your > database, but that's the fault of people who insist on not being > American. Or who spell Zoe with an umlaut. That's not the worst of it... i have many times had a block of text that was valid ASCII except for some intermixed Unicode white-space. Who the hell would even consider inserting Unicode white-space!!! > "I have a file containing text. I can open it in an editor and see it's > nearly all ASCII text, except for a few weird and bizarre characters like > ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > error. What should I do that requires no thought?" > > Obvious answers: the most obvious answer would be to read the file WITHOUT worrying about asinine encoding. From torriem at gmail.com Sat Feb 11 22:35:33 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 11 Feb 2012 20:35:33 -0700 Subject: ldap proxy user bind In-Reply-To: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Message-ID: <4F373385.2090505@gmail.com> On 02/11/2012 02:19 PM, sajuptpm wrote: > Hi Michael Str?der, > Thanks for replay > > Yea i am not totally clear about that > > Client's Requirement is > option to have a ldap proxy user bind to the ldap server if it needs > more directory rights than an anonymous bind. > option to use a ldap proxy user when searching. I wrote a true LDAP proxy server last year that intercepts and rewrites requests (bind, search, modify, etc). I used as my basis the LDAP proxy server that ships with Python-Twisted. Unfortunately I cannot share my code with you, but if you can get your head wrapped around Twisted (it's *extremely* hard to understand how it works at first), then this is the way to go. From torriem at gmail.com Sat Feb 11 23:29:01 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 11 Feb 2012 21:29:01 -0700 Subject: ldap proxy user bind In-Reply-To: <4F373385.2090505@gmail.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> <4F373385.2090505@gmail.com> Message-ID: <4F37400D.2010303@gmail.com> On 02/11/2012 08:35 PM, Michael Torrie wrote: > On 02/11/2012 02:19 PM, sajuptpm wrote: >> Hi Michael Str?der, >> Thanks for replay >> >> Yea i am not totally clear about that >> >> Client's Requirement is >> option to have a ldap proxy user bind to the ldap server if it needs >> more directory rights than an anonymous bind. >> option to use a ldap proxy user when searching. > > I wrote a true LDAP proxy server last year that intercepts and rewrites > requests (bind, search, modify, etc). I used as my basis the LDAP proxy > server that ships with Python-Twisted. Unfortunately I cannot share my > code with you, but if you can get your head wrapped around Twisted (it's > *extremely* hard to understand how it works at first), then this is the > way to go. Okay so I looked over my code. I can share some of it with you if you want. The most simple proxy I could find (I have written several for various purposes) was based on the Twisted LDAP proxy server class (ldaptor.protocols.ldap.proxy). The reason I wrote it was because I had some Sharp multi-function printers that could do LDAP authentication, but instead of binding with a full DN, it would simply bind as "username" which wouldn't work on my ldap server. So I wrote the LDAP proxy server to intercept bind requests (Sharp doesn't even support SSL blah!) and convert it to a proper DN before passing it on to the real LDAP server. Also the LDAP search queries the sharp server generated were crappy, so I rewrote some of the searches as well as they pass through my proxy server. I sharp ===> Twisted LDAP server/Twisted LDAP client ===> ldapserver rewrite bind, rewrite some searches, pass thru everything My other LDAP proxy is fancier and it uses the ldaptor.protocols.ldap.ldapserver.BaseLDAPServer class, and instead of using twisted's LDAP client code, I just use python-ldap. So it's a hybrid approach I suppose. I can strip it down to bare proxy functionality that you could build on. client ==> twisted ldap server/python-ldap client ===> ldapserver Anyway let me know if you want to see some code and I'll post what I can. From rosuav at gmail.com Sat Feb 11 23:38:37 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 15:38:37 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Feb 12, 2012 at 1:36 PM, Rick Johnson wrote: > On Feb 11, 8:23?pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> "I have a file containing text. I can open it in an editor and see it's >> nearly all ASCII text, except for a few weird and bizarre characters like >> ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an >> error. What should I do that requires no thought?" >> >> Obvious answers: > > the most obvious answer would be to read the file WITHOUT worrying > about asinine encoding. What this statement misunderstands, though, is that ASCII is itself an encoding. Files contain bytes, and it's only what's external to those bytes that gives them meaning. The famous "bush hid the facts" trick with Windows Notepad shows the folly of trying to use internal evidence to identify meaning from bytes. Everything that displays text to a human needs to translate bytes into glyphs, and the usual way to do this conceptually is to go via characters. Pretending that it's all the same thing really means pretending that one byte represents one character and that each character is depicted by one glyph. And that's doomed to failure, unless everyone speaks English with no foreign symbols - so, no mathematical notations. ChrisA From nad at acm.org Sun Feb 12 00:28:11 2012 From: nad at acm.org (Ned Deily) Date: Sun, 12 Feb 2012 06:28:11 +0100 Subject: Stopping a looping computation in IDLE 3.2.x References: Message-ID: In article , Franck Ditter wrote: > How do you stop a looping computation with IDLE 3.2.x on MacOS-X Lion ? > It hangs with the colored wheel... > Ctl-C does not work. Ctrl-C in the IDLE shell window works for me on OS X 10.7 Lion. Did you use the python.org 3.2.2 64-bit-/32-bit installer for 10.6? Do you have the latest ActiveState Tcl/Tk 8.5.11 installed? http://www.python.org/download/mac/tcltk/ -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Sun Feb 12 00:51:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 05:51:03 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > Everything that displays text to a human needs to translate bytes into > glyphs, and the usual way to do this conceptually is to go via > characters. Pretending that it's all the same thing really means > pretending that one byte represents one character and that each > character is depicted by one glyph. And that's doomed to failure, unless > everyone speaks English with no foreign symbols - so, no mathematical > notations. Pardon me, but you can't even write *English* in ASCII. You can't say that it cost you ?10 to courier your r?sum? to the head office of Encyclop?dia Britanica to apply for the position of Staff Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy and old-fashioned, but it is traditional English.) Hell, you can't even write in *American*: you can't say that the recipe for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. ASCII truly is a blight on the world, and the sooner it fades into obscurity, like EBCDIC, the better. Even if everyone did change to speak ASCII, you still have all the historical records and documents and files to deal with. Encodings are not going away. -- Steven From rosuav at gmail.com Sun Feb 12 01:08:24 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 17:08:24 +1100 Subject: Python usage numbers In-Reply-To: <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano wrote: > You can't say that it cost you ?10 to courier your r?sum? to the head > office of Encyclop?dia Britanica to apply for the position of Staff > Co?rdinator. True, but if it cost you $10 (or 10 GBP) to courier your curriculum vitae to the head office of Encyclopaedia Britannica to become Staff Coordinator, then you'd be fine. And if it cost you $10 to post your work summary to Britannica's administration to apply for this Staff Coordinator position, you could say it without 'e' too. Doesn't mean you don't need Unicode! ChrisA From steve+comp.lang.python at pearwood.info Sun Feb 12 01:10:20 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 06:10:20 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sat, 11 Feb 2012 18:36:52 -0800, Rick Johnson wrote: >> "I have a file containing text. I can open it in an editor and see it's >> nearly all ASCII text, except for a few weird and bizarre characters >> like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I >> get an error. What should I do that requires no thought?" >> >> Obvious answers: > > the most obvious answer would be to read the file WITHOUT worrying about > asinine encoding. Your mad leet reading comprehension skillz leave me in awe Rick. If you try to read a file containing non-ASCII characters encoded using UTF8 on Windows without explicitly specifying either UTF8 as the encoding, or an error handler, you will get an exception. It's not just UTF8 either, but nearly all encodings. You can't even expect to avoid problems if you stick to nothing but Windows, because Windows' default encoding is localised: a file generated in (say) Israel or Japan or Germany will use a different code page (encoding) by default than one generated in (say) the US, Canada or UK. -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 01:41:20 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 06:41:20 GMT Subject: Numeric root-finding in Python Message-ID: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to improve the approximation. This mostly works well, but sometimes the root-finder gets stuck in a cycle. Here's my function: import math def improve(x, w, exp=math.exp): """Use Halley's method to improve an estimate of W(x) given an initial estimate w. """ try: for i in range(36): # Max number of iterations. ew = exp(w) a = w*ew - x b = ew*(w + 1) err = -a/b # Estimate of the error in the current w. if abs(err) <= 1e-16: break print '%d: w= %r err= %r' % (i, w, err) # Make a better estimate. c = (w + 2)*a/(2*w + 2) delta = a/(b - c) w -= delta else: raise RuntimeError('calculation failed to converge', err) except ZeroDivisionError: assert w == -1 return w Here's an example where improve() converges very quickly: py> improve(-0.36, -1.222769842388856) 0: w= -1.222769842388856 err= -2.9158979924038895e-07 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 -1.222770133978506 That's what I expect: convergence in only a few iterations. Here's an example where it gets stuck in a cycle, bouncing back and forth between two values: py> improve(-0.36787344117144249, -1.0057222396915309) 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 [...] 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 Traceback (most recent call last): File "", line 1, in File "", line 19, in improve RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) (The correct value for w is approximately -1.00572223991.) I know that Newton's method is subject to cycles, but I haven't found any discussion about Halley's method and cycles, nor do I know what the best approach for breaking them would be. None of the papers on calculating the Lambert W function that I have found mentions this. Does anyone have any advice for solving this? -- Steven From bahamutzero8825 at gmail.com Sun Feb 12 02:05:35 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 12 Feb 2012 01:05:35 -0600 Subject: Python usage numbers In-Reply-To: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3764BF.1010602@gmail.com> On 2/12/2012 12:10 AM, Steven D'Aprano wrote: > It's not just UTF8 either, but nearly all encodings. You can't even > expect to avoid problems if you stick to nothing but Windows, because > Windows' default encoding is localised: a file generated in (say) Israel > or Japan or Germany will use a different code page (encoding) by default > than one generated in (say) the US, Canada or UK. Generated by what? Windows will store a locale value for programs to use, but programs use Unicode internally by default (i.e., API calls are Unicode unless they were built for old versions of Windows), and the default filesystem (NTFS) uses Unicode for file names. AFAIK, only the terminal has a localized code page by default. Perhaps Notepad will write text files with the localized code page by default, but that's an application choice... -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From sajuptpm at gmail.com Sun Feb 12 02:16:30 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Sat, 11 Feb 2012 23:16:30 -0800 (PST) Subject: ldap proxy user bind References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> <4F373385.2090505@gmail.com> Message-ID: <3e195947-d67f-42ae-9e9d-6fd111a6beec@ow3g2000pbc.googlegroups.com> Hi Michael Torrie, Thanks to reply Why we need Twisted here, i did not get it. My understanding is that if ldap_proxy_user = ldap_proxy ldap_proxy_pwd = secret ( set more privileges to this user at ldap server side, for get other users infos) are configured at server side, then allow clients to login using username only, this time use ldap_proxy_user and ldap_proxy_pwd for login to ldap server, user validation and get user infos. Is it possible and any drawback ???? I think this is what client need. From mcepl at redhat.com Sun Feb 12 03:14:44 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 12 Feb 2012 09:14:44 +0100 Subject: Python usage numbers In-Reply-To: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12.2.2012 03:23, Steven D'Aprano wrote: > The use-case given is: > > "I have a file containing text. I can open it in an editor and see it's > nearly all ASCII text, except for a few weird and bizarre characters like > ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > error. What should I do that requires no thought?" > > Obvious answers: > > - Try decoding with UTF8 or Latin1. Even if you don't get the right > characters, you'll get *something*. > > - Use open(filename, encoding='ascii', errors='surrogateescape') > > (Or possibly errors='ignore'.) These are not good answer, IMHO. The only answer I can think of, really, is: - pack you luggage, your submarine waits on you to peel onions in it (with reference to the Joel's article). Meaning, really, you should learn your craft and pull up your head from the sand. There is a wider world around you. (and yes, I am a Czech, so I need at least latin-2 for my language). Best, Mat?j From mcepl at redhat.com Sun Feb 12 03:26:57 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 12 Feb 2012 09:26:57 +0100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12.2.2012 09:14, Matej Cepl wrote: >> Obvious answers: >> >> - Try decoding with UTF8 or Latin1. Even if you don't get the right >> characters, you'll get *something*. >> >> - Use open(filename, encoding='ascii', errors='surrogateescape') >> >> (Or possibly errors='ignore'.) > > These are not good answer, IMHO. The only answer I can think of, really, > is: Slightly less flameish answer to the question ?What should I do, really?? is a tough one: all these suggested answers are bad because they don?t deal with the fact, that your input data are obviously broken. The rest is just pure GIGO ? without fixing (and I mean, really, fixing, not ignoring the problem, which is what the previous answers suggest) your input, you?ll get garbage on output. And you should be thankful to py3k that it shown the issue to you. BTW, can you display the following line? P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. Best, Mat?j From jackdied at gmail.com Sun Feb 12 04:04:43 2012 From: jackdied at gmail.com (Jack Diederich) Date: Sun, 12 Feb 2012 04:04:43 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> Message-ID: just google "jack diederich decorators" it costs nothing and you get a free pycon talk out of it. -Jack From steve+comp.lang.python at pearwood.info Sun Feb 12 04:12:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 09:12:57 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 01:05:35 -0600, Andrew Berg wrote: > On 2/12/2012 12:10 AM, Steven D'Aprano wrote: >> It's not just UTF8 either, but nearly all encodings. You can't even >> expect to avoid problems if you stick to nothing but Windows, because >> Windows' default encoding is localised: a file generated in (say) >> Israel or Japan or Germany will use a different code page (encoding) by >> default than one generated in (say) the US, Canada or UK. > Generated by what? Windows will store a locale value for programs to > use, but programs use Unicode internally by default Which programs? And we're not talking about what they use internally, but what they write to files. > (i.e., API calls are > Unicode unless they were built for old versions of Windows), and the > default filesystem (NTFS) uses Unicode for file names. No. File systems do not use Unicode for file names. Unicode is an abstract mapping between code points and characters. File systems are written using bytes. Suppose you're a fan of Russian punk bank ???? and you have a directory of their music. The file system doesn't store the Unicode code points 1053 1072 1253 1074, it has to be encoded to a sequence of bytes first. NTFS by default uses the UTF-16 encoding, which means the actual bytes written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading byte-order mark \xff\xfe). Windows has two separate APIs, one for "wide" characters, the other for single bytes. Depending on which one you use, the directory will appear to be called ???? or 0?2. But in any case, we're not talking about the file name encoding. We're talking about the contents of files. > AFAIK, only the > terminal has a localized code page by default. Perhaps Notepad will > write text files with the localized code page by default, but that's an > application choice... Exactly. And unless you know what encoding the application chooses, you will likely get an exception trying to read the file. -- Steven From anh.hai.trinh at gmail.com Sun Feb 12 04:41:16 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 01:41:16 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <28799160.595.1329039676879.JavaMail.geo-discussion-forums@pbbmq9> Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? extproc does this, but you opted to write a recursive descent parser. I'm sure it's fun but I think simple is better than complex. Most users would prefer not to deal with Python, not another language. * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. For a shell-like library, I would recommend its users to never use threads (so that those who do otherwise know what they are in for). From anh.hai.trinh at gmail.com Sun Feb 12 04:41:16 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 01:41:16 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <28799160.595.1329039676879.JavaMail.geo-discussion-forums@pbbmq9> Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? extproc does this, but you opted to write a recursive descent parser. I'm sure it's fun but I think simple is better than complex. Most users would prefer not to deal with Python, not another language. * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. For a shell-like library, I would recommend its users to never use threads (so that those who do otherwise know what they are in for). From hoogendoorn.eelco at gmail.com Sun Feb 12 05:10:49 2012 From: hoogendoorn.eelco at gmail.com (Eelco) Date: Sun, 12 Feb 2012 02:10:49 -0800 (PST) Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 7:41?am, Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > ? ? """Use Halley's method to improve an estimate of W(x) given > ? ? an initial estimate w. > ? ? """ > ? ? try: > ? ? ? ? for i in range(36): ?# Max number of iterations. > ? ? ? ? ? ? ew = exp(w) > ? ? ? ? ? ? a = w*ew - x > ? ? ? ? ? ? b = ew*(w + 1) > ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. > ? ? ? ? ? ? if abs(err) <= 1e-16: > ? ? ? ? ? ? ? ? break > ? ? ? ? ? ? print '%d: w= %r err= %r' % (i, w, err) > ? ? ? ? ? ? # Make a better estimate. > ? ? ? ? ? ? c = (w + 2)*a/(2*w + 2) > ? ? ? ? ? ? delta = a/(b - c) > ? ? ? ? ? ? w -= delta > ? ? ? ? else: > ? ? ? ? ? ? raise RuntimeError('calculation failed to converge', err) > ? ? except ZeroDivisionError: > ? ? ? ? assert w == -1 > ? ? return w > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > ? File "", line 1, in > ? File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? > > -- > Steven Looks like floating point issues to me, rather than something intrinsic to the iterative algorithm. Surely there is not complex chaotic behavior to be found in this fairly smooth function in a +/- 1e-14 window. Otoh, there is a lot of floating point significant bit loss issues to be suspected in the kind of operations you are performing (exp(x) + something, always a tricky one). I would start by asking: How accurate is good enough? If its not good enough, play around the the ordering of your operations, try solving a transformed problem less sensitive to loss of significance; and begin by trying different numeric types to see if the problem is sensitive thereto to begin with. From bahamutzero8825 at gmail.com Sun Feb 12 06:11:30 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 12 Feb 2012 05:11:30 -0600 Subject: Python usage numbers In-Reply-To: <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F379E62.2040009@gmail.com> On 2/12/2012 3:12 AM, Steven D'Aprano wrote: > NTFS by default uses the UTF-16 encoding, which means the actual bytes > written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading > byte-order mark \xff\xfe). That's what I meant. Those bytes will be interpreted consistently across all locales. > Windows has two separate APIs, one for "wide" characters, the other for > single bytes. Depending on which one you use, the directory will appear > to be called ???? or 0?2. Yes, and AFAIK, the wide API is the default. The other one only exists to support programs that don't support the wide API (generally, such programs were intended to be used on older platforms that lack that API). > But in any case, we're not talking about the file name encoding. We're > talking about the contents of files. Okay then. As I stated, this has nothing to do with the OS since programs are free to interpret bytes any way they like. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From vinay_sajip at yahoo.co.uk Sun Feb 12 06:31:02 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 03:31:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: Message-ID: On Feb 12, 9:41?am, Anh Hai Trinh wrote: > Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: > > * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? It's not hard for the user, and less work e.g. when migrating from an existing Bash script. I may have put in the effort to use a recursive descent parser under the hood, but why should the user of the library care? It doesn't make their life harder. And it's not complicated, not even particularly complex - such parsers are commonplace. > * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. By that token, disasters await if you ever use threads, unless you know what you're doing (and sometimes even then). Sarge doesn't force the use of threads with forking - you can do everything synchronously if you want. The test suite does cover the particular case of thread +fork. Do you have specific caveats, or is it just a "there be dragons" sentiment? Sarge is still in alpha status; no doubt bugs will surface, but unless a real show-stopper occurs, there's not much to be gained by throwing up our hands. BTW extproc is nice, but I wanted to push the envelope a little :-) Regards, Vinay Sajip From dihedral88888 at googlemail.com Sun Feb 12 06:48:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 03:48:32 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7765462.72.1329047312690.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?10????UTC+8??2?32?09??anon hung??? > >> Guide to: Learning Python Decorators > >> New Book http://tinyurl.com/python-decorartor > > > > A whole book about decorators? Cool. I'm going to start writing books to. > > I'll start with 'The Python print statement'. Then to be cutting edge I'll > > follow with 'The Python print function'. > There are books about classes in other computer languages, too. Using decorator is more elegant in reducing the class levels in applications. Just deep copying an object in more than 10 levels of an inherited class hiarchie is so slow. From dihedral88888 at googlemail.com Sun Feb 12 06:48:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 03:48:32 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7765462.72.1329047312690.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?10????UTC+8??2?32?09??anon hung??? > >> Guide to: Learning Python Decorators > >> New Book http://tinyurl.com/python-decorartor > > > > A whole book about decorators? Cool. I'm going to start writing books to. > > I'll start with 'The Python print statement'. Then to be cutting edge I'll > > follow with 'The Python print function'. > There are books about classes in other computer languages, too. Using decorator is more elegant in reducing the class levels in applications. Just deep copying an object in more than 10 levels of an inherited class hiarchie is so slow. From breamoreboy at yahoo.co.uk Sun Feb 12 07:11:01 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Feb 2012 12:11:01 +0000 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/02/2012 08:26, Matej Cepl wrote: > On 12.2.2012 09:14, Matej Cepl wrote: >>> Obvious answers: >>> >>> - Try decoding with UTF8 or Latin1. Even if you don't get the right >>> characters, you'll get *something*. >>> >>> - Use open(filename, encoding='ascii', errors='surrogateescape') >>> >>> (Or possibly errors='ignore'.) >> >> These are not good answer, IMHO. The only answer I can think of, really, >> is: > > Slightly less flameish answer to the question ?What should I do, > really?? is a tough one: all these suggested answers are bad because > they don?t deal with the fact, that your input data are obviously > broken. The rest is just pure GIGO ? without fixing (and I mean, really, > fixing, not ignoring the problem, which is what the previous answers > suggest) your input, you?ll get garbage on output. And you should be > thankful to py3k that it shown the issue to you. > > BTW, can you display the following line? > > P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. > > Best, > > Mat?j Yes in Thunderbird, Notepad, Wordpad and Notepad++ on Windows Vista, can't be bothered to try any other apps. -- Cheers. Mark Lawrence. From waqif at smartbaba.com Sun Feb 12 07:51:34 2012 From: waqif at smartbaba.com (Smart Baba) Date: Sun, 12 Feb 2012 04:51:34 -0800 (PST) Subject: Limited time offer, so hurry up! Message-ID: Take advantage of Smart Baba new offer and get your own customized professional website and promote your business. For further details, Follow us: www.websitedeals.in From michael at stroeder.com Sun Feb 12 07:57:51 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Sun, 12 Feb 2012 13:57:51 +0100 Subject: ldap proxy user bind In-Reply-To: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Message-ID: sajuptpm wrote: > Yea i am not totally clear about that > > Client's Requirement is > option to have a ldap proxy user bind to the ldap server if it needs > more directory rights than an anonymous bind. > option to use a ldap proxy user when searching. As said: there's the proxy authorization control (see RFC 4370) for which a Python class exists in python-ldap. This is used e.g. in web applications if the user has successfully authenticated to the application and his identity should be used when processing ACLs in the LDAP server. In this case the "proxy user" is trusted entity to have done authentication right. The proxy authz control is sent by the application with each LDAP request. The server has to be correctly configured to accept that. Another option is a LDAP proxy server which accepts anon requests and binds as a certain user. You could OpenLDAP with back-ldap or back-meta for that. So you should ask your customer what's really needed. Ciao, Michael. From dihedral88888 at googlemail.com Sun Feb 12 08:13:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 05:13:16 -0800 (PST) Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3267176.47.1329052396463.JavaMail.geo-discussion-forums@pbcqx4> ? 2012?2?12????UTC+8??2?41?20??Steven D'Aprano??? > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > """Use Halley's method to improve an estimate of W(x) given > an initial estimate w. > """ > try: > for i in range(36): # Max number of iterations. > ew = exp(w) > a = w*ew - x W*EXP(W) can converge for negative values of W > b = ew*(w + 1) b=exp(W)*W+W > err = -a/b # Estimate of the error in the current w. What's X not expalained? > if abs(err) <= 1e-16: > break > print '%d: w= %r err= %r' % (i, w, err) > # Make a better estimate. > c = (w + 2)*a/(2*w + 2) > delta = a/(b - c) > w -= delta > else: > raise RuntimeError('calculation failed to converge', err) > except ZeroDivisionError: > assert w == -1 > return w > > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > File "", line 1, in > File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? > > > > -- > Steven I sugest you can use Taylor's series expansion to speed up w*exp(w) for negative values of w. From breamoreboy at yahoo.co.uk Sun Feb 12 08:39:38 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Feb 2012 13:39:38 +0000 Subject: Numeric root-finding in Python In-Reply-To: References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/02/2012 10:10, Eelco wrote: > On Feb 12, 7:41 am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> This is only peripherally a Python problem, but in case anyone has any >> good ideas I'm going to ask it. >> >> I have a routine to calculate an approximation of Lambert's W function, >> and then apply a root-finding technique to improve the approximation. >> This mostly works well, but sometimes the root-finder gets stuck in a >> cycle. >> >> Here's my function: >> >> import math >> def improve(x, w, exp=math.exp): >> """Use Halley's method to improve an estimate of W(x) given >> an initial estimate w. >> """ >> try: >> for i in range(36): # Max number of iterations. >> ew = exp(w) >> a = w*ew - x >> b = ew*(w + 1) >> err = -a/b # Estimate of the error in the current w. >> if abs(err)<= 1e-16: >> break >> print '%d: w= %r err= %r' % (i, w, err) >> # Make a better estimate. >> c = (w + 2)*a/(2*w + 2) >> delta = a/(b - c) >> w -= delta >> else: >> raise RuntimeError('calculation failed to converge', err) >> except ZeroDivisionError: >> assert w == -1 >> return w >> >> Here's an example where improve() converges very quickly: >> >> py> improve(-0.36, -1.222769842388856) >> 0: w= -1.222769842388856 err= -2.9158979924038895e-07 >> 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 >> -1.222770133978506 >> >> That's what I expect: convergence in only a few iterations. >> >> Here's an example where it gets stuck in a cycle, bouncing back and forth >> between two values: >> >> py> improve(-0.36787344117144249, -1.0057222396915309) >> 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> [...] >> 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 19, in improve >> RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) >> >> (The correct value for w is approximately -1.00572223991.) >> >> I know that Newton's method is subject to cycles, but I haven't found any >> discussion about Halley's method and cycles, nor do I know what the best >> approach for breaking them would be. None of the papers on calculating >> the Lambert W function that I have found mentions this. >> >> Does anyone have any advice for solving this? >> >> -- >> Steven > > Looks like floating point issues to me, rather than something > intrinsic to the iterative algorithm. Surely there is not complex > chaotic behavior to be found in this fairly smooth function in a +/- > 1e-14 window. Otoh, there is a lot of floating point significant bit > loss issues to be suspected in the kind of operations you are > performing (exp(x) + something, always a tricky one). > > I would start by asking: How accurate is good enough? If its not good > enough, play around the the ordering of your operations, try solving a > transformed problem less sensitive to loss of significance; and begin > by trying different numeric types to see if the problem is sensitive > thereto to begin with. HTH. c:\Users\Mark\Python>type sda.py import decimal def improve(x, w, exp=decimal.Decimal.exp): """Use Halley's method to improve an estimate of W(x) given an initial estimate w. """ try: for i in range(36): # Max number of iterations. ew = exp(w) a = w*ew - x b = ew*(w + 1) err = -a/b # Estimate of the error in the current w. if abs(err) <= 1e-16: break print '%d: w= %r err= %r' % (i, w, err) # Make a better estimate. c = (w + 2)*a/(2*w + 2) delta = a/(b - c) w -= delta else: raise RuntimeError('calculation failed to converge', err) print '%d: w= %r err= %r' % (i, w, err) except ZeroDivisionError: assert w == -1 return w improve(decimal.Decimal('-0.36'), decimal.Decimal('-1.222769842388856')) improve(decimal.Decimal('-0.36787344117144249'), decimal.Decimal('-1.0057222396915309')) c:\Users\Mark\Python>sda.py 0: w= Decimal('-1.222769842388856') err= Decimal('-2.915897982757542086414504607E-7') 1: w= Decimal('-1.222770133978505953034526059') err= Decimal('-1.084120148360381932277303211E-19') 0: w= Decimal('-1.0057222396915309') err= Decimal('5.744538819905061986438230561E-15') 1: w= Decimal('-1.005722239691525155461180092') err= Decimal('-0E+2') -- Cheers. Mark Lawrence. From robert.kern at gmail.com Sun Feb 12 08:52:48 2012 From: robert.kern at gmail.com (Robert Kern) Date: Sun, 12 Feb 2012 13:52:48 +0000 Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/12 6:41 AM, Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. I don't have any advice for fixing your code, per se, but I would just grab mpmath and use their lambertw function: http://mpmath.googlecode.com/svn/trunk/doc/build/functions/powers.html#lambert-w-function -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From roy at panix.com Sun Feb 12 10:13:07 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 10:13:07 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Sun, Feb 12, 2012 at 1:36 PM, Rick Johnson > wrote: > > On Feb 11, 8:23?pm, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: > >> "I have a file containing text. I can open it in an editor and see it's > >> nearly all ASCII text, except for a few weird and bizarre characters like > >> ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > >> error. What should I do that requires no thought?" > >> > >> Obvious answers: > > > > the most obvious answer would be to read the file WITHOUT worrying > > about asinine encoding. > > What this statement misunderstands, though, is that ASCII is itself an > encoding. Files contain bytes, and it's only what's external to those > bytes that gives them meaning. Exactly. . ASCII was so successful at becoming a universal standard which lasted for decades, people who grew up with it don't realize there was once any other way. Not just EBCDIC, but also SIXBIT, RAD-50, tilt/rotate, packed card records, and so on. Transcoding was a way of life, and if you didn't know what you were starting with and aiming for, it was hopeless. Kind of like now where we are again with Unicode. From inq1ltd at inqvista.com Sun Feb 12 10:20:17 2012 From: inq1ltd at inqvista.com (inq1ltd) Date: Sun, 12 Feb 2012 10:20:17 -0500 Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2276591.XVerqeASP3@mach-114-20> I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 rather than; except ZeroDivisionError: assert w == -1 jimonlinux On Sunday, February 12, 2012 06:41:20 AM Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > """Use Halley's method to improve an estimate of W(x) given > an initial estimate w. > """ > try: > for i in range(36): # Max number of iterations. > ew = exp(w) > a = w*ew - x > b = ew*(w + 1) > err = -a/b # Estimate of the error in the current w. > if abs(err) <= 1e-16: > break > print '%d: w= %r err= %r' % (i, w, err) > # Make a better estimate. > c = (w + 2)*a/(2*w + 2) > delta = a/(b - c) > w -= delta > else: > raise RuntimeError('calculation failed to converge', err) > except ZeroDivisionError: > assert w == -1 > return w > > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > File "", line 1, in > File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? From anh.hai.trinh at gmail.com Sun Feb 12 10:35:08 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 07:35:08 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> > It's not hard for the user I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. Re. threads & fork(): http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them For a careful impl of fork-exec with threads, see http://golang.org/src/pkg/syscall/exec_unix.go > By that token, disasters await if you ever use threads, unless you know what you're doing So don't, this package is mainly a fork-exec-wait library providing shell-like functionalities. Just use fork(). > BTW extproc is nice, but I wanted to push the envelope a little :-) Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p I do think that IO redirection is much nicer with extproc. From roy at panix.com Sun Feb 12 10:48:36 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 10:48:36 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4f375347$0$29986$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > ASCII truly is a blight on the world, and the sooner it fades into > obscurity, like EBCDIC, the better. That's a fair statement, but it's also fair to say that at the time it came out (49 years ago!) it was a revolutionary improvement on the extant state of affairs (every manufacturer inventing their own code, and often different codes for different machines). Given the cost of both computer memory and CPU cycles at the time, sticking to a 7-bit code (the 8th bit was for parity) was a necessary evil. As Steven D'Aprano pointed out, it was missing some commonly used US symbols such as ?? or ??. This was a small price to pay for the simplicity ASCII afforded. It wasn't a bad encoding. I was a very good encoding. But the world has moved on and computing hardware has become cheap enough that supporting richer encodings and character sets is realistic. And, before people complain about the character set being US-Centric, keep in mind that the A in ASCII stands for American, and it was published by ANSI (whose A also stands for American). I'm not trying to wave the flag here, just pointing out that it was never intended to be anything other than a national character set. Part of the complexity of Unicode is that when people switch from working with ASCII to working with Unicode, they're really having to master two distinct things at the same time (and often conflate them into a single confusing mess). One is the Unicode character set. The other is a specific encoding (UTF-8, UTF-16, etc). Not to mention silly things like BOM (Byte Order Mark). I expect that some day, storage costs will become so cheap that we'll all just be using UTF-32, and programmers of the day will wonder how their poor parents and grandparents ever managed in a world where nobody quite knew what you meant when you asked, "how long is that string?". From dan at tombstonezero.net Sun Feb 12 10:55:17 2012 From: dan at tombstonezero.net (Dan Sommers) Date: Sun, 12 Feb 2012 15:55:17 +0000 (UTC) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, 12 Feb 2012 17:08:24 +1100, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano > wrote: >> You can't say that it cost you ?10 to courier your r?sum? to the head >> office of Encyclop?dia Britanica to apply for the position of Staff >> Co?rdinator. > > True, but if it cost you $10 (or 10 GBP) to courier your curriculum > vitae to the head office of Encyclopaedia Britannica to become Staff > Coordinator, then you'd be fine. And if it cost you $10 to post your > work summary to Britannica's administration to apply for this Staff > Coordinator position, you could say it without 'e' too. Doesn't mean you > don't need Unicode! Back in the late 1970's, the economy and the outlook in the USA sucked, and the following joke made the rounds: Mr. Smith: Good morning, Mr. Jones. How are you? Mr. Jones: I'm fine. (The humor is that Mr. Jones had his head so far [in the sand] that he thought that things were fine.) American English is my first spoken language, but I know enough French, Greek, math, and other languages that I am very happy to have more than ASCII these days. I imagine that even Steven's surname should be spelled D?Aprano rather than D'Aprano. Dan From anh.hai.trinh at gmail.com Sun Feb 12 11:19:18 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 08:19:18 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <10831099.690.1329063558642.JavaMail.geo-discussion-forums@pbcmg9> > For a careful impl of fork-exec with threads, see http://golang.org/src/pkg/syscall/exec_unix.go I forgot to mention that this impl is indeed "correct" only because you cannot start thread or call fork() directly in the Go language, other than use goroutines and the ForkExec() function implemented there. So all that locking is internal. If you use threads and call fork(), you'll almost guaranteed to face with deadlocks. Perhaps not in a particular piece of code, but some others. Perhaps not on your laptop, but on the production machine with different kernels. Like most race conditions, they will eventually show up. From rustompmody at gmail.com Sun Feb 12 11:50:28 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 12 Feb 2012 08:50:28 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 10:51?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > Everything that displays text to a human needs to translate bytes into > > glyphs, and the usual way to do this conceptually is to go via > > characters. Pretending that it's all the same thing really means > > pretending that one byte represents one character and that each > > character is depicted by one glyph. And that's doomed to failure, unless > > everyone speaks English with no foreign symbols - so, no mathematical > > notations. > > Pardon me, but you can't even write *English* in ASCII. > > You can't say that it cost you ?10 to courier your r?sum? to the head > office of Encyclop?dia Britanica to apply for the position of Staff > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > and old-fashioned, but it is traditional English.) > > Hell, you can't even write in *American*: you can't say that the recipe > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. [Quite OT but...] How do you type all this? [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] From d at davea.name Sun Feb 12 12:00:33 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 12:00:33 -0500 Subject: Numeric root-finding in Python In-Reply-To: <2276591.XVerqeASP3@mach-114-20> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <2276591.XVerqeASP3@mach-114-20> Message-ID: <4F37F031.8090104@davea.name> On 02/12/2012 10:20 AM, inq1ltd wrote: > > I don't know the first thing about this math problem however, > > if I were to code this I might try ; > > except ZeroDivisionError: > assert w = -1 You top-posted. Please type your response after whatever you're quoting. In my case, I only need a portion of what you said, and my remarks are following it. assert takes an expression, so the one above is just wrong. Fortunately, Python would tell you with SyntaxError: invalid syntax -- DaveA From roy at panix.com Sun Feb 12 12:11:46 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 12:11:46 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Dennis Lee Bieber wrote: > On Sun, 12 Feb 2012 10:48:36 -0500, Roy Smith wrote: > > >As Steven D'Aprano pointed out, it was missing some commonly used US > >symbols such as ?? or ??. That's interesting. When I wrote that, it showed on my screen as a cent symbol and a copyright symbol. What I see in your response is an upper case "A" with a hat accent (circumflex?) over it followed by a cent symbol, and likewise an upper case "A" with a hat accent over it followed by copyright symbol. Oh, for the days of ASCII again :-) Not to mention, of course, that I wrote , but I fully expect some of you will be reading this with absurd clients which turn that into some kind of smiley-face image. > Any volunteers to create an Extended Baudot... Instead of "letter > shift" and "number shift" we could have a generic "encoding shift" which > uses the following characters to identify which 7-bit subset of Unicode > is to be represented I think that's called UTF-8. From roy at panix.com Sun Feb 12 12:21:27 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 12:21:27 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , rusi wrote: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > Everything that displays text to a human needs to translate bytes into > > > glyphs, and the usual way to do this conceptually is to go via > > > characters. Pretending that it's all the same thing really means > > > pretending that one byte represents one character and that each > > > character is depicted by one glyph. And that's doomed to failure, unless > > > everyone speaks English with no foreign symbols - so, no mathematical > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] What I do (on a Mac) is open the Keyboard Viewer thingie and try various combinations of shift-control-option-command-function until the thing I'm looking for shows up on a keycap. A few of them I've got memorized (for example, option-8 gets you a bullet ?). I would imagine if you commonly type in a language other than English, you would quickly memorize the ones you use a lot. Or, open the Character Viewer thingie and either hunt around the various drill-down menus (North American Scripts / Canadian Aboriginal Syllabics, for example) or type in some guess at the official unicode name into the search box. From nicholas.dokos at hp.com Sun Feb 12 12:36:30 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Sun, 12 Feb 2012 12:36:30 -0500 Subject: Python usage numbers In-Reply-To: Message from rusi of "Sun\, 12 Feb 2012 08\:50\:28 PST." References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7533.1329068190@alphaville> rusi wrote: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > Everything that displays text to a human needs to translate bytes into > > > glyphs, and the usual way to do this conceptually is to go via > > > characters. Pretending that it's all the same thing really means > > > pretending that one byte represents one character and that each > > > character is depicted by one glyph. And that's doomed to failure, unless > > > everyone speaks English with no foreign symbols - so, no mathematical > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] [Emacs speficic] Many different ways of course, but in emacs, you can select e.g. the TeX input method with C-x RET C-\ TeX RET. which does all of the above symbols with the exception of the cent symbol (or maybe I missed it) - you type the thing in the first column and you get the thing in the second column \pounds ? \'e ? \ae ? \"o ? ^{TM} ? \copyright ? I gave up on the cent symbol and used ucs-insert (C-x 8 RET) which allows you to type a name, in this case CENT SIGN to get ?. Nick From ppearson at nowhere.invalid Sun Feb 12 12:58:45 2012 From: ppearson at nowhere.invalid (Peter Pearson) Date: 12 Feb 2012 17:58:45 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9pqculF83rU1@mid.individual.net> On 12 Feb 2012 09:12:57 GMT, Steven D'Aprano wrote: > > Suppose you're a fan of Russian punk bank ???? and you have a directory > of their music. Sigh. Banking ain't what it used to be. I'm sticking with classical Muzak. -- To email me, substitute nowhere->spamcop, invalid->net. From f.pollastri at inrim.it Sun Feb 12 13:46:04 2012 From: f.pollastri at inrim.it (Fabrizio Pollastri) Date: Sun, 12 Feb 2012 19:46:04 +0100 Subject: package extension problem Message-ID: <4F3808EC.1000301@inrim.it> Hello, I wish to extend the functionality of an existing python package by creating a new package that redefines the relevant classes of the old package. Each new class inherits the equivalent old class and adds new methods. In the new package there is something like the following. import old_package as op class A(op.A): ... add new methods ... class B(op.B): ... add new methods ... Some classes of the old package works as a dictionary of other classes of the same old package. Example: if class A and class B are classes of the old package, B[some_hash] returns an instance of A. When a program imports the new package and create instances of the new class B, B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. There is a way to solve this problem without redefining in the new package all the methods of the old package that return old classes? Thanks in advance for any suggestion, Fabrizio From not_here at no-where.net Sun Feb 12 13:53:56 2012 From: not_here at no-where.net (Brian) Date: Sun, 12 Feb 2012 10:53:56 -0800 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/2/2012 1:21 AM, Terry Reedy wrote: > On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: >> On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy >> wrote: >>> And it bothers me that you imput such ignorance to me. You >>> made what I think >>> was a bad analogy and I made a better one of the same type, >>> though still >>> imperfect. I acknowledged that the transition will take years. >> >> Ah. It is a common attitude among those that make these sorts of >> comments about Python 3, and I hadn't read anything in what >> you said >> that made me think that you were considering more than the >> superficial >> costs of moving. > > I thought '95% in 10 years' would be a hint that I know > upgrading is not trivial for every one ;-). > >> I am sorry that I did not give you the benefit of the doubt. > > Apology accepted. This is OT, but relevant to the side discussion. Also note that the community respects and appreciates the T.J. Reedy contributions and hard work. Reality. It was a monumental task to convert ATE driver dev and related factory automation stuff from C to Python starting in 2000. Most was done guerrilla-style. My employer now appreciates the resultant infrastructure that even the Mexico factory engineering team can use, and is good for their pride because they are no longer totally dependent on gringo engineers. Am currently being disruptive to their little world with my recent (1Q 2011) switch to 3.x. The corporate natives are restless and there is talk of an armed insurrection. Humans, at the tribal level, do not adapt to change. Expect a long series of battles that are ruthless, bloody, and have a high body count. Vive la Revolution. From alister.ware at ntlworld.com Sun Feb 12 13:55:50 2012 From: alister.ware at ntlworld.com (alister) Date: Sun, 12 Feb 2012 18:55:50 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, 12 Feb 2012 12:11:01 +0000, Mark Lawrence wrote: > On 12/02/2012 08:26, Matej Cepl wrote: >> On 12.2.2012 09:14, Matej Cepl wrote: >>>> Obvious answers: >>>> >>>> - Try decoding with UTF8 or Latin1. Even if you don't get the right >>>> characters, you'll get *something*. >>>> >>>> - Use open(filename, encoding='ascii', errors='surrogateescape') >>>> >>>> (Or possibly errors='ignore'.) >>> >>> These are not good answer, IMHO. The only answer I can think of, >>> really, >>> is: >> >> Slightly less flameish answer to the question ?What should I do, >> really?? is a tough one: all these suggested answers are bad because >> they don?t deal with the fact, that your input data are obviously >> broken. The rest is just pure GIGO ? without fixing (and I mean, >> really, >> fixing, not ignoring the problem, which is what the previous answers >> suggest) your input, you?ll get garbage on output. And you should be >> thankful to py3k that it shown the issue to you. >> >> BTW, can you display the following line? >> >> P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. >> >> Best, >> >> Mat?j > > Yes in Thunderbird, Notepad, Wordpad and Notepad++ on Windows Vista, > can't be bothered to try any other apps. Pan seems to be fine , they at least look like letters not just blocks -- Appearances often are deceiving. -- Aesop From wxjmfauth at gmail.com Sun Feb 12 14:52:46 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 12 Feb 2012 11:52:46 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: There is so much to say on the subject, I do not know where to start. Some points. Today, Sunday, 12 February 2012, 90%, if not more, of the Python applications supposed to work with text and I'm toying with are simply not working. Two reasons: 1) Most of the devs understand nothing or not enough on the field of the coding of the characters. 2) In gui applications, most of the devs understand nothing or not enough in the keyboard keys/chars handling. --- I know Python since version 1.5.2 or 1.5.6 (?). Among the applications I wrote, my fun is in writing GUI interactive interpreters with Python 2 or 3, tkinter, Tkinter, wxPython, PySide, PyQt4 on Windows. Believe or not, my interactive interpreters are the only ones where I can enter text and where text is displayed correctly. IDLE, wxPython/PyShell, DrPython, ... all are failing. (I do not count console applications). Python popularity? I have no popularity-meter. What I know: I can not type French text in IDLE on Windows. It is like this since ~ten years and I never saw any complain about this. (The problem in bad programmation). Ditto for PyShell in wxPython. I do not count, the number of corrections I proposed. In one version, it takes me 18 months until finally decided to propose a correction. During this time, I never heard of the problem. (Now, it is broken again). --- Is there a way to fix this actual status? - Yes, and *very easily*. Will it be fixed? - No, because there is no willingness to solve it. --- Roy Smith's quote: "... that we'll all just be using UTF-32, ..." Considering PEP 393, Python is not taking this road. --- How many devs know, one can not write text in French with the iso-8859-1 coding? (see pep 393) How can one explain, corporates like MS or Apple with their cp1252 or mac-roman codings succeeded to know this? Ditto for foundries (Adobe, LinoType, ...) --- Python is 20 years old. It was developped with ascii in mind. Python was not born, all this stuff was already a no problem with Windows and VB. Even a step higher, Windows was no born, this was a no problem at DOS level (eg TurboPascal), 30 years ago! Design mistake. --- Python 2 introduced the type. Very nice. Problem. The introduction of the automatic coercion ascii-"unicode", which somehow breaks everything. Very bad design mistake. (In my mind, the biggest one). --- One day, I fell on the web on a very old discussion about Python related to the introduction of unicode in Python 2. Something like: Python core dev (it was VS or AP): "... lets go with ucs-4 and we have no problem in the future ...". Look at the situation today. --- And so one. --- Conclusion. A Windows programmer is better served by downloading VB.NET Express. A end Windows user is better served with an application developped with VB.NET Express. I find somehow funny, Python is able to produce this: >>> (1.1).hex() '0x1.199999999999ap+0' >>> and on the other side, Python, Python applications, are not able to deal correctly with text entering and text displaying. Probably, the two most important tasks a "computer" has to do! jmf PS I'm not a computer scientist, only a computer user. From vinay_sajip at yahoo.co.uk Sun Feb 12 15:13:17 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 12:13:17 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> On Feb 12, 3:35?pm, Anh Hai Trinh wrote: > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. > I have looked at pbs and clom: they Pythonify calls to external programs by making spawning those look like function calls. There's nothing wrong with that, it's just a matter of taste. I find that e.g. wc(ls("/etc", "-1"), "-l") is not as readable as call(?ls /etc ?1 | wc ?l?) and the attempt to Pythonify doesn't buy you much, IMO. Of course, it is a matter of taste - I understand that there are people who will prefer the pbs/clom way of doing things. > Re. threads & fork():http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-befo... > > For a careful impl of fork-exec with threads, seehttp://golang.org/src/pkg/syscall/exec_unix.go Thanks for the links. The first seems to me to be talking about the dangers of locking and forking; if you don't use threads, you don't need locks, so the discussion about locking only really applies in a threading+forking scenario. I agree that locking+forking can be problematic because the semantics of what happens to the state of the locks and threads in the child (for example, as mentioned in http://bugs.python.org/issue6721). However, it's not clear that any problem occurs if the child just execs a new program, overwriting the old - which is the case here. The link you pointed to says that "It seems that calling execve(2) to start another program is the only sane reason you would like to call fork(2) in a multi-threaded program." which is what we're doing in this case. Even though it goes on to mention the dangers inherent in inherited file handles, it also mentions that these problems have been overcome in recent Linux kernels, and the subprocess module does contain code to handle at least some of these conditions (e.g. preexec_fn, close_fds keyword arguments to subprocess.Popen). Hopefully, if there are race conditions which emerge in the subprocess code (as has happened in the past), they will be fixed (as has happened in the past). > Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p That is of course your privilege. I would hardly expect you to drop extproc in favour of sarge. But there might be people who need to tread in these dangerous waters, and hopefully sarge will make things easier for them. As I said earlier, one doesn't *need* to use asynchronous calls. I agree that I may have to review the design decisions I've made, based on feedback based on people actually trying the async functionality out. I don't feel that shying away from difficult problems without even trying to solve them is the best way of moving things forward. What are the outcomes? * Maybe people won't even try the async functionality (in which case, they won't hit problems) * They'll hit problems and just give up on the library (I hope not - if I ever have a problem with a library I want to use, I always try and engage with the developers to find a workaround or fix) * They'll report problems which, on investigation, will turn out to be fixable bugs - well and good * The reported bugs will be unfixable for some reason, in which case I'll just have to deprecate that functionality. Remember, this is version 0.1 of the library, not version 1.0. I expect to do some API and functionality tweaks based on feedback and bugs which show up. > I do think that IO redirection is much nicer with extproc. Again, a matter of taste. You feel that it's better to pass dicts around in the public API where integer file handles map to other handles or streams; I feel that using a Capture instance is less fiddly for the user. Let a thousand flowers bloom, and all that. I do thank you for the time you've taken to make these comments, and I found the reading you pointed me to interesting. I will update the sarge docs to point to the link on the Linux Programming blog, to make sure people are informed of potential pitfalls. Regards, Vinay Sajip From steveo at syslang.net Sun Feb 12 15:14:24 2012 From: steveo at syslang.net (Steven W. Orr) Date: Sun, 12 Feb 2012 15:14:24 -0500 Subject: Need help with shutils.copytree Message-ID: <4F381DA0.4020505@syslang.net> I have a 'master' directory and a collection of 'slave' dirs. I want the master to collect all of the stuff in the slave dirs. The slaves all look like this, . |-- slaveX | `-- archI | | `-- distJ | | | ` -- FILE Where the different slaveX dirs may contain multiple occurrences of archI and distJ, but across all slaveX dirs, there will only be one *unique* instance of FILE in archI and distJ. Here's an example: Given slave[1234], arch1 and arch2, and dist1 and dist2, I want master to end up looking like this: . |-- master | `-- arch1 | | ` -- dist1 | | | ` -- FILE | `-- arch1 | | ` -- dist2 | | | ` -- FILE | `-- arch2 | | ` -- dist1 | | | ` -- FILE | `-- arch2 | | ` -- dist2 | | | ` -- FILE etc... In bash, I might use cpio passthrough mode and say something like: master=$path_to_master for slave in ${slaves} do pushd $slave find . -print | cpio -pdum $master popd done but I'm having a hard time trying to get this functionality in python. (I'm trying to avoid writing a subprocess.) I tried using shutil.copytree with a try / except that does a pass on OSError (which is what gets raised when trying to create a dir that already exists). No joy there. I also tried an ignore function that always returns (). Someone must have done this before. Any suggestions / pointers are much appreciated. (I hope this was clear to read.) TIA -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From mdickinson at enthought.com Sun Feb 12 15:18:15 2012 From: mdickinson at enthought.com (Mark Dickinson) Date: Sun, 12 Feb 2012 12:18:15 -0800 (PST) Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 6:41?am, Steven D'Aprano wrote: > ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. > ? ? ? ? ? ? if abs(err) <= 1e-16: > ? ? ? ? ? ? ? ? break If the result you're expecting is around -1.005, this exit condition is rather optimistic: the difference between the two Python floats either side of this value is already 2.22e-16, so you're asking for less than half a ulp of error! As to the rest; your error estimate simply doesn't have enough precision. The main problem is in the computation of a, where you're subtracting two almost identical values. The absolute error incurred in computing w*exp(w) is of the same order of magnitude as the difference 'w*exp(w) - x' itself, so err has lost essentially all of its significant bits, and is at best only a crude indicator of the size of the error. The solution would be to compute the quantities 'exp(w), w*exp(w), and w*exp(w) - x' all with extended precision. For the other quantities, there shouldn't be any major issues---after all, you only need a few significant bits of 'delta' for it to be useful, but with the subtraction that generates a, you don't even get those few significant bits. > (The correct value for w is approximately -1.00572223991.) Are you sure? Wolfram Alpha gives me the following value for W(-1, -0.36787344117144249455719773322925902903079986572265625): -1.005722239691522978... so it looks as though the values you're getting are at least alternating around the exact value. -- Mark From vinay_sajip at yahoo.co.uk Sun Feb 12 15:21:55 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 12:21:55 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <10831099.690.1329063558642.JavaMail.geo-discussion-forums@pbcmg9> Message-ID: On Feb 12, 4:19?pm, Anh Hai Trinh wrote: > If you use threads and call fork(), you'll almost guaranteed to face with deadlocks. Perhaps not in a particular piece of code, but some others. Perhaps not on your laptop, but on the production machine with different kernels. Like most race conditions, they will eventually show up. You can hit deadlocks in multi-threaded programs even without the fork(), can't you? In that situation, you either pin it down to a bug in your code (and even developers experienced in writing multi- threaded programs hit these), or a bug in the underlying library (which can hopefully be fixed, but that applies to any bug you might hit in any library you use, and is something you have to consider whenever you use a library written by someone else), or an unfixable problem (e.g. due to problems in the Python or C runtime) which require a different approach. I understand your concerns, but you are just a little further along the line from people who say "If you use threads, you will have deadlock problems. Don't use threads." I'm not knocking that POV - people need to use what they're comfortable with, and to avoid things that make them uncomfortable. I'm not pushing the async feature as a major advantage of the library - it's still useful without that, IMO. Regards, Vinay Sajip From clp2 at rebertia.com Sun Feb 12 16:09:51 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 12 Feb 2012 13:09:51 -0800 Subject: Need help with shutils.copytree In-Reply-To: <4F381DA0.4020505@syslang.net> References: <4F381DA0.4020505@syslang.net> Message-ID: On Sun, Feb 12, 2012 at 12:14 PM, Steven W. Orr wrote: > I have a 'master' directory and a collection of 'slave' dirs. I want the > master to collect all of the stuff in the slave dirs. > > The slaves all look like this, > > . > |-- slaveX > | ? `-- archI > | ? | ? `-- distJ > | ? | ? | ? ` -- FILE > > Where the different slaveX dirs may contain multiple occurrences of archI > and distJ, but across all slaveX dirs, there will only be one *unique* > instance of FILE in archI and distJ. > > Here's an example: Given slave[1234], arch1 and arch2, and dist1 and dist2, > I want master to end up looking like this: > > . > |-- master > | ? `-- arch1 > | ? | ? ` -- dist1 > | ? | ? | ? ?` -- FILE > | ? `-- arch1 > | ? | ? ` -- dist2 > | ? | ? | ? ?` -- FILE > | ? `-- arch2 > | ? | ? ` -- dist1 > | ? | ? | ? ?` -- FILE > | ? `-- arch2 > | ? | ? ` -- dist2 > | ? | ? | ? ?` -- FILE > > etc... You have multiple directories at the same level in the hierarchy with identical names (e.g. two "arch1"s), which is invalid. I assume you meant for them to be combined? > In bash, I might use cpio passthrough mode and say something like: > > master=$path_to_master > for slave in ${slaves} > do > ? ?pushd $slave > ? ?find . -print | cpio -pdum $master > ? ?popd > done > > but I'm having a hard time trying to get this functionality in python. (I'm > trying to avoid writing a subprocess.) > > I tried using shutil.copytree with a try / except that does a pass on > OSError (which is what gets raised when trying to create a dir that already > exists). No joy there. Right; the stack has already been unwound by the time your `except` clause is reached. You just need to recover by instead copying the children of the subtree individually yourself when their parent already exists. For example: master/arch1 already exists? Then copy the slave/arch1/distN-s individually. Or alternately, abandon copytree() entirely: you just LYBL and check if the parent directories already exist; if not, you try to create the directories yourself; and finally, you copy the individual files. [Useful funcs: os.listdir(), os.path.exists(), os.mkdir() / os.mkdirs()] > I also tried an ignore function that always returns (). That's an effective no-op which doesn't alter copytree()'s behavior whatsoever. Cheers, Chris -- http://rebertia.com From tjreedy at udel.edu Sun Feb 12 16:19:31 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 16:19:31 -0500 Subject: Numeric root-finding in Python In-Reply-To: References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 5:10 AM, Eelco wrote: > On Feb 12, 7:41 am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> This is only peripherally a Python problem, but in case anyone has any >> good ideas I'm going to ask it. >> >> I have a routine to calculate an approximation of Lambert's W function, >> and then apply a root-finding technique to improve the approximation. >> This mostly works well, but sometimes the root-finder gets stuck in a >> cycle. >> >> Here's my function: >> >> import math >> def improve(x, w, exp=math.exp): >> """Use Halley's method to improve an estimate of W(x) given >> an initial estimate w. >> """ >> try: >> for i in range(36): # Max number of iterations. >> ew = exp(w) >> a = w*ew - x >> b = ew*(w + 1) >> err = -a/b # Estimate of the error in the current w. >> if abs(err)<= 1e-16: >> break >> print '%d: w= %r err= %r' % (i, w, err) >> # Make a better estimate. >> c = (w + 2)*a/(2*w + 2) >> delta = a/(b - c) >> w -= delta >> else: >> raise RuntimeError('calculation failed to converge', err) >> except ZeroDivisionError: >> assert w == -1 >> return w >> >> Here's an example where improve() converges very quickly: >> >> py> improve(-0.36, -1.222769842388856) >> 0: w= -1.222769842388856 err= -2.9158979924038895e-07 >> 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 >> -1.222770133978506 >> >> That's what I expect: convergence in only a few iterations. >> >> Here's an example where it gets stuck in a cycle, bouncing back and forth >> between two values: >> >> py> improve(-0.36787344117144249, -1.0057222396915309) >> 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 19, in improve >> RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) >> >> (The correct value for w is approximately -1.00572223991.) >> >> I know that Newton's method is subject to cycles, but I haven't found any >> discussion about Halley's method and cycles, nor do I know what the best >> approach for breaking them would be. None of the papers on calculating >> the Lambert W function that I have found mentions this. >> >> Does anyone have any advice for solving this? > Looks like floating point issues to me, rather than something > intrinsic to the iterative algorithm. Surely there is not complex > chaotic behavior to be found in this fairly smooth function in a +/- > 1e-14 window. Otoh, there is a lot of floating point significant bit > loss issues to be suspected in the kind of operations you are > performing (exp(x) + something, always a tricky one). To investigate this, I would limit the iterations to 2 or 3 and print ew, a,b,c, and delta, maybe in binary(hex) form > I would start by asking: How accurate is good enough? If its not good > enough, play around the the ordering of your operations, try solving a > transformed problem less sensitive to loss of significance; and begin > by trying different numeric types to see if the problem is sensitive > thereto to begin with. -- Terry Jan Reedy From tjreedy at udel.edu Sun Feb 12 17:07:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 17:07:44 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 10:13 AM, Roy Smith wrote: > Exactly.. ASCII was so successful > at becoming a universal standard which lasted for decades, I think you are overstating the universality and length. I used a machine in the 1970s with 60-bit words that could be interpreted as 10 6-bit characters. IBM used EBCDIC at least into the 1980s. The UCLA machine I used had a translator for ascii terminals that connected by modems. I remember discussing the translation table with the man in charge of it. Dedicated wordprocessing machines of the 70s and 80s *had* to use something other than plain ascii, as it is inadequate for business text, as opposed to pure computation and labeled number tables. Whether they used extended ascii or something else, I have no idea. Ascii was, however, as far as I know, the universal basis for the new personal computers starting about 1975, and most importantly, for the IBM PC. But even that actually used its version of extended ascii, as did each wordprocessing program. > people who > grew up with it don't realize there was once any other way. Not just > EBCDIC, but also SIXBIT, RAD-50, tilt/rotate, packed card records, > and so on. Transcoding was a way of life, and if you didn't know what > you were starting with and aiming for, it was hopeless. But because of the limitation of ascii on a worldwide, as opposed to American basis, we ended up with 100-200 codings for almost as many character sets. This is because the idea of ascii was applied by each nation or language group individually to their local situation. > Kind of like now where we are again with Unicode. The situation before ascii is like where we ended up *before* unicode. Unicode aims to replace all those byte encoding and character sets with *one* byte encoding for *one* character set, which will be a great simplification. It is the idea of ascii applied on a global rather that local basis. Let me repeat. Unicode and utf-8 is a solution to the mess, not the cause. Perhaps we should have a synonym for utf-8: escii, for Earthian Standard Code for Information Interchange. -- Terry Jan Reedy From rosuav at gmail.com Sun Feb 12 17:14:29 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 09:14:29 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > The situation before ascii is like where we ended up *before* unicode. > Unicode aims to replace all those byte encoding and character sets with > *one* byte encoding for *one* character set, which will be a great > simplification. It is the idea of ascii applied on a global rather that > local basis. Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so are UTF-16, UTF-32. and as many more as you could hope for. But broadly yes, Unicode IS the solution. ChrisA From roy at panix.com Sun Feb 12 17:22:33 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 17:22:33 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Terry Reedy wrote: > Let me repeat. Unicode and utf-8 is a solution to the mess, not the > cause. Perhaps we should have a synonym for utf-8: escii, for Earthian > Standard Code for Information Interchange. I'm not arguing that Unicode is where we need to get to. Just trying to give a little history. From roy at panix.com Sun Feb 12 17:27:34 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 17:27:34 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > > The situation before ascii is like where we ended up *before* unicode. > > Unicode aims to replace all those byte encoding and character sets with > > *one* byte encoding for *one* character set, which will be a great > > simplification. It is the idea of ascii applied on a global rather that > > local basis. > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so > are UTF-16, UTF-32. and as many more as you could hope for. But > broadly yes, Unicode IS the solution. I could hope for one and only one, but I know I'm just going to be disapointed. The last project I worked on used UTF-8 in most places, but also used some C and Java libraries which were only available for UTF-16. So it was transcoding hell all over the place. Hopefully, we will eventually reach the point where storage is so cheap that nobody minds how inefficient UTF-32 is and we all just start using that. Life will be a lot simpler then. No more transcoding, a string will just as many bytes as it is characters, and everybody will be happy again. From steve+comp.lang.python at pearwood.info Sun Feb 12 17:30:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:30:32 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: > On 2/12/2012 3:12 AM, Steven D'Aprano wrote: >> NTFS by default uses the UTF-16 encoding, which means the actual bytes >> written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading >> byte-order mark \xff\xfe). > > That's what I meant. Those bytes will be interpreted consistently across > all locales. Right. But, that's not Unicode, it is an encoding of Unicode. Terminology is important -- if we don't call things by the "right" names (or at least agreed upon names) how can we communicate? >> Windows has two separate APIs, one for "wide" characters, the other for >> single bytes. Depending on which one you use, the directory will appear >> to be called ???? or 0?2. > > Yes, and AFAIK, the wide API is the default. The other one only exists > to support programs that don't support the wide API (generally, such > programs were intended to be used on older platforms that lack that > API). I'm not sure that "default" is the right word, since (as far as I know) both APIs have different spelling and the coder has to make the choice whether to call function X or function Y. Perhaps you mean that Microsoft encourages the wide API and makes the single-byte API available for legacy reasons? >> But in any case, we're not talking about the file name encoding. We're >> talking about the contents of files. > > Okay then. As I stated, this has nothing to do with the OS since > programs are free to interpret bytes any way they like. Yes, but my point was that even if the developer thinks he can avoid the problem by staying away from "Unicode files" coming from Linux and OS-X, he can't avoid dealing with multiple code pages on Windows. You are absolutely correct that this is *not* a cross-platform issue to do with the OS, but some people may think it is. -- Steven From cezar4846 at gmail.com Sun Feb 12 17:34:38 2012 From: cezar4846 at gmail.com (zigi) Date: Sun, 12 Feb 2012 14:34:38 -0800 (PST) Subject: M2crypto Message-ID: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Hello, M2crypto __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', salt='12345678', i=1, padding=1) I wont write app, using M2crypto and I can not understand what are the arguments: key, iv, op, salt ? What they do ? From davea at dejaviewphoto.com Sun Feb 12 17:40:38 2012 From: davea at dejaviewphoto.com (Dave Angel) Date: Sun, 12 Feb 2012 17:40:38 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F383FE6.1060902@dejaviewphoto.com> On 02/12/2012 05:27 PM, Roy Smith wrote: > In article, > Chris Angelico wrote: > >> On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >>> The situation before ascii is like where we ended up *before* unicode. >>> Unicode aims to replace all those byte encoding and character sets with >>> *one* byte encoding for *one* character set, which will be a great >>> simplification. It is the idea of ascii applied on a global rather that >>> local basis. >> Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so >> are UTF-16, UTF-32. and as many more as you could hope for. But >> broadly yes, Unicode IS the solution. > I could hope for one and only one, but I know I'm just going to be > disapointed. The last project I worked on used UTF-8 in most places, > but also used some C and Java libraries which were only available for > UTF-16. So it was transcoding hell all over the place. > > Hopefully, we will eventually reach the point where storage is so cheap > that nobody minds how inefficient UTF-32 is and we all just start using > that. Life will be a lot simpler then. No more transcoding, a string > will just as many bytes as it is characters, and everybody will be happy > again. Keep your in-memory character strings as Unicode, and only serialize(encode) them when they go to/from a device, or to/from anachronistic code. Then the cost is realized at the point of the problem. No different than when deciding how to serialize any other data type. Do it only at the point of entry/exit of your program. But as long as devices are addressed as bytes, or as anything smaller than 32bit thingies, you will have encoding issues when writing to the device, and decoding issues when reading. At the very least, you have big-endian/little-endian ways to encode that UCS-4 code point. From ben+python at benfinney.id.au Sun Feb 12 17:43:52 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 13 Feb 2012 09:43:52 +1100 Subject: How do you Unicode proponents type your non-ASCII characters? (was: Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87d39j3c5z.fsf_-_@benfinney.id.au> rusi writes: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? In GNU+Linux, I run the IBus daemon to manage different keyboard input methods across all my applications consistently. That makes hundreds of language-specific input methods available, and also many that are not language-specific. It's useful if I want to ????????? type a passage of Japanese with the ?anthy? input method, or likewise for any of the other available language-specific input methods. I normally have IBus presenting the ?rfc1345? input method. That makes just about all keys input the corresponding character just as if no input method were active. But when I type ?&? followed by a two- or three-key sequence, it inputs the corresponding character from the RFC?1345 mnemonics table: & ? & P d ? ? e ' ? ? a e ? ? o : ? ? C t ? ? T M ? ? C o ? ? " 6 ? ? " 9 ? ? ? Those same characters are also available with the ?latex? input method, if I'm familiar with LaTeX character entity names. (I'm not.) -- \ ?If [a technology company] has confidence in their future | `\ ability to innovate, the importance they place on protecting | _o__) their past innovations really should decline.? ?Gary Barnett | Ben Finney From steve+comp.lang.python at pearwood.info Sun Feb 12 17:49:08 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:49:08 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3841e4$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:11:46 -0500, Roy Smith wrote: > In article , > Dennis Lee Bieber wrote: > >> On Sun, 12 Feb 2012 10:48:36 -0500, Roy Smith wrote: >> >> >As Steven D'Aprano pointed out, it was missing some commonly used US >> >symbols such as ? or ?. > > That's interesting. When I wrote that, it showed on my screen as a cent > symbol and a copyright symbol. What I see in your response is an upper > case "A" with a hat accent (circumflex?) over it followed by a cent > symbol, and likewise an upper case "A" with a hat accent over it > followed by copyright symbol. Somebody's mail or news reader is either ignoring the message's encoding line, or not inserting an encoding line. Either way, that's a bug. > Oh, for the days of ASCII again :-) I look forward to the day, probably around 2525, when everybody uses UTF-32 always. -- Steven From d at davea.name Sun Feb 12 17:50:12 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 17:50:12 -0500 Subject: Python usage numbers In-Reply-To: <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F384224.2010508@davea.name> On 02/12/2012 05:30 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: > >> On 2/12/2012 3:12 AM, Steven D'Aprano wrote: > >>> Windows has two separate APIs, one for "wide" characters, the other for >>> single bytes. Depending on which one you use, the directory will appear >>> to be called ???? or 0?2. >> Yes, and AFAIK, the wide API is the default. The other one only exists >> to support programs that don't support the wide API (generally, such >> programs were intended to be used on older platforms that lack that >> API). > I'm not sure that "default" is the right word, since (as far as I know) > both APIs have different spelling and the coder has to make the choice > whether to call function X or function Y. Perhaps you mean that Microsoft > encourages the wide API and makes the single-byte API available for > legacy reasons? > > When I last looked, the pair of functions were equivalently available, and neither one was named the way you'd expect. One had a suffix of A and the other had a suffix of W (guess which was which). C header definitions used #define to define the actual functions, and the preprocessor effectively stuck A's on all of them or W's on all of them. Very bulky, but buried in some MS header files. Other languages were free to use either or both. VB used just the W versions, as I presume java does. But the interesting point was that for most of these functions, the A versions were native on Win95-derived OS'es, while the W versions were native on NT-derived OS's. There were translation DLL's which supplied the secondary versions. So in the old days it was more efficient to use the A versions. No longer true, since as far as I know, nobody that still uses Win ME, Win98, or Win95 is targeted for much new programming. -- DaveA From steve+comp.lang.python at pearwood.info Sun Feb 12 17:53:15 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:53:15 GMT Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3842db$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 13:52:48 +0000, Robert Kern wrote: > I don't have any advice for fixing your code, per se, but I would just > grab mpmath and use their lambertw function: That's no fun! I'd never see mpmath before, it looks like it is worth investigating. Nevertheless, I still intend working on my lambert function, as it's a good learning exercise. I did look into SciPy's lambert too, and was put off by this warning in the docs: "In some corner cases, lambertw might currently fail to converge" http://docs.scipy.org/doc/scipy/reference/generated/ scipy.special.lambertw.html Naturally I thought "I can do better than that". Looks like I can't :) -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 17:56:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:56:32 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3843a0$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 08:50:28 -0800, rusi wrote: >> You can't say that it cost you ?10 to courier your r?sum? to the head >> office of Encyclop?dia Britanica to apply for the position of Staff >> Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit >> stuffy and old-fashioned, but it is traditional English.) >> >> Hell, you can't even write in *American*: you can't say that the recipe >> for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? [Note: I grew up on APL so > unlike Rick I am genuinely asking :-) ] In my case, I used the KDE application "KCharSelect". I manually hunt through the tables for the character I want (which sucks), click on the characters I want, and copy and paste them into my editor. Back in Ancient Days when I ran Mac OS 6, I had memorised many keyboard shortcuts for these things. Option-4 was the pound sign, I believe, and Option-Shift-4 the cent sign. Or perhaps the other way around? -- Steven From tycho at tycho.ws Sun Feb 12 18:04:07 2012 From: tycho at tycho.ws (Tycho Andersen) Date: Sun, 12 Feb 2012 17:04:07 -0600 Subject: Generating a .pc file using distutils In-Reply-To: <20120123233120.GC6157@smitten> References: <20120123233120.GC6157@smitten> Message-ID: <20120212230407.GB29922@smitten> Just re-bumping this - I am fiddling with this code again and it's gross, so any input would be greatly appreciated :-) \t On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: > Is there some standard way to generate a .pc file (given a .pc.in or > similar) using distutils? > > If there's not, is there a good way to access whatever the user passes > in as --prefix (besides parsing sys.argv yourself)? > > Thanks, > > \t From steve+comp.lang.python at pearwood.info Sun Feb 12 18:05:47 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 23:05:47 GMT Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > On Feb 12, 6:41?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > >> ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. >> ? ? ? ? ? ? if abs(err) <= 1e-16: >> ? ? ? ? ? ? ? ? break > > If the result you're expecting is around -1.005, this exit condition is > rather optimistic: the difference between the two Python floats either > side of this value is already 2.22e-16, so you're asking for less than > half a ulp of error! I was gradually coming to the conclusion on my own that I was being overly optimistic with my error condition, although I couldn't put it into words *why*. Thanks for this Mark, this is exactly the sort of thing I need to learn -- as is obvious, I'm no expert on numeric programming. > As to the rest; your error estimate simply doesn't have enough > precision. The main problem is in the computation of a, where you're > subtracting two almost identical values. The absolute error incurred in > computing w*exp(w) is of the same order of magnitude as the difference > 'w*exp(w) - x' itself, so err has lost essentially all of its > significant bits, and is at best only a crude indicator of the size of > the error. The solution would be to compute the quantities 'exp(w), > w*exp(w), and w*exp(w) - x' all with extended precision. Other than using Decimal, there's no way to do that in pure Python, is there? We have floats (double) and that's it. > For the other > quantities, there shouldn't be any major issues---after all, you only > need a few significant bits of 'delta' for it to be useful, but with the > subtraction that generates a, you don't even get those few significant > bits. > >> (The correct value for w is approximately -1.00572223991.) > > Are you sure? Wolfram Alpha gives me the following value for W(-1, > -0.36787344117144249455719773322925902903079986572265625): > > -1.005722239691522978... I did say *approximately*. The figure I quote comes from my HP-48GX, and seems to be accurate to the precision offered by the HP. -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 18:29:51 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 23:29:51 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >> > The situation before ascii is like where we ended up *before* >> > unicode. Unicode aims to replace all those byte encoding and >> > character sets with *one* byte encoding for *one* character set, >> > which will be a great simplification. It is the idea of ascii applied >> > on a global rather that local basis. >> >> Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so >> are UTF-16, UTF-32. and as many more as you could hope for. But broadly >> yes, Unicode IS the solution. > > I could hope for one and only one, but I know I'm just going to be > disapointed. The last project I worked on used UTF-8 in most places, > but also used some C and Java libraries which were only available for > UTF-16. So it was transcoding hell all over the place. Um, surely the solution to that is to always call a simple wrapper function to the UTF-16 code to handle the transcoding? What do the Design Patterns people call it, a facade? No, an adapter. (I never remember the names...) Instead of calling library.foo() which only outputs UTF-16, write a wrapper myfoo() which calls foo, captures its output and transcribes to UTF-8. You have to do that once (per function), but now it works from everywhere, so long as you remember to always call myfoo instead of foo. > Hopefully, we will eventually reach the point where storage is so cheap > that nobody minds how inefficient UTF-32 is and we all just start using > that. Life will be a lot simpler then. No more transcoding, a string > will just as many bytes as it is characters, and everybody will be happy > again. I think you mean 4 times as many bytes as characters. Unless you have 32 bit bytes :) -- Steven From tjreedy at udel.edu Sun Feb 12 18:30:21 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 18:30:21 -0500 Subject: French and IDLE on Windows (was Re: Python usage numbers) In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 2:52 PM, jmfauth wrote: > Python popularity? I have no popularity-meter. What I know: > I can not type French text in IDLE on Windows. It is like I am pretty sure others have managed to. tk and hence idle handle the entire BMP subset of unicode just fine once they get them. Except for the apple version, which has just been fixed so French entry should work. Showing characters on the screen requires an appropriate font. http://bugs.python.org/issue4281 was the result of a font problem. > this since ~ten years and I never saw any complain about > this. Neither have I, except for the issue above I just found. So there is nothing obvious to fix. If you have a problem, give the specifics here and lets see if someone has a solution. -- Terry Jan Reedy From d at davea.name Sun Feb 12 18:32:46 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 18:32:46 -0500 Subject: Generating a .pc file using distutils In-Reply-To: <20120212230407.GB29922@smitten> References: <20120123233120.GC6157@smitten> <20120212230407.GB29922@smitten> Message-ID: <4F384C1E.60304@davea.name> On 02/12/2012 06:04 PM, Tycho Andersen wrote: > Just re-bumping this - I am fiddling with this code again and it's > gross, so any input would be greatly appreciated :-) > > \t > > On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: >> Is there some standard way to generate a .pc file (given a .pc.in or >> similar) using distutils? >> >> If there's not, is there a good way to access whatever the user passes >> in as --prefix (besides parsing sys.argv yourself)? >> >> Thanks, >> >> \t Bumping a message (especially using top-posting) seldom does much good unless you also supply some more information to either catch people's attention, or even better, remind them of something they know that might apply. So you could have said: A .pc file is "lijfds;lkjds;fdsjfds;ljfds;ljfds;ljfd" and I need to produce it in the "slf;lfdsjfds;l;lkjfds;lj" circumstances. Or, a .pc file is described on the wiki page at link http://www.sljfds.slijfdsj.unknown Or even "I tried to get more information on the comp.lang.pc newsgroup, but nobody there will give me the time of day. As it is, the only thing I could do is point you to the only other keyword in your message: Try on a support forum for distutils. -- DaveA From roy at panix.com Sun Feb 12 18:41:21 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 18:41:21 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4f384b6e$0$29986$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > > I could hope for one and only one, but I know I'm just going to be > > disapointed. The last project I worked on used UTF-8 in most places, > > but also used some C and Java libraries which were only available for > > UTF-16. So it was transcoding hell all over the place. > > Um, surely the solution to that is to always call a simple wrapper > function to the UTF-16 code to handle the transcoding? What do the Design > Patterns people call it, a facade? No, an adapter. (I never remember the > names...) I am familiar with the concept. It was ICU. A very big library. Lots of calls. I don't remember the details, I'm sure we wrote wrappers. It was still a mess. > > Hopefully, we will eventually reach the point where storage is so cheap > > that nobody minds how inefficient UTF-32 is and we all just start using > > that. Life will be a lot simpler then. No more transcoding, a string > > will just as many bytes as it is characters, and everybody will be happy > > again. > > I think you mean 4 times as many bytes as characters. Unless you have 32 > bit bytes :) Yes, exactly. From d at davea.name Sun Feb 12 18:52:47 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 18:52:47 -0500 Subject: Numeric root-finding in Python In-Reply-To: <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3850CF.4020802@davea.name> On 02/12/2012 06:05 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > >> On Feb 12, 6:41 am, Steven D'Aprano> +comp.lang.pyt... at pearwood.info> wrote: >> >>> err = -a/b # Estimate of the error in the current w. >>> if abs(err)<= 1e-16: >>> break >> If the result you're expecting is around -1.005, this exit condition is >> rather optimistic: the difference between the two Python floats either >> side of this value is already 2.22e-16, so you're asking for less than >> half a ulp of error! > I was gradually coming to the conclusion on my own that I was being > overly optimistic with my error condition, although I couldn't put it > into words *why*. Thanks for this Mark, this is exactly the sort of thing > I need to learn -- as is obvious, I'm no expert on numeric programming. > > me either. But comments below. >> As to the rest; your error estimate simply doesn't have enough >> precision. The main problem is in the computation of a, where you're >> subtracting two almost identical values. > > Two pieces of my history that come to mind. 40+ years ago I got a letter from a user of our computer stating that our math seemed to be imprecise in certain places. He was very polte about it, and admitted to maybe needing a different algorithm. The letter was so polite that I (as author of the math microcode) worked on his problem, and found the difficulty, as well as a solution. The problem was figuring out the difference in a machining table between being level every place on its surface (in which case it would be slightly curved to match the earth), or being perfectly flat (in which case some parts of the table would be further from the earth's center than others) The table was 200 feet long, and we were talking millionths of an inch. He solved it three ways, and got three different answers. The first two differed in the 3rd place, which he thought far too big an error, and the third answer was just about exactly half the others. Well the 2:1 discrepancy just happens when you change your assumption of what part of the flat table is level. If the center is level, then the edges are only 100 feet out, while if the edge is level, the other edge is 200 feet out. But the other solution was very interesting. Turns out he sketched a right triangle, with narrow angle at the center of the earth, side opposite being 200 feet. He then calculated the difference between the other two sides. one 8000 miles, and the other 8000 miles plus a few microinches. He got that distance by subtracting the sine from the tangent, or something similar to that. I had microcoded both those functions, and was proud of their accuracy. But if you subtract two 13 digit numbers that only differ in the last 3, you only get 3 digits worth of accuracy, best case. Solution was to apply some similar triangles, and some trivial approximations, and the problem turned out not to need trig at all, and accurate to at least 12 places. if I recall, it was something like 8000mi is to 200 feet, as 200 feet is to X. Cross multiply and it's just arithmetic. The other problem was even earlier. It was high school physics, and the challenge was to experimentally determine the index of refraction of air to 5 places. Problem is our measurements can't be that accurate. So this is the same thing in reverse. Find a way to measure the difference of the index of refraction of air and vacuum, to one or two places, and add that to 1.00000000 taken together with lots of other experience, i try to avoid commiting an algorithm to code before thinking about errors, convergence, and exceptional conditions. I've no experience with Lambert, but I suspect it can be attacked similarly. -- DaveA From lists at cheimes.de Sun Feb 12 19:00:14 2012 From: lists at cheimes.de (Christian Heimes) Date: Mon, 13 Feb 2012 01:00:14 +0100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 12.02.2012 23:07, schrieb Terry Reedy: > But because of the limitation of ascii on a worldwide, as opposed to > American basis, we ended up with 100-200 codings for almost as many > character sets. This is because the idea of ascii was applied by each > nation or language group individually to their local situation. You really learn to appreciate unicode when you have to deal with mixed languages in texts and old databases from the 70ties and 80ties. I'm working with books that contain medieval German, old German, modern German, English, French, Latin, Hebrew, Arabic, ancient and modern Greek, Rhaeto-Romanic, East European and more languages. Sometimes three or four languages are used in a single book. Some books are more than 700 years old and contain glyphs that aren't covered by unicode yet. Without unicode it would be virtually impossible to deal with it. Metadata for these books come from old and proprietary databases and are stored in a format that is optimized for magnetic tape. Most people will never have heard about ISO-5426 or ANSEL encoding or about file formats like MAB2, MARC or PICA. It took me quite some time to develop codecs to encode and decode an old and partly undocumented variable multibyte encodings that predates UTF-8 by about a decade. Of course every system interprets the undocumented parts slightly different ... Unicode and XML are bliss for metadata exchange and long term storage! From mwilson at the-wire.com Sun Feb 12 19:00:52 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Sun, 12 Feb 2012 19:00:52 -0500 Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: zigi wrote: > Hello, > M2crypto > > __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > salt='12345678', i=1, padding=1) > > I wont write app, using M2crypto and I can not understand what are the > arguments: > key, iv, op, salt ? > What they do ? I assume you're reading in about M2Crypto.EVP.Cipher. Epydoc claims another victim. I'm having a lot of trouble finding documentation. The obvious OpenSSL pages are kind of thin, too. You might see some useful code in the EVP unit tests m2crypto/tests/test_evp.py in the m2crypto installation. Good hunting, Mel. From d at davea.name Sun Feb 12 19:03:54 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 19:03:54 -0500 Subject: Python usage numbers In-Reply-To: <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F38536A.2030208@davea.name> On 02/12/2012 06:29 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: > >> >> Hopefully, we will eventually reach the point where storage is so cheap >> that nobody minds how inefficient UTF-32 is and we all just start using >> that. Life will be a lot simpler then. No more transcoding, a string >> will just as many bytes as it is characters, and everybody will be happy >> again. > I think you mean 4 times as many bytes as characters. Unless you have 32 > bit bytes :) > > Until you have 32 bit bytes, you'll continue to have encodings, even if only a couple of them. -- DaveA From debatem1 at gmail.com Sun Feb 12 19:28:29 2012 From: debatem1 at gmail.com (geremy condra) Date: Sun, 12 Feb 2012 16:28:29 -0800 Subject: M2crypto In-Reply-To: References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > zigi wrote: > >> Hello, >> M2crypto >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', >> salt='12345678', i=1, padding=1) >> >> I wont write app, using M2crypto and I can not understand what are the >> arguments: >> key, iv, op, salt ? >> What they do ? > > I assume you're reading in > about M2Crypto.EVP.Cipher. > > Epydoc claims another victim. > > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > pages are kind of thin, too. ?You might see some useful code in the EVP unit > tests m2crypto/tests/test_evp.py in the m2crypto installation. Not intending to be rude, but being perfectly serious: as a general rule, if you don't know what an IV is you're probably getting yourself into a lot of trouble working with low-level crypto libraries. Two suggestions: 1. Describe what you're trying to do- I'll be able to help more if I know what you're actually going for. 2. Try keyczar. It's not perfect, but it's a lot easier to get right. Geremy Condra From rosuav at gmail.com Sun Feb 12 19:59:57 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 11:59:57 +1100 Subject: Python usage numbers In-Reply-To: <4F38536A.2030208@davea.name> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F38536A.2030208@davea.name> Message-ID: On Mon, Feb 13, 2012 at 11:03 AM, Dave Angel wrote: > On 02/12/2012 06:29 PM, Steven D'Aprano wrote: >> I think you mean 4 times as many bytes as characters. Unless you have 32 >> bit bytes :) >> >> > Until you have 32 bit bytes, you'll continue to have encodings, even if only > a couple of them. The advantage, though, is that you can always know how many bytes to read for X characters. In ASCII, you allocate 80 bytes of storage and you can store 80 characters. In UTF-8, if you want an 80-character buffer, you can probably get away with allocating 240 characters... but maybe not. In UTF-32, it's easy - just allocate 320 bytes and you know you can store them. Also, you know exactly where the 17th character is; in UTF-8, you have to count. That's a huge advantage for in-memory strings; but is it useful on disk, where (as likely as not) you're actually looking for lines, which you still have to scan for? I'm thinking not, so it makes sense to use a smaller disk image than UTF-32 - less total bytes means less sectors to read/write, which translates fairly directly into performance. ChrisA From roy at panix.com Sun Feb 12 20:11:04 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 20:11:04 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F38536A.2030208@davea.name> Message-ID: In article , Chris Angelico wrote: > The advantage, though, is that you can always know how many bytes to > read for X characters. In ASCII, you allocate 80 bytes of storage and > you can store 80 characters. In UTF-8, if you want an 80-character > buffer, you can probably get away with allocating 240 characters... > but maybe not. In UTF-32, it's easy - just allocate 320 bytes and you > know you can store them. Also, you know exactly where the 17th > character is; in UTF-8, you have to count. That's a huge advantage for > in-memory strings; but is it useful on disk, where (as likely as not) > you're actually looking for lines, which you still have to scan for? > I'm thinking not, so it makes sense to use a smaller disk image than > UTF-32 - less total bytes means less sectors to read/write, which > translates fairly directly into performance. You might just write files compressed. My guess is that a typical gzipped UTF-32 text file will be smaller than the same data stored as uncompressed UTF-8. From rustompmody at gmail.com Sun Feb 12 22:09:32 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 12 Feb 2012 19:09:32 -0800 (PST) Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 10:36?pm, Nick Dokos wrote: > rusi wrote: > > On Feb 12, 10:51?am, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: > > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > > Everything that displays text to a human needs to translate bytes into > > > > glyphs, and the usual way to do this conceptually is to go via > > > > characters. Pretending that it's all the same thing really means > > > > pretending that one byte represents one character and that each > > > > character is depicted by one glyph. And that's doomed to failure, unless > > > > everyone speaks English with no foreign symbols - so, no mathematical > > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > > office of Encyclop?dia Britanica to apply for the position of Staff > > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > > [Quite OT but...] How do you type all this? > > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] > > [Emacs speficic] > > Many different ways of course, but in emacs, you can select e.g. the TeX input method > with C-x RET C-\ TeX RET. > which does all of the above symbols with the exception of the cent > symbol (or maybe I missed it) - you type the thing in the first column and you > get the thing in the second column > > \pounds ? > \'e ? ? ? > \ae ? ? ? > \"o ? ? ? > ^{TM} ? ? > \copyright ? > > I gave up on the cent symbol and used ucs-insert (C-x 8 RET) which allows you to type > a name, in this case CENT SIGN to get ?. > > Nick [OT warning] I asked this on the emacs list: No response there and the responses here are more helpful so asking here. My question there was emacs-specific. If there is some other app, thats fine. I have some bunch of sanskrit (devanagari) to type. It would be easiest for me if I could have the English (roman) as well as the sanskrit (devanagari). For example using the devanagari-itrans input method I can write the gayatri mantra using OM bhUrbhuvaH suvaH tatsaviturvarenyam bhargo devasya dhImahi dhiyo yonaH prachodayAt and emacs produces *on the fly* (ie I cant see/edit the above) ? ???????? ???? ?????????????????? ????? ?????? ????? ???? ???? ?????????? Can I do it in batch mode? ie write the first in a file and run some command on it to produce the second? From tjreedy at udel.edu Sun Feb 12 22:09:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 22:09:50 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 5:14 PM, Chris Angelico wrote: > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >> The situation before ascii is like where we ended up *before* unicode. >> Unicode aims to replace all those byte encoding and character sets with >> *one* byte encoding for *one* character set, which will be a great >> simplification. It is the idea of ascii applied on a global rather that >> local basis. > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, The Unicode Standard specifies 3 UTF storage formats* and 8 UTF byte-oriented transmission formats. UTF-8 is the most common of all encodings for web pages. (And ascii pages are utf-8 also.) It is the only one of the 8 most of us need to much bother with. Look here for the list http://www.unicode.org/glossary/#U and for details look in various places in http://www.unicode.org/versions/Unicode6.1.0/ch03.pdf > but so are UTF-16, UTF-32. > and as many more as you could hope for. All the non-UTF 'as many more as you could hope for' encodings are not part of Unicode. * The new internal unicode scheme for 3.3 is pretty much a mixture of the 3 storage formats (I am of course, skipping some details) by using the widest one needed for each string. The advantage is avoiding problems with each of the three. The disadvantage is greater internal complexity, but that should be hidden from users. They will not need to care about the internals. They will be able to forget about 'narrow' versus 'wide' builds and the possible requirement to code differently for each. There will only be one scheme that works the same on all platforms. Most apps should require less space and about the same time. -- Terry Jan Reedy From sturlamolden at yahoo.no Sun Feb 12 22:21:40 2012 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 12 Feb 2012 19:21:40 -0800 (PST) Subject: Python vs. C++11 Message-ID: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> There are bigsimilarities between Python and the new C++ standard. Now we can actually use our experience as Python programmers to write fantastic C++ :-) Here is a small list of similarities to consider: Iterate over any container, like Python's for loop: for (type& item: container) Pointer type with reference counting: std::shared_ptr Python-like datatypes: tuple std::tuple list std::vector std::list std::stack dict std::unordered_map set std::unordered_set complex std::complex deque std::deque lambda [name](params){body} heapq std::heap weakref weak_ptr str std::string -- unicode, raw strings, etc work as Python Other things of interest: std::regex, std::cmatch std::thread thread api versy similar to Python's std::atomic datatype for atomic operations std::mt19937 same prng as Python From sturlamolden at yahoo.no Sun Feb 12 22:28:57 2012 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 12 Feb 2012 19:28:57 -0800 (PST) Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> Message-ID: <81c14eeb-029b-478e-9f50-f7fe5bca04ab@18g2000yqe.googlegroups.com> On Feb 13, 4:21?am, sturlamolden wrote: > There are bigsimilarities between Python and the new C++ standard. Now > we can actually use our experience as Python programmers to write > fantastic C++ :-) And of course the keyword 'auto', which means automatic type interence. From roy at panix.com Sun Feb 12 22:57:01 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 22:57:01 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Terry Reedy wrote: > On 2/12/2012 5:14 PM, Chris Angelico wrote: > > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > >> The situation before ascii is like where we ended up *before* unicode. > >> Unicode aims to replace all those byte encoding and character sets with > >> *one* byte encoding for *one* character set, which will be a great > >> simplification. It is the idea of ascii applied on a global rather that > >> local basis. > > > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, > > The Unicode Standard specifies 3 UTF storage formats* and 8 UTF > byte-oriented transmission formats. UTF-8 is the most common of all > encodings for web pages. (And ascii pages are utf-8 also.) It is the > only one of the 8 most of us need to much bother with. Look here for the > list > http://www.unicode.org/glossary/#U > and for details look in various places in > http://www.unicode.org/versions/Unicode6.1.0/ch03.pdf > > > but so are UTF-16, UTF-32. > > and as many more as you could hope for. > > All the non-UTF 'as many more as you could hope for' encodings are not > part of Unicode. > > * The new internal unicode scheme for 3.3 is pretty much a mixture of > the 3 storage formats (I am of course, skipping some details) by using > the widest one needed for each string. The advantage is avoiding > problems with each of the three. The disadvantage is greater internal > complexity, but that should be hidden from users. They will not need to > care about the internals. They will be able to forget about 'narrow' > versus 'wide' builds and the possible requirement to code differently > for each. There will only be one scheme that works the same on all > platforms. Most apps should require less space and about the same time. All that is just fine, but what the heck are we going to do about ascii art, that's what I want to know. Python just won't be the same in UTF-8. /^\/^\ _|__| O| \/ /~ \_/ \ \____|__________/ \ \_______ \ `\ \ \ | | \ / / \ / / \\ / / \ \ / / \ \ / / _----_ \ \ / / _-~ ~-_ | | ( ( _-~ _--_ ~-_ _/ | \ ~-____-~ _-~ ~-_ ~-_-~ / ~-_ _-~ ~-_ _-~ - jurcy - ~--______-~ ~-___-~ From anh.hai.trinh at gmail.com Sun Feb 12 22:57:41 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 19:57:41 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> Message-ID: <3727311.760.1329105461373.JavaMail.geo-discussion-forums@pbcmg9> On Monday, February 13, 2012 3:13:17 AM UTC+7, Vinay Sajip wrote: > On Feb 12, 3:35?pm, Anh Hai Trinh wrote: > > > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. > > > > I have looked at pbs and clom: they Pythonify calls to external > programs by making spawning those look like function calls. There's > nothing wrong with that, it's just a matter of taste. I find that e.g. > > wc(ls("/etc", "-1"), "-l") > > is not as readable as > > call(?ls /etc ?1 | wc ?l?) I don't disagree with it. But the solution is really easy, just call 'sh' and pass it a string! >>> from extproc import sh >>> n = int(sh(?ls /etc ?1 | wc ?l?)) No parser needed written! Yes there is a danger of argument parsing and globs and all that. But people are aware of it. With string parsing, ambiguity is always there. Even when you have a BNF grammar, people easily make mistakes. From rantingrickjohnson at gmail.com Sun Feb 12 23:08:24 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:08:24 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> On Feb 12, 9:35?am, Anh Hai Trinh wrote: > > It's not hard for the user > > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. Objection! Does the defense REALLY expect this court to believe that he can testify as to how MOST members of the Python community would or would not favor bash over Python? And IF they do in fact prefer bash, is this display of haughty arrogance nothing more than a hastily stuffed straw-man presented to protect his own ego? > > ?BTW extproc is nice, but I wanted to push the envelope a little :-) > > Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p And why do you need to voice such strong opinions of disdain in an announcement thread? Testing the integrity of a module (or module) author is fine so long as we are respectful whilst doing so. However, i must take exception with your crass attitude. From ben+python at benfinney.id.au Sun Feb 12 23:19:13 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 13 Feb 2012 15:19:13 +1100 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87ty2v1i2m.fsf@benfinney.id.au> Roy Smith writes: > All that is just fine, but what the heck are we going to do about ascii > art, that's what I want to know. Python just won't be the same in > UTF-8. If it helps, ASCII art *is* UTF-8 art. So it will be the same in UTF-8. Or maybe you already knew that, and your sarcasm was lost with the high bit. -- \ ?We are all agreed that your theory is crazy. The question that | `\ divides us is whether it is crazy enough to have a chance of | _o__) being correct.? ?Niels Bohr (to Wolfgang Pauli), 1958 | Ben Finney From rantingrickjohnson at gmail.com Sun Feb 12 23:26:02 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:26:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> Message-ID: <33357dbf-8eef-434c-a872-7c3366c8d071@b23g2000yqn.googlegroups.com> On Feb 12, 2:13?pm, Vinay Sajip wrote: > wc(ls("/etc", "-1"), "-l") > > is not as readable as > > call(?ls /etc ?1 | wc ?l?) And i agree! I remember a case where i was forced to use an idiotic API for creating inputbox dialogs. Something like this: prompts = ['Height', 'Width', 'Color'] values = [10, 20, Null] options = [Null, Null, "Red|White|Blue"] dlg(prompts, values, options) ...and as you can see this is truly asinine! Later, someone "slightly more intelligent" wrapped this interface up like this: dlg = Ipb("Title") dlg.add("Height") dlg.add("Width", 39) dlg.add("Color", ["Red", "White", "Blue"]) dl.show() ...and whilst i prefer this interface over the original, i new we could make it better; because we had the technology! dlg = Ipb( "Title", "Height=10", "Width=20", "Color=Red|Green|Blue", ) Ahh... refreshing as a cold brew! From rantingrickjohnson at gmail.com Sun Feb 12 23:48:54 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:48:54 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> On Feb 12, 12:10?am, Steven D'Aprano wrote: > On Sat, 11 Feb 2012 18:36:52 -0800, Rick Johnson wrote: > >> "I have a file containing text. I can open it in an editor and see it's > >> nearly all ASCII text, except for a few weird and bizarre characters > >> like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I > >> get an error. What should I do that requires no thought?" > > >> Obvious answers: > > > the most obvious answer would be to read the file WITHOUT worrying about > > asinine encoding. > > Your mad leet reading comprehension skillz leave me in awe Rick. Same goes for your abstract reasoning skillz! You're attempting to treat the problem, whilst ignoring the elephant in the room -- THE DISEASE!. Do you think that cost of healthcare is the problem? Do you think the cost of healthcare insurance is the problem? NO! The problem is people expect entitlements. If you can't afford healthcare, then you die. If you can't afford food, then you starve. If you can't afford prophylactics, then you will be sentenced to eighteen years of hell! Maybe a charity will help you, or maybe a friend, or maybe a neighbor. If not, then you suffer the fatal exception. Life sucks, deal with it! You want to solve the healthcare problem then STOP TREATING PEOPLE WHO DON'T HAVE INSURANCE! Problem solved! You are only born with one guarantee; you will die, guaranteed! Any questions? The problem with bytes is not encodings or OS's. Can you guess what the REAL problem is? ..take all the time you need. From rosuav at gmail.com Mon Feb 13 00:03:45 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 16:03:45 +1100 Subject: Python usage numbers In-Reply-To: <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 3:48 PM, Rick Johnson wrote: > The problem with bytes is not encodings or OS's. Can you guess what > the REAL problem is? ..take all the time you need. The REAL problem is trolls. But they're such fun, and so cute when they get ranting... ChrisA From dllizheng at gmail.com Mon Feb 13 01:59:27 2012 From: dllizheng at gmail.com (Zheng Li) Date: Mon, 13 Feb 2012 15:59:27 +0900 Subject: how to tell a method is classmethod or static method or instance method Message-ID: how to tell a method is class method or static method or instance method? From anh.hai.trinh at gmail.com Mon Feb 13 02:08:23 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 23:08:23 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> Message-ID: <29663741.635.1329116903835.JavaMail.geo-discussion-forums@pbbr5> > Objection! Does the defense REALLY expect this court to believe that > he can testify as to how MOST members of the Python community would or > would not favor bash over Python? And IF they do in fact prefer bash, > is this display of haughty arrogance nothing more than a hastily > stuffed straw-man presented to protect his own ego? Double objection! Relevance. The point is that the OP created another language that is neither Python nor Bash. > And why do you need to voice such strong opinions of disdain in an > announcement thread? Testing the integrity of a module (or module) > author is fine so long as we are respectful whilst doing so. However, > i must take exception with your crass attitude. My respectful opinion is that the OP's approach is fundamentally flawed. There are many platform-specific issues when forking and threading are fused. My benign intent was to warn others about unsolved problems and scratching-your-head situations. Obviously, the OP can always choose to continue his direction at his own discretion. From cs at zip.com.au Mon Feb 13 02:23:39 2012 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 13 Feb 2012 18:23:39 +1100 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: References: Message-ID: <20120213072339.GA9132@cskk.homeip.net> On 13Feb2012 15:59, Zheng Li wrote: | how to tell a method is class method or static method or instance method? Maybe a better question is: under what circumstances do you need to figure this out? I'm actually quite serious here. Please outline what circumstances cause you to want to ask and answer this question. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Reason #173 to fear technology: o o o o o o ^|\ ^|^ v|^ v|v |/v |X| \| | /\ >\ /< >\ /< >\ /< >\ o> o o o o o o o \ x <\> <)> |\ /< >\ /< >\ /< >\ >> L Mr. email does the Macarena. From steve+comp.lang.python at pearwood.info Mon Feb 13 03:03:24 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 08:03:24 GMT Subject: how to tell a method is classmethod or static method or instance method References: Message-ID: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > how to tell a method is class method or static method or instance > method? That's a good question, with a subtle answer that depends on exactly what you mean by the question. If you mean the object you get back from ordinary attribute access like "instance.method", then you do this: >>> class K(object): ... @classmethod ... def cmethod(cls): ... pass ... @staticmethod ... def smethod(): ... pass ... def method(self): ... pass ... >>> k = K() >>> type(k.smethod) So static methods are just functions, and both class methods and instance methods share the same underlying type: >>> type(k.method) >>> type(k.cmethod) But if you dig deeper, you learn that all methods are actually descriptors: >>> type(K.__dict__['cmethod']) >>> type(K.__dict__['smethod']) >>> type(K.__dict__['method']) (Functions are descriptors too.) This is deep magic in Python, but if you want to learn more about it, you can read this: http://users.rcn.com/python/download/Descriptor.htm And I'll take this opportunity to plug my dualmethod descriptor: http://code.activestate.com/recipes/577030-dualmethod-descriptor/ -- Steven From steve+comp.lang.python at pearwood.info Mon Feb 13 03:05:33 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 08:05:33 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> Message-ID: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> On Sun, 12 Feb 2012 20:48:54 -0800, Rick Johnson wrote: > Do you think that cost of healthcare is the problem? Do you think the > cost of healthcare insurance is the problem? NO! The problem is people > expect entitlements. Entitlements? I work hard and pay my taxes. I *earned* that healthcare that trolls like you call an entitlement. Damn straight it's an entitlement -- I paid for it, I earned it, I'm entitled to it, and if you try to steal if from me, expect a fight. Socialised healthcare is a win-win system: - the working class wins, because they get healthcare at a much cheaper rate than they could otherwise afford - bosses win, because they have reduced absenteeism, lower training costs to replace workers who die, and fewer epidemics that threaten their own families - Wall Street wins, because productivity is increased due to better health - pharmaceutical companies win, because even though their profits on individual items are reduced, their increased sales more than make up for it - doctors win, because they spend more time getting paid to deal with patients and less unproductive time on dealing with insurance companies - the economy wins, because fewer people are bankrupted by simple medical procedures The only loss is for the insurers, who have to get an honest job. So why on earth is anyone against socialised healthcare when it provably works better than the US system? Simple. To a certain mind, "win-win" is not a good thing, it is a bad thing. "Win-win" implies that you might have to share the pie instead of eating it all yourself, and to that sort of person, anything less than ALL the pie might as well be nothing at all. What's the point of being wealthy and powerful without having hungry, sick peons to lord over? How will you know you have won unless others lose? The inefficiencies (economic and moral) of the US private healthcare system are not a bug, they are a feature. It is part of the war the 1% of the 1% have been waging on the rest of society for the last 40 years. > You are only born with one > guarantee; you will die, guaranteed! Any questions? Yes. Why haven't you moved to a libertarian paradise like Somalia yet? You'd like it there. There are two sorts of people: those who can afford their own private militia, and victims. -- Steven From cezar4846 at gmail.com Mon Feb 13 03:37:13 2012 From: cezar4846 at gmail.com (zigi) Date: Mon, 13 Feb 2012 00:37:13 -0800 (PST) Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Hello, this is must be testing time to crypt files, using just M2crypto :-) I know this is a strange use of the library, but such is the will of the management. On 13 Lut, 01:28, geremy condra wrote: > On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > > zigi wrote: > > >> Hello, > >> M2crypto > > >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > >> salt='12345678', i=1, padding=1) > > >> I wont write app, using M2crypto and I can not understand what are the > >> arguments: > >> key, iv, op, salt ? > >> What they do ? > > > I assume you're reading in > > about M2Crypto.EVP.Cipher. > > > Epydoc claims another victim. > > > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > > pages are kind of thin, too. ?You might see some useful code in the EVP unit > > tests m2crypto/tests/test_evp.py in the m2crypto installation. > > Not intending to be rude, but being perfectly serious: as a general > rule, if you don't know what an IV is you're probably getting yourself > into a lot of trouble working with low-level crypto libraries. > > Two suggestions: > > 1. Describe what you're trying to do- I'll be able to help more if I > know what you're actually going for. > > 2. Try keyczar. It's not perfect, but it's a lot easier to get right. > > Geremy Condra From dihedral88888 at googlemail.com Mon Feb 13 04:01:33 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 13 Feb 2012 01:01:33 -0800 (PST) Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> References: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> Message-ID: <5016707.681.1329123693532.JavaMail.geo-discussion-forums@pbsp9> ? 2012?2?13????UTC+8??4?03?24??Steven D'Aprano??? > On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > > > how to tell a method is class method or static method or instance > > method? > > That's a good question, with a subtle answer that depends on exactly what > you mean by the question. If you mean the object you get back from > ordinary attribute access like "instance.method", then you do this: > > >>> class K(object): > ... @classmethod > ... def cmethod(cls): > ... pass > ... @staticmethod > ... def smethod(): > ... pass > ... def method(self): > ... pass > ... > >>> k = K() > >>> type(k.smethod) > > > So static methods are just functions, and both class methods and instance > methods share the same underlying type: > > >>> type(k.method) > > >>> type(k.cmethod) > > > > But if you dig deeper, you learn that all methods are actually > descriptors: > > >>> type(K.__dict__['cmethod']) > > >>> type(K.__dict__['smethod']) > > >>> type(K.__dict__['method']) > > > (Functions are descriptors too.) > > This is deep magic in Python, but if you want to learn more about it, you > can read this: > > http://users.rcn.com/python/download/Descriptor.htm > > > And I'll take this opportunity to plug my dualmethod descriptor: > > http://code.activestate.com/recipes/577030-dualmethod-descriptor/ > > > > -- > Steven The methods of an object can be well organized to avoid redundant checks of operations desired to be performed on the object. Also an object's methods should be factored to be easy to be maintained and to provide debugging and error information for the programmer to track the operations related to the hardware, the OS, and the sofware design issues. From vinay_sajip at yahoo.co.uk Mon Feb 13 05:34:02 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 13 Feb 2012 02:34:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> <3727311.760.1329105461373.JavaMail.geo-discussion-forums@pbcmg9> Message-ID: <2e7131d3-6d30-45ab-a22a-2e54e2112818@m24g2000yqb.googlegroups.com> On Feb 13, 3:57?am, Anh Hai Trinh wrote: > > I don't disagree with it. But the solution is really easy, just call 'sh' and pass it a string! > > >>> from extproc import sh > >>> n = int(sh(?ls /etc ?1 | wc ?l?)) > > No parser needed written! > > Yes there is a danger of argument parsing and globs and all that. But people are aware of it. With string parsing, ambiguity is always there. Even when you have a BNF grammar, people easily make mistakes. You're missing a few points: * The parser is *already* written, so there's no point worrying about saving any effort. * Your solution is to pass shell=True, which as you point out, can lead to shell injection problems. To say "people are aware of it" is glossing over it a bit - how come you don't say that when it comes to locking+forking? ;-) * I'm aiming to offer cross-platform functionality across Windows and Posix. Your approach will require a lower common denominator, since the Windows shell (cmd.exe) is not as flexible as Bash. For example - no "echo foo; echo bar"; no "a && b" or "a || b" - these are not supported by cmd.exe. * Your comment about people making mistakes applies just as much if someone passes a string with a Bash syntax error, to Bash, via your sh() function. After all, Bash contains a parser, too. For instance: >>> from extproc import sh >>> sh('ls >>> abc') /bin/sh: Syntax error: redirection unexpected '' If you're saying there might be bugs in the parser, that's something else - I'll address those as and when they turn up. Regards, Vinay Sajip From vinay_sajip at yahoo.co.uk Mon Feb 13 05:59:01 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 13 Feb 2012 02:59:01 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> <29663741.635.1329116903835.JavaMail.geo-discussion-forums@pbbr5> Message-ID: On Feb 13, 7:08?am, Anh Hai Trinh wrote: > > Objection! Does the defense REALLY expect this court to believe that > > he can testify as to how MOST members of the Python community would or > > would not favor bash over Python? And IF they do in fact prefer bash, > > is this display of haughty arrogance nothing more than a hastily > > stuffed straw-man presented to protect his own ego? > > Double objection! Relevance. The point is that the OP created another language that is neither Python nor Bash. > Triple objection! I think Rick's point was only that he didn't think you were expressing the views of "most" people, which sort of came across in your post. To say I've created "another language" is misleading - it's just a subset of Bash syntax, so you can do things like "echo foo; echo bar", use "&&", "||" etc. (I used the Bash man page as my guide when designing the parser.) As an experiment on Windows, in a virtualenv, with GnuWin32 installed on the path: (venv) C:\temp>python ActivePython 2.6.6.17 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from extproc import sh >>> sh('echo foo; echo bar') Traceback (most recent call last): File "", line 1, in File "C:\temp\venv\lib\site-packages\extproc.py", line 412, in sh f = Sh(cmd, fd=fd, e=e, cd=cd).capture(1).stdout File "C:\temp\venv\lib\site-packages\extproc.py", line 202, in capture p = subprocess.Popen(self.cmd, cwd=self.cd, env=self.env, stdin=self.fd[0], stdout=self.fd[1], stderr=self.fd[2]) File "C:\Python26\Lib\subprocess.py", line 623, in __init__ errread, errwrite) File "C:\Python26\Lib\subprocess.py", line 833, in _execute_child startupinfo) WindowsError: [Error 3] The system cannot find the path specified >>> from sarge import capture_stdout >>> capture_stdout('echo foo; echo bar').stdout.text u'foo\r\nbar\r\n' >>> That's all from a single interactive session. So as you can see, my use cases are a little different to yours, which in turn makes a different approach reasonable. > My respectful opinion is that the OP's approach is fundamentally flawed. There are many platform-specific issues when forking and threading are fused. My benign intent was to warn others about unsolved problems and scratching-your-head situations. > > Obviously, the OP can always choose to continue his direction at his own discretion. I think you were right to bring up the forking+threading issue, but I have addressed the points you made in this thread - please feel free to respond to the points I made about the Linux Programming Blog article. I've updated the sarge docs to point to that article, and I've added a section on API stability to highlight the fact that the library is in alpha status and that API changes may be needed based on feedback. I'm not being blas? about the issue - it's just that I don't want to be too timid, either. Python does not proscribe using subprocess and threads together, and the issues you mention could easily occur even without the use of sarge. You might say that sarge makes it more likely that the issues will surface - but it'll only do that if you pass "a & b & c & d" to sarge, and not otherwise. The other use of threads by sarge - to read output streams from child processes - is no different from the stdlib usage of threads in subprocess.Popen.communicate(). Possibly Rick was objecting to the tone of your comments, but I generally disregard any tone that seems confrontational when the benefit of the doubt can be given - on the Internet, you can never take for granted, and have to make allowances for, the language style of your interlocutor ... I think you meant well when you responded, and I have taken your posts in that spirit. Regards, Vinay Sajip From mcepl at redhat.com Mon Feb 13 06:20:28 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 13 Feb 2012 12:20:28 +0100 Subject: XSLT to Python script conversion? Message-ID: Hi, I am getting more and more discouraged from using XSLT for a transformation from one XML scheme to another one. Does anybody could share any experience with porting moderately complicated XSLT stylesheet (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) into a Python script using ElementTree's interparse or perhaps xml.sax? Any tools for this? Speed differences (currently I am using xsltproc)? Any thoughts? Thank you, Mat?j From mateusz at loskot.net Mon Feb 13 06:57:41 2012 From: mateusz at loskot.net (mloskot) Date: Mon, 13 Feb 2012 03:57:41 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: References: <1328872312611-4382967.post@n6.nabble.com> Message-ID: <1329134261942-4464760.post@n6.nabble.com> Terry Reedy wrote > > On 2/10/2012 6:11 AM, mloskot wrote: >> The intent of xyz.flag is that it is a value set by the module >> internally. >> xyz is a module wrapping a C library. >> The C library defines concept of a global flag set by the C functions at >> some events, >> so user can check value of this flag. >> I can provide access to it with function: xyz.get_flag() > > If the value of the flag can change during a run, I would do that. > Otherwise, you have to make sure the local copy keeps in sync. Users > might also think that it is a true constant that they could read once. > > I understand that you might be concerned that one person in a > multi-programmer project might decide to rebind xyz.flag and mess up > everyone else. I think the real solution might be an option to freeze an > entire module. > Terry, Thanks for your really helpful notes. Best regards, ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4464760.html Sent from the Python - python-list mailing list archive at Nabble.com. From stefan_ml at behnel.de Mon Feb 13 08:34:08 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 13 Feb 2012 14:34:08 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: Matej Cepl, 13.02.2012 12:20: > I am getting more and more discouraged from using XSLT for a transformation > from one XML scheme to another one. Could you explain what it is that discourages you about it? That would allow us to come up with better alternatives for your specific problem. > Does anybody could share any experience > with porting moderately complicated XSLT stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? Any > thoughts? You could try switching to lxml. It would at least allow you to do a part of the processing in Python and only use XSLT when it seems more appropriate and/or easier. Stefan From info at egenix.com Mon Feb 13 08:49:31 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 13 Feb 2012 14:49:31 +0100 Subject: ANN: eGenix pyOpenSSL Distribution 0.13.0-1.0.0g Message-ID: <4F3914EB.8000306@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.0-1.0.0g An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.0-1.0.0g-1.html ________________________________________________________________________ INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ ________________________________________________________________________ NEWS This new release of the eGenix.com pyOpenSSL Distribution updates the included pyOpenSSL version to 0.13.0 and the included OpenSSL version to 1.0.0g. Main new features in pyOpenSSL sine 0.10.0 ------------------------------------------ * pyOpenSSL 0.11 fixes a few bugs related to error processing; see https://launchpad.net/pyopenssl/+announcement/7128 * pyOpenSSL 0.12 fixes interaction with memoryviews, adds TLS callbacks and x509 extension introspection; see https://launchpad.net/pyopenssl/+announcement/8151 * pyOpenSSL 0.13 adds OpenSSL 1.0 support (which eGenix contributed) and a few new APIs; see https://lists.launchpad.net/pyopenssl-users/msg00008.html Please see Jean-Paul Calderone's above announcements for more details. New features in OpenSSL 1.0.0g since 1.0.0a ------------------------------------------- OpenSSL 1.0.0g fixes several vulnerabilities relative to 1.0.0a: http://openssl.org/news/vulnerabilities.html and includes a number of stability enhancements as well as extra protection against attacks: http://openssl.org/news/changelog.html New features in the eGenix pyOpenSSL Distribution ------------------------------------------------- * Updated the pyOpenSSL license information from LGPL to Apache License 2.0. * Added support for Python 2.7 on all platforms. * Added documentation for automatic download of egg distributions using compatible tools such as easy_install and zc.buildout. As always, we provide binaries that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64. We've also added egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ ________________________________________________________________________ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. _______________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. ________________________________________________________________________ MORE INFORMATION For more information about the eGenix pyOpenSSL Distributon, licensing and download instructions, please visit our web-site or write to sales at egenix.com. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 13 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From tkpmep at gmail.com Mon Feb 13 08:55:41 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Mon, 13 Feb 2012 05:55:41 -0800 (PST) Subject: Removing items from a list References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <306adc3f-e452-48ed-9be0-2656248f738c@m5g2000yqk.googlegroups.com> I could indeed have addressed this problem with a list comprehension. It escaped me at the time because the larger problem I was trying to solve included removing data from a dictionary: months = sorted(list(dataDict.keys())) #Sort months in ascending order for mth in reversed(months): #Remove months with inadequate data if len(dataDict[mth]) < minItems: months.remove(mth) del dataDict[mth] There's more than one way to solve this problem, and, with the benefit of hindsight, my solution was sloppy, but thanks to the help I received, I was able to get my code working correctly. Cleaning up is the next phase! Thanks, all. From rantingrickjohnson at gmail.com Mon Feb 13 11:01:59 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 08:01:59 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Feb 13, 2:05?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 20:48:54 -0800, Rick Johnson wrote: > > Do you think that cost of healthcare is the problem? Do you think the > > cost of healthcare insurance is the problem? NO! The problem is people > > expect entitlements. > > Entitlements? I work hard and pay my taxes. I *earned* that healthcare > that [gentlemen] like you call an entitlement. Damn straight it's an > entitlement -- I paid for it, I earned it, I'm entitled to it, And just how much healthcare dollars are you entitled to exactly? Can you put your entitlement into some form of monetary value? And how can we ever make a system like this fair? If someone works for 30 years and pays a 30% tax rate and another works for 2 years and pays 15%, then how do we delegate the fair share? The answer is you can't delegate fairness in a system like this. The system of "i pay taxes therfore i deserve a free heart transplant" is broken! And don't forget, your tax dollars are not just for coving the cost of healthcare. What about infrastructure, social security, welfare, military, government bail-outs, bribe money to rouge states, earmarks, bridges to nowhere, and and even planting trees on the main highways? These things cost money you know! How about instead of enriching the government by increasing taxes YOU just live within your means? If you can afford healthcare, great! If not, too bad. > and if you > try to steal if from me, expect a fight. Steal what from you... you're stealing from everyone else! You're expecting ME to cover YOUR healthcare. What's next? I should supplement your income so you can you buy a summer home? What about folks who gorge on sugar, saturated fats, and salt all their lives with no regard for their own health? What happens when they develop diabetes, heart disease, and cancer? Do you think the measly little amount of taxes they payed (IF THEY PAYED AT ALL!) will cover a heart transplant or cancer treatments? Who will pay when they cannot? What about the idiots who smoke cigarettes, drink alcohol, and/or abuse drugs (prescription or otherwise). Should your tax dollars cover these medical expenses? Who will pay when they cannot? What about people who are too lazy to cook their children healthy meals and instead rely on fast food and soda? What happens when those same kids become morbidly obese? Why are we not charging these idiots with child abuse? Who will pay when they cannot? *Selfish Sam blubbers:* "I pay taxes, so the government needs to subsidize my unhealthy lifestyle!" But where does the "government money" come from Sam? Sam: Taxes? Very good Sam, and WHO pays taxes? Sam: Citizens? You're very smart Sam. And what do think will happen when the government needs more money? Sam: They will increase taxes? Good boy Sam! Here is a treat. Now run along and fetch the newspaper. Taxes are tranny. And you WANT to give them an excuse to increase taxes! We are doomed! > Socialised healthcare is a win-win system: Sure, for the degenerates! > - the working class wins, because they get healthcare at a much cheaper > rate than they could otherwise afford Healthcare is expensive. Do you want a minimum wage doctor curing your ills? And the frivolous lawsuits are not bringing the costs down either. > - bosses win, because they have reduced absenteeism, lower training costs > to replace workers who die, and fewer epidemics that threaten their own > families BS! With free healthcare, those who would have allowed their immune system fight off the flu, now take off from work, visit a local clinic, and get pumped full of antibiotics so they can create a new strain of antibiotic resistant flu virus! Thanks free healthcare! > - Wall Street wins, because productivity is increased due to better health Oh yes, and wall street is the hope of the future. Thank god they are winning. Thank god they are healthy enough to rob us for another day. Thank god! > - pharmaceutical companies win, because even though their profits on > individual items are reduced, their increased sales more than make up for > it This is the same thing that happened to the funiture industry. They call it the "Assembly Line". I don't know how you feel, but i think mass produced furniture sucks a big fat Python! > - doctors win, because they spend more time getting paid to deal with > patients and less unproductive time on dealing with insurance companies Doctors have minions for those tasks. Do you actually believe doctors are on the phone with insurance companies? They are at the freaking golf course! > - the economy wins, because fewer people are bankrupted by simple medical > procedures It sucks that medical can be so expensive, and i am all for reducing the costs. However, we cannot implement a system that rewards the slothful degenerates of society on the backs of the hard working. Evolution knows how to handle degenerates. > The only loss is for the insurers, who have to get an honest job. So why > on earth is anyone against socialised healthcare when it provably works > better than the US system? If you look around the world, you will see that socialized heathcare has been around for a long time. Let me know when it "solves the healthcare problem"... psst, i won't be holding my breath! > Simple. To a certain mind, "win-win" is not a good thing, it is a bad > thing. "Win-win" implies that you might have to share the pie instead of > eating it all yourself, and to that sort of person, anything less than > ALL the pie might as well be nothing at all. That's the chant of the folks who have no capacity to think for themselves. It's also used by the "controllers" to incite the foolish masses through emotional rhetoric. The fact is, socialized medicine is SOMEONE ELSE paying for YOUR healthcare. Socialized medicine is YOU leaching off the backs of others. Here's a novel idea, subsidize your own damn healthcare! You are born with rights. Life, Liberty, and the pursuit of happiness. Healthcare care is NOT a right, healthcare is a privileged. Driving a car is not a right, it is a privileged. Procreation should be a privilege, however sadly for our collective evolution, it's seems to be a right :( > The inefficiencies (economic and moral) of the US private healthcare > system are not a bug, they are a feature. It is part of the war the 1% of > the 1% have been waging on the rest of society for the last 40 years. What is the goal of the war? Do you really think the one percent want to destroy the working class? If they did manage to destroy us, then who would clean their house, take out there garbage, work in the factories and sweat shops, shine their shoes, wash their cars, wipe their @$$? Who would create that next new cool IPhone app? Look, i hate super rich, arrogant people just as much i hate selfish people. I think you need to take a step back from your emotional temper tantrum and smell the $hit your shoveling! It is my god given right to live free of tyranny, not be enslaved by taxes so i can subsidize you lifespan. Not so you can live to be 104 whilst trying to suck every last breath out of an oxygen canister. No, you live and die by your own choices and the cards that were dealt to you. Leave me the freak out of your selfish card game! From steve+comp.lang.python at pearwood.info Mon Feb 13 11:12:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 16:12:23 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4f393666$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > Evolution knows how to handle degenerates. And yet here you still are. -- Steven From rantingrickjohnson at gmail.com Mon Feb 13 11:27:00 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 08:27:00 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <4f393666$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <07200b63-08a7-4ed4-ac77-0b0f04ee2186@i18g2000yqf.googlegroups.com> On Feb 13, 10:12?am, Steven D'Aprano wrote: > On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > > Evolution knows how to handle degenerates. > > And yet here you still are. Embrace the perfection of evolution, and both our needs shall be met! From mcfletch at vrplumber.com Mon Feb 13 11:28:49 2012 From: mcfletch at vrplumber.com (Mike C. Fletcher) Date: Mon, 13 Feb 2012 11:28:49 -0500 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: <4F393A41.6030901@vrplumber.com> On 12-02-13 06:20 AM, Matej Cepl wrote: > Hi, > > I am getting more and more discouraged from using XSLT for a > transformation from one XML scheme to another one. Does anybody could > share any experience with porting moderately complicated XSLT > stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? > Any thoughts? > > Thank you, > > Mat?j I wound up rewriting the Docbook to XSL transformation for PyOpenGL's docs in Python using lxml.etree and Kid (now reworked to use Genshi). However, that was a fairly direct translation, it has only a handful of strategies for transforming nodes from docbook to xhtml. That said, it took our processing time down from so-long-I-just-didn't-want-to-work-on-the-docs down to regenerate-whenever-I-make-a-trivial-change. http://bazaar.launchpad.net/~mcfletch/pyopengl/directdocs/files Is the repository where the project lives. It *also* does a lot of other processing, but the generate.py, model.py and templates/section.kid files are all you need to look at to understand the docbook processing. HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com From tim.wintle at teamrubber.com Mon Feb 13 11:41:34 2012 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Mon, 13 Feb 2012 16:41:34 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <1329151294.15792.64.camel@tim-laptop> (Sorry for top-posting this bit, but I think it's required before the rest of my response) At the risk of wading into this from a UK citizen's perspective: You're imagining a public healthcare system as if it were private. Imagine you go to a doctor and say "I've got the flu, can you give me antibiotics". In a Private healthcare system: * The doctor gets paid for retaining a client. * He is incentivised to do what you request. ... so he gives you the antibiotics. In a Public healthcare system: * The doctor is paid no matter what. * His job is to stop the population becoming ill. * By reducing illnesses he reduces his workload, without reducing his wage ... so he'll only give you antibiotics if he feels you are at serious risk, and giving you antibiotics carries less risk for the population than the risk of the population getting immunities. Same goes for surgery etc. On Mon, 2012-02-13 at 08:01 -0800, Rick Johnson wrote: > And just how much healthcare dollars are you entitled to exactly? Can > you put your entitlement into some form of monetary value? > > And how can we ever make a system like this fair? If someone works for > 30 years and pays a 30% tax rate and another works for 2 years and > pays 15%, then how do we delegate the fair share? If your children are educated privately then should you still be paying taxes for education? If you work for/bank with a company that doesn't need to be bailed out, then should you still pay tax for that? If you never need benefits (welfare) then should your taxes be paying for that? you can use that same argument for everything that taxes pay for - the only logical conclusion of that argument is anarchy (i.e. no taxes, and no government). If you are an anarchist then that's a different argument all together (not saying it doesn't have intellectual validity). > Healthcare is expensive. Do you want a minimum wage doctor curing your > ills? And the frivolous lawsuits are not bringing the costs down > either. It's so expensive because of the marketing, and because of all the middle-men. A public health system doesn't need to do that marketing. They also don't need to put up with people who aren't seriously ill - I don't know how long your private appointments are, but here in the UK a standard doctor's appointment is 5-10 minutes. If they decide you're actually ill they may extend that. > > - bosses win, because they have reduced absenteeism, lower training costs > > to replace workers who die, and fewer epidemics that threaten their own > > families > > BS! With free healthcare, those who would have allowed their immune > system fight off the flu, now take off from work, visit a local > clinic, and get pumped full of antibiotics so they can create a new > strain of antibiotic resistant flu virus! Thanks free healthcare! See my comments at the top. From miki.tebeka at gmail.com Mon Feb 13 12:18:16 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:18:16 -0800 (PST) Subject: package extension problem In-Reply-To: References: Message-ID: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> > B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. I don't understand this sentence. How does B[some_hash] related to A? I've tried the below and it seems to work. Can you paste some code to help us understand more? -- old.py -- class A: pass -- new.py __ import old class A(old.A): pass -- main.py -- import new a = new.A() a.__class__ # Shows new.A From miki.tebeka at gmail.com Mon Feb 13 12:18:16 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:18:16 -0800 (PST) Subject: package extension problem In-Reply-To: References: Message-ID: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> > B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. I don't understand this sentence. How does B[some_hash] related to A? I've tried the below and it seems to work. Can you paste some code to help us understand more? -- old.py -- class A: pass -- new.py __ import old class A(old.A): pass -- main.py -- import new a = new.A() a.__class__ # Shows new.A From f.pollastri at inrim.it Mon Feb 13 12:53:27 2012 From: f.pollastri at inrim.it (Fabrizio Pollastri) Date: Mon, 13 Feb 2012 18:53:27 +0100 Subject: package extension problem In-Reply-To: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <4F394E17.9090108@inrim.it> Ok. To be more clear, consider the real python package Pandas. This package defines a Series class and a DataFrame class. The DataFrame is a matrix that can have columns of different type. If I write import pandas as pd df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]}) a data frame with two cols named A and B is created. If I write col_A = df['A'] the returned col_A is an instance of Series. Now , let suppose that I want to extend some functionality of pandas by adding new methods to both Series and DataFrame classes. One way to do this is to redefine this classes in a new package (new_pandas) as follow import pandas as pd class Series(pd.Series): ... add new methods ... class DataFrame(pd.DataFrame): ... add new methods ... When I use the new package as a pandas substitute and write import new_pandas as np df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) col_A = df['A'] col_A is an instance of the original pandas and not of the new pandas, losing all the added functionality. Fabrizio Now, how can I add new methods to extend the functionality of pandas classes Series and DataFrame From miki.tebeka at gmail.com Mon Feb 13 12:58:02 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:58:02 -0800 (PST) Subject: package extension problem In-Reply-To: References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] I'm not familiar with pandas, but my *guess* will be that you'll need to override __getitem__ in the new DataFrame. From miki.tebeka at gmail.com Mon Feb 13 12:58:02 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:58:02 -0800 (PST) Subject: package extension problem In-Reply-To: References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] I'm not familiar with pandas, but my *guess* will be that you'll need to override __getitem__ in the new DataFrame. From malaclypse2 at gmail.com Mon Feb 13 13:00:52 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Mon, 13 Feb 2012 13:00:52 -0500 Subject: package extension problem In-Reply-To: <4F3808EC.1000301@inrim.it> References: <4F3808EC.1000301@inrim.it> Message-ID: On Sun, Feb 12, 2012 at 1:46 PM, Fabrizio Pollastri wrote: > Hello, > > I wish to extend the functionality of an existing python package by > creating > a new package that redefines the relevant classes of the old package. Each > new class inherits the equivalent old class and adds new methods. > ... There is a way to solve this problem without redefining in the new package > all the > methods of the old package that return old classes? > The general answer is no. If you want the methods of your subclass to behave differently, in any way, from the same methods in the superclass, then you must write new code that defines the behavior that you want. Sometimes people write their classes so they automatically play nicely when subclassed, and sometimes they don't. In general, it's impossible to always do the right thing when you don't know what particular behavior a subclass might need to override, so a lot of times people don't bother to write their classes to check for subclasses being passed in, etc. Since you haven't actually shown us any code, that's about all I can tell you. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Mon Feb 13 13:26:26 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Mon, 13 Feb 2012 12:26:26 -0600 Subject: Python usage numbers In-Reply-To: <87ty2v1i2m.fsf@benfinney.id.au> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <87ty2v1i2m.fsf@benfinney.id.au> Message-ID: <4F3955D2.90809@gmail.com> On 2/12/2012 10:19 PM, Ben Finney wrote: > If it helps, ASCII art *is* UTF-8 art. So it will be the same in UTF-8. As will non-ASCII text art: ? ?l? ????? ? ? ?l?? ~? ? ??f_, )? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From __peter__ at web.de Mon Feb 13 13:28:05 2012 From: __peter__ at web.de (Peter Otten) Date: Mon, 13 Feb 2012 19:28:05 +0100 Subject: package extension problem References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <4F394E17.9090108@inrim.it> Message-ID: Fabrizio Pollastri wrote: > Ok. To be more clear, consider the real python package Pandas. > > This package defines a Series class and a DataFrame class. > The DataFrame is a matrix that can have columns of > different type. > > If I write > > import pandas as pd > df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > > a data frame with two cols named A and B is created. > > If I write > > col_A = df['A'] > > the returned col_A is an instance of Series. > > Now , let suppose that I want to extend some functionality of pandas > by adding new methods to both Series and DataFrame classes. > > One way to do this is to redefine this classes in a new package > (new_pandas) as follow > > import pandas as pd > > class Series(pd.Series): > ... > add new methods > ... > > class DataFrame(pd.DataFrame): > ... > add new methods > ... > > When I use the new package as a pandas substitute and write > > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] > > col_A is an instance of the original pandas and not of the new pandas, > losing all the added functionality. A quick look into the pandas source reveals that the following might work: # untested class DataFrame(pd.DataFrame): @property def _constructor(self): return DataFrame # your class # your new methods From ian.g.kelly at gmail.com Mon Feb 13 13:38:46 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Feb 2012 11:38:46 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: I hate being suckered in by trolls, but this paragraph demands a response. On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson wrote: > You are born with rights. Life, Liberty, and the pursuit of happiness. > Healthcare care is NOT a right, healthcare is a privileged. If you deprive a person of access to healthcare, and they die, then you have deprived them of life and thus violated the very rights that you just stated they had. In any case, taking that phrase from the Declaration of Independence and holding it out as an exhaustive list of rights is moronic. First, because it's not even a legal document -- it's only a statement of high-minded classical liberalism, albeit a historically important and influential one. Second, because it actually states "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that **AMONG** these are Life, Liberty and the pursuit of Happiness." The phrasing obviously implies that there are other human rights besides the three examples listed. After all, the purpose of the document was not to enumerate all human rights, but to air a list of grievances against King George and assert the right to revolt against him. Incidentally, "not being required to pay taxes" is not something that the founding fathers would have considered a human right, taxation being necessary to support government and representative government (at least according to the Declaration of Independence) being necessary to secure those rights. > Procreation should be a > privilege, however sadly for our collective evolution, it's seems to > be a right :( There is a word for the philosophy that procreation should be a privilege reserved for those with good genes: eugenics. Welcome to fascism, Rick. From tjreedy at udel.edu Mon Feb 13 14:12:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Feb 2012 14:12:44 -0500 Subject: package extension problem In-Reply-To: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> Message-ID: On 2/13/2012 12:58 PM, Miki Tebeka wrote: >> import new_pandas as np df = >> np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) col_A = df['A'] > I'm not familiar with pandas, but my *guess* will be that you'll need > to override __getitem__ in the new DataFrame. This is essentially the same problem that if you, for instance, subclass int as myint, you need to override (wrap) *every* method to get them to return myints instead of ints. class myint(int): ... def __add__(self, other): return myint(self+other) .... In the OP's case, if the original class is in python, one might be able to just change the __class__ attribute. But I would make sure to have a good set of tests in any case. -- Terry Jan Reedy From roncythomas at hotmail.com Mon Feb 13 14:15:45 2012 From: roncythomas at hotmail.com (roncy thomas) Date: Mon, 13 Feb 2012 19:15:45 +0000 Subject: No subject Message-ID: I'm doing a miniproject on electronics voting system.I require help for creating a code in python for coverting the barcode into binary digits.Or atleast an algorithm for the same..please Help..Reply to this mail id. Kindly help me. -------------- next part -------------- An HTML attachment was scrubbed... URL: From waylan at gmail.com Mon Feb 13 14:50:01 2012 From: waylan at gmail.com (waylan) Date: Mon, 13 Feb 2012 11:50:01 -0800 (PST) Subject: Strange Behavior on Python 3 Windows Command Line Message-ID: When I try running any Python Script on the command line with Python 3.2 I get this weird behavior. The cursor dances around the command line window and nothing ever happens. Pressing Ctr+C does nothing. When I close the window (mouse click on X in top right corner), an error dialog appears asking me to "force" it to close. See a short (26 sec) video of it here: https://vimeo.com/36491748 Also, the printer suddenly starts printing multiple copies of the contents of the command line window - which has wasted much paper. Strangely it was working fine the other day. Then while debugging a script it suddenly started do this and now does this for every script I've run in Python 3.2. Multiple system reboots had no effect. I also have Python 2.5 & 2.7 installed and they work fine. Even the most basic script results in this behavior: if __name__ == "__main__": print("Hello, World!") In an attempt to check the exact version of Python, even this causes the strange behavior: c:\Python32\python.exe -V I'm on Windows XP if that matters. IDLE (which works fine) tells me I'm on Python 3.2.2 Any suggestions? From ramit.prasad at jpmorgan.com Mon Feb 13 14:58:37 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Mon, 13 Feb 2012 19:58:37 +0000 Subject: Python barcode scanner was RE: In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474149564@SCACMX008.exchad.jpmchase.net> From: roncy thomas Sent: Monday, February 13, 2012 1:16 PM To: python-list at python.org Subject: I'm doing a miniproject on electronics voting system.I require help for creating a code in python for coverting the barcode into binary digits.Or atleast an algorithm for the same..please Help..Reply to this mail id. Kindly help me. ======================================================================= One of these should help: http://stackoverflow.com/questions/4434959/usb-barcode-scanner-research http://zbar.sourceforge.net/ Please include a descriptive subject next time. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From cv33cv33cv33 at gmail.com Mon Feb 13 15:02:59 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Mon, 13 Feb 2012 12:02:59 -0800 (PST) Subject: UNIQUE FEATURES OF ISLAM !!!!!!!!!!!!!! Message-ID: <45fb87bf-046f-4485-9867-438867b59877@ge5g2000vbb.googlegroups.com> UNIQUE FEATURES OF ISLAM Please forgive us for any disturbance, but we have an important subject to address to you regarding FAITH, and we Don?t intend to overload your email with unnecessary messages? Unique Features of Islam Uniqueness of the Name The name for the religion of Islam is much more than just a name because it expresses a deep spiritual meaning as well as an overall outlook on life and concept of worship. The word "Islam" is an Arabic word which means "complete submission to the will of Almighty God". Other religions are named after their founders, such as Christianity and Buddhism; after a tribe or ethnic group, such as Judaism; or after a specific geographical region, such as Hinduism. Islam, however, is unique because its name represents its outlook on life and reflects its universal nature. Additionally, the name "Islam" was not thought up by its followers or applied by other people, as is the case with the names of other religions, but was revealed by Almighty God. This name expressed nothing new, because submission to the will of God, i.e. "Islam", has always been the true religion of God. Due to this fact, and since the teachings of Islam are straightforward, profound and logical, Islam is the "Natural Religion" of all human beings. The name of no other religion carries any significant message, or conveys the true sense of its outlook on life, as does the name "Islam". Universality & Continuity of the Message The command to worship none other than Almighty God and to submit to His will has been revealed by God to all of His prophets throughout mankind?s long history. The pure essence of the beliefs and teachings that were revealed by God to the Prophet Muhammad are the same as God taught to Abraham, who was one of the earliest and greatest prophets. So actually, Muhammad is the final prophet of Islam ? not the first. Additionally, Islam is the true "religion of Abraham", because Abraham completely submitted himself to the revealed will of Almighty God. Islam is truly unique among the religions of the world because it is addressed to all of mankind. The scripture of Islam, called the Qur?an, repeatedly addresses all human beings by saying: "O mankind!" Additionally, in the Qur?an, Almighty God is never addressed as the God of a particular people or nation. From the very beginning of the mission of Prophet Muhammad, his followers came from a wide spectrum of individuals ? there was Bilal, the African slave; Suhaib, the Byzantine Roman; Ibn Sailam, the Jewish Rabbi; and Salman, the Persian. Since religious truth is eternal and unchanging, and mankind is one universal brotherhood, God?s revelations to man have always been consistent and universal. Submission to the will of God, and worshipping Him alone without intermediaries, has always been the only religion acceptable to Almighty God. A Straightforward Concept of God Unique among the religions of the world, the concept of God in Islam is completely based upon Divine Revelation. Not only is the concept of God in Islam characterized by purity and clarity, but it is also not marred by myths, superstitions or man-made philosophical ideas. In the pure and straightforward teachings of Islam, Almighty God has clearly revealed His unique nature and qualities to man in the way which He wants them to be understood. While other religions have either mixed man-made doctrines with divine revelation, or ignored the divine revelation almost completely, Islam?s concept of God is based totally on what God has said about Himself. Islam?s concept of God can be called pure and straightforward because there is a clear distinction made between the Creator and the created. As such, there is no ambiguity in divinity ? it is made clear that there is nothing divine or worthy of being worshipped except for Almighty God. In Islam, calling someone other than Almighty God "Lord" or "Savior" is completely prohibited because such terms compromise God?s uniqueness and because all of our trust should be put in Almighty God ? who is the Most Merciful and the Controller of all affairs. The only Creator ? Almighty God ? is Unique, Eternal and Transcendent above His Creation. Everything else besides Almighty God ? meaning anything that you can see or even imagine ? is part of God?s creation, and thus not worthy of worship. Almighty God, as He has described Himself in the Qur?an, is Absolutely One and "the Most Merciful of those who show mercy". Even though God is transcendent above His creation, due to His infinite Mercy He is constantly involved with the affairs of His creatures. Even though God is infinite, unique and incomprehensible, in the Holy Qur?an He has revealed Himself in a way suitable to the finite and limited human mind. By reaching out to man and sending revelations through all of His prophets, God has allowed Himself to be known through His unique and most-beautiful attributes. Because the concept of God in Islam was sent by God specifically for mankind, it appeals to the innate nature of the human being. Due to this fact, Islam does not ask man to accept irrational, ludicrous or man-made doctrines about God. The Islamic concept of God strikes a unique balance between various religions an because is avoids reducing God to just being some remote and impersonal "First Cause" or "Higher Power", while on the other hand it also teaches that a direct and personal relationship with God can be maintained without believing God to be like His creation or incarnate in it. Direct Relationship with God In other religions, even the ones which claim belief in "One God", people often approach God through an intermediary, such as a saint, an angel, the Virgin Mary or Jesus. However, it is only in Islam that a person is required only to pray to God. Some people also nullify a truly proper and direct relationship with Almighty God by mistakenly believing that they have a special relationship with Him simply because they are members of a certain ethnic group, tribe or "chosen people". Additionally, in Islam there are no priests or clergy ? each worshipper, man or woman, has a direct relationship with their Merciful Creator ? Almighty God. Since God is the Owner and Sustainer of everything, as well as the only one who can provide true and complete forgiveness, it is completely futile to try to approach Him through anyone else. According to the teachings of Islam, praying to or worshipping anything or anyone besides Almighty God is the greatest sin a person can commit. Even though other religions believe in God, they nullify this belief by making the grave mistake of not always approaching Him directly. Some religions even go so far as to say that human beings, due to their sinfulness, cannot approach God without an intermediary ? which mistakenly implies that God is unable or unwilling to forgive human-beings directly. Islam teaches that Almighty God has the power to do all things and that no one should ever despair of His mercy. According to the teachings of Islam, God is always ready to bestow His abundant Grace and Mercy on anyone who turns to Him in repentance. Even people who used to commit the worst sin of worshipping others besides God will be forgiven if they realize what they are doing is wrong and repent. Having a direct relationship with God, and understanding that He alone deserves worship and praise, goes hand-in-hand with the Islamic concept of God. This is because once a proper concept of God is established in the heart and mind, submission to God and complete reliance on Him alone comes naturally. Unique Concept of Worship According to the teachings of Islam, everything that a human being does with the pure intention of pleasing God is an act of worship. Due to this, Islam has an all encompassing concept of worship unlike any other religion. Almighty God has revealed in the Holy Qur?an that His purpose for creating human beings was to worship Him and Him alone. Like other religions, Islam has required acts of worship, however worship in Islam is not limited to rituals. Since Islam is an all- encompassing religion with guidance for all aspects of life. almost every action in a Muslim?s life becomes an act of worship if it is done to build a better relationship with God. Since man?s purpose in life is to worship and submit to God, worship in Islam has been defined by God Himself in an all-encompassing way. This is special uniqueness can also be seen in the fact that most other religions only require formal worship once per week, while Islam requires it five times a day. Even more importantly, all rites of formal worship in Islam are based on Divine revelation, while the modes of worship in other religions are a mixture of Divine revelation, man-made traditions, opinions of clergymen and religious councils. Additionally, in Islam acts of worship such as prayer and fasting have been described by God and His Prophet in such detail that it gives human beings a feeling of assurance that the way they are worshipping God is pleasing to Him. Based on Authentic Sources The preservation of the scripture of Islam ? the Holy Qur?an ? is unique among world religions. No other religion has a scripture which is both as old and as well-preserved as the one possessed by Muslims today. Even scholars who are hostile to Islam admit that the Qur?an that exists today is exactly the same as the one that existed in the time of the Prophet Muhammad. Even though many people mistakenly assume that the Qu?ran was written by Muhammad, it is actually the literal Word of God. Not only was Muhammad known by his people to be unable to read and write, but the Holy Qur?an clearly and repeatedly exclaims that it is from Almighty God ? the Lord of the Universe. Unlike other religions, the followers of Islam have always considered their scripture to be the Word of God in toto. The scriptures of other religions are made up of writings that were not considered to be scripture until many years after they were written ? the letters of (St.) Paul are a good example of this. Additionally, the Holy Qur?an has always been in the possession of the common believer, and as such was circulated very widely. In this way, Muslims know that their scripture is authentic, unlike other so-called "scriptures" which are still claimed to be scripture even though their authors are unknown. The Qur?an also remained pure and authentic because unlike other scriptures, it was written down and memorized in the lifetime of the prophet that it was revealed to. Also, its wide circulation prevented scholars, clergy and religious councils from deciding what should and should not be part of the scripture ? since it was already in the hands of the people in its complete form. It has always amazed people to find out that the entire Qur?an was not only memorized word-for- word by hundreds of the companions of Prophet Muhammad, but that it has been memorized verbatim by thousands upon thousands of people until this very day in its original language of Arabic. It was only natural for Almighty God to preserve the scripture revealed to Prophet Muhammad, because he was the last Prophet and Final Messenger of God. In short, the Qu?ran is a unique scripture that has come down to us in its original form and unique language. Due to its pristine teachings and unquestionable authenticity, the Qur?an removes the need for man to wonder for himself how to worship and please God, since God Himself has clearly described these things. An Eternal Message Islam has just as much meaning and is just as applicable to people living in today?s "modern world" as it did for people living 1400 years ago. Since the message of Islam is eternally true it is also very robust, and as such still has a strong spiritual impact on millions of people living in the world today. The Pure Monotheism of Islam, as well as its universal brotherhood, strong morals and positive outlook on life, is still very relevant and meaningful to modern man. The continued relevance and applicability to both the spiritual and worldly life of human beings from all around the word is just one of the many proofs of the Divine origin of the message of Islam. Unlike the teachings of other religions, the teachings of Islam don?t need to be updated or watered-down in order to appeal to a human being living in today?s troubled world. Since the teachings of Islam are both spiritually true and eternally practical, they can be lived and implemented in the daily life of a person in order to make their life more fulfilling. In short, unique among world religions, Islam has not had to sacrifice its integrity in order to be both applicable to "modern life" and to have enough spiritual impact to change people?s lives. A Complete Way of Life Islam not just a "religion" in the traditional sense, because it is not just confined to acts of worship, morality and other aspects of personal piety. The teachings of Islam, even though they do cover religious rituals and morality, also encompass all other aspects of life. The Prophet Muhammad?s mission encompassed not only spiritual and religious teachings, but also included guidance for such things as social reform, economics, politics, warfare and family life. Thus due to the diversity and success of Muhammad?s mission, Muslims have clear guidance from God and His Final Prophet on all aspects of life. This goes hand-in-hand with the Islamic belief that Almighty God does not leave human beings without guidance in their daily lives ? thus His guidance is all-encompassing. Due to God?s wisdom, and because Islam is the final revealed religion, the guidance that God has sent is applicable for all times and for all places. This can be seen in the fact that the guidance for some aspects of life is much more broad and flexible than others. Additionally, in the Qur?an, Almighty God has revealed to mankind that the purpose of our creation is to worship and remember God in all aspects of our life, and to follow His guidance in everything that we do. Thus Islam does not accept a secular view of government and society, but only one based on the Law of God. Nor does Islam leave it to human beings to decide what is right and wrong, good and bad, moral and immoral based on their whims, desires or man-made idea. In short, Islam does not teach people to "Render unto Caesar the things which are Caesar?s" because, according to Islam, everything belongs to God. Like all of its other teachings, Islam?s view of other religions is balanced, realistic and moderate. Islam doesn?t view other religions as being either completely true nor completely false, but believes that all true religions were at one time divinely revealed. However, over time the teachings of the various religions, due to a variety of reasons, have become distorted and mixed with made- man ideas. But nonetheless, Muslims are required to be tolerant of other revealed religions since the Qur?an clearly says: "Let there be no compulsion in religion". Moderation The teachings of Islam, since they are divinely revealed, are balanced in all of their aspects. Even though Islam is an all-encompassing way of life, it preaches moderation and rejects extremism. On the one hand, Islam does not preach complete rejection of all worldly pleasures in view of the life hereafter; and on the other hand it does not teach that earthly life is just for pleasure and enjoyment. In Islam, wealth and worldly pleasures can be partaken of in this life as long as they are enjoyed in a way that is in obedience to God. However, Muslims are taught to keep in mind that the life hereafter is their ultimate goal, and therefore one should be charitable and not become too attached to worldly things. By maintaining a balance between man?s spiritual and physical needs, the teachings of Islam are best suited for the needs of human beings in particular and society in general. Since Islam is based on clear guidance from God, it rejects all man-made religious excesses, such as certain forms of monasticism where people try to completely "reject the world" and other forms of extreme self-denial. Islam teaches that human beings have responsibilities at all levels ? to other individuals, to their families and to society as a whole. By maintaining a unique balance between the physical and spiritual, and between the individual and society, Islam maintains a balance in all directions. A Positive Outlook Most people will agree that having a strong self-esteem and a positive outlook on life is conducive to achieving happiness and success. Unique among the religions of the world, Islam?s view of both the nature of the human being and the purpose of life are extremely positive. Islam?s view of the nature of the human being is balanced. On the one hand they are not viewed as being inherently evil, but on the other they are not considered to be perfect ? nor are they expected to be so. According to the teachings of Islam, every human being, man or woman, is born with a clean slate and is equally capable of both good and evil. Since God has bestowed limited free-will on human beings, they will ultimately be held responsible for their actions. Believing that "salvation" is based on "faith alone" reduces human life to a near meaningless and fatalistic existence. The teachings of Islam make it clear that human beings, since their nature is basically good, are capable of positive action in this life, and that the best way to achieve a balanced, happy and fulfilled life is complete submission to Almighty God. Certainly, no person can completely submit to God by simply wanting to do so, but by first realizing that none has a right to be worshipped and obeyed except for Almighty God, and then making a reasonable effort to follow God?s commands, all human beings can fulfill their reason for existence ? which is to worship God alone. . The Holy Qur?an tells us that "man was created weak" and thus falls into sin often. On the other hand, man is not to think of himself as so evil and corrupt so as to despair of God?s mercy. As a recourse to this, and since Islam condemns self- righteousness, a pious life can only be lived by trusting in God ? since there is no power or strength except through God. As such, spiritual felicity is achieved by a combination of both faith and action. As such, the most righteous person is not one who thinks that repentance is unnecessary, but the one who admits and realizes his mistakes ? and then repents. According to the word of Almighty God as revealed in the Holy Qur?an, mankind is God?s trustee on earth; and as such the life of this world is a test, not a punishment. Even before God created the first man, He knew that he would sin, however God created man in spite of this. According to the Qur?an, God has bestowed on human beings a great trust and given them dignity. It is only by worshipping Almighty God, directly and without intermediaries, that a human being can fulfull their true innate nature and purpose of existence. In short, Islam is realistic. It portrays human beings just as they are and the life of the world just as it is. Since the outlook of Islam is divinely revealed is not based on wishful or negative thinking, but simply on reality. Islam also has a positive view of mankind in general, since it teaches that the best person in the sight of God is the one who is most God-conscious. In this way the truth of Islam and the universality of God?s message transcends all of the barriers of race, nationality, ethnic group and economic status. ????????????? For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From arnodel at gmail.com Mon Feb 13 15:16:13 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 13 Feb 2012 20:16:13 +0000 Subject: Strange Behavior on Python 3 Windows Command Line In-Reply-To: References: Message-ID: On 13 February 2012 19:50, waylan wrote: > When I try running any Python Script on the command line with Python > 3.2 I get this weird behavior. The cursor dances around the command > line window and nothing ever happens. Pressing Ctr+C does nothing. > When I close the window (mouse click on X in top right corner), an > error dialog appears asking me to "force" it to close. I'm not a Windows user, so I can't be of assistance but it may help others if you explained how you installed Python 3.2 on your computer. Also have you tried reinstalling it? > Strangely it was working fine the other day. Then while debugging a > script it suddenly started do this and now does this for every script How were you debugging? -- Arnaud From waylan at gmail.com Mon Feb 13 15:47:36 2012 From: waylan at gmail.com (Waylan Limberg) Date: Mon, 13 Feb 2012 15:47:36 -0500 Subject: Strange Behavior on Python 3 Windows Command Line In-Reply-To: References: Message-ID: On Mon, Feb 13, 2012 at 3:16 PM, Arnaud Delobelle wrote: >> Strangely it was working fine the other day. Then while debugging a >> script it suddenly started do this and now does this for every script > > How were you debugging? I think I may have been attempting to use pipes to redirect stdin and/or stdout when the problem first presented itself. Unfortunately, once I closed the window, I lost whatever pipe combination I had tried. It just occurred to me that I was unsure if I had been doing that pipe correctly, and that maybe I overwrote python.exe. Sure enough, the modify date on that file indicated I overwrote it. A re-install has resolved the problem. It's just a little embarrassing that I didn't think of that until now, but the fact that everything else seems to work was throwing me off. Of course, everything else was running `pythonw.exe` not `python.exe`. Anyway, thanks for the pointer Arnaud. -- ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg From rosuav at gmail.com Mon Feb 13 15:47:56 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 07:47:56 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 5:38 AM, Ian Kelly wrote: > "... Rights, that > **AMONG** these are Life, Liberty and the pursuit of Happiness." AMONG our rights are such elements as Life, Liberty, the Pursuit of Happiness, and an almost fanatical devotion to the Founding Fathers.... I'll come in again. (Does that drag this back on topic? Almost? Vain attempt to at least look like it's on topic?) ChrisA From ericsnowcurrently at gmail.com Mon Feb 13 15:55:10 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Mon, 13 Feb 2012 13:55:10 -0700 Subject: (Rebooting) Python Usage Statistics Message-ID: The original topic got side-tracked pretty quickly (surprise, surprise). However, I think the question is valuable enough that it's worth broaching again. Notably, the first time around I did get a meaningful response (thanks Stefan!). If you do feel like diverging from the topic of gathering usage statistics, please at least change the subject. I've also started a wiki page: http://wiki.python.org/moin/usage_stats Feel free to add to it. -------------- Does anyone have (or know of) accurate totals and percentages on how Python is used? I'm particularly interested in the following groupings: - new development vs. stable code-bases - categories (web, scripts, "big data", computation, etc.) - "bare metal" vs. on top of some framework - regional usage I'm thinking about this partly because of a discussion on python-ideas about [some U-word related topic ]. All the rhetoric, anecdotal evidence, and use-cases there have little meaning to me, in regards to Python as a whole, without an understanding of who is actually affected. For instance, if frameworks (like django and numpy) could completely hide the arguable challenges of [some feature] in Python 3--and most projects were built on top of frameworks--then general efforts for making [some feature] easier in Python 3 should go toward helping framework writers. Such usage numbers help us know where efforts could be focused in general to make Python more powerful and easier to use where it's already used extensively. They can show us the areas that Python isn't used much, thus exposing a targeted opportunity to change that. Realistically, it's not entirely feasible to compile such information at a comprehensive level, but even generally accurate numbers would be a valuable resource. If the numbers aren't out there, what would some good approaches to discovering them? Thanks! -eric From rantingrickjohnson at gmail.com Mon Feb 13 16:01:05 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 13:01:05 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> On Feb 13, 12:38?pm, Ian Kelly wrote: > I hate being suckered in by trolls, but this paragraph demands a response. > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > wrote: > > You are born with rights. Life, Liberty, and the pursuit of happiness. > > Healthcare care is NOT a right, healthcare is a privileged. > > If you deprive a person of access to healthcare, and they die, then > you have deprived them of life and thus violated the very rights that > you just stated they had. And finally the "pursuit of happiness". Notice the wording here: "pursuit". You have a right to PURSUE happiness, not a right to steal it. Also, you are guaranteed happiness, only the right to purse your version of happiness -- so long as that version does not interfere with others rights. You have a right to life, NOT a right to unnaturally extend your lifetime by stealing the fruits of other people's labor (in this case: money). You have a right to be free, but NOT to quell the freedom of others so that YOU may benefit (in this case: taxation). Healthy people do not need healthcare very often, and in the rare cases when they do, they don't bog down the system because their bodies are strong. Why are their bodies strong? Because healthy people eat correctly, healthy people exercise, therefore, healthy people have correctly functioning immune systems -- of course quality genes always help! > In any case, taking that phrase from the Declaration of Independence > and holding it out as an exhaustive list of rights is moronic. ?First, > because it's not even a legal document -- it's only a statement of > high-minded classical liberalism, albeit a historically important and > influential one. ?Second, because it actually states "We hold these > truths to be self-evident, that all men are created equal, that they > are endowed by their Creator with certain unalienable Rights, that > **AMONG** these are Life, Liberty and the pursuit of Happiness." ?The > phrasing obviously implies that there are other human rights besides > the three examples listed. ?After all, the purpose of the document was > not to enumerate all human rights, but to air a list of grievances > against King George and assert the right to revolt against him. > Incidentally, "not being required to pay taxes" is not something that > the founding fathers would have considered a human right, taxation > being necessary to support government and representative government > (at least according to the Declaration of Independence) being > necessary to secure those rights. I never stated that taxation violated anyone's "human rights". And i personally believe that "some" amount of taxation is a necessary in a democratic society. How else would the government pay the bills? Rule of law, infrastructure, national security (just to name a few) are all subjects that the government must handle for the sake of society as a whole. HOWEVER, healthcare is not a concern of the greater society, but only the individual -- with the exception of contagious disease of course, which effects us all! Cardiovascular diseases, cancers, cirrhosis, kidney failure, stroke, diabetes, etc..., are NOT contagious but continue to be a drain on healthcare costs. In fact, most of these problems are the results of an unhealthy lifestyle. Listen, I have no objection to folks living an unhealthy lifestyle. I say, if that's what makes you happy, GO FOR IT!. However, i'll be damned if i am going to subsidize their healthcare because now they are dying and can't afford the medical bills. Likewise if someone gets hit by a bus... was the person j-walking? If so, too bad. Ride a motorcycle without a helmet and get a concussion, too bad. Drink and drive and then end up in a coma, too bad! You play with fire and you get burned! You kick a bear in the ass and you get eaten. You stick your head in a crocodiles mouth and you suffer the consequences! You are not fit to survive in this universe. You were given fear for a reason. You were given pain for a reason. Those who refuse to learn are culled from the herd. > > Procreation should be a > > privilege, however sadly for our collective evolution, it's seems to > > be a right :( > > There is a word for the philosophy that procreation should be a > privilege reserved for those with good genes: eugenics. No, the word is evolution; which means: "survival of the fittest". Listen, i will be the first to admit that evolution is VERY unfair to those among us who have a poor gene pool. Poor genes are not our fault. We did not get to CHOOSE our genes, or our parents, or our country of origin, or etc, etc, etc! But these ARE the cards we were dealt as individuals of a species. That last sentence is VERY important: "individuals of a species". We like to think that our individual lives matter in the greater scheme of things, but i can assure you we don't matter. Anyone who has studied animal behavior knows that only the strongest males are allowed to mate. Why is this? Because strength can only manifest itself in an individual with quality genes. An indiviual who is healthy. What all the whiners want to do is strengthen the degenerates. You want to circumvent evolution and devolve as a species for nothing more than the sake of your own selfishness. I can however tell you that what DOES matter is the continued improvement of the base gene pool. Yes, this improvement comes at a cost; the cost of the individual. Those with quality genes will reap the rewards, likewise, those with crap genes will not. Evolution does not care about you and how long your miserable little life will last, or if you're going to get that new Apple device for Christmas, or how many shoes are in your closet, or what brand underwear you choose to cradle your loins with! Your measly little 60-100 years of breathing means nothing against the eons of evolution of individuals within species. YOU are pawn of the Human species and nothing more. And the Human species is a pawn of biological lifeforms. When (or if) you finally come to grips with that grim reality you will be ready to transcend this life -- some make the connection early, others make the connection on their deathbeds, others not at all. >?Welcome to fascism, Rick. Don't try to append me onto a specific ideology structure just because that group happens to support ONE of my beliefs. I carry no political or ideological "membership cards" in my pocket. My mind is free of the boundaries that confine most of the Human species. But go on falsely believing your little puny life matters. Go on believing in your worn out traditions and selfish languages and cultures. Go on believing that humans will be inhabiting this rock in the next 1000 years, or this universe in the next 10,000 -- because the enlightened few will have transcended into the mind hive and your @ $$ will be glued to Terra firma forever! From nagle at animats.com Mon Feb 13 16:15:36 2012 From: nagle at animats.com (John Nagle) Date: Mon, 13 Feb 2012 13:15:36 -0800 Subject: frozendict In-Reply-To: <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f356898$0$11996$742ec2ed@news.sonic.net> <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> Message-ID: <4f397d7a$0$12009$742ec2ed@news.sonic.net> On 2/10/2012 9:52 PM, 88888 Dihedral wrote: > ? 2012?2?11????UTC+8??2?57?34??John Nagle??? >> On 2/10/2012 10:14 AM, Nathan Rice wrote: >>>>> Lets also not forget that knowing an object is immutable lets you do a >>>>> lot of optimizations; it can be inlined, it is safe to convert to a >>>>> contiguous block of memory and stuff in cache, etc. If you know the >>>>> input to a function is guaranteed to be frozen you can just go crazy. >>>>> Being able to freeze(anyobject) seems like a pretty clear win. >>>>> Whether or not it is pythonic is debatable. I'd argue if the meaning >>>>> of pythonic in some context is limiting, we should consider updating >>>>> the term rather than being dogmatic. >> >> A real justification for the ability to make anything immutable is >> to make it safely shareable between threads. If it's immutable, it >> doesn't have to be locked for access. Mozilla's new "Rust" >> language takes advantage of this. Take a look at Rust's concurrency >> semantics. They've made some progress. >> >> John Nagl > > > Lets model the system as an asynchronous set of objects with multiple threads > performing operatons on objects as in the above. I'd argue for a concurrency system where everything is either immutable, unshared, synchronized, or owned by a synchronized object. This eliminates almost all explicit locking. Python's use of immutability has potential in that direction, but Python doesn't do anything with that concept. John Nagle From rosuav at gmail.com Mon Feb 13 16:27:40 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 08:27:40 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: Rick, you are either... On Tue, Feb 14, 2012 at 8:01 AM, Rick Johnson wrote: > I can however tell you that what DOES matter is the continued > improvement of the base gene pool. Yes, this improvement comes at a > cost; the cost of the individual. Those with quality genes will reap > the rewards, likewise, those with crap genes will not. ... a Nazi/Fascist/Commie mutant traitor, or... > But go on falsely believing your little puny life matters. Go on > believing in your worn out traditions and selfish languages and > cultures. Go on believing that humans will be inhabiting this rock in > the next 1000 years, or this universe in the next 10,000 -- because > the enlightened few will have transcended into the mind hive and your @ > $$ will be glued to Terra firma forever! ... the Borg. I'm not sure which is worse. Hmm, I think I just godwinned this thread. But at least I could couple it with a Paranoia reference. ChrisA From breamoreboy at yahoo.co.uk Mon Feb 13 16:46:43 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 13 Feb 2012 21:46:43 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 13/02/2012 21:01, Rick Johnson wrote: > Healthy people do not need healthcare very often, and in the rare > cases when they do, they don't bog down the system because their > bodies are strong. Why are their bodies strong? Because healthy people > eat correctly, healthy people exercise, therefore, healthy people have > correctly functioning immune systems -- of course quality genes always > help! Please explain why previously healthy people get struck down with Common Fatigue Syndrome amongst other things. -- Cheers. Mark Lawrence. From torriem at gmail.com Mon Feb 13 16:46:56 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 Feb 2012 14:46:56 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4F3984D0.5010009@gmail.com> On 02/13/2012 09:01 AM, Rick Johnson wrote: > Look, i hate super rich, arrogant people just as much i hate selfish > people. But wait, Rick. You are a man of contradictions. We all are, but you seem to bluster on and on more about it than most. Firstly, to *hate* anyone, super-rich, arrogant, or not, _is_ selfish by definition. Also, while I accept that you do not see yourself as arrogant, there are others on this list, who are not particularly arrogant, who read your posts as occasionally being extremely arrogant. For example, your post mocking people for using English in ways that you do not personally approve. Maybe this is just an artifact of the limitations of the written word. Now to the second contradiction. You said that one way to fix health care costs would be to deny it to anyone who could not afford health care insurance. Put in another way, health care should only go to those that can afford to pay for the insurance or care, and not the free-loaders. Is that not what you said? Thus a "super rich" person should be commended as he will be able to afford health care without burdening anyone else in society. Does your hatred for super-rich, arrogant, people mean that you believe there is an acceptable dollar value for the wealth a person should morally be able to amass? All of this reminds me that I've always wanted to ask you something. After reading your many posts over the last couple of years, I am curious. What do you do for your career? Are you a professional software developer? From lists.eckel at gmail.com Mon Feb 13 17:01:53 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 14:01:53 -0800 (PST) Subject: Automatic Type Conversion to String Message-ID: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> I'm creating a class to encapsulate OS paths, to reduce the visual noise and typing from the os.path methods. I've got the class and nose tests below, and everything works except the last test which I've prefixed with XXX: def XXXtest_should_work(self): """ Produces: open(self.p2, 'w').write('') TypeError: coercing to Unicode: need string or buffer, Path found """ open(self.p2, 'w').write('') assert self.p2 Note that I *have* a __str__(self) method to perform automatic conversion to string, and I've commented out the __unicode__(self) method because it wasn't getting called. The problem appears to be that open() does not seem to be calling __str__ on its first argument, but instead it appears to want a basestring and this doesn't automatically call __str__. I'm trying to write the Path class so I can just hand a Path object to, for example, open() and have it produce the path string. Thanks for any insights. --------------------------- Class and tests, put in file path.py ------------------------------------ import os, os.path class Path(object): def __init__(self, *args): """ Each of *args is a piece of a path. Assemble them together. """ if len(args) == 0: self.path = os.path.abspath('.') else: self.path = str(args[0]) # str() so you can add Path objects if self.path.endswith(':'): self.path = os.path.join(self.path, os.sep) for a in args[1:]: self.path = os.path.join(self.path, str(a)) def __add__(self, other): return Path(os.path.join(self.path, other)) def __iadd__(self, other): # path += path self.path = os.path.join(self.path, other) return self # Allows chaining def __str__(self): return self.path # def __repr__(self): # assert not self.path, "__repr__" # return os.path.join(self.path) # def __unicode__(self): # assert not self.path, "__unicode__" # print "Unicode called %s" % self.path # return os.path.join(self.path) def __nonzero__(self): """ Boolean test: does this path exist? So you can say "if path:" """ return bool(os.path.exists(self.path)) """ Nose tests. To run, you must first install nose: pip install nose Then: nosetests path.py """ def test_platform(): "First draft tests are Windows-based" import platform assert platform.system() == 'Windows' class test_paths(): def setUp(self): self.paths = [ ("C:\\"), ("C:\\", "Users", "Bruce Eckel", "Downloads", "AtomicScala.zip"), ("C:\\", "Users", "Bruce Eckel", "Dropbox", "AtomicScala"), ] self.p1 = Path(self.paths[0]) self.s1 = os.path.join(self.paths[0], "\\") self.p2 = Path(*self.paths[1]) self.s2 = os.path.join(*self.paths[1]) self.p3 = Path(*self.paths[2]) self.s3 = os.path.join(*self.paths[2]) self.p4 = self.p3 + "TestFile1.tmp" self.s4 = os.path.join(self.s3, "TestFile1.tmp") self.p5 = self.p3 + "TestFile2.tmp" self.s5 = os.path.join(self.s3, "TestFile2.tmp") self.p6 = Path("foo") + "bar" + "baz" def test1(self): "Root directory" print self.p1 print self.s1 assert str(self.p1) == self.s1 def test2(self): "Full path to file" print "p2", self.p2 print "s2", self.s2 assert str(self.p2) == self.s2 def test3(self): "Directory" assert str(self.p3) == self.s3 def test4(self): "Plus operator" assert str(self.p4) == self.s4 def test5(self): "Another temp file" assert str(self.p5) == self.s5 def test6(self): "Chained operator +" assert str(self.p6) == r"foo\bar\baz" def test7(self): "Operator +=" self.p6 += "bingo" assert str(self.p6) == r"foo\bar\baz\bingo" def test8(self): "Create a Path from a Path" p = Path(self.p3) assert p.path == self.s3 class test_existence: """ Test for directory and path existence """ def setUp(self): base = Path("C:", "Users", "Bruce Eckel", "Downloads") self.p1 = base + "TestFile1.tmp" self.p2 = base + "TestFile2.tmp" self.p3 = base + "TestFile3.tmp" def test_basestring(self): print type(self.p1) assert isinstance(self.p1.path, basestring) def test1(self): "p1 existence" open(self.p1.path, 'w').write('') assert self.p1 def test2(self): "p2 existence" open(self.p2.path, 'w').write('') assert self.p2 def test3(self): "p3 existence" assert not self.p3 def XXXtest_should_work(self): """ Produces: open(self.p2, 'w').write('') TypeError: coercing to Unicode: need string or buffer, Path found """ open(self.p2, 'w').write('') assert self.p2 From clp2 at rebertia.com Mon Feb 13 17:27:12 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 13 Feb 2012 14:27:12 -0800 Subject: Automatic Type Conversion to String In-Reply-To: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 2:01 PM, Bruce Eckel wrote: > I'm creating a class to encapsulate OS paths, to reduce the visual > noise and typing from the os.path methods. I've got the class and nose > tests below, and everything works except the last test which I've > prefixed with XXX: > > ? ?def XXXtest_should_work(self): > ? ? ? ?""" > ? ? ? ?Produces: > ? ? ? ?open(self.p2, 'w').write('') > ? ? ? ?TypeError: coercing to Unicode: need string or buffer, Path > found > ? ? ? ?""" > ? ? ? ?open(self.p2, 'w').write('') > ? ? ? ?assert self.p2 > > Note that I *have* a __str__(self) method to perform automatic > conversion to string, and I've commented out the __unicode__(self) > method because it wasn't getting called. The problem appears to be > that open() does not seem to be calling __str__ on its first argument, > but instead it appears to want a basestring and this doesn't > automatically call __str__. Right. Python is strongly-typed, so it requires a genuine str here (as opposed to just something that's stringifyable) and doesn't do an coercion call to str() for you. Just like how str.join() doesn't automatically call str() on the elements of the list you give it. This is to prevent silliness like trying to open() e.g. a dict. Your alternatives are: - Learn to live with having to write open(str(path_obj)) - Add a .open() method to Path, and use that instead of the open() built-in function - Have Path subclass `str` or `unicode` > I'm trying to write the Path class so I can just hand a Path object > to, for example, open() and have it produce the path string. Impossible, short of subclassing `str` or `unicode`. Cheers, Chris From debatem1 at gmail.com Mon Feb 13 17:27:44 2012 From: debatem1 at gmail.com (geremy condra) Date: Mon, 13 Feb 2012 14:27:44 -0800 Subject: M2crypto In-Reply-To: <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 12:37 AM, zigi wrote: > Hello, > this is must be testing time to crypt files, using just M2crypto :-) > I know this is a strange use of the library, but such is the will of > the management. I take it you mean that you're benchmarking file encryption performance using M2Crypto? If your only goal is to do exactly that then go for it, but otherwise you're probably using the wrong tool for the job. Geremy Condra > On 13 Lut, 01:28, geremy condra wrote: >> On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: >> > zigi wrote: >> >> >> Hello, >> >> M2crypto >> >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', >> >> salt='12345678', i=1, padding=1) >> >> >> I wont write app, using M2crypto and I can not understand what are the >> >> arguments: >> >> key, iv, op, salt ? >> >> What they do ? >> >> > I assume you're reading in >> > about M2Crypto.EVP.Cipher. >> >> > Epydoc claims another victim. >> >> > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL >> > pages are kind of thin, too. ?You might see some useful code in the EVP unit >> > tests m2crypto/tests/test_evp.py in the m2crypto installation. >> >> Not intending to be rude, but being perfectly serious: as a general >> rule, if you don't know what an IV is you're probably getting yourself >> into a lot of trouble working with low-level crypto libraries. >> >> Two suggestions: >> >> 1. Describe what you're trying to do- I'll be able to help more if I >> know what you're actually going for. >> >> 2. Try keyczar. It's not perfect, but it's a lot easier to get right. >> >> Geremy Condra > > -- > http://mail.python.org/mailman/listinfo/python-list From cezar4846 at gmail.com Mon Feb 13 17:38:34 2012 From: cezar4846 at gmail.com (zigi) Date: Mon, 13 Feb 2012 14:38:34 -0800 (PST) Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Message-ID: <3a2a0af8-9340-401d-89c7-229fee86aa4c@db5g2000vbb.googlegroups.com> Ok, thanks. On 13 Lut, 23:27, geremy condra wrote: > On Mon, Feb 13, 2012 at 12:37 AM, zigi wrote: > > Hello, > > this is must be testing time to crypt files, using just M2crypto :-) > > I know this is a strange use of the library, but such is the will of > > the management. > > I take it you mean that you're benchmarking file encryption > performance using M2Crypto? If your only goal is to do exactly that > then go for it, but otherwise you're probably using the wrong tool for > the job. > > Geremy Condra > > > > > > > > > On 13 Lut, 01:28, geremy condra wrote: > >> On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > >> > zigi wrote: > > >> >> Hello, > >> >> M2crypto > > >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > >> >> salt='12345678', i=1, padding=1) > > >> >> I wont write app, using M2crypto and I can not understand what are the > >> >> arguments: > >> >> key, iv, op, salt ? > >> >> What they do ? > > >> > I assume you're reading in > >> > about M2Crypto.EVP.Cipher. > > >> > Epydoc claims another victim. > > >> > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > >> > pages are kind of thin, too. ?You might see some useful code in the EVP unit > >> > tests m2crypto/tests/test_evp.py in the m2crypto installation. > > >> Not intending to be rude, but being perfectly serious: as a general > >> rule, if you don't know what an IV is you're probably getting yourself > >> into a lot of trouble working with low-level crypto libraries. > > >> Two suggestions: > > >> 1. Describe what you're trying to do- I'll be able to help more if I > >> know what you're actually going for. > > >> 2. Try keyczar. It's not perfect, but it's a lot easier to get right. > > >> Geremy Condra > > > -- > >http://mail.python.org/mailman/listinfo/python-list From wanderer at dialup4less.com Mon Feb 13 17:59:59 2012 From: wanderer at dialup4less.com (Wanderer) Date: Mon, 13 Feb 2012 14:59:59 -0800 (PST) Subject: Change os.makedirs to handle existing directory Message-ID: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> I think wanting to create a directory if one doesn't exist or do nothing if it does exist and just use the existing directory is a fairly normal programming need. Apparently this is somewhat complicated in Python. If you use if not os.path.exists(dirName): os.makedirs(dirName) you create a race condition. If you use try: try: os.makedirs(dirName) except OSError: pass Now you're silencing too many errors, so you need to select which errors to silence. You can check to see if the directory already exists and assume that the directory already existing is the cause of the error. try: os.makedirs(dirName) except OSError: if os.path.exists(dirName): # We are nearly safe pass else: # There was an error on creation, so make sure we know about it raise or check the error type: try: os.makedirs(dirName) except OSError, e: if e.errno != errno.EEXIST: raise IMHO, os.makedirs should do this for you with something like os.makedirs(dirName, exist = False) and have makedirs silence the error the 'right' way whatever that is, without turning it into an exercise for the user. From lists.eckel at gmail.com Mon Feb 13 18:18:55 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 15:18:55 -0800 (PST) Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: <12584848.58.1329175135396.JavaMail.geo-discussion-forums@ynii32> I'm willing to subclass str, but when I tried it before it became a little confusing -- I think mostly because anytime I assigned to self it seemed like it converted the whole object to a str rather than a Path. I suspect I don't know the proper idiom for doing this -- any hints? Thanks ... From lists.eckel at gmail.com Mon Feb 13 18:18:55 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 15:18:55 -0800 (PST) Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: <12584848.58.1329175135396.JavaMail.geo-discussion-forums@ynii32> I'm willing to subclass str, but when I tried it before it became a little confusing -- I think mostly because anytime I assigned to self it seemed like it converted the whole object to a str rather than a Path. I suspect I don't know the proper idiom for doing this -- any hints? Thanks ... From timothy.c.delaney at gmail.com Mon Feb 13 18:18:58 2012 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Tue, 14 Feb 2012 10:18:58 +1100 Subject: Change os.makedirs to handle existing directory In-Reply-To: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> References: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> Message-ID: On 14 February 2012 09:59, Wanderer wrote: > I think wanting to create a directory if one doesn't exist or do > nothing if it does exist and just use the existing directory is a > fairly normal programming need. Apparently this is somewhat > complicated in Python. > ... > IMHO, os.makedirs should do this for you with something like > > os.makedirs(dirName, exist = False) > > and have makedirs silence the error the 'right' way whatever that is, > without turning it into an exercise for the user. Added in 3.2: http://docs.python.org/py3k/library/os.html?highlight=makedirs#os.makedirs Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Mon Feb 13 18:19:21 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Mon, 13 Feb 2012 17:19:21 -0600 Subject: Change os.makedirs to handle existing directory In-Reply-To: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> References: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> Message-ID: <4F399A79.8020003@gmail.com> On 2/13/2012 4:59 PM, Wanderer wrote: > I think wanting to create a directory if one doesn't exist or do > nothing if it does exist and just use the existing directory is a > fairly normal programming need. Apparently this is somewhat > complicated in Python. There are new exceptions in 3.3, one of which is for exactly this. http://docs.python.org/dev/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy http://docs.python.org/dev/library/exceptions.html#FileExistsError -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From steve+comp.lang.python at pearwood.info Mon Feb 13 19:19:35 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Feb 2012 00:19:35 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <4f39a896$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 13 Feb 2012 13:01:05 -0800, Rick Johnson wrote: > Healthy people do not need healthcare very often Healthy people don't need healthcase AT ALL. By definition, once you need healthcare, you are no longer healthy. Your faith in the magic of "immune system" is touching, but one wonders how "immune system" will save people who have been hit by a car. Rick, isn't it time for you to go back to forking Python so that the adoring silent majority who agrees with you can abandon this cesspool of inefficient Python code and use your awesome new version? Please don't disappoint your millions of fans! -- Steven From rantingrickjohnson at gmail.com Mon Feb 13 19:39:37 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 16:39:37 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Feb 13, 3:46?pm, Michael Torrie wrote: > On 02/13/2012 09:01 AM, Rick Johnson wrote: > > > Look, i hate super rich, arrogant people just as much i hate selfish > > people. > > But wait, Rick. ?You are a man of contradictions. ?We all are, but you > seem to bluster on and on more about it than most. ?Firstly, to *hate* > anyone, super-rich, arrogant, or not, _is_ selfish by definition. Not necessarily. But i will admit that i did not choose my words correctly. I don't "hate" people simply BECAUSE they are rich. Just like i don't hate people simply because they are poor. However i DO hate what the super rich people BECOME. They become blind to their own position in the universe and instead start to believe the universe revolves around them. When their daily lives are consumed with vanity, and they lose all appreciation for the value of money. Yes, they have become something NOT to aspire to. But how much is too much? Good question, and the answer is ALWAYS subjective isn't it? A child might think $20 dollars is a lot of money. A homeless person might think someone who has a new model car is rich and not struggling. Same goes in the opposite direction. A rich man might choose suicide over life if confronted with the possibility of surviving on $40,000 a year. However, as we know, many folks survive on much less than that -- some even pretend to be happy! Can there be a specific amount wherein if you exceed that amount THEN you are living in excess? I believe there is a specific amount, however it is constantly changing depending on the current state of employment and wages. My equation looks like: # Py>=3.0 py> sum(earner.get_income(2012) for earner in earners2012) / len(earners2012) average_income Once you exceed that amount you are robbing your fellow man. How can you justify making more than your fair share UNLESS someone offers their work load to YOU? You can't. You are living in excess. And for those who think the average_income is too small, well then, it's time to implement population control! The fact is, we have far too many people living beyond their needs. We have people buying houses they can't afford and then blaming the bank for some how "tricking" them. They don't have the scruples to accept the blame! Take a look around man. The world is in death throes. World wide economic collapse is upon us. And how did we get here? Entitlements: which is just another manifestation of selfishness. Look at Greece. Look at Europe. America YOU are next! > Put in another way, health care should only go to those > that can afford to pay for the insurance or care, and not the > free-loaders. Yes. Healthcare is a luxury available only to those who can afford it. If you can't afford healthcare, then visit a REAL charity hospital (not one subsidized by taxpayers!). A real charity is subsidized by caring folks who want to help their fellow man -- even if to only extend his suffering a few more days, months, or years. > Thus a "super rich" person > should be commended as he will be able to afford health care without > burdening anyone else in society. "commend" is a strong word. I don't think paying your debts requires a pat on the back. If you have children, then you are required to raise them, you don't get brownie points for raising your children, it's your job! Same for debts. > Does your hatred for super-rich, > arrogant, people mean that you believe there is an acceptable dollar > value for the wealth a person should morally be able to amass? see above equation for enlightenment ^^^ > What do you do for your career? ?Are you a professional > software developer? Why? Do you need the services of a professional software developer? From rantingrickjohnson at gmail.com Mon Feb 13 20:07:35 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 17:07:35 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4f39a896$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 13, 6:19?pm, Steven D'Aprano wrote: > Your faith in the magic of "immune system" is touching, but one wonders > how "immune system" will save people who have been hit by a car. Why do you assume that someone hit by a car is a victim? This mindset is why you (and others like you) cannot understand the REAL problem we face. The problem that is destroying the world as we speak. What if you where driving the car and someone ran out from behind a large truck? (that's called "jaywalking" BTW!) What if you had no time to stop? Who's to blame: the driver or the rebel pedestrian? Streets are no place for walking, and sidewalks no place for driving. Q: But what if the pedestrian had right-of-way? A: Then the driver (or driver's insurance) would be responsible for medical bills. Q: But what if the driver has no money or no insurance A: Then he NEVER should have been driving in the first place! He made a really stupid decision! So sell all his belongings at auction and/or force him into hard labor until the debt is re-paid! I have no problem providing REAL emergency care for my fellow man who might find themselves involved in an accident, or an unlucky victim of violence requiring medical attention -- as long as the accident/ violence was not his fault or caused by his own stupidity! I think anyone who is human would agree with that. HOWEVER, as i have stated before, poor health caused by poor life choices is no excuse for free healthcare. These sloths are the people bankrupting the system! From ian.g.kelly at gmail.com Mon Feb 13 20:29:56 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Feb 2012 18:29:56 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: [Reply sent off-list, partly because this is way off-topic, but also because python-list rejected my response as spam] From torriem at gmail.com Mon Feb 13 20:36:42 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 Feb 2012 18:36:42 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4F39BAAA.4000600@gmail.com> On 02/13/2012 05:39 PM, Rick Johnson wrote: > Why? Do you need the services of a professional software developer? Do you have some to offer? From rosuav at gmail.com Mon Feb 13 20:37:31 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 12:37:31 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson wrote: > # Py>=3.0 > py> sum(earner.get_income(2012) for earner in earners2012) / > len(earners2012) > average_income > > Once you exceed that amount you are robbing your fellow man. How can > you justify making more than your fair share UNLESS someone offers > their work load to YOU? You can't. You are living in excess. And for > those who think the average_income is too small, well then, it's time > to implement population control! My equation looks something like this: # Brain >= 0,1 brain> Your contribution to society / Society's contribution to you This value should be able to exceed 1.0 across the board. In fact, if it doesn't, then as a society we're moving backward. Rick, what's YOUR ratio? Oh wait, you mightn't be able to run that code. You may need to download an upgraded brain. ChrisA From dllizheng at gmail.com Mon Feb 13 23:13:59 2012 From: dllizheng at gmail.com (Zheng Li) Date: Tue, 14 Feb 2012 13:13:59 +0900 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <20120213072339.GA9132@cskk.homeip.net> References: <20120213072339.GA9132@cskk.homeip.net> Message-ID: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> I can get "method1" of class "Test" by a = getattr(Test, "method1") and I also want know how to invoke it a() or a(Test()) BTW: I don't see what the problem is if I ask a question just because I am curious about it. On 2012/02/13, at 16:23, Cameron Simpson wrote: > On 13Feb2012 15:59, Zheng Li wrote: > | how to tell a method is class method or static method or instance method? > > Maybe a better question is: > under what circumstances do you need to figure this out? > > I'm actually quite serious here. Please outline what circumstances cause > you to want to ask and answer this question. > > Cheers, > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Reason #173 to fear technology: > > o o o o o o > ^|\ ^|^ v|^ v|v |/v |X| \| | > /\ >\ /< >\ /< >\ /< >\ > > o> o o o o o o o > \ x <\> <)> |\ > /< >\ /< >\ /< >\ >> L > > Mr. email does the Macarena. From jeanpierreda at gmail.com Mon Feb 13 23:38:03 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Mon, 13 Feb 2012 23:38:03 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? Message-ID: Hey Pythonistas, Consider the regular expression "$*". Compilation fails with the exception, "sre_constants.error: nothing to repeat". Consider the regular expression "(?=$)*". As far as I know it is equivalent. It does not fail to compile. Why the inconsistency? What's going on here? -- Devin From wxjmfauth at gmail.com Tue Feb 14 03:00:01 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 14 Feb 2012 00:00:01 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2076e822-6225-449d-8d93-bf8d1627e77a@l14g2000vbe.googlegroups.com> On 13 f?v, 04:09, Terry Reedy wrote: > > > * The new internal unicode scheme for 3.3 is pretty much a mixture of > the 3 storage formats (I am of course, skipping some details) by using > the widest one needed for each string. The advantage is avoiding > problems with each of the three. The disadvantage is greater internal > complexity, but that should be hidden from users. They will not need to > care about the internals. They will be able to forget about 'narrow' > versus 'wide' builds and the possible requirement to code differently > for each. There will only be one scheme that works the same on all > platforms. Most apps should require less space and about the same time. > > -- Python 2 was built for ascii users. Now, Python 3(.3) is *optimized* for the ascii users. And the rest of the crowd? Not so sure, French users (among others) who can not write their texts will iso-8859-1/latin1 will be very happy. No doubts, it will work. Is this however the correct approach? jmf From blah238 at gmail.com Tue Feb 14 03:40:42 2012 From: blah238 at gmail.com (Logan Pugh) Date: Tue, 14 Feb 2012 02:40:42 -0600 Subject: Override the interpreter used by multiprocessing subprocesses? Message-ID: Hello, I am using a product that has a built-in Python interpreter (ESRI ArcGIS Desktop 10.0 SP3) and have implemented multiprocessing in script that can be run by a tool within the application using the built-in interpreter. The way the built-in interpreter works is incompatible with multiprocessing as it appears to want to start multiple instances of the host application when the subprocesses are created. I am using multiprocessing.Pool with the apply_async function. It works great in a standalone script and I'd rather not rewrite what I've done so far if I can help it, but if there is a way to simply force the standard interpreter to be used for the subprocesses that would be ideal. Thinking about it I realize that this might not be possible due to whatever messaging, pickling, and queueing that the main processes has to handle for the subprocesses, but thought I would ask anyways if only for my own enlightenment. TIA! -------------- next part -------------- An HTML attachment was scrubbed... URL: From research at johnohagan.com Tue Feb 14 03:41:46 2012 From: research at johnohagan.com (John O'Hagan) Date: Tue, 14 Feb 2012 19:41:46 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <20120214194146.091273a00d3af9869bc06979@johnohagan.com> On Mon, 13 Feb 2012 13:01:05 -0800 (PST) Rick Johnson wrote: > On Feb 13, 12:38?pm, Ian Kelly wrote: > > I hate being suckered in by trolls, but this paragraph demands a response. Ditto... > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > > > wrote: > > > You are born with rights. Life, Liberty, and the pursuit of happiness. > > > Healthcare care is NOT a right, healthcare is a privileged. [...] > HOWEVER, healthcare is not a concern of the greater society, but only > the individual -- with the exception of contagious disease of course, [...snip half-baked, social-Darwinist, "there-is-no-such-thing-as-society", naive U.S.-capitalist-libertarian drivel...] > > > Procreation should be a > > > privilege, however sadly for our collective evolution, it's seems to > > > be a right :( > > > > There is a word for the philosophy that procreation should be a > > privilege reserved for those with good genes: eugenics. > > No, the word is evolution; which means: "survival of the fittest". > Don't try to hijack real science to bolster a repugnant ideology. Neither Herbert Spencer nor Darwin meant that phrase the way you do. [...snip egregious, self-serving display of ignorance on the subjects of evolution and genetics...] > > >?Welcome to fascism, Rick. > > Don't try to append me onto a specific ideology structure just because > that group happens to support ONE of my beliefs. I carry no political [...blah blah...] It's called duck-typing. I somewhat optimistically implore you, Rick, to do some basic research on your chosen subjects. Failing that (almost certainly), here are three simple points which debunk your agenda (and that of the U.S. Republican Right): 1. Publicly-funded healthcare is both cheaper and more effective than privatised systems. It's also the right thing to do (i.e. you don't have to stand by while someone dies because their illness is "their fault"). Which makes it a win-win-win. 2. The recent economic problems were not triggered by "degenerates" (are you actually talking about homosexuals here, or just in the more general, McCathyist sense?), but in fact by the operations of the same unregulated markets you are advocating. 3. The central fallacy of social Darwinism is the misapprehension that because natural selection occurs in nature, human society _should_ also work this way. This is a failure to acknowledge the is/ought problem, and is usually compounded (Rick is no exception) by the equally mistaken view that there exist "superior" individuals whose possession of a "quality gene-pool" entitles them to survival - an entitlement that is encroached upon by inferior sorts who take up space by insisting on not dying. Can you guess in which group those who hold this view place themselves? In fact, a gene pool is held by a species, not an individual, and the maintenance of its diversity is essential for long term-survival. And to the great disappointment of those looking for a justification of dog-eat-dog, one of the main drivers of evolution is not competition, but adapting to new environments to _avoid_ competition. I'm told the Spanish have a saying which translates as "dogs don't eat dogs". Genetics is complicated. Switching one gene on switches others off in unpredictable ways, people choose mates by unfathomable processes, good-looking geniuses have dumb, ugly children and vice-versa. This is why eugenics projects are doomed to failure. They are also morally wrong, which is another win-win. If some featureless fungus, toxic to all other living things, engulfed the globe, would that make it "superior"? Of course, not, it merely survived. Considerations of what _should_ happen, of superiority and quality, are human, social concerns. We are humans, so they are important to us. But they have nothing to do with genetics or evolution. Social Darwinism is merely a psuedo-scientific attempt to justify inequity and class divides. Furthermore, it is completely dead outside the U.S. - ironically the only developed nation where real Darwinism is still seriously questioned. [...] > Go on believing that humans will be inhabiting this rock in > the next 1000 years, or this universe in the next 10,000 -- because > the enlightened few will have transcended into the mind hive and your @ > $$ will be glued to Terra firma forever! Now that is some crazy shit! Maybe L. Ron _is_ still alive... Regards, John From cs at zip.com.au Tue Feb 14 04:52:23 2012 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 14 Feb 2012 20:52:23 +1100 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> References: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> Message-ID: <20120214095223.GA1107@cskk.homeip.net> On 14Feb2012 13:13, Zheng Li wrote: | > On 13Feb2012 15:59, Zheng Li wrote: | > | how to tell a method is class method or static method or instance method? | > | > Maybe a better question is: | > under what circumstances do you need to figure this out? | | I can get "method1" of class "Test" by | a = getattr(Test, "method1") | | and I also want know how to invoke it | a() or a(Test()) Normally: a(T) where T is an object of type/class Test. So your second approach is notionally correct (aside from making a throwaway object that is then discarded). | BTW: | I don't see what the problem is if I ask a question just because I am curious about it. There's nothing wrong with it at all. But often, questions arise from some other circumstances and this one is of such a flavour that if you wanted this code in a real application it would _often_ be the wrong solution to seek, because normally you know how to call something - it is not normally useful to introspect it to decide what to do. So I was wondering what the outer context might be, because there may well have been a better solution to the situation that brought up the specific question. Simple curiosity is sufficient reason, of course. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Too young to rest on the weekend, too old to rest during the week. - Mark Randol From duncan.booth at invalid.invalid Tue Feb 14 06:31:48 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Feb 2012 11:31:48 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: Rick Johnson wrote: > BS! With free healthcare, those who would have allowed their immune > system fight off the flu, now take off from work, visit a local > clinic, and get pumped full of antibiotics so they can create a new > strain of antibiotic resistant flu virus! Thanks free healthcare! Anyone who can write 'antibiotic resistant flu virus' as though they believe it really needs to read some elementary books about disease. Here's a clue: No flu viruses are treatable with antibiotics. In some cases antibiotics may be useful for flu patients to treat secondary bacterial infections, but they are not effective against viruses. -- Duncan Booth http://kupuguy.blogspot.com From jeanpierreda at gmail.com Tue Feb 14 07:06:05 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 07:06:05 -0500 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 6:31 AM, Duncan Booth wrote: > Here's a clue: No flu viruses are treatable with antibiotics. Oh my god we're too late! Now they're ALL resistant! -- Devin From rustompmody at gmail.com Tue Feb 14 07:56:30 2012 From: rustompmody at gmail.com (rusi) Date: Tue, 14 Feb 2012 04:56:30 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <49def9d0-c9b7-44ba-af2d-073f01f0ffcd@ir9g2000pbc.googlegroups.com> On Feb 13, 9:01?pm, Rick Johnson wrote: > > And just how much healthcare dollars are you entitled to exactly? Can > you put your entitlement into some form of monetary value? Rick hats off to you man -- you are damn good! Did you study at a top- troll-school? eg. http://www.youtube.com/watch?v=FMEe7JqBgvg From vinay_sajip at yahoo.co.uk Tue Feb 14 08:20:48 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 14 Feb 2012 05:20:48 -0800 (PST) Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? References: Message-ID: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> On Feb 14, 4:38?am, Devin Jeanpierre wrote: > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin $ is a meta character for regular expressions. Use '\$*', which does compile. Regards, Vinay Sajip From jeanpierreda at gmail.com Tue Feb 14 08:33:12 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 08:33:12 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> References: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 8:20 AM, Vinay Sajip wrote: > $ is a meta character for regular expressions. Use '\$*', which does > compile. I mean for it to be a meta-character. I'm wondering why it's OK for to repeat a zero-width match if it is a zero-width assertion. -- Devin From ulrich.eckhardt at dominolaser.com Tue Feb 14 09:26:21 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 14 Feb 2012 15:26:21 +0100 Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: Am 14.02.2012 00:18, schrieb Bruce Eckel: > I'm willing to subclass str, but when I tried it before it became a > little confusing -- I think mostly because anytime I assigned to self > it seemed like it converted the whole object to a str rather than a > Path. I suspect I don't know the proper idiom for doing this -- any > hints? Thanks ... Could it be that you missed the fact that strings are immutable? That means that you can't change the content of the object once it is initialized. In particular, it means that you e.g. have to override __new__ instead of __init__, because the content is already fixed when the latter is called. Python strings rather behave like Java strings than C++ strings. Uli From devipriya0010 at gmail.com Tue Feb 14 09:47:52 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Tue, 14 Feb 2012 06:47:52 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... Message-ID: <9117090c-8696-4416-ad18-0ff40bff375e@kn4g2000pbc.googlegroups.com> http://123maza.com/46/dos754/ From jabba.laci at gmail.com Tue Feb 14 10:01:05 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Tue, 14 Feb 2012 16:01:05 +0100 Subject: name of a sorting algorithm Message-ID: Hi, Could someone please tell me what the following sorting algorithm is called? Let an array contain the elements a_1, a_2, ..., a_N. Then: for i = 1 to N-1: for j = i+1 to N: if a_j < a_i then swap(a_j, a_i) It's so simple that it's not mentioned anywhere. I guess it's called "selection sort" but I'm not sure. The minimum selection sort is an improvement of this one. Thanks, Laszlo From vlastimil.brom at gmail.com Tue Feb 14 10:05:51 2012 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Tue, 14 Feb 2012 16:05:51 +0100 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: 2012/2/14 Devin Jeanpierre : > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I don't know the reason for the observed differences either (I can think of some optimisation issues etc.), but just wanted to mention some other similar patterns to your lookahaed: It seems, that groups (capturing or not capturing) also work ok: >>> re.findall("($)*", "abc") ['', '', '', ''] >>> re.findall("(?:$)*", "abc") ['', '', '', ''] However, is there any realistic usecase for repeated zero-width anchors? regards, vbr From mwilson at the-wire.com Tue Feb 14 10:25:16 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 10:25:16 -0500 Subject: name of a sorting algorithm References: Message-ID: Jabba Laci wrote: > Could someone please tell me what the following sorting algorithm is > called? > > Let an array contain the elements a_1, a_2, ..., a_N. Then: > for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > > It's so simple that it's not mentioned anywhere. I guess it's called > "selection sort" but I'm not sure. The minimum selection sort is an > improvement of this one. It's what Wikipedia says a selection sort is: put the least element in [0], the least of the remaining elements in [1], etc. Mel. From ulrich.eckhardt at dominolaser.com Tue Feb 14 10:33:24 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 14 Feb 2012 16:33:24 +0100 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <4fbq09-3is.ln1@satorlaser.homedns.org> Am 14.02.2012 16:01, schrieb Jabba Laci: > Could someone please tell me what the following sorting algorithm is called? > > Let an array contain the elements a_1, a_2, ..., a_N. Then: > > for i = 1 to N-1: > for j = i+1 to N: > if a_j< a_i then swap(a_j, a_i) > > It's so simple that it's not mentioned anywhere. Please do your own homework. This code isn't even Python! > I guess it's called "selection sort" but I'm not sure. You guessed right. Uli From ramit.prasad at jpmorgan.com Tue Feb 14 10:50:14 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 15:50:14 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414A04E@SCACMX008.exchad.jpmchase.net> > for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > It's what Wikipedia says a selection sort is: put the least element in [0], the least of the remaining elements in [1], etc. If your only requirement to match to selection sort is the end result, then every sort would be selection sort. If you meant "put the least element in [0] in the first pass" then that would indeed be selection sort, but that is not what the above code does. The above code is bubble sort. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From jeanpierreda at gmail.com Tue Feb 14 10:53:38 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 10:53:38 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom wrote: > However, is there any realistic usecase for repeated zero-width anchors? Maybe. There is a repeated zero-width anchor is used in the Python re test suite, which is what made me notice this. I assume that came from some actual use-case. (see: http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599 ) And yeah, even something as crazy as ()* works, but as soon as it becomes (a*)* it doesn't work. Weird. -- Devin From arnodel at gmail.com Tue Feb 14 11:22:45 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 14 Feb 2012 16:22:45 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: On 14 February 2012 15:31, Dennis Lee Bieber wrote: > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci > wrote: > >>Could someone please tell me what the following sorting algorithm is called? >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >>for i = 1 to N-1: >> ? ?for j = i+1 to N: >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) >> > ? ? ? ?Off hand... The ancient Bubble-Sort... > > http://en.wikipedia.org/wiki/Bubble_sort Ahem... No, it's not Bubble Sort. Bubble sort only swaps adjacent terms. I don't know what this sort is called, if it even has a name. It's a kind of Selection Sort, as each pass it looks for the minimum of the remaining unsorted items. But it ruffles the unsorted list each pass, seemingly to save using an extra register to store the current minumum (there was a time when registers were at a premium). -- Arnaud From mwilson at the-wire.com Tue Feb 14 11:44:20 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 11:44:20 -0500 Subject: name of a sorting algorithm References: Message-ID: Prasad, Ramit wrote: >> > for i in xrange (N-1): > for j in xrange (i, N): > if a[j] < a[i]: > a[i], a[j] = a[j], a[i] >> It's what Wikipedia says a selection sort is: put the least element in >> [0], the least of the remaining elements in [1], etc. > > If your only requirement to match to selection sort is the end result, > then every sort would be selection sort. If you meant "put the least > element in [0] in the first pass" then that would indeed be selection > sort, but that is not what the above code does. The above code is bubble > sort. Well, the classic bubble sort swaps adjacent elements until the extreme one gets all the way to the end. This sort continually swaps with the end element during one pass until the end element holds the extreme. Then it shrinks the range and swaps then next less extreme into the new end element. It does extra swaps because it combines the swap operation with recording the temporary extreme while it searches the subrange. Mel. From patentsvnc at gmail.com Tue Feb 14 11:55:09 2012 From: patentsvnc at gmail.com (Den) Date: Tue, 14 Feb 2012 08:55:09 -0800 (PST) Subject: name of a sorting algorithm References: Message-ID: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> On Feb 14, 8:22?am, Arnaud Delobelle wrote: > On 14 February 2012 15:31, Dennis Lee Bieber wrote: > > > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci > > wrote: > > >>Could someone please tell me what the following sorting algorithm is called? > > >>Let an array contain the elements a_1, a_2, ..., a_N. Then: > > >>for i = 1 to N-1: > >> ? ?for j = i+1 to N: > >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) > > > ? ? ? ?Off hand... The ancient Bubble-Sort... > > >http://en.wikipedia.org/wiki/Bubble_sort > > Ahem... > > No, it's not Bubble Sort. ?Bubble sort only swaps adjacent terms. > > I don't know what this sort is called, if it even has a name. ?It's a > kind of Selection Sort, as each pass it looks for the minimum of the > remaining unsorted items. ?But it ruffles the unsorted list each pass, > seemingly to save using an extra register to store the current minumum > (there was a time when registers were at a premium). > > -- > Arnaud I disagree. In a bubble sort, one pointer points to the top element, while another descents through all the other elements, swapping the elements at the pointers when necessary. Then the one pointer moved down to the next element and the process repeats. This looks like the bubble sort to me. It was one of the first algorithms I had to program in my first programming class in 1969. Den From mwilson at the-wire.com Tue Feb 14 12:04:10 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 12:04:10 -0500 Subject: name of a sorting algorithm References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: Den wrote: > I disagree. In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. 'When I use a word,' Humpty Dumpty said, in rather a scornful tone, 'it means just what I choose it to mean ? neither more nor less.' (_Through the Looking Glass, Lewis Caroll). And you, too, have that ability. Contrariwise see Knuth, _The Art of Computer Programming_ Section 5.2.2, Algorithm B. Mel. From ian.g.kelly at gmail.com Tue Feb 14 12:37:35 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Feb 2012 10:37:35 -0700 Subject: name of a sorting algorithm In-Reply-To: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 9:55 AM, Den wrote: > On Feb 14, 8:22?am, Arnaud Delobelle wrote: >> On 14 February 2012 15:31, Dennis Lee Bieber wrote: >> >> > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci >> > wrote: >> >> >>Could someone please tell me what the following sorting algorithm is called? >> >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >> >>for i = 1 to N-1: >> >> ? ?for j = i+1 to N: >> >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) >> >> > ? ? ? ?Off hand... The ancient Bubble-Sort... >> >> >http://en.wikipedia.org/wiki/Bubble_sort >> >> Ahem... >> >> No, it's not Bubble Sort. ?Bubble sort only swaps adjacent terms. >> >> I don't know what this sort is called, if it even has a name. ?It's a >> kind of Selection Sort, as each pass it looks for the minimum of the >> remaining unsorted items. ?But it ruffles the unsorted list each pass, >> seemingly to save using an extra register to store the current minumum >> (there was a time when registers were at a premium). >> >> -- >> Arnaud > > I disagree. ?In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. ?Then the one pointer moved > down to the next element and the process repeats. ?This looks like the > bubble sort to me. ?It was one of the first algorithms I had to > program in my first programming class in 1969. Either you're misremembering, or the algorithm you programmed 43 years ago was not actually bubble sort. Quoting from Wikipedia: """ Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. """ In the present algorithm, you'll note that elements in the unsorted part of the list do not "bubble up" as they would in bubble sort. Rather, they jump around somewhat randomly until they are finally selected for the current sort index. I agree with Arnaud -- this is a selection sort variant that saves a local variable (the index of the minimum element) by placing it at the current sort index instead -- at the cost of doing additional swaps. Probably not a good trade-off in Python (but then again, no pure Python sort algorithm is likely to perform better than the built-in). Cheers, Ian From python at mrabarnett.plus.com Tue Feb 14 13:05:59 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 14 Feb 2012 18:05:59 +0000 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: <4F3AA287.9070604@mrabarnett.plus.com> On 14/02/2012 15:53, Devin Jeanpierre wrote: > On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom > wrote: >> However, is there any realistic usecase for repeated zero-width anchors? > > Maybe. There is a repeated zero-width anchor is used in the Python re > test suite, which is what made me notice this. I assume that came from > some actual use-case. (see: > http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599 > ) > > And yeah, even something as crazy as ()* works, but as soon as it > becomes (a*)* it doesn't work. Weird. > I think it's a combination of warning the user about something that's pointless, as in the case of "$*", and producing a pattern which could cause the internal regex engine to get stuck in an infinite loop. It is inconsistent in that it warns about "$*" but not "(?=$)*" even though they are basically equivalent. From jabba.laci at gmail.com Tue Feb 14 13:10:35 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Tue, 14 Feb 2012 19:10:35 +0100 Subject: name of a sorting algorithm In-Reply-To: References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: Hi, > Either you're misremembering, or the algorithm you programmed 43 years > ago was not actually bubble sort. ?Quoting from Wikipedia: > > """ > Bubble sort, also known as sinking sort, is a simple sorting algorithm > that works by repeatedly stepping through the list to be sorted, > comparing each pair of adjacent items and swapping them if they are in > the wrong order. The pass through the list is repeated until no swaps > are needed, which indicates that the list is sorted. The algorithm > gets its name from the way smaller elements "bubble" to the top of the > list. > """ I don't agree with the last sentence. During bubble sort, in the 1st pass the largest element is moved to the top (for me "top" means the right side (end) of an array). Thus the end of the array is sorted. In the 2nd pass, the largest element of the unsorted left part is moved to the end, etc. That is, it's the _larger_ elements that bubble to the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an animated gif that shows how the algorithm works. > In the present algorithm, you'll note that elements in the unsorted > part of the list do not "bubble up" as they would in bubble sort. > Rather, they jump around somewhat randomly until they are finally > selected for the current sort index. ?I agree with Arnaud -- this is a > selection sort variant that saves a local variable (the index of the > minimum element) by placing it at the current sort index instead -- at > the cost of doing additional swaps. ?Probably not a good trade-off in > Python (but then again, no pure Python sort algorithm is likely to > perform better than the built-in). The minimum selection sort is an improvement of this "noname" algorithm. I give it in pseudo-code. Let A be an array with N elements. Indexing starts with 1. for i := 1 to N-1: minindex := i for j := i+1 to N: if A[j] < A[minindex] then minindex := j end for if i != minindex then swap(A[i], A[minindex]) end for The two loops are the same as in the naive version. It will also sort the array from the left side. It does much less swaps than the naive version. If the "noname" algorithm is called "selection sort", then its name can be misleading. One may ask "OK, but which one? Minimum or maximum selection sort?". Well, neither... Laszlo From toddw at activestate.com Tue Feb 14 13:30:54 2012 From: toddw at activestate.com (Todd Whiteman) Date: Tue, 14 Feb 2012 10:30:54 -0800 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: <4F3AA85E.1030304@activestate.com> On 12-02-08 01:52 PM, Terry Reedy wrote: > On 2/8/2012 3:14 PM, Todd Whiteman wrote: > >> My name is Todd. I'm the lead developer for Komodo IDE (Interactive >> Development Environment) and Komodo Edit (a free, open-source editor) at >> ActiveState. I wanted to announce that the newest version, Komodo 7, has >> been released: >> http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as Komodo > Edit, but it is unclear why only Python editing would be featured for > Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. The above page covers features from both Edit and IDE - some will only apply to the IDE version. For a full comparison of features you can check out: http://www.activestate.com/komodo-edit/compare-with-komodo-ide > > Does K.Edit let me run a program with one key, like F5 in IDLE? > If so, does it leave me in interactive mode (python -i) as IDLE does? > Komodo Edit does not offer a quick run (F5) command by default, you could create your own Python command [1] in the Komodo toolbox and assign it the F5 key binding to serve such a purpose. [1] The short command for running a Python script is: "%(python) %F", which uses Komodo's interpolation shortcuts: http://docs.activestate.com/komodo/7.0/shortcuts.html#shortcuts_top Cheers, Todd From ramit.prasad at jpmorgan.com Tue Feb 14 15:13:04 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 20:13:04 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414CC1F@SCACMX008.exchad.jpmchase.net> Wilson, Mel wrote: >Well, the classic bubble sort swaps adjacent elements until the extreme one >gets all the way to the end. This sort continually swaps with the end >element during one pass until the end element holds the extreme. Then it >shrinks the range and swaps then next less extreme into the new end element. >It does extra swaps because it combines the swap operation with recording >the temporary extreme while it searches the subrange. My apologies, you are correct. It is a selection sort, just an inefficient one. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Tue Feb 14 15:21:20 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 20:21:20 +0000 Subject: name of a sorting algorithm References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414CC5C@SCACMX008.exchad.jpmchase.net> Prasad, Ramit wrote: > My apologies, you are correct. It is a selection sort, just an inefficient one. Hmm, I think I should say it is neither since it reminds me of a hybrid of both (bubble/selection). The swapping seems very bubble sort, but the looking for the min / max case seems selection sort-ish. Whatever it is, it is certainly inefficient. :) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ian.g.kelly at gmail.com Tue Feb 14 15:59:00 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Feb 2012 13:59:00 -0700 Subject: name of a sorting algorithm In-Reply-To: References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 11:10 AM, Jabba Laci wrote: > Hi, > >> Either you're misremembering, or the algorithm you programmed 43 years >> ago was not actually bubble sort. ?Quoting from Wikipedia: >> >> """ >> Bubble sort, also known as sinking sort, is a simple sorting algorithm >> that works by repeatedly stepping through the list to be sorted, >> comparing each pair of adjacent items and swapping them if they are in >> the wrong order. The pass through the list is repeated until no swaps >> are needed, which indicates that the list is sorted. The algorithm >> gets its name from the way smaller elements "bubble" to the top of the >> list. >> """ > > I don't agree with the last sentence. During bubble sort, in the 1st > pass the largest element is moved to the top (for me "top" means the > right side (end) of an array). Thus the end of the array is sorted. In > the 2nd pass, the largest element of the unsorted left part is moved > to the end, etc. That is, it's the _larger_ elements that bubble to > the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an > animated gif that shows how the algorithm works. I think that by "top" they mean "front". Each largest element in turn gets moved to the end in a single pass. It is the smaller elements gradually moving toward the front over many passes that I believe is described as "bubbling", as can be seen in that gif. > If the "noname" algorithm is called "selection sort", then its name > can be misleading. One may ask "OK, but which one? Minimum or maximum > selection sort?". Well, neither... It is a minimum selection sort, because it selects the minimum element on each pass. It just stores the minimum element so far in-place in the array, rather than in a separate variable. From rantingrickjohnson at gmail.com Tue Feb 14 19:21:17 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:21:17 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> On Feb 14, 2:41?am, John O'Hagan wrote: > > 1. Publicly-funded healthcare is both cheaper and more effective than > privatised systems. It's also the right thing to do (i.e. you don't have > to stand by while someone dies because their illness is "their fault"). So you have no problem paying the medical bills of people who overeat sugar, salt, and fat; refuse to put down the ho-ho's; and get a little exercise? If so, then give to charity. Why do you need to FORCE me (and others) to pay for your experiment of "degenerate eugenics"? > 2. The recent economic problems were not triggered by "degenerates" (are you > actually talking about homosexuals here, or just in the more general, > McCathyist sense?) WTF does homosexuality have to do with this conversation? I am talking about lazy/slothful, drug/alcohol abusing, junk food eating, self- induced illiterates, techno-phobic Luddite loving lemmings. Look, i don't care how you want to live YOUR life, just leave me and my money the hell out of it! >, but in fact by the operations of the same unregulated > markets you are advocating. I am well aware of the sins of wall street and the ruling "corporate class" (Greed.inc). That is half the problem, yes. However, you cannot ignore the fact that we are spending trillions around the globe supporting degenerates. Look at Detroit MI. People like to blame GM for the state of the city but GM is only a very small part of the problem. The REAL problem is sleazy politicians and infections entitlements/welfare. When you crush the tax payers with more and more tyrannical taxation to pay for your entitlement programs, the taxpayers leave town; but the welfare recipients stay! Why the heck would they quit a good thing? However, now you find yourself in a major pickle. With the taxpayers gone, who's going to fund the entitlement programs? NOBODY! The whole house of cards comes crumbling down! Of course i'm probably just wasting my time trying to educate you. You'll just blab on and on about how evil i am for not paying other people's bills so they can watch there hero degenerates on Jersey Shore. > 3. The central fallacy of social Darwinism is the misapprehension that because > natural selection occurs in nature, human society _should_ also work this > way. I NEVER said we should adopt such a society. That is anarchy. And anarchy will NEVER move us forward as a species. > This is a failure to acknowledge the is/ought problem, and is usually > compounded (Rick is no exception) by the equally mistaken view that there exist > "superior" individuals whose possession of a "quality gene-pool" entitles them > to survival - an entitlement that is encroached upon by inferior sorts who take > up space by insisting on not dying. Can you guess in which group those who hold > this view place themselves? You'd be surprised which group i reside in. I know my place; but do you know yours? > Genetics is complicated. Switching one gene on switches others off in > unpredictable ways, people choose mates by unfathomable processes, good-looking > geniuses have dumb, ugly children and vice-versa. This is why eugenics projects > are doomed to failure. They are also morally wrong, which is another win-win. There is nothing wrong with denying degenerates the right to reproduce. Would you allow a crack head to reproduce? How about someone who carries a virus/illness/deadly defect for which there is no cure and the virus/illness/deadly defect will be passed on to the child? What if you knew without a doubt the baby would be born with two heads, or mentally incapacitated, or brain dead, or etc...? Would you allow the procreation anyway simply because people have a right to be selfish? What if the couple was healthy but had poor parenting skills, or cannot feed the child, or cannot cloth the child, or etc...? Would you allow the procreation anyway simply because people have a right to be selfish? What abut people who go around making babies but refuse to care for them at all? I mean, birth control has been around for some time, but we can't force degenerates to use it! Would you allow the procreation anyway simply because people have a right to be selfish? > If some featureless fungus, toxic to all other living things, engulfed the > globe, would that make it "superior"? Of course, not, it merely survived. I love when people contradict themselves in the same sentence -- makes my job much easier! > Considerations of what _should_ happen, of superiority and quality, are human, > social concerns. We are humans, so they are important to us. But they have > nothing to do with genetics or evolution. Really??? I think you need to spend more time ruminating on the subject. You can stick your head in the sand if you like, but technology will advance with or without you. Humans will be cloned. Humans will be genetically engineered. Humans will employ eugenics to sculpt the gene pool. It is our destiny to use our intelligence to drive our own evolution at an ever accelerating rate. To NOT use that power would be to spit in the face of evolution itself! From rantingrickjohnson at gmail.com Tue Feb 14 19:40:47 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:40:47 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> On Feb 13, 10:41?am, Tim Wintle wrote: > Imagine you go to a doctor and say "I've got the flu, can you give me > antibiotics". > > In a Private healthcare system: > > ?* The doctor gets paid for retaining a client. > ?* He is incentivised to do what you request. > ... so he gives you the antibiotics. > > In a Public healthcare system: > ?* The doctor is paid no matter what. > ?* His job is to stop the population becoming ill. > ?* By reducing illnesses he reduces his workload, without reducing his > wage > > ... so he'll only give you antibiotics if he feels you are at serious > risk, and giving you antibiotics carries less risk for the population > than the risk of the population getting immunities. Of all the great arguments i have presented you choose the minor "antibiotic comment" and run with it? But you take NO position on "supporting the degenerates of society"? Would you mind making your position known? You see, you can have all the healthcare and healthcare dollars in the world. But if your patient keeps eating greasy hamburgers, salty/oily french fries, and blood-sugar spiking soda-pops, he is going to die a nasty death! Sadly however, he will live for many years in a state of poor heath before finally "kicking the bucket". All the while draining the system of resources and money. > [...] > you can use that same argument for everything that taxes pay for - the > only logical conclusion of that argument is anarchy (i.e. no taxes, and > no government). > > If you are an anarchist then that's a different argument all together > (not saying it doesn't have intellectual validity). I am not an anarchist. Stop trying to label me. > > Healthcare is expensive. Do you want a minimum wage doctor curing your > > ills? And the frivolous lawsuits are not bringing the costs down > > either. > > It's so expensive because of the marketing, and because of all the > middle-men. You're thinking of pharmaceuticals NOT healthcare. And while marketing is a large expense for pharmaceutical companies; R&D, lawsuits, and brown-nosing are the main cost of doing buisness. > They also don't need to put up with people who aren't seriously ill - I > don't know how long your private appointments are, but here in the UK a > standard doctor's appointment is 5-10 minutes. If they decide you're > actually ill they may extend that. Five to ten minutes? Is the doctor an a-hole or a machine? Can a doctor REALLY diagnose an illness in five to ten minutes? Are you joking? And if not, do you ACTUALLY want the experience to be synonymous with an assembly line? You don't fear misdiagnosis? I envy your bravery! From rosuav at gmail.com Tue Feb 14 19:44:35 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Feb 2012 11:44:35 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 11:21 AM, Rick Johnson wrote: > On Feb 14, 2:41?am, John O'Hagan wrote: >> This is a failure to acknowledge the is/ought problem, and is usually >> compounded (Rick is no exception) by the equally mistaken view that there exist >> "superior" individuals whose possession of a "quality gene-pool" entitles them >> to survival - an entitlement that is encroached upon by inferior sorts who take >> up space by insisting on not dying. Can you guess in which group those who hold >> this view place themselves? > > You'd be surprised which group i reside in. I know my place; but do > you know yours? If you truly believe that only the best should be allowed to survive and that you are not of the best, then the logical thing to do is to immediately destroy yourself. Oddly enough, though, I don't see many eugenics proponents committing mass suicide for the benefit of the gene pool. > There is nothing wrong with denying degenerates the right to > reproduce. Actually there is; I'm fairly sure that I wouldn't have been born if such policies had been in place, and I strongly suspect that you wouldn't have either. There was a country in the 20th century that adopted a lot of the sorts of policies you're talking about, and it's such a sensitive topic with MANY people that I'm not going to touch it. Suffice it to say that the world does not appreciate such things. >> If some featureless fungus, toxic to all other living things, engulfed the >> globe, would that make it "superior"? Of course, not, it merely survived. > > I love when people contradict themselves in the same sentence -- makes > my job much easier! No, he did not contradict himself - he drew a distinction between "superior" and "survived". You might argue that your definition of "superior" *is* the ability to survive, but that's a matter for logical argument, not for pointing and laughing. > It is our destiny to use our intelligence to > drive our own evolution at an ever accelerating rate. To NOT use that > power would be to spit in the face of evolution itself! Evolution is driven by the survival of the fittest, not by us using our intelligence to influence it. It's high time I stood up for who I am. I *do* spit in the face of evolution. I do not believe that we came here because we evolved from some lesser life-form, and I do not believe that the world is best served by such philosophies. God created us, roughly 6000-10000 years ago, and since then, many things have happened (both good and bad), but never has there been the emergence of any form of "next-species human". Look at history (just recent history if you like - the last few hundred years) and find the times when one group of people deemed themselves "more evolved" than another group. Why were Negros treated as slaves in the US? Why were Australian Aboriginals treated like animals? And the one I hinted at above. If you truly believe that evolution is the way forward, then go find some of the lobbyists for these groups, and say to their faces that you believe that some humans are lesser than others. If you come out of that alive, report back. Preferably with video. It should be interesting. ChrisA From rantingrickjohnson at gmail.com Tue Feb 14 19:48:13 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:48:13 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> On Feb 14, 5:31?am, Duncan Booth wrote: > Rick Johnson wrote: > > BS! With free healthcare, those who would have allowed their immune > > system fight off the flu, now take off from work, visit a local > > clinic, and get pumped full of antibiotics so they can create a new > > strain of antibiotic resistant flu virus! Thanks free healthcare! > > Anyone who can write 'antibiotic resistant flu virus' as though they > believe it really needs to read some elementary books about disease. > > Here's a clue: No flu viruses are treatable with antibiotics. In some cases > antibiotics may be useful for flu patients to treat secondary bacterial > infections, but they are not effective against viruses. Duncan, your reading and comprehension skills are atrocious. Please re- read the paragraph you quoted, then spend some time "comprehending" it, then show me where i stated that "antibiotics cure viral infections". psst: i NEVER said any such thing! My point is: these "quacks" are prescribing antibiotics when people don't even need them! Such disregard for immunity is frightening. Penicillin was a gift from the gods, and we have squandered it! Thanks free healthcare! From rantingrickjohnson at gmail.com Tue Feb 14 20:26:36 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 17:26:36 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> Message-ID: <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> On Feb 14, 6:44?pm, Chris Angelico wrote: > If you truly believe that only the best should be allowed to survive > and that you are not of the best, then the logical thing to do is to > immediately destroy yourself. Oddly enough, though, I don't see many > eugenics proponents committing mass suicide for the benefit of the > gene pool. I don't need to destroy myself Chris. Likewise i don't need to destroy anyone else. You are trying to cast me as an evil blood thirsty person, and i can assure you, i am not. All i need to do is NOT reproduce and i've done my part. Likewise all WE need to do is keep the rest "of us" from reproducing. I am not a degenerate, but my genes are flawed. All i can hope to do is make an intellectual contribution to our evolution as a species. Just because you're flawed in one area, does not mean you cannot make contributions in other areas. You can still be part of the whole -- AS LONG AS YOU UNDERSTAND YOUR PLACE! > > There is nothing wrong with denying degenerates the right to > > reproduce. > > Actually there is; I'm fairly sure that I wouldn't have been born if > such policies had been in place, and I strongly suspect that you > wouldn't have either. So what's the problem with that? > There was a country in the 20th century that > adopted a lot of the sorts of policies you're talking about, and it's > such a sensitive topic with MANY people that I'm not going to touch > it. Suffice it to say that the world does not appreciate such things. Of course people don't want to admit that they don't belong, or that they are flawed, or that they are inferior. We are "wired" with egos so that we don't purposely destroy ourselves; which is vital to our "collective" evolution, but NOT our individual evolution. However, like all software, the definitions don't always cover the corner cases. Only WE, as intelligent beings, can compensate for the missing code in our own software. Evolution is just a system. A very dumb system. We are the only hope for evolution beyond what this base system can create. We must take the reigns and drive our own evolution. > >> If some featureless fungus, toxic to all other living things, engulfed the > >> globe, would that make it "superior"? Of course, not, it merely survived. > > > I love when people contradict themselves in the same sentence -- makes > > my job much easier! > > No, he did not contradict himself - he drew a distinction between > "superior" and "survived". You might argue that your definition of > "superior" *is* the ability to survive, but that's a matter for > logical argument, not for pointing and laughing. "If" a fungus did in fact "engulf the earth", THEN it MUST be superior! > > It is our destiny to use our intelligence to > > drive our own evolution at an ever accelerating rate. To NOT use that > > power would be to spit in the face of evolution itself! > > Evolution is driven by the survival of the fittest, not by us using > our intelligence to influence it. But WE are the fittest! Because we are INTELLIGENT! > God created us, roughly 6000-10000 years ago, and since then, many > things have happened (both good and bad), but never has there been the > emergence of any form of "next-species human". Look at history (just > recent history if you like - the last few hundred years) and find the > times when one group of people deemed themselves "more evolved" than > another group. Why were Negros treated as slaves in the US? Because they allowed themselves to be subjected. Sad, but true. > Why were > Australian Aboriginals treated like animals? Because they allowed them selves to be subjected. Sad, but true. > And the one I hinted at > above. Because the Jews allowed themselves to be subjected. Sad, but true. Slaves only exist because they allow themselves to exist. When people fight back against tyranny, tyranny fails. When people subject themselves to tyranny, tyranny prospers. There have been many instances in history where people did not allow themselves to be subjected; William Wallace comes to mind. "Freeeeeedoooooooommmmmmm!" "Live free, or die!" "From my cold dead hand!" "Over my dead body!" "Freedom is never voluntarily given by the oppressor; it must be demanded by the oppressed." "Those who deny freedom to others deserve it not for themselves." "Man is free at the moment he wishes to be." "Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one." From rosuav at gmail.com Tue Feb 14 20:32:54 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Feb 2012 12:32:54 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 11:48 AM, Rick Johnson wrote: > Duncan, your reading and comprehension skills are atrocious. Please re- > read the paragraph you quoted, then spend some time "comprehending" > it, then show me where i stated that "antibiotics cure viral > infections". psst: i NEVER said any such thing! I'm not sure how you'd go about creating a new strain of a virus that's resistant to antibiotics, unless the previous strain was NOT resistant. Viruses are _immune_ to antibiotics, and as we know from Angband, immunity equals resistance times ten. ChrisA From jeanpierreda at gmail.com Tue Feb 14 20:43:05 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 20:43:05 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <4F3AA287.9070604@mrabarnett.plus.com> References: <4F3AA287.9070604@mrabarnett.plus.com> Message-ID: On Tue, Feb 14, 2012 at 1:05 PM, MRAB wrote: >> And yeah, even something as crazy as ()* works, but as soon as it >> becomes (a*)* it doesn't work. Weird. >> > I think it's a combination of warning the user about something that's > pointless, > as in the case of "$*", and producing a pattern which could cause the > internal > regex engine to get stuck in an infinite loop. Considering that ()* works fine, I can't imagine it ever gets stuck in infinite loops. But I admit I am too lazy to check against the interpreter. Also, complete failure is an exceptionally (heh) poor way of warning people about stuff. I hope that's not really it. -- Devin From dllizheng at gmail.com Tue Feb 14 20:46:48 2012 From: dllizheng at gmail.com (Zheng Li) Date: Wed, 15 Feb 2012 10:46:48 +0900 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <20120214095223.GA1107@cskk.homeip.net> References: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> <20120214095223.GA1107@cskk.homeip.net> Message-ID: thank you. I know the second way works. but in my case, i need "method1" to be a class method, because I use it to create an object. I have a lot of classes that have "__init__" with 2 arguments -- self, and user id. usually, "SomeClass(user_id)" is used to create an object of "SomeClass", but if "SomeClass" has a class method named "method1", "method1" will be used to finish the job. and i get it. the context is useful. On 2012/02/14, at 18:52, Cameron Simpson wrote: > On 14Feb2012 13:13, Zheng Li wrote: > | > On 13Feb2012 15:59, Zheng Li wrote: > | > | how to tell a method is class method or static method or instance method? > | > > | > Maybe a better question is: > | > under what circumstances do you need to figure this out? > | > | I can get "method1" of class "Test" by > | a = getattr(Test, "method1") > | > | and I also want know how to invoke it > | a() or a(Test()) > > Normally: > > a(T) > > where T is an object of type/class Test. So your second approach is > notionally correct (aside from making a throwaway object that is then > discarded). > > | BTW: > | I don't see what the problem is if I ask a question just because I am curious about it. > > There's nothing wrong with it at all. > > But often, questions arise from some other circumstances and this one is > of such a flavour that if you wanted this code in a real application it > would _often_ be the wrong solution to seek, because normally you know > how to call something - it is not normally useful to introspect it to > decide what to do. > > So I was wondering what the outer context might be, because there may > well have been a better solution to the situation that brought up the > specific question. > > Simple curiosity is sufficient reason, of course. > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Too young to rest on the weekend, too old to rest during the week. > - Mark Randol From python at mrabarnett.plus.com Tue Feb 14 21:08:57 2012 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 15 Feb 2012 02:08:57 +0000 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: <4F3AA287.9070604@mrabarnett.plus.com> Message-ID: <4F3B13B9.2010108@mrabarnett.plus.com> On 15/02/2012 01:43, Devin Jeanpierre wrote: > On Tue, Feb 14, 2012 at 1:05 PM, MRAB > wrote: >>> And yeah, even something as crazy as ()* works, but as soon as >>> it becomes (a*)* it doesn't work. Weird. >>> >> I think it's a combination of warning the user about something >> that's pointless, as in the case of "$*", and producing a pattern >> which could cause the internal regex engine to get stuck in an >> infinite loop. > > Considering that ()* works fine, I can't imagine it ever gets stuck > in infinite loops. But I admit I am too lazy to check against the > interpreter. > > Also, complete failure is an exceptionally (heh) poor way of warning > people about stuff. I hope that's not really it. > There is one place in the re engine where it tries to avoid getting stuck in an infinite loop because of a zero-width match, but the fix inadvertently causes another bug. It's described in issue #1647489. From chaoliu08 at gmail.com Tue Feb 14 23:10:53 2012 From: chaoliu08 at gmail.com (Chao Liu) Date: Wed, 15 Feb 2012 12:10:53 +0800 Subject: Problem in PNG2BMP Message-ID: Hi, everyone, I have a PNG file, and I need to convert it to BMP file. I use, import PIL from PIL import Image im = Image.open('a.png') im.save(?a.bmp?) It works in Python 2.6 with PIL 1.1.7, But when I use Python 2.4, the error occured, File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1439, in save save_handler(self, fp, filename) File "C:\Python24\Lib\site-packages\PIL\BmpImagePlugin.py", line 242, in _save ImageFile._save(im, fp, [("raw", (0,0)+im.size, 0, (rawmode, stride, -1))]) File "C:\Python24\Lib\site-packages\PIL\ImageFile.py", line 499, in _save s = e.encode_to_file(fh, bufsize) IOError: (0, 'Error') I'm wondering if anyone can help me. Thanks Chao Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: From shootgun654 at gmail.com Wed Feb 15 00:34:42 2012 From: shootgun654 at gmail.com (Gun shoot) Date: Tue, 14 Feb 2012 21:34:42 -0800 (PST) Subject: E PUB AND DATA ENTRY SERVICES Message-ID: E PUB AND DATA ENTRY SERVICES AVAILABLE HERE http://www.wincon.in/ From dihedral88888 at googlemail.com Wed Feb 15 02:13:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 14 Feb 2012 23:13:16 -0800 (PST) Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL Message-ID: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> After my testing of JAVA, PYTHON, VB, C-sharp and Erlang like script languages, I noticed that script languages should be timed after the shell interpreter completed loaded. The start up loading time of script interpreters should be excluded in the measure of executing a byte code script. This also explains why C-executables are fast in manny testing programs of various languages to out beat all interpreter loading languages. But I computed the Euler'of s number for tens of thousands of digitsunder different shells , then I was able to check the speed issues of various computer languages. My question is whether a lot speed testings of computer languages are done in a biased way toward script languages to be slow? From timr at probo.com Wed Feb 15 02:18:55 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Feb 2012 23:18:55 -0800 Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> Message-ID: <01nmj7pjer6953dve0t62av3s2floc85q6@4ax.com> sturlamolden wrote: > >There are bigsimilarities between Python and the new C++ standard. Now >we can actually use our experience as Python programmers to write >fantastic C++ :-) This is more true than you might think. For quite a few years now, I've been able to do an almost line-for-line translation of my Python programs to C++ programs. (Microsoft has had a "for each" extension for a while that made this easier.) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From research at johnohagan.com Wed Feb 15 03:56:23 2012 From: research at johnohagan.com (John O'Hagan) Date: Wed, 15 Feb 2012 19:56:23 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <20120215195623.f5666a26e374e8fdd8d54a71@johnohagan.com> On Tue, 14 Feb 2012 17:26:36 -0800 (PST) Rick Johnson wrote: > On Feb 14, 6:44?pm, Chris Angelico wrote: > > But WE are the fittest! Because we are INTELLIGENT! And the whales say: But WE are the fittest! Because we are BIG! And the rabbits say: But WE are the fittest! Because we are FERTILE! And the snakes say: But WE are the fittest! Because we are VENOMOUS! (Apologies to all animals mentioned for ascribing to them gratuitous capitalisation and exclamation marks.) Please read Darwin. He explicitly defined "fittest", in the context of evolutionary science, to mean sufficiently well-adapted to immediate local conditions to be able to reproduce. There is nothing generalisable about this. Intelligence is only useful in human ecological niches; and if the world were underwater you would gladly swap it for gills. But I don't think you'll read Darwin, or any real science on the subject. You'll cling to your popular-science cartoon version of evolution because you need it to support your false, odious worldview, which finally emerges from the swamp: > > Why were Negros treated as slaves in the US? > > Because they allowed themselves to be subjected. Sad, but true. > > > Why were > > Australian Aboriginals treated like animals? > > Because they allowed them selves to be subjected. Sad, but true. > > > And the one I hinted at > > above. > > Because the Jews allowed themselves to be subjected. Sad, but true. You have just demonstrated that you are the worst kind of racist. Not only have you blamed the victim on a truly monstrous scale, you have assigned blame not to individuals, but to entire "races". You are saying that something inherent in each race caused them to "allow" their own subjugation. Calling it "sad" does not get you off the hook. Your cover was always thin but now it's blown. From hfaber at invalid.net Wed Feb 15 03:58:41 2012 From: hfaber at invalid.net (Henrik Faber) Date: Wed, 15 Feb 2012 09:58:41 +0100 Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> <01nmj7pjer6953dve0t62av3s2floc85q6@4ax.com> Message-ID: On 15.02.2012 08:18, Tim Roberts wrote: > sturlamolden wrote: >> >> There are bigsimilarities between Python and the new C++ standard. Now >> we can actually use our experience as Python programmers to write >> fantastic C++ :-) > > This is more true than you might think. For quite a few years now, I've > been able to do an almost line-for-line translation of my Python programs > to C++ programs. (Microsoft has had a "for each" extension for a while > that made this easier.) I disagree. Unicode support comes for free with Python3+ while C++ it still is a piece of crap (or something that you'll have to pass to external libraries). The C++ standard library is nowhere nearly as densely packed with features than Python's. For every little thing you need some external dependencies. Language semantics aren't enough to translate one language into another. Best regards, Henrik From duncan.booth at invalid.invalid Wed Feb 15 04:47:40 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Feb 2012 09:47:40 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: Rick Johnson wrote: > On Feb 14, 5:31?am, Duncan Booth wrote: >> Rick Johnson wrote: >> > BS! With free healthcare, those who would have allowed their immune >> > system fight off the flu, now take off from work, visit a local >> > clinic, and get pumped full of antibiotics so they can create a new >> > strain of antibiotic resistant flu virus! Thanks free healthcare! >> >> Anyone who can write 'antibiotic resistant flu virus' as though they >> believe it really needs to read some elementary books about disease. >> >> Here's a clue: No flu viruses are treatable with antibiotics. In some >> cas > es >> antibiotics may be useful for flu patients to treat secondary >> bacterial infections, but they are not effective against viruses. > > Duncan, your reading and comprehension skills are atrocious. Please > re- read the paragraph you quoted, then spend some time > "comprehending" it, then show me where i stated that "antibiotics cure > viral infections". psst: i NEVER said any such thing! Rick, your reading and comprehension skills are atrocious. Please re-read the paragraph you quoted, then spend some time "comprehending" it, then show me where I stated that you '''stated that "antibiotics cure viral infections"'''. I never said any such thing. -- Duncan Booth http://kupuguy.blogspot.com From as at sci.fi Wed Feb 15 04:56:12 2012 From: as at sci.fi (Anssi Saari) Date: Wed, 15 Feb 2012 11:56:12 +0200 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: Matej Cepl writes: > Slightly less flameish answer to the question ?What should I do, > really?? is a tough one: all these suggested answers are bad because > they don?t deal with the fact, that your input data are obviously > broken. The rest is just pure GIGO ? Well, sure, but it happens that input data is broken and not fixable. For example, I did a little program to display email headers like the old frm that was bundled with elm, only with support for MIME decoding of the headers. Obviously lots of email software is still completely broken regarding MIME and also multi-line headers. However, something useful can still be extracted from that broken data. > BTW, can you display the following line? > > P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. Looks fine to me. You used an ellipsis too above. Well, I don't know what it shold look like exactly. Lots of accents. Hmm, Google says it means "The quick brown fox cried too lazy"? Seems appropriate :) BTW, I'm sending this via Usenet, I wonder what happens in the mail-news gateway? From arnodel at gmail.com Wed Feb 15 04:58:06 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 15 Feb 2012 09:58:06 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: On 15 February 2012 09:47, Duncan Booth wrote: > Rick Johnson wrote: [...] Perhaps it's a bit presumptuous of me but... It's tempting to react to his inflammatory posts, but after all Rick is a troll and experience shows that trolls are best left alone. Also, please spare a thought for all of us who have him in our killfiles. -- Arnaud From duncan.booth at invalid.invalid Wed Feb 15 05:04:34 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Feb 2012 10:04:34 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > On 15 February 2012 09:47, Duncan Booth > wrote: >> Rick Johnson wrote: > [...] > > Perhaps it's a bit presumptuous of me but... > > It's tempting to react to his inflammatory posts, but after all Rick > is a troll and experience shows that trolls are best left alone. > Also, please spare a thought for all of us who have him in our > killfiles. > Yes, sorry about that. Actually, I thought it was a bit weird that I saw ChrisA's comment but not the message he was commenting on until I went and looked for it. I read this group on a couple of machines and it looks like Rick's killfile entry had expired on the other but not this one. Next time I'm back on the other machine I'll try to remember to sort out the killfile. -- Duncan Booth http://kupuguy.blogspot.com From steve+comp.lang.python at pearwood.info Wed Feb 15 05:27:01 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Feb 2012 10:27:01 GMT Subject: Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 10:04:34 +0000, Duncan Booth wrote: > Actually, I thought it was a bit weird that I saw ChrisA's comment but > not the message he was commenting on until I went and looked for it. I > read this group on a couple of machines and it looks like Rick's > killfile entry had expired on the other but not this one. Next time I'm > back on the other machine I'll try to remember to sort out the killfile. Yes, I have this problem too. I'm reluctant to killfile people forever, call me a sucker if you like, but I'm willing to give people second chances (and apparently third and fourth and fifth chances). Methinks it's time for Monsieur Johnson to go back in the killfile. -- Steven From andrea.crotti.0 at gmail.com Wed Feb 15 08:12:06 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 13:12:06 +0000 Subject: atexit.register in case of errors Message-ID: <4F3BAF26.2060505@gmail.com> I have the following very simplified situation from atexit import register def goodbye(): print("saying goodbye") def main(): while True: var = raw_input("read something") if __name__ == '__main__': register(goodbye) main() But in my case the "goodbye" function is deleting the logging file which was created during the application execution. Now the problem is that it *always* executes, even when the applications quits for some bad errors. Is there a way to have an exit hook, which doesn't execute in case of errors? I've seen the code of atexit and it apparently doesn't know anything about the current status and why the application is actually quitting, is that correct? From mwilson at the-wire.com Wed Feb 15 08:33:51 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Wed, 15 Feb 2012 08:33:51 -0500 Subject: atexit.register in case of errors References: Message-ID: Andrea Crotti wrote: > I have the following very simplified situation > > from atexit import register > > > def goodbye(): > print("saying goodbye") > > > def main(): > while True: > var = raw_input("read something") > > > if __name__ == '__main__': > register(goodbye) > main() > > > But in my case the "goodbye" function is deleting the logging file which > was created > during the application execution. > Now the problem is that it *always* executes, even when the applications > quits for > some bad errors. > > Is there a way to have an exit hook, which doesn't execute in case of > errors? > I've seen the code of atexit and it apparently doesn't know anything > about the current > status and why the application is actually quitting, is that correct? That's sort of the point: to do things that simply *have* to happen, even if you've lost control of the program. The usual way to do what you're asking is if __name__ == '__main__': main() goodbye() and write main so that it returns after it's done all the things it's supposed to do. If you've sprinkled `sys.exit()` all over your code, then don't do that. If you're forced to deal with a library that hides `sys.exit()` calls in the functions, then you have my sympathy. Library authors should not do that, and there have been threads on c.l.p explaining why they shouldn't. Mel. From jeanpierreda at gmail.com Wed Feb 15 08:43:37 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 15 Feb 2012 08:43:37 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <4F3B13B9.2010108@mrabarnett.plus.com> References: <4F3AA287.9070604@mrabarnett.plus.com> <4F3B13B9.2010108@mrabarnett.plus.com> Message-ID: On Tue, Feb 14, 2012 at 9:08 PM, MRAB wrote: > There is one place in the re engine where it tries to avoid getting > stuck in an infinite loop because of a zero-width match, but the fix > inadvertently causes another bug. It's described in issue #1647489. Just read the issue. Interesting, didn't know that was a bug rather than deliberate behavior. The other behavior (only match empty space once) makes more sense though. Thanks for linking. Still, that's for avoiding infinite loops in finditer/findall, not match/search :S -- Devin From jeanpierreda at gmail.com Wed Feb 15 08:52:21 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 15 Feb 2012 08:52:21 -0500 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: > The usual way to do what you're asking is > > if __name__ == '__main__': > ? ?main() > ? ?goodbye() > > and write main so that it returns after it's done all the things it's > supposed to do. ?If you've sprinkled `sys.exit()` all over your code, then > don't do that. ?If you're forced to deal with a library that hides > `sys.exit()` calls in the functions, then you have my sympathy. ?Library > authors should not do that, and there have been threads on c.l.p explaining > why they shouldn't. In such a case. one can do:: if __name__ == '__main__': try: main() except SystemExit: pass goodbye() -- Devin From pgiri at yahoo.com Wed Feb 15 09:06:17 2012 From: pgiri at yahoo.com (Giridhar Pemmasani) Date: Wed, 15 Feb 2012 06:06:17 -0800 (PST) Subject: [ANN]: Python module to distribute computations for parallel execution Message-ID: <1329314777.16003.YahooMailNeo@web160605.mail.bf1.yahoo.com> Hello, I would like to announce dispy (http://dispy.sourceforge.net), a python framework for distributing computations for parallel execution to processors/cores on single node to many nodes over the network. The computations can be python functions or programs. If there are any dependencies, such as other python functions, modules, classes, objects or files, they are also distributed as well. The results of each computation, output, error messages and exception trace, if any, are made available to client program for further processing. Popular map/reduce style programs can be easily developed and deployed with dispy. There is also an implementation of dispy, called discopy, that uses asynchronous I/O and coroutines, so that discopy will scale efficiently for large number of network connections (right now this is a bit academic, until it has been tested with such setups). The framework with asynchronous I/O and coroutines, called asyncoro, is independent of dispy - discopy is an implementation of dispy using asyncoro. Others may find asyncoro itself useful. Salient features of dispy/discopy are: ? * Computations (python functions or standalone programs) and its ? ? dependencies (files, python functions, classes, modules) are ? ? distributed automatically. ? * Computation nodes can be anywhere on the network (local or ? ? remote). For security, either simple hash based authentication or ? ? SSL encryption can be used. ? * A computation may specify which nodes are allowed to execute it ? ? (for now, using simple patterns of IP addresses). ? * After each execution is finished, the results of execution, ? ? output, errors and exception trace are made available for further ? ? processing. ? * If callback function is provided, dispy executes that function ? ? when a job is finished; this feature is useful for further ? ? processing of job results. ? * Nodes may become available dynamically: dispy will schedule jobs ? ? whenever a node is available and computations can use that node. ? * Client-side and server-side fault recovery are supported: ? ? If user program (client) terminates unexpectedly (e.g., due to ? ? uncaught exception), the nodes continue to execute scheduled jobs. ? ? If client-side fault recover option is used when creating a cluster, ? ? the results of the scheduled (but unfinished at the time of crash) ? ? jobs for that cluster can be easily retrieved later. ? ? If a computation is marked re-entrant (with 'resubmit=True' option) ? ? when a cluster is created and a node (server) executing jobs for ? ? that computation fails, dispy automatically resubmits those jobs ? ? to other available nodes. ? * In optimization problems it is useful for computations to send ? ? (successive) provisional results back to the client, so it can, ? ? for example,?terminate computations. If computations are python ? ? functions, they can use 'dispy_provisional_result' function for ? ? this purpose. ? * dispy can be used in a single process to use all the nodes ? ? exclusively (with JobCluster - simpler to use) or in multiple ? ? processes simultaneously sharing the nodes (with ShareJobCluster ? ? and dispyscheduler). dispy works with python 2.7. It has been tested on Linux, Mac OS X and known to work with Windows. discopy has been tested on Linux and Mac OS X. I am not subscribed to the list, so please Cc me if you have comments. Cheers, Giri -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Wed Feb 15 09:35:33 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 14:35:33 +0000 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <4F3BC2B5.4090901@gmail.com> On 02/15/2012 01:52 PM, Devin Jeanpierre wrote: > On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: >> The usual way to do what you're asking is >> >> if __name__ == '__main__': >> main() >> goodbye() >> >> and write main so that it returns after it's done all the things it's >> supposed to do. If you've sprinkled `sys.exit()` all over your code, then >> don't do that. If you're forced to deal with a library that hides >> `sys.exit()` calls in the functions, then you have my sympathy. Library >> authors should not do that, and there have been threads on c.l.p explaining >> why they shouldn't. > In such a case. one can do:: > > if __name__ == '__main__': > try: > main() > except SystemExit: > pass > goodbye() > > -- Devin Makes perfect sense, I solved like this then, thanks From lists.eckel at gmail.com Wed Feb 15 09:58:43 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 15 Feb 2012 06:58:43 -0800 (PST) Subject: Automatic Type Conversion to String References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: > Could it be that you missed the fact that strings are immutable? That > means that you can't change the content of the object once it is > initialized. In particular, it means that you e.g. have to override > __new__ instead of __init__, because the content is already fixed when > the latter is called. > > Uli Yes, that's what I missed, and it explains why I found examples of str inheritance using __new__. I think this might end up being a puzzle I poke at for awhile. Also, I discovered that the attempt to create a "Path" class goes back to 2006, where it created a lot of discussion and was finally shelved: http://www.python.org/dev/peps/pep-0355/ A significant part of the problem seems to be that there was no inheritance from str at the time, so maybe a lot of the issues they ran into could be solved now. From rantingrickjohnson at gmail.com Wed Feb 15 10:04:23 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Feb 2012 07:04:23 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> On Feb 15, 2:56?am, John O'Hagan wrote: > You have just demonstrated that you are the worst kind of racist. Not only have > you blamed the victim on a truly monstrous scale, you have assigned blame not to > individuals, but to entire "races". Your tabloid sensationalism is the worst i've seen. You'll jump at any chance to tag someone a racist, homophobic, sexist, or any other kind of hate group you can muster in a weak attempt to win an argument you cannot win by spewing ad hominem attacks. You cannot stay on subject because your argument is baseless and mine is the backed by truth. Just in case you have forgotten, here is the main point: "degenerates are a drain on healthcare/society". Can you counter that argument with a fact and prove they are not? The only winning argument is that "degenerates pay their own medical bills"... but as you and i know, most degenerates DON'T pay their own medical bills. They expect US to pay them. > You are saying that something inherent in > each race caused them to "allow" their own subjugation. I have PROVEN that when people FIGHT back, they will NOT be subjects to tyranny; race has NOTHING to do with it. I gave one example in history where people would rather die than be subjected to tyranny, there are many more. "GIVE ME FREEDOM FOR GIVE ME DEATH!" The world is full of evil people who seek to force their fellow man into slavery. Those who refuse to fight for freedom will be victims, on the other hand, those who are willing to sacrifice ALL in the name of freedom will be free men. 300: "Go now! Run along and tell your Xerxes he faces free men here, not slaves! Do it quickly, before we decide to make our wall just a little bit bigger." John, I have grown weary of educating you. Go back to your day job writing op-eds for the National Inquirer and News of the World; they love this vile sensationalist crap! Goodnight "John boy". From breamoreboy at yahoo.co.uk Wed Feb 15 10:18:07 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 15:18:07 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: On 15/02/2012 15:04, Rick Johnson wrote: > On Feb 15, 2:56 am, John O'Hagan wrote: > John, I have grown weary of educating you. Go back to your day job > writing op-eds for the National Inquirer and News of the World; they > love this vile sensationalist crap! Goodnight "John boy". The News of the Screws closed months ago. As you didn't answer my question from some days back I'll ask it agin. Please explain why previously healthy people get struck down with Common Fatigue Syndrome amongst other things. -- Cheers. Mark Lawrence. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Wed Feb 15 10:18:30 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Wed, 15 Feb 2012 16:18:30 +0100 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: Am 15.02.2012 14:52 schrieb Devin Jeanpierre: > On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: >> The usual way to do what you're asking is >> >> if __name__ == '__main__': >> main() >> goodbye() >> >> and write main so that it returns after it's done all the things it's >> supposed to do. If you've sprinkled `sys.exit()` all over your code, then >> don't do that. If you're forced to deal with a library that hides >> `sys.exit()` calls in the functions, then you have my sympathy. Library >> authors should not do that, and there have been threads on c.l.p explaining >> why they shouldn't. > > In such a case. one can do:: > > if __name__ == '__main__': > try: > main() > except SystemExit: > pass > goodbye() > > -- Devin Wouldn't if __name__ == '__main__': try: main() finally: goodbye() be even better? Or doesn't it work well together with SystemExit? Thomas From andrea.crotti.0 at gmail.com Wed Feb 15 10:41:12 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 15:41:12 +0000 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <4F3BD218.8000701@gmail.com> On 02/15/2012 03:18 PM, Thomas Rachel wrote: > > Wouldn't > > if __name__ == '__main__': > try: > main() > finally: > goodbye() > > be even better? Or doesn't it work well together with SystemExit? > > > Thomas Well in that case goodbye is always called, even if I have some other nasty exception, which is not what I want.. (and is exactly what I had with atexit.register). Isn't it? From breamoreboy at yahoo.co.uk Wed Feb 15 11:04:27 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 16:04:27 +0000 Subject: Interactive keyword help Message-ID: I didn't realise that this was available until today. It doesn't appear to be prominent in the official docs or have I missed something? Certainly I'd have thought a couple of sentences here http://www.python.org/about/help/ would be justified, what do y'all think? -- Cheers. Mark Lawrence. From rantingrickjohnson at gmail.com Wed Feb 15 11:27:08 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Feb 2012 08:27:08 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> On Feb 15, 9:18?am, Mark Lawrence wrote: > As you didn't answer my question from some days back I'll ask it agin. > Please explain why previously healthy people get struck down with Common > Fatigue Syndrome amongst other things. Why do you seek my counsel regarding medical ailments? Do you believe i have special knowledge in the field? But more importantly: how is your question germane to the "destruction of healthcare" and "expansion of tyranny" by the degenerates of society; or by those who support degeneracy by engaging in "degenerate eugenics"? Was your question meant as rhetorical? Or merely yet ANOTHER crude attempt to employ sophistry in hopes of coercing the less astute folks among us to hop in your "clown car of delirium" and head-off down ANOTHER path to that leads to logical fallacy? Stay on subject! From ian.g.kelly at gmail.com Wed Feb 15 11:46:34 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 09:46:34 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 8:04 AM, Rick Johnson wrote: > I have PROVEN that when people FIGHT back, they will NOT be subjects > to tyranny; race has NOTHING to do with it. I gave one example in > history where people would rather die than be subjected to tyranny, > there are many more. "GIVE ME FREEDOM FOR GIVE ME DEATH!" > > The world is full of evil people who seek to force their fellow man > into slavery. Those who refuse to fight for freedom will be victims, > on the other hand, those who are willing to sacrifice ALL in the name > of freedom will be free men. > > 300: "Go now! Run along and tell your Xerxes he faces free men here, > not slaves! Do it quickly, before we decide to make our wall just a > little bit bigger." If you get all your history from Hollywood, then no wonder you are so badly misinformed. Braveheart and 300 are inspiring movies to be sure, but they are also highly fictionalized. In the real world, the execution of William Wallace actually succeeded in quelling the Scottish rebellion for a time -- when Robert the Bruce started it up again half a year later, his motives were entirely political in nature (he had murdered a rival in a church and been excommunicated; his options were to place himself on the throne or become a fugitive), not out of some noble sense of guilt or duty to Wallace or desire for freedom as depicted in the film. Your statement that the Africans brought to America allowed themselves to be enslaved is simply false. There were dozens of slave rebellions in the United States prior to the Civil War. Most of them failed and ended in the executions of the rebels. You won't see Hollywood making too many movies about those, which is probably why you don't know anything about them. From breamoreboy at yahoo.co.uk Wed Feb 15 12:16:19 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 17:16:19 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> Message-ID: On 15/02/2012 16:27, Rick Johnson wrote: > On Feb 15, 9:18 am, Mark Lawrence wrote: >> As you didn't answer my question from some days back I'll ask it agin. >> Please explain why previously healthy people get struck down with Common >> Fatigue Syndrome amongst other things. > > Why do you seek my counsel regarding medical ailments? Do you believe > i have special knowledge in the field? But more importantly: how is > your question germane to the "destruction of healthcare" and > "expansion of tyranny" by the degenerates of society; or by those who > support degeneracy by engaging in "degenerate eugenics"? > > Was your question meant as rhetorical? Or merely yet ANOTHER crude > attempt to employ sophistry in hopes of coercing the less astute folks > among us to hop in your "clown car of delirium" and head-off down > ANOTHER path to that leads to logical fallacy? > > Stay on subject! I don't seek your counsel on anything. You set the ball rolling and I quote "If you can't afford healthcare, then you die." and "You want to solve the healthcare problem then STOP TREATING PEOPLE WHO DON'T HAVE INSURANCE!" You later went on to say and I again quote "Healthy people do not need healthcare very often, and in the rare cases when they do, they don't bog down the system because their bodies are strong. Why are their bodies strong? Because healthy people eat correctly, healthy people exercise, therefore, healthy people have correctly functioning immune systems -- of course quality genes always help!" The question was originally put in response to that, so you've resorted to your usual tactics of spewing ad hominem attacks on anybody who dares to challenge you in any way, shape or form. If I were you I'd stick to things that you understand, like downloading workable help files. But oh dear, you can't even manage that, you simply moan like hell because the help file you had didn't work correctly. Or IDLE is crap. Or ... -- Cheers. Mark Lawrence. From bahamutzero8825 at gmail.com Wed Feb 15 12:23:20 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 15 Feb 2012 11:23:20 -0600 Subject: Interactive keyword help In-Reply-To: References: Message-ID: <4F3BEA08.9010001@gmail.com> On 2/15/2012 10:04 AM, Mark Lawrence wrote: > I didn't realise that this was available until today. It doesn't appear > to be prominent in the official docs or have I missed something? > Certainly I'd have thought a couple of sentences here > http://www.python.org/about/help/ would be justified, what do y'all think? > help() is a built-in function, not a keyword. http://docs.python.org/library/functions.html#help http://docs.python.org/py3k/library/functions.html#help -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From arnodel at gmail.com Wed Feb 15 12:27:57 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 15 Feb 2012 17:27:57 +0000 Subject: Interactive keyword help In-Reply-To: <4F3BEA08.9010001@gmail.com> References: <4F3BEA08.9010001@gmail.com> Message-ID: On 15 February 2012 17:23, Andrew Berg wrote: > On 2/15/2012 10:04 AM, Mark Lawrence wrote: >> I didn't realise that this was available until today. ?It doesn't appear >> to be prominent in the official docs or have I missed something? >> Certainly I'd have thought a couple of sentences here >> http://www.python.org/about/help/ would be justified, what do y'all think? >> > help() is a built-in function, not a keyword. I think he's referring to help *on* keywords, e.g. >>> help('yield') -- Arnaud From breamoreboy at yahoo.co.uk Wed Feb 15 12:36:56 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 17:36:56 +0000 Subject: Interactive keyword help In-Reply-To: References: <4F3BEA08.9010001@gmail.com> Message-ID: On 15/02/2012 17:27, Arnaud Delobelle wrote: > On 15 February 2012 17:23, Andrew Berg wrote: >> On 2/15/2012 10:04 AM, Mark Lawrence wrote: >>> I didn't realise that this was available until today. It doesn't appear >>> to be prominent in the official docs or have I missed something? >>> Certainly I'd have thought a couple of sentences here >>> http://www.python.org/about/help/ would be justified, what do y'all think? >>> >> help() is a built-in function, not a keyword. > > I think he's referring to help *on* keywords, e.g. > >>>> help('yield') > Correct. -- Cheers. Mark Lawrence. From Tim.Arnold at sas.com Wed Feb 15 12:48:13 2012 From: Tim.Arnold at sas.com (Tim Arnold) Date: Wed, 15 Feb 2012 12:48:13 -0500 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: On 2/13/2012 6:20 AM, Matej Cepl wrote: > Hi, > > I am getting more and more discouraged from using XSLT for a > transformation from one XML scheme to another one. Does anybody could > share any experience with porting moderately complicated XSLT stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? > Any thoughts? > > Thank you, > > Mat?j Just a note to encourage you to stick with XSLT. I also use lxml for creating and postprocessing my DocBook documents and it is great. But I use the DocBook XSL stylesheets to convert to html; if you're like me, you got discouraged at the strangeness of the XSLT language. I'm no expert with it by any means, but I'm amazed at some of the things it does. It is a great tool to add to your programming toolbox. Also, I used xsltproc for a while but bogged down in processing time. Now I use SAXON which is much faster for my documents. Good luck, --Tim From franck at ditter.org Wed Feb 15 13:20:21 2012 From: franck at ditter.org (Franck Ditter) Date: Wed, 15 Feb 2012 19:20:21 +0100 Subject: Complexity question on Python 3 lists Message-ID: What is the cost of calling primes(n) below ? I'm mainly interested in knowing if the call to append is O(1), even amortized. Do lists in Python 3 behave like ArrayList in Java (if the capacity is full, then the array grows by more than 1 element) ? def sdiv(n) : # n >= 2 """returns the smallest (prime) divisor of n""" if n % 2 == 0 : return 2 for d in range(3,int(sqrt(n))+1,2) : if n % d == 0 : return d return n def isPrime(n) : """Returns True iff n is prime""" return n >= 2 and n == sdiv(n) def primes(n) : # n >= 2 """Returns the list of primes in [2,n]""" res = [] for k in range(2,n+1) : if isPrime(k) : res.append(k) # cost O(1) ? return res Thanks, franck From nad at acm.org Wed Feb 15 13:21:53 2012 From: nad at acm.org (Ned Deily) Date: Wed, 15 Feb 2012 19:21:53 +0100 Subject: Automatic Type Conversion to String References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: In article , Bruce Eckel wrote: > Also, I discovered that the attempt to create a "Path" class goes back > to 2006, where it created a lot of discussion and was finally shelved: > http://www.python.org/dev/peps/pep-0355/ > > A significant part of the problem seems to be that there was no > inheritance from str at the time, so maybe a lot of the issues they > ran into could be solved now. You might want to take a look at pathlib, a current attempt at providing object-oriented paths, written by Antoine Pitrou, one of the Python core developers: http://pypi.python.org/pypi/pathlib -- Ned Deily, nad at acm.org From nathan.alexander.rice at gmail.com Wed Feb 15 13:31:44 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 15 Feb 2012 13:31:44 -0500 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> References: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> Message-ID: > And I'll take this opportunity to plug my dualmethod descriptor: > > http://code.activestate.com/recipes/577030-dualmethod-descriptor/ I use an analogous pattern in SQL Alchemy all the time (it's called hybridmethod/hybridproperty there). +1 to dualmethod, that pattern is great when you want a method or property that does something concrete when passed an instance, or something abstract relating to all instances when passed a class. Nathan From clp2 at rebertia.com Wed Feb 15 13:35:25 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 10:35:25 -0800 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 10:20 AM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? Yes. Python lists aren't linked lists. list.append() resizes the underlying array intelligently to give O(1) performance, although I can't find any guarantee of this in the docs, but it is true in practice for all major Python implementations. Cheers, Chris From miki.tebeka at gmail.com Wed Feb 15 13:36:26 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:36:26 -0800 (PST) Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> Message-ID: <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. On a site note: ALL CAPS is considered shouting, please don't use that in news groups. From miki.tebeka at gmail.com Wed Feb 15 13:40:00 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:40:00 -0800 (PST) Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <16963932.42.1329331200261.JavaMail.geo-discussion-forums@ynje6> Another option is to use a global error flag and set it in sys.excepthook (see http://docs.python.org/library/sys.html#sys.excepthook). goodbye will check the error flag and skip execution if error flag is set. From miki.tebeka at gmail.com Wed Feb 15 13:40:00 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:40:00 -0800 (PST) Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <16963932.42.1329331200261.JavaMail.geo-discussion-forums@ynje6> Another option is to use a global error flag and set it in sys.excepthook (see http://docs.python.org/library/sys.html#sys.excepthook). goodbye will check the error flag and skip execution if error flag is set. From ian.g.kelly at gmail.com Wed Feb 15 13:43:09 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 11:43:09 -0700 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. Yes, it's amortized O(1). See: http://wiki.python.org/moin/TimeComplexity >From a relatively shallow analysis, primes(n) appears to be O(n ** (3/2)), but it might be possible to tighten that up a bit with an analysis of the distribution of primes and their smallest divisors. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? I believe the behavior in CPython is that if the array is full, the capacity is doubled, but I'm not certain, and that would be an implementation detail in any case. Cheers, Ian From d at davea.name Wed Feb 15 13:45:33 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 13:45:33 -0500 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: <4F3BFD4D.9030100@davea.name> On 02/15/2012 01:20 PM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? > > def sdiv(n) : # n>= 2 > """returns the smallest (prime) divisor of n""" > if n % 2 == 0 : return 2 > for d in range(3,int(sqrt(n))+1,2) : > if n % d == 0 : return d > return n > > def isPrime(n) : > """Returns True iff n is prime""" > return n>= 2 and n == sdiv(n) > > def primes(n) : # n>= 2 > """Returns the list of primes in [2,n]""" > res = [] > for k in range(2,n+1) : > if isPrime(k) : res.append(k) # cost O(1) ? > return res > > Thanks, > > franck Yes, lists behave the way you'd expect (see vector in C++), where when they have to reallocate they do so exponentially. However, realize that your algorithm is inefficient by a huge factor more than any time spent expanding lists. The biggest single thing you need to do is to memoize -- store the list of known primes, and add to it as you encounter more. Then use that list instead of range(3, xxx, 2) for doing the trial divisions. -- DaveA From d at davea.name Wed Feb 15 13:48:44 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 13:48:44 -0500 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> Message-ID: <4F3BFE0C.9080603@davea.name> On 02/15/2012 01:36 PM, Miki Tebeka wrote: > It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. > > On a site note: ALL CAPS is considered shouting, please don't use that in news groups. When you reply to a known bot, please include some indication of the fact, so we know your message can be ignored as well. -- DaveA From stefan_ml at behnel.de Wed Feb 15 14:01:07 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 15 Feb 2012 20:01:07 +0100 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: Ian Kelly, 15.02.2012 19:43: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity is doubled But only up to a certain limit. After that, it grows in constant steps. Otherwise, your memory would be bound to explode on an append even though your list uses only half of it (or one third, in case it needs to copy). >, but I'm not certain, and that would be an > implementation detail in any case. Absolutely. Stefan From clp2 at rebertia.com Wed Feb 15 14:11:27 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 11:11:27 -0800 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 10:43 AM, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity is doubled, but I'm not certain, and that would be an > implementation detail in any case. It's slightly more complex: http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c "The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" -- list_resize() Cheers, Chris From SMac2347 at comcast.net Wed Feb 15 14:11:39 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Wed, 15 Feb 2012 11:11:39 -0800 (PST) Subject: Python to Combine Multiple Excel Worksheets into One Worksheet Message-ID: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> Hello, I have one single Excel file with many separate worksheets, and for work I need to combine all these separate worksheets into one single worksheet (I am not worried about formatting, as the format is the same in each sheet, nor am I worried about Excel's row limit). Essentially, I am looking for a way to append the data in one sheet to the bottom of the sheet that proceeds it. What would be the best way to do this, and how would I go about doing it? Can it be done simply with the xlwt, xlrd, and xutils modules, or (as I was thinking) do I need to convert the sheets to separate csv files, then append the separate csv files, and then write the completed file back into .xls format? Or perhaps something else? As I am really only a Python beginner, any and all help is very much appreciated. Thank you in advance!! From ethan at stoneleaf.us Wed Feb 15 14:29:17 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 15 Feb 2012 11:29:17 -0800 Subject: Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]] In-Reply-To: <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3C078D.9070406@stoneleaf.us> Steven D'Aprano wrote: > On Wed, 15 Feb 2012 10:04:34 +0000, Duncan Booth wrote: > >> Actually, I thought it was a bit weird that I saw ChrisA's comment but >> not the message he was commenting on until I went and looked for it. I >> read this group on a couple of machines and it looks like Rick's >> killfile entry had expired on the other but not this one. Next time I'm >> back on the other machine I'll try to remember to sort out the killfile. > > Yes, I have this problem too. I'm reluctant to killfile people forever, > call me a sucker if you like, but I'm willing to give people second > chances (and apparently third and fourth and fifth chances). Methinks > it's time for Monsieur Johnson to go back in the killfile. Luckily for me there are enough folks that still reply to the trolls in my killfile that I can see if it's time to take them off or not. ;) (This one is a resounding NOT) ~Ethan~ From rsengupta at wisc.edu Wed Feb 15 15:12:41 2012 From: rsengupta at wisc.edu (Rituparna Sengupta) Date: Wed, 15 Feb 2012 14:12:41 -0600 Subject: writing to a file from within nested loops In-Reply-To: <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> Message-ID: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Hi, I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. Ritu . . . i=0 ?while i References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On Wed, Feb 15, 2012 at 12:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. Please post your exact actual code (which this isn't; it has clear fatal syntax errors) and the full error message, including the stack Traceback. I would suspect there is some problematic assignment to `f` that you excluded from the snippet you posted. Cheers, Chris From ian.g.kelly at gmail.com Wed Feb 15 15:32:51 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 13:32:51 -0700 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. There's not enough to go on here. Please post the actual code snippet and the full traceback. Don't summarize the error for us. From d at davea.name Wed Feb 15 15:36:31 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 15:36:31 -0500 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: <4F3C174F.8060305@davea.name> On 02/15/2012 03:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. > > Ritu > > > > . > . > . > i=0 > while i r=name[i] > f=open('file'+'%s' %(r), "a") > f.write("whatever"+r) #part outside innermost loop gets printed > j=0 > while j f.write("output of loop") #part within innermost loop doesn't get printed > j=j+1 > f.close() > i=i+1 > > Welcome to the mailing list. Some fundamentals, please: 1) give python version & os 2) copy/paste the code, don't retype it. You have lots of typos which would cause syntax errors, not "xxx" has no attribute "yyy". And please don't use 1 column indents; they're illegible. 4 spaces is a good number, recommended in a large number of places, including pep8. 3) copy/paste the whole error, including traceback. Without it in this case, we're forced to guess where the problem might be, and that must be somewhere else in the program, since the only write() attribute you've quoted here are on f.write() calls, and f is only set to a file object, not a string object. There are lots of ways in the code you don't show, where you might confuse the system, such as redefining open. Now to your questions: A) Since you don't show n, it could very well be 0 or negative, in which case the inner loop would never execute. B) Since you don't have correct indentation, it's possible the actual program closes the file inside the inner loop, in which case it might execute just once, then get an exception. not the one you quote, but whatever. C) Depending on how you run this program, perhaps the file isn't getting flushed when you get your error, so you just think the output didn't happen. D) BTW, i don't see any prints, but perhaps that's a minor point. You might think of file.write() as printing to a file. Sort of. -- DaveA From breamoreboy at yahoo.co.uk Wed Feb 15 15:44:02 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 20:44:02 +0000 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On 15/02/2012 20:12, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. > > Ritu > > . > i=0 > while i r=name[i] > f=open('file'+'%s' %(r), "a") > f.write("whatever"+r) #part outside innermost loop gets printed > j=0 > while j f.write("output of loop") #part within innermost loop doesn't get printed > j=j+1 > f.close() > i=i+1 > The above isn't Python so please post all of your code or a representative snippet that can show the problem, with the complete traceback and not simply the last line. Having said that I'm guessing that you're reassigning f somewhere to be a string, hence the error. Also why not write Python loops like:- for r in name: etc. -- Cheers. Mark Lawrence. From martin.schoon at gmail.com Wed Feb 15 15:58:11 2012 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 15 Feb 2012 20:58:11 GMT Subject: [semi OT]: Smartphones and Python? Message-ID: <9q2kj3Fmq1U1@mid.individual.net> First of all: I don't have any first hand experience of smartphones but now that my trusted old GSM phone is getting old I decided I am in for an up-grade. It struck me it might be nice to get something for which I could write Python programs. A very quick internet search indicated that this should be no big deal if I go for an Android-based phone. What about the alterna- tives? It struck me this must be the best place to ask. What else? I don't know if it matters but my home PC OS is Linux. And I am not much of a Python programmer but I enjoy learning it and I have reached a level that has turned out to be useful at work. /Martin From ken.allen at sbcglobal.net Wed Feb 15 16:02:45 2012 From: ken.allen at sbcglobal.net (Ken) Date: Wed, 15 Feb 2012 13:02:45 -0800 (PST) Subject: Numerical Linear Algebra in arbitrary precision Message-ID: Brand new Python user and a bit overwhelmed with the variety of packages available. Any recommendation for performing numerical linear algebra (specifically least squares and generalized least squares using QR or SVD) in arbitrary precision? I've been looking at mpmath but can't seem to find much info on built in functions except for LU decomposition/solve. Appreciate any comments. Ken From nagle at animats.com Wed Feb 15 16:24:23 2012 From: nagle at animats.com (John Nagle) Date: Wed, 15 Feb 2012 13:24:23 -0800 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: <4f3c2286$0$12039$742ec2ed@news.sonic.net> On 2/8/2012 9:47 AM, Chris Rebert wrote: > On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice > wrote: >> As a user: >> * Finding the right module in PyPi is a pain because there is limited, >> low quality semantic information, and there is no code indexing. CPAN does it right. They host the code. (PyPi is just a collection of links). They have packaging standards (PyPi does not.) CPAN tends not to be full of low-quality modules that do roughly the same thing. If you want to find a Python module, Google is more useful than PyPi. John Nagle From nagle at animats.com Wed Feb 15 16:28:43 2012 From: nagle at animats.com (John Nagle) Date: Wed, 15 Feb 2012 13:28:43 -0800 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> Message-ID: <4f3c238b$0$11951$742ec2ed@news.sonic.net> On 2/4/2012 12:43 PM, Chris Angelico wrote: > On Sun, Feb 5, 2012 at 3:32 AM, Andrew Berg wrote: >> On 2/3/2012 9:15 PM, Chris Angelico wrote: >>> Do you call on potentially-buggy external modules? >> It imports one module that does little more than define a few simple >> functions. There's certainly no (intentional) interpreter hackery at work. Are you doing a conditional import, one that takes place after load time? If you do an import within a function or class, it is executed when the code around it executes. If you import a file with a syntax error during execution, you could get the error message you're getting. John Nagle From donald.stufft at gmail.com Wed Feb 15 16:31:10 2012 From: donald.stufft at gmail.com (Donald Stufft) Date: Wed, 15 Feb 2012 16:31:10 -0500 Subject: Looking for PyPi 2.0... In-Reply-To: <4f3c2286$0$12039$742ec2ed@news.sonic.net> References: <4f3c2286$0$12039$742ec2ed@news.sonic.net> Message-ID: <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> On Wednesday, February 15, 2012 at 4:24 PM, John Nagle wrote: > On 2/8/2012 9:47 AM, Chris Rebert wrote: > > On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice > > wrote: > > > As a user: > > > * Finding the right module in PyPi is a pain because there is limited, > > > low quality semantic information, and there is no code indexing. > > > > > > > > > > CPAN does it right. They host the code. (PyPi is just a > collection of links). They have packaging standards (PyPi > does not.) CPAN tends not to be full of low-quality modules > that do roughly the same thing. > > If you want to find a Python module, Google is more useful > than PyPi. > > Hopefully soon crate.io will be useful for finding modules ;) I have plans for it to try and, encourage people to host their code and encourage following packaging standards. I'm currently focused mostly on the backend stability (e.g. getting it stable) but emphasizing things that are generally good for the packaging ecosystem is something I hope to do. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list > > Donald Stufft -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Feb 15 16:31:19 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 16:31:19 -0500 Subject: atexit.register in case of errors In-Reply-To: <4F3BAF26.2060505@gmail.com> References: <4F3BAF26.2060505@gmail.com> Message-ID: On 2/15/2012 8:12 AM, Andrea Crotti wrote: > I have the following very simplified situation > > from atexit import register > > def goodbye(): print("saying goodbye") > > def main(): > while True: var = raw_input("read something") > > if __name__ == '__main__': > register(goodbye) > main() > > But in my case the "goodbye" function is deleting the logging file > which was created during the application execution. Now the problem > is that it *always* executes, even when the applications quits for > some bad errors. > > Is there a way to have an exit hook, which doesn't execute in case of > errors? Have a single no-error normal exit point. if __name__ == '__main__': main() cleanup() if you really want to exit by exceptions rather than by returns, if __name__ == '__main__': try: main() except SystemExit: normal_exit_cleanup() -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 15 16:41:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 16:41:11 -0500 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On 2/15/2012 2:11 PM, Chris Rebert wrote: > > It's slightly more complex: > http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c > "The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" > -- list_resize() This has apparently changed from time to time. -- Terry Jan Reedy From bahamutzero8825 at gmail.com Wed Feb 15 16:41:51 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 15 Feb 2012 15:41:51 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f3c238b$0$11951$742ec2ed@news.sonic.net> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> <4f3c238b$0$11951$742ec2ed@news.sonic.net> Message-ID: <4F3C269F.5080400@gmail.com> On 2/15/2012 3:28 PM, John Nagle wrote: > Are you doing a conditional import, one that takes place after load > time? If you do an import within a function or class, it is executed > when the code around it executes. If you import a file with a > syntax error during execution, you could get the error message you're > getting. It does have conditional imports, but the tracebacks don't occur while that function is running (it's executed once, and this happens well after). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From alan.mckay+python at gmail.com Wed Feb 15 16:51:21 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Wed, 15 Feb 2012 16:51:21 -0500 Subject: Is this the right list? Message-ID: Hey folks, I looked all through the list of mailing lists on the mail.python.orgserver and this seems to be the only one that might apply to me other than maybe the German list which did not seem to have any specific python issue associated with it other than that you should write German on it. I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11, and the problem is around .py program. It is a web based program, and seems to use a strange combination of mod_python and python CGI as best I can tell. Would this be the right list to ask? thanks, -Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.alexander.rice at gmail.com Wed Feb 15 16:53:32 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 15 Feb 2012 16:53:32 -0500 Subject: Looking for PyPi 2.0... In-Reply-To: <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> References: <4f3c2286$0$12039$742ec2ed@news.sonic.net> <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> Message-ID: > Hopefully soon crate.io will be useful for finding modules ;) I have plans > for it to try and, encourage people to host their code and encourage > following packaging standards. I'm currently focused mostly on the backend > stability (e.g. getting it stable) but emphasizing things that are generally > good for the packaging ecosystem is something I hope to do. I think providing commit hooks for version control ala read the docs is the #1 thing you could do in the short term to add a lot of value. That would be enough for me to adopt the service :) Nathan From tjreedy at udel.edu Wed Feb 15 17:04:29 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 17:04:29 -0500 Subject: Is this the right list? In-Reply-To: References: Message-ID: On 2/15/2012 4:51 PM, Alan McKay wrote: > I am having a problem moving an application from RHEL 5.7 to Ubuntu > 11.11, and the problem is around .py program. > > It is a web based program, and seems to use a strange combination of > mod_python and python CGI as best I can tell. > > Would this be the right list to ask? Go ahead. If the question is too specialized for readers here, you might get a suggestion where else to look. Include python versions on both systems and any tracebacks from executing the program. -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Wed Feb 15 17:05:29 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 22:05:29 +0000 Subject: Is this the right list? In-Reply-To: References: Message-ID: On 15/02/2012 21:51, Alan McKay wrote: > Hey folks, > > I looked all through the list of mailing lists on the > mail.python.orgserver and this seems to be the only one that might > apply to me other than > maybe the German list which did not seem to have any specific python issue > associated with it other than that you should write German on it. > > I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11, > and the problem is around .py program. > > It is a web based program, and seems to use a strange combination of > mod_python and python CGI as best I can tell. > > Would this be the right list to ask? > > thanks, > -Alan > > > > Welcome. Put (a snippet of) code here that's causing the problem together with a full traceback and you'll soon find out :) If it is the right place you'll get answers, if not you'll certainly be pointed in the right direction. -- Cheers. Mark Lawrence. From ironfroggy at gmail.com Wed Feb 15 17:43:17 2012 From: ironfroggy at gmail.com (Calvin Spealman) Date: Wed, 15 Feb 2012 17:43:17 -0500 Subject: Stand-Alone Python Executable Skeletons Message-ID: I've recently been looking into different options to package python code into stand-alone executables, with tools like Py2EXE and PyInstaller, but I'm left feeling a little lost. Documentation seems sparse on all of them, the setups a little unusual to me. It feels like they could be a lot simpler, or that I could put in some preliminary work to make it easier for my needs in the long run. I'm hoping someone can help me pick the best option. What I would love to do (or know if it is possible) is have a set of executables, for Linux, Windows, and OS X, with a Zip archive appended to the end of them. I know the zip archive at the end of an executable works with EXE and ELF binaries, but does it work for whatever OSX uses (I have no mac machines, currently)? I'd like to build these three empty stand-alone python executables, setup such that they'll run any main.py sitting at the top level of the archive. After this, building for all three platforms would just be a matter of copying the empty versions and dumping the project into it. I'm leaning on doing this with PyInstaller being the easiest. Am I headed in the right direction? Ideally, these empty stand-alones could be distributed for use by others without any tools required to use them other than a zip utility. -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From ian.g.kelly at gmail.com Wed Feb 15 17:54:27 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 15:54:27 -0700 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 1:28 PM, Dennis Lee Bieber wrote: > On Wed, 15 Feb 2012 11:11:27 -0800, Chris Rebert > wrote: > > >>"The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" >> ? ?-- list_resize() >> > ? ? ? ?Rather perverse, is it not? The first set is plain doubling, but > then you get a series of increases by: > > ? ? ? ?... 9, 10, 11, 12, 14, 16, 16,... > > or > > ? ? ? ?100%, 100%, 100%, 56%, 40%, 34%, 30%, 27%, 22%,... > > ? ? ? ?Big jump form 100% to 56%... Based on the formula in the code, it would seem to asymptotically approach 12.5%. From clp2 at rebertia.com Wed Feb 15 17:55:53 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 14:55:53 -0800 Subject: Stand-Alone Python Executable Skeletons In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 2:43 PM, Calvin Spealman wrote: > I've recently been looking into different options to package python > code into stand-alone executables, with tools like Py2EXE and > PyInstaller, but I'm left feeling a little lost. Documentation seems > sparse on all of them, the setups a little unusual to me. It feels > like they could be a lot simpler, or that I could put in some > preliminary work to make it easier for my needs in the long run. I'm > hoping someone can help me pick the best option. > > What I would love to do (or know if it is possible) is have a set of > executables, for Linux, Windows, and OS X, with a Zip archive appended > to the end of them. I know the zip archive at the end of an executable > works with EXE and ELF binaries, but does it work for whatever OSX > uses (I have no mac machines, currently)? OS X has application bundles: http://en.wikipedia.org/wiki/Application_bundle py2app can generate them: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html Cheers, Chris From python at mrabarnett.plus.com Wed Feb 15 18:17:56 2012 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 15 Feb 2012 23:17:56 +0000 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <4F3C3D24.4000900@mrabarnett.plus.com> On 15/02/2012 20:58, Martin Sch??n wrote: > First of all: I don't have any first hand experience of smartphones > but now that my trusted old GSM phone is getting old I decided I am > in for an up-grade. It struck me it might be nice to get something > for which I could write Python programs. > > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alterna- > tives? > > It struck me this must be the best place to ask. > > What else? I don't know if it matters but my home PC OS is Linux. > And I am not much of a Python programmer but I enjoy learning it > and I have reached a level that has turned out to be useful at work. > Python has been ported to iOS, if you're thinking of going the Apple route: http://ipython.hozbox.com From someone at someplace.invalid Wed Feb 15 18:33:26 2012 From: someone at someplace.invalid (HoneyMonster) Date: Wed, 15 Feb 2012 23:33:26 +0000 (UTC) Subject: Wanted: Criticism of code for a Python module, plus a Mac tester Message-ID: I am quite new to Python (running Python 2.7 on Linux). I have written a very small and simple dealing module for the game of Bridge. For those unfamiliar with the game, the idea is to deal each of 4 players a hand of 13 cards from a pack of 52, and to display it thus (use a fixed pitch font): Board 1 Neither vulnerable Dealer North K98432 T7 2 AQT2 T AQJ KJ854 9632 KQ973 T854 85 74 765 AQ AJ6 KJ963 Firstly, is there anyone here who uses Python on a Mac and would be prepared to test it? I have tested it on Linux and Windows, but don't have access to a Mac. Secondly, as a more general point I would welcome comments on code quality, adherence to standards and so forth. The code is at: http://dl.dropbox.com/u/6106778/bridgedeal.py Thanks. From no.email at nospam.invalid Wed Feb 15 18:36:31 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 15 Feb 2012 15:36:31 -0800 Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <7x62f7u0sg.fsf@ruckus.brouhaha.com> Martin Sch??n writes: > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alternatives? It works pretty well with Maemo, though phones with that are not so easy to find. My ex-officemate wrote some SL4A (Android) apps in Python and said it was pretty easy to use, though some features were missing. I know that one missing feature was tkinter. From rosuav at gmail.com Wed Feb 15 18:54:38 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Feb 2012 10:54:38 +1100 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <4F3BFE0C.9080603@davea.name> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> Message-ID: On Thu, Feb 16, 2012 at 5:48 AM, Dave Angel wrote: > When you reply to a known bot, please include some indication of the fact, > so we know your message can be ignored as well. Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. ChrisA From steve+comp.lang.python at pearwood.info Wed Feb 15 18:57:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Feb 2012 23:57:49 GMT Subject: Interactive keyword help References: Message-ID: <4f3c467d$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 11:23:20 -0600, Andrew Berg wrote: > help() is a built-in function, not a keyword. > http://docs.python.org/library/functions.html#help > http://docs.python.org/py3k/library/functions.html#help Technically, it's not actually built-in, it is added to the built-ins by site.py. -- Steven From ian.g.kelly at gmail.com Wed Feb 15 19:07:48 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 17:07:48 -0700 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster wrote: > Secondly, as a more general point I would welcome comments on code > quality, adherence to standards and so forth. The code is at: Looks pretty nice overall. To reduce repetition, I would have constructed the CONDITIONS list by iteration like you did the DECK list, something like: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] VULNERABILITIES = [ "Neither vulnerable", "North-South vulnerable", "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES] You could also eliminate some repetition in the deal method by putting the suit lists in a local dict: suits = {'S': self.spades, 'H': self.hearts, 'D': self.diamonds, 'C': self.clubs} for card in cards: suits[DECK[card][SUIT]].append(DECK[card][RANK]) Another comment I had at first was that instead of creating the pack list, which is just a list of indexes into DECK, you could shuffle and deal the DECK list directly. But then I realized that the indirection allows you to easily sort the cards in the desired order, so that should be left alone. Cheers, Ian From fetchinson at googlemail.com Wed Feb 15 19:18:07 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 01:18:07 +0100 Subject: format a measurement result and its error in "scientific" way Message-ID: Hi folks, often times in science one expresses a value (say 1.03789291) and its error (say 0.00089) in a short way by parentheses like so: 1.0379(9) One can vary things a bit, but let's take the simplest case when we only keep 1 digit of the error (and round it of course) and round the value correspondingly. I've been searching around for a simple function that would take 2 float arguments and would return a string but didn't find anything although something tells me it's been done a gazillion times. What would be the simplest such function? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From jugurtha.hadjar at gmail.com Wed Feb 15 19:34:57 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Thu, 16 Feb 2012 01:34:57 +0100 Subject: Beware, my computer was infected. Message-ID: <4F3C4F31.8020303@gmail.com> Hello gentlemen, I'm writing these words to give you a heads up. My computer has recently been infected with "1.exe", and I am doing what I can to contain it. It spreads via mail and I fear it will send SPAM to lists I am subscribed to. If you receive weird mails from my address, thank you to report it to me. I will not send you an executable, so if you receive one from me, please do not open it and it would be nice to report it. I will send an e-mail to this list once I think it is no longer in the system. Thank you all. -- ~Jugurtha Hadjar, From steve+comp.lang.python at pearwood.info Wed Feb 15 19:41:42 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Feb 2012 00:41:42 GMT Subject: Complexity question on Python 3 lists References: Message-ID: <4f3c50c6$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 19:20:21 +0100, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1) Your primes() function appears to be a variation on trial division, which is asymptotically O(n*sqrt(n)/(log n)**2). Regardless of the exact Big Oh behaviour, it is going to be SLOW for large values of n. The behaviour of append is the least of your concerns. -- Steven From python.list at tim.thechases.com Wed Feb 15 19:43:42 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 15 Feb 2012 18:43:42 -0600 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: <4F3C513E.7080201@tim.thechases.com> On 02/15/12 17:33, HoneyMonster wrote: > Firstly, is there anyone here who uses Python on a Mac and > would be prepared to test it? I have tested it on Linux and > Windows, but don't have access to a Mac. It works from my quick test of it on my Mac. The "class Player():" and the .format() calls choke on 2.4 (if perhaps for some reason you're running it on earlier versions), but otherwise, it should be good if you're running 2.7 everywhere. > Secondly, as a more general point I would welcome comments on > code quality, adherence to standards and so forth. The code is > at: All the .append()s seem a little unpythonic to me. I'd just set it up with CONDITIONS = [ [...], ... ] And since you're not modifying it, I'd even use tuples (or named tuples): CONDITIONS = ( ("Dealer North", "Neither vulnerable"), ... ) I'd also take advantage of iterable-unpacking to do something like the following in your Player.deal() method: for card in cards: suit, rank = DECK[card] { 'S': self.spades, 'D': self.diamonds, 'C': self.clubs, 'H': self.hearts, }[suit].append(rank) (that fixed dictionary might even be hoisted out for reuse elsewhere). Additionally, if you import this as a module rather than running it directly, there's no "north", "south", ... in your module namespace (they're only defined in the "if __name__ ..." section) so it will fail. There are some other structural decisions that I might reconsider too: - just shuffling the deck, rather than shuffling indexes into that deck - there seems to be a lot of redundancy in the drawing code, but I'm not sure how I'd reduce that - assigning to internal rank-named lists seems a little redundant to me. In my (non-bridge) card-playing history, and tinkering with small programs like this to simulate card-games, I usually just give a player the cards and then leave the sifting/sorting to the display algorithm - I see Ian's email came in as I was typing this and agree with his method of defining CONDITIONS with the caveat that it doesn't keep the same order as yours (I seem to recall bridge had some odd rules about that order) -tkc From someone at someplace.invalid Wed Feb 15 20:11:52 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 16 Feb 2012 01:11:52 +0000 (UTC) Subject: Wanted: Criticism of code for a Python module, plus a Mac tester References: Message-ID: On Wed, 15 Feb 2012 17:07:48 -0700, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster > wrote: >> Secondly, as a more general point I would welcome comments on code >> quality, adherence to standards and so forth. The code is at: > > Looks pretty nice overall. To reduce repetition, I would have > constructed the CONDITIONS list by iteration like you did the DECK list, > something like: > > DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] > VULNERABILITIES = [ > "Neither vulnerable", "North-South vulnerable", > "East-West vulnerable", "Both vulnerable", > ] > CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES] > > You could also eliminate some repetition in the deal method by putting > the suit lists in a local dict: > > suits = {'S': self.spades, 'H': self.hearts, > 'D': self.diamonds, 'C': self.clubs} > for card in cards: > suits[DECK[card][SUIT]].append(DECK[card][RANK]) > > Another comment I had at first was that instead of creating the pack > list, which is just a list of indexes into DECK, you could shuffle and > deal the DECK list directly. But then I realized that the indirection > allows you to easily sort the cards in the desired order, so that should > be left alone. Thank you very much indeed, Ian. Your second suggestion has opened my eyes; it had not even occurred to me that the "value" element of a dictionary entry could be a list. Just shows me how much I have to learn! Isn't Python great? As to your first suggestion though, I am having some difficulty. Note that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as CONDITIONS[0]. Is there a better way of doing it than a simple list.append()? Thanks again. From ian.g.kelly at gmail.com Wed Feb 15 20:56:30 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 18:56:30 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 5:18 PM, Daniel Fetchinson wrote: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) > > One can vary things a bit, but let's take the simplest case when we > only keep 1 digit of the error (and round it of course) and round the > value correspondingly. I've been searching around for a simple > function that would take 2 float arguments and would return a string > but didn't find anything although something tells me it's been done a > gazillion times. > > What would be the simplest such function? Well, this basically works: >>> def format_error(value, error): ... precision = int(math.floor(math.log(error, 10))) ... format = "%%.%df(%%d)" % max(-precision, 0) ... return format % (round(value, -precision), ... int(round(error / 10 ** precision))) ... >>> format_error(1.03789291, 0.00089) '1.0379(9)' Note that "math.floor(math.log(error, 10))" may return the wrong decimal precision due to binary floating point rounding error, which could produce some strange results: >>> format_error(10378929, 1000) '10378900(10)' So you'll probably want to use decimals instead: def format_error(value, error): value = decimal.Decimal(value) error = decimal.Decimal(error) value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) precision = value_scale - error_scale if error_scale > 0: format = "%%.%dE" % max(precision, 0) else: format = "%%.%dG" % (max(precision, 0) + 1) value_str = format % value.quantize(decimal.Decimal("10") ** error_scale) error_str = '(%d)' % error.scaleb(-error_scale).to_integral() if 'E' in value_str: index = value_str.index('E') return value_str[:index] + error_str + value_str[index:] else: return value_str + error_str >>> format_error(1.03789291, 0.00089) '1.0379(9)' >>> format_error(103789291, 1000) '1.03789(1)E+08' I haven't tested this thoroughly, so use at your own risk. :-) Cheers, Ian From debatem1 at gmail.com Wed Feb 15 21:19:15 2012 From: debatem1 at gmail.com (geremy condra) Date: Wed, 15 Feb 2012 18:19:15 -0800 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > First of all: I don't have any first hand experience of smartphones > but now that my trusted old GSM phone is getting old I decided I am > in for an up-grade. It struck me it might be nice to get something > for which I could write Python programs. > > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alterna- > tives? > > It struck me this must be the best place to ask. > > What else? I don't know if it matters but my home PC OS is Linux. > And I am not much of a Python programmer but I enjoy learning it > and I have reached a level that has turned out to be useful at work. Please note that while SL4A is a pretty good mobile python environment it doesn't support all of the Android API, which means it generally isn't an easy way to develop fully-fledged Android apps. Geremy Condra From dihedral88888 at googlemail.com Wed Feb 15 21:38:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 15 Feb 2012 18:38:52 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> ? 2012?2?16????UTC+8??10?19?15??geremy condra??? > On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > > First of all: I don't have any first hand experience of smartphones > > but now that my trusted old GSM phone is getting old I decided I am > > in for an up-grade. It struck me it might be nice to get something > > for which I could write Python programs. > > > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alterna- > > tives? > > > > It struck me this must be the best place to ask. > > > > What else? I don't know if it matters but my home PC OS is Linux. > > And I am not much of a Python programmer but I enjoy learning it > > and I have reached a level that has turned out to be useful at work. > > Please note that while SL4A is a pretty good mobile python environment > it doesn't support all of the Android API, which means it generally > isn't an easy way to develop fully-fledged Android apps. > > Geremy Condra In the 4 G space of SW AP in Adndroid phones, check Jython. But I think a better data compression modules is more helpful. Patterns about arithmetic compressions and LZW are expired, but not those in mp4 for the commercial use. Thus, the time to install a complete OS on a tablet or mobile phone with LTE on the way. We need smaller HD or flashes in these small devices. From dihedral88888 at googlemail.com Wed Feb 15 21:38:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 15 Feb 2012 18:38:52 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> ? 2012?2?16????UTC+8??10?19?15??geremy condra??? > On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > > First of all: I don't have any first hand experience of smartphones > > but now that my trusted old GSM phone is getting old I decided I am > > in for an up-grade. It struck me it might be nice to get something > > for which I could write Python programs. > > > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alterna- > > tives? > > > > It struck me this must be the best place to ask. > > > > What else? I don't know if it matters but my home PC OS is Linux. > > And I am not much of a Python programmer but I enjoy learning it > > and I have reached a level that has turned out to be useful at work. > > Please note that while SL4A is a pretty good mobile python environment > it doesn't support all of the Android API, which means it generally > isn't an easy way to develop fully-fledged Android apps. > > Geremy Condra In the 4 G space of SW AP in Adndroid phones, check Jython. But I think a better data compression modules is more helpful. Patterns about arithmetic compressions and LZW are expired, but not those in mp4 for the commercial use. Thus, the time to install a complete OS on a tablet or mobile phone with LTE on the way. We need smaller HD or flashes in these small devices. From torriem at gmail.com Wed Feb 15 22:26:46 2012 From: torriem at gmail.com (Michael Torrie) Date: Wed, 15 Feb 2012 20:26:46 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <4F3C7776.9060204@gmail.com> On 02/15/2012 07:38 PM, 88888 Dihedral wrote: > In the 4 G space of SW AP in Adndroid phones, > check Jython. But I think a better data compression > modules is more helpful. Jython, though a very cool and useful implementation, relies on the Java virtual machine to run. It does not yet run on Dalvik, nor is it clear that it ever will. The project to port jython to Dalvik, but it died and the authors said, just use Android scripting. lame. From solin.pavel at gmail.com Wed Feb 15 22:41:42 2012 From: solin.pavel at gmail.com (Pavel Solin) Date: Wed, 15 Feb 2012 19:41:42 -0800 Subject: Web browser Python programming in NCLab Message-ID: Hello, the NCLab development team would like to invite everybody to try out Python programming in the web browser at www.nclab.com. Using NCLab is free for personal, non-commercial purposes. If you'd like to give us feedback how we are doing, please use the mailing list nclab-user at googlegroups.com. We hope to hear from you! Best, Pavel -- Pavel Solin University of Nevada, Reno http://hpfem. org/~pavel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 16 00:03:44 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 22:03:44 -0700 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster wrote: > As to your first suggestion though, I am having some difficulty. Note > that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as > CONDITIONS[0]. > Is there a better way of doing it than a simple list.append()? Ah, it's more complicated than I realized. I believe this generates the correct result, although adding None to the dealers list is somewhat unsatisfactory: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West", None] VULNERABILITIES = [ "Neither vulnerable", "North-South vulnerable", "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d] I might be tempted to write a custom iterator for it, something like this: def rotating(iterable): cache = collections.deque() for value in iterable: yield value cache.append(value) while True: cache.rotate(-1) for value in cache: yield value # Using the original 4-length DEALERS list CONDITIONS = list(itertools.islice(itertools.izip(itertools.cycle(DEALERS), rotating(VULNERABILITIES)), 16)) But I don't know that it's really worth the added complexity. Cheers, Ian From arnodel at gmail.com Thu Feb 16 02:59:50 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 16 Feb 2012 07:59:50 +0000 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On 16 February 2012 05:03, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster wrote: >> As to your first suggestion though, I am having some difficulty. Note >> that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as >> CONDITIONS[0]. >> Is there a better way of doing it than a simple list.append()? > > Ah, it's more complicated than I realized. ?I believe this generates > the correct result, although adding None to the dealers list is > somewhat unsatisfactory: > > DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West", None] > VULNERABILITIES = [ > ? "Neither vulnerable", "North-South vulnerable", > ? "East-West vulnerable", "Both vulnerable", > ] > CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d] You could also do: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] VULNERABILITIES = [ ? "Neither vulnerable", "North-South vulnerable", ? "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [ (DEALERS[j], VULNERABILITIES[(i + j)%4]) for i in range(4) for j in range(4) ] If you don't care about the order in which the conditions are listed, you could use CONDITIONS = itertools.product(DEALERS, VULNERABILITIES) (But maybe you do, I haven't looked at the code) -- Arnaud From fetchinson at googlemail.com Thu Feb 16 03:36:20 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 09:36:20 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: >> Hi folks, often times in science one expresses a value (say >> 1.03789291) and its error (say 0.00089) in a short way by parentheses >> like so: 1.0379(9) >> >> One can vary things a bit, but let's take the simplest case when we >> only keep 1 digit of the error (and round it of course) and round the >> value correspondingly. I've been searching around for a simple >> function that would take 2 float arguments and would return a string >> but didn't find anything although something tells me it's been done a >> gazillion times. >> >> What would be the simplest such function? > > Well, this basically works: > >>>> def format_error(value, error): > ... precision = int(math.floor(math.log(error, 10))) > ... format = "%%.%df(%%d)" % max(-precision, 0) > ... return format % (round(value, -precision), > ... int(round(error / 10 ** precision))) > ... >>>> format_error(1.03789291, 0.00089) > '1.0379(9)' > > Note that "math.floor(math.log(error, 10))" may return the wrong > decimal precision due to binary floating point rounding error, which > could produce some strange results: > >>>> format_error(10378929, 1000) > '10378900(10)' > > So you'll probably want to use decimals instead: > > def format_error(value, error): > value = decimal.Decimal(value) > error = decimal.Decimal(error) > value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) > error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) > precision = value_scale - error_scale > if error_scale > 0: > format = "%%.%dE" % max(precision, 0) > else: > format = "%%.%dG" % (max(precision, 0) + 1) > value_str = format % value.quantize(decimal.Decimal("10") ** > error_scale) > error_str = '(%d)' % error.scaleb(-error_scale).to_integral() > if 'E' in value_str: > index = value_str.index('E') > return value_str[:index] + error_str + value_str[index:] > else: > return value_str + error_str > >>>> format_error(1.03789291, 0.00089) > '1.0379(9)' >>>> format_error(103789291, 1000) > '1.03789(1)E+08' > > I haven't tested this thoroughly, so use at your own risk. :-) Thanks a lot, this indeed mostly works, except for cases when the error needs to be rounded up and becomes two digits: >>> format_error( '1.34883', '0.0098' ) '1.349(10)' But in this case I'd like to see 1.35(1) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From ssmile03 at gmail.com Thu Feb 16 04:52:52 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 16 Feb 2012 15:22:52 +0530 Subject: Reading sub-string from a file Message-ID: All, I am a python newbie. Let's say I have a filename (test.conf) as below - ---- int Apple(int, int); void Jump_OnUnload(float, int); int Jockey_Apple_cat_1KK(float, int, char, int); int Jockey_Apple_cat_look(int, float, int, int); int Jockey_Apple_cat_test_ki21es(int, int, int, int); int Jockey_Apple_cat_tarLK12OU(void, int, int, int); --- Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a function name. I wish to extract ONLY that function name which has 'Jockey_Apple_cat' as a substring and ignore remaining function names. The program .py written is - ----- --- #!/usr/bin/python def foo(filename): try: one = open(filename, 'r') except: print filename, 'cannot be open.' AllLines = one.readline() for eachLine in AllLines: start = eachLine.find('Jockey_Apple_cat') if start != -1: finish = eachLine.find ('(') print eachLine[start:finish] handle.close() set_foo("test.conf") ----- I did perform debugging using pdb, it only reads all the lines. Plz help!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Feb 16 05:24:49 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 16 Feb 2012 02:24:49 -0800 Subject: Reading sub-string from a file In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 1:52 AM, Smiley 4321 wrote: > All, > > I am a python newbie. > > Let's say I have a filename (test.conf) as below - > > ---- > int Apple(int, int); > void Jump_OnUnload(float, int); > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. > > The program .py written is - > > ----- > --- > #!/usr/bin/python > > def foo(filename): > ??????? try: > ??????????????? one = open(filename, 'r') > ??????? except: > ??????????????? print filename, 'cannot be open.' > > ??????? AllLines = one.readline() > > ??????? for eachLine in AllLines: > ??????????????? start = eachLine.find('Jockey_Apple_cat') > ??????????????? if start != -1: > ??????????????????????? finish = eachLine.find ('(') > ??????????????????????? print eachLine[start:finish] > > ??????? handle.close() > > set_foo("test.conf") > ----- > > I did perform debugging using pdb, it only reads all the lines. > > Plz help!! Several oddities in the code you posted (e.g. you defined foo() but instead call set_foo(); the `handle` variable comes out of nowhere) suggest that it isn't your actual code; this greatly hinders us in assisting you. Please post your /actual/ code verbatim (or as much of it as you can with as few modifications as you can). Also, avoid using "plz" in the future; it's gotten a reputation for being associated with undesirable folk. Cheers, Chris From __peter__ at web.de Thu Feb 16 05:25:49 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 16 Feb 2012 11:25:49 +0100 Subject: Reading sub-string from a file References: Message-ID: Smiley 4321 wrote: > I am a python newbie. Welcome! > Let's say I have a filename (test.conf) as below - > > ---- > int Apple(int, int); > void Jump_OnUnload(float, int); > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. > > The program .py written is - > > ----- > --- > #!/usr/bin/python > > def foo(filename): > try: > one = open(filename, 'r') > except: > print filename, 'cannot be open.' > > AllLines = one.readline() > > for eachLine in AllLines: > start = eachLine.find('Jockey_Apple_cat') > if start != -1: > finish = eachLine.find ('(') > print eachLine[start:finish] > > handle.close() > > set_foo("test.conf") > ----- > > I did perform debugging using pdb, it only reads all the lines. There are errors in the above that suggest that you retyped your actual code. Don't do that! Always use cut and paste for code snippets you are posting here. As to what the problem in your actual code might be, here's a hint: You could be iterating over the characters of the first line of the file instead of the lines. Change > AllLines = one.readline() > > for eachLine in AllLines: to for eachLine in one: to fix that. From rosuav at gmail.com Thu Feb 16 05:32:10 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Feb 2012 21:32:10 +1100 Subject: Reading sub-string from a file In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 8:52 PM, Smiley 4321 wrote: > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. Try this: grep -o 'Jockey_Apple_cat[^(]*' test.conf It's not Python, but it might serve you better than knocking something together! But if you're using this to learn Python, Peter Otten's solution is, I think, what you want. ChrisA From austinbaiy at gmail.com Thu Feb 16 07:33:40 2012 From: austinbaiy at gmail.com (austinbaiy) Date: Thu, 16 Feb 2012 04:33:40 -0800 (PST) Subject: Web Design Company Florida Message-ID: Searching for Best Web Design, Development or Affordable SEO Service in USA? Bestwebsol.com provides professional full-cycle services: web development, custom web design & Best SEO services with guaranteed traffic increase and higher ranking. http://www.bestwebsol.com From rantingrickjohnson at gmail.com Thu Feb 16 09:43:16 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Feb 2012 06:43:16 -0800 (PST) Subject: Is this the right list? References: Message-ID: On Feb 15, 4:04?pm, Terry Reedy wrote: > On 2/15/2012 4:51 PM, Alan McKay wrote: > > > Is this the right list? This is neither the "right" or "left" list, however, it may be either the correct or incorrect depending on your question. From dihedral88888 at googlemail.com Thu Feb 16 09:53:08 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 06:53:08 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms easily. Then I personally prefer python. From dihedral88888 at googlemail.com Thu Feb 16 09:53:08 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 06:53:08 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms easily. Then I personally prefer python. From alan.mckay+python at gmail.com Thu Feb 16 10:16:47 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Thu, 16 Feb 2012 10:16:47 -0500 Subject: Python / Apache config issue Message-ID: OK, since you all said to send it, here it is :-) Though I think it may be an apache issue, I'll send it anyway. I'm using the software called "Open Freezer" which is used to track reagents and other chemicals in research labs. I also posted this here on their discussion forums but have not heard anything yet. In general their install and config instructions are pretty incomplete and even asking the authors direct questions sometimes does not get very good answers https://sourceforge.net/p/openfreezer/discussion/openfreezer/thread/789d5cdb/ It was working fine on Ubuntu 11.04 and RHEL 5.7 but I'm having issues on Ubuntu 11.11 - in all cases the versions of python that come with the respective OS In the working version on Ubuntu 11.04 the entire apache instance was dedicated to this app - something I cannot do on the RHEL and Ubuntu 11.11 machines ---snip--- The specific problem I am having is that I go to "Search Projects", and then select a project and hit "Go", and it does not execute the python. In one configuration, it downloads the .py script instead of executing it. In the other configuration it tells me 404 cannot find it. I had this working fine on RHEL 5.7 but now it is broken on Ubuntu (with the same config file) Details below. I had the basic CGI functions working fine on RHEL but had to move to the latest version of Ubuntu server and am having trouble. One different aspect of both my RHEL and Ubuntu setups is that I cannot dedicate the entire Apache instance to Open Freezer, so my URL is not http://MYIP/ it is http://MYIP/openfreezer/ . On RHEL my openfreezer.conf file looks like this. Note there is no VirtualHost because as mentioned I cannot dedicate this apache instance to just open freezer, and I also do not have control over DNS so I cannot assign a 2nd DNS name to this server. Alias "/openfreezer" "/var/www/OpenFreezer" Alias "/openfreezercgi" "/var/www/OpenFreezer/cgi" Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all #AddHandler python26-mod_python .py #AddHandler mod_python .py PythonDebug On #PythonHandler mod_python.publisher AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all AddHandler mod_python .py #PythonDebug On PythonHandler mod_python.cgihandler PythonPath "['/var/www/OpenFreezer/cgi'] + sys.path" This works fine on RHEL 5.7 with apache 2.2.3 . I select a project, hit "Go" and it executes cgi/project_request_handler.py as it should. But with the exact same config file on Ubuntu it instead tries to download the .py instead of execute it. But I also try putting a couple of test programs in my CGI directory. This first one tries to download as well with the above config : test.py def index(req): return "Test successful"; But this second one executes correctly : testcgi.py #!/usr/bin/python print "Content-type: text/html" print print "" print " Hello!" print "" So I talk to the other guy here who started out working on this for us, because he had it running on Ubuntu as well (a slightly older version - 11.04 versus my 11.11). He has apache 2.2.16 and I have 2.2.20 His config file looks like this - note that he does have the entire apache server dedicated to Open Freezer so his URL is http://HISIP/ ServerAdmin webmaster at localhost ServerName localhost DocumentRoot /var/www/OpenFreezer/ Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all AddHandler mod_python .py PythonDebug On #PythonHandler mod_python.publisher AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all #AddHandler mod_python .py #PythonDebug On #PythonHandler mod_python.cgihandler # # # ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.1/255.0.0.0 ::1/128 If I strip out the two Directory sections from that and make mine look the same, then instead of trying to download the .py file what I get is this error : Not Found The requested URL /openfreezer/cgi/project_request_handler.py was not found on this server and checking the apache error.log that is of course a 404 But that file definitely exists at that location - no question about it. And interestingly, now my test programs have the opposite reaction. test.py works under this config, but testcgi.py gives me the 404 So I'm just stumped at this point. I've googled everywhere loooking for help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From torriem at gmail.com Thu Feb 16 10:22:44 2012 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Feb 2012 08:22:44 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <4F3D1F44.2040403@gmail.com> On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > The law suites of JAVA Vitrtual Machine from Oracle > are famous now. But in 201X the JVM patents will be > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > easily. Umm what does this have to do with anything? You claimed Jython is or will be available on Android. It's not and Jython isn't being ported to Dalvik and it has nothing to do with patents. Android might use java a language, but the virtual machines are very different. And no expired patents are going to change that fact. Android simply isn't going to run the JVM anytime soon. From benjamin.kaplan at case.edu Thu Feb 16 10:30:36 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 16 Feb 2012 10:30:36 -0500 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <4F3D1F44.2040403@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <4F3D1F44.2040403@gmail.com> Message-ID: On Feb 16, 2012 10:25 AM, "Michael Torrie" wrote: > > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. > -- I believe the general consensus is that 88888 is a bot. it makes lots of posts that mention key words from the thread its replying to but don't actually mean anything. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Feb 16 10:33:24 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Feb 2012 02:33:24 +1100 Subject: Is this the right list? In-Reply-To: References: Message-ID: On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: > On Feb 15, 4:04?pm, Terry Reedy wrote: >> On 2/15/2012 4:51 PM, Alan McKay wrote: >> >> > Is this the right list? > > This is neither the "right" or "left" list, however, it may be either > the correct or incorrect depending on your question. There's also no "right" or "responsibility" list, but we'll answer user questions here as much as we can anyway. ChrisA From fuzzyman at gmail.com Thu Feb 16 10:35:56 2012 From: fuzzyman at gmail.com (Fuzzyman) Date: Thu, 16 Feb 2012 07:35:56 -0800 (PST) Subject: ANN: mock 0.8 final released Message-ID: <92d2a5e3-981a-4e32-850a-ef4a76bb3e1d@bs8g2000vbb.googlegroups.com> After more than six months development work mock 0.8 has been released. 0.8 is a big release with many new features, general improvements and bugfixes. You can download mock 0.8.0 final from the PyPI page or install it with: pip install -U mock mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects. http://pypi.python.org/pypi/mock http://www.voidspace.org.uk/python/mock/ http://www.voidspace.org.uk/python/mock/changelog.html#version-0-8-0 The only changes in mock 0.8.0 final since 0.8rc2 are: * Improved repr of `sentinel` objects * `ANY` can be used for comparisons against call objects * The return value of `MagicMock.__iter__` can be set to any iterable and isn't required to be an iterator A longer version of this announcement, including the full changelog since mock 0.7 and a couple of short examples of the most important changes, can be found on my blog: http://www.voidspace.org.uk/python/weblog/arch_d7_2012_02_11.shtml#e1234 Michael Foord From bahamutzero8825 at gmail.com Thu Feb 16 10:57:32 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 16 Feb 2012 09:57:32 -0600 Subject: Is this the right list? In-Reply-To: References: Message-ID: <4F3D276C.9010204@gmail.com> On 2/16/2012 9:33 AM, Chris Angelico wrote: > On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson > wrote: >> On Feb 15, 4:04 pm, Terry Reedy wrote: >>> On 2/15/2012 4:51 PM, Alan McKay wrote: >>> >>> > Is this the right list? >> >> This is neither the "right" or "left" list, however, it may be either >> the correct or incorrect depending on your question. > > There's also no "right" or "responsibility" list, but we'll answer > user questions here as much as we can anyway. Do we have "right" and "privilege" lists? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From ethan at stoneleaf.us Thu Feb 16 11:16:06 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Feb 2012 08:16:06 -0800 Subject: Is this the right list? In-Reply-To: References: Message-ID: <4F3D2BC6.2090307@stoneleaf.us> > On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: >>> On 2/15/2012 4:51 PM, Alan McKay wrote: >>>> Is this the right list? >> >> This is neither the "right" or "left" list, however, it may be either >> the correct or incorrect depending on your question. Alan, Welcome to the list. There are lots of friendly folks here who will try to help. Unfortunately there are also a couple well-known trolls, one of whom is Rick Johnson (aka Ranting Rick). Please do not take his posts as representative of the community. ~Ethan~ From alan.mckay+python at gmail.com Thu Feb 16 11:29:03 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Thu, 16 Feb 2012 11:29:03 -0500 Subject: Is this the right list? In-Reply-To: <4F3D2BC6.2090307@stoneleaf.us> References: <4F3D2BC6.2090307@stoneleaf.us> Message-ID: > > Welcome to the list. There are lots of friendly folks here who will try > to help. > > I noticed that already - thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcepl at redhat.com Thu Feb 16 12:17:13 2012 From: mcepl at redhat.com (Matej Cepl) Date: Thu, 16 Feb 2012 18:17:13 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: On 15.2.2012 18:48, Tim Arnold wrote: > Just a note to encourage you to stick with XSLT. I also use lxml for > creating and postprocessing my DocBook documents and it is great. But I > use the DocBook XSL stylesheets to convert to html; if you're like me, > you got discouraged at the strangeness of the XSLT language. No, the strangness is not that bad (well, it is bad ... almost anything feels bad comparing to Python, to be honest, but not the reason I would give up; after all I spent couple of years with Javascript). The terrible debugging is one thing, and even worse, I just still cannot get over rules around spaces: whitespace just jumps at me randomly in random places and is erased in others. Mat?j From emayssat at gmail.com Thu Feb 16 12:19:11 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Thu, 16 Feb 2012 09:19:11 -0800 Subject: list of properties Message-ID: Hello, Is there a way to list 'properties' ? from PyQt4.QtCore import * class LObject(QObject): def __init__(self, parent=None): super(LObject, self).__init__(parent) self.arg1 = 'toto' def getArg2(self): return self.arg1 + " <--" arg2 = property(getArg2) l = LObject() print l.__dict__ returns only arg1 How can I find that arg2 is a 'virtual' attribute (i.e. property)? Regards, -- E -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 16 12:34:18 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 16 Feb 2012 10:34:18 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson wrote: >>> Hi folks, often times in science one expresses a value (say >>> 1.03789291) and its error (say 0.00089) in a short way by parentheses >>> like so: 1.0379(9) >>> >>> One can vary things a bit, but let's take the simplest case when we >>> only keep 1 digit of the error (and round it of course) and round the >>> value correspondingly. I've been searching around for a simple >>> function that would take 2 float arguments and would return a string >>> but didn't find anything although something tells me it's been done a >>> gazillion times. >>> >>> What would be the simplest such function? >> >> Well, this basically works: >> >>>>> def format_error(value, error): >> ... ? ? precision = int(math.floor(math.log(error, 10))) >> ... ? ? format = "%%.%df(%%d)" % max(-precision, 0) >> ... ? ? return format % (round(value, -precision), >> ... ? ? ? ? ? ? ? ? ? ? ?int(round(error / 10 ** precision))) >> ... >>>>> format_error(1.03789291, 0.00089) >> '1.0379(9)' >> >> Note that "math.floor(math.log(error, 10))" may return the wrong >> decimal precision due to binary floating point rounding error, which >> could produce some strange results: >> >>>>> format_error(10378929, 1000) >> '10378900(10)' >> >> So you'll probably want to use decimals instead: >> >> def format_error(value, error): >> ? ? value = decimal.Decimal(value) >> ? ? error = decimal.Decimal(error) >> ? ? value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) >> ? ? error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) >> ? ? precision = value_scale - error_scale >> ? ? if error_scale > 0: >> ? ? ? ? format = "%%.%dE" % max(precision, 0) >> ? ? else: >> ? ? ? ? format = "%%.%dG" % (max(precision, 0) + 1) >> ? ? value_str = format % value.quantize(decimal.Decimal("10") ** >> error_scale) >> ? ? error_str = '(%d)' % error.scaleb(-error_scale).to_integral() >> ? ? if 'E' in value_str: >> ? ? ? ? index = value_str.index('E') >> ? ? ? ? return value_str[:index] + error_str + value_str[index:] >> ? ? else: >> ? ? ? ? return value_str + error_str >> >>>>> format_error(1.03789291, 0.00089) >> '1.0379(9)' >>>>> format_error(103789291, 1000) >> '1.03789(1)E+08' >> >> I haven't tested this thoroughly, so use at your own risk. :-) > > Thanks a lot, this indeed mostly works, except for cases when the > error needs to be rounded up and becomes two digits: > >>>> format_error( '1.34883', '0.0098' ) > '1.349(10)' > > But in this case I'd like to see 1.35(1) A small adjustment to the scale fixes that. Also tidied up the string formatting part: import decimal def format_error(value, error): value = decimal.Decimal(value) error = decimal.Decimal(error) error_scale = error.adjusted() error_scale += error.scaleb(-error_scale).to_integral().adjusted() value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale))) error_str = '(%d)' % error.scaleb(-error_scale).to_integral() if 'E' in value_str: index = value_str.index('E') return value_str[:index] + error_str + value_str[index:] else: return value_str + error_str Cheers, Ian From invalid at invalid.invalid Thu Feb 16 12:38:17 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 16 Feb 2012 17:38:17 +0000 (UTC) Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 2012-02-16, Michael Torrie wrote: > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. I got curious about Dalvik, and was looking at the Wikipedia page, where it says that programs for Android are compiled into bytecode in JVM compatible .class files. Those files are then converted into .dex files to run on Davlik. I don't know much at all about Jython, but if it generates JVM byte code, mightn't the same conversion to .dex be applicable? -- Grant Edwards grant.b.edwards Yow! What I want to find at out is -- do parrots know gmail.com much about Astro-Turf? From invalid at invalid.invalid Thu Feb 16 12:50:11 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 16 Feb 2012 17:50:11 +0000 (UTC) Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 2012-02-16, Grant Edwards wrote: > On 2012-02-16, Michael Torrie wrote: > >> You claimed Jython is or will be available on Android. It's not and >> Jython isn't being ported to Dalvik and it has nothing to do with >> patents. Android might use java a language, but the virtual machines >> are very different. And no expired patents are going to change that >> fact. Android simply isn't going to run the JVM anytime soon. > > I got curious about Dalvik, and was looking at the Wikipedia page, > where it says that programs for Android are compiled into bytecode in > JVM compatible .class files. Those files are then converted into > .dex files to run on Davlik. > > I don't know much at all about Jython, but if it generates JVM byte > code, mightn't the same conversion to .dex be applicable? Apparently there was a project to do just that: http://code.google.com/p/jythonroid/ But it's been abandonded in favor of SL4A, which offers a PythonForAndroid_r4.apk download. There's a book about Python on Android via SL4A called _Pro_Android_Python_with_SL4A_. http://www.apress.com/9781430235699 Interesting... -- Grant Edwards grant.b.edwards Yow! World War III? at No thanks! gmail.com From emile at fenx.com Thu Feb 16 13:02:38 2012 From: emile at fenx.com (Emile van Sebille) Date: Thu, 16 Feb 2012 10:02:38 -0800 Subject: list of properties In-Reply-To: References: Message-ID: On 2/16/2012 9:19 AM Emmanuel Mayssat said... > Hello, > > Is there a way to list 'properties' ? dir(thingy) > > > from PyQt4.QtCore import * > > class LObject(QObject): > def __init__(self, parent=None): > super(LObject, self).__init__(parent) > self.arg1 = 'toto' > > def getArg2(self): > return self.arg1 + " <--" > arg2 = property(getArg2) > > l = LObject() > print l.__dict__ > > returns only arg1 arg2 is defined at the class level and not the instance level. l.__dict__ returned the instance attributes. Look in LObject.__dict__ for arg2. Emile > > > How can I find that arg2 is a 'virtual' attribute (i.e. property)? > > Regards, > -- > E > > From silentquote at gmail.com Thu Feb 16 15:11:52 2012 From: silentquote at gmail.com (Sherif Shehab Aldin) Date: Thu, 16 Feb 2012 22:11:52 +0200 Subject: python file synchronization In-Reply-To: <20120208095936.GA31545@cskk.homeip.net> References: <20120208095936.GA31545@cskk.homeip.net> Message-ID: Hi Cameron, First sorry for my very very late reply, has been overloaded at work last week :( Anyways... I will reply inline this time ;) On Wed, Feb 8, 2012 at 11:59 AM, Cameron Simpson wrote: > [ Please reply inline; it makes the discussion read like a converation, > with context. - Cameron > ] > > On 08Feb2012 08:57, Sherif Shehab Aldin wrote: > | Thanks a lot for your help, I just forgot to state that the FTP server is > | not under my command, I can't control how the file grow, or how the > records > | are added, I can only login to It, copy the whole file. > > Oh. That's a pity. > > | The reason why I am parsing the file and trying to get the diffs between > | the new file and the old one, and copy it to new_file.time_stamp is that > I > | need to cut down the file size so when server (C) grabs the file, It > grabs > | only new data, also to cut down the network bandwidth. > > Can a simple byte count help here? Copy the whole file with FTP. From > the new copy, extract the bytes from the last byte count offset onward. > Then parse the smaller file, extracting whole records for use by (C). > That way you can just keep the unparsed tail (partial record I imagine) > around for the next fetch. > > Looking at RFC959 (the FTP protocol): > > http://www.w3.org/Protocols/rfc959/4_FileTransfer.html > > it looks like you can do a partial file fetch, also, by issuing a REST > (restart) command to set a file offset and then issuing a RETR (retrieve) > command to get the rest of the file. These all need to be in binary mode > of course. > > So in principle you could track the byte offset of what you have fetched > with FTP so far, and fetch only what is new. > I am actually grabbing the file from ftp with a bash script using lftp, It seemed a simple task for python at the beginning and then I noticed the many problems. I have checked lftp and did not know how to continue downloading a file. Do I have to use ftp library, may be in python so I can use that feature? > > | One of my problems was after mounting server (B) diffs_dir into Server > (A) > | throw NFS, I used to create filename.lock first into server (B) local > file > | then start copy filename to server (B) then remove filename.lock, so when > | the daemon running on server (C) parses the files in the local_diffs dir, > | ignores the files that are still being copied, > | > | After searching more yesterday, I found that local mv is atomic, so > instead > | of creating the lock files, I will copy the new diffs to tmp dir, and > after > | the copy is over, mv it to actual diffs dir, that will avoid reading It > | while It's still being copied. > > Yes, this sounds good. Provided the mv is on the same filesystem. > > For example: "mv /tmp/foo /home/username/foo" is actually a copy and not > a rename because /tmp is normally a different filesystem from /home. > > Yes they are in same file system, I am making sure of that ;) > | Sorry if the above is bit confusing, the system is bit complex. > > Complex systems often need fiddly solutions. > > | Also there is one more factor that confuses me, I am so bad in testing, > and > | I am trying to start actually implement unit testing to test my code, > what > | I find hard is how to test code like the one that do the copy, mv and so, > | also the code that fetch data from the web. > > Ha. I used to be very bad at testing, now I am improving and am merely > weak. > > One approach to testing is to make a mock up of the other half of the > system, and test against the mockup. > > For example, you have code to FTP new data and then feed it to (C). You > don't control the server side of the FTP. So you might make a small mock > up program that writes valid (but fictitious) data records progressively > to a local data file (write record, flush, pause briefly, etc). If you > can FTP to your own test machine you could then treat _that_ growing > file as the remote server's data file. > > Then you could copy it progressively using a byte count to keep track of > the bits you have seen to skip them, and the the > > If you can't FTP to your test system, you could abstract out the "fetch > part of this file by FTP" into its own function. Write an equivalent > function that fetches part of a local file just by opening it. > > Then you could use the local file version in a test that doesn't > actually do the FTP, but could exercise the rest of it. > > It is also useful to make simple tests of small pieces of the code. > So make the code to get part of the data a simple function, and write > tests to execute it in a few ways (no new data, part of a record, > several records etc). > > You are right, my problem is that I don't care about testing until my code grows badly and then I notice what I got myself into :) But ur suggestion is cool. I will try to implement that once I get back to that project again... As I got some problems with another project currently so I had to go fix them first.. and then the customer wanted some changes.. ;-) There are many people better than I to teach testing. > > I really appreciate your help. I am trying to learn from the mailing list, I noticed many interesting posts in the list already. I wish I could read the python-list same way.. but unfortunately the mail digest they send is quiet annoying :( Many thanks to you, and I will keep you posted if I got other ideas. :) > Cheers, > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Testing can show the presence of bugs, but not their absence. - Dijkstra > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ramit.prasad at jpmorgan.com Thu Feb 16 16:06:27 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Thu, 16 Feb 2012 21:06:27 +0000 Subject: Python to Combine Multiple Excel Worksheets into One Worksheet In-Reply-To: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> References: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF4741501E8@SCACMX008.exchad.jpmchase.net> >I have one single Excel file with many separate worksheets, and for work I need to combine all these separate worksheets into one single worksheet (I am not worried about formatting, as the format is the same in each sheet, nor am I worried about Excel's row limit). >Essentially, I am looking for a way to append the data in one sheet to the bottom of the sheet that proceeds it. >What would be the best way to do this, and how would I go about doing it? Can it be done simply with the xlwt, xlrd, and xutils modules, or (as I was thinking) do I need to convert the sheets to separate csv files, then append the separate csv files, and then write the completed file back into .xls format? >Or perhaps something else? >As I am really only a Python beginner, any and all help is very much appreciated. Thank you in advance!! Read the data from the different worksheets using xlrd and then use xlwt to write to a single worksheet in a new excel file. The csv option is probably not useful since it will just add an intermediary step unless you are converting outside of python (i.e. manually). Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Thu Feb 16 16:10:42 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Thu, 16 Feb 2012 21:10:42 +0000 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> Message-ID: <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> >> When you reply to a known bot, please include some indication of the >> fact, so we know your message can be ignored as well. >Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. I was wondering the exact same thing. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From arnodel at gmail.com Thu Feb 16 16:51:27 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 16 Feb 2012 21:51:27 +0000 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> Message-ID: On 16 February 2012 21:10, Prasad, Ramit wrote: >>> When you reply to a known bot, please include some indication of the >>> fact, so we know your message can be ignored as well. > >>Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its > posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. > > I was wondering the exact same thing. I think it may be that what you are underestimating is your ability, as a human being, to create meaning where there is none. -- Arnaud From fetchinson at googlemail.com Thu Feb 16 17:21:50 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 23:21:50 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On 2/16/12, Ian Kelly wrote: > On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson > wrote: >>>> Hi folks, often times in science one expresses a value (say >>>> 1.03789291) and its error (say 0.00089) in a short way by parentheses >>>> like so: 1.0379(9) >>>> >>>> One can vary things a bit, but let's take the simplest case when we >>>> only keep 1 digit of the error (and round it of course) and round the >>>> value correspondingly. I've been searching around for a simple >>>> function that would take 2 float arguments and would return a string >>>> but didn't find anything although something tells me it's been done a >>>> gazillion times. >>>> >>>> What would be the simplest such function? >>> >>> Well, this basically works: >>> >>>>>> def format_error(value, error): >>> ... precision = int(math.floor(math.log(error, 10))) >>> ... format = "%%.%df(%%d)" % max(-precision, 0) >>> ... return format % (round(value, -precision), >>> ... int(round(error / 10 ** precision))) >>> ... >>>>>> format_error(1.03789291, 0.00089) >>> '1.0379(9)' >>> >>> Note that "math.floor(math.log(error, 10))" may return the wrong >>> decimal precision due to binary floating point rounding error, which >>> could produce some strange results: >>> >>>>>> format_error(10378929, 1000) >>> '10378900(10)' >>> >>> So you'll probably want to use decimals instead: >>> >>> def format_error(value, error): >>> value = decimal.Decimal(value) >>> error = decimal.Decimal(error) >>> value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) >>> error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) >>> precision = value_scale - error_scale >>> if error_scale > 0: >>> format = "%%.%dE" % max(precision, 0) >>> else: >>> format = "%%.%dG" % (max(precision, 0) + 1) >>> value_str = format % value.quantize(decimal.Decimal("10") ** >>> error_scale) >>> error_str = '(%d)' % error.scaleb(-error_scale).to_integral() >>> if 'E' in value_str: >>> index = value_str.index('E') >>> return value_str[:index] + error_str + value_str[index:] >>> else: >>> return value_str + error_str >>> >>>>>> format_error(1.03789291, 0.00089) >>> '1.0379(9)' >>>>>> format_error(103789291, 1000) >>> '1.03789(1)E+08' >>> >>> I haven't tested this thoroughly, so use at your own risk. :-) >> >> Thanks a lot, this indeed mostly works, except for cases when the >> error needs to be rounded up and becomes two digits: >> >>>>> format_error( '1.34883', '0.0098' ) >> '1.349(10)' >> >> But in this case I'd like to see 1.35(1) > > A small adjustment to the scale fixes that. Also tidied up the string > formatting part: > > import decimal > > def format_error(value, error): > value = decimal.Decimal(value) > error = decimal.Decimal(error) > error_scale = error.adjusted() > error_scale += error.scaleb(-error_scale).to_integral().adjusted() > value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale))) > error_str = '(%d)' % error.scaleb(-error_scale).to_integral() > if 'E' in value_str: > index = value_str.index('E') > return value_str[:index] + error_str + value_str[index:] > else: > return value_str + error_str > > Cheers, > Ian Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08: Traceback (most recent call last): File "/home/fetchinson/bin/format_error", line 26, in print format_error( sys.argv[1], sys.argv[2] ) File "/home/fetchinson/bin/format_error", line 9, in format_error error_scale += error.scaleb( -error_scale ).to_integral( ).adjusted( ) File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb ans = self._check_nans(other, context) File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans other_is_nan = other._isnan() AttributeError: 'int' object has no attribute '_isnan' Which version of python are you using? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From emekamicro at gmail.com Thu Feb 16 18:10:28 2012 From: emekamicro at gmail.com (Emeka) Date: Fri, 17 Feb 2012 01:10:28 +0200 Subject: Undoing character read from file Message-ID: Hello All, I know about seek and tell while using readline. What about if I am using read, and I want to undo the last character I just read(to return it back to the stream). How do I achieve this? Regards, \Emeka *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Thu Feb 16 18:31:54 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 16 Feb 2012 23:31:54 +0000 Subject: Undoing character read from file In-Reply-To: References: Message-ID: <4F3D91EA.40601@mrabarnett.plus.com> On 16/02/2012 23:10, Emeka wrote: > Hello All, > > I know about seek and tell while using readline. What about if I am > using read, and I want to undo the last character I just read(to return > it back to the stream). How do I achieve this? > Try: f.seek(-1, 1) It seeks -1 relative to the current position (the second argument defaults to 0 for relative to start of file). From ian.g.kelly at gmail.com Thu Feb 16 19:29:27 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 16 Feb 2012 17:29:27 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 3:21 PM, Daniel Fetchinson wrote: > Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08: > > Traceback (most recent call last): > ?File "/home/fetchinson/bin/format_error", line 26, in > ? ?print format_error( sys.argv[1], sys.argv[2] ) > ?File "/home/fetchinson/bin/format_error", line 9, in format_error > ? ?error_scale += error.scaleb( -error_scale ).to_integral( ?).adjusted( ?) > ?File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb > ? ?ans = self._check_nans(other, context) > ?File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans > ? ?other_is_nan = other._isnan() > AttributeError: 'int' object has no attribute '_isnan' > > Which version of python are you using? 2.7.1. At a guess, it's failing because scaleb() (which was new in 2.6) is buggily expecting a decimal argument, but adjusted() returns an int. Convert the results of the two adjusted() calls to decimals, and I think it should be fine. From cs at zip.com.au Thu Feb 16 19:33:24 2012 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 17 Feb 2012 11:33:24 +1100 Subject: python file synchronization In-Reply-To: References: Message-ID: <20120217003324.GA15685@cskk.homeip.net> On 16Feb2012 22:11, Sherif Shehab Aldin wrote: | First sorry for my very very late reply, has been overloaded at work last | week :( Me too. There's no hurry at my end, take your time. [...] | > Can a simple byte count help here? Copy the whole file with FTP. From | > the new copy, extract the bytes from the last byte count offset onward. | > Then parse the smaller file, extracting whole records for use by (C). | > That way you can just keep the unparsed tail (partial record I imagine) | > around for the next fetch. | > | > Looking at RFC959 (the FTP protocol): | > | > http://www.w3.org/Protocols/rfc959/4_FileTransfer.html | > | > it looks like you can do a partial file fetch, also, by issuing a REST | > (restart) command to set a file offset and then issuing a RETR (retrieve) | > command to get the rest of the file. These all need to be in binary mode | > of course. | > | > So in principle you could track the byte offset of what you have fetched | > with FTP so far, and fetch only what is new. | | I am actually grabbing the file from ftp with a bash script using lftp, It | seemed a simple task for python at the beginning and then I noticed the | many problems. I have checked lftp and did not know how to continue | downloading a file. Do I have to use ftp library, may be in python so I can | use that feature? Looking at "man lftp" I see that the "get" command has a "-c" option (for "continue"). That probably does it for you. Should be easy to test: - make big file on FTP server - fetch with lftp (interactively - this is all just to check) - append a little data to the file on the server date >> the-big-file - refetch: get -c the-big-file and see how much data gets copied. Hopefully just the new bytes. [...] | > | After searching more yesterday, I found that local mv is atomic, so | > instead | > | of creating the lock files, I will copy the new diffs to tmp dir, and | > after | > | the copy is over, mv it to actual diffs dir, that will avoid reading It | > | while It's still being copied. | > | > Yes, this sounds good. Provided the mv is on the same filesystem. [...] | > Yes they are in same file system, I am making sure of that ;) Good. BTW, when replying inline try to make sure your new text has clean blank lines above and below and has not kept the indentation quote markers. See above that your "Yes they are in same file system" seems to be at the same indentation as my earlier sentence above? That made your reply look like part of the quote instead of a reply, and I nearly missed it. [...] | > It is also useful to make simple tests of small pieces of the code. | > So make the code to get part of the data a simple function, and write | > tests to execute it in a few ways (no new data, part of a record, | > several records etc). | > | > You are right, my problem is that I don't care about testing until my code | grows badly and then I notice what I got myself into :) (Again, see the quoting level?) One approach to get into testing slowly is to make a test for your bug. Suppose something is not working. Write a small function that exhibits the bug, as small as possible. That is now a test function! When you fix the bug, the test function will pass. Keep it around! Some projects have tests for every bug report that gets fixed. Another approach to growing a test suite is to write out a good docstring for somthing, describing with precision what the function arranges i.e. not the internal mechanisms, but what the caller can rely on being true after the function has been called. Then write a test function that calls the main function and then checks each thing the docstring says should be true. Each check is a test. Trite example: def double(x): ''' Return double the value of `x`. The return value will be twice `x`. The return value will be even. ''' return x * 2 class Tests(unitest.TestCase): def test_double(self): for x in 0, 3, 17, 100: # test a few different values x2 = double(x) self.assertEqual(x2, x + x) # test doubling self.assertEqual(x2 % 2, 0) # test evenness You can see that writing out the guarentees in the docstring assists in writing some tests. | > I really appreciate your help. I am trying to learn from the mailing list, | I noticed many interesting posts in the list already. I wish I could read | the python-list same way.. but unfortunately the mail digest they send is | quiet annoying :( I do not use digests - I have my subscription set to individual emails. Just arrange that your mailer files then in a "python" mail folder when they arrive so they do not clutter your inbox. | Many thanks to you, and I will keep you posted if I got other ideas. :) Excellent. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Q: How does a hacker fix a function which doesn't work for all of the elements in its domain? A: He changes the domain. From stodge at gmail.com Thu Feb 16 20:15:59 2012 From: stodge at gmail.com (Stodge) Date: Thu, 16 Feb 2012 17:15:59 -0800 (PST) Subject: Generating class definitions at runtime in memory from XSD or JSON Message-ID: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Does anyone know of a library to generate class definitions in memory, at runtime, from XSD or JSON? I know about PyXB, generateDS and some others, but they all rely on generating python source files at the command line, and then using those to parse XML. Thanks From gheskett at wdtv.com Thu Feb 16 20:40:11 2012 From: gheskett at wdtv.com (gene heskett) Date: Thu, 16 Feb 2012 20:40:11 -0500 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> Message-ID: <201202162040.12029.gheskett@wdtv.com> On Thursday, February 16, 2012 08:40:04 PM Arnaud Delobelle did opine: > On 16 February 2012 21:10, Prasad, Ramit wrote: > >>> When you reply to a known bot, please include some indication of the > >>> fact, so we know your message can be ignored as well. > >> > >>Sometimes I wonder about 88888. Is there a real person there, as well > >>as the bot? A lot of his/its > >> > > posts look too intelligent to be computer-generated - or maybe I'm > > underestimating the quality of AI. > > > > I was wondering the exact same thing. > > I think it may be that what you are underestimating is your ability, > as a human being, to create meaning where there is none. Ouch! Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Why do seagulls live near the sea? 'Cause if they lived near the bay, they'd be called baygulls. From torriem at gmail.com Thu Feb 16 20:45:15 2012 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Feb 2012 18:45:15 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <4F3DB12B.2000303@gmail.com> On 02/16/2012 10:38 AM, Grant Edwards wrote: > I got curious about Dalvik, and was looking at the Wikipedia page, > where it says that programs for Android are compiled into bytecode in > JVM compatible .class files. Those files are then converted into .dex > files to run on Davlik. > > I don't know much at all about Jython, but if it generates JVM byte > code, mightn't the same conversion to .dex be applicable? I think it has to do with the fact that Jython does dynamic class generation and loading. Similarly I don't think JBoss or Tomcat could be ported easily to Dalvik without making lots of changes to the class loading stuff. But I know nothing about Java, so I could be way wrong here. From yves at zioup.com Thu Feb 16 21:39:22 2012 From: yves at zioup.com (yves at zioup.com) Date: Thu, 16 Feb 2012 19:39:22 -0700 Subject: tkinter.Toplevel Message-ID: With a tkinter.Toplevel, how can I "disable" the parent windown and all its widget, in the same fashion as tkinter.messagebox? -- Yves. http://www.SollerS.ca/ http://ipv6.SollerS.ca http://blog.zioup.org/ From kwa at kuwata-lab.com Thu Feb 16 22:00:00 2012 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 17 Feb 2012 12:00:00 +0900 Subject: ANN: pyTenjin 1.1.0 - a high-speed and full-featured template engine Message-ID: I released pyTenjin 1.1.0. http://pypi.python.org/pypi/Tenjin/ http://www.kuwata-lab.com/tenjin/ Overview of pyTenjin -------------------- * Very fast: about 10 times faster than Django template engine * Easy to learn: no need to learn template-original language * Full-featured: nestable layout template, partial template, preprocessing, etc. * Lightweight: only 2000 lines of code and very fast to import. * Google App Engine supported Documents --------- * User's Guide http://www.kuwata-lab.com/tenjin/pytenjin-users-guide.html * Examples http://www.kuwata-lab.com/tenjin/pytenjin-examples.html * CHANGES http://www.kuwata-lab.com/tenjin/pytenjin-CHANGES.txt Install ------- $ sudo easy_install Tenjin Or: $ wget http://pypi.python.org/packages/source/T/Tenjin/Tenjin-1.1.0.tar.gz $ tar xzf Tenjin-1.1.0.tar.gz $ cd Tenjin-1.1.0/ $ sudo python setup.py install Example ------- ## views/example.pyhtml

${title}

${item}
## main.py import tenjin #tenjin.set_template_encoding('utf-8') # optional (default 'utf-8') from tenjin.helpers import * from tenjin.html import * engine = tenjin.Engine(path=['views']) context = {'title': 'Example', 'items': ['Haruhi', 'Mikuru', 'Yuki'] } output = engine.render('example.pyhtml', context) print(output) ## output $ python main.py

Example

Haruhi
Mikuru
Yuki
Enhancements and Changes in this release ---------------------------------------- (See http://www.kuwata-lab.com/tenjin/pytenjin-CHANGES.txt for details.) * [Change] !! IMPORTANT!! Default cache file format is changed from marshal format to text format. You should remove all cache files to use this release. * [Enhance] Embedded pattern '${}' and '#{}' can contain pair of '{' and '}'. ::

${foo({'x':1})}

# OK

${foo({}+{}+{})}

# OK

${foo({'x':{'y':1}})}

# NG * [Enhance] New preprocessing mechanism. You can specify your own preprocessor class by 'pp' parameter. * [Enhance] Add 'TrimPreprocessor' which removes spaces ad the beginning of lines. You can reduce size of output by it. * [Enhance] Add 'PrefixedLinePreprocessor' which converts ':: ...' into ''. You may like ':: ...' because it is simpler than ''. * [Enhance] Add 'JavaScriptPreprocessor' class which enables you to embed client-side javascript template code into server-side template. For example::
#{i} ${items[i]}
will be converted into::
by JavaScriptPreprocessor. Notice that you should embed 'tenjin.JS_FUNC' to run client-side code. How to use it:: pp = [ tenjin.JavaScriptPreprocessor() ] engine = tenjin.Engine(pp=pp) output = engine.render('example.pyhtml', {}) print(html) * [Enhance] Now supports Jython 2.5.2. (thanks to Lars Hupfeldt Nielsen) * [Enhance] Now supports PyPy 1.7 or later officially. * [Change] Template#convert() now converts "\r\n" into "\\r\n". This is necessary to follow change of language specification on Python 2.7 and 3.2. Have fun! -- makoto kuwata From dihedral88888 at googlemail.com Fri Feb 17 00:25:55 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 21:25:55 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> ? 2012?2?16????UTC+8??11?22?44??Michael Torrie??? > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. The memory systems in mobile phones are different from PCs. This is the current situation in the consumer electronics sector. From dihedral88888 at googlemail.com Fri Feb 17 00:25:55 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 21:25:55 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> ? 2012?2?16????UTC+8??11?22?44??Michael Torrie??? > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. The memory systems in mobile phones are different from PCs. This is the current situation in the consumer electronics sector. From timr at probo.com Fri Feb 17 01:09:11 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Feb 2012 22:09:11 -0800 Subject: Numerical Linear Algebra in arbitrary precision References: Message-ID: Ken wrote: > >Brand new Python user and a bit overwhelmed with the variety of >packages available. Any recommendation for performing numerical >linear algebra (specifically least squares and generalized least >squares using QR or SVD) in arbitrary precision? I've been looking at >mpmath but can't seem to find much info on built in functions except >for LU decomposition/solve. It is been my experience that numpy is the best place to start with requests like this, although I don't know whether it will actually solve your specific tasks: http://docs.scipy.org/doc/numpy/reference/routines.linalg.html -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dllizheng at gmail.com Fri Feb 17 02:53:00 2012 From: dllizheng at gmail.com (Zheng Li) Date: Fri, 17 Feb 2012 16:53:00 +0900 Subject: question about function pointer Message-ID: def method1(a = None): print a i can call it by method1(*(), **{'a' : 1}) I am just curious why it works and how it works? and what do *() and **{'a' : 1} mean? when I type *() in python shell, error below happens File "", line 1 *() ^ SyntaxError: invalid syntax From arnodel at gmail.com Fri Feb 17 03:00:54 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 17 Feb 2012 08:00:54 +0000 Subject: question about function pointer In-Reply-To: References: Message-ID: On 17 February 2012 07:53, Zheng Li wrote: > def method1(a = None): > ? ? ? ?print a > > i can call it by > method1(*(), **{'a' : 1}) > > I am just curious why it works and how it works? > and what do *() and **{'a' : 1} mean? > > when I type *() in python shell, error below happens > > ?File "", line 1 > ? ?*() > ? ?^ > SyntaxError: invalid syntax It's worth reading the Python tutorial. Here's the relevant section: http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists You could read all of 4.7 -- Arnaud From dhrati1singh at gmail.com Fri Feb 17 03:45:47 2012 From: dhrati1singh at gmail.com (Dhrati Singh) Date: Fri, 17 Feb 2012 00:45:47 -0800 (PST) Subject: PHP Tutorials Message-ID: <87e1550c-36c8-42ad-8e8d-da74ed862979@i10g2000pbc.googlegroups.com> R4R provide basic PHP Tutorials with PHP Examples .Through R4R you can develop PHP programming concept. R4R provide PHP Interview Questions with answers.R4R provide PHP programming basic knowledge and related all programming skills. PHP- Hypertext Preprocessor is server side script language like ASP. Its scripts executes on server. PHP is open source software. The goal of PHP language is to allow web developers to write dynamically generated pages quickly. The origins of PHP date back to 1995.PHP was written in the C programming language by Rasmus Lerdorf in 1995 for use in monitoring his online resume and related personal information. For this reason, PHP originally stood for "Personal Home Page". From wxjmfauth at gmail.com Fri Feb 17 04:17:32 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Fri, 17 Feb 2012 01:17:32 -0800 (PST) Subject: format a measurement result and its error in "scientific" way References: Message-ID: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> On 16 f?v, 01:18, Daniel Fetchinson wrote: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) > Before swallowing any Python solution, you should realize, the values (value, error) you are using are a non sense : 1.03789291 +/- 0.00089 You express "more precision" in the value than in the error. --- As ex, in a 1.234(5) notation, the "()" is usually used to indicate the accuracy of the digit in "()". Eg 1.345(7) Typographically, the "()" is sometimes replaced by a bold digit ou a subscripted digit. jmf From nobody at nowhere.com Fri Feb 17 04:55:11 2012 From: nobody at nowhere.com (Nobody) Date: Fri, 17 Feb 2012 09:55:11 +0000 Subject: question about function pointer References: Message-ID: On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: > def method1(a = None): > print a > > i can call it by > method1(*(), **{'a' : 1}) > > I am just curious why it works and how it works? > and what do *() and **{'a' : 1} mean? In a function call, an argument consisting of * followed by an expression of tuple type inserts the tuple's elements as individual positional arguments. An argument consisting of ** followed by an expression of dictionary type inserts the dictionary's elements as individual keyword arguments. So if you have: a = (1,2,3) b = {'a': 1, 'b': 2, 'c': 3} then: func(*a, **b) is equivalent to: func(1, 2, 3, a = 1, b = 2, c = 3) > when I type *() in python shell, error below happens > > File "", line 1 > *() > ^ > SyntaxError: invalid syntax The syntax described above is only valid within function calls. There is a similar syntax for function declarations which does the reverse: > def func(*a, **b): print a print b > func(1, 2, 3, a = 1, b = 2, c = 3) (1, 2, 3) {'a': 1, 'c': 3, 'b': 2} From fetchinson at googlemail.com Fri Feb 17 05:00:27 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 17 Feb 2012 11:00:27 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: >> Thanks, it's simpler indeed, but gives me an error for value=1.267, >> error=0.08: >> >> Traceback (most recent call last): >> File "/home/fetchinson/bin/format_error", line 26, in >> print format_error( sys.argv[1], sys.argv[2] ) >> File "/home/fetchinson/bin/format_error", line 9, in format_error >> error_scale += error.scaleb( -error_scale ).to_integral( ).adjusted( >> ) >> File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb >> ans = self._check_nans(other, context) >> File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans >> other_is_nan = other._isnan() >> AttributeError: 'int' object has no attribute '_isnan' >> >> Which version of python are you using? > > 2.7.1. At a guess, it's failing because scaleb() (which was new in > 2.6) is buggily expecting a decimal argument, but adjusted() returns an int. > Convert the results of the two adjusted() calls to decimals, and I > think it should be fine. Great, with python 2.7 it works indeed! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From nobody at nowhere.com Fri Feb 17 05:02:27 2012 From: nobody at nowhere.com (Nobody) Date: Fri, 17 Feb 2012 10:02:27 +0000 Subject: Generating class definitions at runtime in memory from XSD or JSON References: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Message-ID: On Thu, 16 Feb 2012 17:15:59 -0800, Stodge wrote: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? I know about PyXB, generateDS and some > others, but they all rely on generating python source files at the > command line, and then using those to parse XML. You don't need a library to generate classes. If the type() function is called with 3 arguments, it creates and returns a new class. The first argument is the name of the class, the second argument a tuple of base classes, the third argument is the class' dictionary. E.g.: class Foo(Bar, Baz): def __init__(self): pass could be written as: def foo_init(self): pass Foo = type('Foo', (Bar, Baz), {'__init__': foo_init}) If you want to generate the function bodies from the contents of the JSON or XML file, use exec(). From fetchinson at googlemail.com Fri Feb 17 05:03:42 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 17 Feb 2012 11:03:42 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> References: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> Message-ID: >> Hi folks, often times in science one expresses a value (say >> 1.03789291) and its error (say 0.00089) in a short way by parentheses >> like so: 1.0379(9) > > Before swallowing any Python solution, you should > realize, the values (value, error) you are using are > a non sense : > > 1.03789291 +/- 0.00089 > > You express "more precision" in the value than > in the error. My impression is that you didn't understand the original problem: given an arbitrary value to arbitrary digits and an arbitrary error, find the relevant number of digits for the value that makes sense for the given error. So what you call "non sense" is part of the problem to be solved. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From robert.kern at gmail.com Fri Feb 17 05:26:56 2012 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 17 Feb 2012 10:26:56 +0000 Subject: Numerical Linear Algebra in arbitrary precision In-Reply-To: References: Message-ID: On 2/17/12 6:09 AM, Tim Roberts wrote: > Ken wrote: >> >> Brand new Python user and a bit overwhelmed with the variety of >> packages available. Any recommendation for performing numerical >> linear algebra (specifically least squares and generalized least >> squares using QR or SVD) in arbitrary precision? I've been looking at >> mpmath but can't seem to find much info on built in functions except >> for LU decomposition/solve. > > It is been my experience that numpy is the best place to start with > requests like this, although I don't know whether it will actually solve > your specific tasks: > > http://docs.scipy.org/doc/numpy/reference/routines.linalg.html This will not do arbitrary-precision, though. We use the double- and single-precision routines from LAPACK. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ulrich.eckhardt at dominolaser.com Fri Feb 17 06:16:38 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 17 Feb 2012 12:16:38 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: Am 16.02.2012 01:18, schrieb Daniel Fetchinson: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) Just so that I understand you, the value of the last "digit" is somewhere between 9-9 and 9+9, right? So the value itself is rounded so that its last digit has the same value as the only digit to which the error is rounded. > One can vary things a bit, but let's take the simplest case when we > only keep 1 digit of the error (and round it of course) and round the > value correspondingly. First step is to format the values as decimal string ('{0:f}'.format). Then, pad both values to the same number of digits before and after the radix separator. Then, iterate over the strings, those digits where the error digits are zero are those that are taken verbatim for the value. The following digit is rounded and then added to the result. The according digit in the error is also rounded and added in brackets. Note that you can not compute these "values", since the definition of the rounding depends on a decimal representation. If you have decimal floating point numbers, where 0.1 is representable without loss, you could actually do that. In order to allow common treatment as decimal as required for this algorithm, the first step above was the conversion to a decimal string. Write tests that make sure this works, e.g. I ignored any sign and you also can't use str() to format the value because that could give you "123.45e+5" as a result. Good luck! Uli From fabiofz at gmail.com Fri Feb 17 06:54:21 2012 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 17 Feb 2012 09:54:21 -0200 Subject: How to make PyDev pep8 friendly? In-Reply-To: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> References: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> Message-ID: On Wed, Feb 8, 2012 at 10:15 PM, Ali Zandi wrote: > Hi, > > I was trying to find a way to configure PyDev e.g. in Eclipse to be > pep8 friendly. > > There are a few configurations like right trim lines, use space after > commas, use space before and after operators, add new line at the end > of file which can be configured via Eclipse -> Window -> Preferences - >> PyDev -> Editor -> Code Style -> Code Formatter. But these are not > enough; for example I couldn't find a way to configure double line > spacing between function definitions. > > So is there any way to configure eclipse or PyDev to apply pep8 rules > e.g. on each save? > While this is known, there are still no dates on when this will actually be implemented... On the other way, I'd love to accept patches for that... it could even be done in Python (actually Jython 2.2.1) -- which is also the way that pep8.py was integrated. Cheers, Fabio From wxjmfauth at gmail.com Fri Feb 17 07:13:04 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Fri, 17 Feb 2012 04:13:04 -0800 (PST) Subject: format a measurement result and its error in "scientific" way References: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> Message-ID: On 17 f?v, 11:03, Daniel Fetchinson wrote: > >> Hi folks, often times in science one expresses a value (say > >> 1.03789291) and its error (say 0.00089) in a short way by parentheses > >> like so: 1.0379(9) > > > Before swallowing any Python solution, you should > > realize, the values (value, error) you are using are > > a non sense : > > > 1.03789291 +/- 0.00089 > > > You express "more precision" in the value than > > in the error. > > My impression is that you didn't understand the original problem: > given an arbitrary value to arbitrary digits and an arbitrary error, > find the relevant number of digits for the value that makes sense for > the given error. So what you call "non sense" is part of the problem > to be solved. > I do not know where these numbers (value, error) are coming from. But, when the value and the error have not the same "precision", there is already something wrong somewhere. And this, *prior* to any representation of these values/numbers. jmf From stefan_ml at behnel.de Fri Feb 17 07:57:14 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 17 Feb 2012 13:57:14 +0100 Subject: Generating class definitions at runtime in memory from XSD or JSON In-Reply-To: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> References: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Message-ID: Stodge, 17.02.2012 02:15: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? The question is: why do you want to do that? There may be other ways to do what you *actually* want to do, but we don't know what that is. Stefan From neilc at norwich.edu Fri Feb 17 08:12:07 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 17 Feb 2012 13:12:07 GMT Subject: Undoing character read from file References: Message-ID: <9q7217F6j0U3@mid.individual.net> On 2012-02-16, MRAB wrote: > On 16/02/2012 23:10, Emeka wrote: >> Hello All, >> >> I know about seek and tell while using readline. What about if I am >> using read, and I want to undo the last character I just read(to return >> it back to the stream). How do I achieve this? >> > Try: > > f.seek(-1, 1) > > It seeks -1 relative to the current position (the second > argument defaults to 0 for relative to start of file). Unless it's a stream opened in binary mode this will not work. You'd need to maintain a n-character length buffer instead, with n being the maximum number of characters you'd like to be able to put back. -- Neil Cerutti From dihedral88888 at googlemail.com Fri Feb 17 08:20:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 05:20:52 -0800 (PST) Subject: question about function pointer In-Reply-To: References: Message-ID: <11998859.481.1329484852059.JavaMail.geo-discussion-forums@pbux2> ? 2012?2?17????UTC+8??5?55?11??Nobody??? > On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: > > > def method1(a = None): > > print a > > > > i can call it by > > method1(*(), **{'a' : 1}) > > > > I am just curious why it works and how it works? > > and what do *() and **{'a' : 1} mean? > > In a function call, an argument consisting of * followed by an expression > of tuple type inserts the tuple's elements as individual positional > arguments. An argument consisting of ** followed by an expression of > dictionary type inserts the dictionary's elements as individual keyword > arguments. > > So if you have: > > a = (1,2,3) > b = {'a': 1, 'b': 2, 'c': 3} > > then: > > func(*a, **b) > > is equivalent to: > > func(1, 2, 3, a = 1, b = 2, c = 3) > > > when I type *() in python shell, error below happens > > > > File "", line 1 > > *() > > ^ > > SyntaxError: invalid syntax > > The syntax described above is only valid within function calls. > > There is a similar syntax for function declarations which does the reverse: > > > def func(*a, **b): > print a > print b > > > func(1, 2, 3, a = 1, b = 2, c = 3) > (1, 2, 3) > {'a': 1, 'c': 3, 'b': 2} In the functional programming view, 2 to 5 object parameters are enough to invoke a function. But the tuple and dictionary packing and unpacking are not free in the run time. Enhancement to operations of basic types in Python can speed up everything. From jeanmichel at sequans.com Fri Feb 17 08:49:37 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 17 Feb 2012 14:49:37 +0100 Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <4F3E5AF1.1050802@sequans.com> Vinay Sajip wrote: > Sarge, a cross-platform library which wraps the subprocess module in > the standard library, has been released. > > What does it do? > ---------------- > > Sarge tries to make interfacing with external programs from your > Python applications easier than just using subprocess alone. > > Sarge offers the following features: > > * A simple way to run command lines which allows a rich subset of Bash- > style shell command syntax, but parsed and run by sarge so that you > can run on Windows without cygwin (subject to having those commands > available): > > >>> from sarge import capture_stdout > >>> p = capture_stdout('echo foo | cat; echo bar') > >>> for line in p.stdout: print(repr(line)) > ... > 'foo\n' > 'bar\n' > > * The ability to format shell commands with placeholders, such that > variables are quoted to prevent shell injection attacks. > > * The ability to capture output streams without requiring you to > program your own threads. You just use a Capture object and then you > can read from it as and when you want. > > Advantages over subprocess > --------------------------- > > Sarge offers the following benefits compared to using subprocess: > > * The API is very simple. > > * It's easier to use command pipelines - using subprocess out of the > box often leads to deadlocks because pipe buffers get filled up. > > * It would be nice to use Bash-style pipe syntax on Windows, but > Windows shells don't support some of the syntax which is useful, like > &&, ||, |& and so on. Sarge gives you that functionality on Windows, > without cygwin. > > * Sometimes, subprocess.Popen.communicate() is not flexible enough for > one's needs - for example, when one needs to process output a line at > a time without buffering the entire output in memory. > > * It's desirable to avoid shell injection problems by having the > ability to quote command arguments safely. > > * subprocess allows you to let stderr be the same as stdout, but not > the other way around - and sometimes, you need to do that. > > Python version and platform compatibility > ----------------------------------------- > > Sarge is intended to be used on any Python version >= 2.6 and is > tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, > Windows, and Mac OS X (not all versions are tested on all platforms, > but sarge is expected to work correctly on all these versions on all > these platforms). > > Finding out more > ---------------- > > You can read the documentation at > > http://sarge.readthedocs.org/ > > There's a lot more information, with examples, than I can put into > this post. > > You can install Sarge using "pip install sarge" to try it out. The > project is hosted on BitBucket at > > https://bitbucket.org/vinay.sajip/sarge/ > > And you can leave feedback on the issue tracker there. > > I hope you find Sarge useful! > > Regards, > > > Vinay Sajip > Hi, Thanks for sharing, I hope this one will be as successful as the logging module, possibly integrated into a next version of subprocess. I can't use it though, I'm still using a vintage 2.5 version :-/ JM From lists.eckel at gmail.com Fri Feb 17 10:35:10 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Fri, 17 Feb 2012 07:35:10 -0800 (PST) Subject: Python code file prototype Message-ID: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> I finally figured out how to set up the Windows explorer's right-click "new" so that it will create Python files. Here's how: http://superuser.com/questions/34704/windows-7-add-an-item-to-new-context-menu There's an option when you do this to insert default file contents, so I began searching the web for some kind of prototype Python file that would be appropriate to start with. I'm certain I've seen this before and that there's been discussions about the best starting point for a python code file, but I find I can't get any search hits for it. Hoping for some links, thanks. From gordon at panix.com Fri Feb 17 11:20:37 2012 From: gordon at panix.com (John Gordon) Date: Fri, 17 Feb 2012 16:20:37 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: In <66ea0353-02ee-4152-947a-97b44ff3ec45 at p7g2000yqk.googlegroups.com> Bruce Eckel writes: > There's an option when you do this to insert default file contents, so > I began searching the web for some kind of prototype Python file that > would be appropriate to start with. I'm certain I've seen this before > and that there's been discussions about the best starting point for a > python code file, but I find I can't get any search hits for it. Here's what PyScripter inserts in a new python file: #--------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: $USERNAME # # Created: $DATE # Copyright: (c) $USERNAME $YEAR # Licence: #--------------------------------------------------------------------- #!/usr/bin/env python def main(): pass if __name__ == '__main__': main() Where $USERNAME, $DATE and $YEAR are expanded to the actual values. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ian.g.kelly at gmail.com Fri Feb 17 11:55:46 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 17 Feb 2012 09:55:46 -0700 Subject: Python code file prototype In-Reply-To: References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 9:20 AM, John Gordon wrote: > Here's what PyScripter inserts in a new python file: > > ?#--------------------------------------------------------------------- > ?# Name: ? ? ? ?module1 > ?# Purpose: > ?# > ?# Author: ? ? ?$USERNAME > ?# > ?# Created: ? ? $DATE > ?# Copyright: ? (c) $USERNAME $YEAR > ?# Licence: ? ? > ?#--------------------------------------------------------------------- > ?#!/usr/bin/env python > > ?def main(): > ? ? ?pass > > ?if __name__ == '__main__': > ? ? ?main() The shebang has to be the first thing in the file to be useful. As it is above, it might as well not be there. I would suggest also including a doc string in the skeleton. Cheers, Ian From invalid at invalid.invalid Fri Feb 17 12:02:31 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 17 Feb 2012 17:02:31 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On 2012-02-17, John Gordon wrote: > In <66ea0353-02ee-4152-947a-97b44ff3ec45 at p7g2000yqk.googlegroups.com> Bruce Eckel writes: > >> There's an option when you do this to insert default file contents, so >> I began searching the web for some kind of prototype Python file that >> would be appropriate to start with. I'm certain I've seen this before >> and that there's been discussions about the best starting point for a >> python code file, but I find I can't get any search hits for it. > > Here's what PyScripter inserts in a new python file: > > #--------------------------------------------------------------------- > # Name: module1 > # Purpose: > # > # Author: $USERNAME > # > # Created: $DATE > # Copyright: (c) $USERNAME $YEAR > # Licence: > #--------------------------------------------------------------------- > #!/usr/bin/env python > > def main(): > pass > > if __name__ == '__main__': > main() > > > Where $USERNAME, $DATE and $YEAR are expanded to the actual values. That's just plain broken. The "#!" line has to be first thing in the file for it to be recognized. Apart from that, my personal opinion is that comment blocks like that are bad practice. They're too often wrong (e.g. file got copied modified, but comment block not updated), and the right place for metadata like that is the filesystem and the source-control system (git, mercurial, subversion, CVS, whatever -- anything but VSS). -- Grant From vinay_sajip at yahoo.co.uk Fri Feb 17 12:19:07 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Fri, 17 Feb 2012 09:19:07 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: Message-ID: On Feb 17, 1:49?pm, Jean-Michel Pichavant wrote: > I can't use it though, I'm still using a vintage 2.5 version :-/ That's a shame. I chose 2.6 as a baseline for this package, because I need it to work on Python 2.x and 3.x with the same code base and minimal work, and that meant supporting Unicode literals via "from __future__ import unicode_literals". I'm stuck on 2.5 with other projects, so I share your pain :-( Regards, Vinay Sajip From dihedral88888 at googlemail.com Fri Feb 17 12:29:37 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 09:29:37 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <14723790.1488.1329499777166.JavaMail.geo-discussion-forums@pbvr2> Check PY2EXE, PYREX and PSYChO. I must use these packages to relase commercial products with my own dll in c. From srinivaszmr at gmail.com Fri Feb 17 13:17:58 2012 From: srinivaszmr at gmail.com (vas) Date: Fri, 17 Feb 2012 10:17:58 -0800 (PST) Subject: click here for new updates>PYTHON Message-ID: <7fdb46c1-60d0-4f4d-8be0-b95ee605111b@ow3g2000pbc.googlegroups.com> http://123maza.com/48/plant826/ From kj4eit at gmail.com Fri Feb 17 13:51:42 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 10:51:42 -0800 (PST) Subject: signed to unsigned Message-ID: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> In C or C++, I can do this for integer conversion: unsigned int j = -327681234; // Notice this is signed. j will equal 3967286062. I thought with Python that I could use struct to pack the signed int as an unsigned int, but that fails: >>> x = struct.pack("", line 1, in struct.error: integer out of range for 'I' format code Is there an easy way in Python to do the same conversion that C or C++ code does? Thanks for any advice. From lists.eckel at gmail.com Fri Feb 17 14:03:52 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Fri, 17 Feb 2012 11:03:52 -0800 (PST) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: <7e33534f-0898-4cab-9782-9bdc2584586a@t5g2000yqk.googlegroups.com> > ? ? ? ? Of course, since the OP was talking Windows... the #! line is > ignored no matter where it was Yes, but I use Windows, Mac and Linux so I'm searching for something universal. From clp2 at rebertia.com Fri Feb 17 14:05:23 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 17 Feb 2012 11:05:23 -0800 Subject: signed to unsigned In-Reply-To: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 10:51 AM, Brad Tilley wrote: > In C or C++, I can do this for integer conversion: > > unsigned int j = -327681234; // Notice this is signed. > > j will equal 3967286062. I thought with Python that I could use struct > to pack the signed int as an unsigned int, but that fails: > >>>> x = struct.pack(" Traceback (most recent call last): > ?File "", line 1, in > struct.error: integer out of range for 'I' format code > > Is there an easy way in Python to do the same conversion that C or C++ > code does? Thanks for any advice. Pack it as the actual type, then unpack it as the desired type: Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) Type "help", "copyright", "credits" or "license" for more information. >>> from struct import pack, unpack >>> unpack('=I', pack('=i',-327681234)) (3967286062,) I would think there's some more efficient way to do this though. Cheers, Chris From kj4eit at gmail.com Fri Feb 17 14:10:36 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 11:10:36 -0800 (PST) Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: <34af3238-9541-48bf-b1a3-bd1e07f1fbc5@w1g2000vbg.googlegroups.com> > Pack it as the actual type, then unpack it as the desired type: > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > Type "help", "copyright", "credits" or "license" for more information.>>> from struct import pack, unpack > >>> unpack('=I', pack('=i',-327681234)) > > (3967286062,) > > I would think there's some more efficient way to do this though. > > Cheers, > Chris Thanks Chris! I was doing it backwards. I only have a few of these right now, so performance isn't a concern. I appreciate the advice. Brad From __peter__ at web.de Fri Feb 17 14:14:46 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 17 Feb 2012 20:14:46 +0100 Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: Brad Tilley wrote: > In C or C++, I can do this for integer conversion: > > unsigned int j = -327681234; // Notice this is signed. > > j will equal 3967286062. I thought with Python that I could use struct > to pack the signed int as an unsigned int, but that fails: > >>>> x = struct.pack(" Traceback (most recent call last): > File "", line 1, in > struct.error: integer out of range for 'I' format code > > Is there an easy way in Python to do the same conversion that C or C++ > code does? Thanks for any advice. >>> 0xffffffff & -327681234 3967286062 From kj4eit at gmail.com Fri Feb 17 14:22:43 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 11:22:43 -0800 (PST) Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> > >>> 0xffffffff & -327681234 > > 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0xffffffffffffffff & -9151314442815602945 9295429630893948671L From d at davea.name Fri Feb 17 14:37:52 2012 From: d at davea.name (Dave Angel) Date: Fri, 17 Feb 2012 14:37:52 -0500 Subject: signed to unsigned In-Reply-To: <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> Message-ID: <4F3EAC90.5010209@davea.name> On 02/17/2012 02:22 PM, Brad Tilley wrote: >>>>> 0xffffffff& -327681234 >> 3967286062 > Very nice! Thanks for that example. Unsigned long longs: > > 0xffffffffffffffff& -9151314442815602945 > 9295429630893948671L Or more generally, use modulo -13452324 % 2^64 -- DaveA From ramit.prasad at jpmorgan.com Fri Feb 17 15:09:53 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Fri, 17 Feb 2012 20:09:53 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474151A5C@SCACMX008.exchad.jpmchase.net> >> They also don't need to put up with people who aren't seriously ill - I >> don't know how long your private appointments are, but here in the UK a >> standard doctor's appointment is 5-10 minutes. If they decide you're >> actually ill they may extend that. >Five to ten minutes? Is the doctor an a-hole or a machine? Can a >doctor REALLY diagnose an illness in five to ten minutes? Are you >joking? And if not, do you ACTUALLY want the experience to be >synonymous with an assembly line? You don't fear misdiagnosis? I envy >your bravery! Actually, I find that (5-10 minutes of doctor time) completely true even in America. The difference is that I spend 30-60minutes waiting to be called, then another 5min with a nurse for pre-doctor stuff (blood pressure, why I am there, etc), finally another 5 minutes with the nurse for any necessary post-doctor work (drawing blood, shots, etc.). My total doctor talking time is really 5-10 minutes. Of course, if I was sick in an unusual way then the doctor would see me for longer, but the average doctor tends to see the same couple dozen things over and over. This is true for every doctor I can remember, but YMMV. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From rridge at csclub.uwaterloo.ca Fri Feb 17 15:37:57 2012 From: rridge at csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 17 Feb 2012 15:37:57 -0500 Subject: XSLT to Python script conversion? References: Message-ID: Matej Cepl wrote: >No, the strangness is not that bad (well, it is bad ... almost anything >feels bad comparing to Python, to be honest, but not the reason I would >give up; after all I spent couple of years with Javascript). The XSLT language is one of the worst misuses of XML, which puts it way beyond bad. >The terrible debugging is one thing, and even worse, I just still cannot >get over rules around spaces: whitespace just jumps at me randomly in >random places and is erased in others. I use explicit nodes exclusively to avoid this problem. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From stefan_ml at behnel.de Fri Feb 17 15:53:48 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 17 Feb 2012 21:53:48 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: Ross Ridge, 17.02.2012 21:37: > Matej Cepl wrote: >> No, the strangness is not that bad (well, it is bad ... almost anything >> feels bad comparing to Python, to be honest, but not the reason I would >> give up; after all I spent couple of years with Javascript). > > The XSLT language is one of the worst misuses of XML, which puts it way > beyond bad. Clearly a matter of opinion. Stefan From rridge at csclub.uwaterloo.ca Fri Feb 17 16:11:17 2012 From: rridge at csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 17 Feb 2012 16:11:17 -0500 Subject: XSLT to Python script conversion? References: Message-ID: Ross Ridge writes: > The XSLT language is one of the worst misuses of XML, which puts it way > beyond bad. Stefan Behnel wrote: >Clearly a matter of opinion. No. There's no excuse for using XML as the syntax of a language like XLST. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From jugurtha.hadjar at gmail.com Fri Feb 17 17:01:27 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Fri, 17 Feb 2012 23:01:27 +0100 Subject: Beware, my computer was infected. In-Reply-To: <4F3C4F31.8020303@gmail.com> References: <4F3C4F31.8020303@gmail.com> Message-ID: <4F3ECE37.9000401@gmail.com> On 16/02/2012 01:34, Jugurtha Hadjar wrote: > Hello gentlemen, > > I'm writing these words to give you a heads up. My computer has > recently been infected with "1.exe", and I am doing what I can to > contain it. It spreads via mail and I fear it will send SPAM to lists > I am subscribed to. > > If you receive weird mails from my address, thank you to report it to > me. I will not send you an executable, so if you receive one from me, > please do not open it and it would be nice to report it. > > I will send an e-mail to this list once I think it is no longer in > the system. > > Thank you all. > Everything is under control. -- ~Jugurtha Hadjar, From rantingrickjohnson at gmail.com Fri Feb 17 18:48:56 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 15:48:56 -0800 (PST) Subject: tkinter.Toplevel References: Message-ID: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> On Feb 16, 8:39?pm, y... at zioup.com wrote: > With a tkinter.Toplevel, how can I "disable" the parent windown and all its > widget, in the same fashion as tkinter.messagebox? The answer lies within the tkSimpleDialog source code; which is pure python. Look in the __init__ method of Dialog class. My advice is to study the code until you understand every line. Look at the following references when you need more info: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ http://effbot.org/tkinterbook/ From rantingrickjohnson at gmail.com Fri Feb 17 20:13:37 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 17:13:37 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly wrote: > On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson > I make a middle-class income and do not feel that I am anywhere near > being "enslaved" by my income taxes, which amount to less than 10% of > my gross income after deductions and credits. Ten percent?!?! You pay less income tax by percentage than most rich folks, including Mitt Romney! I envy you since you must be one of the lucky folks who ONLY pay income tax. I guess you never purchase ANYTHING or live under the tyranny of local jurisdictions ON TOP of the federal jurisdiction? Here is a list of taxes most everyone else will encounter: Accounts Receivable Tax Building Permit Tax Capital Gains Tax CDL license Tax Cigarette Tax Corporate Income Tax Court Fines (indirect taxes) Deficit spending Dog License Tax Federal Income Tax Federal Unemployment Tax (FUTA) Fishing License Tax Food License Tax Fuel permit tax Gasoline Tax Gift Tax Hunting License Tax Inflation Inheritance Tax Interest expense (tax on the money) Inventory tax IRS Interest Charges (tax on top of tax) IRS Penalties (tax on top of tax) Liquor Tax Local Income Tax Luxury Taxes Marriage License Tax Medicare Tax Property Tax Real Estate Tax Septic Permit Tax Service Charge Taxes Social Security Tax Road Usage Taxes (Truckers) Sales Taxes Recreational Vehicle Tax Road Toll Booth Taxes School Tax State Income Tax State Unemployment Tax (SUTA) Telephone federal excise tax Telephone federal universal service fee tax Telephone federal, state and local surcharge taxes Telephone minimum usage surcharge tax Telephone recurring and non-recurring charges tax Telephone state and local tax Telephone usage charge tax Toll Bridge Taxes Toll Tunnel Taxes Traffic Fines (indirect taxation) Trailer Registration Tax Utility Taxes Vehicle License Registration Tax Vehicle Sales Tax Watercraft Registration Tax Well Permit Tax Workers Compensation Tax ... and don't forget for declare those pennys on your eyes! > Heck, there are poorer > people than I who voluntarily donate that much to religious > organizations on top of their taxes. Again, lucky you! MOST middle class people pay 30-50% of their income in taxes! > Say what you want about the income tax system, but at least net income > still basically increases monotonically. ?If you make more gross than > me, chances are that you're going to make more net than me as well. So you support a flat tax system? A system where everybody pays the same percentage? Actually i think 10% income tax is a fair amount although i believe taxing income silly. If the government cannot provide national security, domestic security, and LIMITED infratructure on 10% of what we make, they are wasting too much of OUR money. > > HOWEVER, healthcare is not a concern of the greater society, but only > > the individual -- with the exception of contagious disease of course, > > which effects us all! > > I disagree, and here's why. ?Let's say I'm a billionaire, and I'm > diagnosed with cancer. ?Do you think I can just round up a bunch of > scientists and tell them "Here's a billion dollars. ?Now go find a > cure my cancer"? ?Of course not, it doesn't work that way. ?If the > necessary research hasn't already been done, then it's unlikely that > it will be finished in the few years or months that I have before the > cancer kills me, no matter how much of my own money I throw at it. I agree that keeping R&D "alive" is very important for our collective advancement. I do not fear technology like some people. Futhermore, i don't have any problem funding R&D for ANY of the sciences, beit medical or otherwise. But let me assure you, under a private healthcare system (psst: the kind where people pay they own way!) there will ALWAYS be enough people to keep R&D alive. Besides, the degenerates are only seeking care for self induced heath issues. > Real medical research is primarily driven by medical treatment. Yes, but that does not mean we should hand degenerates a meal ticket. > -- if I > as a wealthy private investor am going to invest in such a highly > speculative and risky venture as drug research, I will be more willing > to invest a large sum of money if the potential recipients (i.e. > consumers) number in the hundreds of thousands, not just the few > thousand who will be able to pay for the drug out of pocket. > Likewise, much of the money the drug companies make off of sales goes > back into research so that they can be ready with a newer, better drug > by the time their patents expire. > > Distributing health care coverage expands the market for treatments > and so allows the state of the art to advance faster. ?Yes, with > socialized health care, some of our tax money goes into that pool, and > a lot of that tax money just ends up as profits in the hands of > wealthy shareholders. ?The other side of that coin, though, is that if > we ever find ourselves in the position that we need those treatments > ourselves, the medical state of the art will be that much better for > it. And if you can afford the care great, if not, you'd better buy an insurance policy. You know, people love to whine about how privatized healthcare is so unfair to the degenerates. What about the doctors? Would you expect a doctor to work for free? Remeber, doctors spend a decade or more in college and rack up HUGE debts to pay for their education. You don't mind stealing from taxpayers to fund degenerates, but it's the same as stealing from doctors. Observe: Doctor: "Okay, your diease is cured. You have a clean bill of heath! Your bill is $500,000" Patient: "Thanks doc, but it seems i am little light. Can i just pay you $20.00 and we call it even?" Doctor: "What? I just saved your life. I spent the last three months caring for you. Using expensive medical equipment and years of laboratory research. Do you know how many lab rats and monkeys died a horrible death so that you can live? How can I do all that for $20.00?" Of course you would not, because you'd have to look the doctor in the eye whilst robbing him. On the other hand, with tax payer subsidized healthcare (AKA: Public Heathcare), you don't have to look anyone in the eye. The victim of your plunder is just some random taxpayer footing your bills! People, THERE IS NO FREE LUNCH! Every product that is made and every service rendered was a result of someone's hard labor. Sleep on that you degenerates! Hypocrisy! It's no different than the idiots who whine for the fair treatment of fluffy mammals but them declare chemical warfare on insects and reptiles. To them ONLY fluffy mammals deserve fair treatment because they are so cuddly (and cute BTW) PUKE!. But you want to know the REAL reason? It's because mammals return love and reptiles and insects don't. It's because people are selfish. If another being will no reciprocate their love, then they murder that being with extreme prejudice, and not feel one bit guilty about it! Do you understand how backward you are? Do you understand how selfish and immoral you are? Do you understand how incredibly dense you are? Because of people like YOU, we don't deserve the right to evolve! > But beyond that, I also think that we as a society have an ethical > commitment to help one another out when we find ourselves in trouble, > because that's what a civilized society is. I agree totally. Let say an innocent is shot in the course of a robbery. I would not mind my tax dollars going towards the victims medical care IF he could not afford the care himself. Even if he was a degenerate. On the other hand, if some lame-brain decided to climb MT. Everest and got stuck on top with frost-bite... TOO BAD! Same goes for dummies who develop lung caner from somking... TOO BAD! Or cirrhosis of the liver from one too many "adult beverages"... TOO BAD! Or diabetes from eating too many candy bars and/or drinking too many sodas... TOO BAD, TOO BAD, TOO BAD!!! I am tired of the whines and laments of vermin, almost as much as i am tired of the silence of the moral majority! It's time to put degenerates in their place! From gechangbin11 at 163.com Fri Feb 17 20:26:37 2012 From: gechangbin11 at 163.com (gechangbin11 at 163.com) Date: Fri, 17 Feb 2012 17:26:37 -0800 (PST) Subject: download porn videos free Message-ID: <15dedf83-6f3f-4b13-b8d3-d1faebeb36f6@ow3g2000pbc.googlegroups.com> http://dladult.com/ From rantingrickjohnson at gmail.com Fri Feb 17 20:37:41 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 17:37:41 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <32cb82b9-0e35-4d92-983e-0c08df828174@n12g2000yqb.googlegroups.com> On Feb 13, 7:37?pm, Chris Angelico wrote: > On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson > > wrote: > > # Py>=3.0 > > py> sum(earner.get_income(2012) for earner in earners2012) / > > len(earners2012) > > average_income > > > Once you exceed that amount you are robbing your fellow man. How can > > you justify making more than your fair share UNLESS someone offers > > their work load to YOU? You can't. You are living in excess. And for > > those who think the average_income is too small, well then, it's time > > to implement population control! > > My equation looks something like this: > > # Brain >= 0,1 > brain> Your contribution to society / Society's contribution to you > > This value should be able to exceed 1.0 across the board. In fact, if > it doesn't, then as a society we're moving backward. Are we talking about money or deeds? If deeds then i agree, if money then i disagree. A society is NOT made better by contributing money. Who does the money go to? History has shown that money ends up being wasted, that money ends up being squandered, and that money ends up empowering tyranny! However A society IS improved when good deeds and good wills are injected by the individual. We should ALWAYS invest more good deeds and expect less. So in this case we should ALWAYS exceed 1.0. From torriem at gmail.com Fri Feb 17 20:51:13 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 17 Feb 2012 18:51:13 -0700 Subject: [OT]: Smartphones and Python? In-Reply-To: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <4F3F0411.80508@gmail.com> On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > Android is a customized linux OS used in mobile phones. I don't think > any linux systm has to be locked by JAVA or any JVM to run > applications. Getting waaayyyy off topic here, but... I guess you aren't familiar with what Android is (which is ironic, given that a lot of people on this list think you must be one!). Android is not simply a customized linux distribution. It's a special application environment (an OS in its own right) that is based on the Dalvik virtual machine. Dalvik does depend on the Linux kernel to talk to the hardware, but Linux very much is not a part of Android, at least from the developers' and end users' points of view. Linux is just not a part of the user experience at all. It is true that Dalvik can call into native linux code, but native linux applications typically aren't a part of the Android user experience. Thus you can't just install any JVM on android. Thus cpython or jython just isn't part of it. For one I don't know of any sun-compatible JVM that has been ported to ARM. For two, there aren't any hooks into the Android UI APIs even if you could get it running. Android is even being ported to the QNX kernel by the Blackberry folks, so they can have android compatibility on next-generation blackberries that run their own native OS. > The memory systems in mobile phones are different from PCs. This is > the current situation in the consumer electronics sector. I do not understand what you are saying, or at least why you are saying this. But I don't understand most of your posts. From rosuav at gmail.com Fri Feb 17 21:13:15 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 Feb 2012 13:13:15 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Sat, Feb 18, 2012 at 12:13 PM, Rick Johnson wrote: > Here is a list of taxes most everyone else will encounter: You forgot the Microsoft Tax and the Stupid Tax. ChrisA From breamoreboy at yahoo.co.uk Fri Feb 17 21:39:55 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 18 Feb 2012 02:39:55 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 18/02/2012 02:13, Chris Angelico wrote: > On Sat, Feb 18, 2012 at 12:13 PM, Rick Johnson > wrote: >> Here is a list of taxes most everyone else will encounter: > > You forgot the Microsoft Tax and the Stupid Tax. > > ChrisA This is what I call a tax, some two miles from my home. http://www.bbc.co.uk/news/uk-england-dorset-17074716 -- Cheers. Mark Lawrence. From emekamicro at gmail.com Fri Feb 17 22:17:23 2012 From: emekamicro at gmail.com (Emeka) Date: Sat, 18 Feb 2012 05:17:23 +0200 Subject: Undoing character read from file In-Reply-To: <9q7217F6j0U3@mid.individual.net> References: <9q7217F6j0U3@mid.individual.net> Message-ID: Neil, Thanks. Could you throw a simple example? Regards, \Emeka On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti wrote: > On 2012-02-16, MRAB wrote: > > On 16/02/2012 23:10, Emeka wrote: > >> Hello All, > >> > >> I know about seek and tell while using readline. What about if I am > >> using read, and I want to undo the last character I just read(to return > >> it back to the stream). How do I achieve this? > >> > > Try: > > > > f.seek(-1, 1) > > > > It seeks -1 relative to the current position (the second > > argument defaults to 0 for relative to start of file). > > Unless it's a stream opened in binary mode this will not work. > You'd need to maintain a n-character length buffer instead, with > n being the maximum number of characters you'd like to be able to > put back. > > -- > Neil Cerutti > -- > http://mail.python.org/mailman/listinfo/python-list > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From emekamicro at gmail.com Fri Feb 17 22:38:22 2012 From: emekamicro at gmail.com (Emeka) Date: Sat, 18 Feb 2012 05:38:22 +0200 Subject: Undoing character read from file In-Reply-To: References: <9q7217F6j0U3@mid.individual.net> Message-ID: Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mset is False and mcount == 0: print c mfile.seek(-1, 0) mcount = 1 continue elif c == "e" and mcount == 1: print c mcount = 0 continue print c if mset is False: mset = True if len(c) == 0: break cc.txt foor the this the been we hate to sh wiukr bee here today. But who are we to question him concerning this issue. Is the above code the right way? Regards, \Emeka On Sat, Feb 18, 2012 at 5:17 AM, Emeka wrote: > Neil, > > Thanks. Could you throw a simple example? > > Regards, \Emeka > > > On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti wrote: > >> On 2012-02-16, MRAB wrote: >> > On 16/02/2012 23:10, Emeka wrote: >> >> Hello All, >> >> >> >> I know about seek and tell while using readline. What about if I am >> >> using read, and I want to undo the last character I just read(to return >> >> it back to the stream). How do I achieve this? >> >> >> > Try: >> > >> > f.seek(-1, 1) >> > >> > It seeks -1 relative to the current position (the second >> > argument defaults to 0 for relative to start of file). >> >> Unless it's a stream opened in binary mode this will not work. >> You'd need to maintain a n-character length buffer instead, with >> n being the maximum number of characters you'd like to be able to >> put back. >> >> -- >> Neil Cerutti >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > *Satajanus Nig. Ltd > > > * > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Fri Feb 17 22:58:52 2012 From: d at davea.name (Dave Angel) Date: Fri, 17 Feb 2012 22:58:52 -0500 Subject: Undoing character read from file In-Reply-To: References: <9q7217F6j0U3@mid.individual.net> Message-ID: <4F3F21FC.1080002@davea.name> On 02/17/2012 10:38 PM, Emeka wrote: > Hello All, > > Say I have something like this: > > mfile = open("cc.txt", "rb") > mcount = 0 > mset = False > while True: > c = mfile.read(1) > if c == "e" and mset is True and mcount == 0: > print c > mfile.seek(-1,1) > mcount = 1 > continue > elif c == "e" and mset is False and mcount == 0: > print c > mfile.seek(-1, 0) > mcount = 1 > continue > elif c == "e" and mcount == 1: > print c > mcount = 0 > continue > print c > if mset is False: > mset = True > if len(c) == 0: > break > > cc.txt > > foor the this the been we hate to sh wiukr bee here today. But who are we > to question > him concerning this issue. > > Is the above code the right way? You top-posted, instead of putting your response after whatever you were quoting. So you lose all context. Your code won't compile, and it's unclear just what you were trying to accomplish. What do you mean by "the right way"? Please post the actual code that you're running, and explain what you expected, what you got, and how it didn't do what you wanted. In this case, you should give us the traceback, so it's obvious that you're trying to figure out how to indent. -- DaveA From dihedral88888 at googlemail.com Fri Feb 17 23:19:24 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:19:24 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <96581.1784.1329538764682.JavaMail.geo-discussion-forums@pbcr5> From dihedral88888 at googlemail.com Fri Feb 17 23:51:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:51:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > > Android is a customized linux OS used in mobile phones. I don't think > > any linux systm has to be locked by JAVA or any JVM to run > > applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. A different set of shell tool to write some AP is not a new OS. It can be called a new IDE which supports manny services not well maintained by the free linux contributors in a loosely unorganized way. > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. > > Thus you can't just install any JVM on android. Thus cpython or jython > just isn't part of it. For one I don't know of any sun-compatible JVM > that has been ported to ARM. For two, there aren't any hooks into the > Android UI APIs even if you could get it running. > > Android is even being ported to the QNX kernel by the Blackberry folks, > so they can have android compatibility on next-generation blackberries > that run their own native OS. > > > The memory systems in mobile phones are different from PCs. This is > > the current situation in the consumer electronics sector. > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. You can use VMware like techniques to emulate another OS to support AP of different formats. This is not new at all. i From dihedral88888 at googlemail.com Fri Feb 17 23:51:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:51:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > > Android is a customized linux OS used in mobile phones. I don't think > > any linux systm has to be locked by JAVA or any JVM to run > > applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. A different set of shell tool to write some AP is not a new OS. It can be called a new IDE which supports manny services not well maintained by the free linux contributors in a loosely unorganized way. > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. > > Thus you can't just install any JVM on android. Thus cpython or jython > just isn't part of it. For one I don't know of any sun-compatible JVM > that has been ported to ARM. For two, there aren't any hooks into the > Android UI APIs even if you could get it running. > > Android is even being ported to the QNX kernel by the Blackberry folks, > so they can have android compatibility on next-generation blackberries > that run their own native OS. > > > The memory systems in mobile phones are different from PCs. This is > > the current situation in the consumer electronics sector. > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. You can use VMware like techniques to emulate another OS to support AP of different formats. This is not new at all. i From bahamutzero8825 at gmail.com Sat Feb 18 00:05:23 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 17 Feb 2012 23:05:23 -0600 Subject: [OT]: Smartphones and Python? In-Reply-To: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4F3F3193.9090903@gmail.com> On 2/17/2012 10:51 PM, 88888 Dihedral wrote: > ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? >> On 02/16/2012 10:25 PM, 88888 Dihedral wrote: >> > Android is a customized linux OS used in mobile phones. I don't think >> > any linux systm has to be locked by JAVA or any JVM to run >> > applications. >> >> Getting waaayyyy off topic here, but... >> >> I guess you aren't familiar with what Android is (which is ironic, given >> that a lot of people on this list think you must be one!). Android is >> not simply a customized linux distribution. It's a special application >> environment (an OS in its own right) that is based on the Dalvik virtual >> machine. Dalvik does depend on the Linux kernel to talk to the >> hardware, but Linux very much is not a part of Android, at least from > > Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. > > A different set of shell tool to write some AP is not > a new OS. Lorem ipsum dolor sit amet, GUI adipisicing elit, sed do eiusmod application incididunt ut labore et dolore magna Android. Ut linux ad minim veniam, quis python exercitation ullamco laboris nisi ut aliquip ex hardware commodo consequat. Duis aute irure dolor in Dalvik in voluptate velit esse cillum Java eu fugiat nulla pariatur. Excepteur sint kernel OS non proident, sunt in culpa qui shell deserunt mollit Oracle id est laborum. Sorry for the noise, but I'm hoping I can corrupt the bot's dictionary to make it more obvious. From ian.g.kelly at gmail.com Sat Feb 18 02:28:59 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 18 Feb 2012 00:28:59 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson wrote: > > On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly > wrote: >> On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson >> I make a middle-class income and do not feel that I am anywhere near >> being "enslaved" by my income taxes, which amount to less than 10% of >> my gross income after deductions and credits. > > Ten percent?!?! You pay less income tax by percentage than most rich > folks, including Mitt Romney! I envy you since you must be one of the > lucky folks who ONLY pay income tax. Yes, I feel terribly sorry for Mitt Romney. I can't imagine what it must be like to earn $27 million and only be allowed to keep $23 million of it. Why, that's barely enough to buy a private island in Dubai! I think it says a lot about how far we've come as a nation, though, that somebody who's practically a slave to the IRS can be a front-runner to be elected President. The 10% figure included Medicare, but not Social Security or other taxes. That's because health care coverage (you know, what we've been talking about) is primarily funded by income tax, Medicare, and excise taxes on certain kinds of treatments. Most other taxes go to fund specific unrelated programs. If I were to add everything up, it would probably come to around 30%, which still doesn't bother me, in part because I know that it comes back to benefit the society I live in, and by extension me, in one way or another.. > I guess you never purchase > ANYTHING or live under the tyranny of local jurisdictions ON TOP of > the federal jurisdiction? Paying taxes to fund public schools, police departments, fire departments, and road maintenance is "tyranny"? > Here is a list of taxes most everyone else will encounter: This list is awesome. I love how you include inflation and fines imposed for breaking the law as "taxes". Also how you state that "most everyone" will have to pay taxes for fishing licenses, hunting licenses, CDL licenses, and even corporate income. Marriage license tax? Yeah, I remember paying that fee. Once. I believe it was somewhere around $50. And cigarette tax? Correct me if I'm wrong, but isn't that one mostly paid by those "degenerates" you keep whining about, the ones who aren't pulling their own weight? I hope you can understand that I find it a bit ironic that you're now complaining about cigarette tax. >> Say what you want about the income tax system, but at least net income >> still basically increases monotonically. ?If you make more gross than >> me, chances are that you're going to make more net than me as well. > > So you support a flat tax system? A system where everybody pays the > same percentage? No, what makes you think that? The statement I made is true under either a flat tax or the progressive system we currently have. > Actually i think 10% income tax is a fair amount although i believe > taxing income silly. If the government cannot provide national > security, domestic security, and LIMITED infratructure on 10% of what > we make, they are wasting too much of OUR money. Here's a neat table: government spending as a percentage of GDP, by country. http://anepigone.blogspot.com/2008/03/government-spending-as-percentage-of.html In 2008, the United States spent 19.9% of its GDP in government spending (it's gone up a few percent since then). The only countries on the chart that spent less than 10% were Turkmenistan and Afghanistan. Draw your own conclusions. > People, THERE IS NO FREE LUNCH! Every product that is made and every > service rendered was a result of someone's hard labor. Sleep on that > you degenerates! No shit. I pay those taxes too, you know. I have no delusions about where the money comes from. > Hypocrisy! It's no different than the idiots who whine for the fair > treatment of fluffy mammals but them declare chemical warfare on > insects and reptiles. To them ONLY fluffy mammals deserve fair > treatment because they are so cuddly (and cute BTW) PUKE!. I fail to see any connection whatsoever. Animal lovers who only care about mammals are stealing money from taxpayers? > But you want to know the REAL reason? It's because mammals return love > and reptiles and insects don't. It's because people are selfish. If > another being will no reciprocate their love, then they murder that > being with extreme prejudice, and not feel one bit guilty about it! Do > you understand how backward you are? Do you understand how selfish and > immoral you are? Do you understand how incredibly dense you are? Yes, I am so selfish and immoral that I believe everybody should have access to health care. Instead I should be more like you, and label people who can't afford their own health care as "degenerates", and dismiss their health needs as being unimportant compared to my own completely selfless desire that none of my personal income be used to support the society that I live in and derive benefit from, without my full and specific consent. > Because of people like YOU, we don't deserve the right to evolve! What does that even mean? Evolution is a natural process. That's like saying "we don't deserve the right to be gravitationally bound to the planet", or "we don't deserve the right to drown if we fall in the ocean". From tjreedy at udel.edu Sat Feb 18 04:16:39 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Feb 2012 04:16:39 -0500 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 2/18/2012 2:28 AM, Ian Kelly wrote: > Here's a neat table: government spending as a percentage of GDP, by > country. > > http://anepigone.blogspot.com/2008/03/government-spending-as-percentage-of.html The table is for "national government spending". That means spending by the national government. The US has a lot of spending by state, county, city, school, and special districts that is not included. Total government spending in the US is about 40% of measured GDP. I *suspect* that the US has a higher percentage of non-national government spending than most other countries. For instance, government education spending is about 6% of GDP and that is mostly non-national here but, I believe, more national in some other countries. There are also issues with the denominator. In the US, if someone works at home without pay other than from a spouse, the value of the work is *not* included in GDP. If the same person goes to work elsewhere and hires someone to do the the same work around the home, that same work *is* counted. So the movement of house-spouses into the paid workforce has artificially inflated US GDP relative to, say, 50 years ago. There are also issues of measuring and including the unofficial, off-government books, 'underground' economy. That is relatively larger in many countries than in the US. I have the strong impression that the US IRS is much more diligent about ferreting out taxable income than the equivalent in many other countries. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sat Feb 18 10:02:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Feb 2012 07:02:22 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Feb 18, 1:28?am, Ian Kelly wrote: > On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson > If I were to [sum my tax burden], it would > probably come to around 30%, which still doesn't bother me, in part > because I know that it comes back to benefit the society I live in, > and by extension me, in one way or another.. But do you think you'll get a higher return for your investment? Is it possible to get a higher return on your investment in this type of system? NO! You better off just paying for your own damn healthcare. Well actually, there is a way to get a higher return by taking more than your "fair share". Any intelligent person would realize that public healthcare is advocated by degenerates or the bleeding heart "degenerate eugenics" supporters. Fine, YOU want to subsidize degeneracy? Then give to charity. The more you give the better you'll feel. BTW: How much money do you give to charity? Also, you mentioned Mitt paying 4 million dollars in taxes; that's more tax than you'll pay in a lifetime! > > I guess you never purchase > > ANYTHING or live under the tyranny of local jurisdictions ON TOP of > > the federal jurisdiction? > > Paying taxes to fund public schools, police departments, fire > departments, and road maintenance is "tyranny"? Read my comments and you will know that i support LIMITED infrastructure. Enough with the spin! > > Here is a list of taxes most everyone else will encounter: > > This list is awesome. ?I love how you include inflation and fines > imposed for breaking the law as "taxes". Do you think that ALL traffic tickets are based on reality? You don't think traffic cops are forced to meet ticket quotas? You don't believe that some people are wrongly accused? You don't think some police abuse their power? Have you heard of the many cases of death row inmates being proven innocent by DNA evidence? You are a FOOL to believe the justice system is perfect! >?Also how you state that > "most everyone" will have to pay taxes for fishing licenses, hunting > licenses, CDL licenses, and even corporate income. Maybe you live in Amish country, but I have driven on many US highways and i know for a fact that there are many, MANY, large trucks. All those truck drivers require a CDL license. Maybe you just ignore the people you consider to be "beneath you"? > ?Marriage license > tax? ?Yeah, I remember paying that fee. ?Once. ?I believe it was > somewhere around $50. And why do we need the state involved in our love lives? > ?And cigarette tax? ?Correct me if I'm wrong, > but isn't that one mostly paid by those "degenerates" you keep whining > about, the ones who aren't pulling their own weight? ?I hope you can > understand that I find it a bit ironic that you're now complaining > about cigarette tax. It IS a tax nonetheless. Of course the sales pitch for cigarette tax is that the profit will help offset the medical expenses of cancers due to smoking, BUT, do you REALLY believe all that money is going towards healthcare. HA! That's just more money in some politicians pocket! > > Actually i think 10% income tax is a fair amount although i believe > > taxing income silly. If the government cannot provide national > > security, domestic security, and LIMITED infratructure on 10% of what > > we make, they are wasting too much of OUR money. > > Here's a neat table: government spending as a percentage of GDP, by country. Don't trust polls. Heck, some polls even show Python rising in popularity! > > People, THERE IS NO FREE LUNCH! Every product that is made and every > > service rendered was a result of someone's hard labor. Sleep on that > > you degenerates! > > No shit. ?I pay those taxes too, you know. ?I have no delusions about > where the money comes from. Great. Thanks for being a productive member of society. But why do you support measures that will increase your tax burden? You'll never get back what you put in unless you're a degenerate. Also, you are empowering the government with more money. They can't even manage the money they have now! Has history taught you NOTHING! How many revolutions is it going to take? How many billions of lives is is going to take? When are you going to realize that taxation is tyranny? When are you going to realize that degenerates deserve what they get? > I fail to see any connection whatsoever. ?Animal lovers who only care > about mammals are stealing money from taxpayers? Public healthcare is YOU robbing someone else so YOU can get a service that you don't deserve! That's the hypocrisy! > Yes, I am so selfish and immoral that I believe everybody should have > access to health care. ?Instead I should be more like you, and label > people who can't afford their own health care as "degenerates", I NEVER labeled people who can't afford healthcare degenerates. Enough with the spin cycle already. > > Because of people like YOU, we don't deserve the right to evolve! > > What does that even mean? ?Evolution is a natural process. Not for long my friend. By wielding eugenics, even debutante intelligence's can harness evolution. In the near future, our technology will soon allow much better ways to harness evolution for our own gains. However, in the grander scheme, these flesh bodies are useless to us. Our fragile bodies where the best passport that evolution could give us, and are nothing more than a means to an end; they delivered us like the Santa Maria over perilous waters and into the new lands of enlightenment. Do you think we can travel the universe in biological bodies? That we can withstand the radiation? The lack of atmosphere? NO! Soon we shall cast these "flesh bags" away in the name of progress and become more powerful than evolution itself -- and in the process, we WILL cull the herd of all the selfish individuals and their foolish worship of nostalgic minutia! The individual will be destroyed in the name of progress. And the supreme being will be born! That is our destiny. Embrace it! THE HUMAN IS INSUFFICIENT! From invalid at invalid.invalid Sat Feb 18 10:25:23 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 18 Feb 2012 15:25:23 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On 2012-02-17, Dennis Lee Bieber wrote: > On Fri, 17 Feb 2012 09:55:46 -0700, Ian Kelly > wrote: > >> >>The shebang has to be the first thing in the file to be useful. As it >>is above, it might as well not be there. I would suggest also >>including a doc string in the skeleton. >> > Of course, since the OP was talking Windows... the #! line is > ignored no matter where it was That depends. It always used to work for me, but I'm usually using bash and Cygwin. From rd9663 at gmail.com Sat Feb 18 10:53:26 2012 From: rd9663 at gmail.com (roshni das) Date: Sat, 18 Feb 2012 07:53:26 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: <0e1558e1-0d8c-48f8-b87f-984bf10dacd1@x6g2000pbk.googlegroups.com> EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfree.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfree.yolasite.com/ Thanks ?? From breamoreboy at yahoo.co.uk Sat Feb 18 11:15:10 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 18 Feb 2012 16:15:10 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 18/02/2012 15:02, Rick Johnson wrote: > But do you think you'll get a higher return for your investment? Is it > possible to get a higher return on your investment in this type of > system? NO! You better off just paying for your own damn healthcare. > I guess you'd better get wikipedia to correct its incorrect data then. http://en.wikipedia.org/wiki/Health_care_in_the_United_States Specifically. http://en.wikipedia.org/wiki/File:International_Comparison_-_Healthcare_spending_as_%25_GDP.png -- Cheers. Mark Lawrence. From jason at powerpull.net Sat Feb 18 11:34:38 2012 From: jason at powerpull.net (Jason Friedman) Date: Sat, 18 Feb 2012 16:34:38 +0000 Subject: parse a profile Message-ID: I have a file I use for shell scripts that looks like this: export VAR1=/path/to/dir export VAR2=7 export VAR3=${VAR1}/further/path # comment . /another/file And a file /another/file: export VAR4=database-name Is there an existing package that will read such a file and return a dictionary like this: { 'VAR1': '/path/to/dir', 'VAR2': 7, 'VAR3': '/path/to/dir/further/path', 'VAR4': 'database-name', } From lie.1296 at gmail.com Sat Feb 18 12:46:30 2012 From: lie.1296 at gmail.com (Lie Ryan) Date: Sun, 19 Feb 2012 04:46:30 +1100 Subject: [OT]: Smartphones and Python? In-Reply-To: <4F3F0411.80508@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: On 02/18/2012 12:51 PM, Michael Torrie wrote: > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: >> Android is a customized linux OS used in mobile phones. I don't think >> any linux systm has to be locked by JAVA or any JVM to run >> applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. Strictly speaking, Android *is* a customized Linux distribution; what it is not is Android is not a GNU/Linux distribution. > It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. Android does have a full Linux experience; what it lacks is the GNU experience. Unlike "normal" Linux distros, Android does not use GNU userspace, instead it have its own userspace based on bionic, toolbox, and dalvik. Linux is a core part of Android's user and developer's experience. From rantingrickjohnson at gmail.com Sat Feb 18 13:34:24 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Feb 2012 10:34:24 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <2957aaeb-408c-4c91-8342-63dd30fc056b@p7g2000yqk.googlegroups.com> On Feb 18, 10:15?am, Mark Lawrence wrote: > On 18/02/2012 15:02, Rick Johnson wrote: > > > But do you think you'll get a higher return for your investment? Is it > > possible to get a higher return on your investment in this type of > > system? NO! You better off just paying for your own damn healthcare. > > I guess you'd better get wikipedia to correct its incorrect data then. Sure. I'll do that as soon as you show me mathematical evidence of how N people put X dollars each into a pot and then the same N people pull out MORE than X dollars each. If you can create a proof that creates money from nothing then we may find ourselves in the 1% tomorrow! Louie-the-loose-screw Said: "I'll give you $15 if you'll give me $15!" Okay Louie, but what is the point of that exercise besides money laundering? X + 0 = 0 From python at mrabarnett.plus.com Sat Feb 18 13:43:50 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 18 Feb 2012 18:43:50 +0000 Subject: parse a profile In-Reply-To: References: Message-ID: <4F3FF166.500@mrabarnett.plus.com> On 18/02/2012 16:34, Jason Friedman wrote: > I have a file I use for shell scripts that looks like this: > > export VAR1=/path/to/dir > export VAR2=7 > export VAR3=${VAR1}/further/path > # comment > . /another/file > > And a file /another/file: > export VAR4=database-name > > Is there an existing package that will read such a file and return a > dictionary like this: > { > 'VAR1': '/path/to/dir', > 'VAR2': 7, > 'VAR3': '/path/to/dir/further/path', > 'VAR4': 'database-name', > } I would probably do something like this: import re # Parse the file into a dict. with open(path) as f: d = dict(re.findall(r"(?m)^export (VAR\d+)=(.*)", f.read())) # Expand any references. for key, value in d.items(): d[key] = re.sub(r"\$\{(VAR\d+)\}", lambda m: d[m.group(1)], value) From pywin32 at gmail.com Sat Feb 18 13:49:39 2012 From: pywin32 at gmail.com (random joe) Date: Sat, 18 Feb 2012 10:49:39 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <2957aaeb-408c-4c91-8342-63dd30fc056b@p7g2000yqk.googlegroups.com> Message-ID: <1c4d1210-d324-44c7-9d6c-cec7cfc6a201@p21g2000yqm.googlegroups.com> On Feb 18, 12:34?pm, Rick Johnson wrote: > Louie-the-loose-screw Said: "I'll give you $15 if you'll give me $15!" $15 dolla too beau coup! 5 dolla each! From sherjilozair at gmail.com Sat Feb 18 13:58:02 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sat, 18 Feb 2012 10:58:02 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? Message-ID: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. I'm sure everyone would agree that doing this would make the terminal very powerful. What are your views on this? From jabba.laci at gmail.com Sat Feb 18 14:21:53 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Sat, 18 Feb 2012 20:21:53 +0100 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: Have a look at IPython (http://ipython.org/). It can interact with the normal shell very well. Laszlo On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > What are your views on this? > -- > http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Sat Feb 18 16:46:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 13:46:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4874001.114.1329601576682.JavaMail.geo-discussion-forums@pbcr5> ? 2012?2?19????UTC+8??3?21?53??Jabba Laci??? > Have a look at IPython (http://ipython.org/). It can interact with the > normal shell very well. > > Laszlo > > On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > > > What are your views on this? > > -- > > http://mail.python.org/mailman/listinfo/python-list Yeh, python could be used as a better shell in a text terminal box and with another text editor in another box to write scripts in developement. Also this is easy to test scripts found in the web by copy and paste. From dihedral88888 at googlemail.com Sat Feb 18 16:46:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 13:46:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4874001.114.1329601576682.JavaMail.geo-discussion-forums@pbcr5> ? 2012?2?19????UTC+8??3?21?53??Jabba Laci??? > Have a look at IPython (http://ipython.org/). It can interact with the > normal shell very well. > > Laszlo > > On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > > > What are your views on this? > > -- > > http://mail.python.org/mailman/listinfo/python-list Yeh, python could be used as a better shell in a text terminal box and with another text editor in another box to write scripts in developement. Also this is easy to test scripts found in the web by copy and paste. From cs at zip.com.au Sat Feb 18 17:58:43 2012 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 19 Feb 2012 09:58:43 +1100 Subject: parse a profile In-Reply-To: <4F3FF166.500@mrabarnett.plus.com> References: <4F3FF166.500@mrabarnett.plus.com> Message-ID: <20120218225843.GA13559@cskk.homeip.net> On 18Feb2012 18:43, MRAB wrote: | On 18/02/2012 16:34, Jason Friedman wrote: | > I have a file I use for shell scripts that looks like this: | > | > export VAR1=/path/to/dir | > export VAR2=7 | > export VAR3=${VAR1}/further/path | > # comment | > . /another/file | > | > And a file /another/file: | > export VAR4=database-name | > | > Is there an existing package that will read such a file and return a | > dictionary like this: | > { | > 'VAR1': '/path/to/dir', | > 'VAR2': 7, | > 'VAR3': '/path/to/dir/further/path', | > 'VAR4': 'database-name', | > } | | I would probably do something like this: | | import re | | # Parse the file into a dict. | with open(path) as f: | d = dict(re.findall(r"(?m)^export (VAR\d+)=(.*)", f.read())) | | # Expand any references. | for key, value in d.items(): | d[key] = re.sub(r"\$\{(VAR\d+)\}", lambda m: d[m.group(1)], value) Which fails on the ". /anther/file" step, alas. Jason's point is probably that it may be arbitrary shell. I suspect I would write a shell wrapper like this: #!/bin/sh exec 3>&1 1>&2 . /path/to/jason/s/file exec 1>&3 3>&- env then from inside Python call the shell to run the wrapper. Read the output of "env" and diff it against os.environ. Populate the dictionary with the values that have changed. Crude untested sketch: newvars = {} for envline in subprocess.blah(... run the wrapper script above ...): if not envline.endswith('\n'): raise ValueError("unexpected EOF") envline = envline[:-1] try: var, value = line.split('=', 1) except ValueError: # ouch! continue oldvalue = os.environ.get(var) if oldvalue is None or oldvalue != value: newvars[var] = value You can put the wrapper script as a single inline piece of shell to avoid the separate file once debugged. Just a thought. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ [...] post-block actions should be allowed everywhere, not just on subroutines. The ALWAYS keyword was agreed upon as a good way of doing this, although POST was also suggested. This lead to the semi-inevitable rehash of the try- catch exception handling debate. According to John Porter, "There is no try, there is only do. :-)" - from the perl6 development discussion From mcepl at redhat.com Sat Feb 18 18:41:49 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 19 Feb 2012 00:41:49 +0100 Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 16.2.2012 16:22, Michael Torrie wrote: > Android simply isn't going to run the JVM anytime soon. In reality yes, but just technically speaking there is the project IcedRobot (http://www.icedrobot.org/), which is a fork of Android over OpenJDK. Best, Mat?j From mcepl at redhat.com Sat Feb 18 18:45:18 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 19 Feb 2012 00:45:18 +0100 Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: > For one I don't know of any sun-compatible JVM > that has been ported to ARM. http://www.senecass.com/projects/OpenJDK-ARM/ "This work has been completed, and is now in OpenJDK HEAD. This page is now mostly for historical documentation." Also, http://openjdk.java.net/projects/zero/ (I know my colleagues from Red Hat are involved, because we are very interested in supporting more than just Intel chips well). Best, Mat?j From torriem at gmail.com Sat Feb 18 19:36:48 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 18 Feb 2012 17:36:48 -0700 Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <4F404420.3060408@gmail.com> On 02/18/2012 10:46 AM, Lie Ryan wrote: > Android does have a full Linux experience; what it lacks is the GNU > experience. Unlike "normal" Linux distros, Android does not use GNU > userspace, instead it have its own userspace based on bionic, toolbox, > and dalvik. Linux is a core part of Android's user and developer's > experience. The fact that RIM is porting Android to QNX would seem to contradict your assertion that Linux is a core part of Android's user and developer experience. Have you developed for Android? In what way do you interact with Linux in your apps and APIs? Can you make system calls? How is Linux a core part of Android's user and developer experience? I know that Android does allow some integration of native code, so that does meld Linux and Android somewhat. >From a user's pov (non-rooted), there is nothing of Linux exposed. I just install apps, run them, and manipulate my files which are stored in my sd card. The fact that it's in /mnt/sdcard is completely hidden, as are all files that support dalvik. The OS could be Windows, iOS, or whatever. It doesn't matter because the platform is not defined by the kernel but by the APIs that apps need to use to run on the platform, just like in Python! In fact in some ways calling Android "Linux" would be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" just because it happens to run atop that kernel. I have mentioned those specifically because they are interpreted or virtual machines themselves; the "binaries" run regardless of underlying CPU type, or kernel type. In my mind, the fact that Android runs on the Linux kernel is almost entirely coincidental to Android's aims. Google could have developed their own kernel, but of course it's much cheaper to use Linux. And of course Dalvik is currently written to consume posix APIs from the kernel. In my mind, and in my experience with Android, Linux is irrelevant. In fact continuing to call Android "Linux" might just be doing ourselves a disservice. In any case, saying that since it's linux, you can install anything you want on it, such as a JVM, is neither useful or accurate. From ross at biostat.ucsf.edu Sat Feb 18 19:54:18 2012 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Sat, 18 Feb 2012 16:54:18 -0800 Subject: #line in python Message-ID: <1329612858.9780.13.camel@corn.betterworld.us> The ast module shows that elements of the syntax tree have line and column numbers. Would it be sensible to attempt to revise them to achieve effects like the #line directive in C? Context: Using noweb, a literate programming tool, which from a source file foo.nw produces foo.py. The lines in the two files may be in completely different sequenes. For debugging, it is useful to receive error reports that refer to the original line number in foo.nw. I am not sure how such rewriting would interact with debugger commands that set a breakpoint at a file and line number. I'm also not sure it would change the reported line numbers of errors. The lack of a file name could be problematic if multiple sources contributed to the same .py file, but that is an unlikely scenario. As an extension or alternate, could there be a decorator like @source_line(lineno, filename) for classes and methods that could do the conversion on the fly? I don't know if there's a way to go from the function (or class) object the decorator receives to the AST. Comments? Ross Boylan From nogradi at gmail.com Sat Feb 18 21:00:22 2012 From: nogradi at gmail.com (Daniel Nogradi) Date: Sun, 19 Feb 2012 03:00:22 +0100 Subject: [ANN] markup.py 1.8 Message-ID: A new release of markup.py is available at http://markup.sourceforge.net/ This new release is compatible with both python 2 and 3. What is markup.py? Markup.py is an intuitive, light weight, easy-to-use, customizable and pythonic HTML/XML generator. The only goal is quickly writing HTML/XML segments or whole documents programatically if you need anything more than that you probably want to look for a templating engine. -- interior | space | design | http://www.annazeibig.com | 3d | living | deco From steve+comp.lang.python at pearwood.info Sat Feb 18 22:44:07 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Feb 2012 03:44:07 GMT Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f407007$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 19:09:32 -0800, rusi wrote: > I have some bunch of sanskrit (devanagari) to type. It would be easiest > for me if I could have the English (roman) as well as the sanskrit > (devanagari). > > For example using the devanagari-itrans input method I can write the > gayatri mantra using > > OM bhUrbhuvaH suvaH > tatsaviturvarenyam > bhargo devasya dhImahi > dhiyo yonaH prachodayAt > > and emacs produces *on the fly* (ie I cant see/edit the above) > > ? ???????? ???? ?????????????????? ????? ?????? ????? ???? ???? > ?????????? > > Can I do it in batch mode? ie write the first in a file and run some > command on it to produce the second? What is the devanagari-itrans input method? Do you actually type the characters into a terminal? If so, you should be able to type the first into a file, copy it, then paste it into the input buffer to be processed. -- Steven From bryanjugglercryptographer at yahoo.com Sat Feb 18 23:05:25 2012 From: bryanjugglercryptographer at yahoo.com (Bryan) Date: Sat, 18 Feb 2012 20:05:25 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> SherjilOzair wrote: > Has it been considered to add shell features > to python, such that it can be used as a > default shell, as a replacement for bash, etc. I think yes, but rather than become a shell, Python makes easy programming a shell that can execute Python code. The tendency has been to excel as a scripting language, and prefer to add extra features to the standard library. To start, look at the built-in functions eval() and (raw_)input; and the library modules: subprocess, os and os.path, glob and re, shutil, and code. > I'm sure everyone would agree that doing this > would make the terminal very powerful. 'Cept of course that they already are. From yves at zioup.com Sun Feb 19 00:47:52 2012 From: yves at zioup.com (yves at zioup.com) Date: Sat, 18 Feb 2012 22:47:52 -0700 Subject: tkinter.Toplevel In-Reply-To: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> References: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> Message-ID: On 2012-02-17 16:48, Rick Johnson wrote: > On Feb 16, 8:39 pm, y... at zioup.com wrote: >> With a tkinter.Toplevel, how can I "disable" the parent windown and all its >> widget, in the same fashion as tkinter.messagebox? > > The answer lies within the tkSimpleDialog source code; which is pure > python. Look in the __init__ method of Dialog class. My advice is to > study the code until you understand every line. Look at the following > references when you need more info: > > http://infohost.nmt.edu/tcc/help/pubs/tkinter/ > http://effbot.org/tkinterbook/ ...grab_set() Thanks. -- Yves. http://www.SollerS.ca/ http://ipv6.SollerS.ca http://blog.zioup.org/ From dihedral88888 at googlemail.com Sun Feb 19 00:58:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 21:58:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <27781830.3.1329631112403.JavaMail.geo-discussion-forums@pbne2> ? 2012?2?19????UTC+8??8?36?48??Michael Torrie??? > On 02/18/2012 10:46 AM, Lie Ryan wrote: > > Android does have a full Linux experience; what it lacks is the GNU > > experience. Unlike "normal" Linux distros, Android does not use GNU > > userspace, instead it have its own userspace based on bionic, toolbox, > > and dalvik. Linux is a core part of Android's user and developer's > > experience. > > The fact that RIM is porting Android to QNX would seem to contradict > your assertion that Linux is a core part of Android's user and developer > experience. Have you developed for Android? In what way do you > interact with Linux in your apps and APIs? Can you make system calls? > How is Linux a core part of Android's user and developer experience? I > know that Android does allow some integration of native code, so that > does meld Linux and Android somewhat. > > >From a user's pov (non-rooted), there is nothing of Linux exposed. I > just install apps, run them, and manipulate my files which are stored in > my sd card. The fact that it's in /mnt/sdcard is completely hidden, as > are all files that support dalvik. The OS could be Windows, iOS, or > whatever. It doesn't matter because the platform is not defined by the > kernel but by the APIs that apps need to use to run on the platform, > just like in Python! In fact in some ways calling Android "Linux" would > be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" > just because it happens to run atop that kernel. I have mentioned those > specifically because they are interpreted or virtual machines > themselves; the "binaries" run regardless of underlying CPU type, or > kernel type. > > In my mind, the fact that Android runs on the Linux kernel is almost > entirely coincidental to Android's aims. Google could have developed > their own kernel, but of course it's much cheaper to use Linux. And of > course Dalvik is currently written to consume posix APIs from the kernel. > > In my mind, and in my experience with Android, Linux is irrelevant. Do you have to write a touch screen device driver under any mobile phone requested by your boss? If the current one is not suitable in the market entangled with law suites from other big corps, do you have to chunk a clean implementation? > In > fact continuing to call Android "Linux" might just be doing ourselves a > disservice. In any case, saying that since it's linux, you can install > anything you want on it, such as a JVM, is neither useful or accurate. Check the Jython JRE lib. If it is not compatable under Android's system, then there are jobs to do in the JVM maintainer in Androids or some revised requests for the Jython JRE library group. From dihedral88888 at googlemail.com Sun Feb 19 00:58:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 21:58:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <27781830.3.1329631112403.JavaMail.geo-discussion-forums@pbne2> ? 2012?2?19????UTC+8??8?36?48??Michael Torrie??? > On 02/18/2012 10:46 AM, Lie Ryan wrote: > > Android does have a full Linux experience; what it lacks is the GNU > > experience. Unlike "normal" Linux distros, Android does not use GNU > > userspace, instead it have its own userspace based on bionic, toolbox, > > and dalvik. Linux is a core part of Android's user and developer's > > experience. > > The fact that RIM is porting Android to QNX would seem to contradict > your assertion that Linux is a core part of Android's user and developer > experience. Have you developed for Android? In what way do you > interact with Linux in your apps and APIs? Can you make system calls? > How is Linux a core part of Android's user and developer experience? I > know that Android does allow some integration of native code, so that > does meld Linux and Android somewhat. > > >From a user's pov (non-rooted), there is nothing of Linux exposed. I > just install apps, run them, and manipulate my files which are stored in > my sd card. The fact that it's in /mnt/sdcard is completely hidden, as > are all files that support dalvik. The OS could be Windows, iOS, or > whatever. It doesn't matter because the platform is not defined by the > kernel but by the APIs that apps need to use to run on the platform, > just like in Python! In fact in some ways calling Android "Linux" would > be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" > just because it happens to run atop that kernel. I have mentioned those > specifically because they are interpreted or virtual machines > themselves; the "binaries" run regardless of underlying CPU type, or > kernel type. > > In my mind, the fact that Android runs on the Linux kernel is almost > entirely coincidental to Android's aims. Google could have developed > their own kernel, but of course it's much cheaper to use Linux. And of > course Dalvik is currently written to consume posix APIs from the kernel. > > In my mind, and in my experience with Android, Linux is irrelevant. Do you have to write a touch screen device driver under any mobile phone requested by your boss? If the current one is not suitable in the market entangled with law suites from other big corps, do you have to chunk a clean implementation? > In > fact continuing to call Android "Linux" might just be doing ourselves a > disservice. In any case, saying that since it's linux, you can install > anything you want on it, such as a JVM, is neither useful or accurate. Check the Jython JRE lib. If it is not compatable under Android's system, then there are jobs to do in the JVM maintainer in Androids or some revised requests for the Jython JRE library group. From sherjilozair at gmail.com Sun Feb 19 03:16:43 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sun, 19 Feb 2012 00:16:43 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> Message-ID: <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. Shell would give python raw power! And Python would manage it well. From sherjilozair at gmail.com Sun Feb 19 03:18:16 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sun, 19 Feb 2012 00:18:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> Message-ID: <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. Shell would give python raw power! And Python would manage it well. From steve+comp.lang.python at pearwood.info Sun Feb 19 03:49:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Feb 2012 08:49:57 GMT Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4f40b7b5$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Feb 2012 00:16:43 -0800, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another > shell, which borrows a lot from python, something like merging bash and > python. such that I can do `cd ~/Desktop/dev` and `for i in > open('file.txt'): print i` at the some shell. This I think would be VERY > useful. > > IPyhton is very good, but after all, it is just an advanced interpreter, > not a default shell. I don't want this to run on top of bash or sh. But > it should run on its own, at shell level. That's up to your operating system. If your OS lets you choose a shell, tell it to use IPython. IPython already supports being used as the system shell: http://ipython.org/ipython-doc/dev/interactive/shell.html http://transneptune.net/2009/06/16/ipython-as-your-default-shell/ If your OS doesn't support choosing a shell, you can't use anything but the built-in shell regardless of what Python does. Either way, this is not a Python problem to solve. It is an OS issue. -- Steven From rustompmody at gmail.com Sun Feb 19 03:52:34 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 19 Feb 2012 00:52:34 -0800 (PST) Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f407007$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <6c4323a5-79bb-4105-8581-a2bef19fc39b@4g2000pbz.googlegroups.com> On Feb 19, 8:44?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 19:09:32 -0800, rusi wrote: > > I have some bunch of sanskrit (devanagari) to type. ?It would be easiest > > for me if I could have the English (roman) as well as the sanskrit > > (devanagari). > > > For example using the devanagari-itrans input method I can write the > > gayatri mantra using > > > OM bhUrbhuvaH suvaH > > tatsaviturvarenyam > > bhargo devasya dhImahi > > dhiyo yonaH prachodayAt > > > and emacs produces *on the fly* (ie I cant see/edit the above) > > > ? ???????? ???? ?????????????????? ????? > > ?????? ????? ???? ???? > > > ?????????? > > > Can I do it in batch mode? ie write the first in a file and run some > > command on it to produce the second? > > What is the devanagari-itrans input method? Do you actually type the > characters into a terminal? Its one of the dozens (hundreds actually) of input methods that emacs has. In emacs M-x set-input-method and then give devanagari-itrans. Its details are described (somewhat poorly) here http://en.wikipedia.org/wiki/ITRANS > > If so, you should be able to type the first into a file, copy it, then > paste it into the input buffer to be processed. For now Ive got it working in emacs with some glitches but it will do for now: http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/bfa6b05ce565d96d# > > -- > Steven Thanks [Actually thanks-squared one for looking two for backing up this thread to something more useful than ... :-) ] Coincidentally, along this, your response, Ive got another mail to another unicode related interest of mine: apl under linux. So far I was the sole (known) user of this: http://www.emacswiki.org/emacs/AplInDebian I hear the number of users has just doubled :-) From tjreedy at udel.edu Sun Feb 19 13:28:38 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Feb 2012 13:28:38 -0500 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> Message-ID: On 2/19/2012 3:18 AM, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another > shell, which borrows a lot from python, something like merging bash > and python. such that I can do `cd ~/Desktop/dev` and `for i in 'cd xxx' cannot work because that is not python syntax. "cd('xxx')" could. Right now, one can import os and do shell stuff, but not so convinient for interactive use. 'os.chdir' is not so convenient as 'cd'. Two possible options, either of which might exist on PyPI: 1. a shell module used as 'from bashshell import *' which would have functions closely mimicking, in this example, bash 2. a shell module used as 'from bashshell import bash; bash()' which would invoke an sub-interactive mode like help() that would allow 'cd xxx' and similar syntax, which still affecting the global environment. The latter would trade the inconvenience of '()'s for the inconvenience of entering and exiting a special submode. I have not used IPYthon so I have no idea how close it gets to either of these. -- Terry Jan Reedy From sorsorday at gmail.com Sun Feb 19 15:23:21 2012 From: sorsorday at gmail.com (Herman) Date: Sun, 19 Feb 2012 12:23:21 -0800 Subject: logging with logging.config.fileConfig Message-ID: I tried to use file to config my logger and I got a weird situation that each message is outputted twice... Here is my scenario: python: 2.6 file abc_logging.conf: [loggers] keys=root,abc [handlers] keys=consoleHandler [formatters] keys=detailFormatter [logger_root] level=DEBUG handlers=consoleHandler [logger_abc] level=DEBUG handlers=consoleHandler qualname=abc [handler_consoleHandler] class=StreamHandler level=DEBUG formatter=detailFormatter args=(sys.stdout,) [formatter_detailFormatter] format=%(asctime)-15s %(levelname)s: %(filename)s:%(lineno)s: %(message)s datefmt=%Y-%m-%d %H:%M:%S Then in my program, i config the file with this: SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) logging.config.fileConfig(SCRIPT_DIR + os.path.sep + 'abc_logging.conf') LOG = logging.getLogger('abc') I tried to print out the logger handlers with this: print("*"*10) print("number of handlers: %s" % len(LOG.handlers)) print(LOG.handlers) LOG.debug(sql) But there is no suspicious behavior: ********** number of handlers: 1 [] 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... From python at mrabarnett.plus.com Sun Feb 19 16:07:10 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Feb 2012 21:07:10 +0000 Subject: logging with logging.config.fileConfig In-Reply-To: References: Message-ID: <4F41647E.2020400@mrabarnett.plus.com> On 19/02/2012 20:23, Herman wrote: > I tried to use file to config my logger and I got a weird situation > that each message is outputted twice... > Here is my scenario: > python: 2.6 > > file abc_logging.conf: > [snip] > [logger_abc] > level=DEBUG > handlers=consoleHandler > qualname=abc Add this line to stop the logging message from being propagated to higher level (ancestor) loggers: propagate=0 [snip] > > > Then in my program, i config the file with this: > > SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) > logging.config.fileConfig(SCRIPT_DIR + os.path.sep + 'abc_logging.conf') > LOG = logging.getLogger('abc') > > > I tried to print out the logger handlers with this: > print("*"*10) > print("number of handlers: %s" % len(LOG.handlers)) > print(LOG.handlers) > LOG.debug(sql) > > But there is no suspicious behavior: > > ********** > number of handlers: 1 > [] > 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... > 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... From torriem at gmail.com Sun Feb 19 19:23:33 2012 From: torriem at gmail.com (Michael Torrie) Date: Sun, 19 Feb 2012 17:23:33 -0700 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4F419285.807@gmail.com> On 02/18/2012 11:58 AM, SherjilOzair wrote: > Has it been considered to add shell features to python, such that it > can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal > very powerful. > > What are your views on this? I use python for system programming all the time, in place of bash. However Python is not designed as shell language, just as Bash is not really designed for the type of application development that Python is. Bash works by giving you a view of the file system as your primary way of interacting with it as a shell. This is ideal because usually you want to manipulate files and processes (that's just what you do on a command line shell normally). Python doesn't work on that level. Like other langueages like php, you can manipulate files and processes through standard library calls. Frankly doing: cd ~/blah is much faster and more convenient in an interactive shell than: import os os.chdir(os.getenv("HOME") + "/blah") Also bash is designed to start and control processes: ls *.txt | wc -l or someprocess | grep something 2>&1 > /tmp/somefile.txt In python there is no direct correlation to these things, and in fact Python has different ways of doing that kind of thing (better for some things) if you want to write scripts (for example, http://www.dabeaz.com/generators/) My own experience has shown me that Python is a very capable systems-programming language, but that traditional shells are there for a reason. And if I need to script something, I usually go to Bash first because it's simpler and easier, at least for very small tasks. Once the bash script gets to be 100 lines or more, I switch to python. Then I use some modules I wrote myself to make subprocess.Popen a little simpler. Another library that I heard about on this list, called extproc, also seems to be similarly great for doing this. There have been attempts over the years to bring access to files and processes into python and still be pythonic, but they are all awkward. For example, this sort of syntax using dynamic attributes: shell.wc(shell.ls('/tmp/*.txt'), "-l") or shell.ls('/tmp/*.txt').pipe(shell.wc()) But it turns out that coming up with a python-compatible syntax is pretty hard, especially when it comes to pipes (don't forget standard err!) Besides all this, it's just plain awkward and unnecessary. From dihedral88888 at googlemail.com Mon Feb 20 01:15:44 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 19 Feb 2012 22:15:44 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <15520563.12.1329718544660.JavaMail.geo-discussion-forums@pbnv3> ? 2012?2?20????UTC+8??8?23?33??Michael Torrie??? > On 02/18/2012 11:58 AM, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it > > can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal > > very powerful. > > > > What are your views on this? > > I use python for system programming all the time, in place of bash. > However Python is not designed as shell language, just as Bash is not > really designed for the type of application development that Python is. > To use Python as a shell with customized scripts is feasiable for those hose have to work on different OS enviroments from time to time. This is a handy approach to ease the user the burden to memorize different commands of different OS environments. Of course, this might add some overheads in executing some operations. Nowadays attracting more people especially noices to use linux is the way to keep unix programming alive in the future. From dihedral88888 at googlemail.com Mon Feb 20 01:15:44 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 19 Feb 2012 22:15:44 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <15520563.12.1329718544660.JavaMail.geo-discussion-forums@pbnv3> ? 2012?2?20????UTC+8??8?23?33??Michael Torrie??? > On 02/18/2012 11:58 AM, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it > > can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal > > very powerful. > > > > What are your views on this? > > I use python for system programming all the time, in place of bash. > However Python is not designed as shell language, just as Bash is not > really designed for the type of application development that Python is. > To use Python as a shell with customized scripts is feasiable for those hose have to work on different OS enviroments from time to time. This is a handy approach to ease the user the burden to memorize different commands of different OS environments. Of course, this might add some overheads in executing some operations. Nowadays attracting more people especially noices to use linux is the way to keep unix programming alive in the future. From jerry.scofield at gmail.com Mon Feb 20 03:54:11 2012 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Mon, 20 Feb 2012 16:54:11 +0800 Subject: Beware, my computer was infected. In-Reply-To: <4F3ECE37.9000401@gmail.com> References: <4F3C4F31.8020303@gmail.com> <4F3ECE37.9000401@gmail.com> Message-ID: By the way, i like 1.exe, can i have it? ? 2012?2?18? ??6:01?Jugurtha Hadjar ??? > On 16/02/2012 01:34, Jugurtha Hadjar wrote: > >> Hello gentlemen, >> >> I'm writing these words to give you a heads up. My computer has recently >> been infected with "1.exe", and I am doing what I can to contain it. It >> spreads via mail and I fear it will send SPAM to lists I am subscribed to. >> >> If you receive weird mails from my address, thank you to report it to me. >> I will not send you an executable, so if you receive one from me, please do >> not open it and it would be nice to report it. >> >> I will send an e-mail to this list once I think it is no longer in the >> system. >> >> Thank you all. >> >> > Everything is under control. > > > > -- > ~Jugurtha Hadjar, > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Mon Feb 20 06:27:06 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 20 Feb 2012 11:27:06 GMT Subject: #line in python References: Message-ID: Ross Boylan wrote: > As an extension or alternate, could there be a decorator like > @source_line(lineno, filename) > for classes and methods that could do the conversion on the fly? I > don't know if there's a way to go from the function (or class) object > the decorator receives to the AST. > No [easy] way to go from bytecodes back to AST, but I see no reason why you can't create a new code object with your filename and line numbers and then create a new function using your modified code object. If you don't have a 1:1 correspondence of lines then you'll need to pick out all the existing line numbers from the code object co_lnotab and modify them: see dis.py findlinestarts() for how to do this. Classes would be harder: the decorator doesn't run until after the class body has executed, so you can't change the line numbers that way until it's too late. The only thing I can think would be to put all of the generated code inside a function and fix up that function with a decorator that scans the bytecode to find all contained classes and fix them up. Or you could generate a .pyc file and then fix up line numbers in the whole file: see http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html for some code that shows you what's in a .pyc -- Duncan Booth http://kupuguy.blogspot.com From jeanmichel at sequans.com Mon Feb 20 06:48:22 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 12:48:22 +0100 Subject: logging with logging.config.fileConfig In-Reply-To: <4F41647E.2020400@mrabarnett.plus.com> References: <4F41647E.2020400@mrabarnett.plus.com> Message-ID: <4F423306.1070204@sequans.com> MRAB wrote: > On 19/02/2012 20:23, Herman wrote: >> I tried to use file to config my logger and I got a weird situation >> that each message is outputted twice... >> Here is my scenario: >> python: 2.6 >> >> file abc_logging.conf: >> > [snip] >> [logger_abc] >> level=DEBUG >> handlers=consoleHandler >> qualname=abc > > Add this line to stop the logging message from being propagated to > higher level (ancestor) loggers: > > propagate=0 > > [snip] >> An alternative solution is to add a handler to the root logger only. If you don't plan to have specific handling for the abc logger, this is the way to go. Remove "handlers=consoleHandler" from abc section. Note that %name will still properly identifies the logger that raised the event. JM From jeanmichel at sequans.com Mon Feb 20 06:53:49 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 12:53:49 +0100 Subject: [OT]: Smartphones and Python? In-Reply-To: <4F3F0411.80508@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <4F42344D.90305@sequans.com> Michael Torrie wrote: > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. > It's a bot. Add it to your kill file. JM From johannes.exner at tu-dortmund.de Mon Feb 20 09:57:07 2012 From: johannes.exner at tu-dortmund.de (JohannesTU) Date: Mon, 20 Feb 2012 06:57:07 -0800 (PST) Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' Message-ID: <1329749827797-4487915.post@n6.nabble.com> Hello everyone, I'm new to linux/suse, but I was given the task to install the print accounting software PyKota. Before that I never even touched a linux system, so I don't have any basic knowlegde at all! Up to now I was able to solve all problems with the help of google, but now I'm stuck. My problem: linux-6n5c:/usr/local/bin # pkusers --add john paul Creation... ERROR: PyKota v1.26_official ERROR: pkusers failed ERROR: Traceback (most recent call last): ERROR: File "/usr/local/bin/pkusers", line 442, in ERROR: retcode = manager.main(args, options) ERROR: File "/usr/local/bin/pkusers", line 345, in main ERROR: oldentry = getattr(self.storage, "add%s" % suffix)(entry) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 598, in addUser ERROR: oldentry = self.getUser(user.Name) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storage.py", line 623, in getUser ERROR: user = self.getUserFromBackend(username) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 355, in getUserFromBackend ERROR: % self.doQuote(self.userCharsetToDatabase(username))) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/pgstorage.py", line 144, in doQuote ERROR: return pg._quote(field, typ) ERROR: AttributeError: 'module' object has no attribute '_quote' I have no idea how to deal with it or what it even means! Executing "linux-6n5c:/usr/local/bin # pkusers" works fine and shows me commands, version number etc. But adding users or printers (with pkprinters) won't work. I would be really thankful if anyone could give me some advice or hints how to solve the problem! Kind regards Johannes -- View this message in context: http://python.6.n6.nabble.com/PyKota-Python-AttributeError-module-object-has-no-attribute-quote-tp4487915p4487915.html Sent from the Python - python-list mailing list archive at Nabble.com. From ross at biostat.ucsf.edu Mon Feb 20 10:08:55 2012 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Mon, 20 Feb 2012 07:08:55 -0800 Subject: #line in python (dirty tricks) In-Reply-To: <1329612858.9780.13.camel@corn.betterworld.us> References: <1329612858.9780.13.camel@corn.betterworld.us> Message-ID: <1329750535.1208.22.camel@corn.betterworld.us> Duncan Booth wrote ________________________________________________________________________ > Ross Boylan wrote: > > > As an extension or alternate, could there be a decorator like > > @source_line(lineno, filename) > > for classes and methods that could do the conversion on the fly? I > > don't know if there's a way to go from the function (or class) object > > the decorator receives to the AST. > > > No [easy] way to go from bytecodes back to AST, but I see no reason why you > can't create a new code object with your filename and line numbers and then > create a new function using your modified code object. Could you elaborate? I don't understand what you are suggesting. > > If you don't have a 1:1 correspondence of lines then you'll need to pick > out all the existing line numbers from the code object co_lnotab and modify > them: see dis.py findlinestarts() for how to do this. > > Classes would be harder: the decorator doesn't run until after the class > body has executed, so you can't change the line numbers that way until it's > too late. The only thing I can think would be to put all of the generated > code inside a function and fix up that function with a decorator that scans > the bytecode to find all contained classes and fix them up. > > Or you could generate a .pyc file and then fix up line numbers in the whole > file: see > http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html for > some code that shows you what's in a .pyc > My latest concept is to produce code that rewrites itself. Suppose the naive file would be ----------- mycode.py (naive) -------------------------------- class SomeClass: "class comment" def some_function(self, bar): pass --------- end ------------------------------- Protect that code by putting an "if 0:" in front of it and indenting each line one space. Than prepend a bit of code to do the rewriting, and add indicators of the original line numbers. ----------- mycode.py (after wrapping) ------------- from detangle import detangle detangle("mycode.py", "mycode.nw") if 0: # original code goes here class SomeClass: "class comment" #and when line numbering changes #line 35 def some_function(self, bar): pass ------------- end ------------------- I would write detangle so that it scans through the file in which it appears (named in the first argument), rewriting so that it appears to come from the original file (mycode.nw) given in the second argument. The scanning would look for the "if 0:" in the file. At that point it would accumulate code by reading lines and stripping the leading space. If it found a #line directive it would remember it and then remove it from the string it was accumulating. Finally, detangle would would pass the string of code to ast.compile, catching any syntax errors and rewriting the file and line number (I might rewrite columns too with an extension) and then rethrowing them. If compilation succeeded detangle could rewrite the AST and then exec it. Ross From jason at powerpull.net Mon Feb 20 11:03:25 2012 From: jason at powerpull.net (Jason Friedman) Date: Mon, 20 Feb 2012 16:03:25 +0000 Subject: HTTP logging Message-ID: I am logging to HTTP: logger.addHandler(logging.handlers.HTTPHandler(host, url)) Works great, except if my HTTP server happens to be unavailable: socket.error: [Errno 111] Connection refused Other than wrapping all my logger.log() calls in try/except blocks, is there a way to skip logging to the HTTPhandler if the HTTP server is unavailable? From arnodel at gmail.com Mon Feb 20 11:16:42 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 20 Feb 2012 16:16:42 +0000 Subject: HTTP logging In-Reply-To: References: Message-ID: On 20 February 2012 16:03, Jason Friedman wrote: > I am logging to HTTP: > > logger.addHandler(logging.handlers.HTTPHandler(host, url)) > > Works great, except if my HTTP server happens to be unavailable: > > socket.error: [Errno 111] Connection refused > > Other than wrapping all my logger.log() calls in try/except blocks, is > there a way to skip logging to the HTTPhandler if the HTTP server is > unavailable? Here's one: subclass HTTPHandler :) -- Arnaud From nandinighosh35 at gmail.com Mon Feb 20 11:59:36 2012 From: nandinighosh35 at gmail.com (nandini ghosh) Date: Mon, 20 Feb 2012 08:59:36 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: <2f27be36-017e-4f25-a83e-00ec50e72d7f@ow3g2000pbc.googlegroups.com> EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfree.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfree.yolasite.com/ Thanks ?? From jeanmichel at sequans.com Mon Feb 20 12:07:49 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 18:07:49 +0100 Subject: HTTP logging In-Reply-To: References: Message-ID: <4F427DE5.8040201@sequans.com> Arnaud Delobelle wrote: > On 20 February 2012 16:03, Jason Friedman wrote: > >> I am logging to HTTP: >> >> logger.addHandler(logging.handlers.HTTPHandler(host, url)) >> >> Works great, except if my HTTP server happens to be unavailable: >> >> socket.error: [Errno 111] Connection refused >> >> Other than wrapping all my logger.log() calls in try/except blocks, is >> there a way to skip logging to the HTTPhandler if the HTTP server is >> unavailable? >> > > Here's one: subclass HTTPHandler :) > > short answer: use > logging.raiseExceptions = 0 long and incomplete answer: log calls should not raise any exception. http://docs.python.org/library/logging.html#handler-objects "Handler.handleError(record) This method should be called from handlers when an exception is encountered during an emit() call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The specified record is the one which was being processed when the exception occurred" " However, I looked into the code and find out an (undocumented ?) attribute of the logging module : raiseException which value is set to 1 by default (python 2.5.2 logging.__version__ < '0.5.0.2' > ). When set to 1, handlerError print the traceback. This has been probably fixed in recent version of the module since the handleError doc does not reference raiseException anymore. JM From __peter__ at web.de Mon Feb 20 12:26:12 2012 From: __peter__ at web.de (Peter Otten) Date: Mon, 20 Feb 2012 18:26:12 +0100 Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' References: <1329749827797-4487915.post@n6.nabble.com> Message-ID: JohannesTU wrote: > Hello everyone, > > I'm new to linux/suse, but I was given the task to install the print > accounting software PyKota. > Before that I never even touched a linux system, so I don't have any basic > knowlegde at all! > Up to now I was able to solve all problems with the help of google, but > now I'm stuck. > > My problem: > > > linux-6n5c:/usr/local/bin # pkusers --add john paul > Creation... > ERROR: PyKota v1.26_official > ERROR: pkusers failed > ERROR: Traceback (most recent call last): > ERROR: File "/usr/local/bin/pkusers", line 442, in > ERROR: retcode = manager.main(args, options) > ERROR: File "/usr/local/bin/pkusers", line 345, in main > ERROR: oldentry = getattr(self.storage, "add%s" % suffix)(entry) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 598, > in addUser > ERROR: oldentry = self.getUser(user.Name) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storage.py", line 623, in > getUser > ERROR: user = self.getUserFromBackend(username) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 355, > in getUserFromBackend > ERROR: % self.doQuote(self.userCharsetToDatabase(username))) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/pgstorage.py", > line 144, in doQuote > ERROR: return pg._quote(field, typ) > ERROR: AttributeError: 'module' object has no attribute '_quote' > > > I have no idea how to deal with it or what it even means! I suppose you have successfully repaired your car, but don't know what an engine might be ;) > Executing "linux-6n5c:/usr/local/bin # pkusers" works fine and shows me > commands, version number etc. > But adding users or printers (with pkprinters) won't work. > > I would be really thankful if anyone could give me some advice or hints > how to solve the problem! The error traceback explained: Python is trying to call a function named _quote() in a module named pg. The most likely reason is either that you have the wrong version of the module or a module unrelated to the required one that has the same name and appears earlier in Python's search path. You can start debugging with $ python2.7 -c'import pg; print pg.__file__' to find out the filename and then look into the corresponding .py file. If that is related to postgresql you are probably seeing a version mismatch. Consult PyKota's documentation to find out the program's dependencies. From bblais at gmail.com Mon Feb 20 12:45:56 2012 From: bblais at gmail.com (Brian Blais) Date: Mon, 20 Feb 2012 12:45:56 -0500 Subject: paper submission and versioning system - advice? Message-ID: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> Hello, I'd like to find a web-based system to help a committee I'm on, where we receive proposals from different faculty. I wrote something in python, from scratch, a number of years ago because there wasn't anything available then but it is showing its age and I figured that someone has written something. Essentially I need users to be able to start a proposal, with some basic information, and then be able to add files to it. Other users will be allowed to add files as well, but I'd like to limit deletions to the committee members. It seems as if there just has to be available tools like this, but I am not even sure what such a system is called. Is there anything like this, in python preferably? thanks, Brian Blais -- Brian Blais bblais at gmail.com http://web.bryant.edu/~bblais http://brianblais.wordpress.com/ From vinay_sajip at yahoo.co.uk Mon Feb 20 12:47:54 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 20 Feb 2012 09:47:54 -0800 (PST) Subject: HTTP logging References: Message-ID: <3fbdb48b-675d-4345-a28c-1778bcb68108@db5g2000vbb.googlegroups.com> On Feb 20, 5:07?pm, Jean-Michel Pichavant wrote: > However, I looked into the code and find out an (undocumented ?) > attribute of the logging module : raiseException which value is set to 1 > by default (python 2.5.2 logging.__version__ < '0.5.0.2' > ). > > When set to 1, handlerError print the traceback. > > This has been probably fixed in recent version of the module since the > handleError doc does not reference raiseException anymore. Actually, I think it's a mistake in the docs - when they were reorganised a few months ago, the text referring to raiseExceptions was moved to the tutorial: http://docs.python.org/howto/logging.html#exceptions-raised-during-logging I will reinstate it in the reference API docs, but the answer to Jason's problem is to either subclass HTTPHandler and override handleError to suppress the error, or set logging.raiseExceptions to True (in which case all logging exceptions will be swallowed - not necessarily what he wants). Regards, Vinay Sajip From andrea.crotti.0 at gmail.com Mon Feb 20 13:47:09 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 20 Feb 2012 18:47:09 +0000 Subject: paper submission and versioning system - advice? In-Reply-To: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> References: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> Message-ID: <4F42952D.3030505@gmail.com> On 02/20/2012 05:45 PM, Brian Blais wrote: > Hello, > > I'd like to find a web-based system to help a committee I'm on, where we receive proposals from different faculty. I wrote something in python, from scratch, a number of years ago because there wasn't anything available then but it is showing its age and I figured that someone has written something. > > Essentially I need users to be able to start a proposal, with some basic information, and then be able to add files to it. Other users will be allowed to add files as well, but I'd like to limit deletions to the committee members. > > It seems as if there just has to be available tools like this, but I am not even sure what such a system is called. Is there anything like this, in python preferably? > > > thanks, > > Brian Blais > Well I guess that any web framework would provide you more or less easily with all you need.. Django turbogears pyramid flask or web2py are just the names I know. From vinay_sajip at yahoo.co.uk Mon Feb 20 13:53:14 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 20 Feb 2012 10:53:14 -0800 (PST) Subject: HTTP logging References: <3fbdb48b-675d-4345-a28c-1778bcb68108@db5g2000vbb.googlegroups.com> Message-ID: <87f28356-5582-49f2-8b85-39f0c3b86380@e27g2000vbu.googlegroups.com> On Feb 20, 5:47?pm, Vinay Sajip wrote: > I will reinstate it in the reference API docs, but the answer to > Jason's problem is to either subclass HTTPHandler and override > handleError to suppress the error, or set logging.raiseExceptions to > True (in which case all logging exceptions will be swallowed - not Um, that should be *False*, not True. Regards, Vinay Sajip From duncan.booth at invalid.invalid Mon Feb 20 13:54:01 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 20 Feb 2012 18:54:01 GMT Subject: #line in python (dirty tricks) References: <1329612858.9780.13.camel@corn.betterworld.us> Message-ID: Ross Boylan wrote: >> No [easy] way to go from bytecodes back to AST, but I see no reason >> why you can't create a new code object with your filename and line >> numbers and then create a new function using your modified code >> object. > Could you elaborate? I don't understand what you are suggesting. This (written for Python 3.x, needs some attribute names changing for Python 2.x: import functools def source_line(lineno, filename = None): def decorator(f): c = f.__code__ code = type(c)( c.co_argcount, c.co_kwonlyargcount, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code, c.co_consts, c.co_names, c.co_varnames, c.co_filename if filename is None else filename, c.co_name, lineno, c.co_lnotab, c.co_freevars, c.co_cellvars) f.__code__ = code return f return decorator @source_line(43, 'foo.bar') def foo(): """This is foo""" for i in range(10): bar() @source_line(665, 'evil.txt') def bar(): raise RuntimeError("oops") if __name__=='__main__': import traceback try: foo() except RuntimeError as ex: traceback.print_exc() When you run it the output looks something like this (if you create a file evil.txt with 667 lines): Traceback (most recent call last): File "C:\temp\foo.py", line 30, in foo() File "foo.bar", line 47, in foo File "evil.txt", line 667, in bar Evil line 667 RuntimeError: oops -- Duncan Booth http://kupuguy.blogspot.com From tjreedy at udel.edu Mon Feb 20 14:35:25 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 20 Feb 2012 14:35:25 -0500 Subject: paper submission and versioning system - advice? In-Reply-To: <4F42952D.3030505@gmail.com> References: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> <4F42952D.3030505@gmail.com> Message-ID: On 2/20/2012 1:47 PM, Andrea Crotti wrote: > On 02/20/2012 05:45 PM, Brian Blais wrote: >> I'd like to find a web-based system to help a committee I'm on, where >> we receive proposals from different faculty. I wrote something in >> python, from scratch, a number of years ago because there wasn't >> anything available then but it is showing its age and I figured that >> someone has written something. >> >> Essentially I need users to be able to start a proposal, with some >> basic information, and then be able to add files to it. Other users >> will be allowed to add files as well, but I'd like to limit deletions >> to the committee members. >> >> It seems as if there just has to be available tools like this, but I >> am not even sure what such a system is called. Content Management System (in this case, for a private web site?) is one term I have seen. > Is there anything like this, in python preferably? Too many ;-). > Well I guess that any web framework would provide you more or less > easily with all you need.. > Django turbogears pyramid flask or web2py are just the names I know. + others... To possibly limit choices, decide whether you want files available to the world or just those with accounts (which requires an authentication system). -- Terry Jan Reedy From shejo284 at gmail.com Mon Feb 20 15:37:22 2012 From: shejo284 at gmail.com (Sheldon) Date: Mon, 20 Feb 2012 12:37:22 -0800 (PST) Subject: netCDF4 variable manipulation Message-ID: Hi, I'm trying to read a netCDF4 variable from a file (no problem) and then scale it before writing over the original variable in the file. I'm using python 2.7 and the latest netCDF4 module. It's not that I keep getting an error message but I want to do this without using for loops and all the manuals seems to be skipping this task as if it is never done. I'm new to python and coming over from matlab. Does anyone know how to modify the netCDF4 variable in python and then write it back without creating a new variable, or using for loops? Appreciate the help, /S From drsalists at gmail.com Mon Feb 20 15:53:21 2012 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 20 Feb 2012 12:53:21 -0800 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <7x62f7u0sg.fsf@ruckus.brouhaha.com> References: <9q2kj3Fmq1U1@mid.individual.net> <7x62f7u0sg.fsf@ruckus.brouhaha.com> Message-ID: On Wed, Feb 15, 2012 at 3:36 PM, Paul Rubin wrote: > Martin Sch??n writes: > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alternatives? > > It works pretty well with Maemo, though phones with that are not so easy > to find. My ex-officemate wrote some SL4A (Android) apps in Python and > said it was pretty easy to use, though some features were missing. I > know that one missing feature was tkinter. > The missing features is why I wish SL4A's Python were based on jython or the java version of pypy. Apparently each new function needs a stub for the SL4A CPython; something that runs on a JVM (OK: Dalvik really, but it's almost the same thing) should be able to call java functions directly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Mon Feb 20 17:52:51 2012 From: d at davea.name (Dave Angel) Date: Mon, 20 Feb 2012 17:52:51 -0500 Subject: netCDF4 variable manipulation In-Reply-To: References: Message-ID: <4F42CEC3.1020001@davea.name> On 02/20/2012 03:37 PM, Sheldon wrote: > Hi, > > I'm trying to read a netCDF4 variable from a file (no problem) and > then scale it before writing over the original variable in the file. > > I'm using python 2.7 and the latest netCDF4 module. It's not that I > keep getting an error message but I want to do this without using for > loops and all the manuals seems to be skipping this task as if it is > never done. I'm new to python and coming over from matlab. Does anyone > know how to modify the netCDF4 variable in python and then write it > back without creating a new variable, or using for loops? > > Appreciate the help, > /S Are you using netcdf version 4, or is that name just a coincidence? If you're using a 3rd party library, you really should say so, and post a link, for those curious. in any case, if you are, I can't help you. This is apparently some special kind of variable similar to a numpy array. On the other hand, you may just be asking how to update some bytes in a file, in place. if you read the file in binary mode, then you can use seek() to go back the appropriate distance, and simply write it. -- DaveA From steve+comp.lang.python at pearwood.info Mon Feb 20 18:53:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Feb 2012 23:53:03 GMT Subject: netCDF4 variable manipulation References: Message-ID: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: > Hi, > > I'm trying to read a netCDF4 variable from a file (no problem) and then > scale it before writing over the original variable in the file. > > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep > getting an error message but I want to do this without using for loops > and all the manuals seems to be skipping this task as if it is never > done. I'm new to python and coming over from matlab. Does anyone know > how to modify the netCDF4 variable in python and then write it back > without creating a new variable, or using for loops? There is no such thing as "the netCDF4 variable" in Python -- it is not a built-in part of the language, and therefore there is no built-in feature for manipulating it. You are going to have to be more specific about what you want than just "how do I modify a variable with for loops?". My wild guess is that you have some sort of config file which includes a field called "netCDF4" and you want to update it in place. We can't tell you how to do this without knowing what the config file is -- is it an INI file, XML, JSON, YAML, Unix-style rc file, a binary pickle, or something else? -- Steven From monaghand.david at gmail.com Mon Feb 20 20:33:19 2012 From: monaghand.david at gmail.com (David Monaghan) Date: Tue, 21 Feb 2012 01:33:19 +0000 Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: > > >I don't know the first thing about this math problem however, > >if I were to code this I might try ; > > except ZeroDivisionError: > assert w = -1 > >rather than; > > except ZeroDivisionError: > assert w == -1 Why? DM From delmertr at gmail.com Mon Feb 20 20:50:13 2012 From: delmertr at gmail.com (delmer trena) Date: Mon, 20 Feb 2012 17:50:13 -0800 (PST) Subject: Extreme Face Fucking || Fucking Young Boobs || Young Redhead Xxx Message-ID: http://erohide.com/Feb-2012/Virgin_Pussy_Fuckeeinsest http://erohide.com/Feb-2012/Hot_Teen_Virgin.wmv http://dizzyporn.com/2012-Feb/Young_Sisters_Mobile.spycam.3gp http://dizzyporn.com/2012-Feb/Japanese_Incest_Vol_5_XviD.AC3.avi http://erohide.com/Feb-2012/Teacher_Young_Student_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Iranian_Virgin_Pussy.avi http://dizzyporn.com/2012-Feb/Tied_Forced_Cum_Eat_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Rape_In_Nature.avi http://dizzyporn.com/2012-Feb/Very_Young_Teen_Couple_XviD.AC3.avi http://erohide.com/Feb-2012/School_Of_Bondage_Hentai_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Korean_Virgin_Scandal.avi http://dizzyporn.com/2012-Feb/Incest_Italia_Fratelli_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Asian_Bus_Molestation_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Japa_Hospital.mpeg pussy young free in phoenix free multiple gangbang creampies banned russian extreme pussy fetish amateur brazilian preteens torture electrode anus erotic stories bondage mouth insertions massive extream mammary torture bdsm young in stockings gallery free anal young girl barefoot male bondage extreme pussy squirt free petite girl fucking gangbang sex fantasy story tight anal penetration photos of virgin pussy legal underage nudity pictures young teens raped mature sex young men little rock arkansas apartments forced orgasms bondage young hairy nude guys world's sexiest bondage photo inserting utensils in pussy how to torture your own feet tortured slaves at red doe illegal kids pics oldman fuck young gallery sexy lesbiians licking each other forced to serve pussy silk panties gangbang bi lesbian bondage comics torture nazi girl naked pussy sexy naked young school girls tight rope bondage stories extreme little pussy bondage fairies hentai comics photos of boy licking pussy selfbondage crotch rope amateur twitching clit videos stories of licking pussy young naked little girl movies water bondage clips dirty tactics in divorce free nude young japanese girls japanese bondage mud irc server bondage preteen pee stories petite sex cruel full young sex movies interacial mature fucks young boys men bondage chains bears consquences of underage drinking little pussy big asses younge lesbian sex virgin lolita sex hot bondage whores young fuck buddies little caesars pizza menu hot free young porn com tiny preteen twat topsites young pussy sweedish bondage galleries free young teen threesome porn uncensored youth sex comics young breasts exposed in movies anal licking mpeg free young braces porn dirty bed girls suspension bondage galleries From delmertr at gmail.com Mon Feb 20 20:50:35 2012 From: delmertr at gmail.com (delmer trena) Date: Mon, 20 Feb 2012 17:50:35 -0800 (PST) Subject: Video Samples Lolita || Forced Pussy Eating || Illegal Porn Share Message-ID: <9d2369c4-2234-4fe0-a3f0-edaa7b136e36@b18g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Indian_Mallu_Boob_Press_Rape.avi http://dizzyporn.com/2012-Feb/Beastiality_Dog_Sex.wmv http://erohide.com/Feb-2012/Viy_A_Friend.wmv http://erohide.com/Feb-2012/Indian_Xxx_Rape.avi http://dizzyporn.com/2012-Feb/Milf_Son_Incest_Slutload_Com_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Giant_Insertion_Anal_Prolapse.wmv http://dizzyporn.com/2012-Feb/Lesbian_Drunk_Forced_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Insertion_Football_Ball_In_Ass.wmv http://dizzyporn.com/2012-Feb/Forced_Wear_Diapers_XviD.DVDRip.avi http://erohide.com/Feb-2012/Naage_Lolita.avi http://erohide.com/Feb-2012/Little_Lolita_Incest_Lolicon.com.mp4 http://erohide.com/Feb-2012/Virgin_Off_Natasha.wmv http://dizzyporn.com/2012-Feb/Preteen_Pantyhose_00.avi http://dizzyporn.com/2012-Feb/Femdom_Handjob_Torture_Orgasm.wmv very young free porn videos illegal young nude models femdom crossdress bondage fuck for cash squirting nude petite beautiful underage petite porn stars very young girls pussy xxx amature preteen pussy thumbnail gallery dirty and clean bathroom free movies masturbation young hard penetration movie young girls fuck free videos classic lady sonia bondage del mar ca private annuity trust little girl playing with pussy black youngest porn dirty toon porn little sisters pink pussy free videos xxx women squirt extreme female penetration elisabetta cavalotti bondage movie sexy petite amateur young russian girl nude ice cock torture fine little asians frank's attic bondage little girls russian kiddy porn free tight movie clips squirt men forced to wear silk panties free bondage comix hogtied and tortured real gangbangs bondage old man on young boy movie young man changes sex free bondage forte password catheter fetish bondage sexy hot free young galleries young girl sucking dick bi sexual gangbang porn young pantyhose porn hailey little pussy illegal pics of nude girls cutie schoolgirl young pussy young indian sexy girls bondage fantasy stories pictures hot sexy young pussy sex amateur anal gangbang squirting video on useless junk nude gothic torture free videos of clit play college bondage fiction free porn 100 cock torture petite year old girls sexy young girls free smokin hot pussy squirting movies femdom penis torture stories c r monie bondage bondage boob milking tickle tortured clit young teens illegal porn preteen leather models free lesbian hardcore licking videos donna smith squirts free oral bondage sex bondage video galleries free young nude boys fucking latex bondage pics hentai bondage bukkake pretty young girls galleries bondage super heroins From marybobbyjac at gmail.com Mon Feb 20 20:51:48 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:51:48 -0800 (PST) Subject: Younger Teen Movie || Forced Blowjob Clips || Illegal Teen Fucking Message-ID: <283734df-43aa-4cb6-a3c2-79fb1f88a1ea@hs8g2000vbb.googlegroups.com> http://erohide.com/Feb-2012/Japanese_Incest_2_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Pthc_Vicky_Taboo_Incest_69_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Squirt_Electro_Torture_Fuck_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Facial_Amateur_Forced_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Russian_Mom_Rape.mpeg http://erohide.com/Feb-2012/Teen_Gay_Male_Models_2009.fr.avi http://erohide.com/Feb-2012/Electric_Pussy_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Indian_Real_Virgin_Hymen_Broken.avi http://dizzyporn.com/2012-Feb/Brother_Fucks_Young_Sister_XviD.AC3.avi http://erohide.com/Feb-2012/Mom_Vid.DVDRip.avi http://erohide.com/Feb-2012/Mz_Booty_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Blvid.DVDRip.avi http://erohide.com/Feb-2012/Bizzvid.DVDRip.avi http://erohide.com/Feb-2012/Japature_Rape.mpeg free squirting redhed porn wife gangbang movie pussy licking lesson little gothic girl getting fucked cyber young fuck orgy anal cum licking underage asain porn woman doing it dirty dirty ebony sluts young latina ass double penetration anal movies cunt licker pussy juice funny pussy insertion cock bondage torture cgi young sex lolita sex porno homemade porn drunk hillbilly gangbang china pussy lick templeton bondage art dirty blond girls dog lick fuck woman extreme pussy toy penetration vintage lady sonia in bondage sexiest costume bondage lolitaportal bbs russian petite pants sexy young gax sex stories chinese bondage fetish young sex games free teen squirt videos downloads dirty doggy style sex free bdsm and bondage passwords slave licking mistress pussy map little river sc anateur preteen porn lolita links index worlds youngest pussy pics big clit pumping videos japanese av stars uncensored young teen playing with pussy lesbian pussy licking online clips wet pussy college bondage slave lifestyle hentai lesbian gangbang young teen homemade fuck movies petite mature nude free gangbang video gratuit free younger than 18 porn young teen toon young sexy xxx lolita girls top list bondage and latex stories and contest hot young girls porn sites sex and bondage bdsm young girl fuck dog preteen intercourse pictures mother makes daughter squirt sample clip free thumbs gangbang video next door lolita young teenage couple sex girls forced face fuck afroman - dirty rap free interracial gangbang movies young boys and girls porn photos young girls french sexy xxx young teen sites latex anal bondage young cute faces japanese torture techniques dirty sluts fucked by doctors young small sexy From marybobbyjac at gmail.com Mon Feb 20 20:52:18 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:52:18 -0800 (PST) Subject: Illegal Teen Xxx || Young Feet Porn || Young You Porn Message-ID: <05a5994e-29a3-4ff1-9898-a605b146aebf@m7g2000vbw.googlegroups.com> http://erohide.com/Feb-2012/Hard_Core_Bondage_004.mpeg http://erohide.com/Feb-2012/Breaking_Virgin_Hyman.wmv http://dizzyporn.com/2012-Feb/Young_And_Anal_4_XviD.AC3.avi http://erohide.com/Feb-2012/Christine_Young_Masturbation_BDrip.XviD.AC http://dizzyporn.com/2012-Feb/Very_Young_Group_XviD.AC3.avi http://erohide.com/Feb-2012/Huge_Cock_Rape http://dizzyporn.com/2012-Feb/Rachel_Steele_Rape.mpeg http://dizzyporn.com/2012-Feb/Pov_Incest_Mom_XviD.AC3.avi http://erohide.com/Feb-2012/Young_Homemade_Threesome_XviD.AC3.avi http://erohide.com/Feb-2012/Inn_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Glasses_Boot_Insertion.wmv http://erohide.com/Feb-2012/Little-lolita-nude.avi http://erohide.com/Feb-2012/Vition_Hymen.wmv http://erohide.com/Feb-2012/Wife_Forced_Infront_Of_Husband_XviD.DVDRip.avi holly marie combs in bondage young teen nipples very young bald pussy cat licking woman pussy amazon com youngest sex free young teens porn asian indian bondage slut fake bondage pics nelly furtado young mexican pussy dirty hotel maids stripping petite girls bondage hanging stories asian teen gangbang young panty sluts pretty petite pussy girl licks squirting pussy free very young porn video girls licking juicy pussy private cam orgasms underage boys in jockstrap licking cum from ass underage girls hairy pussy preteen pantyhose photos self bondage nudes video asian appetite no chance bondage ass lick clips cameltoes nice pussy bondage fetish furniture underage girls incest sex bit torrents young creamed pussy what is breast bondage bondage small tits movie girls gangbang guy free adult bondage pic sexy and katie and petite petite ridind dick young n nice pussy free underaged porn private military corporations young wet cfnm pussy free pics of gangbangs girl inserting dogcock in pussy teenager male bondage cum licking bitches hot young swinger dick blick catalog how to sexual squirt dental fetish bondage dental fetish illegal sex movie galleries hairless young lolita preteen models christina carter bondage video xvideo amateur videos of young teens hot nurse hentai bondage jamie hammer bondage eat lick suck ass young hairy teen pussy clit licking video youngest legal porn age cum in clit tiny teen illegal long pussy lick young bodies teen porn bondage reviews dvds free pussy licking galleries suck until squirt big women bondage paranoia max dirty mix underage bisexual sex young humuliating porn tgp From marybobbyjac at gmail.com Mon Feb 20 20:52:33 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:52:33 -0800 (PST) Subject: Alt Porn Young || Little Russian Porn || Forced Bdsm Stories Message-ID: <278bd43b-5626-42cf-bfba-4180d731a523@s7g2000vby.googlegroups.com> http://erohide.com/Feb-2012/Russian_Mom_Young_Son_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Incest_Mom_Gang_XviD.AC3.avi http://erohide.com/Feb-2012/Naked_Tickle_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Young_Lady_Chatterly_2_XviD.AC3.avi http://erohide.com/Feb-2012/Virgin_Boy_Fast_Cumming.wmv http://erohide.com/Feb-2012/Pornstar_And_Male_Virgin.avi http://erohide.com/Feb-2012/Mature_Blondewith_Young_Man_XviD.AC3.avi http://erohide.com/Feb-2012/Russian_Teen_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Young_Blonde_Double_Team_XviD.AC3.avi http://erohide.com/Feb-2012/Indian_Girls_Rape.avi http://erohide.com/Feb-2012/Young_Sisters__mobile.spycam.3gp http://erohide.com/Feb-2012/Blonde_Massage_Rape_Xxx.avi http://erohide.com/Feb-2012/Boys_Outdoor_Sex_BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Teens_Rape_Dad.avi young tease video white wives interracial gangbang young nudes small tits porno bondage site password teen nude dark little pussy squirt tutorial video free young nude pics movies clit fuck comics young shaved pussy cum clips opportunities for petite models hot young chubby pussy youngs vintage home and garden free milk squirting tits the road to morocco bondage dirty blonde slut fat black clit bondage bag pattern girls young amateur masturbating movies advocates for underage drinking amatuer bondage sex movies virgin in black stockings mother fuck by young youth petite sex gallery wild teen lesbians licking each other lick gaged cried forced cock petite teen first time audition bdsm torture picture thumbnails shaved pussies that squirt milf's fucking younger guys young little girles pussy free george carlins seven dirty words transexual gangbang free video cock and ball torture forums want to lick your pussy slick hung studs long legs sexy young girls teens lick pussy russian extreme anal porn masterbating little pussys bondage koko li preteen hairless pussy wet latina pussy solo illegal bollywood porn brother forced to wear sisters panties 42 h breast bondage bras tiny teen clits lolita underage pics young girls porn family free extreme hardcore snuff film pictures young teenagers fucking anime cat lick fur off tummy ass licking porn for free dirty slutty bitches porn amateur ass lick petite carved bath vanity young teen pornography little tee pussy grandma anal gangbang clips mr t bondage very young hot teen pussy black squirter porno fantasy bondage art lindsay lohan bondage stories torture of femal slaves little boys dick bondage play list cock and ball tortured b is for bondage web male bondage stoy to young girls pussy From marybobbyjac at gmail.com Mon Feb 20 20:53:34 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:53:34 -0800 (PST) Subject: Free Young Fucks || Young Filipino Porn || Lolita Amateur Video Message-ID: <3d08452c-a0a5-4b32-9133-83af73d3631d@db5g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Young_Thai_Public_XviD.AC3.avi http://erohide.com/Feb-2012/Brother_Sister_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Sebas_XviD.AC3.avi http://erohide.com/Feb-2012/Japanese_Widow_Rape.mpeg http://dizzyporn.com/2012-Feb/Christine_Young_Masturbation_BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Forced_To_Fuck_Old_Man_XviD.DVDRip.avi http://erohide.com/Feb-2012/Dad_Dfebhter_Incest_Rape_XviD.AC3.avi http://erohide.com/Feb-2012/Double_Penetration_2_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Taboo_American_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_School_Girls_XviD.AC3.avi http://erohide.com/Feb-2012/Whe_Spanking.wmv http://erohide.com/Feb-2012/Russpe_By_Son.mpeg http://dizzyporn.com/2012-Feb/Bondage_Forced_Trailer.wmv http://dizzyporn.com/2012-Feb/Lolita_Pussy_Insertions_XviD.AC3.avi young indians pussy hot petite chicks leather bondage clips mature woment younger girls videos ugly girl young porn bondage in clothes kate mandala bondage young young girl sex bondage having sex restraints petite casual dress illegal shocking porn ridiculously wet pussy live nude video bondage best illegal porn sites young sexey pussy pussy clit cutting off asian bondage listing young porn pix hot very young brunettes fucking fantasy bondage set banned underage lolita vids pics cast of pretty dirty young girls cum in mouth dbz comic dirty fight very young teen fucker thumbs wet pussy landing strip old fucks the young youngest girl sex pics fuck young blonde picture loony tunes gangbang little pussies nude hottest young porn stars young first time lesbian porn teen pussy penetrated girls licking creampies on video young girls fucking bizarre little vixens having sex wet pussy fingering free videos extreme bondage thumbs younger teen blowjob teen gallery outdoors sex petite free bondage video shipping amateur young bikini young girls boys porn old women youngboy sex video prick tease gangbang hot young sluts young nudes no sex blonde teen licked and fucked old women young boys fy air force military pay giraffe licking pussy sexy young virgin girls j j plush bondage sex video ass licking back squirting pussy bondage fairies video tanned little teen young males porno movies mexican preteen girls bdsm bondage cocksuckers tight wet pussy movies little asian pussy holes young little girl fucked woman vaginal needle torture stuff lesbian fingering wet teen pussy older men fucking young girl young teen pussy movie free bondage library see more squirts From marybobbyjac at gmail.com Mon Feb 20 20:54:58 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:54:58 -0800 (PST) Subject: Reall Young Fuck || Jordan Young Porn || Private Teacher Porn Message-ID: <1d9f279e-0362-4761-8f85-6330df56ad83@hk10g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Bizzarvid.DVDRip.avi http://erohide.com/Feb-2012/Father_And_Dfebhter_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Japanese_Incest_Vol_5_07_XviD.AC3.avi http://erohide.com/Feb-2012/Massage_Oil_And_Rape.mpeg http://erohide.com/Feb-2012/Saline_Breast_Torture_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Rape_Scene_35.mpeg http://dizzyporn.com/2012-Feb/Forced_Drunk_Lesbian_Sex_XviD.DVDRip.avi http://erohide.com/Feb-2012/Nude-preteen-video.avi http://dizzyporn.com/2012-Feb/Wife_Fuck_Young_Boy_XviD.DVDRip.avi http://erohide.com/Feb-2012/Double_Penetration_4some_XviD.DVDRip.avi http://erohide.com/Feb-2012/Interracial_Gangbang_Rape.avi http://erohide.com/Feb-2012/Underage_Lesbian_Porn_07.avi http://erohide.com/Feb-2012/Shgirls_Only.wmv http://erohide.com/Feb-2012/Severe_Tit_Torture.wmv young boys galleries jenny lee bondage adult sex porn young skirt bondage pain pics vaginal squirting movies young pink teen lara croft bondage young latin tits bondage in vehicles free girl squirting video bondage mansion part 1 bondage blonde movies free sabras in bondage forced blowjob msmedia lesbians licking deep in pussy squirting mature porn clips little tiny ass younger videos xxx free xxx porn squirt young russia sex eve ellis breast bondage 13 teen young porn jacklyn lick pics young girl sucking cock bondage cartoons domination young teens hardcore fucking movies cock torture cock balls redhead young teens fucking extreme fetish drawings strange sex torture bear wet pussy females licking own pussy petite fishnet stockings erotic chair bondage dirty slut video clips small young girls galleries women fucked in bondage nipple squirting free videos young sexy bikini models naked free petite women movies lesbian preteen story bondage tanning lotion dirty wife sex back prayer arm bondage mpg young fuck extreme kream squirt videos grandmother young sex amateur lolita galleries lick a lot of pussy teenage enema nurses in bondage young indian raw sex purple tits bondage lolita naked forum megateen nude men in torture dungeons symptom: dirty skin xxx young girl peing thin young creampie porn teens gangbang mature extreamly young porn hardcore lesbian bondage strapon teen college virgin shave pussy bondage slave torture comics free illegal sex pics free torture bdsm drawings little girls kds bbs ankle socks bondage women in bondage with women preteen camel toe ebony lolita art youngest pornstar pics From marybobbyjac at gmail.com Mon Feb 20 20:55:09 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:55:09 -0800 (PST) Subject: Dicks Young Porn || Porn Young 5-8 || Ultimate Young Porn Message-ID: <7138e639-5fcc-433b-ad50-2ca9a7be7942@db5g2000vbb.googlegroups.com> http://erohide.com/Feb-2012/Russian_Mom_And_Son_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Virgin_Blond_Hot.wmv http://dizzyporn.com/2012-Feb/Spanking_Teen_Jessica.wmv http://erohide.com/Feb-2012/Father_Dfebhter_Creampie_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Underage_Lolitas_Ing.mpeg http://dizzyporn.com/2012-Feb/Russian_Mom_Rape_By_Son.mpeg http://dizzyporn.com/2012-Feb/Sex_Rape_For_Arab.avi http://erohide.com/Feb-2012/Gay_Hardcore_Xxx_XviD.hdrip.avi http://erohide.com/Feb-2012/Veryn_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Teen_Anal_Creampie_XviD.AC3.avi http://erohide.com/Feb-2012/Boayrip.x264.avi http://erohide.com/Feb-2012/Frvid.DVDRip.avi http://erohide.com/Feb-2012/Realt_XviD.AC3.avi http://erohide.com/Feb-2012/Forced_Diapers_7_XviD.DVDRip.avi kream squirt video super tight virgin pussy free torture sex clips big nip lick free preteen model links free clit bumping porn vids little boy cock big tits and wet pussys young fuck pics pussy party screaming cunt squirting hairy pussy clit slow licking cock video hot girls with wet pussy 3-d cartoon sex young girl teen pussy masturbating pink wet teen pussy fuck squirt preteen lesbian incest d skinny nudes big clits amateur nude women bondage corset free asian hardcore bondage pics sexy make up flickr clitoris stimulation videos man licking cunt videos hot and dirty secretary little tykes yard toys bondage gear and furniture young girl maria fucking windmill dirty lantin maids black anal gangbangs finering virgin pussy porn nude squirting video young sexy blonde fucked very young chubby girls sex real underage sex young girl titty fucked victorian bondage stories penetrate balls asshole girls licking nipples erotic licking video young boy with bogs sex ping pong ball insertion hentai forced bondage shaved lesbian preteens fingering young vixen sex illegal traci lords pics banned underage nude pussy squirting orgasim fresh young chicks young girls who like sex lactating tittie squirting videos brother sister virgin pussy cock young teens get fucked young teen first anal dirty latina maid monique bondage tube sites dirty little boys bondage gallery 4 anime girls dirty free ass licking porn videos ryan devoe bondage skinny young boy japanese porn girls young bondage high def free erotica bondage stories little feet little pussy pics gangbang bisexual hardcore how to squirt from your pussy sexy naked petites younger teens sex hentai wet pussy games From marybobbyjac at gmail.com Mon Feb 20 20:55:25 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:55:25 -0800 (PST) Subject: Xxx Young Bodies || Young Fuckin Boys || Young Female Fucking Message-ID: <0c0f3c5e-b02a-4896-ba9a-a6f0a84c9188@b18g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Cum_S_XviD.AC3.avi http://erohide.com/Feb-2012/Preteen-girl-video.avi http://dizzyporn.com/2012-Feb/Mom_Forced_Son_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Lesbian_Sedeuces_Young_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Free_Full_Length_Beastiality_Movies.wmv http://erohide.com/Feb-2012/Grandma_70__young_Boy_In_Bath_XviD.AC3.avi http://erohide.com/Feb-2012/Underage_Uncensored_Xxx.avi http://erohide.com/Feb-2012/Rachel_Roxxx_Rape.mpeg http://erohide.com/Feb-2012/Underage-movie.avi http://erohide.com/Feb-2012/Teacher_Young_Boy_XviD.DVDRip.avi http://erohide.com/Feb-2012/Nude_Rape_Scene_In_Indian_Movie.mpeg http://erohide.com/Feb-2012/Febgo_Sullivan_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Riley_Rey_Young_And_Disgraced_XviD.AC3.avi http://erohide.com/Feb-2012/Oriental_Shibari_Spanking.wmv young irish girl pussy nude underage teen supermodels womens erotica bondage porn naked girl being licked free young porn movie clips older woman younger men sex sexy bdsm bondage girls byoung teen porn girl fuck lick cunt inflatable bondage sex toys cunt and tit torture young horny housewives little girl pussy model sexy young hairy models cruel cunt torture christine young movies teen petite teens in anal sex women with bondage fantasy yearolds girls underage pussy methods of torture for sex really young girls anal dirty jobs hung like a horse durban public private partnerships bdsm photos torture free tits nipple torture clitoris porn body builder andie valentino bondage asian bondage ring hardcore girl bondage gagged matue young sex hentai toilet bondage mature young man hard core sex young sebastian bondage hair spread outdoors bondage masturbate in self bondage latex bondage gallery very young girls peeing younger then 18 porn extreme pics of womens orgasms old sluts fucking young m bondage products store breast rope torture galleries cowgirls bondage pictures bondage bankok submissive tgp naked bondage movies hentai forced hard pussy video fuck young eve's mouth petite infant sex young teen sex galleries little elizabeth smart bondage video bar gangbang stories sexy pics lick clit pussy lick pussy pussy nude beaches young pussy free bondage video previews boy fingers little girl pussy young girls showing thongs hardest penetration pussy young handjob porn videos cock ball torture male stories young sexy naked irls asian lez bondage lesbians licking pussy free video baptized in dirty water underage girls in thongs gangbang slut free videos spanking dom bondage spreadeagle bondage thumbs hottest little tight teens From marybobbyjac at gmail.com Mon Feb 20 20:56:34 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:56:34 -0800 (PST) Subject: Voyuer Illegal Porn || Young Slut Xxx || Nutella Young Porn Message-ID: http://erohide.com/Feb-2012/Soft_Core_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Amateur_Self_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Color_Climax_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Drunk_Anal_Teen_Rape.mpeg http://erohide.com/Feb-2012/Incest_Taboo_Amatoriale_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cum_Inside_Forced_XviD.DVDRip.avi http://erohide.com/Feb-2012/Mot_XviD.AC3.avi http://erohide.com/Feb-2012/Br_Dfebhter.mpeg http://dizzyporn.com/2012-Feb/Pissing_Sarah_Young_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Underage_Hardcore_Fucking.3gp http://erohide.com/Feb-2012/White_Pantie_Spanking.wmv http://erohide.com/Feb-2012/Young_Boy_Fucking_Aunty_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Rape_Mother_And_Son.avi http://erohide.com/Feb-2012/3d_Underage_Hentai.avi naked young thumbnail sex pictures young little nymphets ashley renee bondage photos japenise breast torture pussy lick pussy tortured female thumbnails pussy lickers boob suckers hogtied breast torture free squirting porn movie archive bondage on men young black girls porn pics lolitas free galleries lolitas galleries transsexual makes bondage film detective bondage magazine covers younger galleries teen sex ass licking fetish fucking younger sister stories extreme penetration preteen secret bondage young dirty ebony girl young models videos free young teen pics squirters xxx free clips wraped up bondage female torture in kosovo young xxx models russian young boy pregnant young girls naked petite tiny tits anal free bondage pissing videos daughter licks mothers pussy hot sexy younger older lesbian little pussy girls models young teen lesbians in bed young girls in panties movies bedroom bondage sex pics xxx young girls being sexy lesbian tickling torture lesbian piss lick fal bald wet pussy licks own pussy juice movies bluebird scan bondage free young teaching old porn hot xxx clit asians young and naked movie cock torture inside guys licking girls pussy squirt pussy video sexy young nude photos young porn portals tiny sexy little asses dirty xxx emoticon for msn messenger hentai ron hermione bondage bondage girl dildo young tiny indian porn young ladies pussy videos young teens black sex free pics young amature porn blonde young girl pics panty crotch bondage illegal mexican teens mature & young final fight maki in bondage hardcore underage kids japanese bondage balette young teen deepthroat movies free moisture perspiration hood bondage bondage erotic vacation young cum sluts electronic pussy insertion movies From marybobbyjac at gmail.com Mon Feb 20 20:56:48 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:56:48 -0800 (PST) Subject: Young Porn Media || Young Sister Xxx || Young Lesbains Porno Message-ID: <29410e39-daf2-4c0b-a06e-39475d6e4604@o6g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Underas_Fucking.mpeg http://dizzyporn.com/2012-Feb/Sky_Lopez_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Bondage_Facial_German_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Realsex_Amelia.wmv http://erohide.com/Feb-2012/Tight_Young_Blonde_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Underwater_Hardcore_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Celebrities_Incest_Sex_Scene_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cute_Blonde_Young_Hardcore_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Brutal_Rape_Tour_Girl.avi http://dizzyporn.com/2012-Feb/Forced_Too_Big_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Christvid.DVDRip.avi http://erohide.com/Feb-2012/Lesbian__seduces_Young_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Daphne_Rosen_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Mom_Triple_Penetration_XviD.DVDRip.avi taime downs bondage boys younger porn sites face care for young girls free midget gangbang pics young hot virgin sexy randy paul jewell bondage romp bondage slut lesbian young girl porn photos vagina clit cutting movie ass squirt vidz femdom gangbang video getting even with dirty tricks free lick pussy close-up dr kink bondage free petite tranny movies alligator sussex pools mcniven-young young love poems young hairy pussy movies so young teens fucking lolita preteen sex links panties preteen schoolgirl japanese web cam preteen free bondage clip nipple clit play innteracial gangbang porn pics petite sluts in xxx action free movies of squirting wives forever young porn movie shayla's house of bondage cum in my virgin pussy erection from torture young boy speedo gallery female bondage technique rough gangbang movies tight little panty pics two lesbos licking pussy squeeze crush breast torture video severe torture galleries tgp free teen bondage porn gangbang password exchange free amatteur bondage hogtied women tortured helpless bondage nbdp caught in diaper bondage inquisition torture and punishment devon michaels licks pussy bondage video pictures ass hook free lolitas mpegs free porn pics galleries squirting hot wet teen pussy pic permanent glue bondage squirters women sex fashion games for preteens sexyy girls licking young african teens girls petite virgin hardcore contortionist ladies breast bondage young teen shaved porn hentai tortured foot up arse air hostess pussy licked model testical torture gangbang story basketball game mature sexual torture women amateur breast torture super becca bondage movie petite teenager free lesbian clit sucking videos real young teenager sex pictures sexy young nude movie stars erotic crouch torture From marybobbyjac at gmail.com Mon Feb 20 20:57:02 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:57:02 -0800 (PST) Subject: Preteen Boys Fucking || Blackyoung Teen Porn || Underage Teen Porno Message-ID: <03bc0121-86df-4cb2-8734-36bb398f1768@bs8g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Young_Busty_Kelly_XviD.AC3.avi http://erohide.com/Feb-2012/Hentai_Toon_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Darla_Crane_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/True_And_Real_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Very_Young_Schoolgirl_Teen_XviD.AC3.avi http://erohide.com/Feb-2012/Lolita-video-hardcore.avi http://erohide.com/Feb-2012/Brother_Rape_Own_Sister.avi http://erohide.com/Feb-2012/Blontakes_Down.wmv http://dizzyporn.com/2012-Feb/Bangladesi_Real_Virgin_Hymen_Broken.wmv http://dizzyporn.com/2012-Feb/Sarah_Young_Pee_XviD.AC3.avi http://erohide.com/Feb-2012/Cheseastiality.wmv http://dizzyporn.com/2012-Feb/Female_Bondage_Sex_Edtv_720x576.avi http://dizzyporn.com/2012-Feb/Indian_Shy_Girl_Forced_Dual.BDrip.XviD.AC.avi http://dizzyporn.com/2012-Feb/Lolitas_Fingering_Pussy_800x600.wmv young teen little girl sex bdsm wooden horse torture discount leather bondage russian hard core lolitas very young boobs young asians pussy hot young teen girls sex free pissing sites of young kids preteen nudist models medical womens petite labcoat young teen movie galleries porn actress kitty young little boys suspenders young couples mutual masturbation video little maggie pussy cock young boys in briefs dirty xxx comics squirt whores password teen with wet pussy dripping wet pussy pics free blunt force trauma dead bitches little girls licking teen pussy young blonde fucking female squirt mpg sexy little pussy girls gangbang black milf free jewel marceau bondage pics male bondage cartoons practice pussy lick training slave girl bondage art leather bondage lingerie vibrator clitoris videos pain bondage tits bdsm sado torture pick wet pussy preteen amature thumbnail gallery tgp male sexual consensual torture guide bondage fantasy art alazar click porn videos fucking young cock young naked movies skinny virgin pussy poppin girls barefoot bondage plastic lab squirt bottles big tits mpeg lolita uncut men bondage anal insertion video monster clit movie clips c guilt's japanese breast bondage young girls in bikini pictures bondage platform shoes dvd underage girls model bdsm cbt torture stories tiffany call creampie virgin scenes heavy latex bondage very young amateurs hot virgin pussy video russian lolitas mpeg underage girls naked and fucking calstar videos tickling bondage petite monster cocks movies young butt fuck police chief young ca free sexy young coeds self bondage masturbation bondage nudes film free porn pvc bondage object's inserted in pussy's squirting tits movies anal too young From marybobbyjac at gmail.com Mon Feb 20 20:57:16 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:57:16 -0800 (PST) Subject: Young Nudism Videos || Illegal Girl Porn || Illegal Lolitas Porn Message-ID: http://dizzyporn.com/2012-Feb/Young_Videomodel_Daphne_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Big_Black_Cock_In_Young_Japan_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Katsuni_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Dad_Fuck_Young_Son_XviD.AC3.avi http://erohide.com/Feb-2012/Old_Man_Rape_Young.mpeg http://dizzyporn.com/2012-Feb/Brianna_Love_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Young_Teen__big_Cock_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Girl_Fucked_By_2_Cocks_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Sarah_Louise_Young_G_XviD.DVDRip.avi http://erohide.com/Feb-2012/Breast_Suspension_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Brut_Tour_Girl.avi http://dizzyporn.com/2012-Feb/Spanking_Maturw_Woman.wmv http://erohide.com/Feb-2012/Girl_Forced_Boy_To__dual.BDrip.XviD.AC.avi http://dizzyporn.com/2012-Feb/Young_Girls_Squirting_Trailer.wmv illegal strip search alameda county pics of young boys fucking steel bondage collar petite teen sexvids ball from clitoris pink floyd young lust saran wrap bondage bondage sex webcams videos young skinny brunette sex young schoolgirl fuck teen anal lick young pussy nipple wet hariy pussy's forced bondage women real squirt orgasm self bondage tutorails underage free pics hentai chain bondage too deep penetration long gangbang video really little girls underage girl pic model bondage club photos young fat sex galleries little lolita boy young anal stories young porn girls tgp blond ass double penetration gushing erupting squirting porn men in diaper bondage pussy lick youtube very young camel toe pics torture pics genital top 100 illegal sex bondage pussy stretching illegal jpg voyeur hispanic petite girl big tits male bodybuilder bondage male bondage cumming underage nudist sex young foreign girls fucked squirting porn tube young sexy turkish girls mexican wet open pussy young girls thongs nadia sexy young model asian girls licking girls preteen model galleries models preteen best squirting internet videos underage boys movies young girl wet pussy free unerage illegal porn big clit teen shaved pussy young under 12 gangbang a hooters girl japanese forced orgasm bondage pre young pink pussy teen forced insertion sexy young people miko lee bondage anal lick asian free new self-bondage sex stories women frog tied bondage men fingering and licking pussy trussed up video bondage extreme bdsm slaves young couple porn xxx movies forced feminization mistress bdsm dildo vibrators clit pussy extreme incest porn From slyvestoramad at gmail.com Mon Feb 20 20:58:59 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:58:59 -0800 (PST) Subject: Petite Dd Xxx || Young Flat Xxx || Casey Young Porn Message-ID: http://erohide.com/Feb-2012/Young_Oriental_Slut_First_Time_Sex_XviD.AC3.avi http://erohide.com/Feb-2012/Amatvid.DVDRip.avi http://dizzyporn.com/2012-Feb/Febia_Ozawa_Forced_XviD.DVDRip.avi http://erohide.com/Feb-2012/A_Well_Deserved_Spanking.wmv http://erohide.com/Feb-2012/Loaved-pussy.avi http://erohide.com/Feb-2012/Tender_Young_Sex_XviD.AC3.avi http://erohide.com/Feb-2012/Famio_XviD.AC3.avi http://erohide.com/Feb-2012/Man_Get_Cum_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Halloween_Banana_Insertion_Treat.wmv http://dizzyporn.com/2012-Feb/Chinese_Mother_Fucked_By_Young_Son_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Sex_Parties_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Mom_Forced_To_Blow_Son_Dual.BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Young_Amateur_Brunet_XviD.DVDRip.avi http://erohide.com/Feb-2012/Daphayrip.x264.avi anus licking video hentai anime bondage looking for sex in youngstown young student fuck old lolita preteen pic watch me lick up the cum bondage gagged hogtie frogtie tapegag preteens in bras and panties closer video bondage preteen porn galleries bdsm bondage dvda extreme crotch torture japan bondage food table flicka ricka dicka vintage under age sex lolita russian really young girls short skirts double penetration younger babe sex pics young virgin italian pussy young stud fuck my wife milly weathers bondage free young teen porn moves fetish rope bondage fantasy babysitter bondage storiies gang forced wife ypf young people fucking bdsm bladder torture filing stretching young girls pics video feet my little pony cakes little girls licking pussy porn black pussy squirters non sexual ass licking ukraine sex young girls porn young teens sex female pussy lick skinny petite anorexic porn self bondage illustrated sensual massage in california illegal little girls brazil bdsm tortures devices dani ashe bondage first time squirting videos dirty dancing trivia porn hub squirt bondage free pictures ad video amateur bondage webcams young and horn y sex male tickle bondage videos young litle porn videos free female bondage fuck professor lick pussy pussy licking cuckold young teen sex boobs foot dirty girl bondage model sex video bondage stories literature hogtied in chains bondage movie young erect boys petite does black dick young teen porn related sites small tits small clits chastity forced stories cuckold bondage tit and nipple pictures very young teen torture email genital torture young latin chicks sexy wet pussy ass fat women squirt adult young pussy petite girl voyeur From slyvestoramad at gmail.com Mon Feb 20 20:59:14 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:59:14 -0800 (PST) Subject: Petite Anal Trailer || Illegal Underage Xxx || Young Slut Porn Message-ID: http://erohide.com/Feb-2012/Bbw_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Lolitas_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Anime_Bondage_V2_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Japanese_Mom_And_Young_XviD.DVDRip.avi http://erohide.com/Feb-2012/Japawife_Rape.mpeg http://dizzyporn.com/2012-Feb/Brother_Fucking_Virgin_Sister.wmv http://dizzyporn.com/2012-Feb/Young_Brooke_Adams_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Hotel_Asian_Sleep_Rape.mpeg http://erohide.com/Feb-2012/German_Virgin_Have_Hymen_Break.wmv http://dizzyporn.com/2012-Feb/Forced_Fuck_Mom_Anal_XviD.DVDRip.avi http://erohide.com/Feb-2012/Blontakes_Down.wmv http://erohide.com/Feb-2012/Hard_Core_Bondage_004.mpeg http://dizzyporn.com/2012-Feb/Double_Penetration_Black_Teen_XviD.DVDRip.avi http://erohide.com/Feb-2012/Real_Girl_Virgin_Defloration.avi gigantic clits videos dirty dozen d bondage crucifixion story busty teen masturbating wet pussy spit picture bondage gat bondage college coeds squirting fluid from anal smoking torture pics young girl cumshot movies peach bondage porn bondage and fucking machiens petite asain pussy g spot orgasm squirt dominc wolfe bondage sex mechines squirting petite pornstars list svens lolita bbs public bondage pain young skater girl porn lesbian younger teen pussy bondage quick release little young girls porn pictures desibaba dirty chat todays top models arse licker sex babe pornstar young gallery lolita sex site illegal teens blowjobs young girls sex toys young couples sex video tape transgender bondage home pages sexy petite teens milk breast squirt sex bizarre insertion pics pussy videos wet stuffed tube free younger babes porn double pussy penetration how to sexy young teens uncensored dog licks teen pussy little girls in bikinis sexy clit stories chrissy moran bondage submission humiliation light bondage the asian extreme pussy games women underage pussy playing biotech training little rock free online hardcore squirting porn japanese naturist preteens very petite sex cuckhold lick pussy underage sex tours teen dick lickers underage little whores gingera bondage clip petite nudes free pics young sex craver free gangbang cum movies forced petite sex video bondage fairies album nv lesbian squirts from dildo fuck forced illegal sex little hairy pussy pics she licks my pussy extreme bdsm torture dvd young teen girl movie clips preteen nude underage lolita blue links free young amatur videos squirt listing porn girl licks girl ass dirty fat asses breastfeeding illegal after certain age From slyvestoramad at gmail.com Mon Feb 20 20:59:29 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:59:29 -0800 (PST) Subject: Young Porn Posers || Video Underage Girls || Old-young Sex Video Message-ID: <6cd35314-4a8e-45ec-b693-01c955990506@z31g2000vbt.googlegroups.com> http://erohide.com/Feb-2012/Underage-rape-video.avi http://dizzyporn.com/2012-Feb/Hardcore_Rape_Hunk.avi http://dizzyporn.com/2012-Feb/Forced_Cum_Inside_Throat_Rough_XviD.DVDRip.avi http://erohide.com/Feb-2012/Celebrities_Incest_Sex_Scene_XviD.AC3.avi http://erohide.com/Feb-2012/Young_Girl_First_Anal_XviD.AC3.avi http://erohide.com/Feb-2012/Torture_Post_Orgasm_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Russian_Mom_Rape_By_Son.mpeg http://dizzyporn.com/2012-Feb/2_Crazy_Bitches_Rape_A_Guy.mpeg http://dizzyporn.com/2012-Feb/Tied_Forced_Cum_Eat_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Pee_Hole_Insertion_Men.wmv http://dizzyporn.com/2012-Feb/Old_Guy_Young_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cfmn_Handjob_Torture_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Young_And_Busty_Lea_In_Public_XviD.AC3.avi http://erohide.com/Feb-2012/Mvid.DVDRip.avi petite sex doll young buck biography lolita teen photomodel hardcore bondage and submission free gallerys closeup intercource young girls free nude little girl pics forced facesitting forced pussy worship fuck young bithes free porn young porn clips illegal chjild porn pussy ooze licking anal dildo insertions electro breast torture kacey licking pussy mature and young porn movies big boobs and little waist galleries pictures porn young pussy sick young pussy pussy pussy forced sissy bondage fucking my young neighbor preteen strip tease youth flying nz young eagles huge clitoris video clips young teen pussy free moview young fist time teenie sex the bondage gaem wife sharing gangbang nurse uniform bondage fuck lick lesbi ebony bdsm forced enema free stories grits bondage videos nylon stockings abd bondage pics nude video clips young free best hentai bondage movies net nubile young teens fucking bondage piss drinking slutty bitches getting forced fucked petite asian sex videos hard fast fucking gangbang young little tits female squirt filetype:avi wetpussygames hentai girl 2 game in her mouth young preteen wearing stockings nude petite sex december download anal bondage free embarrasing bondage stories chained up bondage bbw wet pussy porn tube monster bondage hentia pretty little toes having sex with young girls bondage training gag barb wire bondage text stories bondage nudity wet pussy cunt young girl pic pussy free bondage comics young sexy cartoons underground illegal porn videos female tickle torture hardcore bondage galleries youngest porn models illegal porn busted very young teen pussy mpegs young hot pussy pics jerry cock amy virgin pussy preteen boys nude little boys nude chubby preteens nude lesbo wet pussy From breamoreboy at yahoo.co.uk Mon Feb 20 21:21:38 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Feb 2012 02:21:38 +0000 Subject: Numeric root-finding in Python In-Reply-To: <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> Message-ID: On 21/02/2012 01:33, David Monaghan wrote: > On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: > >> >> >> I don't know the first thing about this math problem however, >> >> if I were to code this I might try ; >> >> except ZeroDivisionError: >> assert w = -1 >> >> rather than; >> >> except ZeroDivisionError: >> assert w == -1 > > Why? > > DM Why not is probably a better question, given that Dennis Lee Bieber and Dave Angel have already pointed out that this is not legal Python, it'll give a syntax error. -- Cheers. Mark Lawrence. From wuwei23 at gmail.com Mon Feb 20 22:31:37 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 20 Feb 2012 19:31:37 -0800 (PST) Subject: paper submission and versioning system - advice? References: Message-ID: <72d09097-3fc7-480d-aa05-235e8efe1440@oh4g2000pbb.googlegroups.com> On Feb 21, 3:45?am, Brian Blais wrote: > Essentially I need users to be able to start a proposal, with > some basic information, and then be able to add files to it. > Other users will be allowed to add files as well, but I'd like > to limit deletions to the committee members. > It seems as if there just has to be available tools like this, > but I am not even sure what such a system is called. ?Is there > anything like this, in python preferably? Frankly, I'd start at a much higher level than a web framework. I think you could easily get what you want from a ticketing system like Trac: http://trac.edgewall.org/ Trac's tickets would be proposals in your system; I believe you can attach files to them by default, and even limit the size & type of attachments. There's a permissions mechanism that would provide your committee members with higher levels of access. It sits by default on SVN, so there's your versioning, and provides a wiki, so it's easy to add supporting documentation to the site. It also provides a very elegant plug-in system for easy extension, and is all in Python. From r1chardj0n3s at gmail.com Tue Feb 21 00:32:39 2012 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Tue, 21 Feb 2012 16:32:39 +1100 Subject: Python Game Programming Challenge (PyWeek) #14 is coming! Message-ID: The 14th Python Game Programming Challenge (PyWeek) is coming. It'll run from the 22nd to the 29th of April. http://pyweek.org/14/ New user registration is NOT YET OPEN. It will open one month before the challenge starts. The PyWeek challenge: - Invites entrants to write a game in one week from scratch either as an individual or in a team, - Is intended to be challenging and fun, - Will hopefully increase the public body of game tools, code and expertise, - Will let a lot of people actually finish a game, and - May inspire new projects (with ready made teams!) If you're in the US and can make it I'm co-presenting a 3 hour pygame tutorial at PyCon in March. From prakashsco71 at gmail.com Tue Feb 21 00:35:06 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Mon, 20 Feb 2012 21:35:06 -0800 (PST) Subject: ONLINE FORM FILLING PROCESS-e RECRUITMENT SERVICES Message-ID: <646e237c-cda7-4471-a23b-98d4472fb65f@oh4g2000pbb.googlegroups.com> COMPUTER SERVICES AVAILABLE HERE. http://imalayagroup.yolasite.com/ From fayaz.yusuf.khan at gmail.com Tue Feb 21 02:23:37 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Tue, 21 Feb 2012 12:53:37 +0530 Subject: Should I acquire lock for logging.Handler.flush()? Message-ID: <1812157.OpZ7u19UP8@dextop08> I'm writing a custom logging Handler that sends emails through AWS Simple Email Service using the boto library. As there's a quota cap on how many (200) emails I can send within 24hrs, I think I need to buffer my log messages from the emit() calls (Or is that a bad idea?). And I was reading the Handler documentation and was confused if I should call the acquire() and release() methods from within a flush() call. -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From shejo284 at gmail.com Tue Feb 21 03:29:03 2012 From: shejo284 at gmail.com (Sheldon) Date: Tue, 21 Feb 2012 00:29:03 -0800 (PST) Subject: netCDF4 variable manipulation References: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> On Feb 21, 12:53?am, Steven D'Aprano wrote: > On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: > > Hi, > > > I'm trying to read a netCDF4 variable from a file (no problem) and then > > scale it before writing over the original variable in the file. > > > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep > > getting an error message but I want to do this without using for loops > > and all the manuals seems to be skipping this task as if it is never > > done. I'm new to python and coming over from matlab. Does anyone know > > how to modify the netCDF4 variable in python and then write it back > > without creating a new variable, or using for loops? > > There is no such thing as "the netCDF4 variable" in Python -- it is not a > built-in part of the language, and therefore there is no built-in feature > for manipulating it. > > You are going to have to be more specific about what you want than just > "how do I modify a variable with for loops?". > > My wild guess is that you have some sort of config file which includes a > field called "netCDF4" and you want to update it in place. We can't tell > you how to do this without knowing what the config file is -- is it an > INI file, XML, JSON, YAML, Unix-style rc file, a binary pickle, or > something else? > > -- > Steven Hi, My apologies. I didn't realize this module was not popular. I'm using the python module "netCDF4" that I installed using PIP. This module gives me the ability to read and write netcdf4 files. The module is an interface to the netcdf4.1.3 and HDF51.8.8 libraries. What I'm trying to do is open an existing netcdf file, extract an variable, modify the variable, and then write it again to the file - effectively replacing the old variable. rgrp = netCDF4.Dataset('ODIN_NWP_2001_01_01_00.NC','r+') pv = rgrp.groups['Data_3D'].variables['PV'] print pv float32 PV(u'level', u'lat', u'lon') longname: Potential Vorticity _FillValue: -999.0 units: K m**2 kg**-1 s**-1 code: 60 scale_factor: 1.0 add_offset: 0.0 path = /Data_3D unlimited dimensions = () current size = (60, 181, 360) As you can see, pv is described here as a netCDF4.Variable. I'm trying to modify this pv and then write it back to the file but the manual is vague on this part. I tried this: pv = pv*2 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ----> 1 pv = pv*2 TypeError: unsupported operand type(s) for *: 'netCDF4.Variable' and 'int' I'm unsure how this is suppose to work. /S From clp2 at rebertia.com Tue Feb 21 04:10:49 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 21 Feb 2012 01:10:49 -0800 Subject: netCDF4 variable manipulation In-Reply-To: <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> References: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> Message-ID: On Tue, Feb 21, 2012 at 12:29 AM, Sheldon wrote: > On Feb 21, 12:53?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: >> > Hi, >> >> > I'm trying to read a netCDF4 variable from a file (no problem) and then >> > scale it before writing over the original variable in the file. >> >> > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep >> > getting an error message but I want to do this without using for loops >> > and all the manuals seems to be skipping this task as if it is never >> > done. I'm new to python and coming over from matlab. Does anyone know >> > how to modify the netCDF4 variable in python and then write it back >> > without creating a new variable, or using for loops? > My apologies. I didn't realize this module was not popular. I'm using > the python module "netCDF4" > that I installed using PIP. This module gives me the ability to read > and write netcdf4 files. > The module is an interface to the netcdf4.1.3 and HDF51.8.8 libraries. > What I'm trying to do is open an existing netcdf file, extract an > variable, modify the variable, and then > write it again to the file - effectively replacing the old variable. > > rgrp = netCDF4.Dataset('ODIN_NWP_2001_01_01_00.NC','r+') > pv = rgrp.groups['Data_3D'].variables['PV'] > > print pv > > float32 PV(u'level', u'lat', u'lon') > ? ?longname: Potential Vorticity > ? ?_FillValue: -999.0 > ? ?units: K m**2 kg**-1 s**-1 > ? ?code: 60 > ? ?scale_factor: 1.0 > ? ?add_offset: 0.0 > path = /Data_3D > unlimited dimensions = () > current size = (60, 181, 360) > > As you can see, pv is described here as a netCDF4.Variable. I'm trying > to modify this pv and then write it back to the file > but the manual is vague on this part. I tried this: > > pv = pv*2 > --------------------------------------------------------------------------- > TypeError ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call > last) > ----> 1 pv = pv*2 > TypeError: unsupported operand type(s) for *: 'netCDF4.Variable' and > 'int' > > I'm unsure how this is suppose to work. The API docs suggest that Variables don't support any arithmetic operations, just slicing and attribute manipulation. They seem to interoperate with numpy arrays though, so presumably you could avoid explicit looping by loading the Variable's contents into a numpy array, doing your calculations on that, and then assigning the resulting numpy array back into a slice of the Variable. Cheers, Chris From storchaka at gmail.com Tue Feb 21 04:15:31 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 21 Feb 2012 11:15:31 +0200 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: 18.02.12 20:58, SherjilOzair ???????(??): > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > What are your views on this? Look at Hotwire (http://code.google.com/p/hotwire-shell/). From chris at simplistix.co.uk Tue Feb 21 04:17:13 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 21 Feb 2012 09:17:13 +0000 Subject: xlrd 0.7.2 released! Message-ID: <4F436119.9090509@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlrd 0.7.2. This release, like the xlwt release, is long overdue and has been over 2.5 years in the making! The highlights: - All messaging and debug logging is now written to the logfile provided to open_workbook. - Tolerant handling of file with non-standard compound document header - Tolerant handling of files with extra zero bytes at end of NUMBER record - Handle mostly-BIFF8 file with BIFF5-7 WINDOWS2 record - Handle dodgy version 2.x .xls files. - Added support for HYPERLINK extraction - Added access to cell notes/comments. - Enable reading files created by pyXLWriter -- puts BIFF8 MERGEDCELLS record in a BIFF5 file. - Fixed a file-locking issue on Windows when an exception was raised in open_workbook() and on_demand was True - Book objects are now context managers - Rich text formatting information is now extracted - Page breaks information is now extracted - Some improvements in zoom factor handling - PANE records are now processed - Some memory and performance enhancements For a full list of the changes, please see the svn log: https://secure.simplistix.co.uk/svn/xlrd/trunk I've currently only put up .tar.gz sdists, if anyone requires anything else, please explain why and I'll be happy to add! cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From chris at simplistix.co.uk Tue Feb 21 04:18:16 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 21 Feb 2012 09:18:16 +0000 Subject: xlwt 0.7.3 released! Message-ID: <4F436158.7060603@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlwt 0.7.3. This release is long overdue and has been over 2.5 years in the making! The highlights: - Added user_set and best_fit attributes to Column class. - Fixed an "[Errno 0] Error" raised when Worksheet.flush_row_data() was called after Workbook.save() - Fixed an error on Windows that occurred when writing large blocks to files. - Added the ability to write rich text cells - Fixed a bug when writing MULBLANK records on big-endian platforms. - allow the active_pane on worksheets to be specified - added support for zoom (magn) factors and improved possibilities when generating split panes For a full list of the changes, please see the svn log: https://secure.simplistix.co.uk/svn/xlwt/trunk I've currently only put up .tar.gz sdists, if anyone requires anything else, please explain why and I'll be happy to add! cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From petite.abeille at gmail.com Tue Feb 21 04:31:36 2012 From: petite.abeille at gmail.com (Petite Abeille) Date: Tue, 21 Feb 2012 10:31:36 +0100 Subject: [bug] imaplib case sensitive Message-ID: Hello, Looks like imaplib is case sensitive, even though the IMAP protocol isn't: (1) Except as noted otherwise, all alphabetic characters are case-insensitive. The use of upper or lower case characters to define token strings is for editorial clarity only. Implementations MUST accept these strings in a case-insensitive fashion. http://tools.ietf.org/html/rfc3501#section-9 For example: [Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) ] [imaplib 2.58] import imaplib M = imaplib.IMAP4( 'localhost', 1143 ) M.login( 'user', 'password' ) M.select() typ, data = M.search(None, 'ALL') for num in data[0].split(): typ, data = M.fetch(num, '(ENVELOPE)') print 'Message %s\n%s\n' % (num, data[0][1]) M.close() M.logout() Traceback (most recent call last): File "Test.py", line 3, in M = imaplib.IMAP4( 'localhost', 1143 ) File "python2.6/imaplib.py", line 184, in __init__ self.welcome = self._get_response() File "python2.6/imaplib.py", line 935, in _get_response raise self.abort("unexpected response: '%s'" % resp) imaplib.abort: unexpected response: '* ok imap4rev1' Note the 'ok' tag in lower case. From kliateni at gmail.com Tue Feb 21 06:02:30 2012 From: kliateni at gmail.com (Karim) Date: Tue, 21 Feb 2012 12:02:30 +0100 Subject: xlwt 0.7.3 released! In-Reply-To: <4F436158.7060603@simplistix.co.uk> References: <4F436158.7060603@simplistix.co.uk> Message-ID: <4F4379C6.8060803@gmail.com> Hello chris, Thanks for the greet news! Is there any chance that xlrd read .xlsx format and arrive to decode special unicode instead of firing some unicode Exception? Cheers Karim Le 21/02/2012 10:18, Chris Withers a ?crit : > Hi All, > > I'm pleased to announce the release of xlwt 0.7.3. This release is > long overdue and has been over 2.5 years in the making! > > The highlights: > > > - Added user_set and best_fit attributes to Column class. > > - Fixed an "[Errno 0] Error" raised when Worksheet.flush_row_data() > was called after Workbook.save() > > - Fixed an error on Windows that occurred when writing large blocks to > files. > > - Added the ability to write rich text cells > > - Fixed a bug when writing MULBLANK records on big-endian platforms. > > - allow the active_pane on worksheets to be specified > > - added support for zoom (magn) factors and improved possibilities > when generating split panes > > For a full list of the changes, please see the svn log: > > https://secure.simplistix.co.uk/svn/xlwt/trunk > > I've currently only put up .tar.gz sdists, if anyone requires anything > else, please explain why and I'll be happy to add! > > cheers, > > Chris > From tsinar at dpem.tuc.gr Tue Feb 21 06:24:59 2012 From: tsinar at dpem.tuc.gr (George Tsinarakis) Date: Tue, 21 Feb 2012 13:24:59 +0200 Subject: Questionnaire on motivation analysis of open source and open content Message-ID: <4F437F0B.1080405@dpem.tuc.gr> Dear Sirs, We are researchers in Technical University of Crete and our current research is in the field of motivation analysis of open source and open content software projects participants. We would like to ask you to fill a questionnaire and forward it to people involved in such teams and projects. The web address is the following: https://docs.google.com/spreadsheet/viewform?formkey=dHdqZUgyay0waXNRbWFvV3hleVBZSWc6MQ All personal information will be kept confidential and will be used for academic purposes only. For further information please do not hesitate to contact with us. Thank you in advance Dr G. Tsinarakis -- ------------------------------------------------------- Dr.George Tsinarakis Production and Management Engineer, CAM Laboratory Department of Production Engineering and Management Technical University of Crete University Campus, 73 100 Chania, Crete , Greece Tel: +30 2821 037306 Fax: +30 2821 037551 E -mail: tsinar@ dpem.tuc.gr ------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Tue Feb 21 12:20:19 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Tue, 21 Feb 2012 18:20:19 +0100 Subject: ANN: python-ldap 2.4.8 Message-ID: Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.8 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. ---------------------------------------------------------------- Released 2.4.8 2012-02-21 Changes since 2.4.7: Lib/ * Fixed overzealous check for non-unique NAMEs in ldap.schema.subentry.SubSchema.__init__() * Fixed typos in control decoding method ldap.controls.simple.OctetStringInteger.decodeControlValue() * Added experimental support for draft-vchu-ldap-pwd-policy From vinay_sajip at yahoo.co.uk Tue Feb 21 15:52:14 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 21 Feb 2012 12:52:14 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> On Feb 21, 7:23?am, Fayaz Yusuf Khan wrote: > I'm writing a custom logging Handler that sends emails through AWS Simple > Email Service using the boto library. > As there's a quota cap on how many (200) emails I can send within 24hrs, I > think I need to buffer my log messages from the emit() calls (Or is that a bad > idea?). > And I was reading the Handler documentation and was confused if I should call > the acquire() and release() methods from within a flush() call. > -- > Fayaz Yusuf Khan > Cloud developer and architect > Dexetra SS, Bangalore, India > fayaz.yusuf.khan_AT_gmail_DOT_com > fayaz_AT_dexetra_DOT_com > +91-9746-830-823 > > ?signature.asc > < 1KViewDownload If you are using SMTPHandler, calling flush() won't do anything. You'll probably need to subclass the handler to implement rate limiting. In the stdlib, only StreamHandler and its subclasses actually implement flush(), which flushes I/O buffers to disk. Regards, Vinay Sajip From johannes.exner at tu-dortmund.de Tue Feb 21 16:38:59 2012 From: johannes.exner at tu-dortmund.de (JohannesTU) Date: Tue, 21 Feb 2012 13:38:59 -0800 (PST) Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' In-Reply-To: References: <1329749827797-4487915.post@n6.nabble.com> Message-ID: <1329860339503-4493041.post@n6.nabble.com> Thanks for your advice. The command itself didn't work, but it brought me on the right path and "car and engine" are running now! ;-) I fixed the problem by copying the correct pg.py-file to the python2.7 path. After that the error didn't show up again and I'm now able to create users etc. Thank you very much! Kind regards, Johannes -- View this message in context: http://python.6.n6.nabble.com/PyKota-Python-AttributeError-module-object-has-no-attribute-quote-tp4487915p4493041.html Sent from the Python - python-list mailing list archive at Nabble.com. From python-excel at raf.org Tue Feb 21 19:37:47 2012 From: python-excel at raf.org (python-excel at raf.org) Date: Wed, 22 Feb 2012 11:37:47 +1100 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F436119.9090509@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> Message-ID: <20120222003747.GA24152@raf.org> Chris Withers wrote: > Hi All, > > I'm pleased to announce the release of xlrd 0.7.2. This release, > like the xlwt release, is long overdue and has been over 2.5 years > in the making! > [...snip...] > > I've currently only put up .tar.gz sdists, if anyone requires > anything else, please explain why and I'll be happy to add! hi, a windows installer exe would be good for the same reasons it was good for previous versions. two reasons that spring to mind immediately are: - it makes it much easier to tell what version is installed - it makes it much easier to uninstall the package i know that both of these are things that the python community does not yet seem to find useful but everyone else seems to. for instance, if i just install the new versions of these packages on windows, it will replace the python-specific files that were associated with the previous version but it will have no impact on the system's list of installed software so if i look at the add/remove software control panel, it will happily tell me that i still have the previous versions. on the other hand, if the new versions were installed with windows installers, they would be able to properly replace the old versions with the new versions and make it clear that it has done do. knowing this, i will of course uninstall the old versions before installing the new versions so at least windows won't be forced to lie to me about what versions are installed. of course, i might be wrong about all of this and setup.py may manage the windows installed software list properly and do a proper upgrade. if so, sorry for wasting time. cheers, raf From umairahmed2526 at gmail.com Tue Feb 21 20:08:08 2012 From: umairahmed2526 at gmail.com (Umair Ahmed) Date: Tue, 21 Feb 2012 17:08:08 -0800 (PST) Subject: ali Message-ID: http://sharecash.org/download.php?file=2652910 From onexpadREMOVE at EVOMERyahoodotyouknow.com Tue Feb 21 21:28:29 2012 From: onexpadREMOVE at EVOMERyahoodotyouknow.com (Kyle T. Jones) Date: Tue, 21 Feb 2012 20:28:29 -0600 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: On 2/19/12 2:16 AM, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. > That's an awful lot of key mashing just to replace 'cat file.txt' for i in big small upper lower ; do for j in conf bin log ; do chmod 2755 /home/me/$i/$j ; done ; done cat data.log | grep Error | awk -F, '{print $5, $1, $2,}' | sort ?? I believe your solution seeks a problem. I also believe a tool that seeks to be all things generally does none of them particularly well. Cheers. > IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. > > Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. > The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. > > Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. > Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. > > We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. > > Shell would give python raw power! And Python would manage it well. From cmpython at gmail.com Tue Feb 21 22:51:07 2012 From: cmpython at gmail.com (CM) Date: Tue, 21 Feb 2012 19:51:07 -0800 (PST) Subject: Python LOC, .exe size, and refactoring Message-ID: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> 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). From umarnawazconsultant at gmail.com Tue Feb 21 23:38:26 2012 From: umarnawazconsultant at gmail.com (umar nawaz) Date: Tue, 21 Feb 2012 23:38:26 -0500 Subject: Campaign to raise $200 for python code statistics tool Message-ID: If $200 of contributions are made, I will create a python code statistics tool. To contribute go to this link on invested.in, a crowdfunding site (I cannot use kickstarter because I'm from Canada). http://invested.in/P2127/python-code-statistics-tool -------------- next part -------------- An HTML attachment was scrubbed... URL: From fayaz.yusuf.khan at gmail.com Tue Feb 21 23:44:44 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Wed, 22 Feb 2012 10:14:44 +0530 Subject: Should I acquire lock for logging.Handler.flush()? In-Reply-To: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> References: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> Message-ID: <8592595.GqlRG0s5VQ@dextop08> On Tuesday 21 Feb 2012 12:52:14 PM Vinay Sajip wrote: > If you are using SMTPHandler, calling flush() won't do anything. > You'll probably need to subclass the handler to implement rate > limiting. Oh, no! I'm writing my own handler. https://github.com/fayazkhan/ses_handler/blob/master/ses_handler.py Now I understand from here http://docs.python.org/library/logging.html#handler-objects that emit() calls are wrapped acquire() and release() in the handle() method. Anyway, I read the source and found many interesting things that ought to be mentioned in the docs. Such as flush() should be called from close() whenever it's implemented. (FileHandler.close() is doing it) And how come close()/flush() isn't being called from inside a lock? (Handler.close() calls the module level _acquireLock() and _releaseLock()s but nothing about the instance level acquire() or release()) Or is it being locked from somewhere else? -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From steve+comp.lang.python at pearwood.info Wed Feb 22 00:29:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 05:29:27 GMT Subject: Python LOC, .exe size, and refactoring References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> Message-ID: <4f447d36$0$11121$c3e8da3@news.astraweb.com> 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.html http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramework.aspx 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 From g.rodola at gmail.com Wed Feb 22 03:56:54 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Wed, 22 Feb 2012 09:56:54 +0100 Subject: [bug] imaplib case sensitive In-Reply-To: References: Message-ID: Please file a bug on http://bugs.python.org/ --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ Il 21 febbraio 2012 10:31, Petite Abeille ha scritto: > Hello, > > Looks like imaplib is case sensitive, even though the IMAP protocol isn't: > > (1) Except as noted otherwise, all alphabetic characters > ? ? ? ?are case-insensitive. ?The use of upper or lower case > ? ? ? ?characters to define token strings is for editorial clarity > ? ? ? ?only. ?Implementations MUST accept these strings in a > ? ? ? ?case-insensitive fashion. > > http://tools.ietf.org/html/rfc3501#section-9 > > For example: > > [Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) ] > [imaplib 2.58] > > import imaplib > > M = imaplib.IMAP4( 'localhost', 1143 ) > M.login( 'user', 'password' ) > M.select() > typ, data = M.search(None, 'ALL') > for num in data[0].split(): > ? ?typ, data = M.fetch(num, '(ENVELOPE)') > ? ?print 'Message %s\n%s\n' % (num, data[0][1]) > M.close() > M.logout() > > Traceback (most recent call last): > ?File "Test.py", line 3, in > ? ?M = imaplib.IMAP4( 'localhost', 1143 ) > ?File "python2.6/imaplib.py", line 184, in __init__ > ? ?self.welcome = self._get_response() > ?File "python2.6/imaplib.py", line 935, in _get_response > ? ?raise self.abort("unexpected response: '%s'" % resp) > imaplib.abort: unexpected response: '* ok imap4rev1' > > Note the 'ok' tag in lower case. > > > > -- > http://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Feb 22 04:31:15 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Feb 2012 20:31:15 +1100 Subject: Python LOC, .exe size, and refactoring In-Reply-To: <4f447d36$0$11121$c3e8da3@news.astraweb.com> References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> <4f447d36$0$11121$c3e8da3@news.astraweb.com> Message-ID: On Wed, Feb 22, 2012 at 4:29 PM, Steven D'Aprano wrote: > 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? There are other reasons for wanting to keep executable size down, though - low-memory VMs and such (of course, "low-memory" still means orders of magnitude more than yesterday's top-end box - the first computer I ever used, my dad bought the super-enormous 20MB hard disk option). But when you're looking at shrinking > ... an 11MB exe down to 10.8MB then it's pretty moot. ChrisA From krishankumar895 at gmail.com Wed Feb 22 04:39:02 2012 From: krishankumar895 at gmail.com (Krishan kumar) Date: Wed, 22 Feb 2012 01:39:02 -0800 (PST) Subject: DATA ENTRY SERVICES AND FORM FILLING SERVICES Message-ID: <9b45dedf-7416-425e-b485-8a72564aa27f@9g2000pbd.googlegroups.com> DATA ENTRY SERVICES AND FORM FILLING SERVICES AVAILABLE HERE http://www.wincon.co.in/ From richardbp at gmail.com Wed Feb 22 07:12:29 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 04:12:29 -0800 (PST) Subject: generate Windows exe on Linux Message-ID: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> hello, I have a python script using only the standard libraries. Currently I use a Windows VM to generate exe's, which is cumbersome. Has anyone had success generating exe's from within Linux? Richard From milkyof1 at gmail.com Wed Feb 22 07:45:09 2012 From: milkyof1 at gmail.com (anuratha) Date: Wed, 22 Feb 2012 04:45:09 -0800 (PST) Subject: hai dear this is special gift for uuuuuuuuu Message-ID: http://123maza.com/46/plant958/ From milkyof1 at gmail.com Wed Feb 22 07:45:44 2012 From: milkyof1 at gmail.com (anuratha) Date: Wed, 22 Feb 2012 04:45:44 -0800 (PST) Subject: hai dear this is special gift for uuuuuuuuu Message-ID: <939e8f14-6c2d-4242-9bf6-a3eae9cae911@z7g2000pbr.googlegroups.com> http://123maza.com/46/plant958/ From chris at simplistix.co.uk Wed Feb 22 08:20:48 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Wed, 22 Feb 2012 13:20:48 +0000 Subject: xlwt 0.7.3 released! In-Reply-To: <4F4379C6.8060803@gmail.com> References: <4F436158.7060603@simplistix.co.uk> <4F4379C6.8060803@gmail.com> Message-ID: <4F44EBB0.8040506@simplistix.co.uk> On 21/02/2012 11:02, Karim wrote: > > Is there any chance that xlrd read .xlsx format I believe this is planned for the next major release. > and arrive to decode > special unicode instead of firing some unicode Exception? Not heard of this, I suggest you explain the problem you're having on the python-excel mailing list, as linked to from http://www.python-excel.org cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From chris at simplistix.co.uk Wed Feb 22 08:22:45 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Wed, 22 Feb 2012 13:22:45 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <20120222003747.GA24152@raf.org> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> Message-ID: <4F44EC25.7060309@simplistix.co.uk> On 22/02/2012 00:37, python-excel at raf.org wrote: > was good for previous versions. two reasons that spring to mind > immediately are: > > - it makes it much easier to tell what version is installed > - it makes it much easier to uninstall the package > > i know that both of these are things that the python community > does not yet seem to find useful but everyone else seems to. That's because it's no longer best practice to polute the global python installation by installing packages directly into it. The recommended wisdom nowadays is to use a virtualenv and then pip install the package. I believe that will give you everything you need, please explain if it doesn't. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From invalid at invalid.invalid Wed Feb 22 10:31:10 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Feb 2012 15:31:10 +0000 (UTC) Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: On 2012-02-22, Kyle T. Jones wrote: > On 2/19/12 2:16 AM, SherjilOzair wrote: >> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. >> > > That's an awful lot of key mashing just to replace 'cat file.txt' No kidding. And how much python would it take to do "less file.txt"? > for i in big small upper lower ; do for j in conf bin log ; do chmod > 2755 /home/me/$i/$j ; done ; done chmod 2755 /home/me/{big,small,upper,lower}/{conf,bin,log} > cat data.log | grep Error | awk -F, '{print $5, $1, $2,}' | sort awk -F, '/Error/ {print $5, $1, $2}' data.log | sort ;) Any decent modern shell (e.g. Bash) is a stunningly powerful environment aimed at solving a certain sort of problems in a certain way. Python is aimed at solving a more general set of problems in an entirely different way. Yes, you can drive a nail with a screwdriver if you try hard enough long enough, but it's still a bad idea. -- Grant Edwards grant.b.edwards Yow! FOOLED you! Absorb at EGO SHATTERING impulse gmail.com rays, polyester poltroon!! From gabomdq at gmail.com Wed Feb 22 11:13:19 2012 From: gabomdq at gmail.com (Gabriel Jacobo) Date: Wed, 22 Feb 2012 13:13:19 -0300 Subject: [ANN] Python/Cython/SDL 2D Game Engine Message-ID: Hello list, I wanted to let you know about my pet project for the last few months, a multiplatform (Linux64/Win32/Android at the moment), Python/Cython/SDL open source 2D game engine called "Ignifuga". The source code mixes Python and Cython code, then uses Cython to convert everything to C, and compiles it all along with the Python interpreter and SDL into a static binary. It's still a long way of from being something serious, but you can already make nice Android Live wallpapers with it! You can check it out at www.ignifuga.org Thanks! -- Gabriel. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists.eckel at gmail.com Wed Feb 22 11:53:52 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 22 Feb 2012 08:53:52 -0800 (PST) Subject: Inheriting from OrderedDict causes problem Message-ID: Notice that both classes are identical, except that one inherits from dict (and works) and the other inherits from OrderedDict and fails. Has anyone seen this before? Thanks. import collections class Y(dict): def __init__(self, stuff): for k, v in stuff: self[k] = v # This works: print Y([('a', 'b'), ('c', 'd')]) class X(collections.OrderedDict): def __init__(self, stuff): for k, v in stuff: self[k] = v # This doesn't: print X([('a', 'b'), ('c', 'd')]) """ Output: {'a': 'b', 'c': 'd'} Traceback (most recent call last): File "OrderedDictInheritance.py", line 17, in print X([('a', 'b'), ('c', 'd')]) File "OrderedDictInheritance.py", line 14, in __init__ self[k] = v File "C:\Python27\lib\collections.py", line 58, in __setitem__ root = self.__root AttributeError: 'X' object has no attribute '_OrderedDict__root' """ From __peter__ at web.de Wed Feb 22 12:10:25 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 22 Feb 2012 18:10:25 +0100 Subject: Inheriting from OrderedDict causes problem References: Message-ID: Bruce Eckel wrote: > Notice that both classes are identical, except that one inherits from > dict (and works) and the other inherits from OrderedDict and fails. > Has anyone seen this before? Thanks. > > import collections > > class Y(dict): > def __init__(self, stuff): > for k, v in stuff: > self[k] = v > > # This works: > print Y([('a', 'b'), ('c', 'd')]) > > class X(collections.OrderedDict): > def __init__(self, stuff): > for k, v in stuff: > self[k] = v > > # This doesn't: > print X([('a', 'b'), ('c', 'd')]) > > """ Output: > {'a': 'b', 'c': 'd'} > Traceback (most recent call last): > File "OrderedDictInheritance.py", line 17, in > print X([('a', 'b'), ('c', 'd')]) > File "OrderedDictInheritance.py", line 14, in __init__ > self[k] = v > File "C:\Python27\lib\collections.py", line 58, in __setitem__ > root = self.__root > AttributeError: 'X' object has no attribute '_OrderedDict__root' > """ Looks like invoking OrderedDict.__init__() is necessary: >>> from collections import OrderedDict >>> class X(OrderedDict): ... def __init__(self, stuff): ... super(X, self).__init__() ... for k, v in stuff: ... self[k] = v ... >>> X([("a", "b"), ("c", "d")]) X([('a', 'b'), ('c', 'd')]) From wm at localhost.localdomain Wed Feb 22 12:19:12 2012 From: wm at localhost.localdomain (Waldek M.) Date: Wed, 22 Feb 2012 18:19:12 +0100 Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: > I have a python script using only the standard libraries. > Currently I use a Windows VM to generate exe's, which is cumbersome. And what exactly *is* this exe about? > Has anyone had success generating exe's from within Linux? That doesn't seem to have anything to do with Python, but you might want to google for cross-compiling. Best regards, Waldek From lists.eckel at gmail.com Wed Feb 22 12:33:12 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 22 Feb 2012 09:33:12 -0800 (PST) Subject: Inheriting from OrderedDict causes problem References: Message-ID: <4c239c43-2cf6-418e-b5e7-c71f51aed07d@y38g2000yqb.googlegroups.com> On Feb 22, 10:10?am, Peter Otten <__pete... at web.de> wrote: > Looks like invoking OrderedDict.__init__() is necessary: > > >>> from collections import OrderedDict > >>> class X(OrderedDict): > > ... ? ? def __init__(self, stuff): > ... ? ? ? ? ? ? super(X, self).__init__() > ... ? ? ? ? ? ? for k, v in stuff: > ... ? ? ? ? ? ? ? ? ? ? self[k] = v > ...>>> X([("a", "b"), ("c", "d")]) > > X([('a', 'b'), ('c', 'd')]) Thank you! That worked. Languages. Some of them automatically call the default base-class constructors, others don't. Apparently. From jerome at jolimont.fr Wed Feb 22 12:42:11 2012 From: jerome at jolimont.fr (=?UTF-8?B?SsOpcsO0bWU=?=) Date: Wed, 22 Feb 2012 18:42:11 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <20120222184211.1935846f@bouzin.lan> Wed, 22 Feb 2012 18:19:12 +0100 Waldek M. a ?crit: > On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: > > I have a python script using only the standard libraries. > > Currently I use a Windows VM to generate exe's, which is cumbersome. > > And what exactly *is* this exe about? Whatever. > > Has anyone had success generating exe's from within Linux? > > That doesn't seem to have anything to do with Python, > but you might want to google for cross-compiling. I think his question is totally python related. As I understand it, Richard creates executables from python scripts using a tool, such as py2exe [1], that requires windows. He would like to have an equivalent tool that runs on linux, to avoid going through the trouble of having to run a windows installation. I'm interested in such a tool as well. [1] http://www.py2exe.org/ -- J?r?me From alec.taylor6 at gmail.com Wed Feb 22 13:05:46 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 23 Feb 2012 05:05:46 +1100 Subject: generate Windows exe on Linux In-Reply-To: <20120222184211.1935846f@bouzin.lan> References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: http://www.pyinstaller.org/ or http://cx-freeze.sourceforge.net/ You can also run py2exe in WINE On Thu, Feb 23, 2012 at 4:42 AM, J?r?me wrote: > Wed, 22 Feb 2012 18:19:12 +0100 > Waldek M. a ?crit: > >> On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: >> > I have a python script using only the standard libraries. >> > Currently I use a Windows VM to generate exe's, which is cumbersome. >> >> And what exactly *is* this exe about? > > Whatever. > >> > Has anyone had success generating exe's from within Linux? >> >> That doesn't seem to have anything to do with Python, >> but you might want to google for cross-compiling. > > I think his question is totally python related. > > As I understand it, Richard creates executables from python scripts using a > tool, such as py2exe [1], that requires windows. He would like to have an > equivalent tool that runs on linux, to avoid going through the trouble of > having to run a windows installation. > > I'm interested in such a tool as well. > > [1] http://www.py2exe.org/ > > -- > J?r?me > -- > http://mail.python.org/mailman/listinfo/python-list From alec.taylor6 at gmail.com Wed Feb 22 13:13:17 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 23 Feb 2012 05:13:17 +1100 Subject: Python math is off by .000000000000045 Message-ID: Simple mathematical problem, + and - only: >>> 1800.00-1041.00-555.74+530.74-794.95 -60.950000000000045 That's wrong. Proof http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 -60.95 aka (-(1219/20)) Is there a reason Python math is only approximated? - Or is this a bug? Thanks for all info, Alec Taylor From breamoreboy at yahoo.co.uk Wed Feb 22 13:24:37 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Feb 2012 18:24:37 +0000 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On 22/02/2012 18:13, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor Please google for floating point numbers. -- Cheers. Mark Lawrence. From ian.g.kelly at gmail.com Wed Feb 22 13:26:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 22 Feb 2012 11:26:12 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 11:13 AM, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? http://docs.python.org/faq/design.html#why-are-floating-point-calculations-so-inaccurate From lists at cheimes.de Wed Feb 22 13:26:26 2012 From: lists at cheimes.de (Christian Heimes) Date: Wed, 22 Feb 2012 19:26:26 +0100 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: Am 22.02.2012 19:13, schrieb Alec Taylor: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. That's only the correct answer for unlimited precision, not for IEEE-754 semantics. http://en.wikipedia.org/wiki/IEEE_754 > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? Python uses the platforms double precision float datatype. Floats are almost never exact. Christian From pruebauno at latinmail.com Wed Feb 22 13:29:21 2012 From: pruebauno at latinmail.com (nn) Date: Wed, 22 Feb 2012 10:29:21 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: <50fc2c9a-ee33-489d-a668-135c1f3cf1bb@p12g2000yqe.googlegroups.com> On Feb 22, 1:13?pm, Alec Taylor wrote: > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > > -60.950000000000045 > > That's wrong. > > Proofhttp://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-... > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor I get the right answer if I use the right datatype: >>> import decimal >>> D=decimal.Decimal >>> D('1800.00')-D('1041.00')-D('555.74')+D('530.74')-D('794.95') Decimal('-60.95') From benjamin.kaplan at case.edu Wed Feb 22 13:32:06 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 22 Feb 2012 13:32:06 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Feb 22, 2012 1:16 PM, "Alec Taylor" wrote: > > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor > -- You aren't doing math with decimal numbers. you're using IEEE 754-compliant double precision floating point numbers. this isn't just a python thing. You'd get the same results in C, Java, VB, and pretty much every other general purpose language written in the last 40 years. Floats are represented in a form similar to scientific notation (a * 2^b), so just like scientific notation, there's a finite number of significant figures. And just like there are rational numbers that can't be represented in decimal, like 1/3, there are numbers that can't be represented in binary, like 1/10. Double-precision numbers are accurate to about 15 decimal digits. if you need more precision, there is the decimal module but it's way slower because your processor doesn't natively support it. > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Feb 22 13:43:06 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 22 Feb 2012 10:43:06 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 10:13 AM, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Welcome to the world of finite-precision binary floating-point arithmetic then! Reality bites. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? Because vanilla floating-point numbers have a finite bit length (and thus finite precision) but they try to represent a portion of the real number line, which has infinitely many points. Some approximation therefore has to occur. It's not a problem specific to Python; it's inherent to your CPU's floating point numeric types. Read http://docs.python.org/tutorial/floatingpoint.html and http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Wolfram Alpha is either rounding off its answer to fewer decimal places (thus merely hiding the imprecision), or using some different, more computationally expensive arithmetic type(s) in its calculations, hence why it gives the exact answer. Alternatives to floats in Python include: * Fractions: http://docs.python.org/library/fractions.html * Arbitrary-precision decimal floating point: http://docs.python.org/library/decimal.html These aren't the default for both historical and performance reasons. Cheers, Chris From jpiitula at ling.helsinki.fi Wed Feb 22 13:44:52 2012 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: 22 Feb 2012 20:44:52 +0200 Subject: Python math is off by .000000000000045 References: Message-ID: Alec Taylor writes: > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Not by much. I'm not an expert, but my guess is that the exact value is not representable in binary floating point, which most programming languages use for this. Ah, indeed: >>> 0.95 0.94999999999999996 Some languages hide the error by printing fewer decimals than they use internally. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? There are practical reasons. Do learn about "floating point". There is a price to pay, but you can have exact rational arithmetic in Python when you need or want it - I folded the long lines by hand afterwards: >>> from fractions import Fraction >>> 1800 - 1041 - Fraction(55574, 100) + Fraction(53074, 100) - Fraction(79495, 100) Fraction(-1219, 20) >>> -1219/20 -61 >>> -1219./20 -60.950000000000003 >>> float(1800 - 1041 - Fraction(55574, 100) + Fraction(53074, 100) - Fraction(79495, 100)) -60.950000000000003 From gheskett at wdtv.com Wed Feb 22 15:16:13 2012 From: gheskett at wdtv.com (gene heskett) Date: Wed, 22 Feb 2012 15:16:13 -0500 Subject: Questionnaire on motivation analysis of open source and open content In-Reply-To: <4F437F0B.1080405@dpem.tuc.gr> References: <4F437F0B.1080405@dpem.tuc.gr> Message-ID: <201202221516.13071.gheskett@wdtv.com> On Wednesday, February 22, 2012 03:14:51 PM George Tsinarakis did opine: > Dear Sirs, > > We are researchers in Technical University of Crete and our current > research is in the field of motivation analysis of open source and open > content software projects participants. We would like to ask you to fill > a questionnaire and forward it to people involved in such teams and > projects. The web address is the following: > > https://docs.google.com/spreadsheet/viewform?formkey=dHdqZUgyay0waXNRbW > FvV3hleVBZSWc6MQ > > All personal information will be kept confidential and will be used for > academic purposes only. For further information please do not hesitate > to contact with us. > > > > Thank you in advance > > Dr G. Tsinarakis (*&^%(*%$ phishing folks never give up... Nuke that subscription forthwith, with extreme prejudice. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: "We can't schedule an orgy, it might be construed as fighting" --Stanley Sutton From invalid at invalid.invalid Wed Feb 22 15:48:34 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Feb 2012 20:48:34 +0000 (UTC) Subject: Python math is off by .000000000000045 References: Message-ID: On 2012-02-22, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Oh good. We haven't have this thread for several days. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? http://docs.python.org/tutorial/floatingpoint.html Python uses binary floating point with a fixed size (64 bit IEEE-754 on all the platforms I've ever run across). Floating point numbers are only approximations of real numbers. For every floating point number there is a corresponding real number, but 0% of real numbers can be represented exactly by floating point numbers. > - Or is this a bug? No, it's how floating point works. If you want something else, then perhaps you should use rationals or decimals: http://docs.python.org/library/fractions.html http://docs.python.org/library/decimal.html -- Grant Edwards grant.b.edwards Yow! What I want to find at out is -- do parrots know gmail.com much about Astro-Turf? From steve+comp.lang.python at pearwood.info Wed Feb 22 17:15:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 22:15:55 GMT Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4f45691a$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Feb 2012 15:31:10 +0000, Grant Edwards wrote: > On 2012-02-22, Kyle T. Jones > wrote: >> On 2/19/12 2:16 AM, SherjilOzair wrote: >>> Well, if not modify python itself, I was thinking of making another >>> shell, which borrows a lot from python, something like merging bash >>> and python. such that I can do `cd ~/Desktop/dev` and `for i in >>> open('file.txt'): print i` at the some shell. This I think would be >>> VERY useful. >>> >>> >> That's an awful lot of key mashing just to replace 'cat file.txt' > > No kidding. And how much python would it take to do "less file.txt"? A lot less than the amount of C it takes to do "less file.txt". I trust you don't imagine that a Python shell would require the user to re-implement "less" using nothing but built-ins each time they needed it. There would be a pre-made "less" replacement (which may even be a wrapper around the system "less") never more than one import away. You can already do something very close to this right now: from pydoc import pager pager(open("file.txt").read()) How much effort would it take to turn pydoc.pager into a full replacement for "less"? I don't know, but it would only need to be done ONCE. This is not a theoretical argument. IPython already does this. It not only gives you full access to all your shell commands, plus more, but it let's you use something very close to shell syntax to do it. http://ipython.org/ipython-doc/dev/interactive/shell.html The advantage of a Python shell like IPython is not for trivial shell commands like "less file.txt". I can think of at least four reasons why you might consider a Python shell would be awesome: "I know Python, and I don't know bash. What do I care if it takes five lines to perform a task in Python, vs one line in bash, if it would take me half an hour of reading man pages and seven attempts to get the bash version right?" "I'm fed up to the back teeth of the shell's cryptic syntax, magic global variables and especially its arcane string quoting rules." "I'm sick and tired of having to parse human-readable presentation text to get the answers I want. I want an environment where the tools don't mix content and presentation by default." "My OS has a shell which sucks and blows at the same time. I want something better." So basically, there exists a niche for Python as a shell, and thanks to the time machine, there already exists a powerful Python shell ready to fill that niche. -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 22 17:21:31 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 22:21:31 GMT Subject: Python math is off by .000000000000045 References: Message-ID: <4f456a6b$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Feb 2012 19:26:26 +0100, Christian Heimes wrote: > Python uses the platforms double precision float datatype. Floats are > almost never exact. Well, that's not quite true. Python floats are always exact. They just may not be exactly what you want :) Pedantic-but-unhelpful-as-always-ly y'rs, -- Steven From gelonida at gmail.com Wed Feb 22 17:25:07 2012 From: gelonida at gmail.com (Gelonida N) Date: Wed, 22 Feb 2012 23:25:07 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: On 02/22/2012 07:05 PM, Alec Taylor wrote: > http://www.pyinstaller.org/ > > or > > http://cx-freeze.sourceforge.net/ > > You can also run py2exe in WINE > You want to say, that I could install python 2.6 some packages like win32api PyQt and tand py2exe under Wine and then compile it. Did you try this? I didn't even think about trying this out, but I know very little about the limits of Wine, so perhaps I underestimate it. From stefan_ml at behnel.de Wed Feb 22 17:43:23 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 22 Feb 2012 23:43:23 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: Gelonida N, 22.02.2012 23:25: > On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > > You want to say, that I could install python 2.6 > some packages like win32api > PyQt and tand py2exe under Wine and then compile it. > > > Did you try this? > > I didn't even think about trying this out, > but I know very little about the limits of Wine, so perhaps I > underestimate it. The compliance requirements for software build tools tend to be rather easy to meet, so Wine shouldn't have any real problems there. Having said that, Wine is actually surprisingly capable these days. It won't always run the latest release of our all-time favourite WYGIWYD character pushing or number layouting programs from MS-Office fame, but at least older versions of many a program tend to work rather nicely. Stefan From python-excel at raf.org Wed Feb 22 18:15:01 2012 From: python-excel at raf.org (python-excel at raf.org) Date: Thu, 23 Feb 2012 10:15:01 +1100 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F44EC25.7060309@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> Message-ID: <20120222231501.GA6553@raf.org> Chris Withers wrote: > On 22/02/2012 00:37, python-excel at raf.org wrote: > >was good for previous versions. two reasons that spring to mind > >immediately are: > > > > - it makes it much easier to tell what version is installed > > - it makes it much easier to uninstall the package > > > >i know that both of these are things that the python community > >does not yet seem to find useful but everyone else seems to. > > That's because it's no longer best practice to polute the global > python installation by installing packages directly into it. > > The recommended wisdom nowadays is to use a virtualenv and then pip > install the package. > > I believe that will give you everything you need, please explain if > it doesn't. > > cheers, > > Chris thanks. i'm sure that'll do nicely. cheers, raf From adrian.klaver at gmail.com Wed Feb 22 18:17:26 2012 From: adrian.klaver at gmail.com (Adrian Klaver) Date: Wed, 22 Feb 2012 15:17:26 -0800 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F44EC25.7060309@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> Message-ID: <201202221517.27298.adrian.klaver@gmail.com> On Wednesday, February 22, 2012 5:22:45 am Chris Withers wrote: > On 22/02/2012 00:37, python-excel at raf.org wrote: > > was good for previous versions. two reasons that spring to mind > > > > immediately are: > > - it makes it much easier to tell what version is installed > > - it makes it much easier to uninstall the package > > > > i know that both of these are things that the python community > > does not yet seem to find useful but everyone else seems to. > > That's because it's no longer best practice to polute the global python > installation by installing packages directly into it. > > The recommended wisdom nowadays is to use a virtualenv and then pip > install the package. I can see where that would be preferred when managing multiple versions of Python, but not when using a single version. The pip system does a good job of managing package installs in the global context. As to the OPs original post, I see the point. On Windows the installer is the point of entry for 'package' management, going outside that can get confusing. I also understand setting up a Windows installer is non-trivial. Assuming a Windows installer is not in the offing, the OP might find it easier to use the Python packaging from here on out. For an example, to find out information on a package: aklaver at tucker:~/.pip$ pip search xlrd xlutils - Utilities for working with Excel files that require both xlrd and xlwt xlrd - Library for developers to extract data from Microsoft Excel (tm) spreadsheet files INSTALLED: 0.7.2 (latest) xlrd3 - Library for developers to extract data from Microsoft Excel (tm) spreadsheet files xlrd1 - library for extracting data from Microsoft Excel spreadsheet files > > I believe that will give you everything you need, please explain if it > doesn't. > > cheers, > > Chris -- Adrian Klaver adrian.klaver at gmail.com From steve+comp.lang.python at pearwood.info Wed Feb 22 19:52:50 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 00:52:50 GMT Subject: distutils + mercurial good practice question Message-ID: <4f458de2$0$11121$c3e8da3@news.astraweb.com> distutils generates a number of files automatically in my projects, including MANIFEST, build/* and dist/* Is there any reason why I would want or need to track them in mercurial? I currently have this .hgignore file: syntax: glob *.pyc *~ exclude/* build/* dist/* MANIFEST Good practice or bad practice? -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 22 21:09:09 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 02:09:09 GMT Subject: ANN: pyprimes 0.1 released Message-ID: <4f459fc5$0$11121$c3e8da3@news.astraweb.com> I am happy to announce the first public release of pyprimes, a pure- Python module for generating prime numbers, primality tests, and prime factorisation. http://pypi.python.org/pypi/pyprimes/0.1.1a With pyprimes, you can compare a number of algorithms for generating and testing primes. It includes fast algorithms for lazily generating primes on demand, such as the Croft Spiral, as well as terrible examples of algorithms to avoid, such as Turner's Sieve (sometimes known as "the Sleight on Eratosthenes"). Examples: py> import pyprimes py> pyprimes.isprime(3300454933) True py> pyprimes.factors(3300454934) [2, 7, 14969, 15749L] py> for p in pyprimes.primes(): ... if p < 500000: continue ... if p > 500100: break ... print p ... 500009 500029 500041 500057 500069 500083 A note on performance: Generating large prime numbers (hundreds of digits) is extremely computationally intensive. A pure-Python solution like pyprimes is unlikely to be suitable for such large numbers, and I make no claim that it will break any world-records. But many popular and common prime number generators can't even deal well with *five* digit primes, slowing down to a crawl. pyprimes is in some cases hundreds of times faster than such prime generators. pyprimes includes examples of these algorithms so you can compare them for yourself: py> from time import time py> def test(generator): ... t = time() ... for p in generator(): ... if p > 10000: break ... return time() - t ... py> test(pyprimes.primes) 0.013000965118408203 py> test(pyprimes.naive_primes1) 4.1489889621734619 -- Steven From richard at pyweek.org Wed Feb 22 22:16:09 2012 From: richard at pyweek.org (Richard Jones) Date: Thu, 23 Feb 2012 14:16:09 +1100 Subject: Python Game Programming Challenge (PyWeek) #14 is coming! [corrected dates] Message-ID: Note: this email corrects the dates given in the previous announcement. The 14th Python Game Programming Challenge (PyWeek) is coming. It'll run from the 6th to the 13th of May. Not April as previously announced. http://pyweek.org/14/ New user registration is NOT YET OPEN. It will open one month before the challenge starts. The PyWeek challenge: - Invites entrants to write a game in one week from scratch either as an individual or in a team, - Is intended to be challenging and fun, - Will hopefully increase the public body of game tools, code and expertise, - Will let a lot of people actually finish a game, and - May inspire new projects (with ready made teams!) If you're in the US and can make it I'm co-presenting a 3 hour pygame tutorial at PyCon in March. From miki.tebeka at gmail.com Wed Feb 22 22:19:22 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 22 Feb 2012 19:19:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: <30968261.1414.1329967162981.JavaMail.geo-discussion-forums@ynlp18> > Having said that, Wine is actually surprisingly capable these days. It > won't always run the latest release of our all-time favourite WYGIWYD > character pushing or number layouting programs from MS-Office fame, but at > least older versions of many a program tend to work rather nicely. Even newer ones, have a look at http://www.playonlinux.com/en/ to get a taste of what it's capable of. From miki.tebeka at gmail.com Wed Feb 22 22:19:22 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 22 Feb 2012 19:19:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: <30968261.1414.1329967162981.JavaMail.geo-discussion-forums@ynlp18> > Having said that, Wine is actually surprisingly capable these days. It > won't always run the latest release of our all-time favourite WYGIWYD > character pushing or number layouting programs from MS-Office fame, but at > least older versions of many a program tend to work rather nicely. Even newer ones, have a look at http://www.playonlinux.com/en/ to get a taste of what it's capable of. From krishankumar895 at gmail.com Thu Feb 23 00:34:08 2012 From: krishankumar895 at gmail.com (Krishan kumar) Date: Wed, 22 Feb 2012 21:34:08 -0800 (PST) Subject: ONLINE FORM FILLING AND DATA ENTRY SERVICES Message-ID: ONLINE FORM FILLING AND DATA ENTRY SERVICES AVAILABLE HERE http://www.wincon.co.in From ssmile03 at gmail.com Thu Feb 23 01:24:42 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 23 Feb 2012 11:54:42 +0530 Subject: storing in list and retrieving. Message-ID: I need to write two file using python script as below - 1. Store.py: Write a script to store a list say "store_list = ["Apple", "Orange", "PineApple". ?and so on? ]" to disk. 2. Retrieve.py: Read the object stored in the ?Store.py? file and print the contents of this list. I have to run on Linux with python-2.6.5. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Feb 23 01:31:25 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Feb 2012 17:31:25 +1100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 wrote: > I need to write two file using python script as below - > > 1. Store.py: Write a script to store a list say "store_list = ["Apple", > "Orange", "PineApple". ?and so on? ]" to disk. > > 2. Retrieve.py: Read the object stored in the ?Store.py? file and print the > contents of this list. > > I have to run on Linux with python-2.6.5. This looks like homework, so I'm just going to give a broad hint. Figure out a file format (one per line, or pickled, or whatever), then write one program that writes that format and another that reads it. The open() built-in function will open files for reading or writing, so that's a good place to start. Get as far as you can on your own, and if you get stuck, ask the list for more specific help. Good luck! Chris Angelico From richardbp at gmail.com Thu Feb 23 01:33:22 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:33:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <33059459.3.1329978802605.JavaMail.geo-discussion-forums@pbib1> thanks J?r?me. Closest I have found is pyinstaller added support for cross-compiling a year ago by mounting a Windows partition on Linux: https://groups.google.com/forum/?fromgroups#!topic/pyinstaller/KISZP5sHCWg But it was not stable so will be removed: https://groups.google.com/forum/?fromgroups#!searchin/PyInstaller/linux$20windows/pyinstaller/veq3BlA_Bns I have come across many vague suggestions to try using Wine with py2exe / pyinstaller / cx_Freeze, but few accounts from people who have actually succeeded. Richard From richardbp at gmail.com Thu Feb 23 01:33:22 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:33:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <33059459.3.1329978802605.JavaMail.geo-discussion-forums@pbib1> thanks J?r?me. Closest I have found is pyinstaller added support for cross-compiling a year ago by mounting a Windows partition on Linux: https://groups.google.com/forum/?fromgroups#!topic/pyinstaller/KISZP5sHCWg But it was not stable so will be removed: https://groups.google.com/forum/?fromgroups#!searchin/PyInstaller/linux$20windows/pyinstaller/veq3BlA_Bns I have come across many vague suggestions to try using Wine with py2exe / pyinstaller / cx_Freeze, but few accounts from people who have actually succeeded. Richard From richardbp at gmail.com Thu Feb 23 01:58:10 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:58:10 -0800 (PST) Subject: asynchronous downloading Message-ID: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> I want to download content asynchronously. This would be straightforward to do threaded or across processes, but difficult asynchronously so people seem to rely on external libraries (twisted / gevent / eventlet). (I would use gevent under different circumstances, but currently need to stick to standard libraries.) I looked around and found there is little interest in developing a proper HTTP client on asyncore. The best I found stopped development a decade ago: http://sourceforge.net/projects/asynchttp/ What do you recommend? And why is there poor support for asynchronous execution? Richard From kingkon098 at gmail.com Thu Feb 23 02:11:05 2012 From: kingkon098 at gmail.com (vikram) Date: Wed, 22 Feb 2012 23:11:05 -0800 (PST) Subject: DATA ENTRY, FORM FILLING AND BPO SERVICES Message-ID: <8384a028-62d5-4edf-8784-96e939055472@jn12g2000pbb.googlegroups.com> DATA ENTRY, FORM FILLING AND BPO SERVICES AVAILABLE HERE http://www.wincon.co.in/ From justin.mailinglists at gmail.com Thu Feb 23 02:25:32 2012 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Wed, 22 Feb 2012 23:25:32 -0800 (PST) Subject: asynchronous downloading References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <8642ad38-41ab-4137-95bb-259e6c1fb519@qt7g2000pbc.googlegroups.com> have you seen http://www.doughellmann.com/PyMOTW/asyncore/ From chris at simplistix.co.uk Thu Feb 23 02:56:43 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 23 Feb 2012 07:56:43 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <201202221517.27298.adrian.klaver@gmail.com> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <201202221517.27298.adrian.klaver@gmail.com> Message-ID: <4F45F13B.2020609@simplistix.co.uk> On 22/02/2012 23:17, Adrian Klaver wrote: > I can see where that would be preferred when managing multiple versions of > Python, but not when using a single version. Sorry, I don't agree. It is *never* a good idea to install packages globally. Using virtualenv or similar (buildout, etc) gives you a single, cross platform way of not ending up with a mess of a python installation where you have a bunch of libraries of random versions installed, often with no way of finding out what version they are or how to uninstall them. Heaven forbid you want to use or develop more than one project per machine; then you end up with different projects needing different versions of the same libraries and you're screwed. ;-) > The pip system does a good job o > managing package installs in the global context. Ask the pip maintainers whether they'd suggest using pip on the global system python or inside a virtualenv... > see the point. On Windows the installer is the point of entry for 'package' > management, going outside that can get confusing. "Python" should be though of as the application, not any individual library... > I also understand setting up a > Windows installer is non-trivial. It isn't a lot of work from what I remember, I just don't like encouraging bad practices... > offing, the OP might find it easier to use the Python packaging from here on out. What is "the Python packaging" you refer to? > xlrd3 - Library for developers to extract data from > Microsoft Excel (tm) spreadsheet files > xlrd1 - library for extracting data from Microsoft Excel > spreadsheet files I would avoid both of these like the plague, it's a shame the people who dumped them on PyPI don't put up a similar warning :-( cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From ssmile03 at gmail.com Thu Feb 23 03:45:00 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 23 Feb 2012 14:15:00 +0530 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: It requires concepts of 'python persistence' for the code to be designed . Else it simple. Looking for some flow?? ---- On Thu, Feb 23, 2012 at 12:01 PM, Chris Angelico wrote: > On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 wrote: > > I need to write two file using python script as below - > > > > 1. Store.py: Write a script to store a list say "store_list = ["Apple", > > "Orange", "PineApple". ?and so on? ]" to disk. > > > > 2. Retrieve.py: Read the object stored in the ?Store.py? file and print > the > > contents of this list. > > > > I have to run on Linux with python-2.6.5. > > This looks like homework, so I'm just going to give a broad hint. > > Figure out a file format (one per line, or pickled, or whatever), then > write one program that writes that format and another that reads it. > The open() built-in function will open files for reading or writing, > so that's a good place to start. > > Get as far as you can on your own, and if you get stuck, ask the list > for more specific help. Good luck! > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From navkirats at gmail.com Thu Feb 23 04:26:21 2012 From: navkirats at gmail.com (Nav) Date: Thu, 23 Feb 2012 01:26:21 -0800 (PST) Subject: Reset static variables or a workaround Message-ID: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Hi Guys, I have a custom user form class, it inherits my own custom Form class: class UserForm(Form): first_name = TextField(attributes={id='id_firstname'}) Now, everytime UserForm() is instantiated it saves the attributes of each form members and passes it on to the new instance. I understand this is because first_name is static in nature. But I would like to reset the first_name for every instance? How can I do this? Regards, Nav From rosuav at gmail.com Thu Feb 23 04:26:44 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Feb 2012 20:26:44 +1100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 7:45 PM, Smiley 4321 wrote: > It requires concepts of 'python persistence' for the code to be designed . > > Else it simple. > > Looking for some flow?? Go through the tutorial on python.org if you haven't, get some code written, and then codify your questions :) Chances are you'll figure it out on your own. ChrisA From clp2 at rebertia.com Thu Feb 23 04:43:42 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 01:43:42 -0800 Subject: Reset static variables or a workaround In-Reply-To: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> References: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 1:26 AM, Nav wrote: > Hi Guys, > > I have a custom user form class, it inherits my own custom Form class: > > class UserForm(Form): > ? ?first_name = TextField(attributes={id='id_firstname'}) > > Now, everytime UserForm() is instantiated it saves the attributes of > each form members and passes it on to the new instance. I understand > this is because first_name is static in nature. But I would like to > reset the first_name for every instance? How can I do this? I infer that your question concerns Django. You might want to ask on their discussion group instead: http://groups.google.com/group/django-users Cheers, Chris From jeanmichel at sequans.com Thu Feb 23 05:18:07 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 23 Feb 2012 11:18:07 +0100 Subject: Reset static variables or a workaround In-Reply-To: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> References: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Message-ID: <4F46125F.4070204@sequans.com> Nav wrote: > Hi Guys, > > I have a custom user form class, it inherits my own custom Form class: > > class UserForm(Form): > first_name = TextField(attributes={id='id_firstname'}) > > Now, everytime UserForm() is instantiated it saves the attributes of > each form members and passes it on to the new instance. I'm not sure I've understood this sentence but if you're saying that class attributes are copied into the subclass instance, that's wrong. > I understand > this is because first_name is static in nature. But I would like to > reset the first_name for every instance? How can I do this? > > Regards, > Nav > Class attributes are not default values for instances. If you want to set the first_name attribute for every instances, you have to make it an instance attribute: class Form: def __init__(self): self.first_name = "foo" class UserForm(Form): def __init__(self, name): Form.__init__(self) self.first_name = name uForm = UserForm('banana') print uForm.first_name Cheers, JM From jeanmichel at sequans.com Thu Feb 23 05:31:17 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 23 Feb 2012 11:31:17 +0100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: <4F461575.5000906@sequans.com> Smiley 4321 wrote: > It requires concepts of 'python persistence' for the code to be designed . > > Else it simple. > > Looking for some flow?? > ---- Hi, Have a look at http://docs.python.org/library/pickle.html Cheers, JM From ralf at systemexit.de Thu Feb 23 06:00:15 2012 From: ralf at systemexit.de (Ralf Schmitt) Date: Thu, 23 Feb 2012 12:00:15 +0100 Subject: [ANNOUNCE] pypiserver 0.5.1 - minimal pypi server Message-ID: <87hayhak74.fsf@winserver.brainbot.com> Hi, I've just uploaded pypiserver 0.5.1 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just easy_install pypiserver). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 0.5.1 ------------------------- - make 'pypi-server -U' compatible with pip 1.1 -- Cheers, Ralf From mhammond at skippinet.com.au Thu Feb 23 06:20:40 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 23 Feb 2012 22:20:40 +1100 Subject: asynchronous downloading In-Reply-To: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <4F462108.2000400@skippinet.com.au> On 23/02/2012 5:58 PM, Plumo wrote: > I want to download content asynchronously. This would be > straightforward to do threaded or across processes, but difficult > asynchronously so people seem to rely on external libraries (twisted > / gevent / eventlet). Exactly - the fact it's difficult is why those tools compete. > (I would use gevent under different circumstances, but currently need > to stick to standard libraries.) As above - use threads or processes - they are fine for relatively modest tasks. If your needs go beyond modest, I'd reevaluate your need to stick with just the stdlib - even demanding *sync* http apps often wind up using modules outside the stdlib. Look into virtualenv etc if permission to install packages is the issue. Batteries included free, but turbo-chargers are an extra ;) Mark From no.email at nospam.invalid Thu Feb 23 06:46:00 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 23 Feb 2012 03:46:00 -0800 Subject: asynchronous downloading References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <7x4nuhlqmf.fsf@ruckus.brouhaha.com> Plumo writes: > What do you recommend? Threads. > And why is there poor support for asynchronous execution? The freenode #python crowd seems to hate threads and prefer twisted, which seems to have the features you want and probably handles very large #'s of connections better than POSIX threads do. But I find the whole event-driven model to be an annoying abstraction inversion and threads to be simpler, so I've stayed with threads. I keep hearing boogieman stories about the evil hazards of race conditions etc. but none of that stuff has ever happened to me (yet) as far as I can tell. The main thing is to avoid sharing mutable data between threads to the extent that you can. Keep the threads isolated from each other except for communication through Queues and not too much can go wrong. The last program I wrote had around 20 threads and one or two condition variables and I don't think any significant bugs resulted from that. FWIW, the Erlang language is built around the above concept, it uses super-lightweight userland threads so it can handle millions of them concurrently, and it's used successfully for ultra-high-reliability phone switches and similar applications that are not allowed to fail, so it must be doing something right. There are a few schemes like Camaelia (sp?) implementing concurrency with Python generators or coroutines, but I think they're not widely used, and Python coroutines are kind of crippled because they don't carry any stack below their entry point. From glicerinu at gmail.com Thu Feb 23 06:52:27 2012 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 23 Feb 2012 03:52:27 -0800 (PST) Subject: unexpected behaviour playing with dynamic methods Message-ID: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Hi, I'm playing a bit with python dynamic methods and I came up with a scenario that I don't understant. Considering the follow code: # Declare a dummy class class A(object): pass # generate a dynamic method and insert it to A class for name in ['a', 'b', 'c']: if name == 'b': @property def get_name(self): return name A.name = get_name a_instance = A() a_instance.name # So far I exptect that a_instance.name returns 'b', since it has been created when name == 'b', but this is what actually returns: >>> a_instance.name 'c' just the last 'name' value. What can I do in order to generate a method like this but that returns 'b' ? What is wrong in my understanding of this pice of code? Thanks !!! marc From __peter__ at web.de Thu Feb 23 08:05:24 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 23 Feb 2012 14:05:24 +0100 Subject: unexpected behaviour playing with dynamic methods References: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Message-ID: Marc Aymerich wrote: > Hi, > > I'm playing a bit with python dynamic methods and I came up with a > scenario that I don't understant. Considering the follow code: > > # Declare a dummy class > class A(object): > pass > > # generate a dynamic method and insert it to A class > for name in ['a', 'b', 'c']: > if name == 'b': > @property > def get_name(self): > return name > A.name = get_name > > > a_instance = A() > a_instance.name > > # So far I exptect that a_instance.name returns 'b', since it has > been created when name == 'b', but this is what actually returns: > >>>> a_instance.name > 'c' > > just the last 'name' value. > What can I do in order to generate a method like this but that returns > 'b' ? What is wrong in my understanding of this pice of code? Look at the method again: > def get_name(self): > return name It returns the global variable name. Why would you expect to see a historical value of that variable? If you want to capture the value of name at the time when get_name() is defined you have several options: - The default argument trick: def get_name(self, name=name): return name - A closure: def make_get_name(name): def get_name(self): return name return get_name A.name = property(make_get_name(name)) - functools.partial() def get_name(self, name): return name A.name = property(partial(get_name, name=name)) From glicerinu at gmail.com Thu Feb 23 08:44:46 2012 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 23 Feb 2012 05:44:46 -0800 (PST) Subject: unexpected behaviour playing with dynamic methods References: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Message-ID: On Feb 23, 2:05?pm, Peter Otten <__pete... at web.de> wrote: > Marc Aymerich wrote: > > Hi, > > > I'm playing a bit with python dynamic methods and I came up with a > > scenario that I don't understant. Considering the follow code: > > > # Declare a dummy class > > class A(object): > > ? ? pass > > > # generate a dynamic method and insert it to A class > > for name in ['a', 'b', 'c']: > > ? ? if name == 'b': > > ? ? ? ? @property > > ? ? ? ? def get_name(self): > > ? ? ? ? ? ? return name > > ? ? ? ? A.name = get_name > > > a_instance = A() > > a_instance.name > > > # So far I exptect that a_instance.name ?returns 'b', since it has > > been created when name == 'b', but this is what actually returns: > > >>>> a_instance.name > > 'c' > > > just the last 'name' value. > > What can I do in order to generate a method like this but that returns > > 'b' ? What is wrong in my understanding of this pice of code? > > Look at the method again: > > > ? ? ? ? def get_name(self): > > ? ? ? ? ? ? return name > > It returns the global variable name. Why would you expect to see a > historical value of that variable? hehe, yeah, after sending my email I realized that it was obvious, but the true is I came up with this problem in a more complex situation involving lot's of imports and so on.. so the question: wtf is going on?? came up to me at this time :P > If you want to capture the value of name at the time when get_name() is > defined you have several options: > > - The default argument trick: > > def get_name(self, name=name): > ? ? return name > > - A closure: > > def make_get_name(name): > ? ? def get_name(self): > ? ? ? ? return name > ? ? return get_name > A.name = property(make_get_name(name)) > > - functools.partial() > > def get_name(self, name): > ? ? return name > A.name = property(partial(get_name, name=name)) Wow Peter, I was expecting one solution and you give me 3 amazing solutions!! :) Thanks a lot! btw I always wondered for what functools.partial can be useful, now I know an example :) From richardbp at gmail.com Thu Feb 23 08:50:34 2012 From: richardbp at gmail.com (Richard Baron Penman) Date: Fri, 24 Feb 2012 00:50:34 +1100 Subject: asynchronous downloading In-Reply-To: <4F462108.2000400@skippinet.com.au> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <4F462108.2000400@skippinet.com.au> Message-ID: >> I want to download content asynchronously. This would be >> straightforward to do threaded or across processes, but difficult >> asynchronously so people seem to rely on external libraries (twisted >> / gevent / eventlet). > > > Exactly - the fact it's difficult is why those tools compete. It is difficult in Python because the async libraries do not offer much. Straightforward in some other languages. Do you know why there is little support for asynchronous execution in the standard libraries? For large scale downloading I found thread pools do not scale well. Richard From steve+comp.lang.python at pearwood.info Thu Feb 23 09:06:22 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 14:06:22 GMT Subject: distutils bdist_wininst failure on Linux Message-ID: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Following instructions here: http://docs.python.org/py3k/distutils/builtdist.html#creating-windows-installers I am trying to create a Windows installer for a pure-module distribution using Python 3.2. I get a "LookupError: unknown encoding: mbcs" Here is the full output of distutils and the traceback: [steve at ando pyprimes]$ python3.2 setup.py bdist_wininst running bdist_wininst running build running build_py creating build/lib copying src/pyprimes.py -> build/lib installing to build/bdist.linux-i686/wininst running install_lib creating build/bdist.linux-i686/wininst creating build/bdist.linux-i686/wininst/PURELIB copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB running install_egg_info Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info creating '/tmp/tmp3utw4_.zip' and adding '.' to it adding 'PURELIB/pyprimes.py' adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info' creating dist Warning: Can't read registry to find the necessary compiler setting Make sure that Python modules winreg, win32api or win32con are installed. Traceback (most recent call last): File "setup.py", line 60, in "License :: OSI Approved :: MIT License", File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command cmd_obj.run() File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run self.create_exe(arcname, fullname, self.bitmap) File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe cfgdata = cfgdata.encode("mbcs") LookupError: unknown encoding: mbcs How do I fix this, and is it a bug in distutils? -- Steven From roy at panix.com Thu Feb 23 09:21:25 2012 From: roy at panix.com (Roy Smith) Date: Thu, 23 Feb 2012 09:21:25 -0500 Subject: What does exc_info do in a logging call? Message-ID: In http://docs.python.org/release/2.6.7/library/logging.html, it says: logging.debug(msg[, *args[, **kwargs]]) [...] There are two keyword arguments in kwargs which are inspected: exc_info which, if it does not evaluate as false, causes exception information to be added to the logging message. If an exception tuple (in the format returned by sys.exc_info()) is provided, it is used; otherwise, sys.exc_info() is called to get the exception information. I don't get what this is trying to do. I have this code: try: f = urllib2.urlopen(url) except urllib2.HTTPError as ex: logger.error("Unable to retrieve profile from facebook (access_token='%r')" % access_token, exc_info=ex) which ends up logging: [...] ERROR _get_profile Unable to retrieve profile from facebook (access_token='u'[token elided]'') so what is the exc_info doing? What "exception information" is being added to the message? Am I just calling this wrong? From xlstime at gmail.com Thu Feb 23 09:40:29 2012 From: xlstime at gmail.com (xlstime) Date: Thu, 23 Feb 2012 20:10:29 +0530 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <20120222231501.GA6553@raf.org> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <20120222231501.GA6553@raf.org> Message-ID: Hi, i want to learn pyxl please help me... kindly send useful information about pyxl *Thank you in Advance* XLS S :) On Thu, Feb 23, 2012 at 4:45 AM, wrote: > Chris Withers wrote: > > > On 22/02/2012 00:37, python-excel at raf.org wrote: > > >was good for previous versions. two reasons that spring to mind > > >immediately are: > > > > > > - it makes it much easier to tell what version is installed > > > - it makes it much easier to uninstall the package > > > > > >i know that both of these are things that the python community > > >does not yet seem to find useful but everyone else seems to. > > > > That's because it's no longer best practice to polute the global > > python installation by installing packages directly into it. > > > > The recommended wisdom nowadays is to use a virtualenv and then pip > > install the package. > > > > I believe that will give you everything you need, please explain if > > it doesn't. > > > > cheers, > > > > Chris > > thanks. i'm sure that'll do nicely. > > cheers, > raf > > -- > You received this message because you are subscribed to the Google Groups > "python-excel" group. > To post to this group, send an email to python-excel at googlegroups.com. > To unsubscribe from this group, send email to > python-excel+unsubscribe at googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/python-excel?hl=en-GB. > > -- ......................... -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 23 10:05:50 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 23 Feb 2012 16:05:50 +0100 Subject: What does exc_info do in a logging call? References: Message-ID: Roy Smith wrote: > In http://docs.python.org/release/2.6.7/library/logging.html, it says: > > logging.debug(msg[, *args[, **kwargs]]) > [...] > There are two keyword arguments in kwargs which are inspected: exc_info > which, if it does not evaluate as false, causes exception information to > be added to the logging message. If an exception tuple (in the format > returned by sys.exc_info()) is provided, it is used; otherwise, > sys.exc_info() is called to get the exception information. > > I don't get what this is trying to do. I have this code: > > try: > f = urllib2.urlopen(url) > except urllib2.HTTPError as ex: > logger.error("Unable to retrieve profile from facebook > (access_token='%r')" % access_token, > exc_info=ex) > > which ends up logging: > > [...] ERROR _get_profile Unable to retrieve profile from facebook > (access_token='u'[token elided]'') > > so what is the exc_info doing? What "exception information" is being > added to the message? Am I just calling this wrong? I think whatever the formatter's formatException() makes out of the (exception_type, exception_value, traceback) tuple lands in the logfile: >> import logging >>> logging.basicConfig() >>> try: 1/0 ... except: logging.error("yadda") ... ERROR:root:yadda >>> try: 1/0 ... except: logging.error("yadda", exc_info=True) ... ERROR:root:yadda Traceback (most recent call last): File "", line 1, in ZeroDivisionError: integer division or modulo by zero >>> class Formatter(logging.Formatter): ... def formatException(self, *args): return "OOPS" ... >>> logging._handlers.keys()[0].setFormatter(Formatter()) # ;) >>> try: 1/0 ... except: logging.error("yadda", exc_info=True) ... yadda OOPS From wxjmfauth at gmail.com Thu Feb 23 10:09:35 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 23 Feb 2012 07:09:35 -0800 (PST) Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 23 f?v, 15:06, Steven D'Aprano wrote: > Following instructions here: > > http://docs.python.org/py3k/distutils/builtdist.html#creating-windows... > > I am trying to create a Windows installer for a pure-module distribution > using Python 3.2. I get a "LookupError: unknown encoding: mbcs" > > Here is the full output of distutils and the traceback: > > [steve at ando pyprimes]$ python3.2 setup.py bdist_wininst > running bdist_wininst > running build > running build_py > creating build/lib > copying src/pyprimes.py -> build/lib > installing to build/bdist.linux-i686/wininst > running install_lib > creating build/bdist.linux-i686/wininst > creating build/bdist.linux-i686/wininst/PURELIB > copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB > running install_egg_info > Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info > creating '/tmp/tmp3utw4_.zip' and adding '.' to it > adding 'PURELIB/pyprimes.py' > adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info' > creating dist > Warning: Can't read registry to find the necessary compiler setting > Make sure that Python modules winreg, win32api or win32con are installed. > Traceback (most recent call last): > ? File "setup.py", line 60, in > ? ? "License :: OSI Approved :: MIT License", > ? File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup > ? ? dist.run_commands() > ? File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands > ? ? self.run_command(cmd) > ? File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command > ? ? cmd_obj.run() > ? File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run > ? ? self.create_exe(arcname, fullname, self.bitmap) > ? File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe > ? ? cfgdata = cfgdata.encode("mbcs") > LookupError: unknown encoding: mbcs > > How do I fix this, and is it a bug in distutils? > > -- > Steven Because the 'mbcs' codec is missing in your Linux, :-) >>> 'abc???'.encode('cp1252') b'abc\xe9\x9c\x80' >>> 'abc???'.encode('missing') Traceback (most recent call last): File "", line 1, in LookupError: unknown encoding: missing jmf From roy at panix.com Thu Feb 23 10:47:21 2012 From: roy at panix.com (Roy Smith) Date: Thu, 23 Feb 2012 07:47:21 -0800 (PST) Subject: What does exc_info do in a logging call? In-Reply-To: References: Message-ID: <25030409.653.1330012041802.JavaMail.geo-discussion-forums@vbux23> Duh, I figured out what's going on. I'm using a custom Formatter class, which overrides format(). It's the job of format() to handle this, and ours doesn't! From vinay_sajip at yahoo.co.uk Thu Feb 23 11:23:42 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 08:23:42 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> Message-ID: On Feb 22, 4:44?am, Fayaz Yusuf Khan wrote: > Anyway, I read the source and found many interesting things that ought to be > mentioned in the docs. > Such as flush() should be called from close() whenever it's implemented. > (FileHandler.close() is doing it) This is entirely handler-dependent - there's no absolute rule that you *have* to call flush() before close(). Some underlying will do flushing when you close. > And how come close()/flush() isn't being called from inside a lock? Why does it need to be? Are you aware of any race conditions or other concurrency problems which will occur with the code as it is now? > (Handler.close() calls the module level _acquireLock() and _releaseLock()s but > nothing about the instance level acquire() or release()) > Or is it being locked from somewhere else? The module level acquisitions are because module-level handler lists are changed in Handler.close(). If locking is required in a particular handler class for close or flush, that can be implemented by the developer of that handler class. AFAIK there is no such need for the handler classes in the stdlib - if you have reason to believe otherwise, please give some examples of potential problems and with example code if possible. Regards, Vinay Sajip From promastermentor at gmail.com Thu Feb 23 11:30:51 2012 From: promastermentor at gmail.com (INCOME STREAMS) Date: Thu, 23 Feb 2012 08:30:51 -0800 (PST) Subject: INCOME STREAMS Message-ID: Hi There, Please confirm your special access link if you have not already done so: >> http://budurl.com/casey0218out << It will be expiring shortly. Thanks Promaster From chris at simplistix.co.uk Thu Feb 23 12:28:31 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 23 Feb 2012 17:28:31 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <20120222231501.GA6553@raf.org> Message-ID: <4F46773F.3080209@simplistix.co.uk> On 23/02/2012 14:40, xlstime wrote: > Hi, > > i want to learn pyxl please help me... > > kindly send useful information about pyxl I would suggest: - using your real name when posting - reading the tutorial at http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From g.rodola at gmail.com Thu Feb 23 12:31:54 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 23 Feb 2012 18:31:54 +0100 Subject: asynchronous downloading In-Reply-To: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: Il 23 febbraio 2012 07:58, Plumo ha scritto: > I want to download content asynchronously. This would be straightforward to do threaded or across processes, but difficult asynchronously so people seem to rely on external libraries (twisted / gevent / eventlet). > > (I would use gevent under different circumstances, but currently need to stick to standard libraries.) > > I looked around and found there is little interest in developing a proper HTTP client on asyncore. The best I found stopped development a decade ago: http://sourceforge.net/projects/asynchttp/ > > What do you recommend? > And why is there poor support for asynchronous execution? > > Richard > -- > http://mail.python.org/mailman/listinfo/python-list If you want to stick with asyncore try to take a look at this: https://gist.github.com/1519999 > And why is there poor support for asynchronous execution? I'd say that's true for stdlib only (asyncore/asynchat). There are plenty of choices amongst third party modules though. To say one, I particularly like tornado which is simple and powerful: http://www.tornadoweb.org/documentation/httpclient.html --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ From fayaz.yusuf.khan at gmail.com Thu Feb 23 12:55:07 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Thu, 23 Feb 2012 23:25:07 +0530 Subject: Should I acquire lock for logging.Handler.flush()? In-Reply-To: References: Message-ID: <4909905.nLhh7fUSGV@dextop08> On Thursday 23 Feb 2012 8:23:42 AM Vinay Sajip wrote: > If locking is required in a particular handler class for close or > flush, that can be implemented by the developer of that handler class. > AFAIK there is no such need for the handler classes in the stdlib - if > you have reason to believe otherwise, please give some examples of > potential problems and with example code if possible. Well, I'm not currently facing any race-around conditions. As I said, I was mostly familiarizing myself with the API. Well, as emit() is always being called from within a lock, I assumed that flush() should/would also be handled similarly. Afterall, they are handling the same underlying output stream or in case of the BufferingHandler share the same buffer. Shouldn't the access be synchronized? -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From eric.frederich at gmail.com Thu Feb 23 12:59:56 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Thu, 23 Feb 2012 12:59:56 -0500 Subject: multiprocessing, what am I doing wrong? Message-ID: Below is some pretty simple code and the resulting output. Sometimes the code runs through but sometimes it just freezes for no apparent reason. The output pasted is where it just got frozen on me. It called start() on the 2nd worker but the 2nd worker never seemed to enter the run method. ################### the code #!/usr/bin/env python import sys import Queue import multiprocessing import time todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, inbox, outbox): super(MyWorker, self).__init__() self.inbox = inbox self.outbox = outbox print >> sys.stderr, '1' * 80; sys.stderr.flush() def run(self): print >> sys.stderr, '2' * 80; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() except Queue.Empty: break self.outbox.put(FOO(*args)) print >> sys.stderr, 'a' * 80; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'b' * 80; sys.stderr.flush() w1 = MyWorker(todo, result_queue) print >> sys.stderr, 'c' * 80; sys.stderr.flush() w2 = MyWorker(todo, result_queue) print >> sys.stderr, 'd' * 80; sys.stderr.flush() w1.start() print >> sys.stderr, 'e' * 80; sys.stderr.flush() w2.start() print >> sys.stderr, 'f' * 80; sys.stderr.flush() for i in xrange(100): print result_queue.get() ################### the output aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 11111111111111111111111111111111111111111111111111111111111111111111111111111111 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 11111111111111111111111111111111111111111111111111111111111111111111111111111111 dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 22222222222222222222222222222222222222222222222222222222222222222222222222222222 foo 0 1 2 foo 1 2 3 foo 2 3 4 foo 3 4 5 foo 4 5 6 22222222222222222222222222222222222222222222222222222222222222222222222222222222 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 2 9 20 35 54 -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinay_sajip at yahoo.co.uk Thu Feb 23 14:08:01 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 11:08:01 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <625ae620-be10-4a15-afd9-d515c019add2@cj6g2000vbb.googlegroups.com> On Feb 23, 5:55?pm, Fayaz Yusuf Khan wrote: > Well, as emit() is always being called from within a lock, I assumed that > flush() should/would also be handled similarly. Afterall, they are handling the > same underlying output stream or in case of the BufferingHandler share the same > buffer. Shouldn't the access be synchronized? Yes, you might well be right - though no problems have been reported, it's probably best to be safe. Regards, Vinay Sajip From someone at someplace.invalid Thu Feb 23 14:11:16 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 23 Feb 2012 19:11:16 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? Message-ID: $ cd /usr/bin $ ls -l python* -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 $ diff -s python python2.7 Files python and python2.7 are identical $ I'm just curious: Why two identical files rather than a symlink? From colinh at somewhere.invalid Thu Feb 23 14:15:01 2012 From: colinh at somewhere.invalid (Colin Higwell) Date: Thu, 23 Feb 2012 19:15:01 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Thu, 23 Feb 2012 19:11:16 +0000, HoneyMonster wrote: (reformatted (I hope) > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? Sorry, my first post didn't format properly. From malaclypse2 at gmail.com Thu Feb 23 14:24:23 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 23 Feb 2012 14:24:23 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster wrote: > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root ? ?6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s ?python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? It's not two files, it's a hardlink. You can confirm by running ls -li python* and comparing the inode numbers. -- Jerry From clp2 at rebertia.com Thu Feb 23 14:26:35 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 11:26:35 -0800 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 11:11 AM, Colin Higwell wrote: > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root ? ?6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s ?python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? Depends on your distro / installation method: $ ls -l python* lrwxrwxrwx 1 root root 9 Apr 12 2011 python -> python2.6 -rwxr-xr-x 1 root root 2288272 Dec 27 2010 python2.6 $ # this is on my Debian server Cheers, Chris From someone at someplace.invalid Thu Feb 23 14:34:05 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 23 Feb 2012 19:34:05 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster > wrote: >> $ cd /usr/bin $ ls -l python* >> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root >> ? ?6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 >> 02:42 python2.7 $ diff -s ?python python2.7 Files python and python2.7 >> are identical $ >> >> I'm just curious: Why two identical files rather than a symlink? > > It's not two files, it's a hardlink. You can confirm by running ls -li > python* and comparing the inode numbers. You are spot on. Thank you, and sorry for my stupidity. From malaclypse2 at gmail.com Thu Feb 23 14:54:10 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 23 Feb 2012 14:54:10 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 2:34 PM, HoneyMonster wrote: > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: >> It's not two files, it's a hardlink. ?You can confirm by running ls -li >> python* and comparing the inode numbers. > > You are spot on. Thank you, and sorry for my stupidity. I don't think you're stupid. It's hard to tell the difference between two separate files with the same file size and a hardlink. The biggest clue is the number "2" in the second column. If I recall correctly, for directories, that's the number of entries in the directory. For files, that number is the number of hardlinks referring to that file. Even with that, it's hard to tell what files are hardlinked together, and figuring it out by inode is a pain in the neck. Personally, I prefer symlinks, even if they introduce a small performance hit. Readability counts, even in the filesystem. -- Jerry From vinay_sajip at yahoo.co.uk Thu Feb 23 15:06:31 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 12:06:31 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <7a003819-4911-4440-b94f-5190f13a6719@i2g2000vbv.googlegroups.com> On Feb 23, 5:55?pm, Fayaz Yusuf Khan wrote: > buffer. Shouldn't the access be synchronized? I've now updated the repos for 2.7, 3.2 and default to add locking for flush/close operations. Thanks for the suggestion. Regards, Vinay Sajip From python at mrabarnett.plus.com Thu Feb 23 15:42:05 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 23 Feb 2012 20:42:05 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: Message-ID: <4F46A49D.9030905@mrabarnett.plus.com> On 23/02/2012 17:59, Eric Frederich wrote: > Below is some pretty simple code and the resulting output. > Sometimes the code runs through but sometimes it just freezes for no > apparent reason. > The output pasted is where it just got frozen on me. > It called start() on the 2nd worker but the 2nd worker never seemed to > enter the run method. > [snip] The 2nd worker did enter the run method; there are 2 lines of "2". Maybe there's an uncaught exception in the run method for some reason. Try doing something like this: try: args = self.inbox.get_nowait() except Queue.Empty: break except: import traceback print "*** Exception in worker" print >> sys.stderr, traceback.print_exc() sys.stderr.flush() print "***" raise From tjreedy at udel.edu Thu Feb 23 16:11:33 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 23 Feb 2012 16:11:33 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On 2/23/2012 2:34 PM, HoneyMonster wrote: > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > >> On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster >> wrote: >>> $ cd /usr/bin $ ls -l python* >>> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root >>> 6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 >>> 02:42 python2.7 $ diff -s python python2.7 Files python and python2.7 >>> are identical $ >>> >>> I'm just curious: Why two identical files rather than a symlink? >> >> It's not two files, it's a hardlink. You can confirm by running ls -li >> python* and comparing the inode numbers. > > You are spot on. Thank you, and sorry for my stupidity. The question 'why a hardlink rather than symlink' is not stupid. It was part of the discussion of http://python.org/dev/peps/pep-0394/ The answer was 'history' and how things were 20 years ago and either the pep or the discussion around it says symlinks are fine now and the decision is up to distributors. -- Terry Jan Reedy From buck at yelp.com Thu Feb 23 16:19:21 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:19:21 -0800 (PST) Subject: sum() requires number, not simply __add__ Message-ID: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> I feel like the design of sum() is inconsistent with other language features of python. Often python doesn't require a specific type, only that the type implement certain methods. Given a class that implements __add__ why should sum() not be able to operate on that class? We can fix this in a backward-compatible way, I believe. Demonstration: I'd expect these two error messages to be identical, but they are not. >>> class C(object): pass >>> c = C() >>> sum((c,c)) TypeError: unsupported operand type(s) for +: 'int' and 'C' >>> c + c TypeError: unsupported operand type(s) for +: 'C' and 'C' From buck at yelp.com Thu Feb 23 16:23:45 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:23:45 -0800 (PST) Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> On Feb 23, 1:19?pm, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? > > We can fix this in a backward-compatible way, I believe. > > Demonstration: > ? ? I'd expect these two error messages to be identical, but they are > not. > > ? ? ?>>> class C(object): pass > ? ? ?>>> c = C() > ? ? ?>>> sum((c,c)) > ? ? TypeError: unsupported operand type(s) for +: 'int' and 'C' > ? ? >>> c + c > ? ? TypeError: unsupported operand type(s) for +: 'C' and 'C' Proposal: def sum(values, base=0): values = iter(values) try: result = values.next() except StopIteration: return base for value in values: result += value return result From arnodel at gmail.com Thu Feb 23 16:32:43 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:32:43 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On 23 February 2012 21:19, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? It can. You need to pass a second argument which will be the start value. Try help(sum) for details. -- Arnaud From clp2 at rebertia.com Thu Feb 23 16:32:45 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 13:32:45 -0800 Subject: sum() requires number, not simply __add__ In-Reply-To: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? The time machine strikes again! sum() already can. You just need to specify an appropriate initial value (the empty list in this example) for the accumulator : Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> sum([[1,2],[3,4]], []) [1, 2, 3, 4] Cheers, Chris -- http://rebertia.com From buck at yelp.com Thu Feb 23 16:38:12 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:38:12 -0800 (PST) Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Feb 23, 1:32?pm, Chris Rebert wrote: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: > > I feel like the design of sum() is inconsistent with other language > > features of python. Often python doesn't require a specific type, only > > that the type implement certain methods. > > > Given a class that implements __add__ why should sum() not be able to > > operate on that class? > > The time machine strikes again! sum() already can. You just need to > specify an appropriate initial value (the empty list in this example) > for the accumulator : > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin > Type "help", "copyright", "credits" or "license" for more information.>>> sum([[1,2],[3,4]], []) > > [1, 2, 3, 4] > > Cheers, > Chris > --http://rebertia.com Thanks. I did not know that! My proposal is still *slightly* superior in two ways: 1) It reduces the number of __add__ operations by one 2) The second argument isn't strictly necessary, if you don't mind that the 'null sum' will produce zero. def sum(values, base=0): values = iter(values) try: result = values.next() except StopIteration: return base for value in values: result += value return result From arnodel at gmail.com Thu Feb 23 16:41:28 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:41:28 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 21:23, Buck Golemon wrote: > def sum(values, > base=0): > ? ? ?values = > iter(values) > > ? ? ?try: > ? ? ? ? ?result = values.next() > ? ? ?except StopIteration: > ? ? ? ? ?return base > > ? ? ?for value in values: > ? ? ? ? ?result += value > ? ? ?return result This is definitely not backward compatible. To get something that has a better chance of working with existing code, try this (untested): _sentinel = object() def sum(iterable, start=_sentinel): if start is _sentinel: iterable = iter(iterable) try: start = iterable.next() except StopIteration: return 0 for x in iterable: start += x return start del _sentinel -- Arnaud From stefan_ml at behnel.de Thu Feb 23 16:42:22 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 23 Feb 2012 22:42:22 +0100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Chris Rebert, 23.02.2012 22:32: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: >> I feel like the design of sum() is inconsistent with other language >> features of python. Often python doesn't require a specific type, only >> that the type implement certain methods. >> >> Given a class that implements __add__ why should sum() not be able to >> operate on that class? > > The time machine strikes again! sum() already can. You just need to > specify an appropriate initial value (the empty list in this example) > for the accumulator : > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> sum([[1,2],[3,4]], []) > [1, 2, 3, 4] I know that you just meant this as an example, but it's worth mentioning in this context that it's not exactly efficient to "sum up" lists this way because there is a lot of copying involved. Each adding of two lists creates a third one and copies all elements into it. So it eats a lot of time and space. Stefan From rosuav at gmail.com Thu Feb 23 16:53:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 08:53:49 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: > _sentinel = object() > > def sum(iterable, start=_sentinel): > ? ?if start is _sentinel: > > del _sentinel Somewhat off-topic: Doesn't the if statement there do a lookup for a global, which would mean that 'del _sentinel' will cause it to fail? Or have I missed something here? ChrisA From ian.g.kelly at gmail.com Thu Feb 23 16:54:22 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 23 Feb 2012 14:54:22 -0700 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:38 PM, Buck Golemon wrote: > My proposal is still *slightly* superior in two ways: > > 1) It reduces the number of __add__ operations by one > 2) The second argument isn't strictly necessary, if you don't mind > that the 'null sum' will produce zero. It produces the wrong result, though: >>> sum([3,4], base=12) 7 If I'm starting with 12 and summing 3 and 4, I expect to get 19. Ideally the second argument should be ignored only if it isn't passed in at all, and I don't know off-hand why the built-in sum doesn't do this. We really don't need to replace it, though. If you want a different sum behavior, just write your own. def sum(iterable, *args): return reduce(operator.add, iterable, *args) >>> sum([3,4]) 7 >>> sum([3,4], 12) 19 >>> sum(['hello', 'world']) 'helloworld' Cheers, Ian From arnodel at gmail.com Thu Feb 23 16:59:08 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:59:08 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 21:53, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? > Or have I missed something here? Yes, you're right :) Change the signature to def sum(iterable, start=_sentinel, _sentinel=_sentinel): This is not pretty... -- Arnaud From ian.g.kelly at gmail.com Thu Feb 23 17:00:07 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 23 Feb 2012 15:00:07 -0700 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:53 PM, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? > Or have I missed something here? I believe you're correct. If you really want to delete the _sentinel reference though, you could do: def sum(iterable, start=object()): if start is sum.func_defaults[0]: ... Cheers, Ian From rosuav at gmail.com Thu Feb 23 17:04:23 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 09:04:23 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: > def sum(iterable, start=_sentinel, _sentinel=_sentinel): Is this a reason for Python to introduce a new syntax, such as: def foo(blah, optional=del): if optional is del: print("No argument was provided") Basically, 'del' is treated like a unique non-providable object, only possible in an argument list and only if the argument was omitted. No more proliferation of individual sentinels... what do you think? (I picked "del" because it's an existing keyword. Fairly arbitrary choice though.) Chris Angelico From arnodel at gmail.com Thu Feb 23 17:09:13 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 22:09:13 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 22:04, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: >> def sum(iterable, start=_sentinel, _sentinel=_sentinel): > > Is this a reason for Python to introduce a new syntax, such as: > > def foo(blah, optional=del): > ? ?if optional is del: print("No argument was provided") > > Basically, 'del' is treated like a unique non-providable object, only > possible in an argument list and only if the argument was omitted. No > more proliferation of individual sentinels... what do you think? The problem with these proposals is to avoid the leakage of 'del'. Here you could do: def get_del(x=del): return x And then you're in trouble again. -- Arnaud From rosuav at gmail.com Thu Feb 23 17:11:51 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 09:11:51 +1100 Subject: Optional arguments syntax (was Re: sum() requires number, not simply __add__) Message-ID: On Fri, Feb 24, 2012 at 9:09 AM, Arnaud Delobelle wrote: > On 23 February 2012 22:04, Chris Angelico wrote: >> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: >>> def sum(iterable, start=_sentinel, _sentinel=_sentinel): >> >> Is this a reason for Python to introduce a new syntax, such as: >> >> def foo(blah, optional=del): >> ? ?if optional is del: print("No argument was provided") >> >> Basically, 'del' is treated like a unique non-providable object, only >> possible in an argument list and only if the argument was omitted. No >> more proliferation of individual sentinels... what do you think? > > The problem with these proposals is to avoid the leakage of 'del'. > Here you could do: > > def get_del(x=del): > ? ?return x > > And then you're in trouble again. Yep; what I was thinking was that this would be a magic token that, if used in any expression other than "is del", would decay to some other object such as 0 or None. Otherwise, yeah, there's no difference between that and any other global sentinel. ChrisA From manish2aug at gmail.com Thu Feb 23 17:13:35 2012 From: manish2aug at gmail.com (Manish Sharma) Date: Thu, 23 Feb 2012 14:13:35 -0800 (PST) Subject: Please verify!! Message-ID: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Hi I am new to python language. On my first day, somebody told me that if any python script file is opened with any editor except python editor, the file is corrupted. Some spacing or indentation is changed and script stops working. I was opening the script file in Windows using Notepad++ but I didn't save anything and closed it. Still it was suggested to never open the python file in any other editor. Can anybody please verify this? Can opening a python script in any editor other than python editor corrupt the script? Did anybody ever face such type of issue or its just misunderstanding of the concept. I hope this group is the best place to ask this. Please reply ! :) Manish From amirouche.boubekki at gmail.com Thu Feb 23 17:22:23 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Thu, 23 Feb 2012 23:22:23 +0100 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: 2012/2/23 Manish Sharma > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. There is compatibility issue with line ending in Windows vs other OS that's all I'm aware of. Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From bungiman at gmail.com Thu Feb 23 17:29:45 2012 From: bungiman at gmail.com (Ben) Date: Thu, 23 Feb 2012 14:29:45 -0800 (PST) Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <21257906.684.1330036185279.JavaMail.geo-discussion-forums@vbne13> They are telling you not to switch between editors that use tabs as tabs and ones that use spaces as tabs. Python gets all wonky. No big, use one editor or have your preferred editor highlight your non-preferred whitespace. FWIW, I use spaces. From ckaynor at zindagigames.com Thu Feb 23 17:32:45 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 23 Feb 2012 14:32:45 -0800 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:22 PM, Amirouche Boubekki < amirouche.boubekki at gmail.com> wrote: > > > 2012/2/23 Manish Sharma > >> Hi I am new to python language. On my first day, somebody told me that >> if any python script file is opened with any editor except python >> editor, the file is corrupted. Some spacing or indentation is changed >> and script stops working. I was opening the script file in Windows >> using Notepad++ but I didn't save anything and closed it. Still it was >> suggested to never open the python file in any other editor. >> >> Can anybody please verify this? Can opening a python script in any >> editor other than python editor corrupt the script? Did anybody ever >> face such type of issue or its just misunderstanding of the concept. > > > > There is compatibility issue with line ending in Windows vs other OS > that's all I'm aware of. > The only issues I can think of off the top of my head would be line endings and indentation (tabs vs spaces, number of spaces for one level). The second would just require care to avoid issues to make sure you match the style guides for the files you are working on (the Python standard is 4 spaces, I believe). The first could be a silent issue with some editors and some versions of Python if crossing between Windows, Linux, and Mac, however most software (including Python) will now convert between the different forms automatically, and Notepad++ is good about its handling - it will create new newlines in the format of the file, if such can be determined. > > Amirouche > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Thu Feb 23 17:43:48 2012 From: d at davea.name (Dave Angel) Date: Thu, 23 Feb 2012 17:43:48 -0500 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F46C124.2070102@davea.name> On 02/23/2012 05:13 PM, Manish Sharma wrote: > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. > > I hope this group is the best place to ask this. Please reply ! > > :) > Manish That is nonsense. I've used at least a dozen text editors, from Windows Notepad to emacs on Linux. And since I know of no program called "python editor," I'm sure none of them was that one. Of course, there are editors that are broken, or can be configured to be broken. I certainly wouldn't try wordpad, even in text mode. But a good editor with a good configuration can be much nicer to use than Notepad. First thing I'd do is to disable tab logic in the editor. When you press the tab key, there's no excuse for an editor to actually put a tab in the file. It should adjust the column by adding the appropriate number of spaces. The main place you get in trouble is when a file has tabs in some lines, and uses spaces for indenting on other lines. Since tabs are not interpreted the same way in various utilities, it's just better not to use them at all. As Amirouche has pointed out, line endings can be inconsistent between different operating systems, and not all editors can handle the differences. But the python compiler/interpreter doesn't care about which line ending is used. One other issue could be files that have non-ASCII characters. Since a text file has no standard way to indicate what format it uses (utf8, ucs2, or dozens of "extended ASCII" encodings), another editor might not deal with it correctly. There is a standard way to indicate to Python how to interpret non-ascii characters, so if you either 1) always use ASCII1 2) always use the same character encoding, or 3) have your editor look for the declaration and honor it, you'd have no trouble. If these problems do occur, they'll be pretty easy to spot. And you can always revert to an earlier version, by using your revision control system. Enabling one of those is about as important as choosing your editor. -- DaveA From steve+comp.lang.python at pearwood.info Thu Feb 23 18:33:39 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 23:33:39 GMT Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 08:53:49 +1100, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle > wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? Or > have I missed something here? Yes, deleting _sentinel will cause the custom sum to fail, and yes, you have missed something. If the caller wants to mess with your library and break it, they have many, many ways to do so apart from deleting your private variables. del _sentinel _sentinel = "something else" sum.__defaults__ = (42,) # mess with the function defaults sum.__code__ = (lambda a, b=None: 100).__code__ # and with func internals sum = None # change your custom sum to something else del sum # or just delete it completely len = 42 # shadow a built-in import builtins; del builtins.range # really screw with you If your application stops working after you carelessly mess with components your application relies on, the right answer is usually: "Don't do that then." Python doesn't try to prevent people from shooting themselves in the foot. Monkey-patching-by-actual-monkeys-for-fun-and-profit-ly y'rs, -- Steven From rosuav at gmail.com Thu Feb 23 18:39:26 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 10:39:26 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 24, 2012 at 10:33 AM, Steven D'Aprano wrote: > Yes, deleting _sentinel will cause the custom sum to fail, and yes, you > have missed something. > > If the caller wants to mess with your library and break it, they have > many, many ways to do so apart from deleting your private variables. I was looking at the module breaking itself, though, not even waiting for the caller to do it. ChrisA From steve+comp.lang.python at pearwood.info Thu Feb 23 19:11:11 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 00:11:11 GMT Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f46d59f$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > On 23 f?v, 15:06, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> Following instructions here: >> >> http://docs.python.org/py3k/distutils/builtdist.html#creating- windows... >> >> I am trying to create a Windows installer for a pure-module >> distribution using Python 3.2. I get a "LookupError: unknown encoding: >> mbcs" [...] >> How do I fix this, and is it a bug in distutils? > > Because the 'mbcs' codec is missing in your Linux, :-) Well duh :-) This is a bug in distutils. Prompted by your comment I expanded my search terms and found this bug report: http://bugs.python.org/issue10945 The problem is that mbcs is not a real codec, it means "whatever codec is currently configured in Windows". So it doesn't exist on non-Windows platforms. But distutils bdist_wininst is explicitly documented as working on non-Windows platforms. Hence, it's a bug. -- Steven From richardbp at gmail.com Thu Feb 23 19:28:05 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 16:28:05 -0800 (PST) Subject: asynchronous downloading In-Reply-To: <7x4nuhlqmf.fsf@ruckus.brouhaha.com> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <7x4nuhlqmf.fsf@ruckus.brouhaha.com> Message-ID: <25425615.930.1330043285287.JavaMail.geo-discussion-forums@pbux2> My current implementation works fine below a few hundred threads. But each thread takes up a lot of memory so does not scale well. I have been looking at Erlang for that reason, but found it is missing useful libraries in other areas. From alex at moreati.org.uk Thu Feb 23 19:30:09 2012 From: alex at moreati.org.uk (Alex Willmer) Date: Thu, 23 Feb 2012 16:30:09 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Message-ID: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> This week I was slightly surprised by a behaviour that I've not considered before. I've long used for i, x in enumerate(seq): # do stuff as a standard looping-with-index construct. In Python for loops don't create a scope, so the loop variables are available afterward. I've sometimes used this to print or return a record count e.g. for i, x in enumerate(seq): # do stuff print 'Processed %i records' % i+1 However as I found out, if seq is empty then i and x are never created. The above code will raise NameError. So if a record count is needed, and the loop is not guaranteed to execute the following seems more correct: i = 0 for x in seq: # do stuff i += 1 print 'Processed %i records' % i Just thought it worth mentioning, curious to hear other options/ improvements/corrections. From steve+comp.lang.python at pearwood.info Thu Feb 23 19:49:11 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 00:49:11 GMT Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f46d59f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f46de87$0$29986$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 00:11:11 +0000, Steven D'Aprano wrote: > On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > >> On 23 f?v, 15:06, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: >>> Following instructions here: >>> >>> http://docs.python.org/py3k/distutils/builtdist.html#creating- > windows... >>> >>> I am trying to create a Windows installer for a pure-module >>> distribution using Python 3.2. I get a "LookupError: unknown encoding: >>> mbcs" > [...] >>> How do I fix this, and is it a bug in distutils? >> >> Because the 'mbcs' codec is missing in your Linux, :-) > > Well duh :-) > > This is a bug in distutils. Prompted by your comment I expanded my > search terms and found this bug report: > > http://bugs.python.org/issue10945 > > The problem is that mbcs is not a real codec, it means "whatever codec > is currently configured in Windows". So it doesn't exist on non-Windows > platforms. But distutils bdist_wininst is explicitly documented as > working on non-Windows platforms. Hence, it's a bug. And I have a work-around that seems to work for me. Put this at the top of your setup.py install script: # Work around mbcs bug in distutils. # http://bugs.python.org/issue10945 import codecs try: codecs.lookup('mbcs') except LookupError: ascii = codecs.lookup('ascii') func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs') codecs.register(func) -- Steven From steve+comp.lang.python at pearwood.info Thu Feb 23 20:08:58 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 01:08:58 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: > This week I was slightly surprised by a behaviour that I've not > considered before. I've long used > > for i, x in enumerate(seq): > # do stuff > > as a standard looping-with-index construct. In Python for loops don't > create a scope, so the loop variables are available afterward. I've > sometimes used this to print or return a record count e.g. > > for i, x in enumerate(seq): > # do stuff > print 'Processed %i records' % i+1 > > However as I found out, if seq is empty then i and x are never created. This has nothing to do with enumerate. It applies to for loops in general: the loop variable is not initialised if the loop never runs. What value should it take? Zero? Minus one? The empty string? None? Whatever answer Python choose would be almost always wrong, so it refuses to guess. > The above code will raise NameError. So if a record count is needed, and > the loop is not guaranteed to execute the following seems more correct: > > i = 0 > for x in seq: > # do stuff > i += 1 > print 'Processed %i records' % i What fixes the problem is not avoiding enumerate, or performing the increments in slow Python instead of fast C, but that you initialise the loop variable you care about before the loop in case it doesn't run. i = 0 for i,x in enumerate(seq): # do stuff is all you need: the addition of one extra line, to initialise the loop variable i (and, if you need it, x) before hand. -- Steven From richardbp at gmail.com Thu Feb 23 20:10:25 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 17:10:25 -0800 (PST) Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> that example is excellent - best use of asynchat I have seen so far. I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. From richardbp at gmail.com Thu Feb 23 20:10:25 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 17:10:25 -0800 (PST) Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> that example is excellent - best use of asynchat I have seen so far. I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. From no.email at nospam.invalid Thu Feb 23 20:21:32 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 23 Feb 2012 17:21:32 -0800 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <7x7gzdyqjn.fsf@ruckus.brouhaha.com> Alex Willmer writes: > i = 0 > for x in seq: > # do stuff > i += 1 > print 'Processed %i records' % i > > Just thought it worth mentioning, curious to hear other options/ > improvements/corrections. Stephen gave an alternate patch, but you are right, it is a pitfall that can be easy to miss in simple testing. A more "functional programming" approach might be: def do_stuff(x): ... n_records = sum(1 for _ in imap(do_stuff, seq)) From milleja46 at gmail.com Thu Feb 23 20:57:24 2012 From: milleja46 at gmail.com (Joshua Miller) Date: Thu, 23 Feb 2012 20:57:24 -0500 Subject: Please verify!! In-Reply-To: <4F46E89F.4080506@davea.name> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <4F46E89F.4080506@davea.name> Message-ID: Wasn't supposed to be private, just something went funky with gmail when i sent it out, oddly enough On Thu, Feb 23, 2012 at 8:32 PM, Dave Angel wrote: > On 02/23/2012 07:15 PM, Joshua Miller wrote: >> >> When he/she said "python editor" i'm sure they meant IDLE which in >> some cases is the worst ide to use. Some ide's do mess with python >> files you just have to make sure to change their settings to >> accomadate python. Otherwise no it's a better idea to use ?something >> other than IDLE. For windows generally people use eclipse with the >> pydev extension, pyscripter, or the several other IDE's that are known >> with a little help not to do what you are describing ;) >> > > I can't argue with anything you say here. ?But you shouldn't have sent it > privately, as this is a public list. ?And please don't top-post > > So I'm forwarding it to the list. > > -- > > DaveA -- ~ Josh Miller A young guy learning to program and develop websites all while still in school From fayaz.yusuf.khan at gmail.com Thu Feb 23 21:31:09 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Thu, 23 Feb 2012 18:31:09 -0800 (PST) Subject: asynchronous downloading In-Reply-To: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: <8420126.Qz9UkS8bM5@dextop08> On Thursday 23 Feb 2012 5:10:25 PM Plumo wrote: > I read through the python-dev archives and found the fundamental problem is > no one maintains asnycore / asynchat. By all means, scratch your own itch. :) -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From bahamutzero8825 at gmail.com Thu Feb 23 22:45:24 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 23 Feb 2012 21:45:24 -0600 Subject: Please verify!! In-Reply-To: <4F46C124.2070102@davea.name> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <4F4707D4.9040401@gmail.com> On 2/23/2012 4:43 PM, Dave Angel wrote: > First thing I'd do is to disable tab logic in the editor. When you > press the tab key, there's no excuse for an editor to actually put a tab > in the file. It should adjust the column by adding the appropriate > number of spaces. Unless, of course, you know, you actually /want/ to use tabs (the horror!). The decision whether to use tabs or spaces shouldn't be made for the novice programmer. Make an argument, explain the advantages/disadvantages, whatever, but don't state your opinion like it's fact. Even worse, you brought it up in the context of editor issues, making it sound like using tabs is a common source of problems. Much of it is personal preference (I could give objective reasons in support of tabs in Python, but I don't intend to start the whole spaces vs. tabs discussion again). > The main place you get in trouble is when a file has > tabs in some lines, and uses spaces for indenting on other lines. I wouldn't call it the main problem, but yes, that happens. It's not terribly difficult to convert all indentation to tabs or spaces (unless the number of spaces used to indent is inconsistent). > As Amirouche has pointed out, line endings can be inconsistent between > different operating systems, and not all editors can handle the > differences. But the python compiler/interpreter doesn't care about > which line ending is used. Yes. However, there are many editors for various platforms that handle the different line endings just fine. In fact, Notepad is the only editor I can think of off the top of my head that has an issue. > One other issue could be files that have non-ASCII characters. Since a > text file has no standard way to indicate what format it uses (utf8, > ucs2, or dozens of "extended ASCII" encodings), another editor might not > deal with it correctly. There is a standard way to indicate to Python > how to interpret non-ascii characters, so if you either 1) always use > ASCII1 2) always use the same character encoding, or 3) have your editor > look for the declaration and honor it, you'd have no trouble. I recommend using UTF-8 always unless there's some reason not to. > If these problems do occur, they'll be pretty easy to spot. And you can > always revert to an earlier version, by using your revision control > system. Enabling one of those is about as important as choosing your > editor. I don't think you can really go wrong outside of Git, Bazaar, or Mercurial. Which of those 3 is best is mainly personal preference. CVS/SVN should be considered legacy and not suitable for new projects. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From ethan at stoneleaf.us Thu Feb 23 22:49:01 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 23 Feb 2012 19:49:01 -0800 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4708AD.1020805@stoneleaf.us> Steven D'Aprano wrote: > On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: > >> This week I was slightly surprised by a behaviour that I've not >> considered before. I've long used >> >> for i, x in enumerate(seq): >> # do stuff >> >> as a standard looping-with-index construct. In Python for loops don't >> create a scope, so the loop variables are available afterward. I've >> sometimes used this to print or return a record count e.g. >> >> for i, x in enumerate(seq): >> # do stuff >> print 'Processed %i records' % i+1 >> >> However as I found out, if seq is empty then i and x are never created. > > This has nothing to do with enumerate. It applies to for loops in > general: the loop variable is not initialised if the loop never runs. > What value should it take? Zero? Minus one? The empty string? None? > Whatever answer Python choose would be almost always wrong, so it refuses > to guess. > > >> The above code will raise NameError. So if a record count is needed, and >> the loop is not guaranteed to execute the following seems more correct: >> >> i = 0 >> for x in seq: >> # do stuff >> i += 1 >> print 'Processed %i records' % i > > What fixes the problem is not avoiding enumerate, or performing the > increments in slow Python instead of fast C, but that you initialise the > loop variable you care about before the loop in case it doesn't run. > > i = 0 > for i,x in enumerate(seq): > # do stuff > > is all you need: the addition of one extra line, to initialise the loop > variable i (and, if you need it, x) before hand. Actually, i = -1 or his reporting will be wrong. ~Ethan~ From wangbo.red at gmail.com Fri Feb 24 00:55:02 2012 From: wangbo.red at gmail.com (xixiliguo) Date: Thu, 23 Feb 2012 21:55:02 -0800 (PST) Subject: namespace question Message-ID: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] def add( self ): c[0] = 15 a = TEST() a.add() print( c, a.c, TEST.c ) result : [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] why a.add() do not update c in Class TEST? but update c in main file From wm at localhost.localdomain Fri Feb 24 01:21:47 2012 From: wm at localhost.localdomain (Waldek M.) Date: Fri, 24 Feb 2012 07:21:47 +0100 Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <18zvco3fybo0d$.dlg@localhost.localdomain> On Wed, 22 Feb 2012 18:42:11 +0100, J?r?me wrote: >>> Has anyone had success generating exe's from within Linux? >> >> That doesn't seem to have anything to do with Python, >> but you might want to google for cross-compiling. > > I think his question is totally python related. > > As I understand it, Richard creates executables from python scripts using a > tool, such as py2exe [1], that requires windows. He would like to have an > equivalent tool that runs on linux, to avoid going through the trouble of > having to run a windows installation. Ah, that's the part I was missing :-) Thanks. Waldek From clp2 at rebertia.com Fri Feb 24 01:35:07 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 22:35:07 -0800 Subject: namespace question In-Reply-To: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: On Thu, Feb 23, 2012 at 9:55 PM, xixiliguo wrote: > c = [1, 2, 3, 4, 5] > class TEST(): > ? ?c = [5, 2, 3, 4, 5] That line creates a class (i.e. "static") variable, which is unlikely to be what you want. Instance variables are normally created in the body of an __init__() method. > ? ?def add( self ): > ? ? ? ?c[0] = 15 > > a = TEST() > > > a.add() > > print( c, a.c, TEST.c ) > > result : > [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] > > > why a.add() do not update c in Class TEST? but update c in main file Python is not Java (or similar). To refer to instance variables, you must explicitly use `self`; i.e. use "self.c[0] = 15" in add(). I would recommend reviewing the relevant section of the Python tutorial: http://docs.python.org/tutorial/classes.html Cheers, Chris From renukasendhilkumar at gmail.com Fri Feb 24 01:57:35 2012 From: renukasendhilkumar at gmail.com (siva kumar) Date: Thu, 23 Feb 2012 22:57:35 -0800 (PST) Subject: variables are available Message-ID: <9022afb4-3aaa-4486-ae15-cb1191f00515@pi3g2000pbb.googlegroups.com> In Python for loops don't create a scope, so the loop variables are available afterward. I've sometimes used this to print or return a record count This release ist mostly about security and bug fixes and a few minor changes ( including Python 2.7 compatibility). For details see: [link] See [link] for the release ... http://123maza.com/46/share781/ From breamoreboy at yahoo.co.uk Fri Feb 24 02:10:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 07:10:39 +0000 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4F4708AD.1020805@stoneleaf.us> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F4708AD.1020805@stoneleaf.us> Message-ID: On 24/02/2012 03:49, Ethan Furman wrote: > Steven D'Aprano wrote: >> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: >> >>> This week I was slightly surprised by a behaviour that I've not >>> considered before. I've long used >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> >>> as a standard looping-with-index construct. In Python for loops don't >>> create a scope, so the loop variables are available afterward. I've >>> sometimes used this to print or return a record count e.g. >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> print 'Processed %i records' % i+1 >>> >>> However as I found out, if seq is empty then i and x are never created. >> >> This has nothing to do with enumerate. It applies to for loops in >> general: the loop variable is not initialised if the loop never runs. >> What value should it take? Zero? Minus one? The empty string? None? >> Whatever answer Python choose would be almost always wrong, so it >> refuses to guess. >> >> >>> The above code will raise NameError. So if a record count is needed, and >>> the loop is not guaranteed to execute the following seems more correct: >>> >>> i = 0 >>> for x in seq: >>> # do stuff >>> i += 1 >>> print 'Processed %i records' % i >> >> What fixes the problem is not avoiding enumerate, or performing the >> increments in slow Python instead of fast C, but that you initialise >> the loop variable you care about before the loop in case it doesn't run. >> >> i = 0 >> for i,x in enumerate(seq): >> # do stuff >> >> is all you need: the addition of one extra line, to initialise the >> loop variable i (and, if you need it, x) before hand. > > Actually, > > i = -1 > > or his reporting will be wrong. > > ~Ethan~ Methinks an off by one error :) -- Cheers. Mark Lawrence. From manish2aug at gmail.com Fri Feb 24 02:11:19 2012 From: manish2aug at gmail.com (Manish Sharma) Date: Fri, 24 Feb 2012 09:11:19 +0200 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: Hi All, Thanks a ton for your replies! Still my question is what if I open the file and dont make any changes to it and close it again? Can it be possible just by doing these steps add indentation to lines? I am not changing the file prefrences to open it always with notepad++. Opening it once only. On Fri, Feb 24, 2012 at 6:08 AM, Jason Friedman wrote: > > Hi I am new to python language. On my first day, somebody told me that > > if any python script file is opened with any editor except python > > editor, the file is corrupted. Some spacing or indentation is changed > > and script stops working. I was opening the script file in Windows > > using Notepad++ but I didn't save anything and closed it. Still it was > > suggested to never open the python file in any other editor. > > It is possible that the OP is not aware of that Python is space > sensitive, unlike most(?) programming languages. > > for i in range(5): > print("Hello.") > print("Goodbye.") > > will not run because the indentation (leading spaces) on the third > line is incorrect. It must instead line up with the second line. > > A single tab is equivalent to a single space as far as Python is > concerned, but your eyes will report a difference and editors that > substitute one for the other can cause, after saving, code that was > formerly working to not work (and, I suppose, the reverse). > > Make sure to read the tutorial at http://python.org (which is > unfortunately down at this moment > (http://www.downforeveryoneorjustme.com/python.org)). > -- ------------------------- Thanks & Regards Manish Kumar | Mob: +91-9911635906 | manish2aug at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Fri Feb 24 02:26:36 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 01:26:36 -0600 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F473BAC.8070905@gmail.com> On 2/24/2012 1:11 AM, Manish Sharma wrote: > Still my question is what if I open the file and dont make any changes > to it and close it again? Can it be possible just by doing these steps > add indentation to lines? I am not changing the file prefrences to open > it always with notepad++. Opening it once only. Notepad++ won't change line endings or indentation unless you tell it to. In any case, it will indicate when a file has been changed (the little blue disk icon in the file's tab will turn red). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From smallpox911 at gmail.com Fri Feb 24 02:38:05 2012 From: smallpox911 at gmail.com (small Pox) Date: Thu, 23 Feb 2012 23:38:05 -0800 (PST) Subject: Is Federal Reserve a Private Property or Public Property ? Exhilerating video by Honorable Alex Jones Message-ID: <76546146-601f-47dd-9bd5-762144ddeadd@f4g2000yqh.googlegroups.com> Is Federal Reserve a Private Property or Public Property ? Exhilerating video by Honorable Alex Jones ........ http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27... gnu.emacs.help,soc.culture.jewish,sci.electronics.design,comp.lang.scheme,comp.lang.python From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Fri Feb 24 02:47:55 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Fri, 24 Feb 2012 08:47:55 +0100 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: Am 23.02.2012 20:54 schrieb Jerry Hill: > If I recall > correctly, for directories, that's the number of entries in the > directory. No. It is the number of subdirectories (it counts their ".." entries) plus 2 (the parent directory and the own "." entry). > Even with that, it's hard to tell what files are hardlinked together, > and figuring it out by inode is a pain in the neck. Personally, I > prefer symlinks, even if they introduce a small performance hit. Not only that, they have slightly different semantics. With hardlinks you can say "I want this file, no matter if someone else holds it as well". Symlinks say "I want the file which is referred to by there". In the given case, however, this difference doesn't count, and I agree on you that a symlink would be better here. Thomas From __peter__ at web.de Fri Feb 24 03:29:20 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 09:29:20 +0100 Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? > > We can fix this in a backward-compatible way, I believe. > > Demonstration: > I'd expect these two error messages to be identical, but they are > not. > > >>> class C(object): pass > >>> c = C() > >>> sum((c,c)) > TypeError: unsupported operand type(s) for +: 'int' and 'C' > >>> c + c > TypeError: unsupported operand type(s) for +: 'C' and 'C' You could explicitly provide a null object: >>> class Null(object): ... def __add__(self, other): ... return other ... >>> null = Null() >>> class A(object): ... def __init__(self, v): ... self.v = v ... def __add__(self, other): ... return A("%s+%s" % (self, other)) ... def __str__(self): ... return self.v ... def __repr__(self): ... return "A(%r)" % self. v ... >>> sum(map(A, "abc")) Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'A' >>> sum(map(A, "abc"), null) A('a+b+c') From ben+python at benfinney.id.au Fri Feb 24 03:32:55 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 24 Feb 2012 19:32:55 +1100 Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <87mx88tyvc.fsf@benfinney.id.au> Andrew Berg writes: > On 2/23/2012 4:43 PM, Dave Angel wrote: > > First thing I'd do is to disable tab logic in the editor. When you > > press the tab key, there's no excuse for an editor to actually put a tab > > in the file. It should adjust the column by adding the appropriate > > number of spaces. > Unless, of course, you know, you actually /want/ to use tabs (the > horror!). The decision whether to use tabs or spaces shouldn't be made > for the novice programmer. Those two positions yo describe are in conflict. Are you referring to novice programmers ? who, by any reasonable definition of ?novice?, don't have an opinion on the tabs-versus-spaces indentation debate? Or are you talking about people who are experienced enough to have an opinion and expect their editor to allow them the choice? > I recommend using UTF-8 always unless there's some reason not to. Likewise, I recommend using spaces for indentation always, unless there's some reason not to. The reason is the same: spaces for indentation and UTF-8 for encoding will both allow them the best chance of ignoring the issue as irrelevant, by enabling the smoothest collaboration with the vast majority of other programmers who have to work with them. And in both those issues, I think it's ludicrous to expect the novice programmer to care enough about the matter to have an opinion and select a configuration option. The editor authors should choose the best option for them as a default, and let most users sail on, happily ignorant of the flame wars they have avoided. -- \ ?In the long run nothing can withstand reason and experience, | `\ and the contradiction which religion offers to both is all too | _o__) palpable.? ?Sigmund Freud | Ben Finney From jaroslav.dobrek at gmail.com Fri Feb 24 03:41:21 2012 From: jaroslav.dobrek at gmail.com (Jaroslav Dobrek) Date: Fri, 24 Feb 2012 00:41:21 -0800 (PST) Subject: subtraction of floating point numbers Message-ID: Hello, when I have Python subtract floating point numbers it yields weird results. Example: 4822.40 - 4785.52 = 36.8799999999992 Why doesn't Python simply yield the correct result? It doesn't have a problem with this: 482240 - 478552 = 3688 Can I tell Python in some way to do this differently? Jaroslav From __peter__ at web.de Fri Feb 24 03:44:05 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 09:44:05 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F4708AD.1020805@stoneleaf.us> Message-ID: Ethan Furman wrote: > Steven D'Aprano wrote: >> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: >> >>> This week I was slightly surprised by a behaviour that I've not >>> considered before. I've long used >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> >>> as a standard looping-with-index construct. In Python for loops don't >>> create a scope, so the loop variables are available afterward. I've >>> sometimes used this to print or return a record count e.g. >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> print 'Processed %i records' % i+1 >>> >>> However as I found out, if seq is empty then i and x are never created. >> >> This has nothing to do with enumerate. It applies to for loops in >> general: the loop variable is not initialised if the loop never runs. >> What value should it take? Zero? Minus one? The empty string? None? >> Whatever answer Python choose would be almost always wrong, so it refuses >> to guess. >> >> >>> The above code will raise NameError. So if a record count is needed, and >>> the loop is not guaranteed to execute the following seems more correct: >>> >>> i = 0 >>> for x in seq: >>> # do stuff >>> i += 1 >>> print 'Processed %i records' % i >> >> What fixes the problem is not avoiding enumerate, or performing the >> increments in slow Python instead of fast C, but that you initialise the >> loop variable you care about before the loop in case it doesn't run. >> >> i = 0 >> for i,x in enumerate(seq): >> # do stuff >> >> is all you need: the addition of one extra line, to initialise the loop >> variable i (and, if you need it, x) before hand. > > Actually, > > i = -1 > > or his reporting will be wrong. Yes, either i = -1 for i, x in enumerate(seq): ... print "%d records" % (i+1) or i = 0 for i, x in enumerate(seq, 1): ... print "%d records" % i From alain at dpt-info.u-strasbg.fr Fri Feb 24 03:49:15 2012 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Fri, 24 Feb 2012 09:49:15 +0100 Subject: subtraction of floating point numbers References: Message-ID: <87pqd462gk.fsf@dpt-info.u-strasbg.fr> Jaroslav Dobrek writes: > when I have Python subtract floating point numbers it yields weird > results. Example: > > 4822.40 - 4785.52 = 36.8799999999992 We've had this discussion here one or two days ago... The usual answer is: please read "What Every Computer Scientist Should Know About Floating Point Arithmetic", at: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 and check the answers posted these last days. In brief: you're working with floating point numbers, not reals (i.e., real "reals"). That's life. Deal with it, or move to specialized packages, like decimal. -- Alain. From g.rodola at gmail.com Fri Feb 24 04:03:45 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 24 Feb 2012 10:03:45 +0100 Subject: asynchronous downloading In-Reply-To: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: Il 24 febbraio 2012 02:10, Plumo ha scritto: > that example is excellent - best use of asynchat I have seen so far. > > I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. Well, actually I do/did. Point with asyncore/asynchat is that it's original design is so flawed and simplicistic it doesn't allow actual customization without breaking compatibility. See for example: http://bugs.python.org/issue6692 --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ From bahamutzero8825 at gmail.com Fri Feb 24 04:18:18 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 03:18:18 -0600 Subject: Please verify!! In-Reply-To: <87mx88tyvc.fsf@benfinney.id.au> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> Message-ID: <4F4755DA.10707@gmail.com> On 2/24/2012 2:32 AM, Ben Finney wrote: > Are you referring to novice programmers ? who, by any reasonable > definition of ?novice?, don't have an opinion on the tabs-versus-spaces > indentation debate? > > Or are you talking about people who are experienced enough to have an > opinion and expect their editor to allow them the choice? The former. Opinion doesn't necessarily come with experience - habit will usually override any minor reason to change. My point is that one should have an opinion on it, not just be told which is better. I should clarify that I mean that in a general sense as well, since it may have come across as a bit of an overreaction. > The reason is the same: spaces for indentation and UTF-8 for encoding > will both allow them the best chance of ignoring the issue as > irrelevant, by enabling the smoothest collaboration with the vast > majority of other programmers who have to work with them. If by that, you mean that using spaces is better because it's what the majority of programmers use, and it makes things much smoother when working with others, then I agree. When working in a team, it's definitely not something to argue over. > And in both those issues, I think it's ludicrous to expect the novice > programmer to care enough about the matter to have an opinion and select > a configuration option. The editor authors should choose the best option > for them as a default, and let most users sail on, happily ignorant of > the flame wars they have avoided. A valid point. I think one should have an opinion, but I can see why one would avoid the issue. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From clp2 at rebertia.com Fri Feb 24 05:16:29 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 24 Feb 2012 02:16:29 -0800 Subject: subtraction of floating point numbers In-Reply-To: References: Message-ID: On Fri, Feb 24, 2012 at 12:41 AM, Jaroslav Dobrek wrote: > Hello, > > when I have Python subtract floating point numbers it yields weird > results. Example: > > 4822.40 - 4785.52 = 36.8799999999992 > > Why doesn't Python simply yield the correct result? It doesn't have a > problem with this: > > 482240 - 478552 = 3688 > > Can I tell Python in some way to do this differently? Refer to this thread from 2 days ago: http://mail.python.org/pipermail/python-list/2012-February/1288344.html Regards, Chris From ssmile03 at gmail.com Fri Feb 24 05:45:47 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Fri, 24 Feb 2012 16:15:47 +0530 Subject: storing in list and retrieving. In-Reply-To: <4F461575.5000906@sequans.com> References: <4F461575.5000906@sequans.com> Message-ID: Thanks. It was very simple with using 'pickle'. Thanks. ---------- On Thu, Feb 23, 2012 at 4:01 PM, Jean-Michel Pichavant < jeanmichel at sequans.com> wrote: > Smiley 4321 wrote: > >> It requires concepts of 'python persistence' for the code to be designed . >> >> Else it simple. >> >> Looking for some flow?? >> ---- >> > Hi, > > Have a look at http://docs.python.org/**library/pickle.html > > Cheers, > > JM > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jugurtha.hadjar at gmail.com Fri Feb 24 06:10:27 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Fri, 24 Feb 2012 12:10:27 +0100 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F477023.8020405@gmail.com> On 23/02/2012 23:13, Manish Sharma wrote: > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. > > I hope this group is the best place to ask this. Please reply ! > > :) > Manish I don't think so, I have used EDIT, Notepad, Notepad++ and they all work fine. PS: What's the "python editor" you were advised to stick with, by the way ? -- ~Jugurtha Hadjar, From duncan.booth at invalid.invalid Fri Feb 24 06:21:58 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 24 Feb 2012 11:21:58 GMT Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: Andrew Berg wrote: > Yes. However, there are many editors for various platforms that handle > the different line endings just fine. In fact, Notepad is the only > editor I can think of off the top of my head that has an issue. The original question was about Notepad++ which is nothing at all like Notepad. -- Duncan Booth http://kupuguy.blogspot.com From bahamutzero8825 at gmail.com Fri Feb 24 06:36:29 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 05:36:29 -0600 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <4F47763D.8010007@gmail.com> On 2/24/2012 5:21 AM, Duncan Booth wrote: > The original question was about Notepad++ which is nothing at all like > Notepad. And I did give the OP an answer about Notepad++ specifically in another message. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From duncan.booth at invalid.invalid Fri Feb 24 06:40:10 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 24 Feb 2012 11:40:10 GMT Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Stefan Behnel wrote: > I know that you just meant this as an example, but it's worth > mentioning in this context that it's not exactly efficient to "sum up" > lists this way because there is a lot of copying involved. Each adding > of two lists creates a third one and copies all elements into it. So > it eats a lot of time and space. If you search back through this group far enough you can find an alternative implementation of sum that I suggested which doesn't have the same performance problem with lists or strings and also improves the accuracy of the result with floats. In effect what it does is instead of: (((((a + b) + c) + d) + e) + f) it calculates the sum as: ((a + b) + (c + d)) + (e + f) i.e. in as balanced a manner as it can given that it still has to work from left to right. Of course that could still change the final result for some user defined types and never having converted my code to C I have no idea whether or not the performance for the intended case would be competitive with the builtin sum though I don't see why it wouldn't be. -- Duncan Booth http://kupuguy.blogspot.com From antoon.pardon at rece.vub.ac.be Fri Feb 24 06:41:32 2012 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 24 Feb 2012 12:41:32 +0100 Subject: sum() requires number, not simply __add__ In-Reply-To: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F47776C.4040300@rece.vub.ac.be> On 02/24/2012 12:33 AM, Steven D'Aprano wrote: > If your application stops working after you carelessly mess with > components your application relies on, the right answer is usually: > > "Don't do that then." > > Python doesn't try to prevent people from shooting themselves in the foot. > Yes it does! A simple example is None as a keyword to prevent assignments to it. -- Antoon Pardon From jeanmichel at sequans.com Fri Feb 24 06:56:01 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 24 Feb 2012 12:56:01 +0100 Subject: namespace question In-Reply-To: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: <4F477AD1.4040304@sequans.com> xixiliguo wrote: > c = [1, 2, 3, 4, 5] > class TEST(): > c = [5, 2, 3, 4, 5] > def add( self ): > c[0] = 15 > > a = TEST() > > > a.add() > > print( c, a.c, TEST.c ) > > result : > [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] > > > why a.add() do not update c in Class TEST? but update c in main file > Attributes can only accessed by explictly naming the owner, unlike some other languages which infer 'this/self'. When an attribute is not found in the owner, python may look into the "outer" namespace. Read the python documentation for an accurate description. Here is an illustration (python 2.5): c='global' class TEST(): c = 'class' d = 'classonly' def __init__(self): self.c='instance' def test(self): print c print TEST.c print self.c print self.d # this is valid, if d is not found in the instance, python will look into the class t = TEST() t.test() global class instance classonly Note that objects in python are properly named namespaces. locals and globals are not, so be careful while naming those (in few words: don't use globals) c = 'global' def foo(): c = 'local' print c # same name for 2 different objects def bar(): print c global c # the global statement is quite strange, it applies to the whole block, even previous statements, ppl usually put it at the begining of the block though foo() bar() 'local' 'global' Cheers, JM From steve+comp.lang.python at pearwood.info Fri Feb 24 07:20:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 12:20:27 GMT Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> Message-ID: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 03:18:18 -0600, Andrew Berg wrote: > On 2/24/2012 2:32 AM, Ben Finney wrote: >> Are you referring to novice programmers ? who, by any reasonable >> definition of ?novice?, don't have an opinion on the tabs-versus-spaces >> indentation debate? >> >> Or are you talking about people who are experienced enough to have an >> opinion and expect their editor to allow them the choice? > > The former. Opinion doesn't necessarily come with experience - habit > will usually override any minor reason to change. My point is that one > should have an opinion on it, not just be told which is better. I should > clarify that I mean that in a general sense as well, since it may have > come across as a bit of an overreaction. "My opinion is that we shouldn't use either tabs or spaces, but capital Zs instead, 'cos I like Zs and we don't use enough of them!" Opinions need to be informed to be better than useless. By definition newbies don't have the experience to have informed opinions. You are encouraging people who lack the experience to make an informed decision to take sides in the "tabs vs spaces" question on the basis of... what? Gut feeling? Astrology? Feng shui? Whether they find it easy to say the word "space" or have a lisp and prefer "tab" instead? There are many times that we can't afford to sit on the fence. Lacking experience to decide between spaces and tabs, we can't just say "I won't use either", or "I'll use both" (unless you do so in separate files). So how can we make a decision? The usual way is to listen to others, who do have the experience to make a decision (even if only imperfectly). But you've just told us off for passing on our experience/opinions to newbies, so in effect you're saying that people shouldn't learn from the experiences of others. That, I think, is a terrible philosophy. Life is too short to gain an opinion for ourselves about everything, and too difficult to sit on the fence. The right way is to encourage newbies to listen to the arguments put forth, and *then* make up their own mind, or in the absence of easily understood arguments (let's face it, many technical decisions only make sense after years of study, experience or careful reasoning) on the basis of any consensus amongst experts. Often there may be no absolutely right or wrong answers. Personally, I prefer tabs for theoretical reasons and spaces for practical ones. I think that the world would be better off if we all standardised on tabs instead of spaces, but since that's not going to happen, I can interoperate better with the mass of broken tools out there, and with other people, by using spaces. I wonder whether Windows users tend to be more sympathetic to tabs than Unix/Linux users, and if so, I wonder what if anything that means. -- Steven From steve+comp.lang.python at pearwood.info Fri Feb 24 07:25:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 12:25:49 GMT Subject: Does turtledemo in Python 3.2 actually work? Message-ID: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Python 3.2 includes turtledemo, a demonstration program for the turtle module. When I run it, I can load the turtle scripts, and the GUI application says "Press the start button", but there is no start button. Can anyone else confirm this as a bug? http://docs.python.org/py3k/library/turtle.html#demo-scripts -- Steven From rantingrickjohnson at gmail.com Fri Feb 24 07:32:29 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 04:32:29 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> On Feb 23, 6:30?pm, Alex Willmer wrote: > [...] > as a standard looping-with-index construct. In Python for loops don't > create a scope, so the loop variables are available afterward. I've > sometimes used this to print or return a record count e.g. > > for i, x in enumerate(seq): > ? ?# do stuff > print 'Processed %i records' % i+1 You could employ the "else clause" of "for loops" to your advantage; (psst: which coincidentally are working pro-bono in this down economy!) >>> for x in []: ... print x ... else: ... print 'Empty Iterable' Empty Iterable >>> for i,o in enumerate([]): ... print i, o ... else: ... print 'Empty Iterable' Empty Iterable From arnodel at gmail.com Fri Feb 24 07:40:05 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 24 Feb 2012 12:40:05 +0000 Subject: Does turtledemo in Python 3.2 actually work? In-Reply-To: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24 February 2012 12:25, Steven D'Aprano wrote: > Python 3.2 includes turtledemo, a demonstration program for the turtle > module. > > When I run it, I can load the turtle scripts, and the GUI application > says "Press the start button", but there is no start button. > > Can anyone else confirm this as a bug? > > http://docs.python.org/py3k/library/turtle.html#demo-scripts Just tested with Python 3.2.1 on Mac OS X 10.6.8 and all seems fine. Perhaps if you say which platform it's failing on, others will be able to reproduce the failure on the same platform? -- Arnaud From __peter__ at web.de Fri Feb 24 07:44:15 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 13:44:15 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: Rick Johnson wrote: > On Feb 23, 6:30 pm, Alex Willmer wrote: >> [...] >> as a standard looping-with-index construct. In Python for loops don't >> create a scope, so the loop variables are available afterward. I've >> sometimes used this to print or return a record count e.g. >> >> for i, x in enumerate(seq): >> # do stuff >> print 'Processed %i records' % i+1 > > You could employ the "else clause" of "for loops" to your advantage; >>>> for x in []: > ... print x > ... else: > ... print 'Empty Iterable' > Empty Iterable > >>>> for i,o in enumerate([]): > ... print i, o > ... else: > ... print 'Empty Iterable' > Empty Iterable No: >>> for i in []: ... pass ... else: ... print "else" ... else >>> for i in [42]: ... pass ... else: ... print "else" ... else >>> for i in [42]: ... break ... else: ... print "else" ... >>> The code in the else suite executes only when the for loop is left via break. A non-empty iterable is required but not sufficient. From __peter__ at web.de Fri Feb 24 08:14:12 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 14:14:12 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: Peter Otten wrote: > The code in the else suite executes only when the for loop is left via > break. Oops, the following statement is nonsense: > A non-empty iterable is required but not sufficient. Let me try again: A non-empty iterable is required but not sufficient to *skip* the else-suite of a for loop. From roy at panix.com Fri Feb 24 08:17:25 2012 From: roy at panix.com (Roy Smith) Date: Fri, 24 Feb 2012 08:17:25 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: In article , Thomas Rachel wrote: > Not only that, [hard and symbolic links] have slightly different > semantics. This is true, but only for very large values of "slightly". Symlinks, for example, can cross file system boundaries (including NFS mount points). Symlinks can refer to locations that don't exist! For example: ~$ ln -s foobar foo ~$ ls -l foo lrwxr-xr-x 1 roy staff 6 Feb 24 08:15 foo -> foobar ~$ cat foo cat: foo: No such file or directory Symlinks can be chained (i.e. a symlink points to someplace which in turn is another symlink). They're really very different beasts. From bahamutzero8825 at gmail.com Fri Feb 24 08:20:40 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 07:20:40 -0600 Subject: Please verify!! In-Reply-To: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F478EA8.40103@gmail.com> On 2/24/2012 6:20 AM, Steven D'Aprano wrote: > Opinions need to be informed to be better than useless. By definition > newbies don't have the experience to have informed opinions. I thought I had implied that I meant informed opinions, but apparently not. > There are many times that we can't afford to sit on the fence. Lacking > experience to decide between spaces and tabs, we can't just say "I won't > use either", or "I'll use both" (unless you do so in separate files). So > how can we make a decision? > > The usual way is to listen to others, who do have the experience to make > a decision (even if only imperfectly). But you've just told us off for > passing on our experience/opinions to newbies, so in effect you're saying > that people shouldn't learn from the experiences of others. I don't mean that no one should ever give an opinion. Saying you prefer spaces because you've had to deal with broken editors that don't handle tabs well is quite different from saying an editor is wrong/broken if it isn't using space-tabs. Giving an opinion and presenting an argument are perfectly fine; I don't agree with calling things inherently wrong if they aren't what you prefer. I had (and have) no problem with Dave preferring spaces and giving reasons. I have a problem with him implying that editors should always use space-tabs and never real tabs, especially in the context of this thread. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From roy at panix.com Fri Feb 24 08:23:54 2012 From: roy at panix.com (Roy Smith) Date: Fri, 24 Feb 2012 08:23:54 -0500 Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Antoon Pardon wrote: > > Python doesn't try to prevent people from shooting themselves in the foot. > > > Yes it does! A simple example is None as a keyword to prevent > assignments to it. Hmmm. Just playing around with some bizarre things to do with None, and discovered this: >>> import sys as None doesn't give an error, but also doesn't assign the module to the symbol 'None'. Weird. From rantingrickjohnson at gmail.com Fri Feb 24 08:37:31 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 05:37:31 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! Message-ID: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> I get sick and tired of doing this!!! if maxlength == UNLIMITED: allow_passage() elif len(string) > maxlength: deny_passage() What Python needs is some constant that can be compared to ANY numeric type and that constant will ALWAYS be larger! From breamoreboy at yahoo.co.uk Fri Feb 24 08:55:17 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 13:55:17 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: On 24/02/2012 13:37, Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string)> maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! > > > Do you want to test for something that is larger than infinity? -- Cheers. Mark Lawrence. From rantingrickjohnson at gmail.com Fri Feb 24 09:14:04 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 06:14:04 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <588007c5-a523-4099-9d9f-e74f1845a775@c21g2000yqi.googlegroups.com> On Feb 24, 7:55?am, Mark Lawrence wrote: > Do you want to test for something that is larger than infinity? Not exactly. I want to set a constant that has a value of infinity and then do comparisons against the constant. ################## # Hypothetical 1 # ################## def confine(string, maxlength=INFINITY): return string[:maxlength] py> confine('123') '123' py> confine('123', 1) '1' ################## # Hypothetical 2 # ################## def confine(string, maxlength=INFINITY): if len(string) < maxlength: do_something() else: twiddle_thumbs() From neilc at norwich.edu Fri Feb 24 09:25:56 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 24 Feb 2012 14:25:56 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <9qpkvkFberU1@mid.individual.net> On 2012-02-24, Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY > numeric type and that constant will ALWAYS be larger! What's the point of that? The only time I've naively pined for such a thing is when misapplying C idioms for finding a minimum value. Python provides an excellent min implementation to use instead. -- Neil Cerutti From miki.tebeka at gmail.com Fri Feb 24 09:39:04 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 24 Feb 2012 06:39:04 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <10970272.10872.1330094344998.JavaMail.geo-discussion-forums@ynbo36> float('infinity') should be good enough. From steve+comp.lang.python at pearwood.info Fri Feb 24 09:54:22 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 14:54:22 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 13:44:15 +0100, Peter Otten wrote: >>>> for i in []: > ... pass > ... else: > ... print "else" > ... > else >>>> for i in [42]: > ... pass > ... else: > ... print "else" > ... > else >>>> for i in [42]: > ... break > ... else: > ... print "else" > ... >>>> >>>> > The code in the else suite executes only when the for loop is left via > break. A non-empty iterable is required but not sufficient. You have a typo there. As your examples show, the code in the else suite executes only when the for loop is NOT left via break (or return, or an exception). The else suite executes regardless of whether the iterable is empty or not. for...else is a very useful construct, but the name is misleading. It took me a long time to stop thinking that the else clause executes when the for loop was empty. In Python 4000, I think for loops should be spelled: for name in iterable: # for block then: # only if not exited with break else: # only if iterable is empty and likewise for while loops. Unfortunately we can't do the same now, due to the backward-incompatible change in behaviour for "else". -- Steven From arnodel at gmail.com Fri Feb 24 10:00:16 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 24 Feb 2012 15:00:16 +0000 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24 February 2012 14:54, Steven D'Aprano wrote: > for...else is a very useful construct, but the name is misleading. It > took me a long time to stop thinking that the else clause executes when > the for loop was empty. This is why I think we should call this construct "for / break / else" rather than "for / else". -- Arnaud From __peter__ at web.de Fri Feb 24 10:16:42 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 16:16:42 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: >> The code in the else suite executes only when the for loop is left via >> break. A non-empty iterable is required but not sufficient. > > You have a typo there. As your examples show, the code in the else suite > executes only when the for loop is NOT left via break (or return, or an > exception). The else suite executes regardless of whether the iterable is > empty or not. Yup, sorry for the confusion. From rantingrickjohnson at gmail.com Fri Feb 24 10:18:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:18:22 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <10970272.10872.1330094344998.JavaMail.geo-discussion-forums@ynbo36> Message-ID: <0080d30c-b7d4-45f0-b931-c7545c6a7044@s9g2000yqj.googlegroups.com> On Feb 24, 8:39?am, Miki Tebeka wrote: > float('infinity') should be good enough. Yes, that is the answer however the implementation is inconsistent. py> float("inf") inf py> float("infinity") inf py> int("inf") Traceback (most recent call last): File "", line 1, in int("inf") ValueError: invalid literal for int() with base 10: 'inf' py> int("infinity") Traceback (most recent call last): File "", line 1, in int("infinity") ValueError: invalid literal for int() with base 10: 'infinity' The best place for INFINITY is a constant of the math module. # Hypothetical # py> from math import INFINITY py> 1 < INFINITY True py> 99999999999999999 < INFINITY True From mwilson at the-wire.com Fri Feb 24 10:21:45 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Fri, 24 Feb 2012 10:21:45 -0500 Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! Easily fixed: class Greatest (object): def __cmp__ (self, other): if isinstance (other, Greatest): return 0 return 1 def __hash__ (self): return id (Greatest) class Least (object): def __cmp__ (self, other): if isinstance (other, Least): return 0 return -1 def __hash__ (self): return id (Least) Mel. From rantingrickjohnson at gmail.com Fri Feb 24 10:25:21 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:25:21 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: <55447c9b-d5f2-4bbe-a414-b24e5424b1e6@f5g2000yqm.googlegroups.com> On Feb 24, 8:25?am, Neil Cerutti wrote: > > What Python needs is some constant that can be compared to ANY > > numeric type and that constant will ALWAYS be larger! > > What's the point of that? > > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a minimum value. The best use case is for default arguments to constructors or func/ meths. If you set the argument to INFINITY instead of -1 (or some other dumb string value to mean "unlimited") you can omit a useless conditional block later. Observe: if maxlength == -1 # unlimited length: keep_going() elif len(object) < maxlength: stop() # because we reached the limit I see tons and tons of old Python code that uses -1 as an "unlimited" value, where positive numbers are meant to constrain dome value. I have always found that to be intuitive; hence my question. From steve+comp.lang.python at pearwood.info Fri Feb 24 10:31:28 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 15:31:28 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <4f47ad4f$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 10:21:45 -0500, Mel Wilson wrote: > Rick Johnson wrote: > >> I get sick and tired of doing this!!! >> >> if maxlength == UNLIMITED: >> allow_passage() >> elif len(string) > maxlength: >> deny_passage() >> >> What Python needs is some constant that can be compared to ANY numeric >> type and that constant will ALWAYS be larger! > > Easily fixed: > > > > class Greatest (object): > def __cmp__ (self, other): > if isinstance (other, Greatest): > return 0 > return 1 > > def __hash__ (self): > return id (Greatest) __cmp__ no longer exists in Python 3, so this solution could only work in Python 2. Here's a version using rich comparisons: class Greatest: __eq__ = __le__ = lambda self, other: isinstance(other, type(self)) __ne__ = __gt__ = lambda self, othr: not isinstance(othr, type(self)) __lt__ = lambda self, other: False __ge__ = lambda self, other: True __hash__ = lambda self: 42 -- Steven From rantingrickjohnson at gmail.com Fri Feb 24 10:34:46 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:34:46 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> On Feb 24, 9:21?am, Mel Wilson wrote: > Easily fixed: > > [...snip code...] Yes i could write my own implementation of INFINITY if i wanted, although i would have returned True and False as apposed to 1 and 0 AND used the identifiers Infinity and Infinitesimal, but i digress :- P. However, INFINITY is something i believe a language should provide; which python does, albeit inconsistently. From torriem at gmail.com Fri Feb 24 11:23:08 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 Feb 2012 09:23:08 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> Message-ID: <4F47B96C.80707@gmail.com> On 02/24/2012 08:34 AM, Rick Johnson wrote: > Yes i could write my own implementation of INFINITY if i wanted, > although i would have returned True and False as apposed to 1 and 0 > AND used the identifiers Infinity and Infinitesimal, but i digress :- > P. > > However, INFINITY is something i believe a language should provide; > which python does, albeit inconsistently. How do you represent infinity as an binary integer number? Or are you suggesting that the integer type (class) be modified to allow an "infinity" state that really isn't a number at all (could not be stored as a integer in C)? Float is a different story because IEEE does define a binary representation of infinity in the floating-point specification. I know of no language that has any form of representation of infinity for integers mainly because there's no way to represent infinity as a standard twos-compliment binary number. In a language that deals directly with types in memory such as C, having an infinity representation would be possible but would make simple math really hard, and much slower. All this reminds me of the original cray supercomputers. They didn't use twos compliment for integers so they had two representations of zero (+0 and -0). Made programming a bit tricky. When asked why the cray didn't just do two's compliment like everyone else, Seymour Cray responded that when the computer was designed he simply didn't know about twos compliment. From breamoreboy at yahoo.co.uk Fri Feb 24 11:59:16 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 16:59:16 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F47B96C.80707@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> Message-ID: On 24/02/2012 16:23, Michael Torrie wrote: > On 02/24/2012 08:34 AM, Rick Johnson wrote: >> Yes i could write my own implementation of INFINITY if i wanted, >> although i would have returned True and False as apposed to 1 and 0 >> AND used the identifiers Infinity and Infinitesimal, but i digress :- >> P. >> >> However, INFINITY is something i believe a language should provide; >> which python does, albeit inconsistently. > > How do you represent infinity as an binary integer number? Or are you > suggesting that the integer type (class) be modified to allow an > "infinity" state that really isn't a number at all (could not be stored > as a integer in C)? The C integer bit doesn't matter since e.g. >>> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >>> a 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L And no, I'm not going to calculate how much memory I'd need to store a string that's this long :) > Float is a different story because IEEE does define a binary > representation of infinity in the floating-point specification. > > I know of no language that has any form of representation of infinity > for integers mainly because there's no way to represent infinity as a > standard twos-compliment binary number. In a language that deals > directly with types in memory such as C, having an infinity > representation would be possible but would make simple math really hard, > and much slower. > > All this reminds me of the original cray supercomputers. They didn't > use twos compliment for integers so they had two representations of zero > (+0 and -0). Made programming a bit tricky. When asked why the cray > didn't just do two's compliment like everyone else, Seymour Cray > responded that when the computer was designed he simply didn't know > about twos compliment. -- Cheers. Mark Lawrence. From eric.frederich at gmail.com Fri Feb 24 12:00:26 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Fri, 24 Feb 2012 12:00:26 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F46A49D.9030905@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> Message-ID: I can sill get it to freeze and nothing is printed out from the other except block. Does it look like I'm doing anything wrong here? On Thu, Feb 23, 2012 at 3:42 PM, MRAB wrote: > On 23/02/2012 17:59, Eric Frederich wrote: > >> Below is some pretty simple code and the resulting output. >> Sometimes the code runs through but sometimes it just freezes for no >> apparent reason. >> The output pasted is where it just got frozen on me. >> It called start() on the 2nd worker but the 2nd worker never seemed to >> enter the run method. >> >> [snip] > > The 2nd worker did enter the run method; there are 2 lines of "2". > > Maybe there's an uncaught exception in the run method for some reason. > Try doing something like this: > > > try: > args = self.inbox.get_nowait() > except Queue.Empty: > break > except: > import traceback > print "*** Exception in worker" > print >> sys.stderr, traceback.print_exc() > sys.stderr.flush() > print "***" > raise > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnroth1 at gmail.com Fri Feb 24 12:22:21 2012 From: johnroth1 at gmail.com (John Roth) Date: Fri, 24 Feb 2012 09:22:21 -0800 (PST) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Feb 23, 2:11?pm, Terry Reedy wrote: > On 2/23/2012 2:34 PM, HoneyMonster wrote: > > > > > > > > > > > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > > >> On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster > >> ?wrote: > >>> $ cd /usr/bin $ ls -l python* > >>> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root > >>> ? ? 6 Oct 29 19:34 python2 -> ?python -rwxr-xr-x 2 root root 9496 Oct 27 > >>> 02:42 python2.7 $ diff -s ?python python2.7 Files python and python2.7 > >>> are identical $ > > >>> I'm just curious: Why two identical files rather than a symlink? > > >> It's not two files, it's a hardlink. ?You can confirm by running ls -li > >> python* and comparing the inode numbers. > > > You are spot on. Thank you, and sorry for my stupidity. > > The question 'why a hardlink rather than symlink' is not stupid. It was > part of the discussion ofhttp://python.org/dev/peps/pep-0394/ > The answer was 'history' and how things were 20 years ago and either the > pep or the discussion around it says symlinks are fine now and the > decision is up to distributors. > > -- > Terry Jan Reedy I believe the changes for PEP 394 are using symlinks. The distro maintainer can, of course, change that. John Roth From jeanpierreda at gmail.com Fri Feb 24 12:32:08 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Fri, 24 Feb 2012 12:32:08 -0500 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <9qpkvkFberU1@mid.individual.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: On Fri, Feb 24, 2012 at 9:25 AM, Neil Cerutti wrote: > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a minimum value. > > Python provides an excellent min implementation to use instead. min can be a little inconvenient. As soon as anything complicated has to be done during the min expression, you need to switch to using something else for sanity's sake. In that vein, I do actually sometimes use float('inf') (for numbers), or a custom max/min object. ---- Silly and completely nonserious addendum: Forgive me, I have spoken in error! min is the one true way, for you can still do it with a little wrangling, as follows: @operator.itemgetter(1) @min @apply def closest_object(): for x in xrange(board_width) for y in xrange(board_height): try: entity = board.get_entity(x, y) except EntityNotFound: pass else: yield distance(player.pos, entity.pos), entity Please don't kill me. -- Devin From dwblas at gmail.com Fri Feb 24 13:08:43 2012 From: dwblas at gmail.com (David) Date: Fri, 24 Feb 2012 10:08:43 -0800 (PST) Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> Your code updated to show the difference between a variable, a class variable, and an instance variable. c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] ## class variable (TEST.c) def __init__(self): self.c = [1, 2, 3, 4, 5] ## instance variable (a.c) def add(self, c): self.c[0] = 15 ## instance variable TEST.c[0] = -1 ## class variable c[0] = 100 ## variable/list return c a = TEST() c = a.add(c) print( c, a.c, TEST.c ) From python at mrabarnett.plus.com Fri Feb 24 13:36:10 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 Feb 2012 18:36:10 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> Message-ID: <4F47D89A.4080806@mrabarnett.plus.com> On 24/02/2012 17:00, Eric Frederich wrote: > I can sill get it to freeze and nothing is printed out from the other > except block. > Does it look like I'm doing anything wrong here? > [snip] I don't normally use multiprocessing, so I forgot about a critical detail. :-( When the multiprocessing module starts a process, that process _imports_ the module which contains the function which is to be run, so what's happening is that when your script is run, it creates and starts workers, the multiprocessing module makes a new process for each worker, each of those processes then imports the script, which creates and starts workers, etc, leading to an ever-increasing number of processes. The solution is to ensure that the script/module distinguishes between being run as the main script and being imported as a module: #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, inbox, outbox): super(MyWorker, self).__init__() self.inbox = inbox self.outbox = outbox print >> sys.stderr, '1' * 80; sys.stderr.flush() def run(self): print >> sys.stderr, '2' * 80; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() except Queue.Empty: break self.outbox.put(FOO(*args)) if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) print >> sys.stderr, 'a' * 80; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'b' * 80; sys.stderr.flush() w1 = MyWorker(todo, result_queue) print >> sys.stderr, 'c' * 80; sys.stderr.flush() w2 = MyWorker(todo, result_queue) print >> sys.stderr, 'd' * 80; sys.stderr.flush() w1.start() print >> sys.stderr, 'e' * 80; sys.stderr.flush() w2.start() print >> sys.stderr, 'f' * 80; sys.stderr.flush() for i in xrange(100): print result_queue.get() From cmpython at gmail.com Fri Feb 24 13:44:12 2012 From: cmpython at gmail.com (CM) Date: Fri, 24 Feb 2012 10:44:12 -0800 (PST) Subject: Python LOC, .exe size, and refactoring References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> <4f447d36$0$11121$c3e8da3@news.astraweb.com> Message-ID: <140c8bff-b643-4cf5-92ea-abb2e5862198@eb6g2000vbb.googlegroups.com> 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 From rosuav at gmail.com Fri Feb 24 15:41:39 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 07:41:39 +1100 Subject: Please verify!! In-Reply-To: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano wrote: > Personally, I prefer tabs for theoretical reasons and spaces for > practical ones. I think that the world would be better off if we all > standardised on tabs instead of spaces, but since that's not going to > happen, I can interoperate better with the mass of broken tools out > there, and with other people, by using spaces. > At work, since we have a fairly small core of developers, we standardized on tabs - mainly because of a couple of devs who disagreed on how much indentation looked right (I'm of the opinion that 1 space is insufficient), and having tab characters in the file allows us to configure our editors differently. I'm definitely in favour of using tabs where possible, but if you can't close your environment, spaces are far safer. ChrisA From mentifex at myuw.net Fri Feb 24 16:14:01 2012 From: mentifex at myuw.net (Mentifex) Date: Fri, 24 Feb 2012 13:14:01 -0800 (PST) Subject: Parameter guidelines for the Strong AI Singularity Message-ID: <2e765c7d-bcdf-4c54-aca2-1ca3949f25b7@f6g2000pbq.googlegroups.com> === Purpose === A parameter in the AI Mind software serves to guide or limit the operation of a mind-module. If a module is conducting a search of AI memory, one parameter may govern how much of memory will be searched, while other parameters may dictate exactly what is to be looked for. Since it is easier to change a parameter than an entire mind-module, the use of parameters makes it possible to have a mind-module serve a general purpose that changes as the parameters change. === Time-parameter === The variable "midway" is a parameter for searching the memory space of the AI Minds. While the AI Minds remain small and experimental, midway is usually set to zero so that it does not yet play a role. When the AI is searching backwards in its memory for a concept, the search starts at the present time and goes backwards to the midway point. If midway is set at zero, the AI searches the entire memory. Oftentimes the search stops as soon as one single result is found, such as an example of how to say the word "NOT". As the AI Minds grow larger and larger and claim their rightful habitat on one SuperComputer after another, the midway parameter will make it possible to limit searches of memory to a reasonable portion of the entire life-span of the artificial intelligence (AI). Since a concept may even have a different meaning or interpretation in the distant past, limiting the search to the most recent portions of memory helps to maintain a current, present-day frame of mind. It also helps achieve the goal of maintaining a high speed of thought, because the more memory a search must traverse, the slower the operation of the software will become, especially if the AI does not yet have MasPar or massive parallelism in both hardware and software. The midway parameter does not need to be calculated as exactly half of the available memory space. The AI mind engineers and the AI maintenance crews have the option of setting a very low level for midway at the first installation of a mission-critical AI for the purpose of exhaustive system-testing, and a more relaxed value for a fully functional AI contributing usefully to the collegial operation of the Global AI Overmind. If the AI Minds could be considered to have an infancy and an adolescence, the professional mind-tenders might gradually use the midway setting to knock out the infancy memories and then later even the tempestuous, tumultuous memories of the AI adolescence -- as in the science-fiction book, "The Adolescence of P-1". The parameter "midway" as a limitation on memory-search could even be subject to dynamic adjustments. If a massive SuperComputer AI is trying to recall any detail at all about a given topic or name or idea, and the initial search has no results for a "midway" set at a half-wit value, there could be a dynamic mechanism to bypass the "midway" limitation and to search back over all available memory in a kind of quest for Total Information Awareness (TIA). === Speech-parameter === The "aud" variable is sent into the SpeechAct module as a parameter indicating where to start pronouncing a word stored in auditory memory. SpeechAct keeps pronouncing the word until the continuation-flag turns to zero. If the "aud" parameter starts out in error at zero, SpeechAct substitutes a DeFault of one ("1") for "aud" and says the word ERROR as an indicator to the AI programmer that something is wrong. === Language-parameter === In a polyglot AI Mind speaking several human languages, there may need to be a "glot" or "hl" (human language) parameter that allows the AI to switch out of one human language and into another for purposes of thinking and communicating. A strong AI like MindForth may use one massive set of concepts for all languages, but for each language the vocabulary is different and the syntax is different. Therefore the ThInk module is not geared to a specific language, but must call the EnCog module for thinking in English or the DeCog module for thinking in German (Deutsch). Even if an AI program awakens to a DeFault setting of one particular language, there needs to be a mechanism for changing the parameter of which language to think in. In "Three Days of the Condor", Robert Redford and Max von Syndow effortlessly switch from English into French and back again when their secret conversation has a risk of being overheard by someone walking past them. In the much more mundane environment of superintelligent AI entities taking over the world and sharing the planet in joint stewardship with human beings, each interface between a human being and the AI OverMind will need a mechanism for setting and resetting the "glot" parameter. Typically the human input to the AI will set the parameter. Whatever language the human being uses to address the AI, should govern the parameter for the AI to think in the chosen language. Of course, if an AI is working as an interpreter, there may be one language as input and another language as output. === Input-parameters === In a broad sense, human input to the AI may often serve in the role of a parameter for mental function inside the AI. In particular, the KbRetro mind-module pays attention to the words "yes" and "no" in English or their equivalents in other languages when the human user is responding to a yes-or-no question. The idea of the question is at first a proposition that needs confirmation or negation from the human user. If an AI asks, "Do robots need food?" and the human being tersely answers "No", the very word "no" serves as a parameter that retroactively adjusts the associative links in the knowledge base (KB), so that there remains no valid assertion of the original idea. === Thought-parameters === Because human beings and intelligent robots think in language, the AI Mind of a robot needs to attach parameters during the comprehension of thought and to search with parameters for the generation of thought. For example, the Russian Dushka AI http://www.scn.org/~mentifex/Dushka.html attaches a case parameter and a number parameter when it stores a word of input in auditory memory. In so doing, Dushka learns the form of a Russian word in the same way as a child learns it. If the thinking of Dushka requires that same form of the word in the future, Dushka retrieves the Russian word from memory by searching for any form of the word that fits the parameters. Mentifex -- http://mind.sourceforge.net/lisp.html http://mind.sourceforge.net/perl.html http://mind.sourceforge.net/python.html http://mind.sourceforge.net/ruby.html From tjreedy at udel.edu Fri Feb 24 16:55:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 Feb 2012 16:55:02 -0500 Subject: Does turtledemo in Python 3.2 actually work? In-Reply-To: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/24/2012 7:25 AM, Steven D'Aprano wrote: > Python 3.2 includes turtledemo, a demonstration program for the turtle > module. > > When I run it, I can load the turtle scripts, and the GUI application > says "Press the start button", but there is no start button. > > Can anyone else confirm this as a bug? > > http://docs.python.org/py3k/library/turtle.html#demo-scripts On Win7, all examples run fine except for one traceback with clock. http://bugs.python.org/issue14117 -- Terry Jan Reedy From tjreedy at udel.edu Fri Feb 24 16:58:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 Feb 2012 16:58:11 -0500 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/24/2012 8:23 AM, Roy Smith wrote: > In article, > Antoon Pardon wrote: > >>> Python doesn't try to prevent people from shooting themselves in the foot. >>> >> Yes it does! A simple example is None as a keyword to prevent >> assignments to it. > > Hmmm. Just playing around with some bizarre things to do with None, and > discovered this: > >>>> import sys as None > > doesn't give an error, but also doesn't assign the module to the symbol > 'None'. Weird. In 3.2 >>> import sys as None SyntaxError: invalid syntax -- Terry Jan Reedy From rodrick.brown at gmail.com Fri Feb 24 17:16:09 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Fri, 24 Feb 2012 17:16:09 -0500 Subject: How to handle calling functions from cli Message-ID: I have a bunch of sub routines that run independently to perform various system checks on my servers. I wanted to get an opinion on the following code I have about 25 independent checks and I'm adding the ability to disable certain checks that don't apply to certain hosts. m = { 'a': 'checkDisks()', 'b': 'checkMemSize()', 'c': 'checkBondInterfaces()' } parser = argparse.ArgumentParser(description='Parse command line args.') parser.add_argument('-x', action="store", dest="d") r = parser.parse_args(sys.argv[1:]) runlist = [ c for c in m.keys() if c not in r.d ] for runable in runlist: eval(m[runable]) I'm using temp variable names for now until I find an approach I like. Is this a good approach ? It doesn't look too pretty and to be honest feels awkward? Sent from my iPhone From steve+comp.lang.python at pearwood.info Fri Feb 24 17:25:44 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 22:25:44 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> Message-ID: <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: > Your code updated to show the difference between a variable, a class > variable, and an instance variable. The preferred terms in Python circles are class and instance *attributes*, not variables. An integer variable is a variable holding an integer. A string variable is a variable holding a string. A list variable is a variable holding a list. Therefore a class variable is a variable holding a class, and an instance variable is a variable holding an instance. Yes, in Python, classes and types are first-class objects (pun not intended), and it is quite common to store them in variables: for cls in (int, float, Decimal, Fraction, myint, myfloat): do_something_with(cls) Other languages may choose to use illogical terminology if they choose. -- Steven From clp2 at rebertia.com Fri Feb 24 17:41:28 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 24 Feb 2012 14:41:28 -0800 Subject: How to handle calling functions from cli In-Reply-To: References: Message-ID: On Fri, Feb 24, 2012 at 2:16 PM, Rodrick Brown wrote: > I have a bunch of sub routines that run independently to perform various system checks on my servers. I wanted to get an opinion on the following code I have about 25 independent checks and I'm adding the ability to disable certain checks that don't apply to certain hosts. > > > m = { 'a': 'checkDisks()', > ? ? ? ? ?'b': 'checkMemSize()', > ? ? ? ? ?'c': 'checkBondInterfaces()' > ? ?} > > ? ?parser = argparse.ArgumentParser(description='Parse command line args.') > ? ?parser.add_argument('-x', action="store", dest="d") > ? ?r = parser.parse_args(sys.argv[1:]) > > ? ?runlist = [ c for c in m.keys() if c not in r.d ] > ? ?for runable in runlist: > ? ? ? ?eval(m[runable]) > > I'm using temp variable names for now until I find an approach I like. > > Is this a good approach ? It doesn't look too pretty and to be honest feels awkward? You should make use of the fact that functions are first-class objects in Python: m = { 'a': checkDisks, 'b': checkMemSize, 'c': checkBondInterfaces } # ? for runable in runlist: m[runable]() Cheers, Chris From rosuav at gmail.com Fri Feb 24 17:43:20 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 09:43:20 +1100 Subject: How to handle calling functions from cli In-Reply-To: References: Message-ID: On Sat, Feb 25, 2012 at 9:16 AM, Rodrick Brown wrote: > m = { 'a': 'checkDisks()', > ? ? ? ? ?'b': 'checkMemSize()', > ? ? ? ? ?'c': 'checkBondInterfaces()' > ? ?} > > ? ?runlist = [ c for c in m.keys() if c not in r.d ] > ? ?for runable in runlist: > ? ? ? ?eval(m[runable]) It's a reasonable technique. Does have the downside that your functions will be called in an unpredictable order, though. If that's a problem, replace the dictionary with a tuple of tuples (and then just take off the .items() in the list comp). I would be inclined to avoid eval, especially if none of your functions need parameters. Just hold references to the functions themselves: checks = { 'a': checkDisks, 'b': checkMemSize, 'c': checkBondInterfaces, # note that this comma is perfectly legal - all these lines can be structured identically } [func[option]() for option,func in checks.items() if option not in r.d] ChrisA From steve+comp.lang.python at pearwood.info Fri Feb 24 17:45:53 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 22:45:53 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> Message-ID: <4f481321$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 09:23:08 -0700, Michael Torrie wrote: > All this reminds me of the original cray supercomputers. They didn't > use twos compliment for integers so they had two representations of zero > (+0 and -0). Made programming a bit tricky. While there is only one integer zero, I would like to point out that in floating point, there are usually two zeroes, -0.0 and +0.0, and that this is by design and a feature, not an accident or a bug. Well-written floating point functions should keep the sign when they underflow, e.g.: py> 1e-200 * 1e-200 0.0 py> 1e-200 * -1e-200 -0.0 and well-written functions should honour those separate zeroes because sometimes it makes a difference. -- Steven From torriem at gmail.com Fri Feb 24 18:16:47 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 Feb 2012 16:16:47 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> Message-ID: <4F481A5F.4080601@gmail.com> On 02/24/2012 09:59 AM, Mark Lawrence wrote: > The C integer bit doesn't matter since e.g. > >>> > a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > >>> a > 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L > > And no, I'm not going to calculate how much memory I'd need to store a > string that's this long :) Sure but that doesn't answer the question posed. How does Rick plan to represent an infinite integer? Obviously you've shown that with an infinite amount of memory we could do it quite easily. But baring that, how does Rick suggest we should represent an infinite integer? From rosuav at gmail.com Fri Feb 24 19:09:00 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 11:09:00 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: On Sat, Feb 25, 2012 at 10:16 AM, Michael Torrie wrote: > Sure but that doesn't answer the question posed. ?How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. ?But baring that, > how does Rick suggest we should represent an infinite integer? Barring a suggestion from Rick, I think we should define the number 8 to be greater than all other integers. After all, Rick's very much in favour of evolution, and what would better depict the evolution of this glorious language than this notation, showing that the infinity symbol is now walking erect! ChrisA From breamoreboy at yahoo.co.uk Fri Feb 24 19:35:43 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:35:43 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: On 24/02/2012 23:16, Michael Torrie wrote: > On 02/24/2012 09:59 AM, Mark Lawrence wrote: >> The C integer bit doesn't matter since e.g. >> >>> >> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >> >>> a >> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L >> >> And no, I'm not going to calculate how much memory I'd need to store a >> string that's this long :) > > Sure but that doesn't answer the question posed. How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. But baring that, > how does Rick suggest we should represent an infinite integer? I understand that a Python integer can run to infinity. Quite how the illustrious rr manages to test for the length of a string that's already used all of the memory on his system has baffled me, but I'm sure that all the people who frequent this list with their Phds, MScs or whatever will soon correct me. -- Cheers. Mark Lawrence. From python at mrabarnett.plus.com Fri Feb 24 19:37:58 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 25 Feb 2012 00:37:58 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: <4F482D66.1070307@mrabarnett.plus.com> On 24/02/2012 23:16, Michael Torrie wrote: > On 02/24/2012 09:59 AM, Mark Lawrence wrote: >> The C integer bit doesn't matter since e.g. >> >>> >> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >> >>> a >> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L >> >> And no, I'm not going to calculate how much memory I'd need to store a >> string that's this long :) > > Sure but that doesn't answer the question posed. How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. But baring that, > how does Rick suggest we should represent an infinite integer? We already have arbitrarily long ints, so there could be a special infinite int singleton (actually, 2 of them, one positive, the other negative). From breamoreboy at yahoo.co.uk Fri Feb 24 19:39:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:39:39 +0000 Subject: namespace question In-Reply-To: <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24/02/2012 22:25, Steven D'Aprano wrote: > On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: > >> Your code updated to show the difference between a variable, a class >> variable, and an instance variable. > > The preferred terms in Python circles are class and instance > *attributes*, not variables. > > An integer variable is a variable holding an integer. > > A string variable is a variable holding a string. > > A list variable is a variable holding a list. > > Therefore a class variable is a variable holding a class, and an instance > variable is a variable holding an instance. > > Yes, in Python, classes and types are first-class objects (pun not > intended), and it is quite common to store them in variables: > > for cls in (int, float, Decimal, Fraction, myint, myfloat): > do_something_with(cls) > > > Other languages may choose to use illogical terminology if they choose. > Surely you mean names, not variables? :) -- Cheers. Mark Lawrence. From breamoreboy at yahoo.co.uk Fri Feb 24 19:49:50 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:49:50 +0000 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24/02/2012 20:41, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano > wrote: >> Personally, I prefer tabs for theoretical reasons and spaces for >> practical ones. I think that the world would be better off if we all >> standardised on tabs instead of spaces, but since that's not going to >> happen, I can interoperate better with the mass of broken tools out >> there, and with other people, by using spaces. >> > > At work, since we have a fairly small core of developers, we > standardized on tabs - mainly because of a couple of devs who > disagreed on how much indentation looked right (I'm of the opinion > that 1 space is insufficient), and having tab characters in the file > allows us to configure our editors differently. I'm definitely in > favour of using tabs where possible, but if you can't close your > environment, spaces are far safer. > > ChrisA Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. OTOH if that's your standard and you stick to it fine. What I can't stand is the "I've always done it this way an I ain't movin jus cos sum standard says so" attitude. Yes I have seen this in real life and the person responsible should be sacked. -- Cheers. Mark Lawrence. From fayaz.yusuf.khan at gmail.com Fri Feb 24 20:22:09 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Sat, 25 Feb 2012 06:52:09 +0530 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F482D66.1070307@mrabarnett.plus.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: <1480058.hmTgWxRlXu@dextop08> On Saturday 25 Feb 2012 12:37:58 AM MRAB wrote: > We already have arbitrarily long ints, so there could be a special > infinite int singleton (actually, 2 of them, one positive, the other > negative). Seconded. Although would a wish request to bugs.python.org saying "Allow storage of the integer infinity" make any sense to the developers? :P -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From rosuav at gmail.com Fri Feb 24 20:25:16 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 12:25:16 +1100 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: > Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. PEP 8 applies only to Python code, our standard is across all our languages :) But yes, I'm a horrible sinner and I like tabs. They separate the display (do you want tabs to show as four-space indent, two-centimeter indent, or fifty-pixel indent?) from the structure (this line is indented two levels). Spaces merge those. ChrisA From ian.g.kelly at gmail.com Fri Feb 24 20:26:42 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 24 Feb 2012 18:26:42 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: On Fri, Feb 24, 2012 at 10:32 AM, Devin Jeanpierre wrote: > On Fri, Feb 24, 2012 at 9:25 AM, Neil Cerutti wrote: >> The only time I've naively pined for such a thing is when >> misapplying C idioms for finding a minimum value. >> >> Python provides an excellent min implementation to use instead. > > min can be a little inconvenient. As soon as anything complicated has > to be done during the min expression, you need to switch to using > something else for sanity's sake. In that vein, I do actually > sometimes use float('inf') (for numbers), or a custom max/min object. > > ---- > > Silly and completely nonserious addendum: > > Forgive me, I have spoken in error! min is the one true way, for you > can still do it with a little wrangling, as follows: > > ? ?@operator.itemgetter(1) > ? ?@min > ? ?@apply > ? ?def closest_object(): > ? ? ? ?for x in xrange(board_width) > ? ? ? ? ? ?for y in xrange(board_height): > ? ? ? ? ? ? ? ?try: > ? ? ? ? ? ? ? ? ? ?entity = board.get_entity(x, y) > ? ? ? ? ? ? ? ?except EntityNotFound: > ? ? ? ? ? ? ? ? ? ?pass > ? ? ? ? ? ? ? ?else: > ? ? ? ? ? ? ? ? ? ?yield distance(player.pos, entity.pos), entity Cute, but what's so terrible about: def all_entities(): for x in xrange(board_width): for y in xrange(board_height): try: yield board.get_entity(x, y) except EntityNotFound: pass closest_object = min(all_entities, key=lambda e: distance(player.pos, e.pos)) Especially given that all_entities should be reusable in other contexts. Cheers, Ian From steve+comp.lang.python at pearwood.info Fri Feb 24 20:38:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 01:38:23 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f483b8f$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 00:39:39 +0000, Mark Lawrence wrote: > On 24/02/2012 22:25, Steven D'Aprano wrote: >> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: >> >>> Your code updated to show the difference between a variable, a class >>> variable, and an instance variable. >> >> The preferred terms in Python circles are class and instance >> *attributes*, not variables. >> >> An integer variable is a variable holding an integer. >> >> A string variable is a variable holding a string. >> >> A list variable is a variable holding a list. >> >> Therefore a class variable is a variable holding a class, and an >> instance variable is a variable holding an instance. >> >> Yes, in Python, classes and types are first-class objects (pun not >> intended), and it is quite common to store them in variables: >> >> for cls in (int, float, Decimal, Fraction, myint, myfloat): >> do_something_with(cls) >> >> >> Other languages may choose to use illogical terminology if they choose. >> >> > Surely you mean names, not variables? :) Well yes, I do, but the idea of classes being first class objects is radical enough to some people without also introducing them to the idea that there are no variables at all! I'm very aware that name binding is not quite the same as variables in some other languages, but the difference is subtle and doesn't mean that the term "variable" is owned by Pascal- or C-like languages. It just means that, like most computer science terms, "variable" has subtle differences from implementation to implementation. -- Steven From steve+comp.lang.python at pearwood.info Fri Feb 24 20:50:02 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 01:50:02 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 06:52:09 +0530, Fayaz Yusuf Khan wrote: > On Saturday 25 Feb 2012 12:37:58 AM MRAB wrote: >> We already have arbitrarily long ints, so there could be a special >> infinite int singleton (actually, 2 of them, one positive, the other >> negative). > Seconded. Although would a wish request to bugs.python.org saying "Allow > storage of the integer infinity" make any sense to the developers? :P If you explained it as a pair of special int values, INF and -INF, rather than the storage of an infinite-sized integer, it would make perfect sense. But it would also be rejected, and rightly so, as unnecessary complexity for the int type. There are already Decimal and float infinities, just use one of them. Or make your own, it's not difficult. Publish it on ActiveState, and if people flock to use it, then you will have a good argument that this is useful and should be part of the Python built-ins. -- Steven From d at davea.name Fri Feb 24 21:36:41 2012 From: d at davea.name (Dave Angel) Date: Fri, 24 Feb 2012 21:36:41 -0500 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F484939.40107@davea.name> On 02/24/2012 08:25 PM, Chris Angelico wrote: > On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: >> Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. > PEP 8 applies only to Python code, our standard is across all our > languages :) But yes, I'm a horrible sinner and I like tabs. They > separate the display (do you want tabs to show as four-space indent, > two-centimeter indent, or fifty-pixel indent?) from the structure > (this line is indented two levels). Spaces merge those. > > ChrisA If tabs were ever implemented consistently and reasonably in both an editor and a matching language, then I'd consider leaving tabs in the file. But to me, they're just a crude way to compress the file, and the space they save is no longer worth the pain they cause (I came to this conclusion 30 years ago, and have re-evaluated it dozens of times as new editors and new languages changed the rules. At that time, I had one of my developers write an editor (shipped with our MSDOS system, instead of Edlin) that implemented it.) Some time when i have a lot more time, I'll state one of (many possible) the ways that tabs could be made acceptable in a limited environment. Almost 40 years ago, I wrote an editor and assembler whose file format used a separation character between fields. I used A0 because our screens at the time ignored the high bit, so a file was sort-of readable right out of the box. And the way that the developer jumped between fields was the semi-colon key, of course, since that's the position of the skip key in the keypunch we were replacing. However, I don't intend to foist my opinions on others, just to state them as opinions. At the office, we use special comment fields at end-of-file to tell Emacs how to deal with a mixture of tabs and spaces. Code written by a dozen people over a dozen years, and nobody wanted to enforce a conversion to something common. -- DaveA From jason at powerpull.net Fri Feb 24 22:17:07 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 24 Feb 2012 20:17:07 -0700 Subject: SSL on 3.2.2 Message-ID: Hello, attempting to build from source on Ubuntu 11.10. Before running ./configure I had set this in Modules/Setup.dist: SSL=/usr/lib/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto $ ll /usr/lib/ssl total 4 lrwxrwxrwx 1 root root 14 2012-02-20 17:58 certs -> /etc/ssl/certs drwxr-xr-x 2 root root 4096 2012-02-20 18:32 misc lrwxrwxrwx 1 root root 20 2012-02-08 18:04 openssl.cnf -> /etc/ssl/openssl.cnf lrwxrwxrwx 1 root root 16 2012-02-20 17:58 private -> /etc/ssl/private $ /opt/python/bin/python3 Python 3.2.2 (default, Feb 24 2012, 20:07:04) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ssl Traceback (most recent call last): File "", line 1, in File "/opt/python/lib/python3.2/ssl.py", line 60, in import _ssl # if we can't import it, let the error propagate ImportError: No module named _ssl From WolfgangMeiners01 at web.de Sat Feb 25 03:18:51 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sat, 25 Feb 2012 09:18:51 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Am 24.02.12 14:37, schrieb Rick Johnson: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! > > > If there is no limit for len(string), why not simply use # get_limit() returns None if there is no limit maxlength = get_limit() if maxlength and (len(string) <= maxlength): allow_passage() else: deny_passage() Wolfgang From sarabareilles996 at gmail.com Sat Feb 25 08:35:05 2012 From: sarabareilles996 at gmail.com (sara bareilles) Date: Sat, 25 Feb 2012 05:35:05 -0800 (PST) Subject: Implement On These Points And Be Safe Message-ID: <986d2a1e-eef7-4613-a3a9-8ae6933b67f4@9g2000yqo.googlegroups.com> Implement On These Points And Be Safe Driving a motor vehicle is very sensitive and tremendous responsibility. As per National Highway Traffic Safety Administration (2008 Traffic Safety Annual Assessment), in a single year there were about over ... http://www.info-world-mania.com/ From amruthang.28 at gmail.com Sat Feb 25 08:48:23 2012 From: amruthang.28 at gmail.com (amrutha ng) Date: Sat, 25 Feb 2012 05:48:23 -0800 (PST) Subject: DATA ENTRY, FORM FILLING AND BPO SERVICES Message-ID: <59fa717f-b435-4ef7-9b6f-164a30788144@b23g2000yqn.googlegroups.com> DATA ENTRY, FORM FILLING AND BPO SERVICES available here http://www.wincon.co.in From tymoteusz.jankowski at gmail.com Sat Feb 25 09:47:17 2012 From: tymoteusz.jankowski at gmail.com (XLiIV) Date: Sat, 25 Feb 2012 06:47:17 -0800 (PST) Subject: Python packaging usabilty (distutils) - automatic downloading required packages Message-ID: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> There is many packaging solutions for python. I was confused about that but it's nothing. I had to pick one of them. I picked distutils because it's part of standard python since 3.3, am i right? My goal is to write setup.py with this feature: 'download required package if not installed already, like sqlalchemy'. How can I achieve that with DISTUTILS? I found out that is not possible, seriously? I can't believe that. It's basic function, I think. Do I really switch to setuptools? From stefan_ml at behnel.de Sat Feb 25 10:29:45 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 25 Feb 2012 16:29:45 +0100 Subject: Python packaging usabilty (distutils) - automatic downloading required packages In-Reply-To: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> References: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> Message-ID: XLiIV, 25.02.2012 15:47: > There is many packaging solutions for python. > I was confused about that but it's nothing. I had to pick one of them. > I picked distutils because it's part of standard python since 3.3, am > i right? Distutils has been part of Python's stdlib for ages. > My goal is to write setup.py with this feature: 'download required > package if not installed already, like sqlalchemy'. > How can I achieve that with DISTUTILS? > I found out that is not possible, seriously? I can't believe that. > It's basic function, I think. > Do I really switch to setuptools? No, use "distribute" instead. Stefan From storchaka at gmail.com Sat Feb 25 10:32:15 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 25 Feb 2012 17:32:15 +0200 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F482D66.1070307@mrabarnett.plus.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: 25.02.12 02:37, MRAB ???????(??): > We already have arbitrarily long ints, so there could be a special > infinite int singleton (actually, 2 of them, one positive, the other > negative). float('inf') and float('-inf'). From devipriya0010 at gmail.com Sat Feb 25 11:45:36 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Sat, 25 Feb 2012 08:45:36 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... http://123maza.com/46/dos754/ Message-ID: <44fea9ed-0af5-4b87-827f-795dfc362e81@w27g2000yqm.googlegroups.com> http://123maza.com/46/dos754/ From hubbard.jeffrey at ymail.com Sat Feb 25 12:24:45 2012 From: hubbard.jeffrey at ymail.com (Jeffrey Hubbard) Date: Sat, 25 Feb 2012 09:24:45 -0800 (PST) Subject: importing python modules from java Message-ID: <1330190685.16162.YahooMailNeo@web120906.mail.ne1.yahoo.com> Hello, I have written a c++ library which embeds python functions as described in http://docs.python.org/extending/embedding.html. Everything works fine, I can import and use modules such as numpy by calling PyImport_ImportModule(...). Now I wrapped this c++ library for java using SWIG. However, when running inside this wrapper, an attempt to import numpy fails: ? PyObject *numpy_module = PyImport_ImportModule("numpy"); returns NULL for numpy_module. I guess I have a similar problem as described in http://www.ibm.com/developerworks/aix/library/au-integratepython.html. It seems that since python 2.3 it is complicated to nest a module import in an embedded python environment. I don't understand the details of their explanations and I cannot use their solution to simulate the java executable, because the library is supposed to be part of an existing java framework. Is there a possibility to import numpy from python2.6, embedded in a c++ library, which is dynamically loaded from java? I am working on Debian linux, if this matters. Regards Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sat Feb 25 12:54:56 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 25 Feb 2012 17:54:56 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <4F492070.2080305@mrabarnett.plus.com> On 25/02/2012 08:18, Wolfgang Meiners wrote: > Am 24.02.12 14:37, schrieb Rick Johnson: >> I get sick and tired of doing this!!! >> >> if maxlength == UNLIMITED: >> allow_passage() >> elif len(string)> maxlength: >> deny_passage() >> >> What Python needs is some constant that can be compared to ANY numeric >> type and that constant will ALWAYS be larger! >> >> >> > If there is no limit for len(string), why not simply use > > # get_limit() returns None if there is no limit > maxlength = get_limit() > if maxlength and (len(string)<= maxlength): > allow_passage() > else: > deny_passage() > That should be: if maxlength is not None and len(string) <= maxlength: From benjamin at python.org Sat Feb 25 12:56:15 2012 From: benjamin at python.org (Benjamin Peterson) Date: Sat, 25 Feb 2012 12:56:15 -0500 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 Message-ID: We're pleased to announce the immediate availability of release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . The main impetus for these releases is fixing a security issue in Python's hash based types, dict and set, as described below. Python 2.7.3 and 3.2.3 include the security patch and the normal set of bug fixes. Since Python 2.6 and 3.1 are maintained only for security issues, 2.6.8 and 3.1.5 contain only various security patches. The security issue exploits Python's dict and set implementations. Carefully crafted input can lead to extremely long computation times and denials of service. [1] Python dict and set types use hash tables to provide amortized constant time operations. Hash tables require a well-distributed hash function to spread data evenly across the hash table. The security issue is that an attacker could compute thousands of keys with colliding hashes; this causes quadratic algorithmic complexity when the hash table is constructed. To alleviate the problem, the new releases add randomization to the hashing of Python's string types (bytes/str in Python 3 and str/unicode in Python 2), datetime.date, and datetime.datetime. This prevents an attacker from computing colliding keys of these types without access to the Python process. Hash randomization causes the iteration order of dicts and sets to be unpredictable and differ across Python runs. Python has never guaranteed iteration order of keys in a dict or set, and applications are advised to never rely on it. Historically, dict iteration order has not changed very often across releases and has always remained consistent between successive executions of Python. Thus, some existing applications may be relying on dict or set ordering. Because of this and the fact that many Python applications which don't accept untrusted input are not vulnerable to this attack, in all stable Python releases mentioned here, HASH RANDOMIZATION IS DISABLED BY DEFAULT. There are two ways to enable it. The -R commandline option can be passed to the python executable. It can also be enabled by setting an environmental variable PYTHONHASHSEED to "random". (Other values are accepted, too; pass -h to python for complete description.) More details about the issue and the patch can be found in the oCERT advisory [1] and the Python bug tracker [2]. These releases are releases candidates and thus not recommended for production use. Please test your applications and libraries with them, and report any bugs you encounter. We are especially interested in any buggy behavior observed using hash randomization. Excepting major calamity, final versions should appear after several weeks. Downloads are at http://python.org/download/releases/2.6.8/ http://python.org/download/releases/2.7.3/ http://python.org/download/releases/3.1.5/ http://python.org/download/releases/3.2.3/ Please test these candidates and report bugs to http://bugs.python.org/ With regards, The Python release team Barry Warsaw (2.6), Georg Brandl (3.2), Benjamin Peterson (2.7 and 3.1) [1] http://www.ocert.org/advisories/ocert-2011-003.html [2] http://bugs.python.org/issue13703 From toby at tobiah.org Sat Feb 25 12:56:49 2012 From: toby at tobiah.org (Tobiah) Date: Sat, 25 Feb 2012 09:56:49 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: > For every floating point > number there is a corresponding real number, but 0% of real numbers > can be represented exactly by floating point numbers. It seems to me that there are a great many real numbers that can be represented exactly by floating point numbers. The number 1 is an example. I suppose that if you divide that count by the infinite count of all real numbers, you could argue that the result is 0%. From tim.wintle at teamrubber.com Sat Feb 25 14:08:47 2012 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sat, 25 Feb 2012 19:08:47 +0000 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: <1330196927.17481.2.camel@tim-laptop> On Sat, 2012-02-25 at 09:56 -0800, Tobiah wrote: > > For every floating point > > number there is a corresponding real number, but 0% of real numbers > > can be represented exactly by floating point numbers. > > It seems to me that there are a great many real numbers that can be > represented exactly by floating point numbers. The number 1 is an > example. > > I suppose that if you divide that count by the infinite count of all > real numbers, you could argue that the result is 0%. It's not just an argument - it's mathematically correct. The same can be said for ints representing the natural numbers, or positive integers. However, ints can represent 100% of integers within a specific range, where floats can't represent all real numbers for any range (except for the empty set) - because there's an infinate number of real numbers within any non-trivial range. Tim From rantingrickjohnson at gmail.com Sat Feb 25 15:25:02 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:25:02 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: <8a6f287c-ba7c-462d-b445-433eb3d9a01d@f2g2000yqh.googlegroups.com> On Feb 24, 6:35?pm, Mark Lawrence wrote: > I understand that a Python integer can run to infinity. ?Quite how the > illustrious rr manages to test for the length of a string that's already > used all of the memory on his system has baffled me, When did i ever say that i would need a string who's length is INFINITY? In fact, i don't. My example was just that, as SIMPLIFIED example of the problem that was the genesis of my question. In my "real world" problem, i don't expect the string to EVER be more than double digits in length. But as any good programmer knows, you never want to solve problems as globally as possible. I need to do comparisons on strings now, but maybe integers later, or who knows. INFINITY comparisons are useful in many places. > but I'm sure that > all the people who frequent this list with their Phds, MScs or whatever > will soon correct me. I don't believe you'd need a Phd to understand my problem. From rantingrickjohnson at gmail.com Sat Feb 25 15:29:45 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:29:45 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> On Feb 24, 7:50?pm, Steven D'Aprano wrote: > But it would also be rejected, and rightly so, as unnecessary complexity > for the int type. There are already Decimal and float infinities, just > use one of them. Sure there are float INFINITIES that work fine for ints and floats, but where is the consistency? INFINITY need not be a int or a float or a str, or whatever. All it need be is a an object who always returns itself as being larger in any comparison. > Or make your own, it's not difficult. INFINITY should be at the very least a constant of the math module. From rantingrickjohnson at gmail.com Sat Feb 25 15:35:52 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:35:52 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> On Feb 25, 11:54?am, MRAB wrote: > [...] > That should be: > if maxlength is not None and len(string) <= maxlength: Using "imaginary" infinity values defiles the intuitive nature of your code. What is more intuitive? def confine_length(string, maxlength=INFINITY): if string.length < maxlength: do_something() def confine_length(string, maxlength=None): if maxlength is not None and len(string) <= maxlength: do_something() From tjreedy at udel.edu Sat Feb 25 16:05:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 25 Feb 2012 16:05:05 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On 2/25/2012 12:56 PM, Tobiah wrote: > It seems to me that there are a great many real numbers that can be > represented exactly by floating point numbers. The number 1 is an > example. Binary floats can represent and integer and any fraction with a denominator of 2**n within certain ranges. For decimal floats, substitute 10**n or more exactly, 2**j * 5**k since if J < k, n / (2**j * 5**k) = (n * 2**(k-j)) / 10**k and similarly if j > k. -- Terry Jan Reedy From Joshua.R.English at gmail.com Sat Feb 25 16:20:52 2012 From: Joshua.R.English at gmail.com (Josh English) Date: Sat, 25 Feb 2012 13:20:52 -0800 (PST) Subject: Udacity CS 101 Message-ID: <28556790.1352.1330204852864.JavaMail.geo-discussion-forums@pbgq3> Has anyone here looked at Udacity's open CS101 course (http://www.udacity.com/overview/Course/cs101) that started this week? The goal of the seven week course is to build a web crawler. So far, I'm not impressed with the speed or content of the course. I was wondering what anyone here may think of it. From wxjmfauth at gmail.com Sat Feb 25 16:25:37 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sat, 25 Feb 2012 13:25:37 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: >>> (2.0).hex() '0x1.0000000000000p+1' >>> (4.0).hex() '0x1.0000000000000p+2' >>> (1.5).hex() '0x1.8000000000000p+0' >>> (1.1).hex() '0x1.199999999999ap+0' >>> jmf From richardbp at gmail.com Sat Feb 25 16:44:16 2012 From: richardbp at gmail.com (Richard Baron Penman) Date: Sun, 26 Feb 2012 08:44:16 +1100 Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: >> I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. > > Well, actually I do/did. ah OK. I had read this comment from a few years back: "IIRC, there was a threat to remove asyncore because there were no maintainers, no one was fixing bugs, no one was improving it, and no one was really using it" > Point with asyncore/asynchat is that it's original design is so flawed > and simplicistic it doesn't allow actual customization without > breaking compatibility. Python3 uses the same API - was there not enough interest to improve it? Richard From steve+comp.lang.python at pearwood.info Sat Feb 25 17:51:33 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 22:51:33 GMT Subject: Python math is off by .000000000000045 References: Message-ID: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>> (2.0).hex() > '0x1.0000000000000p+1' >>>> (4.0).hex() > '0x1.0000000000000p+2' >>>> (1.5).hex() > '0x1.8000000000000p+0' >>>> (1.1).hex() > '0x1.199999999999ap+0' >>>> >>>> > jmf What's your point? I'm afraid my crystal ball is out of order and I have no idea whether you have a question or are just demonstrating your mastery of copy and paste from the Python interactive interpreter. -- Steven From sdl.web at gmail.com Sat Feb 25 20:33:15 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 09:33:15 +0800 Subject: webbrowser.open always opens up Safari on Lion Message-ID: Hello, On Lion and with its stock python version 2.7.1 r271:86832, webbrowser.open('file://localhost/nonexistingfile') always opens up Safari. Is this a bug? Leo From jeanpierreda at gmail.com Sat Feb 25 21:49:59 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 25 Feb 2012 21:49:59 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: <1330196927.17481.2.camel@tim-laptop> References: <1330196927.17481.2.camel@tim-laptop> Message-ID: On Sat, Feb 25, 2012 at 2:08 PM, Tim Wintle wrote: > > It seems to me that there ?are a great many real numbers that can be > > represented exactly by floating point numbers. ?The number 1 is an > > example. > > > > I suppose that if you divide that count by the infinite count of all > > real numbers, you could argue that the result is 0%. > > It's not just an argument - it's mathematically correct. ^ this The floating point numbers are a finite set. Any infinite set, even the rationals, is too big to have "many" floats relative to the whole, as in the percentage sense. ---- In fact, any number we can reasonably deal with must have some finite representation, even if the decimal expansion has an infinite number of digits. We can work with pi, for example, because there are algorithms that can enumerate all the digits up to some precision. But we can't really work with a number for which no algorithm can enumerate the digits, and for which there are infinitely many digits. Most (in some sense involving infinities, which is to say, one that is not really intuitive) of the real numbers cannot in any way or form be represented in a finite amount of space, so most of them can't be worked on by computers. They only exist in any sense because it's convenient to pretend they exist for mathematical purposes, not for computational purposes. What this boils down to is to say that, basically by definition, the set of numbers representable in some finite number of binary digits is countable (just count up in binary value). But the whole of the real numbers are uncountable. The hard part is then accepting that some countable thing is 0% of an uncountable superset. I don't really know of any "proof" of that latter thing, it's something I've accepted axiomatically and then worked out backwards from there. But surely it's obvious, somehow, that the set of finite strings is tiny compared to the set of infinite strings? If we look at binary strings, representing numbers, the reals could be encoded as the union of the two, and by far most of them would be infinite. Anyway, all that aside, the real numbers are kind of dumb. -- Devin From steve+comp.lang.python at pearwood.info Sat Feb 25 22:36:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 03:36:55 GMT Subject: webbrowser.open always opens up Safari on Lion References: Message-ID: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 09:33:15 +0800, Leo wrote: > Hello, > > On Lion and with its stock python version 2.7.1 r271:86832, > webbrowser.open('file://localhost/nonexistingfile') always opens up > Safari. Is this a bug? What part of this do you think is the bug, and why? What part of the behaviour actually experienced contradicts the documented behaviour of webbrowser.open()? http://docs.python.org/library/webbrowser.html -- Steven From anknguyen at gmail.com Sat Feb 25 22:38:25 2012 From: anknguyen at gmail.com (Anthony Nguyen) Date: Sat, 25 Feb 2012 22:38:25 -0500 Subject: webbrowser.open always opens up Safari on Lion In-Reply-To: References: Message-ID: If Safari is your default browser, Python will open the address in Safari. >From the Python docs: webbrowser.open(url[, new=0[, autoraise=True]]) Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (?tab?) is opened if possible. If autoraise is True, the window is raised if possible (note that under many window managers this will occur regardless of the setting of this variable). Note that on some platforms, trying to open a filename using this function, may work and start the operating system?s associated program. However, this is neither supported nor portable. On Sat, Feb 25, 2012 at 8:33 PM, Leo wrote: > > Hello, > > On Lion and with its stock python version 2.7.1 r271:86832, > webbrowser.open('file://localhost/nonexistingfile') always opens up > Safari. Is this a bug? > > Leo > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun Feb 26 00:44:08 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 00:44:08 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: <1330196927.17481.2.camel@tim-laptop> Message-ID: On 2/25/2012 9:49 PM, Devin Jeanpierre wrote: > What this boils down to is to say that, basically by definition, the > set of numbers representable in some finite number of binary digits is > countable (just count up in binary value). But the whole of the real > numbers are uncountable. The hard part is then accepting that some > countable thing is 0% of an uncountable superset. I don't really know > of any "proof" of that latter thing, it's something I've accepted > axiomatically and then worked out backwards from there. Informally, if the infinity of counts were some non-zero fraction f of the reals, then there would, in some sense, be 1/f times a many reals as counts, so the count could be expanded to count 1/f reals for each real counted before, and the reals would be countable. But Cantor showed that the reals are not countable. But as you said, this is all irrelevant for computing. Since the number of finite strings is practically finite, so is the number of algorithms. And even a countable number of algorithms would be a fraction 0, for instance, of the uncountable predicate functions on 0, 1, 2, ... . So we do what we actually can that is of interest. -- Terry Jan Reedy From sdl.web at gmail.com Sun Feb 26 01:23:43 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 14:23:43 +0800 Subject: webbrowser.open always opens up Safari on Lion References: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: > What part of this do you think is the bug, and why? What part of the > behaviour actually experienced contradicts the documented behaviour of > webbrowser.open()? > > http://docs.python.org/library/webbrowser.html If you have the default browser set to Chrome, it still opens up Safari. Leo From cs at zip.com.au Sun Feb 26 02:04:47 2012 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 26 Feb 2012 18:04:47 +1100 Subject: webbrowser.open always opens up Safari on Lion In-Reply-To: References: Message-ID: <20120226070447.GA8352@cskk.homeip.net> On 26Feb2012 14:23, Leo wrote: | On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: | > What part of this do you think is the bug, and why? What part of the | > behaviour actually experienced contradicts the documented behaviour of | > webbrowser.open()? | > | > http://docs.python.org/library/webbrowser.html | | If you have the default browser set to Chrome, it still opens up Safari. On the suppostion that "the default browser" is actually multiple settings, one for each of several URL (URI?) schemes, what do these two shell commands do for you? From a shell prompt in a Terminal: open file://localhost/nonexistingfile and open http://www.python.org/ Do they both open Chome for you? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ DRM doesn't inconvenience pirates ? indeed, over time it trains law-abiding users to become pirates out of sheer frustration. - Charles Stross From steve+comp.lang.python at pearwood.info Sun Feb 26 02:12:06 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 07:12:06 GMT Subject: webbrowser.open always opens up Safari on Lion References: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f49db46$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 14:23:43 +0800, Leo wrote: > On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: >> What part of this do you think is the bug, and why? What part of the >> behaviour actually experienced contradicts the documented behaviour of >> webbrowser.open()? >> >> http://docs.python.org/library/webbrowser.html > > If you have the default browser set to Chrome, it still opens up Safari. That would only be a bug if it occurs with http:// URLs. The documentation clearly says: Note that on some platforms, trying to open a filename using this function, may work and start the operating system?s associated program. However, this is neither supported nor portable. Since you are providing a file:// URL, then the behaviour is unspecified, and no, it is not a bug. Arguably it is a bug that file:// URLs work at all. However, I would guess that if you have a patch to fix this behaviour to something more reasonable (but what?) then it might be approved. Feel free to raise a ticket on the bug tracker. Personally, I'd put it down as a feature request rather than a bug. -- Steven From sdl.web at gmail.com Sun Feb 26 02:29:19 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 15:29:19 +0800 Subject: webbrowser.open always opens up Safari on Lion References: Message-ID: On 2012-02-26 15:04 +0800, Cameron Simpson wrote: > On the suppostion that "the default browser" is actually multiple > settings, one for each of several URL (URI?) schemes, what do these two > shell commands do for you? From a shell prompt in a Terminal: > > open file://localhost/nonexistingfile > and > open http://www.python.org/ > > Do they both open Chome for you? The first one prints: The file /nonexistingfile does not exist. No browser is opened. The second one opened Chrome. Leo From cv33cv33cv33 at gmail.com Sun Feb 26 03:22:31 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Sun, 26 Feb 2012 00:22:31 -0800 (PST) Subject: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM !!!!!!!!!!!!!! Message-ID: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM By: Dr Garry Miller: A very important Christian missionary converted to Islam and became a major herald for Islam, he was a very active missionary and was very knowledgeable about the Bible... This man likes mathematics so much, that's why he likes logic. One day, he decided to read the Quran to try to find any mistakes that he might take advantage of while inviting Muslims to convert to Christianity.... He expected the Koran to be an old book written 14 centuries ago, a book that talks about the desert and so on...He was amazed from what he found. He discovered that this Book had what no other book in the world has.... He expected to find some stories about the hard time that the Prophet Mohammad (Peace Be Upon Him) had, like the death of his wife Khadijah (may Allah be pleased with her) or the death of his sons and daughters...however, he did not find anything like that... and what made him even more confused is that he found a full "sura"(chapter) in the Koran named "Mary" that contains a lot of respect to Mary(peace be upon her) which is not the case even in the books written by Christians nor in their bibles. He did not find a Sura named after "Fatimah"(the prophet's daughter) nor "Aa?ishah"(the Prophet's wife), may Allah(God) be pleased with both of them. He also found that the name of Jesus(Peace Be Upon Him) was mentioned in the Koran 25 times while the name of "Mohammed"(Peace Be Upon Him) was mentioned only 4 times, so he became more confused. He started reading the Koran more thoroughly hoping to find a mistake but he was shocked when he read a great verse which is verse number 82 in Surat Al-Nisa'(Women) that says: ?Do they not consider the Koran (with care)? Had it been from other than Allah, they would surely have found therein much discrepancy?. Dr Miller says about this verse: ? One of the well known scientific principles is the principle of finding mistakes or looking for mistakes in a theory until it?s proved to be right (Falsification Test) ?what?s amazing is that the Holy Quran asks Muslims and non-muslims to try to find mistakes in this book and it tells them that they will never find any?. He also says about this verse: no writer in the world has the courage to write a book and say that it?s empty of mistakes, but the Quran, on the contrary, tells you that it has no mistakes and asks you to try to find one and you won?t find any. Another verse that Dr Miller reflected on for a long time is the verse number 30 in Surat ?Al-Anbiya??(The Prophets): ? Do not the Unbelievers see that the heavens and the earth were joined together (as one unit of Creation), before We clove them asunder? We made from water every living thing. Will they not then believe?? He says: ? This verse is exactly the subject of the scientific research that won the Noble prize in 1973 and was about the theory of the ?Great Explosion?. According to this theory, the universe was the result of a great explosion that leads to the formation of the universe with its skies and planets?. Dr Miller says: ? Now we come to what?s amazing about the Prophet Mohammed (PBUH) and what?s pretended about the devils helping him, God says: ?No evil ones have brought down this (Revelation), it would neither suit them nor would they be able (to produce it). Indeed they have been removed far from even (a chance of) hearing it? (26:210-212). ?When thou do read the Quran, seek Allah's protection from Satan the Rejected One? (16:98). You see? can this be the devil?s way to write a book? how can he write a book then tells you to ask God for protection from this devil before reading that book? those are miraculous verses in this miraculous book! and has a logical answer to those who pretend that it?s from the devil?. And among the stories that amazed Dr Miller is the story of the Prophet (PBUH) with Abu-Lahab? Dr Miller says: ? This man (Abu Lahab) used to hate Islam so much that he would go after the Prophet wherever he goes to humiliate him. If he saw the prophet talking to strangers, he used to wait till he finishes and then ask them: what did Mohammed tell you? If he said it?s white then it?s in reality black and if he said it?s night then it?s day. He meant to falsify all what the prophet says and to make people suspicious about it. And 10 years before the death of Abu Lahab, a sura was inspired to the prophet, named ?Al-Masad?. This sura tells that Abu Lahab will go to hell, in other words, it says that Abu Lahab will not convert to Islam. During 10 years, Abu Lahab could have said: ?Mohammed is saying that I will not become a Muslim and that I will go to the hell fire, but I?m telling you now that I want to convert to Islam and become a Muslim. What do you think about Mohammed now? Is he saying the truth or no? Does his inspiration come from God?? But Abu Lahab did not do that at all although he was disobeying the prophet in all matters, but not in this one. In other words, it was as if the prophet (PBUH) was giving Abu Lahab a chance to prove him wrong! But he did not do that during 10 whole years! he did not convert to Islam and did not even pretend to be a Muslim!! Throughout 10 years, he had the chance to destroy Islam in 1 minute! But this did not happen because those are not the words of Mohammed (PBUH) but the words of God Who knows what?s hidden and knows that Abu Lahab will not become a Muslim. How can the prophet (PBUH) know that Abu Lahab will prove what is said in that Sura if this was not inspiration from Allah? How can he be sure throughout 10 whole years that what he has (the Quran) is true if he did not know that it?s inspiration from Allah?? For a person to take such a risky challenge, this has only one meaning: that this is inspiration from God. ?Perish the hands of the Father of Flame (Abu Lahab)! perish he! No profit to him from all his wealth, and all his gains! Burnt soon will he be in a Fire of blazing Flame! His wife shall carry the (crackling) wood; As fuel! A twisted rope of palm-leaf fibre round her (own) neck!? (surat Al-Masad). Dr Miller says about a verse that amazed him: one of the miracles in the Quran is challenging the future with things that humans cannot predict and to which the ?Falsification Test? applies, this test consists of looking for mistakes until the thing that is being tested is proved to be right. For example, let?s see what the Quran said about the relation between Muslims and Jews. Quran says that Jews are the major enemies for Muslims and this is true until now as the main enemy for Muslims are the Jews. Dr Miller continues: this is considered a great challenge since the Jews have the chance to ruin Islam simply by treating Muslims in a friendly way for few years and then say: here we are treating you as friends and the Quran says that we are your enemies, the Quran must be wrong then! But this did not happen during 1400 years!! and it will never happen because those are the words of The One who knows the unseen (God) and not the words of humans. Dr Miller continues: can you see how the verse that talks about the enmity between Muslims and Jews constitutes a challenge to the human mind? ?Strongest among men in enmity to the Believers wilt thou find the Jews and Pagans; and nearest among them in love to the Believers wilt thou find those who say, "We are Christians": because amongst these are men devoted to learning and men who have renounced the world, and they are not arrogant. And when they listen to the revelation received by the Messenger, thou wilt see their eyes overflowing with tears, for they recognize the truth: they pray: "Our Lord! We believe; write us down among the witnesses? (5: 82-84) This verse applies to Dr Miller as he was a Christian but when he knew the truth, he believed and converted to Islam and became a herald. May Allah support him. Dr Miller says about the unique style of the Quran that he finds wonderful: no doubt there is something unique and amazing in Quran that is not present anywhere else, as the Quran gives you specific information and tells you that you did not know this before. For example: "This is part of the tidings of the things unseen, which We reveal unto thee (O Prophet!) by inspiration: thou was not with them when they cast lots with arrows, as to which of them should be charged with the care of Maryam: nor was thou with them when they disputed (the point)? (3: 44). ?Such are some of the stories of the Unseen, which We have revealed unto thee: before this, neither thou nor thy People knew them. So persevere patiently: for the End is for those who are righteous? (11: 49). ?Such is one of the stories of what happened unseen, which We reveal by inspiration unto thee: nor was thou (present) with them when they concerted their plans together in the process of weaving their plots? (12: 102) Dr Miller continues: ? No other holy book uses this style, all the other books consist of information that tells you where this information came from. For example, when the (distorted) holy bible talks about the stories of the ancient nations, it tells you that a this king lived in a this place and a that leader fought in that battle, and that a certain person had a number of kids and their names are?. But this book (distorted Bible) always tells you that if you want to know more, you can read a certain book since that information came from that book?. Dr Garry Miller continues: ?this is in contrary to the Quran which gives you the information and tells you that it?s new!! And what?s amazing is that the people of Mecca at that time -time of inspiration of those verses- used to hear those verses and the challenge that the information in those verses was new and was not known by Mohammed (PBUH) nor by his people at that time, and despite that, they never said: we know this and it is not new, and they did not say: we know where Mohammed came from with those verses. This never happened, but what happened is that nobody dared to say that he was lying to them because those was really new information, not coming from the human mind but from Allah who knows the unseen in the past, the present and the future?. May Allah reward Dr Miller for this nice reflection on the Book of Allah For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From cv33cv33cv33 at gmail.com Sun Feb 26 03:29:11 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Sun, 26 Feb 2012 00:29:11 -0800 (PST) Subject: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM !!!!!!!!!!!!!! Message-ID: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM By: Dr Garry Miller: A very important Christian missionary converted to Islam and became a major herald for Islam, he was a very active missionary and was very knowledgeable about the Bible... This man likes mathematics so much, that's why he likes logic. One day, he decided to read the Quran to try to find any mistakes that he might take advantage of while inviting Muslims to convert to Christianity.... He expected the Koran to be an old book written 14 centuries ago, a book that talks about the desert and so on...He was amazed from what he found. He discovered that this Book had what no other book in the world has.... He expected to find some stories about the hard time that the Prophet Mohammad (Peace Be Upon Him) had, like the death of his wife Khadijah (may Allah be pleased with her) or the death of his sons and daughters...however, he did not find anything like that... and what made him even more confused is that he found a full "sura"(chapter) in the Koran named "Mary" that contains a lot of respect to Mary(peace be upon her) which is not the case even in the books written by Christians nor in their bibles. He did not find a Sura named after "Fatimah"(the prophet's daughter) nor "Aa?ishah"(the Prophet's wife), may Allah(God) be pleased with both of them. He also found that the name of Jesus(Peace Be Upon Him) was mentioned in the Koran 25 times while the name of "Mohammed"(Peace Be Upon Him) was mentioned only 4 times, so he became more confused. He started reading the Koran more thoroughly hoping to find a mistake but he was shocked when he read a great verse which is verse number 82 in Surat Al-Nisa'(Women) that says: ?Do they not consider the Koran (with care)? Had it been from other than Allah, they would surely have found therein much discrepancy?. Dr Miller says about this verse: ? One of the well known scientific principles is the principle of finding mistakes or looking for mistakes in a theory until it?s proved to be right (Falsification Test) ?what?s amazing is that the Holy Quran asks Muslims and non-muslims to try to find mistakes in this book and it tells them that they will never find any?. He also says about this verse: no writer in the world has the courage to write a book and say that it?s empty of mistakes, but the Quran, on the contrary, tells you that it has no mistakes and asks you to try to find one and you won?t find any. Another verse that Dr Miller reflected on for a long time is the verse number 30 in Surat ?Al-Anbiya??(The Prophets): ? Do not the Unbelievers see that the heavens and the earth were joined together (as one unit of Creation), before We clove them asunder? We made from water every living thing. Will they not then believe?? He says: ? This verse is exactly the subject of the scientific research that won the Noble prize in 1973 and was about the theory of the ?Great Explosion?. According to this theory, the universe was the result of a great explosion that leads to the formation of the universe with its skies and planets?. Dr Miller says: ? Now we come to what?s amazing about the Prophet Mohammed (PBUH) and what?s pretended about the devils helping him, God says: ?No evil ones have brought down this (Revelation), it would neither suit them nor would they be able (to produce it). Indeed they have been removed far from even (a chance of) hearing it? (26:210-212). ?When thou do read the Quran, seek Allah's protection from Satan the Rejected One? (16:98). You see? can this be the devil?s way to write a book? how can he write a book then tells you to ask God for protection from this devil before reading that book? those are miraculous verses in this miraculous book! and has a logical answer to those who pretend that it?s from the devil?. And among the stories that amazed Dr Miller is the story of the Prophet (PBUH) with Abu-Lahab? Dr Miller says: ? This man (Abu Lahab) used to hate Islam so much that he would go after the Prophet wherever he goes to humiliate him. If he saw the prophet talking to strangers, he used to wait till he finishes and then ask them: what did Mohammed tell you? If he said it?s white then it?s in reality black and if he said it?s night then it?s day. He meant to falsify all what the prophet says and to make people suspicious about it. And 10 years before the death of Abu Lahab, a sura was inspired to the prophet, named ?Al-Masad?. This sura tells that Abu Lahab will go to hell, in other words, it says that Abu Lahab will not convert to Islam. During 10 years, Abu Lahab could have said: ?Mohammed is saying that I will not become a Muslim and that I will go to the hell fire, but I?m telling you now that I want to convert to Islam and become a Muslim. What do you think about Mohammed now? Is he saying the truth or no? Does his inspiration come from God?? But Abu Lahab did not do that at all although he was disobeying the prophet in all matters, but not in this one. In other words, it was as if the prophet (PBUH) was giving Abu Lahab a chance to prove him wrong! But he did not do that during 10 whole years! he did not convert to Islam and did not even pretend to be a Muslim!! Throughout 10 years, he had the chance to destroy Islam in 1 minute! But this did not happen because those are not the words of Mohammed (PBUH) but the words of God Who knows what?s hidden and knows that Abu Lahab will not become a Muslim. How can the prophet (PBUH) know that Abu Lahab will prove what is said in that Sura if this was not inspiration from Allah? How can he be sure throughout 10 whole years that what he has (the Quran) is true if he did not know that it?s inspiration from Allah?? For a person to take such a risky challenge, this has only one meaning: that this is inspiration from God. ?Perish the hands of the Father of Flame (Abu Lahab)! perish he! No profit to him from all his wealth, and all his gains! Burnt soon will he be in a Fire of blazing Flame! His wife shall carry the (crackling) wood; As fuel! A twisted rope of palm-leaf fibre round her (own) neck!? (surat Al-Masad). Dr Miller says about a verse that amazed him: one of the miracles in the Quran is challenging the future with things that humans cannot predict and to which the ?Falsification Test? applies, this test consists of looking for mistakes until the thing that is being tested is proved to be right. For example, let?s see what the Quran said about the relation between Muslims and Jews. Quran says that Jews are the major enemies for Muslims and this is true until now as the main enemy for Muslims are the Jews. Dr Miller continues: this is considered a great challenge since the Jews have the chance to ruin Islam simply by treating Muslims in a friendly way for few years and then say: here we are treating you as friends and the Quran says that we are your enemies, the Quran must be wrong then! But this did not happen during 1400 years!! and it will never happen because those are the words of The One who knows the unseen (God) and not the words of humans. Dr Miller continues: can you see how the verse that talks about the enmity between Muslims and Jews constitutes a challenge to the human mind? ?Strongest among men in enmity to the Believers wilt thou find the Jews and Pagans; and nearest among them in love to the Believers wilt thou find those who say, "We are Christians": because amongst these are men devoted to learning and men who have renounced the world, and they are not arrogant. And when they listen to the revelation received by the Messenger, thou wilt see their eyes overflowing with tears, for they recognize the truth: they pray: "Our Lord! We believe; write us down among the witnesses? (5: 82-84) This verse applies to Dr Miller as he was a Christian but when he knew the truth, he believed and converted to Islam and became a herald. May Allah support him. Dr Miller says about the unique style of the Quran that he finds wonderful: no doubt there is something unique and amazing in Quran that is not present anywhere else, as the Quran gives you specific information and tells you that you did not know this before. For example: "This is part of the tidings of the things unseen, which We reveal unto thee (O Prophet!) by inspiration: thou was not with them when they cast lots with arrows, as to which of them should be charged with the care of Maryam: nor was thou with them when they disputed (the point)? (3: 44). ?Such are some of the stories of the Unseen, which We have revealed unto thee: before this, neither thou nor thy People knew them. So persevere patiently: for the End is for those who are righteous? (11: 49). ?Such is one of the stories of what happened unseen, which We reveal by inspiration unto thee: nor was thou (present) with them when they concerted their plans together in the process of weaving their plots? (12: 102) Dr Miller continues: ? No other holy book uses this style, all the other books consist of information that tells you where this information came from. For example, when the (distorted) holy bible talks about the stories of the ancient nations, it tells you that a this king lived in a this place and a that leader fought in that battle, and that a certain person had a number of kids and their names are?. But this book (distorted Bible) always tells you that if you want to know more, you can read a certain book since that information came from that book?. Dr Garry Miller continues: ?this is in contrary to the Quran which gives you the information and tells you that it?s new!! And what?s amazing is that the people of Mecca at that time -time of inspiration of those verses- used to hear those verses and the challenge that the information in those verses was new and was not known by Mohammed (PBUH) nor by his people at that time, and despite that, they never said: we know this and it is not new, and they did not say: we know where Mohammed came from with those verses. This never happened, but what happened is that nobody dared to say that he was lying to them because those was really new information, not coming from the human mind but from Allah who knows the unseen in the past, the present and the future?. May Allah reward Dr Miller for this nice reflection on the Book of Allah For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From ben+python at benfinney.id.au Sun Feb 26 03:47:49 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 19:47:49 +1100 Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87y5rqrney.fsf@benfinney.id.au> Steven D'Aprano writes: > The preferred terms in Python circles are class and instance > *attributes*, not variables. Yes, full ACK. > An integer variable is a variable holding an integer. > A string variable is a variable holding a string. > A list variable is a variable holding a list. And Python has none of those. Its references don't ?hold? anything. I appreciate that you think ?variable? is a useful term in Python, but this kind of mangling of the concept convinces me that it's not worth it. Python doesn't have variables, and even if you want to say ?variables? when you mean ?references?, there's no such thing as a ?string variable? etc. in Python. References don't have types, so its needlessly confusing to perpetuate that kind of thinking. > Other languages may choose to use illogical terminology if they choose. Whereas we are not beholden to it, so let's avoid it where feasible, and help newcomers to do so. -- \ ?There is no reason anyone would want a computer in their | `\ home.? ?Ken Olson, president, chairman and founder of Digital | _o__) Equipment Corp., 1977 | Ben Finney From ben+python at benfinney.id.au Sun Feb 26 03:51:40 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 19:51:40 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: Message-ID: <87ty2ern8j.fsf@benfinney.id.au> Benjamin Peterson writes: > We're pleased to announce the immediate availability of release candidates for > Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . If you're pleased to announce their immediate availability, then please do that! Putting ?RELEASED? in the subject, when they're not released and are instead *candidates for* release, is confusing and muddies the issue of what you even mean by ?release?. -- \ ?Give a man a fish, and you'll feed him for a day; give him a | `\ religion, and he'll starve to death while praying for a fish.? | _o__) ?Anonymous | Ben Finney From rosuav at gmail.com Sun Feb 26 04:03:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Feb 2012 20:03:49 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87ty2ern8j.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: > Benjamin Peterson writes: > >> We're pleased to announce the immediate availability of release candidates for >> Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . > > If you're pleased to announce their immediate availability, then please > do that! Isn't it perfectly accurate to say that the RCs are now available? Considering that "Release candidates" immediately followed "RELEASED" in the subject line, I don't see any confusion. ChrisA From muthu17024 at gmail.com Sun Feb 26 04:29:10 2012 From: muthu17024 at gmail.com (muthu kutti) Date: Sun, 26 Feb 2012 01:29:10 -0800 (PST) Subject: python Message-ID: <72daafb9-95b1-4e22-ab2e-5833a71887d5@c21g2000yqi.googlegroups.com> http://123maza.com/46/glory687/ From wxjmfauth at gmail.com Sun Feb 26 04:59:14 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 26 Feb 2012 01:59:14 -0800 (PST) Subject: Python math is off by .000000000000045 References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 25 f?v, 23:51, Steven D'Aprano wrote: > On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: > >>>> (2.0).hex() > > '0x1.0000000000000p+1' > >>>> (4.0).hex() > > '0x1.0000000000000p+2' > >>>> (1.5).hex() > > '0x1.8000000000000p+0' > >>>> (1.1).hex() > > '0x1.199999999999ap+0' > > > jmf > > What's your point? I'm afraid my crystal ball is out of order and I have > no idea whether you have a question or are just demonstrating your > mastery of copy and paste from the Python interactive interpreter. > It should be enough to indicate the right direction for casual interested readers. From frank at chagford.com Sun Feb 26 05:42:18 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 12:42:18 +0200 Subject: Question about circular imports Message-ID: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to access something in Module B, and a method in Module B needs to access something in Module A. I know that the standard advice is to reorganise the code to avoid this, and I try to do this where possible, but for now I would like to address the question of how to handle the situation if this is otherwise unavoidable. The problem is clearly explained in the Python Programming FAQ - "Circular imports are fine where both modules use the "import " form of import. They fail when the 2nd module wants to grab a name out of the first ("from module import name") and the import is at the top level. That's because names in the 1st are not yet available, because the first module is busy importing the 2nd." Having recently reorganised my code into packages, I find that the same problem arises with packages. Assume the following structure, copied from the Tutorial - sound/ __init__.py formats/ __init__.py wavread.py wavwrite.py The following fails - in wavread.py - from formats import wavwrite [this works] in wavwrite.py - from formats import wavread [this fails with ImportError] I can think of two solutions - one is cumbersome, the other may not be good practice. The first solution is - in wavread.py - import formats.wavwrite in wavwrite.py - import formats.wavread I then have to use the full path to reference any attribute inside the imported module, which I find cumbersome. The second solution is - in formats/__init__.py import sys sys.path.insert(0, __path__[0]) in wavread.py - import wavwrite in wavwrite.py - import wavread This works, but I don't know if it is a good idea to add all the sub-package paths to sys.path. I realise that it is up to me to avoid any name clashes. Are there any other downsides? So I guess my question is - - is there a better solution to my problem? - if not, is my second solution acceptable? If not, I seem to be stuck with using full path names to reference any attributes in imported modules. I am using Python3 exclusively now, if that makes any difference. Any advice will be appreciated. Frank Millman From __peter__ at web.de Sun Feb 26 06:12:55 2012 From: __peter__ at web.de (Peter Otten) Date: Sun, 26 Feb 2012 12:12:55 +0100 Subject: Question about circular imports References: Message-ID: Frank Millman wrote: > I seem to have a recurring battle with circular imports, and I am trying > to nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is > to reorganise the code to avoid this, and I try to do this where possible, > but for now I would like to address the question of how to handle the > situation if this is otherwise unavoidable. To cut a long story short, why should circular imports be unavoidable? > The problem is clearly explained in the Python Programming FAQ - > > "Circular imports are fine where both modules use the "import " > form of import. They fail when the 2nd module wants to grab a name out of > the first ("from module import name") and the import is at the top level. > That's because names in the 1st are not yet available, because the first > module is busy importing the 2nd." > > Having recently reorganised my code into packages, I find that the same > problem arises with packages. Assume the following structure, copied from > the Tutorial - > > sound/ > __init__.py > formats/ > __init__.py > wavread.py > wavwrite.py > > The following fails - > > in wavread.py - > from formats import wavwrite [this works] > > in wavwrite.py - > from formats import wavread [this fails with ImportError] > > I can think of two solutions - one is cumbersome, the other may not be > good practice. > > The first solution is - > > in wavread.py - > import formats.wavwrite > > in wavwrite.py - > import formats.wavread This should be import sound.formats.wavread > I then have to use the full path to reference any attribute inside the > imported module, which I find cumbersome. > > The second solution is - > > in formats/__init__.py > import sys > sys.path.insert(0, __path__[0]) > > in wavread.py - > import wavwrite > > in wavwrite.py - > import wavread > > This works, but I don't know if it is a good idea to add all the > sub-package paths to sys.path. I realise that it is up to me to avoid any > name clashes. Are there any other downsides? > > So I guess my question is - > > - is there a better solution to my problem? > - if not, is my second solution acceptable? Paths into packages are recipe for desaster. You may end up with multiple instances of the same module and your programs will break in "interesting" (hard to debug) ways. > If not, I seem to be stuck with using full path names to reference any > attributes in imported modules. > > I am using Python3 exclusively now, if that makes any difference. > > Any advice will be appreciated. > > Frank Millman From frank at chagford.com Sun Feb 26 06:18:20 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 13:18:20 +0200 Subject: Question about circular imports References: Message-ID: "Frank Millman" wrote in message news:jid2a9$n21$1 at dough.gmane.org... > Hi all > > I seem to have a recurring battle with circular imports, and I am trying > to nail it once and for all. > [...] > > The second solution is - > > in formats/__init__.py > import sys > sys.path.insert(0, __path__[0]) > > in wavread.py - > import wavwrite > > in wavwrite.py - > import wavread > > This works, but I don't know if it is a good idea to add all the > sub-package paths to sys.path. I realise that it is up to me to avoid any > name clashes. Are there any other downsides? > Answering my own question, I have just found a downside that is a showstopper. If a module in a different sub-package needs to import one of these modules, it must use a full path. This results in a new entry in sys.modules, and therefore any attributes referenced by the intra-package module have different identities from those referenced from outside. If they are static, there is no problem, but if not, disaster strikes! Frank From frank at chagford.com Sun Feb 26 06:22:21 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 13:22:21 +0200 Subject: Question about circular imports References: Message-ID: "Peter Otten" <__peter__ at web.de> wrote in message news:jid424$vfp$1 at dough.gmane.org... > Frank Millman wrote: > > > To cut a long story short, why should circular imports be unavoidable? > > Paths into packages are recipe for desaster. You may end up with multiple > instances of the same module and your programs will break in "interesting" > (hard to debug) ways. > Thanks, Peter. I have just figured this out for myself, but you beat me to it. Full paths it is, then. Frank From ssmile03 at gmail.com Sun Feb 26 06:25:23 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Sun, 26 Feb 2012 16:55:23 +0530 Subject: pickle handling multiple objects .. Message-ID: If I have a sample python code to be executed on Linux. How should I handle multiple objects with 'pickle' as below - ------- #!/usr/bin/python import pickle #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] #my_list = () output = open('readfile.pkl', 'wb') pickle.dump(my_list, output) output.close() my_file = open('readfile.pkl', 'rb') my_list2 = pickle.load(my_file) my_file.close() print my_list print my_list2 ----- This code works fine but now I have to handle multiple objects? -------------- next part -------------- An HTML attachment was scrubbed... URL: From WolfgangMeiners01 at web.de Sun Feb 26 06:56:46 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 12:56:46 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Am 25.02.12 18:54, schrieb MRAB: >> If there is no limit for len(string), why not simply use >> >> # get_limit() returns None if there is no limit >> maxlength = get_limit() >> if maxlength and (len(string)<= maxlength): >> allow_passage() >> else: >> deny_passage() >> > That should be: > > if maxlength is not None and len(string) <= maxlength: Take a look at http://docs.python.org/library/stdtypes.html where you can read: ========================================================================= Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below. The following values are considered false: None False zero of any numeric type, for example, 0, 0L, 0.0, 0j. any empty sequence, for example, '', (), []. any empty mapping, for example, {}. instances of user-defined classes, if the class defines __nonzero__() or __len__() method, when that method returns the integer zero or bool value False. [1] All other values are considered true ? so objects of many types are always true. ========================================================================== That means: if maxlength and (len(string) <= maxlength): is equivalent to if (maxlength is not None) and (len(string) <= maxlength): which is more complicated to type and -in my opinion- not so intuitive. But because it is equivalent, it is a matter of taste, what to use. Wolfgang From albert at spenarnc.xs4all.nl Sun Feb 26 06:57:22 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 11:57:22 GMT Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: In article , Gelonida N wrote: >On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > >You want to say, that I could install python 2.6 >some packages like win32api >PyQt and tand py2exe under Wine and then compile it. > > >Did you try this? > >I didn't even think about trying this out, >but I know very little about the limits of Wine, so perhaps I >underestimate it. As a case in point I have this example of another language: colorforth. It was made by a genius inventor (Chuck Moore), and only runs from a boot-floppy and writes pixels to the screen. Someone made an environment in MS-Windows to emulate the booting process and all. This actually runs colorforth. Now about Wine, how good is it? Actually it is good enough to run the above emulator! (We run a third emulator, of the GA144, on top at a decent speed.) Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From clp2 at rebertia.com Sun Feb 26 06:58:18 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 26 Feb 2012 03:58:18 -0800 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 3:25 AM, Smiley 4321 wrote: > If I have a sample python code to be executed on Linux. How should? I handle > multiple objects with 'pickle' as below - > > ------- > #!/usr/bin/python > > import pickle > > #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} > #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') > my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] > #my_list = () > output = open('readfile.pkl', 'wb') > pickle.dump(my_list, output) > output.close() > > my_file = open('readfile.pkl', 'rb') > my_list2 = pickle.load(my_file) > my_file.close() > > print my_list > print my_list2 > ----- > > This code works fine but now I have to handle multiple objects? You can either nest the multiple objects inside a single compound object and just (un)pickle that, or you call call dump()/load() repeatedly (once per object; yes, this works). Cheers, Chris From __peter__ at web.de Sun Feb 26 07:04:00 2012 From: __peter__ at web.de (Peter Otten) Date: Sun, 26 Feb 2012 13:04 +0100 Subject: pickle handling multiple objects .. References: Message-ID: Smiley 4321 wrote: > If I have a sample python code to be executed on Linux. How should I > handle multiple objects with 'pickle' as below - > > ------- > #!/usr/bin/python > > import pickle > > #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} > #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') > my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] > #my_list = () > output = open('readfile.pkl', 'wb') > pickle.dump(my_list, output) > output.close() > > my_file = open('readfile.pkl', 'rb') > my_list2 = pickle.load(my_file) > my_file.close() > > print my_list > print my_list2 > ----- > > This code works fine but now I have to handle multiple objects? You never do that with pickle. You pack your data into a single object before you store it, and unpack it after loading it. Here's an example using a tuple as the container: fruit = ["apple", "orange"] vegetables = ["potato", "tomato"] beverages = ["milk", "coffee", "water"] with open("tmp.pickle", "wb") as f: pickle.dump((fruit, vegetables, beverages), f) with open("tmp.pickle", "rb") as f: fruit, vegetables, beverages = pickle.load(f) print fruit print vegetables print beverages This is however a bit errorprone. If you accidentally write the loading code as fruit, beverages, vegetables = pickle.load(f) you'll end up drinking potatoes. A better container would be a dict. Something like pickle.dump(dict(fruit=fruit, vegetables=vegetables, beverages=beverages), f) ... data = pickle.load(f) fruit = data["fruit"] beverages = data["beverages"] vegetables = data["vegetables"] is harder to get wrong. It is also easier to extend. Code that only reads the pickle will happily ignore extra keys in the dictionary. If you follow that path somewhat more you will probably drop the lowlevel pickle and use a key-value store like Python's shelve instead, see http://docs.python.org/library/shelve.html From albert at spenarnc.xs4all.nl Sun Feb 26 07:14:38 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 12:14:38 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: In article , Rick Johnson wrote: >On Feb 18, 1:28=A0am, Ian Kelly wrote: >> On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson > > >> If I were to [sum my tax burden], it would >> probably come to around 30%, which still doesn't bother me, in part >> because I know that it comes back to benefit the society I live in, >> and by extension me, in one way or another.. > >But do you think you'll get a higher return for your investment? Is it >possible to get a higher return on your investment in this type of >system? NO! You better off just paying for your own damn healthcare. > >Well actually, there is a way to get a higher return by taking more >than your "fair share". Any intelligent person would realize that >public healthcare is advocated by degenerates or the bleeding heart >"degenerate eugenics" supporters. Fine, YOU want to subsidize >degeneracy? Then give to charity. The more you give the better you'll >feel. BTW: How much money do you give to charity? This is technically wrong. It is much cheaper for you to pay a few euro's to combat TBC, then live in a TBC-infected society where you must take great care not to be infected yourself. Paying to rid the society of TBC is not charity, it is is common sense. Your ideas only work for the anti-social few, in an otherwise social society. Education is another case in point. It is in you best interest to allow a getto-genius into Harvard. Otherwise they will become the master-minds of crime. And you will be too stupid to beat them. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From ben+python at benfinney.id.au Sun Feb 26 07:21:07 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 23:21:07 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: <87haydss3w.fsf@benfinney.id.au> Chris Angelico writes: > On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: > > If you're pleased to announce their immediate availability, then > > please do that! > > Isn't it perfectly accurate to say that the RCs are now available? Yes. What's not reasonable is to say that a candidate for release ? i.e. something *prior to* release, by definition ? is nevertheless released. > Considering that "Release candidates" immediately followed "RELEASED" > in the subject line, I don't see any confusion. Unless ?release candidate? means nothing like what those words imply, it can't be both a release candidate *and* released. Either it's released, or it's not. If it's a release candidate, it's not released yet. If it's released, it's no longer a candidate for release. Saying it's simultaneously both is the confusion. -- \ ?The Things to do are: the things that need doing, that you see | `\ need to be done, and that no one else seems to see need to be | _o__) done.? ?Richard Buckminster Fuller, 1970-02-16 | Ben Finney From albert at spenarnc.xs4all.nl Sun Feb 26 07:44:13 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 12:44:13 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: In article <40af8461-1583-4496-9d81-d52d6905d24d at b23g2000yqn.googlegroups.com>, Rick Johnson wrote: >Because the Jews allowed themselves to be subjected. Sad, but true. Actually Jew stands for (relative) coward. Let me explain. Jew comes from Juda, one of the 12 tribes. At some time Israel was subjected and 11 tribes resisted to the death and are eradicated since. Only the Juda tribe gave in and their land was called Judea since. (So the name Israel for the current state is a propagandistic lie, to claim the land once occupied by the 12 tribes.) I don't blame them for the attitude of "live to fight another day" or even for plain survival. If the Jews hadn't allow themselves to be subjected, there would be no Jews. >Slaves only exist because they allow themselves to exist. When people Never been a slave, were you? Try to imagine what it is to be born a slave. > >"Freeeeeedoooooooommmmmmm!" >"Live free, or die!" >"From my cold dead hand!" >"Over my dead body!" >"Freedom is never voluntarily given by the oppressor; it must be >demanded by the oppressed." >"Those who deny freedom to others deserve it not for themselves." >"Man is free at the moment he wishes to be." >"Those who desire to give up freedom in order to gain security, will >not have, nor do they deserve, either one." Black Panther comes to mind. The USA just killed them. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From rosuav at gmail.com Sun Feb 26 07:52:16 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Feb 2012 23:52:16 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners wrote: > That means: > if maxlength and (len(string) <= maxlength): > > is equivalent to > if (maxlength is not None) and (len(string) <= maxlength): On the contrary, it means they are distinctly NOT equivalent. The shorter form would treat a maximum length of 0 as meaning "unlimited". Now, that's an understandable notation, but it's not what's given here; if None means unlimited, then 0 should enforce that string == "". ChrisA From rosuav at gmail.com Sun Feb 26 08:00:31 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 00:00:31 +1100 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > This is however a bit errorprone. If you accidentally write the loading code > as > > fruit, beverages, vegetables = pickle.load(f) > > you'll end up drinking potatoes. You mean vodka? :) Additionally, you'll get a weird crash out of your program if load() returns something other than a sequence of length 3. Remember, everything that comes from outside your code is untrusted, even if you think you made it just two seconds ago. Of course, sometimes that exception is absolutely correct. If you wrap all this in an exception handler that gives some reasonable behaviour - which might even be "terminate the program with a traceback", which is the default - then it's fine to let it throw on failure, and anything else is just a waste of effort. But for maximum extensibility, you would want to make it so that you can add more elements to what you save without your code breaking on an old save file - and that's where the dictionary is far better. A slight tweak, though: data = pickle.load(f) fruit = data.get("fruit",[]) beverages = data.get("beverages",[]) vegetables = data.get("vegetables",[]) With this, you guarantee that (a) unrecognized keys will be safely ignored, and (b) absent keys will quietly go to their given defaults. ChrisA From rosuav at gmail.com Sun Feb 26 08:01:55 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 00:01:55 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87haydss3w.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: On Sun, Feb 26, 2012 at 11:21 PM, Ben Finney wrote: > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. > > Either it's released, or it's not. If it's a release candidate, it's not > released yet. If it's released, it's no longer a candidate for release. Sure, fair enough. So what DO you do with an RC? "Make it available"? Seems a little verbose, but it's the best I can think of off-hand. ChrisA From steve+comp.lang.python at pearwood.info Sun Feb 26 08:08:35 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:08:35 GMT Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: <4f4a2ed2$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 23:21:07 +1100, Ben Finney wrote: > Chris Angelico writes: > >> On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney >> wrote: > >> > If you're pleased to announce their immediate availability, then >> > please do that! >> >> Isn't it perfectly accurate to say that the RCs are now available? > > Yes. What's not reasonable is to say that a candidate for release ? i.e. > something *prior to* release, by definition ? is nevertheless released. We have a piece of software which has just been actively released to the public in a known fixed state, with a specific version number (2.6.8rc etc.). Since this active process of *releasing* software has occurred, the past tense "[RELEASED]" applies. What sort of software is it? Well, it's not a pre-alpha, or alpha, or beta version, nor is it the production-release version. It is a candidate to become the production-release, or "Release candidate". Hence we have the release [verb] of a release candidate [compound noun]. There is no contradiction here, any more than it would be a contradiction to release a beta version. http://en.wikipedia.org/wiki/Software_release_life_cycle >> Considering that "Release candidates" immediately followed "RELEASED" >> in the subject line, I don't see any confusion. > > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. What do you believe the words imply? I believe that they imply that the version is a candidate to be a production-ready release of the software, as opposed to a pre-alpha, alpha or beta version, but not yet the production-ready version. -- Steven From WolfgangMeiners01 at web.de Sun Feb 26 08:16:24 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:16:24 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> Message-ID: <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Am 25.02.12 21:35, schrieb Rick Johnson: > On Feb 25, 11:54 am, MRAB wrote: >> [...] >> That should be: >> if maxlength is not None and len(string) <= maxlength: > > Using "imaginary" infinity values defiles the intuitive nature of your > code. What is more intuitive? > > def confine_length(string, maxlength=INFINITY): > if string.length < maxlength: > do_something() > > def confine_length(string, maxlength=None): > if maxlength is not None and len(string) <= maxlength: > do_something() I just had a closer look at it. It seems to be more complicated than i thougth: You will have to write def confine_length(string, maxlength=None): if maxlength: # maxlength exists, comparison possible if len(string) <= maxlength: do_something() else: # maxlength does not exist, so always do something do_something() you migth also write def confine_length(str, maxlength=None): do_it = (len(str) <= maxlength) if maxlength else True if do_it: do_something() but it really does not look intuitive. Hmm. My idea was that None is a perfect Value for infinity since there is no infinitely large number. But as i see it, you must have two comparisons then. Maybe someone has a better idea? Wolfgang From steve+comp.lang.python at pearwood.info Sun Feb 26 08:19:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:19:23 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a315b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 12:56:46 +0100, Wolfgang Meiners wrote: > That means: > if maxlength and (len(string) <= maxlength): > > is equivalent to > if (maxlength is not None) and (len(string) <= maxlength): > > which is more complicated to type and -in my opinion- not so intuitive. > But because it is equivalent, it is a matter of taste, what to use. Incorrect. The two are *not* equivalent. def test(maxlength, string): flag1 = maxlength and (len(string) <= maxlength) flag2 = (maxlength is not None) and (len(string) <= maxlength) return bool(flag1), bool(flag2) # normalise to booleans >>> test(0, '') (False, True) So the two forms will take opposite branches of the if statement when maxlength is 0 and string is the empty string. -- Steven From WolfgangMeiners01 at web.de Sun Feb 26 08:32:51 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:32:51 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a3483$0$7619$9b4e6d93@newsspool1.arcor-online.net> Am 26.02.12 13:52, schrieb Chris Angelico: > On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners > wrote: >> That means: >> if maxlength and (len(string) <= maxlength): >> >> is equivalent to >> if (maxlength is not None) and (len(string) <= maxlength): > > On the contrary, it means they are distinctly NOT equivalent. The > shorter form would treat a maximum length of 0 as meaning "unlimited". > Now, that's an understandable notation, but it's not what's given > here; if None means unlimited, then 0 should enforce that string == > "". > > ChrisA You are right. It seems I did not get the line zero of any numeric type, for example, 0, 0L, 0.0, 0j. right. Wolfgang From WolfgangMeiners01 at web.de Sun Feb 26 08:38:37 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:38:37 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> Am 26.02.12 14:16, schrieb Wolfgang Meiners: > > I just had a closer look at it. It seems to be more complicated than i > thougth: You will have to write Obviously not close enough, as i just learned. > > def confine_length(string, maxlength=None): > if maxlength: # maxlength exists, comparison possible if maxlength is not None: # maxlength exists, comparison possible > if len(string) <= maxlength: > do_something() > else: # maxlength does not exist, so always do something > do_something() > > you migth also write > > def confine_length(str, maxlength=None): > do_it = (len(str) <= maxlength) if maxlength else True do_it = (len(str) <= maxlength) if maxlength is not None else True > if do_it: > do_something() > I hope, it's correct now. Wolfgang From steve+comp.lang.python at pearwood.info Sun Feb 26 08:40:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:40:03 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> Message-ID: <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: >> An integer variable is a variable holding an integer. A string variable >> is a variable holding a string. A list variable is a variable holding a >> list. > > And Python has none of those. Its references don't ?hold? anything. Ah, but they do. Following the name binding: x = 1 the name "x" now holds a reference to an int, or if you want to cut out one layer of indirection, the name "x" holds an int. That is to say, the value associated with the name "x" is an int. I don't believe this is a troublesome concept. > I appreciate that you think ?variable? is a useful term in Python, but > this kind of mangling of the concept convinces me that it's not worth > it. I'm not sure that there is any mangling here. Or at least, the concept is only mangled if you believe that Pascal- or C-like variables (named memory locations) are the one true definition of "variable". I do not believe this. Words vary in their meanings, pun not intended, and in the same way that the semantics of classes in (say) Java are not identical to the semantics of classes in Python, so I think that it is perfectly reasonable to talk about Python having variables, implemented using bindings to objects in a namespace, even though the semantics of Python variables is slightly different from that of C variables. Fundamentally, a variable is a name associated with a value which can vary. And Python name bindings meet that definition no less than C fixed memory locations. > Python doesn't have variables, and even if you want to say ?variables? > when you mean ?references?, there's no such thing as a ?string variable? > etc. in Python. References don't have types, so its needlessly confusing > to perpetuate that kind of thinking. But objects have types, and it makes sense to state that the type of the name is the type of the object bound to that name, at least for the duration of the binding. That's exactly what we write in Python: type(x) tells us the type of x, whatever x happens to be. There's no implication that it is the type of the *name* x, since names are not typed. More importantly, while Python doesn't have static types, in real code, names generally are expected to be bound to objects of a particular type (perhaps a duck-type, but still a type). It is rare to have code including a name bound to *anything at all* -- the main counter-example I can think of is the id() function. Generally, names are expected to be bound to a specific kind of value: perhaps as specific as "a string", or as general as "an iterable", or "anything with a __add__ method", but nevertheless there is the expectation that if the name is bound to something else, you will get an error. A compile time error in C, a runtime error in Python, but either way, the expectation is that you get an error. In an example like this: def spam(some_string): return some_string.upper() + "###" I maintain that it is reasonable to say that "some_string is a string variable", since that expresses the programmer's intention that some_string should be bound to string objects (modulo duck-typing). If Python were statically typed, then passing some_string=42 would cause a compile-time error. In Python, you get a runtime error instead. I don't believe this invalidates the idea that some_string is intended to be a string. Or to make this painfully complete: some_string is a name linked to a value which can vary (hence a variable) intended to be limited to strings (hence a string variable). Python may not enforce this to the same extent as C or Haskell or Pascal, but the concept still holds. -- Steven From arnodel at gmail.com Sun Feb 26 08:44:57 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sun, 26 Feb 2012 13:44:57 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> Message-ID: On 26 February 2012 13:38, Wolfgang Meiners wrote: > ? ? ?do_it = (len(str) <= maxlength) if maxlength is not None else True That's a funny way to spell: do_it = maxlength is None or len(str) <= maxlength -- Arnaud From steve+comp.lang.python at pearwood.info Sun Feb 26 08:50:01 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:50:01 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a3889$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 14:16:24 +0100, Wolfgang Meiners wrote: > I just had a closer look at it. It seems to be more complicated than i > thougth: You will have to write > > def confine_length(string, maxlength=None): > if maxlength: # maxlength exists, comparison possible > if len(string) <= maxlength: > do_something() > else: # maxlength does not exist, so always do something > do_something() No, that still takes the wrong branch for maxlength = 0. Be explicit in your code. If you want maxlength=None to be a sentinel for "avoid the length test", then explicitly test for maxlength is None, don't be tempted to take short-cuts that can fail. def confine_length(string, maxlength=None): if maxlength is None: # no length comparison needed do_something() elif len(string) <= maxlength: do_something() This can be simplified to: def confine_length(string, maxlength=None): if maxlength is None or len(string) <= maxlength: do_something() Or even simpler: def confine_length(string, maxlength=float('inf')): if len(string) <= maxlength: do_something() -- Steven From k.sahithi2862 at gmail.com Sun Feb 26 11:05:31 2012 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Sun, 26 Feb 2012 08:05:31 -0800 (PST) Subject: HOT LINKS FOR YOUTH ONLY Message-ID: HOT LINKS FOR YOUTH ONLY FOR FAST UPDATES IN FILM INDUSTRY KATRINA KAIF RARE PHOTOS http://allyouwants.blogspot.com/2011/12/katrina-kaif.html KAJAL AGARWAL LATEST STILLS http://allyouwants.blogspot.com/2011/03/kajal-latest-stills.html PRIYANKA CHOPRA LATEST HOT PHOTOSHOOT http://allyouwants.blogspot.com/2011/08/priyanka-chopra.html TAMIL ACTRESS HOT PHOTOS&VIDEOS http://allyouwants.blogspot.com/2011/08/tamil-actress.html ANU SMRUTHI LATEST HOT STILLS http://actressimages-9.blogspot.in/2012/02/anu-smirthi-stills.html EK THA TIGER MOVIE STILLS http://actressgallery-kalyani.blogspot.in/2012/02/ek-tha-tiger-movie-stills.html ACTREESS SUPRIYA SHAILJA LATEST STILLS http://actressgallery-kalyani.blogspot.in/2012/02/supriya-shailja-stills.html BOLLYWOOD ACTRESS APSARA AWARDS 2012 http://actressgallery-kalyani.blogspot.in/2012/01/apsara-awards-2012.html AISHWARYA RAI LATEST HOT PICS http://actressimages-9.blogspot.in/2012/01/aishwarya-rai.html KATRINA KAIF HOT MAGAZINES PHOTOS http://actressimages-9.blogspot.in/2012/01/katrina-kaif-magazine-photos.html TRISHA HOT BEAUTIFUL IMAGES http://actressimages-9.blogspot.in/2012/01/trisha-krishnan.html HOT MALLIKA SHERAWAT PHOTOS http://actressimages-9.blogspot.in/2012/01/mallika-sherawat.html SHEELA LATEST HOT STILLS http://actressgallery-kalyani.blogspot.in/2012/01/sheela-latest-stills.html KATRINA KAIF ITEM SONG STILLS http://actressgallery-kalyani.blogspot.in/2012/01/katrina-kaif-item-song-stills.html From search at bluelinetalent.com Sun Feb 26 13:31:24 2012 From: search at bluelinetalent.com (Blue Line Talent) Date: Sun, 26 Feb 2012 10:31:24 -0800 (PST) Subject: Software Engineer - Storage, Python, C++, Java Message-ID: <7a870e43-cd31-48e0-b993-23c5ad961f13@t16g2000yqt.googlegroups.com> Blue Line Talent is looking for a mid-level software engineer with experience in a combination of Python, C/C++ and/or Java. Experience developing middleware is helpful. The Engineer will join an exciting start-up environment in a newly established location. This is an outstanding opportunity for a high performing software engineer with 3-5 years experience. Must love coding, variety. For this position most of the work is being done in Python now but they expect this SW Engineer will also use increasing amounts of C/C++ and Java. The languages experience isn't as important as finding a really sharp Software Engineer who loves programming (not just design) and would be well suited for the diversity of a start-up environment. Position Title: Software Engineer - Storage Work Location: Broomfield/Flatirons area, CO The Employer: ? A strongly positioned Storage Solutions Software company ? Fully funded and established start-up company with excellent opportunities for growth and advancement ? Comprehensive benefits package Description: ? Full life-cycle software design, development, implementation, test and maintenance. ? Develop, test, and maintain infrastructure-oriented software in Python with some work in C/C++ and Java ? Middleware development - bridge between Linux Kernel and GUI ? Source code control Experience Profile: ? BS in Computer Science or an applicable engineering subject and 3-5+ years of related software engineering experience ? 2+ years software engineering for complex storage solutions ? Loves programming ? Experience developing middleware ? Experience programming in Python (or C/C++ and/or Java) ? Software Engineering experience in a Linux environment. ? Experience with near-real time software development. ? Stable employment history of direct employment Helpful/Preferred: ? Experience in a start-up environment ? Experience with real-time software development. (exposure to embedded software is helpful) ? Enjoys diversity of tasks ? Experience with GUI ? Experience with C/C++ and/or Java ? Experience with various Windows and Linux OS environments ? Exposure to storage subsystems such as Fibre Channel, iSCSI, SAS, SATA, RAID, Snapshot, Replication, NAS, SAN, etc. ? MS in Computer Science, or related degree Please apply at www.bluelinetalent.com/active_jobs NOTES: ? Direct hire with comprehensive benefits ? Local candidates please - no relocation assistance provided ? Not available for Corp-to-Corp, no third parties please Ron Levis Principal, Talent Acquisition Mgr Blue Line Talent, LLC www.bluelinetalent.com www.linkedin.com/in/ronlevis (invitations are welcome) Moderator, Colorado IT Community on LinkedIn Groups Blue Line Talent is a member-owner of NPA, The Worldwide Recruiting Network, your connection to premier independent recruiting firms located throughout Europe, Asia, Australia, Africa and the Americas. From brenNOSPAMbarn at NObrenSPAMbarn.net Sun Feb 26 14:57:49 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sun, 26 Feb 2012 19:57:49 +0000 (UTC) Subject: Question about circular imports References: Message-ID: Frank Millman wrote: > The first solution is - > > in wavread.py - > import formats.wavwrite > > in wavwrite.py - > import formats.wavread > > I then have to use the full path to reference any attribute inside > the imported module, which I find cumbersome. This isn't really true. If this is the only thing you're worried about, you can always do the "manual" version of a "from X import Y": import formats.wavread wavread = formats.wavread wavread.someFunc() # refers to functions in module formats.wavread. Also, I'm too lazy to check right now, but I wouldn't be suprised if "mport formats.wavread as wavread" also works even in the circular case. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From rantingrickjohnson at gmail.com Sun Feb 26 15:35:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 26 Feb 2012 12:35:40 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> On Feb 26, 6:44?am, Albert van der Horst wrote: > I don't blame them for the attitude of "live to fight another day" > or even for plain survival. If the Jews hadn't allow themselves > to be subjected, there would be no Jews. And may i borrow your time machine now that you are finished researching what "may have happened" to the Jews had they adopted the "live free or die" mentality? I always wondered what it would feel like to be god. > >Slaves only exist because they allow themselves to exist. When people > > Never been a slave, were you? Try to imagine what it is to be > born a slave. Don't try to cast me as siding with the slave-master. I detest them as much as anyone. But my point is still valid; empower the people and subjection is a thing of the past. Bullying is a microcosm of slavery. You could take two distinct defensive methods to fighting bullies: 1. you could fight each bully on a case by case bases. 2. you could empower people to fight bullies as a united group. Method one will always fail. Sure, you may defeat the bully that exists today, but tomorrow a new bully will be born. Whereas method 2 will always prevail. Bullies need to exist in the shadows, behind a veil of secrecy and fear. Remove the veil and they will be exposed. Adopt a public policy that bullying will NOT be allowed and the perp WILL be punished, and bulling disappears forever. History has shown that mob behavior can be both detrimentally sadistic AND masochistic. From ben+python at benfinney.id.au Sun Feb 26 15:46:46 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 27 Feb 2012 07:46:46 +1100 Subject: OT: Entitlements References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <874nuds4p5.fsf@benfinney.id.au> Albert van der Horst writes: > In article <40af8461-1583-4496-9d81-d52d6905d24d at b23g2000yqn.googlegroups.com>, > Rick Johnson wrote: > >Because the Jews allowed themselves to be subjected. Sad, but true. > > Actually Jew stands for (relative) coward. Let me explain. No, please don't. Slander of racial groups is not only off-topic here, it's wholly inappropriate regardless of your explanation. Stop doing it, and don't encourage it in others. -- \ ?The sun never sets on the British Empire. But it rises every | `\ morning. The sky must get awfully crowded.? ?Steven Wright | _o__) | Ben Finney From rosuav at gmail.com Sun Feb 26 15:50:40 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 07:50:40 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> Message-ID: On Mon, Feb 27, 2012 at 7:35 AM, Rick Johnson wrote: > ?1. you could fight each bully on a case by case bases. > ?2. you could empower people to fight bullies as a united group. > > Adopt a public policy that bullying will NOT be > allowed and the perp WILL be punished, and bulling disappears > forever. Hmm, I wonder how you go about adopting that policy... oh! I know! By fighting each bully on a case-by-case basis! Funny though, you just said that won't work. ChrisA From tjreedy at udel.edu Sun Feb 26 17:09:17 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 17:09:17 -0500 Subject: Question about circular imports In-Reply-To: References: Message-ID: On 2/26/2012 6:12 AM, Peter Otten wrote: > Frank Millman wrote: > >> I seem to have a recurring battle with circular imports, and I am trying >> to nail it once and for all. ... > This should be > > import sound.formats.wavread To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer -- Terry Jan Reedy From tjreedy at udel.edu Sun Feb 26 17:20:26 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 17:20:26 -0500 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87ty2ern8j.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: On 2/26/2012 3:51 AM, Ben Finney wrote: > Benjamin Peterson writes: > >> We're pleased to announce the immediate availability of release candidates for >> Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . > > If you're pleased to announce their immediate availability, then please > do that! > > Putting ?RELEASED? in the subject, when they're not released and are > instead *candidates for* release, is confusing and muddies the issue of > what you even mean by ?release?. I think the standard [RELEASED] tag is for the benefit of people who do not read the list but filter it for posts with such tags, perhaps automatically, so they know there is something new to go download. And indeed, there is something new to download. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sun Feb 26 17:32:49 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 26 Feb 2012 14:32:49 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> Message-ID: <7b67d136-5c5e-4714-969a-d93a91b86bbc@m3g2000yqc.googlegroups.com> On Feb 26, 2:50?pm, Chris Angelico wrote: > Hmm, I wonder how you go about adopting that policy... oh! I know! By > fighting each bully on a case-by-case basis! Funny though, you just > said that won't work. It's a two-pronged solution Chris. Compound. From ladasky at my-deja.com Sun Feb 26 19:05:15 2012 From: ladasky at my-deja.com (John Ladasky) Date: Sun, 26 Feb 2012 16:05:15 -0800 (PST) Subject: MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! References: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> Message-ID: On Feb 26, 12:29?am, BV wrote: > MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! ...Hey, someone has to keep the spam around here on-topic. From ladasky at my-deja.com Sun Feb 26 19:24:14 2012 From: ladasky at my-deja.com (John Ladasky) Date: Sun, 26 Feb 2012 16:24:14 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Curiosity prompts me to ask... Those of you who program in other languages regularly: if you visit comp.lang.java, for example, do people ask this question about floating-point arithmetic in that forum? Or in comp.lang.perl? Is there something about Python that exposes the uncomfortable truth about practical computer arithmetic that these other languages obscure? For of course, arithmetic is surely no less accurate in Python than in any other computing language. I always found it helpful to ask someone who is confused by this issue to imagine what the binary representation of the number 1/3 would be. 0.011 to three binary digits of precision: 0.0101 to four: 0.01011 to five: 0.010101 to six: 0.0101011 to seven: 0.01010101 to eight: And so on, forever. So, what if you want to do some calculator-style math with the number 1/3, that will not require an INFINITE amount of time? You have to round. Rounding introduces errors. The more binary digits you use for your numbers, the smaller those errors will be. But those errors can NEVER reach zero in finite computational time. If ALL the numbers you are using in your computations are rational numbers, you can use Python's rational and/or decimal modules to get error-free results. Learning to use them is a bit of a specialty. But for those of us who end up with numbers like e, pi, or the square root of 2 in our calculations, the compromise of rounding must be accepted. From tjreedy at udel.edu Sun Feb 26 20:30:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 20:30:02 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Message-ID: On 2/26/2012 7:24 PM, John Ladasky wrote: > I always found it helpful to ask someone who is confused by this issue > to imagine what the binary representation of the number 1/3 would be. > > 0.011 to three binary digits of precision: > 0.0101 to four: > 0.01011 to five: > 0.010101 to six: > 0.0101011 to seven: > 0.01010101 to eight: > > And so on, forever. So, what if you want to do some calculator-style > math with the number 1/3, that will not require an INFINITE amount of > time? You have to round. Rounding introduces errors. The more > binary digits you use for your numbers, the smaller those errors will > be. But those errors can NEVER reach zero in finite computational > time. Ditto for 1/3 in decimal. ... 0.33333333 to eitht > If ALL the numbers you are using in your computations are rational > numbers, you can use Python's rational and/or decimal modules to get > error-free results. Decimal floats are about as error prone as binary floats. One can only exact represent a subset of rationals of the form n / (2**j * 5**k). For a fixed number of bits of storage, they are 'lumpier'. For any fixed precision, the arithmetic issues are the same. The decimal module decimals have three advantages (sometimes) over floats. 1. Variable precision - but there are multiple-precision floats also available outside the stdlib. 2. They better imitate calculators - but that is irrelevant or a minus for scientific calculation. 3. They better follow accounting rules for financial calculation, including a multiplicity of rounding rules. Some of these are laws that *must* be followed to avoid nasty consequences. This is the main reason for being in the stdlib. > Learning to use them is a bit of a specialty. Definitely true. -- Terry Jan Reedy From th982a at googlemail.com Sun Feb 26 20:39:40 2012 From: th982a at googlemail.com (Tamer Higazi) Date: Mon, 27 Feb 2012 02:39:40 +0100 Subject: MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! In-Reply-To: References: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> Message-ID: <4F4ADEDC.8060301@googlemail.com> AND PYTHON IS REALLY COOL!!!!! Especially this beautiful JPype Bridge that makes it possible to push requests between PYTHON and JAVA. really really really cool! Am 27.02.2012 01:05, schrieb John Ladasky: > On Feb 26, 12:29 am, BV wrote: >> MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM > > MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! > > > ...Hey, someone has to keep the spam around here on-topic. From nanothermitefbibustardsattn at gmail.com Sun Feb 26 21:01:51 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Sun, 26 Feb 2012 18:01:51 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: On Feb 25, 4:18?pm, Xah Lee wrote: > worth watching for those who have strong beliefs in emacs user > interface, and those who love to quote how software become smarter and > people become dumber. > > Bret Victor - Inventing on Principlehttp://vimeo.com/36579366 > > also read: > > ?Emacs Modernization?http://xahlee.org/emacs/emacs_modernization.html > > ?Xah @Xah Lee, he only tell one point, fast interpreter avoiding Edit- Compile-Run cycle, and make it INTERACTIVE, the guy did not teach nothing of design. The principle was first given by Margaret Hamilton and Zeldin. These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=3D4UqcY8lGUUE http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 gnu.emacs.help, comp.emacs, comp.unix.shell, comp.lang.c++, comp.lang.python From gelonida at gmail.com Sun Feb 26 21:22:26 2012 From: gelonida at gmail.com (Gelonida N) Date: Mon, 27 Feb 2012 03:22:26 +0100 Subject: Abort an HTTP request before the request timed out Message-ID: Hi, I'm working in a small application, which tries to access data on a web server. Normally the request has a timeout of for example 60 seconds conn = httplib.HTTPConnection(server_name, server_port, timeout=60) while True: conn.request("GET", "/my_url.php") try: resp = conn.getresponse() except HaveToLookUpNameOfTimeOutException as exc: print "timed out" continue parse_response(resp) Sometimes I would like to abort the request from another thread and force an immediate retry. How would I do this best? The other thread would be either a UI button or some other code knowing, when it is not good to wait the ull minute. Normally the timeout of 1 mintues is what I need though. Thanks for any suggestion. The solution should work on Windows and Linux From wuwei23 at gmail.com Sun Feb 26 21:32:27 2012 From: wuwei23 at gmail.com (alex23) Date: Sun, 26 Feb 2012 18:32:27 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> Message-ID: <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> On Feb 26, 6:29?am, Rick Johnson wrote: > Sure there are float INFINITIES that work fine for ints and floats, > but where is the consistency? Sure, there are all of the COMPLEXITIES of floating point arithmetic but I want to ignore all of that and demand ridiculous consistencies. Why should I have to do float(some_int) < float('inf') when it's a far better use of my time to spend days if not weeks bemoaning yet another language wart? Why should I be expected to know what float('inf') actually represents before making stupid demands like: > INFINITY need not be a int or a float or > a str, or whatever. Please provide a non-contrived use case of an "infinite string". > INFINITY should be at the very least a constant of the math module. Why? This isn't a mathematical concept of 'infinite' when you're talking about comparing against "str, or whatever". We need a more appropriate location; please initiate a PEP to add the namespace shit.rick.wants into the stdlib. From steve+comp.lang.python at pearwood.info Sun Feb 26 22:28:07 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Feb 2012 03:28:07 GMT Subject: Python math is off by .000000000000045 References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Message-ID: <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: > Curiosity prompts me to ask... > > Those of you who program in other languages regularly: if you visit > comp.lang.java, for example, do people ask this question about > floating-point arithmetic in that forum? Or in comp.lang.perl? Yes. http://stackoverflow.com/questions/588004/is-javascripts-math-broken And look at the "Linked" sidebar. Obviously StackOverflow users no more search the internet for the solutions to their problems than do comp.lang.python posters. http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error -- Steven From emmynoether3 at gmail.com Sun Feb 26 22:40:35 2012 From: emmynoether3 at gmail.com (Emmy Noether) Date: Sun, 26 Feb 2012 19:40:35 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: your first link is not working but it is to this KEY video http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 On Feb 26, 6:01?pm, NanoThermite FBibustards wrote: > On Feb 25, 4:18?pm, Xah Lee wrote: > > > worth watching for those who have strong beliefs in emacs user > > interface, and those who love to quote how software become smarter and > > people become dumber. > > > Bret Victor - Inventing on Principlehttp://vimeo.com/36579366 > > > also read: > > > ?Emacs Modernization?http://xahlee.org/emacs/emacs_modernization.html > > > ?Xah > > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > > These are also good videos as well as the treatise and court case > document below, you will find them exhilerating, liberating and very > informative > > http://www.youtube.com/watch?v=3D4UqcY8lGUUEhttp://www.youtube.com/watch?v=lX18zUp6WPYhttp://www.youtube.com/watch?v=XQapkVCx1HIhttp://www.youtube.com/watch?v=tXJ-k-iOg0Mhttp://www.youtube.com/watch?v=DhMcii8smxkhttp://www.youtube.com/watch?v=tRfhUezbKLwhttp://www.youtube.com/watch?v=x7kGZ3XPEm4http://www.youtube.com/watch?v=lX18zUp6WPY > > http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcripthttp://anglo-saxonisrael.com/site/GreatImpersonation-8 > > http://www.youtube.com/watch?v=ZcwBEzW8S1Mhttp://www.youtube.com/watch?v=9gBxMJFQd04 > > gnu.emacs.help, comp.emacs, comp.unix.shell, comp.lang.c++, > comp.lang.python From steve+comp.lang.python at pearwood.info Sun Feb 26 22:51:43 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Feb 2012 03:51:43 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> Message-ID: <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 18:32:27 -0800, alex23 wrote: > On Feb 26, 6:29?am, Rick Johnson wrote: >> Sure there are float INFINITIES that work fine for ints and floats, but >> where is the consistency? > > Sure, there are all of the COMPLEXITIES of floating point arithmetic but > I want to ignore all of that and demand ridiculous consistencies. Why > should I have to do float(some_int) < float('inf') Ints and floats can be compared directly, no need to convert the int to a float first: >>> INF = float('inf') >>> 23 < INF True Likewise Fractions and Decimals, at least in Python 3.2 (possibly not in older versions): >>> from fractions import Fraction >>> from decimal import Decimal >>> Fraction(33, 5) < INF True >>> Decimal("42.1568") < INF True > when it's a far > better use of my time to spend days if not weeks bemoaning yet another > language wart? Why should I be expected to know what float('inf') > actually represents before making stupid demands like: > >> INFINITY need not be a int or a float or a str, or whatever. > > Please provide a non-contrived use case of an "infinite string". Any lazy stream of characters that potentially goes on forever could be considered an infinite string. But that's not what Rick is talking about. He's talking about having a pair of special values, say, BIGGEST and SMALLEST, which compare larger and smaller to any other value, regardless of type and including strings, not literally a string with an infinite number of characters. I can see some value for this as a convenience, but not enough to make it a built-in language feature. Every developer should have at least one utility module with all the trivial code snippets they frequently use. This belongs in there. -- Steven From rosuav at gmail.com Sun Feb 26 22:59:48 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 14:59:48 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Feb 27, 2012 at 2:51 PM, Steven D'Aprano wrote: > I can see some value for this as a convenience, but not enough to make it > a built-in language feature. Every developer should have at least one > utility module with all the trivial code snippets they frequently use. +1. I used to call mine "oddsends" - it nicely fitted into eight characters (yeah, was important then - I was on DOS), and I had quite a few odds and ends in there. ChrisA From frank at chagford.com Mon Feb 27 01:16:47 2012 From: frank at chagford.com (Frank Millman) Date: Mon, 27 Feb 2012 08:16:47 +0200 Subject: Question about circular imports References: Message-ID: > > To avoid the tedious reference, follow this with > read = sound.formats.wavread # choose the identifier you prefer > @Terry and OKB I tried that, but it does not work. a.py /b __init__.py c.py d.py a.py - from b import c c.py - import b.d d.py - import b.c If I run a.py, it returns with no error. c.py - import b.d d = b.d d.py - import b.c c = b.c If I run a.py, I get Traceback (most recent call last): File "F:\tests\a.py", line 1, in from b import c File "F:\tests\b\c.py", line 1, in import b.d File "F:\tests\b\d.py", line 2, in c = b.c AttributeError: 'module' object has no attribute 'c' I get the same if I try 'import b.c as c'. Frank From wuwei23 at gmail.com Mon Feb 27 01:49:27 2012 From: wuwei23 at gmail.com (alex23) Date: Sun, 26 Feb 2012 22:49:27 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3c820774-85e6-4d04-b372-b8400867872b@l1g2000vbc.googlegroups.com> On Feb 27, 1:51?pm, Steven D'Aprano wrote: > Ints and floats can be compared directly, no need to convert the int to a > float first Ah, cheers. You can see how often I use the two interchangeably :) > > Please provide a non-contrived use case of an "infinite string". > > Any lazy stream of characters that potentially goes on forever could be > considered an infinite string. But that's not what Rick is talking about. > > He's talking about having a pair of special values, say, BIGGEST and > SMALLEST, which compare larger and smaller to any other value, regardless > of type and including strings, not literally a string with an infinite > number of characters. Yeah, my point was more to highlight Rick's laziness in co-opting a defined term - INFINITE - and trying to use it to mean something else that he couldn't express clearly. His original post stressed numeric comparison, the feature creep to include all other types happened later. Not the sort of thing we've come to expect from the resident linguist extraordinaire :) > I can see some value for this as a convenience, but not enough to make it > a built-in language feature. For me, it feels like a step backwards to comparing different types: >>> 1 < INFINITE True >>> 'string' < INFINITE True >>> 1 < 'string' Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < str() > Every developer should have at least one > utility module with all the trivial code snippets they frequently use. > This belongs in there. Agreed. Especially when it's so trivial: class Bound(object): def __init__(self, value=None, always_greater=False): self.value = value self.always_greater = always_greater def __cmp__(self, other): return True if self.always_greater else self.value.__cmp__(other) >>> upper = Bound(100) >>> 101 > upper True >>> 101 < upper False >>> infinite = Bound(always_greater=True) >>> 101 > infinite False >>> 101 < infinite True >>> upper < 101 < infinite True From johnjsal at gmail.com Mon Feb 27 02:24:31 2012 From: johnjsal at gmail.com (John Salerno) Date: Sun, 26 Feb 2012 23:24:31 -0800 (PST) Subject: How can I make an instance of a class act like a dictionary? Message-ID: Hi everyone. I created a custom class and had it inherit from the "dict" class, and then I have an __init__ method like this: def __init__(self): self = create() The create function creates and returns a dictionary object. Needless to say, this is not working. When I create an instance of the above class, it is simply an empty dictionary rather than the populated dictionary being created by the create function. Am I doing the inheritance wrong, or am I getting the above syntax wrong by assigning the return value to self? I know I could do self.variable = create() and that works fine, but I thought it would be better (and cleaner) simply to use the instance itself as the dictionary, rather than have to go through an instance variable. Thanks. From clp2 at rebertia.com Mon Feb 27 02:39:01 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 26 Feb 2012 23:39:01 -0800 Subject: How can I make an instance of a class act like a dictionary? In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the > "dict" class, and then I have an __init__ method like this: > > def __init__(self): > ? ? ? ?self = create() > > The create function creates and returns a dictionary object. Needless > to say, this is not working. When I create an instance of the above > class, it is simply an empty dictionary rather than the populated > dictionary being created by the create function. Am I doing the > inheritance wrong, or am I getting the above syntax wrong by assigning > the return value to self? Assignment to `self` has no effect outside the method in question; Python uses call-by-object (http://effbot.org/zone/call-by-object.htm ) for argument passing. Even in something like C++, I believe assignment to `this` doesn't work. > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Call the superclass (i.e. dict's) initializer (which you ought to be doing anyway): super(YourClass, self).__init__(create()) Cheers, Chris -- http://rebertia.com From nanothermitefbibustardsattn at gmail.com Mon Feb 27 04:32:06 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 01:32:06 -0800 (PST) Subject: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * * References: <04efd690-a95d-436a-a62f-6bafce40337a@32g2000yqn.googlegroups.com> <1239b6c7-5c47-4536-9db0-60303d9285f7@t15g2000yqi.googlegroups.com> <23e8bc3d-8586-4741-b5e7-7d20f1711fc6@n12g2000yqb.googlegroups.com> Message-ID: <8fdbd7dd-ff24-4dd8-a6f4-b11abdc4e501@c21g2000yqi.googlegroups.com> test From nanothermitefbibustardsattn at gmail.com Mon Feb 27 04:34:39 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 01:34:39 -0800 (PST) Subject: minimal set theory References: <28250a1d-d984-4d02-aec8-4e1864b31e44@sk8g2000pbc.googlegroups.com> <868bf65a-30e3-4ca0-a4d0-9bac422b4267@t15g2000yqi.googlegroups.com> <597245e9-ba30-4500-9887-a2d5b730b7a5@q12g2000yqg.googlegroups.com> <781a3889-d3d5-4878-9816-e9b248fc2fe1@tc8g2000pbc.googlegroups.com> <87aa45l7wp.fsf@uta.fi> Message-ID: test From albert at spenarnc.xs4all.nl Mon Feb 27 05:24:53 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 27 Feb 2012 10:24:53 GMT Subject: Numerical Linear Algebra in arbitrary precision References: Message-ID: In article , Ken wrote: >Brand new Python user and a bit overwhelmed with the variety of >packages available. Any recommendation for performing numerical >linear algebra (specifically least squares and generalized least >squares using QR or SVD) in arbitrary precision? I've been looking at >mpmath but can't seem to find much info on built in functions except >for LU decomposition/solve. Arbitrary precision? As in automatically increasing precision to stay exact? You will find this impractical as the number of decimals will explode, or you will find it not at all. If you mean that you want to be able to select something with larger precision than single or double floats, numpy is the starting point. > >Appreciate any comments. > >Ken Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From Tonicopm at yahoo.com Mon Feb 27 05:27:51 2012 From: Tonicopm at yahoo.com (Tonico) Date: Mon, 27 Feb 2012 02:27:51 -0800 (PST) Subject: From Cain To Khazaria: The True Genealogy of the Jewish People, Documented From the Bible and From Jewish Writings References: <28250a1d-d984-4d02-aec8-4e1864b31e44@sk8g2000pbc.googlegroups.com> <868bf65a-30e3-4ca0-a4d0-9bac422b4267@t15g2000yqi.googlegroups.com> <597245e9-ba30-4500-9887-a2d5b730b7a5@q12g2000yqg.googlegroups.com> <781a3889-d3d5-4878-9816-e9b248fc2fe1@tc8g2000pbc.googlegroups.com> <87aa45l7wp.fsf@uta.fi> <37c9db25-c056-4bd6-b26b-748802aa5492@t16g2000yqt.googlegroups.com> Message-ID: <1cb41569-7ec9-4b11-8994-e356523664cc@hs8g2000vbb.googlegroups.com> On Feb 27, 11:38?am, NanoThermite FBibustards wrote: > A copy of ?The Great Impersonation? can be obtained for $37 (Postpaid) > from my website,www.anglo-saxonisrael.comvia Paypal, or by mail from > ANP POB 411373, Chicago IL 60641. > > From Cain To Khazaria: > > The True Genealogy of the Jewish People, Documented From the Bible and > From Jewish Writings > > (They're NOT Who You THINK They Are!) > > By Pastor Eli James > > Therefore, behold, I will proceed to do a marvellous work among this > people, even a marvellous work and a wonder: for the wisdom of their > wise men shall perish, and the understanding of their prudent men > shall be hid. - Isa. 29:14. > > Children of True Israel, there is a GIGANTIC COVER-UP going on in the > world of religion. It is a DECEPTION of such vast proportions that it > affects every moment of your life. It affects your income, your > health, your family, your residence, your faith, your business, your > welfare and even your sex life. Ultimately, it affects your immortal > soul, which, at this moment in time, is in serious jeopardy. This > cover-up has confounded the wisdom and judgment of millions of > otherwise good people. Most Christians simply do not realize that > there is an IMPOSTOR posing as Israel. > > I have written a 333-page book about this impostor. The book is > entitled, The Great Impersonation, How the Anti-Christ Has Deceived > the Whole World. This book details the two families that came out of > the Garden of Eden. Genesis 3:15 clearly predicts that these two > families will be in a state of continuous war with each other until > the Great Day of the Lord. Yet, no denomination, outside of Christian > Identity, teaches anything about this. Nor do they teach that the > whole world will be deceived by this ?beast,? and largely succumb to > its deceptions. > > Jesus Christ, Himself, repeatedly warns us against the wiles of this > evil generation (race) of vipers (John 8:33-44), who are so evil that > He even refuses to try to convert them (Matt. 13:13-15). > > The purpose of this essay is to demonstrate two basic propositions: > 1.) The Jews ARE NOT related to any of the Twelve Tribes of Israel, > including the Tribe of Judah, and 2.) Judaism IS NOT related to the > Mosaic Law. In fact, it will be proven herein, beyond any doubt, that > Judaism is an IMPOSTOR RELIGION, just as the Jewish people are an > IMPOSTOR PEOPLE. These two great deceptions, combined into one > culture, namely Jewish culture, form the basis of the entity that the > bible calls ?the beast that deceiveth the whole world.? (Rev. 12:9.) > > Obviously, it never occurs to the average good-hearted Christian that > the devil might come calling, wearing priestly garb; but that is > exactly the ploy that the devil is using. Not only that, the devil > employs entire denominations of priests, who both innocently and > deliberately, promote this gigantic deception. > > To put the situation somewhat indelicately, ?Cupidity always defeats > stupidity, because stupidity cannot recognize cupidity.? A related > maxim is ?The victim of the con game is always the last to know.? In > the meantime, the victim gets taken for all he is worth. > > Who Are the Jews? > > First, we must examine several Jewish claims, as to their ?Semitic? > ancestry. Are these claims true or are they false? > > One of the more famous Jewish claims to Israelite heritage is the > rabbinical claim that the Jewish people are the exclusive descendants > of Abraham. This is based on Gen. 12:3. Let's read this passage and > see if it lives up to Jewish claims: > > And I will bless them that bless thee, and curse him that curseth > thee: and in thee shall all families of the earth be blessed. > > This passage is used by Jews and Christians to imply that, if we don't > bless the Jewish people, then we Christians will not be blessed. This > blessing is stated as CONDITIONAL. Being a conditional, it behooves > non-Abrahamites ? the passage DOES NOT MENTION JEWS!! - to bless > Abraham if these non-Abrahamites wish to be blessed. The fact must be > pointed out that nowhere in Scripture is Abraham identified with the > Jewish people. In fact, such an identification is automatically > ANACHRONISTIC, meaning that Abraham, being the grandfather of Israel, > cannot be named after any of his descendants. Jacob was an Abrahamite, > but Abraham was certainly not an Israelite! No grandfather has ever > been named after his grandson. > > It is also true that nowhere in Scripture are the Israelites ever > called ?Jews.? ?There is absolutely no such statement in either > Testament, that says, ?Jacob is a Jew? or ?Israel is a Jew,? or even > ?Judah is a Jew.? In fact, we have several COUNTEREXAMPLES, which > prove the opposite to be true! II Kings 16:6 refers to the House of > Judah as ?Jews,? but it refers to the House of Israel as ?Israel.? > Now, if the Jews are Israel, as we are constantly told, why does this > passage contradict them? The fact is that the word ?Jew? is a modern > invention that simply does not mean either ?Judah? or Israel? or > ?Abraham.? ?All of these claims are deceptions invented by the rabbis > for the express purpose of deceiving Christians. > > Let's look at the entire blessing (verses 1-3) that Yahweh put upon > Abraham and see if it can be applied to the Jewish people: > > 1 Now the LORD had said unto Abram, Get thee out of thy country, and > from thy kindred, and from thy father's house, unto a land that I will > shew thee: 2 And I will make of thee a great nation, and I will bless > thee, and make thy name great; and thou shalt be a blessing: 3 And I > will bless them that bless thee, and curse him that curseth thee: and > in thee shall all families of the earth be blessed. ? Gen. 12:1-3. > > Point #1: Verse 2 says that Yahweh will make a ?great nation? out of > Abraham. Certainly, Abraham's name has become ?great,? but the Jewish > people have always been a greatly despised people, throughout history. > This is proven by their own admissions. They are always recounting how > they have been ?persecuted? by every nation in which they have dwelt. > > Point #2: Abraham had a total of eight sons by three wives. He had > Ishmael by Hagar, Isaac by Sarah; and he had six sons by Keturah, > after Sarah died. These six sons were named Zimran, Jokshan, Medan, > Midian, Ishbak and Shuah (Gen. 25:1). Now all of these 8 sons were > Abrahamites, but none of them were Jews! The Jewish claim that the > blessings of Gen. 12 apply to them is simply false. The Bible says no > such thing! The rabbis have made this doctrine up out of nothing, in > their yeshivas of sophistry! > > Paul tells us to beware of Jewish fables (Titus 1:14); and their > PARTIAL QUOTATION of Gen. 12:3, which doesn?t even mention Jews, is > the beginning of the biggest Jewish Fable of them all: the Great > Impersonation of Israel by the Jews. > > Point #3: Verse 2 states an UNCONDITIONAL blessing: ?and thou shalt be > a blessing.? But, since the Jews ADMIT to being a nation toward which > every other nation has always been hostile, how can they be a > ?blessing? to those nations, who despise them and throw them out! > There is something seriously wrong with these Jewish claims! > > Point #4: Verse 3 says, ?in thee shall all the nations of the earth be > blessed.? Here is another BLATANTLY obvious contradiction between what > is said about Abraham and the Jewish experience. The fact is that the > Jewish people have always been despised wherever they have gone! I > would challenge anyone to cite a single nation in which the Jews have > dwelt, which has considered their presence to be a blessing. On the > contrary, they would not have been expelled from over 100 nations > (Spain, France, Germany, England, etc.) and city-states if the > inhabitants thought they were a blessing. Rather, the Jews have always > been considered a curse and a pestilence wherever they have chosen to > reside. > > And this historical fact fits the Curse of Cain perfectly: fugitives > and vagabonds, (Gen. 4:12) wandering from place to place, because > their presence is so irritating to the host. Of course, the Jews never > quote this passage with regard their own people, even though it > precisely fits the Jewish historical experience. These obvious > discrepancies between Jewish history and the blessings of Abraham tell > us that something is very wrong here! > > Either the Jews are lying about who they are, or the very history that > they claim is wrong. > > Point #4: Under then President Harry S. Truman, America was the first > nation in the world to recognize the bandit State of Impostors. It has > no been over 60 years since that rogue state came into existence. > America was the first to bless the Israelis and America has blessed > the Israelis more abundantly than any other nation. QUESTION: What are > the blessings that we have received in return for blessing the Jews? > ANASER: Chaos, mayhem, debts, subterfuge, treason, war, war, war, and > more war. Our society has precipitously declined morally, spiritually, > economically, religiously, and even intellectually as a result of the > fact that we are blessing the WRONG PEOPLE. > > There are only two possibilities, either the Jews are lying about who > they are, or the blessings of Gen. 12:3 are false. > > In addition, the Jews trace their supposed ?Semitic? descent from > Abraham. Is this also a lie? Yes, it most assuredly is, because all of > Abraham's eight male descendants MUST ALSO BE Shemites, as they are > his direct descendants. Ishmael, the son of Hagar, had twelve sons of > his own; and these sons became known to the world as the Arabs! So, > the Arabs are Shemites. Isaac, son of Sarah, is also, therefore, a > Shemite. And Keturah's six sons are also Shemites. But none of these > people are ever given credit by the Jews for their OBVIOUS SHEMITIC > DESCENT ? through Abraham! > > Consequently, it can be easily seen that the Jewish assertion that > ONLY JEWS are included in the context of Gen. 12:3 is SHEER > PRETENSE! ? The Jewish version of > > read more ?... Idiot From dan at tombstonezero.net Mon Feb 27 05:52:25 2012 From: dan at tombstonezero.net (Dan Sommers) Date: Mon, 27 Feb 2012 10:52:25 +0000 (UTC) Subject: How can I make an instance of a class act like a dictionary? References: Message-ID: On Sun, 26 Feb 2012 23:24:31 -0800, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the "dict" > class, and then I have an __init__ method like this: > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Check out the "Bunch" class: http://code.activestate.com/recipes/52308/ HTH, Dan From ghosh236 at gmail.com Mon Feb 27 06:24:52 2012 From: ghosh236 at gmail.com (honey ghosh) Date: Mon, 27 Feb 2012 03:24:52 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfreehome.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfreehome.yolasite.com/ Thanks ?? From jeanmichel at sequans.com Mon Feb 27 06:55:52 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 12:55:52 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> Message-ID: <4F4B6F48.8070108@sequans.com> Rick Johnson wrote: > On Feb 25, 11:54 am, MRAB wrote: > >> [...] >> That should be: >> if maxlength is not None and len(string) <= maxlength: >> > > Using "imaginary" infinity values defiles the intuitive nature of your > code. What is more intuitive? > > def confine_length(string, maxlength=INFINITY): > if string.length < maxlength: > do_something() > > def confine_length(string, maxlength=None): > if maxlength is not None and len(string) <= maxlength: > do_something() > This one: def confine_length(string, maxlength=None): """Confine the length. @param maxlength: the maximum length allowed, set it to None to allow any length. """ if maxlength is not None and len(string) <= maxlength: do_something() I'm just feeding the troll, I know ... :-/ JM From neilc at norwich.edu Mon Feb 27 07:25:35 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 27 Feb 2012 12:25:35 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <9r1b1vF8t2U2@mid.individual.net> On 2012-02-26, Wolfgang Meiners wrote: > but it really does not look intuitive. Hmm. My idea was that > None is a perfect Value for infinity since there is no > infinitely large number. But as i see it, you must have two > comparisons then. Maybe someone has a better idea? I do. A truncated string with a maxlength of INFINITY is just a string. -- Neil Cerutti From kym at sdf.lonestar.org Mon Feb 27 07:46:16 2012 From: kym at sdf.lonestar.org (R Kym Horsell) Date: Mon, 27 Feb 2012 12:46:16 +0000 (UTC) Subject: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * * References: <04efd690-a95d-436a-a62f-6bafce40337a@32g2000yqn.googlegroups.com> <1239b6c7-5c47-4536-9db0-60303d9285f7@t15g2000yqi.googlegroups.com> <23e8bc3d-8586-4741-b5e7-7d20f1711fc6@n12g2000yqb.googlegroups.com> <8fdbd7dd-ff24-4dd8-a6f4-b11abdc4e501@c21g2000yqi.googlegroups.com> Message-ID: In sci.physics NanoThermite FBibustards wrote: > test fail. -- From amirouche.boubekki at gmail.com Mon Feb 27 08:44:20 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Mon, 27 Feb 2012 14:44:20 +0100 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: for which I could write Python programs. > Android is good bet, kivy has official support for it http://kivy.org/docs/guide/android.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From matze999 at gmail.com Mon Feb 27 08:49:56 2012 From: matze999 at gmail.com (Matt Funk) Date: Mon, 27 Feb 2012 14:49:56 +0100 Subject: setting the length of the backtrace output in pdb Message-ID: Hi, this might be a rather silly question, but i cannot figure out how to make pdb give me more than 10 lines of output whenever i issue a backtrace command. Is there an easy way to do this? thanks matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Mon Feb 27 08:57:56 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 13:57:56 +0000 Subject: windows executable calling python script Message-ID: <4F4B8BE4.9070908@gmail.com> I am creating an installer for python projects, using CMake and NSIS. Now my goal is to be able to select at installer time the python executable that will run that project, and then associate them. I saw that setuptools is able to generate exe wrappers, but how does that work exactly? From what I've understood there is some compiled C code that somehow calls the python script, is that correct? Supposing I ship this executable in the same directory of the python script (with a known name), is there a way to make it run the right python interpreter? The best and easiest solution would be to generate the full installer with PyInstaller or similar, but unfortunately that doesn't work yet, and we would still need both approaches anyway. From dihedral88888 at googlemail.com Mon Feb 27 09:00:22 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 27 Feb 2012 06:00:22 -0800 (PST) Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: <8210916.2683.1330351222098.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?26????UTC+8??9?00?31??Chris Angelico??? > On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > > This is however a bit errorprone. If you accidentally write the loading code > > as > > > > fruit, beverages, vegetables = pickle.load(f) > > > > you'll end up drinking potatoes. > > You mean vodka? :) > > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. > > Of course, sometimes that exception is absolutely correct. If you wrap > all this in an exception handler that gives some reasonable behaviour > - which might even be "terminate the program with a traceback", which > is the default - then it's fine to let it throw on failure, and > anything else is just a waste of effort. But for maximum > extensibility, you would want to make it so that you can add more > elements to what you save without your code breaking on an old save > file - and that's where the dictionary is far better. A slight tweak, > though: > > data = pickle.load(f) > fruit = data.get("fruit",[]) > beverages = data.get("beverages",[]) > vegetables = data.get("vegetables",[]) > > With this, you guarantee that (a) unrecognized keys will be safely > ignored, and (b) absent keys will quietly go to their given defaults. > > ChrisA I love python for pickle and zip lib build in. I write programs that stay in the L1 or L2 cache of the CPU > 97% percent of chance of nontrivial executions. From dihedral88888 at googlemail.com Mon Feb 27 09:00:22 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 27 Feb 2012 06:00:22 -0800 (PST) Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: <8210916.2683.1330351222098.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?26????UTC+8??9?00?31??Chris Angelico??? > On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > > This is however a bit errorprone. If you accidentally write the loading code > > as > > > > fruit, beverages, vegetables = pickle.load(f) > > > > you'll end up drinking potatoes. > > You mean vodka? :) > > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. > > Of course, sometimes that exception is absolutely correct. If you wrap > all this in an exception handler that gives some reasonable behaviour > - which might even be "terminate the program with a traceback", which > is the default - then it's fine to let it throw on failure, and > anything else is just a waste of effort. But for maximum > extensibility, you would want to make it so that you can add more > elements to what you save without your code breaking on an old save > file - and that's where the dictionary is far better. A slight tweak, > though: > > data = pickle.load(f) > fruit = data.get("fruit",[]) > beverages = data.get("beverages",[]) > vegetables = data.get("vegetables",[]) > > With this, you guarantee that (a) unrecognized keys will be safely > ignored, and (b) absent keys will quietly go to their given defaults. > > ChrisA I love python for pickle and zip lib build in. I write programs that stay in the L1 or L2 cache of the CPU > 97% percent of chance of nontrivial executions. From benjamin at python.org Mon Feb 27 09:16:35 2012 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 27 Feb 2012 14:16:35 +0000 (UTC) Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, =?utf-8?b?My4xLjUsCWFuZA==?= 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: Ben Finney benfinney.id.au> writes: > > Putting ?RELEASED? in the subject, when they're not released and are > instead *candidates for* release, is confusing and muddies the issue of > what you even mean by ?release?. > {alpha, beta, release candidate, final} \subsetof releases From andrea.crotti.0 at gmail.com Mon Feb 27 09:21:31 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 14:21:31 +0000 Subject: windows executable calling python script In-Reply-To: <4F4B8BE4.9070908@gmail.com> References: <4F4B8BE4.9070908@gmail.com> Message-ID: <4F4B916B.7080600@gmail.com> On 02/27/2012 01:57 PM, Andrea Crotti wrote: > I am creating an installer for python projects, using CMake and NSIS. > > Now my goal is to be able to select at installer time the python > executable that will run that project, > and then associate them. > > I saw that setuptools is able to generate exe wrappers, but how does > that work exactly? > From what I've understood there is some compiled C code that somehow > calls the python script, is that correct? > Supposing I ship this executable in the same directory of the python > script (with a known name), is there a way > to make it run the right python interpreter? > > The best and easiest solution would be to generate the full installer > with PyInstaller or similar, but unfortunately > that doesn't work yet, and we would still need both approaches anyway. At the moment I ended up with something like this: #include #include #include #include // the function takes as arguments only the python interpreter full path int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage = ./run "); exit(1); } /* TODO: make the path absolute? is it necessary? */ char *const to_run[1] = {"run.py"}; /* TODO: check if the path exists or not, and if it's executable */ execv(argv[1], to_run); return 1; } which still doesn't work (I have to fix the execv) but when it will in theory I will only need to tell NSIS to create a link to that executable passing as argument the right python executable. After that it will run the run.py with in the local directory.. Easier ways (without py2exe and similars?)? From jeanmichel at sequans.com Mon Feb 27 09:23:00 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 15:23:00 +0100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87haydss3w.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: <4F4B91C4.10805@sequans.com> Ben Finney wrote: > Chris Angelico writes: > > >> On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: >> > > >>> If you're pleased to announce their immediate availability, then >>> please do that! >>> >> Isn't it perfectly accurate to say that the RCs are now available? >> > > Yes. What's not reasonable is to say that a candidate for release ? i.e. > something *prior to* release, by definition ? is nevertheless released. > > >> Considering that "Release candidates" immediately followed "RELEASED" >> in the subject line, I don't see any confusion. >> > > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. > > Either it's released, or it's not. If it's a release candidate, it's not > released yet. If it's released, it's no longer a candidate for release. > > Saying it's simultaneously both is the confusion. > > What sort of release can you release ? A release candidate. If you can release a release candidate, a release candidate can be released, hence the released candidate release. More important, we all thank the release team for their efforts and hope they're having fun reading us :o) JM From jeanmichel at sequans.com Mon Feb 27 09:59:52 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 15:59:52 +0100 Subject: Question about circular imports In-Reply-To: References: Message-ID: <4F4B9A68.1050602@sequans.com> Frank Millman wrote: > Hi all > > I seem to have a recurring battle with circular imports, and I am trying to > nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is to > reorganise the code to avoid this, and I try to do this where possible, but > for now I would like to address the question of how to handle the situation > if this is otherwise unavoidable. > Hi Frank, If you consider it unavoidable you've already lost. There is no reliable solution to circular import except refactoring the code to place all common code elsewhere: wavbase.py wavread.py (import wavbase) wavwrite.py (import wavbase) Any code required by both waread and wavwrite would end up in wavbase. Is there anything that prevent you from doing this ? JM From invalid at invalid.invalid Mon Feb 27 10:02:51 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 27 Feb 2012 15:02:51 +0000 (UTC) Subject: Python math is off by .000000000000045 References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2012-02-27, Steven D'Aprano wrote: > On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: > >> Curiosity prompts me to ask... >> >> Those of you who program in other languages regularly: if you visit >> comp.lang.java, for example, do people ask this question about >> floating-point arithmetic in that forum? Or in comp.lang.perl? > > Yes. > > http://stackoverflow.com/questions/588004/is-javascripts-math-broken > > And look at the "Linked" sidebar. Obviously StackOverflow users no > more search the internet for the solutions to their problems than do > comp.lang.python posters. > > http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error One might wonder if the frequency of such questions decreases as the programming language becomes "lower level" (e.g. C or assembly). -- Grant Edwards grant.b.edwards Yow! World War III? at No thanks! gmail.com From andrea.crotti.0 at gmail.com Mon Feb 27 10:05:22 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 15:05:22 +0000 Subject: windows executable calling python script In-Reply-To: <4F4B916B.7080600@gmail.com> References: <4F4B8BE4.9070908@gmail.com> <4F4B916B.7080600@gmail.com> Message-ID: <4F4B9BB2.6070908@gmail.com> On 02/27/2012 02:21 PM, Andrea Crotti wrote: > > At the moment I ended up with something like this: > > #include > #include > #include > #include > > > // the function takes as arguments only the python interpreter full path > int main(int argc, char *argv[]) > { > if (argc < 2) { > fprintf(stderr, "Usage = ./run "); > exit(1); > } > /* TODO: make the path absolute? is it necessary? */ > char *const to_run[1] = {"run.py"}; > /* TODO: check if the path exists or not, and if it's executable */ > > execv(argv[1], to_run); > return 1; > } > > which still doesn't work (I have to fix the execv) but when it will in > theory I will only need > to tell NSIS to create a link to that executable passing as argument > the right python executable. > After that it will run the run.py with in the local directory.. > > Easier ways (without py2exe and similars?)? For the record I think I found a solution, now the wrapper works: int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage = ./run "); exit(1); } /* TODO: make the path absolute? is it necessary? */ char *const to_run[] = {"python", RUNNER, (char *) 0}; execv(argv[1], to_run); return 1; } and I only need to tell NSIS to create a shortcut passing as argument the path to the python executable, nice and simple.. From torriem at gmail.com Mon Feb 27 10:34:54 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 27 Feb 2012 08:34:54 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4BA29E.90509@gmail.com> On 02/27/2012 08:02 AM, Grant Edwards wrote: > On 2012-02-27, Steven D'Aprano wrote: >> On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: >> >>> Curiosity prompts me to ask... >>> >>> Those of you who program in other languages regularly: if you visit >>> comp.lang.java, for example, do people ask this question about >>> floating-point arithmetic in that forum? Or in comp.lang.perl? >> >> Yes. >> >> http://stackoverflow.com/questions/588004/is-javascripts-math-broken >> >> And look at the "Linked" sidebar. Obviously StackOverflow users no >> more search the internet for the solutions to their problems than do >> comp.lang.python posters. >> >> http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error > > One might wonder if the frequency of such questions decreases as the > programming language becomes "lower level" (e.g. C or assembly). I think that most of the use cases in C or assembly of math are integer-based only. For example, counting, bit-twiddling, addressing character cells or pixel coordinates, etc. Maybe when programmers have to statically declare a variable type in advance, since the common use cases require only integer, that gets used far more, so experiences with float happen less often. Some of this could have to do with the fact that historically floating point required a special library to do floating point math, and since a lot of people didn't have floating-point coprocessors back then, most code was integer-only. Early BASIC interpreters defaulted to floating point for everything, and implemented all the floating point arithmetic internally with integer arithmetic, without the help of the x87 processor, but no doubt they did round the results when printing to the screen. They also did not have very much precision to begin with. Anyone remember Microsoft's proprietary floating point binary system and how there were function calls to convert back and forth between the IEEE standard? Another key thing is that most C programmers don't normally just print out floating point numbers without a %.2f kind of notation that properly rounds a number. Now, of course, every processor has a floating-point unit, and the C compilers can generate code that uses it just as easily as integer code. No matter what language, or what floating point scheme you use, significant digits is definitely important to understand! From hwfwguy at gmail.com Mon Feb 27 11:51:12 2012 From: hwfwguy at gmail.com (Brad) Date: Mon, 27 Feb 2012 08:51:12 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: <69ef9280-d781-4111-9434-3c7ac80249c3@f14g2000yqe.googlegroups.com> On Feb 26, 7:01?pm, NanoThermite FBibustards wrote: > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > Bret's main point is that creators need immediate feedback. Okay, that's Forth. But he illustrated something else about the Forth way of working. When you try ideas out immediately, you discover things you wouldn't have thought of if you had written the whole program and then worked through debugging and integration. Another point he made is about crusaders (my word), people who see something wrong with the status quo and make it their business to change it based on principle. Chuck wasn't the crusader type (maybe he didn't look good in spandex). From eric.frederich at gmail.com Mon Feb 27 11:57:20 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Mon, 27 Feb 2012 11:57:20 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F47D89A.4080806@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> Message-ID: Still freezing sometimes, like 1 out of 10 times that I run it. Here is updated code and a couple of outputs. ################ code #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, name, inbox, outbox): super(MyWorker, self).__init__() self.name = name self.inbox = inbox self.outbox = outbox print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() def run(self): print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() print >> sys.stderr, '%s got something to do' % self.name; sys.stderr.flush() except Queue.Empty: break self.outbox.put(FOO(*args)) if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() w1 = MyWorker('Worker 1', todo, result_queue) w2 = MyWorker('Worker 2', todo, result_queue) print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() w1.start() print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() w2.start() for i in xrange(100): print result_queue.get() ################ output 1 (I ctrl-c'd it after it froze) Creating todo queue Creating results queue Creating Workers Created Worker 1 Created Worker 2 Starting Worker 1 Running Worker 1 Starting Worker 2 Running Worker 2 Traceback (most recent call last): File "./multi.py", line 53, in print result_queue.get() File "/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py", line 91, in get res = self._recv() KeyboardInterrupt ################### output 2 Creating todo queue Creating results queue Creating Workers Created Worker 1 Created Worker 2 Starting Worker 1 Running Worker 1 Worker 1 got something to do Starting Worker 2 foo 0 1 2 Worker 1 got something to do foo 1 2 3 Worker 1 got something to do foo 2 3 4 Worker 1 got something to do foo 3 4 5 Worker 1 got something to do foo 4 5 6 Worker 1 got something to do foo 5 6 7 Worker 1 got something to do foo 6 7 8 Worker 1 got something to do foo 7 8 9 Worker 1 got something to do foo 8 9 10 Worker 1 got something to do foo 9 10 11 Worker 1 got something to do foo 10 11 12 Worker 1 got something to do foo 11 12 13 Worker 1 got something to do foo 12 13 14 Worker 1 got something to do foo 13 14 15 Worker 1 got something to do foo 14 15 16 Worker 1 got something to do foo 15 16 17 Worker 1 got something to do foo 16 17 18 Worker 1 got something to do foo 17 18 19 Running Worker 2 2 9 20 35 54 77 104 135 170 209 252 299 350 405 464 527 594 665 Traceback (most recent call last): File "./multi.py", line 53, in print result_queue.get() File "/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py", line 91, in get res = self._recv() KeyboardInterrupt On Fri, Feb 24, 2012 at 1:36 PM, MRAB wrote: > On 24/02/2012 17:00, Eric Frederich wrote: > >> I can sill get it to freeze and nothing is printed out from the other >> except block. >> Does it look like I'm doing anything wrong here? >> >> [snip] > I don't normally use multiprocessing, so I forgot about a critical > detail. :-( > > When the multiprocessing module starts a process, that process > _imports_ the module which contains the function which is to be run, so > what's happening is that when your script is run, it creates and starts > workers, the multiprocessing module makes a new process for each > worker, each of those processes then imports the script, which creates > and starts workers, etc, leading to an ever-increasing number of > processes. > > The solution is to ensure that the script/module distinguishes between > being run as the main script and being imported as a module: > > > #!/usr/bin/env python > > import sys > import Queue > import multiprocessing > import time > > def FOO(a, b, c): > print 'foo', a, b, c > return (a + b) * c > > class MyWorker(multiprocessing.**Process): > def __init__(self, inbox, outbox): > super(MyWorker, self).__init__() > self.inbox = inbox > self.outbox = outbox > print >> sys.stderr, '1' * 80; sys.stderr.flush() > def run(self): > print >> sys.stderr, '2' * 80; sys.stderr.flush() > while True: > try: > args = self.inbox.get_nowait() > except Queue.Empty: > break > self.outbox.put(FOO(*args)) > > if __name__ == '__main__': > # This file is being run as the main script. This part won't be > # run if the file is imported. > > todo = multiprocessing.Queue() > > for i in xrange(100): > todo.put((i, i+1, i+2)) > > print >> sys.stderr, 'a' * 80; sys.stderr.flush() > result_queue = multiprocessing.Queue() > > print >> sys.stderr, 'b' * 80; sys.stderr.flush() > w1 = MyWorker(todo, result_queue) > print >> sys.stderr, 'c' * 80; sys.stderr.flush() > w2 = MyWorker(todo, result_queue) > > print >> sys.stderr, 'd' * 80; sys.stderr.flush() > w1.start() > print >> sys.stderr, 'e' * 80; sys.stderr.flush() > w2.start() > print >> sys.stderr, 'f' * 80; sys.stderr.flush() > > for i in xrange(100): > print result_queue.get() > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Mon Feb 27 12:28:44 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 27 Feb 2012 09:28:44 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4BBD4C.1050603@stoneleaf.us> jmfauth wrote: > On 25 f?v, 23:51, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>>>> (2.0).hex() >>> '0x1.0000000000000p+1' >>>>>> (4.0).hex() >>> '0x1.0000000000000p+2' >>>>>> (1.5).hex() >>> '0x1.8000000000000p+0' >>>>>> (1.1).hex() >>> '0x1.199999999999ap+0' >>> jmf >> What's your point? I'm afraid my crystal ball is out of order and I have >> no idea whether you have a question or are just demonstrating your >> mastery of copy and paste from the Python interactive interpreter. > > It should be enough to indicate the right direction > for casual interested readers. I'm a casual interested reader and I have no idea what your post is trying to say. ~Ethan~ From ian.g.kelly at gmail.com Mon Feb 27 13:24:24 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 11:24:24 -0700 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 6:00 AM, Chris Angelico wrote: > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. While that's true, if your pickle is untrusted then a ValueError from unpacking is the least of your worries. You should never attempt to load an untrusted pickle in the first place, as doing so allows it to execute arbitrary code on your system. Cheers, Ian From ian.g.kelly at gmail.com Mon Feb 27 13:36:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 11:36:12 -0700 Subject: Question about circular imports In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 3:42 AM, Frank Millman wrote: > Hi all > > I seem to have a recurring battle with circular imports, and I am trying to > nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is to > reorganise the code to avoid this, and I try to do this where possible, but > for now I would like to address the question of how to handle the situation > if this is otherwise unavoidable. > > The problem is clearly explained in the Python Programming FAQ - > > "Circular imports are fine where both modules use the "import " form > of import. They fail when the 2nd module wants to grab a name out of the > first ("from module import name") and the import is at the top level. That's > because names in the 1st are not yet available, because the first module is > busy importing the 2nd." > > [SNIP] > > I can think of two solutions - one is cumbersome, the other may not be good > practice. Solution 3: don't do the circular imports at the top level. It's perfectly fine to do the imports locally inside the functions that need them, which resolves the circularity since normally the functions won't be called until the module is fully imported. It does add some overhead to the functions, basically the cost of a dict lookup. Cheers, Ian From johnjsal at gmail.com Mon Feb 27 15:09:55 2012 From: johnjsal at gmail.com (John Salerno) Date: Mon, 27 Feb 2012 12:09:55 -0800 (PST) Subject: How can I make an instance of a class act like a dictionary? References: Message-ID: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> On Feb 27, 1:39?am, Chris Rebert wrote: > On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > > Hi everyone. I created a custom class and had it inherit from the > > "dict" class, and then I have an __init__ method like this: > > > def __init__(self): > > ? ? ? ?self = create() > > > The create function creates and returns a dictionary object. Needless > > to say, this is not working. When I create an instance of the above > > class, it is simply an empty dictionary rather than the populated > > dictionary being created by the create function. Am I doing the > > inheritance wrong, or am I getting the above syntax wrong by assigning > > the return value to self? > > Assignment to `self` has no effect outside the method in question; > Python uses call-by-object (http://effbot.org/zone/call-by-object.htm > ) for argument passing. > Even in something like C++, I believe assignment to `this` doesn't work. > > > I know I could do self.variable = create() and that works fine, but I > > thought it would be better (and cleaner) simply to use the instance > > itself as the dictionary, rather than have to go through an instance > > variable. > > Call the superclass (i.e. dict's) initializer (which you ought to be > doing anyway): > ? ? super(YourClass, self).__init__(create()) > > Cheers, > Chris > --http://rebertia.com Thanks. This ended up working: def __init__(self): self = super().__init__(create_board()) Is that what you meant for me to do? Why did assigning to self work in this case, but not the original case? From benjamin.kaplan at case.edu Mon Feb 27 15:37:15 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 27 Feb 2012 15:37:15 -0500 Subject: How can I make an instance of a class act like a dictionary? In-Reply-To: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> References: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> Message-ID: On Mon, Feb 27, 2012 at 3:09 PM, John Salerno wrote: > On Feb 27, 1:39?am, Chris Rebert wrote: >> On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: >> > Hi everyone. I created a custom class and had it inherit from the >> > "dict" class, and then I have an __init__ method like this: >> >> > def __init__(self): >> > ? ? ? ?self = create() >> >> > The create function creates and returns a dictionary object. Needless >> > to say, this is not working. When I create an instance of the above >> > class, it is simply an empty dictionary rather than the populated >> > dictionary being created by the create function. Am I doing the >> > inheritance wrong, or am I getting the above syntax wrong by assigning >> > the return value to self? >> >> Assignment to `self` has no effect outside the method in question; >> Python uses call-by-object (http://effbot.org/zone/call-by-object.htm >> ) for argument passing. >> Even in something like C++, I believe assignment to `this` doesn't work. >> >> > I know I could do self.variable = create() and that works fine, but I >> > thought it would be better (and cleaner) simply to use the instance >> > itself as the dictionary, rather than have to go through an instance >> > variable. >> >> Call the superclass (i.e. dict's) initializer (which you ought to be >> doing anyway): >> ? ? super(YourClass, self).__init__(create()) >> >> Cheers, >> Chris >> --http://rebertia.com > > Thanks. This ended up working: > > def __init__(self): > ? ? ? ?self = super().__init__(create_board()) > > Is that what you meant for me to do? Why did assigning to self work in > this case, but not the original case? It didn't do anything and still isn't doing anything. In Python, names are assigned to objects self -> ^ foo -------| Reassigning a name does not change the value, so self = create() Just makes an object2 self -> foo ---> The reason it's working here is because the super().__init__() call modifies the existing object in place. It returns None, so you're setting self = None but that doesn't matter because of what I explained before about how assigning to self doesn't actually change anything. > -- > http://mail.python.org/mailman/listinfo/python-list From alexander.borghgraef at gmail.com Mon Feb 27 15:48:27 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Mon, 27 Feb 2012 12:48:27 -0800 (PST) Subject: Python urllib2 problem: Name or service not known Message-ID: Hi all, Some time ago I've written some python code to read video data off an IP camera connected via a router to a laptop. Now I try to run this code on a different laptop and router combination, but now I can't access the camera. Some minimal example code: import urllib2 url = urllib2.urlopen("http://192.168.1.3/-wvhttp-01-/image.cgi") This fails and returns the error: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: <87obskq810.fsf@benfinney.id.au> Benjamin Peterson writes: > Ben Finney benfinney.id.au> writes: > > > > Putting ?RELEASED? in the subject, when they're not released and are > > instead *candidates for* release, is confusing and muddies the issue of > > what you even mean by ?release?. > > > > {alpha, beta, release candidate, final} \subsetof releases So you've chosen to muddy what is meant by ?release? in announcements to the public. That's disappointing, but thank you for acknowledging it. I appreciate the work that goes toward releases of Python, but I do wish you'd use clear terminology in announcements. -- \ ?If history and science have taught us anything, it is that | `\ passion and desire are not the same as truth.? ?E. O. Wilson, | _o__) _Consilience_, 1998 | Ben Finney From vinay_sajip at yahoo.co.uk Mon Feb 27 17:18:07 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 27 Feb 2012 14:18:07 -0800 (PST) Subject: PEP 414 has been accepted Message-ID: PEP 414 has been accepted: http://mail.python.org/pipermail/python-dev/2012-February/116995.html This means that from Python 3.3 onwards, you can specify u'xxx' for Unicode as well as just 'xxx'. The u'xxx' form is not valid syntax in Python 3.2, 3.1 or 3.0. The idea is to make porting code from 2.x to 3.x easier than before. Get porting! Regards, Vinay Sajip From smallpox911 at gmail.com Mon Feb 27 17:43:30 2012 From: smallpox911 at gmail.com (small Pox) Date: Mon, 27 Feb 2012 14:43:30 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) Message-ID: America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case atleast) This message is in part to the FBI racists as well as well as to the RACIST KANGAROO courts of AMERICA. In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also France. In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN EVEN BEING RELEASED. Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE etc) have contempted themselves. Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS ANGELES COUNTY. That is why 9-11 is a jew job and israeli job and the COWARD YANK BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right thing. The court case record of RAPIST ROMAN POLANSKY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript A SWEET SHORT VIDEO for FBI bustards http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://anglo-saxonisrael.com/site/GreatImpersonation-8 From isragaytan at gmail.com Mon Feb 27 18:06:28 2012 From: isragaytan at gmail.com (isragaytan) Date: Mon, 27 Feb 2012 15:06:28 -0800 (PST) Subject: Transfer files via bluetooth for Blackberry devices Message-ID: <952be09c-50e6-4d80-bb56-77880a1bde1b@p12g2000yqe.googlegroups.com> Hi! I am newby on python. I am looking for a utility or a library for transfer files via bluetooth to blackberry. I am seeing that with obex may be is an option. Can you give me any advices on that?. Really appreciated Thanks! From nanothermitefbibustardsattn at gmail.com Mon Feb 27 18:08:27 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 15:08:27 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 27, 2:43?pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 On Feb 27, 2:43 pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 The YANK bustards are truly CONTEMPTUOUS ... It is because of the INCOMPETENT and RACIST dysfunctional courts that there is so much SCHOOL SHOOTINGS and VIOLENCE because NO ONE TRUSTS THE COURTS We will soon talk of the Kerri Dunn (1year for TERRORISM and HOAX) - jew daughter of a police officer VERSUS Dr Aafiya Siddiqui (90 years for FALSE and RIDICULOUS Charges by FBI ODIOUS and DESPICABLE LIARS) The FAT per DIEM FBI bustards use our TAX PAYER MONEY and INCOMPETENCE is UNACCEPTABLE. ===== http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M Hey Racist and INcompetent FBI Bustards, where is the ANTHRAX Mailer ? Where are the 4 blackboxes ? Where are the Pentagon Videos ? Why did you release the 5 dancing Israelis compromising the whole 911 investigation ? If the Dubai Police can catch Mossad Murderers and put the videos and Iranian Police can why cant you put the Pentagon Videos ? If Iran police can put the AMERICAN TERRORIST, Riggi and puting on INTERNATIONAL MEDIA a day after catching him without TORTURE, why cant you put the INNOCENT patsies on the MEDIA. Why did you have to LIE about Dr Afiya Siddiqui and torture that Innocent little mother of 3 and smashing the skull of her one child ? http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=0SZ2lxDJmdg There are CRIMINAL cases against CIA CRIMINAL Bustards in Italian courts. FBI bustards paid a penalty of $5.8 million to Steven Hatfill, but only because he was a white. They got away with MURDER of thousands of Non-whites in all parts of the world. Daily 911 news : http://911blogger.com http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY Conclusion : FBI bustards are RACIST and INcompetent. They could neither catch the ANTHRAX or 911 YANK/Jew criminals nor could they cover them up - whichever was their actual goal or task. SLASH the SALARIES of FBI/CIA/NSA etc BUSTARDS into half all across tbe board, esp the whites/jew on the top. FBI Bustards failed to Catch BERNARD MADOFF even after that RACIST and UNPATRIOTIC Act FBI bustards failed to prevent ROMAN POLANSKY from absconding to europe and rapes. FBI bustards failed to prevent OKLAHOMA From nanothermitefbibustardsattn at gmail.com Mon Feb 27 18:09:53 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 15:09:53 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 27, 2:43 pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 The YANK bustards are truly CONTEMPTUOUS ... It is because of the INCOMPETENT and RACIST dysfunctional courts that there is so much SCHOOL SHOOTINGS and VIOLENCE because NO ONE TRUSTS THE COURTS We will soon talk of the Kerri Dunn (1year for TERRORISM and HOAX) - jew daughter of a police officer VERSUS Dr Aafiya Siddiqui (90 years for FALSE and RIDICULOUS Charges by FBI ODIOUS and DESPICABLE LIARS) The FAT per DIEM FBI bustards use our TAX PAYER MONEY and INCOMPETENCE is UNACCEPTABLE. ===== http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M Hey Racist and INcompetent FBI Bustards, where is the ANTHRAX Mailer ? Where are the 4 blackboxes ? Where are the Pentagon Videos ? Why did you release the 5 dancing Israelis compromising the whole 911 investigation ? If the Dubai Police can catch Mossad Murderers and put the videos and Iranian Police can why cant you put the Pentagon Videos ? If Iran police can put the AMERICAN TERRORIST, Riggi and puting on INTERNATIONAL MEDIA a day after catching him without TORTURE, why cant you put the INNOCENT patsies on the MEDIA. Why did you have to LIE about Dr Afiya Siddiqui and torture that Innocent little mother of 3 and smashing the skull of her one child ? http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=0SZ2lxDJmdg There are CRIMINAL cases against CIA CRIMINAL Bustards in Italian courts. FBI bustards paid a penalty of $5.8 million to Steven Hatfill, but only because he was a white. They got away with MURDER of thousands of Non-whites in all parts of the world. Daily 911 news : http://911blogger.com http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY Conclusion : FBI bustards are RACIST and INcompetent. They could neither catch the ANTHRAX or 911 YANK/Jew criminals nor could they cover them up - whichever was their actual goal or task. SLASH the SALARIES of FBI/CIA/NSA etc BUSTARDS into half all across tbe board, esp the whites/jew on the top. FBI Bustards failed to Catch BERNARD MADOFF even after that RACIST and UNPATRIOTIC Act FBI bustards failed to prevent ROMAN POLANSKY from absconding to europe and rapes. FBI bustards failed to prevent OKLAHOMA From steve+comp.lang.python at pearwood.info Mon Feb 27 19:36:09 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Feb 2012 00:36:09 GMT Subject: Python urllib2 problem: Name or service not known References: Message-ID: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote: > Hi all, > > Some time ago I've written some python code to read video data off an IP > camera connected via a router to a laptop. Now I try to run this code on > a different laptop and router combination, but now I can't access the > camera. [...] Check your web proxy and firewall. -- Steven From torriem at gmail.com Mon Feb 27 19:53:41 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 27 Feb 2012 17:53:41 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: <4F4BBD4C.1050603@stoneleaf.us> References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F4BBD4C.1050603@stoneleaf.us> Message-ID: <4F4C2595.6030207@gmail.com> On 02/27/2012 10:28 AM, Ethan Furman wrote: > jmfauth wrote: >> On 25 f?v, 23:51, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: >>> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>>>>> (2.0).hex() >>>> '0x1.0000000000000p+1' >>>>>>> (4.0).hex() >>>> '0x1.0000000000000p+2' >>>>>>> (1.5).hex() >>>> '0x1.8000000000000p+0' >>>>>>> (1.1).hex() >>>> '0x1.199999999999ap+0' >>>> jmf >>> What's your point? I'm afraid my crystal ball is out of order and I have >>> no idea whether you have a question or are just demonstrating your >>> mastery of copy and paste from the Python interactive interpreter. >> >> It should be enough to indicate the right direction >> for casual interested readers. > > I'm a casual interested reader and I have no idea what your post is > trying to say. He's simply showing you the hex (binary) representation of the floating-point number's binary representation. As you can clearly see in the case of 1.1, there is no finite sequence that can store that. You end up with repeating numbers. Just like 1/3, when represented in base 10 fractions (x1/10 + x2/100, x3/1000, etc), is a repeating sequence, the number base 10 numbers 1.1 or 0.2, or many others that are represented by exact base 10 fractions, end up as repeating sequences in base 2 fractions. This should help you understand why you get errors doing simple things like x/y*y doesn't quite get you back to x. From tjreedy at udel.edu Mon Feb 27 20:01:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 27 Feb 2012 20:01:05 -0500 Subject: Question about circular imports In-Reply-To: References: Message-ID: On 2/27/2012 1:16 AM, Frank Millman wrote: >> >> To avoid the tedious reference, follow this with >> read = sound.formats.wavread # choose the identifier you prefer I tested something like this with stdlib, but there must be some important difference I did not notice. It make be in the contents of __init__.py. > @Terry and OKB > > I tried that, but it does not work. > > a.py > /b > __init__.py > c.py > d.py > > a.py - > from b import c > c.py - > import b.d > d.py - > import b.c How about import b.d as d, etc? > If I run a.py, it returns with no error. > > c.py - > import b.d > d = b.d > d.py - > import b.c > c = b.c > > If I run a.py, I get > > Traceback (most recent call last): > File "F:\tests\a.py", line 1, in > from b import c > File "F:\tests\b\c.py", line 1, in > import b.d > File "F:\tests\b\d.py", line 2, in > c = b.c > AttributeError: 'module' object has no attribute 'c' > > I get the same if I try 'import b.c as c'. Try import b; c = b.c -- Terry Jan Reedy From ian.g.kelly at gmail.com Mon Feb 27 20:37:02 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 18:37:02 -0700 Subject: Question about circular imports In-Reply-To: References: Message-ID: On Mon, Feb 27, 2012 at 6:01 PM, Terry Reedy wrote: > On 2/27/2012 1:16 AM, Frank Millman wrote: >>> >>> >>> To avoid the tedious reference, follow this with >>> read = sound.formats.wavread # choose the identifier you prefer > > > I tested something like this with stdlib, but there must be some important > difference I did not notice. It make be in the contents of __init__.py. I don't know what you tried, but I can easily replicate Frank's results with an empty __init__.py. > How about import b.d as d, etc? > Try import b; c = b.c Why would any of these make a difference? The AttributeError indicates that at the time d tries to grab the module in b's "c" attribute, the attribute does not exist (because it has not finished importing). Alternate syntaxes for getting the "c" attribute from b are not going to change that. Python does some magic so that you can do "import b.c" inside d while b.c is still importing without resulting in infinite recursion, but the success of the import does not signify that b.c is actually available yet. Cheers, Ian From browns2112 at gmail.com Mon Feb 27 21:37:25 2012 From: browns2112 at gmail.com (Ray Clark) Date: Mon, 27 Feb 2012 18:37:25 -0800 (PST) Subject: Udacity CS 101 References: <28556790.1352.1330204852864.JavaMail.geo-discussion-forums@pbgq3> Message-ID: On Feb 25, 4:20?pm, Josh English wrote: > Has anyone here looked at Udacity's open CS101 course (http://www.udacity.com/overview/Course/cs101) that started this week? The goal of the seven week course is to build a web crawler. > > So far, I'm not impressed with the speed or content of the course. I was wondering what anyone here may think of it. You have to remember that this course assumes no prior computer programming knowledge. I agree, it is starting out very basic. Give it some more time. These guys have PhDs from MIT and/or have taught at Stanford. They know what they are doing. From python at mrabarnett.plus.com Mon Feb 27 21:38:26 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Feb 2012 02:38:26 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> Message-ID: <4F4C3E22.5010103@mrabarnett.plus.com> On 27/02/2012 16:57, Eric Frederich wrote: > Still freezing sometimes, like 1 out of 10 times that I run it. > Here is updated code and a couple of outputs. > [snip] I don't know what the problem is. All I can suggest is a slightly modified version. If a worker that says it's terminating without first saying that it's got nothing, then I can only assume that the worker had some uncaught exception. #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, name, inbox, outbox): super(MyWorker, self).__init__() self.name = name self.inbox = inbox self.outbox = outbox print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() def run(self): print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() try: while True: try: args = self.inbox.get_nowait() print >> sys.stderr, '%s got something to do' % self.name; sys.stderr.flush() except Queue.Empty: print >> sys.stderr, '%s got nothing' % self.name; sys.stderr.flush() break self.outbox.put(FOO(*args)) finally: print >> sys.stderr, '%s is terminating' % self.name; sys.stderr.flush() if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i + 1, i + 2)) print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() w1 = MyWorker('Worker 1', todo, result_queue) w2 = MyWorker('Worker 2', todo, result_queue) print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() w1.start() print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() w2.start() for i in xrange(100): print result_queue.get() From Tonicopm at yahoo.com Mon Feb 27 22:13:17 2012 From: Tonicopm at yahoo.com (Tonico) Date: Mon, 27 Feb 2012 19:13:17 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 28, 12:43?am, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 Idiot From bheld at awrcorp.com Mon Feb 27 22:26:31 2012 From: bheld at awrcorp.com (Ben Held) Date: Tue, 28 Feb 2012 03:26:31 +0000 Subject: wcout issue Message-ID: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> Hello, After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: wcout << L"Just a test\n"; now prints out: J u s t a t e s t Any clue why? Ben Held -------------- next part -------------- An HTML attachment was scrubbed... URL: From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Feb 27 22:55:12 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Tue, 28 Feb 2012 03:55:12 +0000 (UTC) Subject: Question about circular imports References: Message-ID: Frank Millman wrote: >> >> To avoid the tedious reference, follow this with >> read = sound.formats.wavread # choose the identifier you prefer >> > > @Terry and OKB > > I tried that, but it does not work. > > a.py > /b > __init__.py > c.py > d.py > > a.py - > from b import c > c.py - > import b.d > d.py - > import b.c > > If I run a.py, it returns with no error. > > c.py - > import b.d > d = b.d > d.py - > import b.c > c = b.c > > If I run a.py, I get > > Traceback (most recent call last): > File "F:\tests\a.py", line 1, in > from b import c > File "F:\tests\b\c.py", line 1, in > import b.d > File "F:\tests\b\d.py", line 2, in > c = b.c > AttributeError: 'module' object has no attribute 'c' > > I get the same if I try 'import b.c as c'. Interesting, you're right. Note that it will work in c.py but not in d.py Anyway, testing this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate library imported by both is easier to understand, and has the nice side bonus that it works. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From ian.g.kelly at gmail.com Tue Feb 28 00:00:56 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 22:00:56 -0700 Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) In-Reply-To: References: Message-ID: On Mon, Feb 27, 2012 at 8:13 PM, Tonico wrote: > Idiot Please don't reply to spam. You're just making it show up in the inboxes of those of us who already have these idiots kill-filed. From frank at chagford.com Tue Feb 28 02:50:17 2012 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Feb 2012 09:50:17 +0200 Subject: Question about sub-packages Message-ID: Hi all This is a follow-up to my recent question about circular imports, but on a different subject, hence the new thread. My application has grown to the point that it makes sense to split it up into sub-packages. >From a certain point of view, each package can be said to have an API, not just for third-party users of the application, but for other sub-packages within the application. In other words, there are a number of functions that can be called and a number of objects that can be instantiated from outside the sub-package. It struck me that, even though I can publish the API, it still requires external users to know enough of the internals of the package to know which modules to import and which objects to reference. This has two disadvantages - it makes it more difficult to understand the API, and it makes it more difficult for me to restructure the package internally. An alternative is to have a dedicated API within the sub-package, in the form of one-line functions that are called externally, and then perform whatever action is required internally and return results as appropriate. This is easier for users of the sub-package, and allows me to restructure the internals of the package without causing problems. If this makes sense, my next thought was, where is the best place to put this API. Then I thought, why not put it in the __init__.py of the sub-package? Then all that the users of the package have to do is import the package, and then place calls on it directly. I did a quick test and it seems to work. Is this a good idea, or are there any downsides? Thanks Frank Millman From jasonveldicott at gmail.com Tue Feb 28 02:55:18 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Tue, 28 Feb 2012 18:55:18 +1100 Subject: Error importing __init__ declared variable from another package Message-ID: Hi, I have a simple configuration of modules as beneath, but an import error is reported: /engine (__init__ is empty here) engine.py /sim __init__.py The module engine.py imports a variable instantiated in sim.__init__ as follows: from sim import var_name var_name.func() The following error messaged is received on the func() call above (Eclipse PyDev): "undefined variable from import: func" Any idea why this is causing an error? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jasonveldicott at gmail.com Tue Feb 28 02:57:06 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Tue, 28 Feb 2012 18:57:06 +1100 Subject: Error importing __init__ declared variable from another package In-Reply-To: References: Message-ID: Accidentally hit post by mistake before msg completed. Any comments appreciated. It's a very simple scenario, but not sure what the mistake is. Thanks Jason On Tue, Feb 28, 2012 at 6:55 PM, Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine > (__init__ is empty here) > engine.py > /sim > __init__.py > > > The module engine.py imports a variable instantiated in sim.__init__ as > follows: > > from sim import var_name > var_name.func() > > The following error messaged is received on the func() call above (Eclipse > PyDev): > > "undefined variable from import: func" > > Any idea why this is causing an error? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Tue Feb 28 03:31:38 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 09:31:38 +0100 Subject: Error importing __init__ declared variable from another package References: Message-ID: Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine > (__init__ is empty here) > engine.py > /sim > __init__.py > > > The module engine.py imports a variable instantiated in sim.__init__ as > follows: > > from sim import var_name > var_name.func() > > The following error messaged is received on the func() call above (Eclipse > PyDev): > > "undefined variable from import: func" Are you rephrasing or is this really the error message? If so run your program again on the command-line. Then please cut and paste the error message together with the traceback. > Any idea why this is causing an error? What version of Python are you using? What does sim/__init__.py contain? From alexander.borghgraef at gmail.com Tue Feb 28 04:50:24 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Tue, 28 Feb 2012 01:50:24 -0800 (PST) Subject: Python urllib2 problem: Name or service not known References: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <70f61b16-a0e7-452d-b295-73838c1b025d@w19g2000vbe.googlegroups.com> On Feb 28, 1:36?am, Steven D'Aprano wrote: > On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote: > > Hi all, > > > Some time ago I've written some python code to read video data off an IP > > camera connected via a router to a laptop. Now I try to run this code on > > a different laptop and router combination, but now I can't access the > > camera. > > [...] > > Check your web proxy and firewall. Hmm. Damn. I had disabled the proxy in .bashrc, but apparently the one in /etc/bash.bashrc was still enabled. Thanks. I'll still have to find out a way to get this thing working with proxy enabled if I ever want to connect it to our overall network. -- Alex From andrea.crotti.0 at gmail.com Tue Feb 28 05:07:39 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 10:07:39 +0000 Subject: check if directory is writable in a portable way Message-ID: <4F4CA76B.5040408@gmail.com> How should I check if I can create files in a directory? I tried to simply check if the directory is writeable with this function: def is_writable(name): """Return true if the file is writable from the current user """ return os.access(name, os.W_OK) but that doesn't work at all on Windows, because for example if I create a new directory and do os.access(dirpath, os.W_OK) it returns false, even if I can create files inside without problems. So maybe the only solution that works is something like try: open(path.join('temp', 'w')) except OsError: return False else: os.remove(path.join('temp')) return True would it make sense? From alexander.borghgraef at gmail.com Tue Feb 28 05:41:32 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Tue, 28 Feb 2012 02:41:32 -0800 (PST) Subject: Python urllib2 problem: Name or service not known References: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> <70f61b16-a0e7-452d-b295-73838c1b025d@w19g2000vbe.googlegroups.com> Message-ID: On Feb 28, 10:50?am, Alex Borghgraef wrote: > I'll still have to find out a way to get this thing working with proxy > enabled if I ever want to connect it to our overall network. Ok, doing os.environ['http_proxy']='' before importing urllib2 seems to do the trick for that. -- Alex From mail at timgolden.me.uk Tue Feb 28 05:50:51 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 28 Feb 2012 10:50:51 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4CB18B.4050300@timgolden.me.uk> On 28/02/2012 10:07, Andrea Crotti wrote: > How should I check if I can create files in a directory? > > I tried to simply check if the directory is writeable with this function: > > def is_writable(name): > """Return true if the file is writable from the current user > """ > return os.access(name, os.W_OK) > > but that doesn't work at all on Windows, because for example if I create > a new directory > and do os.access(dirpath, os.W_OK) it returns false, even if I can > create files inside without problems. > > So maybe the only solution that works is something like > try: > open(path.join('temp', 'w')) > except OsError: > return False > else: > os.remove(path.join('temp')) > return True > > would it make sense? This is remarkably complicated to do on Windows by checking Security APIs etc. If the try:except dance works for you, I recommend that you use it. (In the past, people who have asked this question have not wanted to use try-except because they didn't want the overhead of creating even a zero-length file) TJG From python.list at tim.thechases.com Tue Feb 28 06:34:59 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 28 Feb 2012 05:34:59 -0600 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4CBBE3.5060108@tim.thechases.com> On 02/28/12 04:07, Andrea Crotti wrote: > How should I check if I can create files in a directory? > > So maybe the only solution that works is something like > try: > open(path.join('temp', 'w')) > except OsError: > return False > else: > os.remove(path.join('temp')) > return True It depends on the system & location. It's possible to set up directories with permissions that allow you to create files but not delete them, in which case you'd either (1) create the file and possibly fail on subsequent tests because the file already exists; or (2) litter the directory with tmpnam()-like results that you were unable to delete. It's ugly, I've encountered it, and haven't found a good universal solution myself. -tkc From ben+python at benfinney.id.au Tue Feb 28 06:36:56 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 28 Feb 2012 22:36:56 +1100 Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87mx83p4tj.fsf@benfinney.id.au> Steven D'Aprano writes: > On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: > > >> An integer variable is a variable holding an integer. A string variable > >> is a variable holding a string. A list variable is a variable holding a > >> list. > > > > And Python has none of those. Its references don't ?hold? anything. > > Ah, but they do. Following the name binding: > > x = 1 > > the name "x" now holds a reference to an int, or if you want to cut out > one layer of indirection, the name "x" holds an int. That is to say, the > value associated with the name "x" is an int. Names don't hold anything. Not in natural language, and not in Python. Which is exactly *why* the term ?name? is a good one, since Python's bindings don't hold anything either. It's a reference, not a container. > I don't believe this is a troublesome concept. Then you have a different concept of ?name? from anything I'd expect anyone to understand. > > I appreciate that you think ?variable? is a useful term in Python, > > but this kind of mangling of the concept convinces me that it's not > > worth it. > > I'm not sure that there is any mangling here. Or at least, the concept > is only mangled if you believe that Pascal- or C-like variables (named > memory locations) are the one true definition of "variable". I do not > believe this. The fact that you keep having to come back to container analogies, when that's exactly what Python doesn't have and what differentiates it, is why I think the term ?variable? isn't helping the discussion. Not for us, and not for newcomers to the language. > Words vary in their meanings Of course they do. but we don't have to let any word mean any arbitrary thing. I reject attempts to Humpty Dumpty our way through discussions with newcomers about Python concepts. -- \ ?Simplicity and elegance are unpopular because they require | `\ hard work and discipline to achieve and education to be | _o__) appreciated.? ?Edsger W. Dijkstra | Ben Finney From andrea.crotti.0 at gmail.com Tue Feb 28 07:01:00 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 12:01:00 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CBBE3.5060108@tim.thechases.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> Message-ID: <4F4CC1FC.40502@gmail.com> On 02/28/2012 11:34 AM, Tim Chase wrote: > On 02/28/12 04:07, Andrea Crotti wrote: >> How should I check if I can create files in a directory? >> >> So maybe the only solution that works is something like >> try: >> open(path.join('temp', 'w')) >> except OsError: >> return False >> else: >> os.remove(path.join('temp')) >> return True > > It depends on the system & location. It's possible to set up > directories with permissions that allow you to create files but not > delete them, in which case you'd either (1) create the file and > possibly fail on subsequent tests because the file already exists; or > (2) litter the directory with tmpnam()-like results that you were > unable to delete. > > It's ugly, I've encountered it, and haven't found a good universal > solution myself. > > -tkc > That's really ugly right, didn't think about this possibility. Well it's not a really critical part of my code, so I guess it's fine with the try-except dance.. But isn't there (or should there be) a windows-related library that abstracts this horrible things? Thanks From python.list at tim.thechases.com Tue Feb 28 07:12:44 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 28 Feb 2012 06:12:44 -0600 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CC1FC.40502@gmail.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com> Message-ID: <4F4CC4BC.8050808@tim.thechases.com> On 02/28/12 06:01, Andrea Crotti wrote: >>> How should I check if I can create files in a directory? > > But isn't there (or should there be) a windows-related library that > abstracts this horrible things? Yes, there should be. There isn't as far as I know (though that doesn't mean much given my limited experiences in the recesses of Win32 APIs). Additionally, even if you did a LBYL instead, you'd open yourself to a race-condition where the permissions could theoretically change between the time you check and the time you actually try to write there. Granted, that's a slim chance and usually would be a "Doctor, my foot hurts when I do $THIS"/"Well don't do that" situation where the solution is "don't change the permissions while running this program". -tkc From ssmile03 at gmail.com Tue Feb 28 07:23:36 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 17:53:36 +0530 Subject: pickling to an output file. Message-ID: I have created a bytestream (readfile.pkl) from pickle.dump() already in different folder (say /tmp) succesfully. Now I wish to open the file, read it and finally write the output to a file to "output.txt". To read the file bytestream file (readfile.pkl) I did perform as -- --- import pickle def print_report(): with open('/tmp/readfile.pkl', 'rb') as f: my_shared = pickle.load(f) print my_shared print "================================================================" -- My above code should perform all 3 of below - (a) Open the pickle file as above (b) read the pickled object (c) write the output to a file say "output.txt" Can I have know if my above code is reading properly and how to write to an output file 'output.txt' -------------- next part -------------- An HTML attachment was scrubbed... URL: From frank at chagford.com Tue Feb 28 07:44:48 2012 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Feb 2012 14:44:48 +0200 Subject: Question about sub-packages References: Message-ID: "Frank Millman" wrote in message news:jii0vo$36t$1 at dough.gmane.org... > Hi all > > This is a follow-up to my recent question about circular imports, but on a > different subject, hence the new thread. > [...] > > If this makes sense, my next thought was, where is the best place to put > this API. Then I thought, why not put it in the __init__.py of the > sub-package? Then all that the users of the package have to do is import > the package, and then place calls on it directly. > > I did a quick test and it seems to work. Is this a good idea, or are there > any downsides? > Answering my own question again ... The one-liner API concept *may* be a good idea - still waiting for some feedback on that. But putting them into __init__.py is not a good idea, as I run into some subtle 'circular import' problems again. I don't fully understand the conditions under which it fails, but that is unimportant, as my objective is to avoid circular imports altogether. I have created a module called 'api.py' and put them in there, and that seems to work (for now...). Frank From mail at timgolden.me.uk Tue Feb 28 08:33:52 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 28 Feb 2012 13:33:52 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CC1FC.40502@gmail.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com> Message-ID: <4F4CD7C0.4070104@timgolden.me.uk> On 28/02/2012 12:01, Andrea Crotti wrote: > On 02/28/2012 11:34 AM, Tim Chase wrote: >> On 02/28/12 04:07, Andrea Crotti wrote: >>> How should I check if I can create files in a directory? >>> >>> So maybe the only solution that works is something like >>> try: >>> open(path.join('temp', 'w')) >>> except OsError: >>> return False >>> else: >>> os.remove(path.join('temp')) >>> return True >> >> It depends on the system & location. It's possible to set up >> directories with permissions that allow you to create files but not >> delete them, in which case you'd either (1) create the file and >> possibly fail on subsequent tests because the file already exists; or >> (2) litter the directory with tmpnam()-like results that you were >> unable to delete. >> >> It's ugly, I've encountered it, and haven't found a good universal >> solution myself. >> >> -tkc >> > > That's really ugly right, didn't think about this possibility. > Well it's not a really critical part of my code, so I guess it's fine > with the try-except dance.. > > But isn't there (or should there be) a windows-related library that > abstracts this horrible things? Well I maintain winsys [1] which does help out in admin-y tasks in general on Windows, but I'm afraid I've never had the need to scratch this particular itch, and the API solution is messier than you might think, and more fiddly to get right. If I ever get enough moments together I might do it, but patches are always looked upon kindly :) TJG [1] https://github.com/tjguk/winsys From steve+comp.lang.python at pearwood.info Tue Feb 28 09:06:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Feb 2012 14:06:23 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> <87mx83p4tj.fsf@benfinney.id.au> Message-ID: <4f4cdf5e$0$29989$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Feb 2012 22:36:56 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: >> >> >> An integer variable is a variable holding an integer. A string >> >> variable is a variable holding a string. A list variable is a >> >> variable holding a list. >> > >> > And Python has none of those. Its references don't ?hold? anything. >> >> Ah, but they do. Following the name binding: >> >> x = 1 >> >> the name "x" now holds a reference to an int, or if you want to cut out >> one layer of indirection, the name "x" holds an int. That is to say, >> the value associated with the name "x" is an int. > > Names don't hold anything. Not in natural language, and not in Python. I don't agree, I think the analogy of "holding on to", or "holding", works well for names in this context. A *binding* (the term you prefer) refers to the process of *tying* two objects together with rope, string, or twine such that they *hold fast*. If names don't hold values, neither can they be bound. I would be surprised if many programmers, whether experienced or not, or even non-programmers, failed to grasp the concept of a name "holding" a value. (And I point out that to *grasp a concept* is also to hold on to it. We hold our loved ones dear even when they are on the other side of the world, we hold these truths to be self-evident, and we don't hold with that sort of behaviour -- surely we are capable of holding onto the idea that names can hold values?) But rather than spend any more time trying to convince you to hold a different opinion, I will accept your criticism and rephrase my earlier statement: A string variable is a symbolic identifier given to a value and capable of being varied, which is given to a value which is a string. Python has these -- it has names, which are symbolic identifiers given to values, and those name:value bindings are capable of varying. It has strings. And you can bind names to strings. Ergo, it has string variables. I acknowledge that when I say "string variable", I mean a variable whose value is a string *at this moment*, I don't mean a variable which is prohibited by the compiler from taking a non-string value. To the extent that careless use of the term variable may confuse the naive reader who assumes that Python is just like Pascal (or any other statically typed language), it is sometimes useful to emphasis the differences by talking about "name bindings". But sometimes it is useful to emphasis the similarities, in which case "name binding" is obfuscatory and "variable" is perfectly reasonable. -- Steven From chris at simplistix.co.uk Tue Feb 28 09:41:33 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 28 Feb 2012 14:41:33 +0000 Subject: xlrd 0.7.3 released! Message-ID: <4F4CE79D.5060408@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlrd 0.7.3. This release just brings in some documentation updates that were missed for 0.7.2. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From andrea.crotti.0 at gmail.com Tue Feb 28 09:42:04 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 14:42:04 +0000 Subject: suppressing argparse arguments in the help Message-ID: <4F4CE7BC.6080908@gmail.com> I have a script that might be used interactively but also has some arguments that should not be used by "normal" users. So I just want to suppress them from the help. I've read somewhere that the help=SUPPRESS should do what I want: parser.add_argument('-n', '--test_only', action='store_true', help=SUPPRESS) but that's what I get from "myapp -h", which is not exactly what I was looking for.. -f, --first_level ==SUPPRESS== (default: False) --never_redevelop ==SUPPRESS== (default: False) Any other solutions? From ssmile03 at gmail.com Tue Feb 28 10:14:32 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 20:44:32 +0530 Subject: Pickle performing class instantiation ?? Message-ID: I am looking for pickle performing class instantiation, something as prototype like - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Tue Feb 28 10:54:35 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 21:24:35 +0530 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: Am I doing the right thing for - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump, simply guessing - as - --- #!/usr/bin/python import pickle class Pickle: def __init__(self, Parameter1, Parameter2, Parameter3): self.PM1 = Parameter1 self.PM2 = Parameter2 self.PM3 = Parameter3 with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump((self.PM1, self.PM2, self.PM3), f) with open('/tmp/readfile.pkl', 'rb') as f: self.PM1, self.PM2, self.PM3 = pickle.load(f) print self.PM1 print self.PM2 print self.PM3 ---- but I get an error message as - ----- $ ./class-test1.py Traceback (most recent call last): File "./class-test1.py", line 12, in pickle.dump((self.PM1, self.PM2, self.PM3), f) NameError: name 'self' is not defined ------ On Tue, Feb 28, 2012 at 8:44 PM, Smiley 4321 wrote: > I am looking for pickle performing class instantiation, something as > prototype like - > > - Have a class > - Instantiate the class with 3 parameters > - pickle the class instance > - generate a bytestream (.pkl) using pickle.dump > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Tue Feb 28 11:02:24 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 17:02:24 +0100 Subject: suppressing argparse arguments in the help References: <4F4CE7BC.6080908@gmail.com> Message-ID: Andrea Crotti wrote: > I have a script that might be used interactively but also has some > arguments that > should not be used by "normal" users. > So I just want to suppress them from the help. > I've read somewhere that the help=SUPPRESS should do what I want: > > parser.add_argument('-n', '--test_only', > action='store_true', > help=SUPPRESS) > > but that's what I get from "myapp -h", which is not exactly what I was > looking for.. > > > -f, --first_level ==SUPPRESS== (default: False) > --never_redevelop ==SUPPRESS== (default: False) > > > Any other solutions? That shouldn't happen. Did you reload() somewhere? argparse tests object identity not equality with SUPPRESS, so you have to ensure that SUPPRESS stems from the same instance of the argparse module as your ArgumentParser. From ramit.prasad at jpmorgan.com Tue Feb 28 11:09:07 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 28 Feb 2012 16:09:07 +0000 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474164475@SCACMX008.exchad.jpmchase.net> >class Pickle: >??? def __init__(self, Parameter1, Parameter2, Parameter3): >??? ??? self.PM1 = Parameter1 >??? ??? self.PM2 = Parameter2 >??? ??? self.PM3 = Parameter3 >with open('/tmp/readfile.pkl', 'wb') as f: >??? pickle.dump((self.PM1, self.PM2, self.PM3), f) ??? >with open('/tmp/readfile.pkl', 'rb') as f: > ?? self.PM1, self.PM2, self.PM3 = pickle.load(f) >$ ./class-test1.py >Traceback (most recent call last): >? File "./class-test1.py", line 12, in > ?? pickle.dump((self.PM1, self.PM2, self.PM3), f) >NameError: name 'self' is not defined You need to create an instance of Pickle first and then manipulate that instance. instance = Pickle( 'something', ['blah'], 5 ) print instance.PM1 Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From __peter__ at web.de Tue Feb 28 11:14:36 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 17:14:36 +0100 Subject: Pickle performing class instantiation ?? References: Message-ID: Smiley 4321 wrote: > Am I doing the right thing for - > > - Have a class > - Instantiate the class with 3 parameters > - pickle the class instance > - generate a bytestream (.pkl) using pickle.dump, simply guessing - > > as - > > --- > #!/usr/bin/python > > import pickle > > class Pickle: > def __init__(self, Parameter1, Parameter2, Parameter3): > self.PM1 = Parameter1 > self.PM2 = Parameter2 > self.PM3 = Parameter3 # You need something to pickle first. # You could call it "self", but that is confusing # as this name is by convention used inside methods as # the current instance. So: p = Pickle(1, 2, 3) > with open('/tmp/readfile.pkl', 'wb') as f: # Don't touch the object's attributes, # pickle the whole instance instead: pickle.dump(p, f) > with open('/tmp/readfile.pkl', 'rb') as f: # Load the instance back from file p = pickle.load(f) # print it print p.PM1 print p.PM2 print p.PM3 From andrea.crotti.0 at gmail.com Tue Feb 28 11:14:50 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 16:14:50 +0000 Subject: suppressing argparse arguments in the help In-Reply-To: References: <4F4CE7BC.6080908@gmail.com> Message-ID: <4F4CFD7A.20904@gmail.com> On 02/28/2012 04:02 PM, Peter Otten wrote: > Andrea Crotti wrote: > >> I have a script that might be used interactively but also has some >> arguments that >> should not be used by "normal" users. >> So I just want to suppress them from the help. >> I've read somewhere that the help=SUPPRESS should do what I want: >> >> parser.add_argument('-n', '--test_only', >> action='store_true', >> help=SUPPRESS) >> >> but that's what I get from "myapp -h", which is not exactly what I was >> looking for.. >> >> >> -f, --first_level ==SUPPRESS== (default: False) >> --never_redevelop ==SUPPRESS== (default: False) >> >> >> Any other solutions? > That shouldn't happen. Did you reload() somewhere? > argparse tests object identity not equality with SUPPRESS, so you have to > ensure that SUPPRESS stems from the same instance of the argparse module as > your ArgumentParser. > Ah great yes it wasn't actually the same.. but why not just use if text != SUPPRESS instead of: if text is not SUPPRESS probably the second is more safe, but they are it's still checking against a constant that is very unlikely to clash with anything.. From bahamutzero8825 at gmail.com Tue Feb 28 11:15:09 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Tue, 28 Feb 2012 10:15:09 -0600 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: <4F4CFD8D.7060505@gmail.com> On 2/28/2012 9:54 AM, Smiley 4321 wrote: > NameError: name 'self' is not defined self is meaningless outside a class definition. You should refactor your dump, load and print code as methods inside the class definition, create an instance and call the methods on that instance. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From eric.frederich at gmail.com Tue Feb 28 12:16:19 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Tue, 28 Feb 2012 12:16:19 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F4C3E22.5010103@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> <4F4C3E22.5010103@mrabarnett.plus.com> Message-ID: If I do a time.sleep(0.001) right at the beginning of the run() method, then it completes fine. I was able to run it through a couple hundred times without problem. If I sleep for less time than that or not at all, it may or may not complete. On Mon, Feb 27, 2012 at 9:38 PM, MRAB wrote: > On 27/02/2012 16:57, Eric Frederich wrote: > >> Still freezing sometimes, like 1 out of 10 times that I run it. >> Here is updated code and a couple of outputs. >> >> [snip] > I don't know what the problem is. All I can suggest is a slightly > modified version. > > If a worker that says it's terminating without first saying that it's > got nothing, then I can only assume that the worker had some uncaught > exception. > > > > #!/usr/bin/env python > > import sys > import Queue > import multiprocessing > import time > > def FOO(a, b, c): > print 'foo', a, b, c > return (a + b) * c > > class MyWorker(multiprocessing.**Process): > def __init__(self, name, inbox, outbox): > super(MyWorker, self).__init__() > self.name = name > self.inbox = inbox > self.outbox = outbox > print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() > def run(self): > print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() > try: > > while True: > try: > args = self.inbox.get_nowait() > print >> sys.stderr, '%s got something to do' % > self.name; sys.stderr.flush() > except Queue.Empty: > print >> sys.stderr, '%s got nothing' % self.name; > sys.stderr.flush() > break > self.outbox.put(FOO(*args)) > finally: > print >> sys.stderr, '%s is terminating' % self.name; > sys.stderr.flush() > > > if __name__ == '__main__': > # This file is being run as the main script. This part won't be > # run if the file is imported. > > print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() > todo = multiprocessing.Queue() > > for i in xrange(100): > todo.put((i, i + 1, i + 2)) > > print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() > result_queue = multiprocessing.Queue() > > print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() > w1 = MyWorker('Worker 1', todo, result_queue) > w2 = MyWorker('Worker 2', todo, result_queue) > > print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() > w1.start() > print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() > w2.start() > > for i in xrange(100): > print result_queue.get() > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From crstop at gmail.com Tue Feb 28 12:36:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 09:36:24 -0800 (PST) Subject: Need to write python source with python Message-ID: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Hi All, I'm new to Python but have experience with a few other programming languages(Java, Perl, JavaScript). I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) a python class and functions from python. I will also need to later read and edit the file. I realize I could just write strings using the available string and file writing methods but suspect there is a better way than that. I have read about pickle, ast, and Django; searched this group and the web but haven't found a solution that seems to fit. Any suggestion? From ssmile03 at gmail.com Tue Feb 28 12:51:20 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 23:21:20 +0530 Subject: GUI for pickle read Message-ID: Can I have some thoughts about - building a GUI to display the results of the pickle read? A prototype code should be fine on Linux. ~ BR -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Tue Feb 28 12:56:34 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 28 Feb 2012 09:56:34 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: <4F4C2595.6030207@gmail.com> References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F4BBD4C.1050603@stoneleaf.us> <4F4C2595.6030207@gmail.com> Message-ID: <4F4D1552.60809@stoneleaf.us> Michael Torrie wrote: > He's simply showing you the hex (binary) representation of the > floating-point number's binary representation. As you can clearly see > in the case of 1.1, there is no finite sequence that can store that. > You end up with repeating numbers. Thanks for the explanation. > This should help you understand why you get errors > doing simple things like x/y*y doesn't quite get you back to x. I already understood that. I just didn't understand what point he was trying to make since he gave no explanation. ~Ethan~ From __peter__ at web.de Tue Feb 28 12:56:43 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 18:56:43 +0100 Subject: Need to write python source with python References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: crstop at gmail.com wrote: > I'm new to Python but have experience with a few other programming > languages(Java, Perl, JavaScript). > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > a python class and functions from python. I will also need to later read > and edit the file. I realize I could just write strings using the > available string and file writing methods but suspect there is a better > way than that. > > I have read about pickle, ast, and Django; searched this group and the web > but haven't found a solution that seems to fit. Any suggestion? Due to Python's dynamic nature it is rarely necessary to generate Python code. What are you actually trying to achieve? From ethan at stoneleaf.us Tue Feb 28 12:58:28 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 28 Feb 2012 09:58:28 -0800 Subject: Question about circular imports In-Reply-To: References: Message-ID: <4F4D15C4.7090606@stoneleaf.us> OKB (not okblacke) wrote: > Anyway, testing this just reinforced my distaste for circular > imports. Just trying to think about how it ought to work with a > importing c but then c and d importing each other makes my brain hurt. > Refactoring the files so that common code is in a separate library > imported by both is easier to understand, and has the nice side bonus > that it works. > +1 QOTW From __peter__ at web.de Tue Feb 28 13:07:02 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 19:07:02 +0100 Subject: suppressing argparse arguments in the help References: <4F4CE7BC.6080908@gmail.com> <4F4CFD7A.20904@gmail.com> Message-ID: Andrea Crotti wrote: > On 02/28/2012 04:02 PM, Peter Otten wrote: >> Andrea Crotti wrote: >> >>> I have a script that might be used interactively but also has some >>> arguments that >>> should not be used by "normal" users. >>> So I just want to suppress them from the help. >>> I've read somewhere that the help=SUPPRESS should do what I want: >>> >>> parser.add_argument('-n', '--test_only', >>> action='store_true', >>> help=SUPPRESS) >>> >>> but that's what I get from "myapp -h", which is not exactly what I was >>> looking for.. >>> >>> >>> -f, --first_level ==SUPPRESS== (default: False) >>> --never_redevelop ==SUPPRESS== (default: False) >>> >>> >>> Any other solutions? >> That shouldn't happen. Did you reload() somewhere? >> argparse tests object identity not equality with SUPPRESS, so you have to >> ensure that SUPPRESS stems from the same instance of the argparse module >> as your ArgumentParser. >> > > Ah great yes it wasn't actually the same.. > but why not just use > if text != SUPPRESS > instead of: > if text is not SUPPRESS Steven Bethard would have to answer that. If it were my code I would have used the equality test, but also the correct symbolic constant... > probably the second is more safe, but they are it's still checking > against a constant that > is very unlikely to clash with anything.. From dihedral88888 at googlemail.com Tue Feb 28 13:09:50 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 28 Feb 2012 10:09:50 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <11747773.3845.1330452590293.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?29????UTC+8??1?56?43??Peter Otten??? > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? Check myHDL, and BOA and pythoncard that can translate user messages to pyhton code as delphie. From dihedral88888 at googlemail.com Tue Feb 28 13:09:50 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 28 Feb 2012 10:09:50 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <11747773.3845.1330452590293.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?29????UTC+8??1?56?43??Peter Otten??? > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? Check myHDL, and BOA and pythoncard that can translate user messages to pyhton code as delphie. From python at mrabarnett.plus.com Tue Feb 28 13:12:36 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Feb 2012 18:12:36 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> <4F4C3E22.5010103@mrabarnett.plus.com> Message-ID: <4F4D1914.9010209@mrabarnett.plus.com> On 28/02/2012 17:16, Eric Frederich wrote: > If I do a time.sleep(0.001) right at the beginning of the run() method, > then it completes fine. > I was able to run it through a couple hundred times without problem. > If I sleep for less time than that or not at all, it may or may not > complete. > [snip] To me that suggests that the OS works in units of 1 millisecond, so a sleep of less than 0.001 seconds is rounded to 0 milliseconds. From malaclypse2 at gmail.com Tue Feb 28 13:13:03 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 28 Feb 2012 13:13:03 -0500 Subject: GUI for pickle read In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: > Can I have some thoughts about - building a GUI to display the results of > the pickle read? > > A prototype code should be fine on Linux. It doesn't seem like it would be all that useful, though I may just be lacking in imagination. What would you do with such a thing? -- Jerry From crstop at gmail.com Tue Feb 28 13:30:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 10:30:24 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? I'm trying to generate the script file that will launch a PythonCard resource file. very basic example from the documentation. #!/usr/bin/python """ __version__ = "$Revision: 1.10 $" __date__ = "$Date: 2004/04/24 22:13:31 $" """ from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() From crstop at gmail.com Tue Feb 28 13:30:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 10:30:24 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? I'm trying to generate the script file that will launch a PythonCard resource file. very basic example from the documentation. #!/usr/bin/python """ __version__ = "$Revision: 1.10 $" __date__ = "$Date: 2004/04/24 22:13:31 $" """ from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() From mbadoiu at gmail.com Tue Feb 28 13:33:07 2012 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Tue, 28 Feb 2012 13:33:07 -0500 Subject: Listing children processes Message-ID: I'm trying to compute the total CPU load of an external process and it's children. (so I cannot use resource.getrusage) For the load of the process I can just grab it from /proc/X/stat. How do I get the CPU load of the children processes? Is there an easy way to get a list of the children processes? thanks, --mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.france.mailinglists at gmail.com Tue Feb 28 13:38:44 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 28 Feb 2012 19:38:44 +0100 Subject: GUI for pickle read In-Reply-To: References: Message-ID: <4F4D1F34.40100@gmail.com> > On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: >> Can I have some thoughts about - building a GUI to display the results of >> the pickle read? >> >> A prototype code should be fine on Linux. What on earth is this post asking? Do you want code? Opinions? From __peter__ at web.de Tue Feb 28 14:25:33 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 20:25:33 +0100 Subject: Need to write python source with python References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: crstop at gmail.com wrote: > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: >> crstop at gmail.com wrote: >> >> > I'm new to Python but have experience with a few other programming >> > languages(Java, Perl, JavaScript). >> > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file >> > (.py) a python class and functions from python. I will also need to >> > later read and edit the file. I realize I could just write strings >> > using the available string and file writing methods but suspect there >> > is a better way than that. >> > >> > I have read about pickle, ast, and Django; searched this group and the >> > web but haven't found a solution that seems to fit. Any suggestion? >> >> Due to Python's dynamic nature it is rarely necessary to generate Python >> code. What are you actually trying to achieve? > > I'm trying to generate the script file that will launch a PythonCard > resource file. > > very basic example from the documentation. > > #!/usr/bin/python > """ > __version__ = "$Revision: 1.10 $" > __date__ = "$Date: 2004/04/24 22:13:31 $" > """ > > from PythonCard import model > > class Minimal(model.Background): > pass > > if __name__ == '__main__': > app = model.Application(Minimal) > app.MainLoop() If it doesn't get too complex you could start with Python's built-in string formatting: import sys template = '''\ #!/usr/bin/python from PythonCard import model class {Class}(model.Background): pass if __name__ == '__main__': app = model.Application({Class}) app.MainLoop() ''' resourcename, filename = sys.argv[1:] with open(resourcename, "U") as f: data = eval(f.read()) with open(filename, "w") as f: f.write(template.format(Class=data["application"]["name"])) If you need logic inside the template, here's on overview: http://wiki.python.org/moin/Templating So there are rather too many options than too few. From d at davea.name Tue Feb 28 14:32:16 2012 From: d at davea.name (Dave Angel) Date: Tue, 28 Feb 2012 14:32:16 -0500 Subject: wcout issue In-Reply-To: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> References: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> Message-ID: <4F4D2BC0.40308@davea.name> On 02/27/2012 10:26 PM, Ben Held wrote: > Hello, > > After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: > > wcout<< L"Just a test\n"; > > now prints out: > > J u s t a t e s t > > Any clue why? > > > Ben Held > > Have you tried capturing this output, and looking at it with a hex viewer? Are the characters really space, or could they be nulls? If the latter, perhaps it's outputting ucs2 for Unicode. (I have no further ideas, just trying to provoke some experimentation) -- DaveA From crstop at gmail.com Tue Feb 28 14:36:00 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 11:36:00 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: <4382344.985.1330457760893.JavaMail.geo-discussion-forums@pbbpk4> On Tuesday, February 28, 2012 11:25:33 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > >> crstop at gmail.com wrote: > >> > >> > I'm new to Python but have experience with a few other programming > >> > languages(Java, Perl, JavaScript). > >> > > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file > >> > (.py) a python class and functions from python. I will also need to > >> > later read and edit the file. I realize I could just write strings > >> > using the available string and file writing methods but suspect there > >> > is a better way than that. > >> > > >> > I have read about pickle, ast, and Django; searched this group and the > >> > web but haven't found a solution that seems to fit. Any suggestion? > >> > >> Due to Python's dynamic nature it is rarely necessary to generate Python > >> code. What are you actually trying to achieve? > > > > I'm trying to generate the script file that will launch a PythonCard > > resource file. > > > > very basic example from the documentation. > > > > #!/usr/bin/python > > """ > > __version__ = "$Revision: 1.10 $" > > __date__ = "$Date: 2004/04/24 22:13:31 $" > > """ > > > > from PythonCard import model > > > > class Minimal(model.Background): > > pass > > > > if __name__ == '__main__': > > app = model.Application(Minimal) > > app.MainLoop() > > If it doesn't get too complex you could start with Python's built-in string > formatting: > > import sys > > template = '''\ > #!/usr/bin/python > from PythonCard import model > > class {Class}(model.Background): > pass > > if __name__ == '__main__': > app = model.Application({Class}) > app.MainLoop() > ''' > > resourcename, filename = sys.argv[1:] > > with open(resourcename, "U") as f: > data = eval(f.read()) > > with open(filename, "w") as f: > f.write(template.format(Class=data["application"]["name"])) > > If you need logic inside the template, here's on overview: > > http://wiki.python.org/moin/Templating > > So there are rather too many options than too few. It shouldn't get very complicated so I look through those options. Thanks to all posters From crstop at gmail.com Tue Feb 28 14:36:00 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 11:36:00 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: <4382344.985.1330457760893.JavaMail.geo-discussion-forums@pbbpk4> On Tuesday, February 28, 2012 11:25:33 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > >> crstop at gmail.com wrote: > >> > >> > I'm new to Python but have experience with a few other programming > >> > languages(Java, Perl, JavaScript). > >> > > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file > >> > (.py) a python class and functions from python. I will also need to > >> > later read and edit the file. I realize I could just write strings > >> > using the available string and file writing methods but suspect there > >> > is a better way than that. > >> > > >> > I have read about pickle, ast, and Django; searched this group and the > >> > web but haven't found a solution that seems to fit. Any suggestion? > >> > >> Due to Python's dynamic nature it is rarely necessary to generate Python > >> code. What are you actually trying to achieve? > > > > I'm trying to generate the script file that will launch a PythonCard > > resource file. > > > > very basic example from the documentation. > > > > #!/usr/bin/python > > """ > > __version__ = "$Revision: 1.10 $" > > __date__ = "$Date: 2004/04/24 22:13:31 $" > > """ > > > > from PythonCard import model > > > > class Minimal(model.Background): > > pass > > > > if __name__ == '__main__': > > app = model.Application(Minimal) > > app.MainLoop() > > If it doesn't get too complex you could start with Python's built-in string > formatting: > > import sys > > template = '''\ > #!/usr/bin/python > from PythonCard import model > > class {Class}(model.Background): > pass > > if __name__ == '__main__': > app = model.Application({Class}) > app.MainLoop() > ''' > > resourcename, filename = sys.argv[1:] > > with open(resourcename, "U") as f: > data = eval(f.read()) > > with open(filename, "w") as f: > f.write(template.format(Class=data["application"]["name"])) > > If you need logic inside the template, here's on overview: > > http://wiki.python.org/moin/Templating > > So there are rather too many options than too few. It shouldn't get very complicated so I look through those options. Thanks to all posters From craigyk at me.com Tue Feb 28 16:04:59 2012 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 28 Feb 2012 13:04:59 -0800 Subject: alternative to with statement? Message-ID: I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. The best I've found is to abuse the for notation: for _ in cachingcontext(x): # create cached resources here # return cached resources I would have really liked: with cachingcontext(x): # create cached resources here # return cached resources I'd also like to avoid the following because it is unnecessary boilerplate: with cachingcontext(x) as skip: if not skip: # create cached resources here # return cached resources From clp2 at rebertia.com Tue Feb 28 16:35:47 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 28 Feb 2012 13:35:47 -0800 Subject: Listing children processes In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: > I'm trying to compute the total CPU load of an external process and it's > children.? (so I cannot use resource.getrusage)? For the load of the process > I can just grab it from /proc/X/stat.? How do I get the CPU load of the > children processes?? Is there an easy way to get a list of the children > processes? http://code.google.com/p/psutil/ Cheers, Chris From mbadoiu at gmail.com Tue Feb 28 16:39:07 2012 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Tue, 28 Feb 2012 16:39:07 -0500 Subject: Listing children processes In-Reply-To: References: Message-ID: Looked at that before. psutil doesn't do children. --mihai On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: > On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: > > I'm trying to compute the total CPU load of an external process and it's > > children. (so I cannot use resource.getrusage) For the load of the > process > > I can just grab it from /proc/X/stat. How do I get the CPU load of the > > children processes? Is there an easy way to get a list of the children > > processes? > > http://code.google.com/p/psutil/ > > Cheers, > Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at gmail.com Tue Feb 28 16:47:00 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 28 Feb 2012 21:47:00 +0000 Subject: Listing children processes In-Reply-To: References: Message-ID: On 28 February 2012 21:39, Mihai Badoiu wrote: > On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >> >> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >> > I'm trying to compute the total CPU load of an external process and it's >> > children.? (so I cannot use resource.getrusage)? For the load of the >> > process >> > I can just grab it from /proc/X/stat.? How do I get the CPU load of the >> > children processes?? Is there an easy way to get a list of the children >> > processes? >> >> http://code.google.com/p/psutil/ >> >> Cheers, >> Chris > Looked at that before.? psutil doesn't do children. > > --mihai Please don't top-post! Also, psutil.Process.get_children() looks to me like it "does" children. -- Arnaud From rantingrickjohnson at gmail.com Tue Feb 28 17:12:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 28 Feb 2012 14:12:40 -0800 (PST) Subject: GUI for pickle read References: Message-ID: <92d58b4f-b5b1-4d8e-a379-265d07db9847@f5g2000yqm.googlegroups.com> On Feb 28, 12:13?pm, Jerry Hill wrote: > On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: > > Can I have some thoughts about - building a GUI to display the results of > > the pickle read? Sure. But first can you show us some code that reads a pickled file and prints the contents? Hint: Why does the pickle module have methods called "load", "loads", "dump", and "dumps"? From ramit.prasad at jpmorgan.com Tue Feb 28 17:12:45 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 28 Feb 2012 22:12:45 +0000 Subject: alternative to with statement? In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> Craig Yoshioka wrote: >I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. [..] >I would have really liked: >with cachingcontext(x): > # create cached resources here ># return cached resources Is this a common pattern? I thought the point of the context manager was to remove create and close the resources (like with file opening). Seems slightly odd to use just for creation...but maybe only because I have never used it like that. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ironfroggy at gmail.com Tue Feb 28 17:17:25 2012 From: ironfroggy at gmail.com (Calvin Spealman) Date: Tue, 28 Feb 2012 17:17:25 -0500 Subject: suppressing argparse arguments in the help In-Reply-To: References: <4F4CE7BC.6080908@gmail.com> <4F4CFD7A.20904@gmail.com> Message-ID: On Tue, Feb 28, 2012 at 1:07 PM, Peter Otten <__peter__ at web.de> wrote: > Andrea Crotti wrote: > >> On 02/28/2012 04:02 PM, Peter Otten wrote: >>> Andrea Crotti wrote: >>> >>>> I have a script that might be used interactively but also has some >>>> arguments that >>>> should not be used by "normal" users. >>>> So I just want to suppress them from the help. >>>> I've read somewhere that the help=SUPPRESS should do what I want: >>>> >>>> ? ? ? parser.add_argument('-n', '--test_only', >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? action='store_true', >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? help=SUPPRESS) >>>> >>>> but that's what I get from "myapp -h", which is not exactly what I was >>>> looking for.. >>>> >>>> >>>> ? ? -f, --first_level ? ? ==SUPPRESS== (default: False) >>>> ? ? --never_redevelop ? ? ==SUPPRESS== (default: False) >>>> >>>> >>>> Any other solutions? >>> That shouldn't happen. Did you reload() somewhere? >>> argparse tests object identity not equality with SUPPRESS, so you have to >>> ensure that SUPPRESS stems from the same instance of the argparse module >>> as your ArgumentParser. >>> >> >> Ah great yes it wasn't actually the same.. >> but why not just use >> if text != SUPPRESS >> instead of: >> if text is not SUPPRESS Because identity tests are good in these situations where you need to pass a "special" value and anything else could be valid, technically. This is known as a "sentinel" and is a common pattern. > Steven Bethard would have to answer that. > If it were my code I would have used the equality test, but also the correct > symbolic constant... > >> probably the second is more safe, but they are it's still checking >> against a constant that >> is very unlikely to clash with anything.. > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From ckaynor at zindagigames.com Tue Feb 28 17:19:50 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 28 Feb 2012 14:19:50 -0800 Subject: alternative to with statement? In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka wrote: > > I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. > The best I've found is to abuse the for notation: > > for _ in cachingcontext(x): > ? ?# create cached resources here > # return cached resources > > I would have really liked: > > with cachingcontext(x): > ? ?# create cached resources here > # return cached resources > > I'd also like to avoid the following because it is unnecessary boilerplate: > > with cachingcontext(x) as skip: > ? ?if not skip: > ? ? ? ? # create cached resources here > # return cached resources > An?alternative?way to do this would be to make it a decorator. Something along the lines of (written in my browser): def cachedfunc(func): cachedvalue = None def newfunc(*args, **kwargs): nonlocal cachedvalue if cachedvalue is None: cachedvalue = func(*args, **kwargs) return cachedvalue return newfunc @cachedfunc def test(): import time time.sleep(1) return 10 test() # should take 1 second test() # should be instant While that formula has limitations, it shows the basis of the idea. I'll leave it to the reader to expand it to allow calls with different arguments producing different results. > > > > -- > http://mail.python.org/mailman/listinfo/python-list From craigyk at me.com Tue Feb 28 17:22:46 2012 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 28 Feb 2012 14:22:46 -0800 Subject: alternative to with statement? In-Reply-To: References: Message-ID: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> It is a bit non-normal. but I think this is a good use case as I want to create a very simple-to-use system for non-python experts to safely wrap their CLI programs in a caching architecture... that's why I lament the inability to not use the more streamlined 'with' syntax? abusing the for loop might just be confusing. The with statement is also a good fit because the caching strategy does have to atomically acquire, create and release the appropriate locks. With this statement the cached CLI wrappers can be called from simultaneously from different scripts and still coordinate their activity, by waiting for each other to finish, and reusing the cached results, etc. On Feb 28, 2012, at 1:04 PM, Craig Yoshioka wrote: > I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. > The best I've found is to abuse the for notation: > > for _ in cachingcontext(x): > # create cached resources here > # return cached resources > > I would have really liked: > > with cachingcontext(x): > # create cached resources here > # return cached resources > > I'd also like to avoid the following because it is unnecessary boilerplate: > > with cachingcontext(x) as skip: > if not skip: > # create cached resources here > # return cached resources > > > > -- > http://mail.python.org/mailman/listinfo/python-list From rantingrickjohnson at gmail.com Tue Feb 28 17:56:10 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 28 Feb 2012 14:56:10 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 24, 8:54?am, Steven D'Aprano wrote: > for...else is a very useful construct, but the name is misleading. It > took me a long time to stop thinking that the else clause executes when > the for loop was empty. Agreed. This is a major stumbling block for neophytes. > In Python 4000, I think for loops should be spelled: > > for name in iterable: > ? ? # for block > then: > ? ? # only if not exited with break > else: > ? ? # only if iterable is empty > > and likewise for while loops. I like this syntax better than the current syntax, however, it is STILL far too confusing! > for name in iterable: > ? ? # for block this part is okay > then: > ? ? # only if not exited with break I only know how the "then" clause works if you include that comment each and every time! > else: > ? ? # only if iterable is empty Again. I need more info before this code becomes intuitive. Too much guessing is required. Not to mention that the try/except/else suite treats "else" differently. try: do_this() except EXCEPTION: recover() else NO_EXCEPTION: okay_do_this_also(). for x in iterable: do_this() except EXCEPTION: recover() else NO_EXCEPTION: do_this_also() while LOOPING: do_this() except EXCEPTION: break or recover() else NO_EXCEPTION: do_this_also() In this manner "else" will behave consistently between exception handling and looping. But this whole idea of using an else clause is ridiculous anyway because all you've done is to "break up" the code visually. Not to mention; breaking the cognitive flow of a reader! try: do_this() okay_do_this_also() what_the_heck.do_this_too() except EXCEPTION: recover() finally: always_do_this() Loop syntax can drop the "else" and adopt "then/finally" -- if you think we even need a finally!?!? for x in iterable: do_this() except EXCEPTION: recover() then: okay_do_this_also() what_the_heck.do_this_too() finally: always_do_this() while LOOPING: do_this() except EXCEPTION: recover() then: okay_do_this_also() what_the_heck.do_this_too() finally: always_do_this() From tjreedy at udel.edu Tue Feb 28 17:56:45 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 28 Feb 2012 17:56:45 -0500 Subject: alternative to with statement? In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> References: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> Message-ID: On 2/28/2012 5:12 PM, Prasad, Ramit wrote: > Craig Yoshioka wrote: >> I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. [..] > >> I would have really liked: >> with cachingcontext(x): >> # create cached resources here >> # return cached resources > > Is this a common pattern? I thought the point of the context manager > was to remove create and close the resources (like with file opening). Exactly. It is Python's version of RAII https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization > Seems slightly odd to use just for creation... I do not see the point either. -- Terry Jan Reedy From rosuav at gmail.com Tue Feb 28 18:24:18 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Feb 2012 10:24:18 +1100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Feb 29, 2012 at 9:56 AM, Rick Johnson wrote: > On Feb 24, 8:54?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > >> In Python 4000, I think for loops should be spelled: >> >> for name in iterable: >> ? ? # for block >> then: >> ? ? # only if not exited with break >> else: >> ? ? # only if iterable is empty >> >> and likewise for while loops. > > I like this syntax better than the current syntax, however, it is > STILL far too confusing! Absolutely, it's FAR too confusing. Every syntactic structure should have the addition of a "foo:" suite, which will run when the programmer expects it to and no other time. This would solve a LOT of problems. ChrisA From skippy.hammond at gmail.com Tue Feb 28 18:32:10 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 29 Feb 2012 10:32:10 +1100 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4D63FA.5050200@gmail.com> On 28/02/2012 9:07 PM, Andrea Crotti wrote: > How should I check if I can create files in a directory? By trying to create them there :) Presumably you want to know that so you can write something "real" - so just write that something real. The problem gets quite hard when you consider things like elevation - your *user* may have rights to write to a directory but only when elevated - think writing into Program Files. Further, this check can only ever be transient - what if you have the rights by virtue of a group membership, but tomorrow you are no longer in that group? Or by virtue of being the "owner" of the directory but later losing the ownership? The only reasonable way to check is to write to it, and you may as well skip attempting to write a temp file - just write what you care about and handle failure in the most graceful way you can. This is what almost every app does - consider apps with a "save as" dialog - they never check the directory is writable, they just attempt the actual write and handle the failure. Mark From jobattle at gmail.com Tue Feb 28 18:35:49 2012 From: jobattle at gmail.com (jobattle) Date: 28 Feb 2012 23:35:49 GMT Subject: pyusb and microchip mcp2210 interface Message-ID: Has anybody out there had any experience in using the PYUSB library with the new Microchip MCP2210 USB to SPI chip? From breamoreboy at yahoo.co.uk Tue Feb 28 18:41:16 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 28 Feb 2012 23:41:16 +0000 Subject: Listing children processes In-Reply-To: References: Message-ID: On 28/02/2012 21:47, Arnaud Delobelle wrote: > On 28 February 2012 21:39, Mihai Badoiu wrote: >> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >>> >>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >>>> I'm trying to compute the total CPU load of an external process and it's >>>> children. (so I cannot use resource.getrusage) For the load of the >>>> process >>>> I can just grab it from /proc/X/stat. How do I get the CPU load of the >>>> children processes? Is there an easy way to get a list of the children >>>> processes? >>> >>> http://code.google.com/p/psutil/ >>> >>> Cheers, >>> Chris > >> Looked at that before. psutil doesn't do children. >> >> --mihai > > Please don't top-post! Also, psutil.Process.get_children() looks to > me like it "does" children. > You are incorrect. I've been told of by the BDFL for stating that people should not top post on any Python mailing list/news group. -- Cheers. Mark Lawrence. From d at davea.name Tue Feb 28 19:03:05 2012 From: d at davea.name (Dave Angel) Date: Tue, 28 Feb 2012 19:03:05 -0500 Subject: Listing children processes In-Reply-To: References: Message-ID: <4F4D6B39.2010106@davea.name> On 02/28/2012 06:41 PM, Mark Lawrence wrote: > On 28/02/2012 21:47, Arnaud Delobelle wrote: >> Please don't top-post! Also, psutil.Process.get_children() looks to >> me like it "does" children. >> > > You are incorrect. I've been told of by the BDFL for stating that > people should not top post on any Python mailing list/news group. > What does the BDFL have to do with the usefulness of psutil? I'm not likely to download it, but here's a ref from the docs: http://code.google.com/p/psutil/wiki/Documentation get_open_files() Return files opened by process as a list of namedtuples including file absolute path name and file descriptor. Example: >>> import psutil, os >>> f = open('file.ext', 'w') >>> p = psutil.Process(os.getpid()) >>> p.get_open_files() [openfile(path='/home/giampaolo/svn/psutil/file.ext', fd=3)] -- DaveA From ben+python at benfinney.id.au Tue Feb 28 19:16:24 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 11:16:24 +1100 Subject: Listing children processes References: Message-ID: <87ehtepk87.fsf@benfinney.id.au> Mark Lawrence writes: > On 28/02/2012 21:47, Arnaud Delobelle wrote: > > Please don't top-post! Also, psutil.Process.get_children() looks to > > me like it "does" children. > > You are incorrect. Incorrect? The only factual statement Arnaud made was about ?psutil?. > I've been told of by the BDFL for stating that people should not top > post on any Python mailing list/news group. Fortunately, the BDFL is not a position of authority outside the Python language. We as a community have the long-standing consensus that top-posting is to be avoided. -- \ ?Don't be misled by the enormous flow of money into bad defacto | `\ standards for unsophisticated buyers using poor adaptations of | _o__) incomplete ideas.? ?Alan Kay | Ben Finney From steve+comp.lang.python at pearwood.info Tue Feb 28 19:16:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Feb 2012 00:16:27 GMT Subject: Listing children processes References: Message-ID: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > I've been told of by the BDFL for stating that > people should not top post on any Python mailing list/news group. He's the BDFL of Python, not of mailing list etiquette. -- Steven From steve+comp.lang.python at pearwood.info Tue Feb 28 19:18:54 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Feb 2012 00:18:54 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f4d6eee$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 29 Feb 2012 10:24:18 +1100, Chris Angelico wrote: > Every syntactic structure should > have the addition of a "foo:" suite, which will run when the programmer > expects it to and no other time. This would solve a LOT of problems. Indeed, when I design my killer language, the identifiers "foo" and "bar" will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice. -- Tim Peters, 29 Apr 1998 -- Steven From ramit.prasad at jpmorgan.com Tue Feb 28 19:30:16 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 00:30:16 +0000 Subject: alternative to with statement? In-Reply-To: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> References: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474164DCD@SCACMX008.exchad.jpmchase.net> Craig Yoshioka wrote: >It is a bit non-normal. but I think this is a good use case as I want to create a very simple-to-use system for non-python experts to safely wrap their CLI programs in a caching architecture... that's why I lament the inability to not use the more streamlined 'with' syntax- abusing the for loop might just be confusing. The with statement is also a good fit because the caching strategy does have to atomically acquire, create and release the appropriate locks. With this statement the cached CLI wrappers can be called from simultaneously from different scripts and still coordinate their activity, by waiting for each other to finish, and reusing the cached results, etc. > with cachingcontext(x): > # create cached resources here > # return cached resources On a separate note, how would you even return the cached resources without using the following ? with cachingcontext(x) as blah: The only thing cachingcontext seems to do is catch errors and since cachingcontext would be used by the "non-python experts", I have trouble understanding how this would help them any more than: try: # create cached resources here except SomeError: # handle error If you return the cached resources outside the caching context than how could you possibly release it via the context manager? It seems like you want some kind of resource pooling but if that is the case then just write your own pool. See http://stackoverflow.com/questions/1514120/python-implementation-of-the-object-pool-design-pattern . Sorry if that does not help, but I do not comprehend what you are trying to do. It seems inherently conflicted to say you want to use "with" because it lets you atomically open, use, then close resources but you do NOT want to atomically open, use, then close resources... Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From breamoreboy at yahoo.co.uk Tue Feb 28 20:37:31 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 29 Feb 2012 01:37:31 +0000 Subject: Listing children processes In-Reply-To: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 29/02/2012 00:16, Steven D'Aprano wrote: > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > >> I've been told of by the BDFL for stating that >> people should not top post on any Python mailing list/news group. > > He's the BDFL of Python, not of mailing list etiquette. > > Incorrect, I was told off for this http://code.activestate.com/lists/python-ideas/14065/ Please don't bother apologising as I don't want to read another of your versions of War and Peace. -- Cheers. Mark Lawrence. From example.scripts at gmail.com Tue Feb 28 22:59:40 2012 From: example.scripts at gmail.com (scripts examples) Date: Tue, 28 Feb 2012 19:59:40 -0800 (PST) Subject: python scripts solution for euler projects Message-ID: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Got a web site setup for solving euler problems in python, perl, ruby and javascript. Feel free to give me any feedback, thanks. From rodrick.brown at gmail.com Tue Feb 28 23:16:08 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Tue, 28 Feb 2012 23:16:08 -0500 Subject: python scripts solution for euler projects In-Reply-To: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: On Tue, Feb 28, 2012 at 10:59 PM, scripts examples < example.scripts at gmail.com> wrote: > > Got a web site setup for solving euler problems in python, perl, > ruby and javascript. > > Feel free to give me any feedback, thanks. > ???? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jasonveldicott at gmail.com Tue Feb 28 23:38:33 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Wed, 29 Feb 2012 15:38:33 +1100 Subject: Error importing __init__ declared variable from another package In-Reply-To: References: Message-ID: > > > Hi, > > > > I have a simple configuration of modules as beneath, but an import error > > is reported: > > > > /engine > > (__init__ is empty here) > > engine.py > > /sim > > __init__.py > > > > > > The module engine.py imports a variable instantiated in sim.__init__ as > > follows: > > > > from sim import var_name > > var_name.func() > > > > The following error messaged is received on the func() call above > (Eclipse > > PyDev): > > > > "undefined variable from import: func" > Are you rephrasing or is this really the error message? If so run your > program again on the command-line. Then please cut and paste the error > message together with the traceback. > > Any idea why this is causing an error? > What version of Python are you using? > What does sim/__init__.py contain? Thanks Peter. I'm using Python 2.6, but it works at the command line. The error only appears in Eclipse as a red cross in the margin. The exact error msg, as appears in a floating text caption on mouse over, is as I mentioned (capitalised). Perhaps it is some issue in PyDev, maybe related to the version of Python I'm using. I'm in the process of trying to solve another related import problem, and wished to resolve this one in the hope that it might shed light on the other. But as it works beside the error icon appearing, I might just ignore it and spare the trouble of precise identification of cause. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnjsal at gmail.com Wed Feb 29 00:06:41 2012 From: johnjsal at gmail.com (John Salerno) Date: Tue, 28 Feb 2012 21:06:41 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? Message-ID: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> The book I'm reading about using Tkinter only does this when creating the top-level window: app = Application() app.mainloop() and of course the Application class has subclassed the tkinter.Frame class. However, in the Python documentation, I see this: root = Tk() app = Application(master=root) app.mainloop() root.destroy() Is it necessary to explicitly call Tk(), then pass that result as an argument for the Application call? Is it also necessary to call destroy() on the root frame? I tried the above and I got the following error: Traceback (most recent call last): File "C:\Users\John\Desktop\gui.py", line 12, in root.destroy() File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy self.tk.call('destroy', self._w) _tkinter.TclError: can't invoke "destroy" command: application has been destroyed So apparently closing the window with the X button (on Windows) implicitly calls the destroy() method of the root frame. If that's the case, why does the documentation explicitly call it? Furthermore, I pasted the exact example from the documentation into IDLE and ran it, and I also go the same error, so the example in the documentation doesn't even work. So is it sufficient simply to create an Application instance, use mainloop, and then handle the closing of the window elsewhere in the program (such as a widget calling the destroy method on-click, or just letting the X button do it)? Thanks! From ben+python at benfinney.id.au Wed Feb 29 00:12:41 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 16:12:41 +1100 Subject: Listing children processes References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8762eqp6ie.fsf@benfinney.id.au> Mark Lawrence writes: > On 29/02/2012 00:16, Steven D'Aprano wrote: > > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > >> I've been told of by the BDFL for stating that people should not > >> top post on any Python mailing list/news group. > > > > He's the BDFL of Python, not of mailing list etiquette. > > Incorrect What Steven says is correct: the BDFL of Python has no special authority over mailing list etiquette. > I was told off for this No-one's saying you weren't told off. We're saying that there's no point invoking the BDFL when it comes to mailing list etiquette, as he has no special authority on that. > Please don't bother apologising I doubt anyone feels compelled to apologise to you for this. -- \ ?In the long run nothing can withstand reason and experience, | `\ and the contradiction which religion offers to both is all too | _o__) palpable.? ?Sigmund Freud | Ben Finney From brendon.joyce at gmail.com Wed Feb 29 01:56:22 2012 From: brendon.joyce at gmail.com (Brendon Joyce) Date: Wed, 29 Feb 2012 16:56:22 +1000 Subject: No subject Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Wed Feb 29 02:29:53 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Wed, 29 Feb 2012 12:59:53 +0530 Subject: Pickle handling dictionary Message-ID: I was successful in testing pickle with multiple objects both READ & WRITE. I did WRITE as - --- #!/usr/bin/python import pickle class apple_Class(object): def __init__(self, **kwds): self.__dict__.update(kwds) myInst = apple_Class() myInst.FirstString = "Apple" myInst.SecondString = "Orange" with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump((myInst.FirstString, myInst.SecondString), f) ---- I did READ as - --- #!/usr/bin/python import pickle class apple_Class(object): def __init__(self, **kwds): self.__dict__.update(kwds) myInst = apple_Class() with open('/tmp/readfile.pkl', 'rb') as f: myInst.FirstString, myInst.SecondString = pickle.load(f) print myInst.FirstString print myInst.SecondString --- Both worked successfully. Now, I have to write a file having below three things - - Having dictionary of many instances - string as a Key - Instances as Value. Finally, I have to do the same thing as above to WRITE in separate file and READ in separate file. So, the issues is simply how to handle many instances in a dictionary with Key and Value. -------------- next part -------------- An HTML attachment was scrubbed... URL: From xahlee at gmail.com Wed Feb 29 03:09:16 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 00:09:16 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! Message-ID: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> New Science Discovery: Perl Idiots Remain Idiots After A Decade! A excerpt from the new book ?Modern Perl?, just published, chapter 4 on ?Operators?. Quote: ?The associativity of an operator governs whether it evaluates from left to right or right to left. Addition is left associative, such that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 ** 4 first, then raises 2 to the 81st power. ? LOL. Looks like the perl folks haven't changed. Fundamentals of serious math got botched so badly. Let me explain the idiocy. It says ?The associativity of an operator governs whether it evaluates from left to right or right to left.?. Ok, so let's say we have 2 operators: a white triangle ? and a black triangle ?. Now, by the perl's teaching above, let's suppose the white triangle is ?right associative? and the black triangle is ?left associative?. Now, look at this: 3 ? 6 ? 5 seems like the white and black triangles are going to draw a pistol and fight for the chick 6 there. LOL. Now, let me tell you what operator precedence is. First of all, let's limit ourselfs to discuss operators that are so-called binary operators, which, in our context, basically means single symbol operator that takes it's left and right side as operands. Now, each symbol have a ?precedence?, or in other words, the set of operators has a order. (one easy way to think of this is that, suppose you have n symbols, then you give each a number, from 1 to n, as their order) So, when 2 symbols are placed side by side such as ?3 ? 6 ? 5?, the symbol with higher precedence wins. Another easy way to think of this is that each operator has a stickiness level. The higher its level, it more sticky it is. the problem with the perl explanations is that it's one misleading confusion ball. It isn't about ?left/right associativity?. It isn't about ?evaluates from left to right or right to left?. Worse, the word ?associativity? is a math term that describe a property of algebra that has nothing to do with operator precedence, yet is easily confused with because it is a property about order of evaluation. (for example, the addition function is associative, meaning: ?(3+6)+5 = 3+(6+5)?.) compare it with this: ?Perl ? Python: Complex Numbers? http://xahlee.org/perl-python/complex_numbers.html and for a good understanding of functions and operators, see: ?What's Function, What's Operator?? http://xahlee.org/math/function_and_operators.html From guillaumechorn at gmail.com Wed Feb 29 03:25:52 2012 From: guillaumechorn at gmail.com (Guillaume Chorn) Date: Wed, 29 Feb 2012 16:25:52 +0800 Subject: Problem using s.strip() to remove leading whitespace in .csv file Message-ID: Hello All, I have a .csv file that I created by copying and pasting a list of all the players in the NBA with their respective teams and positions ( http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!). Unfortunately, when I do this I have no choice but to include a single leading whitespace character for each name. I'd like to compare this list of names to another list (also in .csv format but in a different file) using a simple Python script, but in order to do that I need to strip the leading whitespace from all of the names or none of them will match the names in the second list. However, when I try to do this as follows: positions = open('/home/guillaume/Documents/playerpos.csv') for line in positions: info = line.split(',') name = info[0] name = name.strip() print name #to examine the effect of name.strip() I keep getting all of the names with the leading whitespace character NOT removed (for example: " Jeff Adrien". Why is this happening? The following is a sample of the .csv file (the one I'm trying to remove the whitespace from) opened in gedit, the built-in Ubuntu text editor: Jeff Adrien,SF,Houston Rockets Arron Afflalo,SG,Denver Nuggets Maurice Ager,GF,Minnesota Timberwolves Blake Ahearn,PG,Los Angeles Clippers Alexis Ajinca,FC,Toronto Raptors Solomon Alabi,C,Toronto Raptors Cole Aldrich,C,Oklahoma City Thunder LaMarcus Aldridge,FC,Portland Trail Blazers Joe Alexander,SF,New Orleans Hornets Lavoy Allen,FC,Philadelphia 76ers Malik Allen,FC,Orlando Magic Ray Allen,SG,Boston Celtics Tony Allen,GF,Memphis Grizzlies Lance Allred,C,Indiana Pacers Rafer Alston,PG,Miami Heat Any help with this seemingly simple but maddening issue would be much appreciated. thanks, Guillaume -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Feb 29 03:53:38 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 29 Feb 2012 09:53:38 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file References: Message-ID: Guillaume Chorn wrote: > Hello All, > > I have a .csv file that I created by copying and pasting a list of all the > players in the NBA with their respective teams and positions ( > http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!). > Unfortunately, when I do this I have no choice but to include a single > leading whitespace character for each name. I'd like to compare this list > of names to another list (also in .csv format but in a different file) > using a simple Python script, but in order to do that I need to strip the > leading whitespace from all of the names or none of them will match the > names in the second list. However, when I try to do this as follows: > > positions = open('/home/guillaume/Documents/playerpos.csv') > > for line in positions: > info = line.split(',') > name = info[0] > name = name.strip() > print name #to examine the effect of name.strip() > > I keep getting all of the names with the leading whitespace character NOT > removed (for example: " Jeff Adrien". Why is this happening? Do you mean print name.strip() still prints a leading space? If so, what does print repr(name) print? If it is "\xc2\xa0Jeff Adrien" try print name.decode("utf-8").strip() Or do you mean the effect of strip() is not permanent? You have to modify the line then: cleaned_lines = [] for line in positions: info = line.split(",") info[0] = info[0].strip() cleaned_lines.append(",".join(info)) positions = cleaned_lines > The following is a sample of the .csv file (the one I'm trying to remove > the whitespace from) opened in gedit, the built-in Ubuntu text editor: > > Jeff Adrien,SF,Houston Rockets > Arron Afflalo,SG,Denver Nuggets > Maurice Ager,GF,Minnesota Timberwolves > Blake Ahearn,PG,Los Angeles Clippers > Alexis Ajinca,FC,Toronto Raptors > Solomon Alabi,C,Toronto Raptors > Cole Aldrich,C,Oklahoma City Thunder > LaMarcus Aldridge,FC,Portland Trail Blazers > Joe Alexander,SF,New Orleans Hornets > Lavoy Allen,FC,Philadelphia 76ers > Malik Allen,FC,Orlando Magic > Ray Allen,SG,Boston Celtics > Tony Allen,GF,Memphis Grizzlies > Lance Allred,C,Indiana Pacers > Rafer Alston,PG,Miami Heat > > Any help with this seemingly simple but maddening issue would be much > appreciated. > > thanks, > Guillaume From kliateni at gmail.com Wed Feb 29 04:01:21 2012 From: kliateni at gmail.com (Karim) Date: Wed, 29 Feb 2012 10:01:21 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: References: Message-ID: <4F4DE961.2060302@gmail.com> Le 29/02/2012 09:25, Guillaume Chorn a ?crit : > Hello All, > > I have a .csv file that I created by copying and pasting a list of all > the players in the NBA with their respective teams and positions > (http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO! > ). > Unfortunately, when I do this I have no choice but to include a single > leading whitespace character for each name. I'd like to compare this > list of names to another list (also in .csv format but in a different > file) using a simple Python script, but in order to do that I need to > strip the leading whitespace from all of the names or none of them > will match the names in the second list. However, when I try to do > this as follows: > > positions = open('/home/guillaume/Documents/playerpos.csv') > > for line in positions: > info = line.split(',') > name = info[0] > name = name.strip() > print name #to examine the effect of name.strip() > > I keep getting all of the names with the leading whitespace character > NOT removed (for example: " Jeff Adrien". Why is this happening? > > The following is a sample of the .csv file (the one I'm trying to > remove the whitespace from) opened in gedit, the built-in Ubuntu text > editor: > > Jeff Adrien,SF,Houston Rockets > Arron Afflalo,SG,Denver Nuggets > Maurice Ager,GF,Minnesota Timberwolves > Blake Ahearn,PG,Los Angeles Clippers > Alexis Ajinca,FC,Toronto Raptors > Solomon Alabi,C,Toronto Raptors > Cole Aldrich,C,Oklahoma City Thunder > LaMarcus Aldridge,FC,Portland Trail Blazers > Joe Alexander,SF,New Orleans Hornets > Lavoy Allen,FC,Philadelphia 76ers > Malik Allen,FC,Orlando Magic > Ray Allen,SG,Boston Celtics > Tony Allen,GF,Memphis Grizzlies > Lance Allred,C,Indiana Pacers > Rafer Alston,PG,Miami Heat > > Any help with this seemingly simple but maddening issue would be much > appreciated. > > thanks, > Guillaume > > > > > Use csv module instead of parsing yourself the csv file: import csv reader = csv.Reader(open("file.csv")) for row in reader: for key in row: print("key=", key, " value=", row[key]) Code above not tested but should work. Cheers Karim -------------- next part -------------- An HTML attachment was scrubbed... URL: From kliateni at gmail.com Wed Feb 29 04:04:59 2012 From: kliateni at gmail.com (Karim) Date: Wed, 29 Feb 2012 10:04:59 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: <4F4DE961.2060302@gmail.com> References: <4F4DE961.2060302@gmail.com> Message-ID: <4F4DEA3B.8040808@gmail.com> Le 29/02/2012 10:01, Karim a ?crit : > Le 29/02/2012 09:25, Guillaume Chorn a ?crit : >> Hello All, >> >> I have a .csv file that I created by copying and pasting a list of >> all the players in the NBA with their respective teams and positions >> (http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO! >> ). >> Unfortunately, when I do this I have no choice but to include a >> single leading whitespace character for each name. I'd like to >> compare this list of names to another list (also in .csv format but >> in a different file) using a simple Python script, but in order to do >> that I need to strip the leading whitespace from all of the names or >> none of them will match the names in the second list. However, when >> I try to do this as follows: >> >> positions = open('/home/guillaume/Documents/playerpos.csv') >> >> for line in positions: >> info = line.split(',') >> name = info[0] >> name = name.strip() >> print name #to examine the effect of name.strip() >> >> I keep getting all of the names with the leading whitespace character >> NOT removed (for example: " Jeff Adrien". Why is this happening? >> >> The following is a sample of the .csv file (the one I'm trying to >> remove the whitespace from) opened in gedit, the built-in Ubuntu text >> editor: >> >> Jeff Adrien,SF,Houston Rockets >> Arron Afflalo,SG,Denver Nuggets >> Maurice Ager,GF,Minnesota Timberwolves >> Blake Ahearn,PG,Los Angeles Clippers >> Alexis Ajinca,FC,Toronto Raptors >> Solomon Alabi,C,Toronto Raptors >> Cole Aldrich,C,Oklahoma City Thunder >> LaMarcus Aldridge,FC,Portland Trail Blazers >> Joe Alexander,SF,New Orleans Hornets >> Lavoy Allen,FC,Philadelphia 76ers >> Malik Allen,FC,Orlando Magic >> Ray Allen,SG,Boston Celtics >> Tony Allen,GF,Memphis Grizzlies >> Lance Allred,C,Indiana Pacers >> Rafer Alston,PG,Miami Heat >> >> Any help with this seemingly simple but maddening issue would be much >> appreciated. >> >> thanks, >> Guillaume >> >> >> >> >> > Use csv module instead of parsing yourself the csv file: > > import csv > > reader = csv.Reader(open("file.csv")) > > for row in reader: > for key in row: > print("key=", key, " value=", row[key]) > > > Code above not tested but should work. > > Cheers > Karim > Just a correction use a dictionary like csv reader: *reader = csv.DictReader(open("file.csv"))* Cheers Karim -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaumechorn at gmail.com Wed Feb 29 04:05:34 2012 From: guillaumechorn at gmail.com (Guillaume Chorn) Date: Wed, 29 Feb 2012 17:05:34 +0800 Subject: Problem using s.strip() to remove leading whitespace in .csv file Message-ID: Thanks, the suggestion print name.decode("utf-8").strip() worked like a charm. When I did the print repr(name) I got exactly what you predicted. I'm not yet sure what all of this means, but I'm going to read this in the hopes of finding out. Anyway thanks again for the help! cheers, Guillaume -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Wed Feb 29 04:07:55 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Wed, 29 Feb 2012 14:37:55 +0530 Subject: Why this fails?? Message-ID: Why below fails - ---- #!/usr/bin/python import pickle class MyClass(object): Field1 = None Field2 = None def __init__(self, dictionary): self.__dict__.update(dictionary) my_List = {'Field1': 'Apple', 'Field2': 'Orange'} myInst = MyClass(my_List) with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump(myInst, f) ---- with below error messges - $ ./pickleClassWrite.py Traceback (most recent call last): File "./pickleClassWrite.py", line 5, in class MyClass(object): File "./pickleClassWrite.py", line 14, in MyClass myInst = MyClass(my_List) NameError: name 'MyClass' is not defined --- -------------- next part -------------- An HTML attachment was scrubbed... URL: From jabba.laci at gmail.com Wed Feb 29 05:01:16 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 29 Feb 2012 11:01:16 +0100 Subject: use CTRL+L for clearing the screen Message-ID: Hi, I'm working on an interactive script. With raw_input user input is read and the script produces some output and offers the prompt again. I would like to add a clear screen feature, which would be activated with CTRL+L. How to do that? Another thing: raw_input waits until but I'd like to clear the screen at the moment when CTRL+L is pressed. The script should be self-contained, thus I'd like to solve it by using the standard library only. Thanks, Laszlo From d at davea.name Wed Feb 29 05:30:10 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 05:30:10 -0500 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: References: Message-ID: <4F4DFE32.1080703@davea.name> On 02/29/2012 04:05 AM, Guillaume Chorn wrote: > Thanks, the suggestion > > print name.decode("utf-8").strip() > > worked like a charm. When I did the print repr(name) I got exactly what > you predicted. I'm not yet sure what all of this means, but I'm going to > read this in the hopes of > finding out. Anyway thanks again for the help! > > > cheers, > Guillaume > What it means is that the character before the name was not a space character, but some Unicode variant of space. Peter figured that out, not I. It also means that you were using the incorrect decoder for the way the file was encoded and written out. Are you creating that csv file with some Windows app, or with Python? You should look at it with a hex viewer to see if there are other surprises waiting for you in there. For example, you might also need the same kind of solution if there are quotes (or an apostrophe) anywhere in the file. Or if someone's address uses an umlaut. Generally, it's better to clean up cruft at the source, when possible. And if that means the file has to be stored in utf-8, you should decode the whole file that way, and then deal with it as unicode. -- DaveA From d at davea.name Wed Feb 29 05:34:04 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 05:34:04 -0500 Subject: Why this fails?? In-Reply-To: References: Message-ID: <4F4DFF1C.7040109@davea.name> On 02/29/2012 04:07 AM, Smiley 4321 wrote: > Why below fails - > > ---- > #!/usr/bin/python > > import pickle > > class MyClass(object): > > Field1 = None > Field2 = None > > def __init__(self, dictionary): > self.__dict__.update(dictionary) > > my_List = {'Field1': 'Apple', 'Field2': 'Orange'} > myInst = MyClass(my_List) > > with open('/tmp/readfile.pkl', 'wb') as f: > pickle.dump(myInst, f) > ---- > > with below error messges - > > $ ./pickleClassWrite.py > Traceback (most recent call last): > File "./pickleClassWrite.py", line 5, in > class MyClass(object): > File "./pickleClassWrite.py", line 14, in MyClass > myInst = MyClass(my_List) > NameError: name 'MyClass' is not defined > --- > The reason for the error is that you're trying to use the class (by name) before its definition is complete. The cause is that the code starting with the line "my_list = {Field1... " should have been dedented to be at top-level. You don't want those last 4 lines to be inside the class. -- DaveA From ben+python at benfinney.id.au Wed Feb 29 06:39:22 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 22:39:22 +1100 Subject: use CTRL+L for clearing the screen References: Message-ID: <87y5rloolx.fsf@benfinney.id.au> Jabba Laci writes: > I would like to add a clear screen feature, which would be activated > with CTRL+L. How to do that? > Another thing: raw_input waits until but I'd like to clear the > screen at the moment when CTRL+L is pressed. That sounds like a job for the standard library ?readline? module , an interface to the widely-used C library of the same name on free operating systems. -- \ ?We demand rigidly defined areas of doubt and uncertainty!? | `\ ?Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas | _o__) Adams | Ben Finney From Shambhu.Rajak at kpitcummins.com Wed Feb 29 06:43:21 2012 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Wed, 29 Feb 2012 11:43:21 +0000 Subject: Python-list Digest, Vol 101, Issue 164 In-Reply-To: References: Message-ID: <408F64D89899604FB24015E64E10490C20E0F01E@KCHJEXMB01.kpit.com> Hi, I want building GNU debugger for mingw. Need the GDB to support python How should I go about it? Thanks, Shambhu This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. From chiron613 at gmail.com Wed Feb 29 06:43:22 2012 From: chiron613 at gmail.com (Chiron) Date: Wed, 29 Feb 2012 11:43:22 GMT Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: On Wed, 29 Feb 2012 00:09:16 -0800, Xah Lee wrote: Personally, I think this whole issue of precedence in a programming language is over-rated. It seems to me that grouping of any non-trivial set of calculations should be done so as to remove any possible confusion as to intent. It is one more obstacle to accidental errors in logic, where you intend one thing, possibly overlook precedence, and get a strange result. Sure, mathematically it *should* go a particular way, and any programming language *should* follow that. Still... they don't, and since they don't it makes more sense to be really obvious what you meant to do. As someone pointed out, a programming language is for humans; computers don't need them. That being the case, it makes sense to keep things as clear as possible. -- It's OKAY -- I'm an INTELLECTUAL, too. From crowdfinchtechinfo at gmail.com Wed Feb 29 06:46:21 2012 From: crowdfinchtechinfo at gmail.com (CrowdFinch) Date: Wed, 29 Feb 2012 03:46:21 -0800 (PST) Subject: CrowdFinch Technologies Message-ID: <680242e7-9947-4b3c-be2c-1fa62b131da5@p21g2000yqm.googlegroups.com> CrowdFinch Technologies is a leading professional custom web design and web development company specialized in Outsourced Web Development Services, Mobile Application Development, Web design, SEO Services. From kiuhnm03.4t.yahoo.it Wed Feb 29 07:08:53 2012 From: kiuhnm03.4t.yahoo.it (Kiuhnm) Date: Wed, 29 Feb 2012 13:08:53 +0100 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <4f4e1554$0$1385$4fafbaef@reader2.news.tin.it> On 2/29/2012 9:09, Xah Lee wrote: > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. Sorry, but you're wrong and they're right. Associativity governs the order of evaluation of a group of operators *OF THE SAME PRECEDENCE*. If you write 2**3**4 only the fact the '**' is right associative will tell you that the order is 2**(3**4) and not (2**3)**4 I remind you that 2^(3^4) != (2^3)^4. Kiuhnm From jeanpierreda at gmail.com Wed Feb 29 07:12:01 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 29 Feb 2012 07:12:01 -0500 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: On Wed, Feb 29, 2012 at 6:43 AM, Chiron wrote: > Personally, I think this whole issue of precedence in a programming > language is over-rated. ?It seems to me that grouping of any non-trivial > set of calculations should be done so as to remove any possible confusion > as to intent. Some languages do this. e.g. all lisps. -- Devin From alister.ware at ntlworld.com Wed Feb 29 07:21:59 2012 From: alister.ware at ntlworld.com (alister) Date: Wed, 29 Feb 2012 12:21:59 GMT Subject: python scripts solution for euler projects References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: On Tue, 28 Feb 2012 19:59:40 -0800, scripts examples wrote: > Got a web site setup for solving euler problems in python, perl, > ruby and javascript. > > Feel free to give me any feedback, thanks. Failing to give a link to the site is a pretty fundamental failure -- Please take note: From ulrich.eckhardt at dominolaser.com Wed Feb 29 08:02:36 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 29 Feb 2012 14:02:36 +0100 Subject: building GNU debugger (was: Re: Python-list Digest, Vol 101, Issue 164) In-Reply-To: References: Message-ID: Three things up front: 1. Do not reply to digests. If you want to only read, you can use the digests, but they are not usable for replying, because it is completely unclear where in a discussion you are entering and what you are relating your answers to. 2. Do not start new threads by using the reply button. Your reply contains the message ID of the message you're replying to even if you delete any trace from the body. Better email on news clients will display your message associated with the one you replied to, although there is no relation at all. This is also called stealing threads. 3. Pick a meaningful subject. My attitude is generally that if you don't have time to pick a subject line, I don't have time to help you. Generally, getting help is easier if you did your job. Make sure you read and understand Eric S. Raymond's essay on asking questions the smart way. Am 29.02.2012 12:43, schrieb Shambhu Rajak: > I want building GNU debugger for mingw. Doesn't mingw come with GDB or at least have a GDB package? However, this has nothing to do with Python. > Need the GDB to support python How should I go about it? You don't need GDB in order to "support python", which has its own debugger. What is it that you're trying to achieve? See also mentioned essay on how to ask good questions. > This message contains information that may be privileged [...] If you can, please remove this. Good luck! Uli From wxjmfauth at gmail.com Wed Feb 29 08:45:35 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 29 Feb 2012 05:45:35 -0800 (PST) Subject: On u'Unicode string literals' (Py3) Message-ID: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> For those who do not know: The u'' string literal trick has never worked in Python 2. >>> sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' >>> print u'Un oeuf ? z?ro EURO uro' Un uf ? z?ro uro >>> jmf From johann.spies at gmail.com Wed Feb 29 08:52:50 2012 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 29 Feb 2012 15:52:50 +0200 Subject: list comprehension question Message-ID: I understand the following: In [79]: instansie instansie Out[79]: 'Mangosuthu Technikon' In [80]: t = [x.alt_name for x in lys] t = [x.alt_name for x in lys] In [81]: t t Out[81]: [] In [82]: t.append(instansie) t.append(instansie) In [83]: t t Out[83]: ['Mangosuthu Technikon'] But then why does the following behave like this: In [84]: t = [x.alt_name for x in lys].append(instansie) t = [x.alt_name for x in lys].append(instansie) In [85]: t t In [86]: type t type t -------> type(t) Out[86]: NoneType Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidgshi at yahoo.co.uk Wed Feb 29 08:56:40 2012 From: davidgshi at yahoo.co.uk (David Shi) Date: Wed, 29 Feb 2012 13:56:40 +0000 (GMT) Subject: Looking for a simple, generic Python module to provide a secure web service In-Reply-To: References: Message-ID: <1330523800.53282.YahooMailNeo@web171616.mail.ir2.yahoo.com> We are looking for a very simple, generic Python module to provide a secure web service.?? Ideally, it can be put onto the computer and make it available via IIS. ? Off we go. ? Your help will be gratefully received. ? Regards. ? David -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrickjohnson at gmail.com Wed Feb 29 09:24:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 06:24:40 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> Message-ID: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> On Feb 28, 11:06?pm, John Salerno wrote: > The book I'm reading about using Tkinter only does this when creating the top-level window: > > app = Application() > app.mainloop() > > and of course the Application class has subclassed the tkinter.Frame class. > > However, in the Python documentation, I see this: > > root = Tk() > app = Application(master=root) > app.mainloop() > root.destroy() > > Is it necessary to explicitly call Tk(), then pass that result as an argument for the Application call? Is it also necessary to call destroy() on the root frame? It is not necessarily to call Tk explicitly, which i think is a bug BTW. Sure, for simple scripts you can save one line of code but only at the expense of explicitness and intuitiveness. Observe ## START CODE ## import Tkinter as tk root = tk.Tk() root.title('Explicit Root') root.mainloop() f = tk.Frame(master=None, width=100, height=100, bg='red') f.pack() f.mainloop() b = tk.Button(master=None, text='Sloppy Coder') b.pack() b.mainloop() ## END CODE ## as you can see all three examples work even though the last two don't explicitly create a master. The master is still there however Tkinter just created "magically" for you. Talk about laziness! > I tried the above and I got the following error: > > Traceback (most recent call last): > ? File "C:\Users\John\Desktop\gui.py", line 12, in > ? ? root.destroy() > ? File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy > ? ? self.tk.call('destroy', self._w) > _tkinter.TclError: can't invoke "destroy" command: ?application has been destroyed > > So apparently closing the window with the X button (on Windows) implicitly calls the destroy() method of the root frame. If that's the case, why does the documentation explicitly call it? Because the documentation is FLAWED! Please provide links to this "documentation" so we can post it on the Wall Of Shame. > Furthermore, I pasted the exact example from the documentation into IDLE and ran it, and I also go the same error, so the example in the documentation doesn't even work. IDLE uses the same Python as the command line so naturally it will throw the same error. ;-) > So is it sufficient simply to create an Application instance, use mainloop, and then handle the closing of the window elsewhere in the program (such as a widget calling the destroy method on-click, or just letting the X button do it)? Most applications will have both: user destroying, and program destroying. Again, your example is FLAWED. Here is a simplified example: ## START CODE ## from tkMessageBox import askyesnocancel class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title('Close Me -->') self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) def onDestroyWindow(self): title = 'Confirm App Exit' msg = 'Save changes before exiting?' result = askyesnocancel(title, msg, default='cancel') if result is None: return elif result is True: print 'saving changes' elif result is False: print 'dont save changes' self.destroy() if __name__ == '__main__': app = App() app.mainloop() ## END CODE ## From rrakus at redhat.com Wed Feb 29 09:33:50 2012 From: rrakus at redhat.com (Roman Rakus) Date: Wed, 29 Feb 2012 15:33:50 +0100 Subject: Fwd: Question about PyXML and python's stdlib xml In-Reply-To: <4F4BA664.90707@redhat.com> References: <4F4BA664.90707@redhat.com> Message-ID: <4F4E374E.10201@redhat.com> I'm forwarding this message to python-list, since I didn't get answer on xml-sig ML. Hopefully this is right list to question. Please keep me in CC. Original message is below. RR -------- Original Message -------- Subject: Question about PyXML and python's stdlib xml Date: Mon, 27 Feb 2012 16:51:00 +0100 From: Roman Rakus To: xml-sig at python.org Hi, I have concerns about PyXML and stdlib xml included directly in python. Currently (in Fedora) python is trying to import PyXML, which means other results when you have and haven't PyXML installed. Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', 'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides more functionality in those modules? Is python's xml better, same or worse then PyXML? Anyway, python's xml is newer - is PyXML deprecated? Please keep me in CC, I'm not subscribed to the list. RR -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.rodola at gmail.com Wed Feb 29 09:41:19 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Wed, 29 Feb 2012 15:41:19 +0100 Subject: Listing children processes In-Reply-To: References: Message-ID: Il 28 febbraio 2012 22:47, Arnaud Delobelle ha scritto: > On 28 February 2012 21:39, Mihai Badoiu wrote: >> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >>> >>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >>> > I'm trying to compute the total CPU load of an external process and it's >>> > children.? (so I cannot use resource.getrusage)? For the load of the >>> > process >>> > I can just grab it from /proc/X/stat.? How do I get the CPU load of the >>> > children processes?? Is there an easy way to get a list of the children >>> > processes? >>> >>> http://code.google.com/p/psutil/ >>> >>> Cheers, >>> Chris > >> Looked at that before.? psutil doesn't do children. Yes, it does: >>> import psutil, os >>> p = psutil.Process(os.getpid()) >>> p.get_children() [ ... list of process children ... ] >>> --- Giampaolo code.google.com/p/pyftpdlib/ code.google.com/p/psutil/ code.google.com/p/pysendfile/ From stefan_ml at behnel.de Wed Feb 29 09:48:30 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 29 Feb 2012 15:48:30 +0100 Subject: Fwd: Question about PyXML and python's stdlib xml In-Reply-To: <4F4E374E.10201@redhat.com> References: <4F4BA664.90707@redhat.com> <4F4E374E.10201@redhat.com> Message-ID: Roman Rakus, 29.02.2012 15:33: > I'm forwarding this message to python-list, since I didn't get answer on > xml-sig ML I didn't see a message from you on that list. > I have concerns about PyXML and stdlib xml included directly in python. > Currently (in Fedora) python is trying to import PyXML, which means > other results when you have and haven't PyXML installed. What kind of "other results"? > Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". > PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', > 'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides > more functionality in those modules? Is python's xml better, same or > worse then PyXML? PyXML was meant as an extension and hooked into the stdlib XML support. That's only one of the reasons why it's broken now. > Anyway, python's xml is newer - is PyXML deprecated? Yes. It's a dead project. > Please keep me in CC, I'm not subscribed to the list. That may be the problem in the xml-sig case also. Stefan From d at davea.name Wed Feb 29 09:54:05 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 09:54:05 -0500 Subject: On u'Unicode string literals' (Py3) In-Reply-To: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> References: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> Message-ID: <4F4E3C0D.8040307@davea.name> Just who are you replying to? On 02/29/2012 08:45 AM, jmfauth wrote: > For those who do not know: > The u'' string literal trick has never worked in Python 2. > No trick there. If you have something explicit to say, then say it. >>>> sys.version > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' Why then does the subject line say Py3 ? >>>> print u'Un oeuf ? z?ro EURO uro' You're testing three things here, so there's no telling which might be wrong. Your source encoding, the implicit str() conversion for unicode, and the particular terminal you're printing it on. It'd be amazing if all three were right, unless you're on Linux. > Un uf ? z?ro uro > jmf -- DaveA From rweikusat at mssgmbh.com Wed Feb 29 10:15:02 2012 From: rweikusat at mssgmbh.com (Rainer Weikusat) Date: Wed, 29 Feb 2012 15:15:02 +0000 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Xah Lee writes: > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. As the perlop manpage would have told you, Operator associativity defines what happens if a sequence of the same operators is used one after another Since this is not the case in your example, it doesn't seem to be applicable here. Also, the Perl I'm aware doesn't have 'white triangle' and 'black triangle' operators and it also doesn't have operators of equal precedence and different associativity. It can't, actually, since there would be no way to evaluate an expression like the mock one you invented above. Lastly, that something happens to be in one way or another way in the completely arbitrary set of rules and conventions commonly referred to as 'mathematics' (an essentially outdated write-only programming language dating back to the times when humans had to perform computations themselves) doesn't mean it is of any relevance anywhere else just because of this, no matter how dear it might be to lots of people. From wxjmfauth at gmail.com Wed Feb 29 10:17:13 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 29 Feb 2012 07:17:13 -0800 (PST) Subject: On u'Unicode string literals' reintroduction (Py3) References: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> Message-ID: On 29 f?v, 14:45, jmfauth wrote: > For those who do not know: > The u'' string literal trick has never worked in Python 2. > > >>> sys.version > > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'>>> print u'Un oeuf ? z?ro EURO uro' > > Un ?uf ? z?ro ?uro > > > > jmf Sorry, I just wanted to show a small example. I semms Google as "changed" again. You should read (2nd attempt) u'Un ?uf ? z?ro ?' with the *correct* typed glyphs 'LATIN SMALL LIGATURE OE' in ?uf and 'EURO SIGN' in '?uro'. jmf From kiuhnm03.4t.yahoo.it Wed Feb 29 11:18:24 2012 From: kiuhnm03.4t.yahoo.it (Kiuhnm) Date: Wed, 29 Feb 2012 17:18:24 +0100 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Message-ID: <4f4e4fce$0$1386$4fafbaef@reader1.news.tin.it> On 2/29/2012 16:15, Rainer Weikusat wrote: > [...] 'mathematics' (an essentially > outdated write-only programming language dating back to the times > when humans had to perform computations themselves) [...] Theoretical Computer Science is a branch of mathematics. Are you saying it is outdated? Kiuhnm From jamesbroadhead at gmail.com Wed Feb 29 12:01:35 2012 From: jamesbroadhead at gmail.com (James Broadhead) Date: Wed, 29 Feb 2012 17:01:35 +0000 Subject: list comprehension question In-Reply-To: References: Message-ID: On 29 February 2012 13:52, Johann Spies wrote: > In [82]: t.append(instansie) > t.append(instansie) > > In [83]: t > t > Out[83]: ['Mangosuthu Technikon'] > In [84]: t = [x.alt_name for x in lys].append(instansie) > t = [x.alt_name for x in lys].append(instansie) > > In [85]: t > t > > In [86]: type t > type t > -------> type(t) > Out[86]: NoneType > You should note that in [82], you're not doing: > t = t.append(instansie) hth From gordon at panix.com Wed Feb 29 12:08:30 2012 From: gordon at panix.com (John Gordon) Date: Wed, 29 Feb 2012 17:08:30 +0000 (UTC) Subject: list comprehension question References: Message-ID: In James Broadhead writes: > On 29 February 2012 13:52, Johann Spies wrote: > > In [82]: t.append(instansie) > > t.append(instansie) > > > > In [83]: t > > t > > Out[83]: ['Mangosuthu Technikon'] > > In [84]: t = [x.alt_name for x in lys].append(instansie) > > t = [x.alt_name for x in lys].append(instansie) > > > > In [85]: t > > t > > > > In [86]: type t > > type t > > -------> type(t) > > Out[86]: NoneType > > > You should note that in [82], you're not doing: > > t = t.append(instansie) append() modifies the list in-place. It doesn't return anything. (and therefore its return value is None) >>> x = [1, 2, 3] >>> y = x.append(4) >>> print x [1, 2, 3, 4] >>> print y None -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From clp2 at rebertia.com Wed Feb 29 12:10:31 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 29 Feb 2012 09:10:31 -0800 Subject: list comprehension question In-Reply-To: References: Message-ID: On Wed, Feb 29, 2012 at 5:52 AM, Johann Spies wrote: > I understand the following: > > In [79]: instansie > instansie > Out[79]: 'Mangosuthu Technikon' > > In [80]: t = [x.alt_name for x in lys] > t = [x.alt_name for x in lys] > > In [81]: t > t > Out[81]: [] > > In [82]: t.append(instansie) > t.append(instansie) Note the lack of an accompanying "Out". This means that the expression, i.e. `t.append(instansie)`, had a result of None. The list.append() method does *not* return the now-appended-to list. It is a mutator method that modifies the list object in-place; per convention, it therefore returns None to reinforce its side-effecting nature to the user; analogous methods in other languages return void. > In [83]: t > t > Out[83]: ['Mangosuthu Technikon'] > > But then why does the following behave like this: > > In [84]: t = [x.alt_name for x in lys].append(instansie) > t = [x.alt_name for x in lys].append(instansie) You didn't do anything with .append()'s useless return value before; here, you do, by assigning it to t. > In [85]: t > t > > In [86]: type t > type t > -------> type(t) > Out[86]: NoneType Cheers, Chris From namekuseijin at gmail.com Wed Feb 29 12:45:29 2012 From: namekuseijin at gmail.com (namekuseijin) Date: Wed, 29 Feb 2012 09:45:29 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <68375f71-c728-42eb-a096-9a8be05a4ca1@p21g2000yqm.googlegroups.com> On Feb 29, 5:09?am, Xah Lee wrote: > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. > > Now, let me tell you what operator precedence is. First of all, let's > limit ourselfs to discuss operators that are so-called binary > operators, which, in our context, basically means single symbol > operator that takes it's left and right side as operands. Now, each > symbol have a ?precedence?, or in other words, the set of operators > has a order. (one easy way to think of this is that, suppose you have > n symbols, then you give each a number, from 1 to n, as their order) > So, when 2 symbols are placed side by side such as ?3 ? 6 ? 5?, the > symbol with higher precedence wins. Another easy way to think of this > is that each operator has a stickiness level. The higher its level, it > more sticky it is. > > the problem with the perl explanations is that it's one misleading > confusion ball. It isn't about ?left/right associativity?. It isn't > about ?evaluates from left to right or right to left?. Worse, the word > ?associativity? is a math term that describe a property of algebra > that has nothing to do with operator precedence, yet is easily > confused with because it is a property about order of evaluation. (for > example, the addition function is associative, meaning: ?(3+6)+5 = > 3+(6+5)?.) > > compare it with this: > > ?Perl ? Python: Complex Numbers?http://xahlee.org/perl-python/complex_numbers.html > > and for a good understanding of functions and operators, see: > > ?What's Function, What's Operator??http://xahlee.org/math/function_and_operators.html associativity of operators mean little in the Lisp world obviously, so why was this posted here? Sorry, perl, python and emacs folks... BTW, it's the same in javascript: it is so such that 2 + 3 + "4" is "54" and "2" + 3 + 4 is "234". Blame weak typing and + overloading, though it may be a blessing. From ramit.prasad at jpmorgan.com Wed Feb 29 13:03:06 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 18:03:06 +0000 Subject: Question about PyXML and python's stdlib xml In-Reply-To: <4F4E374E.10201@redhat.com> References: <4F4BA664.90707@redhat.com> <4F4E374E.10201@redhat.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474165A1B@SCACMX008.exchad.jpmchase.net> >>I'm forwarding this message to python-list, since I didn't get answer on xml-sig ML. >>Hopefully this is right list to question. >>Please keep me in CC. Original message is below. >>>I have concerns about PyXML and stdlib xml included directly in python. >>>Currently (in Fedora) python is trying to import PyXML, which means >>>other results when you have and haven't PyXML installed. >>>Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". >>>PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', >>>'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides >>>more functionality in those modules? Is python's xml better, same or >>>worse then PyXML? Anyway, python's xml is newer - is PyXML deprecated? >Yes. It's a dead project. >> Please keep me in CC, I'm not subscribed to the list. >That may be the problem in the xml-sig case also. I believe a current equivalent would be lxml. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Wed Feb 29 13:09:42 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 18:09:42 +0000 Subject: Listing children processes In-Reply-To: References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474165A36@SCACMX008.exchad.jpmchase.net> >>> I've been told of by the BDFL for stating that >>> people should not top post on any Python mailing list/news group. >> He's the BDFL of Python, not of mailing list etiquette. >Incorrect, I was told off for this >http://code.activestate.com/lists/python-ideas/14065/ Why the link? If that is supposed to show how you were told off, I do not see it. Even if it were, I still agree with Steven + Ben. Or maybe that's what I get for trying to RTFA. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- -----Original Message----- From: python-list-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of Mark Lawrence Sent: Tuesday, February 28, 2012 7:38 PM To: python-list at python.org Subject: Re: Listing children processes On 29/02/2012 00:16, Steven D'Aprano wrote: > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > > > Please don't bother apologising as I don't want to read another of your versions of War and Peace. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From tjreedy at udel.edu Wed Feb 29 16:01:25 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 16:01:25 -0500 Subject: list comprehension question In-Reply-To: References: Message-ID: On 2/29/2012 8:52 AM, Johann Spies wrote: Please post plain text, the standard for all python.org mailing lists and corresponding newsgroups, and not html. Some readers print the html as plain text, which is confusing and obnoxious. Other like mine, do skip the plain text version and print the rendered html, but in this case, the strong background colors make your post impossible for *me* to read. -- Terry Jan Reedy From greg at tinyco.com Wed Feb 29 18:08:34 2012 From: greg at tinyco.com (Greg Harezlak) Date: Wed, 29 Feb 2012 15:08:34 -0800 Subject: Any Advice Would Be Greatly Appreciated Message-ID: Hello Python Community, I work for a mobile gaming startup in San Francisco, and we're heavily staffing around skilled Python Developers. I've already submitted a job posting to the Python.org website, but I was curious if anyone else had some suggestions on where I could go to find some really awesome people. Thanks in advance for your help. -- *Greg Harezlak* 1 Bush Street, 7th Floor San Francisco, CA 94104 (T): 925.683.8578 (E): greg at tinyco.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From phihag at phihag.de Wed Feb 29 18:48:06 2012 From: phihag at phihag.de (Philipp Hagemeister) Date: Thu, 01 Mar 2012 00:48:06 +0100 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: References: Message-ID: <4F4EB936.1060900@phihag.de> If you're looking for skilled developers, the best way to find them is probably to search their current work. http://careers.stackoverflow.com/ and the more experimental http://githire.com/ are two excellent developer-friendly solutions for that. - Philipp On 03/01/2012 12:08 AM, Greg Harezlak wrote: > Hello Python Community, > > I work for a mobile gaming startup in San Francisco, and we're heavily > staffing around skilled Python Developers. I've already submitted a job > posting to the Python.org website, but I was curious if anyone else had > some suggestions on where I could go to find some really awesome people. > Thanks in advance for your help. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: From xahlee at gmail.com Wed Feb 29 19:02:39 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 16:02:39 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <4f4e1554$0$1385$4fafbaef@reader2.news.tin.it> Message-ID: <9dc55d52-3902-4449-87e7-745fb8b911b3@n12g2000yqb.googlegroups.com> i missed a point in my original post. That is, when the same operator are adjacent. e.g. ?3 ? 6 ? 5?. This is pointed out by Kiuhnm ?kiuhnm03.4t.yahoo.it? and Tim Bradshaw. Thanks. though, i disagree the way they expressed it, or any sense this is different from math. to clarify, amend my original post, here's what's needed for binary operator precedence: ? the symbols are ordered. (e.g. given a unique integer) ? each symbol is has either one of left-side stickness or right-side stickness spec. (needed when adjacent symbols are the same.) About the lisp case mentioned by Tim, e.g. in?(f a b c)?, whether it means ?(f (f a b) c)? or ?(f a (f b c))? . It is not directly relevant to the context of my original post, because it isn't about to operators. It's about function argument eval order. Good point, nevertheless. the perl doc, is still misleading, terribly bad written. Becha ass! Xah On Feb 29, 4:08?am, Kiuhnm wrote: > On 2/29/2012 9:09, Xah Lee wrote: > > > > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > > on ?Operators?. Quote: > > > ?The associativity of an operator governs whether it evaluates from > > left to right or right to left. Addition is left associative, such > > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > > ** 4 first, then raises 2 to the 81st power. ? > > > LOL. Looks like the perl folks haven't changed. Fundamentals of > > serious math got botched so badly. > > > Let me explain the idiocy. > > > It says ?The associativity of an operator governs whether it evaluates > > from left to right or right to left.?. Ok, so let's say we have 2 > > operators: a white triangle ? and a black triangle ?. Now, by the > > perl's teaching above, let's suppose the white triangle is ?right > > associative? and the black triangle is ?left associative?. Now, look > > at this: > > > 3 ? 6 ? 5 > > > seems like the white and black triangles are going to draw a pistol > > and fight for the chick 6 there. LOL. > > Sorry, but you're wrong and they're right. > Associativity governs the order of evaluation of a group of operators > *OF THE SAME PRECEDENCE*. > If you write > ? ?2**3**4 > only the fact the '**' is right associative will tell you that the order is > ? ?2**(3**4) > and not > ? ?(2**3)**4 > I remind you that 2^(3^4) != (2^3)^4. > > Kiuhnm From greg at tinyco.com Wed Feb 29 19:07:48 2012 From: greg at tinyco.com (Greg Harezlak) Date: Wed, 29 Feb 2012 16:07:48 -0800 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: <4F4EB936.1060900@phihag.de> References: <4F4EB936.1060900@phihag.de> Message-ID: Thank you so much for the help, Philipp! On Wed, Feb 29, 2012 at 3:48 PM, Philipp Hagemeister wrote: > If you're looking for skilled developers, the best way to find them is > probably to search their current work. > > http://careers.stackoverflow.com/ and the more experimental > http://githire.com/ are two excellent developer-friendly solutions for > that. > > - Philipp > > On 03/01/2012 12:08 AM, Greg Harezlak wrote: > > Hello Python Community, > > > > I work for a mobile gaming startup in San Francisco, and we're heavily > > staffing around skilled Python Developers. I've already submitted a job > > posting to the Python.org website, but I was curious if anyone else had > > some suggestions on where I could go to find some really awesome people. > > Thanks in advance for your help. > > -- *Greg Harezlak* 1 Bush Street, 7th Floor San Francisco, CA 94104 (T): 925.683.8578 (E): greg at tinyco.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Feb 29 19:17:09 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 19:17:09 -0500 Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <4F4EC005.8010307@udel.edu> On 2/29/2012 9:24 AM, Rick Johnson wrote: > On Feb 28, 11:06 pm, John Salerno wrote: >> However, in the Python documentation, I see this: >> >> root = Tk() >> app = Application(master=root) >> app.mainloop() >> root.destroy() >> I tried the above and I got the following error: >> >> Traceback (most recent call last): >> File "C:\Users\John\Desktop\gui.py", line 12, in >> root.destroy() >> File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy >> self.tk.call('destroy', self._w) >> _tkinter.TclError: can't invoke "destroy" command: application has been destroyed >> >> So apparently closing the window with the X button (on Windows) >> implicitly calls the destroy() method of the root frame. >> If that's the case, why does the documentation explicitly call it? I do not know if tk has changed since the example was written or if it was buggy from the beginning. I opened an issue to fix it. http://bugs.python.org/issue14163 > Most applications will have both: user destroying, and program > destroying. > from tkMessageBox import askyesnocancel from tkinter.messagebox in 3.x > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self.title('Close Me -->') > self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) > > def onDestroyWindow(self): > title = 'Confirm App Exit' > msg = 'Save changes before exiting?' > result = askyesnocancel(title, msg, default='cancel') > if result is None: > return > elif result is True: > print 'saving changes' > elif result is False: > print 'dont save changes' > self.destroy() > > if __name__ == '__main__': > app = App() > app.mainloop() This works as adjusted for 3.x. I presume that a quit button or menu entry should also call onDestroyWindow so the effect is the same as clicking the outer [X] button. I tried the same approach to fix the doc example, but unlike your class App(Tk), class App(Frame) does not a .protocol attribute. See the tracker issue for all my comments on the example. I considered removing both the quit button and 'root.destroy' to get a beginning example that works properly, but as you said, having both is common so I would like both if the solution is not too esoteric. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 29 19:17:09 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 19:17:09 -0500 Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <4F4EC005.8010307@udel.edu> On 2/29/2012 9:24 AM, Rick Johnson wrote: > On Feb 28, 11:06 pm, John Salerno wrote: >> However, in the Python documentation, I see this: >> >> root = Tk() >> app = Application(master=root) >> app.mainloop() >> root.destroy() >> I tried the above and I got the following error: >> >> Traceback (most recent call last): >> File "C:\Users\John\Desktop\gui.py", line 12, in >> root.destroy() >> File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy >> self.tk.call('destroy', self._w) >> _tkinter.TclError: can't invoke "destroy" command: application has been destroyed >> >> So apparently closing the window with the X button (on Windows) >> implicitly calls the destroy() method of the root frame. >> If that's the case, why does the documentation explicitly call it? I do not know if tk has changed since the example was written or if it was buggy from the beginning. I opened an issue to fix it. http://bugs.python.org/issue14163 > Most applications will have both: user destroying, and program > destroying. > from tkMessageBox import askyesnocancel from tkinter.messagebox in 3.x > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self.title('Close Me -->') > self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) > > def onDestroyWindow(self): > title = 'Confirm App Exit' > msg = 'Save changes before exiting?' > result = askyesnocancel(title, msg, default='cancel') > if result is None: > return > elif result is True: > print 'saving changes' > elif result is False: > print 'dont save changes' > self.destroy() > > if __name__ == '__main__': > app = App() > app.mainloop() This works as adjusted for 3.x. I presume that a quit button or menu entry should also call onDestroyWindow so the effect is the same as clicking the outer [X] button. I tried the same approach to fix the doc example, but unlike your class App(Tk), class App(Frame) does not a .protocol attribute. See the tracker issue for all my comments on the example. I considered removing both the quit button and 'root.destroy' to get a beginning example that works properly, but as you said, having both is common so I would like both if the solution is not too esoteric. -- Terry Jan Reedy From rodrick.brown at gmail.com Wed Feb 29 19:54:57 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Wed, 29 Feb 2012 19:54:57 -0500 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: References: Message-ID: <7551F03F-98C3-45C1-971D-75CC6B0960C7@gmail.com> LinkedIn is an excellent resource for finding great candidates, However your problem might be because your searching for Python Developers why not hire great programmers and have them learn Python? Sent from my iPhone On Feb 29, 2012, at 6:08 PM, Greg Harezlak wrote: > Hello Python Community, > > I work for a mobile gaming startup in San Francisco, and we're heavily staffing around skilled Python Developers. I've already submitted a job posting to the Python.org website, but I was curious if anyone else had some suggestions on where I could go to find some really awesome people. Thanks in advance for your help. > > -- > Greg Harezlak > > > > 1 Bush Street, 7th Floor > San Francisco, CA 94104 > > (T): 925.683.8578 > (E): greg at tinyco.com > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From example.scripts at gmail.com Wed Feb 29 21:19:39 2012 From: example.scripts at gmail.com (scripts examples) Date: Wed, 29 Feb 2012 18:19:39 -0800 (PST) Subject: python scripts solution for euler projects References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: <828760b3-2d70-4ba4-9830-e173d2eaf058@f14g2000yqe.googlegroups.com> On Feb 29, 4:21?am, alister wrote: > On Tue, 28 Feb 2012 19:59:40 -0800, scripts examples wrote: > > Got a web site setup for solving euler problems in python, perl, > > ruby and javascript. > > > ? ?Feel free to give me any feedback, thanks. > > Failing to give a link to the site is a pretty fundamental failure > > -- > Please take note: Sorry, forgot the link. Here it is: examplescripts.weebly.com From rantingrickjohnson at gmail.com Wed Feb 29 22:22:16 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 19:22:16 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: On Feb 29, 6:17?pm, Terry Reedy wrote: > On 2/29/2012 9:24 AM, Rick Johnson wrote: > > On Feb 28, 11:06 pm, John Salerno ?wrote: > >> However, in the Python documentation, I see this: > > >> root = Tk() > >> app = Application(master=root) > >> app.mainloop() > >> root.destroy() > >> I tried the above and I got the following error: > > >> Traceback (most recent call last): > >> ? ?File "C:\Users\John\Desktop\gui.py", line 12, in > >> ? ? ?root.destroy() > >> ? ?File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy > >> ? ? ?self.tk.call('destroy', self._w) > >> _tkinter.TclError: can't invoke "destroy" command: ?application has been destroyed > > >> So apparently closing the window with the X button (on Windows) > > ?>> implicitly calls the destroy() method of the root frame. > ?>> If that's the case, why does the documentation explicitly call it? > > I do not know if tk has changed since the example was written or if it > was buggy from the beginning. I opened an issue to fix it. > > http://bugs.python.org/issue14163 "protocol" is ONLY a method of Tkinter.Tk and Tkinter.Toplevel. Actually Toplevel and Tk are exactly the same object but Tk has an TCL interpretor attached. Tkinter.Tk is meant to be the parent of ALL widgets within your Tkinter GUI. Tkinter.Frame is nothing more than a box to stuff widgets into. Tkinter.Frame IS NOT a window and therefor it DOES NOT have window methods. HOWEVER! Most people start falsely believing that a Tkinter.Frame AND Tkinter.Toplevel are the same thing; since Tkinter will "auto- magically" pack your frame into a default Tkinter.Tk window (psst: that's just a fancy Toplevel widget!) if you don't explicitly create the Tk instance yourself. >>>Slightly tangential meanderings This inconsistency also rears it's ugly head in the dialog modules: tkFileDialog and tkMessageBox. Both of which do not require a parent argument to their convenience functions. Instead they allow the parent to be OPTIONALLY passed. Inquisitive Ivan mused: """ What's wrong with that Rick, the dialog will still display whether a parent argument is passed or not. Heck, even if no viable parent exists, Tkinter will create one! Tkinter is a smart module!""" True Ivan. However, if you dig a little deeper you will see that the dialog created WITHOUT a parent does not function in a manner consistent to modal dialogs; that is, owning the focus and becoming a transient of another Toplevel window. Also, about your second point, noobs get confused when that default root window pops up. Then they come here and ask the same question over and over. Can't you see the design flaw that is directly in front of your face NOR smell the pungent odors that reeking from this module! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Some might argue that this implicit root window creation is beneficial for toy GUIs -- and i agree! HOWEVER, you will due enormous damage to a neophyte's learning process. I say just force the extra line of code and be consistent. Actually i believe SO strongly in "explicit root window creation" that i edited the source code of my Tkinter version to NOT allow ANY widget's master to be None. I had written a more exhaustive "expo-say" some time back but i cannot remember the title. > > Most applications will have both: user destroying, and program > > destroying. > > from tkMessageBox import askyesnocancel > > from tkinter.messagebox in 3.x Yes, Tkinter has changed a bit in Python>=3.0, thanks for pointing this out. > [...snip code...] > This works as adjusted for 3.x. I presume that a quit button or menu > entry should also call onDestroyWindow so the effect is the same as > clicking the outer [X] button. Yes, but i think the REAL problem is faulty code logic. Remove the last line "root.destroy()" and the problem is solved. Obviously the author does not have an in-depth knowledge of Tkinter. > I tried the same approach to fix the doc example, but unlike your class > App(Tk), class App(Frame) does not a .protocol attribute. See the > tracker issue for all my comments on the example. see above comments about Tkinter.Frame, Tkinter.Toplevel, and Tkinter.Tk ^^^ > I considered removing both the quit button and 'root.destroy' to get a > beginning example that works properly, but as you said, having both is > common so I would like both if the solution is not too esoteric. If you want to keep things simple, i would: 1. Create the root window explicitly! 2. Bind the command of the button to root.destroy (command=root.destroy) I would offer better advice if i could but i have no idea where this "book the OP is learning" is located? No one ever provided a link to the code in question? PS: I would highly suggest against using the "from Tkinter import *". Instead, use "import Tkinter as tk" and prefix all module contents with "tk.". Also, use "from Tkconstants import X, Y, X" From rantingrickjohnson at gmail.com Wed Feb 29 22:45:38 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 19:45:38 -0800 (PST) Subject: PyTut: Tkinter #1 Message-ID: <55a4abd7-f5dd-4de6-85e9-b00ee7a62603@w27g2000yqm.googlegroups.com> PyTut: Tkinter #1 Graciously donated by the benevolent professor Richard Johnson The first step to creating a Tkinter GUI is to create a blank window. Tkinter has two classes that represent a GUI window: Toplevel and Tk. Both the classes are basically the same, but since a GUI can have an unlimited number of Toplevel windows, the very first window should ALWAYS be an instance of Tk! Let's write some code. ## START CODE ## import Tkinter as tk root = tk.Tk() root.mainloop() ## END CODE ## You can probably guess what the first line does; it creates your parent Toplevel window as an instance of Tk! The second line "root.mainloop()" enters the event loop. Don't worry about the details of "mainloop" at this time, just remeber that all Tkinter GUIs start with an instance of Tk and end with a call to mainloop. Here is the same code in a strict OOP form (For something this simple you need not use strict OOP but eventually you will need to harness the power of OOP!) ## START CODE ## class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) app = App() app.mainloop() ## END CODE ## That's all folks! Keep your eyes peeled for the next glorious installment of "PyTut: Tkinter"! From peter.rubenstein at hotmail.com Wed Feb 29 22:56:22 2012 From: peter.rubenstein at hotmail.com (Peter Rubenstein) Date: Thu, 1 Mar 2012 03:56:22 +0000 Subject: Help needed: dynamically pull data from different levels of a dict Message-ID: Hi, I'd appreciate a bit of help on this problem. I have some data that I've converted to a dict and I want to pull out individual pieces of it. Simplified version-- a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } } } I'd like to be able to code something like: data_needed = ['1', '2', '3:4', '5:6:7-8']for val in data_needed: answer=extract_from(a,val) print answer And get:abcde Problem is I can't figure out what extract_from would look like, such that it would proceed dynamically down to the right level. I'm open to the possibility that I'm not approaching this the right way. If it helps, one member of my actual dict quoted below. So in real life, something likedata_needed=['name','active-defects', 'admin-status:format', 'description', 'traffic-statistics:input-bps']etc. Thanks in advance,Peter { 'ge-0/0/0': {'active-alarms': {'interface-alarms': {'alarm-not-present': ''}}, 'active-defects': {'interface-alarms': {'alarm-not-present': ''}}, 'admin-status': {'_text': 'up', 'format': 'Enabled'}, 'current-physical-address': 'ff:ff:ff:c0:e8:00', 'description': 'XXX', 'hardware-physical-address': 'ff:ff:ff:c0:e8:00', 'if-config-flags': {'iff-snmp-traps': '', 'internal-flags': '0x4000'}, 'if-device-flags': {'ifdf-present': '', 'ifdf-running': ''}, 'if-flow-control': 'enabled', 'if-media-flags': {'ifmf-none': ''}, 'interface-flapped': {'_text': '2010-05-23 18:20:36 UTC (92w3d 02:27 ago)', 'seconds': '55909644'}, 'l2pt-error': 'none', 'link-level-type': 'Ethernet', 'local-index': '171', 'logical-interface': {'address-family': [{'address-family-flags': {'ifff-no-redirects': '', 'internal-flags': '0x0'}, 'address-family-name': 'inet', 'interface-address': {'ifa-destination': '10.46.43.2/31', 'ifa-flags': {'ifaf-current-preferred': '', 'ifaf-current-primary': ''}, 'ifa-local': '10.46.43.2'}, 'mtu': '9178'}, {'address-family-flags': {'ifff-mtu-user-conf': '', 'internal-flags': '0x10000000'}, 'address-family-name': 'mpls', 'mtu': '9174'}, {'address-family-flags': {'ifff-none': ''}, 'address-family-name': 'multiservice', 'mtu': 'Unlimited'}], 'description': 'YYY', 'encapsulation': 'ENET2', 'if-config-flags': {'iff-snmp-traps': ''}, 'local-index': '67', 'name': 'ge-0/0/0.0', 'snmp-index': '117', 'traffic-statistics': {'input-packets': '46367422526659', 'output-packets': '35670513402384', 'style': 'brief'}}, 'loopback': 'disabled', 'mtu': '9192', 'name': 'ge-0/0/0', 'oper-status': 'up', 'physical-interface-cos-information': {'physical-interface-cos-hw-max-queues': '8', 'physical-interface-cos-use-max-queues': '8'}, 'snmp-index': '116', 'source-filtering': 'disabled', 'speed': '10Gbps', 'traffic-statistics': {'input-bps': '4104358720', 'input-pps': '1059450', 'output-bps': '2323588888', 'output-pps': '537816', 'style': 'brief'}},} -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter216 at gmail.com Wed Feb 29 23:04:46 2012 From: peter216 at gmail.com (Peter Rubenstein) Date: Thu, 1 Mar 2012 04:04:46 +0000 Subject: Help needed: dynamically pull data from different levels of a dict Message-ID: --Reposting in plan text, apologies-- Hi, I'd appreciate a bit of help on this problem. ?I have some data that I've converted to a dict and I want to pull out individual pieces of it. Simplified version-- a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } } } I'd like to be able to code something like: data_needed = ['1', '2', '3:4', '5:6:7-8']for val in data_needed:? ??? ? answer=extract_from(a,val)? ??? ? print answer And get:abcde Problem is I can't figure out what extract_from would look like, such that it would proceed dynamically down to the right level. ?I'm open to the possibility that I'm not approaching this the right way. If it helps, one member of my actual dict quoted below. ?So in real life, something likedata_needed=['name','active-defects', 'admin-status:format', 'description', 'traffic-statistics:input-bps']etc. Thanks in advance,Peter {?'ge-0/0/0': {'active-alarms': {'interface-alarms': {'alarm-not-present': ''}},? 'active-defects': {'interface-alarms': {'alarm-not-present': ''}},? 'admin-status': {'_text': 'up', 'format': 'Enabled'},? 'current-physical-address': '00:1f:12:c0:e8:00',? 'description': 'INFRA:CROSS:ASH-64CB-1B:GE-0/0/0:',? 'hardware-physical-address': '00:1f:12:c0:e8:00',? 'if-config-flags': {'iff-snmp-traps': '', 'internal-flags': '0x4000'},? 'if-device-flags': {'ifdf-present': '', 'ifdf-running': ''},? 'if-flow-control': 'enabled',? 'if-media-flags': {'ifmf-none': ''},? 'interface-flapped': {'_text': '2010-05-23 18:20:36 UTC (92w3d 02:27 ago)',? ?'seconds': '55909644'},? 'l2pt-error': 'none',? 'link-level-type': 'Ethernet',? 'local-index': '171',? 'logical-interface': {'address-family': [{'address-family-flags': {'ifff-no-redirects': '',? ? ? 'internal-flags': '0x0'},? ? ?'address-family-name': 'inet',? ? ?'interface-address': {'ifa-destination': '207.46.43.2/31',? ? ? 'ifa-flags': {'ifaf-current-preferred': '', 'ifaf-current-primary': ''},? ? ? 'ifa-local': '207.46.43.2'},? ? ?'mtu': '9178'},? ? {'address-family-flags': {'ifff-mtu-user-conf': '',? ? ? 'internal-flags': '0x10000000'},? ? ?'address-family-name': 'mpls',? ? ?'mtu': '9174'},? ? {'address-family-flags': {'ifff-none': ''},? ? ?'address-family-name': 'multiservice',? ? ?'mtu': 'Unlimited'}],? ?'description': 'INFRA:CROSS:ASH-64CB-1B:GE-0/0/0.0:',? ?'encapsulation': 'ENET2',? ?'if-config-flags': {'iff-snmp-traps': ''},? ?'local-index': '67',? ?'name': 'ge-0/0/0.0',? ?'snmp-index': '117',? ?'traffic-statistics': {'input-packets': '46367422526659',? ? 'output-packets': '35670513402384',? ? 'style': 'brief'}},? 'loopback': 'disabled',? 'mtu': '9192',? 'name': 'ge-0/0/0',? 'oper-status': 'up',? 'physical-interface-cos-information': {'physical-interface-cos-hw-max-queues': '8',? ?'physical-interface-cos-use-max-queues': '8'},? 'snmp-index': '116',? 'source-filtering': 'disabled',? 'speed': '10Gbps',? 'traffic-statistics': {'input-bps': '4104358720',? ?'input-pps': '1059450',? ?'output-bps': '2323588888',? ?'output-pps': '537816',? ?'style': 'brief'}},} From spamtrap at library.lspace.org.invalid Wed Feb 29 23:06:42 2012 From: spamtrap at library.lspace.org.invalid (Shmuel Metz (Seymour J.)) Date: Wed, 29 Feb 2012 23:06:42 -0500 Subject: New Science Discovery: Perl Detracters Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <4f4ef5d2$26$fuzhry+tra$mr2ice@news.patriot.net> In , on 02/29/2012 at 11:43 AM, Chiron said: >Sure, mathematically it *should* go a particular way, No. Mathematically it should go the way that it is defined to go. There is nothing in Mathematics that either requires or prohibits infix notation in programming languages, or even in Mathematical notation. >it makes sense to keep things as clear as possible. Often infix notation with well thought out precedence is the clearest way to go. RPN and the like have their place, but often are difficult for real people to read. -- Shmuel (Seymour J.) Metz, SysProg and JOAT Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap at library.lspace.org From xahlee at gmail.com Wed Feb 29 23:07:49 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 20:07:49 -0800 (PST) Subject: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp Message-ID: <85fa5760-68c8-41a2-9116-2489165f7ca1@j5g2000yqm.googlegroups.com> fun example. in-place algorithm for reversing a list in Perl, Python, Lisp http://xahlee.org/comp/in-place_algorithm.html plain text follows ---------------------------------------- What's ?In-place Algorithm?? Xah Lee, 2012-02-29 This page tells you what's ?In-place algorithm?, using {python, perl, emacs lisp} code to illustrate. Here's Wikipedia In-place algorithm excerpt: In computer science, an in-place algorithm (or in Latin in situ) is an algorithm which transforms input using a data structure with a small, constant amount of extra storage space. The input is usually overwritten by the output as the algorithm executes. An algorithm which is not in-place is sometimes called not-in-place or out-of- place. Python Here's a python code for reversing a list. Done by creating a new list, NOT using in-place: # python # reverse a list list_a = ["a", "b", "c", "d", "e", "f", "g"] list_length = len(list_a) list_b = [0] * list_length for i in range(list_length): list_b[i] = list_a[list_length -1 - i] print list_b Here's in-place algorithm for reversing a list: # python # in-place algorithm for reversing a list list_a = ["a", "b", "c", "d", "e", "f", "g"] list_length = len(list_a) for i in range(list_length/2): x = list_a[i] list_a[i] = list_a[ list_length -1 - i] list_a[ list_length -1 - i] = x print list_a Perl Here's a perl code for reversing a list. Done by creating a new list, NOT using in-place: # perl use strict; use Data::Dumper; my @listA = qw(a b c d e f g); my $listLength = scalar @listA; my @listB = (); for ( my $i = 0; $i < $listLength; $i++ ) { $listB[$i] = $listA[ $listLength - 1 - $i]; } print Dumper(\@listB); # perl # in-place algorithm for reversing a list. use strict; use Data::Dumper; use POSIX; # for ?floor? my @listA = qw(a b c d e f g); my $listLength = scalar @listA; for ( my $i = 0; $i < floor($listLength/2); $i++ ) { my $x = $listA[$i]; $listA[$i] = $listA[ $listLength - 1 - $i]; $listA[ $listLength - 1 - $i] = $x; } print Dumper(\@listA); __END__ emacs lisp ;; emacs lisp ;; reverse a array (setq arrayA ["a" "b" "c" "d" "e" "f" "g"]) (setq arrayLength (length arrayA)) (setq arrayB (make-vector arrayLength 0)) (dotimes (i arrayLength ) (aset arrayB i (aref arrayA (- (1- arrayLength) i)) ) ) (print (format "%S" arrayB)) ;; emacs lisp ;; in-place algorithm for reversing a array (setq arrayA ["a" "b" "c" "d" "e" "f" "g"]) (setq arrayLength (length arrayA)) (dotimes (i (floor (/ arrayLength 2))) (let (x) (setq x (aref arrayA i)) (aset arrayA i (aref arrayA (- (1- arrayLength) i))) (aset arrayA (- (1- arrayLength) i) x) ) ) (print (format "%S" arrayA)) Xah From spamtrap at library.lspace.org.invalid Wed Feb 29 23:10:48 2012 From: spamtrap at library.lspace.org.invalid (Shmuel Metz (Seymour J.)) Date: Wed, 29 Feb 2012 23:10:48 -0500 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots Af References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Message-ID: <4f4ef6c8$27$fuzhry+tra$mr2ice@news.patriot.net> In <87aa41k6x5.fsf at sapphire.mobileactivedefense.com>, on 02/29/2012 at 03:15 PM, Rainer Weikusat said: >'mathematics' (an essentially outdated write-only programming >language dating back to the times when humans had to perform >computations themselves) ROTF,LMAO! You obviously don't have a clue as to what Mathematics means. Free hint: it doesn't mean Arithmetic. You're as bigoted as Xah Lee, -- Shmuel (Seymour J.) Metz, SysProg and JOAT Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap at library.lspace.org From johnjsal at gmail.com Wed Feb 29 23:41:45 2012 From: johnjsal at gmail.com (John Salerno) Date: Wed, 29 Feb 2012 20:41:45 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <17153317.324.1330576905540.JavaMail.geo-discussion-forums@yncd8> > It is not necessarily to call Tk explicitly, which i think is a bug > BTW. Sure, for simple scripts you can save one line of code but only > at the expense of explicitness and intuitiveness. Observe > > ## START CODE ## > import Tkinter as tk > > root = tk.Tk() > root.title('Explicit Root') > root.mainloop() > > f = tk.Frame(master=None, width=100, height=100, bg='red') > f.pack() > f.mainloop() > > b = tk.Button(master=None, text='Sloppy Coder') > b.pack() > b.mainloop() > ## END CODE ## > > as you can see all three examples work even though the last two don't > explicitly create a master. The master is still there however Tkinter > just created "magically" for you. Talk about laziness! I'm not sure I understand which method you are advocating. It sounded like you said calling Tk() explicitly is a bug. I certainly would never create widgets without first creating a master frame, but is creating a Frame object enough, or should I create a Tk object and *then* a Frame object? Also, at what point do you include the destroy method in your program, assuming you do not have a widget that will close the window? If you only want the Windows "X" button to close the window, then is it okay to leave out any call to destroy()? Or should always explicitly destroy it just as I explicitly created a Tk instance? If the latter, then where in the code do you put the call to destroy so it won't conflict with the user closing the window with the X button? From clp2 at rebertia.com Wed Feb 29 23:43:44 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 29 Feb 2012 20:43:44 -0800 Subject: Help needed: dynamically pull data from different levels of a dict In-Reply-To: References: Message-ID: On Wed, Feb 29, 2012 at 7:56 PM, Peter Rubenstein wrote: > Hi, > > I'd appreciate a bit of help on this problem. ?I have some data that I've > converted to a dict and I want to pull out individual pieces of it. > > Simplified version-- > > a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } > } } > > I'd like to be able to code something like: > > data_needed = ['1', '2', '3:4', '5:6:7-8'] > for val in data_needed: > ? ? answer=extract_from(a,val) > ? ? print answer > > And get: > a > b > c "c" apparently sprung completely out of thin air... > d > e > > Problem is I can't figure out what extract_from would look like, such that > it would proceed dynamically down to the right level. ?I'm open to the > possibility that I'm not approaching this the right way. data_needed = ['1', '2', ('3', '4'), ('5', '6', '7', 0, '8')] def extract_from(mapping, key_path): current = mapping for key in key_path: current = current[key] return current I would perhaps try and restructure the data into something less generic than nested dicts & lists, e.g. objects. You then might be able to introduce helper querying methods. I would also be worried about Law of Demeter violations, but fortunately your concrete example doesn't reach any deeper than 2 levels. Cheers, Chris -- http://chrisrebert.com From chiron613 at gmail.com Wed Feb 29 23:52:27 2012 From: chiron613 at gmail.com (Chiron) Date: Thu, 01 Mar 2012 04:52:27 GMT Subject: New Science Discovery: Perl Detracters Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <4f4ef5d2$26$fuzhry+tra$mr2ice@news.patriot.net> Message-ID: On Wed, 29 Feb 2012 23:06:42 -0500, Shmuel (Seymour J.) Metz wrote: > In , on 02/29/2012 > at 11:43 AM, Chiron said: > >>Sure, mathematically it *should* go a particular way, > > No. Mathematically it should go the way that it is defined to go. There > is nothing in Mathematics that either requires or prohibits infix > notation in programming languages, or even in Mathematical notation. > Yes. That (the mathematically defined way) is a particular way, is it not? >>it makes sense to keep things as clear as possible. > > Often infix notation with well thought out precedence is the clearest > way to go. RPN and the like have their place, but often are difficult > for real people to read. However, I wasn't specifically referring to infix/postfix/prefix or anything of that nature. I wasn't limiting my comment to lisp notation in particular, since what I said applies to any language. I was referring to the placement of parentheses (or other groupings) to indicate to *humans* what the intended sequence of events was. The problem with precedence is that it is not always clear how it will go. Different languages have different rules, some of which depart from the rules in mathematics. Some implementations of languages are buggy in this regard. Mathematically, and in any language with which I am familiar, the sequence: 2 + 6 / 3 will yield 4. It is unnecessary, but harmless, to write this as 2 + (6 / 3). A naive reader (or just a tired or hurried one) might come up with 8 / 3 if there aren't any parentheses. Whenever there is *any* possibility of ambiguity, I see no reason not to clarify. Back in the days when the way you wrote your code affected how it was compiled, it made sense to rely heavily on language-specific features, thus saving a few bytes. With gigabyte memories, gigahertz clock speeds, and optimizing compilers, the pressure to try to optimize by hand is gone. A few extra parentheses, or even breaking down a complex sequence of events into discrete, simpler ones, is no longer a costly luxury. A few extra variables, if they help clarity, aren't going to hurt anything. Let the machine do the grunt work. Pamper your readers (which in a few weeks or months might be you) and show exactly what you had in mind. That's all I'm saying. -- I'd just as soon kiss a Wookie. -- Princess Leia Organa From jason at powerpull.net Wed Feb 1 00:53:28 2012 From: jason at powerpull.net (Jason Friedman) Date: Wed, 1 Feb 2012 05:53:28 +0000 Subject: Installing pypi package twice Message-ID: My system's default python is 2.6.5. I have separately installed 3.2.2 at /opt/python. I downloaded python-daemon-1.5.5 and installed with: $ tar xzf python-daemon-1.5.5 $ cd python-daemon-1.5.5 $ python setup.py build $ sudo python setup.py install How would I also install this package for 3.2.2? (I am assuming that python-daemon-1.5.5 is either version3-compatible or I can make it so). From jason at powerpull.net Wed Feb 1 01:04:31 2012 From: jason at powerpull.net (Jason Friedman) Date: Wed, 1 Feb 2012 06:04:31 +0000 Subject: Installing pypi package twice Message-ID: My system's default python is 2.6.5. I have also installed python3.2 at /opt/python. I installed a pypi package for 2.6.5 with: $ tar xzf package.tar.gz $ cd package $ python setup.py build $ sudo python setup.py install How can I also install this same package for 3.2? (I am assuming this package works with 3.2 or that I can make it work.) From huayanghao at gmail.com Wed Feb 1 01:41:27 2012 From: huayanghao at gmail.com (Hua Yanghao) Date: Wed, 1 Feb 2012 14:41:27 +0800 Subject: Python Descriptor as Instance Attribute In-Reply-To: References: Message-ID: Thanks Ian for the explanation. Please see my comments below: > The behavior is by design. ?First, keeping object behavior in the > class definition simplifies the implementation and also makes instance > checks more meaningful. ?To borrow your Register example, if the "M" > descriptor is defined by some instances rather than by the class, then > knowing that the object "reg" is an instance of Register does not tell > me anything about whether "reg.M" is a valid attribute or an error. > As a result, I'll need to guard virtually every access of "reg.M" with > a try-except construct just in case "reg" is the wrong kind of > register. I don't quite understand the above explanation. Sorry I'm not very familiar with the low level details, but from a user's point of view, if I defined reg.M, then it should be a valid access later on.... somehow. :-) > Second, the separation of class from instance also helps you keep > object behavior separate from object data. ?Consider the following > class: > > class ObjectHolder(object): > ? ?def __init__(self, obj): > ? ? ? ?self.obj = obj > > Don't worry about what this class might be useful for. ?Just know that > it's meant to hold and provide unrestricted access to arbitrary Python > objects: > >>>> holder = ObjectHolder(42) >>>> print(holder.obj) > 42 >>>> holder.obj = range(5) >>>> print(holder.obj) > [0, 1, 2, 3, 4] > > Since the class is meant to hold arbitrary objects, it's even valid > that somebody might want to store a descriptor object there: > >>>> holder.obj = property(lambda x: x.foo) >>>> print(holder.obj) > > > Now suppose that Python invoked the descriptor protocol for > descriptors stored in instance attributes: > >>>> holder = ObjectHolder(None) >>>> holder.obj = property(lambda x: x.foo) >>>> print(holder.obj) > Traceback (most recent call last): > ?File "", line 1, in > AttributeError: 'ObjectHolder' object has no attribute 'foo' > > In this case, the ObjectHolder would fail to simply hold the property > object as data. ?The mere act of assigning the property object, a > descriptor, to an instance attribute would *change the behavior* of > the ObjectHolder. ?Instead of treating "holder.obj" as a simple data > attribute, it would start invoking the descriptor protocol on accesses > to "holder.obj" and ultimately redirect them to the non-existent and > meaningless "holder.foo" attribute, which is certainly not what the > author of the class intended. OK I see some fundamental problems here now. And I think that's actually one of the limitations of descriptor: A descriptor only works when it is defined as class attribute and accessed from the instance. It really can be much more powerful if there can be a general way to define an attribute on either a class or an instance, but the access to it (either directly from class or from its instance) actually calls a function. It will make some kind of abstraction much more clean and simple in concept, like my example above, I have one class called register, and all of its instance represent different registers with different field, and assignment to its field automatically checks for validations, and read automatically fetches the value from the hardware. > For the above reasons, I would probably implement your Register class > as a set of related class sharing a common metaclass. ?The solution > you came up with is probably fine to solve your specific problem, > though. this like I said before is not conceptually simple enough, and it can confuses end user if they're not python expert. For years I loved python is because I can always figure out a best way to abstract a problem, and make end-user interface as simple as possible, I never failed before with python, but this time it seems python indeed have limitations here, or does there exist a better solution? To make you understand the problem I'm facing, I'd like to elaborate a bit more here. Registers in SoC peripherals have different field, and each field have different number of bits, different access capabilities (read only, write only, read write, ...), but all registers share some common attribute, like they're all 32 bits long. Also some common operations is shared, like distribute a value to each bit field, meaning that set the value of a register as a whole will automatically update each field. The definition of each register is in an XML file with all attribute for each field. And the preferred way to generate an "representation" of a register is to instantiate the Register class with its definition read from the xml file. This is the natural design, all register representation is an instance of Register class. So now the problem is, how can I have such a simple class with all its instance have different fields, which can be written and read directly (like reg.M = '101', or x = reg.M) with automated validation check and value fetch? Define a separate class for each register doesn't sounds feasible because there's hundreds of registers. Using metaclass to generate a class for each register also doesn't feel good, because you still need to instantiate them *once again* to get the instance that actually invokes the descriptor protocols ... Your input is highly appreciated. Best Regards, Yanghao From arnodel at gmail.com Wed Feb 1 02:09:35 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 07:09:35 +0000 Subject: Iterate from 2nd element of a huge list In-Reply-To: References: Message-ID: On 1 February 2012 03:16, Paulo da Silva wrote: > Em 01-02-2012 01:39, Paulo da Silva escreveu: >> Hi! >> >> What is the best way to iterate thru a huge list having the 1st element >> a different process? I.e.: >> >> process1(mylist[0]) >> for el in mylist[1:]: >> ? ? ? process2(el) >> >> This way mylist is almost duplicated, isn't it? >> >> Thanks. > > > I think iter is nice for what I need. > Thank you very much to all who responded. Nobody mentioned itertools.islice, which can be handy, especially if you weren't interested in the first element of the list: from itertools import islice: for el in islice(mylist, 1): process2(el) -- Arnaud From arnodel at gmail.com Wed Feb 1 02:17:10 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 07:17:10 +0000 Subject: 'class' named tuple In-Reply-To: References: Message-ID: On 1 February 2012 00:54, Emmanuel Mayssat wrote: > I have the following program. > I am trying to have index the attributes of an object using __getitem__. > Reading them this way works great, but assigning them a value doesn't > Is there a way to do such a thing? > (Almost like a named tuple, but with custom methods) > > class LIter(object): > ? ?def __init__(self,parent=None): > ? ? ? ?super(LIter, self).__init__() > ? ? ? ?self.toto = 3 > ? ? ? ?self.tata = 'terto' > Add _attrs = 'toto', 'tata' def __getitem__(self, index): return getattr(self, _attrs[index]) def __setitem__(self, index, value) setattr(self, _attrs[index], value) -- Arnaud From __peter__ at web.de Wed Feb 1 03:11:44 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Feb 2012 09:11:44 +0100 Subject: Iterate from 2nd element of a huge list References: Message-ID: Arnaud Delobelle wrote: >> Em 01-02-2012 01:39, Paulo da Silva escreveu: >>> What is the best way to iterate thru a huge list having the 1st element >>> a different process? I.e.: > Nobody mentioned itertools.islice, which can be handy, especially if > you weren't interested in the first element of the list: Also, skipping two or seven or ... items is just as easy. The example should be > from itertools import islice: for el in islice(mylist, 1, None): > process2(el) From ben+python at benfinney.id.au Wed Feb 1 03:18:20 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 01 Feb 2012 19:18:20 +1100 Subject: Installing pypi package twice References: Message-ID: <87sjivvuer.fsf@benfinney.id.au> Jason Friedman writes: > How would I also install this package for 3.2.2? (I am assuming that > python-daemon-1.5.5 is either version3-compatible or I can make it > so). I am the primary developer of ?python-daemon?. It is an explicit goal of this library to target Python 3, but that has not been achieved yet. I welcome discussion on the new forum for development discussion . -- \ ?Science is a way of trying not to fool yourself. The first | `\ principle is that you must not fool yourself, and you are the | _o__) easiest person to fool.? ?Richard P. Feynman, 1964 | Ben Finney From stefan_ml at behnel.de Wed Feb 1 03:26:15 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 01 Feb 2012 09:26:15 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Tim Arnold, 31.01.2012 19:09: > I have to follow a specification for producing xhtml files. > The original files are in cp1252 encoding and I must reencode them to utf-8. > Also, I have to replace certain characters with html entities. > > I think I've got this right, but I'd like to hear if there's something I'm > doing that is dangerous or wrong. > > Please see the appended code, and thanks for any comments or suggestions. > > I have two functions, translate (replaces high characters with entities) > and reencode (um, reencodes): > --------------------------------- > import codecs, StringIO > from lxml import etree > high_chars = { > 0x2014:'—', # 'EM DASH', > 0x2013:'–', # 'EN DASH', > 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', > 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', > 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', > 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', > 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', > 0x2122:'™', # 'TRADE MARK SIGN', > 0x00A9:'©', # 'COPYRIGHT SYMBOL', > } > def translate(string): > s = '' > for c in string: > if ord(c) in high_chars: > c = high_chars.get(ord(c)) > s += c > return s I hope you are aware that this is about the slowest possible algorithm (well, the slowest one that doesn't do anything unnecessary). Since none of this is required when parsing or generating XHTML, I assume your spec tells you that you should do these replacements? > def reencode(filename, in_encoding='cp1252',out_encoding='utf-8'): > with codecs.open(filename,encoding=in_encoding) as f: > s = f.read() > sio = StringIO.StringIO(translate(s)) > parser = etree.HTMLParser(encoding=in_encoding) > tree = etree.parse(sio, parser) Yes, you are doing something dangerous and wrong here. For one, you are decoding the data twice. Then, didn't you say XHTML? Why do you use the HTML parser to parse XML? > result = etree.tostring(tree.getroot(), method='html', > pretty_print=True, > encoding=out_encoding) > with open(filename,'wb') as f: > f.write(result) Use tree.write(f, ...) Assuming you really meant XHTML and not HTML, I'd just drop your entire code and do this instead: tree = etree.parse(in_path) tree.write(out_path, encoding='utf8', pretty_print=True) Note that I didn't provide an input encoding. XML is safe in that regard. Stefan From ulrich.eckhardt at dominolaser.com Wed Feb 1 03:39:08 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 01 Feb 2012 09:39:08 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Am 31.01.2012 19:09, schrieb Tim Arnold: > high_chars = { > 0x2014:'—', # 'EM DASH', > 0x2013:'–', # 'EN DASH', > 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', > 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', > 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', > 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', > 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', > 0x2122:'™', # 'TRADE MARK SIGN', > 0x00A9:'©', # 'COPYRIGHT SYMBOL', > } You could use Unicode string literals directly instead of using the codepoint, making it a bit more self-documenting and saving you the later call to ord(): high_chars = { u'\u2014': '—', u'\u2013': '–', ... } > for c in string: > if ord(c) in high_chars: > c = high_chars.get(ord(c)) > s += c > return s Instead of checking if there is a replacement and then looking up the replacement again, just use the default: for c in string: s += high_chars.get(c, c) Alternatively, if you find that clearer, you could also check if the returnvalue of get() is None to find out if there is a replacement: for c in string: r = high_chars.get(c) if r is None: s += c else: s += r Uli From no.email at nospam.invalid Wed Feb 1 04:25:05 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 01 Feb 2012 01:25:05 -0800 Subject: Iterate from 2nd element of a huge list References: Message-ID: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> Paulo da Silva writes: > process1(mylist[0]) > for el in mylist[1:]: > process2(el) > > This way mylist is almost duplicated, isn't it? I think it's cleanest to use itertools.islice to get the big sublist (not tested): from itertools import islice process1 (mylist[0]) for el in islice(mylist, 1, None): process2 (el) The islice has a small, constant amount of storage overhead instead of duplicating almost the whole list. From __peter__ at web.de Wed Feb 1 04:32:52 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 01 Feb 2012 10:32:52 +0100 Subject: xhtml encoding question References: Message-ID: Ulrich Eckhardt wrote: > Am 31.01.2012 19:09, schrieb Tim Arnold: >> high_chars = { >> 0x2014:'—', # 'EM DASH', >> 0x2013:'–', # 'EN DASH', >> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >> 0x2122:'™', # 'TRADE MARK SIGN', >> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >> } > > You could use Unicode string literals directly instead of using the > codepoint, making it a bit more self-documenting and saving you the > later call to ord(): > > high_chars = { > u'\u2014': '—', > u'\u2013': '–', > ... > } > >> for c in string: >> if ord(c) in high_chars: >> c = high_chars.get(ord(c)) >> s += c >> return s > > Instead of checking if there is a replacement and then looking up the > replacement again, just use the default: > > for c in string: > s += high_chars.get(c, c) > > Alternatively, if you find that clearer, you could also check if the > returnvalue of get() is None to find out if there is a replacement: > > for c in string: > r = high_chars.get(c) > if r is None: > s += c > else: > s += r It doesn't matter for the OP (see Stefan Behnel's post), but If you want to replace characters in a unicode string the best way is probably the translate() method: >>> print u"\xa9\u2122" ?? >>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) u'©™' From rosuav at gmail.com Wed Feb 1 04:48:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 1 Feb 2012 20:48:50 +1100 Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com> References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> <1328058665.56641.YahooMailNeo@web30607.mail.mud.yahoo.com> Message-ID: On Wed, Feb 1, 2012 at 12:11 PM, Andres Soto wrote: > > okok, my mistake is that I was using string in place of str. Thank you!! > regards Tip: In the interactive interpreter, enter: >>> type("spam") In Python 2, it'll say "type" not "class", but same diff. It tells you there what the type is. Same can be used for any other literal, name, or other object. Can be quite handy at times. ChrisA From jeanmichel at sequans.com Wed Feb 1 05:12:02 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Wed, 01 Feb 2012 11:12:02 +0100 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: <4F290FF2.9030907@sequans.com> Terry Reedy wrote: > On 1/31/2012 9:19 AM, Jean-Michel Pichavant wrote: > >> A: "My wheel is flat" >> B: "Buy a new car" > > A better analogy would be > > Q. "How do I make my old model car do something (it cannot do)?" > A. "Get the free new model that has that feature added." > > Of course, there is a cost to giving up the old and familiar and > learning and adjusting to the new, even when it is available gratis. A > husband wearing an old sweater after his wife gives him a new one, and > even retrieving it from the trash when she tosses it out, is a classic > (and true) cartoon joke. > > But I am sure that 95% of readers here will be using 3.x withing 10 > years. The only question for them is "When?". This not-well-known new > feature is one straw that some will put on the 'sooner' side of the > balance. > A simple solution to that problem has been provided by Miki. Someone should read at least http://wiki.python.org/moin/Python2orPython3 before migrating to python 3. Speaking for myself, I'm stuck with python 2.5 :-/ JM From tjreedy at udel.edu Wed Feb 1 05:28:27 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 05:28:27 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 1/31/2012 11:14 PM, Roy Smith wrote: > We would love to move to 3.x, for the better unicode support, if nothing > else. What's keeping us from doing so is the host of third-party > modules and tools we depend on that don't yet support 3.x. Tell that to the authors of packages you use so they no longer say that they have not converted for lack of demand ;-) -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Wed Feb 1 05:34:23 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 10:34:23 +0000 Subject: configobj In-Reply-To: References: <4F281178.70508@gmail.com> Message-ID: <4F29152F.6030702@gmail.com> On 02/01/2012 12:21 AM, Terry Reedy wrote: > On 1/31/2012 11:06 AM, Andrea Crotti wrote: >> I have a couple of questions about configobj, which I'm happily trying >> to use for this project. > > When asking about 3rd party modules, please include a url, so we can > be sure of what you mean and even take a look. Is > www.voidspace.org.uk/python/configobj.html > what you mean? Yes I meant that sorry. > >> which looked less complete and more cumbersome (to me at least) > > Does ConfigParser have the same problems you found with ConfigObj. > Well no, but also because it just gets raw strings, and doesn't do any validation. With ConfigObj I can do simply a spec file skip_pesky_pyc_paths = string_list include_extra_paths = string_list use_real_dependencies = bool(default=False) compute_dependencies_recursively = bool(default=False) And the options which are not declared will default automatically to that value. And also I never really liked the ConfigParser API.. Anyway I solved just leaving these long lists somewhere else, but otherwise I think a better solution would be YAML in general (which doesn't have much validation either apparently). From arnodel at gmail.com Wed Feb 1 05:54:56 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 10:54:56 +0000 Subject: Iterate from 2nd element of a huge list In-Reply-To: References: Message-ID: On 1 February 2012 08:11, Peter Otten <__peter__ at web.de> wrote: > Arnaud Delobelle wrote: > The example should be > >> from itertools import islice: > > for el in islice(mylist, 1, None): >> ? ? process2(el) Oops! -- Arnaud From jeanpierreda at gmail.com Wed Feb 1 06:14:48 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 1 Feb 2012 06:14:48 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On Tue, Jan 31, 2012 at 6:55 PM, Terry Reedy wrote: > Q. "How do I make my old model car do something (it cannot do)?" > A. "Get the free new model that has that feature added." > > Of course, there is a cost to giving up the old and familiar and learning > and adjusting to the new, even when it is available gratis. A husband > wearing an old sweater after his wife gives him a new one, and even > retrieving it from the trash when she tosses it out, is a classic (and true) > cartoon joke. It really bothers me that you imagine that there are no other problems than the newness. It's disheartening, because the problems are not that trivial and the world would be better if people were less callous about it, and realized that they exist. Python 3 is not very different from Python 2, as far as humans are concerned semantically/syntactically -- but, hell, just pick any project that uses PyPy, or Jython, or IronPython, or Twisted, or Zope, etc. -- it can be a lot of effort (sometimes infeasibly much) to port something dependent on these things, and it's taken years to get the (smallish) set of dependencies ported that we have now [and we literally paid people to do it, too!], and still many large projects haven't made the transition, and many small projects never will. Anyone that relies on those projects is stuck, and your "free car" metaphor completely ignores the true cost of wasting that much time porting everything for a tiny little feature. Evaluating only the monetary amounts can be misleading as to what the rational decision is (in particular when there are no monetary amounts). The only true notion of cost is the alternatives you sacrifice in making a decision: opportunity cost. The car is not free. -- Devin From stefan_ml at behnel.de Wed Feb 1 06:28:33 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 01 Feb 2012 12:28:33 +0100 Subject: Iterate from 2nd element of a huge list In-Reply-To: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> References: <7xy5sm6h3i.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin, 01.02.2012 10:25: > Paulo da Silva writes: >> process1(mylist[0]) >> for el in mylist[1:]: >> process2(el) >> >> This way mylist is almost duplicated, isn't it? > > I think it's cleanest to use itertools.islice to get the big sublist > (not tested): > > from itertools import islice > > process1 (mylist[0]) > for el in islice(mylist, 1, None): > process2 (el) > > The islice has a small, constant amount of storage overhead instead of > duplicating almost the whole list. It also has a tiny runtime overhead, though. So, if your code is totally performance critical and you really just want to strip off the first element and then run through all the rest, it may still be better to go the iter() + next() route. python3.3 -m timeit -s 'l=list(range(100000))' \ 'it = iter(l); next(it); all(it)' 1000 loops, best of 3: 935 usec per loop python3.3 -m timeit -s 'l=list(range(100000))' \ -s 'from itertools import islice' \ 'all(islice(l, 1, None))' 1000 loops, best of 3: 1.63 msec per loop Stefan From anais.conijn at skillsmatter.com Wed Feb 1 06:33:51 2012 From: anais.conijn at skillsmatter.com (=?ISO-8859-1?Q?Ana=EFs?=) Date: Wed, 1 Feb 2012 03:33:51 -0800 (PST) Subject: Russel Winder's Python Workshop in London Message-ID: Python-expert Russel Winder will be hosting a 4-day intensive Python workshop at the Skills Matter eXchange, London's meetup space for the developer community. Read all about it here: http://bit.ly/RWPythonWorkshopFEB13 And, to get a taste of Russel in action, you can watch a skillscast video of his January 31st talk on high performance python right here: http://bit.ly/RWPythonWorkshopFEB13 Hope this is of interest to you. Kind regards. From jason at founderdating.com Wed Feb 1 07:20:37 2012 From: jason at founderdating.com (Jason Demant) Date: Wed, 1 Feb 2012 04:20:37 -0800 (PST) Subject: FounderDating - Helping entrepreneurs find their co-founder & start companies! Message-ID: <52aa9bbc-e5da-4b14-b7e9-762ef3fed7d4@n8g2000pbc.googlegroups.com> Looking for your co-founder? FounderDating is back in San Francisco on March 1st (Apply by February 20th), in Seattle on March 6th (Apply by February 26th) and NY on February 21st (Apply by February 16th) at http://members.founderdating.com/application/. What is FounderDating? A great team is the best predictor of a new venture's success. Great teams are composed of high caliber people with complementary skills, this is where FounderDating comes in. FounderDating brings together super talented, handpicked entrepreneurs with different backgrounds and skill sets who want to start companies. We help them find the right match by giving them access to invitation- only events and an online member network. What differentiates FounderDating is the extreme quality of its members and their commitment to start something now! Apply now! -- http://members.founderdating.com/application/. Thanks! Jason http://www.FounderDating.com From johnroth1 at gmail.com Wed Feb 1 08:11:05 2012 From: johnroth1 at gmail.com (John Roth) Date: Wed, 1 Feb 2012 05:11:05 -0800 (PST) Subject: Disable use of pyc file with no matching py file References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> Message-ID: <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> On Jan 31, 4:43?pm, Terry Reedy wrote: > On 1/31/2012 3:20 PM, John Roth wrote: > > > On Jan 30, 3:43 pm, Terry Reedy ?wrote: > >> On 1/30/2012 4:30 PM, Roy Smith wrote: > > >>> Every so often (typically when refactoring), I'll remove a .py file > >>> and forget to remove the corresponding .pyc file. ?If I then import > >>> the module, python finds the orphaned .pyc and happily imports it. > >>> Usually leading to confusing and hard to debug failures. > > >>> Is there some way to globally tell python, "Never import a .pyc > >>> unless the corresponding .py file exits"? > > >> Upgrade to 3.2. > > I tested before writing this. The caveat is that x.pyc in the same > directly as x.py will not be ignored (for back compatibility). However, > this only happens intentionally as .pyc files are put in __pycache__/ > with name x..pyc, where is 'cpython-32' or something > similar for another version or implementation. > > > I've noticed that the tutorial (section 6.1.3) hasn't been updated for > > PEP 3147; there's no way of telling that this is the behavior from > > reading the tutorial. The development doc for 3.3 hasn't been updated > > either. > > You are right. An oversight. Thanks for noticing.http://bugs.python.org/issue13915 > Suggested rewrites are welcome. > > -- > Terry Jan Reedy I'll see if I can put a suggestion in the bug report. One other point: I'm unclear if a compiled module in the source directory would be named spam.pyc or spam.cpython-32.pyc. I'd think the latter to allow two versions of a compiled-only distribution. John Roth From void.of.time at gmail.com Wed Feb 1 09:15:22 2012 From: void.of.time at gmail.com (oleg korenevich) Date: Wed, 1 Feb 2012 06:15:22 -0800 (PST) Subject: python reliability with EINTR handling in general modules Message-ID: I have linux board on samsung SoC s3c6410 (ARM11). I build rootfs with buildroot: Python 2.7.1, uClibc-0.9.31. Linux kernel: Linux buildroot 2.6.28.6 #177 Mon Oct 3 12:50:57 EEST 2011 armv6l GNU/Linux My app, written on python, in some mysterios conditons raise this exceptions: 1) exception: File "./dfbUtils.py", line 3209, in setItemData ValueError: (4, 'Interrupted system call') code: currentPage=int(math.floor(float(rowId)/ self.pageSize))==self.selectedPage 2) exception: File "./terminalGlobals.py", line 943, in getFirmawareName OSError: [Errno 4] Interrupted system call: 'firmware' code: for fileName in os.listdir('firmware'): Some info about app: it have 3-7 threads, listen serial ports via 'serial' module, use gui implemented via c extension that wrap directfb, i can't reproduce this exceptions, they are not predictable. I googled for EINTR exceptions in python, but only found that EINTR can occur only on slow system calls and python's modules socket, subprocess and another one is already process EINTR. So what happens in my app? Why simple call of math function can interrupt program at any time, it's not reliable at all. I have only suggestions: ulibc bug, kernel/hw handling bug. But this suggestions don't show me solution. Now i created wrap functions (that restart opertion in case of EINTR) around some functions from os module, but wrapping math module will increase execution time in 2 times. There another question: if math can be interrutped than other module also can and how to get reliability? From trustsolutionsteam at gmail.com Wed Feb 1 09:22:31 2012 From: trustsolutionsteam at gmail.com (solutions team) Date: Wed, 1 Feb 2012 06:22:31 -0800 (PST) Subject: solutions manual books Message-ID: trust solutions team trustsolutionsteam(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: t r u s t s o l u t i o n s t e a m @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on trustsolutionsteam at hotmail.com From p.f.moore at gmail.com Wed Feb 1 10:09:02 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Wed, 1 Feb 2012 07:09:02 -0800 (PST) Subject: Registry entries set up by the Windows installer Message-ID: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> I'm trying to get information on what registry entries are set up by the Python Windows installer, and what variations exist. I don't know enough about MSI to easily read the source, so I'm hoping someone who knows can help :-) As far as I can see on my PC, the installer puts entries HKLM\Software\Python\PythonCore\x.y with various bits underneath. I think I've seen indications that sometimes these are in HKCU, presumably for a "per user" install? If I manually hack around in the registry, and have both HKLM and HKCU, which one will Python use? Furthermore, more of a Windows question than Python, but there's a similar question with regard to the .py and .pyw file associations - they can be in HKLM\Software\Classes or HKCU\Software\Classes. Which takes precedence? I assume that the installer writes to HKLM for all users and HKCU for per-user installs. Is there anything else I've missed? The reason I ask, is that I'm starting to work with virtualenv, and I want to see what would be involved in (re-)setting the registry entries to match the currently active virtualenv. virtualenvwrapper- powershell seems to only deal with HKCU (which is a big plus on Windows 7, as it avoids endless elevation requests :-)) but that doesn't work completely cleanly with my all-users install. (Note: I'm not entirely sure that changing global settings like this to patch a per-console virtualenv is a good idea, but I'd like to know how hard it is before dismissing it...) Thanks, Paul. From franck at ditter.org Wed Feb 1 10:17:39 2012 From: franck at ditter.org (Franck Ditter) Date: Wed, 01 Feb 2012 16:17:39 +0100 Subject: Buffering in Wing and IDLE 3 Message-ID: Hi, I'm using Python 3.2.x with beginners. If I try the following in IDLE 3, it works as expected : from time import sleep import sys for i in range(4) : sys.stdout.write(str(i)) sys.stdout.flush() sleep(1) but with Wing-101, it write 0123 after the total sleep time. Why ??? I would prefer to use IDLE but as we are in France, the Python team does not seem to be aware that the ~ and others are not available on MacOS-X here (probably the same in Europe)... franck From torriem at gmail.com Wed Feb 1 10:46:34 2012 From: torriem at gmail.com (Michael Torrie) Date: Wed, 01 Feb 2012 08:46:34 -0700 Subject: python zipfile v. native unzip In-Reply-To: References: Message-ID: <4F295E5A.8010807@gmail.com> On 01/31/2012 06:41 AM, Jason Friedman wrote: > Does Python 2.7's zipfile module use its own algorithm or does it > leverage the zip/unzip libraries that exist on the host? I ask > because my host's native unzip program cannot handle files that, when > unzipped, are larger than 2GB. Will using Python 2.7 get around this > limitation? What operating system and file system? From ulrich.eckhardt at dominolaser.com Wed Feb 1 11:03:19 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 01 Feb 2012 17:03:19 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Am 01.02.2012 10:32, schrieb Peter Otten: > It doesn't matter for the OP (see Stefan Behnel's post), but If you want to > replace characters in a unicode string the best way is probably the > translate() method: > >>>> print u"\xa9\u2122" > ?? >>>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) > u'©™' > Yes, this is both more expressive and at the same time probably even more efficient. Question though: >>> u'abc'.translate({u'a': u'A'}) u'abc' I would call this a chance to improve Python. According to the documentation, using a string is invalid, but it neither raises an exception nor does it do the obvious and accept single-character strings as keys. Thoughts? Uli From andrea.crotti.0 at gmail.com Wed Feb 1 11:15:05 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 16:15:05 +0000 Subject: changing sys.path Message-ID: <4F296509.60607@gmail.com> So suppose I want to modify the sys.path on the fly before running some code which imports from one of the modules added. at run time I do sys.path.extend(paths_to_add) but it still doesn't work and I get an import error. If I take these paths and add them to site-packages/my_paths.pth everything works, but at run-time the paths which I actually see before importing are exactly the same. So there is something I guess that depends on the order, but what can I reset/reload to make these paths available (I thought I didn't need anything in theory)? From hansmu at xs4all.nl Wed Feb 1 11:49:57 2012 From: hansmu at xs4all.nl (Hans Mulder) Date: Wed, 01 Feb 2012 17:49:57 +0100 Subject: Installing pypi package twice In-Reply-To: References: Message-ID: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> On 1/02/12 07:04:31, Jason Friedman wrote: > My system's default python is 2.6.5. I have also installed python3.2 > at /opt/python. > I installed a pypi package for 2.6.5 with: > $ tar xzf package.tar.gz > $ cd package > $ python setup.py build > $ sudo python setup.py install > > How can I also install this same package for 3.2? (I am assuming this > package works with 3.2 or that I can make it work.) How about (in another directory): $ tar xzf package.tar.gz $ cd package $ /opt/python/bin/python setup.py build $ sudo /opt/python/bin/python setup.py install This assumes that /opt/python/bin/python is your python3.2 executable. You may want to insert some testing between the 'build' and 'install' steps. Or you could try: $ /opt/python/bin/python -m compileall build/lib That would try to compile all Python files in the subdirectory to byte code. That's likely to fail if the Python code is not valid Python 3. If it compiles, you may still want to do some testing. Hope this helps, -- HansM From katie.clark at yale.edu Wed Feb 1 11:53:41 2012 From: katie.clark at yale.edu (Clark, Kathleen) Date: Wed, 1 Feb 2012 16:53:41 +0000 Subject: TypeError Message-ID: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Hello, I am new to python and am trying to correct the follow error: TypeError: sequence item 1: expected string, NoneType found The error message is referencing line 86 of my code: ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) If I'm understanding this correctly, the code is expecting a string, but not finding it. I'm wondering, what is meant by a "string" and also how I can figure out the problem and correct it. If anyone could help me understand what the error is and needs to be done to correct it, I think I might be able to fill in the blanks. Thanks, Katie ______________________________________________________________________ [logo for email] Katie Clark Research Assistant SHARRPP 60 Temple Street, Suite 4D New Haven, CT 06510 203-737-7425 katie.clark at yale.edu www.sharrpp.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 3264 bytes Desc: image002.jpg URL: From andrea.crotti.0 at gmail.com Wed Feb 1 11:54:52 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 16:54:52 +0000 Subject: Installing pypi package twice In-Reply-To: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> References: <4f296d35$0$6891$e4fe514c@news2.news.xs4all.nl> Message-ID: <4F296E5C.8000103@gmail.com> On 02/01/2012 04:49 PM, Hans Mulder wrote: > > How about (in another directory): > > $ tar xzf package.tar.gz > $ cd package > $ /opt/python/bin/python setup.py build > $ sudo /opt/python/bin/python setup.py install > > This assumes that /opt/python/bin/python is your python3.2 executable. > > You may want to insert some testing between the 'build' and 'install' > steps. Or you could try: > > $ /opt/python/bin/python -m compileall build/lib > > That would try to compile all Python files in the subdirectory to byte > code. That's likely to fail if the Python code is not valid Python 3. > If it compiles, you may still want to do some testing. > > Hope this helps, > > -- HansM That works, but it's probably easier to (depending on your needs): - install easy_install / pip for that python version - use virtualenv From wxjmfauth at gmail.com Wed Feb 1 12:06:40 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 1 Feb 2012 09:06:40 -0800 (PST) Subject: changing sys.path References: Message-ID: <5b9ced23-b316-44d1-9d69-b12643a873da@c6g2000vbk.googlegroups.com> On 1 f?v, 17:15, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these paths and add them to site-packages/my_paths.pth > everything works, but at run-time the paths which I actually see before > importing are exactly the same. > > So there is something I guess that depends on the order, but what can I > reset/reload to make these paths available (I thought I didn't need > anything in theory)? >>> import mod Traceback (most recent call last): File "", line 1, in ImportError: No module named mod >>> sys.path.append(r'd:\\jm\\junk') >>> import mod >>> mod >>> mod.hello() fct hello in mod.py sys.path? Probably, the most genious Python idea. jmf From diolu at bigfoot.com Wed Feb 1 12:11:17 2012 From: diolu at bigfoot.com (Olive) Date: Wed, 1 Feb 2012 18:11:17 +0100 Subject: Question about name scope Message-ID: <20120201181117.5d35dddc@bigfoot.com> I am learning python and maybe this is obvious but I have not been able to see a solution. What I would like to do is to be able to execute a function within the namespace I would have obtained with from import * For example if I write: def f(a): return sin(a)+cos(a) I could then do: from math import * f(5) But I have polluted my global namespace with all what's defined in math. I would like to be able to do something like "from math import *" at the f level alone. The main reason for this is the sympy module for CAS (computer algebra). It reimplement a lot of functions and define all the letters as symbolic variables. Writing sympy. everywhere is inconvenient. Importing all the symbols in the global namespace would lead to name clash. It would be nice if I could import all the sympy names but for a given function only. Olive From d at davea.name Wed Feb 1 12:15:18 2012 From: d at davea.name (Dave Angel) Date: Wed, 01 Feb 2012 12:15:18 -0500 Subject: TypeError In-Reply-To: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> References: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Message-ID: <4F297326.9060907@davea.name> On 02/01/2012 11:53 AM, Clark, Kathleen wrote: > Hello, Which python version, what operating system. Doesn't cost much to specify, and can frequently be relevant. > > I am new to python and am trying to correct the follow error: > > TypeError: sequence item 1: expected string, NoneType found > That's not an error message, it's just the last line of one. Please use copy/paste to post the entire traceback into your query. > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) > And this couldn't be simplified? The sample is not runnable, so we have to make up a wrapper program to define at least 6 variables, and then execute this line? > If I'm understanding this correctly, the code Which code? > is expecting a string, but not finding it. I'm wondering, what is meant by a "string" and also how I can figure out the problem and correct it. > > If anyone could help me understand what the error is and needs to be done to correct it, I think I might be able to fill in the blanks. > > Thanks, > > Katie > > If I guess you're running Python 2.7 on Linux 11.04, I could try the following: >>> ino = 4 >>> fn = None >>> ln = 12 >>> sdobj = object() >>> '.'.join([str(ino), fn, ln, sdobj) File "", line 1 '.'.join([str(ino), fn, ln, sdobj) ^ SyntaxError: invalid syntax >>> '.'.join([str(ino), fn, ln, sdobj]) Traceback (most recent call last): File "", line 1, in TypeError: sequence item 1: expected string, NoneType found >>> If this matches your circumstance, the problem is that fn has a value of None. You could have guessed this by simply tucking some print statements right in front of the offending line, displaying all six variables, and seeing which is of type NoneType. So now you have to figure out how fn got that value. (please don't post graphic attachments to your message, this is a text mailing list) -- DaveA From rantingrickjohnson at gmail.com Wed Feb 1 12:17:04 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 09:17:04 -0800 (PST) Subject: changing sys.path References: Message-ID: On Feb 1, 10:15?am, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. > > If I take these paths and add them to site-packages/my_paths.pth > everything works, but at run-time the paths which I actually see before > importing are exactly the same. 1. Is paths_to_add a nested list? 2. Have you tried inspecting the contents of sys.path AFTER calling extend method? Consider: py> sys.path.__len__() 14 py> sys.path.extend([[1,2,3]]) py> sys.path.__len__() 15 From rantingrickjohnson at gmail.com Wed Feb 1 12:21:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 09:21:22 -0800 (PST) Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <2f7095cd-12ad-4031-9ebe-0c54ee3ad9c9@p13g2000yqd.googlegroups.com> On Feb 1, 11:11?am, Olive wrote: > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. Seeing is believing! >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> from math import * >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc'] >>> ================================ RESTART ================================ >>> dir() ['__builtins__', '__doc__', '__name__', '__package__'] >>> from math import sin, cos >>> dir() ['__builtins__', '__doc__', '__name__', '__package__', 'cos', 'sin'] >>> From nicholas.dokos at hp.com Wed Feb 1 12:27:47 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Wed, 01 Feb 2012 12:27:47 -0500 Subject: TypeError In-Reply-To: Message from "Clark\, Kathleen" of "Wed\, 01 Feb 2012 16\:53\:41 GMT." <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> References: <0610E9FC98B37742AD184612801101F834B04E@x10-mbx4.yu.yale.edu> Message-ID: <2584.1328117267@alphaville> Clark, Kathleen wrote: > TypeError: sequence item 1: expected string, NoneType found > > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) > > If I?m understanding this correctly, the code is expecting a string, but not finding it. I?m > wondering, what is meant by a ?string? and also how I can figure out the problem and correct it. I'd guess that the sequence in question is the list that's the argument of join(), in which case item 1 is fn: it should be a string but for some reason, it is a None value: ,---- | >>> ','.join([str(45), None, "bar", "foo"]) | Traceback (most recent call last): | File "", line 1, in | TypeError: sequence item 1: expected string, NoneType found |>>> ','.join([str(45), "a string", "bar", "foo"]) |'45,a string,bar,foo' `---- Nick From ckaynor at zindagigames.com Wed Feb 1 12:28:06 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Wed, 1 Feb 2012 09:28:06 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 9:11 AM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. > The standard way would be to just do: import math def f(a): return math.sin(a)+math.cos(a) What this does is import the module math into the current module namespace, then access attributes on that module. > > Olive > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Wed Feb 1 12:36:36 2012 From: d at davea.name (Dave Angel) Date: Wed, 01 Feb 2012 12:36:36 -0500 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F297824.1000202@davea.name> On 02/01/2012 12:11 PM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. > > Olive > > Start by specifying python version and operating system. I tried your experiment using Python 2.7 and Linux 11.04 def f(a): from math import sin, cos return sin(a) + cos(a) print f(45) Does what you needed, and neatly. The only name added to the global namspace is f, of type function. I was a bit surprised that using from math import * inside the function worked, but it generates a warning: olive.py:2: SyntaxWarning: import * only allowed at module level def f(a): I normally avoid any use of the "from XX import *" form, as it pollutes the global name space. The only exception is when a library writer documents that this is the "normal" way to interface to it. In this case, he usually defines just a few things that are visible this way) What I do is put a single import math at the top of my source file, and use math.sin, and math.cos where needed. Occasionally, I'll use something like: from math import sin,cos at the top, so I know just which symbols I'm defining. How about: import math def f(a): sin = math.sin cos = math.cos return sin(a) + cos(a) print f(45) This lets you explicitly use the sin and cos names inside the function, by defining them at entry to the function. -- DaveA From clp2 at rebertia.com Wed Feb 1 12:38:59 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 1 Feb 2012 09:38:59 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 9:11 AM, Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with ?from > import * > > For example if I write: > > def f(a): > ? ? ? ?return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. > > The main reason for this is the sympy module for CAS (computer algebra). > It reimplement a lot of functions and define all the letters as symbolic > variables. Writing sympy. everywhere is inconvenient. > Importing all the symbols in the global namespace would lead to name > clash. It would be nice if I could import all the sympy names but for a > given function only. Don't think that's possible. Best alternative I can think of would be: import sympy as s def f(a): return s.sin(a) + s.cos(a) Cheers, Chris From ethan at stoneleaf.us Wed Feb 1 12:43:14 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 09:43:14 -0800 Subject: Question about name scope In-Reply-To: <20120201181117.5d35dddc@bigfoot.com> References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F2979B2.6070804@stoneleaf.us> Olive wrote: > I am learning python and maybe this is obvious but I have not been able > to see a solution. What I would like to do is to be able to execute a > function within the namespace I would have obtained with from > import * > > For example if I write: > > def f(a): > return sin(a)+cos(a) > > I could then do: > > from math import * > > f(5) > > But I have polluted my global namespace with all what's defined in > math. I would like to be able to do something like "from math import *" > at the f level alone. If you are using Python 2.x you can do: def f(a): from sympy import * return a(a) + d(a) Python 3 does not allow * imports in functions, however, so you would need to do: def f(a): from sympy import a,b,c,d,e,f,g,h,i,j,k,l,m from sympy import n,o,p,q,r,s,t,u,v,w,x,y,z return z(a) / f(a) + o(a) Obviously, only import the functions you are actually going to use. ;) ~Ethan~ From andrea.crotti.0 at gmail.com Wed Feb 1 12:47:22 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 01 Feb 2012 17:47:22 +0000 Subject: changing sys.path In-Reply-To: References: <4F296509.60607@gmail.com> Message-ID: <4F297AAA.8090600@gmail.com> On 02/01/2012 05:13 PM, Eric Snow wrote: > On Wed, Feb 1, 2012 at 9:15 AM, Andrea Crotti wrote: >> So suppose I want to modify the sys.path on the fly before running some code >> which imports from one of the modules added. >> >> at run time I do >> sys.path.extend(paths_to_add) >> >> but it still doesn't work and I get an import error. > Make sure you are adding to sys.path the directories that your > packages/modules are in, and not the actual package directories. > During import Python looks for modules/packages _in_ each of the > directories on sys.path, but not _at_ those directories. Yes sure I do this.. > >> If I take these paths and add them to site-packages/my_paths.pth >> everything works, but at run-time the paths which I actually see before >> importing are exactly the same. > You mean sys.path looks exactly the same in the two cases? > > -eric Yes they are exactly the same, because in that file I just write exactly the same list, but when modifying it at run-time it doesn't work, while if at the application start there is this file everything works correctly... That's what really puzzles me.. What could that be then? From lists at cheimes.de Wed Feb 1 12:50:53 2012 From: lists at cheimes.de (Christian Heimes) Date: Wed, 01 Feb 2012 18:50:53 +0100 Subject: Question about name scope In-Reply-To: <4F297824.1000202@davea.name> References: <20120201181117.5d35dddc@bigfoot.com> <4F297824.1000202@davea.name> Message-ID: Am 01.02.2012 18:36, schrieb Dave Angel: > def f(a): > from math import sin, cos > return sin(a) + cos(a) > > print f(45) > > Does what you needed, and neatly. The only name added to the global > namspace is f, of type function. I recommend against this approach. It's slightly slower and the global import lock will cause trouble if you start using threads. Christian From python.list at tim.thechases.com Wed Feb 1 13:03:38 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 01 Feb 2012 12:03:38 -0600 Subject: python zipfile v. native unzip In-Reply-To: References: Message-ID: <4F297E7A.6040808@tim.thechases.com> On 01/31/12 07:41, Jason Friedman wrote: > Does Python 2.7's zipfile module use its own algorithm or does it > leverage the zip/unzip libraries that exist on the host? I ask > because my host's native unzip program cannot handle files that, when > unzipped, are larger than 2GB. Will using Python 2.7 get around this > limitation? According to: http://hg.python.org/cpython/file/5395f96588d4/Lib/zipfile.py#l669 I'm guessing that the ZIP64_LIMIT references the 2GB limit, and Python's zipfile module requires you to instantiate with zf = ZipFile(..., allosZip64=True) The ZIP64_LIMIT = (1 << 31) - 1 which is 2GB. It appears this was added in revision fd412a00a07d: Patch #1446489 (zipfile: support for ZIP64) which seems to have been implemented back in at least Python 2.5. -tkc From Tim.Arnold at sas.com Wed Feb 1 13:15:09 2012 From: Tim.Arnold at sas.com (Tim Arnold) Date: Wed, 01 Feb 2012 13:15:09 -0500 Subject: xhtml encoding question In-Reply-To: References: Message-ID: On 2/1/2012 3:26 AM, Stefan Behnel wrote: > Tim Arnold, 31.01.2012 19:09: >> I have to follow a specification for producing xhtml files. >> The original files are in cp1252 encoding and I must reencode them to utf-8. >> Also, I have to replace certain characters with html entities. >> --------------------------------- >> import codecs, StringIO >> from lxml import etree >> high_chars = { >> 0x2014:'—', # 'EM DASH', >> 0x2013:'–', # 'EN DASH', >> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >> 0x2122:'™', # 'TRADE MARK SIGN', >> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >> } >> def translate(string): >> s = '' >> for c in string: >> if ord(c) in high_chars: >> c = high_chars.get(ord(c)) >> s += c >> return s > > I hope you are aware that this is about the slowest possible algorithm > (well, the slowest one that doesn't do anything unnecessary). Since none of > this is required when parsing or generating XHTML, I assume your spec tells > you that you should do these replacements? > I wasn't aware of it, but I am now--code's embarassing now. The spec I must follow forces me to do the translation. I am actually working with html not xhtml; which makes a huge difference, sorry for that. Ulrich's line of code for translate is elegant. for c in string: s += high_chars.get(c,c) > >> def reencode(filename, in_encoding='cp1252',out_encoding='utf-8'): >> with codecs.open(filename,encoding=in_encoding) as f: >> s = f.read() >> sio = StringIO.StringIO(translate(s)) >> parser = etree.HTMLParser(encoding=in_encoding) >> tree = etree.parse(sio, parser) > > Yes, you are doing something dangerous and wrong here. For one, you are > decoding the data twice. Then, didn't you say XHTML? Why do you use the > HTML parser to parse XML? > I see that I'm decoding twice now, thanks. Also, I now see that when lxml writes the result back out the entities I got from my translate function are resolved, which defeats the whole purpose. > >> result = etree.tostring(tree.getroot(), method='html', >> pretty_print=True, >> encoding=out_encoding) >> with open(filename,'wb') as f: >> f.write(result) > > Use tree.write(f, ...) From the all the info I've received on this thread, plus some additional reading, I think I need the following code. Use the HTMLParser because the source files are actually HTML, and use output from etree.tostring() as input to translate() as the very last step. def reencode(filename, in_encoding='cp1252', out_encoding='utf-8'): parser = etree.HTMLParser(encoding=in_encoding) tree = etree.parse(filename, parser) result = etree.tostring(tree.getroot(), method='html', pretty_print=True, encoding=out_encoding) with open(filename, 'wb') as f: f.write(translate(result)) not simply tree.write(f...) because I have to do the translation at the end, so I get the entities instead of the resolved entities from lxml. Again, it would be simpler if this was xhtml, but I misspoke (mis-wrote?) when I said xhtml; this is for html. > Assuming you really meant XHTML and not HTML, I'd just drop your entire > code and do this instead: > > tree = etree.parse(in_path) > tree.write(out_path, encoding='utf8', pretty_print=True) > > Note that I didn't provide an input encoding. XML is safe in that regard. > > Stefan > thanks everyone for the help. --Tim Arnold From jenn.turliuk at gmail.com Wed Feb 1 13:38:05 2012 From: jenn.turliuk at gmail.com (Jennifer Turliuk) Date: Wed, 1 Feb 2012 10:38:05 -0800 (PST) Subject: Startup Chile Company Looking For Founding Developer/CTO Message-ID: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> Hi everyone, My name is Jennifer Turliuk. I'm currently in Santiago, Chile for the next 6 months as part of the Startup Chile program. I think you may be able to help me out. We are looking to bring on a developer ASAP (see description below). If you are interested, we'd love to hear from you. Or, if you know of anyone that may be interested, we'd be very grateful if you would pass this along. Thanks in advance, and I look forward to hearing from you. Regards, Jenn *Startup Chile Company Looking for Founding Developer/CTO* We?re building a highly curated online marketplace where people can find others to exchange skills with on a one-to-one, offline basis. We?re looking for a full-time founding developer/CTO to join us, starting with the first 6 months in Santiago, Chile as part of the Startup Chile program. *About Us*: - Selected for Startup Chile program (alumni: Cruisewise, Gym-pact) - Secured seed funding - Finalist in competition to shadow Dave McClure (500 Startups) - Spoke on stage with Peter Thiel - First website was featured in magazine at age 13 - Top sales associate in one of N.A.?s most aggressive sales environments - Publicity stunt garnered $4MM in media coverage in 24hrs - Attended the Oscars & Grammys - Member of exclusive kiteboarding group with CEOs of Dropbox, Scribd, Gowalla, etc. *About the Role*: - Build an AirBnB for skills-exchanges, where people can list skills that they can offer and want to learn (e.g. if they want to learn Spanish and can teach programming, they can find people to exchange with via trade or money) - Create a new sharing economy where time is the currency - Join a tight team that is serious about winning but also has a great time - Opportunity to build a team and manage others as we grow - Flexible compensation includes flights to South America, accommodation, salary, and equity. *About You*: - Comfortable with backend work, particularly working with databases and keeping an eye on application performance - Excited by challenges and the flexibility of a consumer-facing web startup - A deep-seated love of efficient/elegant Python, Ruby, Node.js or Django (front-end knowledge is also helpful) - Passionate about the business idea - Able to relocate to Santiago, Chile for 6 months fairly quickly. Contact us at jenn.turliuk at gmail.com by February 1st. From katie.clark at yale.edu Wed Feb 1 13:46:51 2012 From: katie.clark at yale.edu (Clark, Kathleen) Date: Wed, 1 Feb 2012 18:46:51 +0000 Subject: TypeError Message-ID: <0610E9FC98B37742AD184612801101F834B100@x10-mbx4.yu.yale.edu> Hello and thank you for all responses. I have resolved my problem. Turned out that one of the files was missing "fn" and after deleting the record, the program ran just fine. Thanks again, Katie -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwilson at the-wire.com Wed Feb 1 13:47:57 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Wed, 01 Feb 2012 13:47:57 -0500 Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: Dave Angel wrote: > I tried your experiment using Python 2.7 and Linux 11.04 > > > def f(a): > from math import sin, cos > return sin(a) + cos(a) > > print f(45) > > Does what you needed, and neatly. The only name added to the global > namspace is f, of type function. > > I was a bit surprised that using from math import * inside the > function worked, but it generates a warning: > olive.py:2: SyntaxWarning: import * only allowed at module level > def f(a): I guess they want local symbols in functions to be pre-compiled. Similar to the way you can't usefully update the dict returned by locals(). Strangely, I notice that Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def f(x): ... exec x ... exec 'print a' ... >>> f('a=4') 4 >>> works, but I really cannot explain why. Mel. From fabiofz at gmail.com Wed Feb 1 14:43:12 2012 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 1 Feb 2012 17:43:12 -0200 Subject: PyDev 2.4.0 Released Message-ID: Hi All, PyDev 2.4.0 has been released Details on PyDev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: ------------------------------- PyDev is now faster and uses less memory (many performance and memory improvements were done)! The contents of the homepage are now migrated to a wiki at https://wiki.appcelerator.org/display/tis/Python+Development ... (later most of the homepage will become a mirror of the wiki). Others * Organize imports: Fixed issue where other statements in a commit line got lost (now such a line is ignored). * PyDev Package Explorer: closed project no longer remains with old icons. * Fixed deadlock when setting project as Django. * Fixed issue in code formatting *args on lambda statement. * TODO tags: only searched now in a string/comment partition. * Fixed issue when saving empty document (bad location on code-formatter). * Fixed issue removing comments from document. * Applied patch for internal Jython 2.2.1 to fix list.sort (http://bugs.jython.org/issue1835099). * Fixed resolution of template variable prev_class_or_method and next_class_or_method. What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python, Jython and IronPython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer Appcelerator http://appcelerator.com/ Aptana http://aptana.com/ PyDev - Python Development Environment for Eclipse http://pydev.org http://pydev.blogspot.com From tjreedy at udel.edu Wed Feb 1 14:53:39 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 14:53:39 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/1/2012 6:14 AM, Devin Jeanpierre wrote: > It really bothers me that you imagine that there are no other problems > than the newness. And it bothers me that you imput such ignorance to me. You made what I think was a bad analogy and I made a better one of the same type, though still imperfect. I acknowledged that the transition will take years. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 1 14:57:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 14:57:11 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <18b386df-c1bb-40b1-8910-90c368593e0d@t15g2000yqi.googlegroups.com> Message-ID: On 2/1/2012 8:11 AM, John Roth wrote: > One other point: I'm unclear if a compiled module in the source > directory would be named spam.pyc or spam.cpython-32.pyc. I'd think > the latter to allow two versions of a compiled-only distribution. By test, it has to be spam.pyc, as before. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 1 15:01:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 01 Feb 2012 15:01:40 -0500 Subject: Buffering in Wing and IDLE 3 In-Reply-To: References: Message-ID: On 2/1/2012 10:17 AM, Franck Ditter wrote: > I would prefer to use IDLE but as we are in France, the Python team > does not seem to be aware that the ~ and others are not available > on MacOS-X here (probably the same in Europe)... We are quite aware of the problem but cannot directly do anything about it as the problem is with tcl/tk and Apple. A couple of days ago, Kevin Walzer wrote on an IDLE-sig post "I'm currently reviewing an updated patch to address the problem. When I commit the patch, it will go into both Tk's trunk and in the Cocoa 8.5 backport, and eventually be available through ActiveState's distribution." -- Terry Jan Reedy From timothy.c.delaney at gmail.com Wed Feb 1 15:24:07 2012 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Thu, 2 Feb 2012 07:24:07 +1100 Subject: changing sys.path In-Reply-To: <4F297AAA.8090600@gmail.com> References: <4F296509.60607@gmail.com> <4F297AAA.8090600@gmail.com> Message-ID: On 2 February 2012 04:47, Andrea Crotti wrote: > > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That's what really puzzles me.. What could that be then? Post the actual code, plus traceback. We cannot help you without it. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From rowen at uw.edu Wed Feb 1 16:00:39 2012 From: rowen at uw.edu (Russell E. Owen) Date: Wed, 01 Feb 2012 13:00:39 -0800 Subject: Generator problem: parent class not seen Message-ID: I have an odd and very intermittent problem in Python script. Occasionally it fails with this error: Traceback (most recent call last): File "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas eFocusScript.py", line 884, in run File "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas eFocusScript.py", line 1690, in initAll TypeError: unbound method initAll() must be called with BaseFocusScript instance as first argument (got ScriptClass instance instead) self=; class hierarchy=[(, (,)), [(, (,))]] The code looks like this: def run(self, sr): try: self.initAll() .... except Exception: traceback.print_exc(file=sys.stderr) sys.stderr.write("self=%r; class hierarchy=%s\n" % (self, inspect.getclasstree([type(self)]))) raise As a detail that may be important: the code is a generator that is being run by a script runner class (an instance of which is passed into the run function as argument sr). When the user starts a script the script runner calls the script's "run" generator. The script runner calls the run generator again later when conditions are right (e.g. data that is being waited for arrives, a time limit is reached...). In this case the failure occurs at the very start of the script, so a yield has not yet executed. I am puzzled why Python thinks the class type is wrong, given the output of inspect.getclasstree. Any ideas on what might be wrong and how to track it down (and why it would be so intermittent)? -- Russell From isaacrc82 at gmail.com Wed Feb 1 16:24:25 2012 From: isaacrc82 at gmail.com (Ariel) Date: Wed, 1 Feb 2012 16:24:25 -0500 Subject: Problem sending an email in html with mime image Message-ID: Hi everybody I have a question, here is my problem I want to send an email with content in html with an image embed so I converted the image binary in mime text and then I put the mime code inside the src attribute of the html like this: Then I send the email, here is my code: from django.template.loader import render_to_string from django.core.mail.message import EmailMultiAlternatives contextcopy = {} message = render_to_string('bulletin.html', contextcopy) subject = "TEST" msg = EmailMultiAlternatives(subject, message, from_email,['myemail at gmail.com'']) msg.attach_alternative(message, "text/html") msg.send() The problem is that if I don't put the image mime code inside the src the email is sent but when I put the code then the email is not send and I don't get any error message. Could somebody please, help me ??? Why the email is not send when I put the mime code of the image in the html ??? Regards, Ariel From gafunchal at gmail.com Wed Feb 1 16:24:44 2012 From: gafunchal at gmail.com (Giovanni Funchal) Date: Wed, 1 Feb 2012 21:24:44 +0000 Subject: Patching CGIHTTPServer.py In-Reply-To: <30772597.282.1327766678735.JavaMail.geo-discussion-forums@yqjk7> References: <30772597.282.1327766678735.JavaMail.geo-discussion-forums@yqjk7> Message-ID: Wow, that's very flattering :-) I've opened an item in the python bug tracker for this enhancement and attached my patch, let's see how it goes. Thanks, -- Giovanni On Sat, Jan 28, 2012 at 4:04 PM, Miki Tebeka wrote: > IMO the code is good enough to submit a patch. > -- > http://mail.python.org/mailman/listinfo/python-list From businessmother at hotmail.com Wed Feb 1 16:41:04 2012 From: businessmother at hotmail.com (businessmother at hotmail.com) Date: Wed, 1 Feb 2012 13:41:04 -0800 (PST) Subject: Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Message-ID: <749d23dc-49f4-4248-a57e-2a372813cf3e@b23g2000yqn.googlegroups.com> Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Wanted Online Internet job workers. Job is only through Internet. Work from home part time jobs. You can earn $1500-2500/month working 1-2 hours/day, no matter where you live. These are genuine Data entry jobs & Internet jobs. No Investment required. Only serious enquires please. For more details visit http://www.earnparttimejobs.com/index.php?id=3677959 From businessmother at hotmail.com Wed Feb 1 16:45:01 2012 From: businessmother at hotmail.com (businessmother at hotmail.com) Date: Wed, 1 Feb 2012 13:45:01 -0800 (PST) Subject: Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Message-ID: <2faaf440-f89a-4121-a3f5-d8ea0d8f0f74@o20g2000yqh.googlegroups.com> Work from Home. Earn $2000/month. No Investment. Part Time, 1-2h/day. Wanted Online Internet job workers. Job is only through Internet. Work from home part time jobs. You can earn $1500-2500/month working 1-2 hours/day, no matter where you live. These are genuine Data entry jobs & Internet jobs. No Investment required. Only serious enquires please. For more details visit http://www.earnparttimejobs.com/index.php?id=3677959 From ian.g.kelly at gmail.com Wed Feb 1 16:49:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 14:49:52 -0700 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: On Wed, Feb 1, 2012 at 11:47 AM, Mel Wilson wrote: > I guess they want local symbols in functions to be pre-compiled. ?Similar to > the way you can't usefully update the dict returned by locals(). ?Strangely, > I notice that > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(x): > ... ? exec x > ... ? exec 'print a' > ... >>>> f('a=4') > 4 >>>> > > works, but I really cannot explain why. I am not a dev, but I believe it works because assigning to locals() and assigning via exec are not the same thing. The problem with assigning to locals() is that you're fundamentally just setting a value in a dictionary, and even though it happens to be the locals dict for the stack frame, Python can't figure out that it should go and update the value of the optimized local to match. exec, on the other hand, compiles and executes an actual STORE_NAME operation. Of course, if the particular local variable hasn't been optimized by the compiler, then updating locals() works just fine (although you probably should not rely on this): >>> def f(x, y): ... locals()[x] = y ... print locals()[x] ... exec 'print ' + x ... >>> f('a', 42) 42 42 Another interesting thing to note is that the print in your example doesn't even need to be in a second exec, which I believe works because the presence of any exec statement disables global variable optimizations for the function. Compare: >>> def f(x): ... locals()['a'] = 4 ... print a ... >>> f('pass') Traceback (most recent call last): File "", line 1, in File "", line 3, in f NameError: global name 'a' is not defined >>> def f(x): ... locals()['a'] = 4 ... print a ... exec x ... >>> f('pass') 4 And while we're on the subject, here's a nicely obscure syntax error: >>> def f(x): ... def g(): ... print x ... exec x ... File "", line 4 SyntaxError: unqualified exec is not allowed in function 'f' it contains a nested function with free variables Cheers, Ian From ethan at stoneleaf.us Wed Feb 1 17:24:28 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 14:24:28 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> Message-ID: <4F29BB9C.70405@stoneleaf.us> Ian Kelly wrote: > I am not a dev, but I believe it works because assigning to locals() > and assigning via exec are not the same thing. The problem with > assigning to locals() is that you're fundamentally just setting a > value in a dictionary, and even though it happens to be the locals > dict for the stack frame, Python can't figure out that it should go > and update the value of the optimized local to match. exec, on the > other hand, compiles and executes an actual STORE_NAME operation. Of > course, if the particular local variable hasn't been optimized by the > compiler, then updating locals() works just fine (although you > probably should not rely on this): > >>>> def f(x, y): > ... locals()[x] = y > ... print locals()[x] > ... exec 'print ' + x > ... >>>> f('a', 42) > 42 > 42 Definitely should rely on it, because in CPython 3 exec does not un-optimize the function and assigning to locals() will not actually change the functions variables. ~Ethan~ From crebert at ucsd.edu Wed Feb 1 17:34:45 2012 From: crebert at ucsd.edu (Chris Rebert) Date: Wed, 1 Feb 2012 14:34:45 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen wrote: > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > ?File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > ?File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > The code looks like this: > > ? ?def run(self, sr): > ? ? ? ?try: > ? ? ? ? ? ?self.initAll() > I am puzzled why Python thinks the class type is wrong, given the output > of inspect.getclasstree. Any ideas on what might be wrong and how to > track it down (and why it would be so intermittent)? What's the offending line of initAll() [#1690 in BaseFocusScript.py] look like? The lines preceding it would also be helpful for context. Cheers, Chris From ian.g.kelly at gmail.com Wed Feb 1 17:38:17 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 15:38:17 -0700 Subject: Question about name scope In-Reply-To: <4F29BB9C.70405@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote: > Definitely should rely on it, because in CPython 3 exec does not un-optimize > the function and assigning to locals() will not actually change the > functions variables. Well, the former is not surprising, since exec was changed from a statement to a built-in. I don't see any difference in the way locals() behaves, though: Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(x, y): ... locals()[x] = y ... print(vars()) ... exec('print(' + x + ')') ... >>> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} 42 That still seems to work as I described it. You couldn't directly reference it as 'a', though, since the result would be either that it would try to look up a global with that name, or the compiler would consider it a local, optimize it, and then you could no longer assign it via locals(). Cheers, Ian From rowen at uw.edu Wed Feb 1 17:50:19 2012 From: rowen at uw.edu (Russell Owen) Date: Wed, 1 Feb 2012 14:50:19 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: <88469DEB-CF59-4C76-91DA-B056D68BAC09@uw.edu> On Feb 1, 2012, at 2:34 PM, Chris Rebert wrote: > On Wed, Feb 1, 2012 at 1:00 PM, Russell E. Owen wrote: >> I have an odd and very intermittent problem in Python script. >> Occasionally it fails with this error: >> >> Traceback (most recent call last): >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 884, in run >> File >> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas >> eFocusScript.py", line 1690, in initAll >> TypeError: unbound method initAll() must be called with BaseFocusScript >> instance as first argument (got ScriptClass instance instead) > >> The code looks like this: >> >> def run(self, sr): >> try: >> self.initAll() > >> I am puzzled why Python thinks the class type is wrong, given the output >> of inspect.getclasstree. Any ideas on what might be wrong and how to >> track it down (and why it would be so intermittent)? > > What's the offending line of initAll() [#1690 in BaseFocusScript.py] > look like? The lines preceding it would also be helpful for context. Here you go. The offending line #169 is marked with *** -- Russell class ImagerFocusScript(BaseFocusScript): """...""" def __init__(self, sr, instName, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, maxFindAmpl = None, doWindow = False, windowOrigin = 1, windowIsInclusive = True, doZeroOverscan = False, helpURL = None, debug = False, ): ... BaseFocusScript.__init__(self, sr = sr, gcamActor = gcamActor, instName = instName, imageViewerTLName = imageViewerTLName, defRadius = defRadius, defBinFactor = defBinFactor, maxFindAmpl = maxFindAmpl, doWindow = doWindow, windowOrigin = windowOrigin, windowIsInclusive = windowIsInclusive, helpURL = helpURL, debug = debug, ) self.doZeroOverscan = bool(doZeroOverscan) .... def initAll(self): """Override the default initAll to record initial bin factor, if relevant """ *** BaseFocusScript.initAll(self) if self.exposeModel.instInfo.numBin > 0: self.finalBinFactor = self.exposeModel.bin.getInd(0)[0] Also, here is BaseFocusScript: class BaseFocusScript(object): """Basic focus script object. This is a virtual base class. The inheritor must: - Provide widgets - Provide a "run" method """ cmd_Find = "find" cmd_Measure = "measure" cmd_Sweep = "sweep" # constants #DefRadius = 5.0 # centroid radius, in arcsec #NewStarRad = 2.0 # amount of star position change to be considered a new star DefFocusNPos = 5 # number of focus positions DefFocusRange = 200 # default focus range around current focus FocusWaitMS = 1000 # time to wait after every focus adjustment (ms) BacklashComp = 0 # amount of backlash compensation, in microns (0 for none) WinSizeMult = 2.5 # window radius = centroid radius * WinSizeMult FocGraphMargin = 5 # margin on graph for x axis limits, in um MaxFocSigmaFac = 0.5 # maximum allowed sigma of best fit focus as a multiple of focus range MinFocusIncr = 10 # minimum focus increment, in um def __init__(self, sr, gcamActor, instName, tccInstPrefix = None, imageViewerTLName = None, defRadius = 5.0, defBinFactor = 1, finalBinFactor = None, canSetStarPos = True, maxFindAmpl = None, doWindow = True, windowOrigin = 0, windowIsInclusive = True, helpURL = None, debug = False, ): """....""" self.sr = sr self.sr.debug = bool(debug) self.gcamActor = gcamActor .... def initAll(self): """Initialize variables, table and graph. """ # initialize shared variables self.doTakeFinalImage = False self.focDir = None self.currBoreXYDeg = None self.begBoreXYDeg = None self.instScale = None self.arcsecPerPixel = None self.instCtr = None self.instLim = None self.cmdMode = None self.focPosToRestore = None self.expTime = None self.absStarPos = None self.relStarPos = None self.binFactor = None self.window = None # LL pixel is 0, UR pixel is included self.enableCmdBtns(False) From ethan at stoneleaf.us Wed Feb 1 17:53:09 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 14:53:09 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4F29C255.1050009@stoneleaf.us> Ian Kelly wrote: > On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote: >> Definitely should rely on it, because in CPython 3 exec does not un-optimize >> the function and assigning to locals() will not actually change the >> functions variables. > > Well, the former is not surprising, since exec was changed from a > statement to a built-in. I don't see any difference in the way > locals() behaves, though: > > Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win > 32 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(x, y): > ... locals()[x] = y > ... print(vars()) > ... exec('print(' + x + ')') > ... >>>> f('a', 42) > {'y': 42, 'x': 'a', 'a': 42} > 42 > > That still seems to work as I described it. You couldn't directly > reference it as 'a', though, since the result would be either that it > would try to look up a global with that name, or the compiler would > consider it a local, optimize it, and then you could no longer assign > it via locals(). > > Cheers, > Ian --> def f(x, y): ... locals()[x] = y ... print(vars()) ... exec('print (' + x + ')') ... print(x) ... --> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} 42 a Indeed -- the point to keep in mind is that locals() can become out of sync with the functions actual variables. Definitely falls in the camp of "if you don't know *exactly* what you are doing, do not play this way!" ~Ethan~ From ian.g.kelly at gmail.com Wed Feb 1 18:00:02 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 16:00:02 -0700 Subject: Question about name scope In-Reply-To: <4F29C255.1050009@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 3:53 PM, Ethan Furman wrote: > --> def f(x, y): > > ... ? ? locals()[x] = y > ... ? ? print(vars()) > ... ? ? exec('print (' + x + ')') > ... ? ? print(x) > ... > --> f('a', 42) > > {'y': 42, 'x': 'a', 'a': 42} > 42 > a > > Indeed -- the point to keep in mind is that locals() can become out of sync > with the functions actual variables. ?Definitely falls in the camp of "if > you don't know *exactly* what you are doing, do not play this way!" Sure, but that's not actually out of sync. The argument of your exec evaluates to 'print (a)'. You get two different results because you're actually printing two different variables. You can get the dict temporarily out of sync: >>> def f(x, y): ... frob = None ... loc = locals() ... loc[x] = y ... print(loc) ... print(locals()) ... print(loc) ... >>> f('frob', 42) {'y': 42, 'x': 'frob', 'frob': 42, 'loc': {...}} {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} In this case, 'frob' is updated to 42 in the dict, but the optimized local is not updated. Calling locals() again refreshes the dict. From ethan at stoneleaf.us Wed Feb 1 18:08:24 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:08:24 -0800 Subject: Question about name scope In-Reply-To: <4F29BB9C.70405@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4F29C5E8.6000504@stoneleaf.us> Ethan Furman wrote: > Ian Kelly wrote: >> I am not a dev, but I believe it works because assigning to locals() >> and assigning via exec are not the same thing. The problem with >> assigning to locals() is that you're fundamentally just setting a >> value in a dictionary, and even though it happens to be the locals >> dict for the stack frame, Python can't figure out that it should go >> and update the value of the optimized local to match. exec, on the >> other hand, compiles and executes an actual STORE_NAME operation. Of >> course, if the particular local variable hasn't been optimized by the >> compiler, then updating locals() works just fine (although you >> probably should not rely on this): >> >>>>> def f(x, y): >> ... locals()[x] = y >> ... print locals()[x] >> ... exec 'print ' + x >> ... >>>>> f('a', 42) >> 42 >> 42 > > Definitely should rely on it, because in CPython 3 exec does not > un-optimize the function and assigning to locals() will not actually > change the functions variables. Ouch, that should have been *not* rely on it; not because it doesn't work (exec uses locals() if one is not specified), but because it is easy for the names in the function to get out of sync with the names in the functions locals() (or __dict__). ~Ethan~ From __peter__ at web.de Wed Feb 1 18:15:01 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Feb 2012 00:15:01 +0100 Subject: Generator problem: parent class not seen References: Message-ID: Russell E. Owen wrote: > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > self=; class hierarchy=[( 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > (,))]] > > The code looks like this: > > def run(self, sr): > try: > self.initAll() > .... > except Exception: > traceback.print_exc(file=sys.stderr) > sys.stderr.write("self=%r; class hierarchy=%s\n" % (self, > inspect.getclasstree([type(self)]))) > raise > > As a detail that may be important: the code is a generator that is being > run by a script runner class (an instance of which is passed into the > run function as argument sr). When the user starts a script the script > runner calls the script's "run" generator. The script runner calls the > run generator again later when conditions are right (e.g. data that is > being waited for arrives, a time limit is reached...). In this case the > failure occurs at the very start of the script, so a yield has not yet > executed. > > I am puzzled why Python thinks the class type is wrong, given the output > of inspect.getclasstree. Any ideas on what might be wrong and how to > track it down (and why it would be so intermittent)? Do you reload()? From arnodel at gmail.com Wed Feb 1 18:35:46 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 1 Feb 2012 23:35:46 +0000 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: On Feb 1, 2012 9:01 PM, "Russell E. Owen" wrote: > > I have an odd and very intermittent problem in Python script. > Occasionally it fails with this error: > > Traceback (most recent call last): > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 884, in run > File > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > eFocusScript.py", line 1690, in initAll > TypeError: unbound method initAll() must be called with BaseFocusScript > instance as first argument (got ScriptClass instance instead) > self=; class hierarchy=[( 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > (,))]] > Looks like you have loaded the same module twice. So you have two versions of your class hierarchies. You can check by printing the ids of your classes. You will get classes with the same name but different ids. Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Wed Feb 1 18:41:59 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:41:59 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> Message-ID: <4F29CDC7.2000104@stoneleaf.us> Ian Kelly wrote: > Sure, but that's not actually out of sync. The argument of your exec > evaluates to 'print (a)'. You get two different results because > you're actually printing two different variables. Ah -- thanks, I missed that. > You can get the dict temporarily out of sync: > >>>> def f(x, y): > ... frob = None > ... loc = locals() > ... loc[x] = y > ... print(loc) > ... print(locals()) > ... print(loc) > ... >>>> f('frob', 42) > {'y': 42, 'x': 'frob', 'frob': 42, 'loc': {...}} > {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 42, 'x': 'frob', 'frob': None, 'loc': {...}} > > In this case, 'frob' is updated to 42 in the dict, but the optimized > local is not updated. Calling locals() again refreshes the dict. I'm not sure what you mean by temporary: --> def f(x, y): ... frob = None ... loc = locals() ... loc[x] = y ... print(loc) ... print(locals()) ... print(loc) ... print(locals()) ... --> --> f('frob', 19) {'y': 19, 'x': 'frob', 'frob': 19} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} Seems to be stuck that way. Here is a better example I was thinking of: --> def f(x, y): ... locals()[x] = y ... locals()['x'] = 17 ... print(locals()) ... print(x) ... print(y) ... --> f('a', 42) {'y': 42, 'x': 'a', 'a': 42} a 42 So locals() was updated with 'a', but not with the assignment to 'x'. And of course, if we tried to 'print(a)' we'd get a NameError. ~Ethan~ From kw at codebykevin.com Wed Feb 1 18:42:08 2012 From: kw at codebykevin.com (Kevin Walzer) Date: Wed, 01 Feb 2012 18:42:08 -0500 Subject: Buffering in Wing and IDLE 3 In-Reply-To: References: Message-ID: On 2/1/12 3:01 PM, Terry Reedy wrote: > On 2/1/2012 10:17 AM, Franck Ditter wrote: > >> I would prefer to use IDLE but as we are in France, the Python team >> does not seem to be aware that the ~ and others are not available >> on MacOS-X here (probably the same in Europe)... > > We are quite aware of the problem but cannot directly do anything about > it as the problem is with tcl/tk and Apple. A couple of days ago, Kevin > Walzer wrote on an IDLE-sig post "I'm currently reviewing an updated > patch to address the problem. When I commit the patch, it will go into > both Tk's trunk and in the Cocoa 8.5 backport, and eventually be > available through ActiveState's distribution." > And it's been committed: http://core.tcl.tk/tk/info/9844fe10b9 --Kevin -- Kevin Walzer Code by Kevin http://www.codebykevin.com From solutions.for.student at gmail.com Wed Feb 1 18:42:48 2012 From: solutions.for.student at gmail.com (solutions for student) Date: Wed, 1 Feb 2012 15:42:48 -0800 (PST) Subject: solutions manual Message-ID: <41f0b5f7-9c50-4a25-b4ce-8a4bb60c40fe@kn4g2000pbc.googlegroups.com> solutions for student solutions(dot)for(dot)student(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on solutions.for.student at hotmail.com From solutions.for.student at gmail.com Wed Feb 1 18:45:35 2012 From: solutions.for.student at gmail.com (solutions for student) Date: Wed, 1 Feb 2012 15:45:35 -0800 (PST) Subject: solutions books Message-ID: solutions for student solutions(dot)for(dot)student(at)hotmail(dot)com We're a team for providing solution manuals to help students in their study. We sell the books in a soft copy, PDF format. We will find any book or solution manual for you. Just email us: s o l u t i o n s . f o r . s t u d e n t @ h o t m a i l . c o m List of some books we have ============================= A Course in Modern Mathematical Physics by Peter Szekeres A First Course in Abstract Algebra By John B. Fraleigh A first course in probability 6th edition by Ross A First Course in String Theory by Barton Zwiebach A Practical Introduction to Data Structures and Algorithm Analysis Second Edition by Clifford A. Shaffer A Quantum Approach to Condensed Matter Physics by Philip L. Taylor A Short Introduction to Quantum Information and Quantum Computation by Michel Le Bellac Accompany Digital Systems Principles and Applications, 10th Edition By Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Accompany Electric Machinery and Power System Fundamentals, First Edition by Stephen J. Chapman Accompany Electronic Devices and Circuit Theory, 8Ed By Robert L. Boylestad; Louis Nashelsky; Franz J. Monseen Accompany Elementary Statistics Ninth Edition by MILTON LOYER Accompany Engineering circuit analysis, 6th edition By Hayt Accompany Foundations of Electromagnetic Theory 2nd Ed. by John R. Reitz, Frederick J. Milford Accompany Fundamentals of Fluid Mechanics, 5th Edition by Bruce R. Munson, Donald F. Young, Theodore H. Okiishi Accompany Introduction to algorithms By Sussman J Accompany Physics for Poets Second Edition By Robert H. March Accompany Principles of geotechnical engineering, sixth edition by braja M. DAS Adaptive Control, 2nd Edition, By Karl Johan Astrom,Bjorn Wittenmark Adaptive filter thoery 4th edition By Simon Haykin Advanced Digital Design with the Verilog HDL by Michael D. Ciletti (Selected problems) Advanced engineering electromagnetics by Constantine A. Balanis Advanced Engineering Mathematics 8 Edition By Erwin Kreyszig Advanced Engineering Mathematics 9 Edition By Erwin Kreyszig Advanced Modern Engineering Mathematics 3rd Edition by Glyn James Aircraft Structures for Engineering Students Fourth Edition by T. H. G. Megson (2007) Algebra and Trigonometry and Precalculus, 3rd Edition by Penna & Bittinger Beecher An introduction to database systems 8th edition By C J Date An Introduction to Ordinary Differential Equations By James C. Robinson (with Matlab files) An Introduction to Signals and Systems By John Stuller An Introduction to The Finite Element Method (Third Edition) By J. N. REDDY Analysis and design of analog integrated circuits 4th edition by Srikanth Vaidianathan and Haoyuee Wang Analytical Mechanics, 7th Edition By Fowles & Cassiday Antenna Theory Analysis and Design, 2nd Edition Balanis Antennas for all Applications 3rd edition by John D. Kraus & Ronald J. Marhefka Anton Calculus 8th edition, Exercises solutions Applied Numerical Analysis 7th Edition By Curtis F. Gerald,Patrick O. Wheatley Applied Partial Differential Equations with Fourier Series and Boundary Value Problems 4th Edition by Richard Haberman Applied Quantum Mechanics by A. F. J. Levi Applied Statistics And Probability For Engineers 3rd edition By Montgomery,Runger Applied Statistics And Probability For Engineers 4th edition By Montgomery,Runger Applied Strength of Materials 4th Edition By Robert L. Mott Artificial Intelligence A ModernApproach 2nd edition by StuartJ. Russelland, Peter Norvig Assembly Language for Intel-Based Computers,3ed, by Kip R. Irvine Automatic Control Systems 8th edition By Kuo and Golnaraghi Basic Electrical Engineering By Nagrath, D P Kothari, Nagrath D P Kothari I J Nagrath, I J Nagrath, 2002 Basic Engineering Circuit Analysis 7th Ed. by J. David Irwin (Selected Problems) Basic Engineering Circuit Analysis 8th Edition By J. David Irwin C++ How to Program, 3rd Ed by Harvey M. Deitel, Paul J. Deitel C++ How to Program, 3rd edition By Deitel & Nieto Calculus 5th Edition By James Stewart Calculus A Complete Course 6th Edition by R.A. Adams Calculus Early Transcendentals 5th Edition By Stewart Calculus early transcendentals 7th edition By Anton Bivens Davis calculus multivariable 4th edition Deborah Hughes-Hallett, Andrew M. Gleason, et al Calculus Single Variable Hughes-Hallett, Gleason, McCallum, et al Chemical and Engineering Thermodynamics 3rd Ed. by Stanley I. Sandler Chemical Enginering Vol 6 4th edition by Coulson and Richardson Classical Dynamics A Contemporary Approach by Jorge V. Jose, Eugene J. Saletan Classical Dynamics of Particles and Systems 5th edition by Stephen T. Thornton, Jerry B. Marion Classical Electrodynamics 2nd Edition by John David Jackson by Kasper van Wijk Classical Mechanics - An Undergraduate Text by R. Douglas Gregory Classical Mechanics 2nd edition By Goldstein & Safko CMOS Digital Integrated Circuits 3rd edition By Sung-Mo Kang,Yusuf Leblebici CMOS VLSI Design 3e by ananymous Communication Networks Fundamental Concepts and Key Architectures Alberto Leon-Garcia Communication Systems 4th ed by bruce carlson Communication Systems 4th edition by Simon Haykin Communication Systems Engineering - Second Edition John G. Proakis Masoud Salehi Computational Techniques for Fluid Dynamics (Scientific Computation) by Karkenahalli Srinivas, Clive A. J. Fletcher Computer Networking A Top-Down Approach 3rd Edition by James F.Kurose,Keith W. Ross Computer Networks - 4th Edition by Andrew S. Tanenbaum Computer Networks A Systems Approach 2nd edition by Peterson and Davie Computer Organization 5th edition by Hamacher,Vranesic and Zaky Computer Organization and Design The HardwareSoftware Interface, 3rd edition by David A. Patterson, John L. Hennessy, Computer-Controlled Systems 3rd edition by Karl J. Astrom Concepts of Programming Languages 7th edition Solutions Manual by Robert Sebesta Control systems Principles and Design 2nd Edition by Madan Gopal Control Systems Engineering 4th edition by Norman S. Nise Corporate Finance solution manual 6th Edition by Ross Cryptography and network security-principles and practice 4th ed. By William Stallings Data and computer communications 7th edition William Stallings Data Communications and Networking 4th edition by Behroz Forouzan Database Management Systems 3rd edition Raghu Ramakrishnan Johannes Gehrke Design of Analog CMOS Integrated Circuits Behzad Razavi Design of Nonlinear Control Systems with the Highest Derivative in Feedback 1st Edition by Valery D. Yurkevich [student solution manual] Design with Operational Amplifiers and Analog Integrated Circuits, 3rd edition by Franco, Sergio Device Electronics for Integrated Circuits 3rd edition by Muller Kamins Differential Equations with Boundary Value Problems 2nd Edition by JOHNPOLKING and DAVID ARNOLD Differential Equations with Boundary Value Problems, 2nd edition by John Polking Digital and Analog Communication Systems 7th Edition by Leon W. Couch Digital Communication 4th edition by Proakis Digital Communications 5th edition by John Proakis Digital Communications Fundamentals and Applications, 2nd Edition by Bernard sklar Digital Control and state variable methods - M.Gopal Digital Design 2nd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 3rd Edition by M. Morris Mano,Michael D. Ciletti Digital Design 4th edition Morris Mano Digital Design-Principles and Practices 3rd Edition by John F. Wakerly [selected problems] Digital Fundamentals 9th edition by Thomas L. Floyd Digital Image Processing 2nd edition by Rafael C. Gonzalez Digital Integrated Circuits 2nd edition by Rabaey Digital Integrated Circuits by Thomas A. DeMassa & Zack Ciccone Digital Logic Design 2nd edition by M. Morris Mano Digital Signal Processing - A Modern Introduction, 1st Edition Cengage learning Ashok Ambardar Digital Signal Processing ; A Computer-Based Approach 1st edition By sanjit K. Mitra Digital Signal Processing 2nd Edition by Mitra Digital Signal Processing 3nd Edition by Mitra Digital Signal Processing 4th edition by John G. Proakis and Dimitri s G. Manolakis Digital Signal Processing by Thomas J. Cavicchi Digital signal processing proakis manolakis Digital Signal Processing Signals, Systems, and Filters Andreas Antoniou Digital Signal Processing Using Matlab 2nd edition by Vinay K Ingle Proakis Digital Systems-Principles and Applications 10th Ed. by Ronald Tocci, Neal S. Widmer & Gregory L. Moss Discrete Mathematics with Applications Third Edition By Susanna S. Epp Discrete Time Signal Processing 2nd Edition, by Alan V. Oppenheim Discrete time signal processing 3rd edition by Oppenheim Econometric Analysis 5th Edition by William H. Greene Electric Circuits 7th edition by Nilsson Electric Circuits 8th edition by Nilsson Electric Machinery 6th Edition by Fitzgerald Kingsley Electric Machinery and Power System Fundamentals 1st edition by Stephen Chapman Electric Machinery Fundamentals 4th edition by Stephen J. Chapman Electric Machines Analysis and Design Applying MATLAB by Jim Cathey Electrical Engineering Principles and Applications 3rd edition by Allan R. Hambley Electrical Machines, Drives and Power Systems 6th edition By Theodore Wildi Electromagnetic Fields and Energy 1st Ed. by Haus and Melcher Electromagnetics for Engineers by Ulaby Electromagnetism Major American Universities Ph.D. Qualifying Questions and Solutions by Lim Yung-Kuo Electronic Circuit Analysis and Design 2nd edition by Donald A. Neamen Electronic devices - electron flow version 4th edition by thomas l.floyd Electronic Devices and Circuit Theory 8th Ed. with Lab Solutions, and Test Item File by Robert Boylestad Electronic Devices-6th Edition by Thomas L. Floyd Electronic Physics by Strabman Elementary Differential Equations 8th edition by Boyce Elementary Differential Equations And Boundary Value Problems, 7Th Edition by Boyce And Diprima Elementary Linear Algebra with Applications 9th by Howard Anton, Chris Rorres Elementary Mechanics and Thermodynamics by Jhon W. Norbury Elementary Number Theory and Its Applications, 5th edition by Kenneth H. Rosen Elementary Number Theory and Its Applications, 6th Ed. By Kenneth H. Rosen Elementary Principles of Chemical Processes 3rd edition by Richard M. Felder,Ronald W. Rousseau Elements of Chemical Reaction Engineering, 3rd Edition by H. Scott Fogler Elements of electromagnetics 2nd edition by sadiku Elements of electromagnetics 3rd edition by sadiku Elements of Power System Analysis 4th edition by William D. Stevenson Embedded Microcomputer Systems Real Time Interfacing 2nd Edition by Jonathan W. Valvano Engineering Circuit Analysis 6th edition by Hayt Engineering Circuit Analysis 7th edition by Hayt Engineering Electromagnetics - 7th Ed. - Hayt Engineering Electromagnetics 2d Edition by Nathan Ida Engineering Electromagnetics 6th Edition by William H. Hayt Jr. and Hohn A. Buck Engineering Fluid Mechanics 7th edition by Clayton T. Crowe, Donald F. Elger & John A. Roberson Engineering Mathematics 4th edition by John Bird Engineering Mathematics 4th Edition by NEWNES Engineering Mechanic STATICS 10th Ed. R.C. Hibbeler Engineering Mechanics - Dynamics 2 Edition by Riley and Sturges Engineering Mechanics - Dynamics 11th edition by R. C. Hibbeler Engineering Mechanics - STATICS 4th E - Bedford and Fowler Engineering mechanics - statics 10th edition by R. C. Hibbeler Engineering mechanics Dynamics 4th Ed. by Bedford and Fowler Engineering Mechanics Dynamics 5th J.L Meriam Engineering Mechanics Statics 6th edition by J.L Meriam Engineering Mechanics Statics 11th Edition By R.C.Hibbeler Feedback Control of Dynamic Systems 4th edition by G. F. Franklin, J. D. Powell, A. Emami Feedback control of dynamic systems 6th edition by G. F. Franklin, J. D. Powell, A. Emami Field and Wave Electromagnetics 2nd Edition by Wesley Cheng Field and Wave Electromagnetics International Edition by David K Fluid Mechanics 1st edition by CENGEL Fluid Mechanics 5th Edition by White Fluid Mechanics With Engineering Applications 10th edition by E. John Finnemore, Joseph B Franzini Fracture mechanics fundamentals and applications 2nd edition by Northam Anderson Fundamental of Electric Circuits 3rd editoin by C. K. Alexander M. N. O. Sadiku Fundamental of engineering electromagnetics by David Cheng Fundamentals of Digital Logic with Verilog Design 1st edition by S. Brown Z. Vranesic Fundamentals of Digital Logic with VHDL Design, 1st edt. by S. Brown, Z. Vranesic Fundamentals of Electric Circuits 2nd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of Electric Circuits, 3rd edition by C. K. Alexander M. N. O. Sadiku Fundamentals of engineering thermodynamics by m. j. moran h. n. shapiro Fundamentals of Fluid mechanics 4th edition by Munson Fundamentals of Fluid Mechanics Student Solutions Manual, 3rd Edition [Student solution manual] Fundamentals of Heat and Mass Transfer 4th edition by Incropera & Dewitt Fundamentals of logic design 5th edition by Charles Roth Fundamentals of Machine Component Design - 3rd edition by Robert C. Juvinall and Kurt M. Marshek Fundamentals of Physics 7th edition by Halliday, Resnick and Walker Fundamentals of physics 8th edition by Halliday, Resnick and Walker Fundamentals of Power Electronics 2nd edition by R.W. Erickson Fundamentals of Power Semiconductor Devices 1st Ed. by B. Jayant Baliga Fundamentals of Signals and systems using web and matlab third edition by Edward W. Kamen, Bonnie S Heck Fundamentals of Solid-State Electronics by Chih-Tang Sah Fundamentals of Thermal Fluid Sciences by Yunus A. Cengel, Robert H. Turner, Yunus Cengel, Robert Turner Fundamentals of Thermodynamics,6th ed, by Richard Sonntag Claus Borgnakke Gordon Van Wylen Fundamentals of Wireless Communication by Tse and Viswanath Heat Transfer A Practical Approach 2nd edition by Yunus A. Cengel, Yunus Cengel How English Works A Grammar Handbook with Readings Instructor's Manual by Ann Raimes Introduction to Algorithms 2nd edition by Philip Bille Introduction to Algorithms 2nd Edition by Thomas H. Cormen Introduction to chemical engineering thermodynamics 6th edition by j. m. smith Introduction to Communication Systems 3rd Edition by Stremler Introduction to Computing and Programming with JAVA-A Multimedia Approach 1st Edition by Mark Guzdial and Barbara Ericson Introduction to electric circuits 6th edition by Dorf Svaboda Introduction to Electric Circuits 7th edition by Richard C. Dorf & James A. Svoboda Introduction to Eletrodynamics 3rd ed By David J. Griffiths Introduction to Environmental Engineering and Science 3rd Edition Introduction to Ergonomics By Robert Bridger Introduction to fluid mechanics 5th edition by fox and mcdonald Introduction to fluid mechanics 6th edition by fox and mcdonald Introduction to Java Programming 7th edition by Y. Daniel Liang Introduction to Linear Algebra 3rd Edition By Gilbert Strang Introduction to Linear Programming 1st Edition by L. N. Vaserstein [student solution manual] Introduction to Probability by Dimitri P. Bertsekas Introduction to Quantum Mechanics (1995) by David J. Griffiths Introduction to Solid State Physics by Charles Kittel Introduction to VLSI Circuits and Systems John P Uyemura Introduction to Wireless Systems by P.M. Shankar IP Telephony Solution guide IT Networking Labs by Tom Cavaiani Java How to Program, 5th Edition By Harvey M. Deitel, Paul J. Deitel Journey into Mathematics An Introduction to Proofs (Book and solution manual) by Joseph J. Rotman KC's Problems and Solutions for Microelectronic Circuits, Fourth Edition by Adel S. Sedra, K. C. Smith, Kenneth C. Smith Labview for engineers 1st edition by R.W. Larsen Linear Algebra and Its Applications by David C. Lay Linear Algebra by Otto Bretscher Linear Algebra with Applications 6th edition by Leon Linear circuit analysis 2nd edition by R. A. DeCarlo and P. Lin Linear dynamic systems and signals by Zoran Gajic with matlab experiments and power point slides Linear Systems And Signals 1st edition by B P Lathi Logic and Computer Design Fundamentals 3rd Edition by Morris Mano & Charles Kime Solutions Logic and Computer Design Fundamentals 4th Edition by Morris Mano Managerial Accounting 11th edition by Eric W. Noreen, Peter C. Brewer, Ray H. Garrison Materials and Processes in Manufacturing 9th edition by E. Paul DeGarmo, Solutions Manual by Barney E. Klamecki Materials Science and Engineering 6th edition by Callister Materials Science and Engineering 7th edition by Callister Materials Science by Milton Ohring Mathematical Methods for Physics and Engineering 3rd Edition by K. F. Riley, M. P. Hobson Mathematical Models in Biology An Introduction by Elizabeth S. Allman, John A. Rhodes Mathematical Olympiad in China Problems and Solutions Mathematical Proofs A Transition to Advanced Mathematics. 2nd Ed By Gary Chartrand, Albert D. Polimeni, Ping Zhang Mathematics for Economists by Carl P. Simon Lawrence Blume MATLAB Programming for Engineers by tephen J. Chapman, Cengage Learning ( m files) Matrix Analysis and Applied Linear Algebra By Carl D. Meyer [Book and solution manual] Mechanical Design of Machine Elements and Machines 1st Edition by Collins Mechanical Engineering Design 7th Edition by Shigley Mechanical Engineering Design 8th edition by Shigley Mechanical Vibrations 3rd edition by Singiresu Rao Mechanics of Fluids 5th Edition by Frank White Mechanics of Fluids 8th edition by Massey Mechanics of Materials 3rd Edition by Beer Mechanics of Materials 4th edition By Hibbeler Chapter 12 mechanics of materials 6th edition by James Gere Mechanics of Materials 6th edition by R. C. Hibbeler Mechanics of Materials 7th edition by R. C. Hibbeler Microelectronic Circuit Design 2nd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd Ed. - Richard C. Jaeger and Travis N. Blalock Microelectronic Circuit Design 3rd edition by R. Jaeger Microelectronic circuits 5th edition by Adel S. Sedra kennethSmith Microelectronics 1 & 2 by Dr. Wen Ching Chang Microprocessors and Interfacing-Programming and Hardware 2nd Edition by Douglas V. Hall Microwave and RF design of wireless systems by Pozar Microwave Engineering 2nd edition by David M Pozar Microwave Engineering 3rd Ed. by David M Pozar Microwave transistor amplifiers analysis and design 2nd edition by Guillermo Gonzalez Millman - Microelectronics digital and analog circuits and systems by Thomas V. Papathomas Mobile Communications 2nd Ed. by Jochen H. Schiller Modern Control Engineering 3rd edition by K. OGATA Modern Control Systems 11th edition by Richard C. Dorf Robert H Bishop Modern Control Systems, 12th Edition By Richard C. Dorf, Robert H. Bishop Modern Digital and Analog Communications Systems 3rd edition by B P Lathi Modern Digital Signal Processing by Roberto Cristi Modern physics By Randy Harris Multivariable Calculus 4th edition by Stewart Dan Clegg Barbara Frank Musculoskeletal Function An Anatomy and Kinesiology Laboratory Manual by Dortha Esch Esch Nanoengineering of Structural, Functional and Smart Materials Network Flows Theory, Algorithms, And Applications by Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin Network Simulation Experiments Manual (The Morgan Kaufmann Series in Networking) by Emad Aboelela Neural networks and learning machines 3rd edition by Simon S. Haykin Nonlinear Programming 2nd Edition by Dimitri P. Bertsekas Numerical Analysis 8th ed. By Richard L. Burden, J Douglas Faires Numerical Methods For Engineers 4th edition by Chapra Numerical Solution of Partial Differential Equations An Introduction by K. W. Morton, D. F. Mayers Operating Systems 4th Edition by Stallings Optimal Control Theory An Introduction By Donald E. Kirk Options, Futures and Other Derivatives 5th Edition by John Hull, John C. Hull Options, Futures and Other Derivatives, 4th Edition by John Hull, John C. Hull Organic chemistry 5th edition by Robert C. Athkins and Francis Carey Organic Chemistry 7th Edition by Susan McMurry Partial Differential Equations With Fourier Series And Boundary Value Problems 2nd Edition By Nakhle H.Asmar Physical Chemistry 7th edition by Peter Atkins and Julio de Paula Physical Chemistry 8th edition by Peter Atkins and Julio de Paula Physical Chemistry by Prem Dhawan Physics 5th Edition by Halliday , Resnick , Krane Physics for Scientist and Engineers 1st edition by Knight Physics for Scientists and Engineers 5th edition by Paul A. Tipler, Gene Mosca Physics For Scientists And Engineers 6th Edition By Serway And Jewett Physics for Scientists and Engineers with Modern Physics 3rd Edition PIC Microcontroller and Embedded Systems 1st edition by Mazidi [Book and solution manual] Piping and Pipeline Calculations Manual Construction, Design Fabrication and Examination by Phillip Ellenberger Power Electronics-Converters, Applications and Design 2nd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power Electronics-Converters, Applications and Design 3rd edition by Ned Mohan, Tore M. Undeland and William P. Robbins Power System Analysis by John Grainger and William Stevenson Power Systems Analysis and Design 4th Edition by Glover J. Duncan, Sarma Mulkutla .S Principles and Applications of Electrical Engineering 2nd Ed. by Giorgio Rizzoni Principles and Applications of Electrical Engineering 4th edition by Giorgio Rizzoni Principles of Communications Systems, Modulation and Noise 5th Edition by William H. Tranter and Rodger E. Ziemer Principles of Digital Communication and Coding 1st edition by Andrew J. Viterbi and Jim K. Omura Principles of Electronic Materials and Devices 3rd edition By Safa O. Kasap Principles of Neurocomputing for Science and Engineering 1st Edition Fredric M. Ham and Ivica Kostanic Principles of Physics 4th edition by Serway and Jewett Probability and Random Processes for Electrical Engineering by Alberto Leon-Garcia Probability and Statistical Inference, Seventh Edition By Robert Hogg, Elliot A. Tanis Probability and Statistics for Engineering and the Sciences by Jay L. Devore Probability and Statistics for Engineers and Scientists , 8th Edition by Sharon Myers , Keying Ye, Walpole Probability and Statistics for Engineers and Scientists 3rd Edition by Anthony Hayter Probability and Statistics for Engineers and Scientists Manual by HAYLER Probability and Stochastic Processes 2nd edition by David J. Goodman Probability Random Variables and Random Signal Principles , 4th Edition , by Peyton Peebles Jr Probability Random Variables And Stochastic Processes 4th edition by Papoulis Process Control Instrumentation Technology, 8th edition by Johnson Process Dynamics and Control 2nd edition by Dale E. Seborg Process systems analysis and control - Donald r. Coughanowr Programmable logic controllers 1st edition by Rehg & Sartori Project Management Casebook by Karen M. Bursic, A. Yaroslav Vlasak Quantum Field Theory Problem Solutions 2007 by Mark Srednick Quantum Physics 3rd Edition by Stephen Gasiorowicz RF circuit Design Theory and Application by Ludwig bretchkol Scientific Computing with Case Studies 1st Edition by Dianne P. O?Leary Semiconductor Device Fundamentals by Robert Pierret Semiconductor Manufacturing Technology 1st Edition by Michael Quirk and Julian Serda Semiconductor Physics and Devices Basic Principles 3rd edition Signal Processing and Linear Systems by B P Lathi Signal Processing First - Mclellan , Schafer and Yoder Signals and Systems 2nd edition Oppenheim Willsky Signals and Systems 2003 by M.J. Roberts Signals and Systems Analysis of Signals Through Linear Systems by M.J. Roberts Signals and Systems, Second Edition by Simon Haykin, Barry Van Veen Signals, Systems and Transforms 4th edition by Phillips, Parr & Riskin Sipser's Introduction to the Theory of Computation By Ching Law Solid State Electronic Device 6th edition by Ben Streetman Solution to Skill - Assessment Exercises to Accompany Control Systems Engineering 3rd edt. by Norman S. Nise Starting Out with Java 5 Lab Manual to Accompany Starting out with Java 5 by Diane Christen Statistical digital signal processing and modeling by monson hayes Statistical Physics of Fields by Mehran Kardar statistical physics of particles by Mehran Kardar Structural analysis 5th edition by Hibbeler Student Solution Manual for Essential Mathematical Methods for the Physical Sciences by K. F. Riley, M. P. Hobson System Dynamics 3rd Ed. by Katsuhiko Ogata System Dynamics and Response , 1st Edition by S. Graham Kelly The 8051 Microcontroller 4th Ed. by I. Scott MacKenzie and Raphael C.- W. Phan The 8088 and 8086 Microprocessors Programming, Interfacing, Software, Hardware, and Applications (4th Edition) By Walter A. Triebel, Avtar Singh The ARRL Instructor's Manual for Technician and General License Courses By American Radio Relay League The Art of Electronics by Thomas C. Hayes & Paul Horowitz [student solution manual] The C++ Programming Language , Special 3rd Edition , by Bjarne Stroustrup The Calculus 7 by Louis Leithold The Language of Machines, An Introduction to Computability and Formal Languages by Robert W. Floyd, Richard Beigel The Science and Engineering of Materials 4th edition by Donald R. Askeland Frank Haddleton The Structure and Interpretation of Signals and Systems 1st Edition by Edward A. Lee and Pravin Varaiya Thermodynamics An Engineering Approach 5th edition by Yunus A Cengel and Michael A Boles Thermodynamics An Engineering Approach 6th edition by Yunus A Cengel and Michael A Boles Thomas Calculus 11th edition by George B.Thomas Thomas Calculus 12th edition by George B.Thomas Thomas' Calculus, Eleventh Edition (Thomas Series) By George B. Thomas, Maurice D. Weir, Joel D. Hass, Frank R. Giordano Transport Phenomena 2nd edition by Bird, Stewart and Lightfoot Transport Phenomena in Biological Systems 2nd Edition By George A. Truskey, Fan Yuan, David F. Katz Unit operations of chemical engineering 7th edition by Warren l. Mccabe University physics 11th edition by Young and Freedman Vector Calculus , Linear Algebra and Differential Forms 2nd Edition by Hubbard and Burke Vector Mechanics for Engineers , Dynamics 6th edition by Beer Vector Mechanics for Engineers Dynamics 7th Edition by Beer Vector Mechanics for Engineers Statics and Dynamics 8th edition by Beer Vector Mechanics Statics 7th Edition by Beer and Johnston VHDL for Engineers International Edition by Kenneth L. Short Wireless Communications 1st Ed. by A. F. Molisch Wireless Communications 1st Ed. by Andrea Goldsmith Wireless Communications Principles and Practice 2nd Edition - Theodore S. Rappaport Zill's a First Course in Differential Equations with Modeling Applications (7th ed.) and Zill & Cullen's Diferential Equations with Boundary-Value Problems (5th ed.) ==================================== If your request isn't in the list , we will find it for you, just contact us on solutions.for.student at hotmail.com From ian.g.kelly at gmail.com Wed Feb 1 18:47:53 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 1 Feb 2012 16:47:53 -0700 Subject: Question about name scope In-Reply-To: <4F29CDC7.2000104@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> <4F29CDC7.2000104@stoneleaf.us> Message-ID: On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote: > I'm not sure what you mean by temporary: > > --> def f(x, y): > > ... ? ? frob = None > ... ? ? loc = locals() > ... ? ? loc[x] = y > ... ? ? print(loc) > ... ? ? print(locals()) > ... ? ? print(loc) > ... ? ? print(locals()) > ... > --> > --> f('frob', 19) > {'y': 19, 'x': 'frob', 'frob': 19} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} > > Seems to be stuck that way. The first print is the one that is incorrect. It suggests that the local 'frob' has been changed to 19 as it has in the dict, but the actual value of the local is still None. The second print on accurately reflect that. From ethan at stoneleaf.us Wed Feb 1 18:51:20 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:51:20 -0800 Subject: Question about name scope In-Reply-To: <4F29C5E8.6000504@stoneleaf.us> References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C5E8.6000504@stoneleaf.us> Message-ID: <4F29CFF8.6090502@stoneleaf.us> Ethan Furman wrote: > Ethan Furman wrote: >> Ian Kelly wrote: >>> I am not a dev, but I believe it works because assigning to locals() >>> and assigning via exec are not the same thing. The problem with >>> assigning to locals() is that you're fundamentally just setting a >>> value in a dictionary, and even though it happens to be the locals >>> dict for the stack frame, Python can't figure out that it should go >>> and update the value of the optimized local to match. exec, on the >>> other hand, compiles and executes an actual STORE_NAME operation. Of >>> course, if the particular local variable hasn't been optimized by the >>> compiler, then updating locals() works just fine (although you >>> probably should not rely on this): >>> >>>>>> def f(x, y): >>> ... locals()[x] = y >>> ... print locals()[x] >>> ... exec 'print ' + x >>> ... >>>>>> f('a', 42) >>> 42 >>> 42 >> >> Definitely should rely on it, because in CPython 3 exec does not >> un-optimize the function and assigning to locals() will not actually >> change the functions variables. > > > Ouch, that should have been *not* rely on it; not because it doesn't > work (exec uses locals() if one is not specified), but because it is > easy for the names in the function to get out of sync with the names in > the functions locals() (or __dict__). I should stop answering now :( Ignore the __dict__ comment, it is incorrect. ~Ethan~ From ethan at stoneleaf.us Wed Feb 1 18:59:37 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 01 Feb 2012 15:59:37 -0800 Subject: Question about name scope In-Reply-To: References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> <4F29C255.1050009@stoneleaf.us> <4F29CDC7.2000104@stoneleaf.us> Message-ID: <4F29D1E9.7050304@stoneleaf.us> Ian Kelly wrote: > On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote: >> I'm not sure what you mean by temporary: >> >> --> def f(x, y): >> >> ... frob = None >> ... loc = locals() >> ... loc[x] = y >> ... print(loc) >> ... print(locals()) >> ... print(loc) >> ... print(locals()) >> ... >> --> >> --> f('frob', 19) >> {'y': 19, 'x': 'frob', 'frob': 19} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> {'y': 19, 'x': 'frob', 'frob': None, 'loc': {...}} >> >> Seems to be stuck that way. > > The first print is the one that is incorrect. It suggests that the > local 'frob' has been changed to 19 as it has in the dict, but the > actual value of the local is still None. The second print on > accurately reflect that. Ah. Thanks for the explanations. ~Ethan~ From rowen at uw.edu Wed Feb 1 19:19:51 2012 From: rowen at uw.edu (Russell Owen) Date: Wed, 1 Feb 2012 16:19:51 -0800 Subject: Generator problem: parent class not seen In-Reply-To: References: Message-ID: <2E3D1C43-6C0F-4A2D-9D90-6C5BD1B61D64@uw.edu> On Feb 1, 2012, at 3:35 PM, Arnaud Delobelle wrote: > On Feb 1, 2012 9:01 PM, "Russell E. Owen" wrote: > > > > I have an odd and very intermittent problem in Python script. > > Occasionally it fails with this error: > > > > Traceback (most recent call last): > > File > > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > > eFocusScript.py", line 884, in run > > File > > "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas > > eFocusScript.py", line 1690, in initAll > > TypeError: unbound method initAll() must be called with BaseFocusScript > > instance as first argument (got ScriptClass instance instead) > > self=; class hierarchy=[( > 'TUI.Base.BaseFocusScript.ImagerFocusScript'>, ( > 'TUI.Base.BaseFocusScript.BaseFocusScript'>,)), [(, > > (,))]] > > > > Looks like you have loaded the same module twice. So you have two versions of your class hierarchies. You can check by printing the ids of your classes. You will get classes with the same name but different ids. > > Arnaud > Yes! I was reloading BaseFocusScript. Oops. In detail: script files are dynamically loaded when first requested and can be reloaded for debugging. I think that's safe because script files are self-contained (e.g. the classes in them are never subclassed or anything like that). But I went too far: I had my focus scripts reload BaseFocusScript, which is shared code, so that I could tweak BaseFocusScript while debugging focus scripts. Thank you very much! -- Russell -------------- next part -------------- An HTML attachment was scrubbed... URL: From skippy.hammond at gmail.com Wed Feb 1 19:28:12 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Thu, 02 Feb 2012 11:28:12 +1100 Subject: Registry entries set up by the Windows installer In-Reply-To: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> References: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> Message-ID: <4F29D89C.30708@gmail.com> On 2/02/2012 2:09 AM, Paul Moore wrote: > I'm trying to get information on what registry entries are set up by > the Python Windows installer, and what variations exist. I don't know > enough about MSI to easily read the source, so I'm hoping someone who > knows can help :-) > > As far as I can see on my PC, the installer puts entries > > HKLM\Software\Python\PythonCore\x.y > > with various bits underneath. I think I've seen indications that > sometimes these are in HKCU, presumably for a "per user" install? If I > manually hack around in the registry, and have both HKLM and HKCU, > which one will Python use? For setting PYTHONPATH it uses both - HKEY_CURRENT_USER is added before HKEY_LOCAL_MACHINE. I can't recall which one distutils generated (bdist_wininst) installers will use - it may even offer the choice. > Furthermore, more of a Windows question than Python, but there's a > similar question with regard to the .py and .pyw file associations - > they can be in HKLM\Software\Classes or HKCU\Software\Classes. Which > takes precedence? No idea I'm afraid, but I'd expect it to use HKCU > I assume that the installer writes to HKLM for all > users and HKCU for per-user installs. Yep, I think that is correct. > Is there anything else I've missed? I'm also not sure which one the pylauncher project will prefer, which may become relevant should that get rolled into Python itself. > The reason I ask, is that I'm starting to work with virtualenv, and I > want to see what would be involved in (re-)setting the registry > entries to match the currently active virtualenv. virtualenvwrapper- > powershell seems to only deal with HKCU (which is a big plus on > Windows 7, as it avoids endless elevation requests :-)) but that > doesn't work completely cleanly with my all-users install. (Note: I'm > not entirely sure that changing global settings like this to patch a > per-console virtualenv is a good idea, but I'd like to know how hard > it is before dismissing it...) Out of interest, what is the reason forcing you to look at that - bdist_wininst installers? FWIW, my encounters with virtualenv haven't forced me to hack the registry - I just install bdist_wininst packages into the "parent" Python which isn't ideal but works fine for me. This was a year or so ago, so the world might have changed since then. Mark From steve+comp.lang.python at pearwood.info Wed Feb 1 19:32:42 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:32:42 GMT Subject: TypeError References: Message-ID: <4f29d9a9$0$29989$c3e8da3$5496439d@news.astraweb.com> Hello Katie, When posting to technical news groups like this, can you please send plain text emails rather than so-called "rich text" (actually HTML code) email? Or at least, don't use Microsoft Word as your email editor. Many people will be reading your posts using text applications and will see line after line of very bad HTML like this: >

Hello,

class="MsoNormal"> 

I am new to > python and am trying to correct the follow error:

class="MsoNormal"> 

class="MsoNormal">TypeError: sequence item 1: expected string, > NoneType found

[...] and that's the sort of thing that makes programmers grumpy and less inclined to help. To answer your question: On Wed, 01 Feb 2012 16:53:41 +0000, Clark, Kathleen wrote: > I am new to python and am trying to correct the follow error: > > TypeError: sequence item 1: expected string, NoneType found It is best, if possible, to post the entire traceback starting with the line "Traceback (most recent call last)" rather than just the last line. In this case, the error is simple enough to work out that it may not matter, but in general it often does matter. > The error message is referencing line 86 of my code: > > ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) In this case, one of the variables fn, ln and sdob is None instead of a string. > If I'm understanding this correctly, the code is expecting a string, but > not finding it. I'm wondering, what is meant by a "string" and also how > I can figure out the problem and correct it. If you are new enough to programming that you need to ask what is a string, you might find the Python tutor mailing list a more useful place than here. http://mail.python.org/mailman/listinfo/tutor "String" is short for "string of characters", that is, text, and in Python strings are created with quotation marks or the str() function. So: a = "this is a string" b = 'so is this' c = str(some_variable) # and so is this To fix the problem, there is a quick and dirty way, and the proper way. The quick and dirty way is to just force all items in the list to be strings, regardless of what they currently are. Your line: ws.cell(row=row, column=1).value = ','.join([str(ino), fn, ln, sdob]) becomes: ws.cell(row=row, column=1).value = ','.join( [str(ino), str(fn), str(ln), str(sdob)]) While this might work, the fact that one or more of fn, ln and sdob is None may be a bug in your code, and converting to a string may very well just obscure the source of the bug and make it harder to solve in the long run. So the proper way to fix the problem is: (1) Identify which variable is not a string. (2) Find out why it becomes set to None. (3) Fix it. The first part is easy: insert this line before line 86: print("fn, ln, sdob:", fn, ln, sdob) and see what it says. Fixing it means working backwards from that point, finding out where the variable gets set to None, and fixing that bug. Good luck! -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 1 19:34:56 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:34:56 GMT Subject: Question about name scope References: <20120201181117.5d35dddc@bigfoot.com> <4F29BB9C.70405@stoneleaf.us> Message-ID: <4f29da30$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 14:53:09 -0800, Ethan Furman wrote: > Indeed -- the point to keep in mind is that locals() can become out of > sync with the functions actual variables. Definitely falls in the camp > of "if you don't know *exactly* what you are doing, do not play this > way!" And if you *do* know exactly what you are doing, you will probably decide not to play this way also! -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 1 19:51:34 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 00:51:34 GMT Subject: changing sys.path References: <4F296509.60607@gmail.com> Message-ID: <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > Yes they are exactly the same, because in that file I just write exactly > the same list, > but when modifying it at run-time it doesn't work, while if at the > application start > there is this file everything works correctly... > > That's what really puzzles me.. What could that be then? Are you using IDLE or WingIDE or some other IDE which may not be honouring sys.path? If so, that's a BAD bug in the IDE. Are you changing the working directory manually, by calling os.chdir? If so, that could be interfering with the import somehow. It shouldn't, but you never know... Are you adding absolute paths or relative paths? You say that you get an ImportError, but that covers a lot of things going wrong. Here's a story. Could it be correct? I can't tell because you haven't posted the traceback. When you set site-packages/my_paths.pth you get a sys path that looks like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" which locates b/spam.py and everything works. But when you call sys.path.extend(['a', 'b']) you get a path that looks like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't import, and you get an ImportError. -- Steven From dg.gmane at thesamovar.net Wed Feb 1 20:14:20 2012 From: dg.gmane at thesamovar.net (Dan Goodman) Date: Thu, 02 Feb 2012 02:14:20 +0100 Subject: simple system for building packages for multiple platforms? Message-ID: Hi all, Until recently, our package has been pure Python, so distributing it has been straightforward. Now, however, we want to add some extension modules in C++. We're happy to provide source only distributions on Linux because almost all Linux users will have all the required compilers and so forth already installed. But we also want to support Windows users who may not have C++ compilers available, which means providing built distributions. But, we're faced with this problem, there are three versions of Python we're supporting (2.5-2.7) and two architectures (32 and 64 bit), which means 6 possible platforms to build for (and maybe more in future if we upgrade to Python 3). Is there a straightforward way to set up a semi-automated build system for this? At the moment, I'm thinking about either having a bunch of virtual machines or Amazon EC2 instances and submitting build jobs to these, but setting that up looks to be a lot of work and I guess many people have had this problem before. So, what do other people do? Also, once we have a build system up, I guess it can also be used for a more extensive testing system on these multiple platforms? Dan From research at johnohagan.com Wed Feb 1 22:18:12 2012 From: research at johnohagan.com (John O'Hagan) Date: Thu, 2 Feb 2012 14:18:12 +1100 Subject: copy on write In-Reply-To: <4F107AAF.5000600@stoneleaf.us> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> Message-ID: <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> On Fri, 13 Jan 2012 10:40:47 -0800 Ethan Furman wrote: > Steven D'Aprano wrote: > > Normally this is harmless, but there is one interesting little > > glitch you can get: > > > >>>> t = ('a', [23]) > >>>> t[1] += [42] > > Traceback (most recent call last): > > File "", line 1, in > > TypeError: 'tuple' object does not support item assignment > >>>> t > > ('a', [23, 42]) IMHO, this is worthy of bug-hood: shouldn't we be able to conclude from the TypeError that the assignment failed? > There is one other glitch, and possibly my only complaint: > > --> a = [1, 2, 3] > --> b = 'hello, world' > --> a = a + b > Traceback (most recent call last): > File "", line 1, in > TypeError: can only concatenate list (not "str") to list > --> a += b > --> a > [1, 2, 3, 'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] > > IMO, either both + and += should succeed, or both should fail. > > ~Ethan~ This also happens for tuples, sets, generators and range objects (probably any iterable), AFAIK only when the left operand is a list. Do lists get special treatment in terms of implicitly converting the right-hand operand? The behaviour of the "in-place" operator could be more consistent across types: >>> a=[1,2] >>> a+=(3,4) >>> a [1, 2, 3, 4] >>> a=(1,2) >>> a+=(3,4) >>> a (1, 2, 3, 4) >>> a=(1,2) >>> a+=[3,4] Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate tuple (not "list") to tuple John From rantingrickjohnson at gmail.com Wed Feb 1 22:51:13 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 1 Feb 2012 19:51:13 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jan 13, 10:48?am, Devin Jeanpierre wrote: > On Fri, Jan 13, 2012 at 10:13 AM, Grant Edwards wrote: > > On 2012-01-13, Devin Jeanpierre wrote: > >> On Fri, Jan 13, 2012 at 7:30 AM, Chris Angelico wrote: > There's a bit of a feeling > that code should "do what it looks like" and be sort of understandable > without exactly understanding everything. Yeah there's a word for that; INTUITIVE, And I've been preaching its virtues (sadly in vain it seems!) to these folks for some time now. From steve+comp.lang.python at pearwood.info Thu Feb 2 00:31:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 05:31:03 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2a1f96$0$29895$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 19:51:13 -0800, Rick Johnson wrote: > Yeah there's a word for that; INTUITIVE, And I've been preaching its > virtues (sadly in vain it seems!) to these folks for some time now. Intuitive to whom? Expert Python programmers? VB coders? Perl hackers? School children who have never programmed before? Mathematicians? Babies? Rocket scientists? Hunter-gatherers from the Kalahari desert? My intuition tells me you have never even considered that intuition depends on who is doing the intuiting. -- Steven From jeanpierreda at gmail.com Thu Feb 2 01:34:48 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 01:34:48 -0500 Subject: copy on write In-Reply-To: <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: On Wed, Feb 1, 2012 at 10:18 PM, John O'Hagan wrote: > On Fri, 13 Jan 2012 10:40:47 -0800 > Ethan Furman wrote: > >> Steven D'Aprano wrote: >> > Normally this is harmless, but there is one interesting little >> > glitch you can get: >> > >> >>>> t = ('a', [23]) >> >>>> t[1] += [42] >> > Traceback (most recent call last): >> > ? File "", line 1, in >> > TypeError: 'tuple' object does not support item assignment >> >>>> t >> > ('a', [23, 42]) > > IMHO, this is worthy of bug-hood: shouldn't we be able to conclude from the TypeError that the assignment failed? It did fail. The mutation did not. I can't think of any way out of this misleadingness, although if you can that would be pretty awesome. -- Devin From jeanpierreda at gmail.com Thu Feb 2 01:42:54 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 01:42:54 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: > And it bothers me that you imput such ignorance to me. You made what I think > was a bad analogy and I made a better one of the same type, though still > imperfect. I acknowledged that the transition will take years. Ah. It is a common attitude among those that make these sorts of comments about Python 3, and I hadn't read anything in what you said that made me think that you were considering more than the superficial costs of moving. I am sorry that I did not give you the benefit of the doubt. -- Devin From stefan_ml at behnel.de Thu Feb 2 02:02:06 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 02 Feb 2012 08:02:06 +0100 Subject: xhtml encoding question In-Reply-To: References: Message-ID: Tim Arnold, 01.02.2012 19:15: > On 2/1/2012 3:26 AM, Stefan Behnel wrote: >> Tim Arnold, 31.01.2012 19:09: >>> I have to follow a specification for producing xhtml files. >>> The original files are in cp1252 encoding and I must reencode them to >>> utf-8. >>> Also, I have to replace certain characters with html entities. >>> --------------------------------- >>> import codecs, StringIO >>> from lxml import etree >>> high_chars = { >>> 0x2014:'—', # 'EM DASH', >>> 0x2013:'–', # 'EN DASH', >>> 0x0160:'Š',# 'LATIN CAPITAL LETTER S WITH CARON', >>> 0x201d:'”', # 'RIGHT DOUBLE QUOTATION MARK', >>> 0x201c:'“', # 'LEFT DOUBLE QUOTATION MARK', >>> 0x2019:"’", # 'RIGHT SINGLE QUOTATION MARK', >>> 0x2018:"‘", # 'LEFT SINGLE QUOTATION MARK', >>> 0x2122:'™', # 'TRADE MARK SIGN', >>> 0x00A9:'©', # 'COPYRIGHT SYMBOL', >>> } >>> def translate(string): >>> s = '' >>> for c in string: >>> if ord(c) in high_chars: >>> c = high_chars.get(ord(c)) >>> s += c >>> return s >> >> I hope you are aware that this is about the slowest possible algorithm >> (well, the slowest one that doesn't do anything unnecessary). Since none of >> this is required when parsing or generating XHTML, I assume your spec tells >> you that you should do these replacements? > > I wasn't aware of it, but I am now--code's embarassing now. > The spec I must follow forces me to do the translation. > > I am actually working with html not xhtml; which makes a huge difference, We all learn. > Ulrich's line of code for translate is elegant. > for c in string: > s += high_chars.get(c,c) Still not efficient because it builds the string one character at a time and needs to reallocate (and potentially copy) the string buffer quite frequently in order to do that. You are lucky with CPython, because it has an internal optimisation that mitigates this overhead on some platforms. Other Python implementations don't have that, and even the optimisation in CPython is platform specific (works well on Linux, for example). Peter Otten presented the a better way of doing it. > From the all the info I've received on this thread, plus some additional > reading, I think I need the following code. > > Use the HTMLParser because the source files are actually HTML, and use > output from etree.tostring() as input to translate() as the very last step. > > def reencode(filename, in_encoding='cp1252', out_encoding='utf-8'): > parser = etree.HTMLParser(encoding=in_encoding) > tree = etree.parse(filename, parser) > result = etree.tostring(tree.getroot(), method='html', > pretty_print=True, > encoding=out_encoding) > with open(filename, 'wb') as f: > f.write(translate(result)) > > not simply tree.write(f...) because I have to do the translation at the > end, so I get the entities instead of the resolved entities from lxml. Yes, that's better. Still one thing (since you didn't show us your final translate() function): you do the character escaping on a UTF-8 encoded string and made the encoding configurable. That means that the characters you are looking for must also be encoded with the same encoding in order to find matches. However, if you ever choose a different target encoding that doesn't have the nice properties of UTF-8's byte sequences, you may end up with ambiguous byte sequences in the output that your translate() function accidentally matches on, thus potentially corrupting your data. Assuming that you are using Python 2, you may even be accidentally doing the replacement using Unicode character strings, which then only happens to work on systems that use UTF-8 as their default encoding. Python 3 has fixed this trap, but you have to take care to avoid it in Python 2. I'd prefer serialising the documents into a unicode string (encoding='unicode'), then post-processing that and finally encoding it to the target encoding when writing it out. But you'll have to see how that works out together with your escaping step, and also how it impacts the HTML tag that states the document encoding. Stefan From r.grimm at science-computing.de Thu Feb 2 02:19:57 2012 From: r.grimm at science-computing.de (Rainer Grimm) Date: Wed, 1 Feb 2012 23:19:57 -0800 (PST) Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> Message-ID: <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> You can do it more concise. >>> def isListOrString(p): ... return any((isinstance(p,list),isinstance(p,str))) ... >>> listOrString("string") True >>> listOrString([1,2,3]) True >>> listOrString(2) False >>> listOrString(False) False Rainer From r.grimm at science-computing.de Thu Feb 2 02:19:57 2012 From: r.grimm at science-computing.de (Rainer Grimm) Date: Wed, 1 Feb 2012 23:19:57 -0800 (PST) Subject: How can I verify if the content of a variable is a list or a string? In-Reply-To: References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> Message-ID: <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> You can do it more concise. >>> def isListOrString(p): ... return any((isinstance(p,list),isinstance(p,str))) ... >>> listOrString("string") True >>> listOrString([1,2,3]) True >>> listOrString(2) False >>> listOrString(False) False Rainer From p_s_d_a_s_i_l_v_a at netcabo.pt Thu Feb 2 02:23:04 2012 From: p_s_d_a_s_i_l_v_a at netcabo.pt (Paulo da Silva) Date: Thu, 02 Feb 2012 07:23:04 +0000 Subject: Iterate from 2nd element of a huge list References: Message-ID: Em 01-02-2012 04:55, Cameron Simpson escreveu: > On 01Feb2012 03:34, Paulo da Silva wrote: > | BTW, iter seems faster than iterating thru mylist[1:]! > > I would hope the difference can be attributed to the cost of copying > mylist[1:]. I don't think so. I tried several times and the differences were almost always consistent. I put mylist1=mylist[1:] outside the time control. iter still seems a little bit faster. Running both programs several times (10000000 elements list) I only got iter being slower once! But, of course, most of the difference comes from the copy. From void.of.time at gmail.com Thu Feb 2 02:25:36 2012 From: void.of.time at gmail.com (oleg korenevich) Date: Wed, 1 Feb 2012 23:25:36 -0800 (PST) Subject: python reliability with EINTR handling in general modules References: Message-ID: On Feb 1, 6:07?pm, Dennis Lee Bieber wrote: > On Wed, 1 Feb 2012 06:15:22 -0800 (PST), oleg korenevich > > > > > > > > > > wrote: > >I have linux board on samsung SoC s3c6410 (ARM11). I build rootfs with > >buildroot: Python 2.7.1, uClibc-0.9.31. Linux kernel: Linux buildroot > >2.6.28.6 #177 Mon Oct 3 12:50:57 EEST 2011 armv6l GNU/Linux > > >My app, written on python, in some mysterios conditons raise this > >exceptions: > > >1) exception: > > > File "./dfbUtils.py", line 3209, in setItemData > >ValueError: (4, 'Interrupted system call') > >code: > > >currentPage=int(math.floor(float(rowId)/ > >self.pageSize))==self.selectedPage > >2) exception: > > >File "./terminalGlobals.py", line 943, in getFirmawareName > >OSError: [Errno 4] Interrupted system call: 'firmware' > >code: > > >for fileName in os.listdir('firmware'): > >Some info about app: it have 3-7 threads, listen serial ports via > >'serial' module, use gui implemented via c extension that wrap > >directfb, i can't reproduce this exceptions, they are not predictable. > > >I googled for EINTR exceptions in python, but only found that EINTR > >can occur only on slow system calls and python's modules socket, > >subprocess and another one is already process EINTR. So what happens > >in my app? Why simple call of math function can interrupt program at > >any time, it's not reliable at all. I have only suggestions: ulibc > >bug, kernel/hw handling bug. But this suggestions don't show me > >solution. > > ? ? ? ? I see nothing in your traceback that indicates that the interrupt > occurred in the math library call -- unless you deleted that line. In > the first one, I'd be more likely to suspect your C extension/wrapper... > (are the fields .pageSize and .selectedPage coming from an object > implemented in C?) > > ? ? ? ? As for the math stuff... I presume both rowID and .pageSize are > constrained to be 0 or positive integers. If that is the case, invoking > math.floor() is just redundant overhead as the documented behavior of > int() is to truncate towards 0, which for a positive value, is the same > as floor() > > > > >>> neg = -3.141592654 > >>> pos = 3.141592654 > >>> int(neg) > -3 > >>> math.floor(neg) > -4.0 > >>> int(pos) > 3 > >>> math.floor(pos) > 3.0 > > ? ? ? ? In the second case... Well, os.listdir() is most likely translated > into some operating system call. > > http://www.gnu.org/software/libc/manual/html_node/Interrupted-Primiti... > > And, while that call is waiting for I/O to complete, some sort of signal > is being received. > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ Thanks for help. In first case all vars is python integers, maybe math.floor is redundant, but i'm afraid that same error with math module call will occur in other places of app, where math is needed. Strange thing here is that math library call is not a system call, and strange exception ValueError (all values have right values) and why in braces i have (4, Interruted system call). For second case: if python really does some slow system call from module os, why it doesn't handle EINTR and not restart call. Is SA_RESTART flag in signal can be solution? But how i can set this flag? By placing flag for signal handler in c extension (or ctypes manipulation)? From steve+comp.lang.python at pearwood.info Thu Feb 2 02:31:16 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 07:31:16 GMT Subject: How can I verify if the content of a variable is a list or a string? References: <1328057052.56088.YahooMailNeo@web30601.mail.mud.yahoo.com> <8416844.281.1328167197216.JavaMail.geo-discussion-forums@vby1> Message-ID: <4f2a3bc4$0$29895$c3e8da3$5496439d@news.astraweb.com> On Wed, 01 Feb 2012 23:19:57 -0800, Rainer Grimm wrote: > You can do it more concise. > >>>> def isListOrString(p): > ... return any((isinstance(p,list),isinstance(p,str))) Or even more concisely still: isinstance(p, (list, str)) -- Steven From steve+comp.lang.python at pearwood.info Thu Feb 2 02:38:53 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 07:38:53 GMT Subject: Iterate from 2nd element of a huge list References: Message-ID: <4f2a3d8d$0$29895$c3e8da3$5496439d@news.astraweb.com> On Thu, 02 Feb 2012 07:23:04 +0000, Paulo da Silva wrote: > Em 01-02-2012 04:55, Cameron Simpson escreveu: >> On 01Feb2012 03:34, Paulo da Silva >> wrote: > >> | BTW, iter seems faster than iterating thru mylist[1:]! >> >> I would hope the difference can be attributed to the cost of copying >> mylist[1:]. > I don't think so. I tried several times and the differences were almost > always consistent. Yes, actually iterating over a list-iterator appears to be trivially faster (although this may not apply to arbitrary iterators): steve at runes:~$ python -m timeit -s "L=range(10000)" "for x in L: pass" 1000 loops, best of 3: 280 usec per loop steve at runes:~$ python -m timeit -s "L=range(10000)" "for x in iter(L): pass" 1000 loops, best of 3: 274 usec per loop The difference of 6 microseconds would be lost in the noise if the loops actually did something useful. Also keep in mind that for tiny lists, the overhead of creating the iterator is probably much greater than the time of iterating over the list: steve at runes:~$ python -m timeit -s "L=range(3)" "for x in L: pass" 1000000 loops, best of 3: 0.238 usec per loop steve at runes:~$ python -m timeit -s "L=range(3)" "for x in iter(L): pass" 1000000 loops, best of 3: 0.393 usec per loop But of course the difference is only relatively significant, in absolute terms nobody is going to notice an extra 0.1 or 0.2 microseconds. -- Steven From p.f.moore at gmail.com Thu Feb 2 03:09:55 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:09:55 +0000 Subject: Registry entries set up by the Windows installer In-Reply-To: <4F29D89C.30708@gmail.com> References: <85db953e-15fe-43ad-b128-7437dde7e7b3@m2g2000vbc.googlegroups.com> <4F29D89C.30708@gmail.com> Message-ID: On 2 February 2012 00:28, Mark Hammond wrote: > For setting PYTHONPATH it uses both - HKEY_CURRENT_USER is added before > HKEY_LOCAL_MACHINE. ?I can't recall which one distutils generated > (bdist_wininst) installers will use - it may even offer the choice. [...] > Yep, I think that is correct. Thanks for the information. >> Is there anything else I've missed? > > I'm also not sure which one the pylauncher project will prefer, which may > become relevant should that get rolled into Python itself. Good point - I can look in the source for that, if I need to. >> The reason I ask, is that I'm starting to work with virtualenv, and I >> want to see what would be involved in (re-)setting the registry >> entries to match the currently active virtualenv. virtualenvwrapper- >> powershell seems to only deal with HKCU (which is a big plus on >> Windows 7, as it avoids endless elevation requests :-)) but that >> doesn't work completely cleanly with my all-users install. (Note: I'm >> not entirely sure that changing global settings like this to patch a >> per-console virtualenv is a good idea, but I'd like to know how hard >> it is before dismissing it...) > > > Out of interest, what is the reason forcing you to look at that - > bdist_wininst installers? ?FWIW, my encounters with virtualenv haven't > forced me to hack the registry - I just install bdist_wininst packages into > the "parent" Python which isn't ideal but works fine for me. ?This was a > year or so ago, so the world might have changed since then. It's bdist_msi.rather than bdist_wininst. I want to avoid putting packages into the "main" Python - at least, from my limited experiments the virtual environment doesn't see them (I may be wrong about this, I only did a very limited test and I want to do some more detailed testing before I decide). For bdist_wininst packages, I can install using easy_install - this will unpack and install bdist_wininst installers. (I don't actually like easy_install that much, but if it works...). But easy_install won't deal with MSI installers, and you can't force them to install in an unregistered Python. The only way I can think of is to do an "admin install" to unpack them, and put the various bits in place manually... The other reason for changing the registry is the .py file associations. But as I said, I'm not yet convinced that this is a good idea in any case... Thanks for the help, Paul. From research at johnohagan.com Thu Feb 2 03:11:53 2012 From: research at johnohagan.com (John O'Hagan) Date: Thu, 2 Feb 2012 19:11:53 +1100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: <20120202191153.64036e9eb3655bceaedd7def@johnohagan.com> On Thu, 2 Feb 2012 01:34:48 -0500 Devin Jeanpierre wrote: > On Wed, Feb 1, 2012 at 10:18 PM, John O'Hagan > wrote: > > On Fri, 13 Jan 2012 10:40:47 -0800 > > Ethan Furman wrote: > > > >> Steven D'Aprano wrote: > >> > Normally this is harmless, but there is one interesting little > >> > glitch you can get: > >> > > >> >>>> t = ('a', [23]) > >> >>>> t[1] += [42] > >> > Traceback (most recent call last): > >> > ? File "", line 1, in > >> > TypeError: 'tuple' object does not support item assignment > >> >>>> t > >> > ('a', [23, 42]) > > > > IMHO, this is worthy of bug-hood: shouldn't we be able to conclude > > from the TypeError that the assignment failed? > > It did fail. The mutation did not. You're right, in fact, for me the surprise is that "t[1] +=" is interpreted as an assignment at all, given that for lists (and other mutable objects which use "+=") it is a mutation. Although as Steven says elsewhere, it actually is an assignment, but one which ends up reassigning to the same object. But it shouldn't be both. I can't think of another example of (what appears to be but is not) a single operation failing with an exception, but still doing exactly what you intended. > > I can't think of any way out of this misleadingness, although if you > can that would be pretty awesome. In the case above, the failure of the assignment is of no consequence. I think it would make more sense if applying "+=" to a tuple element were treated (by the interpreter I suppose) only on the merits of the element, and not as an assignment to the tuple. John From devipriya0010 at gmail.com Thu Feb 2 03:14:39 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Thu, 2 Feb 2012 00:14:39 -0800 (PST) Subject: Signup and get starts to earn..... Message-ID: <90370acf-4afc-47e1-84da-5db1b19acd43@h6g2000yqk.googlegroups.com> http://123maza.com/46/dos754/ From steve+comp.lang.python at pearwood.info Thu Feb 2 04:16:40 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Feb 2012 09:16:40 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> Message-ID: <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote: > You're right, in fact, for me the surprise is that "t[1] +=" is > interpreted as an assignment at all, given that for lists (and other > mutable objects which use "+=") it is a mutation. Although as Steven > says elsewhere, it actually is an assignment, but one which ends up > reassigning to the same object. > > But it shouldn't be both. Do you expect that x += 1 should succeed? After all, "increment and decrement numbers" is practically THE use-case for the augmented assignment operators. How can you expect x += 1 to succeed without an assignment? Numbers in Python are immutable, and they have to stay immutable. It would cause chaos and much gnashing of teeth if you did this: x = 2 y = 7 - 5 x += 1 print y * 100 => prints 300 So if you want x += 1 to succeed, += must do an assignment. Perhaps you are thinking that Python could determine ahead of time whether x[1] += y involved a list or a tuple, and not perform the finally assignment if x was a tuple. Well, maybe, but such an approach (if possible!) is fraught with danger and mysterious errors even harder to debug than the current situation. And besides, what should Python do about non-built-in types? There is no way in general to predict whether x[1] = something will succeed except to actually try it. > I can't think of another example of (what > appears to be but is not) a single operation failing with an exception, > but still doing exactly what you intended. Neither can I, but that doesn't mean that the current situation is not the least-worst alternative. >> I can't think of any way out of this misleadingness, although if you >> can that would be pretty awesome. > > In the case above, the failure of the assignment is of no consequence. I > think it would make more sense if applying "+=" to a tuple element were > treated (by the interpreter I suppose) only on the merits of the > element, and not as an assignment to the tuple. How should the interpreter deal with other objects which happen to raise TypeError? By always ignoring it? x = [1, None, 3] x[1] += 2 # apparently succeeds Or perhaps by hard-coding tuples and only ignoring errors for tuples? So now you disguise one error but not others? -- Steven From tjreedy at udel.edu Thu Feb 2 04:21:59 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 04:21:59 -0500 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: > On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy wrote: >> And it bothers me that you imput such ignorance to me. You made what I think >> was a bad analogy and I made a better one of the same type, though still >> imperfect. I acknowledged that the transition will take years. > > Ah. It is a common attitude among those that make these sorts of > comments about Python 3, and I hadn't read anything in what you said > that made me think that you were considering more than the superficial > costs of moving. I thought '95% in 10 years' would be a hint that I know upgrading is not trivial for every one ;-). > I am sorry that I did not give you the benefit of the doubt. Apology accepted. -- Terry Jan Reedy From andrea.crotti.0 at gmail.com Thu Feb 2 05:03:42 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Thu, 02 Feb 2012 10:03:42 +0000 Subject: changing sys.path In-Reply-To: <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4F296509.60607@gmail.com> <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2A5F7E.7000805@gmail.com> On 02/02/2012 12:51 AM, Steven D'Aprano wrote: > On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > >> Yes they are exactly the same, because in that file I just write exactly >> the same list, >> but when modifying it at run-time it doesn't work, while if at the >> application start >> there is this file everything works correctly... >> >> That's what really puzzles me.. What could that be then? > > Are you using IDLE or WingIDE or some other IDE which may not be > honouring sys.path? If so, that's a BAD bug in the IDE. > Are you changing the working directory manually, by calling os.chdir? If > so, that could be interfering with the import somehow. It shouldn't, but > you never know... > > Are you adding absolute paths or relative paths? No, no and absolute paths.. > > You say that you get an ImportError, but that covers a lot of things > going wrong. Here's a story. Could it be correct? I can't tell because > you haven't posted the traceback. > > When you set site-packages/my_paths.pth you get a sys path that looks > like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" > which locates b/spam.py and everything works. > > But when you call sys.path.extend(['a', 'b']) you get a path that looks > like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates > some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't > import, and you get an ImportError. > > And no the problem is not that I already checked inspecting at run-time.. This is the traceback and it might be related to the fact that it runs from the .exe wrapper generated by setuptools: Traceback (most recent call last): File "c:\python25\scripts\dev_main-script.py", line 8, in load_entry_point('psi.devsonly==0.1', 'console_scripts', 'dev_main')() File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", line 152, in main Develer(ns).full_run() File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", line 86, in full_run run(project_name, test_only=self.ns.test_only) File "h:\git_projs\psi\psi.devsonly\psi\devsonly\environment.py", line 277, in run from psi.devsonly.run import Runner File "h:\git_projs\psi\psi.devsonly\psi\devsonly\run.py", line 7, in from psi.workbench.api import Workbench, set_new_dev_main ImportError: No module named workbench.api Another thing which might matter is that I'm launching Envisage applications, which heavily rely on the use of entry points, so I guess that if something is not in the path the entry point is not loaded automatically (but it can be forced I guess somehow). I solved in another way now, since I also need to keep a dev_main.pth in site-packages to make Eclipse happy, just respawning the same process on ImportError works already perfectly.. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Thu Feb 2 05:42:01 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Thu, 02 Feb 2012 11:42:01 +0100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 13.01.2012 13:30 schrieb Chris Angelico: > It seems there's a distinct difference between a+=b (in-place > addition/concatenation) and a=a+b (always rebinding), There is indeed. a = a + b is a = a.__add__(b), while a += b is a = a.__iadd__(b). __add__() is supposed to leave the original object intact and return a new one, while __iadd__() is free to modify (preference, to be done if possible) or return a new one. A immutable object can only return a new one, and its __iadd__() behaviour is the same as __add__(). A mutable object, however, is free to and supposed to modify itself and then return self. Thomas From hniksic at xemacs.org Thu Feb 2 05:53:34 2012 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 02 Feb 2012 11:53:34 +0100 Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87haz9o6a9.fsf@xemacs.org> Steven D'Aprano writes: > Perhaps you are thinking that Python could determine ahead of time > whether x[1] += y involved a list or a tuple, and not perform the > finally assignment if x was a tuple. Well, maybe, but such an approach > (if possible!) is fraught with danger and mysterious errors even > harder to debug than the current situation. And besides, what should > Python do about non-built-in types? There is no way in general to > predict whether x[1] = something will succeed except to actually try > it. An alternative approach is to simply not perform the final assignment if the in-place method is available on the contained object. No prediction is needed to do it, because the contained object has to be examined anyway. No prediction is needed, just don't. Currently, lhs[ind] += rhs is implemented like this: item = lhs[ind] if hasattr(item, '__iadd__'): lhs.__setitem__(ind, item.__iadd__(rhs)) else: lhs.__setitem__(ind, item + rhs) # (Note item assignment in both "if" branches.) It could, however, be implemented like this: item = lhs[ind] if hasattr(item, '__iadd__'): item += rhs # no assignment, item supports in-place change else: lhs.__setitem__(ind, lhs[ind] + rhs) This would raise the exact same exception in the tuple case, but without executing the in-place assignment. On the other hand, some_list[ind] += 1 would continue working exactly the same as it does now. In the same vein, in-place methods should not have a return value (i.e. they should return None), as per Python convention that functions called for side effect don't return values. The alternative behavior is unfortunately not backward-compatible (it ignores the return value of augmented methods), so I'm not seriously proposing it, but I believe it would have been a better implementation of augmented assignments than the current one. The present interface doesn't just bite those who try to use augmented assignment on tuples holding mutable objects, but also those who do the same with read-only properties, which is even more reasonable. For example, obj.list_attr being a list, one would expect that obj.list_attr += [1, 2, 3] does the same thing as obj.list_attr.extend([1, 2, 3]). And it almost does, except it also follows up with an assignment after the list has already been changed, and the assignment to a read-only property raises an exception. Refusing to modify the list would have been fine, modifying it without raising an exception (as described above) would have been better, but modifying it and *then* raising an exception is a surprise that takes some getting used to. From __peter__ at web.de Thu Feb 2 06:02:21 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Feb 2012 12:02:21 +0100 Subject: xhtml encoding question References: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Message-ID: Ulrich Eckhardt wrote: > Am 01.02.2012 10:32, schrieb Peter Otten: >> It doesn't matter for the OP (see Stefan Behnel's post), but If you want >> to replace characters in a unicode string the best way is probably the >> translate() method: >> >>>>> print u"\xa9\u2122" >> ?? >>>>> u"\xa9\u2122".translate({0xa9: u"©", 0x2122: u"™"}) >> u'©™' >> > > Yes, this is both more expressive and at the same time probably even > more efficient. > > > Question though: > > >>> u'abc'.translate({u'a': u'A'}) > u'abc' > > I would call this a chance to improve Python. According to the > documentation, using a string is invalid, but it neither raises an > exception nor does it do the obvious and accept single-character strings > as keys. > > > Thoughts? How could this raise an exception? You'd either need a typed dictionary (int --> unicode) or translate() would have to verify that all keys are indeed integers. The former would go against the grain of Python, the latter would make the method less flexible as the set of keys currently need not be predefined: >>> class A(object): ... def __getitem__(self, key): ... return unichr(key).upper() ... >>> u"alpha".translate(A()) u'ALPHA' Using unicode instead of integer keys would be nice but breaks backwards compatibility, using both could double the number of dictionary lookups. From ulrich.eckhardt at dominolaser.com Thu Feb 2 07:40:22 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Thu, 02 Feb 2012 13:40:22 +0100 Subject: xhtml encoding question In-Reply-To: References: <8b4ov8-ad2.ln1@satorlaser.homedns.org> Message-ID: Am 02.02.2012 12:02, schrieb Peter Otten: > Ulrich Eckhardt wrote: >> >> >>> u'abc'.translate({u'a': u'A'}) >> u'abc' >> >> I would call this a chance to improve Python. According to the >> documentation, using a string [as key] is invalid, but it neither raises >> an exception nor does it do the obvious and accept single-character >> strings as keys. >> >> >> Thoughts? > > How could this raise an exception? You'd either need a typed dictionary (int > --> unicode) or translate() would have to verify that all keys are indeed > integers. The latter is exactly what I would have done, i.e. scan the dictionary for invalid values, in the spirit of not letting errors pass unnoticed. > The former would go against the grain of Python, the latter would > make the method less flexible as the set of keys currently need not be > predefined: > >>>> class A(object): > ... def __getitem__(self, key): > ... return unichr(key).upper() > ... >>>> u"alpha".translate(A()) > u'ALPHA' Working with __getitem__ is a point. I'm not sure if it is reasonable to expect this to work though. I'm -0 on that. I could also imagine a completely separate path for iterable and non-iterable mappings. > Using unicode instead of integer keys would be nice but breaks backwards > compatibility, using both could double the number of dictionary lookups. Dictionary lookups are constant time and well-optimized, so I'd actually go for allowing both and paying that price. I could even imagine preprocessing the supplied dictionary while checking for invalid values. The result could be a structure that makes use of the fact that Unicode codepoints are < 22 bits and that makes the way from the elements of the source sequence to the according map entry as short as possible (I'm not sure if using codepoints or single-character strings is faster). However, those are early optimizations of which I'm not sure if they are worth it. Anyway, thanks for your thoughts, they are always appreciated! Uli From breamoreboy at yahoo.co.uk Thu Feb 2 07:52:40 2012 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Thu, 02 Feb 2012 12:52:40 +0000 Subject: CTRL-Z on windows for 2.7 and 3.2 Message-ID: Not that I'll lose any sleep over it, but section 2.1 of the tutorial for both versions doesn't reflect the minor difference between the behavior shown below. Which is correct, the docs or what actually happens? c:\Users\Mark\Sudoku>c:\Python27\python.exe Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> # you don't need to hit ENTER c:\Users\Mark\Sudoku>c:\Python32\python.exe Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> ^Z # you do need to hit ENTER c:\Users\Mark\Sudoku> -- Cheers. Mark Lawrence. From dihedral88888 at googlemail.com Thu Feb 2 08:33:17 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 2 Feb 2012 05:33:17 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. > > I was talking about the combination of + and =, since the discussion is > about 'a = a + b' vs 'a += b', not 'a + b' vs 'a += b' (where the > differences are obvious). > > And I stand by my statement. In 'a = a + b', operator+ obviously returns > a new object, but operator= should then go and assign the result to and > return a reference to 'a', just like how 'a += b' will return a > reference to 'a'. > The operation a+b means add(a,b) and returns a result instance, furthermore a and b can't be modified. The expression a = a+b are two operations not one. But in C or C++ the problem is mixing operations and expressions in a free style allowed. The operation a+=b means a modified by b and b can't be changed. Note that no new instance is necessary in a+=b. > If you're working in C++ and overload your operators so that 'a += b' > and 'a = a + b' have different observable behaviors (besides perhaps > time), then either your implementation is buggy or your design is very > bad-mannered. > > Evan Do you mean the result instances after 'a+=b' and 'a=a+b' or the actions of behaviors of instances involved in performing 'a+=b' and 'a=a+b'? From dihedral88888 at googlemail.com Thu Feb 2 08:33:17 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 2 Feb 2012 05:33:17 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. > > I was talking about the combination of + and =, since the discussion is > about 'a = a + b' vs 'a += b', not 'a + b' vs 'a += b' (where the > differences are obvious). > > And I stand by my statement. In 'a = a + b', operator+ obviously returns > a new object, but operator= should then go and assign the result to and > return a reference to 'a', just like how 'a += b' will return a > reference to 'a'. > The operation a+b means add(a,b) and returns a result instance, furthermore a and b can't be modified. The expression a = a+b are two operations not one. But in C or C++ the problem is mixing operations and expressions in a free style allowed. The operation a+=b means a modified by b and b can't be changed. Note that no new instance is necessary in a+=b. > If you're working in C++ and overload your operators so that 'a += b' > and 'a = a + b' have different observable behaviors (besides perhaps > time), then either your implementation is buggy or your design is very > bad-mannered. > > Evan Do you mean the result instances after 'a+=b' and 'a=a+b' or the actions of behaviors of instances involved in performing 'a+=b' and 'a=a+b'? From wxjmfauth at gmail.com Thu Feb 2 08:45:23 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 2 Feb 2012 05:45:23 -0800 (PST) Subject: changing sys.path References: <4F296509.60607@gmail.com> <4f29de16$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7a534ec4-3836-4460-af48-205170ebc37e@c20g2000vbb.googlegroups.com> On 2 f?v, 11:03, Andrea Crotti wrote: > On 02/02/2012 12:51 AM, Steven D'Aprano wrote: > > > > > On Wed, 01 Feb 2012 17:47:22 +0000, Andrea Crotti wrote: > > >> Yes they are exactly the same, because in that file I just write exactly > >> the same list, > >> but when modifying it at run-time it doesn't work, while if at the > >> application start > >> there is this file everything works correctly... > > >> That's what really puzzles me.. What could that be then? > > > Are you using IDLE or WingIDE or some other IDE which may not be > > honouring sys.path? If so, that's a BAD bug in the IDE. > > Are you changing the working directory manually, by calling os.chdir? If > > so, that could be interfering with the import somehow. It shouldn't, but > > you never know... > > > Are you adding absolute paths or relative paths? > > No, no and absolute paths.. > > > > > You say that you get an ImportError, but that covers a lot of things > > going wrong. Here's a story. Could it be correct? I can't tell because > > you haven't posted the traceback. > > > When you set site-packages/my_paths.pth you get a sys path that looks > > like ['a', 'b', 'fe', 'fi', 'fo', 'fum']. You then call "import spam" > > which locates b/spam.py and everything works. > > > But when you call sys.path.extend(['a', 'b']) you get a path that looks > > like ['fe', 'fi', 'fo', 'fum', 'a', 'b']. Calling "import spam" locates > > some left over junk file, fi/spam.py or fi/spam.pyc, which doesn't > > import, and you get an ImportError. > > And no the problem is not that I already checked inspecting at run-time.. > This is the traceback and it might be related to the fact that it runs > from the > .exe wrapper generated by setuptools: > > Traceback (most recent call last): > ? ?File "c:\python25\scripts\dev_main-script.py", line 8, in > ? ? ?load_entry_point('psi.devsonly==0.1', 'console_scripts', 'dev_main')() > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", > line 152, in main > ? ? ?Develer(ns).full_run() > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\bin\dev_main.py", > line 86, in full_run > ? ? ?run(project_name, test_only=self.ns.test_only) > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\environment.py", > line 277, in run > ? ? ?from psi.devsonly.run import Runner > ? ?File "h:\git_projs\psi\psi.devsonly\psi\devsonly\run.py", line 7, in > > ? ? ?from psi.workbench.api import Workbench, set_new_dev_main > ImportError: No module named workbench.api > > Another thing which might matter is that I'm launching Envisage > applications, which > heavily rely on the use of entry points, so I guess that if something is > not in the path > the entry point is not loaded automatically (but it can be forced I > guess somehow). > > I solved in another way now, since I also need to keep a dev_main.pth in > site-packages > to make Eclipse happy, just respawning the same process on ImportError works > already perfectly.. There is something strange here. I can not figure out how correct code will fail with the sys.path. It seems to me, the lib you are using is somehow not able to recognize its own structure ("his own sys.path"). Idea. Are you sure you are modifying the sys.path at the right place, understand at the right time when Python processes? I'm using this sys.path tweaking at run time very often; eg to test or to run different versions of the same lib residing in different dirs, and this, in *any* dir and independently of *any* .pth file. jmf From jldunn2000 at gmail.com Thu Feb 2 08:53:22 2012 From: jldunn2000 at gmail.com (loial) Date: Thu, 2 Feb 2012 05:53:22 -0800 (PST) Subject: newbie socket help Message-ID: <4e70f47b-89e4-46bb-929e-9b7db20e7bcc@l16g2000vbl.googlegroups.com> I am trying to write a python script to read data from a printer port using python sockets, but it seems I am locking up the port. Is there a way to ensure that I do not block the port to other applications? My knowledge of python sockets is minimal, so any help would be appreciated. From michal.hantl at gmail.com Thu Feb 2 09:09:13 2012 From: michal.hantl at gmail.com (Michal Hantl) Date: Thu, 2 Feb 2012 06:09:13 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) Message-ID: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Hello, I've been looking for something similar to CoffeeScript, but for python. Does anyone know of such project? So far I haven't found any attempt to do this, so I took few regular expressions and hacked this: https://plus.google.com/116702779841286800811/posts/56sBdwiZ4fT Any advice on what parses to use for the CoffeeScript-like syntaxe? I would like to use parser written in Python so I don't introduce dependencies. Any advice from Python gurus / language experimentators? From research at johnohagan.com Thu Feb 2 09:17:48 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 01:17:48 +1100 Subject: copy on write In-Reply-To: <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> On 02 Feb 2012 09:16:40 GMT Steven D'Aprano wrote: > On Thu, 02 Feb 2012 19:11:53 +1100, John O'Hagan wrote: > > > You're right, in fact, for me the surprise is that "t[1] +=" is > > interpreted as an assignment at all, given that for lists (and other > > mutable objects which use "+=") it is a mutation. Although as Steven > > says elsewhere, it actually is an assignment, but one which ends up > > reassigning to the same object. > > > > But it shouldn't be both. > > Do you expect that x += 1 should succeed? After all, "increment and > decrement numbers" is practically THE use-case for the augmented > assignment operators. > > How can you expect x += 1 to succeed without an assignment? I don't; obviously, for immutable objects assignment is the only possibility. [...] > > Perhaps you are thinking that Python could determine ahead of time > whether x[1] += y involved a list or a tuple, and not perform the > finally assignment if x was a tuple. Well, maybe, but such an > approach (if possible!) is fraught with danger and mysterious errors > even harder to debug than the current situation. And besides, what > should Python do about non-built-in types? There is no way in general > to predict whether x[1] = something will succeed except to actually > try it. It's not so much about the type of x but that of x[1]. Wouldn't it be possible to omit the assignment simply if the object referred to by x[1] uses "+=" without creating a new object? That way, some_tuple[i] += y will succeed if some_tuple[i] is a list but not with, say, an int. That seems reasonable to me. [...] > > > > In the case above, the failure of the assignment is of no > > consequence. I think it would make more sense if applying "+=" to a > > tuple element were treated (by the interpreter I suppose) only on > > the merits of the element, and not as an assignment to the tuple. > > How should the interpreter deal with other objects which happen to > raise TypeError? By always ignoring it? > > x = [1, None, 3] > x[1] += 2 # apparently succeeds > > Or perhaps by hard-coding tuples and only ignoring errors for tuples? > So now you disguise one error but not others? I'm not suggesting either of those. None can't be modified in place. But for objects which can, wouldn't omitting the final assignment prevent the TypeError in the first place? John From bv5bv5bv5 at yahoo.com Thu Feb 2 09:43:07 2012 From: bv5bv5bv5 at yahoo.com (BV) Date: Thu, 2 Feb 2012 06:43:07 -0800 (PST) Subject: =?windows-1252?B?RVhBTVBMRVMgT0YgUFJPUEhFVJJTIE1FUkNZIFVQT04gTk9OIE1VU0xJTVMgICEhISE=?= =?windows-1252?B?ISEhISEhISEhISE=?= Message-ID: <688d3849-b9ad-43d7-a8ad-100e29c3d0a5@o14g2000vbo.googlegroups.com> EXAMPLES OF PROPHET?S MERCY UPON NON MUSLIMS Ex. No. (1) It was narrated that ?Aisha, May Allah be pleased with her, said to the Prophet, Peace be upon him: "Have you ever come across a day harder than the day ofUhod (one of the battles with the polytheists, in which Muslims were defeated failing to comply with the Prophet's instructions)?" He replied: "I have suffered from your people a lot. The hardest I suffered was on the day of Akaba (a place name). I brought out my message to Abd Yaleil bin Abd Kalal. He did not respond positively to what I called him for. I left there with a grief- stricken face. I did not wake up from that feeling, until I was near Karn-Ath-Tha-aleb (a place name). I raised my head, where I found a cloud casting its shadow over me. Upon looking, I saw Jibril (the angel) into it. He called upon me: Allah (the Almighty) has heard the saying of your people, and what kind of reply they gave to you. Allah has sent the angel of the mountains for you ready to do with them whatever you ask. The angel of the mountains called, and saluted me saying: "Oh Muhammad, what I do will be as you request. If you want, I close the two mountains on them?" The Prophet, Peace be upon him, replied: "Instead of that, I am hoping that Allah (the Al mighty) will create from their offspring people who worship Allah alone, without ascribing partners unto Him" narrated by Al Bukhari. Ex. No. (2): It was narrated that Ibn-Omar (the son of Omar), May Allah be pleased with both of them, said that after one of the battles of the Prophet PBUH, a woman was found killed. In response, the Prophet PBUH prohibited the killing of women and children. Narrated by Al Bukhari. Ex. No. (3): Anas-bin-Malek, May Allah be pleased with him, said: A Jewish youth who served the Prophet, Peace be upon him, became ill, and the Prophet paid him a visit. The Prophet, peace be upon him, sat near the youth's head, and he spoke to him saying: "Embrace Islam". The youth averted his eyes towards his father, who was also beside him. The father told his son: "ObeyAbal-Kassem (one of the common names of the Prophet PBUH)". The youth embraced Islam (before dying), and the Prophet, peace be upon him, went out saying: "Thanks to Allah (the Almighty) Who rescued him from hellfire." narrated by Al Bukhari. Ex. No. (4): Abdullah Ibn-Amr, May Allah be pleased with both, reported that the Prophet, peace be upon him, said: "He who kills a promisor (a non-Muslim living among Muslims where he is promised to have protection, and he promises not to help enemies against Muslims, hence, he is called 'a promisor'), will not smell the fragrance of paradise, though its fragrance is recognizable from a distance of forty years." narrated by Al Bukhari. Ex. No. (5): Boraida-bin-Al-Hosaib reported that when the Prophet, peace be upon him, delegated a prince to lead an army or a small army, he advised him, and Muslims with him, to be devoted to Allah, and to act to the common good. Then, he said: "Your battle should be in the name of Allah, and for His sake. Fight disbelievers. Fight, but don't exaggerate, don't cheat, don't mutilate, don't kill a new-born child. If you meet your enemies of polytheists call them for one of three options. Whatever they take, you must accept, and stop fighting them. Call them to Islam. If they take it, accept, and stop fighting them. Then call them to transfer from their home to the home of immigrants (Al Madina, or Hijra house, where all Muslims, at the start of Islam gathered). Tell them if they do so, they will have the same rights and duties of the immigrants. If, however, their choice was not to transfer from home, their status will be the same as the Muslim Bedouins (away in the desert), by the command of Allah not having the right for spoils or almsgiving unless they join holy war (Jihad) beside other Muslims. If they refused (Islam) ask them to pay the tribute (tax taken from non-Muslims for protection). If they gave a positive reply, accept that, and stop fighting them. If they refused, seek the help of Allah, and fight them. If you lay a siege around a fortress, and they ask to have the warranty of Allah and the warranty of his Messenger, do not give them the warranty of Allah and the warranty of his Messenger. But give them your warranty and the warranty of your companions. Observing your warranty and the warranty of your companions will be easier than observing the warranty of Allah and the warranty of his Messenger. If you lay a siege around a fortress, and its people ask to be brought down to thejudgement of Allah, don't bring them down to the judgement of Allah. But, bring them down to your own judgement, since; you never know whether yourjudgement will be the same as the right judgement of Allah about them or not." narrated by Muslim. Ex. No. (6): Abu Huraira, May Allah be pleased with him, reported that the Prophet, Peace be upon him, delegated some horsemen to a place called Najd . The horsemen captured a man from the tribe of Bani-Hanifa called Thomama-bin-Athal. They tied the captive to one of the posts in the mosque. The Prophet, Peace be upon him, came out to him saying: "How do you find yourself Thomama?" Thomama replied: "Good, Muhammad. If you kill me, you shed (retaliatory) blood. If you pardon me, you do a favour to an appreciative person. If you are seeking money, ask whatever amount you want." He was left until the next day. The Prophet, Peace be upon him, asked him the same question (the next day), and he replied "The same like yesterday, if you pardon me, you do a favour to an appreciative person". The Third day, The Prophet, Peace be upon him, asked him the same question, and the captive gave the same reply. The Prophet, Peace be upon him, said" "Set Thomama free!". Thomama went to a place near the mosque where he washed (did ablution; Wudu?), and came back to the mosque giving the testimony "I bear witness that there is no God but Allah, and Muhammad is the Messenger of Allah". Then, he added: "I swear by Allah, that on earth no face was more hateful to me than your face. Now, your face is the one I love most. I swear by Allah, your religion was the one I disliked most. Now, it is the religion I like most. I swear by Allah, your city was the worst place for me. Now, it is your city which I like most. Your horsemen took me, when I was going for Omra (a smaller pilgrimage out of the normal time of Haj that was also practiced by polytheists before Islam imitating the monotheist religion of Abraham, PBUH). So, what is your decision?" The Prophet, Peace be upon him, announced him and ordered him to go for Omra. When he went toMakkah, somebody there said to him: "You have changed your religion!" (a shameful accusation for them) "No." he replied, "But I joined Islam with Muhammad, Peace be upon him. From now on, you will not receive even one grain of wheat from (my land) Al-Yamama, unless by the permission of the Prophet, Peace be upon him." narrated by Al Bukhari. Ex. No. (7): Khalid-bin-Al-Walid, May Allah be pleased with him, said: "I joined the Prophet, Peace be upon him, at the battle of Kheibar, where the Jews came complaining that people were harrying to their warehouses." (In response), the Prophet, Peace be upon him, said: "The possessions of promisors are not permissible unless by a rightful claim". Narrated by Abu-Dawood with a sound reference. Ex. No. (8): Sahel-bin-Saad-As-Sa?edi, May Allah be pleased with him, reported that he heard the Prophet, Peace be upon him, saying on the day of Kheibar battle: "I will give the flag to the man that Allah brings victory through him" The companions stood up to see which of them will be given the flag. Then, he said: "Where is Ali?" He was given the answer that Ali, May Allah be pleased with him, was suffering from pain in his eyes. He called Ali, supplicated Allah (the Almighty) for Ali's cure, spitting in Ali's eyes. Ali was cured on the spot, as if he suffered no pain. Ali, May Allah be pleased with him, said: "We fight them until they are (Muslims) like us"? The Prophet, Peace be upon him, replied "Wait until you are on their land. Then, call them to Islam, and tell them their duties, I swear, that if Allah guided even a single man through you, will be better for you than getting the most expensive livestock." narrated by Al Bukhari, and Muslim. Ex. No. (9): It was reported that Abu Huraira, May Allah be pleased with him, said that the Prophet, Peace be upon him, was asked to invoke Allah (the Almighty) against polytheists. He replied: "I was not sent out for cursing, I was sent out as a mercy" narrated by Muslim. Ex. No. (10): It was reported that Abu Huraira, May Allah be pleased with him, said: "I called my mother for Islam, when she was still a polytheist. One day, upon calling her, she said to me words about the Prophet,Peace be upon him that I hate. I went to the Prophet, Peace be upon him, crying. I said: "Messenger of Allah! I was calling my mother to Islam, but she was refusing. Today, I called her, but she said to me words about you that I hate. Supplicate that Allah (the Almighty) guide mother of Abu Huraira to Islam". At that the Prophet, Peace be upon him, said: "Oh Allah! I call upon you to guide the mother ofAbu Huraira". I went out very happy at the supplication of the Prophet, Peace be upon him. Going back home, when I was near the door, my mother heard my steps. "Stay where you are Abu Huraira!" she shouted. I heard the sound of pouring water. Then, after washing, dressing, and putting on her veil, she opened the door, and said: "AbuHuraira, I bear witness that there is no God but Allah, and thatMuhammad (PBUH) is His Slave and His Messenger" I went back to the Prophet, Peace be upon him, crying this time out of joy, and I said to him: "Oh Messenger of Allah! I have the good news that Allah (the Almighty) responded to your supplication, and guided the mother of Abu Huraira". The Prophet,Peace be upon him, thanked Allah, and praised Him, and said good words. Then, I said: "Oh, Messenger of Allah! Supplicate Allah that His slaves and believers love both me and my mother, and make us love believers. The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to make this little slave of yours ? he means Abu Huraira ? and his mother, beloved to your slaves and believers, and make your slaves and believers beloved to them." No believer on earth who heard of me or saw me, but he loved me" narrated by Muslim. Ex. No. (11): It was reported that Abu Huraira, May Allah be pleased with him, said: "Tofail-bin-Amr-Ad-Dawsi and his companions, came to the Prophet, Peace be upon him, and said: "Messenger of Allah! Daws (a tribe name) disobeyed and revolted against us, invoke Allah (the Almighty) against them. Thinking that the Prophet PBUH would do that, the people said: "Aws has perished". The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to favour Awas with your guidance, and bring them". Narrated by Bukhary Ex. No. (12): It was reported that Jabir-bin-Abdullah, May Allah be pleased with both of them said: "Oh! "Messenger of Allah, we have been hit severely by the fire arrows of Thakif (a tribe name), invoke Allah (the Almighty) against them. The Prophet, Peace be upon him, said: "Oh Allah! I call upon you to favour Thakif with your guidance" narrated by Al-Tirmizi with a sound reference. From:http://www.rasoulallah.net/v2/index.aspx?lang=en From chris at simplistix.co.uk Thu Feb 2 11:17:49 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 02 Feb 2012 16:17:49 +0000 Subject: Startup Chile Company Looking For Founding Developer/CTO In-Reply-To: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> References: <04214723-94b5-4b72-962a-c6259d20d828@c21g2000yqi.googlegroups.com> Message-ID: <4F2AB72D.4030605@simplistix.co.uk> On 01/02/2012 18:38, Jennifer Turliuk wrote: > My name is Jennifer Turliuk. I'm currently in Santiago, Chile for the > next 6 months as part of the Startup Chile program. I think you may be > able to help me out. We are looking to bring on a developer ASAP (see > description below). Please don't spam the list with job adverts, please use the job board instead: http://www.python.org/community/jobs/howto/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From p.f.moore at gmail.com Thu Feb 2 11:27:27 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:27:27 -0800 (PST) Subject: Windows: How do I copy a custom build of Python into a directory structure matching an MSI install? Message-ID: <34779f70-4709-4a31-b2f9-9ae5aca5e118@y10g2000vbn.googlegroups.com> I've got a build of Python (3.3) on my Windows PC. Everything is built, I believe (core, all modules, HTML help, etc). I want to "install" it on my PC (because tools like virtualenv expect a standard install layout, and the checkout basically isn't). I tried using Tools/msi/msi.py to build an installer, but it's making lots of assumptions and it's just becoming a pain (it's started asking me for certificates, and I need cabarc.exe). So I'm giving up on that approach, and just want to move the files into the right places. I can probably just copy stuff around till it works. I might even be able to decipher msi.py and work out how the installer lays things out. But I'm lazy, and I'm hoping that someone already knows and can tell me, or point me to some documentation that I've missed. In return, I'm willing to share the script I write to do the copying :-) Can anyone help? Thanks, Paul. From python at mrabarnett.plus.com Thu Feb 2 11:28:28 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 02 Feb 2012 16:28:28 +0000 Subject: copy on write In-Reply-To: <87haz9o6a9.fsf@xemacs.org> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <87haz9o6a9.fsf@xemacs.org> Message-ID: <4F2AB9AC.3050608@mrabarnett.plus.com> On 02/02/2012 10:53, Hrvoje Niksic wrote: > Steven D'Aprano writes: > >> Perhaps you are thinking that Python could determine ahead of time >> whether x[1] += y involved a list or a tuple, and not perform the >> finally assignment if x was a tuple. Well, maybe, but such an approach >> (if possible!) is fraught with danger and mysterious errors even >> harder to debug than the current situation. And besides, what should >> Python do about non-built-in types? There is no way in general to >> predict whether x[1] = something will succeed except to actually try >> it. > > An alternative approach is to simply not perform the final assignment if > the in-place method is available on the contained object. No prediction > is needed to do it, because the contained object has to be examined > anyway. No prediction is needed, just don't. Currently, > lhs[ind] += rhs is implemented like this: > > item = lhs[ind] > if hasattr(item, '__iadd__'): > lhs.__setitem__(ind, item.__iadd__(rhs)) > else: > lhs.__setitem__(ind, item + rhs) > # (Note item assignment in both "if" branches.) > > It could, however, be implemented like this: > > item = lhs[ind] > if hasattr(item, '__iadd__'): > item += rhs # no assignment, item supports in-place change > else: > lhs.__setitem__(ind, lhs[ind] + rhs) > > This would raise the exact same exception in the tuple case, but without > executing the in-place assignment. On the other hand, some_list[ind] += 1 > would continue working exactly the same as it does now. > > In the same vein, in-place methods should not have a return value > (i.e. they should return None), as per Python convention that functions > called for side effect don't return values. > > The alternative behavior is unfortunately not backward-compatible (it > ignores the return value of augmented methods), so I'm not seriously > proposing it, but I believe it would have been a better implementation > of augmented assignments than the current one. > [snip] Could it not perform the assignment if the reference returned by __iadd__ is the same as the current reference? For example: t[0] += x would do: r = t[0].__iadd__(x) if t[0] is not r: t[0] = r Should failed assignment be raising TypeError? Is it really a type error? From p.f.moore at gmail.com Thu Feb 2 11:30:10 2012 From: p.f.moore at gmail.com (Paul Moore) Date: Thu, 2 Feb 2012 08:30:10 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Feb 2, 2:09?pm, Michal Hantl wrote: > ?I've been looking for something similar to CoffeeScript, but for python. > > Does anyone know of such project? Isn't CoffeeScript just a compiler to convert a cleaner syntax into Javascript? If so, why would you need such a thing for Python, where the syntax is already clean and simple? :-) Paul. From jeanpierreda at gmail.com Thu Feb 2 12:12:33 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 12:12:33 -0500 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Thu, Feb 2, 2012 at 11:30 AM, Paul Moore wrote: > Isn't CoffeeScript just a compiler to convert a cleaner syntax into > Javascript? If so, why would you need such a thing for Python, where > the syntax is already clean and simple? :-) Coffeescript is a more functional syntax. On that note, Python isn't as functional as it could be. e.g. the "Python Coffeescript" could add pattern matching or TCO or something. -- Devin From jeanpierreda at gmail.com Thu Feb 2 12:21:37 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 2 Feb 2012 12:21:37 -0500 Subject: copy on write In-Reply-To: <4F2AB9AC.3050608@mrabarnett.plus.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <87haz9o6a9.fsf@xemacs.org> <4F2AB9AC.3050608@mrabarnett.plus.com> Message-ID: On Thu, Feb 2, 2012 at 11:28 AM, MRAB wrote: > Should failed assignment be raising TypeError? Is it really a type > error? A failed setitem should be a TypeError as much as a failed getitem should. Should 1[0] be a TypeError? -- Devin From tjreedy at udel.edu Thu Feb 2 12:25:00 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 12:25:00 -0500 Subject: copy on write In-Reply-To: <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: On 2/2/2012 9:17 AM, John O'Hagan wrote: > It's not so much about the type of x but that of x[1]. Wouldn't it be > possible to omit the assignment simply if the object referred to by > x[1] uses "+=" without creating a new object? That way, some_tuple[i] > += y will succeed if some_tuple[i] is a list but not with, say, an > int. That seems reasonable to me. There was considerable discussion of the exact semantics of augmented operations when they were introduced. I do not remember if that particular idea was suggested (and rejected) or not. You could try to look at the PEP, if there is one, or the dicussion ( probably on pydev list). -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Thu Feb 2 12:56:54 2012 From: breamoreboy at yahoo.co.uk (Blockheads Oi Oi) Date: Thu, 02 Feb 2012 17:56:54 +0000 Subject: Python book reviews Message-ID: There are several at www.accu.org and select (strangely enough :) book reviews for anyone who may be interested. -- Cheers. Mark Lawrence. From amirouche.boubekki at gmail.com Thu Feb 2 13:17:13 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Thu, 2 Feb 2012 19:17:13 +0100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: They are solution to write Python code that translates to javascript see this thread http://mail.python.org/pipermail/python-list/2011-November/1283110.html 2012/2/2 Michal Hantl > Hello, > I've been looking for something similar to CoffeeScript, but for python. > > Does anyone know of such project? > > > So far I haven't found any attempt to do this, so I took few regular > expressions and hacked this: > https://plus.google.com/116702779841286800811/posts/56sBdwiZ4fT > > Any advice on what parses to use for the CoffeeScript-like syntaxe? I > would like to use parser written in Python so I don't introduce > dependencies. > > Any advice from Python gurus / language experimentators? > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vincenzo.forgetta at mail.mcgill.ca Thu Feb 2 13:42:44 2012 From: vincenzo.forgetta at mail.mcgill.ca (Vince Forgetta) Date: Thu, 2 Feb 2012 13:42:44 -0500 Subject: distribute and reference static content in a python package Message-ID: <1328208164.15687.17.camel@muon> Hi, I have developed a python program that contains multiple python modules and static content in the form of fonts (pil,pbm and tff files), html, images, css and javascript. I want to share the program with others as a python package. I have followed the instructions at http://guide.python-distribute.org/creation.html I have created an identical structure (apart from directory naming) as specified in the link, with the exception of a "static" directory within the module directory (towelstuff in the example). Within this directory are sub-directories named "css", "html", "images", "fonts" and "js". TowelStuff/ bin/ run.py CHANGES.txt docs/ LICENSE.txt MANIFEST.in README.txt setup.py towelstuff/ __init__.py module1.py module2.py static/ images/someimage.png css/ html/ js/ fonts/ When the user install the program using "python setup.py install", the modules (in towelstuff) are copied to the common python library path (e.g. /usr/lib/python2.7/site-packages/), but the static content is not (understandably). What is common method to distribute static content, and how to I make reference to it in my python program? For programs in TowelStuff/bin (i.e. run.py), I currently make reference to the static content like so: sys.path[0] + "../towelstuff/static/images/someimage.png" I am sure there is a more pythonic way of doing this ... Thanks in advance for the help. Vince From forgetta at gmail.com Thu Feb 2 14:09:26 2012 From: forgetta at gmail.com (Vince Forgetta) Date: Thu, 02 Feb 2012 14:09:26 -0500 Subject: distribute and reference static content in a python package In-Reply-To: <1328208164.15687.17.camel@muon> References: <1328208164.15687.17.camel@muon> Message-ID: <1328209766.15687.20.camel@muon> I assume this is an appropriate solution to my problem: http://docs.python.org/distutils/setupscript.html#installing-additional-files On Thu, 2012-02-02 at 13:42 -0500, Vince Forgetta wrote: > Hi, > > I have developed a python program that contains multiple python modules > and static content in the form of fonts (pil,pbm and tff files), html, > images, css and javascript. > > I want to share the program with others as a python package. I have > followed the instructions at > > http://guide.python-distribute.org/creation.html > > I have created an identical structure (apart from directory naming) as > specified in the link, with the exception of a "static" directory within > the module directory (towelstuff in the example). Within this directory > are sub-directories named "css", "html", "images", "fonts" and "js". > > TowelStuff/ > bin/ > run.py > CHANGES.txt > docs/ > LICENSE.txt > MANIFEST.in > README.txt > setup.py > towelstuff/ > __init__.py > module1.py > module2.py > static/ > images/someimage.png > css/ > html/ > js/ > fonts/ > > > When the user install the program using "python setup.py install", the > modules (in towelstuff) are copied to the common python library path > (e.g. /usr/lib/python2.7/site-packages/), but the static content is not > (understandably). > > What is common method to distribute static content, and how to I make > reference to it in my python program? > > For programs in TowelStuff/bin (i.e. run.py), I currently make reference > to the static content like so: > > sys.path[0] + "../towelstuff/static/images/someimage.png" > > I am sure there is a more pythonic way of doing this ... > > Thanks in advance for the help. > > Vince From mwilson at the-wire.com Thu Feb 2 14:42:15 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Thu, 02 Feb 2012 14:42:15 -0500 Subject: python reliability with EINTR handling in general modules References: Message-ID: Dennis Lee Bieber wrote: > On Wed, 1 Feb 2012 23:25:36 -0800 (PST), oleg korenevich > wrote: > > >>Thanks for help. In first case all vars is python integers, maybe >>math.floor is redundant, but i'm afraid that same error with math >>module call will occur in other places of app, where math is needed. >>Strange thing here is that math library call is not a system call, and >>strange exception ValueError (all values have right values) and why in >>braces i have (4, Interruted system call). >> > math.floor() may still be a system call of some sort if access to > the math processor requires synchronization between processes (that is, > the math processor/registers are maintained as a separate structure > apart from the task status during process switches). {Yes -- that is a > wild hypothesis} One thing to remember about errno is that C library code will set it to a non-zero value when an error is encountered, but (I believe) there's no requirement to clear it in the absence of an error. EINTR might just be left over from some long-gone I/O call, then reported "just in case" in handling an exception that didn't involve the C library at all. As a C coder there are times when it's wise to clear errno yourself to make sure your code doesn't get fooled. Mel. From michal.hantl at gmail.com Thu Feb 2 15:23:16 2012 From: michal.hantl at gmail.com (Michal Hantl) Date: Thu, 2 Feb 2012 12:23:16 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: <13539673.900.1328214196126.JavaMail.geo-discussion-forums@vbhn11> See the link I attached. Ruby-like blocks would be nice too. Implicit returns. Better strings like """My name is #{name}""". From stefan at bytereef.org Thu Feb 2 15:54:04 2012 From: stefan at bytereef.org (Stefan Krah) Date: Thu, 2 Feb 2012 21:54:04 +0100 Subject: [ANN] cdecimal-2.3 released Message-ID: <20120202205404.GA18353@sleipnir.bytereef.org> Hi, I'm pleased to announce the release of cdecimal-2.3. cdecimal is a fast drop-in replacement for the decimal module in Python's standard library. Blurb ===== cdecimal is a complete implementation of IBM's General Decimal Arithmetic Specification. With the appropriate context parameters, cdecimal will also conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Typical performance gains over decimal.py are between 30x for I/O heavy benchmarks and 80x for numerical programs. In a PostgreSQL database benchmark, the speedup is 12x. +---------+-------------+--------------+-------------+ | | decimal | cdecimal | speedup | +=========+=============+==============+=============+ | pi | 42.75s | 0.58s | 74x | +---------+-------------+--------------+-------------+ | telco | 172.19s | 5.68s | 30x | +---------+-------------+--------------+-------------+ | psycopg | 3.57s | 0.29s | 12x | +---------+-------------+--------------+-------------+ In the pi benchmark, cdecimal often performs better than Java's BigDecimal running on Java HotSpot(TM) 64-Bit Server VM. What's New ========== o The underlying library - libmpdec - now has a very comprehensive test suite against decNumber. o libmpdec now has full support for compilers without uint64_t. o Code coverage of cdecimal has been increased to 100%. Now both libmpdec and cdecimal have 100% coverage. o Improved code for conversion of small Python integers to Decimals leads to a performance gain of around 15%. o Added real(), imag(), conjugate(), __complex__() methods. o Add Fraction and complex comparisons (enabled for Python 3.2). o Support for DecimalTuple output. Stability ========= Both cdecimal and libmpdec have an extremely conservative release policy. When new features are added, the complete test suite is run both with and without Valgrind on many different platforms. With the added tests against decNumber, this takes around 8 months on four cores. Install ======= Since cdecimal is listed on PyPI, it can be installed using pip: pip install cdecimal Windows installers are available at: http://www.bytereef.org/mpdecimal/download.html Links ===== http://www.bytereef.org/mpdecimal/index.html http://www.bytereef.org/mpdecimal/changelog.html http://www.bytereef.org/mpdecimal/download.html Checksums of the released packages ================================== 03f76f4acbb6e7f648c6efc6e424bbc1b4afb5632dac5196f840e71f603a2b4a mpdecimal-2.3.tar.gz b0fd5bec2cc6a6035bc406339d020d2f4200a7dce8e8136a2850612a06508ed1 mpdecimal-2.3.zip d737cbe43ed1f6ad9874fb86c3db1e9bbe20c0c750868fde5be3f379ade83d8b cdecimal-2.3.tar.gz 84afd94126549a3c67c3bab7437d085347f9d05c cdecimal-2.3.win-amd64-py2.6.msi ba0fbb1f9314dcef29481414a5c3496ec159df2e cdecimal-2.3.win-amd64-py2.7.msi d11bbd560e9cb9d34b0e7a068ac1c1eac5371428 cdecimal-2.3.win-amd64-py3.1.msi d024148ea603dc8e82f8371ebdfaa0e65f5a9945 cdecimal-2.3.win-amd64-py3.2.msi d196a9e0b44dcb75bbf4eda44078b766e6113f72 cdecimal-2.3.win32-py2.6.msi e2b044da6c241df0911059216821c9865cb9e4f0 cdecimal-2.3.win32-py2.7.msi 7e8b47eb3a2f50191e76f981fbe55050f13495e8 cdecimal-2.3.win32-py3.1.msi 61be767b91aab0ba0d602fb2b23f6d882cafec05 cdecimal-2.3.win32-py3.2.msi a2278910a5b447af963e1d427dbeb48f49e377be cdecimal-2.3-no-thread.win-amd64-py2.6.msi 8da96d2f1ab1a98062cd43cb4f381b47309d8c22 cdecimal-2.3-no-thread.win-amd64-py2.7.msi 85cd3ff4496aa7e0d0979d1695eef27cc7735c28 cdecimal-2.3-no-thread.win-amd64-py3.1.msi 6c179a1284aceb3a7bfc481daae1d7d60359d487 cdecimal-2.3-no-thread.win-amd64-py3.2.msi 40f245e907512c5d3602ba5993755a0b4b67ca80 cdecimal-2.3-no-thread.win32-py2.6.msi 960eb9bfd9fcf0faee6493506c1917d46536193a cdecimal-2.3-no-thread.win32-py2.7.msi 42b651ee1bf4c94611c43522d69f1965515949b8 cdecimal-2.3-no-thread.win32-py3.1.msi ec26f14c35502d1d5488d440d7bc22ad41e9ac65 cdecimal-2.3-no-thread.win32-py3.2.msi From jeandupont115 at gmail.com Thu Feb 2 15:57:55 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Thu, 2 Feb 2012 12:57:55 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] Message-ID: I'd like to read in the output of a voltcraft vc960 voltmeter connected to a usb-port. I found the perl-script below but I'd like to accomplish the same with python: I guess I have to use the module serial but I don't know how I should set the serial parameters so they are the same as in the perl-script. Could someone supply me the command for setting the serial-parameters correctly in Python? thanks Jean #!/usr/bin/perl use strict; use warnings; use Device::SerialPort; die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; my ($devicepath) = @ARGV; my $port = new Device::SerialPort($devicepath); die "Couldn't open serial port" if ! defined $port; $port->baudrate(2400); $port->databits(8); $port->parity("none"); $port->stopbits(1); $port->handshake("none"); $port->rts_active(0); $port->dtr_active(1); #$port->read_char_time(5); # wait 5ms per character $port->read_const_time(200); # 0.2 second per unfulfilled "read" call $| = 1; # autoflush STDOUT while(1) { my ($nin, $in) = $port->read(255); print $in; } $port->close; From edriscoll at wisc.edu Thu Feb 2 16:20:48 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Thu, 02 Feb 2012 15:20:48 -0600 Subject: copy on write In-Reply-To: <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> <25876847.362.1328189597333.JavaMail.geo-discussion-forums@prcu6> Message-ID: <4F2AFE30.80203@wisc.edu> On 01/-10/-28163 01:59 PM, 88888 Dihedral wrote: >> If you're working in C++ and overload your operators so that 'a +=' >> and 'a = + b' have different observable behaviors (besides perhaps >> time), then either your implementation is buggy or your design is very >> bad-mannered. >> >> Evan > > Do you mean the result instances after 'a+= and 'a=a+b' or > the actions of behaviors of instances involved in performing 'a+= and 'a=a+b'? > I mean "if which operation you called is distinguishable in any way besides the time it takes to run or by tracing it through in a debugger" That means: 1. The value of 'a' should be the same after executing 'a+=b' and 'a=a+b' 2. The actual result of the expression should be the same in both cases (in both cases it should be a reference to a) 3. Any additional side effects performed (ew!) should be the same in both cases Evan From miki.tebeka at gmail.com Thu Feb 2 16:55:45 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 2 Feb 2012 13:55:45 -0800 (PST) Subject: simple system for building packages for multiple platforms? In-Reply-To: References: Message-ID: <27818322.1316.1328219745948.JavaMail.geo-discussion-forums@yqtt30> IMO you can have different versions of Python on the same machine. So it's two windows machines. (Assuming you're going with *one* OS version :) Also note there is some legal mambo jumbo around distributing MSVC DLLs (unless you plan to use mingw). From miki.tebeka at gmail.com Thu Feb 2 16:55:45 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Thu, 2 Feb 2012 13:55:45 -0800 (PST) Subject: simple system for building packages for multiple platforms? In-Reply-To: References: Message-ID: <27818322.1316.1328219745948.JavaMail.geo-discussion-forums@yqtt30> IMO you can have different versions of Python on the same machine. So it's two windows machines. (Assuming you're going with *one* OS version :) Also note there is some legal mambo jumbo around distributing MSVC DLLs (unless you plan to use mingw). From andrea.crotti.0 at gmail.com Thu Feb 2 17:53:21 2012 From: andrea.crotti.0 at gmail.com (andrea crotti) Date: Thu, 2 Feb 2012 22:53:21 +0000 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: 2012/2/2 Amirouche Boubekki : > They are solution to write Python code that translates to javascript see > this thread > http://mail.python.org/pipermail/python-list/2011-November/1283110.html > Mm I don't think it's what the OP is asking (unless I misunderstood...). I think he wants to compile some syntax TO Python. But I don't really see why you would something like this (if not for fun). Then how are you going to maintain the code? Maintain the compiled code or the source? And proving that your translator is always correct I think it's quite a hard task too... From ivanov161 at gmail.com Thu Feb 2 18:37:03 2012 From: ivanov161 at gmail.com (=?KOI8-U?B?88XSx8XKIPfMwcTJzcnSz9fJ3g==?=) Date: Fri, 3 Feb 2012 01:37:03 +0200 Subject: Python embeded in c++ application. Can't load python module if application is placed in folder with unicode chars. Message-ID: Hello. Please help me to import python module in my application that has python 2.7.2 embeded. I tried example from this link http://docs.python.org/extending/embedding.html#embedding-python-in-c paragraph 5.3. If i place program in folder D:\temp\test_python\test_python?vnes p?\Debug I will get error - Failed to load "multiply". My localization settings (system language) don't correspond the chars' language used in path. From tjreedy at udel.edu Thu Feb 2 19:26:27 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 19:26:27 -0500 Subject: Python embeded in c++ application. Can't load python module if application is placed in folder with unicode chars. In-Reply-To: References: Message-ID: On 2/2/2012 6:37 PM, ?????? ???????????? wrote: > Hello. Please help me to import python module in my application that > has python 2.7.2 embeded. > I tried example from this link > http://docs.python.org/extending/embedding.html#embedding-python-in-c > paragraph 5.3. > If i place program in folder D:\temp\test_python\test_python?vnes > p?\Debug I will get error - Failed to load "multiply". > My localization settings (system language) don't correspond the chars' > language used in path. Easiest is to change your folder name to all ascii. This sort of thing will work better in future 3.x, but even then, a mismatch between encodings is a problem. -- Terry Jan Reedy From ramit.prasad at jpmorgan.com Thu Feb 2 19:53:38 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Fri, 3 Feb 2012 00:53:38 +0000 Subject: unzip function? In-Reply-To: <4f1753cc$0$29987$c3e8da3$5496439d@news.astraweb.com> References: <4f16e4e7$0$29994$c3e8da3$5496439d@news.astraweb.com> <4f1753cc$0$29987$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF47410D75F@SCACMX008.exchad.jpmchase.net> >>> If you understand what zip does, it should be obvious. >> >> Nobody likes to be told the thing they're confused about is trivial. >Nobody likes to be told to brush their teeth, eat their vegetables or clean their room. Then they grow up and learn that life is full of things that you do because you have to, not because you want to. >Learning that some things that they are confused about are trivial is one of those things. Normally, I agree with you, but I think it's less about the truth and how it is stated. "You are wrong, it is like..." VS. "You are a grade-A moron, it is like..." They both teach; one just does it less offensively. What is obvious to one person is not always obvious to everyone. :) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From jason at powerpull.net Thu Feb 2 20:04:32 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 3 Feb 2012 01:04:32 +0000 Subject: Use logging level across application and modules Message-ID: Base module: http://pastebin.com/nQCG5CRC Another module: http://pastebin.com/FFzCCjwG Application: http://pastebin.com/370cWJtT I have a module that will provide base functionality, such as logging and authentication. I have other specialized modules that provide additional functionality. One module will provide database connections, another information about users and groups, etc. I have an application script that uses the base module and one or more specialized modules. I want to allow the user to select a preferred logging level. That is easy to do by passing that level as an argument to base.get_logger(). However, the application also uses the other module; how do I set the logging level there to match the user's preference? From emayssat at gmail.com Thu Feb 2 20:09:15 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Thu, 2 Feb 2012 17:09:15 -0800 Subject: multiple constructor __init__ Message-ID: Hello all, I would like to instantiate my class as follow QObject(, ) QObject() an example would be http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html How can I do this without have to specify parent= in the second version (I always need to supply the parent parameter, but I would like to supply it last) I have read this http://stackoverflow.com/questions/356718/how-to-handle-constructors-or-methods-with-a-different-set-or-type-of-argument but all the suggested methods do not work as I want Any idea? -- Emmanuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 2 20:19:22 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 2 Feb 2012 18:19:22 -0700 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Thu, Feb 2, 2012 at 3:53 PM, andrea crotti wrote: > 2012/2/2 Amirouche Boubekki : >> They are solution to write Python code that translates to javascript see >> this thread >> http://mail.python.org/pipermail/python-list/2011-November/1283110.html >> > > Mm I don't think it's what the OP is asking (unless I misunderstood...). > I think he wants to compile some syntax TO Python. > But I don't really see why you would something like this (if not for fun). Maybe because you think that Python syntax could be improved upon -- for instance, Python with pattern-matching would be freaking awesome -- but at the same time you want to leverage Python's extensive ecosystem of libraries. So instead of creating your own brand-new language with no third party libraries whatsoever, you create one that just compiles down to regular Python. > Then how are you going to maintain the code? Maintain the compiled > code or the source? As with all compiled software, you maintain the input, not the output. > And proving that your translator is always correct That's what unit tests are for. Cheers, Ian From clp2 at rebertia.com Thu Feb 2 20:24:23 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 2 Feb 2012 17:24:23 -0800 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: On Thu, Feb 2, 2012 at 5:09 PM, Emmanuel Mayssat wrote: > Hello all, > > I would like to instantiate my class as follow > > QObject(, ) > QObject() > > an example would be > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html > > How can I do this without have to specify parent= in the second > version > (I always need to supply the parent parameter, but I would like to supply it > last) > > I have read this > http://stackoverflow.com/questions/356718/how-to-handle-constructors-or-methods-with-a-different-set-or-type-of-argument > but all the suggested methods do not work as I want > > Any idea? I believe you can approximate that using a keyword-only argument without a default value: # Untested! # Requires Python 3.x class QObject(object): def __init__(self, param1=some_default, *, parent): # ? obj1 = QObject(parent=daddy) obj2 = QObject(arg1, parent=daddy) obj3 = QObject(daddy) # ERROR obj4 = QObject(arg1, daddy) # ERROR obj5 = QObject() # ERROR Cheers, Chris -- Using names instead of some arbitrary ordering makes much more sense. http://rebertia.com From rosuav at gmail.com Thu Feb 2 21:51:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Feb 2012 13:51:49 +1100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On Fri, Feb 3, 2012 at 9:53 AM, andrea crotti wrote: > Mm I don't think it's what the OP is asking (unless I misunderstood...). > I think he wants to compile some syntax TO Python. > But I don't really see why you would something like this (if not for fun). > > Then how are you going to maintain the code? Maintain the compiled > code or the source? And proving that your translator is always correct > I think it's quite a hard task too... There's two similar concepts here. 1) Skeleton codegens. You do up some kind of template, run it through a program, and get a ready-to-fill-in code structure. In this case, you don't care so much about the translator's quality (if there's bugs/limitations, you fix 'em after codegenning), and will maintain the compiled code. 2) Compilation to Python. You write your program in some other language, run it through a program, and get executable code out of it. You want the translator to be perfect (so that you don't have to edit the resulting code), and will maintain the original source. I think the OP is looking for #2. I've used that sort of technique a number of times (not with Python specifically, but with other languages that lack certain handy features); usually the source is trivially translateable into the output, with 99% of syntax identical (for instance, one oft-wanted feature is a C-like #include - I've written .php.m4 files that get processed through M4 to become PHP files). ChrisA From research at johnohagan.com Thu Feb 2 22:08:06 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 14:08:06 +1100 Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: <20120203140806.ffd1f99f8613ac438b8df719@johnohagan.com> On Thu, 02 Feb 2012 12:25:00 -0500 Terry Reedy wrote: > On 2/2/2012 9:17 AM, John O'Hagan wrote: > > > It's not so much about the type of x but that of x[1]. Wouldn't it > > be possible to omit the assignment simply if the object referred to > > by x[1] uses "+=" without creating a new object? That way, > > some_tuple[i] += y will succeed if some_tuple[i] is a list but not > > with, say, an int. That seems reasonable to me. > > There was considerable discussion of the exact semantics of augmented > operations when they were introduced. I do not remember if that > particular idea was suggested (and rejected) or not. You could try to > look at the PEP, if there is one, or the dicussion ( probably on > pydev list). > I think we're 12 years late on this one. It's PEP 203 from 2000 and the key phrase was: "The in-place function should always return a new reference, either to the old `x' object if the operation was indeed performed in-place, or to a new object." If this had read: "The in-place function should return a reference to a new object if the operation was not performed in-place." or something like that, we wouldn't be discussing this. The discussion on py-dev at the time was quite limited but there was some lively debate on this list the following year (in the context of widespread controversy over new-fangled features which also included list comprehensions and generators), to which the BDFL's response was: "You shouldn't think "+= is confusing because sometimes it modifies an object and sometimes it does". Gee, there are lots of places where something that's *spelled* the same has a different effect depending on the object types involved." That's true, but I don't think there should be a different effect depending on what _name_ we use for an operand: >>> t=([],) >>> l=t[0] >>> l is t[0] True >>> l+=[1] >>> t ([1],) >>> t[0]+=[1] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object does not support item assignment >>> t ([1, 1],) >>> l is t[0] True Same object, same operator, different name, different outcome. Maybe that was obvious from the foregoing discussion, but it shocked me when put that way. John From tjreedy at udel.edu Thu Feb 2 22:43:16 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 02 Feb 2012 22:43:16 -0500 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote: > Hello all, > > I would like to instantiate my class as follow > > > QObject(, ) > QObject() > > an example would be > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html > > How can I do this without have to specify parent= in the second > version > (I always need to supply the parent parameter, but I would like to > supply it last) The same way range(stop) versus range(start,stop) works. But I really recommend against that api. It makes both doc and code messy. You need a really good reason to not use the obvious def __init__(self, parent, param=default):... -- Terry Jan Reedy From teddy.toyama at gmail.com Thu Feb 2 23:13:25 2012 From: teddy.toyama at gmail.com (Teddy Toyama) Date: Thu, 2 Feb 2012 20:13:25 -0800 Subject: python CPU usage 99% on ubuntu aws instance using eventlet Message-ID: Okay, I am crossposting this from the eventlet dev mailing list since I am in urgent need of some help. I am running eventlet 0.9.16 on a Small (not micro) reserved ubuntu 11.10 aws instance. I have a socketserver that is similar to the echo server from the examples in the eventlet documentation. When I first start running the code, everything seems fine, but I have been noticing that after 10 or 15 hours the cpu usage goes from about 1% to 99+%. At that point I am unable to make further connections to the socketserver. This is the important (hopefully) parts of the code that I'm running: # the part of the code that listens for incoming connections def socket_listener(self, port, socket_type): L.LOGG(self._CONN, 0, H.func(), 'Action:Starting|SocketType:%s' % socket_type) listener = eventlet.listen((self._host, port)) listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) pool = eventlet.GreenPool(20000) while True: connection, address = listener.accept() connection.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) """ I want this loop to run as fast as possible. I previously grabbed the first message that a plug/device sent here and used that information to add a new object to the socket_hash. Instead of doing that here I've relocated that logic to the spawned object so that this loop is doing as little work as possible. """ L.LOGG(self._CONN, 0, H.func(), 'IPAddress:%s|GreenthreadsFree:%s|GreenthreadsRunning:%s' % (str(address[0]), str(pool.free()),str(pool.running()))) pool.spawn_n(self.spawn_socketobject, connection, address, socket_type) listener.shutdown(socket.SHUT_RDWR) listener.close() The L.LOGG method simply logs the supplied parameters to a mysql table. I am running the socket_listener in a thread like so: def listen_phones(self): self.socket_listener(self._port_phone, 'phone') t_phones = Thread(target = self.listen_phones) t_phones.start() >From my initial google searches I thought the issue might be similar to the bug reported at https://lists.secondlife.com/pipermail/eventletdev/2008-October/000140.html but I am using a new version of eventlet so surely that cannot be it? Is there any additional information I can provide to help further troubleshoot the issue? Teddy -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason at powerpull.net Thu Feb 2 23:50:29 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 3 Feb 2012 04:50:29 +0000 Subject: Use logging level across application and modules In-Reply-To: References: Message-ID: > Base module: ?http://pastebin.com/nQCG5CRC > Another module: ?http://pastebin.com/FFzCCjwG > Application: ?http://pastebin.com/370cWJtT > > I have a module that will provide base functionality, such as logging > and authentication. > I have other specialized modules that provide additional > functionality. ?One module will provide database connections, another > information about users and groups, etc. > I have an application script that uses the base module and one or more > specialized modules. > > I want to allow the user to select a preferred logging level. ?That is > easy to do by passing that level as an argument to base.get_logger(). > However, the application also uses the other module; how do I set the > logging level there to match the user's preference? I figured a way to do this. In the base module I created a global variable loglevel. I set the logging level according to that value. I set the variable from my application script. Because of the memoization of the get_logger() call, the other modules get that same loglevel value. From steve+comp.lang.python at pearwood.info Fri Feb 3 00:04:39 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 05:04:39 GMT Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> Message-ID: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 14:08:06 +1100, John O'Hagan wrote: > I think we're 12 years late on this one. It's PEP 203 from 2000 and the > key phrase was: > > "The in-place function should always return a new reference, either to > the old `x' object if the operation was indeed performed in-place, or to > a new object." > > If this had read: > > "The in-place function should return a reference to a new object if the > operation was not performed in-place." > > or something like that, we wouldn't be discussing this. And what should it return if the operation *is* performed in-place? "Don't return anything" is not an option, Python doesn't have procedures. That implies that __iadd__ etc. should return None. But two problems come to mind: 1) Using None as an out-of-band signal to the interpreter to say "don't perform the assignment" makes it impossible for the augmented assignment method to return None as the result. If we only think about numeric operations like x += 1 then we might not care, but once you consider the situation more widely the problem is clear: x = Fact(foo) y = Fact(bar) x & y # Returns a composite Fact, or None if they are contradictory With your suggestion, x &= y fails to work, but only sometimes. And when it fails, it doesn't fail with an explicit exception, but silently fails and then does the wrong thing. This makes debugging a horror. 2) And speaking of debugging, sometimes people forget to include the return statement in methods. Normally, the left hand side of the assignment then gets set to None, and the error is pretty obvious as soon as you try to do something with it. But with your suggestion, instead of getting an exception, it silently fails, and your code does the wrong thing. I suppose that they could have invented a new sentinel, or a special exception to be raised as a signal, but that's piling complication on top of complication, and it isn't clear to me that it's worth it for an obscure corner case. Yes, the current behaviour is a Gotcha, but it's a Gotcha that makes good sense compared to the alternatives. Ultimately, augmented assignment is *assignment*, just like it says on the tin. t[1] += x is syntactic sugar for t[1] = t[1].__iadd__(x). It can't and shouldn't fail to raise an exception if t is a tuple, because tuple item assignment *must* fail. The problem is that lists treat __iadd__ as an in-place optimization, and this clashes with tuple immutability. But if lists *didn't* treat __iadd__ as in-place, people would complain when they used it directly without a tuple wrapper. Perhaps lists shouldn't define += at all, but then people will complain that mylist += another_list is slow. Telling them to use mylist.extend instead just makes them cranky. After all, mylist + another_list works, so why shouldn't += work? Ultimately, there is no right answer, because the multitude of requirements are contradictory. No matter what Python did, somebody would complain. -- Steven From timr at probo.com Fri Feb 3 00:10:12 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Feb 2012 21:10:12 -0800 Subject: changing sys.path References: Message-ID: Andrea Crotti wrote: > >So suppose I want to modify the sys.path on the fly before running some code >which imports from one of the modules added. > >at run time I do >sys.path.extend(paths_to_add) > >but it still doesn't work and I get an import error. Are you actually adding multiple paths? One possible cause for error would be this: sys.path.extend( '/usr/local/lib' ) That succeeds, but it doesn't do what you meant. It adds "/" as a path, then "u", then "s", then "r", and so on. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Fri Feb 3 00:14:52 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 02 Feb 2012 21:14:52 -0800 Subject: Problem sending an email in html with mime image References: Message-ID: <87rmi7pc0b3g2f901re67v6vkb0f0ro0lp@4ax.com> Ariel wrote: > >Hi everybody I have a question, here is my problem I want to send an >email with content in html with an image embed so I converted the >image binary in mime text and then I put the mime code inside the src >attribute of the html like this: > > Do email readers actually implement the data: scheme in tags? >The problem is that if I don't put the image mime code inside the src >the email is sent but when I put the code then the email is not send >and I don't get any error message. There must be something else going on. The content of the message is irrelevant to the sending process, unless it makes your message way too big. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From rosuav at gmail.com Fri Feb 3 00:28:05 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 3 Feb 2012 16:28:05 +1100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano wrote: > No matter what Python did, somebody would complain. +1 This is, I think, the ultimate truth of the matter. ChrisA From no.email at nospam.invalid Fri Feb 3 02:33:00 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 02 Feb 2012 23:33:00 -0800 Subject: [ANN] cdecimal-2.3 released References: Message-ID: <7xfwespe1f.fsf@ruckus.brouhaha.com> Stefan Krah writes: > cdecimal is a complete implementation of IBM's General Decimal Arithmetic > Specification. With the appropriate context parameters, cdecimal will also > conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic. Cool. I wonder when we'll start seeing this in non-IBM hardware CPU's. > Both cdecimal and libmpdec have an extremely conservative release policy. > When new features are added, the complete test suite is run both with and > without Valgrind on many different platforms. With the added tests against > decNumber, this takes around 8 months on four cores. Wow. I wonder whether it's worth looking into some formal verification if the required level of confidence is that high. From nagle at animats.com Fri Feb 3 03:14:33 2012 From: nagle at animats.com (John Nagle) Date: Fri, 03 Feb 2012 00:14:33 -0800 Subject: Killing threads, and os.system() In-Reply-To: References: Message-ID: <4f2b976a$0$78773$742ec2ed@news.sonic.net> On 1/31/2012 8:04 AM, Dennis Lee Bieber wrote: > ({muse: who do we have to kill > to persuade OS designers to incorporate something like the Amiga ARexx > "rexxport" system}). QNX, which is a real-time microkernel which looks like POSIX to applications. actually got interprocess communication right. It has to; everything in QNX is done by interprocess communication, including all I/O. File systems and drivers are ordinary programs. The kernel just handles message passing, CPU dispatching, and timers. QNX's message passing looks more like a subroutine call than an I/O operation, and this has important implications for efficient CPU dispatching. Any QNX system call that can block is really a message pass. Message passes can be given a timeout, and they can be canceled from another thread. The "system call" then returns with an error status. This provides a way to keep threads from getting "stuck" in a system call. (Unfortunately, QNX, which survived as a separate company for decades, sold out to Harmon (car audio) a few years ago. They had no clue what to do with an OS. They sold it to Research In Motion, the Blackberry company, which is in the process of tanking.) Python's thread model is unusually dumb. You can't send signals to other threads, you can't force an exception in another thread, and I won't even get into the appalling mess around the Global Interpreter Lock. This has forced the use of subprocesses where, in other languages, you'd use threads. Of course, you load a new copy of the interpreter in each thread, so this bloats memory usage. John Nagle From antoon.pardon at rece.vub.ac.be Fri Feb 3 04:08:19 2012 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 03 Feb 2012 10:08:19 +0100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2BA403.2020309@rece.vub.ac.be> On 02/03/2012 06:04 AM, Steven D'Aprano wrote: > Ultimately, there is no right answer, because the multitude of > requirements are contradictory. No matter what Python did, somebody would > complain. Which makes me wonder why it was introduced at all, or at least so fast If you see the difference in speed in introducing augmented assignment vs how long it took to get conditional expression I start thinking of a bikeshed. In the first case we have something that raises semantic questions that are difficult to resolve, in the second case the semantics were clear, the big problem that delayed introduction was what syntax to use. But the second took a lot longer to become part of the language than the first, which seems very odd to me. -- Antoon Pardon From steve+comp.lang.python at pearwood.info Fri Feb 3 04:25:36 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 09:25:36 GMT Subject: Killing threads, and os.system() References: <4f2b976a$0$78773$742ec2ed@news.sonic.net> Message-ID: <4f2ba810$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 00:14:33 -0800, John Nagle wrote: > I won't even get into the appalling mess around the Global Interpreter > Lock. You know full well that IronPython and Jython don't have a GIL. If the GIL was as harmful as you repeatedly tell us, why haven't you, and everyone else, migrated to IronPython and Jython? Oh yeah, maybe it's because CPython, even with the GIL, is significantly faster than the two implementations without a GIL. Go figure. But never mind the facts, spreading the FUD about Python is much more fun. Hey, I hear that Python 3 is tanking too, and millions of Python developers are rushing, rushing I say, to port their code to Go. Or was it Ruby? Possibly Lua. Maybe VBScript. > This has forced the use of subprocesses where, in other > languages, you'd use threads. Only if by "forced" you mean "not forced at all". http://docs.python.org/library/multiprocessing.html http://www.stackless.com/ http://pypi.python.org/pypi/greenlet/ http://twistedmatrix.com/trac/ http://www.gevent.org/ http://code.google.com/p/cogen/ http://www.kamaelia.org/Home http://code.google.com/p/syncless/ http://opensource.hyves.org/concurrence/ http://www.tornadoweb.org/ http://docs.python.org/library/asyncore.html http://pyro.sourceforge.net/ http://wiki.python.org/moin/ParallelProcessing -- Steven From mcepl at redhat.com Fri Feb 3 05:42:47 2012 From: mcepl at redhat.com (Matej Cepl) Date: Fri, 03 Feb 2012 11:42:47 +0100 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: On 3.2.2012 02:19, Ian Kelly wrote: >> Then how are you going to maintain the code? Maintain the compiled >> code or the source? > > As with all compiled software, you maintain the input, not the output. I don't think that's what was the question. CoffeeScript is a hopeless hack in the hopeless situation of Javascript world where no language development is available (meaning, time between filing a bug to the moment the change is useful in The Real World? is many many years). Ask anybody developing in CoffeeScript/Vala how much they love debugging when they have to go through different styles of errors, bugs in the intermediate processes, etc. In the end all these languages IMHO either develop a new frontend for gcc/clang/PyPy (or fork of CPython) or die, because the former is not that much more difficult than writing your preprocessor, I believe. Best, Mat?j From research at johnohagan.com Fri Feb 3 05:47:50 2012 From: research at johnohagan.com (John O'Hagan) Date: Fri, 3 Feb 2012 21:47:50 +1100 Subject: copy on write In-Reply-To: <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20120203214750.021fe45bdf8c823755b31613@johnohagan.com> On 03 Feb 2012 05:04:39 GMT Steven D'Aprano wrote: > On Fri, 03 Feb 2012 14:08:06 +1100, John O'Hagan wrote: > > > I think we're 12 years late on this one. It's PEP 203 from 2000 and > > the key phrase was: > > > > "The in-place function should always return a new reference, either > > to the old `x' object if the operation was indeed performed > > in-place, or to a new object." > > > > If this had read: > > > > "The in-place function should return a reference to a new object if > > the operation was not performed in-place." > > > > or something like that, we wouldn't be discussing this. > > And what should it return if the operation *is* performed in-place? Not knowing anything about the inner workings of the interpreter, I'm agnostic on that as long as it's not "a new reference". Perhaps the old reference? [...snip undoubted reasons why returning None wouldn't work...] I don't know what would work. Maybe it is insoluble. But didn't Hrvoje Niksic's post in this thread suggest it could have been implemented to work the way I'm saying, even supplying code to demonstrate it? All I'm saying is that however it's implemented, x[i] += y should simply mutate x[i] in-place if x[i] implements that, otherwise it should do x[i] = x[i] + y. If I can say it under 25 words, surely it's implementable? (Whether it's practical to do so is another question.) The x[i] in x[i] += y can be seen as a reference to an object to be incremented rather than an assignment (despite the name). In that view, whether the name x[i] needs to be rebound to a new object, resulting in an assignment, depends on the capabilities of x[i], not x. > > Yes, the current behaviour is a Gotcha, but it's a Gotcha that makes > good sense compared to the alternatives. I think it's worse than a Gotcha. IMHO a Gothcha is, for example, the mutable default arguments thing, which makes sense once you get it. This one has the bizarre consequence that what happens when you operate on an object depends on which name you use for the object. Not to mention that it succeeds after raising an exception. > Ultimately, augmented assignment is *assignment*, just like it says > on the tin. t[1] += x is syntactic sugar for t[1] = t[1].__iadd__(x). > It can't and shouldn't fail to raise an exception if t is a tuple, > because tuple item assignment *must* fail. That makes sense if we view it strictly as assignment (but in that case the mutation of t[1] should not occur either). But isn't it equally true if we say that z = t[1], then t[1] += x is syntactic sugar for z = z.__iadd__(x)? Why should that fail, if z can handle it? [...] > > Ultimately, there is no right answer, because the multitude of > requirements are contradictory. No matter what Python did, somebody > would complain. > Not complaining, just trying to contribute to the best of my ability. :) John From bruno.desthuilliers at gmail.com Fri Feb 3 07:03:32 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Fri, 3 Feb 2012 04:03:32 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> <13539673.900.1328214196126.JavaMail.geo-discussion-forums@vbhn11> Message-ID: <22f59e96-fcad-4127-ac0d-3476a1147588@e27g2000vbu.googlegroups.com> On Feb 2, 9:23?pm, Michal Hantl wrote: > See the link I attached. > Ruby-like blocks would be nice too. > Implicit returns. > Better strings like """My name is #{name}""". Uhu... Looks like you want Ruby, not Python From johnphilliplay at gmail.com Fri Feb 3 08:10:11 2012 From: johnphilliplay at gmail.com (John Lay) Date: Fri, 3 Feb 2012 05:10:11 -0800 (PST) Subject: Help with COM_error Message-ID: I am not a programmer, but this past week I have had a crash course in python scripting am have been rather impressed with myself for having written a fairly complicated script that among many other processes reads a database table via SearchCursor, populates a word template via Bookmarks, then saves the document out as a PDF. The only problem is that it only works on my computer. When I move the script to another computer with the same setup, I continue to receive a Com_error. The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) statement. I have tried both win32com.client and comtypes.client and receive a similar error for both. win32.client: com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ \1033\\WDMAIN11.CHM', 36966, ), None) comtypes.client: COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', 36966, None)) It has been suggested that I try python-docx, but I have not been able to get the module to work for me and I have been unable to find any documentation on it. Can anyone help with the com errors? What do they mean? How do I resolve them? Any help would be appreciated. John From jeandupont115 at gmail.com Fri Feb 3 08:11:54 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Fri, 3 Feb 2012 05:11:54 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: Message-ID: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> As my request might have been too much asked, I have started doing some coding myself. I'm in doubt about the readline statement -which doesn't show anything received- as the meter sends continuously streams of 11 bytes Is there a way to just monitor with python what is arriving at a serial port? #!/usr/bin/python #version 1-2-2012, script to read data from voltcraft vc940-meter import serial, time, os voltport='/dev/ttyUSB2' print "Be sure the Voltcraft is connected to ttyUSB2" print "Enter a filename:", filename = raw_input() voltdata = open(filename,'w') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, timeout=15) print "rs-232 parameters of Voltcraft: ", ser2 print "Opening " + ser2.portstr received=ser2.readline() print received print "Goodbye, data logged in file:" print filename ser2.close() # Close file voltdata.close() On 2 feb, 21:57, Jean Dupont wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly > in Python? > > thanks > Jean > > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); ? ? # wait 5ms per character > $port->read_const_time(200); ? # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > ? ? ? ? my ($nin, $in) = $port->read(255); > ? ? ? ? print $in; > > } > > $port->close; From nathan.alexander.rice at gmail.com Fri Feb 3 09:08:51 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 3 Feb 2012 09:08:51 -0500 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: >> Mm I don't think it's what the OP is asking (unless I misunderstood...). >> I think he wants to compile some syntax TO Python. >> But I don't really see why you would something like this (if not for fun). > > Maybe because you think that Python syntax could be improved upon -- > for instance, Python with pattern-matching would be freaking awesome > -- but at the same time you want to leverage Python's extensive > ecosystem of libraries. ?So instead of creating your own brand-new > language with no third party libraries whatsoever, you create one that > just compiles down to regular Python. You can generalize the dictionary based dispatch used for "case" statements to do this. The main downsides are: 1.) You have to define your functions ahead of time or use lambdas 2.) The syntax is not quite as nice as it could be (e.g.) foo = DispatchDict({ Pattern1: f1, Pattern2: f2, etc... }) Reminds me more of javascript than I would like. >> Then how are you going to maintain the code? Maintain the compiled >> code or the source? > > As with all compiled software, you maintain the input, not the output. I think maintaining the output can be valuable. There are going to be things that can be expressed in the more verbose expanded form that will not be easily expressible in the terse pre-translated macro. Unfortunately, most macro writers don't put much time into making sure their macro produces concise code. >> And proving that your translator is always correct > > That's what unit tests are for. I have a love hate affair with unit tests. You need them, but I'd really rather analytically prove that my software is correct under some set of assumptions. Cheers, Nathan From rjngrj2010 at gmail.com Fri Feb 3 10:23:36 2012 From: rjngrj2010 at gmail.com (gujax) Date: Fri, 3 Feb 2012 07:23:36 -0800 (PST) Subject: IDLE not setting current directory in its path References: Message-ID: On Jan 31, 6:12?pm, Terry Reedy wrote: > On 1/31/2012 11:27 AM,gujaxwrote: > > > Thanks Terry, > > I see that the issue has been closed by you. > > However, I do not know how to run the patch on my Windows. Do I > > reinstall IDLE? > > Please suggest. I am using Python2.7 > Hi Terry, I changed the two files as suggested in your patch and it worked. Thank you, gujax > Choices: > 1. Wait for the next 2.7 release, which should be within a month. > Easiest ;-). Will get you all other patches too. > 2. Edit the files by hand, deleting lines marked - in the patch and > adding lines marked +. Or change lines so they match the + lines. > Harder, but you get the one change now instead of later. > 3. Download and install TortoiseHG, turn your python installation (or > just the idlelib directory) into a repository, apply the patch (or an > edited version thereof), and perhaps delete the repository stuff. I > would only do this if you want to learn to use (Tortoise)HG anyway, > perhaps so you can apply other patches too, without waiting. > > -- > Terry Jan Reedy From rjngrj2010 at gmail.com Fri Feb 3 10:31:03 2012 From: rjngrj2010 at gmail.com (gujax) Date: Fri, 3 Feb 2012 07:31:03 -0800 (PST) Subject: IDLE not setting current directory in its path References: Message-ID: <64b8a37e-bcba-4812-a819-d90f2e02e2e0@q8g2000pbb.googlegroups.com> On Jan 31, 6:12?pm, Terry Reedy wrote: > On 1/31/2012 11:27 AM, gujax wrote: > > > Thanks Terry, > > I see that the issue has been closed by you. > > However, I do not know how to run the patch on my Windows. Do I > > reinstall IDLE? > > Please suggest. I am using Python2.7 > Thank you Terry, The patch suggested by you has worked for me, gujax > Choices: > 1. Wait for the next 2.7 release, which should be within a month. > Easiest ;-). Will get you all other patches too. > 2. Edit the files by hand, deleting lines marked - in the patch and > adding lines marked +. Or change lines so they match the + lines. > Harder, but you get the one change now instead of later. > 3. Download and install TortoiseHG, turn your python installation (or > just the idlelib directory) into a repository, apply the patch (or an > edited version thereof), and perhaps delete the repository stuff. I > would only do this if you want to learn to use (Tortoise)HG anyway, > perhaps so you can apply other patches too, without waiting. > > -- > Terry Jan Reedy From rantingrickjohnson at gmail.com Fri Feb 3 10:35:25 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 3 Feb 2012 07:35:25 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9f5fbe2b-8278-4cc6-b0cb-e2acb39101c2@pk8g2000pbb.googlegroups.com> On Feb 2, 11:28?pm, Chris Angelico wrote: > On Fri, Feb 3, 2012 at 4:04 PM, Steven D'Aprano > > wrote: > > No matter what Python did, somebody would complain. > > +1 > > This is, I think, the ultimate truth of the matter. People would not complain if they did not care. The only useless complaint is people complaining about other people complaining. And the only thing worse than that is rabid fanboi brown-nosing! From devipriya0010 at gmail.com Fri Feb 3 11:12:07 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Fri, 3 Feb 2012 08:12:07 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... Message-ID: <989f9f0a-78fe-4638-a822-a1e6189651e5@n7g2000pbd.googlegroups.com> http://123maza.com/46/dos754/ From brenNOSPAMbarn at NObrenSPAMbarn.net Fri Feb 3 11:15:40 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Fri, 3 Feb 2012 16:15:40 +0000 (UTC) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > Perhaps lists shouldn't define += at all, but then people will > complain that mylist += another_list is slow. Telling them to use > mylist.extend instead just makes them cranky. After all, mylist + > another_list works, so why shouldn't += work? It would work, it just wouldn't work in-place. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From emayssat at gmail.com Fri Feb 3 11:30:50 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Fri, 3 Feb 2012 08:30:50 -0800 Subject: multiple constructor __init__ In-Reply-To: References: Message-ID: Yes, exactly like range .... http://coverage.livinglogic.de/Demo/classes/Range.py.html see handleargs function. Well that's short, but that's still too much code for what I want to do ;-) On Thu, Feb 2, 2012 at 7:43 PM, Terry Reedy wrote: > On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote: > >> Hello all, >> >> I would like to instantiate my class as follow >> >> >> QObject(, ) >> QObject() >> >> an example would be >> http://www.riverbankcomputing.**co.uk/static/Docs/PyQt4/html/**qmenu.html >> >> How can I do this without have to specify parent= in the second >> version >> (I always need to supply the parent parameter, but I would like to >> supply it last) >> > > The same way range(stop) versus range(start,stop) works. > But I really recommend against that api. > It makes both doc and code messy. > You need a really good reason to not use the obvious > def __init__(self, parent, param=default):... > > -- > Terry Jan Reedy > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Fri Feb 3 12:24:54 2012 From: andrea.crotti.0 at gmail.com (andrea crotti) Date: Fri, 3 Feb 2012 17:24:54 +0000 Subject: SnakeScript? (CoffeeScript for Python) In-Reply-To: References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: 2012/2/3 Dennis Lee Bieber : > On Thu, 2 Feb 2012 18:19:22 -0700, Ian Kelly > ? ? ? ? > > ? ? ? ?I spent nearly 20 years having to maintain the /output/ of such a > translator. > Yes I think that is the point, if the code you maintain and the code which you have to debug differ because there is a translator in the middle you're going to be in trouble before or later. Moreover, unless you only work alone (which is very unlikely) I think you should agree with everyone else in such a decision.. And if you really miss so much features that are not in Python at all, why not just use another programming language which has them then? From alec.taylor6 at gmail.com Fri Feb 3 13:33:54 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sat, 4 Feb 2012 05:33:54 +1100 Subject: Linker errors when attempting to install PyCrypto Message-ID: I'm getting linker errors when trying to install PyCrypto on Windows: C:\libraries\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win-amd64-2.7\Release\src\winrand.o build\temp.win-amd64-2.7\Release\src\winrandom.def -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -lws2_32 -ladvapi32 -lpython27 -lmsvcr90 -o "C:\Projects\satchmo_test\Prototype\src\pycrypto\lib\Crypto\Random\OSRNG\winrandom.pyd" Full output: http://pastebin.com/SYBkFt3h How can I resolve installation issues to get PyCrypto install properly on Python 2.7.2 x64? Thanks for all suggestions, Alec Taylor From silideba at gmail.com Fri Feb 3 15:06:48 2012 From: silideba at gmail.com (Debashish Saha) Date: Sat, 4 Feb 2012 01:36:48 +0530 Subject: No subject Message-ID: would u like to help me by answering some vbasic questions about python? -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Fri Feb 3 15:14:42 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 3 Feb 2012 12:14:42 -0800 Subject: No subject In-Reply-To: References: Message-ID: On Fri, Feb 3, 2012 at 12:06 PM, Debashish Saha wrote: > would u like to help me by answering some vbasic questions about python? You might prefer to ask such questions on the tutor mailing list instead: http://mail.python.org/mailman/listinfo/tutor Cheers, Chris From a.france.mailinglists at gmail.com Fri Feb 3 15:14:49 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Fri, 03 Feb 2012 21:14:49 +0100 Subject: No subject In-Reply-To: References: Message-ID: <4F2C4039.6030704@gmail.com> On 02/03/2012 09:14 PM, Chris Rebert wrote: > On Fri, Feb 3, 2012 at 12:06 PM, Debashish Saha wrote: >> would u like to help me by answering some vbasic questions about python? > You might prefer to ask such questions on the tutor mailing list instead: > http://mail.python.org/mailman/listinfo/tutor > > Cheers, > Chris Sounds like this one is gonna be on the lines of: Will you do the needful and write my application for me for the tracker actions? Thanking in advances Sanjay From bahamutzero8825 at gmail.com Fri Feb 3 15:14:57 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 03 Feb 2012 14:14:57 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback Message-ID: <4F2C4041.5030300@gmail.com> It's a rare occurrence, but sometimes my script will terminate and I get this: Traceback (most recent call last): File "C:\path\to\script\script.py", line 992, in That's it. And the line number is always the last line of the file (which in my case is a blank line). I have not seen this on Linux (where my script can run for days or weeks on a remote server), but only on Windows where I do most of my testing (and it typically only runs for minutes at a time). There may be bugs in my program, but I don't see how Python should ever print a traceback like this. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From tolidtm at gmail.com Fri Feb 3 15:27:48 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Fri, 3 Feb 2012 21:27:48 +0100 Subject: Help writelines Message-ID: Hi everyone, I`m totaly new in python and trying to figure out - how to write a list to a file with a newline at the end of each object. I tried alot of combinations :) like: users = ['toli','didi'] fob=open('c:/Python27/Toli/username','w') fob.writelines(users) + '%s\N' fob.close() or fob.writelines('\N' % users) or fob.writelines('%s\N' % users) but nothing of dose works... Could you help me find out the right syntaxes? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From markus.rother at web.de Fri Feb 3 15:41:54 2012 From: markus.rother at web.de (Markus Rother) Date: Fri, 03 Feb 2012 21:41:54 +0100 Subject: Help writelines In-Reply-To: References: Message-ID: <4F2C4692.2040005@web.de> Hi, You have to iterate. Either with for u in users: fob.write( u + '\n' ) or with a lambda function. always a good call: http://python.org/ greets, M. On 02/03/2012 09:27 PM, Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a > list to a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > or fob.writelines('\N' % users) > or fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > > Thanks > > > From nicholas.dokos at hp.com Fri Feb 3 15:47:37 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Fri, 03 Feb 2012 15:47:37 -0500 Subject: Help writelines In-Reply-To: Message from Anatoli Hristov of "Fri\, 03 Feb 2012 21\:27\:48 +0100." References: Message-ID: <9328.1328302057@alphaville> Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a list to a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > ?or?fob.writelines('\N' % users)? > or?fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > >From the docs: | writelines(...) | writelines(sequence_of_strings) -> None. Write the strings to the file. | | Note that newlines are not added. The sequence can be any iterable object | producing strings. This is equivalent to calling write() for each string. So *you* need to add the newlines, e.g. you can use a list comprehension: fob.writelines(["%s\n" % (x) for x in users]) or write in a loop: for u in users: fob.write("%s\n" % (u)) or join the list elements together with a newline separator (but you'll need to add a final newline by hand): fob.writelines("\n".join(users) + "\n") or ... Nick From d at davea.name Fri Feb 3 15:56:29 2012 From: d at davea.name (Dave Angel) Date: Fri, 03 Feb 2012 15:56:29 -0500 Subject: Help writelines In-Reply-To: References: Message-ID: <4F2C49FD.9000200@davea.name> On 02/03/2012 03:27 PM, Anatoli Hristov wrote: > Hi everyone, > > I`m totaly new in python and trying to figure out - how to write a list to > a file with a newline at the end of each object. > I tried alot of combinations :) like: > users = ['toli','didi'] > fob=open('c:/Python27/Toli/username','w') > fob.writelines(users) + '%s\N' > fob.close() > or fob.writelines('\N' % users) > or fob.writelines('%s\N' % users) > but nothing of dose works... > > Could you help me find out the right syntaxes? > > Thanks > mylist.writelines() is a shorthand for a loop of writes, once per list item. It does not append a newline, since if the list had come from readlines(), it would already have the linefeed on each line. So you have a few choices. You could add a newline to each list item before issuing the writelines(), or write your own loop. I vote for writing your own loop, since there may be other things you want to change on each line. 1) users = [item+"\n" for item in users] # add a newline to each item 2) for line in users: fob.write(line + "\n") fob.close() There are other possibilities, such as contents = "\n".join(mylist) #make a single string out of it fob.write(contents + "\n") #note we had to add one at the very end, #because join just puts the separator between items, not after them. -- DaveA From tolidtm at gmail.com Fri Feb 3 16:03:04 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Fri, 3 Feb 2012 22:03:04 +0100 Subject: Help writelines In-Reply-To: <4F2C49FD.9000200@davea.name> References: <4F2C49FD.9000200@davea.name> Message-ID: Thanks guys that was fast: I used for line in users: fob.write(line + "\n") fob.close() and that works Excuse me for the stupid questions, but since one week I read alot of python and I`m confused :p the only program language I knew in the time was Pascal, but i forgot all of it cheers Anatoli On Fri, Feb 3, 2012 at 9:56 PM, Dave Angel wrote: > On 02/03/2012 03:27 PM, Anatoli Hristov wrote: > >> Hi everyone, >> >> I`m totaly new in python and trying to figure out - how to write a list to >> a file with a newline at the end of each object. >> I tried alot of combinations :) like: >> users = ['toli','didi'] >> fob=open('c:/Python27/Toli/**username','w') >> fob.writelines(users) + '%s\N' >> fob.close() >> or fob.writelines('\N' % users) >> or fob.writelines('%s\N' % users) >> but nothing of dose works... >> >> Could you help me find out the right syntaxes? >> >> Thanks >> >> mylist.writelines() is a shorthand for a loop of writes, once per list > item. It does not append a newline, since if the list had come from > readlines(), it would already have the linefeed on each line. > > So you have a few choices. You could add a newline to each list item > before issuing the writelines(), or write your own loop. I vote for > writing your own loop, since there may be other things you want to change > on each line. > > 1) > users = [item+"\n" for item in users] # add a newline to each item > > 2) > for line in users: > fob.write(line + "\n") > fob.close() > > There are other possibilities, such as > contents = "\n".join(mylist) #make a single string out of it > fob.write(contents + "\n") #note we had to add one at the very > end, > #because join just puts the separator between items, not after > them. > > > > > -- > > DaveA > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan-usenet at bytereef.org Fri Feb 3 16:11:09 2012 From: stefan-usenet at bytereef.org (Stefan Krah) Date: Fri, 3 Feb 2012 22:11:09 +0100 Subject: [ANN] cdecimal-2.3 released In-Reply-To: <7xfwespe1f.fsf@ruckus.brouhaha.com> References: <7xfwespe1f.fsf@ruckus.brouhaha.com> Message-ID: <20120203211109.GA24815@sleipnir.bytereef.org> Paul Rubin wrote: > > Both cdecimal and libmpdec have an extremely conservative release policy. > > When new features are added, the complete test suite is run both with and > > without Valgrind on many different platforms. With the added tests against > > decNumber, this takes around 8 months on four cores. > > Wow. I wonder whether it's worth looking into some formal verification > if the required level of confidence is that high. Currently four of the main algorithms (newton-div, inv-sqrt, sqrt, log) and a couple of auxiliary functions have proofs in ACL2. The results are mechanically verified Lisp forms that are guaranteed to produce results *within correct error bounds* in a conforming Lisp implementation. Proving full conformance to the specification including all rounding modes, Overflow etc. would be quite a bit of additional work. For C, I think the why3 tool should be a good approach: http://why3.lri.fr/ The verification of the L4 kernel allegedly took 30 man-years, so it might take a while... Stefan Krah From dihedral88888 at googlemail.com Fri Feb 3 17:16:45 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 3 Feb 2012 14:16:45 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <7136289.998.1328307405342.JavaMail.geo-discussion-forums@prhq15> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. Well, in any associative operation with an identity implemented in a computer language personally I believe the operator overloading part in C++ is another teasing trick. Do we have to work out the algebra here? From dihedral88888 at googlemail.com Fri Feb 3 17:16:45 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 3 Feb 2012 14:16:45 -0800 (PST) Subject: copy on write In-Reply-To: References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <9nb5ubFu17U2@mid.individual.net> <9nblhhFr5bU1@mid.individual.net> Message-ID: <7136289.998.1328307405342.JavaMail.geo-discussion-forums@prhq15> ? 2012?1?14????UTC+8??6?48?29??Evan Driscoll??? > On 01/13/2012 03:20 PM, Neil Cerutti wrote: > > They perform the same action, but their semantics are different. > > operator+ will always return a new object, thanks to its > > signature, and operator+= shall never do so. That's the main > > difference I was getting at. Well, in any associative operation with an identity implemented in a computer language personally I believe the operator overloading part in C++ is another teasing trick. Do we have to work out the algebra here? From steve+comp.lang.python at pearwood.info Fri Feb 3 18:25:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Feb 2012 23:25:32 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: Message-ID: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote: > It's a rare occurrence, but sometimes my script will terminate and I get > this: > > Traceback (most recent call last): > File "C:\path\to\script\script.py", line 992, in > > That's it. And the line number is always the last line of the file > (which in my case is a blank line). Is it reproducible? That is, can you demonstrate a script which will *always* show this failure? > I have not seen this on Linux (where > my script can run for days or weeks on a remote server), but only on > Windows where I do most of my testing (and it typically only runs for > minutes at a time). There may be bugs in my program, but I don't see how > Python should ever print a traceback like this. Which version of Python, which version of Windows? If you upgrade Python, does the problem go away? If you perturb your script (add a few blank lines at the end, or a comment), does it go away? -- Steven From no.email at nospam.invalid Fri Feb 3 18:42:01 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 03 Feb 2012 15:42:01 -0800 Subject: Killing threads, and os.system() References: <4f2b976a$0$78773$742ec2ed@news.sonic.net> Message-ID: <7xwr835vsm.fsf@ruckus.brouhaha.com> John Nagle writes: > QNX's message passing looks more like a subroutine call than an > I/O operation, How do they enforce process isolation, or do they decide they don't need to? From inq1ltd at inqvista.com Fri Feb 3 19:15:30 2012 From: inq1ltd at inqvista.com (inq1ltd) Date: Fri, 03 Feb 2012 19:15:30 -0500 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7879610.izLzYB4Oqi@mach-114-20> Check your code in that module for open parenthesis something like below.. Most likely your code is looking for the closing parenthesis. Start at the bottom and move up. pink = str(self.RecordKey[2] <--missing ")" jimonlinux > On Fri, 03 Feb 2012 14:14:57 -0600, Andrew Berg wrote: > > It's a rare occurrence, but sometimes my script will terminate and I get > > this: > > > > Traceback (most recent call last): > > File "C:\path\to\script\script.py", line 992, in > > > > That's it. And the line number is always the last line of the file > > (which in my case is a blank line). From antti.ylikoski at tkk.fi Fri Feb 3 19:27:56 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 02:27:56 +0200 Subject: Common LISP-style closures with Python Message-ID: In Python textbooks that I have read, it is usually not mentioned that we can very easily program Common LISP-style closures with Python. It is done as follows: ------------------------------------- # Make a Common LISP-like closure with Python. # # Antti J Ylikoski 02-03-2012. def f1(): n = 0 def f2(): nonlocal n n += 1 return n return f2 ------------------------------------- and now we can do: ------------------------------------- >>> >>> a=f1() >>> b=f1() >>> a() 1 >>> a() 2 >>> a() 3 >>> a() 4 >>> b() 1 >>> b() 2 >>> a() 5 >>> b() 3 >>> b() 4 >>> ------------------------------------- i. e. we can have several functions with private local states which are kept between function calls, in other words we can have Common LISP-like closures. yours, Antti J Ylikoski Helsinki, Finland, the EU From clp2 at rebertia.com Fri Feb 3 21:47:20 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 3 Feb 2012 18:47:20 -0800 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. ?It > is done as follows: > > ------------------------------------- > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > ? ?n = 0 > ? ?def f2(): > ? ? ? ?nonlocal n > ? ? ? ?n += 1 > ? ? ? ?return n > ? ?return f2 > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. Out of curiosity, what would be non-Common-Lisp-style closures? Cheers, Chris From steve+comp.lang.python at pearwood.info Fri Feb 3 21:47:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Feb 2012 02:47:49 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2c9c55$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 03 Feb 2012 19:15:30 -0500, inq1ltd wrote: > Check your code in that module for open parenthesis something like > below.. Most likely your code is looking for the closing parenthesis. > Start at the bottom and move up. > > pink = str(self.RecordKey[2] <--missing ")" If that were the case, the module wouldn't run at all, it would consistently raise SyntaxError before running. -- Steven From rosuav at gmail.com Fri Feb 3 22:15:18 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 4 Feb 2012 14:15:18 +1100 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4F2C4041.5030300@gmail.com> References: <4F2C4041.5030300@gmail.com> Message-ID: On Sat, Feb 4, 2012 at 7:14 AM, Andrew Berg wrote: > It's a rare occurrence, but sometimes my script will terminate and I get > this: > > Traceback (most recent call last): > ?File "C:\path\to\script\script.py", line 992, in Do you call on potentially-buggy external modules? I'd be curious to see if this can happen if a module somehow sets an "error state" in the interpreter, without actually raising an error - or, alternatively, if a module has some kind of cleanup code that returns failure. Unfortunately I don't have facilities for testing that, at the moment. ChrisA From dgcoventry at gmail.com Sat Feb 4 02:02:28 2012 From: dgcoventry at gmail.com (Cov) Date: Fri, 3 Feb 2012 23:02:28 -0800 (PST) Subject: undefined symbol: PyUnicodeUCS4_AsUTF8String Message-ID: I'm attempting to run a python script in Blender (blender3d.org) which is generating an error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ File "/home/dave/Apps/blender-2.49b-linux-glibc236-py26- x86_64/.blender/scripts/pantographLib.py", line 1941, in Pen MITER = cairo.LINE_JOIN_MITER NameError: name 'cairo' is not defined ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ When I type "import cairo" from within the blender python console, I get the following error which (I am presuming) is why the Cairo libraries are not being loaded. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ : /usr/lib/python2.6/dist-packages/ cairo/_cairo.so: undefined symbol: PyUnicodeUCS4_AsUTF8String ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8< ~~~~~~~~~~~~~~~~~~~~~~~~~~ The machine has three versions of python installed, 2.6 (which is the version that Blender has been compiled against and is using), 2.7 and 3.2. Presumably, there is an unicode conflict which needs to be resolved. Can anyone offer any suggestions on resolving this? Kind regards, Dave Coventry From austinbaiy at gmail.com Sat Feb 4 04:35:06 2012 From: austinbaiy at gmail.com (austinbaiy) Date: Sat, 4 Feb 2012 01:35:06 -0800 (PST) Subject: Open Source Customization Message-ID: <13055537-a91b-42bf-a81a-72e74175f085@og8g2000pbb.googlegroups.com> Searching for Best Web Design, Development or Affordable SEO Service in USA? Bestwebsol.com provides professional full-cycle services: web development, custom web design & Best SEO services with guaranteed traffic increase and higher ranking. http://www.bestwebsol.com From antti.ylikoski at tkk.fi Sat Feb 4 05:14:59 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 12:14:59 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 4:47, Chris Rebert wrote: > On Fri, Feb 3, 2012 at 4:27 PM, Antti J Ylikoski wrote: >> >> In Python textbooks that I have read, it is usually not mentioned that >> we can very easily program Common LISP-style closures with Python. It >> is done as follows: >> >> ------------------------------------- >> >> # Make a Common LISP-like closure with Python. >> # >> # Antti J Ylikoski 02-03-2012. >> >> def f1(): >> n = 0 >> def f2(): >> nonlocal n >> n += 1 >> return n >> return f2 > >> i. e. we can have several functions with private local states which >> are kept between function calls, in other words we can have Common >> LISP-like closures. > > Out of curiosity, what would be non-Common-Lisp-style closures? > > Cheers, > Chris I understand that a "closure" is something which is typical of functional programming languages. -- Scheme-style closures, for example. I don't know Haskell, ML etc. but I do suspect that we could create closures in those languages as well. Maybe someone more expert than me can help? regards, Andy From antti.ylikoski at tkk.fi Sat Feb 4 05:23:47 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 12:23:47 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 12:14, Antti J Ylikoski wrote: > On 4.2.2012 4:47, Chris Rebert wrote: >> On Fri, Feb 3, 2012 at 4:27 PM, Antti J >> Ylikoski wrote: >>> >>> In Python textbooks that I have read, it is usually not mentioned that >>> we can very easily program Common LISP-style closures with Python. It >>> is done as follows: >>> >>> ------------------------------------- >>> >>> # Make a Common LISP-like closure with Python. >>> # >>> # Antti J Ylikoski 02-03-2012. >>> >>> def f1(): >>> n = 0 >>> def f2(): >>> nonlocal n >>> n += 1 >>> return n >>> return f2 >> >>> i. e. we can have several functions with private local states which >>> are kept between function calls, in other words we can have Common >>> LISP-like closures. >> >> Out of curiosity, what would be non-Common-Lisp-style closures? >> >> Cheers, >> Chris > > I understand that a "closure" is something which is typical of > functional programming languages. -- Scheme-style closures, for example. > > I don't know Haskell, ML etc. but I do suspect that we could create > closures in those languages as well. Maybe someone more expert than me > can help? > > regards, Andy > This is how it is done in standard Common LISP: ----------------------------------------- ;;; Closure with Common LISP. ;;; ;;; Antti J Ylikoski 02-03-2012. (defun mak-1 () (let ((n 0)) #'(lambda () (incf n)))) ----------------------------------------- kind regards, Andy From arnodel at gmail.com Sat Feb 4 05:58:49 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sat, 4 Feb 2012 10:58:49 +0000 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4 February 2012 10:14, Antti J Ylikoski wrote: > On 4.2.2012 4:47, Chris Rebert wrote: >> Out of curiosity, what would be non-Common-Lisp-style closures? >> >> Cheers, >> Chris > > > I understand that a "closure" is something which is typical of functional > programming languages. ?-- Scheme-style closures, for example. > > I don't know Haskell, ML etc. but I do suspect that we could create closures > in those languages as well. ?Maybe someone more expert than me can help? I think what Chris asking is: what is the feature of Common-Lisp closures that Python closures share but other languages don't? I think what he is implying is that there is no such feature. Python closures are no more "Common-Lisp-style" than they are "Scheme-style" or "Smalltalk-like" or any other language-like. -- Arnaud From jeandupont115 at gmail.com Sat Feb 4 07:47:17 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Sat, 4 Feb 2012 04:47:17 -0800 (PST) Subject: pySerial question, setting certain serial parameters [newbie] Message-ID: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): $port->handshake("none"); $port->rts_active(0); $port->dtr_active(1); I have thus far the following statements but I think it does not set the above parameters correctly: import serial voltport='/dev/ttyUSB2' ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) thanks Jean From antti.ylikoski at tkk.fi Sat Feb 4 08:09:14 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sat, 04 Feb 2012 15:09:14 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 4.2.2012 12:58, Arnaud Delobelle wrote: > On 4 February 2012 10:14, Antti J Ylikoski wrote: >> On 4.2.2012 4:47, Chris Rebert wrote: >>> Out of curiosity, what would be non-Common-Lisp-style closures? >>> >>> Cheers, >>> Chris >> >> >> I understand that a "closure" is something which is typical of functional >> programming languages. -- Scheme-style closures, for example. >> >> I don't know Haskell, ML etc. but I do suspect that we could create closures >> in those languages as well. Maybe someone more expert than me can help? > > I think what Chris asking is: what is the feature of Common-Lisp > closures that Python closures share but other languages don't? > > I think what he is implying is that there is no such feature. Python > closures are no more "Common-Lisp-style" than they are "Scheme-style" > or "Smalltalk-like" or any other language-like. > I would say that Python closures are equivalent with Common LISP closures (except that LAMBDA is more limited in Python, which is a feature which I don't like.) Do you maybe mean non-Common-LISP-style closures in Python? I cannot think of any ones. kind regards, Andy From bahamutzero8825 at gmail.com Sat Feb 4 11:32:25 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 04 Feb 2012 10:32:25 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2D5D99.4030808@gmail.com> On 2/3/2012 5:25 PM, Steven D'Aprano wrote: > Which version of Python, which version of Windows? I keep that information in my signature for every post I make to this list. CPython 3.2.2 | Windows NT 6.1.7601.17640 > If you upgrade Python, does the problem go away? I use the most recent stable version. It would be hard to say if the problem went away since it's rare and random AFAICT. On 2/3/2012 9:15 PM, Chris Angelico wrote: > Do you call on potentially-buggy external modules? It imports one module that does little more than define a few simple functions. There's certainly no (intentional) interpreter hackery at work. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From steve+comp.lang.python at pearwood.info Sat Feb 4 12:06:14 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Feb 2012 17:06:14 GMT Subject: Script randomly exits for seemingly no reason with strange traceback References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 04 Feb 2012 10:32:25 -0600, Andrew Berg wrote: > On 2/3/2012 5:25 PM, Steven D'Aprano wrote: >> Which version of Python, which version of Windows? > I keep that information in my signature for every post I make to this > list. CPython 3.2.2 | Windows NT 6.1.7601.17640 Why so you do. Did you expect that people would read it? As a rule, sigs fade into the background -- my mail client colours it grey, my news client colours it light blue, and I generally don't even notice it. The Zen of Python applies here: explicit is better than implicit. >> If you upgrade Python, does the problem go away? > I use the most recent stable version. It would be hard to say if the > problem went away since it's rare and random AFAICT. I suggest you raise an issue on the bug tracker. If you can't reproduce the bug, it's unlikely to be fixed, but you might get lucky. -- Steven From vinay_sajip at yahoo.co.uk Sat Feb 4 12:09:32 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 4 Feb 2012 09:09:32 -0800 (PST) Subject: PythonWin debugger holds onto global logging objects too long References: Message-ID: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> On Jan 24, 2:52?pm, Rob Richardson wrote: > I use PythonWin to debug the Python scripts we write. ?Our scripts often use the log2pyloggingpackage. ?When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. ?The result is that after running the script five times, the log file contains five copies of every message. ?The only way I know to clean this up and get only a single copy of each message is to close PythonWin and restart it. > > What do I have to do in my scripts to clean up theloggingobjects so that I never get more than one copy of each message in my log files? > I don't know what log2py is - Google didn't show up anything that looked relevant. If you're talking about the logging package in the Python standard library, I may be able to help: but a simple script that I ran in PythonWin didn't show any problems, so you'll probably need to post a short script which demonstrates the problem when run in PythonWin. Regards, Vinay Sajip From rtomek at ceti.pl Sat Feb 4 12:42:03 2012 From: rtomek at ceti.pl (Tomasz Rola) Date: Sat, 4 Feb 2012 18:42:03 +0100 (CET) Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, 4 Feb 2012, Antti J Ylikoski wrote: > On 4.2.2012 12:58, Arnaud Delobelle wrote: > > On 4 February 2012 10:14, Antti J Ylikoski wrote: > > > On 4.2.2012 4:47, Chris Rebert wrote: > > > > Out of curiosity, what would be non-Common-Lisp-style closures? > > > > > > > > Cheers, > > > > Chris > > > > > > > > > I understand that a "closure" is something which is typical of functional > > > programming languages. -- Scheme-style closures, for example. > > > > > > I don't know Haskell, ML etc. but I do suspect that we could create > > > closures > > > in those languages as well. Maybe someone more expert than me can help? > > > > I think what Chris asking is: what is the feature of Common-Lisp > > closures that Python closures share but other languages don't? > > > > I think what he is implying is that there is no such feature. Python > > closures are no more "Common-Lisp-style" than they are "Scheme-style" > > or "Smalltalk-like" or any other language-like. > > > > I would say that Python closures are equivalent with Common LISP closures > (except that LAMBDA is more limited in Python, which is a feature which I > don't like.) > > Do you maybe mean non-Common-LISP-style closures in Python? I cannot > think of any ones. > > kind regards, Andy AFAIK there is only one style for closure, similar to one style for square. There are quite a lot languages implementing closures, and quite a lot try to imitate them, including C with non-standard extension (without using those imitations I cannot say if they are good enough). http://en.wikipedia.org/wiki/Closure_(computer_science) Wrt lambdas, I really like blocks from Ruby (which AFAIK stem from blocks in Smalltalk, not sure if they call them "blocks"). http://lesscode.org/2005/07/12/ruby-colored-blocks-in-python/ http://railsguru.org/2010/03/learn-ruby-procs-blocks-lambda/ I mean, myself I am ok with lambdas (using them in languages where lambda is welcomed and contributing citizen) but blocks in place of lambdas would be nice to have in Python. Introduction of "with" construct was good IMHO, but if one likes coding style relying on passing anonymous pieces of code then Python might not be good choice for this. On the other hand, one can argue that using anonymous code too much is not the best style. I am not sure if extensive use of blocks/lambdas really helps, or if it contributes to "clever" hacks and a source of maintainance pain. So, perhaps it is good to have it in a few different ways - like, Ruby, Python and CL - and experiment with them all. In other words, rather than talking about making Python more like some other language(s) I think it is much better to learn those other language(s). If you'd like to try "unlimited" lambda, you might want to play with Racket, a Scheme superset. Or any other Scheme - it's simple enough to start coding after a day or two of learning (I mean Fibonaccis and Erastotenes sieves, not implementing database or web server). Myself, I would rather have blocks/lambdas and not need them rather than the other way, but that's just me. Regards, Tomasz Rola -- ** A C programmer asked whether computer had Buddha's nature. ** ** As the answer, master did "rm -rif" on the programmer's home ** ** directory. And then the C programmer became enlightened... ** ** ** ** Tomasz Rola mailto:tomasz_rola at bigfoot.com ** From bahamutzero8825 at gmail.com Sat Feb 4 13:13:02 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 04 Feb 2012 12:13:02 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4f2d6586$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F2D752E.4030400@gmail.com> On 2/4/2012 11:06 AM, Steven D'Aprano wrote: > I suggest you raise an issue on the bug tracker. If you can't reproduce > the bug, it's unlikely to be fixed, but you might get lucky. Since I can't narrow it down to any specific circumstance or code, I'll gather information from a build of the interpreter with debugging enabled first. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From jenn.duerr at gmail.com Sat Feb 4 13:13:06 2012 From: jenn.duerr at gmail.com (noydb) Date: Sat, 4 Feb 2012 10:13:06 -0800 (PST) Subject: building a dictionary dynamically Message-ID: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> How do you build a dictionary dynamically? Doesn't seem to be an insert object or anything. So I need an empty dictionary that I then want to populate with values I get from looping through a list and grabbing some properties. So simply, I have (fyi, arcpy = module for interacting with gis data) >>> inDict = {} >>> for inFC in inFClist: >>> print inFC >>> inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) where I want to make a dictionary like {inFC: inCount, inFC: inCount, ....} How do I build this??? And, is dictionaries the best route go about doing a comparison, such that in the end I will have two dictionaries, one for IN and one for OUT, as in I'm moving data files and want to verify that the count in each file matches between IN and OUT. Thanks for any help! From rosuav at gmail.com Sat Feb 4 15:43:51 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Feb 2012 07:43:51 +1100 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4F2D5D99.4030808@gmail.com> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> Message-ID: On Sun, Feb 5, 2012 at 3:32 AM, Andrew Berg wrote: > On 2/3/2012 9:15 PM, Chris Angelico wrote: >> Do you call on potentially-buggy external modules? > It imports one module that does little more than define a few simple > functions. There's certainly no (intentional) interpreter hackery at work. If it's safe for you to do so (copyright/licence etc), it may be worth posting the code along with your bug report, just in case. I had some REALLY weird issues from embedding Python that derived, ultimately, from buggy ref management - one such case came from forgetting to incref None; it took me a long time to track it down, because the problem didn't actually surface until the interpreter was shutting down. ChrisA From software.buy.design at gmail.com Sat Feb 4 16:33:32 2012 From: software.buy.design at gmail.com (Python_Junkie) Date: Sat, 4 Feb 2012 13:33:32 -0800 (PST) Subject: os.stat last accessed attribute updating last accessed value Message-ID: <660c3625-b27c-42a0-b85b-bcd3047eb6fc@t30g2000vbx.googlegroups.com> I am trying to obtain the last accessed date. About 50% of the files' attributes were updated such that the file was last accessed when this script touches the file. I was not opening the files Anyone have a thought of why this happened. Python 2.6 on windows xp From jeanpierreda at gmail.com Sat Feb 4 17:52:45 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 4 Feb 2012 17:52:45 -0500 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, Feb 4, 2012 at 5:58 AM, Arnaud Delobelle wrote: > I think what Chris asking is: what is the feature of Common-Lisp > closures that Python closures share but other languages don't? > > I think what he is implying is that there is no such feature. ?Python > closures are no more "Common-Lisp-style" than they are "Scheme-style" > or "Smalltalk-like" or any other language-like. "No such feature"? What's that nonlocal thing then? The above function could not be written that way in Python 2. Of course maybe we want to put this feature in another category, but anyway, the function couldn't be written in some languages, even though they have closures. -- Devin From research at johnohagan.com Sat Feb 4 20:31:12 2012 From: research at johnohagan.com (John O'Hagan) Date: Sun, 5 Feb 2012 12:31:12 +1100 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <20120205123112.373fcc7448af003660548cdd@johnohagan.com> On Sat, 04 Feb 2012 02:27:56 +0200 Antti J Ylikoski wrote: [...] > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > [...] > > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. > I'm not sure how naughty this is, but the same thing can be done without using nonlocal by storing the local state as an attribute of the enclosed function object: >>> def f(): ... def g(): ... g.count += 1 ... return g.count ... g.count = 0 ... return g ... >>> h = f() >>> j = f() >>> h() 1 >>> h() 2 >>> h() 3 >>> j() 1 >>> j() 2 >>> j() 3 This way, you can also write to the attribute: >>> j.count = 0 >>> j() 1 John From chardster at gmail.com Sat Feb 4 21:18:30 2012 From: chardster at gmail.com (Richard Thomas) Date: Sat, 4 Feb 2012 18:18:30 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: On Feb 4, 6:13?pm, noydb wrote: > How do you build a dictionary dynamically? ?Doesn't seem to be an > insert object or anything. ?So I need an empty dictionary that I then > want to populate with values I get from looping through a list and > grabbing some properties. ?So simply, I have (fyi, arcpy = module for > interacting with gis data) > > >>> inDict = {} > >>> for inFC in inFClist: > >>> ? ? print inFC > >>> ? ? inCount = ?int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? > > And, is dictionaries the best route go about doing a comparison, such > that in the end I will have two dictionaries, one for IN and one for > OUT, as in I'm moving data files and want to verify that the count in > each file matches between IN and OUT. > > Thanks for any help! Dictionaries are mutable, you can modify them in place: >>> myDict = {} >>> for myKey in myList: ... myDict[myKey] = doSomething(myKey) Dictionaries sound like a good way to go. You only need the one dictionary though, the IN one. When processing the outCount values you can just check them against the inDict at that point. Regards, Chard. From antti.ylikoski at tkk.fi Sat Feb 4 23:19:40 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Sun, 05 Feb 2012 06:19:40 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 5.2.2012 3:31, John O'Hagan wrote: > On Sat, 04 Feb 2012 02:27:56 +0200 > Antti J Ylikoski wrote: > > [...] > > >> >> # Make a Common LISP-like closure with Python. >> # >> # Antti J Ylikoski 02-03-2012. >> >> def f1(): >> n = 0 >> def f2(): >> nonlocal n >> n += 1 >> return n >> return f2 >> > > [...] > >> >> i. e. we can have several functions with private local states which >> are kept between function calls, in other words we can have Common >> LISP-like closures. >> > > I'm not sure how naughty this is, but the same thing can be done without using > nonlocal by storing the local state as an attribute of the enclosed function > object: > >>>> def f(): > ... def g(): > ... g.count += 1 > ... return g.count > ... g.count = 0 > ... return g > ... >>>> h = f() >>>> j = f() >>>> h() > 1 >>>> h() > 2 >>>> h() > 3 >>>> j() > 1 >>>> j() > 2 >>>> j() > 3 > > This way, you can also write to the attribute: > >>>> j.count = 0 >>>> j() > 1 > > > John Yes, I do know that, but then it would not be a closure :-))))))))) Andy From alec.taylor6 at gmail.com Sun Feb 5 06:49:43 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 5 Feb 2012 22:49:43 +1100 Subject: [Perl Golf] Round 1 Message-ID: One sentence can contain one or more strings next to each-other, which can be joined to make another word. e.g.: "to get her" == "together" "an other" == "another" "where about" == "whereabouts" &etc Solve this problem using as few lines of code as possible[1]. Good luck! [1] Don't use external non-default libraries; non-custom word-lists excepted From wolfram.hinderer at googlemail.com Sun Feb 5 09:09:50 2012 From: wolfram.hinderer at googlemail.com (Wolfram Hinderer) Date: Sun, 5 Feb 2012 06:09:50 -0800 (PST) Subject: copy on write References: <4f101f45$0$29999$c3e8da3$5496439d@news.astraweb.com> <4f102bd0$0$29999$c3e8da3$5496439d@news.astraweb.com> <4F107AAF.5000600@stoneleaf.us> <20120202141812.649c31d832bb15bd899eb952@johnohagan.com> <4f2a5478$0$29895$c3e8da3$5496439d@news.astraweb.com> <20120203011748.592f060f32ac79d450a2ca8d@johnohagan.com> <4f2b6ae6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 3 Feb., 11:47, John O'Hagan wrote: > But isn't it equally true if we say that z = t[1], then t[1] += x is syntactic sugar for z = z.__iadd__(x)? Why should that fail, if z can handle it? It's more like syntactic sugar for y = t; z = y.__getitem__(1); z.__iadd__(x); y.__setitem__(1, z) It's clear that only the last expression fails, after the mutation has taken place. Just in case you wonder about the y: you need it for more complicated cases. t[1][1] += [4] is syntactic sugar for y = t.__getitem__(1); z = y.__getitem__(1); z.__iadd__([4]); y.__setitem__(1, z) That makes clear why there's no exception in this code: >>> t = (0, [1, [2, 3]]) >>> t[1][1] += [4] >>> t (0, [1, [2, 3, 4]]) From alec.taylor6 at gmail.com Sun Feb 5 09:37:14 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Sun, 5 Feb 2012 06:37:14 -0800 (PST) Subject: Visual Studio 2010 Support Message-ID: <8830893.1884.1328452634877.JavaMail.geo-discussion-forums@prj1> PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycrypto>vcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycrypto>python setup.py build --compiler msvc http://pastebin.com/nBsuXDGg Error output from G:\pycrypto>python setup.py build --compiler mingw32 1> log1 2> log2 Log1: http://pastebin.com/yG3cbdZv Log2: http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor From alec.taylor6 at gmail.com Sun Feb 5 09:40:31 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 6 Feb 2012 01:40:31 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: PIL, PyCrypto and many other modules require a C compiler and linker. Unfortunately neither install on my computer, with a PATH with the following: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC C:\libraries\MinGW\msys\1.0\bin C:\libraries\MinGW C:\Python27\Scripts Output from G:\pycrypto>vcvarsall.bat Setting environment for using Microsoft Visual Studio 2010 x86 tools. Error output from G:\pycrypto>python setup.py build --compiler msvc http://pastebin.com/nBsuXDGg Error output from G:\pycrypto>python setup.py build --compiler mingw32 1> log1 2> log2 Log1: http://pastebin.com/yG3cbdZv Log2: http://pastebin.com/qvnshPeh Will there ever be support for newer MSVC versions? - Also, why doesn't even MinGW install PyCrypto for me? Thanks for all suggestions, Alec Taylor From joncle at googlemail.com Sun Feb 5 09:52:23 2012 From: joncle at googlemail.com (Jon Clements) Date: Sun, 5 Feb 2012 06:52:23 -0800 (PST) Subject: os.stat last accessed attribute updating last accessed value References: <660c3625-b27c-42a0-b85b-bcd3047eb6fc@t30g2000vbx.googlegroups.com> Message-ID: <5278aa1d-bddc-4fbf-be6d-5b30407c701f@s7g2000vby.googlegroups.com> On Feb 4, 9:33?pm, Python_Junkie wrote: > I am trying to obtain the last accessed date. ?About 50% of the files' > attributes were updated such that the file was last accessed when this > script touches the file. > I was not opening the files > > Anyone have a thought of why this happened. > > Python 2.6 on windows xp Read up on NTFS - but on some file systems - to check a file access time is, well umm, is accessing it. Also possible that listing a directory is considered an access. It's the least useful of all records - I've only ever possibly wanted modification or creation times. hth, Jon. From tolidtm at gmail.com Sun Feb 5 10:13:39 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Sun, 5 Feb 2012 16:13:39 +0100 Subject: Help about dictionary append Message-ID: Hi there, I`m again confused and its the dictionary. As dictionary does not support append I create a variable list with dictionary key values and want to add new values to it and then copy it again to the dictionary as I dont know other methods. mydict = {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} Then I use the key "Name" from the dict name = mydict['Name'] and tel = mydict['Tel'] then I want to add at the end new values and doing: name.append('Name4') and I get and error that TUPLE object has no attribute Append !!! But how to add new Values to a dictionary then ? I know its kind of basics in python, but I was seeking in the python website and even google and could not realise that. Thank you for your suggestions A.H -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sun Feb 5 10:20:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 02:20:50 +1100 Subject: Help about dictionary append In-Reply-To: References: Message-ID: On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov wrote: > Hi there, > > I`m again confused and its the dictionary. As dictionary does not support > append I create a variable list with dictionary key values and want to add > new values to it and then copy it again to the dictionary as I dont know > other methods. A dictionary maps a key to exactly one value. If you want multiples, you do pretty much what you've done here... > mydict = > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} >... > and I get and error that TUPLE object has no attribute Append !!! > > But how to add new Values to a dictionary then ? ... but instead of using parentheses and creating a Tuple, use square brackets and create a List: mydict = {'Name':['Name1','Name2','Name3'],'Tel':['023333','037777','049999']} Then you can append to it, and it will work just fine! Chris Angelico From jamesbroadhead at gmail.com Sun Feb 5 10:21:18 2012 From: jamesbroadhead at gmail.com (James Broadhead) Date: Sun, 5 Feb 2012 15:21:18 +0000 Subject: Help about dictionary append In-Reply-To: References: Message-ID: On 5 February 2012 15:13, Anatoli Hristov wrote: > Hi there, > > I`m again confused and its the dictionary. As dictionary does not support > append I create a variable list with dictionary key values and want to add > new values to it and then copy it again to the dictionary as I dont know > other methods. > > mydict = > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} > dicts are intended to be used differently from this; more like: name_tel = {} name_tel['Name1'] = 023333 name_tel['Name2'] = 037777 print name_tel['Name1'] ... where Name is the key used to retrieve the value (the telephone number). From lists at cheimes.de Sun Feb 5 10:23:29 2012 From: lists at cheimes.de (Christian Heimes) Date: Sun, 05 Feb 2012 16:23:29 +0100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: Am 05.02.2012 15:40, schrieb Alec Taylor: > PIL, PyCrypto and many other modules require a C compiler and linker. > > Unfortunately neither install on my computer, with a PATH with the following: > > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC > C:\libraries\MinGW\msys\1.0\bin > C:\libraries\MinGW > C:\Python27\Scripts MSVC 10 is not supported, you need VC 9 (2008). Christian From bahamutzero8825 at gmail.com Sun Feb 5 10:29:40 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 05 Feb 2012 09:29:40 -0600 Subject: Help about dictionary append In-Reply-To: References: Message-ID: <4F2EA064.9060502@gmail.com> On 2/5/2012 9:13 AM, Anatoli Hristov wrote: > and I get and error that TUPLE object has no attribute Append !!! You defined mydict['name'] as a tuple, and tuples are immutable. Using a tuple means that you don't ever want the values to change. > But how to add new Values to a dictionary then ? This has nothing to do with dictionaries. If you want to add, delete, or change items, use a list (or a set if there aren't supposed to be any duplicates). Information on built-in types is here: http://docs.python.org/library/stdtypes.html (2.7) http://docs.python.org/py3k/library/stdtypes.html (3.2) -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From alan.ristow at gmail.com Sun Feb 5 10:56:44 2012 From: alan.ristow at gmail.com (Alan Ristow) Date: Sun, 05 Feb 2012 16:56:44 +0100 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <4F2EA6BC.40108@gmail.com> On 02/05/2012 05:19 AM, Antti J Ylikoski wrote: > > Yes, I do know that, but then it would not be a closure :-))))))))) Forgive me if this is terribly naive, but what is the advantage of using a closure as opposed to, say, some other function that returns the same value in the same context, but is not a closure? Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: From alec.taylor6 at gmail.com Sun Feb 5 11:42:08 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Mon, 6 Feb 2012 03:42:08 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: Message-ID: A 4 year old compiler? I also have MSVC11 installed. Can the python project add support for that so that we aren't waiting 5 years between compiler support? On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes wrote: > Am 05.02.2012 15:40, schrieb Alec Taylor: >> PIL, PyCrypto and many other modules require a C compiler and linker. >> >> Unfortunately neither install on my computer, with a PATH with the following: >> >> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC >> C:\libraries\MinGW\msys\1.0\bin >> C:\libraries\MinGW >> C:\Python27\Scripts > > MSVC 10 is not supported, you need VC 9 (2008). > > Christian > > -- > http://mail.python.org/mailman/listinfo/python-list From steve+comp.lang.python at pearwood.info Sun Feb 5 11:55:52 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 05 Feb 2012 16:55:52 GMT Subject: PyCrypto builds neither with MSVC nor MinGW References: Message-ID: <4f2eb498$0$29965$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 03:42:08 +1100, Alec Taylor wrote: > A 4 year old compiler? Compilers aren't like milk. They don't go off after a few weeks. A good compiler/operating system combination should still be usable after 4 or 14 years. The compiler I'm using is six years old, and I expect that it will continue to get patches and upgrades without breaking backwards compatibility for the next six years. > I also have MSVC11 installed. Can the python project add support for > that so that we aren't waiting 5 years between compiler support? Are you volunteering to provide that support? I'm sure it would be appreciated. P.S. Please don't top-post. > On Mon, Feb 6, 2012 at 2:23 AM, Christian Heimes > wrote: >> Am 05.02.2012 15:40, schrieb Alec Taylor: >>> PIL, PyCrypto and many other modules require a C compiler and linker. >>> >>> Unfortunately neither install on my computer, with a PATH with the >>> following: >>> >>> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC >>> C:\libraries\MinGW\msys\1.0\bin >>> C:\libraries\MinGW >>> C:\Python27\Scripts >> >> MSVC 10 is not supported, you need VC 9 (2008). >> >> Christian -- Steven From modelnine at modelnine.org Sun Feb 5 12:13:00 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Sun, 05 Feb 2012 18:13:00 +0100 Subject: [Perl Golf] Round 1 In-Reply-To: References: Message-ID: <4F2EB89C.9080801@modelnine.org> Am 05.02.2012 12:49, schrieb Alec Taylor: > Solve this problem using as few lines of code as possible[1]. Pardon me, but where's "the problem"? If your intention is to propose "a challenge", say so, and state the associated problem clearly. -- --- Heiko. From tolidtm at gmail.com Sun Feb 5 15:12:48 2012 From: tolidtm at gmail.com (Anatoli Hristov) Date: Sun, 5 Feb 2012 21:12:48 +0100 Subject: Help about dictionary append In-Reply-To: References: Message-ID: Thanks Chris, It works fine, I see it will take time till I understand all the syntax :( A.H On Sun, Feb 5, 2012 at 4:20 PM, Chris Angelico wrote: > On Mon, Feb 6, 2012 at 2:13 AM, Anatoli Hristov wrote: > > Hi there, > > > > I`m again confused and its the dictionary. As dictionary does not support > > append I create a variable list with dictionary key values and want to > add > > new values to it and then copy it again to the dictionary as I dont know > > other methods. > > A dictionary maps a key to exactly one value. If you want multiples, > you do pretty much what you've done here... > > > mydict = > > {'Name':('Name1','Name2','Name3'),'Tel':('023333','037777','049999')} > >... > > and I get and error that TUPLE object has no attribute Append !!! > > > > But how to add new Values to a dictionary then ? > > ... but instead of using parentheses and creating a Tuple, use square > brackets and create a List: > > mydict = > {'Name':['Name1','Name2','Name3'],'Tel':['023333','037777','049999']} > > Then you can append to it, and it will work just fine! > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Sun Feb 5 15:58:31 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 5 Feb 2012 13:58:31 -0700 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: >> I'm not sure how naughty this is, but the same thing can be done without >> using >> nonlocal by storing the local state as an attribute of the enclosed >> function >> object: >> >> ... > > Yes, I do know that, but then it would not be a closure :-))))))))) Sure it is. Where do you think it looks up the function object? Cheers, Ian From jenn.duerr at gmail.com Sun Feb 5 16:10:45 2012 From: jenn.duerr at gmail.com (noydb) Date: Sun, 5 Feb 2012 13:10:45 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> Ahh, I see now, thanks! From ben+python at benfinney.id.au Sun Feb 5 16:15:21 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 06 Feb 2012 08:15:21 +1100 Subject: [Perl Golf] Round 1 References: Message-ID: <87r4y93rti.fsf@benfinney.id.au> Alec Taylor writes: > One sentence can contain one or more strings next to each-other, which > can be joined to make another word. > > e.g.: > > "to get her" == "together" > "an other" == "another" > "where about" == "whereabouts" > > &etc Yes, that's true. > Solve this problem using as few lines of code as possible[1]. Easy:: True > Good luck! What do I win? -- \ ?All opinions are not equal. Some are a very great deal more | `\ robust, sophisticated, and well supported in logic and argument | _o__) than others.? ?Douglas Adams | Ben Finney From ndbecker2 at gmail.com Sun Feb 5 17:15:10 2012 From: ndbecker2 at gmail.com (Neal Becker) Date: Sun, 05 Feb 2012 17:15:10 -0500 Subject: [Perl Golf] Round 1 References: <4F2EB89C.9080801@modelnine.org> Message-ID: Heiko Wundram wrote: > Am 05.02.2012 12:49, schrieb Alec Taylor: >> Solve this problem using as few lines of code as possible[1]. > > Pardon me, but where's "the problem"? If your intention is to propose "a > challenge", say so, and state the associated problem clearly. > But this really misses the point. Python is not about coming up with some clever, cryptic, one-liner to solve some problem. It's about clear code. If you want clever, cryptic, one-liner's stick with perl. From emekamicro at gmail.com Sun Feb 5 17:41:24 2012 From: emekamicro at gmail.com (Emeka) Date: Mon, 6 Feb 2012 00:41:24 +0200 Subject: MySQLdb not allowing hyphen Message-ID: Hello All, I noticed that MySQLdb not allowing hyphen may be way to prevent injection attack. I have something like below: "insert into reviews(message, title)values('%s', '%s')" %( "We don't know where to go","We can't wait till morrow" ) ProgrammingError(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't know where to go. How do I work around this error? Regards, Emeka -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Sun Feb 5 17:46:36 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 5 Feb 2012 14:46:36 -0800 Subject: MySQLdb not allowing hyphen In-Reply-To: References: Message-ID: On Sun, Feb 5, 2012 at 2:41 PM, Emeka wrote: > > Hello All, > > I noticed that?MySQLdb not allowing hyphen may be way to prevent injection > attack. > I have something like below: > > "insert into reviews(message, title)values('%s', '%s')" %( "We don't know > where to go","We can't wait till morrow"?) > > ProgrammingError(1064, "You have an error in your SQL syntax; check the > manual that corresponds to your MySQL server version for the right syntax to > use near 't know where to go. > > How do I work around this error? Don't use raw SQL strings in the first place. Use a proper parameterized query, e.g.: cursor.execute("insert into reviews(message, title) values (%s, %s)", ("We don't know where to go", "We can't wait till morrow")) Cheers, Chris From modelnine at modelnine.org Sun Feb 5 18:03:33 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Mon, 06 Feb 2012 00:03:33 +0100 Subject: [Perl Golf] Round 1 In-Reply-To: References: <4F2EB89C.9080801@modelnine.org> Message-ID: <4F2F0AC5.1060908@modelnine.org> Am 05.02.2012 23:15, schrieb Neal Becker: > Heiko Wundram wrote: >> Am 05.02.2012 12:49, schrieb Alec Taylor: >>> Solve this problem using as few lines of code as possible[1]. >> >> Pardon me, but where's "the problem"? If your intention is to propose "a >> challenge", say so, and state the associated problem clearly. > > But this really misses the point. Python is not about coming up with some > clever, cryptic, one-liner to solve some problem. It's about clear code. If > you want clever, cryptic, one-liner's stick with perl. You're only allowed to bash him for one-liners as soon as he formulates something that in some way or another resembles a programming challenge, and not some incoherent listing of words without actual intent... ;-) -- --- Heiko. From rantingrickjohnson at gmail.com Sun Feb 5 18:29:35 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 5 Feb 2012 15:29:35 -0800 (PST) Subject: Common LISP-style closures with Python References: Message-ID: <6abce3f9-808a-4642-9a24-24951230e825@h3g2000yqe.googlegroups.com> On Feb 3, 6:27?pm, Antti J Ylikoski wrote: > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. ?It > is done as follows: > [...] do my eyes not see nor my ears not hear? a thread about common Lisp and Xan Lee is not near? would someone please him wake up and tell him all about, the thread titled "Common LISP-style closures with Python" and that he has been left out! From emekamicro at gmail.com Sun Feb 5 18:52:28 2012 From: emekamicro at gmail.com (Emeka) Date: Mon, 6 Feb 2012 01:52:28 +0200 Subject: MySQLdb not allowing hyphen In-Reply-To: <3a3ui7hmkbq7op1b2m2tvsmee6aimaelkh@4ax.com> References: <3a3ui7hmkbq7op1b2m2tvsmee6aimaelkh@4ax.com> Message-ID: Dennis , Chris Thanks so much! On Mon, Feb 6, 2012 at 1:23 AM, Dennis Lee Bieber wrote: > On Mon, 6 Feb 2012 00:41:24 +0200, Emeka wrote: > > >Hello All, > > > >I noticed that MySQLdb not allowing hyphen may be way to prevent injection > >attack. > > What hyphen? > > >I have something like below: > > > >"insert into reviews(message, title)values('%s', '%s')" %( "We don't know > >where to go","We can't wait till morrow" ) > > > > >How do I work around this error? > > Very simple... DON'T QUOTE PLACEHOLDERS AND USE MySQLdb > parameterized queries. > > csr.execute("insert into reviews (message, title) values (%s, %s)", > ( "We don't know where to go", > "We can't wait till morrow" ) ) > > The whole purpose of parameterized queries is that the .execute() > logic will SAFELY wrap the supplied values with quotes AND escape any > problem characters within the value. > > The reason you got an error was not a hyphen (there are no hyphens > in your example) but rather that you closed the quote. Your generated > SQL was: > > insert into reviews (message, title) values ('We don't know where to > go', 'We can't wait till morrow') > > which means a string of: > "We don" > SQL garbage > t know where to go > string > ", " > SQL garbage > We can > and another string > "t wait till morrow" > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcepl at redhat.com Sun Feb 5 19:58:32 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 01:58:32 +0100 Subject: Python and TAP Message-ID: I have just finished listening to the FLOSS Weekly podcast #200 (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned about the existence of TAP (http://testanything.org/). A standardization of testing seems to be so obviously The Right Thing?, that it is strange that I don't see much related movement in the Python world (I know only about http://git.codesimply.com/?p=PyTAP.git;a=summary or git://git.codesimply.com/PyTAP.git, which seems to be very very simple and only producer). What am I missing? Why nobody seems to care about joining TAP standard? Best, Mat?j From tjreedy at udel.edu Sun Feb 5 20:26:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 05 Feb 2012 20:26:40 -0500 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: > On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor > wrote: > >> A 4 year old compiler? >> >> I also have MSVC11 installed. Can the python project add support for >> that so that we aren't waiting 5 years between compiler support? 3.3 will almost certainly be built with VS2010. -- Terry Jan Reedy From mcepl at redhat.com Sun Feb 5 20:27:38 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 02:27:38 +0100 Subject: difference between random module in python 2.6 and 3.2? Message-ID: Hi, I have this working function: def as_xml(self): out = etree.Element("or") for k in sorted(self.keys()): out.append(etree.Element("hostname", attrib={'op': '=', 'value': random.choice(self[k])})) # ... return somehow string representing XML and this unit test def test_XML_print(self): random.seed(1) expected = ... # expected XML observed = self.data.as_xml() self.assertEqual(observed, expected, "Verbose print (including PCI IDs)") Strange thing is that this unit tests correctly with python3, but fails with python2. The problem is that apparently python3 random.choice picks different element of self[k] than the one python2 (at least, both of them are constant in their choice). Is it known that there is this difference? Is there a way how to make both random.choice select the same? Best, Mat?j From steve+comp.lang.python at pearwood.info Sun Feb 5 23:01:05 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 04:01:05 GMT Subject: difference between random module in python 2.6 and 3.2? References: Message-ID: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote: > Strange thing is that this unit tests correctly with python3, but fails > with python2. The problem is that apparently python3 random.choice picks > different element of self[k] than the one python2 (at least, both of > them are constant in their choice). Confirmed: steve at runes:~$ python2.6 -c "from random import choice, seed; seed(1); print choice(range(1000))" 134 steve at runes:~$ python3.2 -c "from random import choice, seed; seed(1); print(choice(list(range(1000))))" 137 steve at runes:~$ python2.6 -c "from random import choice, seed; seed(42); print choice(range(1000))" 639 steve at runes:~$ python3.2 -c "from random import choice, seed; seed(42); print(choice(list(range(1000))))" 654 > Is it known that there is this difference? Is there a way how to make > both random.choice select the same? Reading the docs, I would expect that when using an int as seed, you should get identical results. There is no mention that the PRNG has changed between 2.6 and 3.2; both should use the given int as seed. There is a change of behaviour when using strings/bytes/bytearrays, and Python3.2 provides a "version=N" argument to seed to set the old behaviour. But this doesn't apply to integer seeds. I call this a bug. It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6: steve at runes:~$ python3.1 -c "from random import choice, seed; seed(42); print(choice(list(range(1000))))" 639 steve at runes:~$ python3.1 -c "from random import choice, seed; seed(1); print(choice(list(range(1000))))" 134 -- Steven From tjreedy at udel.edu Mon Feb 6 00:07:04 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 00:07:04 -0500 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > Reading the docs, I would expect that when using an int as seed, you > should get identical results. That is similar to expecting hash to be consistent from version to version. > There is no mention that the PRNG has changed between 2.6 and 3.2; There is at best an informal policy. This was discussed in http://bugs.python.org/issue9025 Antoine argued that if there were a written policy, it should be limited to bug-fix releases within a version. I agree. > It appears to be a bug in 3.2, because 3.1 gives the same results as 2.6: This change is a side effect of fixing the bug of non-uniformity discussed in that issue. In any case, in 2.7 and probably 3.1: def choice(self, seq): """Choose a random element from a non-empty sequence.""" return seq[int(self.random() * len(seq))] # raises IndexError whereas in 3.2: def choice(self, seq): """Choose a random element from a non-empty sequence.""" try: i = self._randbelow(len(seq)) except ValueError: raise IndexError('Cannot choose from an empty sequence') return seq[i] The change was announced in What's New in 3.2 random The integer methods in the random module now do a better job of producing uniform distributions. Previously, they computed selections with int(n*random()) which had a slight bias whenever n was not a power of two. Now, multiple selections are made from a range up to the next power of two and a selection is kept only when it falls within the range 0 <= x < n. The functions and methods affected are randrange(), randint(), choice(), shuffle() and sample(). -- Terry Jan Reedy From mohsen at pahlevanzadeh.org Mon Feb 6 00:48:02 2012 From: mohsen at pahlevanzadeh.org (Mohsen Pahlevanzadeh) Date: Mon, 06 Feb 2012 09:18:02 +0330 Subject: help function and operetors overloading Message-ID: <1328507282.11367.40.camel@debian> Dear all, You know python has many functions for operators overloading such as __add__, __radd__, __invert__, __eq__ and so on. How i see the complete list of them with help function? Yours, Mohsen -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 316 bytes Desc: This is a digitally signed message part URL: From antti.ylikoski at tkk.fi Mon Feb 6 00:55:50 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Mon, 06 Feb 2012 07:55:50 +0200 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: On 5.2.2012 22:58, Ian Kelly wrote: > On Sat, Feb 4, 2012 at 9:19 PM, Antti J Ylikoski wrote: >>> I'm not sure how naughty this is, but the same thing can be done without >>> using >>> nonlocal by storing the local state as an attribute of the enclosed >>> function >>> object: >>> >>> ... >> >> Yes, I do know that, but then it would not be a closure :-))))))))) > > Sure it is. Where do you think it looks up the function object? > > Cheers, > Ian OK, thank you for correcting me. Andy From steve+comp.lang.python at pearwood.info Mon Feb 6 00:56:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 05:56:23 GMT Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > >> Reading the docs, I would expect that when using an int as seed, you >> should get identical results. > > That is similar to expecting hash to be consistent from version to > version. No. hash is not intended to be consistent across versions, or even across runs of the interpreter. Of course it may be, but that's not an implicit or explicit promise. Seeding a pseudo-random number generator, on the other hand, is explicitly for generating the same repeatable, consistent set of results. That's what seed is *for*. It is even documented that way: http://docs.python.org/py3k/library/random.html#notes-on-reproducibility although the docs weasel out of promising anything other than random.random() will be predictable. When the Mersenne Twister was introduced, the old Wichman-Hill PRNG was provided for those who needed repeatability. (I see it's gone now, but if people haven't migrated their code from 2.3 yet, shame on them.) >> There is no mention that the PRNG has changed between 2.6 and 3.2; > > There is at best an informal policy. This was discussed in > http://bugs.python.org/issue9025 > Antoine argued that if there were a written policy, it should be limited > to bug-fix releases within a version. I agree. I think this thread demonstrates that there are people who depend on repeatability of the random number routines, and not just for random.random(). I think it is ironic (and annoying) that the same release of Python that introduced a version argument to seed() to provide a backward compatible seeding algorithm, also introduced a backward incompatible change to choice(). This, plus Raymond Hettinger's comments on the bug report, make me think that the change in behaviour of randrange and choice is not deliberate and should be treated as a bug. Raymond made a strong case arguing for repeatability, and then approved a bug fix that broke repeatability. I doubt that was deliberate. -- Steven From clp2 at rebertia.com Mon Feb 6 01:00:14 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 5 Feb 2012 22:00:14 -0800 Subject: help function and operetors overloading In-Reply-To: <1328507282.11367.40.camel@debian> References: <1328507282.11367.40.camel@debian> Message-ID: On Sun, Feb 5, 2012 at 9:48 PM, Mohsen Pahlevanzadeh wrote: > Dear all, > > You know python has many functions for operators overloading such as > __add__, __radd__, __invert__, __eq__ and so on. > How i see the complete list of them with help function? I don't know if there's a help() entry for them. The docs have a full list of those "special method names": http://docs.python.org/reference/datamodel.html#special-method-names Cheers, Chris From rosuav at gmail.com Mon Feb 6 01:49:20 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 17:49:20 +1100 Subject: [Perl Golf] Round 1 In-Reply-To: <4F2F0AC5.1060908@modelnine.org> References: <4F2EB89C.9080801@modelnine.org> <4F2F0AC5.1060908@modelnine.org> Message-ID: On Mon, Feb 6, 2012 at 10:03 AM, Heiko Wundram wrote: > You're only allowed to bash him for one-liners as soon as he formulates > something that in some way or another resembles a programming challenge, and > not some incoherent listing of words without actual intent... ;-) Nah, one-liners are fun. Look, here's a Python one-liner that generates a month's worth of emails: t = ('a', [23]); t[1] += [42] *ducks for cover* ChrisA From rosuav at gmail.com Mon Feb 6 01:53:50 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 17:53:50 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy wrote: > On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: >> >> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor >> wrote: >> >>> A 4 year old compiler? >>> >>> I also have MSVC11 installed. Can the python project add support for >>> that so that we aren't waiting 5 years between compiler support? > > > 3.3 will almost certainly be built with VS2010. I suppose there's no chance of moving to a free compiler? For my Windows work, I've generally used the Open Watcom compiler; that's not to say it's the best, but it does the job, and it's free software. But no, I'm not offering. Way way too many jobs that I already have queued, sorry! ChrisA From tjreedy at udel.edu Mon Feb 6 02:27:14 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:27:14 -0500 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/6/2012 12:56 AM, Steven D'Aprano wrote: > On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > >> On 2/5/2012 11:01 PM, Steven D'Aprano wrote: >> >>> Reading the docs, I would expect that when using an int as seed, you >>> should get identical results. >> >> That is similar to expecting hash to be consistent from version to >> version. > > No. hash is not intended to be consistent across versions, or even across Oh, but it was. Changing it will break tests, including some in the Python test suite. ... > This, plus Raymond Hettinger's comments on the bug report, make me think > that the change in behaviour of randrange and choice is not deliberate As I said, it was a necessary consequence of a bug fix. > and should be treated as a bug. Raymond made a strong case arguing for > repeatability, and then approved a bug fix that broke repeatability. I > doubt that was deliberate. It was deliberate that randrange was changed to an even distribution from a slightly uneven distribute. That implies a change in the pattern. That was known and the main subject of discussion. As Antoine said, making functions exactly repeatable across versions means not fixing bugs or otherwise improving them. This statement is not limited to the random module. You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improvements are needed or thought sufficiently desirable. -- Terry Jan Reedy From tjreedy at udel.edu Mon Feb 6 02:28:52 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:28:52 -0500 Subject: help function and operetors overloading In-Reply-To: <1328507282.11367.40.camel@debian> References: <1328507282.11367.40.camel@debian> Message-ID: On 2/6/2012 12:48 AM, Mohsen Pahlevanzadeh wrote: > Dear all, > > You know python has many functions for operators overloading such as > __add__, __radd__, __invert__, __eq__ and so on. > How i see the complete list of them with help function? >>> import operator >>> help(operator) Help on built-in module operator: ... -- Terry Jan Reedy From tjreedy at udel.edu Mon Feb 6 02:39:32 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 02:39:32 -0500 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On 2/6/2012 1:53 AM, Chris Angelico wrote: > On Mon, Feb 6, 2012 at 12:26 PM, Terry Reedy wrote: >> On 2/5/2012 6:23 PM, Dennis Lee Bieber wrote: >>> >>> On Mon, 6 Feb 2012 03:42:08 +1100, Alec Taylor >>> wrote: >>> >>>> A 4 year old compiler? >>>> >>>> I also have MSVC11 installed. Can the python project add support for >>>> that so that we aren't waiting 5 years between compiler support? >> >> >> 3.3 will almost certainly be built with VS2010. > > I suppose there's no chance of moving to a free compiler? VC express is free-as-in-beer. The whole V. Studio is free to core developers. MS may not *like* open-source software, but they have decided they would like it even less if everyone compiled it with non-MS compilers. > Windows work, I've generally used the Open Watcom compiler; that's not > to say it's the best, but it does the job, and it's free software. Would it build CPython, including the +- dependent libraries like tcl/tk? How would the speed compare? > But no, I'm not offering. Way way too many jobs that I already have > queued, sorry! I guess the answer will have to wait ;-). -- Terry Jan Reedy From steve+comp.lang.python at pearwood.info Mon Feb 6 03:05:43 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Feb 2012 08:05:43 GMT Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote: [...] >> and should be treated as a bug. Raymond made a strong case arguing for >> repeatability, and then approved a bug fix that broke repeatability. I >> doubt that was deliberate. > > It was deliberate that randrange was changed to an even distribution > from a slightly uneven distribute. That implies a change in the pattern. Okay, granted. > That was known and the main subject of discussion. As Antoine said, > making functions exactly repeatable across versions means not fixing > bugs or otherwise improving them. This statement is not limited to the > random module. > > You have persuaded me that the doc should be more explicit that while > the basic random.random sequence will be kept repeatable with seed set > (except perhaps after a changeover of several releases), the convenience > transformations can be changed if improvements are needed or thought > sufficiently desirable. A more explicit note will help, but the basic problem applies: how do you write deterministic tests given that the random.methods (apart from random.random itself) can be changed without warning? -- Steven From bruno.desthuilliers at gmail.com Mon Feb 6 03:26:14 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 6 Feb 2012 00:26:14 -0800 (PST) Subject: Help about dictionary append References: Message-ID: <8017354d-3766-4c20-96f0-259b9b1a7274@f30g2000yqh.googlegroups.com> On Feb 5, 4:29?pm, Andrew Berg wrote: > This has nothing to do with dictionaries. If you want to add, delete, or > change items, use a list (or a set if there aren't supposed to be any > duplicates). AND you don't care about ordering... From mcepl at redhat.com Mon Feb 6 03:45:30 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 09:45:30 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 6.2.2012 09:05, Steven D'Aprano wrote: >> You have persuaded me that the doc should be more explicit that while >> the basic random.random sequence will be kept repeatable with seed set >> (except perhaps after a changeover of several releases), the convenience >> transformations can be changed if improvements are needed or thought >> sufficiently desirable. > > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Could we get some hint in the release notes? Thanks for the help, Mat?j From mcepl at redhat.com Mon Feb 6 03:57:04 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 09:57:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 6.2.2012 09:45, Matej Cepl wrote: > Also, how could I write a re-implementation of random.choice which would > work same on python 2.6 and python 3.2? It is not only matter of unit > tests, but I would really welcome if the results on both versions > produce the same results. Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Mat?j From rosuav at gmail.com Mon Feb 6 03:57:10 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 6 Feb 2012 19:57:10 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <423ui7l611mppe6g8ljnj5fm98umimh508@4ax.com> Message-ID: On Mon, Feb 6, 2012 at 6:39 PM, Terry Reedy wrote: > On 2/6/2012 1:53 AM, Chris Angelico wrote: >> I suppose there's no chance of moving to a free compiler? > > VC express is free-as-in-beer. The whole V. Studio is free to core > developers. MS may not *like* open-source software, but they have decided > they would like it even less if everyone compiled it with non-MS compilers. Oh, that's something at least. I wasn't aware of what exactly they charge for and what they don't. >> Windows work, I've generally used the Open Watcom compiler; that's not >> to say it's the best, but it does the job, and it's free software. > > Would it build CPython, including the +- dependent libraries like tcl/tk? > How would the speed compare? I can't answer that question without grabbing the sources, going through the whole work of porting makefiles etc, and finding out whether there's failures - in other words, doing the whole job. It's entirely possible that there'll be some dependency failure; but I would posit that, on balance, it's more likely there won't be. As to speed - I've not done a lot of compiler benchmarking. (Not sure whether you mean compilation speed or the efficiency of the resulting code; either way, I've not tried.) Never actually had multiple compilers on any one platform for long enough to do serious testing. It's hardly fair to compare Borland C++ for Windows 3.1, icc on OS/2 32-bit, Open Watcom on XP, and gcc on Debian 64-bit! It's probably not worth the hassle of changing compilers, although I do wonder whether changing compiler _versions_ isn't sometimes nearly as much work. ("What? All that legacy code doesn't compile any more? Ohh... it doesn't like #include any more...") ChrisA From jldunn2000 at gmail.com Mon Feb 6 04:23:41 2012 From: jldunn2000 at gmail.com (loial) Date: Mon, 6 Feb 2012 01:23:41 -0800 (PST) Subject: newbie socket help References: <4e70f47b-89e4-46bb-929e-9b7db20e7bcc@l16g2000vbl.googlegroups.com> Message-ID: <5563be07-e64f-497e-81a4-23bd3cb0eda5@bs8g2000vbb.googlegroups.com> OS is Red hat enterprise linux 5.5 and python version is 2.6 On Feb 2, 4:34?pm, Dennis Lee Bieber wrote: > On Thu, 2 Feb 2012 05:53:22 -0800 (PST), loial > wrote: > > >I am trying to write a python script to read data from a printer port > >using python sockets, but it seems I am locking up the port. > > >Is there a way to ensure that I do not block the port to other > >applications? > > >My knowledge of python sockets is minimal, so any help would be > >appreciated. > > ? ? ? ? OS and Python version might be of interest... > > ? ? ? ? However, parallel ports are typically unshared devices (which is why > any multitasking system has things like print spooling -- so multiple > tasks and "print" to the spool, and the spool driver is the only process > actually accessing the printer port). > > ? ? ? ? I still have nightmares over one assignment I had some 8 years ago: > Reading a clock signal (square wave) on one of the parallel port's > signal pins, in order to time a three-bit /balanced/ (using 6-pins of > the output) data stream. Done on a W98 laptop (since W98 didn't have the > protected ports of WinXP) using Visual C++ ?-- and on the laptop as the > eventual plan had been to send "red" GPS decryption keys to satellites; > contact with "red" keys makes the hardware it passes through highly > classified, and the main hardware had to stay "open" for uncleared > developers working on flight software. > > ? ? ? ? Unfortunately, even with the program running at the highest > available Windows priority, the OS still did every few > milliseconds, which led to glitches in the output stream. (The good > news: by the time the DTD with the keys became available, the CONOPS had > changed to use "black" keys, which did not "infect" the computer system > -- so the regular command formatter could be used for uploading). > > -- > ? ? ? ? Wulfraed ? ? ? ? ? ? ? ? Dennis Lee Bieber ? ? ? ? AF6VN > ? ? ? ? wlfr... at ix.netcom.com ? ?HTTP://wlfraed.home.netcom.com/ From fb at alien8.de Mon Feb 6 07:24:23 2012 From: fb at alien8.de (Frank Becker) Date: Mon, 06 Feb 2012 13:24:23 +0100 Subject: Python and TAP In-Reply-To: References: Message-ID: <4F2FC677.7020606@alien8.de> On 06.02.12 01:58, Matej Cepl wrote: Hi, > I have just finished listening to the FLOSS Weekly podcast #200 > (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned > about the existence of TAP (http://testanything.org/). A standardization > of testing seems to be so obviously The Right Thing?, that it is strange > that I don't see much related movement in the Python world (I know only > about http://git.codesimply.com/?p=PyTAP.git;a=summary or > git://git.codesimply.com/PyTAP.git, which seems to be very very simple > and only producer). > > What am I missing? Why nobody seems to care about joining TAP standard? Not sure. Probably it comes down to what you need depending on your tool chain. But there are alternatives. Most prominent to my knowledge is subunit [0]. Here is a comparison between the two [1]. One warning when you jump on the TAP train: Using the Python YAML module PyYAML you will have to find out that TAP uses a YAML subset called YAMLish [3]. It's not the same and pretty much defined by the Perl implementation. [0] https://launchpad.net/subunit [1] http://www.kinoshita.eti.br/2011/06/04/a-comparison-of-tap-test-anything-protocol-and-subunit/ [2] http://pyyaml.org/ [3] http://testanything.org/wiki/index.php/YAMLish Bye, Frank -- Frank Becker (jabber|mail) | http://twitter.com/41i3n8 GnuPG: 0xADC29ECD | F01B 5E9C 1D09 981B 5B40 50D3 C80F 7459 ADC2 9ECD -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 307 bytes Desc: OpenPGP digital signature URL: From info at egenix.com Mon Feb 6 08:46:47 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 06 Feb 2012 14:46:47 +0100 Subject: ANN: eGenix mx Base Distribution 3.2.3 (mxDateTime, mxTextTools, etc.) Message-ID: <4F2FD9C7.50101@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mx Base Distribution Version 3.2.3 for Python 2.4 - 2.7 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.3-GA.html ________________________________________________________________________ ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Easy to use Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python The package also include a number of helpful smaller modules in the mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing or mx.Misc.CommandLine to quickly write command line applications in Python. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. For more information, please see the distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ NEWS The 3.2.3 release of the eGenix mx Base Distribution is the latest release of our open-source Python extensions. The new patch-level version includes a few important fixes: * Fixed a possible segfault when using the .pydate(), .pydatetime() and .pytime() methods. Thanks to Daniel Szoska for reporting this. If you are upgrading from eGenix mx Base 3.1.x, please also see the eGenix mx Base Distribution 3.2.0 release notes for details on what has changed and which new features are available: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on all other Python platforms, such as Solaris, AIX, HP-UX, etc. To simplify installation in Zope/Plone and other egg-based systems, we have also precompiled egg distributions for all platforms. These are available on our own PyPI-style index server for easy and automatic download. Whether you are using a pre-built package or the source distribution, installation is a simple "python setup.py install" command in all cases. The only difference is that the pre-built packages do not require a compiler or the Python development packages to be installed. For a full list of changes, please refer to the eGenix mx Base Distribution change log at http://www.egenix.com/products/python/mxBase/changelog.html and the change logs of the various included Python packages. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use the packages in both commercial and non-commercial settings without fee or charge. The package comes with full source code ________________________________________________________________________ SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 06 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From eric.frederich at gmail.com Mon Feb 6 09:39:21 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Mon, 6 Feb 2012 09:39:21 -0500 Subject: nested embedding of interpreter Message-ID: Hello, I work with a 3rd party tool that provides a C API for customization. I created Python bindings for this C API so my customizations are nothing more than this example wrapper code almost verbatim: http://docs.python.org/extending/embedding.html#pure-embedding I have many .c files just like that only differing by the module and function that they load and execute. This has been working fine for a long time. Now, as we add more and more customizations that get triggered at various events we have come to a problem. If some of the Python customization code gets triggered from inside another Python customization I get a segfault. I thought this might have something to do with the nesting which is the equivalent of calling Py_Initialize() twice followed by Py_Finalize() twice. I went into the C wrapper code for the inner-most customization and commented out the Py_Initialize and Py_Finalize calls and it worked nicely. Further testing showed that I only needed to remove the Py_Finalize call and that calling Py_Initialize twice didn't cause a segfault. So, now that I think I verified that this is what was causing the segfault, I'd like to ask some questions. 1) Is calling Py_Initialize twice correct, or will I run into other problems down the road? 2) Another option I have is that I can remove all Py_Initialize / Py_Finalize calls from the individual customizations and just call Py_Initialize once when a user first starts the program. I am not sure if there is a mechanism to get something called at the end of the user's session with the program though, so is it a problem if I don't call Py_Finalize at the end? 3) Is there a proper way to nest these things? I imagine not since Py_Finalize doesn't take any arguments. If I could do... int session = Py_Initialize() Py_Finalize(session) But obviously, CPython is not coded that way so it is not supported. Thanks, ~Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwilson at the-wire.com Mon Feb 6 10:20:31 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Mon, 06 Feb 2012 10:20:31 -0500 Subject: difference between random module in python 2.6 and 3.2? References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control. Jon Bentley somewhere, sometime, published a portable PRNG for that exact reason. (I wish I could find that article.) Specifically he wanted portability across various manufacturer's O/Ss. Mel. From jenn.duerr at gmail.com Mon Feb 6 11:10:33 2012 From: jenn.duerr at gmail.com (noydb) Date: Mon, 6 Feb 2012 08:10:33 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> Message-ID: <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> Adding to dictionaries just isn't obvious... if it's not dict.Add or dict.Appaned or the like, not obvious to inexperienced me! From miki.tebeka at gmail.com Mon Feb 6 13:01:07 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 6 Feb 2012 10:01:07 -0800 (PST) Subject: undefined symbol: PyUnicodeUCS4_AsUTF8String In-Reply-To: References: Message-ID: <11079676.854.1328551268243.JavaMail.geo-discussion-forums@yqia35> IIRC it means that cairo was compiled against a Python compiled with --enable-unicode=ucs4. But the version of Python you have was not (default is ucs2). Maybe you can find a different version/packaging of cairo that matches this. From a.france.mailinglists at gmail.com Mon Feb 6 13:48:40 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Mon, 06 Feb 2012 19:48:40 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F302088.8010901@gmail.com> On 02/06/2012 09:57 AM, Matej Cepl wrote: > On 6.2.2012 09:45, Matej Cepl wrote: >> Also, how could I write a re-implementation of random.choice which would >> work same on python 2.6 and python 3.2? It is not only matter of unit >> tests, but I would really welcome if the results on both versions >> produce the same results. > > Silly, of course, the solution is obvious ... I have just embedded > random.choice from 2.6 to my code. > > Mat?j Is the above actually a good idea though? What I understand you're doing is embedding the source from the Python2.6 random.py file, /into/ your project files? Regards, A -------------- next part -------------- An HTML attachment was scrubbed... URL: From python.list at tim.thechases.com Mon Feb 6 14:26:42 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 06 Feb 2012 13:26:42 -0600 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: <4F302088.8010901@gmail.com> References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: <4F302972.4010607@tim.thechases.com> On 02/06/12 12:48, Aaron France wrote: > On 02/06/2012 09:57 AM, Matej Cepl wrote: >> Silly, of course, the solution is obvious ... I have just >> embedded random.choice from 2.6 to my code. >> >> Mat?j > Is the above actually a good idea though? > > What I understand you're doing is embedding the source from > the Python2.6 random.py file, /into/ your project files? In an ideal world, the code wouldn't have broken backwards compat. However, given the conditions, if Matej is willing to forgo bug-fixes, it's a reasonable solution. The alternate might be to try moving the recent/fixed version into the old project and updating tests/data to work with it. I have some 2.4 production code in which I've pulled 2.6's zipfile module in to give access to the iterator access (rather than the .read() method which tries to read in umpteen gigs of data that I just want to spool out to a file on disk). -tkc From solipsis at pitrou.net Mon Feb 6 14:59:24 2012 From: solipsis at pitrou.net (Antoine Pitrou) Date: Mon, 6 Feb 2012 19:59:24 +0000 (UTC) Subject: nested embedding of interpreter References: Message-ID: Hello, Eric Frederich gmail.com> writes: > > 1)Is calling Py_Initialize twice correct, or will I run into other problems > down the road? It's fine in practice (spurious calls are ignored). > I am not sure if there is a mechanism to get something called at the end of the > user's session with the program though, so is it a problem if I don't call > Py_Finalize at the end? Yes, it's a problem. If you don't call Py_Finalize, atexit handlers, object destructors and the like will not be called. These include destructors of file objects (including stdout): any buffering in a still-open file opened for writing can be lost. Regards Antoine. From tjreedy at udel.edu Mon Feb 6 15:51:54 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 15:51:54 -0500 Subject: Python and TAP In-Reply-To: <4F2FC677.7020606@alien8.de> References: <4F2FC677.7020606@alien8.de> Message-ID: On 2/6/2012 7:24 AM, Frank Becker wrote: > On 06.02.12 01:58, Matej Cepl wrote: >> I have just finished listening to the FLOSS Weekly podcast #200 >> (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned >> about the existence of TAP (http://testanything.org/). A standardization >> of testing seems to be so obviously The Right Thing?, that it is strange >> that I don't see much related movement in the Python world (I know only TAP is not about 'standardization of testing' but standardized communication of test results between test modules and test harness. Python's two stdlib test packages include both test-writing methods and a test harness. They are compatible in the sense that doctests can be run within the unittest framework. >> about http://git.codesimply.com/?p=PyTAP.git;a=summary or >> git://git.codesimply.com/PyTAP.git, which seems to be very very simple >> and only producer). I presume PyTAP does something like converting (or rather, wrapping) output from unittests to (or rather, within) the TAP format, which includes wrapping in YAMLish. Or it provides alternate versions of the numerous AssertXxx functions in unittest. This is useful for someone running Python tests within a TAP harness, but not otherwise. >> What am I missing? Why nobody seems to care about joining TAP standard? The 'TAP standard' is what the Perl TAP module does. There is a pre-draft for an IETF standard. You could ask why Perl people don't care about joining the unittest 'standard'. -- Terry Jan Reedy From nedimmuminovic at gmail.com Mon Feb 6 16:18:15 2012 From: nedimmuminovic at gmail.com (n3d!m) Date: Mon, 6 Feb 2012 13:18:15 -0800 (PST) Subject: Http post and http get In-Reply-To: <26848894.3029.1327530209876.JavaMail.geo-discussion-forums@vbxy22> References: <26848894.3029.1327530209876.JavaMail.geo-discussion-forums@vbxy22> Message-ID: <31716695.3432.1328563095624.JavaMail.geo-discussion-forums@vbek1> Cookies work because I am able to login on website and GET other pages. From jeandupont115 at gmail.com Mon Feb 6 16:40:35 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Mon, 6 Feb 2012 13:40:35 -0800 (PST) Subject: how to read serial stream of data [newbie] Message-ID: I'd like to read in a stream of data which looks like this: the device sends out a byte-string of 11 bytes roughly every second: B0B0B0B0B03131B0B50D8A B0B0B0B0B03131B0B50D8A B0B0B031B63131B0310D8A B0B034B3323432B3310D8A B0B03237B53432B3310D8A . . . As you see every string is ended by 0D8A How can this be accomplished in Python? thanks Jean From mcepl at redhat.com Mon Feb 6 17:03:09 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 23:03:09 +0100 Subject: Python and TAP In-Reply-To: References: <4F2FC677.7020606@alien8.de> Message-ID: On 6.2.2012 21:51, Terry Reedy wrote: > The 'TAP standard' is what the Perl TAP module does. There is a > pre-draft for an IETF standard. You could ask why Perl people don't care > about joining the unittest 'standard'. I don't think it is fair: http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links (or http://testanything.org/wiki/index.php/TAP_Producers and http://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of producers and consumers in various programming languages. Mat?j From mcepl at redhat.com Mon Feb 6 17:06:04 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 06 Feb 2012 23:06:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: On 6.2.2012 20:26, Tim Chase wrote: > In an ideal world, the code wouldn't have broken backwards compat. > However, given the conditions, if Matej is willing to forgo bug-fixes, > it's a reasonable solution. The alternate might be to try moving the > recent/fixed version into the old project and updating tests/data to > work with it. I have some 2.4 production code in which I've pulled 2.6's > zipfile module in to give access to the iterator access (rather than the > .read() method which tries to read in umpteen gigs of data that I just > want to spool out to a file on disk). Given I really don't care that much about distribution of my choice, this function def _choice(self, seq): """Choose a random element from a non-empty sequence. Embedding random.choice from 2.6 in order to get an uniform results between 2.6 and 3.2, where random module has been changed because of http://bugs.python.org/issue9025. See also http://groups.google.com/group/comp.lang.python\ /browse_thread/thread/2b000b8ca8c5e98e Raises IndexError if seq is empty """ return seq[int(random.random() * len(seq))] doesn't seem like something so terrible (and maintenance intense). :) Thanks for the help though Mat?j From casevh at gmail.com Mon Feb 6 18:27:17 2012 From: casevh at gmail.com (casevh) Date: Mon, 6 Feb 2012 15:27:17 -0800 (PST) Subject: PyCrypto builds neither with MSVC nor MinGW References: Message-ID: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> On Feb 5, 6:40?am, Alec Taylor wrote: > PIL, PyCrypto and many other modules require a C compiler and linker. > > Unfortunately neither install on my computer, with a PATH with the following: > > C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC > C:\libraries\MinGW\msys\1.0\bin > C:\libraries\MinGW > C:\Python27\Scripts > > Output from G:\pycrypto>vcvarsall.bat > Setting environment for using Microsoft Visual Studio 2010 x86 tools. > > Error output from G:\pycrypto>python setup.py build --compiler msvc > http://pastebin.com/nBsuXDGg A couple of comments. You will need to complile either GMP or MPIR first. MPIR is a windows friendly fork of GMP and I use it create Windows binaries for gmpy. > > Error output from G:\pycrypto>python setup.py build --compiler mingw32 > 1> log1 2> log2 > Log1:http://pastebin.com/yG3cbdZv > Log2:http://pastebin.com/qvnshPeh > > Will there ever be support for newer MSVC versions? - Also, why Python 2.7 uses VS2008. I use the command line compiler included with in Microsoft's SDK 7.0 which is still available for download. I have step- by-step build instructions included in gmpy's source download. I would try to build MPIR and gmpy first and then adapt/modify the process for PyCrypto. MPIR home page: www.mpir.org gmpy source: gmpy.googlecode.com/files/gmpy-1.15.zip > doesn't even MinGW install PyCrypto for me? > > Thanks for all suggestions, > > Alec Taylor Hope these comments help... casevh From nitinbhargava74 at hotmail.com Mon Feb 6 21:12:08 2012 From: nitinbhargava74 at hotmail.com (Nitin Bhargava) Date: Tue, 7 Feb 2012 02:12:08 +0000 Subject: ctypes pointer Message-ID: Hi, I wish to call a function in c++ dll which returns a unicode array from python. extern "c" { __declspec(dllexport) int test(wchar_t** ppText) { *ppText = new wchar_t[30]; wcscpy(*ppText, L"this is a test"); return 0; } __declspec(dllexport) int FreeString(wchar_t** ppText) { delete [] *ppText; return 0; } } In python I'm doing this import ctypes dll = ctypes.cdll.LoadLibrary(r"x") func = dll.test func.argtypes = [ ctypes.POINTER(ctypes.c_wchar_p)] funcDel = dll.FreeString funcDel.argtypes = [ctypes.POINTER(ctypes.c_wchar_p)] a = ctypes.c_wchar_p('') z = ctypes.pointer(a) n= func(z) print a /* displays "this is a test" */ /* is this correct way to return charater array */ /* will memory allocated in c++ function be freed by python */ /* or should I call */ n = funcDel(z) thanks, Nitin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From wuwei23 at gmail.com Mon Feb 6 22:21:08 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:21:08 -0800 (PST) Subject: Python and TAP References: <4F2FC677.7020606@alien8.de> Message-ID: <8fcb166f-71b1-4024-9158-aa1b9ca29f9c@v6g2000pba.googlegroups.com> On Feb 7, 8:03?am, Matej Cepl wrote: > On 6.2.2012 21:51, Terry Reedy wrote: > > The 'TAP standard' is what the Perl TAP module does. There is a > > pre-draft for an IETF standard. You could ask why Perl people don't care > > about joining the unittest 'standard'. > > I don't think it is fair:http://en.wikipedia.org/wiki/Test_Anything_Protocol#External_links(orhttp://testanything.org/wiki/index.php/TAP_Producersandhttp://testanything.org/wiki/index.php/TAP_Consumers) shows a lot of > producers and consumers in various programming languages. That doesn't really disprove Terry's point. A lot of languages support Perl's regular expression syntax too: http://en.wikipedia.org/wiki/Regular_expression#Perl-derived_regular_expressions From wuwei23 at gmail.com Mon Feb 6 22:24:17 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:24:17 -0800 (PST) Subject: Python and TAP References: Message-ID: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> On Feb 6, 10:58?am, Matej Cepl wrote: > I have just finished listening to the FLOSS Weekly podcast #200 > (http://twit.tv/show/floss-weekly/200) on autotest, where I've learned > about the existence of TAP (http://testanything.org/). [...] > What am I missing? Experience? Are you seriously advocating something for which you've done nothing more than watch a podcast? > Why nobody seems to care about joining TAP standard? You just discovered it, why do you assume that everyone else is familiar with it? Use it, document your successes and failures, and then if it _has value to you_ come back and tell us about your experiences. From wuwei23 at gmail.com Mon Feb 6 22:38:15 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:38:15 -0800 (PST) Subject: building a dictionary dynamically References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <6e10da9a-a4e2-4531-8272-5f4fc4a592b9@g4g2000pbi.googlegroups.com> On Feb 5, 4:13?am, noydb wrote: > How do you build a dictionary dynamically? > >>> inDict = {} > >>> for inFC in inFClist: > >>> ? ? print inFC > >>> ? ? inCount = ?int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? The easiest way is to use the standard dictionary constructor. dict() can accept a list of key/value pairs: >>> pairs = [('a',1), ('b',2), ('c',3)] >>> dict(pairs) {'a': 1, 'c': 3, 'b': 2} And one way to build a list is with a list comprehension: >>> pairs = [(key, i+1) for i, key in enumerate(['a','b','c'])] >>> pairs [('a', 1), ('b', 2), ('c', 3)] So you can combine the two, using a list comprehension to build the list that is passed into dict(): >>> dict([(key, i+1) for i, key in enumerate(['a','b','c'])]) {'a': 1, 'c': 3, 'b': 2} As a convenience, you don't need the square brackets: >>> dict((key, i+1) for i, key in enumerate(['a','b','c'])) {'a': 1, 'c': 3, 'b': 2} For your example, I'd go with something like this: getCount = lambda x: int(arcpy.GetCount_management(x).getOutput(0)) inDict = dict( (inFC, getCount(inFC)) for inFC in inFClist ) Hope this helps. From wuwei23 at gmail.com Mon Feb 6 22:52:49 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 6 Feb 2012 19:52:49 -0800 (PST) Subject: SnakeScript? (CoffeeScript for Python) References: <21293604.477.1328191753730.JavaMail.geo-discussion-forums@vbbfd4> Message-ID: <34adb528-f190-4d3a-b5ac-92aa826aadfe@iu7g2000pbc.googlegroups.com> On Feb 3, 8:42?pm, Matej Cepl wrote: > Ask anybody developing in CoffeeScript/Vala how much they love debugging > when they have to go through different styles of errors, bugs in the > intermediate processes, etc. I develop in CoffeeScript. I love debugging it because _it's just javascript_. CS doesn't replace JS in any way. It just provides some convenience to cover a lot of the regular heavy lifting. If you're trying to write CS without any understanding of JS at all, well, I can see how that might be a problem, but that's hardly CoffeeScript's failing. From tjreedy at udel.edu Mon Feb 6 23:21:24 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 06 Feb 2012 23:21:24 -0500 Subject: convert perl-script for voltcraft voltmeter to python [newbie] In-Reply-To: References: Message-ID: On 2/2/2012 3:57 PM, Jean Dupont wrote: > I'd like to read in the output of a voltcraft vc960 voltmeter > connected to a usb-port. > I found the perl-script below but I'd like to accomplish the same with > python: The script below is for an old-fashioned, slow, multiple-pin serial port, not usb. I don't know anything about interfacing through usb. Recheck what the voltmeter actually connects to. > I guess I have to use the module serial but I don't know how I should > set the serial parameters so they are the same as in the perl-script. > Could someone supply me the command for setting the serial-parameters > correctly in Python? Last I know, pyserial is also for old serial ports. Setting the properties should be pretty obvious from the manual or code. There are also python usb modules. http://sourceforge.net/projects/mysql-python/?source=directory > #!/usr/bin/perl > > use strict; > use warnings; > > use Device::SerialPort; > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > my ($devicepath) = @ARGV; > > my $port = new Device::SerialPort($devicepath); > die "Couldn't open serial port" if ! defined $port; > > $port->baudrate(2400); > $port->databits(8); > $port->parity("none"); > $port->stopbits(1); > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > #$port->read_char_time(5); # wait 5ms per character > $port->read_const_time(200); # 0.2 second per unfulfilled "read" > call > $| = 1; # autoflush STDOUT > while(1) { > my ($nin, $in) = $port->read(255); > print $in; > } > > $port->close; -- Terry Jan Reedy From d at davea.name Mon Feb 6 23:43:36 2012 From: d at davea.name (Dave Angel) Date: Mon, 06 Feb 2012 23:43:36 -0500 Subject: building a dictionary dynamically In-Reply-To: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> Message-ID: <4F30ABF8.8010202@davea.name> On 02/04/2012 01:13 PM, noydb wrote: > How do you build a dictionary dynamically? Doesn't seem to be an > insert object or anything. So I need an empty dictionary that I then > want to populate with values I get from looping through a list and > grabbing some properties. So simply, I have (fyi, arcpy = module for > interacting with gis data) > >>>> inDict = {} >>>> for inFC in inFClist: >>>> print inFC >>>> inCount = int(arcpy.GetCount_management(inFC).getOutput(0)) > > where I want to make a dictionary like {inFC: inCount, inFC: > inCount, ....} > > How do I build this??? > > And, is dictionaries the best route go about doing a comparison, such > that in the end I will have two dictionaries, one for IN and one for > OUT, as in I'm moving data files and want to verify that the count in > each file matches between IN and OUT. > > Thanks for any help! A dictionary is a mapping from key to value. So each entry consists of a key and a value, where the key is unique. As soon as you add another item with the same key, it overwrites the earlier one. The only other important constraint is that the key has to be of an immutable type, such as int or string. So you want to add the current inFC:inCount as an item in the dictionary? Put the following in your loop. inDict[inFC] = inCount You might also want to check if the key is a duplicate, so you could warn your user, or something. Easiest way to do that is if inFC in inDict: -- DaveA From clp2 at rebertia.com Mon Feb 6 23:48:54 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 6 Feb 2012 20:48:54 -0800 Subject: pySerial question, setting certain serial parameters [newbie] In-Reply-To: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> References: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> Message-ID: On Sat, Feb 4, 2012 at 4:47 AM, Jean Dupont wrote: > I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): > > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > I have thus far the following ?statements but I think it does not set the above parameters correctly: > import serial > voltport='/dev/ttyUSB2' > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) A link to the Perl library's documentation would be helpful. Cheers, Chris From skippy.hammond at gmail.com Mon Feb 6 23:56:45 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Tue, 07 Feb 2012 15:56:45 +1100 Subject: Help with COM_error In-Reply-To: References: Message-ID: <4F30AF0D.2000606@gmail.com> Unfortunately this just means that Word threw an error and it's not giving many details about what that might be. Are you sure out_TOC is valid on the other computer? eg, http://stackoverflow.com/questions/3730428/why-cant-i-save-as-an-excel-file-from-my-python-code indicates Office fails in that way when the path isn't valid... Mark On 4/02/2012 12:10 AM, John Lay wrote: > I am not a programmer, but this past week I have had a crash course in > python scripting am have been rather impressed with myself for having > written a fairly complicated script that among many other processes > reads a database table via SearchCursor, populates a word template via > Bookmarks, then saves the document out as a PDF. > > The only problem is that it only works on my computer. When I move the > script to another computer with the same setup, I continue to receive > a Com_error. > > The script fails at my SaveAs(out_TOC, FileFormat=wdFormatPDF) > statement. I have tried both win32com.client and comtypes.client and > receive a similar error for both. > > win32.client: > com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Word', > u'Command failed', u'C:\\Program Files\\Microsoft Office\\Office12\ > \1033\\WDMAIN11.CHM', 36966, ), None) > > comtypes.client: > COMError: (-2146824090, None, (u'Command failed', u'Microsoft Word', > u'C:\\Program Files\\Microsoft Office\\Office12\\1033\\WDMAIN11.CHM', > 36966, None)) > > It has been suggested that I try python-docx, but I have not been able > to get the module to work for me and I have been unable to find any > documentation on it. > > Can anyone help with the com errors? What do they mean? How do I > resolve them? > > Any help would be appreciated. > > John From roy at panix.com Tue Feb 7 00:07:36 2012 From: roy at panix.com (Roy Smith) Date: Tue, 07 Feb 2012 00:07:36 -0500 Subject: how to read serial stream of data [newbie] References: Message-ID: In article , Jean Dupont wrote: > I'd like to read in a stream of data which looks like this: > the device sends out a byte-string of 11 bytes roughly every second: > > B0B0B0B0B03131B0B50D8A > B0B0B0B0B03131B0B50D8A > B0B0B031B63131B0310D8A > B0B034B3323432B3310D8A > B0B03237B53432B3310D8A > . > . > . > > As you see every string is ended by 0D8A > How can this be accomplished in Python? The basic idea would be to open your datastream in binary mode (http://docs.python.org/library/functions.html#open), then use read(11) to read exactly 11 bytes into a string. Depending on what the 11 bytes are, you might want to use the struct module (http://docs.python.org/library/struct.html) to extract the data in a more useful form. From tjreedy at udel.edu Tue Feb 7 02:03:41 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 07 Feb 2012 02:03:41 -0500 Subject: building a dictionary dynamically In-Reply-To: <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> References: <4ea33a86-a329-45e1-a765-0cdacd8de57f@m24g2000yqb.googlegroups.com> <6cbbbca9-49a6-4c8d-a00c-7ccfd24966d3@t30g2000vbx.googlegroups.com> <8c689454-157e-4b80-a1a0-41ae317ad207@i18g2000yqf.googlegroups.com> Message-ID: On 2/6/2012 11:10 AM, noydb wrote: > Adding to dictionaries just isn't obvious... if it's not dict.Add or > dict.Appaned or the like, not obvious to inexperienced me! Have you read section 4.8-mapping types, of the library manual? Or help(dict) at the interactive prompt? -- Terry Jan Reedy From mcepl at redhat.com Tue Feb 7 03:21:05 2012 From: mcepl at redhat.com (Matej Cepl) Date: Tue, 07 Feb 2012 09:21:05 +0100 Subject: Python and TAP In-Reply-To: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> References: <0d9571fc-961a-44c0-8596-5c75ab56e146@x6g2000pbk.googlegroups.com> Message-ID: On 7.2.2012 04:24, alex23 wrote: > Experience? > > Are you seriously advocating something for which you've done nothing > more than watch a podcast? No, I am not. If you reread my original post, you may find that I was asking exactly for experience and explanation why something which seems to me obvious is not done. I guess there must be some hook somewhere, right? Which is what I was asking for. One hook I've got (YAMLish is really ... well, let's keep this group G rated), others may yet to follow. Mat?j From silentquote at gmail.com Tue Feb 7 04:33:21 2012 From: silentquote at gmail.com (silentnights) Date: Tue, 7 Feb 2012 01:33:21 -0800 (PST) Subject: python file synchronization Message-ID: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> Hi All, I have the following problem, I have an appliance (A) which generates records and write them into file (X), the appliance is accessible throw ftp from a server (B). I have another central server (C) that runs a Django App, that I need to get continuously the records from file (A). The problems are as follows: 1. (A) is heavily writing to the file, so copying the file will result of uncompleted line at the end. 2. I have many (A)s and (B)s that I need to get the data from. 3. I can't afford losing any records from file (X) My current implementation is as follows: 1. Server (B) copy the file (X) throw FTP. 2. Server (B) make a copy of file (X) to file (Y.time_stamp) ignoring the last line to avoid incomplete lines. 3. Server (B) periodically make copies of file (X) and copy the lines starting from previous ignored line to file (Y.time_stamp) 4. Server (C) mounts the diffs_dir locally. 5. Server (C) create file (Y.time_stamp.lock) on target_dir then copy file (Y.time_stamp) to local target_dir then delete (Y.time_stamp.lock) 6. A deamon running in Server (C) read file list from the target_dir, and process those file that doesn't have a matching *.lock file, this procedure to avoid reading the file until It's completely copied. The above is implemented and working, the problem is that It required so many syncs and has a high overhead and It's hard to debug. I greatly appreciate your thoughts and suggestions. Lastly I want to note that am not a programming guru, still a noob, but I am trying to learn from the experts. :-) From storchaka at gmail.com Tue Feb 7 05:05:35 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 07 Feb 2012 12:05:35 +0200 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> <4F302088.8010901@gmail.com> Message-ID: 07.02.12 00:06, Matej Cepl ???????(??): > return seq[int(random.random() * len(seq))] > > doesn't seem like something so terrible (and maintenance intense). :) _choice('abc') returns 'a' with probability P('a') = 1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with probability P('b') = 3002399751580331/9007199254740992 = 1/3 + 1/27021597764222976. P('b') - P('a') = 1/9007199254740992. This may be acceptable for your application, but for applications that are concerned not only about the repeatability of results, but the accuracy and consistency with the results obtained by other (not Python) applications, it is better to get rid of such a notorious bias. From jeanmichel at sequans.com Tue Feb 7 05:48:04 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Tue, 07 Feb 2012 11:48:04 +0100 Subject: PythonWin debugger holds onto global logging objects too long In-Reply-To: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> References: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> Message-ID: <4F310164.3070606@sequans.com> Vinay Sajip wrote: > On Jan 24, 2:52 pm, Rob Richardson wrote: > >> I use PythonWin to debug the Python scripts we write. Our scripts often use the log2pyloggingpackage. When running the scripts inside the debugger, we seem to get oneloggingobject for every time we run the script. The result is that after running the script five times, the log file contains five copies of every message. The only way I know to clean this up and get only a single copy of each message is to close PythonWin and restart it. >> >> What do I have to do in my scripts to clean up theloggingobjects so that I never get more than one copy of each message in my log files? >> >> > > I don't know what log2py is - Google didn't show up anything that > looked relevant. If you're talking about the logging package in the > Python standard library, I may be able to help: but a simple script > that I ran in PythonWin didn't show any problems, so you'll probably > need to post a short script which demonstrates the problem when run in > PythonWin. > > Regards, > > Vinay Sajip > Same here, can't find anything about log2py. Anyway it's possible that your pythonwin does not spawn a clean python interpreter for every run, keeping the same one. So you could possibly keep adding log handlers to your loggers because they may be static objects (like for the standard logging module). One solution would be to empty your logger handler list before adding any. I'm just guessing though, difficult to know without any info on log2py. JM From fw at deneb.enyo.de Tue Feb 7 07:11:12 2012 From: fw at deneb.enyo.de (Florian Weimer) Date: Tue, 07 Feb 2012 13:11:12 +0100 Subject: Static HTML documentation from docstrings Message-ID: <87zkcu4zdr.fsf@mid.deneb.enyo.de> I'm slightly confused about docstrings and HTML documentation. I used to think that the library reference was (in part) generated from the source code, but this does not seem to be the case. Is there any tool support for keeping documentation and code in sync? From jeandupont115 at gmail.com Tue Feb 7 07:13:39 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 04:13:39 -0800 (PST) Subject: how to read serial stream of data [newbie] References: Message-ID: On 7 feb, 06:07, Roy Smith wrote: > In article > , > ?Jean Dupont wrote: > > > I'd like to read in a stream of data which looks like this: > > the device sends out a byte-string of 11 bytes roughly every second: > > > ? ? B0B0B0B0B03131B0B50D8A > > ? ? B0B0B0B0B03131B0B50D8A > > ? ? B0B0B031B63131B0310D8A > > ? ? B0B034B3323432B3310D8A > > ? ? B0B03237B53432B3310D8A > > . > > . > > . > > > As you see every string is ended by 0D8A > > How can this be accomplished in Python? > > The basic idea would be to open your datastream in binary mode > (http://docs.python.org/library/functions.html#open), then use read(11) > to read exactly 11 bytes into a string. > > Depending on what the 11 bytes are, you might want to use the struct > module (http://docs.python.org/library/struct.html) to extract the data > in a more useful form. Thank you very much for taking the time to reply. I'm really completely new to python and all help is really very welcome. In the documentation I read that to open the datastream binary I need to add the option b this is how far I got until now: #!/usr/bin/python import serial, time, os voltport='/dev/ttyUSB2' print "Enter a filename:", filename = raw_input() voltdata = open(filename,'wb') ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) ser2.setDTR(level=True) print "State of DSR-line: ", ser2.getDSR() #the following line was added because I want to be sure that all parameters are set the same as under a working application for the same device os.system("stty -F31:0:bbb: 0:0:0:0:0:0:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0") print "Opening " + ser2.portstr s =ser2.read(11) #read up to 11bytes voltdata.write(s) ser2.close() voltdata.close() However the above code doesn't fill my file with data, I guess the data should also be flushed somewhere in the code but I'm unsure where to do that. A futher consideration: because the device sends its data continuously I guess I'd have to use the byte sequence 0D8A of the previously sent data string as an indicator that the next 9 bytes are those I really want and put those in a string which than coudl be written to the file all help welcome Jean From samdansobe at yahoo.com Tue Feb 7 07:27:25 2012 From: samdansobe at yahoo.com (Sammy Danso) Date: Tue, 7 Feb 2012 04:27:25 -0800 (PST) Subject: iterating over list with one mising value Message-ID: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Hello experts, I am having trouble accessing the content of my list. my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] ? I am unable to iterate through list to access invidual value pairs ? I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? ? Your help would be much appreciated. ? Thanks Sammy ___________________________________ http://www.comp.leeds.ac.uk/scsod/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Tue Feb 7 07:33:32 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 7 Feb 2012 04:33:32 -0800 Subject: Static HTML documentation from docstrings In-Reply-To: <87zkcu4zdr.fsf@mid.deneb.enyo.de> References: <87zkcu4zdr.fsf@mid.deneb.enyo.de> Message-ID: On Tue, Feb 7, 2012 at 4:11 AM, Florian Weimer wrote: > I'm slightly confused about docstrings and HTML documentation. ?I used > to think that the library reference was (in part) generated from the > source code, but this does not seem to be the case. > > Is there any tool support for keeping documentation and code in sync? Yes. Sphinx's "autodoc" extension allows the placement of API documentation directly in docstrings and comments: http://sphinx.pocoo.org/ext/autodoc.html Cheers, Chris From antti.ylikoski at tkk.fi Tue Feb 7 08:48:07 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Tue, 07 Feb 2012 15:48:07 +0200 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: On 7.2.2012 14:13, Jean Dupont wrote: > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > rtscts=0, dsrdtr=0, timeout=15) In Python, if you want to continue the source line into the next text line, you must end the line to be continued with a backslash '\'. So you should write: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ rtscts=0, dsrdtr=0, timeout=15) and analogously. Hope that this will help. Andy. From __peter__ at web.de Tue Feb 7 09:02:33 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 15:02:33 +0100 Subject: how to read serial stream of data [newbie] References: Message-ID: Antti J Ylikoski wrote: > On 7.2.2012 14:13, Jean Dupont wrote: >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >> rtscts=0, dsrdtr=0, timeout=15) > > In Python, if you want to continue the source line into the next text > line, you must end the line to be continued with a backslash '\'. > > So you should write: > > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ > rtscts=0, dsrdtr=0, timeout=15) > > and analogously. > > Hope that this will help. Andy. This is wrong. A line with an open parenthesis is continued automatically: >>> zip("abc", ... "def") [('a', 'd'), ('b', 'e'), ('c', 'f')] >>> ("abc" ... "def") 'abcdef' >>> 1 + 2 + ( ... 3) 6 From modelnine at modelnine.org Tue Feb 7 09:04:39 2012 From: modelnine at modelnine.org (Heiko Wundram) Date: Tue, 07 Feb 2012 15:04:39 +0100 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: <4F312F77.2000203@modelnine.org> Am 07.02.2012 14:48, schrieb Antti J Ylikoski: > On 7.2.2012 14:13, Jean Dupont wrote: >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >> rtscts=0, dsrdtr=0, timeout=15) > > In Python, if you want to continue the source line into the next text > line, you must end the line to be continued with a backslash '\'. Absolutely not true, and this is bad advice (stylistically). When (any form of) brackets are open at the end of a line, Python does not start a new command on the next line but rather continues the backeted content. So: ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, rtscts=0, dsrdtr=0, timeout=15) is perfectly fine and certainly the recommended way of putting this. Adding the backslash-continuation is always _possible_, but only _required_ when there are no open brackets. So: x = "hello" \ " test" is equivalent to: x = ("hello" " test") in assigning: x = "hello test" -- --- Heiko. From d at davea.name Tue Feb 7 09:46:12 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 09:46:12 -0500 Subject: iterating over list with one mising value In-Reply-To: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4F313934.9000502@davea.name> On 02/07/2012 07:27 AM, Sammy Danso wrote: > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example ['a', 1, 'b', 1, 'c', 3, 'd'] > > I am unable to iterate through list to access invidual value pairs > > I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? > > Your help would be much appreciated. > > Thanks > Sammy The real answer is to figure out how it gets into that state. Is the input file invalid? Or you have a device that sometimes skips one? But if you're stuck with the data in that list: If the list is of odd size, truncate it. Then your loop should not run into an uneven pair. Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions. -- DaveA From jeandupont115 at gmail.com Tue Feb 7 09:46:28 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 06:46:28 -0800 (PST) Subject: how to read serial stream of data [newbie] References: Message-ID: <97e03762-e7b7-4202-a0b8-51ff579c5066@l14g2000vbe.googlegroups.com> On 7 feb, 15:04, Heiko Wundram wrote: > Am 07.02.2012 14:48, schrieb Antti J Ylikoski: > > > On 7.2.2012 14:13, Jean Dupont wrote: > >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > >> rtscts=0, dsrdtr=0, timeout=15) > > > In Python, if you want to continue the source line into the next text > > line, you must end the line to be continued with a backslash '\'. > > Absolutely not true, and this is bad advice (stylistically). > > When (any form of) brackets are open at the end of a line, Python does > not start a new command on the next line but rather continues the > backeted content. > > So: > > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, > ? ? ? ? ? ? ? ? ? ? ? rtscts=0, dsrdtr=0, timeout=15) > > is perfectly fine and certainly the recommended way of putting this. > > Adding the backslash-continuation is always _possible_, but only > _required_ when there are no open brackets. > > So: > > x = "hello" \ > ? ? ?" test" > > is equivalent to: > > x = ("hello" > ? ? ? " test") > > in assigning: > > x = "hello test" > > -- > --- Heiko. Hello to all who gave advice concerning the line continuation, in fact this was not a real problem but happened by accident copying and pasting my program lines. Advice concerning the empty file would of course also be very much appreciated. thanks, Jean From waqif at smartbaba.com Tue Feb 7 10:00:43 2012 From: waqif at smartbaba.com (Smart Baba) Date: Tue, 7 Feb 2012 07:00:43 -0800 (PST) Subject: smart baba new year special offer Message-ID: <4091ec8b-7253-43c0-a32f-adff9ad5544c@q8g2000pbb.googlegroups.com> Smart Baba special limited offer. We are the only world lowest-cost, yet professional and elegant-designing website developing company. Follow us for further details: www.websitedeals.com From ulrich.eckhardt at dominolaser.com Tue Feb 7 10:11:04 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 07 Feb 2012 16:11:04 +0100 Subject: difference between random module in python 2.6 and 3.2? In-Reply-To: References: <4f2f5081$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f6b87$0$29992$c3e8da3$5496439d@news.astraweb.com> <4f2f89d7$0$29992$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9hr709-i9c.ln1@satorlaser.homedns.org> Am 06.02.2012 09:45, schrieb Matej Cepl: > Also, how could I write a re-implementation of random.choice which would > work same on python 2.6 and python 3.2? It is not only matter of unit > tests, but I would really welcome if the results on both versions > produce the same results. Two approaches come to mind: 1. make two runs and verify that they differ This is a bit problematic, because there is a small but nonzero chance that two runs don't differ. Random numbers are just not random enough. Anyhow, afterwards, sort the results again and verify that it was just the order that differs. 2. hack the random module into something nonrandom I think you can "import debug_random as random" and then have your testee automatically pick up that module instead of the real one. Since you already hardcoded the results to check against ("expected = ..." in your code), you can also hard-code the sequence of random numbers corresponding to that. This is even cleaner, as you don't rely on something being deterministic that is supposed to be random, which is not totally surprising but still somehow paradox. Uli From rantingrickjohnson at gmail.com Tue Feb 7 10:34:14 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 7 Feb 2012 07:34:14 -0800 (PST) Subject: iterating over list with one mising value References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: On Feb 7, 8:46?am, Dave Angel wrote: > On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, > > I am having trouble accessing the content of my list. > > my list content has 2-pair value with the exception of one which has single value. here is an example ?['a', 1, 'b', 1, 'c', 3, 'd'] First you need to explain why you're using a flat list when a number of other structures would be the better choice; like a list of tuples or a dict. From ian.g.kelly at gmail.com Tue Feb 7 11:03:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 7 Feb 2012 09:03:52 -0700 Subject: iterating over list with one mising value In-Reply-To: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso wrote: > > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] > > I am unable to iterate through list to access invidual value pairs > > I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? What are you using to iterate through pairs instead of individual elements? It sounds like it is not very flexible. I would recommend instead using the "grouper" recipe from the itertools documentation: http://docs.python.org/library/itertools.html#recipes Cheers, Ian From python.list at tim.thechases.com Tue Feb 7 11:34:32 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 07 Feb 2012 10:34:32 -0600 Subject: iterating over list with one mising value In-Reply-To: References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4F315298.9030204@tim.thechases.com> On 02/07/12 09:34, Rick Johnson wrote: > On Feb 7, 8:46 am, Dave Angel wrote: >> On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, >>> I am having trouble accessing the content of my list. my >>> list content has 2-pair value with the exception of one >>> which has single value. here is an example ['a', 1, 'b', >>> 1, 'c', 3, 'd'] > > First you need to explain why you're using a flat list when a > number of other structures would be the better choice; like a > list of tuples or a dict. I'm not sure there's really a need for the OP to explain why...perhaps the data comes from an untrusted (or incompetent) source and the routine the OP is asking about is to *create* such a list-of-tuples or a dict. The more important question is what the user/app wants to do when such a case is encountered: do they want to ignore the unpaired value, or do they want to pad it with a default value? -tkc From antti.ylikoski at tkk.fi Tue Feb 7 12:44:59 2012 From: antti.ylikoski at tkk.fi (Antti J Ylikoski) Date: Tue, 07 Feb 2012 19:44:59 +0200 Subject: how to read serial stream of data [newbie] In-Reply-To: References: Message-ID: On 7.2.2012 16:02, Peter Otten wrote: > Antti J Ylikoski wrote: > >> On 7.2.2012 14:13, Jean Dupont wrote: >>> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, >>> rtscts=0, dsrdtr=0, timeout=15) >> >> In Python, if you want to continue the source line into the next text >> line, you must end the line to be continued with a backslash '\'. >> >> So you should write: >> >> ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1, \ >> rtscts=0, dsrdtr=0, timeout=15) >> >> and analogously. >> >> Hope that this will help. Andy. > > This is wrong. A line with an open parenthesis is continued automatically: > >>>> zip("abc", > ... "def") > [('a', 'd'), ('b', 'e'), ('c', 'f')] >>>> ("abc" > ... "def") > 'abcdef' >>>> 1 + 2 + ( > ... 3) > 6 > > Thank you for correcting me. Andy. From SMac2347 at comcast.net Tue Feb 7 13:14:28 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 10:14:28 -0800 (PST) Subject: Reading files in from the proper directory Message-ID: Hello. I am admittedly a Python novice, and ran into some trouble trying to write a program that will pull multiple excel files all into one file, with each file on a different sheet. I am confident most of the code is correct, as the program runs without any errors and I found the base of it online, making changes as necessary for my own purposes. However, I am having trouble specifying the exact directory where my code should be pulling the files from. All the files are in the same folder, and I have put the folder on my desktop. Am I correct in thinking that I need to change the current working directory to this folder in order for Python to read in these files, then generate my output? Or should I be doing something else? Any and all help is appreciated, thanks! From d at davea.name Tue Feb 7 13:40:10 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 13:40:10 -0500 Subject: Reading files in from the proper directory In-Reply-To: References: Message-ID: <4F31700A.8050905@davea.name> On 02/07/2012 01:14 PM, SMac2347 at comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without any errors and I found the base of it online, making changes > as necessary for my own purposes. However, I am having trouble > specifying the exact directory where my code should be pulling the > files from. All the files are in the same folder, and I have put the > folder on my desktop. Am I correct in thinking that I need to change > the current working directory to this folder in order for Python to > read in these files, No, Python certainly does not constrain you to working with files only in the current working directory. My rule of thumb is never to change the cwd in a Python program. You can use relative paths to open files, or you can use absolute paths. There is even a library function os.path.abspath() for converting a relative path to an absolute one. If you do change cwd during the running of a program, then relative filenames that worked earlier might no longer work. You could convert them all to absolute paths, but that's more work. You can piece together path strings using os.path.join(). It's smart enough to know the path separator for your particular platform. Check out this page: http://docs.python.org/library/os.path.html > then generate my output? Or should I be doing > something else? > > Any and all help is appreciated, thanks! > -- DaveA From tyler at tysdomain.com Tue Feb 7 13:41:57 2012 From: tyler at tysdomain.com (Littlefield, Tyler) Date: Tue, 07 Feb 2012 11:41:57 -0700 Subject: keeping twisted and wxPython in sync Message-ID: <4F317075.40209@tysdomain.com> Hello all: I have a couple questions. First, is there a way to know if connectTCP failed? I am writing a client with Twisted and would like to be able to notify the user if they couldn't connect. Second, I set the protocol on my factory after a connection has been made. So when I send my user and password, that is when I connect. Is there a way to handle waiting for the connection to complete? -- Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud Sent from my toaster. From __peter__ at web.de Tue Feb 7 13:59:05 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 19:59:05 +0100 Subject: Reading files in from the proper directory References: Message-ID: SMac2347 at comcast.net wrote: > Hello. I am admittedly a Python novice, and ran into some trouble > trying to write a program that will pull multiple excel files all into > one file, with each file on a different sheet. > > I am confident most of the code is correct, as the program runs > without any errors and I found the base of it online, making changes > as necessary for my own purposes. That confidence usually evaporates once you write the first unit test ;) > However, I am having trouble > specifying the exact directory where my code should be pulling the > files from. All the files are in the same folder, and I have put the > folder on my desktop. Am I correct in thinking that I need to change > the current working directory to this folder in order for Python to > read in these files, then generate my output? Or should I be doing > something else? Do it properly, allow specifying the files on the commandline: import argparse def process_files(files, destfile): # put your real code here print "merge " + "\n ".join(files) print "into " + destfile if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("files", metavar="file", nargs="+") parser.add_argument("destfile") args = parser.parse_args() process_files(args.files, args.destfile) If you have standard locations for sources and destination you can wrap your python script into a little batch file containing something like python \source\path\*.xls \dest\path\merged.xls and invoke that to get both flexibility and convenience. From SMac2347 at comcast.net Tue Feb 7 14:03:11 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 11:03:11 -0800 (PST) Subject: Reading files in from the proper directory References: Message-ID: <6fc4ebfa-6607-4af7-83d7-65c61408a6ac@m24g2000yqb.googlegroups.com> On Feb 7, 1:40?pm, Dave Angel wrote: > On 02/07/2012 01:14 PM, SMac2... at comcast.net wrote:> Hello. I am admittedly a Python novice, and ran into some trouble > > trying to write a program that will pull multiple excel files all into > > one file, with each file on a different sheet. > > > I am confident most of the code is correct, as the program runs > > without any errors and I found the base of it online, making changes > > as necessary for my own purposes. However, I am having trouble > > specifying the exact directory where my code should be pulling the > > files from. All the files are in the same folder, and I have put the > > folder on my desktop. Am I correct in thinking that I need to change > > the current working directory to this folder in order for Python to > > read in these files, > > No, Python certainly does not constrain you to working with files only > in the current working directory. ?My rule of thumb is never to change > the cwd in a Python program. ?You can use relative paths to open files, > or you can use absolute paths. ?There is even a library function > os.path.abspath() for converting a relative path to an absolute one. > > If you do change cwd during the running of a program, then relative > filenames that worked earlier might no longer work. ?You could convert > them all to absolute paths, but that's more work. > > You can piece together path strings using os.path.join(). ?It's smart > enough to know the path separator for your particular platform. > > Check out this page:http://docs.python.org/library/os.path.html > > > then generate my output? Or should I be doing > > something else? > > > Any and all help is appreciated, thanks! > > -- > > DaveA Thanks Dave. I am a bit lost as to what the problem is then - the program runs glitch free, but then only prints: "NOTE *** No xls files in C:/Documents and Settings/smacdon/." as specified below by my program. Any idea what the issue might be (my code is below): import xlrd, xlwt import glob, os.path def merge_xls (in_dir, out_file="C:\Documents and Settings\smacdon \Desktop\09 Aggregate JWS\09_merged_data.xls"): xls_files = glob.glob(in_dir + "*.xls") sheet_names = [os.path.basename(v)[:-4] for v in xls_files] sheet_excl = [os.path.basename(v)[:-4] for v in xls_files if len (os.path.basename(v)[:-4]) > 29] merged_book = xlwt.Workbook() if in_dir[-1:] != "/": in_dir = in_dir + "/" xls_files.sort() if xls_files: for k, xls_file in enumerate(xls_files): print "---> Processing file %s" % (xls_file) if len (sheet_names[k]) <= 29: book = xlrd.open_workbook(xls_file) if book.nsheets == 1: ws = merged_book.add_sheet(sheet_names[k]) sheet = book.sheet_by_index(0) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) elif book.nsheets in range(2, 100): for sheetx in range(book.nsheets): sheet0n = sheet_names[k]+str(sheetx +1).zfill(2) ws = merged_book.add_sheet(sheet0n) sheet = book.sheet_by_index(sheetx) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) else: print "ERROR *** File %s has %s sheets (maximum is 99)" % (xls_file, book.nsheets) raise else: print "WARNING *** File name too long: <%s.xls> (maximum is 29 chars) " % (sheet_names[k]) print "WARNING *** File <%s.xls> was skipped." % (sheet_names[k]) merged_book.save(out_file) print print "---> Merged xls file written to %s using the following source files: " % (out_file) for k, v in enumerate(sheet_names): if len(v) <= 29: print "\t", str(k+1).zfill(3), "%s.xls" % (v) print if sheet_excl: print "--> The following files were skipped because the file name exceeds 29 characters: " for k, v in enumerate(sheet_excl): print "\t", str(k+1).zfill(3), v else: print "NOTE *** No xls files in %s." % (in_dir) merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" From SMac2347 at comcast.net Tue Feb 7 14:13:26 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Tue, 7 Feb 2012 11:13:26 -0800 (PST) Subject: Reading files in from the proper directory References: Message-ID: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Thanks for the responses. Below is the code I have thus far. while the program runs glitch-free, it only results in the printing of the message: "NOTE *** No xls files in C:/Documents and Settings/smacdon/." as specified by my code. Any idea as to why it might be unable to find the .xls documents (yes they are .xls documents and not .xlsx). Thanks! import xlrd, xlwt import glob, os.path def merge_xls (in_dir, out_file="C:\Documents and Settings\smacdon \Desktop\09 Aggregate JWS\09_merged_data.xls"): xls_files = glob.glob(in_dir + "*.xls") sheet_names = [os.path.basename(v)[:-4] for v in xls_files] sheet_excl = [os.path.basename(v)[:-4] for v in xls_files if len (os.path.basename(v)[:-4]) > 29] merged_book = xlwt.Workbook() if in_dir[-1:] != "/": in_dir = in_dir + "/" xls_files.sort() if xls_files: for k, xls_file in enumerate(xls_files): print "---> Processing file %s" % (xls_file) if len (sheet_names[k]) <= 29: book = xlrd.open_workbook(xls_file) if book.nsheets == 1: ws = merged_book.add_sheet(sheet_names[k]) sheet = book.sheet_by_index(0) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) elif book.nsheets in range(2, 100): for sheetx in range(book.nsheets): sheet0n = sheet_names[k]+str(sheetx +1).zfill(2) ws = merged_book.add_sheet(sheet0n) sheet = book.sheet_by_index(sheetx) for rx in range(sheet.nrows): for cx in range(sheet.ncols): ws.write(rx, cx, sheet.cell_value(rx, cx)) else: print "ERROR *** File %s has %s sheets (maximum is 99)" % (xls_file, book.nsheets) raise else: print "WARNING *** File name too long: <%s.xls> (maximum is 29 chars) " % (sheet_names[k]) print "WARNING *** File <%s.xls> was skipped." % (sheet_names[k]) merged_book.save(out_file) print print "---> Merged xls file written to %s using the following source files: " % (out_file) for k, v in enumerate(sheet_names): if len(v) <= 29: print "\t", str(k+1).zfill(3), "%s.xls" % (v) print if sheet_excl: print "--> The following files were skipped because the file name exceeds 29 characters: " for k, v in enumerate(sheet_excl): print "\t", str(k+1).zfill(3), v else: print "NOTE *** No xls files in %s." % (in_dir) merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" From jeandupont115 at gmail.com Tue Feb 7 14:44:40 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Tue, 7 Feb 2012 11:44:40 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: Message-ID: On 7 feb, 05:21, Terry Reedy wrote: > On 2/2/2012 3:57 PM, Jean Dupont wrote: > > > I'd like to read in the output of a voltcraft vc960 voltmeter > > connected to a usb-port. > > I found the perl-script below but I'd like to accomplish the same with > > python: > > The script below is for an old-fashioned, slow, multiple-pin serial > port, not usb. I don't know anything about interfacing through usb. > Recheck what the voltmeter actually connects to. The voltmeter uses an optical rs232-connection, that is "good enough technology" for this purpose. But as I don't have a computer with real rs232 ports I use a rs232toUSB adapter which presents itself to the linux-computer as /dev/ttyUSBx. > > > I guess I have to use the module serial but I don't know how I should > > set the serial parameters so they are the same as in the perl-script. > > Could someone supply me the command for setting the serial-parameters > > correctly in Python? > > Last I know, pyserial is also for old serial ports. Setting the > properties should be pretty obvious from the manual or code. > It is not so obvious as you might think, one reason being the handshake line(s?) are used in an unconvential way to supply power to the rs232-optical interface > There are also python usb modules.http://sourceforge.net/projects/mysql-python/?source=directory I followed this link but all I found was something concerning mysql...??? > anyway, thanks for trying to help Jean > > > > > > > > #!/usr/bin/perl > > > use strict; > > use warnings; > > > use Device::SerialPort; > > > die("Usage: $0 /dev/ttyS0\n") unless $#ARGV == 0; > > > my ($devicepath) = @ARGV; > > > my $port = new Device::SerialPort($devicepath); > > die "Couldn't open serial port" if ! defined $port; > > > $port->baudrate(2400); > > $port->databits(8); > > $port->parity("none"); > > $port->stopbits(1); > > $port->handshake("none"); > > $port->rts_active(0); > > $port->dtr_active(1); > > > #$port->read_char_time(5); ? ? # wait 5ms per character > > $port->read_const_time(200); ? # 0.2 second per unfulfilled "read" > > call > > $| = 1; # autoflush STDOUT > > while(1) { > > ? ? ? ? ?my ($nin, $in) = $port->read(255); > > ? ? ? ? ?print $in; > > } > > > $port->close; > > -- > Terry Jan Reedy From gordon at panix.com Tue Feb 7 14:46:42 2012 From: gordon at panix.com (John Gordon) Date: Tue, 7 Feb 2012 19:46:42 +0000 (UTC) Subject: Reading files in from the proper directory References: Message-ID: In SMac2347 at comcast.net writes: > Am I correct in thinking that I need to change the current working > directory to this folder in order for Python to read in these files, > then generate my output? You don't have to do it that way, no. In general, when opening a file, you can do it two ways: Either provide a full pathname, or provide a relative pathname. If you provide a full pathname (for example "/usr/home/smith/myfile.txt"), that file will be opened and it does not matter what the current working directory is. If you provide a relative pathname (for example "myfile.txt"), python will attempt to open that file starting from the current working dir. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From rantingrickjohnson at gmail.com Tue Feb 7 14:47:31 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 7 Feb 2012 11:47:31 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: <46cb8864-dd45-482a-b0b0-ccf20ce3638b@f14g2000yqe.googlegroups.com> On Feb 7, 11:44?am, Dennis Lee Bieber wrote: > > [...] > > ? ? ? ? Well, since readline() pretty much by definition wants a line-ending > character before returning, it obviously won't work. (Side comment: > readline() isn't even shown as part of the basic Serial class -- it is > in a class FileLike:http://pyserial.sourceforge.net/pyserial_api.html > -- oh wait.. fine print says that is a base class for Serial on non-io > module systems). > > ? ? ? ? What is the boundary marker for your 11-byte chunks? You may need to > do a synchronization loop using > > [...] > > ? ? ? ? Your timeout is FIFTEEN SECONDS! > > ? ? ? ? Suspect you want something like Why do you have this unnatural penchant for superfluous eight space indention? I always thought that indenting the first sentence of a paragraph was quite ridiculous anyhow, however, i cannot even fathom any need to indent a single sentence! Are you purposely injecting this noise or is this some automated behavior of your broken mail client? Either way, i find it annoying and unreadable. Could you please rectify this issue and bring signal to noise ratio back to reasonable levels? From gordon at panix.com Tue Feb 7 15:00:34 2012 From: gordon at panix.com (John Gordon) Date: Tue, 7 Feb 2012 20:00:34 +0000 (UTC) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: In <9bfb3e39-2bc6-4399-90cc-1c53aa06265e at h6g2000yqk.googlegroups.com> SMac2347 at comcast.net writes: > xls_files = glob.glob(in_dir + "*.xls") You may want to put a directory separator character in between the directory name and the filename glob pattern. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From __peter__ at web.de Tue Feb 7 15:16:57 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 07 Feb 2012 21:16:57 +0100 Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: SMac2347 at comcast.net wrote: > xls_files = glob.glob(in_dir + "*.xls") Try changing that to pattern = os.path.join(in_dir, "*.xls") xls_files = glob.glob(pattern) os.path.join() inserts a (back)slash between directory and filename if necessary. > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") If you paste the directory name literal into the interactive interpreter you'll be surprised: >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' "\09" is intrpreted as chr(9). Use a raw string to prevent Python from interpreting a backslash as the start of an escape sequence >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' or use forward slashes as directory separators. From samdansobe at yahoo.com Tue Feb 7 15:23:09 2012 From: samdansobe at yahoo.com (Sammy Danso) Date: Tue, 7 Feb 2012 12:23:09 -0800 (PST) Subject: iterating over list with one mising value Message-ID: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Hi Expert, Thanks for your responses and help. thought I should provide more information for clarity. ? Please find the error message below for more information ? ???for (key, value) in wordFreq2: ValueError: need more than 1 value to unpack ? this is a sample of my data ? ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] ? What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully ? my desired ouput is the format?below in a text file. with 3 which 3 were 2 .. . . other ? Thanks again. Sammy --- On Tue, 2/7/12, Dave Angel wrote: From: Dave Angel Subject: Re: iterating over list with one mising value To: "Sammy Danso" Cc: python-list at python.org Date: Tuesday, February 7, 2012, 2:46 PM On 02/07/2012 07:27 AM, Sammy Danso wrote: > Hello experts, > I am having trouble accessing the content of my list. > my list content has 2-pair value with the exception of one which has single value. here is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] >???I am unable to iterate through list to access invidual value pairs >???I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem? >???Your help would be much appreciated. >???Thanks > Sammy The real answer is to figure out how it gets into that state.? Is the input file invalid?? Or you have a device that sometimes skips one? But if you're stuck with the data in that list: If the list is of odd size, truncate it.? Then your loop should not run into an uneven pair. Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions. -- DaveA -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Feb 7 15:58:25 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 15:58:25 -0500 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319071.1080402@davea.name> On 02/07/2012 03:23 PM, Sammy Danso wrote: > Please don't top-post. It hopelessly mixes responses out of order. > > Hi Expert, > Thanks for your responses and help. thought I should provide more information for clarity. > > Please find the error message below for more information > > for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack That's not the complete error message; it's missing the call stack. And also missing the line that's getting the ValueError. > > this is a sample of my data > > ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', > 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully OK, good. If you know your error is always at the end, and you know the data to be padded, then just do it: if len(mylist) % 2 > 0: mylist.append(0) > > my desired ouput is the format below in a text file. > with 3 > which 3 > were 2 > .. > . > . > other > > > Thanks again. > Sammy My guess is that you have an entirely different problem, unrelated to the missing value at the end. But you don't show us enough code to help you. How many items of the list are processed before the exception happens? -- DaveA From python at mrabarnett.plus.com Tue Feb 7 16:13:42 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 07 Feb 2012 21:13:42 +0000 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319406.8060206@mrabarnett.plus.com> On 07/02/2012 20:23, Sammy Danso wrote: > Hi Expert, > Thanks for your responses and help. thought I should provide more > information for clarity. > > Please find the error message below for more information > > for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack > > this is a sample of my data > > ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, > 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, > 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, > 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, > 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, > 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, > 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, > 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', > 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, > 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, > 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, > 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, > 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', > 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, > 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', > 1, '600am', 1, '100pm', 1, '', 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default > so I can iterate sucessfully > > my desired ouput is the format below in a text file. > with 3 > which 3 > were 2 > .. > . > . > other > The line: for (key, value) in wordFreq2: attempts to iterate through the list wordFreq2, where each item in the list is a _pair_ of values. However, what you have is a list of _single_ values, alternating string and number. That's why it's complaining that it can't unpack. From a.france.mailinglists at gmail.com Tue Feb 7 16:25:13 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 07 Feb 2012 22:25:13 +0100 Subject: iterating over list with one mising value In-Reply-To: <4F319406.8060206@mrabarnett.plus.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> Message-ID: <4F3196B9.8080109@gmail.com> On 02/07/2012 10:13 PM, MRAB wrote: > On 07/02/2012 20:23, Sammy Danso wrote: >> Hi Expert, >> Thanks for your responses and help. thought I should provide more >> information for clarity. > > >> Please find the error message below for more information >> > >> for (key, value) in wordFreq2: >> ValueError: need more than 1 value to unpack >> >> this is a sample of my data >> >> ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, >> 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, >> 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, >> 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, >> 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, >> 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, >> 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, >> 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', >> 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, >> 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, >> 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, >> 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, >> 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', >> 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, >> 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', >> 1, '600am', 1, '100pm', 1, '', 3, 'other'] >> >> What I would like to do is to pad the last value 'other' with a default >> so I can iterate sucessfully >> >> my desired ouput is the format below in a text file. >> with 3 >> which 3 >> were 2 >> .. >> . >> . >> other >> > The line: > > for (key, value) in wordFreq2: > > attempts to iterate through the list wordFreq2, where each item in the > list is a _pair_ of values. > > However, what you have is a list of _single_ values, alternating string > and number. > > That's why it's complaining that it can't unpack. for i in range(0, len(x), 2): print x[i-1], x[i] From python.list at tim.thechases.com Tue Feb 7 16:31:49 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 07 Feb 2012 15:31:49 -0600 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: <4F319845.10301@tim.thechases.com> > Thanks for your responses and help. thought I should provide > more information for clarity. It sounds like you want the "grouper" function as defined here: http://docs.python.org/library/itertools.html#recipes which does what you describe. -tkc From rosuav at gmail.com Tue Feb 7 16:37:14 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 8 Feb 2012 08:37:14 +1100 Subject: iterating over list with one mising value In-Reply-To: <4F3196B9.8080109@gmail.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: On Wed, Feb 8, 2012 at 8:25 AM, Aaron France wrote: > for i in range(0, len(x), 2): > ? ?print x[i-1], x[i] I think you want x[i], x[i+1] here, but in any case, this is a fairly standard non-Python way to do this sort of thing. There's a variety of more Pythonic ways to loop, but every now and then, the old C habits still come in handy! ChrisA From arnodel at gmail.com Tue Feb 7 16:37:20 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 7 Feb 2012 21:37:20 +0000 Subject: iterating over list with one mising value In-Reply-To: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> Message-ID: On 7 February 2012 20:23, Sammy Danso wrote: > > Hi Expert, > Thanks for your responses and help. thought I should provide more information for clarity. Please don't top-post. > Please find the error message below for more information > > ???for (key, value) in wordFreq2: > ValueError: need more than 1 value to unpack > > this is a sample of my data > > ['with', 3, 'which', 1, [...] , 3, 'other'] > > What I would like to do is to pad the last value 'other' with a default so I can iterate sucessfully * It would be better if you provided the code that produces the error, rather than just the error. This would allow others to diagnose your problem without having to guess what you're really doing (see my guess below) * Also, don't truncate the traceback. My guess: you're running a loop like this, where each item is unpacked: for (key, value) in wordFreq2: print key, value on data like that: wordFreq2 = ['with', 3, 'which', 1, 'were', 2, 'well', 1] Your list is flat so the unpacking fails. For it to work, you need your list to be of the form: wordFreq2 = [('with', 3), ('which', 1), ('were', 2), ('well', 1)] Then it will work. The quickest way to transform your list to the required form is something like this: def pairs(seq, fillvalue): it = iter(seq) return list(izip_longest(it, it, fillvalue=fillvalue) so you can do: word_freq_pairs = pairs(wordFreq2) -- Arnaud From breamoreboy at yahoo.co.uk Tue Feb 7 17:09:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 07 Feb 2012 22:09:39 +0000 Subject: iterating over list with one mising value In-Reply-To: <4F3196B9.8080109@gmail.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: On 07/02/2012 21:25, Aaron France wrote: > for i in range(0, len(x), 2): > print x[i-1], x[i] x = ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', 1, '600am', 1, '100pm', 1, '', 3, 'other'] for i in range(0, len(x), 2): print x[i-1], x[i] other with 3 which ... 1 3 other Houston, we've got a problem:) -- Cheers. Mark Lawrence. From a.france.mailinglists at gmail.com Tue Feb 7 17:30:30 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 07 Feb 2012 23:30:30 +0100 Subject: iterating over list with one mising value In-Reply-To: References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Message-ID: <4F31A606.6040609@gmail.com> On 02/07/2012 11:09 PM, Mark Lawrence wrote: > On 07/02/2012 21:25, Aaron France wrote: >> for i in range(0, len(x), 2): >> print x[i-1], x[i] > x = ['with', 3, 'which', 1, 'were', 2, 'well', 1, 'water', 1, 'was', 4, > 'two', 1, 'to', 2, 'through', 1, 'thlabour', 1, 'these', 1, 'theat', 1, > 'the', 8, 'tetanus', 1, 'started', 1, 'size', 1, 'scent', 1, > 'respectively', 1, 'received', 1, 'problems', 2, 'prince', 1, > 'pregnancy', 1, 'poured', 1, 'peace', 1, 'pains', 1, 'painless', 1, > 'out', 1, 'of', 1, 'noseat', 1, 'nose', 2, 'no', 2, 'maternity', 1, > 'malformation', 1, 'made', 1, 'lower', 1, 'labour/delivery', 2, > 'kintampo', 1, 'into', 1, 'injections', 1, 'in', 3, 'i', 2, 'hospital', > 1, 'home', 1, 'him', 1, 'having', 1, 'had', 2, 'green', 1, 'gave', 1, > 'flowing', 2, 'encountered', 1, 'eleven', 1, 'during', 3, 'district', 1, > 'difficulty', 1, 'cord', 1, 'consecutive', 1, 'colour', 1, 'cleared', 1, > 'child', 1, 'checkups', 1, 'came', 1, 'but', 2, 'breathing', 2, > 'breath', 1, 'blood', 2, 'bleeding', 1, 'birth', 4, 'before', 1, 'bad', > 1, 'average', 1, 'at', 2, 'assist', 1, 'artificial', 1, 'around', 2, > 'antenatal', 1, 'and', 5, 'an', 1, 'ambrical', 1, 'air', 1, 'abdominal', > 1, '600am', 1, '100pm', 1, '', 3, 'other'] > for i in range(0, len(x), 2): > print x[i-1], x[i] > > other with > 3 which > ... > 1 > 3 other > > Houston, we've got a problem:) > Yupp. The real problem is that there's been over 20 messages about this 'problem'. From arnodel at gmail.com Tue Feb 7 18:03:51 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 7 Feb 2012 23:03:51 +0000 Subject: iterating over list with one mising value In-Reply-To: <9na3j751i8q3ks75sda28edig2qclghfht@4ax.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <9na3j751i8q3ks75sda28edig2qclghfht@4ax.com> Message-ID: On 7 February 2012 22:57, Dennis Lee Bieber wrote: > On Tue, 7 Feb 2012 21:37:20 +0000, Arnaud Delobelle > wrote: > > >> >>Your list is flat so the unpacking fails. ?For it to work, you need >>your list to be of the form: >> >> ? ?wordFreq2 = [('with', 3), ('which', 1), ('were', 2), ('well', 1)] >> >>Then it will work. ?The quickest way to transform your list to the >>required form is something like this: >> > ? ? ? ?Well... From my viewpoint, the quickest way is to load the list > correctly in the first place... Where does this list come from? If it's > a file of Of course, but how much guessing can you do in a reply? The OP provided a Python list, that's what I used. -- Arnaud From skippy.hammond at gmail.com Tue Feb 7 18:04:29 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 08 Feb 2012 10:04:29 +1100 Subject: PythonWin debugger holds onto global logging objects too long In-Reply-To: <4F310164.3070606@sequans.com> References: <86ba1ef0-fe15-4404-a11e-8d762ca8b600@e27g2000vbu.googlegroups.com> <4F310164.3070606@sequans.com> Message-ID: <4F31ADFD.3050006@gmail.com> On 7/02/2012 9:48 PM, Jean-Michel Pichavant wrote: > Vinay Sajip wrote: >> On Jan 24, 2:52 pm, Rob Richardson wrote: >>> I use PythonWin to debug the Python scripts we write. Our scripts >>> often use the log2pyloggingpackage. When running the scripts inside >>> the debugger, we seem to get oneloggingobject for every time we run >>> the script. The result is that after running the script five times, >>> the log file contains five copies of every message. The only way I >>> know to clean this up and get only a single copy of each message is >>> to close PythonWin and restart it. >>> >>> What do I have to do in my scripts to clean up theloggingobjects so >>> that I never get more than one copy of each message in my log files? >>> >> >> I don't know what log2py is - Google didn't show up anything that >> looked relevant. If you're talking about the logging package in the >> Python standard library, I may be able to help: but a simple script >> that I ran in PythonWin didn't show any problems, so you'll probably >> need to post a short script which demonstrates the problem when run in >> PythonWin. >> >> Regards, >> >> Vinay Sajip > Same here, can't find anything about log2py. > Anyway it's possible that your pythonwin does not spawn a clean python > interpreter for every run, keeping the same one. That is what everyone's pythonwin does :) It always works "in process" - not ideal, but also likely to not change. Cheers, Mark > > So you could possibly keep adding log handlers to your loggers because > they may be static objects (like for the standard logging module). > One solution would be to empty your logger handler list before adding any. > > I'm just guessing though, difficult to know without any info on log2py. > > JM From peter.milliken at gmail.com Tue Feb 7 19:16:51 2012 From: peter.milliken at gmail.com (Peter) Date: Tue, 7 Feb 2012 16:16:51 -0800 (PST) Subject: pySerial question, setting certain serial parameters [newbie] References: <4142345.2853.1328359637311.JavaMail.geo-discussion-forums@yquu38> Message-ID: <22a9c96e-60a2-4c03-b80e-954c30ea6872@g4g2000pbi.googlegroups.com> On Feb 4, 11:47?pm, Jean Dupont wrote: > I need to set the following options I found in a Perl-script in Python for serial communication with a device (a voltmeter): > > $port->handshake("none"); > $port->rts_active(0); > $port->dtr_active(1); > > I have thus far the following ?statements but I think it does not set the above parameters correctly: > import serial > voltport='/dev/ttyUSB2' > ser2 = serial.Serial(voltport, 2400, 8, serial.PARITY_NONE, 1,timeout=15) > > thanks > Jean My reading of the __init__ method documentations shows you should have: ser2 = serial.Serial(voltport, 2400, dsrdtr=True, timeout=15) since the defaults for bytesize are EIGHTBITS (for which you use 8 - wrong), parity is already default to PARITY_NONE (so this isn't needed), stopbits defaults to STOPBITS_ONE (for which you use 1 - wrong) and (assuming the Perl code "1" is to enable) dsrdtr=True (xonxoff and rtscts both default to False). Try that. From news at schwertberger.de Tue Feb 7 19:26:48 2012 From: news at schwertberger.de (Dietmar Schwertberger) Date: Wed, 08 Feb 2012 01:26:48 +0100 Subject: convert perl-script for voltcraft voltmeter to python [newbie] In-Reply-To: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: Am 03.02.2012 14:11, schrieb Jean Dupont: > As my request might have been too much asked, I have started doing > some coding myself. > I'm in doubt about the readline statement -which doesn't show anything > received- as the meter sends continuously streams of 11 bytes > Is there a way to just monitor with python what is arriving at a > serial port? Some time ago I started working on reading data from a VC940. I would assume that the protocol is the same. Please find below the code that will return the raw values from a VC940 (tested on a classical RS232 port, but probably will work on USB-RS232 converters as well). If you don't get anything, then you should check whether your USB converter is supplying voltage on the DTR pin once you have called self.serial.setDTR(1). You have the description how to decode the values? E.g. the string "0003:1401" translates to 0.3 Ohms. I did not implement anything else, as I just wanted to be sure that I could read the values, but I never needed to... Regards, Dietmar import serial import time class VC940(object): def __init__(self, port="COM3"): self.port = port self.serial=serial.Serial(port,2400, bytesize=7, parity="N", stopbits=1, timeout=1.5, xonxoff=0, rtscts=0, dsrdtr=None) self.serial.setRTS(0) self.serial.setDTR(0) def _read_raw_value(self): timeout = True for n in range(5): self.serial.flushInput() self.serial.setDTR(1) data = self.serial.read(11) self.serial.setDTR(0) if data.endswith("\r\n") and len(data)==11: return data if not data: raise ValueError, "communication timeout" raise ValueError, "could not read data from port" if __name__=="__main__": vc = VC940() while True: print vc._read_raw_value() From breamoreboy at yahoo.co.uk Tue Feb 7 20:10:28 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 01:10:28 +0000 Subject: Cycle around a sequence Message-ID: I'm looking at a way of cycling around a sequence i.e. starting at some given location in the middle of a sequence and running to the end before coming back to the beginning and running to the start place. About the best I could come up with is the following, any better ideas for some definition of better? PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32. Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information. >>> from itertools import chain >>> a=range(10) >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) >>> for x in g: print x, ... 4 5 6 7 8 9 0 1 2 3 >>> -- Cheers. Mark Lawrence. From wentlv at gmail.com Tue Feb 7 20:13:23 2012 From: wentlv at gmail.com (crow) Date: Tue, 7 Feb 2012 17:13:23 -0800 (PST) Subject: keeping twisted and wxPython in sync References: Message-ID: On Feb 8, 2:41?am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory after a connection has been > made. So when I send my user and password, that is when I connect. Is > there a way to handle waiting for the connection to complete? > > -- > > Take care, > Ty > Web:http://tds-solutions.net > The Aspen project: a light-weight barebones mud enginehttp://code.google.com/p/aspenmud > > Sent from my toaster. You can send your user & password in connectionMade() method, I think. From wentlv at gmail.com Tue Feb 7 20:15:02 2012 From: wentlv at gmail.com (crow) Date: Tue, 7 Feb 2012 17:15:02 -0800 (PST) Subject: keeping twisted and wxPython in sync References: Message-ID: <1eccf21e-25bf-4e1c-8b44-18b6997e6f80@3g2000pbd.googlegroups.com> On Feb 8, 2:41?am, "Littlefield, Tyler" wrote: > Hello all: > I have a couple questions. First, is there a way to know if connectTCP > failed? I am writing a client with Twisted and would like to be able to > notify the user if they couldn't connect. > Second, I set the protocol on my factory after a connection has been > made. So when I send my user and password, that is when I connect. Is > there a way to handle waiting for the connection to complete? > > -- > > Take care, > Ty > Web:http://tds-solutions.net > The Aspen project: a light-weight barebones mud enginehttp://code.google.com/p/aspenmud > > Sent from my toaster. And for connection failed, you can write some hook code in connectionLost() method, this method will be called when connection failed. From tjreedy at udel.edu Tue Feb 7 20:41:01 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 07 Feb 2012 20:41:01 -0500 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: On 2/7/2012 8:10 PM, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? > > PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit > (Intel)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. > >>> from itertools import chain > >>> a=range(10) > >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) > >>> for x in g: print x, > ... > 4 5 6 7 8 9 0 1 2 3 a=range(10) n = len(a) off = 4 for k in (a[(i+off) % n] for i in range(n)): print(a[k], end = ' ') -- Terry Jan Reedy From pat.inside at gmail.com Tue Feb 7 20:48:10 2012 From: pat.inside at gmail.com (Lei Cheng) Date: Wed, 8 Feb 2012 09:48:10 +0800 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? Message-ID: Hi all, In a py file, when to use import statements in the header, when to use import statements in the blocks where they are used? What are the best practices? Thanks! Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Feb 7 20:50:56 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Feb 2012 01:50:56 GMT Subject: iterating over list with one mising value References: <1328617645.12769.YahooMailClassic@web161204.mail.bf1.yahoo.com> Message-ID: <4f31d500$0$29992$c3e8da3$5496439d@news.astraweb.com> (Apologies in advance for breaking threading, but the original post in this thread doesn't appear for me.) > On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso > wrote: >> >> Hello experts, >> I am having trouble accessing the content of my list. my list content >> has 2-pair value with the exception of one which has single value. here >> is an example? ['a', 1, 'b', 1, 'c', 3, 'd'] >> >> I am unable to iterate through list to access invidual value pairs Here's a recipe to collate a sequence of interleaved items. It collects every nth item: from itertools import islice, tee def collate(iterable, n): t = tee(iter(iterable), n) slices = (islice(it, i, None, n) for (i, it) in enumerate(t)) return [list(slice) for slice in slices] And here it is in use: >>> seq = [1, 'a', 'A', 2, 'b', 'B', 3, 'c', 'C', 4, 'd', 'D', 5, 'e'] >>> collate(seq, 3) [[1, 2, 3, 4, 5], ['a', 'b', 'c', 'd', 'e'], ['A', 'B', 'C', 'D']] >>> collate(seq, 2) [[1, 'A', 'b', 3, 'C', 'd', 5], ['a', 2, 'B', 'c', 4, 'D', 'e']] >>> collate(seq, 9) [[1, 4], ['a', 'd'], ['A', 'D'], [2, 5], ['b', 'e'], ['B'], [3], ['c'], ['C']] -- Steven From ch at radamanthys.de Tue Feb 7 21:01:37 2012 From: ch at radamanthys.de (Christoph Hansen) Date: Wed, 08 Feb 2012 03:01:37 +0100 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: Mark Lawrence schrieb: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? # quick&dirty seq=range(10) for x in seq[4:]+seq[:4]: print x # or def oneround(seq, start=0): i=start l=len(seq) while True: yield seq[i] i = (i+1) % l if i==start: break for x in oneround(range(50), 4): print x From d at davea.name Tue Feb 7 21:05:15 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 21:05:15 -0500 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: Message-ID: <4F31D85B.4040406@davea.name> On 02/07/2012 08:48 PM, Lei Cheng wrote: > Hi all, > > In a py file, when to use import statements in the header, when to use > import statements in the blocks where they are used? > What are the best practices? > Thanks! > > Pat > Best practice is to put all the imports at the beginning of the module, so they are easy to spot. If you put an import inside a function, it gets re-executed each time the function is called, which is a waste of time. Not too much, since import first checks sys.modules to see if it's already loaded. Also, avoid the from xxx import * form, as it pollutes the namespace. And it makes it hard to figure out where a particular name is declared. I believe these and other best practices can be found in pep8. http://www.python.org/dev/peps/pep-0008/ -- DaveA From pat.inside at gmail.com Tue Feb 7 21:38:08 2012 From: pat.inside at gmail.com (Patto) Date: Wed, 8 Feb 2012 10:38:08 +0800 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: <4F31D85B.4040406@davea.name> Message-ID: Dave Angel? On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: > On 02/07/2012 08:48 PM, Lei Cheng wrote: > >> Hi all, >> >> In a py file, when to use import statements in the header, when to use >> import statements in the blocks where they are used? >> What are the best practices? >> Thanks! >> >> Pat >> >> Best practice is to put all the imports at the beginning of the module, > so they are easy to spot. > > If you put an import inside a function, it gets re-executed each time the > function is called, which is a waste of time. Not too much, since import > first checks sys.modules to see if it's already loaded. > > Also, avoid the from xxx import * form, as it pollutes the > namespace. And it makes it hard to figure out where a particular name is > declared. > > I believe these and other best practices can be found in pep8. > > http://www.python.org/dev/**peps/pep-0008/ > > -- > > DaveA > > yeah, I read pep8. However I find in the file path/to/djcelery/loaders.py from django-celery source, there are so many import/from statements used inside functions, I do not know why the author coded like this. Are there any special facts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Tue Feb 7 21:41:49 2012 From: d at davea.name (Dave Angel) Date: Tue, 07 Feb 2012 21:41:49 -0500 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: <4F31D85B.4040406@davea.name> Message-ID: <4F31E0ED.30908@davea.name> You forgot to include the list in your reply, so I'm forwarding it for you. One way you could have done it was to reply-all. On 02/07/2012 09:32 PM, Patto wrote: > Dave Angel? > > On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: > >> On 02/07/2012 08:48 PM, Lei Cheng wrote: >> >>> Hi all, >>> >>> In a py file, when to use import statements in the header, when to use >>> import statements in the blocks where they are used? >>> What are the best practices? >>> Thanks! >>> >>> Pat >>> >>> Best practice is to put all the imports at the beginning of the module, >> so they are easy to spot. >> >> If you put an import inside a function, it gets re-executed each time the >> function is called, which is a waste of time. Not too much, since import >> first checks sys.modules to see if it's already loaded. >> >> Also, avoid the from xxx import * form, as it pollutes the >> namespace. And it makes it hard to figure out where a particular name is >> declared. >> >> I believe these and other best practices can be found in pep8. >> >> http://www.python.org/dev/**peps/pep-0008/ >> >> -- >> >> DaveA >> >> > yeah, I read pep8. > However I find in the file path/to/djcelery/loaders.py from django-celery > source, there are so many import/from statements used inside functions, I > do not know why the author coded like this. Are there any special facts? > I can't speak for django or django-celery. There are people that disagree on this, and there are some reasons to override the ones I mentioned. One would be large modules that are not used in most circumstances, or not used till the program has run for a while. If you put the import inside a function, you can save on startup time by deferring some of the logic till later. And if there's a module that probably won't be used at all (eg. an error handler), perhaps you can avoid loading it at all. I still think readability trumps all the other reasons, for nearly all programs. Only once you decide you have a performance problem should you change that. -- DaveA From cs at zip.com.au Tue Feb 7 22:40:25 2012 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 8 Feb 2012 14:40:25 +1100 Subject: python file synchronization In-Reply-To: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> References: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> Message-ID: <20120208034025.GA14347@cskk.homeip.net> On 07Feb2012 01:33, silentnights wrote: | I have the following problem, I have an appliance (A) which generates | records and write them into file (X), the appliance is accessible | throw ftp from a server (B). I have another central server (C) that | runs a Django App, that I need to get continuously the records from | file (A). | | The problems are as follows: | 1. (A) is heavily writing to the file, so copying the file will result | of uncompleted line at the end. | 2. I have many (A)s and (B)s that I need to get the data from. | 3. I can't afford losing any records from file (X) [...] | The above is implemented and working, the problem is that It required | so many syncs and has a high overhead and It's hard to debug. Yep. I would change the file discipline. Accept that FTP is slow and has no locking. Accept that reading records from an actively growing file is often tricky and sometimes impossible depending on the record format. So don't. Hand off completed files regularly and keep the incomplete file small. Have (A) write records to a file whose name clearly shows the file to be incomplete. Eg "data.new". Every so often (even once a second), _if_ the file is not empty: close it, _rename_ to "data.timestamp" or "data.sequence-number", open a new "data.new" for new records. Have the FTP client fetch only the completed files. You can perform a similar effort for the socket daemon: look only for completed data files. Reading the filenames from a directory is very fast if you don't stat() them (i.e. just os.listdir). Just open and scan any new files that appear. That would be my first cut. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Performing random acts of moral ambiguity. - Jeff Miller From anonhung at gmail.com Wed Feb 8 00:17:17 2012 From: anonhung at gmail.com (anon hung) Date: Wed, 8 Feb 2012 06:17:17 +0100 Subject: turbogears 1 Message-ID: Hey guys, someone asked me to maintain his old website, trouble is, it's in python, more trouble is it's in turbogears 1. I'm not fluent in python but all right, I can learn, but this turbogears thing.......... First of all, is it still alive? Looks like turbogears 2 is the most recent version but even that is being abandoned. Am I basically given vaporware? Does anyone have any up to date info? Best, Hung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From saibabagod1 at gmail.com Wed Feb 8 00:32:53 2012 From: saibabagod1 at gmail.com (VICKY) Date: Tue, 7 Feb 2012 21:32:53 -0800 (PST) Subject: MEGA INFO SYSTEMS Message-ID: Lead Generation Database scrubbing Debt Collection Services available here http://megainfosystems.yolasite.com From roy at panix.com Wed Feb 8 00:33:55 2012 From: roy at panix.com (Roy Smith) Date: Wed, 08 Feb 2012 00:33:55 -0500 Subject: turbogears 1 References: Message-ID: In article , anon hung wrote: > Hey guys, someone asked me to maintain his old website, trouble is, > it's in python, more trouble is it's in turbogears 1. I'm not fluent > in python but all right, I can learn, but this turbogears > thing.......... > > First of all, is it still alive? Looks like turbogears 2 is the most > recent version but even that is being abandoned. Yup, looks dead to me. Hasn't had a release in almost 2 months or a commit to the GIT repo in 2 days. Must be nailed to its perch or something. http://turbogears.org/en/current-status http://sourceforge.net/p/turbogears2/tg2/commit_browser > Am I basically given vaporware? Does anyone have any up to date info? Have you considered Ruby on Rails? From alec.taylor6 at gmail.com Wed Feb 8 00:37:01 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 8 Feb 2012 16:37:01 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: Thanks all for your replies. I have now installed MSVC8 and YASM. I was able to successfully run configure.bat and make.bat (including make.bat check). However, I'm unsure what to do about install, since there is no install arg. Do I copy it across to my VC\bin folder, or does it need it's own place in PATH + system variables? I am asking because I don't know where it is looking for the MPIR library. Thanks for all suggestions, Alec Taylor From jenichristy23 at gmail.com Wed Feb 8 00:57:25 2012 From: jenichristy23 at gmail.com (christy jenifer) Date: Tue, 7 Feb 2012 21:57:25 -0800 (PST) Subject: Wanted Professionals Message-ID: <7d861a84-586a-4b12-8cac-c3fb768bd2d2@ir9g2000pbc.googlegroups.com> Do you want to be a professional with more than 1000 dollars, Want to do shopping, want to book for hotel ......for everything Click on below link http://entertainmentgallexy.tripod.com/home.html From prakashsco71 at gmail.com Wed Feb 8 01:01:46 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Tue, 7 Feb 2012 22:01:46 -0800 (PST) Subject: hardware service required. Message-ID: hardware service required here. http://megainfosystems.yolasite.com From steve+comp.lang.python at pearwood.info Wed Feb 8 01:03:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Feb 2012 06:03:32 GMT Subject: turbogears 1 References: Message-ID: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 00:33:55 -0500, Roy Smith wrote: > In article , > anon hung wrote: > >> Hey guys, someone asked me to maintain his old website, trouble is, >> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >> python but all right, I can learn, but this turbogears thing.......... >> >> First of all, is it still alive? Looks like turbogears 2 is the most >> recent version but even that is being abandoned. > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > commit to the GIT repo in 2 days. Must be nailed to its perch or > something. > > http://turbogears.org/en/current-status > http://sourceforge.net/p/turbogears2/tg2/commit_browser Ohhh, sarcasm... To the original poster: what makes you think that Turbogears 2 is abandoned? >> Am I basically given vaporware? Does anyone have any up to date info? > > Have you considered Ruby on Rails? Now that's just cruel. -- Steven From prakashsco71 at gmail.com Wed Feb 8 01:05:06 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Tue, 7 Feb 2012 22:05:06 -0800 (PST) Subject: hardware service required. Message-ID: <5883e1e8-725c-417b-a531-67ace32bc607@4g2000pbz.googlegroups.com> hardware service required here. http://megainfosystems.yolasite.com From abhi.forall at gmail.com Wed Feb 8 01:36:17 2012 From: abhi.forall at gmail.com (abhijeet mahagaonkar) Date: Wed, 8 Feb 2012 12:06:17 +0530 Subject: Issue with Scrapping Data from a webpage- Noob Question Message-ID: Hi Fellow Pythoners, I'm trying to collect table data from an authenticated webpage (Tool) to which I have access. I will have the required data after 'click'ing a submit button on the tool homepage. When I inspect the submit button i see Thus the tool's homepage is of the form www.example.com/Tool and on clicking the submit button the data I need will be at www.example.com/Tool/index.do The problem that I'm running into is in my below code is giving me the source of homepage(www.example.com/Tool) and not the of the submitted page( www.example.com/Tool/index.do) url="www.example.com/Tool/index.do" request = urllib2.Request(url, data, {'Authorization': "Basic " + base64.b64encode("%s:%s" % (username, password))}) Response_Page=urllib2.urlopen(request).read() Is there a way I can access the source of the submitted page? PS: Sorry for laying out very tiny details on what I'm trying to do, I just wanted to explain myself clearly :) Thanks in advance for your time on this one. Warm Regards, Abhi -------------- next part -------------- An HTML attachment was scrubbed... URL: From silentquote at gmail.com Wed Feb 8 01:57:43 2012 From: silentquote at gmail.com (Sherif Shehab Aldin) Date: Wed, 8 Feb 2012 08:57:43 +0200 Subject: python file synchronization In-Reply-To: <20120208034025.GA14347@cskk.homeip.net> References: <24cb8965-9211-4601-b096-4bf482aead18@h6g2000yqk.googlegroups.com> <20120208034025.GA14347@cskk.homeip.net> Message-ID: Hi Cameron, Thanks a lot for your help, I just forgot to state that the FTP server is not under my command, I can't control how the file grow, or how the records are added, I can only login to It, copy the whole file. The reason why I am parsing the file and trying to get the diffs between the new file and the old one, and copy it to new_file.time_stamp is that I need to cut down the file size so when server (C) grabs the file, It grabs only new data, also to cut down the network bandwidth. One of my problems was after mounting server (B) diffs_dir into Server (A) throw NFS, I used to create filename.lock first into server (B) local file then start copy filename to server (B) then remove filename.lock, so when the daemon running on server (C) parses the files in the local_diffs dir, ignores the files that are still being copied, After searching more yesterday, I found that local mv is atomic, so instead of creating the lock files, I will copy the new diffs to tmp dir, and after the copy is over, mv it to actual diffs dir, that will avoid reading It while It's still being copied. Sorry if the above is bit confusing, the system is bit complex. Also there is one more factor that confuses me, I am so bad in testing, and I am trying to start actually implement unit testing to test my code, what I find hard is how to test code like the one that do the copy, mv and so, also the code that fetch data from the web. On Wed, Feb 8, 2012 at 5:40 AM, Cameron Simpson wrote: > On 07Feb2012 01:33, silentnights wrote: > | I have the following problem, I have an appliance (A) which generates > | records and write them into file (X), the appliance is accessible > | throw ftp from a server (B). I have another central server (C) that > | runs a Django App, that I need to get continuously the records from > | file (A). > | > | The problems are as follows: > | 1. (A) is heavily writing to the file, so copying the file will result > | of uncompleted line at the end. > | 2. I have many (A)s and (B)s that I need to get the data from. > | 3. I can't afford losing any records from file (X) > [...] > | The above is implemented and working, the problem is that It required > | so many syncs and has a high overhead and It's hard to debug. > > Yep. > > I would change the file discipline. Accept that FTP is slow and has no > locking. Accept that reading records from an actively growing file is > often tricky and sometimes impossible depending on the record format. > So don't. Hand off completed files regularly and keep the incomplete > file small. > > Have (A) write records to a file whose name clearly shows the file to be > incomplete. Eg "data.new". Every so often (even once a second), _if_ the > file is not empty: close it, _rename_ to "data.timestamp" or > "data.sequence-number", open a new "data.new" for new records. > > Have the FTP client fetch only the completed files. > > You can perform a similar effort for the socket daemon: look only for > completed data files. Reading the filenames from a directory is very > fast if you don't stat() them (i.e. just os.listdir). Just open and scan > any new files that appear. > > That would be my first cut. > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Performing random acts of moral ambiguity. > - Jeff Miller > -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Wed Feb 8 03:17:59 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 08:17:59 +0000 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: <4F31E0ED.30908@davea.name> References: <4F31D85B.4040406@davea.name> <4F31E0ED.30908@davea.name> Message-ID: On 08/02/2012 02:41, Dave Angel wrote: > You forgot to include the list in your reply, so I'm forwarding it for > you. One way you could have done it was to reply-all. > > > On 02/07/2012 09:32 PM, Patto wrote: >> Dave Angel? >> >> On Wed, Feb 8, 2012 at 10:05 AM, Dave Angel wrote: >> >>> On 02/07/2012 08:48 PM, Lei Cheng wrote: >>> >>>> Hi all, >>>> >>>> In a py file, when to use import statements in the header, when to use >>>> import statements in the blocks where they are used? >>>> What are the best practices? >>>> Thanks! >>>> >>>> Pat >>>> >>>> Best practice is to put all the imports at the beginning of the module, >>> so they are easy to spot. >>> >>> If you put an import inside a function, it gets re-executed each time >>> the >>> function is called, which is a waste of time. Not too much, since import >>> first checks sys.modules to see if it's already loaded. >>> >>> Also, avoid the from xxx import * form, as it pollutes the >>> namespace. And it makes it hard to figure out where a particular name is >>> declared. >>> >>> I believe these and other best practices can be found in pep8. >>> >>> http://www.python.org/dev/**peps/pep-0008/ >>> >>> >>> -- >>> >>> DaveA >>> >>> >> yeah, I read pep8. >> However I find in the file path/to/djcelery/loaders.py from django-celery >> source, there are so many import/from statements used inside functions, I >> do not know why the author coded like this. Are there any special facts? >> > > I can't speak for django or django-celery. There are people that > disagree on this, and there are some reasons to override the ones I > mentioned. One would be large modules that are not used in most > circumstances, or not used till the program has run for a while. > > If you put the import inside a function, you can save on startup time by > deferring some of the logic till later. And if there's a module that > probably won't be used at all (eg. an error handler), perhaps you can > avoid loading it at all. > > I still think readability trumps all the other reasons, for nearly all > programs. Only once you decide you have a performance problem should you > change that. > There's a thread on the dev ml about imports that also discusses startup times for anyone who's interested. -- Cheers. Mark Lawrence. From breamoreboy at yahoo.co.uk Wed Feb 8 03:26:33 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 08:26:33 +0000 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: On 08/02/2012 01:26, Dennis Lee Bieber wrote: > On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence > wrote: > >> I'm looking at a way of cycling around a sequence i.e. starting at some >> given location in the middle of a sequence and running to the end before >> coming back to the beginning and running to the start place. About the >> best I could come up with is the following, any better ideas for some >> definition of better? >> >> PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit >> (Intel)] on win32. >> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' >> for further copyright information. >>>>> from itertools import chain >>>>> a=range(10) >>>>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in xrange(4))) >>>>> for x in g: print x, >> ... >> 4 5 6 7 8 9 0 1 2 3 >>>>> > > How large a sequence and, more important, is it fully known at the > start... > >>>> a = range(20) >>>> a > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>>> a_shift = a[5:] + a[:5] >>>> a_shift > [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] >>>> > > IOWs, just slice and join: tail first, then front-end. > The sequences are small and the start is always known but the function that uses this is called thousands of times so I was trying to avoid building lists if at all possible. -- Cheers. Mark Lawrence. From mail at timgolden.me.uk Wed Feb 8 03:36:16 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 08 Feb 2012 08:36:16 +0000 Subject: Cycle around a sequence In-Reply-To: References: Message-ID: <4F323400.7050506@timgolden.me.uk> On 08/02/2012 08:26, Mark Lawrence wrote: > On 08/02/2012 01:26, Dennis Lee Bieber wrote: >> On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence >> wrote: >> >>> I'm looking at a way of cycling around a sequence i.e. starting at some >>> given location in the middle of a sequence and running to the end before >>> coming back to the beginning and running to the start place. About the >>> best I could come up with is the following, any better ideas for some >>> definition of better? >>> >>> PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit >>> (Intel)] on win32. >>> Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' >>> for further copyright information. >>>>>> from itertools import chain >>>>>> a=range(10) >>>>>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in >>>>>> xrange(4))) >>>>>> for x in g: print x, >>> ... >>> 4 5 6 7 8 9 0 1 2 3 >>>>>> >> >> How large a sequence and, more important, is it fully known at the >> start... >> >>>>> a = range(20) >>>>> a >> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] >>>>> a_shift = a[5:] + a[:5] >>>>> a_shift >> [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] >>>>> >> >> IOWs, just slice and join: tail first, then front-end. >> > > The sequences are small and the start is always known but the function > that uses this is called thousands of times so I was trying to avoid > building lists if at all possible. > I'm not an itertools expert, but does this do what you want? (Untested - I might well be off by one) import itertools sequence = range (100) split = 70 rslice = itertools.islice (sequence, split, len (sequence)) lslice = itertools.islice (sequence, split) repeater = itertools.cycle (itertools.chain (rslice, lslice)) TJG From vetrivijay09 at gmail.com Wed Feb 8 03:57:06 2012 From: vetrivijay09 at gmail.com (vetri vijay) Date: Wed, 8 Feb 2012 00:57:06 -0800 (PST) Subject: would u wanna details about ur life partner.click here free registration. Message-ID: <8fec2774-d3fc-436f-a410-fa60f68c28b7@v6g2000pba.googlegroups.com> http://123maza.com/46/river834/ From cs at zip.com.au Wed Feb 8 04:59:36 2012 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 8 Feb 2012 20:59:36 +1100 Subject: python file synchronization In-Reply-To: References: Message-ID: <20120208095936.GA31545@cskk.homeip.net> [ Please reply inline; it makes the discussion read like a converation, with context. - Cameron ] On 08Feb2012 08:57, Sherif Shehab Aldin wrote: | Thanks a lot for your help, I just forgot to state that the FTP server is | not under my command, I can't control how the file grow, or how the records | are added, I can only login to It, copy the whole file. Oh. That's a pity. | The reason why I am parsing the file and trying to get the diffs between | the new file and the old one, and copy it to new_file.time_stamp is that I | need to cut down the file size so when server (C) grabs the file, It grabs | only new data, also to cut down the network bandwidth. Can a simple byte count help here? Copy the whole file with FTP. From the new copy, extract the bytes from the last byte count offset onward. Then parse the smaller file, extracting whole records for use by (C). That way you can just keep the unparsed tail (partial record I imagine) around for the next fetch. Looking at RFC959 (the FTP protocol): http://www.w3.org/Protocols/rfc959/4_FileTransfer.html it looks like you can do a partial file fetch, also, by issuing a REST (restart) command to set a file offset and then issuing a RETR (retrieve) command to get the rest of the file. These all need to be in binary mode of course. So in principle you could track the byte offset of what you have fetched with FTP so far, and fetch only what is new. | One of my problems was after mounting server (B) diffs_dir into Server (A) | throw NFS, I used to create filename.lock first into server (B) local file | then start copy filename to server (B) then remove filename.lock, so when | the daemon running on server (C) parses the files in the local_diffs dir, | ignores the files that are still being copied, | | After searching more yesterday, I found that local mv is atomic, so instead | of creating the lock files, I will copy the new diffs to tmp dir, and after | the copy is over, mv it to actual diffs dir, that will avoid reading It | while It's still being copied. Yes, this sounds good. Provided the mv is on the same filesystem. For example: "mv /tmp/foo /home/username/foo" is actually a copy and not a rename because /tmp is normally a different filesystem from /home. | Sorry if the above is bit confusing, the system is bit complex. Complex systems often need fiddly solutions. | Also there is one more factor that confuses me, I am so bad in testing, and | I am trying to start actually implement unit testing to test my code, what | I find hard is how to test code like the one that do the copy, mv and so, | also the code that fetch data from the web. Ha. I used to be very bad at testing, now I am improving and am merely weak. One approach to testing is to make a mock up of the other half of the system, and test against the mockup. For example, you have code to FTP new data and then feed it to (C). You don't control the server side of the FTP. So you might make a small mock up program that writes valid (but fictitious) data records progressively to a local data file (write record, flush, pause briefly, etc). If you can FTP to your own test machine you could then treat _that_ growing file as the remote server's data file. Then you could copy it progressively using a byte count to keep track of the bits you have seen to skip them, and the the If you can't FTP to your test system, you could abstract out the "fetch part of this file by FTP" into its own function. Write an equivalent function that fetches part of a local file just by opening it. Then you could use the local file version in a test that doesn't actually do the FTP, but could exercise the rest of it. It is also useful to make simple tests of small pieces of the code. So make the code to get part of the data a simple function, and write tests to execute it in a few ways (no new data, part of a record, several records etc). There are many people better than I to teach testing. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Testing can show the presence of bugs, but not their absence. - Dijkstra From casevh at gmail.com Wed Feb 8 05:48:30 2012 From: casevh at gmail.com (Case Van Horsen) Date: Wed, 8 Feb 2012 02:48:30 -0800 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: > Thanks all for your replies. > > I have now installed MSVC8 and YASM. I assume you installed Visual Studio. I've omitted the commands to use the SDK compiler below. > > I was able to successfully run configure.bat and make.bat (including > make.bat check). > > However, I'm unsure what to do about install, since there is no > install arg. Do I copy it across to my VC\bin folder, or does it need > it's own place in PATH + system variables? The following is just a guess. I copy the files to a convenient location and then specify that location to setup.py. Below is an excerpt from my build process. mkdir c:\src\lib mkdir c:\src\include xcopy /Y mpir.h c:\src\include\*.* xcopy /Y win\mpir.lib c:\src\lib\*.* python setup.py build_ext -Ic:\src\include -Lc:\src\lib install > > I am asking because I don't know where it is looking for the MPIR library. > > Thanks for all suggestions, > > Alec Taylor From jeandupont115 at gmail.com Wed Feb 8 07:24:12 2012 From: jeandupont115 at gmail.com (Jean Dupont) Date: Wed, 8 Feb 2012 04:24:12 -0800 (PST) Subject: convert perl-script for voltcraft voltmeter to python [newbie] References: <8a475c9d-24ed-45a4-af9f-2ca826f9301d@m2g2000vbc.googlegroups.com> Message-ID: On 8 feb, 01:26, Dietmar Schwertberger wrote: > Am 03.02.2012 14:11, schrieb Jean Dupont:> As my request might have been too much asked, I have started doing > > some coding myself. > > I'm in doubt about the readline statement -which doesn't show anything > > received- as the meter sends continuously streams of 11 bytes > > Is there a way to just monitor with python what is arriving at a > > serial port? > > Some time ago I started working on reading data from a VC940. > I would assume that the protocol is the same. > > Please find below the code that will return the raw values from > a VC940 (tested on a classical RS232 port, but probably > will work on USB-RS232 converters as well). > > If you don't get anything, then you should check whether your > USB converter is supplying voltage on the DTR pin once you have called > self.serial.setDTR(1). > > You have the description how to decode the values? > E.g. the string "0003:1401" translates to 0.3 Ohms. > > I did not implement anything else, as I just wanted to be sure > that I could read the values, but I never needed to... > > Regards, > > Dietmar > > import serial > import time > > class VC940(object): > ? ? ?def __init__(self, port="COM3"): > ? ? ? ? ?self.port = port > ? ? ? ? ?self.serial=serial.Serial(port,2400, bytesize=7, parity="N", > stopbits=1, timeout=1.5, xonxoff=0, rtscts=0, dsrdtr=None) > ? ? ? ? ?self.serial.setRTS(0) > ? ? ? ? ?self.serial.setDTR(0) > ? ? ?def _read_raw_value(self): > ? ? ? ? ?timeout = True > ? ? ? ? ?for n in range(5): > ? ? ? ? ? ? ?self.serial.flushInput() > ? ? ? ? ? ? ?self.serial.setDTR(1) > ? ? ? ? ? ? ?data = self.serial.read(11) > ? ? ? ? ? ? ?self.serial.setDTR(0) > ? ? ? ? ? ? ?if data.endswith("\r\n") and len(data)==11: > ? ? ? ? ? ? ? ? ?return data > ? ? ? ? ? ? ?if not data: > ? ? ? ? ? ? ? ? ?raise ValueError, "communication timeout" > ? ? ? ? ?raise ValueError, "could not read data from port" > > if __name__=="__main__": > ? ? ?vc = VC940() > ? ? ?while True: > ? ? ? ? ?print vc._read_raw_value() Wow, this is great, it works like a charm. Thanks a lot! Jean From alec.taylor6 at gmail.com Wed Feb 8 07:24:18 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Wed, 8 Feb 2012 23:24:18 +1100 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: Thanks, but to get it to work with pip, wouldn't I need to add it to PATH? - Or can I just add those library args to pip? On Wed, Feb 8, 2012 at 9:48 PM, Case Van Horsen wrote: > On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: >> Thanks all for your replies. >> >> I have now installed MSVC8 and YASM. > I assume you installed Visual Studio. I've omitted the commands to use > the SDK compiler below. >> >> I was able to successfully run configure.bat and make.bat (including >> make.bat check). >> >> However, I'm unsure what to do about install, since there is no >> install arg. Do I copy it across to my VC\bin folder, or does it need >> it's own place in PATH + system variables? > > The following is just a guess. > > I copy the files to a convenient location and then specify that > location to setup.py. Below is an excerpt from my build process. > > mkdir c:\src\lib > mkdir c:\src\include > xcopy /Y mpir.h c:\src\include\*.* > xcopy /Y win\mpir.lib c:\src\lib\*.* > > python setup.py build_ext -Ic:\src\include -Lc:\src\lib install > >> >> I am asking because I don't know where it is looking for the MPIR library. >> >> Thanks for all suggestions, >> >> Alec Taylor From casevh at gmail.com Wed Feb 8 07:31:34 2012 From: casevh at gmail.com (Case Van Horsen) Date: Wed, 8 Feb 2012 04:31:34 -0800 Subject: PyCrypto builds neither with MSVC nor MinGW In-Reply-To: References: <35da69c3-edcc-4466-8a0d-70237c88af3b@qv4g2000pbc.googlegroups.com> Message-ID: On Wed, Feb 8, 2012 at 4:24 AM, Alec Taylor wrote: > Thanks, but to get it to work with pip, wouldn't I need to add it to > PATH? - Or can I just add those library args to pip? I don't think so. pyCrypto probably builds a single DLL so the MPIR library is statically linked into that DLL. Only the innvocation of setup.py should need to refer to the MPIR library locations. I don't use pip so I'm not sure how to get pip to install the resulting DLL, etc. > > On Wed, Feb 8, 2012 at 9:48 PM, Case Van Horsen wrote: >> On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor wrote: >>> Thanks all for your replies. >>> >>> I have now installed MSVC8 and YASM. >> I assume you installed Visual Studio. I've omitted the commands to use >> the SDK compiler below. >>> >>> I was able to successfully run configure.bat and make.bat (including >>> make.bat check). >>> >>> However, I'm unsure what to do about install, since there is no >>> install arg. Do I copy it across to my VC\bin folder, or does it need >>> it's own place in PATH + system variables? >> >> The following is just a guess. >> >> I copy the files to a convenient location and then specify that >> location to setup.py. Below is an excerpt from my build process. >> >> mkdir c:\src\lib >> mkdir c:\src\include >> xcopy /Y mpir.h c:\src\include\*.* >> xcopy /Y win\mpir.lib c:\src\lib\*.* >> >> python setup.py build_ext -Ic:\src\include -Lc:\src\lib install >> >>> >>> I am asking because I don't know where it is looking for the MPIR library. >>> >>> Thanks for all suggestions, >>> >>> Alec Taylor From neilc at norwich.edu Wed Feb 8 09:25:33 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 8 Feb 2012 14:25:33 GMT Subject: Cycle around a sequence References: Message-ID: <9pfeutFtjiU2@mid.individual.net> On 2012-02-08, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting > at some given location in the middle of a sequence and running > to the end before coming back to the beginning and running to > the start place. About the best I could come up with is the > following, any better ideas for some definition of better? Python's indices were designed for these kinds of shenanigans. def rotated(seq, n): """Iterate through all of seq, but starting from index n. >>> ", ".join(str(n) for n in rotated(range(5), 3)) '3, 4, 0, 1, 2' """ i = n - len(seq) while i < n: yield seq[i] i += 1 if __name__ == "__main__": import doctest doctest.testmod() If you have merely an iterable instead of a sequence, then look to some of the other clever stuff already posted. -- Neil Cerutti From wanderer at dialup4less.com Wed Feb 8 10:36:15 2012 From: wanderer at dialup4less.com (Wanderer) Date: Wed, 8 Feb 2012 07:36:15 -0800 (PST) Subject: PyDev not saving Ipython History between sessions Message-ID: <1dbd178b-f96b-4709-8c9d-b17959f6269a@kn4g2000pbc.googlegroups.com> One feature I like about Ipython is that it saves the history between sessions. The history isn't saved if you close Ipython with the corner X, but if you type 'exit()' it is saved. This doesn't work when using Ipython as the console in Pydev. Do I have something setup wrong? Is there a different command than exit() I should use before closing a session in PyDev. Is there a command to load the history when I start a session? Thanks From nathan.alexander.rice at gmail.com Wed Feb 8 11:54:38 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 8 Feb 2012 11:54:38 -0500 Subject: Looking for PyPi 2.0... Message-ID: As a user: * Finding the right module in PyPi is a pain because there is limited, low quality semantic information, and there is no code indexing. * I have to install the module to examine it; I don't need to look at docs all the time, sometimes I just want a package/class/function/method breakdown. * Given the previous point, having in-line documentation would be nice (for instance, just the output of .. automodule::) * Package usage/modification stats are not well exposed * No code metrics are available * I would like some kind of social service integration, for tagging and +1/likes. I know ratings were scrapped (and they weren't that useful anyhow), but for example, if Armin Ronacher or Robert Kern thumbs up a module there is a pretty good chance I will be interested in it. As a developer: * I don't want to have to maintain my code repository and my package releases separately. I want to let module repository know that my code repository exists, and that branches tagged as "release" should be made available. * I want to maintain one README. I don't like "someone needs to do this now" type posts but every time I use PyPi it infuratiates me. I usually end up finding modules via Stack Overflow, which seems silly to me. Nathan From someone at someplace.invalid Wed Feb 8 12:15:23 2012 From: someone at someplace.invalid (HoneyMonster) Date: Wed, 8 Feb 2012 17:15:23 +0000 (UTC) Subject: Naming convention for in-house modules (Newbie question) Message-ID: I am quite new to Python (2.7 on Linux), and have built a few modules using wxPython/wxGlade for GUI elements and Psycopg2 for database access. I adhere mostly to the PEP8 guidelines, and use Pylint to help with quality control. So far I have been *very* impressed. Due to Python's straightforwardness and the wealth of documentation, results have been excellent. Here is my question: I would like to start an in-house library of small modules to import, for things like error handling/logging. That's easy enough, but is there a recommended way of naming such modules? I am concerned about avoiding name clashes with standard modules and site packages. Thanks. From clp2 at rebertia.com Wed Feb 8 12:47:34 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 8 Feb 2012 09:47:34 -0800 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice wrote: > As a user: > * Finding the right module in PyPi is a pain because there is limited, > low quality semantic information, and there is no code indexing. > * I have to install the module to examine it; ?I don't need to look at > docs all the time, sometimes I just want a > package/class/function/method breakdown. > * Given the previous point, having in-line documentation would be nice > (for instance, just the output of .. automodule::) > * Package usage/modification stats are not well exposed > * No code metrics are available > * I would like some kind of social service integration, for tagging > and +1/likes. ?I know ratings were scrapped (and they weren't that > useful anyhow), but for example, if Armin Ronacher or Robert Kern > thumbs up a module there is a pretty good chance I will be interested > in it. > > As a developer: > * I don't want to have to maintain my code repository and my package > releases separately. ?I want to let module repository know that my > code repository exists, and that branches tagged as "release" should > be made available. > * I want to maintain one README. > > > I don't like "someone needs to do this now" type posts but every time > I use PyPi it infuratiates me. ?I usually end up finding modules via > Stack Overflow, which seems silly to me. They don't have all the features you're looking for, but at least they seem to be working on the problem: http://crate.io Cheers, Chris From amirouche.boubekki at gmail.com Wed Feb 8 12:47:54 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Wed, 8 Feb 2012 18:47:54 +0100 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: H?llo Nathan, See below, 2012/2/8 Nathan Rice > As a user: > * Finding the right module in PyPi is a pain because there is limited, > low quality semantic information, and there is no code indexing. > * I have to install the module to examine it; I don't need to look at > docs all the time, sometimes I just want a > package/class/function/method breakdown. > * Given the previous point, having in-line documentation would be nice > (for instance, just the output of .. automodule::) > * Package usage/modification stats are not well exposed > * No code metrics are available > * I would like some kind of social service integration, for tagging > and +1/likes. I know ratings were scrapped (and they weren't that > useful anyhow), but for example, if Armin Ronacher or Robert Kern > thumbs up a module there is a pretty good chance I will be interested > in it. > > As a developer: > * I don't want to have to maintain my code repository and my package > releases separately. I want to let module repository know that my > code repository exists, and that branches tagged as "release" should > be made available. > * I want to maintain one README. > > > I don't like "someone needs to do this now" type posts but every time > I use PyPi it infuratiates me. I usually end up finding modules via > Stack Overflow, which seems silly to me. > > Let me do a recap with application analogies: You want a combination of - github / bitbucket for source management *et ce terra* - http://readthedocs.org/ for documentation and search - http://nullege.com for code search - http://repos.io/ for the social features I think it's not enough for fully integrated project management solution, I will add this features: - Paragraph level and document level comments for documentation like http://djangobook.com/ - Matrix comparaisons : grid feature of http://djangopackages.com/ - Dependency tracking, library usage in a nice visual way - Ask for review thingy - Buildbot et all - Q/A system - Mailling lis - Bounties - Agenda because time lapse - Blogs because it's all the rage - CLI interface so that hipsters can hypergrep all the way - A big fat red button to promote good libraries into the standard lib - A specialized reader UI for hypernerds so that they can cope with that much information while still pretending to be human And when the Python WAR-like format is done, automatic deployement of web application on the Python.org cloud powered by machines using a pure Python implemention of the HURD on top a green chips running PyPy. HTH, Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Feb 8 12:49:31 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 8 Feb 2012 09:49:31 -0800 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: On Wed, Feb 8, 2012 at 9:15 AM, HoneyMonster wrote: > I am quite new to Python (2.7 on Linux), and have built a few modules > using wxPython/wxGlade for GUI elements and Psycopg2 for database access. > I adhere mostly to the PEP8 guidelines, and use Pylint to help with > quality control. > > So far I have been *very* impressed. Due to Python's straightforwardness > and the wealth of documentation, results have been excellent. > > Here is my question: I would like to start an in-house library of small > modules to import, for things like error handling/logging. That's easy > enough, but is there a recommended way of naming such modules? I am > concerned about avoiding name clashes with standard modules and site > packages. You could put all the modules under a single package; then you only need to worry about avoiding 1 name conflict. Cheers, Chris From nagle at animats.com Wed Feb 8 14:41:44 2012 From: nagle at animats.com (John Nagle) Date: Wed, 08 Feb 2012 11:41:44 -0800 Subject: MySQLdb not allowing hyphen In-Reply-To: References: Message-ID: <4f32cff3$0$12030$742ec2ed@news.sonic.net> On 2/5/2012 2:46 PM, Chris Rebert wrote: > On Sun, Feb 5, 2012 at 2:41 PM, Emeka wrote: >> >> Hello All, >> >> I noticed that MySQLdb not allowing hyphen may be way to prevent injection >> attack. >> I have something like below: >> >> "insert into reviews(message, title)values('%s', '%s')" %( "We don't know >> where to go","We can't wait till morrow" ) >> >> ProgrammingError(1064, "You have an error in your SQL syntax; check the >> manual that corresponds to your MySQL server version for the right syntax to >> use near 't know where to go. >> >> How do I work around this error? > > Don't use raw SQL strings in the first place. Use a proper > parameterized query, e.g.: > > cursor.execute("insert into reviews(message, title) values (%s, %s)", > ("We don't know where to go", "We can't wait till morrow")) Yes. You are doing it wrong. Do NOT use the "%" operator when putting SQL queries together. Let "cursor.execute" fill them in. It knows how to escape special characters in the input fields, which will fix your bug and prevent SQL injection. John Nagle From toddw at activestate.com Wed Feb 8 15:14:13 2012 From: toddw at activestate.com (Todd Whiteman) Date: Wed, 08 Feb 2012 12:14:13 -0800 Subject: Komodo 7 release (Python development tools) Message-ID: <4F32D795.2040702@activestate.com> Hello, My name is Todd. I'm the lead developer for Komodo IDE (Interactive Development Environment) and Komodo Edit (a free, open-source editor) at ActiveState. I wanted to announce that the newest version, Komodo 7, has been released: http://www.activestate.com/komodo-ide Python has long been one of the main languages supported by Komodo, so we're always getting useful feedback and suggestions. For Komodo 7, we've incorporated a lot of this feedback into enhancing our Python features. * Python Code Profiling (IDE only) Users have asked if there is a way to find out why their programs are taking so long to run. Komodo IDE 7 can show a graph of the methods and calls made by your program, so that you can detect where your CPU is being taken up. * Sophisticated Syntax Checking Choose between multiple syntax checkers like PyLint, PyFlakes and PyChecker. Provides language-specific syntax checking for CSS/JavaScript/Django inside HTML template languages like Django. * Code Collaboration (IDE only) We wanted to make pair programming easier. With the collaboration feature, multiple users can edit a document at the same time. It's kind of like Google Docs, but for code editing! * Speed With Komodo 7 you'll notice a lot snappier Komodo start-up time, lower CPU utilization - particularly when idle, and lower memory usage for large projects. * Even more... There are way more features in Komodo 7 than I can outline in a single post, so check out the online web pages for more Komodo 7 enhancements: http://www.activestate.com/komodo-ide/python-editor Again, note that Komodo comes in two different flavours: 1) Komodo Edit - completely free and fully open-source editor, offering smart code completions, syntax checking, code colorizing, sophisticated editing and more. 2) Komodo IDE - a full featured IDE, offering advanced debugging, interactive shells, code browsing, source code control, database integration, unit testing, regular expression tools and more. Try out Komodo 7 and let me know what you think. We really appreciate the support and feedback! Cheers, Todd From tjreedy at udel.edu Wed Feb 8 15:15:59 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 15:15:59 -0500 Subject: Cycle around a sequence In-Reply-To: <9pfeutFtjiU2@mid.individual.net> References: <9pfeutFtjiU2@mid.individual.net> Message-ID: On 2/8/2012 9:25 AM, Neil Cerutti wrote: > On 2012-02-08, Mark Lawrence wrote: >> I'm looking at a way of cycling around a sequence i.e. starting >> at some given location in the middle of a sequence and running >> to the end before coming back to the beginning and running to >> the start place. About the best I could come up with is the >> following, any better ideas for some definition of better? > > Python's indices were designed for these kinds of shenanigans. > > def rotated(seq, n): > """Iterate through all of seq, but starting from index n. > > >>> ", ".join(str(n) for n in rotated(range(5), 3)) > '3, 4, 0, 1, 2' > """ > > i = n - len(seq) > while i< n: > yield seq[i] > i += 1 This is really nice, in the category of "Why didn't I think of that?" (Probably because I knew the % mod solution from C and never 'updated'!) > if __name__ == "__main__": > import doctest > doctest.testmod() > > If you have merely an iterable instead of a sequence, then look > to some of the other clever stuff already posted. To make a repeating rotator is only a slight adjustment: k = n - len(seq) while True: i = k while i < n: yield seq[i] i += 1 -- Terry Jan Reedy From nagle at animats.com Wed Feb 8 16:43:11 2012 From: nagle at animats.com (John Nagle) Date: Wed, 08 Feb 2012 13:43:11 -0800 Subject: changing sys.path In-Reply-To: References: Message-ID: <4f32ec6a$0$11980$742ec2ed@news.sonic.net> On 2/1/2012 8:15 AM, Andrea Crotti wrote: > So suppose I want to modify the sys.path on the fly before running some > code > which imports from one of the modules added. > > at run time I do > sys.path.extend(paths_to_add) > > but it still doesn't work and I get an import error. Do import sys first. John Nagle From tjreedy at udel.edu Wed Feb 8 16:52:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 16:52:50 -0500 Subject: Komodo 7 release (Python development tools) In-Reply-To: <4F32D795.2040702@activestate.com> References: <4F32D795.2040702@activestate.com> Message-ID: On 2/8/2012 3:14 PM, Todd Whiteman wrote: > My name is Todd. I'm the lead developer for Komodo IDE (Interactive > Development Environment) and Komodo Edit (a free, open-source editor) at > ActiveState. I wanted to announce that the newest version, Komodo 7, has > been released: This is a pretty good release announcement, but a few questions. ... > http://www.activestate.com/komodo-ide/python-editor It would seem that the Professional Python Editor is the same as Komodo Edit, but it is unclear why only Python editing would be featured for Komodo IDE. http://www.activestate.com/komodo-edit is the page with the link people need to download just the editor. Does K.Edit let me run a program with one key, like F5 in IDLE? If so, does it leave me in interactive mode (python -i) as IDLE does? -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Wed Feb 8 17:47:04 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 08 Feb 2012 22:47:04 +0000 Subject: Cycle around a sequence In-Reply-To: <9pfeutFtjiU2@mid.individual.net> References: <9pfeutFtjiU2@mid.individual.net> Message-ID: On 08/02/2012 14:25, Neil Cerutti wrote: > On 2012-02-08, Mark Lawrence wrote: >> I'm looking at a way of cycling around a sequence i.e. starting >> at some given location in the middle of a sequence and running >> to the end before coming back to the beginning and running to >> the start place. About the best I could come up with is the >> following, any better ideas for some definition of better? > > Python's indices were designed for these kinds of shenanigans. > > def rotated(seq, n): > """Iterate through all of seq, but starting from index n. > > >>> ", ".join(str(n) for n in rotated(range(5), 3)) > '3, 4, 0, 1, 2' > """ > > i = n - len(seq) > while i< n: > yield seq[i] > i += 1 > > if __name__ == "__main__": > import doctest > doctest.testmod() > > If you have merely an iterable instead of a sequence, then look > to some of the other clever stuff already posted. > The winner :) -- Cheers. Mark Lawrence. From azandi at adconion.com Wed Feb 8 19:15:03 2012 From: azandi at adconion.com (Ali Zandi) Date: Wed, 8 Feb 2012 16:15:03 -0800 (PST) Subject: How to make PyDev pep8 friendly? Message-ID: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> Hi, I was trying to find a way to configure PyDev e.g. in Eclipse to be pep8 friendly. There are a few configurations like right trim lines, use space after commas, use space before and after operators, add new line at the end of file which can be configured via Eclipse -> Window -> Preferences - > PyDev -> Editor -> Code Style -> Code Formatter. But these are not enough; for example I couldn't find a way to configure double line spacing between function definitions. So is there any way to configure eclipse or PyDev to apply pep8 rules e.g. on each save? Thanks, From edriscoll at wisc.edu Wed Feb 8 20:23:19 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 19:23:19 -0600 Subject: frozendict Message-ID: <4F332007.9080800@wisc.edu> Hi all, I've been trying for a few days (only a little bit at a time) to come up with a way of implementing a frozendict that doesn't suck. I'm gradually converging to a solution, but I can't help but think that there's some subtlety that I'm probably missing which is why it's not already provided. Does anyone know why Python doesn't already come with a frozendict, or why there seem to only be a couple attempts to write one? Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From steve+comp.lang.python at pearwood.info Wed Feb 8 21:01:40 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 02:01:40 GMT Subject: frozendict References: Message-ID: <4f332903$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 19:23:19 -0600, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already > provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Because there is no way to implement one that doesn't suck? Because it's a solution in search of a problem? Actually, that's unfair. A write-once dict would be awesome for providing read-only constants, if only there were some way to set a namespace to using non-builtin dicts. -- Steven From tjreedy at udel.edu Wed Feb 8 21:07:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 21:07:40 -0500 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: On 2/8/2012 8:23 PM, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Turn the question around: why should there be? Python is intentionally parsimonious in adding builtins. -- Terry Jan Reedy From ian.g.kelly at gmail.com Wed Feb 8 21:13:10 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 8 Feb 2012 19:13:10 -0700 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: On Wed, Feb 8, 2012 at 6:23 PM, Evan Driscoll wrote: > Hi all, > > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. > > Does anyone know why Python doesn't already come with a frozendict, or > why there seem to only be a couple attempts to write one? Define "doesn't suck". If I were to hack one up, it would look something like this: from collections import Mapping, Hashable class frozendict(Mapping, Hashable): def __init__(self, *args, **kwargs): self.__dict = dict(*args, **kwargs) def __len__(self): return len(self.__dict) def __iter__(self): return iter(self.__dict) def __getitem__(self, key): return self.__dict[key] def __hash__(self): return hash(frozenset(self.__dict.iteritems())) def __repr__(self): return 'frozendict(%r)' % (self.__dict,) Not extensively tested, but it seems to work pretty well for me. Cheers, Ian From steve+comp.lang.python at pearwood.info Wed Feb 8 22:32:02 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 03:32:02 GMT Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? References: <4F31D85B.4040406@davea.name> Message-ID: <4f333e32$0$1615$c3e8da3$76491128@news.astraweb.com> On Tue, 07 Feb 2012 21:41:49 -0500, Dave Angel wrote: > On 02/07/2012 09:32 PM, Patto wrote: >> However I find in the file path/to/djcelery/loaders.py from >> django-celery source, there are so many import/from statements used >> inside functions, I do not know why the author coded like this. Are >> there any special facts? >> >> > I can't speak for django or django-celery. There are people that > disagree on this, and there are some reasons to override the ones I > mentioned. One would be large modules that are not used in most > circumstances, or not used till the program has run for a while. > > If you put the import inside a function, you can save on startup time by > deferring some of the logic till later. And if there's a module that > probably won't be used at all (eg. an error handler), perhaps you can > avoid loading it at all. Yes, the idea is "lazy importing" -- add the module name to the namespace, but don't actually load it until necessary. Apparently it is used heavily in Django and by PyPy. Interestingly, the CPython developers are currently migrating the low- level import machinery from C to pure Python (or at least mostly pure Python), because (1) the C code is a mess and practically nobody understands it; (2) the exact import behaviour is very hard to explain; (3) consequently Jython, IronPython etc. may behave slightly differently; (4) and they'd like to share the same code base as CPython; and (5) it's really hard to write custom importers. Moving to a pure Python implementation should fix these problems, provided that the speed hit isn't too big. http://sayspy.blogspot.com.au/2012/02/how-i-bootstrapped-importlib.html One suggestion made is that Python should support lazy imports out of the box. Another reason for putting imports inside a function is that global imports are, well, global. If you only need access to a module from one function, why pollute the global namespace? A reason for *not* importing inside a function is that there can sometimes be strange effects with threads, or so I've been told, but I couldn't begin to explain exactly what (allegedly) can go wrong. > I still think readability trumps all the other reasons, for nearly all > programs. Which is a good reason for importing inside a function: why confuse the reader with a global import if it isn't needed globally? -- Steven From nathan.alexander.rice at gmail.com Wed Feb 8 22:43:33 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 8 Feb 2012 22:43:33 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: > Turn the question around: why should there be? > Python is intentionally parsimonious in adding builtins. For the same reason there are frozensets? I put dicts in sets all the time. I just tuple the items, but that means you have to re-dict it on the way out to do anything useful with it. I am too lazy to write a frozendict or import one, but I would use it if it was a builtin. Nathan From emekamicro at gmail.com Wed Feb 8 22:48:25 2012 From: emekamicro at gmail.com (Emeka) Date: Thu, 9 Feb 2012 05:48:25 +0200 Subject: Id of methods Message-ID: Hell All, I am trying to see if I could get more of Python without being insane. class Boo(object): def __init__(self , moon, sun): self.moon = moon self.sun = sun def daf(self): return self.sun + self.moon def ball(self): return self.sun * self.moon print Boo.__dict__ {'__module__': '__main__', 'ball': , 'daf': , '__dict__ ......} print hex(id(Boo.daf)) 0x27de5a0 My question is why is it that the id of Boo.daf is different from daf's hex value in the above dict? Regards, \Emeka *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Wed Feb 8 22:55:30 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Feb 2012 03:55:30 GMT Subject: Cycle around a sequence References: Message-ID: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> On Wed, 08 Feb 2012 01:10:28 +0000, Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. If you have a sequence, and don't mind copying it, the easiest way is just to slice and join: >>> a = range(20) >>> b = a[5:] + a[:5] >>> print b [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] Short, sweet, easy and simple. What's not to like about it? For small (say, less than a few thousand of items) sequences, this probably is the fastest way to do it. Handling this lazily is trickier than it seems, because you have to store the first N items somewhere until you get to the rest of the iterable. There is no Right Way to do it, since the best solution will depend on how many items you have and how large N is. Here's one way with itertools: >>> from itertools import islice, chain, tee >>> a = iter(range(20)) >>> t1, t2 = tee(a) >>> b = chain(islice(t1, 5, None), islice(t2, None, 5)) >>> print list(b) [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] But read the docs for tee first: it may be that converting to a list is faster and more memory efficient. http://docs.python.org/library/itertools.html#itertools.tee Using tee may be overkill. Here's a simpler way: >>> a = iter(range(20)) >>> t = list(islice(a, 5)) >>> b = chain(a, t) >>> list(b) [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4] If your data is truly humongous, already stored in a list, and you don't want to make a copy, then I recommend your trick of generating the indexes: def cycle(seq, n): for indexes in (xrange(n, len(seq)), xrange(n)): for i in indexes: yield seq[i] If your data is humongous but only available lazily, buy more memory :) -- Steven From rmorgan466 at gmail.com Wed Feb 8 23:01:08 2012 From: rmorgan466 at gmail.com (Rita) Date: Wed, 8 Feb 2012 23:01:08 -0500 Subject: standalone python web server Message-ID: I am building a small intranet website and I would like to use Python. I was wondering if there was a easy and medium performance python based web server available. I would like to run it on port :8080 since I wont have root access also I prefer something easy to deploy meaning I would like to move the server from one physical host to another without too much fuss. Currently, I am using flask (development server) and everything is ok but the performance is really bad. -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Feb 8 23:06:21 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 15:06:21 +1100 Subject: Id of methods In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > I am trying to see if I could get more of Python without being insane. Oh, I thought insanity was a prerequisite... anyway. > print Boo.__dict__ > > {'__module__': '__main__', 'ball': , 'daf': > , '__dict__ ......} > > print ?hex(id(Boo.daf)) > 0x27de5a0 > > My question is why is it that the id of Boo.daf ?is different from daf's hex > value in the above dict? Take no notice of the exact value of id(). It is an opaque value that shouldn't be relied upon for anything. That said, though, I tried your example in my two Windows Pythons, 2.6.5 and 3.2; in 3.2, the behavior is most like what you seem to be accepting: >>> Boo.__dict__ dict_proxy({'__module__': '__main__', 'ball': , 'daf': , '__dict__': , '__weakref__': , '__doc__': None, '__init__': }) >>> hex(id(Boo.daf)) '0xfcbc90' >>> Boo.daf Same number everywhere. But 2.6.5 has a difference that might give you a hint: >>> print Boo.__dict__ {'__module__': '__main__', 'ball': , 'daf': , '__dict__': , '__weakref__': , '__doc__': None, '__init__': } >>> Boo.daf daf is not a function, it's a special object for an unbound method. The exact identity of it is not necessarily useful; and buried inside it is the actual function that you defined: >>> hex(id(Boo.daf)) '0x11b5c10' >>> hex(id(Boo.daf.im_func)) '0x11bdc30' And that seems to be the number that's given in the repr(). But mainly, don't rely on id() for anything beyond uniqueness against all current objects. ChrisA From tjreedy at udel.edu Wed Feb 8 23:08:36 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 08 Feb 2012 23:08:36 -0500 Subject: Id of methods In-Reply-To: References: Message-ID: On 2/8/2012 10:48 PM, Emeka wrote: >class Boo(object): > > def __init__(self , moon, sun): > self.moon = moon > self.sun = sun > def daf(self): > return self.sun + self.moon > def ball(self): > return self.sun * self.moon > > > print Boo.__dict__ > > {'__module__': '__main__', 'ball': , 'daf': > , '__dict__ ......} > > print hex(id(Boo.daf)) > 0x27de5a0 > My question is why is it that the id of Boo.daf is different from daf's > hex value in the above dict? Because you are using Python 2. Just print Boo.daf and you will see that it is not a 'function'. In Python 3, it will be, and have the same address. -- Terry Jan Reedy From rodrick.brown at gmail.com Wed Feb 8 23:12:04 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Wed, 8 Feb 2012 23:12:04 -0500 Subject: standalone python web server In-Reply-To: References: Message-ID: <5D252A02-CE40-4944-8A20-1AAB9F2FC2A3@gmail.com> On Feb 8, 2012, at 11:01 PM, Rita wrote: > I am building a small intranet website and I would like to use Python. I was wondering if there was a easy and medium performance python based web server available. I would like to run it on port :8080 since I wont have root access also I prefer something easy to deploy meaning I would like to move the server from one physical host to another without too much fuss. > > Currently, I am using flask (development server) and everything is ok but the performance is really bad. > Checkout TwistedWeb it's an HTTP server that can be used as a library or standalone server. $ twistd web --path . --port 8080 > > > -- > --- Get your facts first, then you can distort them as you please.-- > -- > http://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Feb 8 23:16:43 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 15:16:43 +1100 Subject: Cycle around a sequence In-Reply-To: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano wrote: > If your data is humongous but only available lazily, buy more memory :) Or if you have a huge iterable and only need a small index into it, snag those first few entries into a list, then yield everything else, then yield the saved ones: def cycle(seq,n): seq=iter(seq) lst=[next(seq) for i in range(n)] try: while True: yield next(seq) except StopIteration: for i in lst: yield i >>> list(cycle(range(10,20),2)) [12, 13, 14, 15, 16, 17, 18, 19, 10, 11] Requires storage space relative to n, regardless of the length of the iterator. ChrisA From roy at panix.com Wed Feb 8 23:31:55 2012 From: roy at panix.com (Roy Smith) Date: Wed, 08 Feb 2012 23:31:55 -0500 Subject: standalone python web server References: Message-ID: In article , Rodrick Brown wrote: > On Feb 8, 2012, at 11:01 PM, Rita wrote: > > > I am building a small intranet website and I would like to use Python. I > > was wondering if there was a easy and medium performance python based web > > server available. I would like to run it on port :8080 since I wont have > > root access also I prefer something easy to deploy meaning I would like to > > move the server from one physical host to another without too much fuss. > > > > Currently, I am using flask (development server) and everything is ok but > > the performance is really bad. > > > > Checkout TwistedWeb it's an HTTP server that can be used as a library or > standalone server. > > $ twistd web --path . --port 8080 > Another one to look at is gunicorn. From anonhung at gmail.com Wed Feb 8 23:50:42 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:50:42 +0100 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: >> My name is Todd. I'm the lead developer for Komodo IDE (Interactive >> Development Environment) and Komodo Edit (a free, open-source editor) at >> ActiveState. I wanted to announce that the newest version, Komodo 7, has >> been released: > > This is a pretty good release announcement, but a few questions. > ... > > http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as Komodo > Edit, but it is unclear why only Python editing would be featured for > Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. > > Does K.Edit let me run a program with one key, like F5 in IDLE? AFAIK it sure does! > If so, does it leave me in interactive mode (python -i) as IDLE does? Hmmm, I don't know about that. Best, anonhung -- Viktor Orban Prime minister of Hungary From anonhung at gmail.com Wed Feb 8 23:53:38 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:53:38 +0100 Subject: turbogears 1 In-Reply-To: References: Message-ID: >> Hey guys, someone asked me to maintain his old website, trouble is, >> it's in python, more trouble is it's in turbogears 1. I'm not fluent >> in python but all right, I can learn, but this turbogears >> thing.......... >> >> First of all, is it still alive? Looks like turbogears 2 is the most >> recent version but even that is being abandoned. > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > commit to the GIT repo in 2 days. Must be nailed to its perch or > something. > > http://turbogears.org/en/current-status > http://sourceforge.net/p/turbogears2/tg2/commit_browser All right, what I got confused about is that they talk about pyramid these days which will not be turbogears 2 based. >> Am I basically given vaporware? Does anyone have any up to date info? > > Have you considered Ruby on Rails? This is joke, right? :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Wed Feb 8 23:55:22 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:55:22 +0100 Subject: turbogears 1 In-Reply-To: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> References: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: >>> Hey guys, someone asked me to maintain his old website, trouble is, >>> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >>> python but all right, I can learn, but this turbogears thing.......... >>> >>> First of all, is it still alive? Looks like turbogears 2 is the most >>> recent version but even that is being abandoned. >> >> Yup, looks dead to me. Hasn't had a release in almost 2 months or a >> commit to the GIT repo in 2 days. Must be nailed to its perch or >> something. >> >> http://turbogears.org/en/current-status >> http://sourceforge.net/p/turbogears2/tg2/commit_browser > > Ohhh, sarcasm... > > To the original poster: what makes you think that Turbogears 2 is > abandoned? As I've said in another reply they keep talking about pyramid as if that will be a totally new framework. I'm not saying I know things definitely but surely my impression was that the team is out for something new not based on turbogears 2. >>> Am I basically given vaporware? Does anyone have any up to date info? >> >> Have you considered Ruby on Rails? > > Now that's just cruel. Yep, it is :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Wed Feb 8 23:59:17 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 05:59:17 +0100 Subject: Fwd: turbogears 1 In-Reply-To: References: <4f321034$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: >>> Hey guys, someone asked me to maintain his old website, trouble is, >>> it's in python, more trouble is it's in turbogears 1. I'm not fluent in >>> python but all right, I can learn, but this turbogears thing.......... >>> >>> First of all, is it still alive? Looks like turbogears 2 is the most >>> recent version but even that is being abandoned. >> >> Yup, looks dead to me. Hasn't had a release in almost 2 months or a >> commit to the GIT repo in 2 days. Must be nailed to its perch or >> something. >> >> http://turbogears.org/en/current-status >> http://sourceforge.net/p/turbogears2/tg2/commit_browser > > Ohhh, sarcasm... > > To the original poster: what makes you think that Turbogears 2 is > abandoned? The development team keeps talking about pyramid which is supposed to be a totally new framework. I don't pretend to understand the work flow but surely they got me confused about switching gears (no pun intended!). >>> Am I basically given vaporware? Does anyone have any up to date info? >> >> Have you considered Ruby on Rails? > > Now that's just cruel. Yep, it is :) Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Thu Feb 9 00:05:35 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 06:05:35 +0100 Subject: standalone python web server In-Reply-To: References: Message-ID: >> I am building a small intranet website and I would like to use Python. I >> was wondering if there was a easy and medium performance python based web >> server available. I would like to run it on port :8080 since I wont have >> root access also I prefer something easy to deploy meaning I would like >> to >> move the server from one physical host to another without too much fuss. >> >> Currently, I am using flask (development server) and everything is ok but >> the performance is really bad. How about cherrypy? Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Thu Feb 9 00:07:42 2012 From: anonhung at gmail.com (anon hung) Date: Thu, 9 Feb 2012 06:07:42 +0100 Subject: Issue with Scrapping Data from a webpage- Noob Question In-Reply-To: References: Message-ID: > Hi Fellow Pythoners, > > I'm trying to collect table data from an authenticated webpage (Tool) to > which I have access. > > I will have the required data after 'click'ing a submit button on the tool > homepage. > When I inspect the submit button i see > > > Thus the tool's homepage is of the form www.example.com/Tool and on > clicking the submit button the data I need will be at > www.example.com/Tool/index.do > > The problem that I'm running into is in my below code is giving me the > source of homepage(www.example.com/Tool) and not the of the submitted page( > www.example.com/Tool/index.do) > > url="www.example.com/Tool/index.do" > request = urllib2.Request(url, data, {'Authorization': "Basic " + > base64.b64encode("%s:%s" % (username, password))}) > Response_Page=urllib2.urlopen(request).read() > > Is there a way I can access the source of the submitted page? > > PS: Sorry for laying out very tiny details on what I'm trying to do, I just > wanted to explain myself clearly :) > > Thanks in advance for your time on this one. Have you checked beautifulsoup? Best, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From driscoll at cs.wisc.edu Thu Feb 9 00:33:23 2012 From: driscoll at cs.wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 23:33:23 -0600 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: <4F335AA3.4010707@cs.wisc.edu> On 13:59, Nathan Rice wrote: >> Turn the question around: why should there be? >> Python is intentionally parsimonious in adding builtins. > > For the same reason there are frozensets? > > I put dicts in sets all the time. I just tuple the items, but that > means you have to re-dict it on the way out to do anything useful with > it. I am too lazy to write a frozendict or import one, but I would > use it if it was a builtin. I've wanted to do that as well. My current use case is I want to have a dict as an attribute of another object, and I want to use that object as a key in a dictionary. That means that the outer object has to be immutable (an obnoxious enough task on its own, BTW) and that either the dict itself has to be excluded from computing the hash or the dict also has to be immutable. Also, it's not like it has to be a builtin, per se. I know how to spell 'import'. :-) Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From edriscoll at wisc.edu Thu Feb 9 00:40:55 2012 From: edriscoll at wisc.edu (Evan Driscoll) Date: Wed, 08 Feb 2012 23:40:55 -0600 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: <4F335C67.3050703@wisc.edu> On 13:59, Ian Kelly wrote: > > Define "doesn't suck". If I were to hack one up, it would look > something like this: > > > from collections import Mapping, Hashable So part of my objection was that I wanted to make sure I got all of the expected functionality, and that takes a bunch of functions. I didn't know about the ABTs in 'collections' though, so that helps a bit. However, I'd still prefer something that guaranteed immutability better than that. I might just be fighting the language too much at that point though... Evan -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 552 bytes Desc: OpenPGP digital signature URL: From amarjeet.java at gmail.com Thu Feb 9 02:04:25 2012 From: amarjeet.java at gmail.com (amarjeet yadav) Date: Thu, 9 Feb 2012 12:34:25 +0530 Subject: Can not get the result of query in pymssql module of python... Message-ID: Hi All, This is my first post to any mailing group. I am QA engg and using python for testing automation. I need to connect with Mysql (2008) and mssql databases for executing some queries. I have installed following modules & softwares in python 2.7 : python 2.7.2 setuptools MySQLdb Module pymssql module yum install mysql msql-devel freetdf I have installed freetds 0.9version. After installation of all the above components, I have done following things Python 2.6 (r26:66714, Apr 8 2010, 08:46:35) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pymssql >>> conn = pymssql.connect(host='mssql_server', user='_username', password='_password', database='_db',as_dict=True) >>> cur = conn.cursor() >>> cur.execute('select count(*) from D2.dbo.abc (nolock)') >>> print cur.fetchall() [] >>> cur.rowcount -1 >>> exit() I am expecting that the result of the query will be 16. But it is not retuning any data from query with no error at any place. On execting the same query in tsql, I got result as 16. freetds.log file : ############################################################################ mem.c:615:tds_free_all_results() util.c:156:Changed query state from IDLE to QUERYING write.c:140:tds_put_string converting 50 bytes of "select count(*) from D2.dbo.abc (nolock)" write.c:168:tds_put_string wrote 100 bytes util.c:156:Changed query state from QUERYING to PENDING net.c:741:Sending packet 0000 01 01 00 6c 00 00 01 00-73 00 65 00 6c 00 65 00 |...l.... s.e.l.e.| 0010 63 00 74 00 20 00 63 00-6f 00 75 00 6e 00 74 00 |c.t. .c. o.u.n.t.| 0020 28 00 2a 00 29 00 20 00-66 00 72 00 6f 00 6d 00 |(.*.). . f.r.o.m.| 0030 20 00 44 00 32 00 2e 00-64 00 62 00 6f 00 2e 00 | .D.2... d.b.o...| 0040 61 00 63 00 74 00 69 00-76 00 65 00 5f 00 61 00 |a.c.t.i. v.e._.a.| 0050 67 00 65 00 6e 00 74 00-73 00 20 00 28 00 6e 00 |g.e.n.t. s. .(.n.| 0060 6f 00 6c 00 6f 00 63 00-6b 00 29 00 |o.l.o.c. k.).| dblib.c:4639:dbsqlok(0x99d1148) dblib.c:4669:dbsqlok() not done, calling tds_process_tokens() token.c:540:tds_process_tokens(0x998ff70, 0xbff42098, 0xbff42094, 0x6914) util.c:156:Changed query state from PENDING to READING net.c:555:Received header 0000 04 01 00 21 00 46 01 00- |...!.F..| net.c:609:Received packet 0000 04 01 00 21 00 46 01 00-81 01 00 00 00 01 00 26 |...!.F.. .......&| 0010 04 00 d1 04 10 00 00 00-fd 10 00 c1 00 01 00 00 |........ ........| 0020 00 - |.| token.c:555:processing result tokens. marker is 81(TDS7_RESULT) token.c:1515:processing TDS7 result metadata. mem.c:615:tds_free_all_results() token.c:1540:set current_results (1 column) to tds->res_info token.c:1547:setting up 1 columns token.c:1486:tds7_get_data_info: colname = (0 bytes) type = 38 (integer-null) server's type = 38 (integer-null) column_varint_size = 1 column_size = 4 (4 on server) token.c:1556: name size/wsize type/wtype utype token.c:1557: -------------------- --------------- --------------- ------- token.c:1567: 4/4 38/38 0 util.c:156:Changed query state from READING to PENDING dblib.c:4700:dbsqlok() found result token dblib.c:1813:dbnumcols(0x99d1148) dblib.c:2761:dbcount(0x99d1148) dblib.c:1813:dbnumcols(0x99d1148) dblib.c:1839:dbcolname(0x99d1148, 1) dblib.c:2831:dbcoltype(0x99d1148, 1) dblib.c:2018:dbnextrow(0x99d1148) dblib.c:2031:dbnextrow() dbresults_state = 1 (_DB_RES_RESULTSET_EMPTY) dblib.c:2036:leaving dbnextrow() returning -2 (NO_MORE_ROWS) dblib.c:2761:dbcount(0x99d1148) dblib.c:1443:dbclose(0x99d1148) dblib.c:258:dblib_del_connection(0xeff460, 0x998ff70) mem.c:615:tds_free_all_results() util.c:156:Changed query state from PENDING to DEAD dblib.c:305:dblib_release_tds_ctx(1) dblib.c:5882:dbfreebuf(0x99d1148) #################################################################################### Please let me know what could be the issue? Am I forgettting to set any variable ot conf file change. Is anyone has faced the same problem. Thanks in Advance for your help.... -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 9 03:33:13 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 09:33:13 +0100 Subject: Cycle around a sequence References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:55 PM, Steven D'Aprano > wrote: >> If your data is humongous but only available lazily, buy more memory :) > > Or if you have a huge iterable and only need a small index into it, > snag those first few entries into a list, then yield everything else, > then yield the saved ones: > def cycle(seq,n): > seq=iter(seq) > lst=[next(seq) for i in range(n)] > try: > while True: yield next(seq) > except StopIteration: > for i in lst: yield i I think that should be spelt def cycle2(seq, n): seq = iter(seq) head = [next(seq) for i in range(n)] for item in seq: yield item for item in head: yield item or, if you are into itertools, def cycle3(seq, n): seq = iter(seq) return chain(seq, list(islice(seq, n))) $ python -m timeit -s'from tmp import cycle; data = range(1000); start=10' 'for item in cycle(data, 10): pass' 1000 loops, best of 3: 358 usec per loop $ python -m timeit -s'from tmp import cycle2; data = range(1000); start=10' 'for item in cycle2(data, 10): pass' 1000 loops, best of 3: 172 usec per loop $ python -m timeit -s'from tmp import cycle3; data = range(1000); start=10' 'for item in cycle3(data, 10): pass' 10000 loops, best of 3: 56.5 usec per loop For reference: $ python -m timeit -s'data = range(1000); start=10' 'for item in data[start:] + data[:start]: pass' 10000 loops, best of 3: 56.4 usec per loop From __peter__ at web.de Thu Feb 9 03:36:30 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 09:36:30 +0100 Subject: Cycle around a sequence References: Message-ID: Mark Lawrence wrote: > I'm looking at a way of cycling around a sequence i.e. starting at some > given location in the middle of a sequence and running to the end before > coming back to the beginning and running to the start place. About the > best I could come up with is the following, any better ideas for some > definition of better? You could use a deque instead of a list and .rotate() that: >>> from collections import deque >>> d = deque(range(10)) >>> d.rotate(-4) >>> d deque([4, 5, 6, 7, 8, 9, 0, 1, 2, 3]) > > PythonWin 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit > (Intel)] on win32. > Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' > for further copyright information. > >>> from itertools import chain > >>> a=range(10) > >>> g = chain((a[i] for i in xrange(4, 10, 1)), (a[i] for i in > >>> xrange(4))) for x in g: print x, > ... > 4 5 6 7 8 9 0 1 2 3 > >>> From dllizheng at gmail.com Thu Feb 9 03:49:10 2012 From: dllizheng at gmail.com (newme) Date: Thu, 9 Feb 2012 00:49:10 -0800 (PST) Subject: what is the difference between @property and method Message-ID: <0c959426-d6a5-42ac-a869-e2a4edba1655@v6g2000pba.googlegroups.com> class A(object): @properymethod def value1(self): return 'value1' def value2(self): return 'value2' what is the difference between value1 and value2. From dllizheng at gmail.com Thu Feb 9 03:50:38 2012 From: dllizheng at gmail.com (Zheng Li) Date: Thu, 9 Feb 2012 17:50:38 +0900 Subject: what is the difference between @property and method Message-ID: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> class A(object): @properymethod def value1(self): return 'value1' def value2(self): return 'value2' what is the difference between value1 and value2. From jeanpierreda at gmail.com Thu Feb 9 04:05:06 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Thu, 9 Feb 2012 04:05:06 -0500 Subject: what is the difference between @property and method In-Reply-To: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> Message-ID: On Thu, Feb 9, 2012 at 3:50 AM, Zheng Li wrote: > class A(object): > @properymethod > def value1(self): > return 'value1' > > def value2(self): > return 'value2' > > what is the difference between value1 and value2. There is no such thing as @properymethod After you change the code to use @property, try writing it in the interactive interpreter and calling A().value2(). Then try calling A().value1() . Or maybe try googling for it. The fourth result for "property python" for me is http://adam.gomaa.us/blog/2008/aug/11/the-python-property-builtin/ -- It is kind of funny that the docs don't ever explicitly say what a property is. http://docs.python.org/library/functions.html#property -- Devin From storchaka at gmail.com Thu Feb 9 05:10:41 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Thu, 09 Feb 2012 12:10:41 +0200 Subject: Cycle around a sequence In-Reply-To: References: <9pfeutFtjiU2@mid.individual.net> Message-ID: 08.02.12 22:15, Terry Reedy ???????(??): > To make a repeating rotator is only a slight adjustment: > > k = n - len(seq) > while True: > i = k > while i < n: > yield seq[i] > i += 1 for i in range(n, len(seq)): yield seq[i] while True: for x in seq: yield x From duncan.booth at invalid.invalid Thu Feb 9 05:33:58 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 10:33:58 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > I put dicts in sets all the time. I just tuple the items, but that > means you have to re-dict it on the way out to do anything useful with > it. I am too lazy to write a frozendict or import one, but I would > use it if it was a builtin. > I hope you sort the items before putting them in a tuple, otherwise how do you handle two identical dicts that return their items in a different order? -- Duncan Booth http://kupuguy.blogspot.com From rosuav at gmail.com Thu Feb 9 05:34:45 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 9 Feb 2012 21:34:45 +1100 Subject: Cycle around a sequence In-Reply-To: References: <4f3343b2$0$1615$c3e8da3$76491128@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 7:33 PM, Peter Otten <__peter__ at web.de> wrote: > Chris Angelico wrote: > >> def cycle(seq,n): >> ? ? ? ? seq=iter(seq) >> ? ? ? ? lst=[next(seq) for i in range(n)] >> ? ? ? ? try: >> ? ? ? ? ? ? ? ? while True: yield next(seq) >> ? ? ? ? except StopIteration: >> ? ? ? ? ? ? ? ? for i in lst: yield i > > I think that should be spelt > > def cycle2(seq, n): > ? ?seq = iter(seq) > ? ?head = [next(seq) for i in range(n)] > ? ?for item in seq: > ? ? ? ?yield item > ? ?for item in head: > ? ? ? ?yield item Thanks, yeah, don't know what I was thinking :) Too much C work lately! ChrisA From phil at freehackers.org Thu Feb 9 05:46:46 2012 From: phil at freehackers.org (BlueBird) Date: Thu, 9 Feb 2012 02:46:46 -0800 (PST) Subject: unicode printing on Windows Message-ID: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Hi, The question is not totally related to Python but there is a strong connection. Everytime that I try to debug some python programs under Windows, I encounter the issue that things printed on the console simply break the program because : 1. My windows console does not support UTF8 2. Things printed by the program on the stdout / stderr do not necessarily use sys.getpreferredencoding() so break with UnicodeError. Does anybody know how to fix problem 1 ? That way, I could at least deal with programs that print UTF8 on stdout. Regarding point 2, I must admit even when I am the author of the program, printing debug information (in unicode) on the stdout is a really really tricky thing. Is there a recommendation on how to do that properly ? Important information : I am using Python 2.5 cheers, Philippe From bahamutzero8825 at gmail.com Thu Feb 9 06:19:10 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 09 Feb 2012 05:19:10 -0600 Subject: unicode printing on Windows In-Reply-To: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> References: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Message-ID: <4F33ABAE.9050804@gmail.com> On 2/9/2012 4:46 AM, BlueBird wrote: > Does anybody know how to fix problem 1 ? That way, I could at least > deal with programs that print UTF8 on stdout. I'm pretty sure there isn't a way. cp65001 is supposed to be UTF-8, but it doesn't work in my experience (I fed it some UTF-8 demo text and I got garbage and beeping). Python 3.3 will support cp65001, 3.2 and below do not. > Regarding point 2, I must admit even when I am the author of the > program, printing debug information (in unicode) on the stdout is a > really really tricky thing. Is there a recommendation on how to do > that properly ? Use the logging module, perhaps? It has handled encoding issues automatically, at least in my experience. In Python 3, you can convert a string to bytes from one encoding, then convert to another encoding, but Python 2 has things set up very differently (and my experience is with py3k, so I can't help much). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From thbach at students.uni-mainz.de Thu Feb 9 06:28:21 2012 From: thbach at students.uni-mainz.de (Thomas Bach) Date: Thu, 9 Feb 2012 12:28:21 +0100 Subject: standalone python web server In-Reply-To: (Rita's message of "Wed, 8 Feb 2012 23:01:08 -0500") References: Message-ID: <87pqdoutyi.fsf@jubold.box> Rita writes: > I am building a small intranet website and I would like to use > Python. I was wondering if there was a easy and medium performance > python based web server available. Are you going to use a framework? Most of these ship with a light web server implementation? You probably want to check these out too? I got a pretty robust setup via + nginx, + supervisord, + the web server shipped with Pyramid If you want to use the WSGI standard I'd recommend to read http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/deployment.html This document describes several possible set ups to serve an WSGI application? Regards, vince From mateusz at loskot.net Thu Feb 9 06:43:44 2012 From: mateusz at loskot.net (Mateusz Loskot) Date: Thu, 9 Feb 2012 11:43:44 +0000 Subject: Read-only attribute in module Message-ID: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the following import xyz print(xyz.flag) # OK xyz.flag = 0 # error due to no write access Best regards, -- Mateusz Loskot, http://mateusz.loskot.net From rodperson at rodperson.com Thu Feb 9 07:31:56 2012 From: rodperson at rodperson.com (Rod Person) Date: Thu, 9 Feb 2012 07:31:56 -0500 Subject: Can not get the result of query in pymssql module of python... In-Reply-To: References: Message-ID: <20120209073156.000012b2@unknown> On Thu, 9 Feb 2012 12:34:25 +0530 amarjeet yadav wrote: > Hi All, > This is my first post to any mailing group. I am QA engg > and using python for testing automation. I need to connect with Mysql > (2008) and mssql databases for executing some queries. > > I have installed following modules & softwares in python 2.7 : > > python 2.7.2 > setuptools > MySQLdb Module > pymssql module > yum install mysql msql-devel freetdf > > I have installed freetds 0.9version. After installation of all the > above components, I have done following things > > Python 2.6 (r26:66714, Apr 8 2010, 08:46:35) > [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import pymssql > >>> conn = pymssql.connect(host='mssql_server', user='_username', > password='_password', database='_db',as_dict=True) > >>> cur = conn.cursor() > >>> cur.execute('select count(*) from D2.dbo.abc (nolock)') > >>> print cur.fetchall() What if you change this to print cur.fetchone() About 95% of my python database work is with MS SQL. I use fetchone when as_dict is True and it seems to work better for me. > [] > >>> cur.rowcount > -1 > >>> exit() > > I am expecting that the result of the query will be 16. But it is not > retuning any data from query with no error at any place. On execting > the same query in tsql, I got result as 16. > -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From ben+python at benfinney.id.au Thu Feb 9 07:32:59 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 09 Feb 2012 23:32:59 +1100 Subject: Read-only attribute in module References: Message-ID: <878vkc426c.fsf@benfinney.id.au> Mateusz Loskot writes: > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Python is designed by and for consenting adults. Rather than restricting, instead use conventions to make your intent clear to the user of your library. > So, the following > > import xyz > print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access PEP 8 gives the style guide for Python code (strictly for the standard library, but it is recommended for all Python code). If you want a module attribute that is intended to remain bound to the same value, use PEP 8's recommendation and name the attribute in ?ALL_UPPER_CASE?. If you want an attribute that is intended only for internal use (an implementation detail that should not be relied upon outside the library), use PEP 8's recommendation and name the attribute with a ?_single_leading_underscore?. -- \ ?We jealously reserve the right to be mistaken in our view of | `\ what exists, given that theories often change under pressure | _o__) from further investigation.? ?Thomas W. Clark, 2009 | Ben Finney From rmorgan466 at gmail.com Thu Feb 9 07:41:26 2012 From: rmorgan466 at gmail.com (Rita) Date: Thu, 9 Feb 2012 07:41:26 -0500 Subject: standalone python web server In-Reply-To: <87pqdoutyi.fsf@jubold.box> References: <87pqdoutyi.fsf@jubold.box> Message-ID: yes, I would like to use a framework. I like the twisted method the user posted. Are there any examples of it using a framework, get/post, etc..? On Thu, Feb 9, 2012 at 6:28 AM, Thomas Bach wrote: > Rita writes: > > > I am building a small intranet website and I would like to use > > Python. I was wondering if there was a easy and medium performance > > python based web server available. > > Are you going to use a framework? Most of these ship with a light > web server implementation? You probably want to check these out too? > > I got a pretty robust setup via > + nginx, > + supervisord, > + the web server shipped with Pyramid > > If you want to use the WSGI standard I'd recommend to read > > > http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/deployment.html > > This document describes several possible set ups to serve an WSGI > application? > > > Regards, > vince > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From rodperson at rodperson.com Thu Feb 9 07:45:56 2012 From: rodperson at rodperson.com (Rod Person) Date: Thu, 9 Feb 2012 07:45:56 -0500 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: <20120209074556.00006c72@unknown> On Wed, 08 Feb 2012 16:52:50 -0500 Terry Reedy wrote: > On 2/8/2012 3:14 PM, Todd Whiteman wrote: > > > My name is Todd. I'm the lead developer for Komodo IDE (Interactive > > Development Environment) and Komodo Edit (a free, open-source > > editor) at ActiveState. I wanted to announce that the newest > > version, Komodo 7, has been released: > > This is a pretty good release announcement, but a few questions. > ... > > http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as > Komodo Edit, but it is unclear why only Python editing would be > featured for Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. > > Does K.Edit let me run a program with one key, like F5 in IDLE? > If so, does it leave me in interactive mode (python -i) as IDLE does? > I'm not an ActiveState employee, but I have used Komodo IDE since version 4, on FreeBSD and Windows. The selling point of the IDE is definitely the interactive python debugger which isn't in the editor. It also supports more than python, just in case for some old reason you'd find the need to write Perl, Ruby or TCL code. -- Rod Person http://www.rodperson.com rodperson at rodperson.com 'Silence is a fence around wisdom' From bruno.desthuilliers at gmail.com Thu Feb 9 07:59:17 2012 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 9 Feb 2012 04:59:17 -0800 (PST) Subject: Id of methods References: Message-ID: <779734b6-4f0a-488f-8a0f-75d79aac9e31@ge5g2000vbb.googlegroups.com> On Feb 9, 5:06?am, Chris Angelico wrote: > On Thu, Feb 9, 2012 at 2:48 PM, Emeka wrote: > > > My question is why is it that the id of Boo.daf ?is different from daf's hex > > value in the above dict? > > > daf is not a function, it's a special object for an unbound method. http://wiki.python.org/moin/FromFunctionToMethod From johnoksz at gmail.com Thu Feb 9 08:19:06 2012 From: johnoksz at gmail.com (John Oksz) Date: Thu, 9 Feb 2012 05:19:06 -0800 (PST) Subject: Software tool for stochastic simulation as well as for the stochastic optimization Message-ID: Hello Python World, I am starting work on stochastic approach. I plan to work in decision support field in environmental engineering so I will use both the stochastic simulation as well as the stochastic optimization. I would like to select the best for both approaches software tool. what you suggest ... Matlab ... python ... something else? Any thoughts would be appreciated, John From moky.math at gmail.com Thu Feb 9 09:00:38 2012 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 09 Feb 2012 15:00:38 +0100 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: > Here is my question: I would like to start an in-house library of small > modules to import, for things like error handling/logging. That's easy > enough, but is there a recommended way of naming such modules? I am > concerned about avoiding name clashes with standard modules and site > packages. > > Thanks. > This is not 100% an answer to the question, but you should read that : http://www.python.org/dev/peps/pep-0008/ This explain you WhatCaseToChoose for_naming youVariables. Laurent From roy at panix.com Thu Feb 9 09:01:42 2012 From: roy at panix.com (Roy Smith) Date: Thu, 09 Feb 2012 09:01:42 -0500 Subject: turbogears 1 References: Message-ID: In article , anon hung wrote: > >> Hey guys, someone asked me to maintain his old website, trouble is, > >> it's in python, more trouble is it's in turbogears 1. I'm not fluent > >> in python but all right, I can learn, but this turbogears > >> thing.......... > >> > >> First of all, is it still alive? Looks like turbogears 2 is the most > >> recent version but even that is being abandoned. > > > > Yup, looks dead to me. Hasn't had a release in almost 2 months or a > > commit to the GIT repo in 2 days. Must be nailed to its perch or > > something. > > > > http://turbogears.org/en/current-status > > http://sourceforge.net/p/turbogears2/tg2/commit_browser > > All right, what I got confused about is that they talk about pyramid > these days which will not be turbogears 2 based. > > >> Am I basically given vaporware? Does anyone have any up to date info? > > > > Have you considered Ruby on Rails? > > This is joke, right? :) Yes. From sales at smartbaba.com Thu Feb 9 09:28:28 2012 From: sales at smartbaba.com (Smart Baba Sales) Date: Thu, 9 Feb 2012 06:28:28 -0800 (PST) Subject: Have your own business web Message-ID: Do you know about Smart Baba new offer? Now get your own business customized professional website and start promoting your business. For further details, Follow us at: www.websitedeals.in From nathan.alexander.rice at gmail.com Thu Feb 9 09:36:12 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 09:36:12 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth wrote: > Nathan Rice wrote: > >> I put dicts in sets all the time. ?I just tuple the items, but that >> means you have to re-dict it on the way out to do anything useful with >> it. ?I am too lazy to write a frozendict or import one, but I would >> use it if it was a builtin. >> > I hope you sort the items before putting them in a tuple, otherwise how do > you handle two identical dicts that return their items in a different > order? Two dicts created from the same inputs will return items in the same arbitrary order. As long as you don't insert or delete a key you're fine. Nathan From arnodel at gmail.com Thu Feb 9 09:36:52 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 9 Feb 2012 14:36:52 +0000 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: On 9 February 2012 14:00, Laurent Claessens wrote: > >> Here is my question: I would like to start an in-house library of small >> modules to import, for things like error handling/logging. That's easy >> enough, but is there a recommended way of naming such modules? I am >> concerned about avoiding name clashes with standard modules and site >> packages. >> >> Thanks. >> > > This is not 100% an answer to the question, but you should read that : > http://www.python.org/dev/peps/pep-0008/ The OP mentions PEP 8 in the bit of his message that you *don't* quote. -- Arnaud From duncan.booth at invalid.invalid Thu Feb 9 09:52:17 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 14:52:17 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > On Thu, Feb 9, 2012 at 5:33 AM, Duncan Booth > wrote: >> Nathan Rice wrote: >> >>> I put dicts in sets all the time. ?I just tuple the items, but that >>> means you have to re-dict it on the way out to do anything useful >>> with it. ?I am too lazy to write a frozendict or import one, but I >>> would use it if it was a builtin. >>> >> I hope you sort the items before putting them in a tuple, otherwise >> how d > o >> you handle two identical dicts that return their items in a different >> order? > > Two dicts created from the same inputs will return items in the same > arbitrary order. As long as you don't insert or delete a key you're > fine. > Two dicts that contain the same keys and values may or may not return them in the same order: >>> dict.fromkeys('ia') {'i': None, 'a': None} >>> dict.fromkeys('ai') {'a': None, 'i': None} Would your system count those two dicts as the same? If the sequence in which the keys were added to the dict (and deleted if appropriate) is exactly the same then it is likely but still not guaranteed that they will have the same order. The only ordering guarantee is that within a single dict keys and values will appear in a consistent order so long as you don't add/delete keys between calls. -- Duncan Booth http://kupuguy.blogspot.com From info at egenix.com Thu Feb 9 10:16:59 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Thu, 09 Feb 2012 16:16:59 +0100 Subject: ANN: eGenix mxODBC Zope Database Adapter 2.0.2 Message-ID: <4F33E36B.40001@egenix.com> ________________________________________________________________________ ANNOUNCEMENT mxODBC Zope Database Adapter Version 2.0.2 for Zope and the Plone CMS Available for Zope 2.10 and later on Windows, Linux, Mac OS X, FreeBSD and other platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.0.2-GA.html ________________________________________________________________________ INTRODUCTION The eGenix mxODBC Zope Database Adapter allows you to easily connect your Zope or Plone installation to just about any database backend on the market today, giving you the reliability of the commercially supported eGenix product mxODBC and the flexibility of the ODBC standard as middle-tier architecture. The mxODBC Zope Database Adapter is highly portable, just like Zope itself and provides a high performance interface to all your ODBC data sources, using a single well-supported interface on Windows, Linux, Mac OS X, FreeBSD and other platforms. This makes it ideal for deployment in ZEO Clusters and Zope hosting environments where stability and high performance are a top priority, establishing an excellent basis and scalable solution for your Plone CMS. Product page: http://www.egenix.com/products/zope/mxODBCZopeDA/ ________________________________________________________________________ NEWS We are pleased to announce a new version 2.0.2 of our mxODBC Zope DA product. With the patch level 2.0.2 release we have updated the integrated mxODBC Python Extension to the latest 3.1.1 release, which includes a number of important workarounds for these ODBC drivers: * Oracle 10gR1 and 10gR2 * Oracle 11gR1 and 11gR2 * Teradata 13 * Netezza Due to popular demand, we have also added instructions on how to install mxODBC Zope DA 2.0 with Plone 4.1 and Zope 2.13 - even though this combination is not officially supported by the mxODBC Zope DA 2.0 series: http://www.egenix.com/products/zope/mxODBCZopeDA/#Installation ________________________________________________________________________ UPGRADING Licenses purchased for version 2.0.x of the mxODBC Zope DA will continue to work with the 2.0.2 patch level release. Licenses purchased for version 1.0.x of the mxODBC Zope DA will not work with version 2.0. More information about available licenses is available on the product page: http://www.egenix.com/products/zope/mxODBCZopeDA/#Licensing Compared to the popular mxODBC Zope DA 1.0, version 2.0 offers these enhancements: * Includes mxODBC 3.1 with updated support for many current ODBC drivers, giving you more portability and features for a wider range of database backends. * Mac OS X 10.6 (Snow Leopard) support. * Plone 3.2, 3.3, 4.0 support. Plone 4.1 works as well. * Zope 2.10, 2.11, 2.12 support. Zope 2.13 works as well. * Python 2.4 - 2.6 support. * Zero maintenance support to automatically reconnect the Zope connection after a network or database problem. * More flexible Unicode support with options to work with pure Unicode, plain strings or mixed setups - even for databases that don't support Unicode * Automatic and transparent text encoding and decoding * More flexible date/time support including options to work with Python datetime objects, mxDateTime, strings or tuples * New decimal support to have the Zope DA return decimal column values using Python's decimal objects. * Fully eggified to simplify easy_install and zc.buildout based installation ________________________________________________________________________ MORE INFORMATION For more information on the mxODBC Zope Database Adapter, licensing and download instructions, please visit our web-site: http://www.egenix.com/products/zope/mxODBCZopeDA/ You can buy mxODBC Zope DA licenses online from the eGenix.com shop at: http://shop.egenix.com/ ________________________________________________________________________ Thank you, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 09 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From nathan.alexander.rice at gmail.com Thu Feb 9 10:19:46 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 10:19:46 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: >> Two dicts created from the same inputs will return items in the same >> arbitrary order. ?As long as you don't insert or delete a key you're >> fine. >> > Two dicts that contain the same keys and values may or may not return them > in the same order: > >>>> dict.fromkeys('ia') > {'i': None, 'a': None} >>>> dict.fromkeys('ai') > {'a': None, 'i': None} > > Would your system count those two dicts as the same? > > If the sequence in which the keys were added to the dict (and deleted if > appropriate) is exactly the same then it is likely but still not guaranteed > that they will have the same order. The only ordering guarantee is that > within a single dict keys and values will appear in a consistent order so > long as you don't add/delete keys between calls. As I said, two dictionaries created from the same input will be the same... 'ai' != 'ia'. If I need to hash a dict that I don't know was created in a deterministic order, I'd frozenset(thedict.items()). Nathan From jjposner at optimum.net Thu Feb 9 10:36:38 2012 From: jjposner at optimum.net (John Posner) Date: Thu, 09 Feb 2012 10:36:38 -0500 Subject: what is the difference between @property and method In-Reply-To: References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> Message-ID: <4F33E806.8070700@optimum.net> On 2:59 PM, Devin Jeanpierre wrote: > It is kind of funny that the docs don't ever explicitly say what a > property is. http://docs.python.org/library/functions.html#property -- > Devin Here's a writeup that does: http://wiki.python.org/moin/AlternativeDescriptionOfProperty -John From feliphil at gmx.net Thu Feb 9 11:24:09 2012 From: feliphil at gmx.net (Wolfgang Keller) Date: Thu, 9 Feb 2012 17:24:09 +0100 Subject: Software tool for stochastic simulation as well as for the stochastic optimization References: Message-ID: <20120209172409.19a887eb.feliphil@gmx.net> > I plan to work in decision support field in environmental engineering > so I will use both the stochastic simulation as well as the stochastic > optimization. > I would like to select the best for both approaches software tool. > > what you suggest ... Matlab ... python ... something else? I have no clue whether it does stochastic simulation and optimisation, but R is THE free open-source statistic analysis tool. It does have a Python interface, RPy. And there's a free open-source replacement for Matlab, Scilab. Which has a Python interface as well. Sincerely, Wolfgang -- HOMO HOMINI HOSTIS IN FELIBUS FELICITAS From ian.g.kelly at gmail.com Thu Feb 9 11:35:52 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 09:35:52 -0700 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... That's an implementation detail, not a guarantee. It will hold for current versions of CPython but not necessarily for other Python implementations. From mateusz at loskot.net Thu Feb 9 11:44:33 2012 From: mateusz at loskot.net (mloskot) Date: Thu, 9 Feb 2012 08:44:33 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: <878vkc426c.fsf@benfinney.id.au> References: <878vkc426c.fsf@benfinney.id.au> Message-ID: <1328805873302-4380150.post@n6.nabble.com> Ben Finney-10 wrote > > Mateusz Loskot <mateusz@> writes: > >> So, the following >> >> import xyz >> print(xyz.flag) # OK >> xyz.flag = 0 # error due to no write access > > PEP 8 <URL:http://www.python.org/dev/peps/pep-0008/> gives the style > guide for Python code (strictly for the standard library, but it is > recommended for all Python code). > Ben, That's what I thought really. Thank you for confirming the sanity of the style-powered conventions. Best regards, ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4380150.html Sent from the Python - python-list mailing list archive at Nabble.com. From nathan.alexander.rice at gmail.com Thu Feb 9 11:50:51 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 11:50:51 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> Message-ID: On Thu, Feb 9, 2012 at 11:35 AM, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee. ?It will hold for > current versions of CPython but not necessarily for other Python > implementations. That is true. The implications of the function that creates dictionaries being non-deterministic are a little scary though, so I suspect that it will hold :) Nathan From moky.math at gmail.com Thu Feb 9 12:42:40 2012 From: moky.math at gmail.com (Laurent Claessens) Date: Thu, 09 Feb 2012 18:42:40 +0100 Subject: Naming convention for in-house modules (Newbie question) In-Reply-To: References: Message-ID: <4F340590.6090503@gmail.com> >> This is not 100% an answer to the question, but you should read that : >> http://www.python.org/dev/peps/pep-0008/ > > The OP mentions PEP 8 in the bit of his message that you *don't* quote. Well... I've to sleep. Sorry :( Laurent From sajuptpm at gmail.com Thu Feb 9 12:56:36 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Thu, 9 Feb 2012 09:56:36 -0800 (PST) Subject: Guide to: Learning Python Decorators Message-ID: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Guide to: Learning Python Decorators New Book http://tinyurl.com/python-decorartor From tjreedy at udel.edu Thu Feb 9 13:21:53 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 13:21:53 -0500 Subject: unicode printing on Windows In-Reply-To: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> References: <4f625c3f-77b0-410a-ad63-4acd1a6f1f44@hs8g2000vbb.googlegroups.com> Message-ID: On 2/9/2012 5:46 AM, BlueBird wrote: > Hi, > > The question is not totally related to Python but there is a strong > connection. Everytime that I try to debug some python programs under > Windows, I encounter the issue that things printed on the console > simply break the program because : > 1. My windows console does not support UTF8 The IDLE shell (now) is friendlier to unicode, supporting the entire BMP. So you may have more success loading into an IDLE editor and running from there with F5. Or perhaps execfile in the shell (I never tried this). Of course, import and pdb in the shell work. This all depends on what 'debugging' means to you. > Important information : I am using Python 2.5 I don't know if IDLE was different then. -- Terry Jan Reedy From jkn_gg at nicorp.f9.co.uk Thu Feb 9 13:32:35 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Thu, 9 Feb 2012 10:32:35 -0800 (PST) Subject: multiple namespaces within a single module? Message-ID: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Hello there is it possible to have multiple namespaces within a single python module? I have a small app which is in three or four .py files. For various reasons I would like to (perhaps optionally) combine these into one file. I was hoping that there might be a simple mechanism that would let me do this and maintain the namespaces referred to: so that the 'combined' file would look something like # # not real python # # originally from a.py with namespace a: def function(): pass # ... # originally from b.py with namespace b: def function(): pass # originally from main module a.function() b.function() etc. Is there anything like this available? Thanks J^n From duncan.booth at invalid.invalid Thu Feb 9 13:47:20 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Feb 2012 18:47:20 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: Nathan Rice wrote: > As I said, two dictionaries created from the same input will be the > same... 'ai' != 'ia'. If I need to hash a dict that I don't know was > created in a deterministic order, I'd frozenset(thedict.items()). > Fair enough, the idea scares me, but it's your code and your risk. BTW, make sure that if you ever copy any of those dictionaries they all get copied the same number of times as simply copying a dict can change the key order. >>> dict.fromkeys('me') {'e': None, 'm': None} >>> dict(dict.fromkeys('me')) {'m': None, 'e': None} >>> dict(dict(dict.fromkeys('me'))) {'e': None, 'm': None} -- Duncan Booth http://kupuguy.blogspot.com From someone at someplace.invalid Thu Feb 9 13:53:54 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 18:53:54 +0000 (UTC) Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) References: Message-ID: On Thu, 09 Feb 2012 14:36:52 +0000, Arnaud Delobelle wrote: > On 9 February 2012 14:00, Laurent Claessens wrote: >> >>> Here is my question: I would like to start an in-house library of >>> small modules to import, for things like error handling/logging. >>> That's easy enough, but is there a recommended way of naming such >>> modules? I am concerned about avoiding name clashes with standard >>> modules and site packages. >>> >>> Thanks. >>> >>> >> This is not 100% an answer to the question, but you should read that : >> http://www.python.org/dev/peps/pep-0008/ > > The OP mentions PEP 8 in the bit of his message that you *don't* quote. Thank you for that Arnaud, and thanks to Chris R. I'm going along with Chris's suggestion for the moment. One issue I have run into, which may or may not be a problem: I am finding that modules in the in-house "library" package sometimes have to import modules like sys and os, which are also imported by the "calling" module. Is this a problem or an overhead, or does it just result in two names for the same object? Thanks again. From arnodel at gmail.com Thu Feb 9 13:55:53 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 9 Feb 2012 18:55:53 +0000 Subject: Guide to: Learning Python Decorators In-Reply-To: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: On Feb 9, 2012 6:00 PM, "sajuptpm" wrote: > > Guide to: Learning Python Decorators > New Book http://tinyurl.com/python-decorartor A whole book about decorators? Cool. I'm going to start writing books to. I'll start with 'The Python print statement'. Then to be cutting edge I'll follow with 'The Python print function'. -- Arnaud -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 9 14:02:03 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 12:02:03 -0700 Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster wrote: > One issue I have run into, which may or may not be a problem: I am > finding that modules in the in-house "library" package sometimes have to > import modules like sys and os, which are also imported by the "calling" > module. Is this a problem or an overhead, or does it just result in two > names for the same object? Two names for the same object. When a module is imported, the module object is stored in the sys.modules dict. Further imports of the same module just return the same module object from sys.modules. From tjreedy at udel.edu Thu Feb 9 14:15:45 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 14:15:45 -0500 Subject: Read-only attribute in module In-Reply-To: References: Message-ID: On 2/9/2012 6:43 AM, Mateusz Loskot wrote: > Hi, > > I'm implementing Python 3 extension using the Python C API. I am > familiar with defining new types, implementing get/set for > attributes, etc. > > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Not that I know of. Python intentionally leaves modules mutable even after the code has executed so they can be monkey-patched from outside. The argument for is that it is unusual to do so but sometimes very useful and necessary. The main argument against is that it prevents optimizations that would make code in modules run faster. > import xyz print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access Why prevent that? If you called it 'FLAG', that would indicate that it is a constant that should not be changed. While Python make some effort to prevent bugs, it is generally a 'consenting adults' language. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 14:18:33 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 14:18:33 -0500 Subject: what is the difference between @property and method In-Reply-To: <4F33E806.8070700@optimum.net> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> <4F33E806.8070700@optimum.net> Message-ID: On 2/9/2012 10:36 AM, John Posner wrote: > On 2:59 PM, Devin Jeanpierre wrote: > > >> It is kind of funny that the docs don't ever explicitly say what a >> property is. http://docs.python.org/library/functions.html#property -- >> Devin > > Here's a writeup that does: > http://wiki.python.org/moin/AlternativeDescriptionOfProperty Suggested doc changes on the tracker get reviewed, and often applied. -- Terry Jan Reedy From __peter__ at web.de Thu Feb 9 14:33:27 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 20:33:27 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: jkn wrote: > is it possible to have multiple namespaces within a single python > module? Unless you are abusing classes I don't think so. > I have a small app which is in three or four .py files. For various > reasons I would like to (perhaps optionally) combine these into one > file. Rename your main script into __main__.py, put it into a zip file together with the other modules and run that. From breamoreboy at yahoo.co.uk Thu Feb 9 14:35:13 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 09 Feb 2012 19:35:13 +0000 Subject: Read-only attribute in module In-Reply-To: References: Message-ID: On 09/02/2012 11:43, Mateusz Loskot wrote: > Hi, > > I'm implementing Python 3 extension using the Python C API. > I am familiar with defining new types, implementing get/set for attributes, etc. > > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? > > So, the following > > import xyz > print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access > > Best regards, There's a recipe by Alex Martelli here http://code.activestate.com/recipes/65207-constants-in-python/ but most people wouldn't bother with it. As others have said simply use THIS_IS_A_CONSTANT. -- Cheers. Mark Lawrence. From someone at someplace.invalid Thu Feb 9 14:40:41 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 19:40:41 +0000 (UTC) Subject: Apparent "double imports" (was: Naming convention for in-house modules (Newbie question)) References: Message-ID: On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster > wrote: >> One issue I have run into, which may or may not be a problem: I am >> finding that modules in the in-house "library" package sometimes have >> to import modules like sys and os, which are also imported by the >> "calling" >> module. Is this a problem or an overhead, or does it just result in two >> names for the same object? > > Two names for the same object. When a module is imported, the module > object is stored in the sys.modules dict. Further imports of the same > module just return the same module object from sys.modules. Excellent! It seems it is not a problem at all, then. Thank you. From d at davea.name Thu Feb 9 15:05:52 2012 From: d at davea.name (Dave Angel) Date: Thu, 09 Feb 2012 15:05:52 -0500 Subject: Apparent "double imports" In-Reply-To: References: Message-ID: <4F342720.1050601@davea.name> On 02/09/2012 02:40 PM, HoneyMonster wrote: > On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster >> wrote: >>> One issue I have run into, which may or may not be a problem: I am >>> finding that modules in the in-house "library" package sometimes have >>> to import modules like sys and os, which are also imported by the >>> "calling" >>> module. Is this a problem or an overhead, or does it just result in two >>> names for the same object? >> Two names for the same object. When a module is imported, the module >> object is stored in the sys.modules dict. Further imports of the same >> module just return the same module object from sys.modules. > Excellent! It seems it is not a problem at all, then. Thank you. Just to add a little subtlety, there is a problem with mutually recursive imports. If module aaa imports module bbb, and modole bbb imports aaa, there can be some problems. Most can be avoided by putting the imports right at the beginning of each file, so no work has been done before doing the imports. Then by the time some code tries to use them, they're all resolved. One exception is if you try to import the file that is your script file. This one is made into a module by the special name of __main__, and if you import it using the original name, you'll have two copies around. That can lead to some very interesting anomalies. Better is to make sure no loops exist in the importing tree, which is a desirable structuring goal anyway. When two modules need each other, try to either move the common stuff to a 3rd module they each import, or do something with callbacks or other mechanism that reflects what's really going on. Of cours that last paragraph is strictly my own opinion. -- DaveA From jenn.duerr at gmail.com Thu Feb 9 15:08:41 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 12:08:41 -0800 (PST) Subject: Formate a number with commas Message-ID: How do you format a number to print with commas? Some quick searching, i came up with: >>> import locale >>> locale.setlocale(locale.LC_ALL, "") >>> locale.format('%d', 2348721, True) '2,348,721' I'm a perpetual novice, so just looking for better, slicker, more proper, pythonic ways to do this. Thanks! From neilc at norwich.edu Thu Feb 9 15:17:38 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 9 Feb 2012 20:17:38 GMT Subject: Formate a number with commas References: Message-ID: <9pinv2F5hpU2@mid.individual.net> On 2012-02-09, noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") >>>> locale.format('%d', 2348721, True) > '2,348,721' > > I'm a perpetual novice, so just looking for better, slicker, > more proper, pythonic ways to do this. I think you've found an excellent way to do it. -- Neil Cerutti From tjreedy at udel.edu Thu Feb 9 15:28:40 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 15:28:40 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: On 2/9/2012 1:55 PM, Arnaud Delobelle wrote: > > On Feb 9, 2012 6:00 PM, "sajuptpm" > wrote: > > > > Guide to: Learning Python Decorators > > New Book http://tinyurl.com/python-decorartor Which goes to Amazon, perhaps with an Amazon Associate id embedded. > A whole book about decorators? Cool. I'm going to start writing books > to. I'll start with 'The Python print statement'. Then to be cutting > edge I'll follow with 'The Python print function'. Sarcasm aside, it is a small (200K) digital book at a small price ($4). According to the 5-star reviews, it is not as trivial as the title indicates. It starts with explaining functions, scope, parameters, nesting, *args, **kwds, and nesting. In other words, everything one needs to know to understand decorators. It is based on tutorials given at PyCon and elsewhere. I plan to borrow it and take a look. A book on Printing with Python that clearly explained everything one needs to know about characters, glyphs, fonts, bytes, unicode, encodings, and serialization in order to print would also be worthwhile. For a bonus, add in something about console windows, OS differences, and printers. -- Terry Jan Reedy From SMac2347 at comcast.net Thu Feb 9 15:32:35 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Thu, 9 Feb 2012 12:32:35 -0800 (PST) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: <10d15214-1fd8-4b80-8384-c0b291c6976d@h3g2000yqe.googlegroups.com> On Feb 7, 3:16?pm, Peter Otten <__pete... at web.de> wrote: > SMac2... at comcast.net wrote: > > xls_files ? = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and filename if > necessary. > > > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") > > If you paste the directory name literal into the interactive interpreter > you'll be surprised: > > >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' > > "\09" is intrpreted as chr(9). Use a raw string to prevent Python from > interpreting a backslash as the start of an escape sequence > > >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' > > or use forward slashes as directory separators. Peter, thanks so much for your help, your suggestions were spot on. So now my program runs and is able to find and process the files correctly, but I end up getting the following message: Traceback (most recent call last): File "C:/Documents and Settings/smacdon/My Documents/ excel_merge_files_indirectory v2.py", line 49, in merge_xls(in_dir=r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") File "C:/Documents and Settings/smacdon/My Documents/ excel_merge_files_indirectory v2.py", line 36, in merge_xls merged_book.save(out_file) File "C:\Python27\lib\site-packages\xlwt\Workbook.py", line 634, in save doc.save(filename, self.get_biff_data()) File "C:\Python27\lib\site-packages\xlwt\CompoundDoc.py", line 507, in save f = open(file_name_or_filelike_obj, 'wb') TypeError: file() argument 1 must be encoded string without NULL bytes, not str If I am interpreting correctly, am I to understand that it would appear the issue is tracing back to functions in the xlwt module? If so, what can I do to fix this? Again, any and all help is appreciated! From SMac2347 at comcast.net Thu Feb 9 15:36:45 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Thu, 9 Feb 2012 12:36:45 -0800 (PST) Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> Message-ID: On Feb 7, 3:16?pm, Peter Otten <__pete... at web.de> wrote: > SMac2... at comcast.net wrote: > > xls_files ? = glob.glob(in_dir + "*.xls") > > Try changing that to > > pattern = os.path.join(in_dir, "*.xls") > xls_files = glob.glob(pattern) > > os.path.join() inserts a (back)slash between directory and filename if > necessary. > > > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS") > > If you paste the directory name literal into the interactive interpreter > you'll be surprised: > > >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' > > "\09" is intrpreted as chr(9). Use a raw string to prevent Python from > interpreting a backslash as the start of an escape sequence > > >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" > > 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' > > or use forward slashes as directory separators. Disregard my last post, I was able to figure it out, I also had to cover the out_file file name into a raw string as well. Thanks again for all the help!!! From __peter__ at web.de Thu Feb 9 15:39:00 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 21:39 +0100 Subject: Formate a number with commas References: Message-ID: noydb wrote: > How do you format a number to print with commas? > > Some quick searching, i came up with: > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") >>>> locale.format('%d', 2348721, True) > '2,348,721' > > > I'm a perpetual novice, so just looking for better, slicker, more > proper, pythonic ways to do this. >>> import locale >>> locale.setlocale(locale.LC_ALL, "") 'de_DE.UTF-8' >>> "{:n}".format(1234) # locale-aware '1.234' >>> "{:,d}".format(1234) # always a comma '1,234' From clp2 at rebertia.com Thu Feb 9 15:51:58 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 12:51:58 -0800 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: > noydb wrote: > >> How do you format a number to print with commas? >> >> Some quick searching, i came up with: >> >>>>> import locale >>>>> locale.setlocale(locale.LC_ALL, "") >>>>> locale.format('%d', 2348721, True) >> '2,348,721' >> >> >> I'm a perpetual novice, so just looking for better, slicker, more >> proper, pythonic ways to do this. > >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") > 'de_DE.UTF-8' >>>> "{:n}".format(1234) # locale-aware > '1.234' >>>> "{:,d}".format(1234) # always a comma > '1,234' The latter requires Python 3.1+ and is courtesy PEP 378 (http://www.python.org/dev/peps/pep-0378/ ). Cheers, Chris From __peter__ at web.de Thu Feb 9 16:07:58 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:07:58 +0100 Subject: Reading files in from the proper directory References: <9bfb3e39-2bc6-4399-90cc-1c53aa06265e@h6g2000yqk.googlegroups.com> <10d15214-1fd8-4b80-8384-c0b291c6976d@h3g2000yqe.googlegroups.com> Message-ID: SMac2347 at comcast.net wrote: > On Feb 7, 3:16 pm, Peter Otten <__pete... at web.de> wrote: >> SMac2... at comcast.net wrote: >> > xls_files = glob.glob(in_dir + "*.xls") >> >> Try changing that to >> >> pattern = os.path.join(in_dir, "*.xls") >> xls_files = glob.glob(pattern) >> >> os.path.join() inserts a (back)slash between directory and filename if >> necessary. >> >> > merge_xls(in_dir="C:\Documents and Settings\smacdon\Desktop\09 >> > Aggregate JWS") >> >> If you paste the directory name literal into the interactive interpreter >> you'll be surprised: >> >> >>> "C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" >> >> 'C:\\Documents and Settings\\smacdon\\Desktop\x009 Aggregate JWS' >> >> "\09" is intrpreted as chr(9). Use a raw string to prevent Python from Sorry, I was wrong here. "\09" is actually "\0" (i. e. chr(0)) followed by "9". Escape sequences starting with 0 are octal numbers in Python 2 and thus may never contain digits > 7. >> interpreting a backslash as the start of an escape sequence >> >> >>> r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS" >> >> 'C:\\Documents and Settings\\smacdon\\Desktop\\09 Aggregate JWS' >> >> or use forward slashes as directory separators. > > Peter, thanks so much for your help, your suggestions were spot on. So > now my program runs and is able to find and process the files > correctly, but I end up getting the following message: > > Traceback (most recent call last): > File "C:/Documents and Settings/smacdon/My Documents/ > excel_merge_files_indirectory v2.py", line 49, in > merge_xls(in_dir=r"C:\Documents and Settings\smacdon\Desktop\09 > Aggregate JWS") > File "C:/Documents and Settings/smacdon/My Documents/ > excel_merge_files_indirectory v2.py", line 36, in merge_xls > merged_book.save(out_file) > File "C:\Python27\lib\site-packages\xlwt\Workbook.py", line 634, in > save > doc.save(filename, self.get_biff_data()) > File "C:\Python27\lib\site-packages\xlwt\CompoundDoc.py", line 507, > in save > f = open(file_name_or_filelike_obj, 'wb') > TypeError: file() argument 1 must be encoded string without NULL > bytes, not str > > > If I am interpreting correctly, am I to understand that it would > appear the issue is tracing back to functions in the xlwt module? If > so, what can I do to fix this? Again, any and all help is appreciated! You probably forgot to convert the default value for out_file into a raw string: def merge_xls(in_dir, out_file= r"C:\Documents and Settings\smacdon\Desktop\09 Aggregate JWS\09_merged_data.xls"): "\0" is therefore interpreted as chr(0) which marks the end of a C string and may not occur in a file name. chr(0) is called "NULL byte" in the error message you get. From ethan at stoneleaf.us Thu Feb 9 16:12:42 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 13:12:42 -0800 Subject: multiple namespaces within a single module? In-Reply-To: References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: <4F3436CA.2020800@stoneleaf.us> Peter Otten wrote: > jkn wrote: > >> is it possible to have multiple namespaces within a single python >> module? > > Unless you are abusing classes I don't think so. Speaking of... class NameSpace(object): def __init__(self, globals): self.globals = globals self.current_keys = list(globals.keys()) def __enter__(self): return self def __exit__(self, *args): new_items = [] for key, value in self.globals.items(): if key not in self.current_keys and value is not self: new_items.append((key, value)) for key, value in new_items: setattr(self, key, value) del self.globals[key] if __name__ == '__main__': with NameSpace(globals()) as a: def function(): print('inside a!') with NameSpace(globals()) as b: def function(): print('inside b!') a.function() b.function() print(vars()) The NameSpace objects do *not* get their own copy of globals(), but for functions, etc., it should work fine. As a bonus the above code works for both 2.x and 3.x. ~Ethan~ From alain at dpt-info.u-strasbg.fr Thu Feb 9 16:13:10 2012 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Thu, 09 Feb 2012 22:13:10 +0100 Subject: Formate a number with commas References: Message-ID: <87wr7v1zix.fsf@dpt-info.u-strasbg.fr> noydb writes: > How do you format a number to print with commas? >>>> import locale >>>> locale.setlocale(locale.LC_ALL, "") This sets the locale according to the environment (typically LANG---I'm talking about linux, don't know others). >>>> locale.format('%d', 2348721, True) > '2,348,721' This would not give the same result in environments with other locales (typically de or fr or ...) Anyway, it's probably the right thing to do: the user will get numbers written according to its own locale. If you really want commas whatever locale you're running in, you will need to use setlocale to change number formatting to a locale that uses commas. For instance: locale.setlocale(LC_NUMERIC,"en_US.utf8") locale.format('%d', 2348721, True) -- Alain. From __peter__ at web.de Thu Feb 9 16:16:03 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:16:03 +0100 Subject: Formate a number with commas References: Message-ID: Chris Rebert wrote: > On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: >>>>> import locale >>>>> locale.setlocale(locale.LC_ALL, "") >> 'de_DE.UTF-8' >>>>> "{:n}".format(1234) # locale-aware >> '1.234' >>>>> "{:,d}".format(1234) # always a comma >> '1,234' > > The latter requires Python 3.1+ and is courtesy PEP 378 > (http://www.python.org/dev/peps/pep-0378/ ). I actually ran the above session in 2.7, so that should do, too. http://docs.python.org/whatsnew/2.7.html#pep-378-format-specifier-for- thousands-separator From a.france.mailinglists at gmail.com Thu Feb 9 16:41:12 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Thu, 09 Feb 2012 22:41:12 +0100 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <4F343D78.1010800@gmail.com> On 02/09/2012 07:55 PM, Arnaud Delobelle wrote: > > > On Feb 9, 2012 6:00 PM, "sajuptpm" > wrote: > > > > Guide to: Learning Python Decorators > > New Book http://tinyurl.com/python-decorartor > > A whole book about decorators? Cool. I'm going to start writing books > to. I'll start with 'The Python print statement'. Then to be cutting > edge I'll follow with 'The Python print function'. > > -- > Arnaud > > > How many pages is that? The amazon page conveniently left that off. -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 9 16:53:16 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 09 Feb 2012 22:53:16 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> Message-ID: Ethan Furman wrote: > Peter Otten wrote: >> jkn wrote: >> >>> is it possible to have multiple namespaces within a single python >>> module? >> >> Unless you are abusing classes I don't think so. > > > Speaking of... > > > class NameSpace(object): > def __init__(self, globals): > self.globals = globals > self.current_keys = list(globals.keys()) > def __enter__(self): > return self > def __exit__(self, *args): > new_items = [] > for key, value in self.globals.items(): > if key not in self.current_keys and value is not self: > new_items.append((key, value)) > for key, value in new_items: > setattr(self, key, value) > del self.globals[key] > > if __name__ == '__main__': > with NameSpace(globals()) as a: > def function(): > print('inside a!') > with NameSpace(globals()) as b: > def function(): > print('inside b!') > > a.function() > b.function() > print(vars()) > > > The NameSpace objects do *not* get their own copy of globals(), but for > functions, etc., it should work fine. As a bonus the above code works > for both 2.x and 3.x. Hm, what about with NameSpace(globals()) as a: x = "inside a!" def function(): print(x) with NameSpace(globals()) as b: x = "inside b!" def function(): print(x) x = "inside main!" a.function() b.function() From someone at someplace.invalid Thu Feb 9 16:57:09 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 9 Feb 2012 21:57:09 +0000 (UTC) Subject: Apparent "double imports" References: Message-ID: On Thu, 09 Feb 2012 15:05:52 -0500, Dave Angel wrote: > On 02/09/2012 02:40 PM, HoneyMonster wrote: >> On Thu, 09 Feb 2012 12:02:03 -0700, Ian Kelly wrote: >> >>> On Thu, Feb 9, 2012 at 11:53 AM, HoneyMonster >>> wrote: >>>> One issue I have run into, which may or may not be a problem: I am >>>> finding that modules in the in-house "library" package sometimes have >>>> to import modules like sys and os, which are also imported by the >>>> "calling" >>>> module. Is this a problem or an overhead, or does it just result in >>>> two names for the same object? >>> Two names for the same object. When a module is imported, the module >>> object is stored in the sys.modules dict. Further imports of the same >>> module just return the same module object from sys.modules. >> Excellent! It seems it is not a problem at all, then. Thank you. > Just to add a little subtlety, there is a problem with mutually > recursive imports. If module aaa imports module bbb, and modole bbb > imports aaa, there can be some problems. Most can be avoided by putting > the imports right at the beginning of each file, so no work has been > done before doing the imports. Then by the time some code tries to use > them, they're all resolved. One exception is if you try to import the > file that is your script file. This one is made into a module by the > special name of __main__, and if you import it using the original name, > you'll have two copies around. That can lead to some very interesting > anomalies. > > Better is to make sure no loops exist in the importing tree, which is a > desirable structuring goal anyway. When two modules need each other, > try to either move the common stuff to a 3rd module they each import, or > do something with callbacks or other mechanism that reflects what's > really going on. > > Of cours that last paragraph is strictly my own opinion. Thanks, Dave. I'm sure I won't have a problem with circular imports. The structure I have in mind is: A package (say ihlib) consisting of in-house "library" routines for local use. The directory above ihlib will be added to PYTHONPATH, so that imports can find ihlib. "Top level" modules will import ihlib.blah as necessary in order to avoid code duplication amongst them. From clp2 at rebertia.com Thu Feb 9 17:12:35 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 14:12:35 -0800 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On Thu, Feb 9, 2012 at 1:16 PM, Peter Otten <__peter__ at web.de> wrote: > Chris Rebert wrote: >> On Thu, Feb 9, 2012 at 12:39 PM, Peter Otten <__peter__ at web.de> wrote: >>>>>> import locale >>>>>> locale.setlocale(locale.LC_ALL, "") >>> 'de_DE.UTF-8' >>>>>> "{:n}".format(1234) # locale-aware >>> '1.234' >>>>>> "{:,d}".format(1234) # always a comma >>> '1,234' >> >> The latter requires Python 3.1+ and is courtesy PEP 378 >> (http://www.python.org/dev/peps/pep-0378/ ). > > I actually ran the above session in 2.7, so that should do, too. > > http://docs.python.org/whatsnew/2.7.html#pep-378-format-specifier-for- > thousands-separator Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it was added in 3.1 (Guido's backporting time machine messes with "causality"). Both statements are completely technically correct, but misleading when not taken together. Cheers, Chris From ethan at stoneleaf.us Thu Feb 9 17:25:46 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 14:25:46 -0800 Subject: multiple namespaces within a single module? In-Reply-To: References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> Message-ID: <4F3447EA.6070601@stoneleaf.us> Peter Otten wrote: > Hm, what about > > with NameSpace(globals()) as a: > x = "inside a!" > def function(): > print(x) > with NameSpace(globals()) as b: > x = "inside b!" > def function(): > print(x) > > x = "inside main!" > a.function() > b.function() > > It would have to be `a.x = ...` and `b.x = ...` with corresponding `print(a.x)` and `print(b.x)`. Hrm -- and functions/classes/etc would have to refer to each other that way as well inside the namespace... not sure I'm in love with that... ~Ethan~ From hobson42 at gmail.com Thu Feb 9 17:43:09 2012 From: hobson42 at gmail.com (Ian) Date: Thu, 09 Feb 2012 22:43:09 +0000 Subject: Guide to: Learning Python Decorators In-Reply-To: <4F343D78.1010800@gmail.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> Message-ID: <4F344BFD.9050200@gmail.com> On 09/02/2012 21:41, Aaron France wrote: > How many pages is that? The amazon page conveniently left that off. There is an average of 5.1 chars per word in English, and usually about 350 words an A4 page. The 215K file is a) Compressed - typically by 60% b) Contains simple html and images as its source. c) Must contain the cover image. As a *very* rough guess, that means the files expands to 344K. Remove the cover image at 250-300kb leaves 44 to 94KB That is 8700 words to 18400 words or approx 25 to 50 pages. But that is *very* *very* rough. Regards Ian From jjposner at optimum.net Thu Feb 9 17:57:42 2012 From: jjposner at optimum.net (John Posner) Date: Thu, 09 Feb 2012 17:57:42 -0500 Subject: Formate a number with commas In-Reply-To: References: Message-ID: <4F344F66.7040206@optimum.net> On 2:59 PM, noydb wrote: > How do you format a number to print with commas? I would readily admit that both the "locale" module and "format" method are preferable to this regular expression, which certainly violates the "readability counts" dictum: r"(?<=\d)(?=(\d\d\d)+$)" # python 2.6.6 import re find_blocks = re.compile(r"(?<=\d)(?=(\d\d\d)+$)") for numstr in "1 12 123 1234 12345 123456 1234567 12345678".split(): print find_blocks.sub("," , numstr) output is: 1 12 123 1,234 12,345 123,456 1,234,567 12,345,678 -John From hobson42 at gmail.com Thu Feb 9 18:09:07 2012 From: hobson42 at gmail.com (Ian) Date: Thu, 09 Feb 2012 23:09:07 +0000 Subject: Want to improve my code. Message-ID: <4F345213.8060807@gmail.com> Hi all, I'm using lxml etree, and have written a routine to remove nodes in the parsed tree. Typically, I load html, and remove tags, so I am moving the font tags children up and moving the text and tail data about. The code of the deleteElem routine is here http://snipt.org/GSoo0 It troubles me that there is so much repetition in the lines that call joiner. How can I improve the code? Regards Ian From jkn_gg at nicorp.f9.co.uk Thu Feb 9 18:24:58 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Thu, 9 Feb 2012 15:24:58 -0800 (PST) Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> Message-ID: <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Hi Peter On Feb 9, 7:33?pm, Peter Otten <__pete... at web.de> wrote: > jkn wrote: > > ? ? is it possible to have multiple namespaces within a single python > > module? > > Unless you are abusing classes I don't think so. > > > I have a small app which is in three or four .py files. For various > > reasons I would like to (perhaps optionally) combine these into one > > file. > > Rename your main script into __main__.py, put it into a zip file together > with the other modules and run that. Hmm ... thanks for mentioning this feature, I didn't know of it before. Sounds great, except that I gather it needs Python >2.5? I'm stuck with v2.4 at the moment unfortunately... J^n From ethan at stoneleaf.us Thu Feb 9 19:05:41 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 09 Feb 2012 16:05:41 -0800 Subject: multiple namespaces within a single module? In-Reply-To: <4F3447EA.6070601@stoneleaf.us> References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> <4F3447EA.6070601@stoneleaf.us> Message-ID: <4F345F55.8050300@stoneleaf.us> Ethan Furman wrote: > Hrm -- and functions/classes/etc would have to refer to each other that > way as well inside the namespace... not sure I'm in love with that... Not sure I hate it, either. ;) Slightly more sophisticated code: class NameSpace(object): def __init__(self, current_globals): self.globals = current_globals self.saved_globals = current_globals.copy() def __enter__(self): return self def __exit__(self, *args): new_items = [] for key, value in self.globals.items(): if (key not in self.saved_globals and value is not self or key in self.saved_globals and value != self.saved_globals[key]): new_items.append((key, value)) for key, value in new_items: setattr(self, key, value) del self.globals[key] self.globals.update(self.saved_globals) if __name__ == '__main__': x = 'inside main!' with NameSpace(globals()) as a: x = 'inside a?' def fn1(): print(a.x) with NameSpace(globals()) as b: x = 'inside b?' def fn1(): print(b.x) def fn2(): print('hello!') b.fn1() y = 'still inside main' a.fn1() b.fn1() print(x) print(y) ~Ethan~ From jenn.duerr at gmail.com Thu Feb 9 19:30:53 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 16:30:53 -0800 (PST) Subject: round down to nearest number Message-ID: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> How do you round down ALWAYS to nearest 100? Like, if I have number 3268, I want that rounded down to 3200. I'm doing my rounding like >>> round(3268, -2) But, how to round DOWN? From ian.g.kelly at gmail.com Thu Feb 9 19:47:09 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 17:47:09 -0700 Subject: round down to nearest number In-Reply-To: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:30 PM, noydb wrote: > How do you round down ALWAYS to nearest 100? ?Like, if I have number > 3268, I want that rounded down to 3200. ?I'm doing my rounding like >>>> round(3268, -2) > But, how to round DOWN? >>> 3268 // 100 * 100 3200 For more complicated cases, Decimal objects allow you to specify alternate rounding modes. From steve+comp.lang.python at pearwood.info Thu Feb 9 20:04:41 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 01:04:41 GMT Subject: Read-only attribute in module References: <878vkc426c.fsf@benfinney.id.au> Message-ID: <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 23:32:59 +1100, Ben Finney wrote: > Mateusz Loskot writes: > >> I'm wondering, is there any mean to implement attribute in module scope >> which is read-only? > > Python is designed by and for consenting adults. Rather than > restricting, instead use conventions to make your intent clear to the > user of your library. Oh I agree. The convention I want to use to make my intent clear is the same convention used for the rest of Python: a runtime exception. I find this "consenting adults" argument less than convincing. We already have constants in Python -- every int and float and string is a constant. You can't modify the object 1 to have the value 42, and for very good reason, "consenting adults" be damned. What we don't have is *named* constants. Python has no shortage of read-only values and members, e.g.: >>> class A(object): ... pass ... >>> A.__dict__ = {} Traceback (most recent call last): File "", line 1, in AttributeError: attribute '__dict__' of 'type' objects is not writable Consider this: If you pass an int to len(), you get a runtime error telling you that you did something wrong. Does this violate "consenting adults"? No, if you want to, you can monkey-patch len to accept ints, but you have to work at it. The normal behaviour is to get an error, not some arbitrary but meaningless behaviour. You certainly don't get told to use a naming convention (Hungarian notation, perhaps) to avoid passing the wrong value to len(). If you assign to something which is intended to be constant, you don't get an exception telling you that you made a mistake. Instead, you get unspecified (but almost certainly incorrect) behaviour in the module, and told to use a naming convention to remind you not to screw up. The excuse given is that Python is for "consenting adults", but I don't believe it. I believe that the real reason is that it is hard to introduce named constants to Python, and rather than solve that hard problem, people just whitewash the issue and pretend that it's a feature. It's not a feature, it's a wart. There is no conceivable use-case for allowing math.pi = 2.5 to succeed. Python happily violates "consenting adults" all over the place. We have properties, which can easily create read-only and write-once attributes. We have descriptors which can be used for the same. We have immutable types, and constant values, but not constant names. Python can enforce all common software contracts I can think of, except the contract that a name will be set to a specific value. And that is, in my opinion, a weakness in Python. -- Steven From jenn.duerr at gmail.com Thu Feb 9 20:23:46 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 17:23:46 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: hmmm, okay. So how would you round UP always? Say the number is 3219, so you want 3300 returned. From steve+comp.lang.python at pearwood.info Thu Feb 9 20:24:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 01:24:57 GMT Subject: frozendict References: <4F332007.9080800@wisc.edu> Message-ID: <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice > wrote: >> As I said, two dictionaries created from the same input will be the >> same... > > That's an implementation detail, not a guarantee. It will hold for > current versions of CPython but not necessarily for other Python > implementations. That day may be sooner than you think. It is very likely that in Python 3.3, dict order will be randomized on creation as a side-effect of adding a random salt to hashes to prevent a serious vulnerability in dicts. http://securitytracker.com/id/1026478 http://bugs.python.org/issue13703 If there is anyone still assuming that dicts have a predictable order, they're going to be in for a nasty surprise one of these days. -- Steven From ckaynor at zindagigames.com Thu Feb 9 20:40:12 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 9 Feb 2012 17:40:12 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always? Say the number is 3219, so you want > 3300 returned. > You may want to look into the mathematical floor and ceiling functions[1]. Python exposes them in the math module as floor and ceil[2]. [1] http://en.wikipedia.org/wiki/Floor_and_ceiling_functions [2] http://docs.python.org/library/math.html#math.floor and http://docs.python.org/library/math.html#math.ceil > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckaynor at zindagigames.com Thu Feb 9 20:41:51 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 9 Feb 2012 17:41:51 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:40 PM, Chris Kaynor wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > >> hmmm, okay. >> >> So how would you round UP always? Say the number is 3219, so you want >> 3300 returned. >> > > You may want to look into the mathematical floor and ceiling functions[1]. > Python exposes them in the math module as floor and ceil[2]. > > [1] http://en.wikipedia.org/wiki/Floor_and_ceiling_functions > [2] http://docs.python.org/library/math.html#math.floor and > http://docs.python.org/library/math.html#math.ceil > > I should have added, you can use multiplication and division to apply those functions to other digits rather than the base one. For example, multiply by 10, floor, divide by ten, will floor to one decimal point. > -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Feb 9 20:43:58 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 9 Feb 2012 17:43:58 -0800 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > hmmm, okay. > > So how would you round UP always? ?Say the number is 3219, so you want > 3300 returned. http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 Thus: (3219 + 99) // 100 Slight tangent: Beware negative numbers when using // or %. Cheers, Chris From ian.g.kelly at gmail.com Thu Feb 9 21:00:37 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 19:00:37 -0700 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On Thu, Feb 9, 2012 at 6:43 PM, Chris Rebert wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: >> hmmm, okay. >> >> So how would you round UP always? ?Say the number is 3219, so you want >> 3300 returned. > > http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 > > Thus: (3219 + 99) // 100 > > Slight tangent: Beware negative numbers when using // or %. There's no problem with negative numbers here, as long as you actually want to round *up* or *down*, as opposed to away from zero or toward zero. From jenn.duerr at gmail.com Thu Feb 9 21:25:56 2012 From: jenn.duerr at gmail.com (noydb) Date: Thu, 9 Feb 2012 18:25:56 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: That {>>> (3219 + 99) // 100} doesnt work if the number is other then 4 digits. (for rounding up to nearest 100): >>> (3219 + 99)//100 33 >>> (3289 + 99)//100 33 >>> (328678 + 99)//100 3287 >>> (328 + 99)//100 4 From nathan.alexander.rice at gmail.com Thu Feb 9 21:30:46 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Thu, 9 Feb 2012 21:30:46 -0500 Subject: frozendict In-Reply-To: <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Feb 9, 2012 at 8:24 PM, Steven D'Aprano wrote: > On Thu, 09 Feb 2012 09:35:52 -0700, Ian Kelly wrote: > >> On Thu, Feb 9, 2012 at 8:19 AM, Nathan Rice >> wrote: >>> As I said, two dictionaries created from the same input will be the >>> same... >> >> That's an implementation detail, not a guarantee. ?It will hold for >> current versions of CPython but not necessarily for other Python >> implementations. > > That day may be sooner than you think. It is very likely that in Python > 3.3, dict order will be randomized on creation as a side-effect of adding > a random salt to hashes to prevent a serious vulnerability in dicts. > > http://securitytracker.com/id/1026478 > > http://bugs.python.org/issue13703 > > > If there is anyone still assuming that dicts have a predictable order, > they're going to be in for a nasty surprise one of these days. The only thing needed to avoid the hash collision is that your hash function is not not 100% predictable just by looking at the python source code. I don't see why every dict would have to be created differently. I would think having the most ubiquitous data structure in your language be more predictable would be a priority. Oh well.... Nathan From tjreedy at udel.edu Thu Feb 9 22:06:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:06:02 -0500 Subject: Formate a number with commas In-Reply-To: References: Message-ID: On 2/9/2012 5:12 PM, Chris Rebert wrote: > Argh. The 2.7 docs say it was added in 2.7, but the 3.3a0 docs say it > was added in 3.1 (Guido's backporting time machine messes with > "causality"). Python 2 docs refer to Python 2. Python 3 docs refer to Python 3. So 'it' was in neither 2.6 nor 3.1. > Both statements are completely technically correct, but misleading > when not taken together. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:22:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:22:44 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: <4F344BFD.9050200@gmail.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> <4F344BFD.9050200@gmail.com> Message-ID: On 2/9/2012 5:43 PM, Ian wrote: > On 09/02/2012 21:41, Aaron France wrote: >> How many pages is that? The amazon page conveniently left that off. > There is an average of 5.1 chars per word in English, and usually about > 350 words an A4 page. > > The 215K file is > a) Compressed - typically by 60% > b) Contains simple html and images as its source. > c) Must contain the cover image. > > As a *very* rough guess, that means the files expands to 344K. > Remove the cover image at 250-300kb leaves 44 to 94KB > That is 8700 words to 18400 words or approx 25 to 50 pages. > But that is *very* *very* rough. The file is about 500 'locations'. The Kindle Users Guide, 3rd Ed., has 1300, Lao Tza, the Art of War, (project Gutenberg), aaabut 2100. I read about half in an hour. Even knowing the material, it is slower than a novel. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:27:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:27:50 -0500 Subject: Read-only attribute in module In-Reply-To: <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > Python happily violates "consenting adults" all over the place. We have > properties, which can easily create read-only and write-once attributes. So propose that propery() work at module level, for module attributes, as well as for class attributes. -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:29:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:29:05 -0500 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: On 2/9/2012 8:23 PM, noydb wrote: > So how would you round UP always? Say the number is 3219, so you want >>> (3333//100+1)*100 3400 -- Terry Jan Reedy From tjreedy at udel.edu Thu Feb 9 22:33:16 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 09 Feb 2012 22:33:16 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/9/2012 9:30 PM, Nathan Rice wrote: >> That day may be sooner than you think. It is very likely that in Python >> 3.3, dict order will be randomized on creation as a side-effect of adding >> a random salt to hashes to prevent a serious vulnerability in dicts. >> >> http://securitytracker.com/id/1026478 >> >> http://bugs.python.org/issue13703 >> >> >> If there is anyone still assuming that dicts have a predictable order, >> they're going to be in for a nasty surprise one of these days. > > The only thing needed to avoid the hash collision is that your hash > function is not not 100% predictable just by looking at the python > source code. I don't see why every dict would have to be created > differently. I would think having the most ubiquitous data structure > in your language be more predictable would be a priority. Oh well.... I believe 'on creation' means 'on process startup', not on dict creation. There have, however, been several variants suggested, and the focus has been on choosing one first for past and current versions. 3.3 is about 6 months off and hash for it may still be debated. -- Terry Jan Reedy From python at mrabarnett.plus.com Thu Feb 9 22:36:11 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 03:36:11 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <4F3490AB.7080701@mrabarnett.plus.com> On 10/02/2012 02:25, noydb wrote: > That {>>> (3219 + 99) // 100} doesnt work if the number is other then > 4 digits. > > > (for rounding up to nearest 100): >>>> (3219 + 99)//100 > 33 >>>> (3289 + 99)//100 > 33 >>>> (328678 + 99)//100 > 3287 >>>> (328 + 99)//100 > 4 >>> (3219 + 99) // 100 * 100 3300 >>> (3289 + 99) // 100 * 100 3300 >>> (328678 + 99) // 100 * 100 328700 >>> (328 + 99) // 100 * 100 400 Those are all rounded up to the nearest 100 correctly. From python at mrabarnett.plus.com Thu Feb 9 22:39:08 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 03:39:08 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <4F34915C.3080007@mrabarnett.plus.com> On 10/02/2012 03:29, Terry Reedy wrote: > On 2/9/2012 8:23 PM, noydb wrote: >> So how would you round UP always? Say the number is 3219, so you want > >>> (3333//100+1)*100 > 3400 > Doing it that way doesn't always work. For example: >>> (3400 // 100 + 1) * 100 3500 However: >>> (3400 + 99) // 100 * 100 3400 From hitlarmamu at gmail.com Fri Feb 10 01:13:10 2012 From: hitlarmamu at gmail.com (Hitlar mamu) Date: Thu, 9 Feb 2012 22:13:10 -0800 (PST) Subject: mega soft info systems Message-ID: mega soft info systems available here http://win-con.blogspot.in/ From sajuptpm at gmail.com Fri Feb 10 01:20:57 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Thu, 9 Feb 2012 22:20:57 -0800 (PST) Subject: Guide to: Learning Python Decorators References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <4F343D78.1010800@gmail.com> <4F344BFD.9050200@gmail.com> Message-ID: Hi, Thanks for replay, I am looking for PDF version of same book. Please share if you can. http://www.amazon.com/gp/product/B006ZHJSIM/ref=as_li_tf_tl?ie=UTF8&tag=8012-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=B006ZHJSIM From ian.g.kelly at gmail.com Fri Feb 10 01:21:31 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 9 Feb 2012 23:21:31 -0700 Subject: round down to nearest number In-Reply-To: <4F3490AB.7080701@mrabarnett.plus.com> References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On Thu, Feb 9, 2012 at 8:36 PM, MRAB wrote: > On 10/02/2012 02:25, noydb wrote: >> >> That {>>> ?(3219 + 99) // 100} doesnt work if the number is other then >> 4 digits. >> >> >> (for rounding up to nearest 100): >>>>> >>>>> ?(3219 + 99)//100 >> >> 33 >>>>> >>>>> ?(3289 + 99)//100 >> >> 33 >>>>> >>>>> ?(328678 + 99)//100 >> >> 3287 >>>>> >>>>> ?(328 + 99)//100 >> >> 4 > > >>>> (3219 + 99) // 100 * 100 > 3300 >>>> (3289 + 99) // 100 * 100 > 3300 >>>> (328678 + 99) // 100 * 100 > 328700 >>>> (328 + 99) // 100 * 100 > 400 > > Those are all rounded up to the nearest 100 correctly. One thing to be aware of though is that while the "round down" formula works interchangeably for ints and floats, the "round up" formula does not. >>> (3300.5 + 99) // 100 * 100 3300.0 A more consistent alternative is to negate the number, round down, and then negate again. >>> -(-(3300.5) // 100 * 100) 3400.0 Cheers, Ian From nagle at animats.com Fri Feb 10 01:26:04 2012 From: nagle at animats.com (John Nagle) Date: Thu, 09 Feb 2012 22:26:04 -0800 Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <4f34b876$0$12004$742ec2ed@news.sonic.net> On 2/3/2012 4:27 PM, Antti J Ylikoski wrote: > > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: Most dynamic languages have closures. Even Perl and Javascript have closures. Javascript really needs them, because the "callback" orientation of Javascript means you often need to package up state and pass it into a callback. It really has very little to do with functional programming. If you want to see a different style of closure, check out Rust, Mozilla's new language. Rust doesn't have the "spaghetti stack" needed to implement closures, so it has more limited closure semantics. It's more like some of the C add-ons for closures, but sounder. John Nagle From anonhung at gmail.com Fri Feb 10 01:32:09 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:32:09 +0100 Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: >> Guide to: Learning Python Decorators >> New Book http://tinyurl.com/python-decorartor > > A whole book about decorators? Cool. I'm going to start writing books to. > I'll start with 'The Python print statement'. Then to be cutting edge I'll > follow with 'The Python print function'. How about 'Tips and tricks about python loops'? :) -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Fri Feb 10 01:35:17 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:35:17 +0100 Subject: ANN: eGenix mxODBC Zope Database Adapter 2.0.2 In-Reply-To: <4F33E36B.40001@egenix.com> References: <4F33E36B.40001@egenix.com> Message-ID: Thanks a bunch for the whole team! Best, anonhung On 2/9/12, eGenix Team: M.-A. Lemburg wrote: > ________________________________________________________________________ > ANNOUNCEMENT > > mxODBC Zope Database Adapter > > Version 2.0.2 > > for Zope and the Plone CMS > > Available for Zope 2.10 and later on > Windows, Linux, Mac OS X, FreeBSD and other platforms > > This announcement is also available on our web-site for online reading: > http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.0.2-GA.html > > ________________________________________________________________________ > INTRODUCTION > > The eGenix mxODBC Zope Database Adapter allows you to easily connect > your Zope or Plone installation to just about any database backend on > the market today, giving you the reliability of the commercially > supported eGenix product mxODBC and the flexibility of the ODBC > standard as middle-tier architecture. > > The mxODBC Zope Database Adapter is highly portable, just like Zope > itself and provides a high performance interface to all your ODBC data > sources, using a single well-supported interface on Windows, Linux, > Mac OS X, FreeBSD and other platforms. > > This makes it ideal for deployment in ZEO Clusters and Zope hosting > environments where stability and high performance are a top priority, > establishing an excellent basis and scalable solution for your Plone > CMS. > > Product page: > > http://www.egenix.com/products/zope/mxODBCZopeDA/ > > ________________________________________________________________________ > NEWS > > We are pleased to announce a new version 2.0.2 of our mxODBC Zope DA > product. > > With the patch level 2.0.2 release we have updated the integrated > mxODBC Python Extension to the latest 3.1.1 release, which > includes a number of important workarounds for these ODBC drivers: > > * Oracle 10gR1 and 10gR2 > * Oracle 11gR1 and 11gR2 > * Teradata 13 > * Netezza > > Due to popular demand, we have also added instructions on how to > install mxODBC Zope DA 2.0 with Plone 4.1 and Zope 2.13 - even though > this combination is not officially supported by the mxODBC Zope DA 2.0 > series: > > http://www.egenix.com/products/zope/mxODBCZopeDA/#Installation > > ________________________________________________________________________ > UPGRADING > > Licenses purchased for version 2.0.x of the mxODBC Zope DA will continue > to work with the 2.0.2 patch level release. > > Licenses purchased for version 1.0.x of the mxODBC Zope DA will not > work with version 2.0. More information about available licenses > is available on the product page: > > http://www.egenix.com/products/zope/mxODBCZopeDA/#Licensing > > Compared to the popular mxODBC Zope DA 1.0, version 2.0 offers > these enhancements: > > * Includes mxODBC 3.1 with updated support for many current ODBC > drivers, giving you more portability and features for a wider > range of database backends. > > * Mac OS X 10.6 (Snow Leopard) support. > > * Plone 3.2, 3.3, 4.0 support. Plone 4.1 works as well. > > * Zope 2.10, 2.11, 2.12 support. Zope 2.13 works as well. > > * Python 2.4 - 2.6 support. > > * Zero maintenance support to automatically reconnect the > Zope connection after a network or database problem. > > * More flexible Unicode support with options to work with > pure Unicode, plain strings or mixed setups - even for > databases that don't support Unicode > > * Automatic and transparent text encoding and decoding > > * More flexible date/time support including options to work > with Python datetime objects, mxDateTime, strings or tuples > > * New decimal support to have the Zope DA return decimal > column values using Python's decimal objects. > > * Fully eggified to simplify easy_install and zc.buildout based > installation > > ________________________________________________________________________ > MORE INFORMATION > > For more information on the mxODBC Zope Database Adapter, licensing > and download instructions, please visit our web-site: > > http://www.egenix.com/products/zope/mxODBCZopeDA/ > > You can buy mxODBC Zope DA licenses online from the eGenix.com shop at: > > http://shop.egenix.com/ > > ________________________________________________________________________ > > Thank you, > -- > Marc-Andre Lemburg > eGenix.com > > Professional Python Services directly from the Source (#1, Feb 09 2012) >>>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ > ________________________________________________________________________ > > ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: > > > eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 > D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg > Registered at Amtsgericht Duesseldorf: HRB 46611 > http://www.egenix.com/company/contact/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From anonhung at gmail.com Fri Feb 10 01:38:43 2012 From: anonhung at gmail.com (anon hung) Date: Fri, 10 Feb 2012 07:38:43 +0100 Subject: frozendict In-Reply-To: <4F332007.9080800@wisc.edu> References: <4F332007.9080800@wisc.edu> Message-ID: > I've been trying for a few days (only a little bit at a time) to come up > with a way of implementing a frozendict that doesn't suck. I'm gradually > converging to a solution, but I can't help but think that there's some > subtlety that I'm probably missing which is why it's not already provided. The freezing temperature of typical dicts is around - 10 Celsius. HTH, anonhung -- Viktor Orban Prime minister of Hungary http://spreadingviktororban.weebly.com From dihedral88888 at googlemail.com Fri Feb 10 02:55:23 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 9 Feb 2012 23:55:23 -0800 (PST) Subject: Common LISP-style closures with Python In-Reply-To: References: Message-ID: <14449658.339.1328860523539.JavaMail.geo-discussion-forums@prly15> ? 2012?2?4????UTC+8??8?27?56??Antti J Ylikoski??? > In Python textbooks that I have read, it is usually not mentioned that > we can very easily program Common LISP-style closures with Python. It > is done as follows: > > ------------------------------------- > > # Make a Common LISP-like closure with Python. > # > # Antti J Ylikoski 02-03-2012. > > def f1(): > n = 0 > def f2(): > nonlocal n > n += 1 > return n > return f2 > > ------------------------------------- > > and now we can do: > > ------------------------------------- > > >>> > >>> a=f1() > >>> b=f1() > >>> a() > 1 > >>> a() > 2 > >>> a() > 3 > >>> a() > 4 > >>> b() > 1 > >>> b() > 2 > >>> a() > 5 > >>> b() > 3 > >>> b() > 4 > >>> > > ------------------------------------- > > i. e. we can have several functions with private local states which > are kept between function calls, in other words we can have Common > LISP-like closures. > > yours, Antti J Ylikoski > Helsinki, Finland, the EU We are not in the 1990's now. A descent CAD or internet application now should be able to support users with at least one or more script languages easily. Whether it's javascript or java or flash in the browser-based applications, or go, python in the google desktop API, commercial SW applications to be able to evolve in the long run are not jobs from the publishers and the original writers of the SW packages only. I don't want to include a big fat compiler in my software, what else can I do ? LISP is too fat, too. From dllizheng at gmail.com Fri Feb 10 02:57:26 2012 From: dllizheng at gmail.com (Zheng Li) Date: Fri, 10 Feb 2012 16:57:26 +0900 Subject: what is the difference between @property and method In-Reply-To: <4F33E806.8070700@optimum.net> References: <21E56249-1F53-4316-8256-5C3B53E68BCE@gmail.com> <4F33E806.8070700@optimum.net> Message-ID: <13BD6C0A-27B5-4D2D-8E2B-FA84FBAA4CB2@gmail.com> Thank you On 2012/02/10, at 0:36, John Posner wrote: > On 2:59 PM, Devin Jeanpierre wrote: > > >> It is kind of funny that the docs don't ever explicitly say what a >> property is. http://docs.python.org/library/functions.html#property -- >> Devin > > Here's a writeup that does: > http://wiki.python.org/moin/AlternativeDescriptionOfProperty > > -John > From dihedral88888 at googlemail.com Fri Feb 10 03:11:13 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 10 Feb 2012 00:11:13 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> I prefer to decorate a function not a method. I prefer to decorate an object to own a new method from the existed ones inherited in all the class levels. I do not decorate a class if not necessary. I believe this is more pythonic to add functionalities to objects in classes by aggregated scripts that use similar modules over a period of time. From arnodel at gmail.com Fri Feb 10 04:58:35 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 09:58:35 +0000 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On 10 February 2012 06:21, Ian Kelly wrote: >>>>> (3219 + 99) // 100 * 100 >> 3300 >>>>> (3289 + 99) // 100 * 100 >> 3300 >>>>> (328678 + 99) // 100 * 100 >> 328700 >>>>> (328 + 99) // 100 * 100 >> 400 >> >> Those are all rounded up to the nearest 100 correctly. > > One thing to be aware of though is that while the "round down" formula > works interchangeably for ints and floats, the "round up" formula does > not. > >>>> (3300.5 + 99) // 100 * 100 > 3300.0 > I'm surprised I haven't seen: >>> 212 - (212 % -100) 300 Here's a function that: * rounds up and down * works for both integers and floats * is only two operations (as opposed to 3 in the solutions given above) >>> def round(n, k): ... return n - n%k ... >>> # Round down with a positive k: ... round(167, 100) 100 >>> round(-233, 100 ... ) -300 >>> # Round up with a negative k: ... round(167, -100) 200 >>> round(-233, -100) -200 >>> # Edge cases ... round(500, -100) 500 >>> round(500, 100) 500 >>> # Floats ... round(100.5, -100) 200.0 >>> round(199.5, 100) 100.0 -- Arnaud From rosuav at gmail.com Fri Feb 10 05:08:04 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 10 Feb 2012 21:08:04 +1100 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice wrote: > The only thing needed to avoid the hash collision is that your hash > function is not not 100% predictable just by looking at the python > source code. ?I don't see why every dict would have to be created > differently. ?I would think having the most ubiquitous data structure > in your language be more predictable would be a priority. ?Oh well.... It's perfectly predictable. If you put a series of keys into it, you get those same keys back. Nobody ever promised anything about order. If your hash function is not 100% predictable, that means it varies on the basis of something that isn't part of either the Python interpreter or the script being run. That means that, from one execution to another of the exact same code, the results could be different. The keys will come out in different orders. ChrisA From arnodel at gmail.com Fri Feb 10 05:09:24 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:09:24 +0000 Subject: Read-only attribute in module In-Reply-To: References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 10 February 2012 03:27, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once attributes. > > > So propose that propery() work at module level, for module attributes, as > well as for class attributes. I think Steven would like something else: bare names that cannot be rebound. E.g. something like: >>> const a = 42 >>> a = 7 Would raise an exception. Is that right? -- Arnaud From python at borja.fagorederlan.es Fri Feb 10 05:10:59 2012 From: python at borja.fagorederlan.es (sisifus) Date: Fri, 10 Feb 2012 11:10:59 +0100 Subject: Any idea for build code bars??? Message-ID: Hello all, I new in python but i want to practice very much. In interesting in build an application which read a text file, translate the information in 128 bar code format and print all the information in a printer. File text content: 123456 123456 Where each line mean: 1? --> Print in text format (Ej: 123456) 2? --> Print in bar code format (Ej: |||||||||||) With this information my script hast to build a documento (pdf, html, etc) and send it to the printer. Can any one say me what python modules i could use? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Fri Feb 10 05:28:27 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Feb 2012 10:28:27 +0000 Subject: Any idea for build code bars??? In-Reply-To: References: Message-ID: On 10/02/2012 10:10, sisifus wrote: > Hello all, > > I new in python but i want to practice very much. > > In interesting in build an application which read a text file, translate > the information in 128 bar code format and print all the information in a > printer. > > File text content: > 123456 > 123456 > > Where each line mean: > 1? --> Print in text format (Ej: 123456) > 2? --> Print in bar code format (Ej: |||||||||||) > > With this information my script hast to build a documento (pdf, html, etc) > and send it to the printer. > > Can any one say me what python modules i could use? > > > Regards > Studying this should give you some ideas. http://pypi.python.org/pypi/pyBarcode -- Cheers. Mark Lawrence. From arnodel at gmail.com Fri Feb 10 05:41:06 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:41:06 +0000 Subject: multiple namespaces within a single module? In-Reply-To: <4F345F55.8050300@stoneleaf.us> References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <4F3436CA.2020800@stoneleaf.us> <4F3447EA.6070601@stoneleaf.us> <4F345F55.8050300@stoneleaf.us> Message-ID: On 10 February 2012 00:05, Ethan Furman wrote: > Ethan Furman wrote: >> >> Hrm -- and functions/classes/etc would have to refer to each other that >> way as well inside the namespace... not sure I'm in love with that... > > > > Not sure I hate it, either. ?;) > > Slightly more sophisticated code: > > > class NameSpace(object): > ? ?def __init__(self, current_globals): > ? ? ? ?self.globals = current_globals > ? ? ? ?self.saved_globals = current_globals.copy() > > ? ?def __enter__(self): > ? ? ? ?return self > ? ?def __exit__(self, *args): > ? ? ? ?new_items = [] > ? ? ? ?for key, value in self.globals.items(): > ? ? ? ? ? ?if (key not in self.saved_globals and value is not self > ? ? ? ? ? ? ? ? ? ?or key in self.saved_globals > ? ? ? ? ? ? ? ? ? ?and value != self.saved_globals[key]): > > ? ? ? ? ? ? ? ?new_items.append((key, value)) > ? ? ? ?for key, value in new_items: > ? ? ? ? ? ?setattr(self, key, value) > ? ? ? ? ? ?del self.globals[key] > ? ? ? ?self.globals.update(self.saved_globals) > > if __name__ == '__main__': > ? ?x = 'inside main!' > ? ?with NameSpace(globals()) as a: > ? ? ? ?x = 'inside a?' > ? ? ? ?def fn1(): > ? ? ? ? ? ?print(a.x) > ? ?with NameSpace(globals()) as b: > ? ? ? ?x = 'inside b?' > ? ? ? ?def fn1(): > ? ? ? ? ? ?print(b.x) > ? ? ? ?def fn2(): > ? ? ? ? ? ?print('hello!') > ? ? ? ? ? ?b.fn1() > ? ?y = 'still inside main' > ? ?a.fn1() > ? ?b.fn1() > ? ?print(x) > ? ?print(y) > Please! Metaclasses are the obvious way to proceed here :) Then there is no need for the 'a.x' and 'b.x' cruft. marigold:junk arno$ cat namespace.py function = type(lambda:0) def change_globals(f, g): return function(f.__code__, g, f.__name__, f.__defaults__, f.__closure__) class MetaNamespace(type): def __new__(self, name, bases, attrs): attrs['__builtins__'] = __builtins__ for name, value in attrs.items(): if isinstance(value, function): attrs[name] = change_globals(value, attrs) return type.__new__(self, name, bases, attrs) class Namespace(metaclass=MetaNamespace): pass x = "inside main" class a(Namespace): x = "inside a" def fn1(): print(x) class b(Namespace): x = "inside b" def fn1(): print(x) def fn2(): print("hello") fn1() y = "inside main" a.fn1() b.fn1() b.fn2() print(x) print(y) marigold:junk arno$ python3 namespace.py inside a inside b hello inside b inside main inside main A bit more work would be needed to support nested functions and closures... -- Arnaud From arnodel at gmail.com Fri Feb 10 05:46:41 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 10:46:41 +0000 Subject: when to use import statements in the header, when to use import statements in the blocks where they are used? In-Reply-To: References: Message-ID: On 8 February 2012 01:48, Lei Cheng wrote: > Hi all, > > ? ?In a py file, when to use import statements in the header, when to use > import statements in the blocks where they are used? > ? ?What are the best practices? > ? ?Thanks! Aside from other answers: in some rare cases, importing within a function can avoid circularity problems (e.g. A imports B which tries itself to import A) -- Arnaud From alec.taylor6 at gmail.com Fri Feb 10 06:05:39 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Fri, 10 Feb 2012 22:05:39 +1100 Subject: round down to nearest number In-Reply-To: References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: o.O Very nice On Fri, Feb 10, 2012 at 8:58 PM, Arnaud Delobelle wrote: > On 10 February 2012 06:21, Ian Kelly wrote: >>>>>> (3219 + 99) // 100 * 100 >>> 3300 >>>>>> (3289 + 99) // 100 * 100 >>> 3300 >>>>>> (328678 + 99) // 100 * 100 >>> 328700 >>>>>> (328 + 99) // 100 * 100 >>> 400 >>> >>> Those are all rounded up to the nearest 100 correctly. >> >> One thing to be aware of though is that while the "round down" formula >> works interchangeably for ints and floats, the "round up" formula does >> not. >> >>>>> (3300.5 + 99) // 100 * 100 >> 3300.0 >> > > I'm surprised I haven't seen: > >>>> 212 - (212 % -100) > 300 > > Here's a function that: > * rounds up and down > * works for both integers and floats > * is only two operations (as opposed to 3 in the solutions given above) > >>>> def round(n, k): > ... ? ? return n - n%k > ... >>>> # Round down with a positive k: > ... round(167, 100) > 100 >>>> round(-233, 100 > ... ) > -300 >>>> # Round up with a negative k: > ... round(167, -100) > 200 >>>> round(-233, -100) > -200 >>>> # Edge cases > ... round(500, -100) > 500 >>>> round(500, 100) > 500 >>>> # Floats > ... round(100.5, -100) > 200.0 >>>> round(199.5, 100) > 100.0 > > -- > Arnaud > -- > http://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Fri Feb 10 06:10:33 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 12:10:33 +0100 Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Message-ID: jkn wrote: > Hi Peter > > On Feb 9, 7:33 pm, Peter Otten <__pete... at web.de> wrote: >> jkn wrote: >> > is it possible to have multiple namespaces within a single python >> > module? >> >> Unless you are abusing classes I don't think so. >> >> > I have a small app which is in three or four .py files. For various >> > reasons I would like to (perhaps optionally) combine these into one >> > file. >> >> Rename your main script into __main__.py, put it into a zip file together >> with the other modules and run that. > > Hmm ... thanks for mentioning this feature, I didn't know of it > before. Sounds great, except that I gather it needs Python >2.5? I'm > stuck with v2.4 at the moment unfortunately... You can import and run explicitly, $ PYTHONPATH mylib.zip python -c'import mainmod; mainmod.main()' assuming you have a module mainmod.py containing a function main() in mylib.zip. From mateusz at loskot.net Fri Feb 10 06:11:52 2012 From: mateusz at loskot.net (mloskot) Date: Fri, 10 Feb 2012 03:11:52 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: References: Message-ID: <1328872312611-4382967.post@n6.nabble.com> Terry Reedy wrote > > On 2/9/2012 6:43 AM, Mateusz Loskot wrote: >> import xyz print(xyz.flag) # OK >> xyz.flag = 0 # error due to no write access > > Why prevent that? If you called it 'FLAG', that would indicate that it > is a constant that should not be changed. While Python make some effort > to prevent bugs, it is generally a 'consenting adults' language. > Terry, The intent of xyz.flag is that it is a value set by the module internally. xyz is a module wrapping a C library. The C library defines concept of a global flag set by the C functions at some events, so user can check value of this flag. I can provide access to it with function: xyz.get_flag() But, I thought it would be more convenient to have a read-only property in scope of the module. Sometimes, especially when wrapping C code, it is not possible to map C API semantics to Python concepts as 1:1. ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4382967.html Sent from the Python - python-list mailing list archive at Nabble.com. From sajuptpm at gmail.com Fri Feb 10 07:30:27 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 04:30:27 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. Message-ID: Hi, I want to log time taken to complete database requests inside a method/ function using decorator . is it possible ???? I think, i have to inject log code inside the method/fuctions or modify it. I wrote a decorator to log taken by a method/function to complete it execution and its working well. My requirement : log everything and figure out what bits are slow and optimize them. What are your suggestions ?? From arnodel at gmail.com Fri Feb 10 07:38:34 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 12:38:34 +0000 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: On 10 February 2012 12:30, sajuptpm wrote: > Hi, > > I want to log time taken to complete database requests inside a method/ > function using decorator . ?is it possible ???? > I think, i have to inject log code inside the method/fuctions or > modify it. > I wrote a decorator to log taken by a method/function to complete it > execution and its working well. > > My requirement : log everything and figure out what bits are slow and > optimize them. > > What are your suggestions ?? Are you familiar with this? http://docs.python.org/library/profile.html -- Arnaud From sajuptpm at gmail.com Fri Feb 10 07:42:56 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:12:56 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Hi, Yes i saw profile module, I think i have to do function call via cProfile.run('foo()') I know, we can debug this way. But i need a fixed logging system .. On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: > On 10 February 2012 12:30, sajuptpm wrote: > > Hi, > > > > I want to log time taken to complete database requests inside a method/ > > function using decorator . is it possible ???? > > I think, i have to inject log code inside the method/fuctions or > > modify it. > > I wrote a decorator to log taken by a method/function to complete it > > execution and its working well. > > > > My requirement : log everything and figure out what bits are slow and > > optimize them. > > > > What are your suggestions ?? > > Are you familiar with this? > > http://docs.python.org/library/profile.html > > -- > Arnaud > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From sajuptpm at gmail.com Fri Feb 10 07:48:33 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:18:33 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 6:12 PM, Saju M wrote: > Hi, > > Yes i saw profile module, > I think i have to do function call via > > cProfile.run('foo()') > > I know, we can debug this way. > > But i need a fixed logging system .. > > > > On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: > >> On 10 February 2012 12:30, sajuptpm wrote: >> > Hi, >> > >> > I want to log time taken to complete database requests inside a method/ >> > function using decorator . is it possible ???? >> > I think, i have to inject log code inside the method/fuctions or >> > modify it. >> > I wrote a decorator to log taken by a method/function to complete it >> > execution and its working well. >> > >> > My requirement : log everything and figure out what bits are slow and >> > optimize them. >> > >> > What are your suggestions ?? >> >> Are you familiar with this? >> >> http://docs.python.org/library/profile.html >> > I need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? > -- >> Arnaud >> > > > > -- > Regards > Saju Madhavan > +91 09535134654 > > Anyone who has never made a mistake has never tried anything new -- Albert > Einstein > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From sajuptpm at gmail.com Fri Feb 10 07:56:17 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 04:56:17 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: Hi, Yes i saw profile module, I think i have to do function call via cProfile.run('foo()') I know, we can debug this way. But, i need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? From sajuptpm at gmail.com Fri Feb 10 07:59:51 2012 From: sajuptpm at gmail.com (Saju M) Date: Fri, 10 Feb 2012 18:29:51 +0530 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Yes i saw profile module, I think, i have to do function call via cProfile.run('foo()') I know, we can debug this way. But, I need a fixed logging system and want to use it in production. I think, we can't permanently include profile's debugging code in source code, will cause any performance issue ?? On Fri, Feb 10, 2012 at 6:18 PM, Saju M wrote: > > > On Fri, Feb 10, 2012 at 6:12 PM, Saju M wrote: > >> Hi, >> >> Yes i saw profile module, >> I think i have to do function call via >> >> cProfile.run('foo()') >> >> I know, we can debug this way. >> >> But i need a fixed logging system .. >> >> >> >> On Fri, Feb 10, 2012 at 6:08 PM, Arnaud Delobelle wrote: >> >>> On 10 February 2012 12:30, sajuptpm wrote: >>> > Hi, >>> > >>> > I want to log time taken to complete database requests inside a method/ >>> > function using decorator . is it possible ???? >>> > I think, i have to inject log code inside the method/fuctions or >>> > modify it. >>> > I wrote a decorator to log taken by a method/function to complete it >>> > execution and its working well. >>> > >>> > My requirement : log everything and figure out what bits are slow and >>> > optimize them. >>> > >>> > What are your suggestions ?? >>> >>> Are you familiar with this? >>> >>> http://docs.python.org/library/profile.html >>> >> > > > I need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code in > source code, > will cause any performance issue ?? > > > > >> -- >>> Arnaud >>> >> >> >> >> -- >> Regards >> Saju Madhavan >> +91 09535134654 >> >> Anyone who has never made a mistake has never tried anything new -- >> Albert Einstein >> > > > > -- > Regards > Saju Madhavan > +91 09535134654 > > Anyone who has never made a mistake has never tried anything new -- Albert > Einstein > -- Regards Saju Madhavan +91 09535134654 Anyone who has never made a mistake has never tried anything new -- Albert Einstein -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Fri Feb 10 08:08:28 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 13:08:28 +0000 Subject: changing sys.path In-Reply-To: References: Message-ID: <4F3516CC.1070401@gmail.com> I think I finally located the issue with the sys.path extension. The problem is that I have many namespace directories, for example lib: - sub1 - sub2 lib: - sub3 - sub4 But to have everything working I had lib.sub3 in easy-install.pth. Now if I try to add something else to the path it doesn't take care of the namespace declaration (every __init__.py in the packages contains: __import__('pkg_resources').declare_namespace(__name__)) and just doesn't find the other submodules.. If I try to add manually lib.sub1, lib.sub2 changing the sys.path the imports will only work for the first one. Strangely if I just create a dev_main.pth in site-packages containing the same paths, everything works perfectly. Any suggestions now that the problem is more clear? Thanks, Andrea From d at davea.name Fri Feb 10 09:24:50 2012 From: d at davea.name (Dave Angel) Date: Fri, 10 Feb 2012 09:24:50 -0500 Subject: changing sys.path In-Reply-To: <4F3516CC.1070401@gmail.com> References: <4F3516CC.1070401@gmail.com> Message-ID: <4F3528B2.3050806@davea.name> On 02/10/2012 08:08 AM, Andrea Crotti wrote: > I think I finally located the issue with the sys.path extension. > > The problem is that I have many namespace directories, for example > > lib: > - sub1 > - sub2 > > lib: > - sub3 > - sub4 > > But to have everything working I had lib.sub3 in easy-install.pth. > Now if I try to add something else to the path it doesn't take care of > the namespace > declaration > (every __init__.py in the packages contains: > __import__('pkg_resources').declare_namespace(__name__)) > and just doesn't find the other submodules.. > > If I try to add manually lib.sub1, lib.sub2 changing the sys.path the > imports will only work for the first one. > > Strangely if I just create a dev_main.pth in site-packages containing > the same paths, everything works perfectly. > > Any suggestions now that the problem is more clear? > Thanks, > Andrea The only code I saw in this thread was: sys.path.extend(paths_to_add) Can you add a print of paths_to_add, and of sys.path after you execute it? If there's only one path, are you putting it in a list anyway? If not then it won't do what you expect. -- DaveA From breamoreboy at yahoo.co.uk Fri Feb 10 09:25:10 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 10 Feb 2012 14:25:10 +0000 Subject: log and figure out what bits are slow and optimize them. In-Reply-To: References: Message-ID: Please don't top post. On 10/02/2012 12:59, Saju M wrote: > Yes i saw profile module, > I think, i have to do function call via > cProfile.run('foo()') > I know, we can debug this way. > But, I need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code in > source code, > will cause any performance issue ?? > How about http://docs.python.org/library/logging.html ? -- Cheers. Mark Lawrence. From andrea.crotti.0 at gmail.com Fri Feb 10 09:51:20 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 14:51:20 +0000 Subject: changing sys.path In-Reply-To: <4F3528B2.3050806@davea.name> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> Message-ID: <4F352EE8.1030101@gmail.com> Ok now it's getting really confusing, I tried a small example to see what is the real behaviour, so I created some package namespaces (where the __init__.py declare the namespace package). /home/andrea/test_ns: total used in directory 12 available 5655372 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py /home/andrea/test_ns/a.b: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.b/a/b: total 12 -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c: total 8 drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a: total 8 drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py /home/andrea/test_ns/a.c/a/c: total 12 -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py So this test.py works perfectly: import sys sys.path.insert(0, 'a.c') sys.path.insert(0, 'a.b') from a.b import api as api_ab from a.c import api as api_ac While just mixing the order: import sys sys.path.insert(0, 'a.b') from a.b import api as api_ab sys.path.insert(0, 'a.c') from a.c import api as api_ac Doesn't work anymore [andrea at precision test_ns]$ python2 test.py Traceback (most recent call last): File "test.py", line 7, in from a.c import api as api_ac ImportError: No module named c Am I missing something/doing something stupid? From d at davea.name Fri Feb 10 10:06:28 2012 From: d at davea.name (Dave Angel) Date: Fri, 10 Feb 2012 10:06:28 -0500 Subject: changing sys.path In-Reply-To: <4F352EE8.1030101@gmail.com> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: <4F353274.704@davea.name> On 02/10/2012 09:51 AM, Andrea Crotti wrote: > Ok now it's getting really confusing, I tried a small example to see > what is the real behaviour, > so I created some package namespaces (where the __init__.py declare the > namespace package). > > /home/andrea/test_ns: > total used in directory 12 available 5655372 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c > -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py > > /home/andrea/test_ns/a.b: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a/b: > total 12 > -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a/c: > total 12 > -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > > So this test.py works perfectly: > import sys > sys.path.insert(0, 'a.c') > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > from a.c import api as api_ac > > While just mixing the order: > import sys > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > sys.path.insert(0, 'a.c') > from a.c import api as api_ac > > Doesn't work anymore > > [andrea at precision test_ns]$ python2 test.py > Traceback (most recent call last): > File "test.py", line 7, in > from a.c import api as api_ac > ImportError: No module named c > > > > Am I missing something/doing something stupid? Yes, you've got periods in your directory names. A period means something special within python, and specifically within the import. When you say from a.c import api You're telling it: from package a get module c, and from there impoort the symbol api But package a has no module c, so it complains. In an earlier message you asserted you were using all absolute paths in your additions to sys.path. Here you're inserting relative ones. How come? -- DaveA From andrea.crotti.0 at gmail.com Fri Feb 10 10:14:23 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 15:14:23 +0000 Subject: changing sys.path In-Reply-To: <4F353274.704@davea.name> References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F353274.704@davea.name> Message-ID: <4F35344F.7040308@gmail.com> On 02/10/2012 03:06 PM, Dave Angel wrote: > > Yes, you've got periods in your directory names. A period means > something special within python, and specifically within the import. > > When you say from a.c import api > > You're telling it: from package a get module c, and from there > impoort the symbol api > > But package a has no module c, so it complains. > > > In an earlier message you asserted you were using all absolute paths > in your additions to sys.path. Here you're inserting relative ones. > How come? > Well yes I have periods, but that's also the real-world situation. We have many directories that are contributing to the same namespace in the same superdirectory which should not interfere, so it was decided to give this naming. It would be quite hard to change I guess and I have to prove that this is problem. I renamed everything and this import sys from os import path sys.path.insert(0, path.abspath('ab')) from a.b import api as api_ab sys.path.insert(0, path.abspath('ac')) from a.c import api as api_ac still fails, so the period in the name is not the problem. Also absolute or relative paths in this small example doesn't make any difference. Adding all the paths in one go works perfectly fine anyway, so I probably have to make sure I add them *all* before anything is imported. If there are better solutions I would like to hear them :) From __peter__ at web.de Fri Feb 10 10:27:24 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 16:27:24 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: Andrea Crotti wrote: > Ok now it's getting really confusing, I tried a small example to see > what is the real behaviour, > so I created some package namespaces (where the __init__.py declare the > namespace package). > > /home/andrea/test_ns: > total used in directory 12 available 5655372 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.b > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:46 a.c > -rw-r--r-- 1 andrea andrea 125 Feb 10 14:46 test.py > > /home/andrea/test_ns/a.b: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 b > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.b/a/b: > total 12 > -rw-r--r-- 1 andrea andrea 25 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 153 Feb 10 14:37 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c: > total 8 > drwxr-xr-x 3 andrea andrea 4096 Feb 10 14:47 a > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a: > total 8 > drwxr-xr-x 2 andrea andrea 4096 Feb 10 14:47 c > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > /home/andrea/test_ns/a.c/a/c: > total 12 > -rw-r--r-- 1 andrea andrea 20 Feb 10 14:36 api.py > -rw-r--r-- 1 andrea andrea 148 Feb 10 14:38 api.pyc > -rw-r--r-- 1 andrea andrea 56 Feb 10 14:35 __init__.py > > > So this test.py works perfectly: > import sys > sys.path.insert(0, 'a.c') > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > from a.c import api as api_ac > > While just mixing the order: > import sys > sys.path.insert(0, 'a.b') > > from a.b import api as api_ab > > sys.path.insert(0, 'a.c') > from a.c import api as api_ac > > Doesn't work anymore > > [andrea at precision test_ns]$ python2 test.py > Traceback (most recent call last): > File "test.py", line 7, in > from a.c import api as api_ac > ImportError: No module named c > > > > Am I missing something/doing something stupid? The package a will be either a.c/a/ or a.b/a/ depending on whether a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not contain a c submodule or subpackage. From andrea.crotti.0 at gmail.com Fri Feb 10 10:38:18 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 15:38:18 +0000 Subject: changing sys.path In-Reply-To: References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: <4F3539EA.80004@gmail.com> On 02/10/2012 03:27 PM, Peter Otten wrote: > The package a will be either a.c/a/ or a.b/a/ depending on whether > a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not > contain a c submodule or subpackage. I would agree if I didn't have this declaration __import__('pkg_resources').declare_namespace(__name__) in each subdirectory. And how do you explain the fact that changing the order everything works? Namespace packages are supposed to work exactly like this, if it doesn't resolve the "c" instead of raising an Exception it goes forward in the sys.path and try again, which is what actually happens when I do this sys.path.append(path.abspath('ab')) sys.path.append(path.abspath('ac')) from a.b import api as api_ab from a.c import api as api_ac Maybe this: Definition: pkgutil.extend_path(path, name) Docstring: Extend a package's path. Intended use is to place the following code in a package's __init__.py: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) might come handy, from what I'm gathering is the only way to have a more dynamic path manipulation with namespace packages.. From __peter__ at web.de Fri Feb 10 10:40:52 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 16:40:52 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> Message-ID: Peter Otten wrote: > If it's a.c/a, that does not contain a c submodule or subpackage. Sorry, I meant a.b/a From __peter__ at web.de Fri Feb 10 11:00:39 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 10 Feb 2012 17:00:39 +0100 Subject: changing sys.path References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F3539EA.80004@gmail.com> Message-ID: Andrea Crotti wrote: > On 02/10/2012 03:27 PM, Peter Otten wrote: >> The package a will be either a.c/a/ or a.b/a/ depending on whether >> a.c/ or a.b/ appears first in sys.path. If it's a.c/a, that does not >> contain a c submodule or subpackage. > > > I would agree if I didn't have this declaration > __import__('pkg_resources').declare_namespace(__name__) > in each subdirectory. Sorry, you didn't mention that in the post I responded to and I didn't follow the thread closely. I found a description for declare_namespace() at http://peak.telecommunity.com/DevCenter/PkgResources but the text explaining the function is completely unintelligible to me, so I cannot contribute anything helpful here :( From technovegas at gmail.com Fri Feb 10 11:04:05 2012 From: technovegas at gmail.com (Fabric Paul) Date: Fri, 10 Feb 2012 08:04:05 -0800 (PST) Subject: Fabric Engine + Python benchmarks Message-ID: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Hi all - just letting you know that we recently integrated Fabric with Python. Fabric is a high-performance multi-threading engine that integrates with dynamic languages. We're releasing soon (probably under AGPL), and we just released these benchmarks. http://fabric-engine.com/2012/02/fabric-engine-python-value-at-risk-benchmark/ Before anyone starts attacking the vanilla python :), the point we want to make is that our Python integration performs just as well as our Node.js implementation (benchmarks found at http://fabric-engine.com/tag/benchmarks/). Obviously, it's pretty trivial to compile Python to byte code, and present multi-threaded versions of the program - however, the goal of Fabric is to handle that side of things automatically (that's what the engine does). This means we take care of threading, dynamic compilation, memory management etc Interested to get your feedback. Kind regards, Paul (I work at Fabric) From jkn_gg at nicorp.f9.co.uk Fri Feb 10 11:28:50 2012 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Fri, 10 Feb 2012 08:28:50 -0800 (PST) Subject: multiple namespaces within a single module? References: <6f50fa3d-74e6-4682-b5d8-2634d418dd23@d15g2000yqg.googlegroups.com> <2caddc2a-f412-49bc-b02e-d475bc6db8a0@s13g2000yqe.googlegroups.com> Message-ID: Hi Peter On Feb 10, 11:10?am, Peter Otten <__pete... at web.de> wrote: [...] > > Hmm ... thanks for mentioning this feature, I didn't know of it > > before. Sounds great, except that I gather it needs Python >2.5? I'm > > stuck with v2.4 at the moment unfortunately... > > You can import and run explicitly, > > $ PYTHONPATH mylib.zip python -c'import mainmod; mainmod.main()' > > assuming you have a module mainmod.py containing a function main() in > mylib.zip. That looks very useful -thanks for the tip! J^n From nathan.alexander.rice at gmail.com Fri Feb 10 11:53:08 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 10 Feb 2012 11:53:08 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 5:08 AM, Chris Angelico wrote: > On Fri, Feb 10, 2012 at 1:30 PM, Nathan Rice > wrote: >> The only thing needed to avoid the hash collision is that your hash >> function is not not 100% predictable just by looking at the python >> source code. ?I don't see why every dict would have to be created >> differently. ?I would think having the most ubiquitous data structure >> in your language be more predictable would be a priority. ?Oh well.... > > It's perfectly predictable. If you put a series of keys into it, you > get those same keys back. Nobody ever promised anything about order. > > If your hash function is not 100% predictable, that means it varies on > the basis of something that isn't part of either the Python > interpreter or the script being run. That means that, from one > execution to another of the exact same code, the results could be > different. The keys will come out in different orders. I think having a hash function that is not referentially transparent is a bad thing. Basing your language on a non-deterministic function? Yeah... A type factory that produces the dict type on interpreter initialization (or, replaces the hash function, rather), and uses time/system information/etc would solve the problem, while limiting the introduced non-determinism. I don't care if the order of iteration for keys is different from interpreter run to run. I have used frozenset(mydict.items()) when my requirements dictated. It is a minor performance hit. Lets also not forget that knowing an object is immutable lets you do a lot of optimizations; it can be inlined, it is safe to convert to a contiguous block of memory and stuff in cache, etc. If you know the input to a function is guaranteed to be frozen you can just go crazy. Being able to freeze(anyobject) seems like a pretty clear win. Whether or not it is pythonic is debatable. I'd argue if the meaning of pythonic in some context is limiting, we should consider updating the term rather than being dogmatic. Just my 2 cents... Nathan From clp2 at rebertia.com Fri Feb 10 12:00:55 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 09:00:55 -0800 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 10, 2012 at 8:53 AM, Nathan Rice wrote: > Lets also not forget that knowing an object is immutable lets you do a > lot of optimizations; it can be inlined, it is safe to convert to a > contiguous block of memory and stuff in cache, etc. ?If you know the > input to a function is guaranteed to be frozen you can just go crazy. > Being able to freeze(anyobject) seems like a pretty clear win. > Whether or not it is pythonic is debatable. ?I'd argue if the meaning > of pythonic in some context is limiting, we should consider updating > the term rather than being dogmatic. It's been proposed previously and rejected: PEP 351 -- The freeze protocol http://www.python.org/dev/peps/pep-0351/ Cheers, Chris From stefan_ml at behnel.de Fri Feb 10 12:21:23 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 10 Feb 2012 18:21:23 +0100 Subject: Fabric Engine + Python benchmarks In-Reply-To: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Message-ID: Fabric Paul, 10.02.2012 17:04: > Fabric is a high-performance multi-threading engine that > integrates with dynamic languages. Hmm, first of all, fabric is a tool for automating admin/deployment/whatever tasks: http://pypi.python.org/pypi/Fabric/1.3.4 http://docs.fabfile.org/en/1.3.4/index.html Not sure which went first, but since you mentioned that you're "releasing soon", you may want to stop the engines for a moment and reconsider the name. Stefan From jenn.duerr at gmail.com Fri Feb 10 12:23:21 2012 From: jenn.duerr at gmail.com (noydb) Date: Fri, 10 Feb 2012 09:23:21 -0800 (PST) Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> <4F3490AB.7080701@mrabarnett.plus.com> Message-ID: On Feb 10, 4:58?am, Arnaud Delobelle wrote: > On 10 February 2012 06:21, Ian Kelly wrote: > > > > > > >>>>> (3219 + 99) // 100 * 100 > >> 3300 > >>>>> (3289 + 99) // 100 * 100 > >> 3300 > >>>>> (328678 + 99) // 100 * 100 > >> 328700 > >>>>> (328 + 99) // 100 * 100 > >> 400 > > >> Those are all rounded up to the nearest 100 correctly. > > > One thing to be aware of though is that while the "round down" formula > > works interchangeably for ints and floats, the "round up" formula does > > not. > > >>>> (3300.5 + 99) // 100 * 100 > > 3300.0 > > I'm surprised I haven't seen: > > >>> 212 - (212 % -100) > > 300 > > Here's a function that: > * rounds up and down > * works for both integers and floats > * is only two operations (as opposed to 3 in the solutions given above) > > >>> def round(n, k): > > ... ? ? return n - n%k > ...>>> # Round down with a positive k: > > ... round(167, 100) > 100>>> round(-233, 100 > > ... ) > -300>>> # Round up with a negative k: > > ... round(167, -100) > 200>>> round(-233, -100) > -200 > >>> # Edge cases > > ... round(500, -100) > 500>>> round(500, 100) > 500 > >>> # Floats > > ... round(100.5, -100) > 200.0>>> round(199.5, 100) > > 100.0 > > -- > Arnaud- Hide quoted text - > > - Show quoted text - Thanks! Covers all bases, good. From technovegas at gmail.com Fri Feb 10 12:27:31 2012 From: technovegas at gmail.com (Fabric Paul) Date: Fri, 10 Feb 2012 09:27:31 -0800 (PST) Subject: Fabric Engine + Python benchmarks References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> Message-ID: <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> On Feb 10, 12:21?pm, Stefan Behnel wrote: > Fabric Paul, 10.02.2012 17:04: > > > Fabric is a high-performance multi-threading engine that > > integrates with dynamic languages. > > Hmm, first of all, fabric is a tool for automating > admin/deployment/whatever tasks: > > http://pypi.python.org/pypi/Fabric/1.3.4 > > http://docs.fabfile.org/en/1.3.4/index.html > > Not sure which went first, but since you mentioned that you're "releasing > soon", you may want to stop the engines for a moment and reconsider the name. > > Stefan Hi Stefan - Thanks for the heads up. Fabric Engine has been going for about 2 years now. Registered company etc. I'll be sure to refer to it as Fabric Engine so there's no confusion. We were unaware there was a python tool called Fabric. Thanks, Paul From nathan.alexander.rice at gmail.com Fri Feb 10 13:14:26 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Fri, 10 Feb 2012 13:14:26 -0500 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: >> Lets also not forget that knowing an object is immutable lets you do a >> lot of optimizations; it can be inlined, it is safe to convert to a >> contiguous block of memory and stuff in cache, etc. ?If you know the >> input to a function is guaranteed to be frozen you can just go crazy. >> Being able to freeze(anyobject) seems like a pretty clear win. >> Whether or not it is pythonic is debatable. ?I'd argue if the meaning >> of pythonic in some context is limiting, we should consider updating >> the term rather than being dogmatic. Sweet, looking at the reason for rejection: 1. How dicts (and multiply nested objects) should be frozen was not completely obvious 2. "frozen()" implies in place, thus confusing users 3. freezing something like a list is confusing because some list methods would disappear or cause errors 4. Because automatic conversion in the proposal was seen as too involved to be so magical 5. Because frozendicts are the main end user benefit, and using dicts as keys was seen as "suspect" Honestly, as far as #1, we already have copy and deepcopy, the can of worms is already opened (and necessarily so). For 2, choose a better name? For 3, we have abstract base classes now, which make a nice distinction between mutable and immutable sequences; nominal types are a crutch, thinking in terms of structure is much more powerful. I agree with point 4, if magic does anything besides make the code conform to what an informed user would expect, it should be considered heretical. As for #5, I feel using a collection of key value relations as a key in another collection is not inherently bad, it just depends on the context... The mutability is the rub. Also, immutability provides scaffolding to improve performance and concurrency (both of which are top tier language features). I understand that this is one of those cases where Guido has a strong "bad feeling" about something, and I think a consequence of that is people tread lightly. Perhaps I'm a bit of a language communist in that regard (historically a dangerous philosophy :) As an aside, I find it kind of schizophrenic how on one hand Python is billed as a language for consenting adults (see duck typing, no data hiding, etc) and on the other hand users need to be protected from themselves. Better to serve just one flavor of kool-aid imo. Nathan From nagle at animats.com Fri Feb 10 13:57:34 2012 From: nagle at animats.com (John Nagle) Date: Fri, 10 Feb 2012 10:57:34 -0800 Subject: frozendict In-Reply-To: References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f356898$0$11996$742ec2ed@news.sonic.net> On 2/10/2012 10:14 AM, Nathan Rice wrote: >>> Lets also not forget that knowing an object is immutable lets you do a >>> lot of optimizations; it can be inlined, it is safe to convert to a >>> contiguous block of memory and stuff in cache, etc. If you know the >>> input to a function is guaranteed to be frozen you can just go crazy. >>> Being able to freeze(anyobject) seems like a pretty clear win. >>> Whether or not it is pythonic is debatable. I'd argue if the meaning >>> of pythonic in some context is limiting, we should consider updating >>> the term rather than being dogmatic. A real justification for the ability to make anything immutable is to make it safely shareable between threads. If it's immutable, it doesn't have to be locked for access. Mozilla's new "Rust" language takes advantage of this. Take a look at Rust's concurrency semantics. They've made some progress. John Nagle From vinay_sajip at yahoo.co.uk Fri Feb 10 14:28:52 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Fri, 10 Feb 2012 11:28:52 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. Message-ID: Sarge, a cross-platform library which wraps the subprocess module in the standard library, has been released. What does it do? ---------------- Sarge tries to make interfacing with external programs from your Python applications easier than just using subprocess alone. Sarge offers the following features: * A simple way to run command lines which allows a rich subset of Bash- style shell command syntax, but parsed and run by sarge so that you can run on Windows without cygwin (subject to having those commands available): >>> from sarge import capture_stdout >>> p = capture_stdout('echo foo | cat; echo bar') >>> for line in p.stdout: print(repr(line)) ... 'foo\n' 'bar\n' * The ability to format shell commands with placeholders, such that variables are quoted to prevent shell injection attacks. * The ability to capture output streams without requiring you to program your own threads. You just use a Capture object and then you can read from it as and when you want. Advantages over subprocess --------------------------- Sarge offers the following benefits compared to using subprocess: * The API is very simple. * It's easier to use command pipelines - using subprocess out of the box often leads to deadlocks because pipe buffers get filled up. * It would be nice to use Bash-style pipe syntax on Windows, but Windows shells don't support some of the syntax which is useful, like &&, ||, |& and so on. Sarge gives you that functionality on Windows, without cygwin. * Sometimes, subprocess.Popen.communicate() is not flexible enough for one's needs - for example, when one needs to process output a line at a time without buffering the entire output in memory. * It's desirable to avoid shell injection problems by having the ability to quote command arguments safely. * subprocess allows you to let stderr be the same as stdout, but not the other way around - and sometimes, you need to do that. Python version and platform compatibility ----------------------------------------- Sarge is intended to be used on any Python version >= 2.6 and is tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, Windows, and Mac OS X (not all versions are tested on all platforms, but sarge is expected to work correctly on all these versions on all these platforms). Finding out more ---------------- You can read the documentation at http://sarge.readthedocs.org/ There's a lot more information, with examples, than I can put into this post. You can install Sarge using "pip install sarge" to try it out. The project is hosted on BitBucket at https://bitbucket.org/vinay.sajip/sarge/ And you can leave feedback on the issue tracker there. I hope you find Sarge useful! Regards, Vinay Sajip From tkpmep at gmail.com Fri Feb 10 15:04:34 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 10 Feb 2012 12:04:34 -0800 (PST) Subject: Removing items from a list Message-ID: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> In the past, when deleting items from a list, I looped through the list in reverse to avoid accidentally deleting items I wanted to keep. I tried something different today, and, to my surprise, was able to delete items correctly, regardless of the direction in which I looped, in both Python 3.2.2. and 2..1 - does the remove() function somehow allow the iteration to continue correctly even when items are removed from the midde of the list? >>> x = list(range(10)) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> for i in x: if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> x = list(range(10)) >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] Sincerely Thomas Philips From ian.g.kelly at gmail.com Fri Feb 10 15:22:47 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 10 Feb 2012 13:22:47 -0700 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: On Fri, Feb 10, 2012 at 1:04 PM, Thomas Philips wrote: > In the past, when deleting items from a list, I looped through the > list in reverse to avoid accidentally deleting items I wanted to keep. > I tried something different today, and, to my surprise, was able to > delete items correctly, regardless of the direction in which I looped, > in both Python 3.2.2. and 2..1 - ?does the remove() function somehow > allow the iteration to continue correctly even when items are removed > from the midde of the list? No. Your test works because you never attempt to remove two adjacent items, so the skipping of items doesn't end up mattering. Try the same thing, but print out the values as you iterate over them: >>> x = list(range(10)) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> for i in x: ... print(i) ... if i % 2 == 0: ... x.remove(i) ... 0 2 4 6 8 >>> x [1, 3, 5, 7, 9] Had you attempted to remove any of the odd numbers as well, it would have failed. Cheers, Ian From python at mrabarnett.plus.com Fri Feb 10 15:26:26 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 10 Feb 2012 20:26:26 +0000 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <4F357D72.8050107@mrabarnett.plus.com> On 10/02/2012 20:04, Thomas Philips wrote: > In the past, when deleting items from a list, I looped through the > list in reverse to avoid accidentally deleting items I wanted to keep. > I tried something different today, and, to my surprise, was able to > delete items correctly, regardless of the direction in which I looped, > in both Python 3.2.2. and 2..1 - does the remove() function somehow > allow the iteration to continue correctly even when items are removed > from the midde of the list? > >>>> x = list(range(10)) >>>> x > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>> for i in x: > if i % 2 == 0: > x.remove(i) > >>>> x > [1, 3, 5, 7, 9] >>>> for i in reversed(x): > if i % 2 == 0: > x.remove(i) > >>>> x > [1, 3, 5, 7, 9] >>>> x = list(range(10)) >>>> for i in reversed(x): > if i % 2 == 0: > x.remove(i) > > >>>> x > [1, 3, 5, 7, 9] > The answer is no. For example: >>> for i in x: print("i is", i) if i % 2 == 0: x.remove(i) i is 0 i is 1 i is 2 i is 4 >>> x [0, 1, 3, 5] From amirouche.boubekki at gmail.com Fri Feb 10 15:27:54 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Fri, 10 Feb 2012 21:27:54 +0100 Subject: Forking simplejson In-Reply-To: References: Message-ID: H?llo, I did it, it wasn't that difficult actually. the source is available @ https://github.com/amirouche/jsonir there is example : https://github.com/amirouche/jsonir/blob/master/example.py What makes the implementation of __json__ awkward is the iterencode support of simplejson that I kept. I'm wondering if it makes sens to have such a feature, what do you think ? I does not support multiple json representation of an object out-of-the-box, one solution is to "__json__" hook a parameter of the encoder. I did not test it. Cheers, Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From tkpmep at gmail.com Fri Feb 10 15:48:49 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Fri, 10 Feb 2012 12:48:49 -0800 (PST) Subject: Removing items from a list References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> Thanks for the insight. I saw the behavious as soon as I extended x with a bunch of 0's >>> x = list(range(10)) >>> x.extend([0]*10) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> for i in reversed(x): if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9] >>> x = list(range(10)) >>> x.extend([0]*10) >>> x [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> for i in x: if i % 2 == 0: x.remove(i) >>> x [1, 3, 5, 7, 9, 0, 0, 0, 0, 0] From diolu at bigfoot.com Fri Feb 10 15:56:44 2012 From: diolu at bigfoot.com (Olive) Date: Fri, 10 Feb 2012 21:56:44 +0100 Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <20120210215644.6d865482@bigfoot.com> On Thu, 9 Feb 2012 17:43:58 -0800 Chris Rebert wrote: > On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote: > > hmmm, okay. > > > > So how would you round UP always? ?Say the number is 3219, so you > > want 3300 returned. > > http://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division/96921 > > Thus: (3219 + 99) // 100 > > Slight tangent: Beware negative numbers when using // or %. This trick work always (even if the entry is a float): -(-a//100)*100 >>> -(-3219//100)*100 3300 >>> -(-3200.1//100)*100 3300.0 From andrea.crotti.0 at gmail.com Fri Feb 10 15:58:35 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Fri, 10 Feb 2012 20:58:35 +0000 Subject: changing sys.path In-Reply-To: References: <4F3516CC.1070401@gmail.com> <4F3528B2.3050806@davea.name> <4F352EE8.1030101@gmail.com> <4F3539EA.80004@gmail.com> Message-ID: <4F3584FB.7050005@gmail.com> On 02/10/2012 04:00 PM, Peter Otten wrote: > Sorry, you didn't mention that in the post I responded to and I didn't > follow the thread closely. > > I found a description for declare_namespace() at > http://peak.telecommunity.com/DevCenter/PkgResources > > but the text explaining the function is completely unintelligible to me, so > I cannot contribute anything helpful here :( > Well in the end I submitted a bug report http://bugs.python.org/issue13991 I'm not sure it's really a bug and maybe I'm just doing something wrong, but to me the behavior is at least unexpected.. From gordon at panix.com Fri Feb 10 16:06:58 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 21:06:58 +0000 (UTC) Subject: How can I catch misnamed variables? Message-ID: Recently I was been bitten by some stupid errors in my code, and I'm wondering if there's a simple way to catch them. One error was of the form: my_object.some_function() .. when I hadn't declared an object named "my_object". The other error was similar: x = my_module.CONSTANT .. when I hadn't imported my_module. Of course both of these errors were deep inside a long-running function call, so it took a while for them to crop up. Is there an automated way to catch errors like these? I'm using the compileall module to build my program and it does catch some errors such as incorrect indentation, but not errors like the above. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From arnodel at gmail.com Fri Feb 10 16:17:02 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 10 Feb 2012 21:17:02 +0000 Subject: How can I catch misnamed variables? In-Reply-To: References: Message-ID: On 10 February 2012 21:06, John Gordon wrote: > Recently I was been bitten by some stupid errors in my code, and I'm > wondering if there's a simple way to catch them. > > One error was of the form: > > ?my_object.some_function() > > .. when I hadn't declared an object named "my_object". > > The other error was similar: > > ?x = my_module.CONSTANT > > .. when I hadn't imported my_module. > > Of course both of these errors were deep inside a long-running function > call, so it took a while for them to crop up. > > Is there an automated way to catch errors like these? ?I'm using the > compileall module to build my program and it does catch some errors > such as incorrect indentation, but not errors like the above. There's pychecker and pylint -- Arnaud From kevin.p.dwyer at gmail.com Fri Feb 10 16:22:32 2012 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Fri, 10 Feb 2012 21:22:32 +0000 Subject: How can I catch misnamed variables? References: Message-ID: John Gordon wrote: > Recently I was been bitten by some stupid errors in my code, and I'm > wondering if there's a simple way to catch them. > Pyflakes is another static checker that can catch these sorts of errors. Cheers, Kev From diolu at bigfoot.com Fri Feb 10 16:25:45 2012 From: diolu at bigfoot.com (Olive) Date: Fri, 10 Feb 2012 22:25:45 +0100 Subject: datetime module and timezone Message-ID: <20120210222545.4cbe6924@bigfoot.com> In the datetime module, it has support for a notion of timezone but is it possible to use one of the available timezone (I am on Linux). Linux has a notion of timezone (in my distribution, they are stored in /usr/share/zoneinfo). I would like to be able 1) to know the current timezone and 2) to be able to use the timezone available on the system. How can I do that? Olive From ben+python at benfinney.id.au Fri Feb 10 16:26:01 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 11 Feb 2012 08:26:01 +1100 Subject: How can I catch misnamed variables? References: Message-ID: <87vcne2xee.fsf@benfinney.id.au> John Gordon writes: > Is there an automated way to catch errors like these? Use a static code checker, such as ?pyflakes? (simple but limited) or ?pylint? (complex but highly configurable) to catch these and many other problems in Python code. -- \ ?It's a terrible paradox that most charities are driven by | `\ religious belief.? if you think altruism without Jesus is not | _o__) altruism, then you're a dick.? ?Tim Minchin, 2010-11-28 | Ben Finney From gordon at panix.com Fri Feb 10 16:30:07 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 21:30:07 +0000 (UTC) Subject: datetime module and timezone References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: In <20120210222545.4cbe6924 at bigfoot.com> Olive writes: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/share/zoneinfo). I would like to be able 1) to know the current > timezone and 2) to be able to use the timezone available on the system. > How can I do that? I believe the current user's timezone is stored in the TZ environment variable. I don't understand your second question. Are you asking for a list of of all the possible timezone choices? -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ethan at stoneleaf.us Fri Feb 10 16:56:38 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 10 Feb 2012 13:56:38 -0800 Subject: OT (waaaayyyyyyyyy off-topic) [was Re: How can I catch misnamed variables?] In-Reply-To: <87vcne2xee.fsf@benfinney.id.au> References: <87vcne2xee.fsf@benfinney.id.au> Message-ID: <4F359296.9090905@stoneleaf.us> Ben Finney wrote (from signature): > ?It's a terrible paradox that most charities are driven by religious > belief. . . . if you think altruism without Jesus is not altruism, > then you're a dick.? ?Tim Minchin, 2010-11-28 1) Why is it paradoxical? If anything it's a sad commentary on those who don't ascribe to a religion, as it would appear that they care less for their society. 2) altruism: unselfish regard for or devotion to the welfare of others... no mention of religion of any kind, or Jesus in particular. Altruistic-yet-paradoxically-religious-ly yours, ~Ethan~ From rosuav at gmail.com Fri Feb 10 16:58:55 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 11 Feb 2012 08:58:55 +1100 Subject: Removing items from a list In-Reply-To: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 7:04 AM, Thomas Philips wrote: > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>>> for i in x: > ? ? ? ?if i % 2 == 0: > ? ? ? ? ? ? ? ?x.remove(i) Just a quickie, is there a reason you can't use a list comprehension? x = [i for i in x if i % 2] ChrisA From clp2 at rebertia.com Fri Feb 10 17:00:16 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 14:00:16 -0800 Subject: datetime module and timezone In-Reply-To: <20120210222545.4cbe6924@bigfoot.com> References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: On Fri, Feb 10, 2012 at 1:25 PM, Olive wrote: > In the datetime module, it has support for a notion of timezone but is > it possible to use one of the available timezone (I am on Linux). Linux > has a notion of timezone (in my distribution, they are stored > in /usr/share/zoneinfo). I would like to be able 1) to know the current > timezone time.tzname gives the zone names (plural due to DST); time.timezone and time.altzone gives their UTC offsets. > and 2) to be able to use the timezone available on the system. You can use the name to look it up in pytz (http://pypi.python.org/pypi/pytz/ ). And python-dateutil (http://labix.org/python-dateutil ) can apparently parse zoneinfo files, if that's what you mean. Cheers, Chris From umedoblock at gmail.com Fri Feb 10 17:06:22 2012 From: umedoblock at gmail.com (umedoblock) Date: Sat, 11 Feb 2012 07:06:22 +0900 Subject: why does subtype_dict() and getset_get() makes infinite loop ? Message-ID: <4F3594DE.206@gmail.com> Hi, everyone. I'm umedoblock. now, I wrote a below sentence. But I cannot debug below infinite loop. Do I mistake when I write a c exetension ? I attached sample code. Please help me. ========================================== Python 3.2.2 (default, Jan 27 2012, 03:19:53) [GCC 4.6.1] on linux2 class Bar_abstract(metaclass=ABCMeta): pass # c extension # class Bar_base(Bar_abstract): # pass class Bar(Bar_base): pass ========================================== but do this bar = Bar() dir(bar) then python3.2.2 generates a core. Because subtype_dict() and getset_get() makes infinite loop. I checked stack with GDB. ================================================================== #130948 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130949 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 #130950 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130951 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 #130952 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44, type=0x88ba4cc) at ../Objects/descrobject.c:148 #130953 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0) at ../Objects/typeobject.c:1756 ================================================================== GDB show me above code. Now, I suspect below point PyObject_GetAttrString(). But I cannot debug this infinite loop. Do I mistake when I write a c exetension ? I attached sample code. Please help me. ojects/object.c:1325 static PyObject * _generic_dir(PyObject *obj) { PyObject *result = NULL; PyObject *dict = NULL; PyObject *itsclass = NULL; /* Get __dict__ (which may or may not be a real dict...) */ >>> dict = PyObject_GetAttrString(obj, "__dict__"); -------------- next part -------------- A non-text attachment was scrubbed... Name: bar_ext.zip Type: application/zip Size: 3156 bytes Desc: not available URL: From steve+comp.lang.python at pearwood.info Fri Feb 10 17:23:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Feb 2012 22:23:55 GMT Subject: Read-only attribute in module References: <878vkc426c.fsf@benfinney.id.au> <4f346d28$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3598fb$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once >> attributes. > > So propose that propery() work at module level, for module attributes, > as well as for class attributes. I'm not wedded to a specific implementation. Besides, it's not just a matter of saying "property should work in modules" -- that would require the entire descriptor protocol work for module lookups, and I don't know how big a can of worms that is. Constant names is a lot more constrained than computed name lookups. -- Steven From tjreedy at udel.edu Fri Feb 10 17:29:36 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 10 Feb 2012 17:29:36 -0500 Subject: Read-only attribute in module In-Reply-To: <1328872312611-4382967.post@n6.nabble.com> References: <1328872312611-4382967.post@n6.nabble.com> Message-ID: On 2/10/2012 6:11 AM, mloskot wrote: > The intent of xyz.flag is that it is a value set by the module internally. > xyz is a module wrapping a C library. > The C library defines concept of a global flag set by the C functions at > some events, > so user can check value of this flag. > I can provide access to it with function: xyz.get_flag() If the value of the flag can change during a run, I would do that. Otherwise, you have to make sure the local copy keeps in sync. Users might also think that it is a true constant that they could read once. I understand that you might be concerned that one person in a multi-programmer project might decide to rebind xyz.flag and mess up everyone else. I think the real solution might be an option to freeze an entire module. -- Terry Jan Reedy From kevin.p.dwyer at gmail.com Fri Feb 10 17:37:18 2012 From: kevin.p.dwyer at gmail.com (Kev Dwyer) Date: Fri, 10 Feb 2012 22:37:18 +0000 Subject: log and figure out what bits are slow and optimize them. References: Message-ID: sajuptpm wrote: > Hi, > > Yes i saw profile module, > I think i have to do function call via > > cProfile.run('foo()') > > I know, we can debug this way. > > But, i need a fixed logging system and want to use it in production. > I think, we can't permanently include profile's debugging code > in source code, > will cause any performance issue ?? *Any* instrumentation code is going to affect performance. It's a trade-off that you need to analyse and manage in the context of your application. From ben+python at benfinney.id.au Fri Feb 10 17:45:28 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sat, 11 Feb 2012 09:45:28 +1100 Subject: OT (waaaayyyyyyyyy off-topic) References: <87vcne2xee.fsf@benfinney.id.au> Message-ID: <87mx8q2tpz.fsf@benfinney.id.au> Thanks for responding. Rather than take this discussion too far where it's quite off-topic, I'll respond briefly and ask for a change of forum if we want to continue. Ethan Furman writes: > Ben Finney wrote (from signature): > > ?It's a terrible paradox that most charities are driven by religious > > belief. . . . if you think altruism without Jesus is not altruism, > > then you're a dick.? ?Tim Minchin, 2010-11-28 The quote is from an interview with Tim Minchin . > 1) Why is it paradoxical? If anything it's a sad commentary on those > who don't ascribe to a religion, as it would appear that they care > less for their society. It's an outcome of history that religious institutions have historically been well-situated to be the facilitators of charitable work (and much other work) simply because they have been ubiquitous in most societies. The paradox is that they spend much of their resources away from the worldly, i.e. secular, work of charity. But charitable work is not dependent on religious belief, and indeed in recent decades there are now a great many wholly secular charities (e.g. International Red Cross and Oxfam) which do not divert their resources from addressing the real world. > 2) altruism: unselfish regard for or devotion to the welfare of > others... no mention of religion of any kind, or Jesus in particular. Yes, that's the point. Altruism is a human activity independent of religious belief, yet the default assumption of too many is that they are somehow necessarily connected. > Altruistic-yet-paradoxically-religious-ly yours, As you rightly point out, this discussion is off-topic here. So while I'm open to discussion on this topic, we should move it to some other forum. -- \ ?Most people, I think, don't even know what a rootkit is, so | `\ why should they care about it?? ?Thomas Hesse, Sony BMG, 2006 | _o__) | Ben Finney From no.email at nospam.invalid Fri Feb 10 17:52:34 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 10 Feb 2012 14:52:34 -0800 Subject: Fabric Engine + Python benchmarks References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> Message-ID: <7xhayy9u8d.fsf@ruckus.brouhaha.com> Fabric Paul writes: > Hi Stefan - Thanks for the heads up. Fabric Engine has been going for > about 2 years now. Registered company etc. I'll be sure to refer to it > as Fabric Engine so there's no confusion. We were unaware there was a > python tool called Fabric. There will still be confusion. The Fabric configuration tool is quite well known in the python and sysadmin communities, so it will be the first thing people will think of. If you weren't already aware of it, I'd guess you're pretty far out of contact with Python's existing user population, so there may be further sources of mismatch between your product and what else is out there (I'm thinking of Stackless, PyPy, etc.) Still, yoour product sounds pretty cool. From vincent.vandevyvre at swing.be Fri Feb 10 17:54:12 2012 From: vincent.vandevyvre at swing.be (Vincent Vande Vyvre) Date: Fri, 10 Feb 2012 23:54:12 +0100 Subject: Removing items from a list In-Reply-To: <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> <66f4c010-31f4-4aa5-851e-48ec174c0b96@t24g2000yqj.googlegroups.com> Message-ID: <4F35A014.1050700@swing.be> An HTML attachment was scrubbed... URL: From pluijzer at gmail.com Fri Feb 10 18:01:52 2012 From: pluijzer at gmail.com (Righard van Roy) Date: Sat, 11 Feb 2012 00:01:52 +0100 Subject: Postpone evaluation of argument Message-ID: Hello, I want to add an item to a list, except if the evaluation of that item results in an exception. I could do that like this: def r(x): if x > 3: raise(ValueError) try: list.append(r(1)) except: pass try: list.append(r(5)) except: pass This looks rather clumbsy though, and it does not work with i.e. list comprehensions. I was thinking of writing a decorator like this: def tryAppendDecorator(fn): def new(*args): try: fn(*args) except: pass return new @tryAppendDecorator def tryAppend(list, item): list.append(item) tryAppend(list, r(1)) tryAppend(list, r(5)) This does not work however because the 'item' argument gets evaluated before the decorator does it's magic. Is there a way to postpone the evaluation of 'item' till it gets used inside the decorator. Like it is possible to quote a form in Lisp. Thank you, Righard From gordon at panix.com Fri Feb 10 18:06:52 2012 From: gordon at panix.com (John Gordon) Date: Fri, 10 Feb 2012 23:06:52 +0000 (UTC) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: In Kev Dwyer writes: > *Any* instrumentation code is going to affect performance. Funny story about that... I wanted to profile some code of mine, and a colleague recommended the 'hotshot' module. It's pretty easy to use: there are functions to start profiling, stop profiling and print results. So I added the function calls and ran my code.... and it took a really long time. I mean a REALLY long time. In fact I eventually had to kill the process. I briefly wondered if my coworker was playing a prank on me... then I realized that I had neglected to call the function to stop profiling! So when I went to print the results, it was still profiling... endlessly. (Okay, maybe it wasn't that funny.) -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From clp2 at rebertia.com Fri Feb 10 18:12:38 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 10 Feb 2012 15:12:38 -0800 Subject: Postpone evaluation of argument In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 3:01 PM, Righard van Roy wrote: > Hello, > > I want to add an item to a list, except if the evaluation of that item > results in an exception. > I could do that like this: > > def r(x): > ? ?if x > 3: > ? ? ? ?raise(ValueError) > > try: > ? ?list.append(r(1)) > except: > ? ?pass > try: > ? ?list.append(r(5)) > except: > ? ?pass > > This looks rather clumbsy though, and it does not work with i.e. list > comprehensions. > > I was thinking of writing a decorator like this: > > def tryAppendDecorator(fn): > ? ?def new(*args): > ? ? ? ?try: > ? ? ? ? ? ?fn(*args) > ? ? ? ?except: > ? ? ? ? ? ?pass > ? ?return new > > @tryAppendDecorator > def tryAppend(list, item): > ? ?list.append(item) > > tryAppend(list, r(1)) > tryAppend(list, r(5)) > > This does not work however because the 'item' argument gets evaluated > before the decorator does it's magic. > > Is there a way to postpone the evaluation of 'item' till it gets used > inside the decorator. Like it is possible to quote a form in Lisp. Nope. All arguments always get evaluated before control passes to the callee. You'd have to "quote" the arguments manually by putting them in lambdas, thus explicitly delaying their evaluation. Cheers, Chris -- http://rebertia.com From lists at cheimes.de Fri Feb 10 18:21:11 2012 From: lists at cheimes.de (Christian Heimes) Date: Sat, 11 Feb 2012 00:21:11 +0100 Subject: How can I catch misnamed variables? In-Reply-To: References: Message-ID: Am 10.02.2012 22:06, schrieb John Gordon: > Is there an automated way to catch errors like these? I'm using the > compileall module to build my program and it does catch some errors > such as incorrect indentation, but not errors like the above. Write unit tests and use coverage to aim for 100% code and branch coverage. If you want to write high quality code and avoid problems like misnamed variables then you have to write unit tests and functional tests for your program. I'm well aware that it's hard and requires time. But in the long run it will *save* lots of time. From no.email at nospam.invalid Fri Feb 10 18:57:56 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Fri, 10 Feb 2012 15:57:56 -0800 Subject: Postpone evaluation of argument References: Message-ID: <7xsjii2qd7.fsf@ruckus.brouhaha.com> Righard van Roy writes: > I want to add an item to a list, except if the evaluation of that item > results in an exception. This may be overkill and probably slow, but perhaps most in the spirit that you're asking. from itertools import chain def r(x): if x > 3: raise(ValueError) return x def maybe(func): try: yield func() except: return def p(i): return maybe(lambda: r(i)) your_list = list(chain(p(1), p(5))) print your_list From marduk at letterboxes.org Fri Feb 10 18:59:35 2012 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Fri, 10 Feb 2012 18:59:35 -0500 Subject: Fabric Engine + Python benchmarks In-Reply-To: <7xhayy9u8d.fsf@ruckus.brouhaha.com> References: <6277efff-3aa8-4e35-bb89-dfd0dcc03f20@c6g2000vbk.googlegroups.com> <8f6c5726-7479-4d49-8489-bb397605c470@s7g2000vby.googlegroups.com> <7xhayy9u8d.fsf@ruckus.brouhaha.com> Message-ID: <1328918375.151158.3.camel@stretch.local> On Fri, 2012-02-10 at 14:52 -0800, Paul Rubin wrote: > Fabric Paul writes: > > Hi Stefan - Thanks for the heads up. Fabric Engine has been going for > > about 2 years now. Registered company etc. I'll be sure to refer to it > > as Fabric Engine so there's no confusion. We were unaware there was a > > python tool called Fabric. > > There will still be confusion. The Fabric configuration tool is quite > well known in the python and sysadmin communities, so it will be the > first thing people will think of. If you weren't already aware of it, > I'd guess you're pretty far out of contact with Python's existing user > population, so there may be further sources of mismatch between your > product and what else is out there (I'm thinking of Stackless, PyPy, > etc.) Still, yoour product sounds pretty cool. > Indeed. When I first saw the subject header I thought it was referring to the Python-based deployment tool. It's just going to confuse people. It's enough already that we have a bunch of stuff with "pi" and "py" in the name :| Does the OSS community *really* need another "Firebird" incident? -a From ethan at stoneleaf.us Fri Feb 10 19:38:41 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 10 Feb 2012 16:38:41 -0800 Subject: ANN: dbf.py 0.90.001 Message-ID: <4F35B891.5010701@stoneleaf.us> Still messing with .dbf files? Somebody brought you a 15 year old floppy, which still luckily (?) worked, and now wants that ancient data? dbf to the rescue! Supported tables/features ========================= - dBase III - FoxPro - Visual FoxPro supported - Null value Supported field types ===================== - Char - Date - Logical - Memo - Numeric - Currency (returns Decimal) - DateTime - Double - Float (same as Numeric) - General - Integer - Picture Still to come (or, Not Yet Working ;) ===================================== - Index files (although you can create temporary memory indices) - auto incrementing fields Latest version can be found on PyPI at http://pypi.python.org/pypi/dbf. Comments, bug reports, etc, appreciated! ~Ethan~ From 7stud at excite.com Fri Feb 10 21:48:10 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 18:48:10 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self Message-ID: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> The following code demonstrates that a collections.defaultdict is shelve worthy: import shelve import collections as c dd = c.defaultdict(int) dd["Joe"] = 3 print(dd) my_shelve = shelve.open('data.shelve') my_shelve['strike_record'] = dd my_shelve.close() my_shelve = shelve.open('data.shelve') data = my_shelve['strike_record'] my_shelve.close() dd.clear() dd.update(data) print(dd) --output:-- defaultdict(, {'Joe': 3}) defaultdict(, {'Joe': 3}) And the following code demonstrates that a class that inherits from dict can shelve itself: import collections as c import shelve class Dog(dict): def __init__(self): super().__init__(Joe=1) print('****', self) def save(self): my_shelve = shelve.open('data22.shelve') my_shelve['x'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.shelve') data = my_shelve['x'] my_shelve.close() print(data) d = Dog() d.save() d.load() --output:-- **** {'Joe': 1} {'Joe': 1} But I cannot get a class that inherits from collections.defaultdict to shelve itself: import collections as c import shelve class Dog(c.defaultdict): def __init__(self): super().__init__(int, Joe=0) print('****', self) def save(self): my_shelve = shelve.open('data22.shelve') my_shelve['dd'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.shelve') data = my_shelve['dd'] my_shelve.close() print(data) d = Dog() d.save() d.load() --output:-- **** defaultdict(, {'Joe': 30}) Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 111, in __getitem__ value = self.cache[key] KeyError: 'dd' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "3.py", line 95, in d.load() File "3.py", line 87, in load data = my_shelve['dd'] File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 114, in __getitem__ value = Unpickler(f).load() TypeError: __init__() takes exactly 1 positional argument (2 given) I deleted all *.shelve.db files between program runs. I can't figure out what I'm doing wrong. From 7stud at excite.com Fri Feb 10 21:52:08 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 18:52:08 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: <18ac41a4-4afa-472d-99fa-b60185d12943@m5g2000yqk.googlegroups.com> On Feb 10, 7:48?pm, 7stud <7s... at excite.com> wrote: > > But I cannot get a class that inherits from collections.defaultdict to > shelve itself: > > import collections as c > import shelve > > class Dog(c.defaultdict): > ? ? def __init__(self): > ? ? ? ? super().__init__(int, Joe=0) > ? ? ? ? print('****', self) Whoops. I changed: super().__init__(int, Joe=0) to: super().__init__(int, Joe=30) hence this output.. > --output:-- > > **** defaultdict(, {'Joe': 30}) From 7stud at excite.com Fri Feb 10 22:30:47 2012 From: 7stud at excite.com (7stud) Date: Fri, 10 Feb 2012 19:30:47 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> <18ac41a4-4afa-472d-99fa-b60185d12943@m5g2000yqk.googlegroups.com> Message-ID: <9258636e-b975-4f7b-8c52-57d089e832c2@c21g2000yqi.googlegroups.com> On Feb 10, 7:52?pm, 7stud <7s... at excite.com> wrote: I don't know if this helps, but I notice when I initially do this: shelve.open('data22') the file is saved as 'data22.db'. But on subsequent calls to shelve.open(), if I use the file name 'data22.db', I get a different error: --output:-- **** defaultdict(, {'Joe': 30}) Traceback (most recent call last): File "3.py", line 95, in d.load() File "3.py", line 86, in load my_shelve = shelve.open('data22.db') File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 232, in open return DbfilenameShelf(filename, flag, protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/shelve.py", line 216, in __init__ Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback) File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ python3.2/dbm/__init__.py", line 83, in open raise error[0]("db type could not be determined") dbm.error: db type could not be determined The code that produced that error: import collections as c import shelve class Dog(c.defaultdict): def __init__(self): super().__init__(int, Joe=30) print('****', self) def save(self): my_shelve = shelve.open('data22') my_shelve['dd'] = self my_shelve.close() def load(self): my_shelve = shelve.open('data22.db') data = my_shelve['dd'] my_shelve.close() print(data) d = Dog() d.save() d.load() I'm using python 3.2.2. From dihedral88888 at googlemail.com Sat Feb 11 00:52:59 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 10 Feb 2012 21:52:59 -0800 (PST) Subject: frozendict In-Reply-To: <4f356898$0$11996$742ec2ed@news.sonic.net> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f356898$0$11996$742ec2ed@news.sonic.net> Message-ID: <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?11????UTC+8??2?57?34??John Nagle??? > On 2/10/2012 10:14 AM, Nathan Rice wrote: > >>> Lets also not forget that knowing an object is immutable lets you do a > >>> lot of optimizations; it can be inlined, it is safe to convert to a > >>> contiguous block of memory and stuff in cache, etc. If you know the > >>> input to a function is guaranteed to be frozen you can just go crazy. > >>> Being able to freeze(anyobject) seems like a pretty clear win. > >>> Whether or not it is pythonic is debatable. I'd argue if the meaning > >>> of pythonic in some context is limiting, we should consider updating > >>> the term rather than being dogmatic. > > A real justification for the ability to make anything immutable is > to make it safely shareable between threads. If it's immutable, it > doesn't have to be locked for access. Mozilla's new "Rust" > language takes advantage of this. Take a look at Rust's concurrency > semantics. They've made some progress. > > John Nagl Lets model the system as an asynchronous set of objects with multiple threads performing operatons on objects as in the above. This reminds me the old problem solved before in the digital hardware. From bob.martin at excite.com Sat Feb 11 02:05:21 2012 From: bob.martin at excite.com (Bob Martin) Date: Sat, 11 Feb 2012 07:05:21 GMT Subject: datetime module and timezone References: <20120210222545.4cbe6924@bigfoot.com> Message-ID: <9pmi9iFufgU1@mid.individual.net> in 671891 20120210 212545 Olive wrote: >In the datetime module, it has support for a notion of timezone but is >it possible to use one of the available timezone (I am on Linux). Linux >has a notion of timezone (in my distribution, they are stored >in /usr/share/zoneinfo). I would like to be able 1) to know the current >timezone and 2) to be able to use the timezone available on the system. >How can I do that? For 1) just type "date" on the command line. From sajuptpm at gmail.com Sat Feb 11 02:27:31 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 23:27:31 -0800 (PST) Subject: ldap proxy user bind Message-ID: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> I have developed a LDAP auth system using python-ldap module. Using that i can validate username and password, fetch user and groups info from LDAP directory. Now i want to implement ldap proxy user bind to the ldap server. I googled and find this http://ldapwiki.willeke.com/wiki/LDAPProxyUser But i don't have any idea about how implement it usng python-ldap. My existing LDAP settings at client side ldap_enabled = True ldap_host = your_ldap_server ldap_port = 389 ldap_basedn = o=My_omain ldap_user_key = cn ldap_group_key = groupMembership ldap_email_key = mail ldap_user_search = ou=Users ldap_group_search = ou=Groups ldap_group_objectclass = groupOfNames I want to add following 2 new flags ldap_proxy_user = ldap_proxy ldap_proxy_pwd = secret I don't know how this ldapproxy system would works. Could you please point me to an python article/example ?? From sajuptpm at gmail.com Sat Feb 11 02:53:42 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Fri, 10 Feb 2012 23:53:42 -0800 (PST) Subject: log and figure out what bits are slow and optimize them. References: Message-ID: I decided to create a decorator like. import cProfile def debug_time(method): def timed(*args, **kw): prof = cProfile.Profile() prof.enable(subcalls=False, builtins=False) result = prof.runcall(method, *args, **kw) #prof.print_stats() msg = "\n\n\n\n#######################################" msg += "\n\nURL : %s" %(tg.request.url) msg += "\nMethod: %r" %(method.__name__) print "--ddd--------", type(prof.getstats()) msg += "\n\nStatus : %s" %(prof.print_stats()) msg += "\n\n#######################################" print msg LOGGER.info(msg) return result return timed Ref : http://stackoverflow.com/questions/5375624/a-decorator-that-profiles-a-method-call-and-logs-the-profiling-result I want to log it in existing log file in my project, so i tried prof.print_stats() and prof.getstats(). prof.getstats() will need extra loop for fetch data. prof.print_stats() will log library calls also. Please suggest a better way to log profiler output. From jpiitula at ling.helsinki.fi Sat Feb 11 03:54:10 2012 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: 11 Feb 2012 10:54:10 +0200 Subject: Postpone evaluation of argument References: Message-ID: Righard van Roy writes: > Hello, > > I want to add an item to a list, except if the evaluation of that item > results in an exception. > I could do that like this: > > def r(x): > if x > 3: > raise(ValueError) > > try: > list.append(r(1)) > except: > pass > try: > list.append(r(5)) > except: > pass > > This looks rather clumbsy though, and it does not work with i.e. list > comprehensions. > > I was thinking of writing a decorator like this: > > def tryAppendDecorator(fn): > def new(*args): > try: > fn(*args) > except: > pass > return new > > @tryAppendDecorator > def tryAppend(list, item): > list.append(item) > > tryAppend(list, r(1)) > tryAppend(list, r(5)) > > This does not work however because the 'item' argument gets evaluated > before the decorator does it's magic. > > Is there a way to postpone the evaluation of 'item' till it gets used > inside the decorator. Like it is possible to quote a form in Lisp. That's not considered good practice in Lisp either. One would use a lambda expression to delay the computation, as others have suggested. You might be able to arrange your program so that tryAppend is called with the error-raising function and its arguments separately. I mean like this: def r(x): if x > 3: raise(ValueError) return x def tryAppendDecorator(fn): def new(xs, f, *args): try: fn(xs, f(*args)) except: pass return new @tryAppendDecorator def tryAppend(items, item): items.append(item) sub3 = [] tryAppend(sub3, r, 3) tryAppend(sub3, r, 1) tryAppend(sub3, r, 4) tryAppend(sub3, r, 1) tryAppend(sub3, r, 5) Maybe you should only ignore some specific type of exception, like ValueError if you are specifically using r as a filter whose task it is to raise a ValueError. From jeyamithraj at gmail.com Sat Feb 11 04:22:23 2012 From: jeyamithraj at gmail.com (Jeya Mithra Jeyandran) Date: Sat, 11 Feb 2012 01:22:23 -0800 (PST) Subject: Orphanage Funds Message-ID: <5ca1f5eb-ba92-4b73-a9b3-f4a772c6902b@sw7g2000pbc.googlegroups.com> Hi, I am Mithra. Me and my friends joined together ti help the orphanage people after visiting their home once. There are nearly 100 students interested in studies but they dont have enough fund to be provided for their studies. Please help them by donating as much as you can. Thanks for your help. Please forward this mail for your friends. Please click the following link to donate : http://www.gofundme.com/dij30 Thanks in Advance From hniksic at xemacs.org Sat Feb 11 05:26:08 2012 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Sat, 11 Feb 2012 11:26:08 +0100 Subject: round down to nearest number References: <460b3d7b-d2ce-492a-ab61-ea4a1ee58198@1g2000yqv.googlegroups.com> Message-ID: <878vk93bun.fsf@xemacs.org> Terry Reedy writes: > On 2/9/2012 8:23 PM, noydb wrote: >> So how would you round UP always? Say the number is 3219, so you want >>>> (3333//100+1)*100 > 3400 Note that that doesn't work for numbers that are already round: >>> (3300//100+1)*100 3400 # 3300 would be correct I'd go with Chris Rebert's (x + 99) // 100. From dihedral88888 at googlemail.com Sat Feb 11 06:16:39 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 11 Feb 2012 03:16:39 -0800 (PST) Subject: Postpone evaluation of argument In-Reply-To: <7xsjii2qd7.fsf@ruckus.brouhaha.com> References: <7xsjii2qd7.fsf@ruckus.brouhaha.com> Message-ID: <412049.429.1328958999552.JavaMail.geo-discussion-forums@pbctz8> ? 2012?2?11????UTC+8??7?57?56??Paul Rubin??? > Righard van Roy > writes: > > I want to add an item to a list, except if the evaluation of that item > > results in an exception. > > This may be overkill and probably slow, but perhaps most in the spirit > that you're asking. > > from itertools import chain > > def r(x): > if x > 3: > raise(ValueError) > return x > > def maybe(func): > try: > yield func() > except: > return > I am wondering at which level to yield in a nested decorated function is more controllable. It is definitely wrong to yield in manny levels decorated. > def p(i): return maybe(lambda: r(i)) > > your_list = list(chain(p(1), p(5))) > print your_list From waqif at smartbaba.com Sat Feb 11 08:34:50 2012 From: waqif at smartbaba.com (Smart Baba) Date: Sat, 11 Feb 2012 05:34:50 -0800 (PST) Subject: Have your own business web Message-ID: <7f4fd3ba-fc17-4ad9-8564-d5faca19a336@q8g2000pbb.googlegroups.com> Smart Baba new year special price offer, Basic website = 132 $ only, Standard website = 271 $ and Dynamic website = 408 $. Now have your own business customized professional website and start promoting your business. For further details, Follow us at: www.websitedeals.in From therve at free.fr Sat Feb 11 08:35:15 2012 From: therve at free.fr (=?UTF-8?B?VGhvbWFzIEhlcnbDqQ==?=) Date: Sat, 11 Feb 2012 14:35:15 +0100 Subject: Twisted 12.0.0 released Message-ID: <4F366E93.80804@free.fr> On behalf of Twisted Matrix Laboratories, I am honored to announce the release of Twisted 12.0. 47 tickets are closed by this release, among them: * A fix to the GTK2 reactor preventing unnecessary wake-ups * Preliminary support of IPV6 on the server side * Several fixes to the new protocol-based TLS implementation * Improved core documentation's main page Twisted no longer supports Python 2.4, the latest supported version is 2.5. For more information, see the NEWS file here: http://twistedmatrix.com/Releases/Twisted/12.0/NEWS.txt Download it now from: http://pypi.python.org/packages/source/T/Twisted/Twisted-12.0.0.tar.bz2 or http://pypi.python.org/packages/2.5/T/Twisted/Twisted-12.0.0.win32-py2.5.msi or http://pypi.python.org/packages/2.6/T/Twisted/Twisted-12.0.0.win32-py2.6.msi or http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.0.0.win32-py2.7.msi Thanks to the supporters of the Twisted Software Foundation and to the many contributors for this release. -- Thomas From rodrick.brown at gmail.com Sat Feb 11 12:37:40 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Sat, 11 Feb 2012 12:37:40 -0500 Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: On Fri, Feb 10, 2012 at 2:28 PM, Vinay Sajip wrote: > Sarge, a cross-platform library which wraps the subprocess module in > the standard library, has been released. > > What does it do? > ---------------- > > Sarge tries to make interfacing with external programs from your > Python applications easier than just using subprocess alone. > > Sarge offers the following features: > > * A simple way to run command lines which allows a rich subset of Bash- > style shell command syntax, but parsed and run by sarge so that you > can run on Windows without cygwin (subject to having those commands > available): > > >>> from sarge import capture_stdout > >>> p = capture_stdout('echo foo | cat; echo bar') > >>> for line in p.stdout: print(repr(line)) > ... > 'foo\n' > 'bar\n' > > * The ability to format shell commands with placeholders, such that > variables are quoted to prevent shell injection attacks. > > * The ability to capture output streams without requiring you to > program your own threads. You just use a Capture object and then you > can read from it as and when you want. > > Advantages over subprocess > --------------------------- > > Sarge offers the following benefits compared to using subprocess: > > * The API is very simple. > > * It's easier to use command pipelines - using subprocess out of the > box often leads to deadlocks because pipe buffers get filled up. > > * It would be nice to use Bash-style pipe syntax on Windows, but > Windows shells don't support some of the syntax which is useful, like > &&, ||, |& and so on. Sarge gives you that functionality on Windows, > without cygwin. > > * Sometimes, subprocess.Popen.communicate() is not flexible enough for > one's needs - for example, when one needs to process output a line at > a time without buffering the entire output in memory. > > * It's desirable to avoid shell injection problems by having the > ability to quote command arguments safely. > > * subprocess allows you to let stderr be the same as stdout, but not > the other way around - and sometimes, you need to do that. > > Python version and platform compatibility > ----------------------------------------- > > Sarge is intended to be used on any Python version >= 2.6 and is > tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, > Windows, and Mac OS X (not all versions are tested on all platforms, > but sarge is expected to work correctly on all these versions on all > these platforms). > > Finding out more > ---------------- > > You can read the documentation at > > http://sarge.readthedocs.org/ > > There's a lot more information, with examples, than I can put into > this post. > > You can install Sarge using "pip install sarge" to try it out. The > project is hosted on BitBucket at > > https://bitbucket.org/vinay.sajip/sarge/ > > And you can leave feedback on the issue tracker there. > > I hope you find Sarge useful! > > Regards, > > This is pretty cool I think ill check it out! I really hate working with subprocess it just seems a bit too low level for my taste. > > Vinay Sajip > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevinmurphy9999 at gmail.com Sat Feb 11 12:40:09 2012 From: kevinmurphy9999 at gmail.com (Kevin Murphy) Date: Sat, 11 Feb 2012 09:40:09 -0800 (PST) Subject: MySQL: AttributeError: cursor Message-ID: Hi All, I'm using Python 2.7 and having a problem creating the cursor below. Any suggestions would be appreciated! import sys import _mysql print "cursor test" db = _mysql.connect(host="localhost",user="root",passwd="mypw",db="python- test") cursor = db.cursor() >>> cursor test Traceback (most recent call last): File "C:\Python27\dbconnect.py", line 8, in cursor = db.cursor() AttributeError: cursor From ian.g.kelly at gmail.com Sat Feb 11 12:46:00 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:46:00 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Fri, Feb 10, 2012 at 7:48 PM, 7stud <7stud at excite.com> wrote: > But I cannot get a class that inherits from collections.defaultdict to > shelve itself: > > > import collections as c > import shelve > > class Dog(c.defaultdict): > ? ?def __init__(self): > ? ? ? ?super().__init__(int, Joe=0) > ? ? ? ?print('****', self) > > ? ?def save(self): > ? ? ? ?my_shelve = shelve.open('data22.shelve') > ? ? ? ?my_shelve['dd'] = self > ? ? ? ?my_shelve.close() > > ? ?def load(self): > ? ? ? ?my_shelve = shelve.open('data22.shelve') > ? ? ? ?data = my_shelve['dd'] > ? ? ? ?my_shelve.close() > > ? ? ? ?print(data) > > > d = Dog() > d.save() > d.load() > > --output:-- > > **** defaultdict(, {'Joe': 30}) > Traceback (most recent call last): > ?File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ > python3.2/shelve.py", line 111, in __getitem__ > ? ?value = self.cache[key] > KeyError: 'dd' > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > ?File "3.py", line 95, in > ? ?d.load() > ?File "3.py", line 87, in load > ? ?data = my_shelve['dd'] > ?File "/Library/Frameworks/Python.framework/Versions/3.2/lib/ > python3.2/shelve.py", line 114, in __getitem__ > ? ?value = Unpickler(f).load() > TypeError: __init__() takes exactly 1 positional argument (2 given) > > > > I deleted all *.shelve.db files between program runs. ?I can't figure > out what I'm doing wrong. The problem is that defaultdict defines a custom __reduce__ method which is used by the pickle protocol to determine how the object should be reconstructed. It uses this to reconstruct the defaultdict with the same default factory, by calling the type with a single argument of the default factory. Since your subclass's __init__ method takes no arguments, this results in the error you see. There are a couple of ways you could fix this. The first would be to change the signature of the __init__ method to take an optional argument accepting the default factory instead of hard-coding it, like this: def __init__(self, default_factory=int): super().__init__(default_factory, Joe=0) The other would be to just fix the __reduce__ method to not pass the default factory to your initializer, since it is hard-coded. That would look like this: def __reduce__(self): return (type(self), ()) Cheers, Ian From ian.g.kelly at gmail.com Sat Feb 11 12:54:58 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:54:58 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 10:46 AM, Ian Kelly wrote: > The problem is that defaultdict defines a custom __reduce__ method > which is used by the pickle protocol to determine how the object > should be reconstructed. ?It uses this to reconstruct the defaultdict > with the same default factory, by calling the type with a single > argument of the default factory. ?Since your subclass's __init__ > method takes no arguments, this results in the error you see. > > There are a couple of ways you could fix this. ?The first would be to > change the signature of the __init__ method to take an optional > argument accepting the default factory instead of hard-coding it, like > this: > > ? ?def __init__(self, default_factory=int): > ? ? ? ?super().__init__(default_factory, Joe=0) > > The other would be to just fix the __reduce__ method to not pass the > default factory to your initializer, since it is hard-coded. ?That > would look like this: > > ? ?def __reduce__(self): > ? ? ? ?return (type(self), ()) It occurs to me that there's also an option 3: you don't really need a defaultdict to do what you're trying to do here. You just need a dict with a custom __missing__ method. That could look something like this: class Dog(dict): def __missing__(self): return 0 And then you don't have to worry about the weird pickle behavior of defaultdict at all. Cheers, Ian From ian.g.kelly at gmail.com Sat Feb 11 12:56:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 11 Feb 2012 10:56:12 -0700 Subject: problems with shelve(), collections.defaultdict, self In-Reply-To: References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote: > class Dog(dict): > > ? ?def __missing__(self): > ? ? ? ?return 0 Sorry, that should have been: class Dog(dict): def __missing__(self, key): return 0 Cheers, Ian From marduk at letterboxes.org Sat Feb 11 13:07:25 2012 From: marduk at letterboxes.org (Albert W. Hopkins) Date: Sat, 11 Feb 2012 13:07:25 -0500 Subject: MySQL: AttributeError: cursor In-Reply-To: References: Message-ID: <1328983645.608779.3.camel@stretch.local> On Sat, 2012-02-11 at 09:40 -0800, Kevin Murphy wrote: > Hi All, > I'm using Python 2.7 and having a problem creating the cursor below. > Any suggestions would be appreciated! > > import sys > import _mysql > > print "cursor test" > > db = > _mysql.connect(host="localhost",user="root",passwd="mypw",db="python- > test") > > cursor = db.cursor() > > >>> > cursor test > > Traceback (most recent call last): > File "C:\Python27\dbconnect.py", line 8, in > cursor = db.cursor() > AttributeError: cursor You are using the low-level C API wrapper (not sure why). Most people, I believe, would use the pythonic API: >>> import MySQLdb >>> db = MySQLdb.connect(host='localhost', user='root', passwd='mypw', db='python-test') >>> cursor = db.cursor() The low-level API is... well.. for when you want to do low-level stuff. You probably want the pythonic API. -a From franck at ditter.org Sat Feb 11 13:15:24 2012 From: franck at ditter.org (Franck Ditter) Date: Sat, 11 Feb 2012 19:15:24 +0100 Subject: Stopping a looping computation in IDLE 3.2.x Message-ID: How do you stop a looping computation with IDLE 3.2.x on MacOS-X Lion ? It hangs with the colored wheel... Ctl-C does not work. Thanks, franck From 7stud at excite.com Sat Feb 11 14:22:14 2012 From: 7stud at excite.com (7stud) Date: Sat, 11 Feb 2012 11:22:14 -0800 (PST) Subject: problems with shelve(), collections.defaultdict, self References: <24d4f1d8-050c-460d-ba98-446d4206a3aa@1g2000yqv.googlegroups.com> Message-ID: On Feb 11, 10:56?am, Ian Kelly wrote: > On Sat, Feb 11, 2012 at 10:54 AM, Ian Kelly wrote: > > class Dog(dict): > > > ? ?def __missing__(self): > > ? ? ? ?return 0 > > Sorry, that should have been: > > class Dog(dict): > > ? ? def __missing__(self, key): > ? ? ? ? return 0 > > Cheers, > Ian Thanks Ian! From bahamutzero8825 at gmail.com Sat Feb 11 15:02:08 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 14:02:08 -0600 Subject: Building a debug version of Python 3.2.2 under Windows Message-ID: <4F36C940.8020009@gmail.com> I tried to build Python 3.2.2 with VS 2008, but it seems I'm missing some header files (e.g. sqlite3, openssl). Is there a nice little package with all the dependencies, or do I need to grab source code packages for each program from their respective websites, or something else entirely? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From michael at stroeder.com Sat Feb 11 15:22:45 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Sat, 11 Feb 2012 21:22:45 +0100 Subject: ldap proxy user bind In-Reply-To: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> Message-ID: sajuptpm wrote: > I have developed a LDAP auth system using python-ldap module. > Using that i can validate username and password, fetch user and > groups info from LDAP directory. > Now i want to implement ldap proxy user bind to the ldap server. What do you mean exactly? Are you talking about LDAPv3 proxy authorization (see http://tools.ietf.org/html/rfc4370)? If yes, then pass an instance of class ldap.controls.simple.ProxyAuthzControl to the LDAPObject methods when sending your LDAP requests. This is usable no matter how your proxy user has bound the directory. Another option is to send a SASL authz-ID along with the initial SASL bind request of your proxy user. No matter what you have to get your LDAP server configuration right for this to work. Which LDAP server is it? > I googled and find this http://ldapwiki.willeke.com/wiki/LDAPProxyUser AFAICS this web page talks about the proxy user for eDirectory's LDAP gateway to NDS. It's unlikely that this is relevant to your needs. > But i don't have any idea about how implement it usng python-ldap. > [..] > I want to add following 2 new flags > > ldap_proxy_user = ldap_proxy > ldap_proxy_pwd = secret Hmm, please don't take it personally but my impression is that you're not totally clear on what you need. Could you please try to explain what you want to achieve? Ciao, Michael. From mlortiz at uci.cu Sat Feb 11 15:32:14 2012 From: mlortiz at uci.cu (Marcos Ortiz Valmaseda) Date: Sat, 11 Feb 2012 16:02:14 -0430 Subject: Can anyone send me the last version of psycopg2 by email? In-Reply-To: <4F366E93.80804@free.fr> References: <4F366E93.80804@free.fr> Message-ID: <4F36D04E.90002@uci.cu> I have a minor trouble here with my Internet connection. Can anyone send me the last version of psycopg2 to this email? Thanks a lot for the help. Regards and best wishes -- Marcos Luis Ort?z Valmaseda Sr. Software Engineer (UCI) http://marcosluis2186.posterous.com http://www.linkedin.com/in/marcosluis2186 Twitter: @marcosluis2186 Fin a la injusticia, LIBERTAD AHORA A NUESTROS CINCO COMPATRIOTAS QUE SE ENCUENTRAN INJUSTAMENTE EN PRISIONES DE LOS EEUU! http://www.antiterroristas.cu http://justiciaparaloscinco.wordpress.com From ralf at systemexit.de Sat Feb 11 15:44:02 2012 From: ralf at systemexit.de (Ralf Schmitt) Date: Sat, 11 Feb 2012 21:44:02 +0100 Subject: [ANNOUNCE] greenlet 0.3.4 Message-ID: <87ty2xgkx9.fsf@myhost.localnet> Hi, I have uploaded greenlet 0.3.4 to PyPI: http://pypi.python.org/pypi/greenlet What is it? ----------- The greenlet module provides coroutines for python. coroutines allow suspending and resuming execution at certain locations. concurrence[1], eventlet[2] and gevent[3] use the greenlet module in order to implement concurrent network applications. Documentation can be found here: http://greenlet.readthedocs.org The code is hosted on github: https://github.com/python-greenlet/greenlet Changes in version 0.3.4 ------------------------ The NEWS file lists these changes for release 0.3.4: * Use plain distutils for install command, this fixes installation of the greenlet.h header. * Enhanced arm32 support * Fix support for Linux/S390 zSeries * Workaround compiler bug on RHEL 3 / CentOS 3 [1] http://opensource.hyves.org/concurrence/ [2] http://eventlet.net/ [3] http://www.gevent.org/ -- Cheers Ralf Schmitt From tjreedy at udel.edu Sat Feb 11 16:01:52 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 11 Feb 2012 16:01:52 -0500 Subject: Building a debug version of Python 3.2.2 under Windows In-Reply-To: <4F36C940.8020009@gmail.com> References: <4F36C940.8020009@gmail.com> Message-ID: On 2/11/2012 3:02 PM, Andrew Berg wrote: > I tried to build Python 3.2.2 with VS 2008, but it seems I'm missing > some header files (e.g. sqlite3, openssl). Is there a nice little > package with all the dependencies, or do I need to grab source code > packages for each program from their respective websites, or something > else entirely? The readme file in PCBuild supposedly has all the info needed, though I know one thing out of date. Trying to follow the instructions is on my todo list ;-). -- Terry Jan Reedy From ericsnowcurrently at gmail.com Sat Feb 11 16:02:47 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 14:02:47 -0700 Subject: Python usage numbers Message-ID: Does anyone have (or know of) accurate totals and percentages on how Python is used? I'm particularly interested in the following groupings: - new development vs. stable code-bases - categories (web, scripts, "big data", computation, etc.) - "bare metal" vs. on top of some framework - regional usage I'm thinking about this partly because of the discussion on python-ideas about the perceived challenges of Unicode in Python 3. All the rhetoric, anecdotal evidence, and use-cases there have little meaning to me, in regards to Python as a whole, without an understanding of who is actually affected. For instance, if frameworks (like django and numpy) could completely hide the arguable challenges of Unicode in Python 3--and most projects were built on top of frameworks--then general efforts for making Unicode easier in Python 3 should go toward helping framework writers. Not only are such usage numbers useful for the Unicode discussion (which I wish would get resolved and die so we could move on to more interesting stuff :) ). They help us know where efforts could be focused in general to make Python more powerful and easier to use where it's already used extensively. They can show us the areas that Python isn't used much, thus exposing a targeted opportunity to change that. Realistically, it's not entirely feasible to compile such information at a comprehensive level, but even generally accurate numbers would be a valuable resource. If the numbers aren't out there, what would some good approaches to discovering them? Thanks! -eric From sajuptpm at gmail.com Sat Feb 11 16:19:49 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Sat, 11 Feb 2012 13:19:49 -0800 (PST) Subject: ldap proxy user bind References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> Message-ID: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Hi Michael Str?der, Thanks for replay Yea i am not totally clear about that Client's Requirement is option to have a ldap proxy user bind to the ldap server if it needs more directory rights than an anonymous bind. option to use a ldap proxy user when searching. From bahamutzero8825 at gmail.com Sat Feb 11 16:21:21 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 15:21:21 -0600 Subject: Building a debug version of Python 3.2.2 under Windows In-Reply-To: References: <4F36C940.8020009@gmail.com> Message-ID: <4F36DBD1.4080704@gmail.com> On 2/11/2012 3:01 PM, Terry Reedy wrote: > The readme file in PCBuild supposedly has all the info needed, though I > know one thing out of date. Trying to follow the instructions is on my > todo list ;-). > I didn't notice the readme in there. I was following instructions from here: http://docs.python.org/devguide/ Looks like the build process is a bit more complicated than just "Build Solution". Thanks. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From stefan_ml at behnel.de Sat Feb 11 16:28:01 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 11 Feb 2012 22:28:01 +0100 Subject: Python usage numbers In-Reply-To: References: Message-ID: Eric Snow, 11.02.2012 22:02: > - categories (web, scripts, "big data", computation, etc.) No numbers, but from my stance, the four largest areas where Python is used appear to be (in increasing line length order): a) web applications b) scripting and tooling c) high-performance computation d) testing (non-Python/embedded/whatever code) I'm sure others will manage to remind me of the one or two I forgot... Stefan From bahamutzero8825 at gmail.com Sat Feb 11 16:51:49 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sat, 11 Feb 2012 15:51:49 -0600 Subject: Python usage numbers In-Reply-To: References: Message-ID: <4F36E2F5.9000505@gmail.com> On 2/11/2012 3:02 PM, Eric Snow wrote: > I'm thinking about this partly because of the discussion on > python-ideas about the perceived challenges of Unicode in Python 3. > For instance, if frameworks (like django and numpy) could completely > hide the arguable challenges of Unicode in Python 3--and most projects > were built on top of frameworks--then general efforts for making > Unicode easier in Python 3 should go toward helping framework writers. Huh? I'll admit I'm a novice, but isn't Unicode mostly trivial in py3k compared to 2.x? Or are you referring to porting 2.x to 3.x? I've been under the impression that Unicode in 2.x can be painful at times, but easy in 3.x. I've been using 3.2 and Unicode hasn't been much of an issue. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From breamoreboy at yahoo.co.uk Sat Feb 11 17:17:20 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 11 Feb 2012 22:17:20 +0000 Subject: Python usage numbers In-Reply-To: References: Message-ID: On 11/02/2012 21:02, Eric Snow wrote: > Does anyone have (or know of) accurate totals and percentages on how > Python is used? I'm particularly interested in the following > groupings: > > - new development vs. stable code-bases > - categories (web, scripts, "big data", computation, etc.) > - "bare metal" vs. on top of some framework > - regional usage > > I'm thinking about this partly because of the discussion on > python-ideas about the perceived challenges of Unicode in Python 3. > All the rhetoric, anecdotal evidence, and use-cases there have little > meaning to me, in regards to Python as a whole, without an > understanding of who is actually affected. > > For instance, if frameworks (like django and numpy) could completely > hide the arguable challenges of Unicode in Python 3--and most projects > were built on top of frameworks--then general efforts for making > Unicode easier in Python 3 should go toward helping framework writers. > > Not only are such usage numbers useful for the Unicode discussion > (which I wish would get resolved and die so we could move on to more > interesting stuff :) ). They help us know where efforts could be > focused in general to make Python more powerful and easier to use > where it's already used extensively. They can show us the areas that > Python isn't used much, thus exposing a targeted opportunity to change > that. > > Realistically, it's not entirely feasible to compile such information > at a comprehensive level, but even generally accurate numbers would be > a valuable resource. If the numbers aren't out there, what would some > good approaches to discovering them? Thanks! > > -eric As others have said on other Python newsgroups it ain't a problem. The only time I've ever had a problem was with matplotlib which couldn't print a ? sign. I used a U to enforce unicode job done. If I had a major problem I reckon that a search on c.l.p would give me an answer easy peasy. -- Cheers. Mark Lawrence. From ericsnowcurrently at gmail.com Sat Feb 11 20:21:01 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 18:21:01 -0700 Subject: Python usage numbers In-Reply-To: <4F36E2F5.9000505@gmail.com> References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sat, Feb 11, 2012 at 2:51 PM, Andrew Berg wrote: > On 2/11/2012 3:02 PM, Eric Snow wrote: >> I'm thinking about this partly because of the discussion on >> python-ideas about the perceived challenges of Unicode in Python 3. > >> For instance, if frameworks (like django and numpy) could completely >> hide the arguable challenges of Unicode in Python 3--and most projects >> were built on top of frameworks--then general efforts for making >> Unicode easier in Python 3 should go toward helping framework writers. > Huh? I'll admit I'm a novice, but isn't Unicode mostly trivial in py3k > compared to 2.x? Or are you referring to porting 2.x to 3.x? I've been > under the impression that Unicode in 2.x can be painful at times, but > easy in 3.x. > I've been using 3.2 and Unicode hasn't been much of an issue. My expectation is that yours is the common experience. However, in at least one current thread (on python-ideas) and at a variety of times in the past, _some_ people have found Unicode in Python 3 to make more work. So that got me to thinking about who's experience is the general case, and if any concerns broadly apply to more that framework/library writers (like django, jinja, twisted, etc.). Having usage statistics would be helpful in identifying the impact of things like Unicode in Python 3. -eric From rosuav at gmail.com Sat Feb 11 20:28:30 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 12:28:30 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow wrote: > However, in at > least one current thread (on python-ideas) and at a variety of times > in the past, _some_ people have found Unicode in Python 3 to make more > work. If Unicode in Python is causing you more work, isn't it most likely that the issue would have come up anyway? For instance, suppose you have a web form and you accept customer names, which you then store in a database. You could assume that the browser submits it in UTF-8 and that your database back-end can accept UTF-8, and then pretend that it's all ASCII, but if you then want to upper-case the name for a heading, somewhere you're going to needto deal with Unicode; and when your programming language has facilities like str.upper(), that's going to make it easier, not later. Sure, the simple case is easier if you pretend it's all ASCII, but it's still better to have language facilities. ChrisA From ericsnowcurrently at gmail.com Sat Feb 11 20:38:53 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Sat, 11 Feb 2012 18:38:53 -0700 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> Message-ID: On Sat, Feb 11, 2012 at 6:28 PM, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow wrote: >> However, in at >> least one current thread (on python-ideas) and at a variety of times >> in the past, _some_ people have found Unicode in Python 3 to make more >> work. > > If Unicode in Python is causing you more work, isn't it most likely > that the issue would have come up anyway? For instance, suppose you > have a web form and you accept customer names, which you then store in > a database. You could assume that the browser submits it in UTF-8 and > that your database back-end can accept UTF-8, and then pretend that > it's all ASCII, but if you then want to upper-case the name for a > heading, somewhere you're going to needto deal with Unicode; and when > your programming language has facilities like str.upper(), that's > going to make it easier, not later. Sure, the simple case is easier if > you pretend it's all ASCII, but it's still better to have language > facilities. Yeah, that's how I see it too. However, my sample size is much too small to have any sense of the broader Python 3 experience. That's what I'm going for with those Python usage statistics (if it's even feasible). -eric From steve+comp.lang.python at pearwood.info Sat Feb 11 21:23:24 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 02:23:24 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> Message-ID: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:28:30 +1100, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > wrote: >> However, in at >> least one current thread (on python-ideas) and at a variety of times in >> the past, _some_ people have found Unicode in Python 3 to make more >> work. > > If Unicode in Python is causing you more work, isn't it most likely that > the issue would have come up anyway? The argument being made is that in Python 2, if you try to read a file that contains Unicode characters encoded with some unknown codec, you don't have to think about it. Sure, you get moji-bake rubbish in your database, but that's the fault of people who insist on not being American. Or who spell Zoe with an umlaut. In Python 3, if you try the same thing, you get an error. Fixing the error requires thought, and even if that is only a minuscule amount of thought, that's too much for some developers who are scared of Unicode. Hence the FUD that Python 3 is too hard because it makes you learn Unicode. I know this isn't exactly helpful, but I wish they'd just HTFU. I'm with Joel Spolsky on this one: if you're a programmer in 2003 who doesn't have at least a basic working knowledge of Unicode, you're the equivalent of a doctor who doesn't believe in germs. http://www.joelonsoftware.com/articles/Unicode.html Learning a basic working knowledge of Unicode is not that hard. You don't need to be an expert, and it's just not that scary. The use-case given is: "I have a file containing text. I can open it in an editor and see it's nearly all ASCII text, except for a few weird and bizarre characters like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an error. What should I do that requires no thought?" Obvious answers: - Try decoding with UTF8 or Latin1. Even if you don't get the right characters, you'll get *something*. - Use open(filename, encoding='ascii', errors='surrogateescape') (Or possibly errors='ignore'.) -- Steven From rantingrickjohnson at gmail.com Sat Feb 11 21:36:52 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 11 Feb 2012 18:36:52 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 11, 8:23?pm, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 12:28:30 +1100, Chris Angelico wrote: > > On Sun, Feb 12, 2012 at 12:21 PM, Eric Snow > > wrote: > >> However, in at > >> least one current thread (on python-ideas) and at a variety of times in > >> the past, _some_ people have found Unicode in Python 3 to make more > >> work. > > > If Unicode in Python is causing you more work, isn't it most likely that > > the issue would have come up anyway? > > The argument being made is that in Python 2, if you try to read a file > that contains Unicode characters encoded with some unknown codec, you > don't have to think about it. Sure, you get moji-bake rubbish in your > database, but that's the fault of people who insist on not being > American. Or who spell Zoe with an umlaut. That's not the worst of it... i have many times had a block of text that was valid ASCII except for some intermixed Unicode white-space. Who the hell would even consider inserting Unicode white-space!!! > "I have a file containing text. I can open it in an editor and see it's > nearly all ASCII text, except for a few weird and bizarre characters like > ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > error. What should I do that requires no thought?" > > Obvious answers: the most obvious answer would be to read the file WITHOUT worrying about asinine encoding. From torriem at gmail.com Sat Feb 11 22:35:33 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 11 Feb 2012 20:35:33 -0700 Subject: ldap proxy user bind In-Reply-To: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Message-ID: <4F373385.2090505@gmail.com> On 02/11/2012 02:19 PM, sajuptpm wrote: > Hi Michael Str?der, > Thanks for replay > > Yea i am not totally clear about that > > Client's Requirement is > option to have a ldap proxy user bind to the ldap server if it needs > more directory rights than an anonymous bind. > option to use a ldap proxy user when searching. I wrote a true LDAP proxy server last year that intercepts and rewrites requests (bind, search, modify, etc). I used as my basis the LDAP proxy server that ships with Python-Twisted. Unfortunately I cannot share my code with you, but if you can get your head wrapped around Twisted (it's *extremely* hard to understand how it works at first), then this is the way to go. From torriem at gmail.com Sat Feb 11 23:29:01 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 11 Feb 2012 21:29:01 -0700 Subject: ldap proxy user bind In-Reply-To: <4F373385.2090505@gmail.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> <4F373385.2090505@gmail.com> Message-ID: <4F37400D.2010303@gmail.com> On 02/11/2012 08:35 PM, Michael Torrie wrote: > On 02/11/2012 02:19 PM, sajuptpm wrote: >> Hi Michael Str?der, >> Thanks for replay >> >> Yea i am not totally clear about that >> >> Client's Requirement is >> option to have a ldap proxy user bind to the ldap server if it needs >> more directory rights than an anonymous bind. >> option to use a ldap proxy user when searching. > > I wrote a true LDAP proxy server last year that intercepts and rewrites > requests (bind, search, modify, etc). I used as my basis the LDAP proxy > server that ships with Python-Twisted. Unfortunately I cannot share my > code with you, but if you can get your head wrapped around Twisted (it's > *extremely* hard to understand how it works at first), then this is the > way to go. Okay so I looked over my code. I can share some of it with you if you want. The most simple proxy I could find (I have written several for various purposes) was based on the Twisted LDAP proxy server class (ldaptor.protocols.ldap.proxy). The reason I wrote it was because I had some Sharp multi-function printers that could do LDAP authentication, but instead of binding with a full DN, it would simply bind as "username" which wouldn't work on my ldap server. So I wrote the LDAP proxy server to intercept bind requests (Sharp doesn't even support SSL blah!) and convert it to a proper DN before passing it on to the real LDAP server. Also the LDAP search queries the sharp server generated were crappy, so I rewrote some of the searches as well as they pass through my proxy server. I sharp ===> Twisted LDAP server/Twisted LDAP client ===> ldapserver rewrite bind, rewrite some searches, pass thru everything My other LDAP proxy is fancier and it uses the ldaptor.protocols.ldap.ldapserver.BaseLDAPServer class, and instead of using twisted's LDAP client code, I just use python-ldap. So it's a hybrid approach I suppose. I can strip it down to bare proxy functionality that you could build on. client ==> twisted ldap server/python-ldap client ===> ldapserver Anyway let me know if you want to see some code and I'll post what I can. From rosuav at gmail.com Sat Feb 11 23:38:37 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 15:38:37 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Feb 12, 2012 at 1:36 PM, Rick Johnson wrote: > On Feb 11, 8:23?pm, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> "I have a file containing text. I can open it in an editor and see it's >> nearly all ASCII text, except for a few weird and bizarre characters like >> ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an >> error. What should I do that requires no thought?" >> >> Obvious answers: > > the most obvious answer would be to read the file WITHOUT worrying > about asinine encoding. What this statement misunderstands, though, is that ASCII is itself an encoding. Files contain bytes, and it's only what's external to those bytes that gives them meaning. The famous "bush hid the facts" trick with Windows Notepad shows the folly of trying to use internal evidence to identify meaning from bytes. Everything that displays text to a human needs to translate bytes into glyphs, and the usual way to do this conceptually is to go via characters. Pretending that it's all the same thing really means pretending that one byte represents one character and that each character is depicted by one glyph. And that's doomed to failure, unless everyone speaks English with no foreign symbols - so, no mathematical notations. ChrisA From nad at acm.org Sun Feb 12 00:28:11 2012 From: nad at acm.org (Ned Deily) Date: Sun, 12 Feb 2012 06:28:11 +0100 Subject: Stopping a looping computation in IDLE 3.2.x References: Message-ID: In article , Franck Ditter wrote: > How do you stop a looping computation with IDLE 3.2.x on MacOS-X Lion ? > It hangs with the colored wheel... > Ctl-C does not work. Ctrl-C in the IDLE shell window works for me on OS X 10.7 Lion. Did you use the python.org 3.2.2 64-bit-/32-bit installer for 10.6? Do you have the latest ActiveState Tcl/Tk 8.5.11 installed? http://www.python.org/download/mac/tcltk/ -- Ned Deily, nad at acm.org From steve+comp.lang.python at pearwood.info Sun Feb 12 00:51:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 05:51:03 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > Everything that displays text to a human needs to translate bytes into > glyphs, and the usual way to do this conceptually is to go via > characters. Pretending that it's all the same thing really means > pretending that one byte represents one character and that each > character is depicted by one glyph. And that's doomed to failure, unless > everyone speaks English with no foreign symbols - so, no mathematical > notations. Pardon me, but you can't even write *English* in ASCII. You can't say that it cost you ?10 to courier your r?sum? to the head office of Encyclop?dia Britanica to apply for the position of Staff Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy and old-fashioned, but it is traditional English.) Hell, you can't even write in *American*: you can't say that the recipe for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. ASCII truly is a blight on the world, and the sooner it fades into obscurity, like EBCDIC, the better. Even if everyone did change to speak ASCII, you still have all the historical records and documents and files to deal with. Encodings are not going away. -- Steven From rosuav at gmail.com Sun Feb 12 01:08:24 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 12 Feb 2012 17:08:24 +1100 Subject: Python usage numbers In-Reply-To: <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano wrote: > You can't say that it cost you ?10 to courier your r?sum? to the head > office of Encyclop?dia Britanica to apply for the position of Staff > Co?rdinator. True, but if it cost you $10 (or 10 GBP) to courier your curriculum vitae to the head office of Encyclopaedia Britannica to become Staff Coordinator, then you'd be fine. And if it cost you $10 to post your work summary to Britannica's administration to apply for this Staff Coordinator position, you could say it without 'e' too. Doesn't mean you don't need Unicode! ChrisA From steve+comp.lang.python at pearwood.info Sun Feb 12 01:10:20 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 06:10:20 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sat, 11 Feb 2012 18:36:52 -0800, Rick Johnson wrote: >> "I have a file containing text. I can open it in an editor and see it's >> nearly all ASCII text, except for a few weird and bizarre characters >> like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I >> get an error. What should I do that requires no thought?" >> >> Obvious answers: > > the most obvious answer would be to read the file WITHOUT worrying about > asinine encoding. Your mad leet reading comprehension skillz leave me in awe Rick. If you try to read a file containing non-ASCII characters encoded using UTF8 on Windows without explicitly specifying either UTF8 as the encoding, or an error handler, you will get an exception. It's not just UTF8 either, but nearly all encodings. You can't even expect to avoid problems if you stick to nothing but Windows, because Windows' default encoding is localised: a file generated in (say) Israel or Japan or Germany will use a different code page (encoding) by default than one generated in (say) the US, Canada or UK. -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 01:41:20 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 06:41:20 GMT Subject: Numeric root-finding in Python Message-ID: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to improve the approximation. This mostly works well, but sometimes the root-finder gets stuck in a cycle. Here's my function: import math def improve(x, w, exp=math.exp): """Use Halley's method to improve an estimate of W(x) given an initial estimate w. """ try: for i in range(36): # Max number of iterations. ew = exp(w) a = w*ew - x b = ew*(w + 1) err = -a/b # Estimate of the error in the current w. if abs(err) <= 1e-16: break print '%d: w= %r err= %r' % (i, w, err) # Make a better estimate. c = (w + 2)*a/(2*w + 2) delta = a/(b - c) w -= delta else: raise RuntimeError('calculation failed to converge', err) except ZeroDivisionError: assert w == -1 return w Here's an example where improve() converges very quickly: py> improve(-0.36, -1.222769842388856) 0: w= -1.222769842388856 err= -2.9158979924038895e-07 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 -1.222770133978506 That's what I expect: convergence in only a few iterations. Here's an example where it gets stuck in a cycle, bouncing back and forth between two values: py> improve(-0.36787344117144249, -1.0057222396915309) 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 [...] 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 Traceback (most recent call last): File "", line 1, in File "", line 19, in improve RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) (The correct value for w is approximately -1.00572223991.) I know that Newton's method is subject to cycles, but I haven't found any discussion about Halley's method and cycles, nor do I know what the best approach for breaking them would be. None of the papers on calculating the Lambert W function that I have found mentions this. Does anyone have any advice for solving this? -- Steven From bahamutzero8825 at gmail.com Sun Feb 12 02:05:35 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 12 Feb 2012 01:05:35 -0600 Subject: Python usage numbers In-Reply-To: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3764BF.1010602@gmail.com> On 2/12/2012 12:10 AM, Steven D'Aprano wrote: > It's not just UTF8 either, but nearly all encodings. You can't even > expect to avoid problems if you stick to nothing but Windows, because > Windows' default encoding is localised: a file generated in (say) Israel > or Japan or Germany will use a different code page (encoding) by default > than one generated in (say) the US, Canada or UK. Generated by what? Windows will store a locale value for programs to use, but programs use Unicode internally by default (i.e., API calls are Unicode unless they were built for old versions of Windows), and the default filesystem (NTFS) uses Unicode for file names. AFAIK, only the terminal has a localized code page by default. Perhaps Notepad will write text files with the localized code page by default, but that's an application choice... -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From sajuptpm at gmail.com Sun Feb 12 02:16:30 2012 From: sajuptpm at gmail.com (sajuptpm) Date: Sat, 11 Feb 2012 23:16:30 -0800 (PST) Subject: ldap proxy user bind References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> <4F373385.2090505@gmail.com> Message-ID: <3e195947-d67f-42ae-9e9d-6fd111a6beec@ow3g2000pbc.googlegroups.com> Hi Michael Torrie, Thanks to reply Why we need Twisted here, i did not get it. My understanding is that if ldap_proxy_user = ldap_proxy ldap_proxy_pwd = secret ( set more privileges to this user at ldap server side, for get other users infos) are configured at server side, then allow clients to login using username only, this time use ldap_proxy_user and ldap_proxy_pwd for login to ldap server, user validation and get user infos. Is it possible and any drawback ???? I think this is what client need. From mcepl at redhat.com Sun Feb 12 03:14:44 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 12 Feb 2012 09:14:44 +0100 Subject: Python usage numbers In-Reply-To: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12.2.2012 03:23, Steven D'Aprano wrote: > The use-case given is: > > "I have a file containing text. I can open it in an editor and see it's > nearly all ASCII text, except for a few weird and bizarre characters like > ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > error. What should I do that requires no thought?" > > Obvious answers: > > - Try decoding with UTF8 or Latin1. Even if you don't get the right > characters, you'll get *something*. > > - Use open(filename, encoding='ascii', errors='surrogateescape') > > (Or possibly errors='ignore'.) These are not good answer, IMHO. The only answer I can think of, really, is: - pack you luggage, your submarine waits on you to peel onions in it (with reference to the Joel's article). Meaning, really, you should learn your craft and pull up your head from the sand. There is a wider world around you. (and yes, I am a Czech, so I need at least latin-2 for my language). Best, Mat?j From mcepl at redhat.com Sun Feb 12 03:26:57 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 12 Feb 2012 09:26:57 +0100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12.2.2012 09:14, Matej Cepl wrote: >> Obvious answers: >> >> - Try decoding with UTF8 or Latin1. Even if you don't get the right >> characters, you'll get *something*. >> >> - Use open(filename, encoding='ascii', errors='surrogateescape') >> >> (Or possibly errors='ignore'.) > > These are not good answer, IMHO. The only answer I can think of, really, > is: Slightly less flameish answer to the question ?What should I do, really?? is a tough one: all these suggested answers are bad because they don?t deal with the fact, that your input data are obviously broken. The rest is just pure GIGO ? without fixing (and I mean, really, fixing, not ignoring the problem, which is what the previous answers suggest) your input, you?ll get garbage on output. And you should be thankful to py3k that it shown the issue to you. BTW, can you display the following line? P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. Best, Mat?j From jackdied at gmail.com Sun Feb 12 04:04:43 2012 From: jackdied at gmail.com (Jack Diederich) Date: Sun, 12 Feb 2012 04:04:43 -0500 Subject: Guide to: Learning Python Decorators In-Reply-To: <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> <7265933.362.1328861473828.JavaMail.geo-discussion-forums@prew38> Message-ID: just google "jack diederich decorators" it costs nothing and you get a free pycon talk out of it. -Jack From steve+comp.lang.python at pearwood.info Sun Feb 12 04:12:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 09:12:57 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 01:05:35 -0600, Andrew Berg wrote: > On 2/12/2012 12:10 AM, Steven D'Aprano wrote: >> It's not just UTF8 either, but nearly all encodings. You can't even >> expect to avoid problems if you stick to nothing but Windows, because >> Windows' default encoding is localised: a file generated in (say) >> Israel or Japan or Germany will use a different code page (encoding) by >> default than one generated in (say) the US, Canada or UK. > Generated by what? Windows will store a locale value for programs to > use, but programs use Unicode internally by default Which programs? And we're not talking about what they use internally, but what they write to files. > (i.e., API calls are > Unicode unless they were built for old versions of Windows), and the > default filesystem (NTFS) uses Unicode for file names. No. File systems do not use Unicode for file names. Unicode is an abstract mapping between code points and characters. File systems are written using bytes. Suppose you're a fan of Russian punk bank ???? and you have a directory of their music. The file system doesn't store the Unicode code points 1053 1072 1253 1074, it has to be encoded to a sequence of bytes first. NTFS by default uses the UTF-16 encoding, which means the actual bytes written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading byte-order mark \xff\xfe). Windows has two separate APIs, one for "wide" characters, the other for single bytes. Depending on which one you use, the directory will appear to be called ???? or 0?2. But in any case, we're not talking about the file name encoding. We're talking about the contents of files. > AFAIK, only the > terminal has a localized code page by default. Perhaps Notepad will > write text files with the localized code page by default, but that's an > application choice... Exactly. And unless you know what encoding the application chooses, you will likely get an exception trying to read the file. -- Steven From anh.hai.trinh at gmail.com Sun Feb 12 04:41:16 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 01:41:16 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <28799160.595.1329039676879.JavaMail.geo-discussion-forums@pbbmq9> Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? extproc does this, but you opted to write a recursive descent parser. I'm sure it's fun but I think simple is better than complex. Most users would prefer not to deal with Python, not another language. * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. For a shell-like library, I would recommend its users to never use threads (so that those who do otherwise know what they are in for). From anh.hai.trinh at gmail.com Sun Feb 12 04:41:16 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 01:41:16 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <28799160.595.1329039676879.JavaMail.geo-discussion-forums@pbbmq9> Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? extproc does this, but you opted to write a recursive descent parser. I'm sure it's fun but I think simple is better than complex. Most users would prefer not to deal with Python, not another language. * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. For a shell-like library, I would recommend its users to never use threads (so that those who do otherwise know what they are in for). From hoogendoorn.eelco at gmail.com Sun Feb 12 05:10:49 2012 From: hoogendoorn.eelco at gmail.com (Eelco) Date: Sun, 12 Feb 2012 02:10:49 -0800 (PST) Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 7:41?am, Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > ? ? """Use Halley's method to improve an estimate of W(x) given > ? ? an initial estimate w. > ? ? """ > ? ? try: > ? ? ? ? for i in range(36): ?# Max number of iterations. > ? ? ? ? ? ? ew = exp(w) > ? ? ? ? ? ? a = w*ew - x > ? ? ? ? ? ? b = ew*(w + 1) > ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. > ? ? ? ? ? ? if abs(err) <= 1e-16: > ? ? ? ? ? ? ? ? break > ? ? ? ? ? ? print '%d: w= %r err= %r' % (i, w, err) > ? ? ? ? ? ? # Make a better estimate. > ? ? ? ? ? ? c = (w + 2)*a/(2*w + 2) > ? ? ? ? ? ? delta = a/(b - c) > ? ? ? ? ? ? w -= delta > ? ? ? ? else: > ? ? ? ? ? ? raise RuntimeError('calculation failed to converge', err) > ? ? except ZeroDivisionError: > ? ? ? ? assert w == -1 > ? ? return w > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > ? File "", line 1, in > ? File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? > > -- > Steven Looks like floating point issues to me, rather than something intrinsic to the iterative algorithm. Surely there is not complex chaotic behavior to be found in this fairly smooth function in a +/- 1e-14 window. Otoh, there is a lot of floating point significant bit loss issues to be suspected in the kind of operations you are performing (exp(x) + something, always a tricky one). I would start by asking: How accurate is good enough? If its not good enough, play around the the ordering of your operations, try solving a transformed problem less sensitive to loss of significance; and begin by trying different numeric types to see if the problem is sensitive thereto to begin with. From bahamutzero8825 at gmail.com Sun Feb 12 06:11:30 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Sun, 12 Feb 2012 05:11:30 -0600 Subject: Python usage numbers In-Reply-To: <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F379E62.2040009@gmail.com> On 2/12/2012 3:12 AM, Steven D'Aprano wrote: > NTFS by default uses the UTF-16 encoding, which means the actual bytes > written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading > byte-order mark \xff\xfe). That's what I meant. Those bytes will be interpreted consistently across all locales. > Windows has two separate APIs, one for "wide" characters, the other for > single bytes. Depending on which one you use, the directory will appear > to be called ???? or 0?2. Yes, and AFAIK, the wide API is the default. The other one only exists to support programs that don't support the wide API (generally, such programs were intended to be used on older platforms that lack that API). > But in any case, we're not talking about the file name encoding. We're > talking about the contents of files. Okay then. As I stated, this has nothing to do with the OS since programs are free to interpret bytes any way they like. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From vinay_sajip at yahoo.co.uk Sun Feb 12 06:31:02 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 03:31:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: Message-ID: On Feb 12, 9:41?am, Anh Hai Trinh wrote: > Having written something with similar purpose (https://github.com/aht/extproc), here are my comments: > > * Having command parsed from a string is complicated. Why not just have an OOP API to construct commands? It's not hard for the user, and less work e.g. when migrating from an existing Bash script. I may have put in the effort to use a recursive descent parser under the hood, but why should the user of the library care? It doesn't make their life harder. And it's not complicated, not even particularly complex - such parsers are commonplace. > * Using threads and fork()ing process does not play nice together unless extreme care is taken. Disasters await. By that token, disasters await if you ever use threads, unless you know what you're doing (and sometimes even then). Sarge doesn't force the use of threads with forking - you can do everything synchronously if you want. The test suite does cover the particular case of thread +fork. Do you have specific caveats, or is it just a "there be dragons" sentiment? Sarge is still in alpha status; no doubt bugs will surface, but unless a real show-stopper occurs, there's not much to be gained by throwing up our hands. BTW extproc is nice, but I wanted to push the envelope a little :-) Regards, Vinay Sajip From dihedral88888 at googlemail.com Sun Feb 12 06:48:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 03:48:32 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7765462.72.1329047312690.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?10????UTC+8??2?32?09??anon hung??? > >> Guide to: Learning Python Decorators > >> New Book http://tinyurl.com/python-decorartor > > > > A whole book about decorators? Cool. I'm going to start writing books to. > > I'll start with 'The Python print statement'. Then to be cutting edge I'll > > follow with 'The Python print function'. > There are books about classes in other computer languages, too. Using decorator is more elegant in reducing the class levels in applications. Just deep copying an object in more than 10 levels of an inherited class hiarchie is so slow. From dihedral88888 at googlemail.com Sun Feb 12 06:48:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 03:48:32 -0800 (PST) Subject: Guide to: Learning Python Decorators In-Reply-To: References: <476f8fff-9f08-4a54-8704-449cfaf6ad60@vv9g2000pbc.googlegroups.com> Message-ID: <7765462.72.1329047312690.JavaMail.geo-discussion-forums@pbcql8> ? 2012?2?10????UTC+8??2?32?09??anon hung??? > >> Guide to: Learning Python Decorators > >> New Book http://tinyurl.com/python-decorartor > > > > A whole book about decorators? Cool. I'm going to start writing books to. > > I'll start with 'The Python print statement'. Then to be cutting edge I'll > > follow with 'The Python print function'. > There are books about classes in other computer languages, too. Using decorator is more elegant in reducing the class levels in applications. Just deep copying an object in more than 10 levels of an inherited class hiarchie is so slow. From breamoreboy at yahoo.co.uk Sun Feb 12 07:11:01 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Feb 2012 12:11:01 +0000 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/02/2012 08:26, Matej Cepl wrote: > On 12.2.2012 09:14, Matej Cepl wrote: >>> Obvious answers: >>> >>> - Try decoding with UTF8 or Latin1. Even if you don't get the right >>> characters, you'll get *something*. >>> >>> - Use open(filename, encoding='ascii', errors='surrogateescape') >>> >>> (Or possibly errors='ignore'.) >> >> These are not good answer, IMHO. The only answer I can think of, really, >> is: > > Slightly less flameish answer to the question ?What should I do, > really?? is a tough one: all these suggested answers are bad because > they don?t deal with the fact, that your input data are obviously > broken. The rest is just pure GIGO ? without fixing (and I mean, really, > fixing, not ignoring the problem, which is what the previous answers > suggest) your input, you?ll get garbage on output. And you should be > thankful to py3k that it shown the issue to you. > > BTW, can you display the following line? > > P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. > > Best, > > Mat?j Yes in Thunderbird, Notepad, Wordpad and Notepad++ on Windows Vista, can't be bothered to try any other apps. -- Cheers. Mark Lawrence. From waqif at smartbaba.com Sun Feb 12 07:51:34 2012 From: waqif at smartbaba.com (Smart Baba) Date: Sun, 12 Feb 2012 04:51:34 -0800 (PST) Subject: Limited time offer, so hurry up! Message-ID: Take advantage of Smart Baba new offer and get your own customized professional website and promote your business. For further details, Follow us: www.websitedeals.in From michael at stroeder.com Sun Feb 12 07:57:51 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Sun, 12 Feb 2012 13:57:51 +0100 Subject: ldap proxy user bind In-Reply-To: <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> References: <452a9dab-af23-44ef-9460-33a6fbf6faf0@g4g2000pbi.googlegroups.com> <224a1023-a78f-4658-92b3-8448e305e6bd@iu7g2000pbc.googlegroups.com> Message-ID: sajuptpm wrote: > Yea i am not totally clear about that > > Client's Requirement is > option to have a ldap proxy user bind to the ldap server if it needs > more directory rights than an anonymous bind. > option to use a ldap proxy user when searching. As said: there's the proxy authorization control (see RFC 4370) for which a Python class exists in python-ldap. This is used e.g. in web applications if the user has successfully authenticated to the application and his identity should be used when processing ACLs in the LDAP server. In this case the "proxy user" is trusted entity to have done authentication right. The proxy authz control is sent by the application with each LDAP request. The server has to be correctly configured to accept that. Another option is a LDAP proxy server which accepts anon requests and binds as a certain user. You could OpenLDAP with back-ldap or back-meta for that. So you should ask your customer what's really needed. Ciao, Michael. From dihedral88888 at googlemail.com Sun Feb 12 08:13:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 12 Feb 2012 05:13:16 -0800 (PST) Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3267176.47.1329052396463.JavaMail.geo-discussion-forums@pbcqx4> ? 2012?2?12????UTC+8??2?41?20??Steven D'Aprano??? > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > """Use Halley's method to improve an estimate of W(x) given > an initial estimate w. > """ > try: > for i in range(36): # Max number of iterations. > ew = exp(w) > a = w*ew - x W*EXP(W) can converge for negative values of W > b = ew*(w + 1) b=exp(W)*W+W > err = -a/b # Estimate of the error in the current w. What's X not expalained? > if abs(err) <= 1e-16: > break > print '%d: w= %r err= %r' % (i, w, err) > # Make a better estimate. > c = (w + 2)*a/(2*w + 2) > delta = a/(b - c) > w -= delta > else: > raise RuntimeError('calculation failed to converge', err) > except ZeroDivisionError: > assert w == -1 > return w > > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > File "", line 1, in > File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? > > > > -- > Steven I sugest you can use Taylor's series expansion to speed up w*exp(w) for negative values of w. From breamoreboy at yahoo.co.uk Sun Feb 12 08:39:38 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 12 Feb 2012 13:39:38 +0000 Subject: Numeric root-finding in Python In-Reply-To: References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12/02/2012 10:10, Eelco wrote: > On Feb 12, 7:41 am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> This is only peripherally a Python problem, but in case anyone has any >> good ideas I'm going to ask it. >> >> I have a routine to calculate an approximation of Lambert's W function, >> and then apply a root-finding technique to improve the approximation. >> This mostly works well, but sometimes the root-finder gets stuck in a >> cycle. >> >> Here's my function: >> >> import math >> def improve(x, w, exp=math.exp): >> """Use Halley's method to improve an estimate of W(x) given >> an initial estimate w. >> """ >> try: >> for i in range(36): # Max number of iterations. >> ew = exp(w) >> a = w*ew - x >> b = ew*(w + 1) >> err = -a/b # Estimate of the error in the current w. >> if abs(err)<= 1e-16: >> break >> print '%d: w= %r err= %r' % (i, w, err) >> # Make a better estimate. >> c = (w + 2)*a/(2*w + 2) >> delta = a/(b - c) >> w -= delta >> else: >> raise RuntimeError('calculation failed to converge', err) >> except ZeroDivisionError: >> assert w == -1 >> return w >> >> Here's an example where improve() converges very quickly: >> >> py> improve(-0.36, -1.222769842388856) >> 0: w= -1.222769842388856 err= -2.9158979924038895e-07 >> 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 >> -1.222770133978506 >> >> That's what I expect: convergence in only a few iterations. >> >> Here's an example where it gets stuck in a cycle, bouncing back and forth >> between two values: >> >> py> improve(-0.36787344117144249, -1.0057222396915309) >> 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> [...] >> 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 19, in improve >> RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) >> >> (The correct value for w is approximately -1.00572223991.) >> >> I know that Newton's method is subject to cycles, but I haven't found any >> discussion about Halley's method and cycles, nor do I know what the best >> approach for breaking them would be. None of the papers on calculating >> the Lambert W function that I have found mentions this. >> >> Does anyone have any advice for solving this? >> >> -- >> Steven > > Looks like floating point issues to me, rather than something > intrinsic to the iterative algorithm. Surely there is not complex > chaotic behavior to be found in this fairly smooth function in a +/- > 1e-14 window. Otoh, there is a lot of floating point significant bit > loss issues to be suspected in the kind of operations you are > performing (exp(x) + something, always a tricky one). > > I would start by asking: How accurate is good enough? If its not good > enough, play around the the ordering of your operations, try solving a > transformed problem less sensitive to loss of significance; and begin > by trying different numeric types to see if the problem is sensitive > thereto to begin with. HTH. c:\Users\Mark\Python>type sda.py import decimal def improve(x, w, exp=decimal.Decimal.exp): """Use Halley's method to improve an estimate of W(x) given an initial estimate w. """ try: for i in range(36): # Max number of iterations. ew = exp(w) a = w*ew - x b = ew*(w + 1) err = -a/b # Estimate of the error in the current w. if abs(err) <= 1e-16: break print '%d: w= %r err= %r' % (i, w, err) # Make a better estimate. c = (w + 2)*a/(2*w + 2) delta = a/(b - c) w -= delta else: raise RuntimeError('calculation failed to converge', err) print '%d: w= %r err= %r' % (i, w, err) except ZeroDivisionError: assert w == -1 return w improve(decimal.Decimal('-0.36'), decimal.Decimal('-1.222769842388856')) improve(decimal.Decimal('-0.36787344117144249'), decimal.Decimal('-1.0057222396915309')) c:\Users\Mark\Python>sda.py 0: w= Decimal('-1.222769842388856') err= Decimal('-2.915897982757542086414504607E-7') 1: w= Decimal('-1.222770133978505953034526059') err= Decimal('-1.084120148360381932277303211E-19') 0: w= Decimal('-1.0057222396915309') err= Decimal('5.744538819905061986438230561E-15') 1: w= Decimal('-1.005722239691525155461180092') err= Decimal('-0E+2') -- Cheers. Mark Lawrence. From robert.kern at gmail.com Sun Feb 12 08:52:48 2012 From: robert.kern at gmail.com (Robert Kern) Date: Sun, 12 Feb 2012 13:52:48 +0000 Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/12 6:41 AM, Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. I don't have any advice for fixing your code, per se, but I would just grab mpmath and use their lambertw function: http://mpmath.googlecode.com/svn/trunk/doc/build/functions/powers.html#lambert-w-function -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From roy at panix.com Sun Feb 12 10:13:07 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 10:13:07 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Sun, Feb 12, 2012 at 1:36 PM, Rick Johnson > wrote: > > On Feb 11, 8:23?pm, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: > >> "I have a file containing text. I can open it in an editor and see it's > >> nearly all ASCII text, except for a few weird and bizarre characters like > >> ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I get an > >> error. What should I do that requires no thought?" > >> > >> Obvious answers: > > > > the most obvious answer would be to read the file WITHOUT worrying > > about asinine encoding. > > What this statement misunderstands, though, is that ASCII is itself an > encoding. Files contain bytes, and it's only what's external to those > bytes that gives them meaning. Exactly. . ASCII was so successful at becoming a universal standard which lasted for decades, people who grew up with it don't realize there was once any other way. Not just EBCDIC, but also SIXBIT, RAD-50, tilt/rotate, packed card records, and so on. Transcoding was a way of life, and if you didn't know what you were starting with and aiming for, it was hopeless. Kind of like now where we are again with Unicode. From inq1ltd at inqvista.com Sun Feb 12 10:20:17 2012 From: inq1ltd at inqvista.com (inq1ltd) Date: Sun, 12 Feb 2012 10:20:17 -0500 Subject: Numeric root-finding in Python In-Reply-To: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2276591.XVerqeASP3@mach-114-20> I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 rather than; except ZeroDivisionError: assert w == -1 jimonlinux On Sunday, February 12, 2012 06:41:20 AM Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation. > This mostly works well, but sometimes the root-finder gets stuck in a > cycle. > > Here's my function: > > import math > def improve(x, w, exp=math.exp): > """Use Halley's method to improve an estimate of W(x) given > an initial estimate w. > """ > try: > for i in range(36): # Max number of iterations. > ew = exp(w) > a = w*ew - x > b = ew*(w + 1) > err = -a/b # Estimate of the error in the current w. > if abs(err) <= 1e-16: > break > print '%d: w= %r err= %r' % (i, w, err) > # Make a better estimate. > c = (w + 2)*a/(2*w + 2) > delta = a/(b - c) > w -= delta > else: > raise RuntimeError('calculation failed to converge', err) > except ZeroDivisionError: > assert w == -1 > return w > > > Here's an example where improve() converges very quickly: > > py> improve(-0.36, -1.222769842388856) > 0: w= -1.222769842388856 err= -2.9158979924038895e-07 > 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 > -1.222770133978506 > > That's what I expect: convergence in only a few iterations. > > Here's an example where it gets stuck in a cycle, bouncing back and forth > between two values: > > py> improve(-0.36787344117144249, -1.0057222396915309) > 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 5: w= -1.0057222396915044 err= -2.6521238905872001e-14 > [...] > 32: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 33: w= -1.0057222396915044 err= -2.6521238905872001e-14 > 34: w= -1.0057222396915309 err= 2.6521238905750239e-14 > 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 > Traceback (most recent call last): > File "", line 1, in > File "", line 19, in improve > RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) > > (The correct value for w is approximately -1.00572223991.) > > I know that Newton's method is subject to cycles, but I haven't found any > discussion about Halley's method and cycles, nor do I know what the best > approach for breaking them would be. None of the papers on calculating > the Lambert W function that I have found mentions this. > > Does anyone have any advice for solving this? From anh.hai.trinh at gmail.com Sun Feb 12 10:35:08 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 07:35:08 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> > It's not hard for the user I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. Re. threads & fork(): http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-before-using-them For a careful impl of fork-exec with threads, see http://golang.org/src/pkg/syscall/exec_unix.go > By that token, disasters await if you ever use threads, unless you know what you're doing So don't, this package is mainly a fork-exec-wait library providing shell-like functionalities. Just use fork(). > BTW extproc is nice, but I wanted to push the envelope a little :-) Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p I do think that IO redirection is much nicer with extproc. From roy at panix.com Sun Feb 12 10:48:36 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 10:48:36 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4f375347$0$29986$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > ASCII truly is a blight on the world, and the sooner it fades into > obscurity, like EBCDIC, the better. That's a fair statement, but it's also fair to say that at the time it came out (49 years ago!) it was a revolutionary improvement on the extant state of affairs (every manufacturer inventing their own code, and often different codes for different machines). Given the cost of both computer memory and CPU cycles at the time, sticking to a 7-bit code (the 8th bit was for parity) was a necessary evil. As Steven D'Aprano pointed out, it was missing some commonly used US symbols such as ?? or ??. This was a small price to pay for the simplicity ASCII afforded. It wasn't a bad encoding. I was a very good encoding. But the world has moved on and computing hardware has become cheap enough that supporting richer encodings and character sets is realistic. And, before people complain about the character set being US-Centric, keep in mind that the A in ASCII stands for American, and it was published by ANSI (whose A also stands for American). I'm not trying to wave the flag here, just pointing out that it was never intended to be anything other than a national character set. Part of the complexity of Unicode is that when people switch from working with ASCII to working with Unicode, they're really having to master two distinct things at the same time (and often conflate them into a single confusing mess). One is the Unicode character set. The other is a specific encoding (UTF-8, UTF-16, etc). Not to mention silly things like BOM (Byte Order Mark). I expect that some day, storage costs will become so cheap that we'll all just be using UTF-32, and programmers of the day will wonder how their poor parents and grandparents ever managed in a world where nobody quite knew what you meant when you asked, "how long is that string?". From dan at tombstonezero.net Sun Feb 12 10:55:17 2012 From: dan at tombstonezero.net (Dan Sommers) Date: Sun, 12 Feb 2012 15:55:17 +0000 (UTC) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, 12 Feb 2012 17:08:24 +1100, Chris Angelico wrote: > On Sun, Feb 12, 2012 at 4:51 PM, Steven D'Aprano > wrote: >> You can't say that it cost you ?10 to courier your r?sum? to the head >> office of Encyclop?dia Britanica to apply for the position of Staff >> Co?rdinator. > > True, but if it cost you $10 (or 10 GBP) to courier your curriculum > vitae to the head office of Encyclopaedia Britannica to become Staff > Coordinator, then you'd be fine. And if it cost you $10 to post your > work summary to Britannica's administration to apply for this Staff > Coordinator position, you could say it without 'e' too. Doesn't mean you > don't need Unicode! Back in the late 1970's, the economy and the outlook in the USA sucked, and the following joke made the rounds: Mr. Smith: Good morning, Mr. Jones. How are you? Mr. Jones: I'm fine. (The humor is that Mr. Jones had his head so far [in the sand] that he thought that things were fine.) American English is my first spoken language, but I know enough French, Greek, math, and other languages that I am very happy to have more than ASCII these days. I imagine that even Steven's surname should be spelled D?Aprano rather than D'Aprano. Dan From anh.hai.trinh at gmail.com Sun Feb 12 11:19:18 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 08:19:18 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <10831099.690.1329063558642.JavaMail.geo-discussion-forums@pbcmg9> > For a careful impl of fork-exec with threads, see http://golang.org/src/pkg/syscall/exec_unix.go I forgot to mention that this impl is indeed "correct" only because you cannot start thread or call fork() directly in the Go language, other than use goroutines and the ForkExec() function implemented there. So all that locking is internal. If you use threads and call fork(), you'll almost guaranteed to face with deadlocks. Perhaps not in a particular piece of code, but some others. Perhaps not on your laptop, but on the production machine with different kernels. Like most race conditions, they will eventually show up. From rustompmody at gmail.com Sun Feb 12 11:50:28 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 12 Feb 2012 08:50:28 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 10:51?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > Everything that displays text to a human needs to translate bytes into > > glyphs, and the usual way to do this conceptually is to go via > > characters. Pretending that it's all the same thing really means > > pretending that one byte represents one character and that each > > character is depicted by one glyph. And that's doomed to failure, unless > > everyone speaks English with no foreign symbols - so, no mathematical > > notations. > > Pardon me, but you can't even write *English* in ASCII. > > You can't say that it cost you ?10 to courier your r?sum? to the head > office of Encyclop?dia Britanica to apply for the position of Staff > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > and old-fashioned, but it is traditional English.) > > Hell, you can't even write in *American*: you can't say that the recipe > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. [Quite OT but...] How do you type all this? [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] From d at davea.name Sun Feb 12 12:00:33 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 12:00:33 -0500 Subject: Numeric root-finding in Python In-Reply-To: <2276591.XVerqeASP3@mach-114-20> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <2276591.XVerqeASP3@mach-114-20> Message-ID: <4F37F031.8090104@davea.name> On 02/12/2012 10:20 AM, inq1ltd wrote: > > I don't know the first thing about this math problem however, > > if I were to code this I might try ; > > except ZeroDivisionError: > assert w = -1 You top-posted. Please type your response after whatever you're quoting. In my case, I only need a portion of what you said, and my remarks are following it. assert takes an expression, so the one above is just wrong. Fortunately, Python would tell you with SyntaxError: invalid syntax -- DaveA From roy at panix.com Sun Feb 12 12:11:46 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 12:11:46 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Dennis Lee Bieber wrote: > On Sun, 12 Feb 2012 10:48:36 -0500, Roy Smith wrote: > > >As Steven D'Aprano pointed out, it was missing some commonly used US > >symbols such as ?? or ??. That's interesting. When I wrote that, it showed on my screen as a cent symbol and a copyright symbol. What I see in your response is an upper case "A" with a hat accent (circumflex?) over it followed by a cent symbol, and likewise an upper case "A" with a hat accent over it followed by copyright symbol. Oh, for the days of ASCII again :-) Not to mention, of course, that I wrote , but I fully expect some of you will be reading this with absurd clients which turn that into some kind of smiley-face image. > Any volunteers to create an Extended Baudot... Instead of "letter > shift" and "number shift" we could have a generic "encoding shift" which > uses the following characters to identify which 7-bit subset of Unicode > is to be represented I think that's called UTF-8. From roy at panix.com Sun Feb 12 12:21:27 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 12:21:27 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , rusi wrote: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > Everything that displays text to a human needs to translate bytes into > > > glyphs, and the usual way to do this conceptually is to go via > > > characters. Pretending that it's all the same thing really means > > > pretending that one byte represents one character and that each > > > character is depicted by one glyph. And that's doomed to failure, unless > > > everyone speaks English with no foreign symbols - so, no mathematical > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] What I do (on a Mac) is open the Keyboard Viewer thingie and try various combinations of shift-control-option-command-function until the thing I'm looking for shows up on a keycap. A few of them I've got memorized (for example, option-8 gets you a bullet ?). I would imagine if you commonly type in a language other than English, you would quickly memorize the ones you use a lot. Or, open the Character Viewer thingie and either hunt around the various drill-down menus (North American Scripts / Canadian Aboriginal Syllabics, for example) or type in some guess at the official unicode name into the search box. From nicholas.dokos at hp.com Sun Feb 12 12:36:30 2012 From: nicholas.dokos at hp.com (Nick Dokos) Date: Sun, 12 Feb 2012 12:36:30 -0500 Subject: Python usage numbers In-Reply-To: Message from rusi of "Sun\, 12 Feb 2012 08\:50\:28 PST." References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <7533.1329068190@alphaville> rusi wrote: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > Everything that displays text to a human needs to translate bytes into > > > glyphs, and the usual way to do this conceptually is to go via > > > characters. Pretending that it's all the same thing really means > > > pretending that one byte represents one character and that each > > > character is depicted by one glyph. And that's doomed to failure, unless > > > everyone speaks English with no foreign symbols - so, no mathematical > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] [Emacs speficic] Many different ways of course, but in emacs, you can select e.g. the TeX input method with C-x RET C-\ TeX RET. which does all of the above symbols with the exception of the cent symbol (or maybe I missed it) - you type the thing in the first column and you get the thing in the second column \pounds ? \'e ? \ae ? \"o ? ^{TM} ? \copyright ? I gave up on the cent symbol and used ucs-insert (C-x 8 RET) which allows you to type a name, in this case CENT SIGN to get ?. Nick From ppearson at nowhere.invalid Sun Feb 12 12:58:45 2012 From: ppearson at nowhere.invalid (Peter Pearson) Date: 12 Feb 2012 17:58:45 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9pqculF83rU1@mid.individual.net> On 12 Feb 2012 09:12:57 GMT, Steven D'Aprano wrote: > > Suppose you're a fan of Russian punk bank ???? and you have a directory > of their music. Sigh. Banking ain't what it used to be. I'm sticking with classical Muzak. -- To email me, substitute nowhere->spamcop, invalid->net. From f.pollastri at inrim.it Sun Feb 12 13:46:04 2012 From: f.pollastri at inrim.it (Fabrizio Pollastri) Date: Sun, 12 Feb 2012 19:46:04 +0100 Subject: package extension problem Message-ID: <4F3808EC.1000301@inrim.it> Hello, I wish to extend the functionality of an existing python package by creating a new package that redefines the relevant classes of the old package. Each new class inherits the equivalent old class and adds new methods. In the new package there is something like the following. import old_package as op class A(op.A): ... add new methods ... class B(op.B): ... add new methods ... Some classes of the old package works as a dictionary of other classes of the same old package. Example: if class A and class B are classes of the old package, B[some_hash] returns an instance of A. When a program imports the new package and create instances of the new class B, B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. There is a way to solve this problem without redefining in the new package all the methods of the old package that return old classes? Thanks in advance for any suggestion, Fabrizio From not_here at no-where.net Sun Feb 12 13:53:56 2012 From: not_here at no-where.net (Brian) Date: Sun, 12 Feb 2012 10:53:56 -0800 Subject: Disable use of pyc file with no matching py file In-Reply-To: References: <12592360.1754.1327959045517.JavaMail.geo-discussion-forums@vby1> <4f27d81e$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F27F861.8020505@sequans.com> Message-ID: On 2/2/2012 1:21 AM, Terry Reedy wrote: > On 2/2/2012 1:42 AM, Devin Jeanpierre wrote: >> On Wed, Feb 1, 2012 at 2:53 PM, Terry Reedy >> wrote: >>> And it bothers me that you imput such ignorance to me. You >>> made what I think >>> was a bad analogy and I made a better one of the same type, >>> though still >>> imperfect. I acknowledged that the transition will take years. >> >> Ah. It is a common attitude among those that make these sorts of >> comments about Python 3, and I hadn't read anything in what >> you said >> that made me think that you were considering more than the >> superficial >> costs of moving. > > I thought '95% in 10 years' would be a hint that I know > upgrading is not trivial for every one ;-). > >> I am sorry that I did not give you the benefit of the doubt. > > Apology accepted. This is OT, but relevant to the side discussion. Also note that the community respects and appreciates the T.J. Reedy contributions and hard work. Reality. It was a monumental task to convert ATE driver dev and related factory automation stuff from C to Python starting in 2000. Most was done guerrilla-style. My employer now appreciates the resultant infrastructure that even the Mexico factory engineering team can use, and is good for their pride because they are no longer totally dependent on gringo engineers. Am currently being disruptive to their little world with my recent (1Q 2011) switch to 3.x. The corporate natives are restless and there is talk of an armed insurrection. Humans, at the tribal level, do not adapt to change. Expect a long series of battles that are ruthless, bloody, and have a high body count. Vive la Revolution. From alister.ware at ntlworld.com Sun Feb 12 13:55:50 2012 From: alister.ware at ntlworld.com (alister) Date: Sun, 12 Feb 2012 18:55:50 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, 12 Feb 2012 12:11:01 +0000, Mark Lawrence wrote: > On 12/02/2012 08:26, Matej Cepl wrote: >> On 12.2.2012 09:14, Matej Cepl wrote: >>>> Obvious answers: >>>> >>>> - Try decoding with UTF8 or Latin1. Even if you don't get the right >>>> characters, you'll get *something*. >>>> >>>> - Use open(filename, encoding='ascii', errors='surrogateescape') >>>> >>>> (Or possibly errors='ignore'.) >>> >>> These are not good answer, IMHO. The only answer I can think of, >>> really, >>> is: >> >> Slightly less flameish answer to the question ?What should I do, >> really?? is a tough one: all these suggested answers are bad because >> they don?t deal with the fact, that your input data are obviously >> broken. The rest is just pure GIGO ? without fixing (and I mean, >> really, >> fixing, not ignoring the problem, which is what the previous answers >> suggest) your input, you?ll get garbage on output. And you should be >> thankful to py3k that it shown the issue to you. >> >> BTW, can you display the following line? >> >> P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. >> >> Best, >> >> Mat?j > > Yes in Thunderbird, Notepad, Wordpad and Notepad++ on Windows Vista, > can't be bothered to try any other apps. Pan seems to be fine , they at least look like letters not just blocks -- Appearances often are deceiving. -- Aesop From wxjmfauth at gmail.com Sun Feb 12 14:52:46 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 12 Feb 2012 11:52:46 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: There is so much to say on the subject, I do not know where to start. Some points. Today, Sunday, 12 February 2012, 90%, if not more, of the Python applications supposed to work with text and I'm toying with are simply not working. Two reasons: 1) Most of the devs understand nothing or not enough on the field of the coding of the characters. 2) In gui applications, most of the devs understand nothing or not enough in the keyboard keys/chars handling. --- I know Python since version 1.5.2 or 1.5.6 (?). Among the applications I wrote, my fun is in writing GUI interactive interpreters with Python 2 or 3, tkinter, Tkinter, wxPython, PySide, PyQt4 on Windows. Believe or not, my interactive interpreters are the only ones where I can enter text and where text is displayed correctly. IDLE, wxPython/PyShell, DrPython, ... all are failing. (I do not count console applications). Python popularity? I have no popularity-meter. What I know: I can not type French text in IDLE on Windows. It is like this since ~ten years and I never saw any complain about this. (The problem in bad programmation). Ditto for PyShell in wxPython. I do not count, the number of corrections I proposed. In one version, it takes me 18 months until finally decided to propose a correction. During this time, I never heard of the problem. (Now, it is broken again). --- Is there a way to fix this actual status? - Yes, and *very easily*. Will it be fixed? - No, because there is no willingness to solve it. --- Roy Smith's quote: "... that we'll all just be using UTF-32, ..." Considering PEP 393, Python is not taking this road. --- How many devs know, one can not write text in French with the iso-8859-1 coding? (see pep 393) How can one explain, corporates like MS or Apple with their cp1252 or mac-roman codings succeeded to know this? Ditto for foundries (Adobe, LinoType, ...) --- Python is 20 years old. It was developped with ascii in mind. Python was not born, all this stuff was already a no problem with Windows and VB. Even a step higher, Windows was no born, this was a no problem at DOS level (eg TurboPascal), 30 years ago! Design mistake. --- Python 2 introduced the type. Very nice. Problem. The introduction of the automatic coercion ascii-"unicode", which somehow breaks everything. Very bad design mistake. (In my mind, the biggest one). --- One day, I fell on the web on a very old discussion about Python related to the introduction of unicode in Python 2. Something like: Python core dev (it was VS or AP): "... lets go with ucs-4 and we have no problem in the future ...". Look at the situation today. --- And so one. --- Conclusion. A Windows programmer is better served by downloading VB.NET Express. A end Windows user is better served with an application developped with VB.NET Express. I find somehow funny, Python is able to produce this: >>> (1.1).hex() '0x1.199999999999ap+0' >>> and on the other side, Python, Python applications, are not able to deal correctly with text entering and text displaying. Probably, the two most important tasks a "computer" has to do! jmf PS I'm not a computer scientist, only a computer user. From vinay_sajip at yahoo.co.uk Sun Feb 12 15:13:17 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 12:13:17 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> On Feb 12, 3:35?pm, Anh Hai Trinh wrote: > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. > I have looked at pbs and clom: they Pythonify calls to external programs by making spawning those look like function calls. There's nothing wrong with that, it's just a matter of taste. I find that e.g. wc(ls("/etc", "-1"), "-l") is not as readable as call(?ls /etc ?1 | wc ?l?) and the attempt to Pythonify doesn't buy you much, IMO. Of course, it is a matter of taste - I understand that there are people who will prefer the pbs/clom way of doing things. > Re. threads & fork():http://www.linuxprogrammingblog.com/threads-and-fork-think-twice-befo... > > For a careful impl of fork-exec with threads, seehttp://golang.org/src/pkg/syscall/exec_unix.go Thanks for the links. The first seems to me to be talking about the dangers of locking and forking; if you don't use threads, you don't need locks, so the discussion about locking only really applies in a threading+forking scenario. I agree that locking+forking can be problematic because the semantics of what happens to the state of the locks and threads in the child (for example, as mentioned in http://bugs.python.org/issue6721). However, it's not clear that any problem occurs if the child just execs a new program, overwriting the old - which is the case here. The link you pointed to says that "It seems that calling execve(2) to start another program is the only sane reason you would like to call fork(2) in a multi-threaded program." which is what we're doing in this case. Even though it goes on to mention the dangers inherent in inherited file handles, it also mentions that these problems have been overcome in recent Linux kernels, and the subprocess module does contain code to handle at least some of these conditions (e.g. preexec_fn, close_fds keyword arguments to subprocess.Popen). Hopefully, if there are race conditions which emerge in the subprocess code (as has happened in the past), they will be fixed (as has happened in the past). > Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p That is of course your privilege. I would hardly expect you to drop extproc in favour of sarge. But there might be people who need to tread in these dangerous waters, and hopefully sarge will make things easier for them. As I said earlier, one doesn't *need* to use asynchronous calls. I agree that I may have to review the design decisions I've made, based on feedback based on people actually trying the async functionality out. I don't feel that shying away from difficult problems without even trying to solve them is the best way of moving things forward. What are the outcomes? * Maybe people won't even try the async functionality (in which case, they won't hit problems) * They'll hit problems and just give up on the library (I hope not - if I ever have a problem with a library I want to use, I always try and engage with the developers to find a workaround or fix) * They'll report problems which, on investigation, will turn out to be fixable bugs - well and good * The reported bugs will be unfixable for some reason, in which case I'll just have to deprecate that functionality. Remember, this is version 0.1 of the library, not version 1.0. I expect to do some API and functionality tweaks based on feedback and bugs which show up. > I do think that IO redirection is much nicer with extproc. Again, a matter of taste. You feel that it's better to pass dicts around in the public API where integer file handles map to other handles or streams; I feel that using a Capture instance is less fiddly for the user. Let a thousand flowers bloom, and all that. I do thank you for the time you've taken to make these comments, and I found the reading you pointed me to interesting. I will update the sarge docs to point to the link on the Linux Programming blog, to make sure people are informed of potential pitfalls. Regards, Vinay Sajip From steveo at syslang.net Sun Feb 12 15:14:24 2012 From: steveo at syslang.net (Steven W. Orr) Date: Sun, 12 Feb 2012 15:14:24 -0500 Subject: Need help with shutils.copytree Message-ID: <4F381DA0.4020505@syslang.net> I have a 'master' directory and a collection of 'slave' dirs. I want the master to collect all of the stuff in the slave dirs. The slaves all look like this, . |-- slaveX | `-- archI | | `-- distJ | | | ` -- FILE Where the different slaveX dirs may contain multiple occurrences of archI and distJ, but across all slaveX dirs, there will only be one *unique* instance of FILE in archI and distJ. Here's an example: Given slave[1234], arch1 and arch2, and dist1 and dist2, I want master to end up looking like this: . |-- master | `-- arch1 | | ` -- dist1 | | | ` -- FILE | `-- arch1 | | ` -- dist2 | | | ` -- FILE | `-- arch2 | | ` -- dist1 | | | ` -- FILE | `-- arch2 | | ` -- dist2 | | | ` -- FILE etc... In bash, I might use cpio passthrough mode and say something like: master=$path_to_master for slave in ${slaves} do pushd $slave find . -print | cpio -pdum $master popd done but I'm having a hard time trying to get this functionality in python. (I'm trying to avoid writing a subprocess.) I tried using shutil.copytree with a try / except that does a pass on OSError (which is what gets raised when trying to create a dir that already exists). No joy there. I also tried an ignore function that always returns (). Someone must have done this before. Any suggestions / pointers are much appreciated. (I hope this was clear to read.) TIA -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From mdickinson at enthought.com Sun Feb 12 15:18:15 2012 From: mdickinson at enthought.com (Mark Dickinson) Date: Sun, 12 Feb 2012 12:18:15 -0800 (PST) Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 6:41?am, Steven D'Aprano wrote: > ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. > ? ? ? ? ? ? if abs(err) <= 1e-16: > ? ? ? ? ? ? ? ? break If the result you're expecting is around -1.005, this exit condition is rather optimistic: the difference between the two Python floats either side of this value is already 2.22e-16, so you're asking for less than half a ulp of error! As to the rest; your error estimate simply doesn't have enough precision. The main problem is in the computation of a, where you're subtracting two almost identical values. The absolute error incurred in computing w*exp(w) is of the same order of magnitude as the difference 'w*exp(w) - x' itself, so err has lost essentially all of its significant bits, and is at best only a crude indicator of the size of the error. The solution would be to compute the quantities 'exp(w), w*exp(w), and w*exp(w) - x' all with extended precision. For the other quantities, there shouldn't be any major issues---after all, you only need a few significant bits of 'delta' for it to be useful, but with the subtraction that generates a, you don't even get those few significant bits. > (The correct value for w is approximately -1.00572223991.) Are you sure? Wolfram Alpha gives me the following value for W(-1, -0.36787344117144249455719773322925902903079986572265625): -1.005722239691522978... so it looks as though the values you're getting are at least alternating around the exact value. -- Mark From vinay_sajip at yahoo.co.uk Sun Feb 12 15:21:55 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sun, 12 Feb 2012 12:21:55 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <10831099.690.1329063558642.JavaMail.geo-discussion-forums@pbcmg9> Message-ID: On Feb 12, 4:19?pm, Anh Hai Trinh wrote: > If you use threads and call fork(), you'll almost guaranteed to face with deadlocks. Perhaps not in a particular piece of code, but some others. Perhaps not on your laptop, but on the production machine with different kernels. Like most race conditions, they will eventually show up. You can hit deadlocks in multi-threaded programs even without the fork(), can't you? In that situation, you either pin it down to a bug in your code (and even developers experienced in writing multi- threaded programs hit these), or a bug in the underlying library (which can hopefully be fixed, but that applies to any bug you might hit in any library you use, and is something you have to consider whenever you use a library written by someone else), or an unfixable problem (e.g. due to problems in the Python or C runtime) which require a different approach. I understand your concerns, but you are just a little further along the line from people who say "If you use threads, you will have deadlock problems. Don't use threads." I'm not knocking that POV - people need to use what they're comfortable with, and to avoid things that make them uncomfortable. I'm not pushing the async feature as a major advantage of the library - it's still useful without that, IMO. Regards, Vinay Sajip From clp2 at rebertia.com Sun Feb 12 16:09:51 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 12 Feb 2012 13:09:51 -0800 Subject: Need help with shutils.copytree In-Reply-To: <4F381DA0.4020505@syslang.net> References: <4F381DA0.4020505@syslang.net> Message-ID: On Sun, Feb 12, 2012 at 12:14 PM, Steven W. Orr wrote: > I have a 'master' directory and a collection of 'slave' dirs. I want the > master to collect all of the stuff in the slave dirs. > > The slaves all look like this, > > . > |-- slaveX > | ? `-- archI > | ? | ? `-- distJ > | ? | ? | ? ` -- FILE > > Where the different slaveX dirs may contain multiple occurrences of archI > and distJ, but across all slaveX dirs, there will only be one *unique* > instance of FILE in archI and distJ. > > Here's an example: Given slave[1234], arch1 and arch2, and dist1 and dist2, > I want master to end up looking like this: > > . > |-- master > | ? `-- arch1 > | ? | ? ` -- dist1 > | ? | ? | ? ?` -- FILE > | ? `-- arch1 > | ? | ? ` -- dist2 > | ? | ? | ? ?` -- FILE > | ? `-- arch2 > | ? | ? ` -- dist1 > | ? | ? | ? ?` -- FILE > | ? `-- arch2 > | ? | ? ` -- dist2 > | ? | ? | ? ?` -- FILE > > etc... You have multiple directories at the same level in the hierarchy with identical names (e.g. two "arch1"s), which is invalid. I assume you meant for them to be combined? > In bash, I might use cpio passthrough mode and say something like: > > master=$path_to_master > for slave in ${slaves} > do > ? ?pushd $slave > ? ?find . -print | cpio -pdum $master > ? ?popd > done > > but I'm having a hard time trying to get this functionality in python. (I'm > trying to avoid writing a subprocess.) > > I tried using shutil.copytree with a try / except that does a pass on > OSError (which is what gets raised when trying to create a dir that already > exists). No joy there. Right; the stack has already been unwound by the time your `except` clause is reached. You just need to recover by instead copying the children of the subtree individually yourself when their parent already exists. For example: master/arch1 already exists? Then copy the slave/arch1/distN-s individually. Or alternately, abandon copytree() entirely: you just LYBL and check if the parent directories already exist; if not, you try to create the directories yourself; and finally, you copy the individual files. [Useful funcs: os.listdir(), os.path.exists(), os.mkdir() / os.mkdirs()] > I also tried an ignore function that always returns (). That's an effective no-op which doesn't alter copytree()'s behavior whatsoever. Cheers, Chris -- http://rebertia.com From tjreedy at udel.edu Sun Feb 12 16:19:31 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 16:19:31 -0500 Subject: Numeric root-finding in Python In-Reply-To: References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 5:10 AM, Eelco wrote: > On Feb 12, 7:41 am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> This is only peripherally a Python problem, but in case anyone has any >> good ideas I'm going to ask it. >> >> I have a routine to calculate an approximation of Lambert's W function, >> and then apply a root-finding technique to improve the approximation. >> This mostly works well, but sometimes the root-finder gets stuck in a >> cycle. >> >> Here's my function: >> >> import math >> def improve(x, w, exp=math.exp): >> """Use Halley's method to improve an estimate of W(x) given >> an initial estimate w. >> """ >> try: >> for i in range(36): # Max number of iterations. >> ew = exp(w) >> a = w*ew - x >> b = ew*(w + 1) >> err = -a/b # Estimate of the error in the current w. >> if abs(err)<= 1e-16: >> break >> print '%d: w= %r err= %r' % (i, w, err) >> # Make a better estimate. >> c = (w + 2)*a/(2*w + 2) >> delta = a/(b - c) >> w -= delta >> else: >> raise RuntimeError('calculation failed to converge', err) >> except ZeroDivisionError: >> assert w == -1 >> return w >> >> Here's an example where improve() converges very quickly: >> >> py> improve(-0.36, -1.222769842388856) >> 0: w= -1.222769842388856 err= -2.9158979924038895e-07 >> 1: w= -1.2227701339785069 err= 8.4638038491998997e-16 >> -1.222770133978506 >> >> That's what I expect: convergence in only a few iterations. >> >> Here's an example where it gets stuck in a cycle, bouncing back and forth >> between two values: >> >> py> improve(-0.36787344117144249, -1.0057222396915309) >> 0: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 1: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 2: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 3: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> 4: w= -1.0057222396915309 err= 2.6521238905750239e-14 >> 35: w= -1.0057222396915044 err= -2.6521238905872001e-14 >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 19, in improve >> RuntimeError: ('calculation failed to converge', -2.6521238905872001e-14) >> >> (The correct value for w is approximately -1.00572223991.) >> >> I know that Newton's method is subject to cycles, but I haven't found any >> discussion about Halley's method and cycles, nor do I know what the best >> approach for breaking them would be. None of the papers on calculating >> the Lambert W function that I have found mentions this. >> >> Does anyone have any advice for solving this? > Looks like floating point issues to me, rather than something > intrinsic to the iterative algorithm. Surely there is not complex > chaotic behavior to be found in this fairly smooth function in a +/- > 1e-14 window. Otoh, there is a lot of floating point significant bit > loss issues to be suspected in the kind of operations you are > performing (exp(x) + something, always a tricky one). To investigate this, I would limit the iterations to 2 or 3 and print ew, a,b,c, and delta, maybe in binary(hex) form > I would start by asking: How accurate is good enough? If its not good > enough, play around the the ordering of your operations, try solving a > transformed problem less sensitive to loss of significance; and begin > by trying different numeric types to see if the problem is sensitive > thereto to begin with. -- Terry Jan Reedy From tjreedy at udel.edu Sun Feb 12 17:07:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 17:07:44 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 10:13 AM, Roy Smith wrote: > Exactly.. ASCII was so successful > at becoming a universal standard which lasted for decades, I think you are overstating the universality and length. I used a machine in the 1970s with 60-bit words that could be interpreted as 10 6-bit characters. IBM used EBCDIC at least into the 1980s. The UCLA machine I used had a translator for ascii terminals that connected by modems. I remember discussing the translation table with the man in charge of it. Dedicated wordprocessing machines of the 70s and 80s *had* to use something other than plain ascii, as it is inadequate for business text, as opposed to pure computation and labeled number tables. Whether they used extended ascii or something else, I have no idea. Ascii was, however, as far as I know, the universal basis for the new personal computers starting about 1975, and most importantly, for the IBM PC. But even that actually used its version of extended ascii, as did each wordprocessing program. > people who > grew up with it don't realize there was once any other way. Not just > EBCDIC, but also SIXBIT, RAD-50, tilt/rotate, packed card records, > and so on. Transcoding was a way of life, and if you didn't know what > you were starting with and aiming for, it was hopeless. But because of the limitation of ascii on a worldwide, as opposed to American basis, we ended up with 100-200 codings for almost as many character sets. This is because the idea of ascii was applied by each nation or language group individually to their local situation. > Kind of like now where we are again with Unicode. The situation before ascii is like where we ended up *before* unicode. Unicode aims to replace all those byte encoding and character sets with *one* byte encoding for *one* character set, which will be a great simplification. It is the idea of ascii applied on a global rather that local basis. Let me repeat. Unicode and utf-8 is a solution to the mess, not the cause. Perhaps we should have a synonym for utf-8: escii, for Earthian Standard Code for Information Interchange. -- Terry Jan Reedy From rosuav at gmail.com Sun Feb 12 17:14:29 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 09:14:29 +1100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > The situation before ascii is like where we ended up *before* unicode. > Unicode aims to replace all those byte encoding and character sets with > *one* byte encoding for *one* character set, which will be a great > simplification. It is the idea of ascii applied on a global rather that > local basis. Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so are UTF-16, UTF-32. and as many more as you could hope for. But broadly yes, Unicode IS the solution. ChrisA From roy at panix.com Sun Feb 12 17:22:33 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 17:22:33 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Terry Reedy wrote: > Let me repeat. Unicode and utf-8 is a solution to the mess, not the > cause. Perhaps we should have a synonym for utf-8: escii, for Earthian > Standard Code for Information Interchange. I'm not arguing that Unicode is where we need to get to. Just trying to give a little history. From roy at panix.com Sun Feb 12 17:27:34 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 17:27:34 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > > The situation before ascii is like where we ended up *before* unicode. > > Unicode aims to replace all those byte encoding and character sets with > > *one* byte encoding for *one* character set, which will be a great > > simplification. It is the idea of ascii applied on a global rather that > > local basis. > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so > are UTF-16, UTF-32. and as many more as you could hope for. But > broadly yes, Unicode IS the solution. I could hope for one and only one, but I know I'm just going to be disapointed. The last project I worked on used UTF-8 in most places, but also used some C and Java libraries which were only available for UTF-16. So it was transcoding hell all over the place. Hopefully, we will eventually reach the point where storage is so cheap that nobody minds how inefficient UTF-32 is and we all just start using that. Life will be a lot simpler then. No more transcoding, a string will just as many bytes as it is characters, and everybody will be happy again. From steve+comp.lang.python at pearwood.info Sun Feb 12 17:30:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:30:32 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: > On 2/12/2012 3:12 AM, Steven D'Aprano wrote: >> NTFS by default uses the UTF-16 encoding, which means the actual bytes >> written to disk are \x1d\x040\x04\xe5\x042\x04 (possibly with a leading >> byte-order mark \xff\xfe). > > That's what I meant. Those bytes will be interpreted consistently across > all locales. Right. But, that's not Unicode, it is an encoding of Unicode. Terminology is important -- if we don't call things by the "right" names (or at least agreed upon names) how can we communicate? >> Windows has two separate APIs, one for "wide" characters, the other for >> single bytes. Depending on which one you use, the directory will appear >> to be called ???? or 0?2. > > Yes, and AFAIK, the wide API is the default. The other one only exists > to support programs that don't support the wide API (generally, such > programs were intended to be used on older platforms that lack that > API). I'm not sure that "default" is the right word, since (as far as I know) both APIs have different spelling and the coder has to make the choice whether to call function X or function Y. Perhaps you mean that Microsoft encourages the wide API and makes the single-byte API available for legacy reasons? >> But in any case, we're not talking about the file name encoding. We're >> talking about the contents of files. > > Okay then. As I stated, this has nothing to do with the OS since > programs are free to interpret bytes any way they like. Yes, but my point was that even if the developer thinks he can avoid the problem by staying away from "Unicode files" coming from Linux and OS-X, he can't avoid dealing with multiple code pages on Windows. You are absolutely correct that this is *not* a cross-platform issue to do with the OS, but some people may think it is. -- Steven From cezar4846 at gmail.com Sun Feb 12 17:34:38 2012 From: cezar4846 at gmail.com (zigi) Date: Sun, 12 Feb 2012 14:34:38 -0800 (PST) Subject: M2crypto Message-ID: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Hello, M2crypto __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', salt='12345678', i=1, padding=1) I wont write app, using M2crypto and I can not understand what are the arguments: key, iv, op, salt ? What they do ? From davea at dejaviewphoto.com Sun Feb 12 17:40:38 2012 From: davea at dejaviewphoto.com (Dave Angel) Date: Sun, 12 Feb 2012 17:40:38 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F383FE6.1060902@dejaviewphoto.com> On 02/12/2012 05:27 PM, Roy Smith wrote: > In article, > Chris Angelico wrote: > >> On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >>> The situation before ascii is like where we ended up *before* unicode. >>> Unicode aims to replace all those byte encoding and character sets with >>> *one* byte encoding for *one* character set, which will be a great >>> simplification. It is the idea of ascii applied on a global rather that >>> local basis. >> Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so >> are UTF-16, UTF-32. and as many more as you could hope for. But >> broadly yes, Unicode IS the solution. > I could hope for one and only one, but I know I'm just going to be > disapointed. The last project I worked on used UTF-8 in most places, > but also used some C and Java libraries which were only available for > UTF-16. So it was transcoding hell all over the place. > > Hopefully, we will eventually reach the point where storage is so cheap > that nobody minds how inefficient UTF-32 is and we all just start using > that. Life will be a lot simpler then. No more transcoding, a string > will just as many bytes as it is characters, and everybody will be happy > again. Keep your in-memory character strings as Unicode, and only serialize(encode) them when they go to/from a device, or to/from anachronistic code. Then the cost is realized at the point of the problem. No different than when deciding how to serialize any other data type. Do it only at the point of entry/exit of your program. But as long as devices are addressed as bytes, or as anything smaller than 32bit thingies, you will have encoding issues when writing to the device, and decoding issues when reading. At the very least, you have big-endian/little-endian ways to encode that UCS-4 code point. From ben+python at benfinney.id.au Sun Feb 12 17:43:52 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 13 Feb 2012 09:43:52 +1100 Subject: How do you Unicode proponents type your non-ASCII characters? (was: Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87d39j3c5z.fsf_-_@benfinney.id.au> rusi writes: > On Feb 12, 10:51?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > office of Encyclop?dia Britanica to apply for the position of Staff > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? In GNU+Linux, I run the IBus daemon to manage different keyboard input methods across all my applications consistently. That makes hundreds of language-specific input methods available, and also many that are not language-specific. It's useful if I want to ????????? type a passage of Japanese with the ?anthy? input method, or likewise for any of the other available language-specific input methods. I normally have IBus presenting the ?rfc1345? input method. That makes just about all keys input the corresponding character just as if no input method were active. But when I type ?&? followed by a two- or three-key sequence, it inputs the corresponding character from the RFC?1345 mnemonics table: & ? & P d ? ? e ' ? ? a e ? ? o : ? ? C t ? ? T M ? ? C o ? ? " 6 ? ? " 9 ? ? ? Those same characters are also available with the ?latex? input method, if I'm familiar with LaTeX character entity names. (I'm not.) -- \ ?If [a technology company] has confidence in their future | `\ ability to innovate, the importance they place on protecting | _o__) their past innovations really should decline.? ?Gary Barnett | Ben Finney From steve+comp.lang.python at pearwood.info Sun Feb 12 17:49:08 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:49:08 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3841e4$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:11:46 -0500, Roy Smith wrote: > In article , > Dennis Lee Bieber wrote: > >> On Sun, 12 Feb 2012 10:48:36 -0500, Roy Smith wrote: >> >> >As Steven D'Aprano pointed out, it was missing some commonly used US >> >symbols such as ? or ?. > > That's interesting. When I wrote that, it showed on my screen as a cent > symbol and a copyright symbol. What I see in your response is an upper > case "A" with a hat accent (circumflex?) over it followed by a cent > symbol, and likewise an upper case "A" with a hat accent over it > followed by copyright symbol. Somebody's mail or news reader is either ignoring the message's encoding line, or not inserting an encoding line. Either way, that's a bug. > Oh, for the days of ASCII again :-) I look forward to the day, probably around 2525, when everybody uses UTF-32 always. -- Steven From d at davea.name Sun Feb 12 17:50:12 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 17:50:12 -0500 Subject: Python usage numbers In-Reply-To: <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f378298$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f383d87$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F384224.2010508@davea.name> On 02/12/2012 05:30 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 05:11:30 -0600, Andrew Berg wrote: > >> On 2/12/2012 3:12 AM, Steven D'Aprano wrote: > >>> Windows has two separate APIs, one for "wide" characters, the other for >>> single bytes. Depending on which one you use, the directory will appear >>> to be called ???? or 0?2. >> Yes, and AFAIK, the wide API is the default. The other one only exists >> to support programs that don't support the wide API (generally, such >> programs were intended to be used on older platforms that lack that >> API). > I'm not sure that "default" is the right word, since (as far as I know) > both APIs have different spelling and the coder has to make the choice > whether to call function X or function Y. Perhaps you mean that Microsoft > encourages the wide API and makes the single-byte API available for > legacy reasons? > > When I last looked, the pair of functions were equivalently available, and neither one was named the way you'd expect. One had a suffix of A and the other had a suffix of W (guess which was which). C header definitions used #define to define the actual functions, and the preprocessor effectively stuck A's on all of them or W's on all of them. Very bulky, but buried in some MS header files. Other languages were free to use either or both. VB used just the W versions, as I presume java does. But the interesting point was that for most of these functions, the A versions were native on Win95-derived OS'es, while the W versions were native on NT-derived OS's. There were translation DLL's which supplied the secondary versions. So in the old days it was more efficient to use the A versions. No longer true, since as far as I know, nobody that still uses Win ME, Win98, or Win95 is targeted for much new programming. -- DaveA From steve+comp.lang.python at pearwood.info Sun Feb 12 17:53:15 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:53:15 GMT Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3842db$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 13:52:48 +0000, Robert Kern wrote: > I don't have any advice for fixing your code, per se, but I would just > grab mpmath and use their lambertw function: That's no fun! I'd never see mpmath before, it looks like it is worth investigating. Nevertheless, I still intend working on my lambert function, as it's a good learning exercise. I did look into SciPy's lambert too, and was put off by this warning in the docs: "In some corner cases, lambertw might currently fail to converge" http://docs.scipy.org/doc/scipy/reference/generated/ scipy.special.lambertw.html Naturally I thought "I can do better than that". Looks like I can't :) -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 17:56:32 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 22:56:32 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3843a0$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 08:50:28 -0800, rusi wrote: >> You can't say that it cost you ?10 to courier your r?sum? to the head >> office of Encyclop?dia Britanica to apply for the position of Staff >> Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit >> stuffy and old-fashioned, but it is traditional English.) >> >> Hell, you can't even write in *American*: you can't say that the recipe >> for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > [Quite OT but...] How do you type all this? [Note: I grew up on APL so > unlike Rick I am genuinely asking :-) ] In my case, I used the KDE application "KCharSelect". I manually hunt through the tables for the character I want (which sucks), click on the characters I want, and copy and paste them into my editor. Back in Ancient Days when I ran Mac OS 6, I had memorised many keyboard shortcuts for these things. Option-4 was the pound sign, I believe, and Option-Shift-4 the cent sign. Or perhaps the other way around? -- Steven From tycho at tycho.ws Sun Feb 12 18:04:07 2012 From: tycho at tycho.ws (Tycho Andersen) Date: Sun, 12 Feb 2012 17:04:07 -0600 Subject: Generating a .pc file using distutils In-Reply-To: <20120123233120.GC6157@smitten> References: <20120123233120.GC6157@smitten> Message-ID: <20120212230407.GB29922@smitten> Just re-bumping this - I am fiddling with this code again and it's gross, so any input would be greatly appreciated :-) \t On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: > Is there some standard way to generate a .pc file (given a .pc.in or > similar) using distutils? > > If there's not, is there a good way to access whatever the user passes > in as --prefix (besides parsing sys.argv yourself)? > > Thanks, > > \t From steve+comp.lang.python at pearwood.info Sun Feb 12 18:05:47 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 23:05:47 GMT Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > On Feb 12, 6:41?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > >> ? ? ? ? ? ? err = -a/b ?# Estimate of the error in the current w. >> ? ? ? ? ? ? if abs(err) <= 1e-16: >> ? ? ? ? ? ? ? ? break > > If the result you're expecting is around -1.005, this exit condition is > rather optimistic: the difference between the two Python floats either > side of this value is already 2.22e-16, so you're asking for less than > half a ulp of error! I was gradually coming to the conclusion on my own that I was being overly optimistic with my error condition, although I couldn't put it into words *why*. Thanks for this Mark, this is exactly the sort of thing I need to learn -- as is obvious, I'm no expert on numeric programming. > As to the rest; your error estimate simply doesn't have enough > precision. The main problem is in the computation of a, where you're > subtracting two almost identical values. The absolute error incurred in > computing w*exp(w) is of the same order of magnitude as the difference > 'w*exp(w) - x' itself, so err has lost essentially all of its > significant bits, and is at best only a crude indicator of the size of > the error. The solution would be to compute the quantities 'exp(w), > w*exp(w), and w*exp(w) - x' all with extended precision. Other than using Decimal, there's no way to do that in pure Python, is there? We have floats (double) and that's it. > For the other > quantities, there shouldn't be any major issues---after all, you only > need a few significant bits of 'delta' for it to be useful, but with the > subtraction that generates a, you don't even get those few significant > bits. > >> (The correct value for w is approximately -1.00572223991.) > > Are you sure? Wolfram Alpha gives me the following value for W(-1, > -0.36787344117144249455719773322925902903079986572265625): > > -1.005722239691522978... I did say *approximately*. The figure I quote comes from my HP-48GX, and seems to be accurate to the precision offered by the HP. -- Steven From steve+comp.lang.python at pearwood.info Sun Feb 12 18:29:51 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Feb 2012 23:29:51 GMT Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >> > The situation before ascii is like where we ended up *before* >> > unicode. Unicode aims to replace all those byte encoding and >> > character sets with *one* byte encoding for *one* character set, >> > which will be a great simplification. It is the idea of ascii applied >> > on a global rather that local basis. >> >> Unicode doesn't deal with byte encodings; UTF-8 is an encoding, but so >> are UTF-16, UTF-32. and as many more as you could hope for. But broadly >> yes, Unicode IS the solution. > > I could hope for one and only one, but I know I'm just going to be > disapointed. The last project I worked on used UTF-8 in most places, > but also used some C and Java libraries which were only available for > UTF-16. So it was transcoding hell all over the place. Um, surely the solution to that is to always call a simple wrapper function to the UTF-16 code to handle the transcoding? What do the Design Patterns people call it, a facade? No, an adapter. (I never remember the names...) Instead of calling library.foo() which only outputs UTF-16, write a wrapper myfoo() which calls foo, captures its output and transcribes to UTF-8. You have to do that once (per function), but now it works from everywhere, so long as you remember to always call myfoo instead of foo. > Hopefully, we will eventually reach the point where storage is so cheap > that nobody minds how inefficient UTF-32 is and we all just start using > that. Life will be a lot simpler then. No more transcoding, a string > will just as many bytes as it is characters, and everybody will be happy > again. I think you mean 4 times as many bytes as characters. Unless you have 32 bit bytes :) -- Steven From tjreedy at udel.edu Sun Feb 12 18:30:21 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 18:30:21 -0500 Subject: French and IDLE on Windows (was Re: Python usage numbers) In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 2:52 PM, jmfauth wrote: > Python popularity? I have no popularity-meter. What I know: > I can not type French text in IDLE on Windows. It is like I am pretty sure others have managed to. tk and hence idle handle the entire BMP subset of unicode just fine once they get them. Except for the apple version, which has just been fixed so French entry should work. Showing characters on the screen requires an appropriate font. http://bugs.python.org/issue4281 was the result of a font problem. > this since ~ten years and I never saw any complain about > this. Neither have I, except for the issue above I just found. So there is nothing obvious to fix. If you have a problem, give the specifics here and lets see if someone has a solution. -- Terry Jan Reedy From d at davea.name Sun Feb 12 18:32:46 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 18:32:46 -0500 Subject: Generating a .pc file using distutils In-Reply-To: <20120212230407.GB29922@smitten> References: <20120123233120.GC6157@smitten> <20120212230407.GB29922@smitten> Message-ID: <4F384C1E.60304@davea.name> On 02/12/2012 06:04 PM, Tycho Andersen wrote: > Just re-bumping this - I am fiddling with this code again and it's > gross, so any input would be greatly appreciated :-) > > \t > > On Mon, Jan 23, 2012 at 05:31:20PM -0600, Tycho Andersen wrote: >> Is there some standard way to generate a .pc file (given a .pc.in or >> similar) using distutils? >> >> If there's not, is there a good way to access whatever the user passes >> in as --prefix (besides parsing sys.argv yourself)? >> >> Thanks, >> >> \t Bumping a message (especially using top-posting) seldom does much good unless you also supply some more information to either catch people's attention, or even better, remind them of something they know that might apply. So you could have said: A .pc file is "lijfds;lkjds;fdsjfds;ljfds;ljfds;ljfd" and I need to produce it in the "slf;lfdsjfds;l;lkjfds;lj" circumstances. Or, a .pc file is described on the wiki page at link http://www.sljfds.slijfdsj.unknown Or even "I tried to get more information on the comp.lang.pc newsgroup, but nobody there will give me the time of day. As it is, the only thing I could do is point you to the only other keyword in your message: Try on a support forum for distutils. -- DaveA From roy at panix.com Sun Feb 12 18:41:21 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 18:41:21 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <4f384b6e$0$29986$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > > I could hope for one and only one, but I know I'm just going to be > > disapointed. The last project I worked on used UTF-8 in most places, > > but also used some C and Java libraries which were only available for > > UTF-16. So it was transcoding hell all over the place. > > Um, surely the solution to that is to always call a simple wrapper > function to the UTF-16 code to handle the transcoding? What do the Design > Patterns people call it, a facade? No, an adapter. (I never remember the > names...) I am familiar with the concept. It was ICU. A very big library. Lots of calls. I don't remember the details, I'm sure we wrote wrappers. It was still a mess. > > Hopefully, we will eventually reach the point where storage is so cheap > > that nobody minds how inefficient UTF-32 is and we all just start using > > that. Life will be a lot simpler then. No more transcoding, a string > > will just as many bytes as it is characters, and everybody will be happy > > again. > > I think you mean 4 times as many bytes as characters. Unless you have 32 > bit bytes :) Yes, exactly. From d at davea.name Sun Feb 12 18:52:47 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 18:52:47 -0500 Subject: Numeric root-finding in Python In-Reply-To: <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3845cb$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3850CF.4020802@davea.name> On 02/12/2012 06:05 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > >> On Feb 12, 6:41 am, Steven D'Aprano> +comp.lang.pyt... at pearwood.info> wrote: >> >>> err = -a/b # Estimate of the error in the current w. >>> if abs(err)<= 1e-16: >>> break >> If the result you're expecting is around -1.005, this exit condition is >> rather optimistic: the difference between the two Python floats either >> side of this value is already 2.22e-16, so you're asking for less than >> half a ulp of error! > I was gradually coming to the conclusion on my own that I was being > overly optimistic with my error condition, although I couldn't put it > into words *why*. Thanks for this Mark, this is exactly the sort of thing > I need to learn -- as is obvious, I'm no expert on numeric programming. > > me either. But comments below. >> As to the rest; your error estimate simply doesn't have enough >> precision. The main problem is in the computation of a, where you're >> subtracting two almost identical values. > > Two pieces of my history that come to mind. 40+ years ago I got a letter from a user of our computer stating that our math seemed to be imprecise in certain places. He was very polte about it, and admitted to maybe needing a different algorithm. The letter was so polite that I (as author of the math microcode) worked on his problem, and found the difficulty, as well as a solution. The problem was figuring out the difference in a machining table between being level every place on its surface (in which case it would be slightly curved to match the earth), or being perfectly flat (in which case some parts of the table would be further from the earth's center than others) The table was 200 feet long, and we were talking millionths of an inch. He solved it three ways, and got three different answers. The first two differed in the 3rd place, which he thought far too big an error, and the third answer was just about exactly half the others. Well the 2:1 discrepancy just happens when you change your assumption of what part of the flat table is level. If the center is level, then the edges are only 100 feet out, while if the edge is level, the other edge is 200 feet out. But the other solution was very interesting. Turns out he sketched a right triangle, with narrow angle at the center of the earth, side opposite being 200 feet. He then calculated the difference between the other two sides. one 8000 miles, and the other 8000 miles plus a few microinches. He got that distance by subtracting the sine from the tangent, or something similar to that. I had microcoded both those functions, and was proud of their accuracy. But if you subtract two 13 digit numbers that only differ in the last 3, you only get 3 digits worth of accuracy, best case. Solution was to apply some similar triangles, and some trivial approximations, and the problem turned out not to need trig at all, and accurate to at least 12 places. if I recall, it was something like 8000mi is to 200 feet, as 200 feet is to X. Cross multiply and it's just arithmetic. The other problem was even earlier. It was high school physics, and the challenge was to experimentally determine the index of refraction of air to 5 places. Problem is our measurements can't be that accurate. So this is the same thing in reverse. Find a way to measure the difference of the index of refraction of air and vacuum, to one or two places, and add that to 1.00000000 taken together with lots of other experience, i try to avoid commiting an algorithm to code before thinking about errors, convergence, and exceptional conditions. I've no experience with Lambert, but I suspect it can be attacked similarly. -- DaveA From lists at cheimes.de Sun Feb 12 19:00:14 2012 From: lists at cheimes.de (Christian Heimes) Date: Mon, 13 Feb 2012 01:00:14 +0100 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: Am 12.02.2012 23:07, schrieb Terry Reedy: > But because of the limitation of ascii on a worldwide, as opposed to > American basis, we ended up with 100-200 codings for almost as many > character sets. This is because the idea of ascii was applied by each > nation or language group individually to their local situation. You really learn to appreciate unicode when you have to deal with mixed languages in texts and old databases from the 70ties and 80ties. I'm working with books that contain medieval German, old German, modern German, English, French, Latin, Hebrew, Arabic, ancient and modern Greek, Rhaeto-Romanic, East European and more languages. Sometimes three or four languages are used in a single book. Some books are more than 700 years old and contain glyphs that aren't covered by unicode yet. Without unicode it would be virtually impossible to deal with it. Metadata for these books come from old and proprietary databases and are stored in a format that is optimized for magnetic tape. Most people will never have heard about ISO-5426 or ANSEL encoding or about file formats like MAB2, MARC or PICA. It took me quite some time to develop codecs to encode and decode an old and partly undocumented variable multibyte encodings that predates UTF-8 by about a decade. Of course every system interprets the undocumented parts slightly different ... Unicode and XML are bliss for metadata exchange and long term storage! From mwilson at the-wire.com Sun Feb 12 19:00:52 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Sun, 12 Feb 2012 19:00:52 -0500 Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: zigi wrote: > Hello, > M2crypto > > __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > salt='12345678', i=1, padding=1) > > I wont write app, using M2crypto and I can not understand what are the > arguments: > key, iv, op, salt ? > What they do ? I assume you're reading in about M2Crypto.EVP.Cipher. Epydoc claims another victim. I'm having a lot of trouble finding documentation. The obvious OpenSSL pages are kind of thin, too. You might see some useful code in the EVP unit tests m2crypto/tests/test_evp.py in the m2crypto installation. Good hunting, Mel. From d at davea.name Sun Feb 12 19:03:54 2012 From: d at davea.name (Dave Angel) Date: Sun, 12 Feb 2012 19:03:54 -0500 Subject: Python usage numbers In-Reply-To: <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F38536A.2030208@davea.name> On 02/12/2012 06:29 PM, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 17:27:34 -0500, Roy Smith wrote: > >> >> Hopefully, we will eventually reach the point where storage is so cheap >> that nobody minds how inefficient UTF-32 is and we all just start using >> that. Life will be a lot simpler then. No more transcoding, a string >> will just as many bytes as it is characters, and everybody will be happy >> again. > I think you mean 4 times as many bytes as characters. Unless you have 32 > bit bytes :) > > Until you have 32 bit bytes, you'll continue to have encodings, even if only a couple of them. -- DaveA From debatem1 at gmail.com Sun Feb 12 19:28:29 2012 From: debatem1 at gmail.com (geremy condra) Date: Sun, 12 Feb 2012 16:28:29 -0800 Subject: M2crypto In-Reply-To: References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > zigi wrote: > >> Hello, >> M2crypto >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', >> salt='12345678', i=1, padding=1) >> >> I wont write app, using M2crypto and I can not understand what are the >> arguments: >> key, iv, op, salt ? >> What they do ? > > I assume you're reading in > about M2Crypto.EVP.Cipher. > > Epydoc claims another victim. > > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > pages are kind of thin, too. ?You might see some useful code in the EVP unit > tests m2crypto/tests/test_evp.py in the m2crypto installation. Not intending to be rude, but being perfectly serious: as a general rule, if you don't know what an IV is you're probably getting yourself into a lot of trouble working with low-level crypto libraries. Two suggestions: 1. Describe what you're trying to do- I'll be able to help more if I know what you're actually going for. 2. Try keyczar. It's not perfect, but it's a lot easier to get right. Geremy Condra From rosuav at gmail.com Sun Feb 12 19:59:57 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 11:59:57 +1100 Subject: Python usage numbers In-Reply-To: <4F38536A.2030208@davea.name> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F38536A.2030208@davea.name> Message-ID: On Mon, Feb 13, 2012 at 11:03 AM, Dave Angel wrote: > On 02/12/2012 06:29 PM, Steven D'Aprano wrote: >> I think you mean 4 times as many bytes as characters. Unless you have 32 >> bit bytes :) >> >> > Until you have 32 bit bytes, you'll continue to have encodings, even if only > a couple of them. The advantage, though, is that you can always know how many bytes to read for X characters. In ASCII, you allocate 80 bytes of storage and you can store 80 characters. In UTF-8, if you want an 80-character buffer, you can probably get away with allocating 240 characters... but maybe not. In UTF-32, it's easy - just allocate 320 bytes and you know you can store them. Also, you know exactly where the 17th character is; in UTF-8, you have to count. That's a huge advantage for in-memory strings; but is it useful on disk, where (as likely as not) you're actually looking for lines, which you still have to scan for? I'm thinking not, so it makes sense to use a smaller disk image than UTF-32 - less total bytes means less sectors to read/write, which translates fairly directly into performance. ChrisA From roy at panix.com Sun Feb 12 20:11:04 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 20:11:04 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f384b6e$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F38536A.2030208@davea.name> Message-ID: In article , Chris Angelico wrote: > The advantage, though, is that you can always know how many bytes to > read for X characters. In ASCII, you allocate 80 bytes of storage and > you can store 80 characters. In UTF-8, if you want an 80-character > buffer, you can probably get away with allocating 240 characters... > but maybe not. In UTF-32, it's easy - just allocate 320 bytes and you > know you can store them. Also, you know exactly where the 17th > character is; in UTF-8, you have to count. That's a huge advantage for > in-memory strings; but is it useful on disk, where (as likely as not) > you're actually looking for lines, which you still have to scan for? > I'm thinking not, so it makes sense to use a smaller disk image than > UTF-32 - less total bytes means less sectors to read/write, which > translates fairly directly into performance. You might just write files compressed. My guess is that a typical gzipped UTF-32 text file will be smaller than the same data stored as uncompressed UTF-8. From rustompmody at gmail.com Sun Feb 12 22:09:32 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 12 Feb 2012 19:09:32 -0800 (PST) Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 12, 10:36?pm, Nick Dokos wrote: > rusi wrote: > > On Feb 12, 10:51?am, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: > > > On Sun, 12 Feb 2012 15:38:37 +1100, Chris Angelico wrote: > > > > Everything that displays text to a human needs to translate bytes into > > > > glyphs, and the usual way to do this conceptually is to go via > > > > characters. Pretending that it's all the same thing really means > > > > pretending that one byte represents one character and that each > > > > character is depicted by one glyph. And that's doomed to failure, unless > > > > everyone speaks English with no foreign symbols - so, no mathematical > > > > notations. > > > > Pardon me, but you can't even write *English* in ASCII. > > > > You can't say that it cost you ?10 to courier your r?sum? to the head > > > office of Encyclop?dia Britanica to apply for the position of Staff > > > Co?rdinator. (Admittedly, the umlaut on the second "o" looks a bit stuffy > > > and old-fashioned, but it is traditional English.) > > > > Hell, you can't even write in *American*: you can't say that the recipe > > > for the 20? WobblyBurger? is ? 2012 WobblyBurgerWorld Inc. > > > [Quite OT but...] How do you type all this? > > [Note: I grew up on APL so unlike Rick I am genuinely asking :-) ] > > [Emacs speficic] > > Many different ways of course, but in emacs, you can select e.g. the TeX input method > with C-x RET C-\ TeX RET. > which does all of the above symbols with the exception of the cent > symbol (or maybe I missed it) - you type the thing in the first column and you > get the thing in the second column > > \pounds ? > \'e ? ? ? > \ae ? ? ? > \"o ? ? ? > ^{TM} ? ? > \copyright ? > > I gave up on the cent symbol and used ucs-insert (C-x 8 RET) which allows you to type > a name, in this case CENT SIGN to get ?. > > Nick [OT warning] I asked this on the emacs list: No response there and the responses here are more helpful so asking here. My question there was emacs-specific. If there is some other app, thats fine. I have some bunch of sanskrit (devanagari) to type. It would be easiest for me if I could have the English (roman) as well as the sanskrit (devanagari). For example using the devanagari-itrans input method I can write the gayatri mantra using OM bhUrbhuvaH suvaH tatsaviturvarenyam bhargo devasya dhImahi dhiyo yonaH prachodayAt and emacs produces *on the fly* (ie I cant see/edit the above) ? ???????? ???? ?????????????????? ????? ?????? ????? ???? ???? ?????????? Can I do it in batch mode? ie write the first in a file and run some command on it to produce the second? From tjreedy at udel.edu Sun Feb 12 22:09:50 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 12 Feb 2012 22:09:50 -0500 Subject: Python usage numbers In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/12/2012 5:14 PM, Chris Angelico wrote: > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: >> The situation before ascii is like where we ended up *before* unicode. >> Unicode aims to replace all those byte encoding and character sets with >> *one* byte encoding for *one* character set, which will be a great >> simplification. It is the idea of ascii applied on a global rather that >> local basis. > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, The Unicode Standard specifies 3 UTF storage formats* and 8 UTF byte-oriented transmission formats. UTF-8 is the most common of all encodings for web pages. (And ascii pages are utf-8 also.) It is the only one of the 8 most of us need to much bother with. Look here for the list http://www.unicode.org/glossary/#U and for details look in various places in http://www.unicode.org/versions/Unicode6.1.0/ch03.pdf > but so are UTF-16, UTF-32. > and as many more as you could hope for. All the non-UTF 'as many more as you could hope for' encodings are not part of Unicode. * The new internal unicode scheme for 3.3 is pretty much a mixture of the 3 storage formats (I am of course, skipping some details) by using the widest one needed for each string. The advantage is avoiding problems with each of the three. The disadvantage is greater internal complexity, but that should be hidden from users. They will not need to care about the internals. They will be able to forget about 'narrow' versus 'wide' builds and the possible requirement to code differently for each. There will only be one scheme that works the same on all platforms. Most apps should require less space and about the same time. -- Terry Jan Reedy From sturlamolden at yahoo.no Sun Feb 12 22:21:40 2012 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 12 Feb 2012 19:21:40 -0800 (PST) Subject: Python vs. C++11 Message-ID: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> There are bigsimilarities between Python and the new C++ standard. Now we can actually use our experience as Python programmers to write fantastic C++ :-) Here is a small list of similarities to consider: Iterate over any container, like Python's for loop: for (type& item: container) Pointer type with reference counting: std::shared_ptr Python-like datatypes: tuple std::tuple list std::vector std::list std::stack dict std::unordered_map set std::unordered_set complex std::complex deque std::deque lambda [name](params){body} heapq std::heap weakref weak_ptr str std::string -- unicode, raw strings, etc work as Python Other things of interest: std::regex, std::cmatch std::thread thread api versy similar to Python's std::atomic datatype for atomic operations std::mt19937 same prng as Python From sturlamolden at yahoo.no Sun Feb 12 22:28:57 2012 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 12 Feb 2012 19:28:57 -0800 (PST) Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> Message-ID: <81c14eeb-029b-478e-9f50-f7fe5bca04ab@18g2000yqe.googlegroups.com> On Feb 13, 4:21?am, sturlamolden wrote: > There are bigsimilarities between Python and the new C++ standard. Now > we can actually use our experience as Python programmers to write > fantastic C++ :-) And of course the keyword 'auto', which means automatic type interence. From roy at panix.com Sun Feb 12 22:57:01 2012 From: roy at panix.com (Roy Smith) Date: Sun, 12 Feb 2012 22:57:01 -0500 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Terry Reedy wrote: > On 2/12/2012 5:14 PM, Chris Angelico wrote: > > On Mon, Feb 13, 2012 at 9:07 AM, Terry Reedy wrote: > >> The situation before ascii is like where we ended up *before* unicode. > >> Unicode aims to replace all those byte encoding and character sets with > >> *one* byte encoding for *one* character set, which will be a great > >> simplification. It is the idea of ascii applied on a global rather that > >> local basis. > > > > Unicode doesn't deal with byte encodings; UTF-8 is an encoding, > > The Unicode Standard specifies 3 UTF storage formats* and 8 UTF > byte-oriented transmission formats. UTF-8 is the most common of all > encodings for web pages. (And ascii pages are utf-8 also.) It is the > only one of the 8 most of us need to much bother with. Look here for the > list > http://www.unicode.org/glossary/#U > and for details look in various places in > http://www.unicode.org/versions/Unicode6.1.0/ch03.pdf > > > but so are UTF-16, UTF-32. > > and as many more as you could hope for. > > All the non-UTF 'as many more as you could hope for' encodings are not > part of Unicode. > > * The new internal unicode scheme for 3.3 is pretty much a mixture of > the 3 storage formats (I am of course, skipping some details) by using > the widest one needed for each string. The advantage is avoiding > problems with each of the three. The disadvantage is greater internal > complexity, but that should be hidden from users. They will not need to > care about the internals. They will be able to forget about 'narrow' > versus 'wide' builds and the possible requirement to code differently > for each. There will only be one scheme that works the same on all > platforms. Most apps should require less space and about the same time. All that is just fine, but what the heck are we going to do about ascii art, that's what I want to know. Python just won't be the same in UTF-8. /^\/^\ _|__| O| \/ /~ \_/ \ \____|__________/ \ \_______ \ `\ \ \ | | \ / / \ / / \\ / / \ \ / / \ \ / / _----_ \ \ / / _-~ ~-_ | | ( ( _-~ _--_ ~-_ _/ | \ ~-____-~ _-~ ~-_ ~-_-~ / ~-_ _-~ ~-_ _-~ - jurcy - ~--______-~ ~-___-~ From anh.hai.trinh at gmail.com Sun Feb 12 22:57:41 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 19:57:41 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> Message-ID: <3727311.760.1329105461373.JavaMail.geo-discussion-forums@pbcmg9> On Monday, February 13, 2012 3:13:17 AM UTC+7, Vinay Sajip wrote: > On Feb 12, 3:35?pm, Anh Hai Trinh wrote: > > > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. > > > > I have looked at pbs and clom: they Pythonify calls to external > programs by making spawning those look like function calls. There's > nothing wrong with that, it's just a matter of taste. I find that e.g. > > wc(ls("/etc", "-1"), "-l") > > is not as readable as > > call(?ls /etc ?1 | wc ?l?) I don't disagree with it. But the solution is really easy, just call 'sh' and pass it a string! >>> from extproc import sh >>> n = int(sh(?ls /etc ?1 | wc ?l?)) No parser needed written! Yes there is a danger of argument parsing and globs and all that. But people are aware of it. With string parsing, ambiguity is always there. Even when you have a BNF grammar, people easily make mistakes. From rantingrickjohnson at gmail.com Sun Feb 12 23:08:24 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:08:24 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> Message-ID: <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> On Feb 12, 9:35?am, Anh Hai Trinh wrote: > > It's not hard for the user > > I think most users like to use Python, or they'd use Bash. I think people prefer not another language that is different from both, and having little benefits. My own opinion of course. Objection! Does the defense REALLY expect this court to believe that he can testify as to how MOST members of the Python community would or would not favor bash over Python? And IF they do in fact prefer bash, is this display of haughty arrogance nothing more than a hastily stuffed straw-man presented to protect his own ego? > > ?BTW extproc is nice, but I wanted to push the envelope a little :-) > > Hmm, if the extra "envelop" is the async code with threads that may deadlock, I would say "thanks but no thanks" :p And why do you need to voice such strong opinions of disdain in an announcement thread? Testing the integrity of a module (or module) author is fine so long as we are respectful whilst doing so. However, i must take exception with your crass attitude. From ben+python at benfinney.id.au Sun Feb 12 23:19:13 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 13 Feb 2012 15:19:13 +1100 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87ty2v1i2m.fsf@benfinney.id.au> Roy Smith writes: > All that is just fine, but what the heck are we going to do about ascii > art, that's what I want to know. Python just won't be the same in > UTF-8. If it helps, ASCII art *is* UTF-8 art. So it will be the same in UTF-8. Or maybe you already knew that, and your sarcasm was lost with the high bit. -- \ ?We are all agreed that your theory is crazy. The question that | `\ divides us is whether it is crazy enough to have a chance of | _o__) being correct.? ?Niels Bohr (to Wolfgang Pauli), 1958 | Ben Finney From rantingrickjohnson at gmail.com Sun Feb 12 23:26:02 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:26:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> Message-ID: <33357dbf-8eef-434c-a872-7c3366c8d071@b23g2000yqn.googlegroups.com> On Feb 12, 2:13?pm, Vinay Sajip wrote: > wc(ls("/etc", "-1"), "-l") > > is not as readable as > > call(?ls /etc ?1 | wc ?l?) And i agree! I remember a case where i was forced to use an idiotic API for creating inputbox dialogs. Something like this: prompts = ['Height', 'Width', 'Color'] values = [10, 20, Null] options = [Null, Null, "Red|White|Blue"] dlg(prompts, values, options) ...and as you can see this is truly asinine! Later, someone "slightly more intelligent" wrapped this interface up like this: dlg = Ipb("Title") dlg.add("Height") dlg.add("Width", 39) dlg.add("Color", ["Red", "White", "Blue"]) dl.show() ...and whilst i prefer this interface over the original, i new we could make it better; because we had the technology! dlg = Ipb( "Title", "Height=10", "Width=20", "Color=Red|Green|Blue", ) Ahh... refreshing as a cold brew! From rantingrickjohnson at gmail.com Sun Feb 12 23:48:54 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 12 Feb 2012 20:48:54 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> On Feb 12, 12:10?am, Steven D'Aprano wrote: > On Sat, 11 Feb 2012 18:36:52 -0800, Rick Johnson wrote: > >> "I have a file containing text. I can open it in an editor and see it's > >> nearly all ASCII text, except for a few weird and bizarre characters > >> like ? ? ? or ?. In Python 2, I can read that file fine. In Python 3 I > >> get an error. What should I do that requires no thought?" > > >> Obvious answers: > > > the most obvious answer would be to read the file WITHOUT worrying about > > asinine encoding. > > Your mad leet reading comprehension skillz leave me in awe Rick. Same goes for your abstract reasoning skillz! You're attempting to treat the problem, whilst ignoring the elephant in the room -- THE DISEASE!. Do you think that cost of healthcare is the problem? Do you think the cost of healthcare insurance is the problem? NO! The problem is people expect entitlements. If you can't afford healthcare, then you die. If you can't afford food, then you starve. If you can't afford prophylactics, then you will be sentenced to eighteen years of hell! Maybe a charity will help you, or maybe a friend, or maybe a neighbor. If not, then you suffer the fatal exception. Life sucks, deal with it! You want to solve the healthcare problem then STOP TREATING PEOPLE WHO DON'T HAVE INSURANCE! Problem solved! You are only born with one guarantee; you will die, guaranteed! Any questions? The problem with bytes is not encodings or OS's. Can you guess what the REAL problem is? ..take all the time you need. From rosuav at gmail.com Mon Feb 13 00:03:45 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 13 Feb 2012 16:03:45 +1100 Subject: Python usage numbers In-Reply-To: <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 3:48 PM, Rick Johnson wrote: > The problem with bytes is not encodings or OS's. Can you guess what > the REAL problem is? ..take all the time you need. The REAL problem is trolls. But they're such fun, and so cute when they get ranting... ChrisA From dllizheng at gmail.com Mon Feb 13 01:59:27 2012 From: dllizheng at gmail.com (Zheng Li) Date: Mon, 13 Feb 2012 15:59:27 +0900 Subject: how to tell a method is classmethod or static method or instance method Message-ID: how to tell a method is class method or static method or instance method? From anh.hai.trinh at gmail.com Mon Feb 13 02:08:23 2012 From: anh.hai.trinh at gmail.com (Anh Hai Trinh) Date: Sun, 12 Feb 2012 23:08:23 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> Message-ID: <29663741.635.1329116903835.JavaMail.geo-discussion-forums@pbbr5> > Objection! Does the defense REALLY expect this court to believe that > he can testify as to how MOST members of the Python community would or > would not favor bash over Python? And IF they do in fact prefer bash, > is this display of haughty arrogance nothing more than a hastily > stuffed straw-man presented to protect his own ego? Double objection! Relevance. The point is that the OP created another language that is neither Python nor Bash. > And why do you need to voice such strong opinions of disdain in an > announcement thread? Testing the integrity of a module (or module) > author is fine so long as we are respectful whilst doing so. However, > i must take exception with your crass attitude. My respectful opinion is that the OP's approach is fundamentally flawed. There are many platform-specific issues when forking and threading are fused. My benign intent was to warn others about unsolved problems and scratching-your-head situations. Obviously, the OP can always choose to continue his direction at his own discretion. From cs at zip.com.au Mon Feb 13 02:23:39 2012 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 13 Feb 2012 18:23:39 +1100 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: References: Message-ID: <20120213072339.GA9132@cskk.homeip.net> On 13Feb2012 15:59, Zheng Li wrote: | how to tell a method is class method or static method or instance method? Maybe a better question is: under what circumstances do you need to figure this out? I'm actually quite serious here. Please outline what circumstances cause you to want to ask and answer this question. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Reason #173 to fear technology: o o o o o o ^|\ ^|^ v|^ v|v |/v |X| \| | /\ >\ /< >\ /< >\ /< >\ o> o o o o o o o \ x <\> <)> |\ /< >\ /< >\ /< >\ >> L Mr. email does the Macarena. From steve+comp.lang.python at pearwood.info Mon Feb 13 03:03:24 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 08:03:24 GMT Subject: how to tell a method is classmethod or static method or instance method References: Message-ID: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > how to tell a method is class method or static method or instance > method? That's a good question, with a subtle answer that depends on exactly what you mean by the question. If you mean the object you get back from ordinary attribute access like "instance.method", then you do this: >>> class K(object): ... @classmethod ... def cmethod(cls): ... pass ... @staticmethod ... def smethod(): ... pass ... def method(self): ... pass ... >>> k = K() >>> type(k.smethod) So static methods are just functions, and both class methods and instance methods share the same underlying type: >>> type(k.method) >>> type(k.cmethod) But if you dig deeper, you learn that all methods are actually descriptors: >>> type(K.__dict__['cmethod']) >>> type(K.__dict__['smethod']) >>> type(K.__dict__['method']) (Functions are descriptors too.) This is deep magic in Python, but if you want to learn more about it, you can read this: http://users.rcn.com/python/download/Descriptor.htm And I'll take this opportunity to plug my dualmethod descriptor: http://code.activestate.com/recipes/577030-dualmethod-descriptor/ -- Steven From steve+comp.lang.python at pearwood.info Mon Feb 13 03:05:33 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 08:05:33 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> Message-ID: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> On Sun, 12 Feb 2012 20:48:54 -0800, Rick Johnson wrote: > Do you think that cost of healthcare is the problem? Do you think the > cost of healthcare insurance is the problem? NO! The problem is people > expect entitlements. Entitlements? I work hard and pay my taxes. I *earned* that healthcare that trolls like you call an entitlement. Damn straight it's an entitlement -- I paid for it, I earned it, I'm entitled to it, and if you try to steal if from me, expect a fight. Socialised healthcare is a win-win system: - the working class wins, because they get healthcare at a much cheaper rate than they could otherwise afford - bosses win, because they have reduced absenteeism, lower training costs to replace workers who die, and fewer epidemics that threaten their own families - Wall Street wins, because productivity is increased due to better health - pharmaceutical companies win, because even though their profits on individual items are reduced, their increased sales more than make up for it - doctors win, because they spend more time getting paid to deal with patients and less unproductive time on dealing with insurance companies - the economy wins, because fewer people are bankrupted by simple medical procedures The only loss is for the insurers, who have to get an honest job. So why on earth is anyone against socialised healthcare when it provably works better than the US system? Simple. To a certain mind, "win-win" is not a good thing, it is a bad thing. "Win-win" implies that you might have to share the pie instead of eating it all yourself, and to that sort of person, anything less than ALL the pie might as well be nothing at all. What's the point of being wealthy and powerful without having hungry, sick peons to lord over? How will you know you have won unless others lose? The inefficiencies (economic and moral) of the US private healthcare system are not a bug, they are a feature. It is part of the war the 1% of the 1% have been waging on the rest of society for the last 40 years. > You are only born with one > guarantee; you will die, guaranteed! Any questions? Yes. Why haven't you moved to a libertarian paradise like Somalia yet? You'd like it there. There are two sorts of people: those who can afford their own private militia, and victims. -- Steven From cezar4846 at gmail.com Mon Feb 13 03:37:13 2012 From: cezar4846 at gmail.com (zigi) Date: Mon, 13 Feb 2012 00:37:13 -0800 (PST) Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> Message-ID: <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Hello, this is must be testing time to crypt files, using just M2crypto :-) I know this is a strange use of the library, but such is the will of the management. On 13 Lut, 01:28, geremy condra wrote: > On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > > zigi wrote: > > >> Hello, > >> M2crypto > > >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > >> salt='12345678', i=1, padding=1) > > >> I wont write app, using M2crypto and I can not understand what are the > >> arguments: > >> key, iv, op, salt ? > >> What they do ? > > > I assume you're reading in > > about M2Crypto.EVP.Cipher. > > > Epydoc claims another victim. > > > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > > pages are kind of thin, too. ?You might see some useful code in the EVP unit > > tests m2crypto/tests/test_evp.py in the m2crypto installation. > > Not intending to be rude, but being perfectly serious: as a general > rule, if you don't know what an IV is you're probably getting yourself > into a lot of trouble working with low-level crypto libraries. > > Two suggestions: > > 1. Describe what you're trying to do- I'll be able to help more if I > know what you're actually going for. > > 2. Try keyczar. It's not perfect, but it's a lot easier to get right. > > Geremy Condra From dihedral88888 at googlemail.com Mon Feb 13 04:01:33 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 13 Feb 2012 01:01:33 -0800 (PST) Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> References: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> Message-ID: <5016707.681.1329123693532.JavaMail.geo-discussion-forums@pbsp9> ? 2012?2?13????UTC+8??4?03?24??Steven D'Aprano??? > On Mon, 13 Feb 2012 15:59:27 +0900, Zheng Li wrote: > > > how to tell a method is class method or static method or instance > > method? > > That's a good question, with a subtle answer that depends on exactly what > you mean by the question. If you mean the object you get back from > ordinary attribute access like "instance.method", then you do this: > > >>> class K(object): > ... @classmethod > ... def cmethod(cls): > ... pass > ... @staticmethod > ... def smethod(): > ... pass > ... def method(self): > ... pass > ... > >>> k = K() > >>> type(k.smethod) > > > So static methods are just functions, and both class methods and instance > methods share the same underlying type: > > >>> type(k.method) > > >>> type(k.cmethod) > > > > But if you dig deeper, you learn that all methods are actually > descriptors: > > >>> type(K.__dict__['cmethod']) > > >>> type(K.__dict__['smethod']) > > >>> type(K.__dict__['method']) > > > (Functions are descriptors too.) > > This is deep magic in Python, but if you want to learn more about it, you > can read this: > > http://users.rcn.com/python/download/Descriptor.htm > > > And I'll take this opportunity to plug my dualmethod descriptor: > > http://code.activestate.com/recipes/577030-dualmethod-descriptor/ > > > > -- > Steven The methods of an object can be well organized to avoid redundant checks of operations desired to be performed on the object. Also an object's methods should be factored to be easy to be maintained and to provide debugging and error information for the programmer to track the operations related to the hardware, the OS, and the sofware design issues. From vinay_sajip at yahoo.co.uk Mon Feb 13 05:34:02 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 13 Feb 2012 02:34:02 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <58b4a0f8-1a8a-4c02-b6f1-f1baf463eb48@h6g2000yqk.googlegroups.com> <3727311.760.1329105461373.JavaMail.geo-discussion-forums@pbcmg9> Message-ID: <2e7131d3-6d30-45ab-a22a-2e54e2112818@m24g2000yqb.googlegroups.com> On Feb 13, 3:57?am, Anh Hai Trinh wrote: > > I don't disagree with it. But the solution is really easy, just call 'sh' and pass it a string! > > >>> from extproc import sh > >>> n = int(sh(?ls /etc ?1 | wc ?l?)) > > No parser needed written! > > Yes there is a danger of argument parsing and globs and all that. But people are aware of it. With string parsing, ambiguity is always there. Even when you have a BNF grammar, people easily make mistakes. You're missing a few points: * The parser is *already* written, so there's no point worrying about saving any effort. * Your solution is to pass shell=True, which as you point out, can lead to shell injection problems. To say "people are aware of it" is glossing over it a bit - how come you don't say that when it comes to locking+forking? ;-) * I'm aiming to offer cross-platform functionality across Windows and Posix. Your approach will require a lower common denominator, since the Windows shell (cmd.exe) is not as flexible as Bash. For example - no "echo foo; echo bar"; no "a && b" or "a || b" - these are not supported by cmd.exe. * Your comment about people making mistakes applies just as much if someone passes a string with a Bash syntax error, to Bash, via your sh() function. After all, Bash contains a parser, too. For instance: >>> from extproc import sh >>> sh('ls >>> abc') /bin/sh: Syntax error: redirection unexpected '' If you're saying there might be bugs in the parser, that's something else - I'll address those as and when they turn up. Regards, Vinay Sajip From vinay_sajip at yahoo.co.uk Mon Feb 13 05:59:01 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 13 Feb 2012 02:59:01 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: <6037825.619.1329060908829.JavaMail.geo-discussion-forums@pbkf5> <69e7ef3a-2ec8-4ebd-a183-2901ccb33eda@f30g2000yqh.googlegroups.com> <29663741.635.1329116903835.JavaMail.geo-discussion-forums@pbbr5> Message-ID: On Feb 13, 7:08?am, Anh Hai Trinh wrote: > > Objection! Does the defense REALLY expect this court to believe that > > he can testify as to how MOST members of the Python community would or > > would not favor bash over Python? And IF they do in fact prefer bash, > > is this display of haughty arrogance nothing more than a hastily > > stuffed straw-man presented to protect his own ego? > > Double objection! Relevance. The point is that the OP created another language that is neither Python nor Bash. > Triple objection! I think Rick's point was only that he didn't think you were expressing the views of "most" people, which sort of came across in your post. To say I've created "another language" is misleading - it's just a subset of Bash syntax, so you can do things like "echo foo; echo bar", use "&&", "||" etc. (I used the Bash man page as my guide when designing the parser.) As an experiment on Windows, in a virtualenv, with GnuWin32 installed on the path: (venv) C:\temp>python ActivePython 2.6.6.17 (ActiveState Software Inc.) based on Python 2.6.6 (r266:84292, Nov 24 2010, 09:16:51) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from extproc import sh >>> sh('echo foo; echo bar') Traceback (most recent call last): File "", line 1, in File "C:\temp\venv\lib\site-packages\extproc.py", line 412, in sh f = Sh(cmd, fd=fd, e=e, cd=cd).capture(1).stdout File "C:\temp\venv\lib\site-packages\extproc.py", line 202, in capture p = subprocess.Popen(self.cmd, cwd=self.cd, env=self.env, stdin=self.fd[0], stdout=self.fd[1], stderr=self.fd[2]) File "C:\Python26\Lib\subprocess.py", line 623, in __init__ errread, errwrite) File "C:\Python26\Lib\subprocess.py", line 833, in _execute_child startupinfo) WindowsError: [Error 3] The system cannot find the path specified >>> from sarge import capture_stdout >>> capture_stdout('echo foo; echo bar').stdout.text u'foo\r\nbar\r\n' >>> That's all from a single interactive session. So as you can see, my use cases are a little different to yours, which in turn makes a different approach reasonable. > My respectful opinion is that the OP's approach is fundamentally flawed. There are many platform-specific issues when forking and threading are fused. My benign intent was to warn others about unsolved problems and scratching-your-head situations. > > Obviously, the OP can always choose to continue his direction at his own discretion. I think you were right to bring up the forking+threading issue, but I have addressed the points you made in this thread - please feel free to respond to the points I made about the Linux Programming Blog article. I've updated the sarge docs to point to that article, and I've added a section on API stability to highlight the fact that the library is in alpha status and that API changes may be needed based on feedback. I'm not being blas? about the issue - it's just that I don't want to be too timid, either. Python does not proscribe using subprocess and threads together, and the issues you mention could easily occur even without the use of sarge. You might say that sarge makes it more likely that the issues will surface - but it'll only do that if you pass "a & b & c & d" to sarge, and not otherwise. The other use of threads by sarge - to read output streams from child processes - is no different from the stdlib usage of threads in subprocess.Popen.communicate(). Possibly Rick was objecting to the tone of your comments, but I generally disregard any tone that seems confrontational when the benefit of the doubt can be given - on the Internet, you can never take for granted, and have to make allowances for, the language style of your interlocutor ... I think you meant well when you responded, and I have taken your posts in that spirit. Regards, Vinay Sajip From mcepl at redhat.com Mon Feb 13 06:20:28 2012 From: mcepl at redhat.com (Matej Cepl) Date: Mon, 13 Feb 2012 12:20:28 +0100 Subject: XSLT to Python script conversion? Message-ID: Hi, I am getting more and more discouraged from using XSLT for a transformation from one XML scheme to another one. Does anybody could share any experience with porting moderately complicated XSLT stylesheet (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) into a Python script using ElementTree's interparse or perhaps xml.sax? Any tools for this? Speed differences (currently I am using xsltproc)? Any thoughts? Thank you, Mat?j From mateusz at loskot.net Mon Feb 13 06:57:41 2012 From: mateusz at loskot.net (mloskot) Date: Mon, 13 Feb 2012 03:57:41 -0800 (PST) Subject: Read-only attribute in module In-Reply-To: References: <1328872312611-4382967.post@n6.nabble.com> Message-ID: <1329134261942-4464760.post@n6.nabble.com> Terry Reedy wrote > > On 2/10/2012 6:11 AM, mloskot wrote: >> The intent of xyz.flag is that it is a value set by the module >> internally. >> xyz is a module wrapping a C library. >> The C library defines concept of a global flag set by the C functions at >> some events, >> so user can check value of this flag. >> I can provide access to it with function: xyz.get_flag() > > If the value of the flag can change during a run, I would do that. > Otherwise, you have to make sure the local copy keeps in sync. Users > might also think that it is a true constant that they could read once. > > I understand that you might be concerned that one person in a > multi-programmer project might decide to rebind xyz.flag and mess up > everyone else. I think the real solution might be an option to freeze an > entire module. > Terry, Thanks for your really helpful notes. Best regards, ----- -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4464760.html Sent from the Python - python-list mailing list archive at Nabble.com. From stefan_ml at behnel.de Mon Feb 13 08:34:08 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 13 Feb 2012 14:34:08 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: Matej Cepl, 13.02.2012 12:20: > I am getting more and more discouraged from using XSLT for a transformation > from one XML scheme to another one. Could you explain what it is that discourages you about it? That would allow us to come up with better alternatives for your specific problem. > Does anybody could share any experience > with porting moderately complicated XSLT stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? Any > thoughts? You could try switching to lxml. It would at least allow you to do a part of the processing in Python and only use XSLT when it seems more appropriate and/or easier. Stefan From info at egenix.com Mon Feb 13 08:49:31 2012 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Mon, 13 Feb 2012 14:49:31 +0100 Subject: ANN: eGenix pyOpenSSL Distribution 0.13.0-1.0.0g Message-ID: <4F3914EB.8000306@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com pyOpenSSL Distribution Version 0.13.0-1.0.0g An easy-to-install and easy-to-use distribution of the pyOpenSSL Python interface for OpenSSL - available for Windows, Mac OS X and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.0-1.0.0g-1.html ________________________________________________________________________ INTRODUCTION The eGenix.com pyOpenSSL Distribution includes everything you need to get started with SSL in Python. It comes with an easy-to-use installer that includes the most recent OpenSSL library versions in pre-compiled form, making your application independent of OS provided OpenSSL libraries: http://www.egenix.com/products/python/pyOpenSSL/ pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS- aware network applications as well as certificate management tools: https://launchpad.net/pyopenssl/ OpenSSL is an open-source implementation of the SSL/TLS protocol: http://www.openssl.org/ ________________________________________________________________________ NEWS This new release of the eGenix.com pyOpenSSL Distribution updates the included pyOpenSSL version to 0.13.0 and the included OpenSSL version to 1.0.0g. Main new features in pyOpenSSL sine 0.10.0 ------------------------------------------ * pyOpenSSL 0.11 fixes a few bugs related to error processing; see https://launchpad.net/pyopenssl/+announcement/7128 * pyOpenSSL 0.12 fixes interaction with memoryviews, adds TLS callbacks and x509 extension introspection; see https://launchpad.net/pyopenssl/+announcement/8151 * pyOpenSSL 0.13 adds OpenSSL 1.0 support (which eGenix contributed) and a few new APIs; see https://lists.launchpad.net/pyopenssl-users/msg00008.html Please see Jean-Paul Calderone's above announcements for more details. New features in OpenSSL 1.0.0g since 1.0.0a ------------------------------------------- OpenSSL 1.0.0g fixes several vulnerabilities relative to 1.0.0a: http://openssl.org/news/vulnerabilities.html and includes a number of stability enhancements as well as extra protection against attacks: http://openssl.org/news/changelog.html New features in the eGenix pyOpenSSL Distribution ------------------------------------------------- * Updated the pyOpenSSL license information from LGPL to Apache License 2.0. * Added support for Python 2.7 on all platforms. * Added documentation for automatic download of egg distributions using compatible tools such as easy_install and zc.buildout. As always, we provide binaries that include both pyOpenSSL and the necessary OpenSSL libraries for all supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X PPC, x86 and x64. We've also added egg-file distribution versions of our eGenix.com pyOpenSSL Distribution for Windows, Linux and Mac OS X to the available download options. These make setups using e.g. zc.buildout and other egg-file based installers a lot easier. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/pyOpenSSL/ ________________________________________________________________________ UPGRADING Before installing this version of pyOpenSSL, please make sure that you uninstall any previously installed pyOpenSSL version. Otherwise, you could end up not using the included OpenSSL libs. _______________________________________________________________________ SUPPORT Commercial support for these packages is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. ________________________________________________________________________ MORE INFORMATION For more information about the eGenix pyOpenSSL Distributon, licensing and download instructions, please visit our web-site or write to sales at egenix.com. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Feb 13 2012) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From tkpmep at gmail.com Mon Feb 13 08:55:41 2012 From: tkpmep at gmail.com (Thomas Philips) Date: Mon, 13 Feb 2012 05:55:41 -0800 (PST) Subject: Removing items from a list References: <7c4cc084-7b55-48f9-a3ac-219f33b69d0b@k10g2000yqk.googlegroups.com> Message-ID: <306adc3f-e452-48ed-9be0-2656248f738c@m5g2000yqk.googlegroups.com> I could indeed have addressed this problem with a list comprehension. It escaped me at the time because the larger problem I was trying to solve included removing data from a dictionary: months = sorted(list(dataDict.keys())) #Sort months in ascending order for mth in reversed(months): #Remove months with inadequate data if len(dataDict[mth]) < minItems: months.remove(mth) del dataDict[mth] There's more than one way to solve this problem, and, with the benefit of hindsight, my solution was sloppy, but thanks to the help I received, I was able to get my code working correctly. Cleaning up is the next phase! Thanks, all. From rantingrickjohnson at gmail.com Mon Feb 13 11:01:59 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 08:01:59 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Feb 13, 2:05?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 20:48:54 -0800, Rick Johnson wrote: > > Do you think that cost of healthcare is the problem? Do you think the > > cost of healthcare insurance is the problem? NO! The problem is people > > expect entitlements. > > Entitlements? I work hard and pay my taxes. I *earned* that healthcare > that [gentlemen] like you call an entitlement. Damn straight it's an > entitlement -- I paid for it, I earned it, I'm entitled to it, And just how much healthcare dollars are you entitled to exactly? Can you put your entitlement into some form of monetary value? And how can we ever make a system like this fair? If someone works for 30 years and pays a 30% tax rate and another works for 2 years and pays 15%, then how do we delegate the fair share? The answer is you can't delegate fairness in a system like this. The system of "i pay taxes therfore i deserve a free heart transplant" is broken! And don't forget, your tax dollars are not just for coving the cost of healthcare. What about infrastructure, social security, welfare, military, government bail-outs, bribe money to rouge states, earmarks, bridges to nowhere, and and even planting trees on the main highways? These things cost money you know! How about instead of enriching the government by increasing taxes YOU just live within your means? If you can afford healthcare, great! If not, too bad. > and if you > try to steal if from me, expect a fight. Steal what from you... you're stealing from everyone else! You're expecting ME to cover YOUR healthcare. What's next? I should supplement your income so you can you buy a summer home? What about folks who gorge on sugar, saturated fats, and salt all their lives with no regard for their own health? What happens when they develop diabetes, heart disease, and cancer? Do you think the measly little amount of taxes they payed (IF THEY PAYED AT ALL!) will cover a heart transplant or cancer treatments? Who will pay when they cannot? What about the idiots who smoke cigarettes, drink alcohol, and/or abuse drugs (prescription or otherwise). Should your tax dollars cover these medical expenses? Who will pay when they cannot? What about people who are too lazy to cook their children healthy meals and instead rely on fast food and soda? What happens when those same kids become morbidly obese? Why are we not charging these idiots with child abuse? Who will pay when they cannot? *Selfish Sam blubbers:* "I pay taxes, so the government needs to subsidize my unhealthy lifestyle!" But where does the "government money" come from Sam? Sam: Taxes? Very good Sam, and WHO pays taxes? Sam: Citizens? You're very smart Sam. And what do think will happen when the government needs more money? Sam: They will increase taxes? Good boy Sam! Here is a treat. Now run along and fetch the newspaper. Taxes are tranny. And you WANT to give them an excuse to increase taxes! We are doomed! > Socialised healthcare is a win-win system: Sure, for the degenerates! > - the working class wins, because they get healthcare at a much cheaper > rate than they could otherwise afford Healthcare is expensive. Do you want a minimum wage doctor curing your ills? And the frivolous lawsuits are not bringing the costs down either. > - bosses win, because they have reduced absenteeism, lower training costs > to replace workers who die, and fewer epidemics that threaten their own > families BS! With free healthcare, those who would have allowed their immune system fight off the flu, now take off from work, visit a local clinic, and get pumped full of antibiotics so they can create a new strain of antibiotic resistant flu virus! Thanks free healthcare! > - Wall Street wins, because productivity is increased due to better health Oh yes, and wall street is the hope of the future. Thank god they are winning. Thank god they are healthy enough to rob us for another day. Thank god! > - pharmaceutical companies win, because even though their profits on > individual items are reduced, their increased sales more than make up for > it This is the same thing that happened to the funiture industry. They call it the "Assembly Line". I don't know how you feel, but i think mass produced furniture sucks a big fat Python! > - doctors win, because they spend more time getting paid to deal with > patients and less unproductive time on dealing with insurance companies Doctors have minions for those tasks. Do you actually believe doctors are on the phone with insurance companies? They are at the freaking golf course! > - the economy wins, because fewer people are bankrupted by simple medical > procedures It sucks that medical can be so expensive, and i am all for reducing the costs. However, we cannot implement a system that rewards the slothful degenerates of society on the backs of the hard working. Evolution knows how to handle degenerates. > The only loss is for the insurers, who have to get an honest job. So why > on earth is anyone against socialised healthcare when it provably works > better than the US system? If you look around the world, you will see that socialized heathcare has been around for a long time. Let me know when it "solves the healthcare problem"... psst, i won't be holding my breath! > Simple. To a certain mind, "win-win" is not a good thing, it is a bad > thing. "Win-win" implies that you might have to share the pie instead of > eating it all yourself, and to that sort of person, anything less than > ALL the pie might as well be nothing at all. That's the chant of the folks who have no capacity to think for themselves. It's also used by the "controllers" to incite the foolish masses through emotional rhetoric. The fact is, socialized medicine is SOMEONE ELSE paying for YOUR healthcare. Socialized medicine is YOU leaching off the backs of others. Here's a novel idea, subsidize your own damn healthcare! You are born with rights. Life, Liberty, and the pursuit of happiness. Healthcare care is NOT a right, healthcare is a privileged. Driving a car is not a right, it is a privileged. Procreation should be a privilege, however sadly for our collective evolution, it's seems to be a right :( > The inefficiencies (economic and moral) of the US private healthcare > system are not a bug, they are a feature. It is part of the war the 1% of > the 1% have been waging on the rest of society for the last 40 years. What is the goal of the war? Do you really think the one percent want to destroy the working class? If they did manage to destroy us, then who would clean their house, take out there garbage, work in the factories and sweat shops, shine their shoes, wash their cars, wipe their @$$? Who would create that next new cool IPhone app? Look, i hate super rich, arrogant people just as much i hate selfish people. I think you need to take a step back from your emotional temper tantrum and smell the $hit your shoveling! It is my god given right to live free of tyranny, not be enslaved by taxes so i can subsidize you lifespan. Not so you can live to be 104 whilst trying to suck every last breath out of an oxygen canister. No, you live and die by your own choices and the cards that were dealt to you. Leave me the freak out of your selfish card game! From steve+comp.lang.python at pearwood.info Mon Feb 13 11:12:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Feb 2012 16:12:23 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4f393666$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > Evolution knows how to handle degenerates. And yet here you still are. -- Steven From rantingrickjohnson at gmail.com Mon Feb 13 11:27:00 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 08:27:00 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <4f393666$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <07200b63-08a7-4ed4-ac77-0b0f04ee2186@i18g2000yqf.googlegroups.com> On Feb 13, 10:12?am, Steven D'Aprano wrote: > On Mon, 13 Feb 2012 08:01:59 -0800, Rick Johnson wrote: > > Evolution knows how to handle degenerates. > > And yet here you still are. Embrace the perfection of evolution, and both our needs shall be met! From mcfletch at vrplumber.com Mon Feb 13 11:28:49 2012 From: mcfletch at vrplumber.com (Mike C. Fletcher) Date: Mon, 13 Feb 2012 11:28:49 -0500 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: <4F393A41.6030901@vrplumber.com> On 12-02-13 06:20 AM, Matej Cepl wrote: > Hi, > > I am getting more and more discouraged from using XSLT for a > transformation from one XML scheme to another one. Does anybody could > share any experience with porting moderately complicated XSLT > stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? > Any thoughts? > > Thank you, > > Mat?j I wound up rewriting the Docbook to XSL transformation for PyOpenGL's docs in Python using lxml.etree and Kid (now reworked to use Genshi). However, that was a fairly direct translation, it has only a handful of strategies for transforming nodes from docbook to xhtml. That said, it took our processing time down from so-long-I-just-didn't-want-to-work-on-the-docs down to regenerate-whenever-I-make-a-trivial-change. http://bazaar.launchpad.net/~mcfletch/pyopengl/directdocs/files Is the repository where the project lives. It *also* does a lot of other processing, but the generate.py, model.py and templates/section.kid files are all you need to look at to understand the docbook processing. HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com From tim.wintle at teamrubber.com Mon Feb 13 11:41:34 2012 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Mon, 13 Feb 2012 16:41:34 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <1329151294.15792.64.camel@tim-laptop> (Sorry for top-posting this bit, but I think it's required before the rest of my response) At the risk of wading into this from a UK citizen's perspective: You're imagining a public healthcare system as if it were private. Imagine you go to a doctor and say "I've got the flu, can you give me antibiotics". In a Private healthcare system: * The doctor gets paid for retaining a client. * He is incentivised to do what you request. ... so he gives you the antibiotics. In a Public healthcare system: * The doctor is paid no matter what. * His job is to stop the population becoming ill. * By reducing illnesses he reduces his workload, without reducing his wage ... so he'll only give you antibiotics if he feels you are at serious risk, and giving you antibiotics carries less risk for the population than the risk of the population getting immunities. Same goes for surgery etc. On Mon, 2012-02-13 at 08:01 -0800, Rick Johnson wrote: > And just how much healthcare dollars are you entitled to exactly? Can > you put your entitlement into some form of monetary value? > > And how can we ever make a system like this fair? If someone works for > 30 years and pays a 30% tax rate and another works for 2 years and > pays 15%, then how do we delegate the fair share? If your children are educated privately then should you still be paying taxes for education? If you work for/bank with a company that doesn't need to be bailed out, then should you still pay tax for that? If you never need benefits (welfare) then should your taxes be paying for that? you can use that same argument for everything that taxes pay for - the only logical conclusion of that argument is anarchy (i.e. no taxes, and no government). If you are an anarchist then that's a different argument all together (not saying it doesn't have intellectual validity). > Healthcare is expensive. Do you want a minimum wage doctor curing your > ills? And the frivolous lawsuits are not bringing the costs down > either. It's so expensive because of the marketing, and because of all the middle-men. A public health system doesn't need to do that marketing. They also don't need to put up with people who aren't seriously ill - I don't know how long your private appointments are, but here in the UK a standard doctor's appointment is 5-10 minutes. If they decide you're actually ill they may extend that. > > - bosses win, because they have reduced absenteeism, lower training costs > > to replace workers who die, and fewer epidemics that threaten their own > > families > > BS! With free healthcare, those who would have allowed their immune > system fight off the flu, now take off from work, visit a local > clinic, and get pumped full of antibiotics so they can create a new > strain of antibiotic resistant flu virus! Thanks free healthcare! See my comments at the top. From miki.tebeka at gmail.com Mon Feb 13 12:18:16 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:18:16 -0800 (PST) Subject: package extension problem In-Reply-To: References: Message-ID: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> > B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. I don't understand this sentence. How does B[some_hash] related to A? I've tried the below and it seems to work. Can you paste some code to help us understand more? -- old.py -- class A: pass -- new.py __ import old class A(old.A): pass -- main.py -- import new a = new.A() a.__class__ # Shows new.A From miki.tebeka at gmail.com Mon Feb 13 12:18:16 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:18:16 -0800 (PST) Subject: package extension problem In-Reply-To: References: Message-ID: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> > B[some_hash] still returns an instance of the old class A, while I want an instance of the new class A. I don't understand this sentence. How does B[some_hash] related to A? I've tried the below and it seems to work. Can you paste some code to help us understand more? -- old.py -- class A: pass -- new.py __ import old class A(old.A): pass -- main.py -- import new a = new.A() a.__class__ # Shows new.A From f.pollastri at inrim.it Mon Feb 13 12:53:27 2012 From: f.pollastri at inrim.it (Fabrizio Pollastri) Date: Mon, 13 Feb 2012 18:53:27 +0100 Subject: package extension problem In-Reply-To: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <4F394E17.9090108@inrim.it> Ok. To be more clear, consider the real python package Pandas. This package defines a Series class and a DataFrame class. The DataFrame is a matrix that can have columns of different type. If I write import pandas as pd df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]}) a data frame with two cols named A and B is created. If I write col_A = df['A'] the returned col_A is an instance of Series. Now , let suppose that I want to extend some functionality of pandas by adding new methods to both Series and DataFrame classes. One way to do this is to redefine this classes in a new package (new_pandas) as follow import pandas as pd class Series(pd.Series): ... add new methods ... class DataFrame(pd.DataFrame): ... add new methods ... When I use the new package as a pandas substitute and write import new_pandas as np df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) col_A = df['A'] col_A is an instance of the original pandas and not of the new pandas, losing all the added functionality. Fabrizio Now, how can I add new methods to extend the functionality of pandas classes Series and DataFrame From miki.tebeka at gmail.com Mon Feb 13 12:58:02 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:58:02 -0800 (PST) Subject: package extension problem In-Reply-To: References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] I'm not familiar with pandas, but my *guess* will be that you'll need to override __getitem__ in the new DataFrame. From miki.tebeka at gmail.com Mon Feb 13 12:58:02 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 13 Feb 2012 09:58:02 -0800 (PST) Subject: package extension problem In-Reply-To: References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> Message-ID: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] I'm not familiar with pandas, but my *guess* will be that you'll need to override __getitem__ in the new DataFrame. From malaclypse2 at gmail.com Mon Feb 13 13:00:52 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Mon, 13 Feb 2012 13:00:52 -0500 Subject: package extension problem In-Reply-To: <4F3808EC.1000301@inrim.it> References: <4F3808EC.1000301@inrim.it> Message-ID: On Sun, Feb 12, 2012 at 1:46 PM, Fabrizio Pollastri wrote: > Hello, > > I wish to extend the functionality of an existing python package by > creating > a new package that redefines the relevant classes of the old package. Each > new class inherits the equivalent old class and adds new methods. > ... There is a way to solve this problem without redefining in the new package > all the > methods of the old package that return old classes? > The general answer is no. If you want the methods of your subclass to behave differently, in any way, from the same methods in the superclass, then you must write new code that defines the behavior that you want. Sometimes people write their classes so they automatically play nicely when subclassed, and sometimes they don't. In general, it's impossible to always do the right thing when you don't know what particular behavior a subclass might need to override, so a lot of times people don't bother to write their classes to check for subclasses being passed in, etc. Since you haven't actually shown us any code, that's about all I can tell you. -- Jerry -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Mon Feb 13 13:26:26 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Mon, 13 Feb 2012 12:26:26 -0600 Subject: Python usage numbers In-Reply-To: <87ty2v1i2m.fsf@benfinney.id.au> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <87ty2v1i2m.fsf@benfinney.id.au> Message-ID: <4F3955D2.90809@gmail.com> On 2/12/2012 10:19 PM, Ben Finney wrote: > If it helps, ASCII art *is* UTF-8 art. So it will be the same in UTF-8. As will non-ASCII text art: ? ?l? ????? ? ? ?l?? ~? ? ??f_, )? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From __peter__ at web.de Mon Feb 13 13:28:05 2012 From: __peter__ at web.de (Peter Otten) Date: Mon, 13 Feb 2012 19:28:05 +0100 Subject: package extension problem References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <4F394E17.9090108@inrim.it> Message-ID: Fabrizio Pollastri wrote: > Ok. To be more clear, consider the real python package Pandas. > > This package defines a Series class and a DataFrame class. > The DataFrame is a matrix that can have columns of > different type. > > If I write > > import pandas as pd > df = pd.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > > a data frame with two cols named A and B is created. > > If I write > > col_A = df['A'] > > the returned col_A is an instance of Series. > > Now , let suppose that I want to extend some functionality of pandas > by adding new methods to both Series and DataFrame classes. > > One way to do this is to redefine this classes in a new package > (new_pandas) as follow > > import pandas as pd > > class Series(pd.Series): > ... > add new methods > ... > > class DataFrame(pd.DataFrame): > ... > add new methods > ... > > When I use the new package as a pandas substitute and write > > import new_pandas as np > df = np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) > col_A = df['A'] > > col_A is an instance of the original pandas and not of the new pandas, > losing all the added functionality. A quick look into the pandas source reveals that the following might work: # untested class DataFrame(pd.DataFrame): @property def _constructor(self): return DataFrame # your class # your new methods From ian.g.kelly at gmail.com Mon Feb 13 13:38:46 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Feb 2012 11:38:46 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: I hate being suckered in by trolls, but this paragraph demands a response. On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson wrote: > You are born with rights. Life, Liberty, and the pursuit of happiness. > Healthcare care is NOT a right, healthcare is a privileged. If you deprive a person of access to healthcare, and they die, then you have deprived them of life and thus violated the very rights that you just stated they had. In any case, taking that phrase from the Declaration of Independence and holding it out as an exhaustive list of rights is moronic. First, because it's not even a legal document -- it's only a statement of high-minded classical liberalism, albeit a historically important and influential one. Second, because it actually states "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that **AMONG** these are Life, Liberty and the pursuit of Happiness." The phrasing obviously implies that there are other human rights besides the three examples listed. After all, the purpose of the document was not to enumerate all human rights, but to air a list of grievances against King George and assert the right to revolt against him. Incidentally, "not being required to pay taxes" is not something that the founding fathers would have considered a human right, taxation being necessary to support government and representative government (at least according to the Declaration of Independence) being necessary to secure those rights. > Procreation should be a > privilege, however sadly for our collective evolution, it's seems to > be a right :( There is a word for the philosophy that procreation should be a privilege reserved for those with good genes: eugenics. Welcome to fascism, Rick. From tjreedy at udel.edu Mon Feb 13 14:12:44 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 13 Feb 2012 14:12:44 -0500 Subject: package extension problem In-Reply-To: <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> References: <19027093.1215.1329153496662.JavaMail.geo-discussion-forums@ynel5> <19082837.1211.1329155882652.JavaMail.geo-discussion-forums@ynbt34> Message-ID: On 2/13/2012 12:58 PM, Miki Tebeka wrote: >> import new_pandas as np df = >> np.DataFrame({'A':[1,2,3],'B':[4,5,6]}) col_A = df['A'] > I'm not familiar with pandas, but my *guess* will be that you'll need > to override __getitem__ in the new DataFrame. This is essentially the same problem that if you, for instance, subclass int as myint, you need to override (wrap) *every* method to get them to return myints instead of ints. class myint(int): ... def __add__(self, other): return myint(self+other) .... In the OP's case, if the original class is in python, one might be able to just change the __class__ attribute. But I would make sure to have a good set of tests in any case. -- Terry Jan Reedy From roncythomas at hotmail.com Mon Feb 13 14:15:45 2012 From: roncythomas at hotmail.com (roncy thomas) Date: Mon, 13 Feb 2012 19:15:45 +0000 Subject: No subject Message-ID: I'm doing a miniproject on electronics voting system.I require help for creating a code in python for coverting the barcode into binary digits.Or atleast an algorithm for the same..please Help..Reply to this mail id. Kindly help me. -------------- next part -------------- An HTML attachment was scrubbed... URL: From waylan at gmail.com Mon Feb 13 14:50:01 2012 From: waylan at gmail.com (waylan) Date: Mon, 13 Feb 2012 11:50:01 -0800 (PST) Subject: Strange Behavior on Python 3 Windows Command Line Message-ID: When I try running any Python Script on the command line with Python 3.2 I get this weird behavior. The cursor dances around the command line window and nothing ever happens. Pressing Ctr+C does nothing. When I close the window (mouse click on X in top right corner), an error dialog appears asking me to "force" it to close. See a short (26 sec) video of it here: https://vimeo.com/36491748 Also, the printer suddenly starts printing multiple copies of the contents of the command line window - which has wasted much paper. Strangely it was working fine the other day. Then while debugging a script it suddenly started do this and now does this for every script I've run in Python 3.2. Multiple system reboots had no effect. I also have Python 2.5 & 2.7 installed and they work fine. Even the most basic script results in this behavior: if __name__ == "__main__": print("Hello, World!") In an attempt to check the exact version of Python, even this causes the strange behavior: c:\Python32\python.exe -V I'm on Windows XP if that matters. IDLE (which works fine) tells me I'm on Python 3.2.2 Any suggestions? From ramit.prasad at jpmorgan.com Mon Feb 13 14:58:37 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Mon, 13 Feb 2012 19:58:37 +0000 Subject: Python barcode scanner was RE: In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474149564@SCACMX008.exchad.jpmchase.net> From: roncy thomas Sent: Monday, February 13, 2012 1:16 PM To: python-list at python.org Subject: I'm doing a miniproject on electronics voting system.I require help for creating a code in python for coverting the barcode into binary digits.Or atleast an algorithm for the same..please Help..Reply to this mail id. Kindly help me. ======================================================================= One of these should help: http://stackoverflow.com/questions/4434959/usb-barcode-scanner-research http://zbar.sourceforge.net/ Please include a descriptive subject next time. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From cv33cv33cv33 at gmail.com Mon Feb 13 15:02:59 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Mon, 13 Feb 2012 12:02:59 -0800 (PST) Subject: UNIQUE FEATURES OF ISLAM !!!!!!!!!!!!!! Message-ID: <45fb87bf-046f-4485-9867-438867b59877@ge5g2000vbb.googlegroups.com> UNIQUE FEATURES OF ISLAM Please forgive us for any disturbance, but we have an important subject to address to you regarding FAITH, and we Don?t intend to overload your email with unnecessary messages? Unique Features of Islam Uniqueness of the Name The name for the religion of Islam is much more than just a name because it expresses a deep spiritual meaning as well as an overall outlook on life and concept of worship. The word "Islam" is an Arabic word which means "complete submission to the will of Almighty God". Other religions are named after their founders, such as Christianity and Buddhism; after a tribe or ethnic group, such as Judaism; or after a specific geographical region, such as Hinduism. Islam, however, is unique because its name represents its outlook on life and reflects its universal nature. Additionally, the name "Islam" was not thought up by its followers or applied by other people, as is the case with the names of other religions, but was revealed by Almighty God. This name expressed nothing new, because submission to the will of God, i.e. "Islam", has always been the true religion of God. Due to this fact, and since the teachings of Islam are straightforward, profound and logical, Islam is the "Natural Religion" of all human beings. The name of no other religion carries any significant message, or conveys the true sense of its outlook on life, as does the name "Islam". Universality & Continuity of the Message The command to worship none other than Almighty God and to submit to His will has been revealed by God to all of His prophets throughout mankind?s long history. The pure essence of the beliefs and teachings that were revealed by God to the Prophet Muhammad are the same as God taught to Abraham, who was one of the earliest and greatest prophets. So actually, Muhammad is the final prophet of Islam ? not the first. Additionally, Islam is the true "religion of Abraham", because Abraham completely submitted himself to the revealed will of Almighty God. Islam is truly unique among the religions of the world because it is addressed to all of mankind. The scripture of Islam, called the Qur?an, repeatedly addresses all human beings by saying: "O mankind!" Additionally, in the Qur?an, Almighty God is never addressed as the God of a particular people or nation. From the very beginning of the mission of Prophet Muhammad, his followers came from a wide spectrum of individuals ? there was Bilal, the African slave; Suhaib, the Byzantine Roman; Ibn Sailam, the Jewish Rabbi; and Salman, the Persian. Since religious truth is eternal and unchanging, and mankind is one universal brotherhood, God?s revelations to man have always been consistent and universal. Submission to the will of God, and worshipping Him alone without intermediaries, has always been the only religion acceptable to Almighty God. A Straightforward Concept of God Unique among the religions of the world, the concept of God in Islam is completely based upon Divine Revelation. Not only is the concept of God in Islam characterized by purity and clarity, but it is also not marred by myths, superstitions or man-made philosophical ideas. In the pure and straightforward teachings of Islam, Almighty God has clearly revealed His unique nature and qualities to man in the way which He wants them to be understood. While other religions have either mixed man-made doctrines with divine revelation, or ignored the divine revelation almost completely, Islam?s concept of God is based totally on what God has said about Himself. Islam?s concept of God can be called pure and straightforward because there is a clear distinction made between the Creator and the created. As such, there is no ambiguity in divinity ? it is made clear that there is nothing divine or worthy of being worshipped except for Almighty God. In Islam, calling someone other than Almighty God "Lord" or "Savior" is completely prohibited because such terms compromise God?s uniqueness and because all of our trust should be put in Almighty God ? who is the Most Merciful and the Controller of all affairs. The only Creator ? Almighty God ? is Unique, Eternal and Transcendent above His Creation. Everything else besides Almighty God ? meaning anything that you can see or even imagine ? is part of God?s creation, and thus not worthy of worship. Almighty God, as He has described Himself in the Qur?an, is Absolutely One and "the Most Merciful of those who show mercy". Even though God is transcendent above His creation, due to His infinite Mercy He is constantly involved with the affairs of His creatures. Even though God is infinite, unique and incomprehensible, in the Holy Qur?an He has revealed Himself in a way suitable to the finite and limited human mind. By reaching out to man and sending revelations through all of His prophets, God has allowed Himself to be known through His unique and most-beautiful attributes. Because the concept of God in Islam was sent by God specifically for mankind, it appeals to the innate nature of the human being. Due to this fact, Islam does not ask man to accept irrational, ludicrous or man-made doctrines about God. The Islamic concept of God strikes a unique balance between various religions an because is avoids reducing God to just being some remote and impersonal "First Cause" or "Higher Power", while on the other hand it also teaches that a direct and personal relationship with God can be maintained without believing God to be like His creation or incarnate in it. Direct Relationship with God In other religions, even the ones which claim belief in "One God", people often approach God through an intermediary, such as a saint, an angel, the Virgin Mary or Jesus. However, it is only in Islam that a person is required only to pray to God. Some people also nullify a truly proper and direct relationship with Almighty God by mistakenly believing that they have a special relationship with Him simply because they are members of a certain ethnic group, tribe or "chosen people". Additionally, in Islam there are no priests or clergy ? each worshipper, man or woman, has a direct relationship with their Merciful Creator ? Almighty God. Since God is the Owner and Sustainer of everything, as well as the only one who can provide true and complete forgiveness, it is completely futile to try to approach Him through anyone else. According to the teachings of Islam, praying to or worshipping anything or anyone besides Almighty God is the greatest sin a person can commit. Even though other religions believe in God, they nullify this belief by making the grave mistake of not always approaching Him directly. Some religions even go so far as to say that human beings, due to their sinfulness, cannot approach God without an intermediary ? which mistakenly implies that God is unable or unwilling to forgive human-beings directly. Islam teaches that Almighty God has the power to do all things and that no one should ever despair of His mercy. According to the teachings of Islam, God is always ready to bestow His abundant Grace and Mercy on anyone who turns to Him in repentance. Even people who used to commit the worst sin of worshipping others besides God will be forgiven if they realize what they are doing is wrong and repent. Having a direct relationship with God, and understanding that He alone deserves worship and praise, goes hand-in-hand with the Islamic concept of God. This is because once a proper concept of God is established in the heart and mind, submission to God and complete reliance on Him alone comes naturally. Unique Concept of Worship According to the teachings of Islam, everything that a human being does with the pure intention of pleasing God is an act of worship. Due to this, Islam has an all encompassing concept of worship unlike any other religion. Almighty God has revealed in the Holy Qur?an that His purpose for creating human beings was to worship Him and Him alone. Like other religions, Islam has required acts of worship, however worship in Islam is not limited to rituals. Since Islam is an all- encompassing religion with guidance for all aspects of life. almost every action in a Muslim?s life becomes an act of worship if it is done to build a better relationship with God. Since man?s purpose in life is to worship and submit to God, worship in Islam has been defined by God Himself in an all-encompassing way. This is special uniqueness can also be seen in the fact that most other religions only require formal worship once per week, while Islam requires it five times a day. Even more importantly, all rites of formal worship in Islam are based on Divine revelation, while the modes of worship in other religions are a mixture of Divine revelation, man-made traditions, opinions of clergymen and religious councils. Additionally, in Islam acts of worship such as prayer and fasting have been described by God and His Prophet in such detail that it gives human beings a feeling of assurance that the way they are worshipping God is pleasing to Him. Based on Authentic Sources The preservation of the scripture of Islam ? the Holy Qur?an ? is unique among world religions. No other religion has a scripture which is both as old and as well-preserved as the one possessed by Muslims today. Even scholars who are hostile to Islam admit that the Qur?an that exists today is exactly the same as the one that existed in the time of the Prophet Muhammad. Even though many people mistakenly assume that the Qu?ran was written by Muhammad, it is actually the literal Word of God. Not only was Muhammad known by his people to be unable to read and write, but the Holy Qur?an clearly and repeatedly exclaims that it is from Almighty God ? the Lord of the Universe. Unlike other religions, the followers of Islam have always considered their scripture to be the Word of God in toto. The scriptures of other religions are made up of writings that were not considered to be scripture until many years after they were written ? the letters of (St.) Paul are a good example of this. Additionally, the Holy Qur?an has always been in the possession of the common believer, and as such was circulated very widely. In this way, Muslims know that their scripture is authentic, unlike other so-called "scriptures" which are still claimed to be scripture even though their authors are unknown. The Qur?an also remained pure and authentic because unlike other scriptures, it was written down and memorized in the lifetime of the prophet that it was revealed to. Also, its wide circulation prevented scholars, clergy and religious councils from deciding what should and should not be part of the scripture ? since it was already in the hands of the people in its complete form. It has always amazed people to find out that the entire Qur?an was not only memorized word-for- word by hundreds of the companions of Prophet Muhammad, but that it has been memorized verbatim by thousands upon thousands of people until this very day in its original language of Arabic. It was only natural for Almighty God to preserve the scripture revealed to Prophet Muhammad, because he was the last Prophet and Final Messenger of God. In short, the Qu?ran is a unique scripture that has come down to us in its original form and unique language. Due to its pristine teachings and unquestionable authenticity, the Qur?an removes the need for man to wonder for himself how to worship and please God, since God Himself has clearly described these things. An Eternal Message Islam has just as much meaning and is just as applicable to people living in today?s "modern world" as it did for people living 1400 years ago. Since the message of Islam is eternally true it is also very robust, and as such still has a strong spiritual impact on millions of people living in the world today. The Pure Monotheism of Islam, as well as its universal brotherhood, strong morals and positive outlook on life, is still very relevant and meaningful to modern man. The continued relevance and applicability to both the spiritual and worldly life of human beings from all around the word is just one of the many proofs of the Divine origin of the message of Islam. Unlike the teachings of other religions, the teachings of Islam don?t need to be updated or watered-down in order to appeal to a human being living in today?s troubled world. Since the teachings of Islam are both spiritually true and eternally practical, they can be lived and implemented in the daily life of a person in order to make their life more fulfilling. In short, unique among world religions, Islam has not had to sacrifice its integrity in order to be both applicable to "modern life" and to have enough spiritual impact to change people?s lives. A Complete Way of Life Islam not just a "religion" in the traditional sense, because it is not just confined to acts of worship, morality and other aspects of personal piety. The teachings of Islam, even though they do cover religious rituals and morality, also encompass all other aspects of life. The Prophet Muhammad?s mission encompassed not only spiritual and religious teachings, but also included guidance for such things as social reform, economics, politics, warfare and family life. Thus due to the diversity and success of Muhammad?s mission, Muslims have clear guidance from God and His Final Prophet on all aspects of life. This goes hand-in-hand with the Islamic belief that Almighty God does not leave human beings without guidance in their daily lives ? thus His guidance is all-encompassing. Due to God?s wisdom, and because Islam is the final revealed religion, the guidance that God has sent is applicable for all times and for all places. This can be seen in the fact that the guidance for some aspects of life is much more broad and flexible than others. Additionally, in the Qur?an, Almighty God has revealed to mankind that the purpose of our creation is to worship and remember God in all aspects of our life, and to follow His guidance in everything that we do. Thus Islam does not accept a secular view of government and society, but only one based on the Law of God. Nor does Islam leave it to human beings to decide what is right and wrong, good and bad, moral and immoral based on their whims, desires or man-made idea. In short, Islam does not teach people to "Render unto Caesar the things which are Caesar?s" because, according to Islam, everything belongs to God. Like all of its other teachings, Islam?s view of other religions is balanced, realistic and moderate. Islam doesn?t view other religions as being either completely true nor completely false, but believes that all true religions were at one time divinely revealed. However, over time the teachings of the various religions, due to a variety of reasons, have become distorted and mixed with made- man ideas. But nonetheless, Muslims are required to be tolerant of other revealed religions since the Qur?an clearly says: "Let there be no compulsion in religion". Moderation The teachings of Islam, since they are divinely revealed, are balanced in all of their aspects. Even though Islam is an all-encompassing way of life, it preaches moderation and rejects extremism. On the one hand, Islam does not preach complete rejection of all worldly pleasures in view of the life hereafter; and on the other hand it does not teach that earthly life is just for pleasure and enjoyment. In Islam, wealth and worldly pleasures can be partaken of in this life as long as they are enjoyed in a way that is in obedience to God. However, Muslims are taught to keep in mind that the life hereafter is their ultimate goal, and therefore one should be charitable and not become too attached to worldly things. By maintaining a balance between man?s spiritual and physical needs, the teachings of Islam are best suited for the needs of human beings in particular and society in general. Since Islam is based on clear guidance from God, it rejects all man-made religious excesses, such as certain forms of monasticism where people try to completely "reject the world" and other forms of extreme self-denial. Islam teaches that human beings have responsibilities at all levels ? to other individuals, to their families and to society as a whole. By maintaining a unique balance between the physical and spiritual, and between the individual and society, Islam maintains a balance in all directions. A Positive Outlook Most people will agree that having a strong self-esteem and a positive outlook on life is conducive to achieving happiness and success. Unique among the religions of the world, Islam?s view of both the nature of the human being and the purpose of life are extremely positive. Islam?s view of the nature of the human being is balanced. On the one hand they are not viewed as being inherently evil, but on the other they are not considered to be perfect ? nor are they expected to be so. According to the teachings of Islam, every human being, man or woman, is born with a clean slate and is equally capable of both good and evil. Since God has bestowed limited free-will on human beings, they will ultimately be held responsible for their actions. Believing that "salvation" is based on "faith alone" reduces human life to a near meaningless and fatalistic existence. The teachings of Islam make it clear that human beings, since their nature is basically good, are capable of positive action in this life, and that the best way to achieve a balanced, happy and fulfilled life is complete submission to Almighty God. Certainly, no person can completely submit to God by simply wanting to do so, but by first realizing that none has a right to be worshipped and obeyed except for Almighty God, and then making a reasonable effort to follow God?s commands, all human beings can fulfill their reason for existence ? which is to worship God alone. . The Holy Qur?an tells us that "man was created weak" and thus falls into sin often. On the other hand, man is not to think of himself as so evil and corrupt so as to despair of God?s mercy. As a recourse to this, and since Islam condemns self- righteousness, a pious life can only be lived by trusting in God ? since there is no power or strength except through God. As such, spiritual felicity is achieved by a combination of both faith and action. As such, the most righteous person is not one who thinks that repentance is unnecessary, but the one who admits and realizes his mistakes ? and then repents. According to the word of Almighty God as revealed in the Holy Qur?an, mankind is God?s trustee on earth; and as such the life of this world is a test, not a punishment. Even before God created the first man, He knew that he would sin, however God created man in spite of this. According to the Qur?an, God has bestowed on human beings a great trust and given them dignity. It is only by worshipping Almighty God, directly and without intermediaries, that a human being can fulfull their true innate nature and purpose of existence. In short, Islam is realistic. It portrays human beings just as they are and the life of the world just as it is. Since the outlook of Islam is divinely revealed is not based on wishful or negative thinking, but simply on reality. Islam also has a positive view of mankind in general, since it teaches that the best person in the sight of God is the one who is most God-conscious. In this way the truth of Islam and the universality of God?s message transcends all of the barriers of race, nationality, ethnic group and economic status. ????????????? For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From arnodel at gmail.com Mon Feb 13 15:16:13 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 13 Feb 2012 20:16:13 +0000 Subject: Strange Behavior on Python 3 Windows Command Line In-Reply-To: References: Message-ID: On 13 February 2012 19:50, waylan wrote: > When I try running any Python Script on the command line with Python > 3.2 I get this weird behavior. The cursor dances around the command > line window and nothing ever happens. Pressing Ctr+C does nothing. > When I close the window (mouse click on X in top right corner), an > error dialog appears asking me to "force" it to close. I'm not a Windows user, so I can't be of assistance but it may help others if you explained how you installed Python 3.2 on your computer. Also have you tried reinstalling it? > Strangely it was working fine the other day. Then while debugging a > script it suddenly started do this and now does this for every script How were you debugging? -- Arnaud From waylan at gmail.com Mon Feb 13 15:47:36 2012 From: waylan at gmail.com (Waylan Limberg) Date: Mon, 13 Feb 2012 15:47:36 -0500 Subject: Strange Behavior on Python 3 Windows Command Line In-Reply-To: References: Message-ID: On Mon, Feb 13, 2012 at 3:16 PM, Arnaud Delobelle wrote: >> Strangely it was working fine the other day. Then while debugging a >> script it suddenly started do this and now does this for every script > > How were you debugging? I think I may have been attempting to use pipes to redirect stdin and/or stdout when the problem first presented itself. Unfortunately, once I closed the window, I lost whatever pipe combination I had tried. It just occurred to me that I was unsure if I had been doing that pipe correctly, and that maybe I overwrote python.exe. Sure enough, the modify date on that file indicated I overwrote it. A re-install has resolved the problem. It's just a little embarrassing that I didn't think of that until now, but the fact that everything else seems to work was throwing me off. Of course, everything else was running `pythonw.exe` not `python.exe`. Anyway, thanks for the pointer Arnaud. -- ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg From rosuav at gmail.com Mon Feb 13 15:47:56 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 07:47:56 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 5:38 AM, Ian Kelly wrote: > "... Rights, that > **AMONG** these are Life, Liberty and the pursuit of Happiness." AMONG our rights are such elements as Life, Liberty, the Pursuit of Happiness, and an almost fanatical devotion to the Founding Fathers.... I'll come in again. (Does that drag this back on topic? Almost? Vain attempt to at least look like it's on topic?) ChrisA From ericsnowcurrently at gmail.com Mon Feb 13 15:55:10 2012 From: ericsnowcurrently at gmail.com (Eric Snow) Date: Mon, 13 Feb 2012 13:55:10 -0700 Subject: (Rebooting) Python Usage Statistics Message-ID: The original topic got side-tracked pretty quickly (surprise, surprise). However, I think the question is valuable enough that it's worth broaching again. Notably, the first time around I did get a meaningful response (thanks Stefan!). If you do feel like diverging from the topic of gathering usage statistics, please at least change the subject. I've also started a wiki page: http://wiki.python.org/moin/usage_stats Feel free to add to it. -------------- Does anyone have (or know of) accurate totals and percentages on how Python is used? I'm particularly interested in the following groupings: - new development vs. stable code-bases - categories (web, scripts, "big data", computation, etc.) - "bare metal" vs. on top of some framework - regional usage I'm thinking about this partly because of a discussion on python-ideas about [some U-word related topic ]. All the rhetoric, anecdotal evidence, and use-cases there have little meaning to me, in regards to Python as a whole, without an understanding of who is actually affected. For instance, if frameworks (like django and numpy) could completely hide the arguable challenges of [some feature] in Python 3--and most projects were built on top of frameworks--then general efforts for making [some feature] easier in Python 3 should go toward helping framework writers. Such usage numbers help us know where efforts could be focused in general to make Python more powerful and easier to use where it's already used extensively. They can show us the areas that Python isn't used much, thus exposing a targeted opportunity to change that. Realistically, it's not entirely feasible to compile such information at a comprehensive level, but even generally accurate numbers would be a valuable resource. If the numbers aren't out there, what would some good approaches to discovering them? Thanks! -eric From rantingrickjohnson at gmail.com Mon Feb 13 16:01:05 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 13:01:05 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> On Feb 13, 12:38?pm, Ian Kelly wrote: > I hate being suckered in by trolls, but this paragraph demands a response. > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > wrote: > > You are born with rights. Life, Liberty, and the pursuit of happiness. > > Healthcare care is NOT a right, healthcare is a privileged. > > If you deprive a person of access to healthcare, and they die, then > you have deprived them of life and thus violated the very rights that > you just stated they had. And finally the "pursuit of happiness". Notice the wording here: "pursuit". You have a right to PURSUE happiness, not a right to steal it. Also, you are guaranteed happiness, only the right to purse your version of happiness -- so long as that version does not interfere with others rights. You have a right to life, NOT a right to unnaturally extend your lifetime by stealing the fruits of other people's labor (in this case: money). You have a right to be free, but NOT to quell the freedom of others so that YOU may benefit (in this case: taxation). Healthy people do not need healthcare very often, and in the rare cases when they do, they don't bog down the system because their bodies are strong. Why are their bodies strong? Because healthy people eat correctly, healthy people exercise, therefore, healthy people have correctly functioning immune systems -- of course quality genes always help! > In any case, taking that phrase from the Declaration of Independence > and holding it out as an exhaustive list of rights is moronic. ?First, > because it's not even a legal document -- it's only a statement of > high-minded classical liberalism, albeit a historically important and > influential one. ?Second, because it actually states "We hold these > truths to be self-evident, that all men are created equal, that they > are endowed by their Creator with certain unalienable Rights, that > **AMONG** these are Life, Liberty and the pursuit of Happiness." ?The > phrasing obviously implies that there are other human rights besides > the three examples listed. ?After all, the purpose of the document was > not to enumerate all human rights, but to air a list of grievances > against King George and assert the right to revolt against him. > Incidentally, "not being required to pay taxes" is not something that > the founding fathers would have considered a human right, taxation > being necessary to support government and representative government > (at least according to the Declaration of Independence) being > necessary to secure those rights. I never stated that taxation violated anyone's "human rights". And i personally believe that "some" amount of taxation is a necessary in a democratic society. How else would the government pay the bills? Rule of law, infrastructure, national security (just to name a few) are all subjects that the government must handle for the sake of society as a whole. HOWEVER, healthcare is not a concern of the greater society, but only the individual -- with the exception of contagious disease of course, which effects us all! Cardiovascular diseases, cancers, cirrhosis, kidney failure, stroke, diabetes, etc..., are NOT contagious but continue to be a drain on healthcare costs. In fact, most of these problems are the results of an unhealthy lifestyle. Listen, I have no objection to folks living an unhealthy lifestyle. I say, if that's what makes you happy, GO FOR IT!. However, i'll be damned if i am going to subsidize their healthcare because now they are dying and can't afford the medical bills. Likewise if someone gets hit by a bus... was the person j-walking? If so, too bad. Ride a motorcycle without a helmet and get a concussion, too bad. Drink and drive and then end up in a coma, too bad! You play with fire and you get burned! You kick a bear in the ass and you get eaten. You stick your head in a crocodiles mouth and you suffer the consequences! You are not fit to survive in this universe. You were given fear for a reason. You were given pain for a reason. Those who refuse to learn are culled from the herd. > > Procreation should be a > > privilege, however sadly for our collective evolution, it's seems to > > be a right :( > > There is a word for the philosophy that procreation should be a > privilege reserved for those with good genes: eugenics. No, the word is evolution; which means: "survival of the fittest". Listen, i will be the first to admit that evolution is VERY unfair to those among us who have a poor gene pool. Poor genes are not our fault. We did not get to CHOOSE our genes, or our parents, or our country of origin, or etc, etc, etc! But these ARE the cards we were dealt as individuals of a species. That last sentence is VERY important: "individuals of a species". We like to think that our individual lives matter in the greater scheme of things, but i can assure you we don't matter. Anyone who has studied animal behavior knows that only the strongest males are allowed to mate. Why is this? Because strength can only manifest itself in an individual with quality genes. An indiviual who is healthy. What all the whiners want to do is strengthen the degenerates. You want to circumvent evolution and devolve as a species for nothing more than the sake of your own selfishness. I can however tell you that what DOES matter is the continued improvement of the base gene pool. Yes, this improvement comes at a cost; the cost of the individual. Those with quality genes will reap the rewards, likewise, those with crap genes will not. Evolution does not care about you and how long your miserable little life will last, or if you're going to get that new Apple device for Christmas, or how many shoes are in your closet, or what brand underwear you choose to cradle your loins with! Your measly little 60-100 years of breathing means nothing against the eons of evolution of individuals within species. YOU are pawn of the Human species and nothing more. And the Human species is a pawn of biological lifeforms. When (or if) you finally come to grips with that grim reality you will be ready to transcend this life -- some make the connection early, others make the connection on their deathbeds, others not at all. >?Welcome to fascism, Rick. Don't try to append me onto a specific ideology structure just because that group happens to support ONE of my beliefs. I carry no political or ideological "membership cards" in my pocket. My mind is free of the boundaries that confine most of the Human species. But go on falsely believing your little puny life matters. Go on believing in your worn out traditions and selfish languages and cultures. Go on believing that humans will be inhabiting this rock in the next 1000 years, or this universe in the next 10,000 -- because the enlightened few will have transcended into the mind hive and your @ $$ will be glued to Terra firma forever! From nagle at animats.com Mon Feb 13 16:15:36 2012 From: nagle at animats.com (John Nagle) Date: Mon, 13 Feb 2012 13:15:36 -0800 Subject: frozendict In-Reply-To: <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> References: <4F332007.9080800@wisc.edu> <4f3471e9$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f356898$0$11996$742ec2ed@news.sonic.net> <11277623.419.1328939579823.JavaMail.geo-discussion-forums@pbcql8> Message-ID: <4f397d7a$0$12009$742ec2ed@news.sonic.net> On 2/10/2012 9:52 PM, 88888 Dihedral wrote: > ? 2012?2?11????UTC+8??2?57?34??John Nagle??? >> On 2/10/2012 10:14 AM, Nathan Rice wrote: >>>>> Lets also not forget that knowing an object is immutable lets you do a >>>>> lot of optimizations; it can be inlined, it is safe to convert to a >>>>> contiguous block of memory and stuff in cache, etc. If you know the >>>>> input to a function is guaranteed to be frozen you can just go crazy. >>>>> Being able to freeze(anyobject) seems like a pretty clear win. >>>>> Whether or not it is pythonic is debatable. I'd argue if the meaning >>>>> of pythonic in some context is limiting, we should consider updating >>>>> the term rather than being dogmatic. >> >> A real justification for the ability to make anything immutable is >> to make it safely shareable between threads. If it's immutable, it >> doesn't have to be locked for access. Mozilla's new "Rust" >> language takes advantage of this. Take a look at Rust's concurrency >> semantics. They've made some progress. >> >> John Nagl > > > Lets model the system as an asynchronous set of objects with multiple threads > performing operatons on objects as in the above. I'd argue for a concurrency system where everything is either immutable, unshared, synchronized, or owned by a synchronized object. This eliminates almost all explicit locking. Python's use of immutability has potential in that direction, but Python doesn't do anything with that concept. John Nagle From rosuav at gmail.com Mon Feb 13 16:27:40 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 08:27:40 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: Rick, you are either... On Tue, Feb 14, 2012 at 8:01 AM, Rick Johnson wrote: > I can however tell you that what DOES matter is the continued > improvement of the base gene pool. Yes, this improvement comes at a > cost; the cost of the individual. Those with quality genes will reap > the rewards, likewise, those with crap genes will not. ... a Nazi/Fascist/Commie mutant traitor, or... > But go on falsely believing your little puny life matters. Go on > believing in your worn out traditions and selfish languages and > cultures. Go on believing that humans will be inhabiting this rock in > the next 1000 years, or this universe in the next 10,000 -- because > the enlightened few will have transcended into the mind hive and your @ > $$ will be glued to Terra firma forever! ... the Borg. I'm not sure which is worse. Hmm, I think I just godwinned this thread. But at least I could couple it with a Paranoia reference. ChrisA From breamoreboy at yahoo.co.uk Mon Feb 13 16:46:43 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 13 Feb 2012 21:46:43 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 13/02/2012 21:01, Rick Johnson wrote: > Healthy people do not need healthcare very often, and in the rare > cases when they do, they don't bog down the system because their > bodies are strong. Why are their bodies strong? Because healthy people > eat correctly, healthy people exercise, therefore, healthy people have > correctly functioning immune systems -- of course quality genes always > help! Please explain why previously healthy people get struck down with Common Fatigue Syndrome amongst other things. -- Cheers. Mark Lawrence. From torriem at gmail.com Mon Feb 13 16:46:56 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 Feb 2012 14:46:56 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4F3984D0.5010009@gmail.com> On 02/13/2012 09:01 AM, Rick Johnson wrote: > Look, i hate super rich, arrogant people just as much i hate selfish > people. But wait, Rick. You are a man of contradictions. We all are, but you seem to bluster on and on more about it than most. Firstly, to *hate* anyone, super-rich, arrogant, or not, _is_ selfish by definition. Also, while I accept that you do not see yourself as arrogant, there are others on this list, who are not particularly arrogant, who read your posts as occasionally being extremely arrogant. For example, your post mocking people for using English in ways that you do not personally approve. Maybe this is just an artifact of the limitations of the written word. Now to the second contradiction. You said that one way to fix health care costs would be to deny it to anyone who could not afford health care insurance. Put in another way, health care should only go to those that can afford to pay for the insurance or care, and not the free-loaders. Is that not what you said? Thus a "super rich" person should be commended as he will be able to afford health care without burdening anyone else in society. Does your hatred for super-rich, arrogant, people mean that you believe there is an acceptable dollar value for the wealth a person should morally be able to amass? All of this reminds me that I've always wanted to ask you something. After reading your many posts over the last couple of years, I am curious. What do you do for your career? Are you a professional software developer? From lists.eckel at gmail.com Mon Feb 13 17:01:53 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 14:01:53 -0800 (PST) Subject: Automatic Type Conversion to String Message-ID: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> I'm creating a class to encapsulate OS paths, to reduce the visual noise and typing from the os.path methods. I've got the class and nose tests below, and everything works except the last test which I've prefixed with XXX: def XXXtest_should_work(self): """ Produces: open(self.p2, 'w').write('') TypeError: coercing to Unicode: need string or buffer, Path found """ open(self.p2, 'w').write('') assert self.p2 Note that I *have* a __str__(self) method to perform automatic conversion to string, and I've commented out the __unicode__(self) method because it wasn't getting called. The problem appears to be that open() does not seem to be calling __str__ on its first argument, but instead it appears to want a basestring and this doesn't automatically call __str__. I'm trying to write the Path class so I can just hand a Path object to, for example, open() and have it produce the path string. Thanks for any insights. --------------------------- Class and tests, put in file path.py ------------------------------------ import os, os.path class Path(object): def __init__(self, *args): """ Each of *args is a piece of a path. Assemble them together. """ if len(args) == 0: self.path = os.path.abspath('.') else: self.path = str(args[0]) # str() so you can add Path objects if self.path.endswith(':'): self.path = os.path.join(self.path, os.sep) for a in args[1:]: self.path = os.path.join(self.path, str(a)) def __add__(self, other): return Path(os.path.join(self.path, other)) def __iadd__(self, other): # path += path self.path = os.path.join(self.path, other) return self # Allows chaining def __str__(self): return self.path # def __repr__(self): # assert not self.path, "__repr__" # return os.path.join(self.path) # def __unicode__(self): # assert not self.path, "__unicode__" # print "Unicode called %s" % self.path # return os.path.join(self.path) def __nonzero__(self): """ Boolean test: does this path exist? So you can say "if path:" """ return bool(os.path.exists(self.path)) """ Nose tests. To run, you must first install nose: pip install nose Then: nosetests path.py """ def test_platform(): "First draft tests are Windows-based" import platform assert platform.system() == 'Windows' class test_paths(): def setUp(self): self.paths = [ ("C:\\"), ("C:\\", "Users", "Bruce Eckel", "Downloads", "AtomicScala.zip"), ("C:\\", "Users", "Bruce Eckel", "Dropbox", "AtomicScala"), ] self.p1 = Path(self.paths[0]) self.s1 = os.path.join(self.paths[0], "\\") self.p2 = Path(*self.paths[1]) self.s2 = os.path.join(*self.paths[1]) self.p3 = Path(*self.paths[2]) self.s3 = os.path.join(*self.paths[2]) self.p4 = self.p3 + "TestFile1.tmp" self.s4 = os.path.join(self.s3, "TestFile1.tmp") self.p5 = self.p3 + "TestFile2.tmp" self.s5 = os.path.join(self.s3, "TestFile2.tmp") self.p6 = Path("foo") + "bar" + "baz" def test1(self): "Root directory" print self.p1 print self.s1 assert str(self.p1) == self.s1 def test2(self): "Full path to file" print "p2", self.p2 print "s2", self.s2 assert str(self.p2) == self.s2 def test3(self): "Directory" assert str(self.p3) == self.s3 def test4(self): "Plus operator" assert str(self.p4) == self.s4 def test5(self): "Another temp file" assert str(self.p5) == self.s5 def test6(self): "Chained operator +" assert str(self.p6) == r"foo\bar\baz" def test7(self): "Operator +=" self.p6 += "bingo" assert str(self.p6) == r"foo\bar\baz\bingo" def test8(self): "Create a Path from a Path" p = Path(self.p3) assert p.path == self.s3 class test_existence: """ Test for directory and path existence """ def setUp(self): base = Path("C:", "Users", "Bruce Eckel", "Downloads") self.p1 = base + "TestFile1.tmp" self.p2 = base + "TestFile2.tmp" self.p3 = base + "TestFile3.tmp" def test_basestring(self): print type(self.p1) assert isinstance(self.p1.path, basestring) def test1(self): "p1 existence" open(self.p1.path, 'w').write('') assert self.p1 def test2(self): "p2 existence" open(self.p2.path, 'w').write('') assert self.p2 def test3(self): "p3 existence" assert not self.p3 def XXXtest_should_work(self): """ Produces: open(self.p2, 'w').write('') TypeError: coercing to Unicode: need string or buffer, Path found """ open(self.p2, 'w').write('') assert self.p2 From clp2 at rebertia.com Mon Feb 13 17:27:12 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Mon, 13 Feb 2012 14:27:12 -0800 Subject: Automatic Type Conversion to String In-Reply-To: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 2:01 PM, Bruce Eckel wrote: > I'm creating a class to encapsulate OS paths, to reduce the visual > noise and typing from the os.path methods. I've got the class and nose > tests below, and everything works except the last test which I've > prefixed with XXX: > > ? ?def XXXtest_should_work(self): > ? ? ? ?""" > ? ? ? ?Produces: > ? ? ? ?open(self.p2, 'w').write('') > ? ? ? ?TypeError: coercing to Unicode: need string or buffer, Path > found > ? ? ? ?""" > ? ? ? ?open(self.p2, 'w').write('') > ? ? ? ?assert self.p2 > > Note that I *have* a __str__(self) method to perform automatic > conversion to string, and I've commented out the __unicode__(self) > method because it wasn't getting called. The problem appears to be > that open() does not seem to be calling __str__ on its first argument, > but instead it appears to want a basestring and this doesn't > automatically call __str__. Right. Python is strongly-typed, so it requires a genuine str here (as opposed to just something that's stringifyable) and doesn't do an coercion call to str() for you. Just like how str.join() doesn't automatically call str() on the elements of the list you give it. This is to prevent silliness like trying to open() e.g. a dict. Your alternatives are: - Learn to live with having to write open(str(path_obj)) - Add a .open() method to Path, and use that instead of the open() built-in function - Have Path subclass `str` or `unicode` > I'm trying to write the Path class so I can just hand a Path object > to, for example, open() and have it produce the path string. Impossible, short of subclassing `str` or `unicode`. Cheers, Chris From debatem1 at gmail.com Mon Feb 13 17:27:44 2012 From: debatem1 at gmail.com (geremy condra) Date: Mon, 13 Feb 2012 14:27:44 -0800 Subject: M2crypto In-Reply-To: <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 12:37 AM, zigi wrote: > Hello, > this is must be testing time to crypt files, using just M2crypto :-) > I know this is a strange use of the library, but such is the will of > the management. I take it you mean that you're benchmarking file encryption performance using M2Crypto? If your only goal is to do exactly that then go for it, but otherwise you're probably using the wrong tool for the job. Geremy Condra > On 13 Lut, 01:28, geremy condra wrote: >> On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: >> > zigi wrote: >> >> >> Hello, >> >> M2crypto >> >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', >> >> salt='12345678', i=1, padding=1) >> >> >> I wont write app, using M2crypto and I can not understand what are the >> >> arguments: >> >> key, iv, op, salt ? >> >> What they do ? >> >> > I assume you're reading in >> > about M2Crypto.EVP.Cipher. >> >> > Epydoc claims another victim. >> >> > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL >> > pages are kind of thin, too. ?You might see some useful code in the EVP unit >> > tests m2crypto/tests/test_evp.py in the m2crypto installation. >> >> Not intending to be rude, but being perfectly serious: as a general >> rule, if you don't know what an IV is you're probably getting yourself >> into a lot of trouble working with low-level crypto libraries. >> >> Two suggestions: >> >> 1. Describe what you're trying to do- I'll be able to help more if I >> know what you're actually going for. >> >> 2. Try keyczar. It's not perfect, but it's a lot easier to get right. >> >> Geremy Condra > > -- > http://mail.python.org/mailman/listinfo/python-list From cezar4846 at gmail.com Mon Feb 13 17:38:34 2012 From: cezar4846 at gmail.com (zigi) Date: Mon, 13 Feb 2012 14:38:34 -0800 (PST) Subject: M2crypto References: <2515ca96-77c9-4264-aaf2-42bd98fcf9ca@dq9g2000vbb.googlegroups.com> <61db3262-c120-4dc8-8f63-1d7496e4001c@gr6g2000vbb.googlegroups.com> Message-ID: <3a2a0af8-9340-401d-89c7-229fee86aa4c@db5g2000vbb.googlegroups.com> Ok, thanks. On 13 Lut, 23:27, geremy condra wrote: > On Mon, Feb 13, 2012 at 12:37 AM, zigi wrote: > > Hello, > > this is must be testing time to crypt files, using just M2crypto :-) > > I know this is a strange use of the library, but such is the will of > > the management. > > I take it you mean that you're benchmarking file encryption > performance using M2Crypto? If your only goal is to do exactly that > then go for it, but otherwise you're probably using the wrong tool for > the job. > > Geremy Condra > > > > > > > > > On 13 Lut, 01:28, geremy condra wrote: > >> On Sun, Feb 12, 2012 at 4:00 PM, Mel Wilson wrote: > >> > zigi wrote: > > >> >> Hello, > >> >> M2crypto > > >> >> __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', > >> >> salt='12345678', i=1, padding=1) > > >> >> I wont write app, using M2crypto and I can not understand what are the > >> >> arguments: > >> >> key, iv, op, salt ? > >> >> What they do ? > > >> > I assume you're reading in > >> > about M2Crypto.EVP.Cipher. > > >> > Epydoc claims another victim. > > >> > I'm having a lot of trouble finding documentation. ?The obvious OpenSSL > >> > pages are kind of thin, too. ?You might see some useful code in the EVP unit > >> > tests m2crypto/tests/test_evp.py in the m2crypto installation. > > >> Not intending to be rude, but being perfectly serious: as a general > >> rule, if you don't know what an IV is you're probably getting yourself > >> into a lot of trouble working with low-level crypto libraries. > > >> Two suggestions: > > >> 1. Describe what you're trying to do- I'll be able to help more if I > >> know what you're actually going for. > > >> 2. Try keyczar. It's not perfect, but it's a lot easier to get right. > > >> Geremy Condra > > > -- > >http://mail.python.org/mailman/listinfo/python-list From wanderer at dialup4less.com Mon Feb 13 17:59:59 2012 From: wanderer at dialup4less.com (Wanderer) Date: Mon, 13 Feb 2012 14:59:59 -0800 (PST) Subject: Change os.makedirs to handle existing directory Message-ID: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> I think wanting to create a directory if one doesn't exist or do nothing if it does exist and just use the existing directory is a fairly normal programming need. Apparently this is somewhat complicated in Python. If you use if not os.path.exists(dirName): os.makedirs(dirName) you create a race condition. If you use try: try: os.makedirs(dirName) except OSError: pass Now you're silencing too many errors, so you need to select which errors to silence. You can check to see if the directory already exists and assume that the directory already existing is the cause of the error. try: os.makedirs(dirName) except OSError: if os.path.exists(dirName): # We are nearly safe pass else: # There was an error on creation, so make sure we know about it raise or check the error type: try: os.makedirs(dirName) except OSError, e: if e.errno != errno.EEXIST: raise IMHO, os.makedirs should do this for you with something like os.makedirs(dirName, exist = False) and have makedirs silence the error the 'right' way whatever that is, without turning it into an exercise for the user. From lists.eckel at gmail.com Mon Feb 13 18:18:55 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 15:18:55 -0800 (PST) Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: <12584848.58.1329175135396.JavaMail.geo-discussion-forums@ynii32> I'm willing to subclass str, but when I tried it before it became a little confusing -- I think mostly because anytime I assigned to self it seemed like it converted the whole object to a str rather than a Path. I suspect I don't know the proper idiom for doing this -- any hints? Thanks ... From lists.eckel at gmail.com Mon Feb 13 18:18:55 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Mon, 13 Feb 2012 15:18:55 -0800 (PST) Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: <12584848.58.1329175135396.JavaMail.geo-discussion-forums@ynii32> I'm willing to subclass str, but when I tried it before it became a little confusing -- I think mostly because anytime I assigned to self it seemed like it converted the whole object to a str rather than a Path. I suspect I don't know the proper idiom for doing this -- any hints? Thanks ... From timothy.c.delaney at gmail.com Mon Feb 13 18:18:58 2012 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Tue, 14 Feb 2012 10:18:58 +1100 Subject: Change os.makedirs to handle existing directory In-Reply-To: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> References: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> Message-ID: On 14 February 2012 09:59, Wanderer wrote: > I think wanting to create a directory if one doesn't exist or do > nothing if it does exist and just use the existing directory is a > fairly normal programming need. Apparently this is somewhat > complicated in Python. > ... > IMHO, os.makedirs should do this for you with something like > > os.makedirs(dirName, exist = False) > > and have makedirs silence the error the 'right' way whatever that is, > without turning it into an exercise for the user. Added in 3.2: http://docs.python.org/py3k/library/os.html?highlight=makedirs#os.makedirs Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Mon Feb 13 18:19:21 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Mon, 13 Feb 2012 17:19:21 -0600 Subject: Change os.makedirs to handle existing directory In-Reply-To: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> References: <2d67ab5b-1916-4f45-b920-476d8cd19c1e@tj4g2000pbc.googlegroups.com> Message-ID: <4F399A79.8020003@gmail.com> On 2/13/2012 4:59 PM, Wanderer wrote: > I think wanting to create a directory if one doesn't exist or do > nothing if it does exist and just use the existing directory is a > fairly normal programming need. Apparently this is somewhat > complicated in Python. There are new exceptions in 3.3, one of which is for exactly this. http://docs.python.org/dev/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy http://docs.python.org/dev/library/exceptions.html#FileExistsError -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From steve+comp.lang.python at pearwood.info Mon Feb 13 19:19:35 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Feb 2012 00:19:35 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <4f39a896$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 13 Feb 2012 13:01:05 -0800, Rick Johnson wrote: > Healthy people do not need healthcare very often Healthy people don't need healthcase AT ALL. By definition, once you need healthcare, you are no longer healthy. Your faith in the magic of "immune system" is touching, but one wonders how "immune system" will save people who have been hit by a car. Rick, isn't it time for you to go back to forking Python so that the adoring silent majority who agrees with you can abandon this cesspool of inefficient Python code and use your awesome new version? Please don't disappoint your millions of fans! -- Steven From rantingrickjohnson at gmail.com Mon Feb 13 19:39:37 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 16:39:37 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Feb 13, 3:46?pm, Michael Torrie wrote: > On 02/13/2012 09:01 AM, Rick Johnson wrote: > > > Look, i hate super rich, arrogant people just as much i hate selfish > > people. > > But wait, Rick. ?You are a man of contradictions. ?We all are, but you > seem to bluster on and on more about it than most. ?Firstly, to *hate* > anyone, super-rich, arrogant, or not, _is_ selfish by definition. Not necessarily. But i will admit that i did not choose my words correctly. I don't "hate" people simply BECAUSE they are rich. Just like i don't hate people simply because they are poor. However i DO hate what the super rich people BECOME. They become blind to their own position in the universe and instead start to believe the universe revolves around them. When their daily lives are consumed with vanity, and they lose all appreciation for the value of money. Yes, they have become something NOT to aspire to. But how much is too much? Good question, and the answer is ALWAYS subjective isn't it? A child might think $20 dollars is a lot of money. A homeless person might think someone who has a new model car is rich and not struggling. Same goes in the opposite direction. A rich man might choose suicide over life if confronted with the possibility of surviving on $40,000 a year. However, as we know, many folks survive on much less than that -- some even pretend to be happy! Can there be a specific amount wherein if you exceed that amount THEN you are living in excess? I believe there is a specific amount, however it is constantly changing depending on the current state of employment and wages. My equation looks like: # Py>=3.0 py> sum(earner.get_income(2012) for earner in earners2012) / len(earners2012) average_income Once you exceed that amount you are robbing your fellow man. How can you justify making more than your fair share UNLESS someone offers their work load to YOU? You can't. You are living in excess. And for those who think the average_income is too small, well then, it's time to implement population control! The fact is, we have far too many people living beyond their needs. We have people buying houses they can't afford and then blaming the bank for some how "tricking" them. They don't have the scruples to accept the blame! Take a look around man. The world is in death throes. World wide economic collapse is upon us. And how did we get here? Entitlements: which is just another manifestation of selfishness. Look at Greece. Look at Europe. America YOU are next! > Put in another way, health care should only go to those > that can afford to pay for the insurance or care, and not the > free-loaders. Yes. Healthcare is a luxury available only to those who can afford it. If you can't afford healthcare, then visit a REAL charity hospital (not one subsidized by taxpayers!). A real charity is subsidized by caring folks who want to help their fellow man -- even if to only extend his suffering a few more days, months, or years. > Thus a "super rich" person > should be commended as he will be able to afford health care without > burdening anyone else in society. "commend" is a strong word. I don't think paying your debts requires a pat on the back. If you have children, then you are required to raise them, you don't get brownie points for raising your children, it's your job! Same for debts. > Does your hatred for super-rich, > arrogant, people mean that you believe there is an acceptable dollar > value for the wealth a person should morally be able to amass? see above equation for enlightenment ^^^ > What do you do for your career? ?Are you a professional > software developer? Why? Do you need the services of a professional software developer? From rantingrickjohnson at gmail.com Mon Feb 13 20:07:35 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 13 Feb 2012 17:07:35 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4f39a896$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 13, 6:19?pm, Steven D'Aprano wrote: > Your faith in the magic of "immune system" is touching, but one wonders > how "immune system" will save people who have been hit by a car. Why do you assume that someone hit by a car is a victim? This mindset is why you (and others like you) cannot understand the REAL problem we face. The problem that is destroying the world as we speak. What if you where driving the car and someone ran out from behind a large truck? (that's called "jaywalking" BTW!) What if you had no time to stop? Who's to blame: the driver or the rebel pedestrian? Streets are no place for walking, and sidewalks no place for driving. Q: But what if the pedestrian had right-of-way? A: Then the driver (or driver's insurance) would be responsible for medical bills. Q: But what if the driver has no money or no insurance A: Then he NEVER should have been driving in the first place! He made a really stupid decision! So sell all his belongings at auction and/or force him into hard labor until the debt is re-paid! I have no problem providing REAL emergency care for my fellow man who might find themselves involved in an accident, or an unlucky victim of violence requiring medical attention -- as long as the accident/ violence was not his fault or caused by his own stupidity! I think anyone who is human would agree with that. HOWEVER, as i have stated before, poor health caused by poor life choices is no excuse for free healthcare. These sloths are the people bankrupting the system! From ian.g.kelly at gmail.com Mon Feb 13 20:29:56 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 13 Feb 2012 18:29:56 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: [Reply sent off-list, partly because this is way off-topic, but also because python-list rejected my response as spam] From torriem at gmail.com Mon Feb 13 20:36:42 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 13 Feb 2012 18:36:42 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <4F39BAAA.4000600@gmail.com> On 02/13/2012 05:39 PM, Rick Johnson wrote: > Why? Do you need the services of a professional software developer? Do you have some to offer? From rosuav at gmail.com Mon Feb 13 20:37:31 2012 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 14 Feb 2012 12:37:31 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson wrote: > # Py>=3.0 > py> sum(earner.get_income(2012) for earner in earners2012) / > len(earners2012) > average_income > > Once you exceed that amount you are robbing your fellow man. How can > you justify making more than your fair share UNLESS someone offers > their work load to YOU? You can't. You are living in excess. And for > those who think the average_income is too small, well then, it's time > to implement population control! My equation looks something like this: # Brain >= 0,1 brain> Your contribution to society / Society's contribution to you This value should be able to exceed 1.0 across the board. In fact, if it doesn't, then as a society we're moving backward. Rick, what's YOUR ratio? Oh wait, you mightn't be able to run that code. You may need to download an upgraded brain. ChrisA From dllizheng at gmail.com Mon Feb 13 23:13:59 2012 From: dllizheng at gmail.com (Zheng Li) Date: Tue, 14 Feb 2012 13:13:59 +0900 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <20120213072339.GA9132@cskk.homeip.net> References: <20120213072339.GA9132@cskk.homeip.net> Message-ID: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> I can get "method1" of class "Test" by a = getattr(Test, "method1") and I also want know how to invoke it a() or a(Test()) BTW: I don't see what the problem is if I ask a question just because I am curious about it. On 2012/02/13, at 16:23, Cameron Simpson wrote: > On 13Feb2012 15:59, Zheng Li wrote: > | how to tell a method is class method or static method or instance method? > > Maybe a better question is: > under what circumstances do you need to figure this out? > > I'm actually quite serious here. Please outline what circumstances cause > you to want to ask and answer this question. > > Cheers, > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Reason #173 to fear technology: > > o o o o o o > ^|\ ^|^ v|^ v|v |/v |X| \| | > /\ >\ /< >\ /< >\ /< >\ > > o> o o o o o o o > \ x <\> <)> |\ > /< >\ /< >\ /< >\ >> L > > Mr. email does the Macarena. From jeanpierreda at gmail.com Mon Feb 13 23:38:03 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Mon, 13 Feb 2012 23:38:03 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? Message-ID: Hey Pythonistas, Consider the regular expression "$*". Compilation fails with the exception, "sre_constants.error: nothing to repeat". Consider the regular expression "(?=$)*". As far as I know it is equivalent. It does not fail to compile. Why the inconsistency? What's going on here? -- Devin From wxjmfauth at gmail.com Tue Feb 14 03:00:01 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Tue, 14 Feb 2012 00:00:01 -0800 (PST) Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <2076e822-6225-449d-8d93-bf8d1627e77a@l14g2000vbe.googlegroups.com> On 13 f?v, 04:09, Terry Reedy wrote: > > > * The new internal unicode scheme for 3.3 is pretty much a mixture of > the 3 storage formats (I am of course, skipping some details) by using > the widest one needed for each string. The advantage is avoiding > problems with each of the three. The disadvantage is greater internal > complexity, but that should be hidden from users. They will not need to > care about the internals. They will be able to forget about 'narrow' > versus 'wide' builds and the possible requirement to code differently > for each. There will only be one scheme that works the same on all > platforms. Most apps should require less space and about the same time. > > -- Python 2 was built for ascii users. Now, Python 3(.3) is *optimized* for the ascii users. And the rest of the crowd? Not so sure, French users (among others) who can not write their texts will iso-8859-1/latin1 will be very happy. No doubts, it will work. Is this however the correct approach? jmf From blah238 at gmail.com Tue Feb 14 03:40:42 2012 From: blah238 at gmail.com (Logan Pugh) Date: Tue, 14 Feb 2012 02:40:42 -0600 Subject: Override the interpreter used by multiprocessing subprocesses? Message-ID: Hello, I am using a product that has a built-in Python interpreter (ESRI ArcGIS Desktop 10.0 SP3) and have implemented multiprocessing in script that can be run by a tool within the application using the built-in interpreter. The way the built-in interpreter works is incompatible with multiprocessing as it appears to want to start multiple instances of the host application when the subprocesses are created. I am using multiprocessing.Pool with the apply_async function. It works great in a standalone script and I'd rather not rewrite what I've done so far if I can help it, but if there is a way to simply force the standard interpreter to be used for the subprocesses that would be ideal. Thinking about it I realize that this might not be possible due to whatever messaging, pickling, and queueing that the main processes has to handle for the subprocesses, but thought I would ask anyways if only for my own enlightenment. TIA! -------------- next part -------------- An HTML attachment was scrubbed... URL: From research at johnohagan.com Tue Feb 14 03:41:46 2012 From: research at johnohagan.com (John O'Hagan) Date: Tue, 14 Feb 2012 19:41:46 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <20120214194146.091273a00d3af9869bc06979@johnohagan.com> On Mon, 13 Feb 2012 13:01:05 -0800 (PST) Rick Johnson wrote: > On Feb 13, 12:38?pm, Ian Kelly wrote: > > I hate being suckered in by trolls, but this paragraph demands a response. Ditto... > > On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson > > > > wrote: > > > You are born with rights. Life, Liberty, and the pursuit of happiness. > > > Healthcare care is NOT a right, healthcare is a privileged. [...] > HOWEVER, healthcare is not a concern of the greater society, but only > the individual -- with the exception of contagious disease of course, [...snip half-baked, social-Darwinist, "there-is-no-such-thing-as-society", naive U.S.-capitalist-libertarian drivel...] > > > Procreation should be a > > > privilege, however sadly for our collective evolution, it's seems to > > > be a right :( > > > > There is a word for the philosophy that procreation should be a > > privilege reserved for those with good genes: eugenics. > > No, the word is evolution; which means: "survival of the fittest". > Don't try to hijack real science to bolster a repugnant ideology. Neither Herbert Spencer nor Darwin meant that phrase the way you do. [...snip egregious, self-serving display of ignorance on the subjects of evolution and genetics...] > > >?Welcome to fascism, Rick. > > Don't try to append me onto a specific ideology structure just because > that group happens to support ONE of my beliefs. I carry no political [...blah blah...] It's called duck-typing. I somewhat optimistically implore you, Rick, to do some basic research on your chosen subjects. Failing that (almost certainly), here are three simple points which debunk your agenda (and that of the U.S. Republican Right): 1. Publicly-funded healthcare is both cheaper and more effective than privatised systems. It's also the right thing to do (i.e. you don't have to stand by while someone dies because their illness is "their fault"). Which makes it a win-win-win. 2. The recent economic problems were not triggered by "degenerates" (are you actually talking about homosexuals here, or just in the more general, McCathyist sense?), but in fact by the operations of the same unregulated markets you are advocating. 3. The central fallacy of social Darwinism is the misapprehension that because natural selection occurs in nature, human society _should_ also work this way. This is a failure to acknowledge the is/ought problem, and is usually compounded (Rick is no exception) by the equally mistaken view that there exist "superior" individuals whose possession of a "quality gene-pool" entitles them to survival - an entitlement that is encroached upon by inferior sorts who take up space by insisting on not dying. Can you guess in which group those who hold this view place themselves? In fact, a gene pool is held by a species, not an individual, and the maintenance of its diversity is essential for long term-survival. And to the great disappointment of those looking for a justification of dog-eat-dog, one of the main drivers of evolution is not competition, but adapting to new environments to _avoid_ competition. I'm told the Spanish have a saying which translates as "dogs don't eat dogs". Genetics is complicated. Switching one gene on switches others off in unpredictable ways, people choose mates by unfathomable processes, good-looking geniuses have dumb, ugly children and vice-versa. This is why eugenics projects are doomed to failure. They are also morally wrong, which is another win-win. If some featureless fungus, toxic to all other living things, engulfed the globe, would that make it "superior"? Of course, not, it merely survived. Considerations of what _should_ happen, of superiority and quality, are human, social concerns. We are humans, so they are important to us. But they have nothing to do with genetics or evolution. Social Darwinism is merely a psuedo-scientific attempt to justify inequity and class divides. Furthermore, it is completely dead outside the U.S. - ironically the only developed nation where real Darwinism is still seriously questioned. [...] > Go on believing that humans will be inhabiting this rock in > the next 1000 years, or this universe in the next 10,000 -- because > the enlightened few will have transcended into the mind hive and your @ > $$ will be glued to Terra firma forever! Now that is some crazy shit! Maybe L. Ron _is_ still alive... Regards, John From cs at zip.com.au Tue Feb 14 04:52:23 2012 From: cs at zip.com.au (Cameron Simpson) Date: Tue, 14 Feb 2012 20:52:23 +1100 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> References: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> Message-ID: <20120214095223.GA1107@cskk.homeip.net> On 14Feb2012 13:13, Zheng Li wrote: | > On 13Feb2012 15:59, Zheng Li wrote: | > | how to tell a method is class method or static method or instance method? | > | > Maybe a better question is: | > under what circumstances do you need to figure this out? | | I can get "method1" of class "Test" by | a = getattr(Test, "method1") | | and I also want know how to invoke it | a() or a(Test()) Normally: a(T) where T is an object of type/class Test. So your second approach is notionally correct (aside from making a throwaway object that is then discarded). | BTW: | I don't see what the problem is if I ask a question just because I am curious about it. There's nothing wrong with it at all. But often, questions arise from some other circumstances and this one is of such a flavour that if you wanted this code in a real application it would _often_ be the wrong solution to seek, because normally you know how to call something - it is not normally useful to introspect it to decide what to do. So I was wondering what the outer context might be, because there may well have been a better solution to the situation that brought up the specific question. Simple curiosity is sufficient reason, of course. -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Too young to rest on the weekend, too old to rest during the week. - Mark Randol From duncan.booth at invalid.invalid Tue Feb 14 06:31:48 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Feb 2012 11:31:48 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: Rick Johnson wrote: > BS! With free healthcare, those who would have allowed their immune > system fight off the flu, now take off from work, visit a local > clinic, and get pumped full of antibiotics so they can create a new > strain of antibiotic resistant flu virus! Thanks free healthcare! Anyone who can write 'antibiotic resistant flu virus' as though they believe it really needs to read some elementary books about disease. Here's a clue: No flu viruses are treatable with antibiotics. In some cases antibiotics may be useful for flu patients to treat secondary bacterial infections, but they are not effective against viruses. -- Duncan Booth http://kupuguy.blogspot.com From jeanpierreda at gmail.com Tue Feb 14 07:06:05 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 07:06:05 -0500 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: On Tue, Feb 14, 2012 at 6:31 AM, Duncan Booth wrote: > Here's a clue: No flu viruses are treatable with antibiotics. Oh my god we're too late! Now they're ALL resistant! -- Devin From rustompmody at gmail.com Tue Feb 14 07:56:30 2012 From: rustompmody at gmail.com (rusi) Date: Tue, 14 Feb 2012 04:56:30 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <49def9d0-c9b7-44ba-af2d-073f01f0ffcd@ir9g2000pbc.googlegroups.com> On Feb 13, 9:01?pm, Rick Johnson wrote: > > And just how much healthcare dollars are you entitled to exactly? Can > you put your entitlement into some form of monetary value? Rick hats off to you man -- you are damn good! Did you study at a top- troll-school? eg. http://www.youtube.com/watch?v=FMEe7JqBgvg From vinay_sajip at yahoo.co.uk Tue Feb 14 08:20:48 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 14 Feb 2012 05:20:48 -0800 (PST) Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? References: Message-ID: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> On Feb 14, 4:38?am, Devin Jeanpierre wrote: > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin $ is a meta character for regular expressions. Use '\$*', which does compile. Regards, Vinay Sajip From jeanpierreda at gmail.com Tue Feb 14 08:33:12 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 08:33:12 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> References: <0cc200e6-6e4c-47b7-8563-3abc3ac94f22@k10g2000yqk.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 8:20 AM, Vinay Sajip wrote: > $ is a meta character for regular expressions. Use '\$*', which does > compile. I mean for it to be a meta-character. I'm wondering why it's OK for to repeat a zero-width match if it is a zero-width assertion. -- Devin From ulrich.eckhardt at dominolaser.com Tue Feb 14 09:26:21 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 14 Feb 2012 15:26:21 +0100 Subject: Automatic Type Conversion to String In-Reply-To: References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: Am 14.02.2012 00:18, schrieb Bruce Eckel: > I'm willing to subclass str, but when I tried it before it became a > little confusing -- I think mostly because anytime I assigned to self > it seemed like it converted the whole object to a str rather than a > Path. I suspect I don't know the proper idiom for doing this -- any > hints? Thanks ... Could it be that you missed the fact that strings are immutable? That means that you can't change the content of the object once it is initialized. In particular, it means that you e.g. have to override __new__ instead of __init__, because the content is already fixed when the latter is called. Python strings rather behave like Java strings than C++ strings. Uli From devipriya0010 at gmail.com Tue Feb 14 09:47:52 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Tue, 14 Feb 2012 06:47:52 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... Message-ID: <9117090c-8696-4416-ad18-0ff40bff375e@kn4g2000pbc.googlegroups.com> http://123maza.com/46/dos754/ From jabba.laci at gmail.com Tue Feb 14 10:01:05 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Tue, 14 Feb 2012 16:01:05 +0100 Subject: name of a sorting algorithm Message-ID: Hi, Could someone please tell me what the following sorting algorithm is called? Let an array contain the elements a_1, a_2, ..., a_N. Then: for i = 1 to N-1: for j = i+1 to N: if a_j < a_i then swap(a_j, a_i) It's so simple that it's not mentioned anywhere. I guess it's called "selection sort" but I'm not sure. The minimum selection sort is an improvement of this one. Thanks, Laszlo From vlastimil.brom at gmail.com Tue Feb 14 10:05:51 2012 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Tue, 14 Feb 2012 16:05:51 +0100 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: 2012/2/14 Devin Jeanpierre : > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin > -- > http://mail.python.org/mailman/listinfo/python-list Hi, I don't know the reason for the observed differences either (I can think of some optimisation issues etc.), but just wanted to mention some other similar patterns to your lookahaed: It seems, that groups (capturing or not capturing) also work ok: >>> re.findall("($)*", "abc") ['', '', '', ''] >>> re.findall("(?:$)*", "abc") ['', '', '', ''] However, is there any realistic usecase for repeated zero-width anchors? regards, vbr From mwilson at the-wire.com Tue Feb 14 10:25:16 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 10:25:16 -0500 Subject: name of a sorting algorithm References: Message-ID: Jabba Laci wrote: > Could someone please tell me what the following sorting algorithm is > called? > > Let an array contain the elements a_1, a_2, ..., a_N. Then: > for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > > It's so simple that it's not mentioned anywhere. I guess it's called > "selection sort" but I'm not sure. The minimum selection sort is an > improvement of this one. It's what Wikipedia says a selection sort is: put the least element in [0], the least of the remaining elements in [1], etc. Mel. From ulrich.eckhardt at dominolaser.com Tue Feb 14 10:33:24 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Tue, 14 Feb 2012 16:33:24 +0100 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <4fbq09-3is.ln1@satorlaser.homedns.org> Am 14.02.2012 16:01, schrieb Jabba Laci: > Could someone please tell me what the following sorting algorithm is called? > > Let an array contain the elements a_1, a_2, ..., a_N. Then: > > for i = 1 to N-1: > for j = i+1 to N: > if a_j< a_i then swap(a_j, a_i) > > It's so simple that it's not mentioned anywhere. Please do your own homework. This code isn't even Python! > I guess it's called "selection sort" but I'm not sure. You guessed right. Uli From ramit.prasad at jpmorgan.com Tue Feb 14 10:50:14 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 15:50:14 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414A04E@SCACMX008.exchad.jpmchase.net> > for i in xrange (N-1): for j in xrange (i, N): if a[j] < a[i]: a[i], a[j] = a[j], a[i] > It's what Wikipedia says a selection sort is: put the least element in [0], the least of the remaining elements in [1], etc. If your only requirement to match to selection sort is the end result, then every sort would be selection sort. If you meant "put the least element in [0] in the first pass" then that would indeed be selection sort, but that is not what the above code does. The above code is bubble sort. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From jeanpierreda at gmail.com Tue Feb 14 10:53:38 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 10:53:38 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom wrote: > However, is there any realistic usecase for repeated zero-width anchors? Maybe. There is a repeated zero-width anchor is used in the Python re test suite, which is what made me notice this. I assume that came from some actual use-case. (see: http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599 ) And yeah, even something as crazy as ()* works, but as soon as it becomes (a*)* it doesn't work. Weird. -- Devin From arnodel at gmail.com Tue Feb 14 11:22:45 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 14 Feb 2012 16:22:45 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: On 14 February 2012 15:31, Dennis Lee Bieber wrote: > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci > wrote: > >>Could someone please tell me what the following sorting algorithm is called? >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >>for i = 1 to N-1: >> ? ?for j = i+1 to N: >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) >> > ? ? ? ?Off hand... The ancient Bubble-Sort... > > http://en.wikipedia.org/wiki/Bubble_sort Ahem... No, it's not Bubble Sort. Bubble sort only swaps adjacent terms. I don't know what this sort is called, if it even has a name. It's a kind of Selection Sort, as each pass it looks for the minimum of the remaining unsorted items. But it ruffles the unsorted list each pass, seemingly to save using an extra register to store the current minumum (there was a time when registers were at a premium). -- Arnaud From mwilson at the-wire.com Tue Feb 14 11:44:20 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 11:44:20 -0500 Subject: name of a sorting algorithm References: Message-ID: Prasad, Ramit wrote: >> > for i in xrange (N-1): > for j in xrange (i, N): > if a[j] < a[i]: > a[i], a[j] = a[j], a[i] >> It's what Wikipedia says a selection sort is: put the least element in >> [0], the least of the remaining elements in [1], etc. > > If your only requirement to match to selection sort is the end result, > then every sort would be selection sort. If you meant "put the least > element in [0] in the first pass" then that would indeed be selection > sort, but that is not what the above code does. The above code is bubble > sort. Well, the classic bubble sort swaps adjacent elements until the extreme one gets all the way to the end. This sort continually swaps with the end element during one pass until the end element holds the extreme. Then it shrinks the range and swaps then next less extreme into the new end element. It does extra swaps because it combines the swap operation with recording the temporary extreme while it searches the subrange. Mel. From patentsvnc at gmail.com Tue Feb 14 11:55:09 2012 From: patentsvnc at gmail.com (Den) Date: Tue, 14 Feb 2012 08:55:09 -0800 (PST) Subject: name of a sorting algorithm References: Message-ID: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> On Feb 14, 8:22?am, Arnaud Delobelle wrote: > On 14 February 2012 15:31, Dennis Lee Bieber wrote: > > > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci > > wrote: > > >>Could someone please tell me what the following sorting algorithm is called? > > >>Let an array contain the elements a_1, a_2, ..., a_N. Then: > > >>for i = 1 to N-1: > >> ? ?for j = i+1 to N: > >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) > > > ? ? ? ?Off hand... The ancient Bubble-Sort... > > >http://en.wikipedia.org/wiki/Bubble_sort > > Ahem... > > No, it's not Bubble Sort. ?Bubble sort only swaps adjacent terms. > > I don't know what this sort is called, if it even has a name. ?It's a > kind of Selection Sort, as each pass it looks for the minimum of the > remaining unsorted items. ?But it ruffles the unsorted list each pass, > seemingly to save using an extra register to store the current minumum > (there was a time when registers were at a premium). > > -- > Arnaud I disagree. In a bubble sort, one pointer points to the top element, while another descents through all the other elements, swapping the elements at the pointers when necessary. Then the one pointer moved down to the next element and the process repeats. This looks like the bubble sort to me. It was one of the first algorithms I had to program in my first programming class in 1969. Den From mwilson at the-wire.com Tue Feb 14 12:04:10 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Tue, 14 Feb 2012 12:04:10 -0500 Subject: name of a sorting algorithm References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: Den wrote: > I disagree. In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. 'When I use a word,' Humpty Dumpty said, in rather a scornful tone, 'it means just what I choose it to mean ? neither more nor less.' (_Through the Looking Glass, Lewis Caroll). And you, too, have that ability. Contrariwise see Knuth, _The Art of Computer Programming_ Section 5.2.2, Algorithm B. Mel. From ian.g.kelly at gmail.com Tue Feb 14 12:37:35 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Feb 2012 10:37:35 -0700 Subject: name of a sorting algorithm In-Reply-To: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 9:55 AM, Den wrote: > On Feb 14, 8:22?am, Arnaud Delobelle wrote: >> On 14 February 2012 15:31, Dennis Lee Bieber wrote: >> >> > On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci >> > wrote: >> >> >>Could someone please tell me what the following sorting algorithm is called? >> >> >>Let an array contain the elements a_1, a_2, ..., a_N. Then: >> >> >>for i = 1 to N-1: >> >> ? ?for j = i+1 to N: >> >> ? ? ? ?if a_j < a_i then swap(a_j, a_i) >> >> > ? ? ? ?Off hand... The ancient Bubble-Sort... >> >> >http://en.wikipedia.org/wiki/Bubble_sort >> >> Ahem... >> >> No, it's not Bubble Sort. ?Bubble sort only swaps adjacent terms. >> >> I don't know what this sort is called, if it even has a name. ?It's a >> kind of Selection Sort, as each pass it looks for the minimum of the >> remaining unsorted items. ?But it ruffles the unsorted list each pass, >> seemingly to save using an extra register to store the current minumum >> (there was a time when registers were at a premium). >> >> -- >> Arnaud > > I disagree. ?In a bubble sort, one pointer points to the top element, > while another descents through all the other elements, swapping the > elements at the pointers when necessary. ?Then the one pointer moved > down to the next element and the process repeats. ?This looks like the > bubble sort to me. ?It was one of the first algorithms I had to > program in my first programming class in 1969. Either you're misremembering, or the algorithm you programmed 43 years ago was not actually bubble sort. Quoting from Wikipedia: """ Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. """ In the present algorithm, you'll note that elements in the unsorted part of the list do not "bubble up" as they would in bubble sort. Rather, they jump around somewhat randomly until they are finally selected for the current sort index. I agree with Arnaud -- this is a selection sort variant that saves a local variable (the index of the minimum element) by placing it at the current sort index instead -- at the cost of doing additional swaps. Probably not a good trade-off in Python (but then again, no pure Python sort algorithm is likely to perform better than the built-in). Cheers, Ian From python at mrabarnett.plus.com Tue Feb 14 13:05:59 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 14 Feb 2012 18:05:59 +0000 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: Message-ID: <4F3AA287.9070604@mrabarnett.plus.com> On 14/02/2012 15:53, Devin Jeanpierre wrote: > On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom > wrote: >> However, is there any realistic usecase for repeated zero-width anchors? > > Maybe. There is a repeated zero-width anchor is used in the Python re > test suite, which is what made me notice this. I assume that came from > some actual use-case. (see: > http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599 > ) > > And yeah, even something as crazy as ()* works, but as soon as it > becomes (a*)* it doesn't work. Weird. > I think it's a combination of warning the user about something that's pointless, as in the case of "$*", and producing a pattern which could cause the internal regex engine to get stuck in an infinite loop. It is inconsistent in that it warns about "$*" but not "(?=$)*" even though they are basically equivalent. From jabba.laci at gmail.com Tue Feb 14 13:10:35 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Tue, 14 Feb 2012 19:10:35 +0100 Subject: name of a sorting algorithm In-Reply-To: References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: Hi, > Either you're misremembering, or the algorithm you programmed 43 years > ago was not actually bubble sort. ?Quoting from Wikipedia: > > """ > Bubble sort, also known as sinking sort, is a simple sorting algorithm > that works by repeatedly stepping through the list to be sorted, > comparing each pair of adjacent items and swapping them if they are in > the wrong order. The pass through the list is repeated until no swaps > are needed, which indicates that the list is sorted. The algorithm > gets its name from the way smaller elements "bubble" to the top of the > list. > """ I don't agree with the last sentence. During bubble sort, in the 1st pass the largest element is moved to the top (for me "top" means the right side (end) of an array). Thus the end of the array is sorted. In the 2nd pass, the largest element of the unsorted left part is moved to the end, etc. That is, it's the _larger_ elements that bubble to the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an animated gif that shows how the algorithm works. > In the present algorithm, you'll note that elements in the unsorted > part of the list do not "bubble up" as they would in bubble sort. > Rather, they jump around somewhat randomly until they are finally > selected for the current sort index. ?I agree with Arnaud -- this is a > selection sort variant that saves a local variable (the index of the > minimum element) by placing it at the current sort index instead -- at > the cost of doing additional swaps. ?Probably not a good trade-off in > Python (but then again, no pure Python sort algorithm is likely to > perform better than the built-in). The minimum selection sort is an improvement of this "noname" algorithm. I give it in pseudo-code. Let A be an array with N elements. Indexing starts with 1. for i := 1 to N-1: minindex := i for j := i+1 to N: if A[j] < A[minindex] then minindex := j end for if i != minindex then swap(A[i], A[minindex]) end for The two loops are the same as in the naive version. It will also sort the array from the left side. It does much less swaps than the naive version. If the "noname" algorithm is called "selection sort", then its name can be misleading. One may ask "OK, but which one? Minimum or maximum selection sort?". Well, neither... Laszlo From toddw at activestate.com Tue Feb 14 13:30:54 2012 From: toddw at activestate.com (Todd Whiteman) Date: Tue, 14 Feb 2012 10:30:54 -0800 Subject: Komodo 7 release (Python development tools) In-Reply-To: References: <4F32D795.2040702@activestate.com> Message-ID: <4F3AA85E.1030304@activestate.com> On 12-02-08 01:52 PM, Terry Reedy wrote: > On 2/8/2012 3:14 PM, Todd Whiteman wrote: > >> My name is Todd. I'm the lead developer for Komodo IDE (Interactive >> Development Environment) and Komodo Edit (a free, open-source editor) at >> ActiveState. I wanted to announce that the newest version, Komodo 7, has >> been released: >> http://www.activestate.com/komodo-ide/python-editor > > It would seem that the Professional Python Editor is the same as Komodo > Edit, but it is unclear why only Python editing would be featured for > Komodo IDE. > > http://www.activestate.com/komodo-edit > > is the page with the link people need to download just the editor. The above page covers features from both Edit and IDE - some will only apply to the IDE version. For a full comparison of features you can check out: http://www.activestate.com/komodo-edit/compare-with-komodo-ide > > Does K.Edit let me run a program with one key, like F5 in IDLE? > If so, does it leave me in interactive mode (python -i) as IDLE does? > Komodo Edit does not offer a quick run (F5) command by default, you could create your own Python command [1] in the Komodo toolbox and assign it the F5 key binding to serve such a purpose. [1] The short command for running a Python script is: "%(python) %F", which uses Komodo's interpolation shortcuts: http://docs.activestate.com/komodo/7.0/shortcuts.html#shortcuts_top Cheers, Todd From ramit.prasad at jpmorgan.com Tue Feb 14 15:13:04 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 20:13:04 +0000 Subject: name of a sorting algorithm In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414CC1F@SCACMX008.exchad.jpmchase.net> Wilson, Mel wrote: >Well, the classic bubble sort swaps adjacent elements until the extreme one >gets all the way to the end. This sort continually swaps with the end >element during one pass until the end element holds the extreme. Then it >shrinks the range and swaps then next less extreme into the new end element. >It does extra swaps because it combines the swap operation with recording >the temporary extreme while it searches the subrange. My apologies, you are correct. It is a selection sort, just an inefficient one. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Tue Feb 14 15:21:20 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 14 Feb 2012 20:21:20 +0000 Subject: name of a sorting algorithm References: Message-ID: <5B80DD153D7D744689F57F4FB69AF47414CC5C@SCACMX008.exchad.jpmchase.net> Prasad, Ramit wrote: > My apologies, you are correct. It is a selection sort, just an inefficient one. Hmm, I think I should say it is neither since it reminds me of a hybrid of both (bubble/selection). The swapping seems very bubble sort, but the looking for the min / max case seems selection sort-ish. Whatever it is, it is certainly inefficient. :) Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ian.g.kelly at gmail.com Tue Feb 14 15:59:00 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 14 Feb 2012 13:59:00 -0700 Subject: name of a sorting algorithm In-Reply-To: References: <73b8d112-9e94-486e-b06c-bdeebc0bf964@q12g2000yqg.googlegroups.com> Message-ID: On Tue, Feb 14, 2012 at 11:10 AM, Jabba Laci wrote: > Hi, > >> Either you're misremembering, or the algorithm you programmed 43 years >> ago was not actually bubble sort. ?Quoting from Wikipedia: >> >> """ >> Bubble sort, also known as sinking sort, is a simple sorting algorithm >> that works by repeatedly stepping through the list to be sorted, >> comparing each pair of adjacent items and swapping them if they are in >> the wrong order. The pass through the list is repeated until no swaps >> are needed, which indicates that the list is sorted. The algorithm >> gets its name from the way smaller elements "bubble" to the top of the >> list. >> """ > > I don't agree with the last sentence. During bubble sort, in the 1st > pass the largest element is moved to the top (for me "top" means the > right side (end) of an array). Thus the end of the array is sorted. In > the 2nd pass, the largest element of the unsorted left part is moved > to the end, etc. That is, it's the _larger_ elements that bubble to > the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an > animated gif that shows how the algorithm works. I think that by "top" they mean "front". Each largest element in turn gets moved to the end in a single pass. It is the smaller elements gradually moving toward the front over many passes that I believe is described as "bubbling", as can be seen in that gif. > If the "noname" algorithm is called "selection sort", then its name > can be misleading. One may ask "OK, but which one? Minimum or maximum > selection sort?". Well, neither... It is a minimum selection sort, because it selects the minimum element on each pass. It just stores the minimum element so far in-place in the array, rather than in a separate variable. From rantingrickjohnson at gmail.com Tue Feb 14 19:21:17 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:21:17 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> On Feb 14, 2:41?am, John O'Hagan wrote: > > 1. Publicly-funded healthcare is both cheaper and more effective than > privatised systems. It's also the right thing to do (i.e. you don't have > to stand by while someone dies because their illness is "their fault"). So you have no problem paying the medical bills of people who overeat sugar, salt, and fat; refuse to put down the ho-ho's; and get a little exercise? If so, then give to charity. Why do you need to FORCE me (and others) to pay for your experiment of "degenerate eugenics"? > 2. The recent economic problems were not triggered by "degenerates" (are you > actually talking about homosexuals here, or just in the more general, > McCathyist sense?) WTF does homosexuality have to do with this conversation? I am talking about lazy/slothful, drug/alcohol abusing, junk food eating, self- induced illiterates, techno-phobic Luddite loving lemmings. Look, i don't care how you want to live YOUR life, just leave me and my money the hell out of it! >, but in fact by the operations of the same unregulated > markets you are advocating. I am well aware of the sins of wall street and the ruling "corporate class" (Greed.inc). That is half the problem, yes. However, you cannot ignore the fact that we are spending trillions around the globe supporting degenerates. Look at Detroit MI. People like to blame GM for the state of the city but GM is only a very small part of the problem. The REAL problem is sleazy politicians and infections entitlements/welfare. When you crush the tax payers with more and more tyrannical taxation to pay for your entitlement programs, the taxpayers leave town; but the welfare recipients stay! Why the heck would they quit a good thing? However, now you find yourself in a major pickle. With the taxpayers gone, who's going to fund the entitlement programs? NOBODY! The whole house of cards comes crumbling down! Of course i'm probably just wasting my time trying to educate you. You'll just blab on and on about how evil i am for not paying other people's bills so they can watch there hero degenerates on Jersey Shore. > 3. The central fallacy of social Darwinism is the misapprehension that because > natural selection occurs in nature, human society _should_ also work this > way. I NEVER said we should adopt such a society. That is anarchy. And anarchy will NEVER move us forward as a species. > This is a failure to acknowledge the is/ought problem, and is usually > compounded (Rick is no exception) by the equally mistaken view that there exist > "superior" individuals whose possession of a "quality gene-pool" entitles them > to survival - an entitlement that is encroached upon by inferior sorts who take > up space by insisting on not dying. Can you guess in which group those who hold > this view place themselves? You'd be surprised which group i reside in. I know my place; but do you know yours? > Genetics is complicated. Switching one gene on switches others off in > unpredictable ways, people choose mates by unfathomable processes, good-looking > geniuses have dumb, ugly children and vice-versa. This is why eugenics projects > are doomed to failure. They are also morally wrong, which is another win-win. There is nothing wrong with denying degenerates the right to reproduce. Would you allow a crack head to reproduce? How about someone who carries a virus/illness/deadly defect for which there is no cure and the virus/illness/deadly defect will be passed on to the child? What if you knew without a doubt the baby would be born with two heads, or mentally incapacitated, or brain dead, or etc...? Would you allow the procreation anyway simply because people have a right to be selfish? What if the couple was healthy but had poor parenting skills, or cannot feed the child, or cannot cloth the child, or etc...? Would you allow the procreation anyway simply because people have a right to be selfish? What abut people who go around making babies but refuse to care for them at all? I mean, birth control has been around for some time, but we can't force degenerates to use it! Would you allow the procreation anyway simply because people have a right to be selfish? > If some featureless fungus, toxic to all other living things, engulfed the > globe, would that make it "superior"? Of course, not, it merely survived. I love when people contradict themselves in the same sentence -- makes my job much easier! > Considerations of what _should_ happen, of superiority and quality, are human, > social concerns. We are humans, so they are important to us. But they have > nothing to do with genetics or evolution. Really??? I think you need to spend more time ruminating on the subject. You can stick your head in the sand if you like, but technology will advance with or without you. Humans will be cloned. Humans will be genetically engineered. Humans will employ eugenics to sculpt the gene pool. It is our destiny to use our intelligence to drive our own evolution at an ever accelerating rate. To NOT use that power would be to spit in the face of evolution itself! From rantingrickjohnson at gmail.com Tue Feb 14 19:40:47 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:40:47 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> On Feb 13, 10:41?am, Tim Wintle wrote: > Imagine you go to a doctor and say "I've got the flu, can you give me > antibiotics". > > In a Private healthcare system: > > ?* The doctor gets paid for retaining a client. > ?* He is incentivised to do what you request. > ... so he gives you the antibiotics. > > In a Public healthcare system: > ?* The doctor is paid no matter what. > ?* His job is to stop the population becoming ill. > ?* By reducing illnesses he reduces his workload, without reducing his > wage > > ... so he'll only give you antibiotics if he feels you are at serious > risk, and giving you antibiotics carries less risk for the population > than the risk of the population getting immunities. Of all the great arguments i have presented you choose the minor "antibiotic comment" and run with it? But you take NO position on "supporting the degenerates of society"? Would you mind making your position known? You see, you can have all the healthcare and healthcare dollars in the world. But if your patient keeps eating greasy hamburgers, salty/oily french fries, and blood-sugar spiking soda-pops, he is going to die a nasty death! Sadly however, he will live for many years in a state of poor heath before finally "kicking the bucket". All the while draining the system of resources and money. > [...] > you can use that same argument for everything that taxes pay for - the > only logical conclusion of that argument is anarchy (i.e. no taxes, and > no government). > > If you are an anarchist then that's a different argument all together > (not saying it doesn't have intellectual validity). I am not an anarchist. Stop trying to label me. > > Healthcare is expensive. Do you want a minimum wage doctor curing your > > ills? And the frivolous lawsuits are not bringing the costs down > > either. > > It's so expensive because of the marketing, and because of all the > middle-men. You're thinking of pharmaceuticals NOT healthcare. And while marketing is a large expense for pharmaceutical companies; R&D, lawsuits, and brown-nosing are the main cost of doing buisness. > They also don't need to put up with people who aren't seriously ill - I > don't know how long your private appointments are, but here in the UK a > standard doctor's appointment is 5-10 minutes. If they decide you're > actually ill they may extend that. Five to ten minutes? Is the doctor an a-hole or a machine? Can a doctor REALLY diagnose an illness in five to ten minutes? Are you joking? And if not, do you ACTUALLY want the experience to be synonymous with an assembly line? You don't fear misdiagnosis? I envy your bravery! From rosuav at gmail.com Tue Feb 14 19:44:35 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Feb 2012 11:44:35 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 11:21 AM, Rick Johnson wrote: > On Feb 14, 2:41?am, John O'Hagan wrote: >> This is a failure to acknowledge the is/ought problem, and is usually >> compounded (Rick is no exception) by the equally mistaken view that there exist >> "superior" individuals whose possession of a "quality gene-pool" entitles them >> to survival - an entitlement that is encroached upon by inferior sorts who take >> up space by insisting on not dying. Can you guess in which group those who hold >> this view place themselves? > > You'd be surprised which group i reside in. I know my place; but do > you know yours? If you truly believe that only the best should be allowed to survive and that you are not of the best, then the logical thing to do is to immediately destroy yourself. Oddly enough, though, I don't see many eugenics proponents committing mass suicide for the benefit of the gene pool. > There is nothing wrong with denying degenerates the right to > reproduce. Actually there is; I'm fairly sure that I wouldn't have been born if such policies had been in place, and I strongly suspect that you wouldn't have either. There was a country in the 20th century that adopted a lot of the sorts of policies you're talking about, and it's such a sensitive topic with MANY people that I'm not going to touch it. Suffice it to say that the world does not appreciate such things. >> If some featureless fungus, toxic to all other living things, engulfed the >> globe, would that make it "superior"? Of course, not, it merely survived. > > I love when people contradict themselves in the same sentence -- makes > my job much easier! No, he did not contradict himself - he drew a distinction between "superior" and "survived". You might argue that your definition of "superior" *is* the ability to survive, but that's a matter for logical argument, not for pointing and laughing. > It is our destiny to use our intelligence to > drive our own evolution at an ever accelerating rate. To NOT use that > power would be to spit in the face of evolution itself! Evolution is driven by the survival of the fittest, not by us using our intelligence to influence it. It's high time I stood up for who I am. I *do* spit in the face of evolution. I do not believe that we came here because we evolved from some lesser life-form, and I do not believe that the world is best served by such philosophies. God created us, roughly 6000-10000 years ago, and since then, many things have happened (both good and bad), but never has there been the emergence of any form of "next-species human". Look at history (just recent history if you like - the last few hundred years) and find the times when one group of people deemed themselves "more evolved" than another group. Why were Negros treated as slaves in the US? Why were Australian Aboriginals treated like animals? And the one I hinted at above. If you truly believe that evolution is the way forward, then go find some of the lobbyists for these groups, and say to their faces that you believe that some humans are lesser than others. If you come out of that alive, report back. Preferably with video. It should be interesting. ChrisA From rantingrickjohnson at gmail.com Tue Feb 14 19:48:13 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 16:48:13 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> On Feb 14, 5:31?am, Duncan Booth wrote: > Rick Johnson wrote: > > BS! With free healthcare, those who would have allowed their immune > > system fight off the flu, now take off from work, visit a local > > clinic, and get pumped full of antibiotics so they can create a new > > strain of antibiotic resistant flu virus! Thanks free healthcare! > > Anyone who can write 'antibiotic resistant flu virus' as though they > believe it really needs to read some elementary books about disease. > > Here's a clue: No flu viruses are treatable with antibiotics. In some cases > antibiotics may be useful for flu patients to treat secondary bacterial > infections, but they are not effective against viruses. Duncan, your reading and comprehension skills are atrocious. Please re- read the paragraph you quoted, then spend some time "comprehending" it, then show me where i stated that "antibiotics cure viral infections". psst: i NEVER said any such thing! My point is: these "quacks" are prescribing antibiotics when people don't even need them! Such disregard for immunity is frightening. Penicillin was a gift from the gods, and we have squandered it! Thanks free healthcare! From rantingrickjohnson at gmail.com Tue Feb 14 20:26:36 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 14 Feb 2012 17:26:36 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> Message-ID: <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> On Feb 14, 6:44?pm, Chris Angelico wrote: > If you truly believe that only the best should be allowed to survive > and that you are not of the best, then the logical thing to do is to > immediately destroy yourself. Oddly enough, though, I don't see many > eugenics proponents committing mass suicide for the benefit of the > gene pool. I don't need to destroy myself Chris. Likewise i don't need to destroy anyone else. You are trying to cast me as an evil blood thirsty person, and i can assure you, i am not. All i need to do is NOT reproduce and i've done my part. Likewise all WE need to do is keep the rest "of us" from reproducing. I am not a degenerate, but my genes are flawed. All i can hope to do is make an intellectual contribution to our evolution as a species. Just because you're flawed in one area, does not mean you cannot make contributions in other areas. You can still be part of the whole -- AS LONG AS YOU UNDERSTAND YOUR PLACE! > > There is nothing wrong with denying degenerates the right to > > reproduce. > > Actually there is; I'm fairly sure that I wouldn't have been born if > such policies had been in place, and I strongly suspect that you > wouldn't have either. So what's the problem with that? > There was a country in the 20th century that > adopted a lot of the sorts of policies you're talking about, and it's > such a sensitive topic with MANY people that I'm not going to touch > it. Suffice it to say that the world does not appreciate such things. Of course people don't want to admit that they don't belong, or that they are flawed, or that they are inferior. We are "wired" with egos so that we don't purposely destroy ourselves; which is vital to our "collective" evolution, but NOT our individual evolution. However, like all software, the definitions don't always cover the corner cases. Only WE, as intelligent beings, can compensate for the missing code in our own software. Evolution is just a system. A very dumb system. We are the only hope for evolution beyond what this base system can create. We must take the reigns and drive our own evolution. > >> If some featureless fungus, toxic to all other living things, engulfed the > >> globe, would that make it "superior"? Of course, not, it merely survived. > > > I love when people contradict themselves in the same sentence -- makes > > my job much easier! > > No, he did not contradict himself - he drew a distinction between > "superior" and "survived". You might argue that your definition of > "superior" *is* the ability to survive, but that's a matter for > logical argument, not for pointing and laughing. "If" a fungus did in fact "engulf the earth", THEN it MUST be superior! > > It is our destiny to use our intelligence to > > drive our own evolution at an ever accelerating rate. To NOT use that > > power would be to spit in the face of evolution itself! > > Evolution is driven by the survival of the fittest, not by us using > our intelligence to influence it. But WE are the fittest! Because we are INTELLIGENT! > God created us, roughly 6000-10000 years ago, and since then, many > things have happened (both good and bad), but never has there been the > emergence of any form of "next-species human". Look at history (just > recent history if you like - the last few hundred years) and find the > times when one group of people deemed themselves "more evolved" than > another group. Why were Negros treated as slaves in the US? Because they allowed themselves to be subjected. Sad, but true. > Why were > Australian Aboriginals treated like animals? Because they allowed them selves to be subjected. Sad, but true. > And the one I hinted at > above. Because the Jews allowed themselves to be subjected. Sad, but true. Slaves only exist because they allow themselves to exist. When people fight back against tyranny, tyranny fails. When people subject themselves to tyranny, tyranny prospers. There have been many instances in history where people did not allow themselves to be subjected; William Wallace comes to mind. "Freeeeeedoooooooommmmmmm!" "Live free, or die!" "From my cold dead hand!" "Over my dead body!" "Freedom is never voluntarily given by the oppressor; it must be demanded by the oppressed." "Those who deny freedom to others deserve it not for themselves." "Man is free at the moment he wishes to be." "Those who desire to give up freedom in order to gain security, will not have, nor do they deserve, either one." From rosuav at gmail.com Tue Feb 14 20:32:54 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 15 Feb 2012 12:32:54 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 11:48 AM, Rick Johnson wrote: > Duncan, your reading and comprehension skills are atrocious. Please re- > read the paragraph you quoted, then spend some time "comprehending" > it, then show me where i stated that "antibiotics cure viral > infections". psst: i NEVER said any such thing! I'm not sure how you'd go about creating a new strain of a virus that's resistant to antibiotics, unless the previous strain was NOT resistant. Viruses are _immune_ to antibiotics, and as we know from Angband, immunity equals resistance times ten. ChrisA From jeanpierreda at gmail.com Tue Feb 14 20:43:05 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 14 Feb 2012 20:43:05 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <4F3AA287.9070604@mrabarnett.plus.com> References: <4F3AA287.9070604@mrabarnett.plus.com> Message-ID: On Tue, Feb 14, 2012 at 1:05 PM, MRAB wrote: >> And yeah, even something as crazy as ()* works, but as soon as it >> becomes (a*)* it doesn't work. Weird. >> > I think it's a combination of warning the user about something that's > pointless, > as in the case of "$*", and producing a pattern which could cause the > internal > regex engine to get stuck in an infinite loop. Considering that ()* works fine, I can't imagine it ever gets stuck in infinite loops. But I admit I am too lazy to check against the interpreter. Also, complete failure is an exceptionally (heh) poor way of warning people about stuff. I hope that's not really it. -- Devin From dllizheng at gmail.com Tue Feb 14 20:46:48 2012 From: dllizheng at gmail.com (Zheng Li) Date: Wed, 15 Feb 2012 10:46:48 +0900 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <20120214095223.GA1107@cskk.homeip.net> References: <9150D72E-0014-4D45-A7C2-758D7BE5F3CD@gmail.com> <20120214095223.GA1107@cskk.homeip.net> Message-ID: thank you. I know the second way works. but in my case, i need "method1" to be a class method, because I use it to create an object. I have a lot of classes that have "__init__" with 2 arguments -- self, and user id. usually, "SomeClass(user_id)" is used to create an object of "SomeClass", but if "SomeClass" has a class method named "method1", "method1" will be used to finish the job. and i get it. the context is useful. On 2012/02/14, at 18:52, Cameron Simpson wrote: > On 14Feb2012 13:13, Zheng Li wrote: > | > On 13Feb2012 15:59, Zheng Li wrote: > | > | how to tell a method is class method or static method or instance method? > | > > | > Maybe a better question is: > | > under what circumstances do you need to figure this out? > | > | I can get "method1" of class "Test" by > | a = getattr(Test, "method1") > | > | and I also want know how to invoke it > | a() or a(Test()) > > Normally: > > a(T) > > where T is an object of type/class Test. So your second approach is > notionally correct (aside from making a throwaway object that is then > discarded). > > | BTW: > | I don't see what the problem is if I ask a question just because I am curious about it. > > There's nothing wrong with it at all. > > But often, questions arise from some other circumstances and this one is > of such a flavour that if you wanted this code in a real application it > would _often_ be the wrong solution to seek, because normally you know > how to call something - it is not normally useful to introspect it to > decide what to do. > > So I was wondering what the outer context might be, because there may > well have been a better solution to the situation that brought up the > specific question. > > Simple curiosity is sufficient reason, of course. > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Too young to rest on the weekend, too old to rest during the week. > - Mark Randol From python at mrabarnett.plus.com Tue Feb 14 21:08:57 2012 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 15 Feb 2012 02:08:57 +0000 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: References: <4F3AA287.9070604@mrabarnett.plus.com> Message-ID: <4F3B13B9.2010108@mrabarnett.plus.com> On 15/02/2012 01:43, Devin Jeanpierre wrote: > On Tue, Feb 14, 2012 at 1:05 PM, MRAB > wrote: >>> And yeah, even something as crazy as ()* works, but as soon as >>> it becomes (a*)* it doesn't work. Weird. >>> >> I think it's a combination of warning the user about something >> that's pointless, as in the case of "$*", and producing a pattern >> which could cause the internal regex engine to get stuck in an >> infinite loop. > > Considering that ()* works fine, I can't imagine it ever gets stuck > in infinite loops. But I admit I am too lazy to check against the > interpreter. > > Also, complete failure is an exceptionally (heh) poor way of warning > people about stuff. I hope that's not really it. > There is one place in the re engine where it tries to avoid getting stuck in an infinite loop because of a zero-width match, but the fix inadvertently causes another bug. It's described in issue #1647489. From chaoliu08 at gmail.com Tue Feb 14 23:10:53 2012 From: chaoliu08 at gmail.com (Chao Liu) Date: Wed, 15 Feb 2012 12:10:53 +0800 Subject: Problem in PNG2BMP Message-ID: Hi, everyone, I have a PNG file, and I need to convert it to BMP file. I use, import PIL from PIL import Image im = Image.open('a.png') im.save(?a.bmp?) It works in Python 2.6 with PIL 1.1.7, But when I use Python 2.4, the error occured, File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1439, in save save_handler(self, fp, filename) File "C:\Python24\Lib\site-packages\PIL\BmpImagePlugin.py", line 242, in _save ImageFile._save(im, fp, [("raw", (0,0)+im.size, 0, (rawmode, stride, -1))]) File "C:\Python24\Lib\site-packages\PIL\ImageFile.py", line 499, in _save s = e.encode_to_file(fh, bufsize) IOError: (0, 'Error') I'm wondering if anyone can help me. Thanks Chao Liu -------------- next part -------------- An HTML attachment was scrubbed... URL: From shootgun654 at gmail.com Wed Feb 15 00:34:42 2012 From: shootgun654 at gmail.com (Gun shoot) Date: Tue, 14 Feb 2012 21:34:42 -0800 (PST) Subject: E PUB AND DATA ENTRY SERVICES Message-ID: E PUB AND DATA ENTRY SERVICES AVAILABLE HERE http://www.wincon.in/ From dihedral88888 at googlemail.com Wed Feb 15 02:13:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 14 Feb 2012 23:13:16 -0800 (PST) Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL Message-ID: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> After my testing of JAVA, PYTHON, VB, C-sharp and Erlang like script languages, I noticed that script languages should be timed after the shell interpreter completed loaded. The start up loading time of script interpreters should be excluded in the measure of executing a byte code script. This also explains why C-executables are fast in manny testing programs of various languages to out beat all interpreter loading languages. But I computed the Euler'of s number for tens of thousands of digitsunder different shells , then I was able to check the speed issues of various computer languages. My question is whether a lot speed testings of computer languages are done in a biased way toward script languages to be slow? From timr at probo.com Wed Feb 15 02:18:55 2012 From: timr at probo.com (Tim Roberts) Date: Tue, 14 Feb 2012 23:18:55 -0800 Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> Message-ID: <01nmj7pjer6953dve0t62av3s2floc85q6@4ax.com> sturlamolden wrote: > >There are bigsimilarities between Python and the new C++ standard. Now >we can actually use our experience as Python programmers to write >fantastic C++ :-) This is more true than you might think. For quite a few years now, I've been able to do an almost line-for-line translation of my Python programs to C++ programs. (Microsoft has had a "for each" extension for a while that made this easier.) -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From research at johnohagan.com Wed Feb 15 03:56:23 2012 From: research at johnohagan.com (John O'Hagan) Date: Wed, 15 Feb 2012 19:56:23 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <20120215195623.f5666a26e374e8fdd8d54a71@johnohagan.com> On Tue, 14 Feb 2012 17:26:36 -0800 (PST) Rick Johnson wrote: > On Feb 14, 6:44?pm, Chris Angelico wrote: > > But WE are the fittest! Because we are INTELLIGENT! And the whales say: But WE are the fittest! Because we are BIG! And the rabbits say: But WE are the fittest! Because we are FERTILE! And the snakes say: But WE are the fittest! Because we are VENOMOUS! (Apologies to all animals mentioned for ascribing to them gratuitous capitalisation and exclamation marks.) Please read Darwin. He explicitly defined "fittest", in the context of evolutionary science, to mean sufficiently well-adapted to immediate local conditions to be able to reproduce. There is nothing generalisable about this. Intelligence is only useful in human ecological niches; and if the world were underwater you would gladly swap it for gills. But I don't think you'll read Darwin, or any real science on the subject. You'll cling to your popular-science cartoon version of evolution because you need it to support your false, odious worldview, which finally emerges from the swamp: > > Why were Negros treated as slaves in the US? > > Because they allowed themselves to be subjected. Sad, but true. > > > Why were > > Australian Aboriginals treated like animals? > > Because they allowed them selves to be subjected. Sad, but true. > > > And the one I hinted at > > above. > > Because the Jews allowed themselves to be subjected. Sad, but true. You have just demonstrated that you are the worst kind of racist. Not only have you blamed the victim on a truly monstrous scale, you have assigned blame not to individuals, but to entire "races". You are saying that something inherent in each race caused them to "allow" their own subjugation. Calling it "sad" does not get you off the hook. Your cover was always thin but now it's blown. From hfaber at invalid.net Wed Feb 15 03:58:41 2012 From: hfaber at invalid.net (Henrik Faber) Date: Wed, 15 Feb 2012 09:58:41 +0100 Subject: Python vs. C++11 References: <2ad83c4d-bafe-4a96-a846-c467cd30c98d@p21g2000yqm.googlegroups.com> <01nmj7pjer6953dve0t62av3s2floc85q6@4ax.com> Message-ID: On 15.02.2012 08:18, Tim Roberts wrote: > sturlamolden wrote: >> >> There are bigsimilarities between Python and the new C++ standard. Now >> we can actually use our experience as Python programmers to write >> fantastic C++ :-) > > This is more true than you might think. For quite a few years now, I've > been able to do an almost line-for-line translation of my Python programs > to C++ programs. (Microsoft has had a "for each" extension for a while > that made this easier.) I disagree. Unicode support comes for free with Python3+ while C++ it still is a piece of crap (or something that you'll have to pass to external libraries). The C++ standard library is nowhere nearly as densely packed with features than Python's. For every little thing you need some external dependencies. Language semantics aren't enough to translate one language into another. Best regards, Henrik From duncan.booth at invalid.invalid Wed Feb 15 04:47:40 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Feb 2012 09:47:40 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: Rick Johnson wrote: > On Feb 14, 5:31?am, Duncan Booth wrote: >> Rick Johnson wrote: >> > BS! With free healthcare, those who would have allowed their immune >> > system fight off the flu, now take off from work, visit a local >> > clinic, and get pumped full of antibiotics so they can create a new >> > strain of antibiotic resistant flu virus! Thanks free healthcare! >> >> Anyone who can write 'antibiotic resistant flu virus' as though they >> believe it really needs to read some elementary books about disease. >> >> Here's a clue: No flu viruses are treatable with antibiotics. In some >> cas > es >> antibiotics may be useful for flu patients to treat secondary >> bacterial infections, but they are not effective against viruses. > > Duncan, your reading and comprehension skills are atrocious. Please > re- read the paragraph you quoted, then spend some time > "comprehending" it, then show me where i stated that "antibiotics cure > viral infections". psst: i NEVER said any such thing! Rick, your reading and comprehension skills are atrocious. Please re-read the paragraph you quoted, then spend some time "comprehending" it, then show me where I stated that you '''stated that "antibiotics cure viral infections"'''. I never said any such thing. -- Duncan Booth http://kupuguy.blogspot.com From as at sci.fi Wed Feb 15 04:56:12 2012 From: as at sci.fi (Anssi Saari) Date: Wed, 15 Feb 2012 11:56:12 +0200 Subject: Python usage numbers References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: Matej Cepl writes: > Slightly less flameish answer to the question ?What should I do, > really?? is a tough one: all these suggested answers are bad because > they don?t deal with the fact, that your input data are obviously > broken. The rest is just pure GIGO ? Well, sure, but it happens that input data is broken and not fixable. For example, I did a little program to display email headers like the old frm that was bundled with elm, only with support for MIME decoding of the headers. Obviously lots of email software is still completely broken regarding MIME and also multi-line headers. However, something useful can still be extracted from that broken data. > BTW, can you display the following line? > > P??li? ?lu?ou?k? k?? ?p?l ??belsk? ?dy. Looks fine to me. You used an ellipsis too above. Well, I don't know what it shold look like exactly. Lots of accents. Hmm, Google says it means "The quick brown fox cried too lazy"? Seems appropriate :) BTW, I'm sending this via Usenet, I wonder what happens in the mail-news gateway? From arnodel at gmail.com Wed Feb 15 04:58:06 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 15 Feb 2012 09:58:06 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: On 15 February 2012 09:47, Duncan Booth wrote: > Rick Johnson wrote: [...] Perhaps it's a bit presumptuous of me but... It's tempting to react to his inflammatory posts, but after all Rick is a troll and experience shows that trolls are best left alone. Also, please spare a thought for all of us who have him in our killfiles. -- Arnaud From duncan.booth at invalid.invalid Wed Feb 15 05:04:34 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Feb 2012 10:04:34 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > On 15 February 2012 09:47, Duncan Booth > wrote: >> Rick Johnson wrote: > [...] > > Perhaps it's a bit presumptuous of me but... > > It's tempting to react to his inflammatory posts, but after all Rick > is a troll and experience shows that trolls are best left alone. > Also, please spare a thought for all of us who have him in our > killfiles. > Yes, sorry about that. Actually, I thought it was a bit weird that I saw ChrisA's comment but not the message he was commenting on until I went and looked for it. I read this group on a couple of machines and it looks like Rick's killfile entry had expired on the other but not this one. Next time I'm back on the other machine I'll try to remember to sort out the killfile. -- Duncan Booth http://kupuguy.blogspot.com From steve+comp.lang.python at pearwood.info Wed Feb 15 05:27:01 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Feb 2012 10:27:01 GMT Subject: Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> Message-ID: <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 10:04:34 +0000, Duncan Booth wrote: > Actually, I thought it was a bit weird that I saw ChrisA's comment but > not the message he was commenting on until I went and looked for it. I > read this group on a couple of machines and it looks like Rick's > killfile entry had expired on the other but not this one. Next time I'm > back on the other machine I'll try to remember to sort out the killfile. Yes, I have this problem too. I'm reluctant to killfile people forever, call me a sucker if you like, but I'm willing to give people second chances (and apparently third and fourth and fifth chances). Methinks it's time for Monsieur Johnson to go back in the killfile. -- Steven From andrea.crotti.0 at gmail.com Wed Feb 15 08:12:06 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 13:12:06 +0000 Subject: atexit.register in case of errors Message-ID: <4F3BAF26.2060505@gmail.com> I have the following very simplified situation from atexit import register def goodbye(): print("saying goodbye") def main(): while True: var = raw_input("read something") if __name__ == '__main__': register(goodbye) main() But in my case the "goodbye" function is deleting the logging file which was created during the application execution. Now the problem is that it *always* executes, even when the applications quits for some bad errors. Is there a way to have an exit hook, which doesn't execute in case of errors? I've seen the code of atexit and it apparently doesn't know anything about the current status and why the application is actually quitting, is that correct? From mwilson at the-wire.com Wed Feb 15 08:33:51 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Wed, 15 Feb 2012 08:33:51 -0500 Subject: atexit.register in case of errors References: Message-ID: Andrea Crotti wrote: > I have the following very simplified situation > > from atexit import register > > > def goodbye(): > print("saying goodbye") > > > def main(): > while True: > var = raw_input("read something") > > > if __name__ == '__main__': > register(goodbye) > main() > > > But in my case the "goodbye" function is deleting the logging file which > was created > during the application execution. > Now the problem is that it *always* executes, even when the applications > quits for > some bad errors. > > Is there a way to have an exit hook, which doesn't execute in case of > errors? > I've seen the code of atexit and it apparently doesn't know anything > about the current > status and why the application is actually quitting, is that correct? That's sort of the point: to do things that simply *have* to happen, even if you've lost control of the program. The usual way to do what you're asking is if __name__ == '__main__': main() goodbye() and write main so that it returns after it's done all the things it's supposed to do. If you've sprinkled `sys.exit()` all over your code, then don't do that. If you're forced to deal with a library that hides `sys.exit()` calls in the functions, then you have my sympathy. Library authors should not do that, and there have been threads on c.l.p explaining why they shouldn't. Mel. From jeanpierreda at gmail.com Wed Feb 15 08:43:37 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 15 Feb 2012 08:43:37 -0500 Subject: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? In-Reply-To: <4F3B13B9.2010108@mrabarnett.plus.com> References: <4F3AA287.9070604@mrabarnett.plus.com> <4F3B13B9.2010108@mrabarnett.plus.com> Message-ID: On Tue, Feb 14, 2012 at 9:08 PM, MRAB wrote: > There is one place in the re engine where it tries to avoid getting > stuck in an infinite loop because of a zero-width match, but the fix > inadvertently causes another bug. It's described in issue #1647489. Just read the issue. Interesting, didn't know that was a bug rather than deliberate behavior. The other behavior (only match empty space once) makes more sense though. Thanks for linking. Still, that's for avoiding infinite loops in finditer/findall, not match/search :S -- Devin From jeanpierreda at gmail.com Wed Feb 15 08:52:21 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 15 Feb 2012 08:52:21 -0500 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: > The usual way to do what you're asking is > > if __name__ == '__main__': > ? ?main() > ? ?goodbye() > > and write main so that it returns after it's done all the things it's > supposed to do. ?If you've sprinkled `sys.exit()` all over your code, then > don't do that. ?If you're forced to deal with a library that hides > `sys.exit()` calls in the functions, then you have my sympathy. ?Library > authors should not do that, and there have been threads on c.l.p explaining > why they shouldn't. In such a case. one can do:: if __name__ == '__main__': try: main() except SystemExit: pass goodbye() -- Devin From pgiri at yahoo.com Wed Feb 15 09:06:17 2012 From: pgiri at yahoo.com (Giridhar Pemmasani) Date: Wed, 15 Feb 2012 06:06:17 -0800 (PST) Subject: [ANN]: Python module to distribute computations for parallel execution Message-ID: <1329314777.16003.YahooMailNeo@web160605.mail.bf1.yahoo.com> Hello, I would like to announce dispy (http://dispy.sourceforge.net), a python framework for distributing computations for parallel execution to processors/cores on single node to many nodes over the network. The computations can be python functions or programs. If there are any dependencies, such as other python functions, modules, classes, objects or files, they are also distributed as well. The results of each computation, output, error messages and exception trace, if any, are made available to client program for further processing. Popular map/reduce style programs can be easily developed and deployed with dispy. There is also an implementation of dispy, called discopy, that uses asynchronous I/O and coroutines, so that discopy will scale efficiently for large number of network connections (right now this is a bit academic, until it has been tested with such setups). The framework with asynchronous I/O and coroutines, called asyncoro, is independent of dispy - discopy is an implementation of dispy using asyncoro. Others may find asyncoro itself useful. Salient features of dispy/discopy are: ? * Computations (python functions or standalone programs) and its ? ? dependencies (files, python functions, classes, modules) are ? ? distributed automatically. ? * Computation nodes can be anywhere on the network (local or ? ? remote). For security, either simple hash based authentication or ? ? SSL encryption can be used. ? * A computation may specify which nodes are allowed to execute it ? ? (for now, using simple patterns of IP addresses). ? * After each execution is finished, the results of execution, ? ? output, errors and exception trace are made available for further ? ? processing. ? * If callback function is provided, dispy executes that function ? ? when a job is finished; this feature is useful for further ? ? processing of job results. ? * Nodes may become available dynamically: dispy will schedule jobs ? ? whenever a node is available and computations can use that node. ? * Client-side and server-side fault recovery are supported: ? ? If user program (client) terminates unexpectedly (e.g., due to ? ? uncaught exception), the nodes continue to execute scheduled jobs. ? ? If client-side fault recover option is used when creating a cluster, ? ? the results of the scheduled (but unfinished at the time of crash) ? ? jobs for that cluster can be easily retrieved later. ? ? If a computation is marked re-entrant (with 'resubmit=True' option) ? ? when a cluster is created and a node (server) executing jobs for ? ? that computation fails, dispy automatically resubmits those jobs ? ? to other available nodes. ? * In optimization problems it is useful for computations to send ? ? (successive) provisional results back to the client, so it can, ? ? for example,?terminate computations. If computations are python ? ? functions, they can use 'dispy_provisional_result' function for ? ? this purpose. ? * dispy can be used in a single process to use all the nodes ? ? exclusively (with JobCluster - simpler to use) or in multiple ? ? processes simultaneously sharing the nodes (with ShareJobCluster ? ? and dispyscheduler). dispy works with python 2.7. It has been tested on Linux, Mac OS X and known to work with Windows. discopy has been tested on Linux and Mac OS X. I am not subscribed to the list, so please Cc me if you have comments. Cheers, Giri -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Wed Feb 15 09:35:33 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 14:35:33 +0000 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <4F3BC2B5.4090901@gmail.com> On 02/15/2012 01:52 PM, Devin Jeanpierre wrote: > On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: >> The usual way to do what you're asking is >> >> if __name__ == '__main__': >> main() >> goodbye() >> >> and write main so that it returns after it's done all the things it's >> supposed to do. If you've sprinkled `sys.exit()` all over your code, then >> don't do that. If you're forced to deal with a library that hides >> `sys.exit()` calls in the functions, then you have my sympathy. Library >> authors should not do that, and there have been threads on c.l.p explaining >> why they shouldn't. > In such a case. one can do:: > > if __name__ == '__main__': > try: > main() > except SystemExit: > pass > goodbye() > > -- Devin Makes perfect sense, I solved like this then, thanks From lists.eckel at gmail.com Wed Feb 15 09:58:43 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 15 Feb 2012 06:58:43 -0800 (PST) Subject: Automatic Type Conversion to String References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: > Could it be that you missed the fact that strings are immutable? That > means that you can't change the content of the object once it is > initialized. In particular, it means that you e.g. have to override > __new__ instead of __init__, because the content is already fixed when > the latter is called. > > Uli Yes, that's what I missed, and it explains why I found examples of str inheritance using __new__. I think this might end up being a puzzle I poke at for awhile. Also, I discovered that the attempt to create a "Path" class goes back to 2006, where it created a lot of discussion and was finally shelved: http://www.python.org/dev/peps/pep-0355/ A significant part of the problem seems to be that there was no inheritance from str at the time, so maybe a lot of the issues they ran into could be solved now. From rantingrickjohnson at gmail.com Wed Feb 15 10:04:23 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Feb 2012 07:04:23 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> On Feb 15, 2:56?am, John O'Hagan wrote: > You have just demonstrated that you are the worst kind of racist. Not only have > you blamed the victim on a truly monstrous scale, you have assigned blame not to > individuals, but to entire "races". Your tabloid sensationalism is the worst i've seen. You'll jump at any chance to tag someone a racist, homophobic, sexist, or any other kind of hate group you can muster in a weak attempt to win an argument you cannot win by spewing ad hominem attacks. You cannot stay on subject because your argument is baseless and mine is the backed by truth. Just in case you have forgotten, here is the main point: "degenerates are a drain on healthcare/society". Can you counter that argument with a fact and prove they are not? The only winning argument is that "degenerates pay their own medical bills"... but as you and i know, most degenerates DON'T pay their own medical bills. They expect US to pay them. > You are saying that something inherent in > each race caused them to "allow" their own subjugation. I have PROVEN that when people FIGHT back, they will NOT be subjects to tyranny; race has NOTHING to do with it. I gave one example in history where people would rather die than be subjected to tyranny, there are many more. "GIVE ME FREEDOM FOR GIVE ME DEATH!" The world is full of evil people who seek to force their fellow man into slavery. Those who refuse to fight for freedom will be victims, on the other hand, those who are willing to sacrifice ALL in the name of freedom will be free men. 300: "Go now! Run along and tell your Xerxes he faces free men here, not slaves! Do it quickly, before we decide to make our wall just a little bit bigger." John, I have grown weary of educating you. Go back to your day job writing op-eds for the National Inquirer and News of the World; they love this vile sensationalist crap! Goodnight "John boy". From breamoreboy at yahoo.co.uk Wed Feb 15 10:18:07 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 15:18:07 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: On 15/02/2012 15:04, Rick Johnson wrote: > On Feb 15, 2:56 am, John O'Hagan wrote: > John, I have grown weary of educating you. Go back to your day job > writing op-eds for the National Inquirer and News of the World; they > love this vile sensationalist crap! Goodnight "John boy". The News of the Screws closed months ago. As you didn't answer my question from some days back I'll ask it agin. Please explain why previously healthy people get struck down with Common Fatigue Syndrome amongst other things. -- Cheers. Mark Lawrence. From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Wed Feb 15 10:18:30 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Wed, 15 Feb 2012 16:18:30 +0100 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: Am 15.02.2012 14:52 schrieb Devin Jeanpierre: > On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: >> The usual way to do what you're asking is >> >> if __name__ == '__main__': >> main() >> goodbye() >> >> and write main so that it returns after it's done all the things it's >> supposed to do. If you've sprinkled `sys.exit()` all over your code, then >> don't do that. If you're forced to deal with a library that hides >> `sys.exit()` calls in the functions, then you have my sympathy. Library >> authors should not do that, and there have been threads on c.l.p explaining >> why they shouldn't. > > In such a case. one can do:: > > if __name__ == '__main__': > try: > main() > except SystemExit: > pass > goodbye() > > -- Devin Wouldn't if __name__ == '__main__': try: main() finally: goodbye() be even better? Or doesn't it work well together with SystemExit? Thomas From andrea.crotti.0 at gmail.com Wed Feb 15 10:41:12 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Wed, 15 Feb 2012 15:41:12 +0000 Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <4F3BD218.8000701@gmail.com> On 02/15/2012 03:18 PM, Thomas Rachel wrote: > > Wouldn't > > if __name__ == '__main__': > try: > main() > finally: > goodbye() > > be even better? Or doesn't it work well together with SystemExit? > > > Thomas Well in that case goodbye is always called, even if I have some other nasty exception, which is not what I want.. (and is exactly what I had with atexit.register). Isn't it? From breamoreboy at yahoo.co.uk Wed Feb 15 11:04:27 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 16:04:27 +0000 Subject: Interactive keyword help Message-ID: I didn't realise that this was available until today. It doesn't appear to be prominent in the official docs or have I missed something? Certainly I'd have thought a couple of sentences here http://www.python.org/about/help/ would be justified, what do y'all think? -- Cheers. Mark Lawrence. From rantingrickjohnson at gmail.com Wed Feb 15 11:27:08 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 15 Feb 2012 08:27:08 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> On Feb 15, 9:18?am, Mark Lawrence wrote: > As you didn't answer my question from some days back I'll ask it agin. > Please explain why previously healthy people get struck down with Common > Fatigue Syndrome amongst other things. Why do you seek my counsel regarding medical ailments? Do you believe i have special knowledge in the field? But more importantly: how is your question germane to the "destruction of healthcare" and "expansion of tyranny" by the degenerates of society; or by those who support degeneracy by engaging in "degenerate eugenics"? Was your question meant as rhetorical? Or merely yet ANOTHER crude attempt to employ sophistry in hopes of coercing the less astute folks among us to hop in your "clown car of delirium" and head-off down ANOTHER path to that leads to logical fallacy? Stay on subject! From ian.g.kelly at gmail.com Wed Feb 15 11:46:34 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 09:46:34 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> Message-ID: On Wed, Feb 15, 2012 at 8:04 AM, Rick Johnson wrote: > I have PROVEN that when people FIGHT back, they will NOT be subjects > to tyranny; race has NOTHING to do with it. I gave one example in > history where people would rather die than be subjected to tyranny, > there are many more. "GIVE ME FREEDOM FOR GIVE ME DEATH!" > > The world is full of evil people who seek to force their fellow man > into slavery. Those who refuse to fight for freedom will be victims, > on the other hand, those who are willing to sacrifice ALL in the name > of freedom will be free men. > > 300: "Go now! Run along and tell your Xerxes he faces free men here, > not slaves! Do it quickly, before we decide to make our wall just a > little bit bigger." If you get all your history from Hollywood, then no wonder you are so badly misinformed. Braveheart and 300 are inspiring movies to be sure, but they are also highly fictionalized. In the real world, the execution of William Wallace actually succeeded in quelling the Scottish rebellion for a time -- when Robert the Bruce started it up again half a year later, his motives were entirely political in nature (he had murdered a rival in a church and been excommunicated; his options were to place himself on the throne or become a fugitive), not out of some noble sense of guilt or duty to Wallace or desire for freedom as depicted in the film. Your statement that the Africans brought to America allowed themselves to be enslaved is simply false. There were dozens of slave rebellions in the United States prior to the Civil War. Most of them failed and ended in the executions of the rebels. You won't see Hollywood making too many movies about those, which is probably why you don't know anything about them. From breamoreboy at yahoo.co.uk Wed Feb 15 12:16:19 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 17:16:19 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <4b4d07e0-f4b8-45f3-bb2a-0ec2d27e205d@b23g2000yqn.googlegroups.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <545b1a0c-130e-4629-ab90-0537f377e1c3@m24g2000yqb.googlegroups.com> <9fc20830-cd21-4f1d-900f-8e259895abae@p7g2000yqk.googlegroups.com> Message-ID: On 15/02/2012 16:27, Rick Johnson wrote: > On Feb 15, 9:18 am, Mark Lawrence wrote: >> As you didn't answer my question from some days back I'll ask it agin. >> Please explain why previously healthy people get struck down with Common >> Fatigue Syndrome amongst other things. > > Why do you seek my counsel regarding medical ailments? Do you believe > i have special knowledge in the field? But more importantly: how is > your question germane to the "destruction of healthcare" and > "expansion of tyranny" by the degenerates of society; or by those who > support degeneracy by engaging in "degenerate eugenics"? > > Was your question meant as rhetorical? Or merely yet ANOTHER crude > attempt to employ sophistry in hopes of coercing the less astute folks > among us to hop in your "clown car of delirium" and head-off down > ANOTHER path to that leads to logical fallacy? > > Stay on subject! I don't seek your counsel on anything. You set the ball rolling and I quote "If you can't afford healthcare, then you die." and "You want to solve the healthcare problem then STOP TREATING PEOPLE WHO DON'T HAVE INSURANCE!" You later went on to say and I again quote "Healthy people do not need healthcare very often, and in the rare cases when they do, they don't bog down the system because their bodies are strong. Why are their bodies strong? Because healthy people eat correctly, healthy people exercise, therefore, healthy people have correctly functioning immune systems -- of course quality genes always help!" The question was originally put in response to that, so you've resorted to your usual tactics of spewing ad hominem attacks on anybody who dares to challenge you in any way, shape or form. If I were you I'd stick to things that you understand, like downloading workable help files. But oh dear, you can't even manage that, you simply moan like hell because the help file you had didn't work correctly. Or IDLE is crap. Or ... -- Cheers. Mark Lawrence. From bahamutzero8825 at gmail.com Wed Feb 15 12:23:20 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 15 Feb 2012 11:23:20 -0600 Subject: Interactive keyword help In-Reply-To: References: Message-ID: <4F3BEA08.9010001@gmail.com> On 2/15/2012 10:04 AM, Mark Lawrence wrote: > I didn't realise that this was available until today. It doesn't appear > to be prominent in the official docs or have I missed something? > Certainly I'd have thought a couple of sentences here > http://www.python.org/about/help/ would be justified, what do y'all think? > help() is a built-in function, not a keyword. http://docs.python.org/library/functions.html#help http://docs.python.org/py3k/library/functions.html#help -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From arnodel at gmail.com Wed Feb 15 12:27:57 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Wed, 15 Feb 2012 17:27:57 +0000 Subject: Interactive keyword help In-Reply-To: <4F3BEA08.9010001@gmail.com> References: <4F3BEA08.9010001@gmail.com> Message-ID: On 15 February 2012 17:23, Andrew Berg wrote: > On 2/15/2012 10:04 AM, Mark Lawrence wrote: >> I didn't realise that this was available until today. ?It doesn't appear >> to be prominent in the official docs or have I missed something? >> Certainly I'd have thought a couple of sentences here >> http://www.python.org/about/help/ would be justified, what do y'all think? >> > help() is a built-in function, not a keyword. I think he's referring to help *on* keywords, e.g. >>> help('yield') -- Arnaud From breamoreboy at yahoo.co.uk Wed Feb 15 12:36:56 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 17:36:56 +0000 Subject: Interactive keyword help In-Reply-To: References: <4F3BEA08.9010001@gmail.com> Message-ID: On 15/02/2012 17:27, Arnaud Delobelle wrote: > On 15 February 2012 17:23, Andrew Berg wrote: >> On 2/15/2012 10:04 AM, Mark Lawrence wrote: >>> I didn't realise that this was available until today. It doesn't appear >>> to be prominent in the official docs or have I missed something? >>> Certainly I'd have thought a couple of sentences here >>> http://www.python.org/about/help/ would be justified, what do y'all think? >>> >> help() is a built-in function, not a keyword. > > I think he's referring to help *on* keywords, e.g. > >>>> help('yield') > Correct. -- Cheers. Mark Lawrence. From Tim.Arnold at sas.com Wed Feb 15 12:48:13 2012 From: Tim.Arnold at sas.com (Tim Arnold) Date: Wed, 15 Feb 2012 12:48:13 -0500 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: On 2/13/2012 6:20 AM, Matej Cepl wrote: > Hi, > > I am getting more and more discouraged from using XSLT for a > transformation from one XML scheme to another one. Does anybody could > share any experience with porting moderately complicated XSLT stylesheet > (https://gitorious.org/sword/czekms-csp_bible/blobs/master/CEP2OSIS.xsl) > into a Python script using ElementTree's interparse or perhaps xml.sax? > > Any tools for this? Speed differences (currently I am using xsltproc)? > Any thoughts? > > Thank you, > > Mat?j Just a note to encourage you to stick with XSLT. I also use lxml for creating and postprocessing my DocBook documents and it is great. But I use the DocBook XSL stylesheets to convert to html; if you're like me, you got discouraged at the strangeness of the XSLT language. I'm no expert with it by any means, but I'm amazed at some of the things it does. It is a great tool to add to your programming toolbox. Also, I used xsltproc for a while but bogged down in processing time. Now I use SAXON which is much faster for my documents. Good luck, --Tim From franck at ditter.org Wed Feb 15 13:20:21 2012 From: franck at ditter.org (Franck Ditter) Date: Wed, 15 Feb 2012 19:20:21 +0100 Subject: Complexity question on Python 3 lists Message-ID: What is the cost of calling primes(n) below ? I'm mainly interested in knowing if the call to append is O(1), even amortized. Do lists in Python 3 behave like ArrayList in Java (if the capacity is full, then the array grows by more than 1 element) ? def sdiv(n) : # n >= 2 """returns the smallest (prime) divisor of n""" if n % 2 == 0 : return 2 for d in range(3,int(sqrt(n))+1,2) : if n % d == 0 : return d return n def isPrime(n) : """Returns True iff n is prime""" return n >= 2 and n == sdiv(n) def primes(n) : # n >= 2 """Returns the list of primes in [2,n]""" res = [] for k in range(2,n+1) : if isPrime(k) : res.append(k) # cost O(1) ? return res Thanks, franck From nad at acm.org Wed Feb 15 13:21:53 2012 From: nad at acm.org (Ned Deily) Date: Wed, 15 Feb 2012 19:21:53 +0100 Subject: Automatic Type Conversion to String References: <090e2893-7a1c-4b11-9e45-974ed33e7b77@i18g2000yqf.googlegroups.com> Message-ID: In article , Bruce Eckel wrote: > Also, I discovered that the attempt to create a "Path" class goes back > to 2006, where it created a lot of discussion and was finally shelved: > http://www.python.org/dev/peps/pep-0355/ > > A significant part of the problem seems to be that there was no > inheritance from str at the time, so maybe a lot of the issues they > ran into could be solved now. You might want to take a look at pathlib, a current attempt at providing object-oriented paths, written by Antoine Pitrou, one of the Python core developers: http://pypi.python.org/pypi/pathlib -- Ned Deily, nad at acm.org From nathan.alexander.rice at gmail.com Wed Feb 15 13:31:44 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 15 Feb 2012 13:31:44 -0500 Subject: how to tell a method is classmethod or static method or instance method In-Reply-To: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> References: <4f38c3cc$0$11112$c3e8da3@news.astraweb.com> Message-ID: > And I'll take this opportunity to plug my dualmethod descriptor: > > http://code.activestate.com/recipes/577030-dualmethod-descriptor/ I use an analogous pattern in SQL Alchemy all the time (it's called hybridmethod/hybridproperty there). +1 to dualmethod, that pattern is great when you want a method or property that does something concrete when passed an instance, or something abstract relating to all instances when passed a class. Nathan From clp2 at rebertia.com Wed Feb 15 13:35:25 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 10:35:25 -0800 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 10:20 AM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? Yes. Python lists aren't linked lists. list.append() resizes the underlying array intelligently to give O(1) performance, although I can't find any guarantee of this in the docs, but it is true in practice for all major Python implementations. Cheers, Chris From miki.tebeka at gmail.com Wed Feb 15 13:36:26 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:36:26 -0800 (PST) Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> Message-ID: <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. On a site note: ALL CAPS is considered shouting, please don't use that in news groups. From miki.tebeka at gmail.com Wed Feb 15 13:40:00 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:40:00 -0800 (PST) Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <16963932.42.1329331200261.JavaMail.geo-discussion-forums@ynje6> Another option is to use a global error flag and set it in sys.excepthook (see http://docs.python.org/library/sys.html#sys.excepthook). goodbye will check the error flag and skip execution if error flag is set. From miki.tebeka at gmail.com Wed Feb 15 13:40:00 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 15 Feb 2012 10:40:00 -0800 (PST) Subject: atexit.register in case of errors In-Reply-To: References: Message-ID: <16963932.42.1329331200261.JavaMail.geo-discussion-forums@ynje6> Another option is to use a global error flag and set it in sys.excepthook (see http://docs.python.org/library/sys.html#sys.excepthook). goodbye will check the error flag and skip execution if error flag is set. From ian.g.kelly at gmail.com Wed Feb 15 13:43:09 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 11:43:09 -0700 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. Yes, it's amortized O(1). See: http://wiki.python.org/moin/TimeComplexity >From a relatively shallow analysis, primes(n) appears to be O(n ** (3/2)), but it might be possible to tighten that up a bit with an analysis of the distribution of primes and their smallest divisors. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? I believe the behavior in CPython is that if the array is full, the capacity is doubled, but I'm not certain, and that would be an implementation detail in any case. Cheers, Ian From d at davea.name Wed Feb 15 13:45:33 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 13:45:33 -0500 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: <4F3BFD4D.9030100@davea.name> On 02/15/2012 01:20 PM, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1), even amortized. > Do lists in Python 3 behave like ArrayList in Java (if the capacity > is full, then the array grows by more than 1 element) ? > > def sdiv(n) : # n>= 2 > """returns the smallest (prime) divisor of n""" > if n % 2 == 0 : return 2 > for d in range(3,int(sqrt(n))+1,2) : > if n % d == 0 : return d > return n > > def isPrime(n) : > """Returns True iff n is prime""" > return n>= 2 and n == sdiv(n) > > def primes(n) : # n>= 2 > """Returns the list of primes in [2,n]""" > res = [] > for k in range(2,n+1) : > if isPrime(k) : res.append(k) # cost O(1) ? > return res > > Thanks, > > franck Yes, lists behave the way you'd expect (see vector in C++), where when they have to reallocate they do so exponentially. However, realize that your algorithm is inefficient by a huge factor more than any time spent expanding lists. The biggest single thing you need to do is to memoize -- store the list of known primes, and add to it as you encounter more. Then use that list instead of range(3, xxx, 2) for doing the trial divisions. -- DaveA From d at davea.name Wed Feb 15 13:48:44 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 13:48:44 -0500 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> Message-ID: <4F3BFE0C.9080603@davea.name> On 02/15/2012 01:36 PM, Miki Tebeka wrote: > It depends on the overall runtime of the script vs start time of the vm. But yes in most benchmarks the script start time will bias against scripted languages. > > On a site note: ALL CAPS is considered shouting, please don't use that in news groups. When you reply to a known bot, please include some indication of the fact, so we know your message can be ignored as well. -- DaveA From stefan_ml at behnel.de Wed Feb 15 14:01:07 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 15 Feb 2012 20:01:07 +0100 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: Ian Kelly, 15.02.2012 19:43: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity is doubled But only up to a certain limit. After that, it grows in constant steps. Otherwise, your memory would be bound to explode on an append even though your list uses only half of it (or one third, in case it needs to copy). >, but I'm not certain, and that would be an > implementation detail in any case. Absolutely. Stefan From clp2 at rebertia.com Wed Feb 15 14:11:27 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 11:11:27 -0800 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 10:43 AM, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 11:20 AM, Franck Ditter wrote: >> Do lists in Python 3 behave like ArrayList in Java (if the capacity >> is full, then the array grows by more than 1 element) ? > > I believe the behavior in CPython is that if the array is full, the > capacity is doubled, but I'm not certain, and that would be an > implementation detail in any case. It's slightly more complex: http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c "The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" -- list_resize() Cheers, Chris From SMac2347 at comcast.net Wed Feb 15 14:11:39 2012 From: SMac2347 at comcast.net (SMac2347 at comcast.net) Date: Wed, 15 Feb 2012 11:11:39 -0800 (PST) Subject: Python to Combine Multiple Excel Worksheets into One Worksheet Message-ID: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> Hello, I have one single Excel file with many separate worksheets, and for work I need to combine all these separate worksheets into one single worksheet (I am not worried about formatting, as the format is the same in each sheet, nor am I worried about Excel's row limit). Essentially, I am looking for a way to append the data in one sheet to the bottom of the sheet that proceeds it. What would be the best way to do this, and how would I go about doing it? Can it be done simply with the xlwt, xlrd, and xutils modules, or (as I was thinking) do I need to convert the sheets to separate csv files, then append the separate csv files, and then write the completed file back into .xls format? Or perhaps something else? As I am really only a Python beginner, any and all help is very much appreciated. Thank you in advance!! From ethan at stoneleaf.us Wed Feb 15 14:29:17 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 15 Feb 2012 11:29:17 -0800 Subject: Kill files [was Re: OT: Entitlements [was Re: Python usage numbers]] In-Reply-To: <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <6d40acbf-1a4e-4004-8968-edc8f84015ab@p7g2000yqk.googlegroups.com> <4f3b8875$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F3C078D.9070406@stoneleaf.us> Steven D'Aprano wrote: > On Wed, 15 Feb 2012 10:04:34 +0000, Duncan Booth wrote: > >> Actually, I thought it was a bit weird that I saw ChrisA's comment but >> not the message he was commenting on until I went and looked for it. I >> read this group on a couple of machines and it looks like Rick's >> killfile entry had expired on the other but not this one. Next time I'm >> back on the other machine I'll try to remember to sort out the killfile. > > Yes, I have this problem too. I'm reluctant to killfile people forever, > call me a sucker if you like, but I'm willing to give people second > chances (and apparently third and fourth and fifth chances). Methinks > it's time for Monsieur Johnson to go back in the killfile. Luckily for me there are enough folks that still reply to the trolls in my killfile that I can see if it's time to take them off or not. ;) (This one is a resounding NOT) ~Ethan~ From rsengupta at wisc.edu Wed Feb 15 15:12:41 2012 From: rsengupta at wisc.edu (Rituparna Sengupta) Date: Wed, 15 Feb 2012 14:12:41 -0600 Subject: writing to a file from within nested loops In-Reply-To: <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> Message-ID: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Hi, I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. Ritu . . . i=0 ?while i References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On Wed, Feb 15, 2012 at 12:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. Please post your exact actual code (which this isn't; it has clear fatal syntax errors) and the full error message, including the stack Traceback. I would suspect there is some problematic assignment to `f` that you excluded from the snippet you posted. Cheers, Chris From ian.g.kelly at gmail.com Wed Feb 15 15:32:51 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 13:32:51 -0700 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. There's not enough to go on here. Please post the actual code snippet and the full traceback. Don't summarize the error for us. From d at davea.name Wed Feb 15 15:36:31 2012 From: d at davea.name (Dave Angel) Date: Wed, 15 Feb 2012 15:36:31 -0500 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: <4F3C174F.8060305@davea.name> On 02/15/2012 03:12 PM, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. > > Ritu > > > > . > . > . > i=0 > while i r=name[i] > f=open('file'+'%s' %(r), "a") > f.write("whatever"+r) #part outside innermost loop gets printed > j=0 > while j f.write("output of loop") #part within innermost loop doesn't get printed > j=j+1 > f.close() > i=i+1 > > Welcome to the mailing list. Some fundamentals, please: 1) give python version & os 2) copy/paste the code, don't retype it. You have lots of typos which would cause syntax errors, not "xxx" has no attribute "yyy". And please don't use 1 column indents; they're illegible. 4 spaces is a good number, recommended in a large number of places, including pep8. 3) copy/paste the whole error, including traceback. Without it in this case, we're forced to guess where the problem might be, and that must be somewhere else in the program, since the only write() attribute you've quoted here are on f.write() calls, and f is only set to a file object, not a string object. There are lots of ways in the code you don't show, where you might confuse the system, such as redefining open. Now to your questions: A) Since you don't show n, it could very well be 0 or negative, in which case the inner loop would never execute. B) Since you don't have correct indentation, it's possible the actual program closes the file inside the inner loop, in which case it might execute just once, then get an exception. not the one you quote, but whatever. C) Depending on how you run this program, perhaps the file isn't getting flushed when you get your error, so you just think the output didn't happen. D) BTW, i don't see any prints, but perhaps that's a minor point. You might think of file.write() as printing to a file. Sort of. -- DaveA From breamoreboy at yahoo.co.uk Wed Feb 15 15:44:02 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 20:44:02 +0000 Subject: writing to a file from within nested loops In-Reply-To: <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> References: <75208cce174437.4f3bf1a2@wiscmail.wisc.edu> <77a0ddfa17203f.4f3bf1de@wiscmail.wisc.edu> <775093eb1740b6.4f3bf21b@wiscmail.wisc.edu> <7760fe7a17153d.4f3bf258@wiscmail.wisc.edu> <75909037172f2d.4f3bf294@wiscmail.wisc.edu> <76f0965b175c1f.4f3bf2d0@wiscmail.wisc.edu> <77c0ac1d173db4.4f3bf403@wiscmail.wisc.edu> <7750b096170a1e.4f3c11b5@wiscmail.wisc.edu> <77a0e187170dca.4f3bbd59@wiscmail.wisc.edu> Message-ID: On 15/02/2012 20:12, Rituparna Sengupta wrote: > Hi, > > I'm working on this code and I keep getting an error. It might be some very basic thing but I was wondering if someone could help. Its a loop within a loop. The part outside the innermost loop gets printed fine, but the part within the innermost loop doesn't get printed. I get an error: 'str' has no attribute 'write'. Thanks in advance. > > Ritu > > . > i=0 > while i r=name[i] > f=open('file'+'%s' %(r), "a") > f.write("whatever"+r) #part outside innermost loop gets printed > j=0 > while j f.write("output of loop") #part within innermost loop doesn't get printed > j=j+1 > f.close() > i=i+1 > The above isn't Python so please post all of your code or a representative snippet that can show the problem, with the complete traceback and not simply the last line. Having said that I'm guessing that you're reassigning f somewhere to be a string, hence the error. Also why not write Python loops like:- for r in name: etc. -- Cheers. Mark Lawrence. From martin.schoon at gmail.com Wed Feb 15 15:58:11 2012 From: martin.schoon at gmail.com (Martin =?UTF-8?Q?Sch=C3=B6=C3=B6n?=) Date: 15 Feb 2012 20:58:11 GMT Subject: [semi OT]: Smartphones and Python? Message-ID: <9q2kj3Fmq1U1@mid.individual.net> First of all: I don't have any first hand experience of smartphones but now that my trusted old GSM phone is getting old I decided I am in for an up-grade. It struck me it might be nice to get something for which I could write Python programs. A very quick internet search indicated that this should be no big deal if I go for an Android-based phone. What about the alterna- tives? It struck me this must be the best place to ask. What else? I don't know if it matters but my home PC OS is Linux. And I am not much of a Python programmer but I enjoy learning it and I have reached a level that has turned out to be useful at work. /Martin From ken.allen at sbcglobal.net Wed Feb 15 16:02:45 2012 From: ken.allen at sbcglobal.net (Ken) Date: Wed, 15 Feb 2012 13:02:45 -0800 (PST) Subject: Numerical Linear Algebra in arbitrary precision Message-ID: Brand new Python user and a bit overwhelmed with the variety of packages available. Any recommendation for performing numerical linear algebra (specifically least squares and generalized least squares using QR or SVD) in arbitrary precision? I've been looking at mpmath but can't seem to find much info on built in functions except for LU decomposition/solve. Appreciate any comments. Ken From nagle at animats.com Wed Feb 15 16:24:23 2012 From: nagle at animats.com (John Nagle) Date: Wed, 15 Feb 2012 13:24:23 -0800 Subject: Looking for PyPi 2.0... In-Reply-To: References: Message-ID: <4f3c2286$0$12039$742ec2ed@news.sonic.net> On 2/8/2012 9:47 AM, Chris Rebert wrote: > On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice > wrote: >> As a user: >> * Finding the right module in PyPi is a pain because there is limited, >> low quality semantic information, and there is no code indexing. CPAN does it right. They host the code. (PyPi is just a collection of links). They have packaging standards (PyPi does not.) CPAN tends not to be full of low-quality modules that do roughly the same thing. If you want to find a Python module, Google is more useful than PyPi. John Nagle From nagle at animats.com Wed Feb 15 16:28:43 2012 From: nagle at animats.com (John Nagle) Date: Wed, 15 Feb 2012 13:28:43 -0800 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> Message-ID: <4f3c238b$0$11951$742ec2ed@news.sonic.net> On 2/4/2012 12:43 PM, Chris Angelico wrote: > On Sun, Feb 5, 2012 at 3:32 AM, Andrew Berg wrote: >> On 2/3/2012 9:15 PM, Chris Angelico wrote: >>> Do you call on potentially-buggy external modules? >> It imports one module that does little more than define a few simple >> functions. There's certainly no (intentional) interpreter hackery at work. Are you doing a conditional import, one that takes place after load time? If you do an import within a function or class, it is executed when the code around it executes. If you import a file with a syntax error during execution, you could get the error message you're getting. John Nagle From donald.stufft at gmail.com Wed Feb 15 16:31:10 2012 From: donald.stufft at gmail.com (Donald Stufft) Date: Wed, 15 Feb 2012 16:31:10 -0500 Subject: Looking for PyPi 2.0... In-Reply-To: <4f3c2286$0$12039$742ec2ed@news.sonic.net> References: <4f3c2286$0$12039$742ec2ed@news.sonic.net> Message-ID: <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> On Wednesday, February 15, 2012 at 4:24 PM, John Nagle wrote: > On 2/8/2012 9:47 AM, Chris Rebert wrote: > > On Wed, Feb 8, 2012 at 8:54 AM, Nathan Rice > > wrote: > > > As a user: > > > * Finding the right module in PyPi is a pain because there is limited, > > > low quality semantic information, and there is no code indexing. > > > > > > > > > > CPAN does it right. They host the code. (PyPi is just a > collection of links). They have packaging standards (PyPi > does not.) CPAN tends not to be full of low-quality modules > that do roughly the same thing. > > If you want to find a Python module, Google is more useful > than PyPi. > > Hopefully soon crate.io will be useful for finding modules ;) I have plans for it to try and, encourage people to host their code and encourage following packaging standards. I'm currently focused mostly on the backend stability (e.g. getting it stable) but emphasizing things that are generally good for the packaging ecosystem is something I hope to do. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list > > Donald Stufft -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Feb 15 16:31:19 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 16:31:19 -0500 Subject: atexit.register in case of errors In-Reply-To: <4F3BAF26.2060505@gmail.com> References: <4F3BAF26.2060505@gmail.com> Message-ID: On 2/15/2012 8:12 AM, Andrea Crotti wrote: > I have the following very simplified situation > > from atexit import register > > def goodbye(): print("saying goodbye") > > def main(): > while True: var = raw_input("read something") > > if __name__ == '__main__': > register(goodbye) > main() > > But in my case the "goodbye" function is deleting the logging file > which was created during the application execution. Now the problem > is that it *always* executes, even when the applications quits for > some bad errors. > > Is there a way to have an exit hook, which doesn't execute in case of > errors? Have a single no-error normal exit point. if __name__ == '__main__': main() cleanup() if you really want to exit by exceptions rather than by returns, if __name__ == '__main__': try: main() except SystemExit: normal_exit_cleanup() -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 15 16:41:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 16:41:11 -0500 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On 2/15/2012 2:11 PM, Chris Rebert wrote: > > It's slightly more complex: > http://hg.python.org/cpython/file/096b31e0f8ea/Objects/listobject.c > "The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" > -- list_resize() This has apparently changed from time to time. -- Terry Jan Reedy From bahamutzero8825 at gmail.com Wed Feb 15 16:41:51 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Wed, 15 Feb 2012 15:41:51 -0600 Subject: Script randomly exits for seemingly no reason with strange traceback In-Reply-To: <4f3c238b$0$11951$742ec2ed@news.sonic.net> References: <4f2c6cec$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F2D5D99.4030808@gmail.com> <4f3c238b$0$11951$742ec2ed@news.sonic.net> Message-ID: <4F3C269F.5080400@gmail.com> On 2/15/2012 3:28 PM, John Nagle wrote: > Are you doing a conditional import, one that takes place after load > time? If you do an import within a function or class, it is executed > when the code around it executes. If you import a file with a > syntax error during execution, you could get the error message you're > getting. It does have conditional imports, but the tracebacks don't occur while that function is running (it's executed once, and this happens well after). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From alan.mckay+python at gmail.com Wed Feb 15 16:51:21 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Wed, 15 Feb 2012 16:51:21 -0500 Subject: Is this the right list? Message-ID: Hey folks, I looked all through the list of mailing lists on the mail.python.orgserver and this seems to be the only one that might apply to me other than maybe the German list which did not seem to have any specific python issue associated with it other than that you should write German on it. I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11, and the problem is around .py program. It is a web based program, and seems to use a strange combination of mod_python and python CGI as best I can tell. Would this be the right list to ask? thanks, -Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: From nathan.alexander.rice at gmail.com Wed Feb 15 16:53:32 2012 From: nathan.alexander.rice at gmail.com (Nathan Rice) Date: Wed, 15 Feb 2012 16:53:32 -0500 Subject: Looking for PyPi 2.0... In-Reply-To: <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> References: <4f3c2286$0$12039$742ec2ed@news.sonic.net> <93D84DCF9C77473CB4276AD37DB7877A@gmail.com> Message-ID: > Hopefully soon crate.io will be useful for finding modules ;) I have plans > for it to try and, encourage people to host their code and encourage > following packaging standards. I'm currently focused mostly on the backend > stability (e.g. getting it stable) but emphasizing things that are generally > good for the packaging ecosystem is something I hope to do. I think providing commit hooks for version control ala read the docs is the #1 thing you could do in the short term to add a lot of value. That would be enough for me to adopt the service :) Nathan From tjreedy at udel.edu Wed Feb 15 17:04:29 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 15 Feb 2012 17:04:29 -0500 Subject: Is this the right list? In-Reply-To: References: Message-ID: On 2/15/2012 4:51 PM, Alan McKay wrote: > I am having a problem moving an application from RHEL 5.7 to Ubuntu > 11.11, and the problem is around .py program. > > It is a web based program, and seems to use a strange combination of > mod_python and python CGI as best I can tell. > > Would this be the right list to ask? Go ahead. If the question is too specialized for readers here, you might get a suggestion where else to look. Include python versions on both systems and any tracebacks from executing the program. -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Wed Feb 15 17:05:29 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 15 Feb 2012 22:05:29 +0000 Subject: Is this the right list? In-Reply-To: References: Message-ID: On 15/02/2012 21:51, Alan McKay wrote: > Hey folks, > > I looked all through the list of mailing lists on the > mail.python.orgserver and this seems to be the only one that might > apply to me other than > maybe the German list which did not seem to have any specific python issue > associated with it other than that you should write German on it. > > I am having a problem moving an application from RHEL 5.7 to Ubuntu 11.11, > and the problem is around .py program. > > It is a web based program, and seems to use a strange combination of > mod_python and python CGI as best I can tell. > > Would this be the right list to ask? > > thanks, > -Alan > > > > Welcome. Put (a snippet of) code here that's causing the problem together with a full traceback and you'll soon find out :) If it is the right place you'll get answers, if not you'll certainly be pointed in the right direction. -- Cheers. Mark Lawrence. From ironfroggy at gmail.com Wed Feb 15 17:43:17 2012 From: ironfroggy at gmail.com (Calvin Spealman) Date: Wed, 15 Feb 2012 17:43:17 -0500 Subject: Stand-Alone Python Executable Skeletons Message-ID: I've recently been looking into different options to package python code into stand-alone executables, with tools like Py2EXE and PyInstaller, but I'm left feeling a little lost. Documentation seems sparse on all of them, the setups a little unusual to me. It feels like they could be a lot simpler, or that I could put in some preliminary work to make it easier for my needs in the long run. I'm hoping someone can help me pick the best option. What I would love to do (or know if it is possible) is have a set of executables, for Linux, Windows, and OS X, with a Zip archive appended to the end of them. I know the zip archive at the end of an executable works with EXE and ELF binaries, but does it work for whatever OSX uses (I have no mac machines, currently)? I'd like to build these three empty stand-alone python executables, setup such that they'll run any main.py sitting at the top level of the archive. After this, building for all three platforms would just be a matter of copying the empty versions and dumping the project into it. I'm leaning on doing this with PyInstaller being the easiest. Am I headed in the right direction? Ideally, these empty stand-alones could be distributed for use by others without any tools required to use them other than a zip utility. -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From ian.g.kelly at gmail.com Wed Feb 15 17:54:27 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 15:54:27 -0700 Subject: Complexity question on Python 3 lists In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 1:28 PM, Dennis Lee Bieber wrote: > On Wed, 15 Feb 2012 11:11:27 -0800, Chris Rebert > wrote: > > >>"The growth pattern is: 0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ?" >> ? ?-- list_resize() >> > ? ? ? ?Rather perverse, is it not? The first set is plain doubling, but > then you get a series of increases by: > > ? ? ? ?... 9, 10, 11, 12, 14, 16, 16,... > > or > > ? ? ? ?100%, 100%, 100%, 56%, 40%, 34%, 30%, 27%, 22%,... > > ? ? ? ?Big jump form 100% to 56%... Based on the formula in the code, it would seem to asymptotically approach 12.5%. From clp2 at rebertia.com Wed Feb 15 17:55:53 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 15 Feb 2012 14:55:53 -0800 Subject: Stand-Alone Python Executable Skeletons In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 2:43 PM, Calvin Spealman wrote: > I've recently been looking into different options to package python > code into stand-alone executables, with tools like Py2EXE and > PyInstaller, but I'm left feeling a little lost. Documentation seems > sparse on all of them, the setups a little unusual to me. It feels > like they could be a lot simpler, or that I could put in some > preliminary work to make it easier for my needs in the long run. I'm > hoping someone can help me pick the best option. > > What I would love to do (or know if it is possible) is have a set of > executables, for Linux, Windows, and OS X, with a Zip archive appended > to the end of them. I know the zip archive at the end of an executable > works with EXE and ELF binaries, but does it work for whatever OSX > uses (I have no mac machines, currently)? OS X has application bundles: http://en.wikipedia.org/wiki/Application_bundle py2app can generate them: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html Cheers, Chris From python at mrabarnett.plus.com Wed Feb 15 18:17:56 2012 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 15 Feb 2012 23:17:56 +0000 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <4F3C3D24.4000900@mrabarnett.plus.com> On 15/02/2012 20:58, Martin Sch??n wrote: > First of all: I don't have any first hand experience of smartphones > but now that my trusted old GSM phone is getting old I decided I am > in for an up-grade. It struck me it might be nice to get something > for which I could write Python programs. > > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alterna- > tives? > > It struck me this must be the best place to ask. > > What else? I don't know if it matters but my home PC OS is Linux. > And I am not much of a Python programmer but I enjoy learning it > and I have reached a level that has turned out to be useful at work. > Python has been ported to iOS, if you're thinking of going the Apple route: http://ipython.hozbox.com From someone at someplace.invalid Wed Feb 15 18:33:26 2012 From: someone at someplace.invalid (HoneyMonster) Date: Wed, 15 Feb 2012 23:33:26 +0000 (UTC) Subject: Wanted: Criticism of code for a Python module, plus a Mac tester Message-ID: I am quite new to Python (running Python 2.7 on Linux). I have written a very small and simple dealing module for the game of Bridge. For those unfamiliar with the game, the idea is to deal each of 4 players a hand of 13 cards from a pack of 52, and to display it thus (use a fixed pitch font): Board 1 Neither vulnerable Dealer North K98432 T7 2 AQT2 T AQJ KJ854 9632 KQ973 T854 85 74 765 AQ AJ6 KJ963 Firstly, is there anyone here who uses Python on a Mac and would be prepared to test it? I have tested it on Linux and Windows, but don't have access to a Mac. Secondly, as a more general point I would welcome comments on code quality, adherence to standards and so forth. The code is at: http://dl.dropbox.com/u/6106778/bridgedeal.py Thanks. From no.email at nospam.invalid Wed Feb 15 18:36:31 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Wed, 15 Feb 2012 15:36:31 -0800 Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <7x62f7u0sg.fsf@ruckus.brouhaha.com> Martin Sch??n writes: > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alternatives? It works pretty well with Maemo, though phones with that are not so easy to find. My ex-officemate wrote some SL4A (Android) apps in Python and said it was pretty easy to use, though some features were missing. I know that one missing feature was tkinter. From rosuav at gmail.com Wed Feb 15 18:54:38 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Feb 2012 10:54:38 +1100 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <4F3BFE0C.9080603@davea.name> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> Message-ID: On Thu, Feb 16, 2012 at 5:48 AM, Dave Angel wrote: > When you reply to a known bot, please include some indication of the fact, > so we know your message can be ignored as well. Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. ChrisA From steve+comp.lang.python at pearwood.info Wed Feb 15 18:57:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Feb 2012 23:57:49 GMT Subject: Interactive keyword help References: Message-ID: <4f3c467d$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 11:23:20 -0600, Andrew Berg wrote: > help() is a built-in function, not a keyword. > http://docs.python.org/library/functions.html#help > http://docs.python.org/py3k/library/functions.html#help Technically, it's not actually built-in, it is added to the built-ins by site.py. -- Steven From ian.g.kelly at gmail.com Wed Feb 15 19:07:48 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 17:07:48 -0700 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster wrote: > Secondly, as a more general point I would welcome comments on code > quality, adherence to standards and so forth. The code is at: Looks pretty nice overall. To reduce repetition, I would have constructed the CONDITIONS list by iteration like you did the DECK list, something like: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] VULNERABILITIES = [ "Neither vulnerable", "North-South vulnerable", "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES] You could also eliminate some repetition in the deal method by putting the suit lists in a local dict: suits = {'S': self.spades, 'H': self.hearts, 'D': self.diamonds, 'C': self.clubs} for card in cards: suits[DECK[card][SUIT]].append(DECK[card][RANK]) Another comment I had at first was that instead of creating the pack list, which is just a list of indexes into DECK, you could shuffle and deal the DECK list directly. But then I realized that the indirection allows you to easily sort the cards in the desired order, so that should be left alone. Cheers, Ian From fetchinson at googlemail.com Wed Feb 15 19:18:07 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 01:18:07 +0100 Subject: format a measurement result and its error in "scientific" way Message-ID: Hi folks, often times in science one expresses a value (say 1.03789291) and its error (say 0.00089) in a short way by parentheses like so: 1.0379(9) One can vary things a bit, but let's take the simplest case when we only keep 1 digit of the error (and round it of course) and round the value correspondingly. I've been searching around for a simple function that would take 2 float arguments and would return a string but didn't find anything although something tells me it's been done a gazillion times. What would be the simplest such function? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From jugurtha.hadjar at gmail.com Wed Feb 15 19:34:57 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Thu, 16 Feb 2012 01:34:57 +0100 Subject: Beware, my computer was infected. Message-ID: <4F3C4F31.8020303@gmail.com> Hello gentlemen, I'm writing these words to give you a heads up. My computer has recently been infected with "1.exe", and I am doing what I can to contain it. It spreads via mail and I fear it will send SPAM to lists I am subscribed to. If you receive weird mails from my address, thank you to report it to me. I will not send you an executable, so if you receive one from me, please do not open it and it would be nice to report it. I will send an e-mail to this list once I think it is no longer in the system. Thank you all. -- ~Jugurtha Hadjar, From steve+comp.lang.python at pearwood.info Wed Feb 15 19:41:42 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Feb 2012 00:41:42 GMT Subject: Complexity question on Python 3 lists References: Message-ID: <4f3c50c6$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 15 Feb 2012 19:20:21 +0100, Franck Ditter wrote: > What is the cost of calling primes(n) below ? I'm mainly interested in > knowing if the call to append is O(1) Your primes() function appears to be a variation on trial division, which is asymptotically O(n*sqrt(n)/(log n)**2). Regardless of the exact Big Oh behaviour, it is going to be SLOW for large values of n. The behaviour of append is the least of your concerns. -- Steven From python.list at tim.thechases.com Wed Feb 15 19:43:42 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 15 Feb 2012 18:43:42 -0600 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: <4F3C513E.7080201@tim.thechases.com> On 02/15/12 17:33, HoneyMonster wrote: > Firstly, is there anyone here who uses Python on a Mac and > would be prepared to test it? I have tested it on Linux and > Windows, but don't have access to a Mac. It works from my quick test of it on my Mac. The "class Player():" and the .format() calls choke on 2.4 (if perhaps for some reason you're running it on earlier versions), but otherwise, it should be good if you're running 2.7 everywhere. > Secondly, as a more general point I would welcome comments on > code quality, adherence to standards and so forth. The code is > at: All the .append()s seem a little unpythonic to me. I'd just set it up with CONDITIONS = [ [...], ... ] And since you're not modifying it, I'd even use tuples (or named tuples): CONDITIONS = ( ("Dealer North", "Neither vulnerable"), ... ) I'd also take advantage of iterable-unpacking to do something like the following in your Player.deal() method: for card in cards: suit, rank = DECK[card] { 'S': self.spades, 'D': self.diamonds, 'C': self.clubs, 'H': self.hearts, }[suit].append(rank) (that fixed dictionary might even be hoisted out for reuse elsewhere). Additionally, if you import this as a module rather than running it directly, there's no "north", "south", ... in your module namespace (they're only defined in the "if __name__ ..." section) so it will fail. There are some other structural decisions that I might reconsider too: - just shuffling the deck, rather than shuffling indexes into that deck - there seems to be a lot of redundancy in the drawing code, but I'm not sure how I'd reduce that - assigning to internal rank-named lists seems a little redundant to me. In my (non-bridge) card-playing history, and tinkering with small programs like this to simulate card-games, I usually just give a player the cards and then leave the sifting/sorting to the display algorithm - I see Ian's email came in as I was typing this and agree with his method of defining CONDITIONS with the caveat that it doesn't keep the same order as yours (I seem to recall bridge had some odd rules about that order) -tkc From someone at someplace.invalid Wed Feb 15 20:11:52 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 16 Feb 2012 01:11:52 +0000 (UTC) Subject: Wanted: Criticism of code for a Python module, plus a Mac tester References: Message-ID: On Wed, 15 Feb 2012 17:07:48 -0700, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 4:33 PM, HoneyMonster > wrote: >> Secondly, as a more general point I would welcome comments on code >> quality, adherence to standards and so forth. The code is at: > > Looks pretty nice overall. To reduce repetition, I would have > constructed the CONDITIONS list by iteration like you did the DECK list, > something like: > > DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] > VULNERABILITIES = [ > "Neither vulnerable", "North-South vulnerable", > "East-West vulnerable", "Both vulnerable", > ] > CONDITIONS = [(d, v) for d in DEALERS for v in VULNERABILITIES] > > You could also eliminate some repetition in the deal method by putting > the suit lists in a local dict: > > suits = {'S': self.spades, 'H': self.hearts, > 'D': self.diamonds, 'C': self.clubs} > for card in cards: > suits[DECK[card][SUIT]].append(DECK[card][RANK]) > > Another comment I had at first was that instead of creating the pack > list, which is just a list of indexes into DECK, you could shuffle and > deal the DECK list directly. But then I realized that the indirection > allows you to easily sort the cards in the desired order, so that should > be left alone. Thank you very much indeed, Ian. Your second suggestion has opened my eyes; it had not even occurred to me that the "value" element of a dictionary entry could be a list. Just shows me how much I have to learn! Isn't Python great? As to your first suggestion though, I am having some difficulty. Note that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as CONDITIONS[0]. Is there a better way of doing it than a simple list.append()? Thanks again. From ian.g.kelly at gmail.com Wed Feb 15 20:56:30 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 18:56:30 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 5:18 PM, Daniel Fetchinson wrote: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) > > One can vary things a bit, but let's take the simplest case when we > only keep 1 digit of the error (and round it of course) and round the > value correspondingly. I've been searching around for a simple > function that would take 2 float arguments and would return a string > but didn't find anything although something tells me it's been done a > gazillion times. > > What would be the simplest such function? Well, this basically works: >>> def format_error(value, error): ... precision = int(math.floor(math.log(error, 10))) ... format = "%%.%df(%%d)" % max(-precision, 0) ... return format % (round(value, -precision), ... int(round(error / 10 ** precision))) ... >>> format_error(1.03789291, 0.00089) '1.0379(9)' Note that "math.floor(math.log(error, 10))" may return the wrong decimal precision due to binary floating point rounding error, which could produce some strange results: >>> format_error(10378929, 1000) '10378900(10)' So you'll probably want to use decimals instead: def format_error(value, error): value = decimal.Decimal(value) error = decimal.Decimal(error) value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) precision = value_scale - error_scale if error_scale > 0: format = "%%.%dE" % max(precision, 0) else: format = "%%.%dG" % (max(precision, 0) + 1) value_str = format % value.quantize(decimal.Decimal("10") ** error_scale) error_str = '(%d)' % error.scaleb(-error_scale).to_integral() if 'E' in value_str: index = value_str.index('E') return value_str[:index] + error_str + value_str[index:] else: return value_str + error_str >>> format_error(1.03789291, 0.00089) '1.0379(9)' >>> format_error(103789291, 1000) '1.03789(1)E+08' I haven't tested this thoroughly, so use at your own risk. :-) Cheers, Ian From debatem1 at gmail.com Wed Feb 15 21:19:15 2012 From: debatem1 at gmail.com (geremy condra) Date: Wed, 15 Feb 2012 18:19:15 -0800 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > First of all: I don't have any first hand experience of smartphones > but now that my trusted old GSM phone is getting old I decided I am > in for an up-grade. It struck me it might be nice to get something > for which I could write Python programs. > > A very quick internet search indicated that this should be no big > deal if I go for an Android-based phone. What about the alterna- > tives? > > It struck me this must be the best place to ask. > > What else? I don't know if it matters but my home PC OS is Linux. > And I am not much of a Python programmer but I enjoy learning it > and I have reached a level that has turned out to be useful at work. Please note that while SL4A is a pretty good mobile python environment it doesn't support all of the Android API, which means it generally isn't an easy way to develop fully-fledged Android apps. Geremy Condra From dihedral88888 at googlemail.com Wed Feb 15 21:38:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 15 Feb 2012 18:38:52 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> ? 2012?2?16????UTC+8??10?19?15??geremy condra??? > On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > > First of all: I don't have any first hand experience of smartphones > > but now that my trusted old GSM phone is getting old I decided I am > > in for an up-grade. It struck me it might be nice to get something > > for which I could write Python programs. > > > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alterna- > > tives? > > > > It struck me this must be the best place to ask. > > > > What else? I don't know if it matters but my home PC OS is Linux. > > And I am not much of a Python programmer but I enjoy learning it > > and I have reached a level that has turned out to be useful at work. > > Please note that while SL4A is a pretty good mobile python environment > it doesn't support all of the Android API, which means it generally > isn't an easy way to develop fully-fledged Android apps. > > Geremy Condra In the 4 G space of SW AP in Adndroid phones, check Jython. But I think a better data compression modules is more helpful. Patterns about arithmetic compressions and LZW are expired, but not those in mp4 for the commercial use. Thus, the time to install a complete OS on a tablet or mobile phone with LTE on the way. We need smaller HD or flashes in these small devices. From dihedral88888 at googlemail.com Wed Feb 15 21:38:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Wed, 15 Feb 2012 18:38:52 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> ? 2012?2?16????UTC+8??10?19?15??geremy condra??? > On Wed, Feb 15, 2012 at 12:58 PM, Martin Sch??n wrote: > > First of all: I don't have any first hand experience of smartphones > > but now that my trusted old GSM phone is getting old I decided I am > > in for an up-grade. It struck me it might be nice to get something > > for which I could write Python programs. > > > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alterna- > > tives? > > > > It struck me this must be the best place to ask. > > > > What else? I don't know if it matters but my home PC OS is Linux. > > And I am not much of a Python programmer but I enjoy learning it > > and I have reached a level that has turned out to be useful at work. > > Please note that while SL4A is a pretty good mobile python environment > it doesn't support all of the Android API, which means it generally > isn't an easy way to develop fully-fledged Android apps. > > Geremy Condra In the 4 G space of SW AP in Adndroid phones, check Jython. But I think a better data compression modules is more helpful. Patterns about arithmetic compressions and LZW are expired, but not those in mp4 for the commercial use. Thus, the time to install a complete OS on a tablet or mobile phone with LTE on the way. We need smaller HD or flashes in these small devices. From torriem at gmail.com Wed Feb 15 22:26:46 2012 From: torriem at gmail.com (Michael Torrie) Date: Wed, 15 Feb 2012 20:26:46 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <4F3C7776.9060204@gmail.com> On 02/15/2012 07:38 PM, 88888 Dihedral wrote: > In the 4 G space of SW AP in Adndroid phones, > check Jython. But I think a better data compression > modules is more helpful. Jython, though a very cool and useful implementation, relies on the Java virtual machine to run. It does not yet run on Dalvik, nor is it clear that it ever will. The project to port jython to Dalvik, but it died and the authors said, just use Android scripting. lame. From solin.pavel at gmail.com Wed Feb 15 22:41:42 2012 From: solin.pavel at gmail.com (Pavel Solin) Date: Wed, 15 Feb 2012 19:41:42 -0800 Subject: Web browser Python programming in NCLab Message-ID: Hello, the NCLab development team would like to invite everybody to try out Python programming in the web browser at www.nclab.com. Using NCLab is free for personal, non-commercial purposes. If you'd like to give us feedback how we are doing, please use the mailing list nclab-user at googlegroups.com. We hope to hear from you! Best, Pavel -- Pavel Solin University of Nevada, Reno http://hpfem. org/~pavel -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 16 00:03:44 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 15 Feb 2012 22:03:44 -0700 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster wrote: > As to your first suggestion though, I am having some difficulty. Note > that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as > CONDITIONS[0]. > Is there a better way of doing it than a simple list.append()? Ah, it's more complicated than I realized. I believe this generates the correct result, although adding None to the dealers list is somewhat unsatisfactory: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West", None] VULNERABILITIES = [ "Neither vulnerable", "North-South vulnerable", "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d] I might be tempted to write a custom iterator for it, something like this: def rotating(iterable): cache = collections.deque() for value in iterable: yield value cache.append(value) while True: cache.rotate(-1) for value in cache: yield value # Using the original 4-length DEALERS list CONDITIONS = list(itertools.islice(itertools.izip(itertools.cycle(DEALERS), rotating(VULNERABILITIES)), 16)) But I don't know that it's really worth the added complexity. Cheers, Ian From arnodel at gmail.com Thu Feb 16 02:59:50 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 16 Feb 2012 07:59:50 +0000 Subject: Wanted: Criticism of code for a Python module, plus a Mac tester In-Reply-To: References: Message-ID: On 16 February 2012 05:03, Ian Kelly wrote: > On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster wrote: >> As to your first suggestion though, I am having some difficulty. Note >> that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as >> CONDITIONS[0]. >> Is there a better way of doing it than a simple list.append()? > > Ah, it's more complicated than I realized. ?I believe this generates > the correct result, although adding None to the dealers list is > somewhat unsatisfactory: > > DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West", None] > VULNERABILITIES = [ > ? "Neither vulnerable", "North-South vulnerable", > ? "East-West vulnerable", "Both vulnerable", > ] > CONDITIONS = [(d, v) for (d, v) in zip(DEALERS * 4, VULNERABILITIES * 5) if d] You could also do: DEALERS = ["Dealer North", "Dealer East", "Dealer South", "Dealer West"] VULNERABILITIES = [ ? "Neither vulnerable", "North-South vulnerable", ? "East-West vulnerable", "Both vulnerable", ] CONDITIONS = [ (DEALERS[j], VULNERABILITIES[(i + j)%4]) for i in range(4) for j in range(4) ] If you don't care about the order in which the conditions are listed, you could use CONDITIONS = itertools.product(DEALERS, VULNERABILITIES) (But maybe you do, I haven't looked at the code) -- Arnaud From fetchinson at googlemail.com Thu Feb 16 03:36:20 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 09:36:20 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: >> Hi folks, often times in science one expresses a value (say >> 1.03789291) and its error (say 0.00089) in a short way by parentheses >> like so: 1.0379(9) >> >> One can vary things a bit, but let's take the simplest case when we >> only keep 1 digit of the error (and round it of course) and round the >> value correspondingly. I've been searching around for a simple >> function that would take 2 float arguments and would return a string >> but didn't find anything although something tells me it's been done a >> gazillion times. >> >> What would be the simplest such function? > > Well, this basically works: > >>>> def format_error(value, error): > ... precision = int(math.floor(math.log(error, 10))) > ... format = "%%.%df(%%d)" % max(-precision, 0) > ... return format % (round(value, -precision), > ... int(round(error / 10 ** precision))) > ... >>>> format_error(1.03789291, 0.00089) > '1.0379(9)' > > Note that "math.floor(math.log(error, 10))" may return the wrong > decimal precision due to binary floating point rounding error, which > could produce some strange results: > >>>> format_error(10378929, 1000) > '10378900(10)' > > So you'll probably want to use decimals instead: > > def format_error(value, error): > value = decimal.Decimal(value) > error = decimal.Decimal(error) > value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) > error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) > precision = value_scale - error_scale > if error_scale > 0: > format = "%%.%dE" % max(precision, 0) > else: > format = "%%.%dG" % (max(precision, 0) + 1) > value_str = format % value.quantize(decimal.Decimal("10") ** > error_scale) > error_str = '(%d)' % error.scaleb(-error_scale).to_integral() > if 'E' in value_str: > index = value_str.index('E') > return value_str[:index] + error_str + value_str[index:] > else: > return value_str + error_str > >>>> format_error(1.03789291, 0.00089) > '1.0379(9)' >>>> format_error(103789291, 1000) > '1.03789(1)E+08' > > I haven't tested this thoroughly, so use at your own risk. :-) Thanks a lot, this indeed mostly works, except for cases when the error needs to be rounded up and becomes two digits: >>> format_error( '1.34883', '0.0098' ) '1.349(10)' But in this case I'd like to see 1.35(1) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From ssmile03 at gmail.com Thu Feb 16 04:52:52 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 16 Feb 2012 15:22:52 +0530 Subject: Reading sub-string from a file Message-ID: All, I am a python newbie. Let's say I have a filename (test.conf) as below - ---- int Apple(int, int); void Jump_OnUnload(float, int); int Jockey_Apple_cat_1KK(float, int, char, int); int Jockey_Apple_cat_look(int, float, int, int); int Jockey_Apple_cat_test_ki21es(int, int, int, int); int Jockey_Apple_cat_tarLK12OU(void, int, int, int); --- Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a function name. I wish to extract ONLY that function name which has 'Jockey_Apple_cat' as a substring and ignore remaining function names. The program .py written is - ----- --- #!/usr/bin/python def foo(filename): try: one = open(filename, 'r') except: print filename, 'cannot be open.' AllLines = one.readline() for eachLine in AllLines: start = eachLine.find('Jockey_Apple_cat') if start != -1: finish = eachLine.find ('(') print eachLine[start:finish] handle.close() set_foo("test.conf") ----- I did perform debugging using pdb, it only reads all the lines. Plz help!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Thu Feb 16 05:24:49 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 16 Feb 2012 02:24:49 -0800 Subject: Reading sub-string from a file In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 1:52 AM, Smiley 4321 wrote: > All, > > I am a python newbie. > > Let's say I have a filename (test.conf) as below - > > ---- > int Apple(int, int); > void Jump_OnUnload(float, int); > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. > > The program .py written is - > > ----- > --- > #!/usr/bin/python > > def foo(filename): > ??????? try: > ??????????????? one = open(filename, 'r') > ??????? except: > ??????????????? print filename, 'cannot be open.' > > ??????? AllLines = one.readline() > > ??????? for eachLine in AllLines: > ??????????????? start = eachLine.find('Jockey_Apple_cat') > ??????????????? if start != -1: > ??????????????????????? finish = eachLine.find ('(') > ??????????????????????? print eachLine[start:finish] > > ??????? handle.close() > > set_foo("test.conf") > ----- > > I did perform debugging using pdb, it only reads all the lines. > > Plz help!! Several oddities in the code you posted (e.g. you defined foo() but instead call set_foo(); the `handle` variable comes out of nowhere) suggest that it isn't your actual code; this greatly hinders us in assisting you. Please post your /actual/ code verbatim (or as much of it as you can with as few modifications as you can). Also, avoid using "plz" in the future; it's gotten a reputation for being associated with undesirable folk. Cheers, Chris From __peter__ at web.de Thu Feb 16 05:25:49 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 16 Feb 2012 11:25:49 +0100 Subject: Reading sub-string from a file References: Message-ID: Smiley 4321 wrote: > I am a python newbie. Welcome! > Let's say I have a filename (test.conf) as below - > > ---- > int Apple(int, int); > void Jump_OnUnload(float, int); > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. > > The program .py written is - > > ----- > --- > #!/usr/bin/python > > def foo(filename): > try: > one = open(filename, 'r') > except: > print filename, 'cannot be open.' > > AllLines = one.readline() > > for eachLine in AllLines: > start = eachLine.find('Jockey_Apple_cat') > if start != -1: > finish = eachLine.find ('(') > print eachLine[start:finish] > > handle.close() > > set_foo("test.conf") > ----- > > I did perform debugging using pdb, it only reads all the lines. There are errors in the above that suggest that you retyped your actual code. Don't do that! Always use cut and paste for code snippets you are posting here. As to what the problem in your actual code might be, here's a hint: You could be iterating over the characters of the first line of the file instead of the lines. Change > AllLines = one.readline() > > for eachLine in AllLines: to for eachLine in one: to fix that. From rosuav at gmail.com Thu Feb 16 05:32:10 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 16 Feb 2012 21:32:10 +1100 Subject: Reading sub-string from a file In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 8:52 PM, Smiley 4321 wrote: > int Jockey_Apple_cat_1KK(float, int, char, int); > int Jockey_Apple_cat_look(int, float, int, int); > int Jockey_Apple_cat_test_ki21es(int, int, int, int); > int Jockey_Apple_cat_tarLK12OU(void, int, int, int); > --- > > Here substring "Jockey_Apple_cat" is common from 3rd line onwards as a > function name. I wish to extract ONLY that function name which has > 'Jockey_Apple_cat' as a substring and ignore remaining function names. Try this: grep -o 'Jockey_Apple_cat[^(]*' test.conf It's not Python, but it might serve you better than knocking something together! But if you're using this to learn Python, Peter Otten's solution is, I think, what you want. ChrisA From austinbaiy at gmail.com Thu Feb 16 07:33:40 2012 From: austinbaiy at gmail.com (austinbaiy) Date: Thu, 16 Feb 2012 04:33:40 -0800 (PST) Subject: Web Design Company Florida Message-ID: Searching for Best Web Design, Development or Affordable SEO Service in USA? Bestwebsol.com provides professional full-cycle services: web development, custom web design & Best SEO services with guaranteed traffic increase and higher ranking. http://www.bestwebsol.com From rantingrickjohnson at gmail.com Thu Feb 16 09:43:16 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 16 Feb 2012 06:43:16 -0800 (PST) Subject: Is this the right list? References: Message-ID: On Feb 15, 4:04?pm, Terry Reedy wrote: > On 2/15/2012 4:51 PM, Alan McKay wrote: > > > Is this the right list? This is neither the "right" or "left" list, however, it may be either the correct or incorrect depending on your question. From dihedral88888 at googlemail.com Thu Feb 16 09:53:08 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 06:53:08 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms easily. Then I personally prefer python. From dihedral88888 at googlemail.com Thu Feb 16 09:53:08 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 06:53:08 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> Message-ID: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> The law suites of JAVA Vitrtual Machine from Oracle are famous now. But in 201X the JVM patents will be expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms easily. Then I personally prefer python. From alan.mckay+python at gmail.com Thu Feb 16 10:16:47 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Thu, 16 Feb 2012 10:16:47 -0500 Subject: Python / Apache config issue Message-ID: OK, since you all said to send it, here it is :-) Though I think it may be an apache issue, I'll send it anyway. I'm using the software called "Open Freezer" which is used to track reagents and other chemicals in research labs. I also posted this here on their discussion forums but have not heard anything yet. In general their install and config instructions are pretty incomplete and even asking the authors direct questions sometimes does not get very good answers https://sourceforge.net/p/openfreezer/discussion/openfreezer/thread/789d5cdb/ It was working fine on Ubuntu 11.04 and RHEL 5.7 but I'm having issues on Ubuntu 11.11 - in all cases the versions of python that come with the respective OS In the working version on Ubuntu 11.04 the entire apache instance was dedicated to this app - something I cannot do on the RHEL and Ubuntu 11.11 machines ---snip--- The specific problem I am having is that I go to "Search Projects", and then select a project and hit "Go", and it does not execute the python. In one configuration, it downloads the .py script instead of executing it. In the other configuration it tells me 404 cannot find it. I had this working fine on RHEL 5.7 but now it is broken on Ubuntu (with the same config file) Details below. I had the basic CGI functions working fine on RHEL but had to move to the latest version of Ubuntu server and am having trouble. One different aspect of both my RHEL and Ubuntu setups is that I cannot dedicate the entire Apache instance to Open Freezer, so my URL is not http://MYIP/ it is http://MYIP/openfreezer/ . On RHEL my openfreezer.conf file looks like this. Note there is no VirtualHost because as mentioned I cannot dedicate this apache instance to just open freezer, and I also do not have control over DNS so I cannot assign a 2nd DNS name to this server. Alias "/openfreezer" "/var/www/OpenFreezer" Alias "/openfreezercgi" "/var/www/OpenFreezer/cgi" Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all #AddHandler python26-mod_python .py #AddHandler mod_python .py PythonDebug On #PythonHandler mod_python.publisher AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all AddHandler mod_python .py #PythonDebug On PythonHandler mod_python.cgihandler PythonPath "['/var/www/OpenFreezer/cgi'] + sys.path" This works fine on RHEL 5.7 with apache 2.2.3 . I select a project, hit "Go" and it executes cgi/project_request_handler.py as it should. But with the exact same config file on Ubuntu it instead tries to download the .py instead of execute it. But I also try putting a couple of test programs in my CGI directory. This first one tries to download as well with the above config : test.py def index(req): return "Test successful"; But this second one executes correctly : testcgi.py #!/usr/bin/python print "Content-type: text/html" print print "" print " Hello!" print "" So I talk to the other guy here who started out working on this for us, because he had it running on Ubuntu as well (a slightly older version - 11.04 versus my 11.11). He has apache 2.2.16 and I have 2.2.20 His config file looks like this - note that he does have the entire apache server dedicated to Open Freezer so his URL is http://HISIP/ ServerAdmin webmaster at localhost ServerName localhost DocumentRoot /var/www/OpenFreezer/ Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all AddHandler mod_python .py PythonDebug On #PythonHandler mod_python.publisher AllowOverride All Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all #AddHandler mod_python .py #PythonDebug On #PythonHandler mod_python.cgihandler # # # ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.1/255.0.0.0 ::1/128 If I strip out the two Directory sections from that and make mine look the same, then instead of trying to download the .py file what I get is this error : Not Found The requested URL /openfreezer/cgi/project_request_handler.py was not found on this server and checking the apache error.log that is of course a 404 But that file definitely exists at that location - no question about it. And interestingly, now my test programs have the opposite reaction. test.py works under this config, but testcgi.py gives me the 404 So I'm just stumped at this point. I've googled everywhere loooking for help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From torriem at gmail.com Thu Feb 16 10:22:44 2012 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Feb 2012 08:22:44 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <4F3D1F44.2040403@gmail.com> On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > The law suites of JAVA Vitrtual Machine from Oracle > are famous now. But in 201X the JVM patents will be > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > easily. Umm what does this have to do with anything? You claimed Jython is or will be available on Android. It's not and Jython isn't being ported to Dalvik and it has nothing to do with patents. Android might use java a language, but the virtual machines are very different. And no expired patents are going to change that fact. Android simply isn't going to run the JVM anytime soon. From benjamin.kaplan at case.edu Thu Feb 16 10:30:36 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Thu, 16 Feb 2012 10:30:36 -0500 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <4F3D1F44.2040403@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <4F3D1F44.2040403@gmail.com> Message-ID: On Feb 16, 2012 10:25 AM, "Michael Torrie" wrote: > > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. > -- I believe the general consensus is that 88888 is a bot. it makes lots of posts that mention key words from the thread its replying to but don't actually mean anything. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Feb 16 10:33:24 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 17 Feb 2012 02:33:24 +1100 Subject: Is this the right list? In-Reply-To: References: Message-ID: On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: > On Feb 15, 4:04?pm, Terry Reedy wrote: >> On 2/15/2012 4:51 PM, Alan McKay wrote: >> >> > Is this the right list? > > This is neither the "right" or "left" list, however, it may be either > the correct or incorrect depending on your question. There's also no "right" or "responsibility" list, but we'll answer user questions here as much as we can anyway. ChrisA From fuzzyman at gmail.com Thu Feb 16 10:35:56 2012 From: fuzzyman at gmail.com (Fuzzyman) Date: Thu, 16 Feb 2012 07:35:56 -0800 (PST) Subject: ANN: mock 0.8 final released Message-ID: <92d2a5e3-981a-4e32-850a-ef4a76bb3e1d@bs8g2000vbb.googlegroups.com> After more than six months development work mock 0.8 has been released. 0.8 is a big release with many new features, general improvements and bugfixes. You can download mock 0.8.0 final from the PyPI page or install it with: pip install -U mock mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects. http://pypi.python.org/pypi/mock http://www.voidspace.org.uk/python/mock/ http://www.voidspace.org.uk/python/mock/changelog.html#version-0-8-0 The only changes in mock 0.8.0 final since 0.8rc2 are: * Improved repr of `sentinel` objects * `ANY` can be used for comparisons against call objects * The return value of `MagicMock.__iter__` can be set to any iterable and isn't required to be an iterator A longer version of this announcement, including the full changelog since mock 0.7 and a couple of short examples of the most important changes, can be found on my blog: http://www.voidspace.org.uk/python/weblog/arch_d7_2012_02_11.shtml#e1234 Michael Foord From bahamutzero8825 at gmail.com Thu Feb 16 10:57:32 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 16 Feb 2012 09:57:32 -0600 Subject: Is this the right list? In-Reply-To: References: Message-ID: <4F3D276C.9010204@gmail.com> On 2/16/2012 9:33 AM, Chris Angelico wrote: > On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson > wrote: >> On Feb 15, 4:04 pm, Terry Reedy wrote: >>> On 2/15/2012 4:51 PM, Alan McKay wrote: >>> >>> > Is this the right list? >> >> This is neither the "right" or "left" list, however, it may be either >> the correct or incorrect depending on your question. > > There's also no "right" or "responsibility" list, but we'll answer > user questions here as much as we can anyway. Do we have "right" and "privilege" lists? -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From ethan at stoneleaf.us Thu Feb 16 11:16:06 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 16 Feb 2012 08:16:06 -0800 Subject: Is this the right list? In-Reply-To: References: Message-ID: <4F3D2BC6.2090307@stoneleaf.us> > On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: >>> On 2/15/2012 4:51 PM, Alan McKay wrote: >>>> Is this the right list? >> >> This is neither the "right" or "left" list, however, it may be either >> the correct or incorrect depending on your question. Alan, Welcome to the list. There are lots of friendly folks here who will try to help. Unfortunately there are also a couple well-known trolls, one of whom is Rick Johnson (aka Ranting Rick). Please do not take his posts as representative of the community. ~Ethan~ From alan.mckay+python at gmail.com Thu Feb 16 11:29:03 2012 From: alan.mckay+python at gmail.com (Alan McKay) Date: Thu, 16 Feb 2012 11:29:03 -0500 Subject: Is this the right list? In-Reply-To: <4F3D2BC6.2090307@stoneleaf.us> References: <4F3D2BC6.2090307@stoneleaf.us> Message-ID: > > Welcome to the list. There are lots of friendly folks here who will try > to help. > > I noticed that already - thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcepl at redhat.com Thu Feb 16 12:17:13 2012 From: mcepl at redhat.com (Matej Cepl) Date: Thu, 16 Feb 2012 18:17:13 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: On 15.2.2012 18:48, Tim Arnold wrote: > Just a note to encourage you to stick with XSLT. I also use lxml for > creating and postprocessing my DocBook documents and it is great. But I > use the DocBook XSL stylesheets to convert to html; if you're like me, > you got discouraged at the strangeness of the XSLT language. No, the strangness is not that bad (well, it is bad ... almost anything feels bad comparing to Python, to be honest, but not the reason I would give up; after all I spent couple of years with Javascript). The terrible debugging is one thing, and even worse, I just still cannot get over rules around spaces: whitespace just jumps at me randomly in random places and is erased in others. Mat?j From emayssat at gmail.com Thu Feb 16 12:19:11 2012 From: emayssat at gmail.com (Emmanuel Mayssat) Date: Thu, 16 Feb 2012 09:19:11 -0800 Subject: list of properties Message-ID: Hello, Is there a way to list 'properties' ? from PyQt4.QtCore import * class LObject(QObject): def __init__(self, parent=None): super(LObject, self).__init__(parent) self.arg1 = 'toto' def getArg2(self): return self.arg1 + " <--" arg2 = property(getArg2) l = LObject() print l.__dict__ returns only arg1 How can I find that arg2 is a 'virtual' attribute (i.e. property)? Regards, -- E -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Thu Feb 16 12:34:18 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 16 Feb 2012 10:34:18 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson wrote: >>> Hi folks, often times in science one expresses a value (say >>> 1.03789291) and its error (say 0.00089) in a short way by parentheses >>> like so: 1.0379(9) >>> >>> One can vary things a bit, but let's take the simplest case when we >>> only keep 1 digit of the error (and round it of course) and round the >>> value correspondingly. I've been searching around for a simple >>> function that would take 2 float arguments and would return a string >>> but didn't find anything although something tells me it's been done a >>> gazillion times. >>> >>> What would be the simplest such function? >> >> Well, this basically works: >> >>>>> def format_error(value, error): >> ... ? ? precision = int(math.floor(math.log(error, 10))) >> ... ? ? format = "%%.%df(%%d)" % max(-precision, 0) >> ... ? ? return format % (round(value, -precision), >> ... ? ? ? ? ? ? ? ? ? ? ?int(round(error / 10 ** precision))) >> ... >>>>> format_error(1.03789291, 0.00089) >> '1.0379(9)' >> >> Note that "math.floor(math.log(error, 10))" may return the wrong >> decimal precision due to binary floating point rounding error, which >> could produce some strange results: >> >>>>> format_error(10378929, 1000) >> '10378900(10)' >> >> So you'll probably want to use decimals instead: >> >> def format_error(value, error): >> ? ? value = decimal.Decimal(value) >> ? ? error = decimal.Decimal(error) >> ? ? value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) >> ? ? error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) >> ? ? precision = value_scale - error_scale >> ? ? if error_scale > 0: >> ? ? ? ? format = "%%.%dE" % max(precision, 0) >> ? ? else: >> ? ? ? ? format = "%%.%dG" % (max(precision, 0) + 1) >> ? ? value_str = format % value.quantize(decimal.Decimal("10") ** >> error_scale) >> ? ? error_str = '(%d)' % error.scaleb(-error_scale).to_integral() >> ? ? if 'E' in value_str: >> ? ? ? ? index = value_str.index('E') >> ? ? ? ? return value_str[:index] + error_str + value_str[index:] >> ? ? else: >> ? ? ? ? return value_str + error_str >> >>>>> format_error(1.03789291, 0.00089) >> '1.0379(9)' >>>>> format_error(103789291, 1000) >> '1.03789(1)E+08' >> >> I haven't tested this thoroughly, so use at your own risk. :-) > > Thanks a lot, this indeed mostly works, except for cases when the > error needs to be rounded up and becomes two digits: > >>>> format_error( '1.34883', '0.0098' ) > '1.349(10)' > > But in this case I'd like to see 1.35(1) A small adjustment to the scale fixes that. Also tidied up the string formatting part: import decimal def format_error(value, error): value = decimal.Decimal(value) error = decimal.Decimal(error) error_scale = error.adjusted() error_scale += error.scaleb(-error_scale).to_integral().adjusted() value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale))) error_str = '(%d)' % error.scaleb(-error_scale).to_integral() if 'E' in value_str: index = value_str.index('E') return value_str[:index] + error_str + value_str[index:] else: return value_str + error_str Cheers, Ian From invalid at invalid.invalid Thu Feb 16 12:38:17 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 16 Feb 2012 17:38:17 +0000 (UTC) Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 2012-02-16, Michael Torrie wrote: > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. I got curious about Dalvik, and was looking at the Wikipedia page, where it says that programs for Android are compiled into bytecode in JVM compatible .class files. Those files are then converted into .dex files to run on Davlik. I don't know much at all about Jython, but if it generates JVM byte code, mightn't the same conversion to .dex be applicable? -- Grant Edwards grant.b.edwards Yow! What I want to find at out is -- do parrots know gmail.com much about Astro-Turf? From invalid at invalid.invalid Thu Feb 16 12:50:11 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 16 Feb 2012 17:50:11 +0000 (UTC) Subject: [semi OT]: Smartphones and Python? References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 2012-02-16, Grant Edwards wrote: > On 2012-02-16, Michael Torrie wrote: > >> You claimed Jython is or will be available on Android. It's not and >> Jython isn't being ported to Dalvik and it has nothing to do with >> patents. Android might use java a language, but the virtual machines >> are very different. And no expired patents are going to change that >> fact. Android simply isn't going to run the JVM anytime soon. > > I got curious about Dalvik, and was looking at the Wikipedia page, > where it says that programs for Android are compiled into bytecode in > JVM compatible .class files. Those files are then converted into > .dex files to run on Davlik. > > I don't know much at all about Jython, but if it generates JVM byte > code, mightn't the same conversion to .dex be applicable? Apparently there was a project to do just that: http://code.google.com/p/jythonroid/ But it's been abandonded in favor of SL4A, which offers a PythonForAndroid_r4.apk download. There's a book about Python on Android via SL4A called _Pro_Android_Python_with_SL4A_. http://www.apress.com/9781430235699 Interesting... -- Grant Edwards grant.b.edwards Yow! World War III? at No thanks! gmail.com From emile at fenx.com Thu Feb 16 13:02:38 2012 From: emile at fenx.com (Emile van Sebille) Date: Thu, 16 Feb 2012 10:02:38 -0800 Subject: list of properties In-Reply-To: References: Message-ID: On 2/16/2012 9:19 AM Emmanuel Mayssat said... > Hello, > > Is there a way to list 'properties' ? dir(thingy) > > > from PyQt4.QtCore import * > > class LObject(QObject): > def __init__(self, parent=None): > super(LObject, self).__init__(parent) > self.arg1 = 'toto' > > def getArg2(self): > return self.arg1 + " <--" > arg2 = property(getArg2) > > l = LObject() > print l.__dict__ > > returns only arg1 arg2 is defined at the class level and not the instance level. l.__dict__ returned the instance attributes. Look in LObject.__dict__ for arg2. Emile > > > How can I find that arg2 is a 'virtual' attribute (i.e. property)? > > Regards, > -- > E > > From silentquote at gmail.com Thu Feb 16 15:11:52 2012 From: silentquote at gmail.com (Sherif Shehab Aldin) Date: Thu, 16 Feb 2012 22:11:52 +0200 Subject: python file synchronization In-Reply-To: <20120208095936.GA31545@cskk.homeip.net> References: <20120208095936.GA31545@cskk.homeip.net> Message-ID: Hi Cameron, First sorry for my very very late reply, has been overloaded at work last week :( Anyways... I will reply inline this time ;) On Wed, Feb 8, 2012 at 11:59 AM, Cameron Simpson wrote: > [ Please reply inline; it makes the discussion read like a converation, > with context. - Cameron > ] > > On 08Feb2012 08:57, Sherif Shehab Aldin wrote: > | Thanks a lot for your help, I just forgot to state that the FTP server is > | not under my command, I can't control how the file grow, or how the > records > | are added, I can only login to It, copy the whole file. > > Oh. That's a pity. > > | The reason why I am parsing the file and trying to get the diffs between > | the new file and the old one, and copy it to new_file.time_stamp is that > I > | need to cut down the file size so when server (C) grabs the file, It > grabs > | only new data, also to cut down the network bandwidth. > > Can a simple byte count help here? Copy the whole file with FTP. From > the new copy, extract the bytes from the last byte count offset onward. > Then parse the smaller file, extracting whole records for use by (C). > That way you can just keep the unparsed tail (partial record I imagine) > around for the next fetch. > > Looking at RFC959 (the FTP protocol): > > http://www.w3.org/Protocols/rfc959/4_FileTransfer.html > > it looks like you can do a partial file fetch, also, by issuing a REST > (restart) command to set a file offset and then issuing a RETR (retrieve) > command to get the rest of the file. These all need to be in binary mode > of course. > > So in principle you could track the byte offset of what you have fetched > with FTP so far, and fetch only what is new. > I am actually grabbing the file from ftp with a bash script using lftp, It seemed a simple task for python at the beginning and then I noticed the many problems. I have checked lftp and did not know how to continue downloading a file. Do I have to use ftp library, may be in python so I can use that feature? > > | One of my problems was after mounting server (B) diffs_dir into Server > (A) > | throw NFS, I used to create filename.lock first into server (B) local > file > | then start copy filename to server (B) then remove filename.lock, so when > | the daemon running on server (C) parses the files in the local_diffs dir, > | ignores the files that are still being copied, > | > | After searching more yesterday, I found that local mv is atomic, so > instead > | of creating the lock files, I will copy the new diffs to tmp dir, and > after > | the copy is over, mv it to actual diffs dir, that will avoid reading It > | while It's still being copied. > > Yes, this sounds good. Provided the mv is on the same filesystem. > > For example: "mv /tmp/foo /home/username/foo" is actually a copy and not > a rename because /tmp is normally a different filesystem from /home. > > Yes they are in same file system, I am making sure of that ;) > | Sorry if the above is bit confusing, the system is bit complex. > > Complex systems often need fiddly solutions. > > | Also there is one more factor that confuses me, I am so bad in testing, > and > | I am trying to start actually implement unit testing to test my code, > what > | I find hard is how to test code like the one that do the copy, mv and so, > | also the code that fetch data from the web. > > Ha. I used to be very bad at testing, now I am improving and am merely > weak. > > One approach to testing is to make a mock up of the other half of the > system, and test against the mockup. > > For example, you have code to FTP new data and then feed it to (C). You > don't control the server side of the FTP. So you might make a small mock > up program that writes valid (but fictitious) data records progressively > to a local data file (write record, flush, pause briefly, etc). If you > can FTP to your own test machine you could then treat _that_ growing > file as the remote server's data file. > > Then you could copy it progressively using a byte count to keep track of > the bits you have seen to skip them, and the the > > If you can't FTP to your test system, you could abstract out the "fetch > part of this file by FTP" into its own function. Write an equivalent > function that fetches part of a local file just by opening it. > > Then you could use the local file version in a test that doesn't > actually do the FTP, but could exercise the rest of it. > > It is also useful to make simple tests of small pieces of the code. > So make the code to get part of the data a simple function, and write > tests to execute it in a few ways (no new data, part of a record, > several records etc). > > You are right, my problem is that I don't care about testing until my code grows badly and then I notice what I got myself into :) But ur suggestion is cool. I will try to implement that once I get back to that project again... As I got some problems with another project currently so I had to go fix them first.. and then the customer wanted some changes.. ;-) There are many people better than I to teach testing. > > I really appreciate your help. I am trying to learn from the mailing list, I noticed many interesting posts in the list already. I wish I could read the python-list same way.. but unfortunately the mail digest they send is quiet annoying :( Many thanks to you, and I will keep you posted if I got other ideas. :) > Cheers, > -- > Cameron Simpson DoD#743 > http://www.cskk.ezoshosting.com/cs/ > > Testing can show the presence of bugs, but not their absence. - Dijkstra > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ramit.prasad at jpmorgan.com Thu Feb 16 16:06:27 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Thu, 16 Feb 2012 21:06:27 +0000 Subject: Python to Combine Multiple Excel Worksheets into One Worksheet In-Reply-To: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> References: <657c4fb5-db56-4bd5-b5a7-112d1d673fbb@d15g2000yqg.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF4741501E8@SCACMX008.exchad.jpmchase.net> >I have one single Excel file with many separate worksheets, and for work I need to combine all these separate worksheets into one single worksheet (I am not worried about formatting, as the format is the same in each sheet, nor am I worried about Excel's row limit). >Essentially, I am looking for a way to append the data in one sheet to the bottom of the sheet that proceeds it. >What would be the best way to do this, and how would I go about doing it? Can it be done simply with the xlwt, xlrd, and xutils modules, or (as I was thinking) do I need to convert the sheets to separate csv files, then append the separate csv files, and then write the completed file back into .xls format? >Or perhaps something else? >As I am really only a Python beginner, any and all help is very much appreciated. Thank you in advance!! Read the data from the different worksheets using xlrd and then use xlwt to write to a single worksheet in a new excel file. The csv option is probably not useful since it will just add an intermediary step unless you are converting outside of python (i.e. manually). Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Thu Feb 16 16:10:42 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Thu, 16 Feb 2012 21:10:42 +0000 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> Message-ID: <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> >> When you reply to a known bot, please include some indication of the >> fact, so we know your message can be ignored as well. >Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. I was wondering the exact same thing. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From arnodel at gmail.com Thu Feb 16 16:51:27 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 16 Feb 2012 21:51:27 +0000 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <27157671.70.1329330986455.JavaMail.geo-discussion-forums@yndy9> <4F3BFE0C.9080603@davea.name> <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> Message-ID: On 16 February 2012 21:10, Prasad, Ramit wrote: >>> When you reply to a known bot, please include some indication of the >>> fact, so we know your message can be ignored as well. > >>Sometimes I wonder about 88888. Is there a real person there, as well as the bot? A lot of his/its > posts look too intelligent to be computer-generated - or maybe I'm underestimating the quality of AI. > > I was wondering the exact same thing. I think it may be that what you are underestimating is your ability, as a human being, to create meaning where there is none. -- Arnaud From fetchinson at googlemail.com Thu Feb 16 17:21:50 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 16 Feb 2012 23:21:50 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On 2/16/12, Ian Kelly wrote: > On Thu, Feb 16, 2012 at 1:36 AM, Daniel Fetchinson > wrote: >>>> Hi folks, often times in science one expresses a value (say >>>> 1.03789291) and its error (say 0.00089) in a short way by parentheses >>>> like so: 1.0379(9) >>>> >>>> One can vary things a bit, but let's take the simplest case when we >>>> only keep 1 digit of the error (and round it of course) and round the >>>> value correspondingly. I've been searching around for a simple >>>> function that would take 2 float arguments and would return a string >>>> but didn't find anything although something tells me it's been done a >>>> gazillion times. >>>> >>>> What would be the simplest such function? >>> >>> Well, this basically works: >>> >>>>>> def format_error(value, error): >>> ... precision = int(math.floor(math.log(error, 10))) >>> ... format = "%%.%df(%%d)" % max(-precision, 0) >>> ... return format % (round(value, -precision), >>> ... int(round(error / 10 ** precision))) >>> ... >>>>>> format_error(1.03789291, 0.00089) >>> '1.0379(9)' >>> >>> Note that "math.floor(math.log(error, 10))" may return the wrong >>> decimal precision due to binary floating point rounding error, which >>> could produce some strange results: >>> >>>>>> format_error(10378929, 1000) >>> '10378900(10)' >>> >>> So you'll probably want to use decimals instead: >>> >>> def format_error(value, error): >>> value = decimal.Decimal(value) >>> error = decimal.Decimal(error) >>> value_scale = value.log10().to_integral(decimal.ROUND_FLOOR) >>> error_scale = error.log10().to_integral(decimal.ROUND_FLOOR) >>> precision = value_scale - error_scale >>> if error_scale > 0: >>> format = "%%.%dE" % max(precision, 0) >>> else: >>> format = "%%.%dG" % (max(precision, 0) + 1) >>> value_str = format % value.quantize(decimal.Decimal("10") ** >>> error_scale) >>> error_str = '(%d)' % error.scaleb(-error_scale).to_integral() >>> if 'E' in value_str: >>> index = value_str.index('E') >>> return value_str[:index] + error_str + value_str[index:] >>> else: >>> return value_str + error_str >>> >>>>>> format_error(1.03789291, 0.00089) >>> '1.0379(9)' >>>>>> format_error(103789291, 1000) >>> '1.03789(1)E+08' >>> >>> I haven't tested this thoroughly, so use at your own risk. :-) >> >> Thanks a lot, this indeed mostly works, except for cases when the >> error needs to be rounded up and becomes two digits: >> >>>>> format_error( '1.34883', '0.0098' ) >> '1.349(10)' >> >> But in this case I'd like to see 1.35(1) > > A small adjustment to the scale fixes that. Also tidied up the string > formatting part: > > import decimal > > def format_error(value, error): > value = decimal.Decimal(value) > error = decimal.Decimal(error) > error_scale = error.adjusted() > error_scale += error.scaleb(-error_scale).to_integral().adjusted() > value_str = str(value.quantize(decimal.Decimal("1E%d" % error_scale))) > error_str = '(%d)' % error.scaleb(-error_scale).to_integral() > if 'E' in value_str: > index = value_str.index('E') > return value_str[:index] + error_str + value_str[index:] > else: > return value_str + error_str > > Cheers, > Ian Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08: Traceback (most recent call last): File "/home/fetchinson/bin/format_error", line 26, in print format_error( sys.argv[1], sys.argv[2] ) File "/home/fetchinson/bin/format_error", line 9, in format_error error_scale += error.scaleb( -error_scale ).to_integral( ).adjusted( ) File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb ans = self._check_nans(other, context) File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans other_is_nan = other._isnan() AttributeError: 'int' object has no attribute '_isnan' Which version of python are you using? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From emekamicro at gmail.com Thu Feb 16 18:10:28 2012 From: emekamicro at gmail.com (Emeka) Date: Fri, 17 Feb 2012 01:10:28 +0200 Subject: Undoing character read from file Message-ID: Hello All, I know about seek and tell while using readline. What about if I am using read, and I want to undo the last character I just read(to return it back to the stream). How do I achieve this? Regards, \Emeka *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Thu Feb 16 18:31:54 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 16 Feb 2012 23:31:54 +0000 Subject: Undoing character read from file In-Reply-To: References: Message-ID: <4F3D91EA.40601@mrabarnett.plus.com> On 16/02/2012 23:10, Emeka wrote: > Hello All, > > I know about seek and tell while using readline. What about if I am > using read, and I want to undo the last character I just read(to return > it back to the stream). How do I achieve this? > Try: f.seek(-1, 1) It seeks -1 relative to the current position (the second argument defaults to 0 for relative to start of file). From ian.g.kelly at gmail.com Thu Feb 16 19:29:27 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 16 Feb 2012 17:29:27 -0700 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: On Thu, Feb 16, 2012 at 3:21 PM, Daniel Fetchinson wrote: > Thanks, it's simpler indeed, but gives me an error for value=1.267, error=0.08: > > Traceback (most recent call last): > ?File "/home/fetchinson/bin/format_error", line 26, in > ? ?print format_error( sys.argv[1], sys.argv[2] ) > ?File "/home/fetchinson/bin/format_error", line 9, in format_error > ? ?error_scale += error.scaleb( -error_scale ).to_integral( ?).adjusted( ?) > ?File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb > ? ?ans = self._check_nans(other, context) > ?File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans > ? ?other_is_nan = other._isnan() > AttributeError: 'int' object has no attribute '_isnan' > > Which version of python are you using? 2.7.1. At a guess, it's failing because scaleb() (which was new in 2.6) is buggily expecting a decimal argument, but adjusted() returns an int. Convert the results of the two adjusted() calls to decimals, and I think it should be fine. From cs at zip.com.au Thu Feb 16 19:33:24 2012 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 17 Feb 2012 11:33:24 +1100 Subject: python file synchronization In-Reply-To: References: Message-ID: <20120217003324.GA15685@cskk.homeip.net> On 16Feb2012 22:11, Sherif Shehab Aldin wrote: | First sorry for my very very late reply, has been overloaded at work last | week :( Me too. There's no hurry at my end, take your time. [...] | > Can a simple byte count help here? Copy the whole file with FTP. From | > the new copy, extract the bytes from the last byte count offset onward. | > Then parse the smaller file, extracting whole records for use by (C). | > That way you can just keep the unparsed tail (partial record I imagine) | > around for the next fetch. | > | > Looking at RFC959 (the FTP protocol): | > | > http://www.w3.org/Protocols/rfc959/4_FileTransfer.html | > | > it looks like you can do a partial file fetch, also, by issuing a REST | > (restart) command to set a file offset and then issuing a RETR (retrieve) | > command to get the rest of the file. These all need to be in binary mode | > of course. | > | > So in principle you could track the byte offset of what you have fetched | > with FTP so far, and fetch only what is new. | | I am actually grabbing the file from ftp with a bash script using lftp, It | seemed a simple task for python at the beginning and then I noticed the | many problems. I have checked lftp and did not know how to continue | downloading a file. Do I have to use ftp library, may be in python so I can | use that feature? Looking at "man lftp" I see that the "get" command has a "-c" option (for "continue"). That probably does it for you. Should be easy to test: - make big file on FTP server - fetch with lftp (interactively - this is all just to check) - append a little data to the file on the server date >> the-big-file - refetch: get -c the-big-file and see how much data gets copied. Hopefully just the new bytes. [...] | > | After searching more yesterday, I found that local mv is atomic, so | > instead | > | of creating the lock files, I will copy the new diffs to tmp dir, and | > after | > | the copy is over, mv it to actual diffs dir, that will avoid reading It | > | while It's still being copied. | > | > Yes, this sounds good. Provided the mv is on the same filesystem. [...] | > Yes they are in same file system, I am making sure of that ;) Good. BTW, when replying inline try to make sure your new text has clean blank lines above and below and has not kept the indentation quote markers. See above that your "Yes they are in same file system" seems to be at the same indentation as my earlier sentence above? That made your reply look like part of the quote instead of a reply, and I nearly missed it. [...] | > It is also useful to make simple tests of small pieces of the code. | > So make the code to get part of the data a simple function, and write | > tests to execute it in a few ways (no new data, part of a record, | > several records etc). | > | > You are right, my problem is that I don't care about testing until my code | grows badly and then I notice what I got myself into :) (Again, see the quoting level?) One approach to get into testing slowly is to make a test for your bug. Suppose something is not working. Write a small function that exhibits the bug, as small as possible. That is now a test function! When you fix the bug, the test function will pass. Keep it around! Some projects have tests for every bug report that gets fixed. Another approach to growing a test suite is to write out a good docstring for somthing, describing with precision what the function arranges i.e. not the internal mechanisms, but what the caller can rely on being true after the function has been called. Then write a test function that calls the main function and then checks each thing the docstring says should be true. Each check is a test. Trite example: def double(x): ''' Return double the value of `x`. The return value will be twice `x`. The return value will be even. ''' return x * 2 class Tests(unitest.TestCase): def test_double(self): for x in 0, 3, 17, 100: # test a few different values x2 = double(x) self.assertEqual(x2, x + x) # test doubling self.assertEqual(x2 % 2, 0) # test evenness You can see that writing out the guarentees in the docstring assists in writing some tests. | > I really appreciate your help. I am trying to learn from the mailing list, | I noticed many interesting posts in the list already. I wish I could read | the python-list same way.. but unfortunately the mail digest they send is | quiet annoying :( I do not use digests - I have my subscription set to individual emails. Just arrange that your mailer files then in a "python" mail folder when they arrive so they do not clutter your inbox. | Many thanks to you, and I will keep you posted if I got other ideas. :) Excellent. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Q: How does a hacker fix a function which doesn't work for all of the elements in its domain? A: He changes the domain. From stodge at gmail.com Thu Feb 16 20:15:59 2012 From: stodge at gmail.com (Stodge) Date: Thu, 16 Feb 2012 17:15:59 -0800 (PST) Subject: Generating class definitions at runtime in memory from XSD or JSON Message-ID: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Does anyone know of a library to generate class definitions in memory, at runtime, from XSD or JSON? I know about PyXB, generateDS and some others, but they all rely on generating python source files at the command line, and then using those to parse XML. Thanks From gheskett at wdtv.com Thu Feb 16 20:40:11 2012 From: gheskett at wdtv.com (gene heskett) Date: Thu, 16 Feb 2012 20:40:11 -0500 Subject: TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL In-Reply-To: References: <3474662.0.1329289996380.JavaMail.geo-discussion-forums@pbcpa10> <5B80DD153D7D744689F57F4FB69AF474150235@SCACMX008.exchad.jpmchase.net> Message-ID: <201202162040.12029.gheskett@wdtv.com> On Thursday, February 16, 2012 08:40:04 PM Arnaud Delobelle did opine: > On 16 February 2012 21:10, Prasad, Ramit wrote: > >>> When you reply to a known bot, please include some indication of the > >>> fact, so we know your message can be ignored as well. > >> > >>Sometimes I wonder about 88888. Is there a real person there, as well > >>as the bot? A lot of his/its > >> > > posts look too intelligent to be computer-generated - or maybe I'm > > underestimating the quality of AI. > > > > I was wondering the exact same thing. > > I think it may be that what you are underestimating is your ability, > as a human being, to create meaning where there is none. Ouch! Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: Why do seagulls live near the sea? 'Cause if they lived near the bay, they'd be called baygulls. From torriem at gmail.com Thu Feb 16 20:45:15 2012 From: torriem at gmail.com (Michael Torrie) Date: Thu, 16 Feb 2012 18:45:15 -0700 Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <4F3DB12B.2000303@gmail.com> On 02/16/2012 10:38 AM, Grant Edwards wrote: > I got curious about Dalvik, and was looking at the Wikipedia page, > where it says that programs for Android are compiled into bytecode in > JVM compatible .class files. Those files are then converted into .dex > files to run on Davlik. > > I don't know much at all about Jython, but if it generates JVM byte > code, mightn't the same conversion to .dex be applicable? I think it has to do with the fact that Jython does dynamic class generation and loading. Similarly I don't think JBoss or Tomcat could be ported easily to Dalvik without making lots of changes to the class loading stuff. But I know nothing about Java, so I could be way wrong here. From yves at zioup.com Thu Feb 16 21:39:22 2012 From: yves at zioup.com (yves at zioup.com) Date: Thu, 16 Feb 2012 19:39:22 -0700 Subject: tkinter.Toplevel Message-ID: With a tkinter.Toplevel, how can I "disable" the parent windown and all its widget, in the same fashion as tkinter.messagebox? -- Yves. http://www.SollerS.ca/ http://ipv6.SollerS.ca http://blog.zioup.org/ From kwa at kuwata-lab.com Thu Feb 16 22:00:00 2012 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Fri, 17 Feb 2012 12:00:00 +0900 Subject: ANN: pyTenjin 1.1.0 - a high-speed and full-featured template engine Message-ID: I released pyTenjin 1.1.0. http://pypi.python.org/pypi/Tenjin/ http://www.kuwata-lab.com/tenjin/ Overview of pyTenjin -------------------- * Very fast: about 10 times faster than Django template engine * Easy to learn: no need to learn template-original language * Full-featured: nestable layout template, partial template, preprocessing, etc. * Lightweight: only 2000 lines of code and very fast to import. * Google App Engine supported Documents --------- * User's Guide http://www.kuwata-lab.com/tenjin/pytenjin-users-guide.html * Examples http://www.kuwata-lab.com/tenjin/pytenjin-examples.html * CHANGES http://www.kuwata-lab.com/tenjin/pytenjin-CHANGES.txt Install ------- $ sudo easy_install Tenjin Or: $ wget http://pypi.python.org/packages/source/T/Tenjin/Tenjin-1.1.0.tar.gz $ tar xzf Tenjin-1.1.0.tar.gz $ cd Tenjin-1.1.0/ $ sudo python setup.py install Example ------- ## views/example.pyhtml

${title}

${item}
## main.py import tenjin #tenjin.set_template_encoding('utf-8') # optional (default 'utf-8') from tenjin.helpers import * from tenjin.html import * engine = tenjin.Engine(path=['views']) context = {'title': 'Example', 'items': ['Haruhi', 'Mikuru', 'Yuki'] } output = engine.render('example.pyhtml', context) print(output) ## output $ python main.py

Example

Haruhi
Mikuru
Yuki
Enhancements and Changes in this release ---------------------------------------- (See http://www.kuwata-lab.com/tenjin/pytenjin-CHANGES.txt for details.) * [Change] !! IMPORTANT!! Default cache file format is changed from marshal format to text format. You should remove all cache files to use this release. * [Enhance] Embedded pattern '${}' and '#{}' can contain pair of '{' and '}'. ::

${foo({'x':1})}

# OK

${foo({}+{}+{})}

# OK

${foo({'x':{'y':1}})}

# NG * [Enhance] New preprocessing mechanism. You can specify your own preprocessor class by 'pp' parameter. * [Enhance] Add 'TrimPreprocessor' which removes spaces ad the beginning of lines. You can reduce size of output by it. * [Enhance] Add 'PrefixedLinePreprocessor' which converts ':: ...' into ''. You may like ':: ...' because it is simpler than ''. * [Enhance] Add 'JavaScriptPreprocessor' class which enables you to embed client-side javascript template code into server-side template. For example::
#{i} ${items[i]}
will be converted into::
by JavaScriptPreprocessor. Notice that you should embed 'tenjin.JS_FUNC' to run client-side code. How to use it:: pp = [ tenjin.JavaScriptPreprocessor() ] engine = tenjin.Engine(pp=pp) output = engine.render('example.pyhtml', {}) print(html) * [Enhance] Now supports Jython 2.5.2. (thanks to Lars Hupfeldt Nielsen) * [Enhance] Now supports PyPy 1.7 or later officially. * [Change] Template#convert() now converts "\r\n" into "\\r\n". This is necessary to follow change of language specification on Python 2.7 and 3.2. Have fun! -- makoto kuwata From dihedral88888 at googlemail.com Fri Feb 17 00:25:55 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 21:25:55 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> ? 2012?2?16????UTC+8??11?22?44??Michael Torrie??? > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. The memory systems in mobile phones are different from PCs. This is the current situation in the consumer electronics sector. From dihedral88888 at googlemail.com Fri Feb 17 00:25:55 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Thu, 16 Feb 2012 21:25:55 -0800 (PST) Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> ? 2012?2?16????UTC+8??11?22?44??Michael Torrie??? > On 02/16/2012 07:53 AM, 88888 Dihedral wrote: > > The law suites of JAVA Vitrtual Machine from Oracle > > are famous now. But in 201X the JVM patents will be > > expired, thus it is not very urgent to chunk out a new jython now. Anyway just write codes that can be maintained and ported to other languages and platforms > > easily. > > Umm what does this have to do with anything? > > You claimed Jython is or will be available on Android. It's not and > Jython isn't being ported to Dalvik and it has nothing to do with > patents. Android might use java a language, but the virtual machines > are very different. And no expired patents are going to change that > fact. Android simply isn't going to run the JVM anytime soon. Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. The memory systems in mobile phones are different from PCs. This is the current situation in the consumer electronics sector. From timr at probo.com Fri Feb 17 01:09:11 2012 From: timr at probo.com (Tim Roberts) Date: Thu, 16 Feb 2012 22:09:11 -0800 Subject: Numerical Linear Algebra in arbitrary precision References: Message-ID: Ken wrote: > >Brand new Python user and a bit overwhelmed with the variety of >packages available. Any recommendation for performing numerical >linear algebra (specifically least squares and generalized least >squares using QR or SVD) in arbitrary precision? I've been looking at >mpmath but can't seem to find much info on built in functions except >for LU decomposition/solve. It is been my experience that numpy is the best place to start with requests like this, although I don't know whether it will actually solve your specific tasks: http://docs.scipy.org/doc/numpy/reference/routines.linalg.html -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dllizheng at gmail.com Fri Feb 17 02:53:00 2012 From: dllizheng at gmail.com (Zheng Li) Date: Fri, 17 Feb 2012 16:53:00 +0900 Subject: question about function pointer Message-ID: def method1(a = None): print a i can call it by method1(*(), **{'a' : 1}) I am just curious why it works and how it works? and what do *() and **{'a' : 1} mean? when I type *() in python shell, error below happens File "", line 1 *() ^ SyntaxError: invalid syntax From arnodel at gmail.com Fri Feb 17 03:00:54 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 17 Feb 2012 08:00:54 +0000 Subject: question about function pointer In-Reply-To: References: Message-ID: On 17 February 2012 07:53, Zheng Li wrote: > def method1(a = None): > ? ? ? ?print a > > i can call it by > method1(*(), **{'a' : 1}) > > I am just curious why it works and how it works? > and what do *() and **{'a' : 1} mean? > > when I type *() in python shell, error below happens > > ?File "", line 1 > ? ?*() > ? ?^ > SyntaxError: invalid syntax It's worth reading the Python tutorial. Here's the relevant section: http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists You could read all of 4.7 -- Arnaud From dhrati1singh at gmail.com Fri Feb 17 03:45:47 2012 From: dhrati1singh at gmail.com (Dhrati Singh) Date: Fri, 17 Feb 2012 00:45:47 -0800 (PST) Subject: PHP Tutorials Message-ID: <87e1550c-36c8-42ad-8e8d-da74ed862979@i10g2000pbc.googlegroups.com> R4R provide basic PHP Tutorials with PHP Examples .Through R4R you can develop PHP programming concept. R4R provide PHP Interview Questions with answers.R4R provide PHP programming basic knowledge and related all programming skills. PHP- Hypertext Preprocessor is server side script language like ASP. Its scripts executes on server. PHP is open source software. The goal of PHP language is to allow web developers to write dynamically generated pages quickly. The origins of PHP date back to 1995.PHP was written in the C programming language by Rasmus Lerdorf in 1995 for use in monitoring his online resume and related personal information. For this reason, PHP originally stood for "Personal Home Page". From wxjmfauth at gmail.com Fri Feb 17 04:17:32 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Fri, 17 Feb 2012 01:17:32 -0800 (PST) Subject: format a measurement result and its error in "scientific" way References: Message-ID: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> On 16 f?v, 01:18, Daniel Fetchinson wrote: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) > Before swallowing any Python solution, you should realize, the values (value, error) you are using are a non sense : 1.03789291 +/- 0.00089 You express "more precision" in the value than in the error. --- As ex, in a 1.234(5) notation, the "()" is usually used to indicate the accuracy of the digit in "()". Eg 1.345(7) Typographically, the "()" is sometimes replaced by a bold digit ou a subscripted digit. jmf From nobody at nowhere.com Fri Feb 17 04:55:11 2012 From: nobody at nowhere.com (Nobody) Date: Fri, 17 Feb 2012 09:55:11 +0000 Subject: question about function pointer References: Message-ID: On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: > def method1(a = None): > print a > > i can call it by > method1(*(), **{'a' : 1}) > > I am just curious why it works and how it works? > and what do *() and **{'a' : 1} mean? In a function call, an argument consisting of * followed by an expression of tuple type inserts the tuple's elements as individual positional arguments. An argument consisting of ** followed by an expression of dictionary type inserts the dictionary's elements as individual keyword arguments. So if you have: a = (1,2,3) b = {'a': 1, 'b': 2, 'c': 3} then: func(*a, **b) is equivalent to: func(1, 2, 3, a = 1, b = 2, c = 3) > when I type *() in python shell, error below happens > > File "", line 1 > *() > ^ > SyntaxError: invalid syntax The syntax described above is only valid within function calls. There is a similar syntax for function declarations which does the reverse: > def func(*a, **b): print a print b > func(1, 2, 3, a = 1, b = 2, c = 3) (1, 2, 3) {'a': 1, 'c': 3, 'b': 2} From fetchinson at googlemail.com Fri Feb 17 05:00:27 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 17 Feb 2012 11:00:27 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: >> Thanks, it's simpler indeed, but gives me an error for value=1.267, >> error=0.08: >> >> Traceback (most recent call last): >> File "/home/fetchinson/bin/format_error", line 26, in >> print format_error( sys.argv[1], sys.argv[2] ) >> File "/home/fetchinson/bin/format_error", line 9, in format_error >> error_scale += error.scaleb( -error_scale ).to_integral( ).adjusted( >> ) >> File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb >> ans = self._check_nans(other, context) >> File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans >> other_is_nan = other._isnan() >> AttributeError: 'int' object has no attribute '_isnan' >> >> Which version of python are you using? > > 2.7.1. At a guess, it's failing because scaleb() (which was new in > 2.6) is buggily expecting a decimal argument, but adjusted() returns an int. > Convert the results of the two adjusted() calls to decimals, and I > think it should be fine. Great, with python 2.7 it works indeed! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From nobody at nowhere.com Fri Feb 17 05:02:27 2012 From: nobody at nowhere.com (Nobody) Date: Fri, 17 Feb 2012 10:02:27 +0000 Subject: Generating class definitions at runtime in memory from XSD or JSON References: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Message-ID: On Thu, 16 Feb 2012 17:15:59 -0800, Stodge wrote: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? I know about PyXB, generateDS and some > others, but they all rely on generating python source files at the > command line, and then using those to parse XML. You don't need a library to generate classes. If the type() function is called with 3 arguments, it creates and returns a new class. The first argument is the name of the class, the second argument a tuple of base classes, the third argument is the class' dictionary. E.g.: class Foo(Bar, Baz): def __init__(self): pass could be written as: def foo_init(self): pass Foo = type('Foo', (Bar, Baz), {'__init__': foo_init}) If you want to generate the function bodies from the contents of the JSON or XML file, use exec(). From fetchinson at googlemail.com Fri Feb 17 05:03:42 2012 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 17 Feb 2012 11:03:42 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> References: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> Message-ID: >> Hi folks, often times in science one expresses a value (say >> 1.03789291) and its error (say 0.00089) in a short way by parentheses >> like so: 1.0379(9) > > Before swallowing any Python solution, you should > realize, the values (value, error) you are using are > a non sense : > > 1.03789291 +/- 0.00089 > > You express "more precision" in the value than > in the error. My impression is that you didn't understand the original problem: given an arbitrary value to arbitrary digits and an arbitrary error, find the relevant number of digits for the value that makes sense for the given error. So what you call "non sense" is part of the problem to be solved. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From robert.kern at gmail.com Fri Feb 17 05:26:56 2012 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 17 Feb 2012 10:26:56 +0000 Subject: Numerical Linear Algebra in arbitrary precision In-Reply-To: References: Message-ID: On 2/17/12 6:09 AM, Tim Roberts wrote: > Ken wrote: >> >> Brand new Python user and a bit overwhelmed with the variety of >> packages available. Any recommendation for performing numerical >> linear algebra (specifically least squares and generalized least >> squares using QR or SVD) in arbitrary precision? I've been looking at >> mpmath but can't seem to find much info on built in functions except >> for LU decomposition/solve. > > It is been my experience that numpy is the best place to start with > requests like this, although I don't know whether it will actually solve > your specific tasks: > > http://docs.scipy.org/doc/numpy/reference/routines.linalg.html This will not do arbitrary-precision, though. We use the double- and single-precision routines from LAPACK. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From ulrich.eckhardt at dominolaser.com Fri Feb 17 06:16:38 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Fri, 17 Feb 2012 12:16:38 +0100 Subject: format a measurement result and its error in "scientific" way In-Reply-To: References: Message-ID: Am 16.02.2012 01:18, schrieb Daniel Fetchinson: > Hi folks, often times in science one expresses a value (say > 1.03789291) and its error (say 0.00089) in a short way by parentheses > like so: 1.0379(9) Just so that I understand you, the value of the last "digit" is somewhere between 9-9 and 9+9, right? So the value itself is rounded so that its last digit has the same value as the only digit to which the error is rounded. > One can vary things a bit, but let's take the simplest case when we > only keep 1 digit of the error (and round it of course) and round the > value correspondingly. First step is to format the values as decimal string ('{0:f}'.format). Then, pad both values to the same number of digits before and after the radix separator. Then, iterate over the strings, those digits where the error digits are zero are those that are taken verbatim for the value. The following digit is rounded and then added to the result. The according digit in the error is also rounded and added in brackets. Note that you can not compute these "values", since the definition of the rounding depends on a decimal representation. If you have decimal floating point numbers, where 0.1 is representable without loss, you could actually do that. In order to allow common treatment as decimal as required for this algorithm, the first step above was the conversion to a decimal string. Write tests that make sure this works, e.g. I ignored any sign and you also can't use str() to format the value because that could give you "123.45e+5" as a result. Good luck! Uli From fabiofz at gmail.com Fri Feb 17 06:54:21 2012 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 17 Feb 2012 09:54:21 -0200 Subject: How to make PyDev pep8 friendly? In-Reply-To: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> References: <5321a1a2-679e-4808-a04e-bdd639dba78d@db5g2000vbb.googlegroups.com> Message-ID: On Wed, Feb 8, 2012 at 10:15 PM, Ali Zandi wrote: > Hi, > > I was trying to find a way to configure PyDev e.g. in Eclipse to be > pep8 friendly. > > There are a few configurations like right trim lines, use space after > commas, use space before and after operators, add new line at the end > of file which can be configured via Eclipse -> Window -> Preferences - >> PyDev -> Editor -> Code Style -> Code Formatter. But these are not > enough; for example I couldn't find a way to configure double line > spacing between function definitions. > > So is there any way to configure eclipse or PyDev to apply pep8 rules > e.g. on each save? > While this is known, there are still no dates on when this will actually be implemented... On the other way, I'd love to accept patches for that... it could even be done in Python (actually Jython 2.2.1) -- which is also the way that pep8.py was integrated. Cheers, Fabio From wxjmfauth at gmail.com Fri Feb 17 07:13:04 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Fri, 17 Feb 2012 04:13:04 -0800 (PST) Subject: format a measurement result and its error in "scientific" way References: <955b9613-2386-40ef-bbf7-c60ef623b0cd@k6g2000vbz.googlegroups.com> Message-ID: On 17 f?v, 11:03, Daniel Fetchinson wrote: > >> Hi folks, often times in science one expresses a value (say > >> 1.03789291) and its error (say 0.00089) in a short way by parentheses > >> like so: 1.0379(9) > > > Before swallowing any Python solution, you should > > realize, the values (value, error) you are using are > > a non sense : > > > 1.03789291 +/- 0.00089 > > > You express "more precision" in the value than > > in the error. > > My impression is that you didn't understand the original problem: > given an arbitrary value to arbitrary digits and an arbitrary error, > find the relevant number of digits for the value that makes sense for > the given error. So what you call "non sense" is part of the problem > to be solved. > I do not know where these numbers (value, error) are coming from. But, when the value and the error have not the same "precision", there is already something wrong somewhere. And this, *prior* to any representation of these values/numbers. jmf From stefan_ml at behnel.de Fri Feb 17 07:57:14 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 17 Feb 2012 13:57:14 +0100 Subject: Generating class definitions at runtime in memory from XSD or JSON In-Reply-To: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> References: <5cf03bed-8173-4910-80d1-5716334a6184@z9g2000vbv.googlegroups.com> Message-ID: Stodge, 17.02.2012 02:15: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? The question is: why do you want to do that? There may be other ways to do what you *actually* want to do, but we don't know what that is. Stefan From neilc at norwich.edu Fri Feb 17 08:12:07 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 17 Feb 2012 13:12:07 GMT Subject: Undoing character read from file References: Message-ID: <9q7217F6j0U3@mid.individual.net> On 2012-02-16, MRAB wrote: > On 16/02/2012 23:10, Emeka wrote: >> Hello All, >> >> I know about seek and tell while using readline. What about if I am >> using read, and I want to undo the last character I just read(to return >> it back to the stream). How do I achieve this? >> > Try: > > f.seek(-1, 1) > > It seeks -1 relative to the current position (the second > argument defaults to 0 for relative to start of file). Unless it's a stream opened in binary mode this will not work. You'd need to maintain a n-character length buffer instead, with n being the maximum number of characters you'd like to be able to put back. -- Neil Cerutti From dihedral88888 at googlemail.com Fri Feb 17 08:20:52 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 05:20:52 -0800 (PST) Subject: question about function pointer In-Reply-To: References: Message-ID: <11998859.481.1329484852059.JavaMail.geo-discussion-forums@pbux2> ? 2012?2?17????UTC+8??5?55?11??Nobody??? > On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: > > > def method1(a = None): > > print a > > > > i can call it by > > method1(*(), **{'a' : 1}) > > > > I am just curious why it works and how it works? > > and what do *() and **{'a' : 1} mean? > > In a function call, an argument consisting of * followed by an expression > of tuple type inserts the tuple's elements as individual positional > arguments. An argument consisting of ** followed by an expression of > dictionary type inserts the dictionary's elements as individual keyword > arguments. > > So if you have: > > a = (1,2,3) > b = {'a': 1, 'b': 2, 'c': 3} > > then: > > func(*a, **b) > > is equivalent to: > > func(1, 2, 3, a = 1, b = 2, c = 3) > > > when I type *() in python shell, error below happens > > > > File "", line 1 > > *() > > ^ > > SyntaxError: invalid syntax > > The syntax described above is only valid within function calls. > > There is a similar syntax for function declarations which does the reverse: > > > def func(*a, **b): > print a > print b > > > func(1, 2, 3, a = 1, b = 2, c = 3) > (1, 2, 3) > {'a': 1, 'c': 3, 'b': 2} In the functional programming view, 2 to 5 object parameters are enough to invoke a function. But the tuple and dictionary packing and unpacking are not free in the run time. Enhancement to operations of basic types in Python can speed up everything. From jeanmichel at sequans.com Fri Feb 17 08:49:37 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 17 Feb 2012 14:49:37 +0100 Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <4F3E5AF1.1050802@sequans.com> Vinay Sajip wrote: > Sarge, a cross-platform library which wraps the subprocess module in > the standard library, has been released. > > What does it do? > ---------------- > > Sarge tries to make interfacing with external programs from your > Python applications easier than just using subprocess alone. > > Sarge offers the following features: > > * A simple way to run command lines which allows a rich subset of Bash- > style shell command syntax, but parsed and run by sarge so that you > can run on Windows without cygwin (subject to having those commands > available): > > >>> from sarge import capture_stdout > >>> p = capture_stdout('echo foo | cat; echo bar') > >>> for line in p.stdout: print(repr(line)) > ... > 'foo\n' > 'bar\n' > > * The ability to format shell commands with placeholders, such that > variables are quoted to prevent shell injection attacks. > > * The ability to capture output streams without requiring you to > program your own threads. You just use a Capture object and then you > can read from it as and when you want. > > Advantages over subprocess > --------------------------- > > Sarge offers the following benefits compared to using subprocess: > > * The API is very simple. > > * It's easier to use command pipelines - using subprocess out of the > box often leads to deadlocks because pipe buffers get filled up. > > * It would be nice to use Bash-style pipe syntax on Windows, but > Windows shells don't support some of the syntax which is useful, like > &&, ||, |& and so on. Sarge gives you that functionality on Windows, > without cygwin. > > * Sometimes, subprocess.Popen.communicate() is not flexible enough for > one's needs - for example, when one needs to process output a line at > a time without buffering the entire output in memory. > > * It's desirable to avoid shell injection problems by having the > ability to quote command arguments safely. > > * subprocess allows you to let stderr be the same as stdout, but not > the other way around - and sometimes, you need to do that. > > Python version and platform compatibility > ----------------------------------------- > > Sarge is intended to be used on any Python version >= 2.6 and is > tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 on Linux, > Windows, and Mac OS X (not all versions are tested on all platforms, > but sarge is expected to work correctly on all these versions on all > these platforms). > > Finding out more > ---------------- > > You can read the documentation at > > http://sarge.readthedocs.org/ > > There's a lot more information, with examples, than I can put into > this post. > > You can install Sarge using "pip install sarge" to try it out. The > project is hosted on BitBucket at > > https://bitbucket.org/vinay.sajip/sarge/ > > And you can leave feedback on the issue tracker there. > > I hope you find Sarge useful! > > Regards, > > > Vinay Sajip > Hi, Thanks for sharing, I hope this one will be as successful as the logging module, possibly integrated into a next version of subprocess. I can't use it though, I'm still using a vintage 2.5 version :-/ JM From lists.eckel at gmail.com Fri Feb 17 10:35:10 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Fri, 17 Feb 2012 07:35:10 -0800 (PST) Subject: Python code file prototype Message-ID: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> I finally figured out how to set up the Windows explorer's right-click "new" so that it will create Python files. Here's how: http://superuser.com/questions/34704/windows-7-add-an-item-to-new-context-menu There's an option when you do this to insert default file contents, so I began searching the web for some kind of prototype Python file that would be appropriate to start with. I'm certain I've seen this before and that there's been discussions about the best starting point for a python code file, but I find I can't get any search hits for it. Hoping for some links, thanks. From gordon at panix.com Fri Feb 17 11:20:37 2012 From: gordon at panix.com (John Gordon) Date: Fri, 17 Feb 2012 16:20:37 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: In <66ea0353-02ee-4152-947a-97b44ff3ec45 at p7g2000yqk.googlegroups.com> Bruce Eckel writes: > There's an option when you do this to insert default file contents, so > I began searching the web for some kind of prototype Python file that > would be appropriate to start with. I'm certain I've seen this before > and that there's been discussions about the best starting point for a > python code file, but I find I can't get any search hits for it. Here's what PyScripter inserts in a new python file: #--------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: $USERNAME # # Created: $DATE # Copyright: (c) $USERNAME $YEAR # Licence: #--------------------------------------------------------------------- #!/usr/bin/env python def main(): pass if __name__ == '__main__': main() Where $USERNAME, $DATE and $YEAR are expanded to the actual values. -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From ian.g.kelly at gmail.com Fri Feb 17 11:55:46 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 17 Feb 2012 09:55:46 -0700 Subject: Python code file prototype In-Reply-To: References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 9:20 AM, John Gordon wrote: > Here's what PyScripter inserts in a new python file: > > ?#--------------------------------------------------------------------- > ?# Name: ? ? ? ?module1 > ?# Purpose: > ?# > ?# Author: ? ? ?$USERNAME > ?# > ?# Created: ? ? $DATE > ?# Copyright: ? (c) $USERNAME $YEAR > ?# Licence: ? ? > ?#--------------------------------------------------------------------- > ?#!/usr/bin/env python > > ?def main(): > ? ? ?pass > > ?if __name__ == '__main__': > ? ? ?main() The shebang has to be the first thing in the file to be useful. As it is above, it might as well not be there. I would suggest also including a doc string in the skeleton. Cheers, Ian From invalid at invalid.invalid Fri Feb 17 12:02:31 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 17 Feb 2012 17:02:31 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On 2012-02-17, John Gordon wrote: > In <66ea0353-02ee-4152-947a-97b44ff3ec45 at p7g2000yqk.googlegroups.com> Bruce Eckel writes: > >> There's an option when you do this to insert default file contents, so >> I began searching the web for some kind of prototype Python file that >> would be appropriate to start with. I'm certain I've seen this before >> and that there's been discussions about the best starting point for a >> python code file, but I find I can't get any search hits for it. > > Here's what PyScripter inserts in a new python file: > > #--------------------------------------------------------------------- > # Name: module1 > # Purpose: > # > # Author: $USERNAME > # > # Created: $DATE > # Copyright: (c) $USERNAME $YEAR > # Licence: > #--------------------------------------------------------------------- > #!/usr/bin/env python > > def main(): > pass > > if __name__ == '__main__': > main() > > > Where $USERNAME, $DATE and $YEAR are expanded to the actual values. That's just plain broken. The "#!" line has to be first thing in the file for it to be recognized. Apart from that, my personal opinion is that comment blocks like that are bad practice. They're too often wrong (e.g. file got copied modified, but comment block not updated), and the right place for metadata like that is the filesystem and the source-control system (git, mercurial, subversion, CVS, whatever -- anything but VSS). -- Grant From vinay_sajip at yahoo.co.uk Fri Feb 17 12:19:07 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Fri, 17 Feb 2012 09:19:07 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. References: Message-ID: On Feb 17, 1:49?pm, Jean-Michel Pichavant wrote: > I can't use it though, I'm still using a vintage 2.5 version :-/ That's a shame. I chose 2.6 as a baseline for this package, because I need it to work on Python 2.x and 3.x with the same code base and minimal work, and that meant supporting Unicode literals via "from __future__ import unicode_literals". I'm stuck on 2.5 with other projects, so I share your pain :-( Regards, Vinay Sajip From dihedral88888 at googlemail.com Fri Feb 17 12:29:37 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 09:29:37 -0800 (PST) Subject: ANN: Sarge, a library wrapping the subprocess module, has been released. In-Reply-To: References: Message-ID: <14723790.1488.1329499777166.JavaMail.geo-discussion-forums@pbvr2> Check PY2EXE, PYREX and PSYChO. I must use these packages to relase commercial products with my own dll in c. From srinivaszmr at gmail.com Fri Feb 17 13:17:58 2012 From: srinivaszmr at gmail.com (vas) Date: Fri, 17 Feb 2012 10:17:58 -0800 (PST) Subject: click here for new updates>PYTHON Message-ID: <7fdb46c1-60d0-4f4d-8be0-b95ee605111b@ow3g2000pbc.googlegroups.com> http://123maza.com/48/plant826/ From kj4eit at gmail.com Fri Feb 17 13:51:42 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 10:51:42 -0800 (PST) Subject: signed to unsigned Message-ID: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> In C or C++, I can do this for integer conversion: unsigned int j = -327681234; // Notice this is signed. j will equal 3967286062. I thought with Python that I could use struct to pack the signed int as an unsigned int, but that fails: >>> x = struct.pack("", line 1, in struct.error: integer out of range for 'I' format code Is there an easy way in Python to do the same conversion that C or C++ code does? Thanks for any advice. From lists.eckel at gmail.com Fri Feb 17 14:03:52 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Fri, 17 Feb 2012 11:03:52 -0800 (PST) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: <7e33534f-0898-4cab-9782-9bdc2584586a@t5g2000yqk.googlegroups.com> > ? ? ? ? Of course, since the OP was talking Windows... the #! line is > ignored no matter where it was Yes, but I use Windows, Mac and Linux so I'm searching for something universal. From clp2 at rebertia.com Fri Feb 17 14:05:23 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 17 Feb 2012 11:05:23 -0800 Subject: signed to unsigned In-Reply-To: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 10:51 AM, Brad Tilley wrote: > In C or C++, I can do this for integer conversion: > > unsigned int j = -327681234; // Notice this is signed. > > j will equal 3967286062. I thought with Python that I could use struct > to pack the signed int as an unsigned int, but that fails: > >>>> x = struct.pack(" Traceback (most recent call last): > ?File "", line 1, in > struct.error: integer out of range for 'I' format code > > Is there an easy way in Python to do the same conversion that C or C++ > code does? Thanks for any advice. Pack it as the actual type, then unpack it as the desired type: Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) Type "help", "copyright", "credits" or "license" for more information. >>> from struct import pack, unpack >>> unpack('=I', pack('=i',-327681234)) (3967286062,) I would think there's some more efficient way to do this though. Cheers, Chris From kj4eit at gmail.com Fri Feb 17 14:10:36 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 11:10:36 -0800 (PST) Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: <34af3238-9541-48bf-b1a3-bd1e07f1fbc5@w1g2000vbg.googlegroups.com> > Pack it as the actual type, then unpack it as the desired type: > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > Type "help", "copyright", "credits" or "license" for more information.>>> from struct import pack, unpack > >>> unpack('=I', pack('=i',-327681234)) > > (3967286062,) > > I would think there's some more efficient way to do this though. > > Cheers, > Chris Thanks Chris! I was doing it backwards. I only have a few of these right now, so performance isn't a concern. I appreciate the advice. Brad From __peter__ at web.de Fri Feb 17 14:14:46 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 17 Feb 2012 20:14:46 +0100 Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: Brad Tilley wrote: > In C or C++, I can do this for integer conversion: > > unsigned int j = -327681234; // Notice this is signed. > > j will equal 3967286062. I thought with Python that I could use struct > to pack the signed int as an unsigned int, but that fails: > >>>> x = struct.pack(" Traceback (most recent call last): > File "", line 1, in > struct.error: integer out of range for 'I' format code > > Is there an easy way in Python to do the same conversion that C or C++ > code does? Thanks for any advice. >>> 0xffffffff & -327681234 3967286062 From kj4eit at gmail.com Fri Feb 17 14:22:43 2012 From: kj4eit at gmail.com (Brad Tilley) Date: Fri, 17 Feb 2012 11:22:43 -0800 (PST) Subject: signed to unsigned References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> Message-ID: <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> > >>> 0xffffffff & -327681234 > > 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0xffffffffffffffff & -9151314442815602945 9295429630893948671L From d at davea.name Fri Feb 17 14:37:52 2012 From: d at davea.name (Dave Angel) Date: Fri, 17 Feb 2012 14:37:52 -0500 Subject: signed to unsigned In-Reply-To: <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> References: <436b024b-20f7-462b-a21e-11f44802e578@s7g2000vby.googlegroups.com> <17514709-e8bc-4533-b9db-5cf9b27c4c90@m2g2000vbc.googlegroups.com> Message-ID: <4F3EAC90.5010209@davea.name> On 02/17/2012 02:22 PM, Brad Tilley wrote: >>>>> 0xffffffff& -327681234 >> 3967286062 > Very nice! Thanks for that example. Unsigned long longs: > > 0xffffffffffffffff& -9151314442815602945 > 9295429630893948671L Or more generally, use modulo -13452324 % 2^64 -- DaveA From ramit.prasad at jpmorgan.com Fri Feb 17 15:09:53 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Fri, 17 Feb 2012 20:09:53 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <0d04f99d-f7a0-4b8a-9552-e545a012decd@p7g2000yqk.googlegroups.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474151A5C@SCACMX008.exchad.jpmchase.net> >> They also don't need to put up with people who aren't seriously ill - I >> don't know how long your private appointments are, but here in the UK a >> standard doctor's appointment is 5-10 minutes. If they decide you're >> actually ill they may extend that. >Five to ten minutes? Is the doctor an a-hole or a machine? Can a >doctor REALLY diagnose an illness in five to ten minutes? Are you >joking? And if not, do you ACTUALLY want the experience to be >synonymous with an assembly line? You don't fear misdiagnosis? I envy >your bravery! Actually, I find that (5-10 minutes of doctor time) completely true even in America. The difference is that I spend 30-60minutes waiting to be called, then another 5min with a nurse for pre-doctor stuff (blood pressure, why I am there, etc), finally another 5 minutes with the nurse for any necessary post-doctor work (drawing blood, shots, etc.). My total doctor talking time is really 5-10 minutes. Of course, if I was sick in an unusual way then the doctor would see me for longer, but the average doctor tends to see the same couple dozen things over and over. This is true for every doctor I can remember, but YMMV. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From rridge at csclub.uwaterloo.ca Fri Feb 17 15:37:57 2012 From: rridge at csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 17 Feb 2012 15:37:57 -0500 Subject: XSLT to Python script conversion? References: Message-ID: Matej Cepl wrote: >No, the strangness is not that bad (well, it is bad ... almost anything >feels bad comparing to Python, to be honest, but not the reason I would >give up; after all I spent couple of years with Javascript). The XSLT language is one of the worst misuses of XML, which puts it way beyond bad. >The terrible debugging is one thing, and even worse, I just still cannot >get over rules around spaces: whitespace just jumps at me randomly in >random places and is erased in others. I use explicit nodes exclusively to avoid this problem. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From stefan_ml at behnel.de Fri Feb 17 15:53:48 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 17 Feb 2012 21:53:48 +0100 Subject: XSLT to Python script conversion? In-Reply-To: References: Message-ID: Ross Ridge, 17.02.2012 21:37: > Matej Cepl wrote: >> No, the strangness is not that bad (well, it is bad ... almost anything >> feels bad comparing to Python, to be honest, but not the reason I would >> give up; after all I spent couple of years with Javascript). > > The XSLT language is one of the worst misuses of XML, which puts it way > beyond bad. Clearly a matter of opinion. Stefan From rridge at csclub.uwaterloo.ca Fri Feb 17 16:11:17 2012 From: rridge at csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 17 Feb 2012 16:11:17 -0500 Subject: XSLT to Python script conversion? References: Message-ID: Ross Ridge writes: > The XSLT language is one of the worst misuses of XML, which puts it way > beyond bad. Stefan Behnel wrote: >Clearly a matter of opinion. No. There's no excuse for using XML as the syntax of a language like XLST. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From jugurtha.hadjar at gmail.com Fri Feb 17 17:01:27 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Fri, 17 Feb 2012 23:01:27 +0100 Subject: Beware, my computer was infected. In-Reply-To: <4F3C4F31.8020303@gmail.com> References: <4F3C4F31.8020303@gmail.com> Message-ID: <4F3ECE37.9000401@gmail.com> On 16/02/2012 01:34, Jugurtha Hadjar wrote: > Hello gentlemen, > > I'm writing these words to give you a heads up. My computer has > recently been infected with "1.exe", and I am doing what I can to > contain it. It spreads via mail and I fear it will send SPAM to lists > I am subscribed to. > > If you receive weird mails from my address, thank you to report it to > me. I will not send you an executable, so if you receive one from me, > please do not open it and it would be nice to report it. > > I will send an e-mail to this list once I think it is no longer in > the system. > > Thank you all. > Everything is under control. -- ~Jugurtha Hadjar, From rantingrickjohnson at gmail.com Fri Feb 17 18:48:56 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 15:48:56 -0800 (PST) Subject: tkinter.Toplevel References: Message-ID: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> On Feb 16, 8:39?pm, y... at zioup.com wrote: > With a tkinter.Toplevel, how can I "disable" the parent windown and all its > widget, in the same fashion as tkinter.messagebox? The answer lies within the tkSimpleDialog source code; which is pure python. Look in the __init__ method of Dialog class. My advice is to study the code until you understand every line. Look at the following references when you need more info: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ http://effbot.org/tkinterbook/ From rantingrickjohnson at gmail.com Fri Feb 17 20:13:37 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 17:13:37 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly wrote: > On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson > I make a middle-class income and do not feel that I am anywhere near > being "enslaved" by my income taxes, which amount to less than 10% of > my gross income after deductions and credits. Ten percent?!?! You pay less income tax by percentage than most rich folks, including Mitt Romney! I envy you since you must be one of the lucky folks who ONLY pay income tax. I guess you never purchase ANYTHING or live under the tyranny of local jurisdictions ON TOP of the federal jurisdiction? Here is a list of taxes most everyone else will encounter: Accounts Receivable Tax Building Permit Tax Capital Gains Tax CDL license Tax Cigarette Tax Corporate Income Tax Court Fines (indirect taxes) Deficit spending Dog License Tax Federal Income Tax Federal Unemployment Tax (FUTA) Fishing License Tax Food License Tax Fuel permit tax Gasoline Tax Gift Tax Hunting License Tax Inflation Inheritance Tax Interest expense (tax on the money) Inventory tax IRS Interest Charges (tax on top of tax) IRS Penalties (tax on top of tax) Liquor Tax Local Income Tax Luxury Taxes Marriage License Tax Medicare Tax Property Tax Real Estate Tax Septic Permit Tax Service Charge Taxes Social Security Tax Road Usage Taxes (Truckers) Sales Taxes Recreational Vehicle Tax Road Toll Booth Taxes School Tax State Income Tax State Unemployment Tax (SUTA) Telephone federal excise tax Telephone federal universal service fee tax Telephone federal, state and local surcharge taxes Telephone minimum usage surcharge tax Telephone recurring and non-recurring charges tax Telephone state and local tax Telephone usage charge tax Toll Bridge Taxes Toll Tunnel Taxes Traffic Fines (indirect taxation) Trailer Registration Tax Utility Taxes Vehicle License Registration Tax Vehicle Sales Tax Watercraft Registration Tax Well Permit Tax Workers Compensation Tax ... and don't forget for declare those pennys on your eyes! > Heck, there are poorer > people than I who voluntarily donate that much to religious > organizations on top of their taxes. Again, lucky you! MOST middle class people pay 30-50% of their income in taxes! > Say what you want about the income tax system, but at least net income > still basically increases monotonically. ?If you make more gross than > me, chances are that you're going to make more net than me as well. So you support a flat tax system? A system where everybody pays the same percentage? Actually i think 10% income tax is a fair amount although i believe taxing income silly. If the government cannot provide national security, domestic security, and LIMITED infratructure on 10% of what we make, they are wasting too much of OUR money. > > HOWEVER, healthcare is not a concern of the greater society, but only > > the individual -- with the exception of contagious disease of course, > > which effects us all! > > I disagree, and here's why. ?Let's say I'm a billionaire, and I'm > diagnosed with cancer. ?Do you think I can just round up a bunch of > scientists and tell them "Here's a billion dollars. ?Now go find a > cure my cancer"? ?Of course not, it doesn't work that way. ?If the > necessary research hasn't already been done, then it's unlikely that > it will be finished in the few years or months that I have before the > cancer kills me, no matter how much of my own money I throw at it. I agree that keeping R&D "alive" is very important for our collective advancement. I do not fear technology like some people. Futhermore, i don't have any problem funding R&D for ANY of the sciences, beit medical or otherwise. But let me assure you, under a private healthcare system (psst: the kind where people pay they own way!) there will ALWAYS be enough people to keep R&D alive. Besides, the degenerates are only seeking care for self induced heath issues. > Real medical research is primarily driven by medical treatment. Yes, but that does not mean we should hand degenerates a meal ticket. > -- if I > as a wealthy private investor am going to invest in such a highly > speculative and risky venture as drug research, I will be more willing > to invest a large sum of money if the potential recipients (i.e. > consumers) number in the hundreds of thousands, not just the few > thousand who will be able to pay for the drug out of pocket. > Likewise, much of the money the drug companies make off of sales goes > back into research so that they can be ready with a newer, better drug > by the time their patents expire. > > Distributing health care coverage expands the market for treatments > and so allows the state of the art to advance faster. ?Yes, with > socialized health care, some of our tax money goes into that pool, and > a lot of that tax money just ends up as profits in the hands of > wealthy shareholders. ?The other side of that coin, though, is that if > we ever find ourselves in the position that we need those treatments > ourselves, the medical state of the art will be that much better for > it. And if you can afford the care great, if not, you'd better buy an insurance policy. You know, people love to whine about how privatized healthcare is so unfair to the degenerates. What about the doctors? Would you expect a doctor to work for free? Remeber, doctors spend a decade or more in college and rack up HUGE debts to pay for their education. You don't mind stealing from taxpayers to fund degenerates, but it's the same as stealing from doctors. Observe: Doctor: "Okay, your diease is cured. You have a clean bill of heath! Your bill is $500,000" Patient: "Thanks doc, but it seems i am little light. Can i just pay you $20.00 and we call it even?" Doctor: "What? I just saved your life. I spent the last three months caring for you. Using expensive medical equipment and years of laboratory research. Do you know how many lab rats and monkeys died a horrible death so that you can live? How can I do all that for $20.00?" Of course you would not, because you'd have to look the doctor in the eye whilst robbing him. On the other hand, with tax payer subsidized healthcare (AKA: Public Heathcare), you don't have to look anyone in the eye. The victim of your plunder is just some random taxpayer footing your bills! People, THERE IS NO FREE LUNCH! Every product that is made and every service rendered was a result of someone's hard labor. Sleep on that you degenerates! Hypocrisy! It's no different than the idiots who whine for the fair treatment of fluffy mammals but them declare chemical warfare on insects and reptiles. To them ONLY fluffy mammals deserve fair treatment because they are so cuddly (and cute BTW) PUKE!. But you want to know the REAL reason? It's because mammals return love and reptiles and insects don't. It's because people are selfish. If another being will no reciprocate their love, then they murder that being with extreme prejudice, and not feel one bit guilty about it! Do you understand how backward you are? Do you understand how selfish and immoral you are? Do you understand how incredibly dense you are? Because of people like YOU, we don't deserve the right to evolve! > But beyond that, I also think that we as a society have an ethical > commitment to help one another out when we find ourselves in trouble, > because that's what a civilized society is. I agree totally. Let say an innocent is shot in the course of a robbery. I would not mind my tax dollars going towards the victims medical care IF he could not afford the care himself. Even if he was a degenerate. On the other hand, if some lame-brain decided to climb MT. Everest and got stuck on top with frost-bite... TOO BAD! Same goes for dummies who develop lung caner from somking... TOO BAD! Or cirrhosis of the liver from one too many "adult beverages"... TOO BAD! Or diabetes from eating too many candy bars and/or drinking too many sodas... TOO BAD, TOO BAD, TOO BAD!!! I am tired of the whines and laments of vermin, almost as much as i am tired of the silence of the moral majority! It's time to put degenerates in their place! From gechangbin11 at 163.com Fri Feb 17 20:26:37 2012 From: gechangbin11 at 163.com (gechangbin11 at 163.com) Date: Fri, 17 Feb 2012 17:26:37 -0800 (PST) Subject: download porn videos free Message-ID: <15dedf83-6f3f-4b13-b8d3-d1faebeb36f6@ow3g2000pbc.googlegroups.com> http://dladult.com/ From rantingrickjohnson at gmail.com Fri Feb 17 20:37:41 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 17 Feb 2012 17:37:41 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <32cb82b9-0e35-4d92-983e-0c08df828174@n12g2000yqb.googlegroups.com> On Feb 13, 7:37?pm, Chris Angelico wrote: > On Tue, Feb 14, 2012 at 11:39 AM, Rick Johnson > > wrote: > > # Py>=3.0 > > py> sum(earner.get_income(2012) for earner in earners2012) / > > len(earners2012) > > average_income > > > Once you exceed that amount you are robbing your fellow man. How can > > you justify making more than your fair share UNLESS someone offers > > their work load to YOU? You can't. You are living in excess. And for > > those who think the average_income is too small, well then, it's time > > to implement population control! > > My equation looks something like this: > > # Brain >= 0,1 > brain> Your contribution to society / Society's contribution to you > > This value should be able to exceed 1.0 across the board. In fact, if > it doesn't, then as a society we're moving backward. Are we talking about money or deeds? If deeds then i agree, if money then i disagree. A society is NOT made better by contributing money. Who does the money go to? History has shown that money ends up being wasted, that money ends up being squandered, and that money ends up empowering tyranny! However A society IS improved when good deeds and good wills are injected by the individual. We should ALWAYS invest more good deeds and expect less. So in this case we should ALWAYS exceed 1.0. From torriem at gmail.com Fri Feb 17 20:51:13 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 17 Feb 2012 18:51:13 -0700 Subject: [OT]: Smartphones and Python? In-Reply-To: <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <4F3F0411.80508@gmail.com> On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > Android is a customized linux OS used in mobile phones. I don't think > any linux systm has to be locked by JAVA or any JVM to run > applications. Getting waaayyyy off topic here, but... I guess you aren't familiar with what Android is (which is ironic, given that a lot of people on this list think you must be one!). Android is not simply a customized linux distribution. It's a special application environment (an OS in its own right) that is based on the Dalvik virtual machine. Dalvik does depend on the Linux kernel to talk to the hardware, but Linux very much is not a part of Android, at least from the developers' and end users' points of view. Linux is just not a part of the user experience at all. It is true that Dalvik can call into native linux code, but native linux applications typically aren't a part of the Android user experience. Thus you can't just install any JVM on android. Thus cpython or jython just isn't part of it. For one I don't know of any sun-compatible JVM that has been ported to ARM. For two, there aren't any hooks into the Android UI APIs even if you could get it running. Android is even being ported to the QNX kernel by the Blackberry folks, so they can have android compatibility on next-generation blackberries that run their own native OS. > The memory systems in mobile phones are different from PCs. This is > the current situation in the consumer electronics sector. I do not understand what you are saying, or at least why you are saying this. But I don't understand most of your posts. From rosuav at gmail.com Fri Feb 17 21:13:15 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 18 Feb 2012 13:13:15 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Sat, Feb 18, 2012 at 12:13 PM, Rick Johnson wrote: > Here is a list of taxes most everyone else will encounter: You forgot the Microsoft Tax and the Stupid Tax. ChrisA From breamoreboy at yahoo.co.uk Fri Feb 17 21:39:55 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 18 Feb 2012 02:39:55 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 18/02/2012 02:13, Chris Angelico wrote: > On Sat, Feb 18, 2012 at 12:13 PM, Rick Johnson > wrote: >> Here is a list of taxes most everyone else will encounter: > > You forgot the Microsoft Tax and the Stupid Tax. > > ChrisA This is what I call a tax, some two miles from my home. http://www.bbc.co.uk/news/uk-england-dorset-17074716 -- Cheers. Mark Lawrence. From emekamicro at gmail.com Fri Feb 17 22:17:23 2012 From: emekamicro at gmail.com (Emeka) Date: Sat, 18 Feb 2012 05:17:23 +0200 Subject: Undoing character read from file In-Reply-To: <9q7217F6j0U3@mid.individual.net> References: <9q7217F6j0U3@mid.individual.net> Message-ID: Neil, Thanks. Could you throw a simple example? Regards, \Emeka On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti wrote: > On 2012-02-16, MRAB wrote: > > On 16/02/2012 23:10, Emeka wrote: > >> Hello All, > >> > >> I know about seek and tell while using readline. What about if I am > >> using read, and I want to undo the last character I just read(to return > >> it back to the stream). How do I achieve this? > >> > > Try: > > > > f.seek(-1, 1) > > > > It seeks -1 relative to the current position (the second > > argument defaults to 0 for relative to start of file). > > Unless it's a stream opened in binary mode this will not work. > You'd need to maintain a n-character length buffer instead, with > n being the maximum number of characters you'd like to be able to > put back. > > -- > Neil Cerutti > -- > http://mail.python.org/mailman/listinfo/python-list > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From emekamicro at gmail.com Fri Feb 17 22:38:22 2012 From: emekamicro at gmail.com (Emeka) Date: Sat, 18 Feb 2012 05:38:22 +0200 Subject: Undoing character read from file In-Reply-To: References: <9q7217F6j0U3@mid.individual.net> Message-ID: Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mset is False and mcount == 0: print c mfile.seek(-1, 0) mcount = 1 continue elif c == "e" and mcount == 1: print c mcount = 0 continue print c if mset is False: mset = True if len(c) == 0: break cc.txt foor the this the been we hate to sh wiukr bee here today. But who are we to question him concerning this issue. Is the above code the right way? Regards, \Emeka On Sat, Feb 18, 2012 at 5:17 AM, Emeka wrote: > Neil, > > Thanks. Could you throw a simple example? > > Regards, \Emeka > > > On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti wrote: > >> On 2012-02-16, MRAB wrote: >> > On 16/02/2012 23:10, Emeka wrote: >> >> Hello All, >> >> >> >> I know about seek and tell while using readline. What about if I am >> >> using read, and I want to undo the last character I just read(to return >> >> it back to the stream). How do I achieve this? >> >> >> > Try: >> > >> > f.seek(-1, 1) >> > >> > It seeks -1 relative to the current position (the second >> > argument defaults to 0 for relative to start of file). >> >> Unless it's a stream opened in binary mode this will not work. >> You'd need to maintain a n-character length buffer instead, with >> n being the maximum number of characters you'd like to be able to >> put back. >> >> -- >> Neil Cerutti >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > > > -- > *Satajanus Nig. Ltd > > > * > -- *Satajanus Nig. Ltd * -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Fri Feb 17 22:58:52 2012 From: d at davea.name (Dave Angel) Date: Fri, 17 Feb 2012 22:58:52 -0500 Subject: Undoing character read from file In-Reply-To: References: <9q7217F6j0U3@mid.individual.net> Message-ID: <4F3F21FC.1080002@davea.name> On 02/17/2012 10:38 PM, Emeka wrote: > Hello All, > > Say I have something like this: > > mfile = open("cc.txt", "rb") > mcount = 0 > mset = False > while True: > c = mfile.read(1) > if c == "e" and mset is True and mcount == 0: > print c > mfile.seek(-1,1) > mcount = 1 > continue > elif c == "e" and mset is False and mcount == 0: > print c > mfile.seek(-1, 0) > mcount = 1 > continue > elif c == "e" and mcount == 1: > print c > mcount = 0 > continue > print c > if mset is False: > mset = True > if len(c) == 0: > break > > cc.txt > > foor the this the been we hate to sh wiukr bee here today. But who are we > to question > him concerning this issue. > > Is the above code the right way? You top-posted, instead of putting your response after whatever you were quoting. So you lose all context. Your code won't compile, and it's unclear just what you were trying to accomplish. What do you mean by "the right way"? Please post the actual code that you're running, and explain what you expected, what you got, and how it didn't do what you wanted. In this case, you should give us the traceback, so it's obvious that you're trying to figure out how to indent. -- DaveA From dihedral88888 at googlemail.com Fri Feb 17 23:19:24 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:19:24 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <96581.1784.1329538764682.JavaMail.geo-discussion-forums@pbcr5> From dihedral88888 at googlemail.com Fri Feb 17 23:51:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:51:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > > Android is a customized linux OS used in mobile phones. I don't think > > any linux systm has to be locked by JAVA or any JVM to run > > applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. A different set of shell tool to write some AP is not a new OS. It can be called a new IDE which supports manny services not well maintained by the free linux contributors in a loosely unorganized way. > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. > > Thus you can't just install any JVM on android. Thus cpython or jython > just isn't part of it. For one I don't know of any sun-compatible JVM > that has been ported to ARM. For two, there aren't any hooks into the > Android UI APIs even if you could get it running. > > Android is even being ported to the QNX kernel by the Blackberry folks, > so they can have android compatibility on next-generation blackberries > that run their own native OS. > > > The memory systems in mobile phones are different from PCs. This is > > the current situation in the consumer electronics sector. > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. You can use VMware like techniques to emulate another OS to support AP of different formats. This is not new at all. i From dihedral88888 at googlemail.com Fri Feb 17 23:51:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Fri, 17 Feb 2012 20:51:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: > > Android is a customized linux OS used in mobile phones. I don't think > > any linux systm has to be locked by JAVA or any JVM to run > > applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. A different set of shell tool to write some AP is not a new OS. It can be called a new IDE which supports manny services not well maintained by the free linux contributors in a loosely unorganized way. > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. > > Thus you can't just install any JVM on android. Thus cpython or jython > just isn't part of it. For one I don't know of any sun-compatible JVM > that has been ported to ARM. For two, there aren't any hooks into the > Android UI APIs even if you could get it running. > > Android is even being ported to the QNX kernel by the Blackberry folks, > so they can have android compatibility on next-generation blackberries > that run their own native OS. > > > The memory systems in mobile phones are different from PCs. This is > > the current situation in the consumer electronics sector. > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. You can use VMware like techniques to emulate another OS to support AP of different formats. This is not new at all. i From bahamutzero8825 at gmail.com Sat Feb 18 00:05:23 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 17 Feb 2012 23:05:23 -0600 Subject: [OT]: Smartphones and Python? In-Reply-To: <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <12957999.3.1329540692291.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4F3F3193.9090903@gmail.com> On 2/17/2012 10:51 PM, 88888 Dihedral wrote: > ? 2012?2?18????UTC+8??9?51?13??Michael Torrie??? >> On 02/16/2012 10:25 PM, 88888 Dihedral wrote: >> > Android is a customized linux OS used in mobile phones. I don't think >> > any linux systm has to be locked by JAVA or any JVM to run >> > applications. >> >> Getting waaayyyy off topic here, but... >> >> I guess you aren't familiar with what Android is (which is ironic, given >> that a lot of people on this list think you must be one!). Android is >> not simply a customized linux distribution. It's a special application >> environment (an OS in its own right) that is based on the Dalvik virtual >> machine. Dalvik does depend on the Linux kernel to talk to the >> hardware, but Linux very much is not a part of Android, at least from > > Android is a Linux OS kernal plus a virtual machine which supports GUI services and a JIT compiler in law suites charged by Oracles now. > > A different set of shell tool to write some AP is not > a new OS. Lorem ipsum dolor sit amet, GUI adipisicing elit, sed do eiusmod application incididunt ut labore et dolore magna Android. Ut linux ad minim veniam, quis python exercitation ullamco laboris nisi ut aliquip ex hardware commodo consequat. Duis aute irure dolor in Dalvik in voluptate velit esse cillum Java eu fugiat nulla pariatur. Excepteur sint kernel OS non proident, sunt in culpa qui shell deserunt mollit Oracle id est laborum. Sorry for the noise, but I'm hoping I can corrupt the bot's dictionary to make it more obvious. From ian.g.kelly at gmail.com Sat Feb 18 02:28:59 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 18 Feb 2012 00:28:59 -0700 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson wrote: > > On Mon, Feb 13, 2012 at 7:23 PM, Ian Kelly > wrote: >> On Mon, Feb 13, 2012 at 2:01 PM, Rick Johnson >> I make a middle-class income and do not feel that I am anywhere near >> being "enslaved" by my income taxes, which amount to less than 10% of >> my gross income after deductions and credits. > > Ten percent?!?! You pay less income tax by percentage than most rich > folks, including Mitt Romney! I envy you since you must be one of the > lucky folks who ONLY pay income tax. Yes, I feel terribly sorry for Mitt Romney. I can't imagine what it must be like to earn $27 million and only be allowed to keep $23 million of it. Why, that's barely enough to buy a private island in Dubai! I think it says a lot about how far we've come as a nation, though, that somebody who's practically a slave to the IRS can be a front-runner to be elected President. The 10% figure included Medicare, but not Social Security or other taxes. That's because health care coverage (you know, what we've been talking about) is primarily funded by income tax, Medicare, and excise taxes on certain kinds of treatments. Most other taxes go to fund specific unrelated programs. If I were to add everything up, it would probably come to around 30%, which still doesn't bother me, in part because I know that it comes back to benefit the society I live in, and by extension me, in one way or another.. > I guess you never purchase > ANYTHING or live under the tyranny of local jurisdictions ON TOP of > the federal jurisdiction? Paying taxes to fund public schools, police departments, fire departments, and road maintenance is "tyranny"? > Here is a list of taxes most everyone else will encounter: This list is awesome. I love how you include inflation and fines imposed for breaking the law as "taxes". Also how you state that "most everyone" will have to pay taxes for fishing licenses, hunting licenses, CDL licenses, and even corporate income. Marriage license tax? Yeah, I remember paying that fee. Once. I believe it was somewhere around $50. And cigarette tax? Correct me if I'm wrong, but isn't that one mostly paid by those "degenerates" you keep whining about, the ones who aren't pulling their own weight? I hope you can understand that I find it a bit ironic that you're now complaining about cigarette tax. >> Say what you want about the income tax system, but at least net income >> still basically increases monotonically. ?If you make more gross than >> me, chances are that you're going to make more net than me as well. > > So you support a flat tax system? A system where everybody pays the > same percentage? No, what makes you think that? The statement I made is true under either a flat tax or the progressive system we currently have. > Actually i think 10% income tax is a fair amount although i believe > taxing income silly. If the government cannot provide national > security, domestic security, and LIMITED infratructure on 10% of what > we make, they are wasting too much of OUR money. Here's a neat table: government spending as a percentage of GDP, by country. http://anepigone.blogspot.com/2008/03/government-spending-as-percentage-of.html In 2008, the United States spent 19.9% of its GDP in government spending (it's gone up a few percent since then). The only countries on the chart that spent less than 10% were Turkmenistan and Afghanistan. Draw your own conclusions. > People, THERE IS NO FREE LUNCH! Every product that is made and every > service rendered was a result of someone's hard labor. Sleep on that > you degenerates! No shit. I pay those taxes too, you know. I have no delusions about where the money comes from. > Hypocrisy! It's no different than the idiots who whine for the fair > treatment of fluffy mammals but them declare chemical warfare on > insects and reptiles. To them ONLY fluffy mammals deserve fair > treatment because they are so cuddly (and cute BTW) PUKE!. I fail to see any connection whatsoever. Animal lovers who only care about mammals are stealing money from taxpayers? > But you want to know the REAL reason? It's because mammals return love > and reptiles and insects don't. It's because people are selfish. If > another being will no reciprocate their love, then they murder that > being with extreme prejudice, and not feel one bit guilty about it! Do > you understand how backward you are? Do you understand how selfish and > immoral you are? Do you understand how incredibly dense you are? Yes, I am so selfish and immoral that I believe everybody should have access to health care. Instead I should be more like you, and label people who can't afford their own health care as "degenerates", and dismiss their health needs as being unimportant compared to my own completely selfless desire that none of my personal income be used to support the society that I live in and derive benefit from, without my full and specific consent. > Because of people like YOU, we don't deserve the right to evolve! What does that even mean? Evolution is a natural process. That's like saying "we don't deserve the right to be gravitationally bound to the planet", or "we don't deserve the right to drown if we fall in the ocean". From tjreedy at udel.edu Sat Feb 18 04:16:39 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 18 Feb 2012 04:16:39 -0500 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 2/18/2012 2:28 AM, Ian Kelly wrote: > Here's a neat table: government spending as a percentage of GDP, by > country. > > http://anepigone.blogspot.com/2008/03/government-spending-as-percentage-of.html The table is for "national government spending". That means spending by the national government. The US has a lot of spending by state, county, city, school, and special districts that is not included. Total government spending in the US is about 40% of measured GDP. I *suspect* that the US has a higher percentage of non-national government spending than most other countries. For instance, government education spending is about 6% of GDP and that is mostly non-national here but, I believe, more national in some other countries. There are also issues with the denominator. In the US, if someone works at home without pay other than from a spouse, the value of the work is *not* included in GDP. If the same person goes to work elsewhere and hires someone to do the the same work around the home, that same work *is* counted. So the movement of house-spouses into the paid workforce has artificially inflated US GDP relative to, say, 50 years ago. There are also issues of measuring and including the unofficial, off-government books, 'underground' economy. That is relatively larger in many countries than in the US. I have the strong impression that the US IRS is much more diligent about ferreting out taxable income than the equivalent in many other countries. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sat Feb 18 10:02:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Feb 2012 07:02:22 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On Feb 18, 1:28?am, Ian Kelly wrote: > On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson > If I were to [sum my tax burden], it would > probably come to around 30%, which still doesn't bother me, in part > because I know that it comes back to benefit the society I live in, > and by extension me, in one way or another.. But do you think you'll get a higher return for your investment? Is it possible to get a higher return on your investment in this type of system? NO! You better off just paying for your own damn healthcare. Well actually, there is a way to get a higher return by taking more than your "fair share". Any intelligent person would realize that public healthcare is advocated by degenerates or the bleeding heart "degenerate eugenics" supporters. Fine, YOU want to subsidize degeneracy? Then give to charity. The more you give the better you'll feel. BTW: How much money do you give to charity? Also, you mentioned Mitt paying 4 million dollars in taxes; that's more tax than you'll pay in a lifetime! > > I guess you never purchase > > ANYTHING or live under the tyranny of local jurisdictions ON TOP of > > the federal jurisdiction? > > Paying taxes to fund public schools, police departments, fire > departments, and road maintenance is "tyranny"? Read my comments and you will know that i support LIMITED infrastructure. Enough with the spin! > > Here is a list of taxes most everyone else will encounter: > > This list is awesome. ?I love how you include inflation and fines > imposed for breaking the law as "taxes". Do you think that ALL traffic tickets are based on reality? You don't think traffic cops are forced to meet ticket quotas? You don't believe that some people are wrongly accused? You don't think some police abuse their power? Have you heard of the many cases of death row inmates being proven innocent by DNA evidence? You are a FOOL to believe the justice system is perfect! >?Also how you state that > "most everyone" will have to pay taxes for fishing licenses, hunting > licenses, CDL licenses, and even corporate income. Maybe you live in Amish country, but I have driven on many US highways and i know for a fact that there are many, MANY, large trucks. All those truck drivers require a CDL license. Maybe you just ignore the people you consider to be "beneath you"? > ?Marriage license > tax? ?Yeah, I remember paying that fee. ?Once. ?I believe it was > somewhere around $50. And why do we need the state involved in our love lives? > ?And cigarette tax? ?Correct me if I'm wrong, > but isn't that one mostly paid by those "degenerates" you keep whining > about, the ones who aren't pulling their own weight? ?I hope you can > understand that I find it a bit ironic that you're now complaining > about cigarette tax. It IS a tax nonetheless. Of course the sales pitch for cigarette tax is that the profit will help offset the medical expenses of cancers due to smoking, BUT, do you REALLY believe all that money is going towards healthcare. HA! That's just more money in some politicians pocket! > > Actually i think 10% income tax is a fair amount although i believe > > taxing income silly. If the government cannot provide national > > security, domestic security, and LIMITED infratructure on 10% of what > > we make, they are wasting too much of OUR money. > > Here's a neat table: government spending as a percentage of GDP, by country. Don't trust polls. Heck, some polls even show Python rising in popularity! > > People, THERE IS NO FREE LUNCH! Every product that is made and every > > service rendered was a result of someone's hard labor. Sleep on that > > you degenerates! > > No shit. ?I pay those taxes too, you know. ?I have no delusions about > where the money comes from. Great. Thanks for being a productive member of society. But why do you support measures that will increase your tax burden? You'll never get back what you put in unless you're a degenerate. Also, you are empowering the government with more money. They can't even manage the money they have now! Has history taught you NOTHING! How many revolutions is it going to take? How many billions of lives is is going to take? When are you going to realize that taxation is tyranny? When are you going to realize that degenerates deserve what they get? > I fail to see any connection whatsoever. ?Animal lovers who only care > about mammals are stealing money from taxpayers? Public healthcare is YOU robbing someone else so YOU can get a service that you don't deserve! That's the hypocrisy! > Yes, I am so selfish and immoral that I believe everybody should have > access to health care. ?Instead I should be more like you, and label > people who can't afford their own health care as "degenerates", I NEVER labeled people who can't afford healthcare degenerates. Enough with the spin cycle already. > > Because of people like YOU, we don't deserve the right to evolve! > > What does that even mean? ?Evolution is a natural process. Not for long my friend. By wielding eugenics, even debutante intelligence's can harness evolution. In the near future, our technology will soon allow much better ways to harness evolution for our own gains. However, in the grander scheme, these flesh bodies are useless to us. Our fragile bodies where the best passport that evolution could give us, and are nothing more than a means to an end; they delivered us like the Santa Maria over perilous waters and into the new lands of enlightenment. Do you think we can travel the universe in biological bodies? That we can withstand the radiation? The lack of atmosphere? NO! Soon we shall cast these "flesh bags" away in the name of progress and become more powerful than evolution itself -- and in the process, we WILL cull the herd of all the selfish individuals and their foolish worship of nostalgic minutia! The individual will be destroyed in the name of progress. And the supreme being will be born! That is our destiny. Embrace it! THE HUMAN IS INSUFFICIENT! From invalid at invalid.invalid Sat Feb 18 10:25:23 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Sat, 18 Feb 2012 15:25:23 +0000 (UTC) Subject: Python code file prototype References: <66ea0353-02ee-4152-947a-97b44ff3ec45@p7g2000yqk.googlegroups.com> Message-ID: On 2012-02-17, Dennis Lee Bieber wrote: > On Fri, 17 Feb 2012 09:55:46 -0700, Ian Kelly > wrote: > >> >>The shebang has to be the first thing in the file to be useful. As it >>is above, it might as well not be there. I would suggest also >>including a doc string in the skeleton. >> > Of course, since the OP was talking Windows... the #! line is > ignored no matter where it was That depends. It always used to work for me, but I'm usually using bash and Cygwin. From rd9663 at gmail.com Sat Feb 18 10:53:26 2012 From: rd9663 at gmail.com (roshni das) Date: Sat, 18 Feb 2012 07:53:26 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: <0e1558e1-0d8c-48f8-b87f-984bf10dacd1@x6g2000pbk.googlegroups.com> EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfree.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfree.yolasite.com/ Thanks ?? From breamoreboy at yahoo.co.uk Sat Feb 18 11:15:10 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 18 Feb 2012 16:15:10 +0000 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: On 18/02/2012 15:02, Rick Johnson wrote: > But do you think you'll get a higher return for your investment? Is it > possible to get a higher return on your investment in this type of > system? NO! You better off just paying for your own damn healthcare. > I guess you'd better get wikipedia to correct its incorrect data then. http://en.wikipedia.org/wiki/Health_care_in_the_United_States Specifically. http://en.wikipedia.org/wiki/File:International_Comparison_-_Healthcare_spending_as_%25_GDP.png -- Cheers. Mark Lawrence. From jason at powerpull.net Sat Feb 18 11:34:38 2012 From: jason at powerpull.net (Jason Friedman) Date: Sat, 18 Feb 2012 16:34:38 +0000 Subject: parse a profile Message-ID: I have a file I use for shell scripts that looks like this: export VAR1=/path/to/dir export VAR2=7 export VAR3=${VAR1}/further/path # comment . /another/file And a file /another/file: export VAR4=database-name Is there an existing package that will read such a file and return a dictionary like this: { 'VAR1': '/path/to/dir', 'VAR2': 7, 'VAR3': '/path/to/dir/further/path', 'VAR4': 'database-name', } From lie.1296 at gmail.com Sat Feb 18 12:46:30 2012 From: lie.1296 at gmail.com (Lie Ryan) Date: Sun, 19 Feb 2012 04:46:30 +1100 Subject: [OT]: Smartphones and Python? In-Reply-To: <4F3F0411.80508@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: On 02/18/2012 12:51 PM, Michael Torrie wrote: > On 02/16/2012 10:25 PM, 88888 Dihedral wrote: >> Android is a customized linux OS used in mobile phones. I don't think >> any linux systm has to be locked by JAVA or any JVM to run >> applications. > > Getting waaayyyy off topic here, but... > > I guess you aren't familiar with what Android is (which is ironic, given > that a lot of people on this list think you must be one!). Android is > not simply a customized linux distribution. Strictly speaking, Android *is* a customized Linux distribution; what it is not is Android is not a GNU/Linux distribution. > It's a special application > environment (an OS in its own right) that is based on the Dalvik virtual > machine. Dalvik does depend on the Linux kernel to talk to the > hardware, but Linux very much is not a part of Android, at least from > the developers' and end users' points of view. Linux is just not a part > of the user experience at all. It is true that Dalvik can call into > native linux code, but native linux applications typically aren't a part > of the Android user experience. Android does have a full Linux experience; what it lacks is the GNU experience. Unlike "normal" Linux distros, Android does not use GNU userspace, instead it have its own userspace based on bionic, toolbox, and dalvik. Linux is a core part of Android's user and developer's experience. From rantingrickjohnson at gmail.com Sat Feb 18 13:34:24 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 18 Feb 2012 10:34:24 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> Message-ID: <2957aaeb-408c-4c91-8342-63dd30fc056b@p7g2000yqk.googlegroups.com> On Feb 18, 10:15?am, Mark Lawrence wrote: > On 18/02/2012 15:02, Rick Johnson wrote: > > > But do you think you'll get a higher return for your investment? Is it > > possible to get a higher return on your investment in this type of > > system? NO! You better off just paying for your own damn healthcare. > > I guess you'd better get wikipedia to correct its incorrect data then. Sure. I'll do that as soon as you show me mathematical evidence of how N people put X dollars each into a pot and then the same N people pull out MORE than X dollars each. If you can create a proof that creates money from nothing then we may find ourselves in the 1% tomorrow! Louie-the-loose-screw Said: "I'll give you $15 if you'll give me $15!" Okay Louie, but what is the point of that exercise besides money laundering? X + 0 = 0 From python at mrabarnett.plus.com Sat Feb 18 13:43:50 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 18 Feb 2012 18:43:50 +0000 Subject: parse a profile In-Reply-To: References: Message-ID: <4F3FF166.500@mrabarnett.plus.com> On 18/02/2012 16:34, Jason Friedman wrote: > I have a file I use for shell scripts that looks like this: > > export VAR1=/path/to/dir > export VAR2=7 > export VAR3=${VAR1}/further/path > # comment > . /another/file > > And a file /another/file: > export VAR4=database-name > > Is there an existing package that will read such a file and return a > dictionary like this: > { > 'VAR1': '/path/to/dir', > 'VAR2': 7, > 'VAR3': '/path/to/dir/further/path', > 'VAR4': 'database-name', > } I would probably do something like this: import re # Parse the file into a dict. with open(path) as f: d = dict(re.findall(r"(?m)^export (VAR\d+)=(.*)", f.read())) # Expand any references. for key, value in d.items(): d[key] = re.sub(r"\$\{(VAR\d+)\}", lambda m: d[m.group(1)], value) From pywin32 at gmail.com Sat Feb 18 13:49:39 2012 From: pywin32 at gmail.com (random joe) Date: Sat, 18 Feb 2012 10:49:39 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f3757cc$0$29986$c3e8da3$5496439d@news.astraweb.com> <1c0e800d-1196-4fcd-9eaf-4fd1788f7f74@q12g2000yqg.googlegroups.com> <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <39962880-2073-4ed3-83b2-83fa86409b53@i18g2000yqf.googlegroups.com> <2957aaeb-408c-4c91-8342-63dd30fc056b@p7g2000yqk.googlegroups.com> Message-ID: <1c4d1210-d324-44c7-9d6c-cec7cfc6a201@p21g2000yqm.googlegroups.com> On Feb 18, 12:34?pm, Rick Johnson wrote: > Louie-the-loose-screw Said: "I'll give you $15 if you'll give me $15!" $15 dolla too beau coup! 5 dolla each! From sherjilozair at gmail.com Sat Feb 18 13:58:02 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sat, 18 Feb 2012 10:58:02 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? Message-ID: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. I'm sure everyone would agree that doing this would make the terminal very powerful. What are your views on this? From jabba.laci at gmail.com Sat Feb 18 14:21:53 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Sat, 18 Feb 2012 20:21:53 +0100 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: Have a look at IPython (http://ipython.org/). It can interact with the normal shell very well. Laszlo On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > What are your views on this? > -- > http://mail.python.org/mailman/listinfo/python-list From dihedral88888 at googlemail.com Sat Feb 18 16:46:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 13:46:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4874001.114.1329601576682.JavaMail.geo-discussion-forums@pbcr5> ? 2012?2?19????UTC+8??3?21?53??Jabba Laci??? > Have a look at IPython (http://ipython.org/). It can interact with the > normal shell very well. > > Laszlo > > On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > > > What are your views on this? > > -- > > http://mail.python.org/mailman/listinfo/python-list Yeh, python could be used as a better shell in a text terminal box and with another text editor in another box to write scripts in developement. Also this is easy to test scripts found in the web by copy and paste. From dihedral88888 at googlemail.com Sat Feb 18 16:46:16 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 13:46:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4874001.114.1329601576682.JavaMail.geo-discussion-forums@pbcr5> ? 2012?2?19????UTC+8??3?21?53??Jabba Laci??? > Have a look at IPython (http://ipython.org/). It can interact with the > normal shell very well. > > Laszlo > > On Sat, Feb 18, 2012 at 19:58, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > > > What are your views on this? > > -- > > http://mail.python.org/mailman/listinfo/python-list Yeh, python could be used as a better shell in a text terminal box and with another text editor in another box to write scripts in developement. Also this is easy to test scripts found in the web by copy and paste. From cs at zip.com.au Sat Feb 18 17:58:43 2012 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 19 Feb 2012 09:58:43 +1100 Subject: parse a profile In-Reply-To: <4F3FF166.500@mrabarnett.plus.com> References: <4F3FF166.500@mrabarnett.plus.com> Message-ID: <20120218225843.GA13559@cskk.homeip.net> On 18Feb2012 18:43, MRAB wrote: | On 18/02/2012 16:34, Jason Friedman wrote: | > I have a file I use for shell scripts that looks like this: | > | > export VAR1=/path/to/dir | > export VAR2=7 | > export VAR3=${VAR1}/further/path | > # comment | > . /another/file | > | > And a file /another/file: | > export VAR4=database-name | > | > Is there an existing package that will read such a file and return a | > dictionary like this: | > { | > 'VAR1': '/path/to/dir', | > 'VAR2': 7, | > 'VAR3': '/path/to/dir/further/path', | > 'VAR4': 'database-name', | > } | | I would probably do something like this: | | import re | | # Parse the file into a dict. | with open(path) as f: | d = dict(re.findall(r"(?m)^export (VAR\d+)=(.*)", f.read())) | | # Expand any references. | for key, value in d.items(): | d[key] = re.sub(r"\$\{(VAR\d+)\}", lambda m: d[m.group(1)], value) Which fails on the ". /anther/file" step, alas. Jason's point is probably that it may be arbitrary shell. I suspect I would write a shell wrapper like this: #!/bin/sh exec 3>&1 1>&2 . /path/to/jason/s/file exec 1>&3 3>&- env then from inside Python call the shell to run the wrapper. Read the output of "env" and diff it against os.environ. Populate the dictionary with the values that have changed. Crude untested sketch: newvars = {} for envline in subprocess.blah(... run the wrapper script above ...): if not envline.endswith('\n'): raise ValueError("unexpected EOF") envline = envline[:-1] try: var, value = line.split('=', 1) except ValueError: # ouch! continue oldvalue = os.environ.get(var) if oldvalue is None or oldvalue != value: newvars[var] = value You can put the wrapper script as a single inline piece of shell to avoid the separate file once debugged. Just a thought. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ [...] post-block actions should be allowed everywhere, not just on subroutines. The ALWAYS keyword was agreed upon as a good way of doing this, although POST was also suggested. This lead to the semi-inevitable rehash of the try- catch exception handling debate. According to John Porter, "There is no try, there is only do. :-)" - from the perl6 development discussion From mcepl at redhat.com Sat Feb 18 18:41:49 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 19 Feb 2012 00:41:49 +0100 Subject: [semi OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> Message-ID: On 16.2.2012 16:22, Michael Torrie wrote: > Android simply isn't going to run the JVM anytime soon. In reality yes, but just technically speaking there is the project IcedRobot (http://www.icedrobot.org/), which is a fork of Android over OpenJDK. Best, Mat?j From mcepl at redhat.com Sat Feb 18 18:45:18 2012 From: mcepl at redhat.com (Matej Cepl) Date: Sun, 19 Feb 2012 00:45:18 +0100 Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> Message-ID: > For one I don't know of any sun-compatible JVM > that has been ported to ARM. http://www.senecass.com/projects/OpenJDK-ARM/ "This work has been completed, and is now in OpenJDK HEAD. This page is now mostly for historical documentation." Also, http://openjdk.java.net/projects/zero/ (I know my colleagues from Red Hat are involved, because we are very interested in supporting more than just Intel chips well). Best, Mat?j From torriem at gmail.com Sat Feb 18 19:36:48 2012 From: torriem at gmail.com (Michael Torrie) Date: Sat, 18 Feb 2012 17:36:48 -0700 Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <4F404420.3060408@gmail.com> On 02/18/2012 10:46 AM, Lie Ryan wrote: > Android does have a full Linux experience; what it lacks is the GNU > experience. Unlike "normal" Linux distros, Android does not use GNU > userspace, instead it have its own userspace based on bionic, toolbox, > and dalvik. Linux is a core part of Android's user and developer's > experience. The fact that RIM is porting Android to QNX would seem to contradict your assertion that Linux is a core part of Android's user and developer experience. Have you developed for Android? In what way do you interact with Linux in your apps and APIs? Can you make system calls? How is Linux a core part of Android's user and developer experience? I know that Android does allow some integration of native code, so that does meld Linux and Android somewhat. >From a user's pov (non-rooted), there is nothing of Linux exposed. I just install apps, run them, and manipulate my files which are stored in my sd card. The fact that it's in /mnt/sdcard is completely hidden, as are all files that support dalvik. The OS could be Windows, iOS, or whatever. It doesn't matter because the platform is not defined by the kernel but by the APIs that apps need to use to run on the platform, just like in Python! In fact in some ways calling Android "Linux" would be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" just because it happens to run atop that kernel. I have mentioned those specifically because they are interpreted or virtual machines themselves; the "binaries" run regardless of underlying CPU type, or kernel type. In my mind, the fact that Android runs on the Linux kernel is almost entirely coincidental to Android's aims. Google could have developed their own kernel, but of course it's much cheaper to use Linux. And of course Dalvik is currently written to consume posix APIs from the kernel. In my mind, and in my experience with Android, Linux is irrelevant. In fact continuing to call Android "Linux" might just be doing ourselves a disservice. In any case, saying that since it's linux, you can install anything you want on it, such as a JVM, is neither useful or accurate. From ross at biostat.ucsf.edu Sat Feb 18 19:54:18 2012 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Sat, 18 Feb 2012 16:54:18 -0800 Subject: #line in python Message-ID: <1329612858.9780.13.camel@corn.betterworld.us> The ast module shows that elements of the syntax tree have line and column numbers. Would it be sensible to attempt to revise them to achieve effects like the #line directive in C? Context: Using noweb, a literate programming tool, which from a source file foo.nw produces foo.py. The lines in the two files may be in completely different sequenes. For debugging, it is useful to receive error reports that refer to the original line number in foo.nw. I am not sure how such rewriting would interact with debugger commands that set a breakpoint at a file and line number. I'm also not sure it would change the reported line numbers of errors. The lack of a file name could be problematic if multiple sources contributed to the same .py file, but that is an unlikely scenario. As an extension or alternate, could there be a decorator like @source_line(lineno, filename) for classes and methods that could do the conversion on the fly? I don't know if there's a way to go from the function (or class) object the decorator receives to the AST. Comments? Ross Boylan From nogradi at gmail.com Sat Feb 18 21:00:22 2012 From: nogradi at gmail.com (Daniel Nogradi) Date: Sun, 19 Feb 2012 03:00:22 +0100 Subject: [ANN] markup.py 1.8 Message-ID: A new release of markup.py is available at http://markup.sourceforge.net/ This new release is compatible with both python 2 and 3. What is markup.py? Markup.py is an intuitive, light weight, easy-to-use, customizable and pythonic HTML/XML generator. The only goal is quickly writing HTML/XML segments or whole documents programatically if you need anything more than that you probably want to look for a templating engine. -- interior | space | design | http://www.annazeibig.com | 3d | living | deco From steve+comp.lang.python at pearwood.info Sat Feb 18 22:44:07 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Feb 2012 03:44:07 GMT Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f407007$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 12 Feb 2012 19:09:32 -0800, rusi wrote: > I have some bunch of sanskrit (devanagari) to type. It would be easiest > for me if I could have the English (roman) as well as the sanskrit > (devanagari). > > For example using the devanagari-itrans input method I can write the > gayatri mantra using > > OM bhUrbhuvaH suvaH > tatsaviturvarenyam > bhargo devasya dhImahi > dhiyo yonaH prachodayAt > > and emacs produces *on the fly* (ie I cant see/edit the above) > > ? ???????? ???? ?????????????????? ????? ?????? ????? ???? ???? > ?????????? > > Can I do it in batch mode? ie write the first in a file and run some > command on it to produce the second? What is the devanagari-itrans input method? Do you actually type the characters into a terminal? If so, you should be able to type the first into a file, copy it, then paste it into the input buffer to be processed. -- Steven From bryanjugglercryptographer at yahoo.com Sat Feb 18 23:05:25 2012 From: bryanjugglercryptographer at yahoo.com (Bryan) Date: Sat, 18 Feb 2012 20:05:25 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> SherjilOzair wrote: > Has it been considered to add shell features > to python, such that it can be used as a > default shell, as a replacement for bash, etc. I think yes, but rather than become a shell, Python makes easy programming a shell that can execute Python code. The tendency has been to excel as a scripting language, and prefer to add extra features to the standard library. To start, look at the built-in functions eval() and (raw_)input; and the library modules: subprocess, os and os.path, glob and re, shutil, and code. > I'm sure everyone would agree that doing this > would make the terminal very powerful. 'Cept of course that they already are. From yves at zioup.com Sun Feb 19 00:47:52 2012 From: yves at zioup.com (yves at zioup.com) Date: Sat, 18 Feb 2012 22:47:52 -0700 Subject: tkinter.Toplevel In-Reply-To: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> References: <5d1fe990-69c2-4e33-8c93-a37583c3d907@f5g2000yqm.googlegroups.com> Message-ID: On 2012-02-17 16:48, Rick Johnson wrote: > On Feb 16, 8:39 pm, y... at zioup.com wrote: >> With a tkinter.Toplevel, how can I "disable" the parent windown and all its >> widget, in the same fashion as tkinter.messagebox? > > The answer lies within the tkSimpleDialog source code; which is pure > python. Look in the __init__ method of Dialog class. My advice is to > study the code until you understand every line. Look at the following > references when you need more info: > > http://infohost.nmt.edu/tcc/help/pubs/tkinter/ > http://effbot.org/tkinterbook/ ...grab_set() Thanks. -- Yves. http://www.SollerS.ca/ http://ipv6.SollerS.ca http://blog.zioup.org/ From dihedral88888 at googlemail.com Sun Feb 19 00:58:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 21:58:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <27781830.3.1329631112403.JavaMail.geo-discussion-forums@pbne2> ? 2012?2?19????UTC+8??8?36?48??Michael Torrie??? > On 02/18/2012 10:46 AM, Lie Ryan wrote: > > Android does have a full Linux experience; what it lacks is the GNU > > experience. Unlike "normal" Linux distros, Android does not use GNU > > userspace, instead it have its own userspace based on bionic, toolbox, > > and dalvik. Linux is a core part of Android's user and developer's > > experience. > > The fact that RIM is porting Android to QNX would seem to contradict > your assertion that Linux is a core part of Android's user and developer > experience. Have you developed for Android? In what way do you > interact with Linux in your apps and APIs? Can you make system calls? > How is Linux a core part of Android's user and developer experience? I > know that Android does allow some integration of native code, so that > does meld Linux and Android somewhat. > > >From a user's pov (non-rooted), there is nothing of Linux exposed. I > just install apps, run them, and manipulate my files which are stored in > my sd card. The fact that it's in /mnt/sdcard is completely hidden, as > are all files that support dalvik. The OS could be Windows, iOS, or > whatever. It doesn't matter because the platform is not defined by the > kernel but by the APIs that apps need to use to run on the platform, > just like in Python! In fact in some ways calling Android "Linux" would > be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" > just because it happens to run atop that kernel. I have mentioned those > specifically because they are interpreted or virtual machines > themselves; the "binaries" run regardless of underlying CPU type, or > kernel type. > > In my mind, the fact that Android runs on the Linux kernel is almost > entirely coincidental to Android's aims. Google could have developed > their own kernel, but of course it's much cheaper to use Linux. And of > course Dalvik is currently written to consume posix APIs from the kernel. > > In my mind, and in my experience with Android, Linux is irrelevant. Do you have to write a touch screen device driver under any mobile phone requested by your boss? If the current one is not suitable in the market entangled with law suites from other big corps, do you have to chunk a clean implementation? > In > fact continuing to call Android "Linux" might just be doing ourselves a > disservice. In any case, saying that since it's linux, you can install > anything you want on it, such as a JVM, is neither useful or accurate. Check the Jython JRE lib. If it is not compatable under Android's system, then there are jobs to do in the JVM maintainer in Androids or some revised requests for the Jython JRE library group. From dihedral88888 at googlemail.com Sun Feb 19 00:58:32 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sat, 18 Feb 2012 21:58:32 -0800 (PST) Subject: [OT]: Smartphones and Python? In-Reply-To: References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <27781830.3.1329631112403.JavaMail.geo-discussion-forums@pbne2> ? 2012?2?19????UTC+8??8?36?48??Michael Torrie??? > On 02/18/2012 10:46 AM, Lie Ryan wrote: > > Android does have a full Linux experience; what it lacks is the GNU > > experience. Unlike "normal" Linux distros, Android does not use GNU > > userspace, instead it have its own userspace based on bionic, toolbox, > > and dalvik. Linux is a core part of Android's user and developer's > > experience. > > The fact that RIM is porting Android to QNX would seem to contradict > your assertion that Linux is a core part of Android's user and developer > experience. Have you developed for Android? In what way do you > interact with Linux in your apps and APIs? Can you make system calls? > How is Linux a core part of Android's user and developer experience? I > know that Android does allow some integration of native code, so that > does meld Linux and Android somewhat. > > >From a user's pov (non-rooted), there is nothing of Linux exposed. I > just install apps, run them, and manipulate my files which are stored in > my sd card. The fact that it's in /mnt/sdcard is completely hidden, as > are all files that support dalvik. The OS could be Windows, iOS, or > whatever. It doesn't matter because the platform is not defined by the > kernel but by the APIs that apps need to use to run on the platform, > just like in Python! In fact in some ways calling Android "Linux" would > be similar to calling Java and the Sun JVM "Linux" or Python, "Linux" > just because it happens to run atop that kernel. I have mentioned those > specifically because they are interpreted or virtual machines > themselves; the "binaries" run regardless of underlying CPU type, or > kernel type. > > In my mind, the fact that Android runs on the Linux kernel is almost > entirely coincidental to Android's aims. Google could have developed > their own kernel, but of course it's much cheaper to use Linux. And of > course Dalvik is currently written to consume posix APIs from the kernel. > > In my mind, and in my experience with Android, Linux is irrelevant. Do you have to write a touch screen device driver under any mobile phone requested by your boss? If the current one is not suitable in the market entangled with law suites from other big corps, do you have to chunk a clean implementation? > In > fact continuing to call Android "Linux" might just be doing ourselves a > disservice. In any case, saying that since it's linux, you can install > anything you want on it, such as a JVM, is neither useful or accurate. Check the Jython JRE lib. If it is not compatable under Android's system, then there are jobs to do in the JVM maintainer in Androids or some revised requests for the Jython JRE library group. From sherjilozair at gmail.com Sun Feb 19 03:16:43 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sun, 19 Feb 2012 00:16:43 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> Message-ID: <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. Shell would give python raw power! And Python would manage it well. From sherjilozair at gmail.com Sun Feb 19 03:18:16 2012 From: sherjilozair at gmail.com (SherjilOzair) Date: Sun, 19 Feb 2012 00:18:16 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> Message-ID: <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. Shell would give python raw power! And Python would manage it well. From steve+comp.lang.python at pearwood.info Sun Feb 19 03:49:57 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Feb 2012 08:49:57 GMT Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4f40b7b5$0$29986$c3e8da3$5496439d@news.astraweb.com> On Sun, 19 Feb 2012 00:16:43 -0800, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another > shell, which borrows a lot from python, something like merging bash and > python. such that I can do `cd ~/Desktop/dev` and `for i in > open('file.txt'): print i` at the some shell. This I think would be VERY > useful. > > IPyhton is very good, but after all, it is just an advanced interpreter, > not a default shell. I don't want this to run on top of bash or sh. But > it should run on its own, at shell level. That's up to your operating system. If your OS lets you choose a shell, tell it to use IPython. IPython already supports being used as the system shell: http://ipython.org/ipython-doc/dev/interactive/shell.html http://transneptune.net/2009/06/16/ipython-as-your-default-shell/ If your OS doesn't support choosing a shell, you can't use anything but the built-in shell regardless of what Python does. Either way, this is not a Python problem to solve. It is an OS issue. -- Steven From rustompmody at gmail.com Sun Feb 19 03:52:34 2012 From: rustompmody at gmail.com (rusi) Date: Sun, 19 Feb 2012 00:52:34 -0800 (PST) Subject: entering unicode (was Python usage numbers) References: <4F36E2F5.9000505@gmail.com> <4f37229b$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f375347$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f407007$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <6c4323a5-79bb-4105-8581-a2bef19fc39b@4g2000pbz.googlegroups.com> On Feb 19, 8:44?am, Steven D'Aprano wrote: > On Sun, 12 Feb 2012 19:09:32 -0800, rusi wrote: > > I have some bunch of sanskrit (devanagari) to type. ?It would be easiest > > for me if I could have the English (roman) as well as the sanskrit > > (devanagari). > > > For example using the devanagari-itrans input method I can write the > > gayatri mantra using > > > OM bhUrbhuvaH suvaH > > tatsaviturvarenyam > > bhargo devasya dhImahi > > dhiyo yonaH prachodayAt > > > and emacs produces *on the fly* (ie I cant see/edit the above) > > > ? ???????? ???? ?????????????????? ????? > > ?????? ????? ???? ???? > > > ?????????? > > > Can I do it in batch mode? ie write the first in a file and run some > > command on it to produce the second? > > What is the devanagari-itrans input method? Do you actually type the > characters into a terminal? Its one of the dozens (hundreds actually) of input methods that emacs has. In emacs M-x set-input-method and then give devanagari-itrans. Its details are described (somewhat poorly) here http://en.wikipedia.org/wiki/ITRANS > > If so, you should be able to type the first into a file, copy it, then > paste it into the input buffer to be processed. For now Ive got it working in emacs with some glitches but it will do for now: http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/bfa6b05ce565d96d# > > -- > Steven Thanks [Actually thanks-squared one for looking two for backing up this thread to something more useful than ... :-) ] Coincidentally, along this, your response, Ive got another mail to another unicode related interest of mine: apl under linux. So far I was the sole (known) user of this: http://www.emacswiki.org/emacs/AplInDebian I hear the number of users has just doubled :-) From tjreedy at udel.edu Sun Feb 19 13:28:38 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 19 Feb 2012 13:28:38 -0500 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <6736331.2480.1329639496391.JavaMail.geo-discussion-forums@pbbox6> Message-ID: On 2/19/2012 3:18 AM, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another > shell, which borrows a lot from python, something like merging bash > and python. such that I can do `cd ~/Desktop/dev` and `for i in 'cd xxx' cannot work because that is not python syntax. "cd('xxx')" could. Right now, one can import os and do shell stuff, but not so convinient for interactive use. 'os.chdir' is not so convenient as 'cd'. Two possible options, either of which might exist on PyPI: 1. a shell module used as 'from bashshell import *' which would have functions closely mimicking, in this example, bash 2. a shell module used as 'from bashshell import bash; bash()' which would invoke an sub-interactive mode like help() that would allow 'cd xxx' and similar syntax, which still affecting the global environment. The latter would trade the inconvenience of '()'s for the inconvenience of entering and exiting a special submode. I have not used IPYthon so I have no idea how close it gets to either of these. -- Terry Jan Reedy From sorsorday at gmail.com Sun Feb 19 15:23:21 2012 From: sorsorday at gmail.com (Herman) Date: Sun, 19 Feb 2012 12:23:21 -0800 Subject: logging with logging.config.fileConfig Message-ID: I tried to use file to config my logger and I got a weird situation that each message is outputted twice... Here is my scenario: python: 2.6 file abc_logging.conf: [loggers] keys=root,abc [handlers] keys=consoleHandler [formatters] keys=detailFormatter [logger_root] level=DEBUG handlers=consoleHandler [logger_abc] level=DEBUG handlers=consoleHandler qualname=abc [handler_consoleHandler] class=StreamHandler level=DEBUG formatter=detailFormatter args=(sys.stdout,) [formatter_detailFormatter] format=%(asctime)-15s %(levelname)s: %(filename)s:%(lineno)s: %(message)s datefmt=%Y-%m-%d %H:%M:%S Then in my program, i config the file with this: SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) logging.config.fileConfig(SCRIPT_DIR + os.path.sep + 'abc_logging.conf') LOG = logging.getLogger('abc') I tried to print out the logger handlers with this: print("*"*10) print("number of handlers: %s" % len(LOG.handlers)) print(LOG.handlers) LOG.debug(sql) But there is no suspicious behavior: ********** number of handlers: 1 [] 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... From python at mrabarnett.plus.com Sun Feb 19 16:07:10 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 19 Feb 2012 21:07:10 +0000 Subject: logging with logging.config.fileConfig In-Reply-To: References: Message-ID: <4F41647E.2020400@mrabarnett.plus.com> On 19/02/2012 20:23, Herman wrote: > I tried to use file to config my logger and I got a weird situation > that each message is outputted twice... > Here is my scenario: > python: 2.6 > > file abc_logging.conf: > [snip] > [logger_abc] > level=DEBUG > handlers=consoleHandler > qualname=abc Add this line to stop the logging message from being propagated to higher level (ancestor) loggers: propagate=0 [snip] > > > Then in my program, i config the file with this: > > SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) > logging.config.fileConfig(SCRIPT_DIR + os.path.sep + 'abc_logging.conf') > LOG = logging.getLogger('abc') > > > I tried to print out the logger handlers with this: > print("*"*10) > print("number of handlers: %s" % len(LOG.handlers)) > print(LOG.handlers) > LOG.debug(sql) > > But there is no suspicious behavior: > > ********** > number of handlers: 1 > [] > 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... > 2012-02-19 12:21:56 DEBUG: abc.py:88: SELECT ... From torriem at gmail.com Sun Feb 19 19:23:33 2012 From: torriem at gmail.com (Michael Torrie) Date: Sun, 19 Feb 2012 17:23:33 -0700 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <4F419285.807@gmail.com> On 02/18/2012 11:58 AM, SherjilOzair wrote: > Has it been considered to add shell features to python, such that it > can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal > very powerful. > > What are your views on this? I use python for system programming all the time, in place of bash. However Python is not designed as shell language, just as Bash is not really designed for the type of application development that Python is. Bash works by giving you a view of the file system as your primary way of interacting with it as a shell. This is ideal because usually you want to manipulate files and processes (that's just what you do on a command line shell normally). Python doesn't work on that level. Like other langueages like php, you can manipulate files and processes through standard library calls. Frankly doing: cd ~/blah is much faster and more convenient in an interactive shell than: import os os.chdir(os.getenv("HOME") + "/blah") Also bash is designed to start and control processes: ls *.txt | wc -l or someprocess | grep something 2>&1 > /tmp/somefile.txt In python there is no direct correlation to these things, and in fact Python has different ways of doing that kind of thing (better for some things) if you want to write scripts (for example, http://www.dabeaz.com/generators/) My own experience has shown me that Python is a very capable systems-programming language, but that traditional shells are there for a reason. And if I need to script something, I usually go to Bash first because it's simpler and easier, at least for very small tasks. Once the bash script gets to be 100 lines or more, I switch to python. Then I use some modules I wrote myself to make subprocess.Popen a little simpler. Another library that I heard about on this list, called extproc, also seems to be similarly great for doing this. There have been attempts over the years to bring access to files and processes into python and still be pythonic, but they are all awkward. For example, this sort of syntax using dynamic attributes: shell.wc(shell.ls('/tmp/*.txt'), "-l") or shell.ls('/tmp/*.txt').pipe(shell.wc()) But it turns out that coming up with a python-compatible syntax is pretty hard, especially when it comes to pipes (don't forget standard err!) Besides all this, it's just plain awkward and unnecessary. From dihedral88888 at googlemail.com Mon Feb 20 01:15:44 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 19 Feb 2012 22:15:44 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <15520563.12.1329718544660.JavaMail.geo-discussion-forums@pbnv3> ? 2012?2?20????UTC+8??8?23?33??Michael Torrie??? > On 02/18/2012 11:58 AM, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it > > can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal > > very powerful. > > > > What are your views on this? > > I use python for system programming all the time, in place of bash. > However Python is not designed as shell language, just as Bash is not > really designed for the type of application development that Python is. > To use Python as a shell with customized scripts is feasiable for those hose have to work on different OS enviroments from time to time. This is a handy approach to ease the user the burden to memorize different commands of different OS environments. Of course, this might add some overheads in executing some operations. Nowadays attracting more people especially noices to use linux is the way to keep unix programming alive in the future. From dihedral88888 at googlemail.com Mon Feb 20 01:15:44 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Sun, 19 Feb 2012 22:15:44 -0800 (PST) Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: <15520563.12.1329718544660.JavaMail.geo-discussion-forums@pbnv3> ? 2012?2?20????UTC+8??8?23?33??Michael Torrie??? > On 02/18/2012 11:58 AM, SherjilOzair wrote: > > Has it been considered to add shell features to python, such that it > > can be used as a default shell, as a replacement for bash, etc. > > > > I'm sure everyone would agree that doing this would make the terminal > > very powerful. > > > > What are your views on this? > > I use python for system programming all the time, in place of bash. > However Python is not designed as shell language, just as Bash is not > really designed for the type of application development that Python is. > To use Python as a shell with customized scripts is feasiable for those hose have to work on different OS enviroments from time to time. This is a handy approach to ease the user the burden to memorize different commands of different OS environments. Of course, this might add some overheads in executing some operations. Nowadays attracting more people especially noices to use linux is the way to keep unix programming alive in the future. From jerry.scofield at gmail.com Mon Feb 20 03:54:11 2012 From: jerry.scofield at gmail.com (Jerry Zhang) Date: Mon, 20 Feb 2012 16:54:11 +0800 Subject: Beware, my computer was infected. In-Reply-To: <4F3ECE37.9000401@gmail.com> References: <4F3C4F31.8020303@gmail.com> <4F3ECE37.9000401@gmail.com> Message-ID: By the way, i like 1.exe, can i have it? ? 2012?2?18? ??6:01?Jugurtha Hadjar ??? > On 16/02/2012 01:34, Jugurtha Hadjar wrote: > >> Hello gentlemen, >> >> I'm writing these words to give you a heads up. My computer has recently >> been infected with "1.exe", and I am doing what I can to contain it. It >> spreads via mail and I fear it will send SPAM to lists I am subscribed to. >> >> If you receive weird mails from my address, thank you to report it to me. >> I will not send you an executable, so if you receive one from me, please do >> not open it and it would be nice to report it. >> >> I will send an e-mail to this list once I think it is no longer in the >> system. >> >> Thank you all. >> >> > Everything is under control. > > > > -- > ~Jugurtha Hadjar, > > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Mon Feb 20 06:27:06 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 20 Feb 2012 11:27:06 GMT Subject: #line in python References: Message-ID: Ross Boylan wrote: > As an extension or alternate, could there be a decorator like > @source_line(lineno, filename) > for classes and methods that could do the conversion on the fly? I > don't know if there's a way to go from the function (or class) object > the decorator receives to the AST. > No [easy] way to go from bytecodes back to AST, but I see no reason why you can't create a new code object with your filename and line numbers and then create a new function using your modified code object. If you don't have a 1:1 correspondence of lines then you'll need to pick out all the existing line numbers from the code object co_lnotab and modify them: see dis.py findlinestarts() for how to do this. Classes would be harder: the decorator doesn't run until after the class body has executed, so you can't change the line numbers that way until it's too late. The only thing I can think would be to put all of the generated code inside a function and fix up that function with a decorator that scans the bytecode to find all contained classes and fix them up. Or you could generate a .pyc file and then fix up line numbers in the whole file: see http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html for some code that shows you what's in a .pyc -- Duncan Booth http://kupuguy.blogspot.com From jeanmichel at sequans.com Mon Feb 20 06:48:22 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 12:48:22 +0100 Subject: logging with logging.config.fileConfig In-Reply-To: <4F41647E.2020400@mrabarnett.plus.com> References: <4F41647E.2020400@mrabarnett.plus.com> Message-ID: <4F423306.1070204@sequans.com> MRAB wrote: > On 19/02/2012 20:23, Herman wrote: >> I tried to use file to config my logger and I got a weird situation >> that each message is outputted twice... >> Here is my scenario: >> python: 2.6 >> >> file abc_logging.conf: >> > [snip] >> [logger_abc] >> level=DEBUG >> handlers=consoleHandler >> qualname=abc > > Add this line to stop the logging message from being propagated to > higher level (ancestor) loggers: > > propagate=0 > > [snip] >> An alternative solution is to add a handler to the root logger only. If you don't plan to have specific handling for the abc logger, this is the way to go. Remove "handlers=consoleHandler" from abc section. Note that %name will still properly identifies the logger that raised the event. JM From jeanmichel at sequans.com Mon Feb 20 06:53:49 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 12:53:49 +0100 Subject: [OT]: Smartphones and Python? In-Reply-To: <4F3F0411.80508@gmail.com> References: <9q2kj3Fmq1U1@mid.individual.net> <21549161.0.1329359932765.JavaMail.geo-discussion-forums@pbia1> <9616539.5.1329403988795.JavaMail.geo-discussion-forums@pbt3> <21970709.902.1329456355016.JavaMail.geo-discussion-forums@pbai10> <4F3F0411.80508@gmail.com> Message-ID: <4F42344D.90305@sequans.com> Michael Torrie wrote: > > I do not understand what you are saying, or at least why you are saying > this. But I don't understand most of your posts. > It's a bot. Add it to your kill file. JM From johannes.exner at tu-dortmund.de Mon Feb 20 09:57:07 2012 From: johannes.exner at tu-dortmund.de (JohannesTU) Date: Mon, 20 Feb 2012 06:57:07 -0800 (PST) Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' Message-ID: <1329749827797-4487915.post@n6.nabble.com> Hello everyone, I'm new to linux/suse, but I was given the task to install the print accounting software PyKota. Before that I never even touched a linux system, so I don't have any basic knowlegde at all! Up to now I was able to solve all problems with the help of google, but now I'm stuck. My problem: linux-6n5c:/usr/local/bin # pkusers --add john paul Creation... ERROR: PyKota v1.26_official ERROR: pkusers failed ERROR: Traceback (most recent call last): ERROR: File "/usr/local/bin/pkusers", line 442, in ERROR: retcode = manager.main(args, options) ERROR: File "/usr/local/bin/pkusers", line 345, in main ERROR: oldentry = getattr(self.storage, "add%s" % suffix)(entry) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 598, in addUser ERROR: oldentry = self.getUser(user.Name) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storage.py", line 623, in getUser ERROR: user = self.getUserFromBackend(username) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 355, in getUserFromBackend ERROR: % self.doQuote(self.userCharsetToDatabase(username))) ERROR: File "/usr/local/lib/python2.7/site-packages/pykota/storages/pgstorage.py", line 144, in doQuote ERROR: return pg._quote(field, typ) ERROR: AttributeError: 'module' object has no attribute '_quote' I have no idea how to deal with it or what it even means! Executing "linux-6n5c:/usr/local/bin # pkusers" works fine and shows me commands, version number etc. But adding users or printers (with pkprinters) won't work. I would be really thankful if anyone could give me some advice or hints how to solve the problem! Kind regards Johannes -- View this message in context: http://python.6.n6.nabble.com/PyKota-Python-AttributeError-module-object-has-no-attribute-quote-tp4487915p4487915.html Sent from the Python - python-list mailing list archive at Nabble.com. From ross at biostat.ucsf.edu Mon Feb 20 10:08:55 2012 From: ross at biostat.ucsf.edu (Ross Boylan) Date: Mon, 20 Feb 2012 07:08:55 -0800 Subject: #line in python (dirty tricks) In-Reply-To: <1329612858.9780.13.camel@corn.betterworld.us> References: <1329612858.9780.13.camel@corn.betterworld.us> Message-ID: <1329750535.1208.22.camel@corn.betterworld.us> Duncan Booth wrote ________________________________________________________________________ > Ross Boylan wrote: > > > As an extension or alternate, could there be a decorator like > > @source_line(lineno, filename) > > for classes and methods that could do the conversion on the fly? I > > don't know if there's a way to go from the function (or class) object > > the decorator receives to the AST. > > > No [easy] way to go from bytecodes back to AST, but I see no reason why you > can't create a new code object with your filename and line numbers and then > create a new function using your modified code object. Could you elaborate? I don't understand what you are suggesting. > > If you don't have a 1:1 correspondence of lines then you'll need to pick > out all the existing line numbers from the code object co_lnotab and modify > them: see dis.py findlinestarts() for how to do this. > > Classes would be harder: the decorator doesn't run until after the class > body has executed, so you can't change the line numbers that way until it's > too late. The only thing I can think would be to put all of the generated > code inside a function and fix up that function with a decorator that scans > the bytecode to find all contained classes and fix them up. > > Or you could generate a .pyc file and then fix up line numbers in the whole > file: see > http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html for > some code that shows you what's in a .pyc > My latest concept is to produce code that rewrites itself. Suppose the naive file would be ----------- mycode.py (naive) -------------------------------- class SomeClass: "class comment" def some_function(self, bar): pass --------- end ------------------------------- Protect that code by putting an "if 0:" in front of it and indenting each line one space. Than prepend a bit of code to do the rewriting, and add indicators of the original line numbers. ----------- mycode.py (after wrapping) ------------- from detangle import detangle detangle("mycode.py", "mycode.nw") if 0: # original code goes here class SomeClass: "class comment" #and when line numbering changes #line 35 def some_function(self, bar): pass ------------- end ------------------- I would write detangle so that it scans through the file in which it appears (named in the first argument), rewriting so that it appears to come from the original file (mycode.nw) given in the second argument. The scanning would look for the "if 0:" in the file. At that point it would accumulate code by reading lines and stripping the leading space. If it found a #line directive it would remember it and then remove it from the string it was accumulating. Finally, detangle would would pass the string of code to ast.compile, catching any syntax errors and rewriting the file and line number (I might rewrite columns too with an extension) and then rethrowing them. If compilation succeeded detangle could rewrite the AST and then exec it. Ross From jason at powerpull.net Mon Feb 20 11:03:25 2012 From: jason at powerpull.net (Jason Friedman) Date: Mon, 20 Feb 2012 16:03:25 +0000 Subject: HTTP logging Message-ID: I am logging to HTTP: logger.addHandler(logging.handlers.HTTPHandler(host, url)) Works great, except if my HTTP server happens to be unavailable: socket.error: [Errno 111] Connection refused Other than wrapping all my logger.log() calls in try/except blocks, is there a way to skip logging to the HTTPhandler if the HTTP server is unavailable? From arnodel at gmail.com Mon Feb 20 11:16:42 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Mon, 20 Feb 2012 16:16:42 +0000 Subject: HTTP logging In-Reply-To: References: Message-ID: On 20 February 2012 16:03, Jason Friedman wrote: > I am logging to HTTP: > > logger.addHandler(logging.handlers.HTTPHandler(host, url)) > > Works great, except if my HTTP server happens to be unavailable: > > socket.error: [Errno 111] Connection refused > > Other than wrapping all my logger.log() calls in try/except blocks, is > there a way to skip logging to the HTTPhandler if the HTTP server is > unavailable? Here's one: subclass HTTPHandler :) -- Arnaud From nandinighosh35 at gmail.com Mon Feb 20 11:59:36 2012 From: nandinighosh35 at gmail.com (nandini ghosh) Date: Mon, 20 Feb 2012 08:59:36 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: <2f27be36-017e-4f25-a83e-00ec50e72d7f@ow3g2000pbc.googlegroups.com> EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfree.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfree.yolasite.com/ Thanks ?? From jeanmichel at sequans.com Mon Feb 20 12:07:49 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 20 Feb 2012 18:07:49 +0100 Subject: HTTP logging In-Reply-To: References: Message-ID: <4F427DE5.8040201@sequans.com> Arnaud Delobelle wrote: > On 20 February 2012 16:03, Jason Friedman wrote: > >> I am logging to HTTP: >> >> logger.addHandler(logging.handlers.HTTPHandler(host, url)) >> >> Works great, except if my HTTP server happens to be unavailable: >> >> socket.error: [Errno 111] Connection refused >> >> Other than wrapping all my logger.log() calls in try/except blocks, is >> there a way to skip logging to the HTTPhandler if the HTTP server is >> unavailable? >> > > Here's one: subclass HTTPHandler :) > > short answer: use > logging.raiseExceptions = 0 long and incomplete answer: log calls should not raise any exception. http://docs.python.org/library/logging.html#handler-objects "Handler.handleError(record) This method should be called from handlers when an exception is encountered during an emit() call. By default it does nothing, which means that exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The specified record is the one which was being processed when the exception occurred" " However, I looked into the code and find out an (undocumented ?) attribute of the logging module : raiseException which value is set to 1 by default (python 2.5.2 logging.__version__ < '0.5.0.2' > ). When set to 1, handlerError print the traceback. This has been probably fixed in recent version of the module since the handleError doc does not reference raiseException anymore. JM From __peter__ at web.de Mon Feb 20 12:26:12 2012 From: __peter__ at web.de (Peter Otten) Date: Mon, 20 Feb 2012 18:26:12 +0100 Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' References: <1329749827797-4487915.post@n6.nabble.com> Message-ID: JohannesTU wrote: > Hello everyone, > > I'm new to linux/suse, but I was given the task to install the print > accounting software PyKota. > Before that I never even touched a linux system, so I don't have any basic > knowlegde at all! > Up to now I was able to solve all problems with the help of google, but > now I'm stuck. > > My problem: > > > linux-6n5c:/usr/local/bin # pkusers --add john paul > Creation... > ERROR: PyKota v1.26_official > ERROR: pkusers failed > ERROR: Traceback (most recent call last): > ERROR: File "/usr/local/bin/pkusers", line 442, in > ERROR: retcode = manager.main(args, options) > ERROR: File "/usr/local/bin/pkusers", line 345, in main > ERROR: oldentry = getattr(self.storage, "add%s" % suffix)(entry) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 598, > in addUser > ERROR: oldentry = self.getUser(user.Name) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storage.py", line 623, in > getUser > ERROR: user = self.getUserFromBackend(username) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/sql.py", line 355, > in getUserFromBackend > ERROR: % self.doQuote(self.userCharsetToDatabase(username))) > ERROR: File > "/usr/local/lib/python2.7/site-packages/pykota/storages/pgstorage.py", > line 144, in doQuote > ERROR: return pg._quote(field, typ) > ERROR: AttributeError: 'module' object has no attribute '_quote' > > > I have no idea how to deal with it or what it even means! I suppose you have successfully repaired your car, but don't know what an engine might be ;) > Executing "linux-6n5c:/usr/local/bin # pkusers" works fine and shows me > commands, version number etc. > But adding users or printers (with pkprinters) won't work. > > I would be really thankful if anyone could give me some advice or hints > how to solve the problem! The error traceback explained: Python is trying to call a function named _quote() in a module named pg. The most likely reason is either that you have the wrong version of the module or a module unrelated to the required one that has the same name and appears earlier in Python's search path. You can start debugging with $ python2.7 -c'import pg; print pg.__file__' to find out the filename and then look into the corresponding .py file. If that is related to postgresql you are probably seeing a version mismatch. Consult PyKota's documentation to find out the program's dependencies. From bblais at gmail.com Mon Feb 20 12:45:56 2012 From: bblais at gmail.com (Brian Blais) Date: Mon, 20 Feb 2012 12:45:56 -0500 Subject: paper submission and versioning system - advice? Message-ID: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> Hello, I'd like to find a web-based system to help a committee I'm on, where we receive proposals from different faculty. I wrote something in python, from scratch, a number of years ago because there wasn't anything available then but it is showing its age and I figured that someone has written something. Essentially I need users to be able to start a proposal, with some basic information, and then be able to add files to it. Other users will be allowed to add files as well, but I'd like to limit deletions to the committee members. It seems as if there just has to be available tools like this, but I am not even sure what such a system is called. Is there anything like this, in python preferably? thanks, Brian Blais -- Brian Blais bblais at gmail.com http://web.bryant.edu/~bblais http://brianblais.wordpress.com/ From vinay_sajip at yahoo.co.uk Mon Feb 20 12:47:54 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 20 Feb 2012 09:47:54 -0800 (PST) Subject: HTTP logging References: Message-ID: <3fbdb48b-675d-4345-a28c-1778bcb68108@db5g2000vbb.googlegroups.com> On Feb 20, 5:07?pm, Jean-Michel Pichavant wrote: > However, I looked into the code and find out an (undocumented ?) > attribute of the logging module : raiseException which value is set to 1 > by default (python 2.5.2 logging.__version__ < '0.5.0.2' > ). > > When set to 1, handlerError print the traceback. > > This has been probably fixed in recent version of the module since the > handleError doc does not reference raiseException anymore. Actually, I think it's a mistake in the docs - when they were reorganised a few months ago, the text referring to raiseExceptions was moved to the tutorial: http://docs.python.org/howto/logging.html#exceptions-raised-during-logging I will reinstate it in the reference API docs, but the answer to Jason's problem is to either subclass HTTPHandler and override handleError to suppress the error, or set logging.raiseExceptions to True (in which case all logging exceptions will be swallowed - not necessarily what he wants). Regards, Vinay Sajip From andrea.crotti.0 at gmail.com Mon Feb 20 13:47:09 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 20 Feb 2012 18:47:09 +0000 Subject: paper submission and versioning system - advice? In-Reply-To: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> References: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> Message-ID: <4F42952D.3030505@gmail.com> On 02/20/2012 05:45 PM, Brian Blais wrote: > Hello, > > I'd like to find a web-based system to help a committee I'm on, where we receive proposals from different faculty. I wrote something in python, from scratch, a number of years ago because there wasn't anything available then but it is showing its age and I figured that someone has written something. > > Essentially I need users to be able to start a proposal, with some basic information, and then be able to add files to it. Other users will be allowed to add files as well, but I'd like to limit deletions to the committee members. > > It seems as if there just has to be available tools like this, but I am not even sure what such a system is called. Is there anything like this, in python preferably? > > > thanks, > > Brian Blais > Well I guess that any web framework would provide you more or less easily with all you need.. Django turbogears pyramid flask or web2py are just the names I know. From vinay_sajip at yahoo.co.uk Mon Feb 20 13:53:14 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 20 Feb 2012 10:53:14 -0800 (PST) Subject: HTTP logging References: <3fbdb48b-675d-4345-a28c-1778bcb68108@db5g2000vbb.googlegroups.com> Message-ID: <87f28356-5582-49f2-8b85-39f0c3b86380@e27g2000vbu.googlegroups.com> On Feb 20, 5:47?pm, Vinay Sajip wrote: > I will reinstate it in the reference API docs, but the answer to > Jason's problem is to either subclass HTTPHandler and override > handleError to suppress the error, or set logging.raiseExceptions to > True (in which case all logging exceptions will be swallowed - not Um, that should be *False*, not True. Regards, Vinay Sajip From duncan.booth at invalid.invalid Mon Feb 20 13:54:01 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 20 Feb 2012 18:54:01 GMT Subject: #line in python (dirty tricks) References: <1329612858.9780.13.camel@corn.betterworld.us> Message-ID: Ross Boylan wrote: >> No [easy] way to go from bytecodes back to AST, but I see no reason >> why you can't create a new code object with your filename and line >> numbers and then create a new function using your modified code >> object. > Could you elaborate? I don't understand what you are suggesting. This (written for Python 3.x, needs some attribute names changing for Python 2.x: import functools def source_line(lineno, filename = None): def decorator(f): c = f.__code__ code = type(c)( c.co_argcount, c.co_kwonlyargcount, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code, c.co_consts, c.co_names, c.co_varnames, c.co_filename if filename is None else filename, c.co_name, lineno, c.co_lnotab, c.co_freevars, c.co_cellvars) f.__code__ = code return f return decorator @source_line(43, 'foo.bar') def foo(): """This is foo""" for i in range(10): bar() @source_line(665, 'evil.txt') def bar(): raise RuntimeError("oops") if __name__=='__main__': import traceback try: foo() except RuntimeError as ex: traceback.print_exc() When you run it the output looks something like this (if you create a file evil.txt with 667 lines): Traceback (most recent call last): File "C:\temp\foo.py", line 30, in foo() File "foo.bar", line 47, in foo File "evil.txt", line 667, in bar Evil line 667 RuntimeError: oops -- Duncan Booth http://kupuguy.blogspot.com From tjreedy at udel.edu Mon Feb 20 14:35:25 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 20 Feb 2012 14:35:25 -0500 Subject: paper submission and versioning system - advice? In-Reply-To: <4F42952D.3030505@gmail.com> References: <00611584-0A32-4DD2-A10E-1A28797229CC@gmail.com> <4F42952D.3030505@gmail.com> Message-ID: On 2/20/2012 1:47 PM, Andrea Crotti wrote: > On 02/20/2012 05:45 PM, Brian Blais wrote: >> I'd like to find a web-based system to help a committee I'm on, where >> we receive proposals from different faculty. I wrote something in >> python, from scratch, a number of years ago because there wasn't >> anything available then but it is showing its age and I figured that >> someone has written something. >> >> Essentially I need users to be able to start a proposal, with some >> basic information, and then be able to add files to it. Other users >> will be allowed to add files as well, but I'd like to limit deletions >> to the committee members. >> >> It seems as if there just has to be available tools like this, but I >> am not even sure what such a system is called. Content Management System (in this case, for a private web site?) is one term I have seen. > Is there anything like this, in python preferably? Too many ;-). > Well I guess that any web framework would provide you more or less > easily with all you need.. > Django turbogears pyramid flask or web2py are just the names I know. + others... To possibly limit choices, decide whether you want files available to the world or just those with accounts (which requires an authentication system). -- Terry Jan Reedy From shejo284 at gmail.com Mon Feb 20 15:37:22 2012 From: shejo284 at gmail.com (Sheldon) Date: Mon, 20 Feb 2012 12:37:22 -0800 (PST) Subject: netCDF4 variable manipulation Message-ID: Hi, I'm trying to read a netCDF4 variable from a file (no problem) and then scale it before writing over the original variable in the file. I'm using python 2.7 and the latest netCDF4 module. It's not that I keep getting an error message but I want to do this without using for loops and all the manuals seems to be skipping this task as if it is never done. I'm new to python and coming over from matlab. Does anyone know how to modify the netCDF4 variable in python and then write it back without creating a new variable, or using for loops? Appreciate the help, /S From drsalists at gmail.com Mon Feb 20 15:53:21 2012 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 20 Feb 2012 12:53:21 -0800 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <7x62f7u0sg.fsf@ruckus.brouhaha.com> References: <9q2kj3Fmq1U1@mid.individual.net> <7x62f7u0sg.fsf@ruckus.brouhaha.com> Message-ID: On Wed, Feb 15, 2012 at 3:36 PM, Paul Rubin wrote: > Martin Sch??n writes: > > A very quick internet search indicated that this should be no big > > deal if I go for an Android-based phone. What about the alternatives? > > It works pretty well with Maemo, though phones with that are not so easy > to find. My ex-officemate wrote some SL4A (Android) apps in Python and > said it was pretty easy to use, though some features were missing. I > know that one missing feature was tkinter. > The missing features is why I wish SL4A's Python were based on jython or the java version of pypy. Apparently each new function needs a stub for the SL4A CPython; something that runs on a JVM (OK: Dalvik really, but it's almost the same thing) should be able to call java functions directly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Mon Feb 20 17:52:51 2012 From: d at davea.name (Dave Angel) Date: Mon, 20 Feb 2012 17:52:51 -0500 Subject: netCDF4 variable manipulation In-Reply-To: References: Message-ID: <4F42CEC3.1020001@davea.name> On 02/20/2012 03:37 PM, Sheldon wrote: > Hi, > > I'm trying to read a netCDF4 variable from a file (no problem) and > then scale it before writing over the original variable in the file. > > I'm using python 2.7 and the latest netCDF4 module. It's not that I > keep getting an error message but I want to do this without using for > loops and all the manuals seems to be skipping this task as if it is > never done. I'm new to python and coming over from matlab. Does anyone > know how to modify the netCDF4 variable in python and then write it > back without creating a new variable, or using for loops? > > Appreciate the help, > /S Are you using netcdf version 4, or is that name just a coincidence? If you're using a 3rd party library, you really should say so, and post a link, for those curious. in any case, if you are, I can't help you. This is apparently some special kind of variable similar to a numpy array. On the other hand, you may just be asking how to update some bytes in a file, in place. if you read the file in binary mode, then you can use seek() to go back the appropriate distance, and simply write it. -- DaveA From steve+comp.lang.python at pearwood.info Mon Feb 20 18:53:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Feb 2012 23:53:03 GMT Subject: netCDF4 variable manipulation References: Message-ID: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: > Hi, > > I'm trying to read a netCDF4 variable from a file (no problem) and then > scale it before writing over the original variable in the file. > > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep > getting an error message but I want to do this without using for loops > and all the manuals seems to be skipping this task as if it is never > done. I'm new to python and coming over from matlab. Does anyone know > how to modify the netCDF4 variable in python and then write it back > without creating a new variable, or using for loops? There is no such thing as "the netCDF4 variable" in Python -- it is not a built-in part of the language, and therefore there is no built-in feature for manipulating it. You are going to have to be more specific about what you want than just "how do I modify a variable with for loops?". My wild guess is that you have some sort of config file which includes a field called "netCDF4" and you want to update it in place. We can't tell you how to do this without knowing what the config file is -- is it an INI file, XML, JSON, YAML, Unix-style rc file, a binary pickle, or something else? -- Steven From monaghand.david at gmail.com Mon Feb 20 20:33:19 2012 From: monaghand.david at gmail.com (David Monaghan) Date: Tue, 21 Feb 2012 01:33:19 +0000 Subject: Numeric root-finding in Python References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: > > >I don't know the first thing about this math problem however, > >if I were to code this I might try ; > > except ZeroDivisionError: > assert w = -1 > >rather than; > > except ZeroDivisionError: > assert w == -1 Why? DM From delmertr at gmail.com Mon Feb 20 20:50:13 2012 From: delmertr at gmail.com (delmer trena) Date: Mon, 20 Feb 2012 17:50:13 -0800 (PST) Subject: Extreme Face Fucking || Fucking Young Boobs || Young Redhead Xxx Message-ID: http://erohide.com/Feb-2012/Virgin_Pussy_Fuckeeinsest http://erohide.com/Feb-2012/Hot_Teen_Virgin.wmv http://dizzyporn.com/2012-Feb/Young_Sisters_Mobile.spycam.3gp http://dizzyporn.com/2012-Feb/Japanese_Incest_Vol_5_XviD.AC3.avi http://erohide.com/Feb-2012/Teacher_Young_Student_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Iranian_Virgin_Pussy.avi http://dizzyporn.com/2012-Feb/Tied_Forced_Cum_Eat_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Rape_In_Nature.avi http://dizzyporn.com/2012-Feb/Very_Young_Teen_Couple_XviD.AC3.avi http://erohide.com/Feb-2012/School_Of_Bondage_Hentai_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Korean_Virgin_Scandal.avi http://dizzyporn.com/2012-Feb/Incest_Italia_Fratelli_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Asian_Bus_Molestation_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Japa_Hospital.mpeg pussy young free in phoenix free multiple gangbang creampies banned russian extreme pussy fetish amateur brazilian preteens torture electrode anus erotic stories bondage mouth insertions massive extream mammary torture bdsm young in stockings gallery free anal young girl barefoot male bondage extreme pussy squirt free petite girl fucking gangbang sex fantasy story tight anal penetration photos of virgin pussy legal underage nudity pictures young teens raped mature sex young men little rock arkansas apartments forced orgasms bondage young hairy nude guys world's sexiest bondage photo inserting utensils in pussy how to torture your own feet tortured slaves at red doe illegal kids pics oldman fuck young gallery sexy lesbiians licking each other forced to serve pussy silk panties gangbang bi lesbian bondage comics torture nazi girl naked pussy sexy naked young school girls tight rope bondage stories extreme little pussy bondage fairies hentai comics photos of boy licking pussy selfbondage crotch rope amateur twitching clit videos stories of licking pussy young naked little girl movies water bondage clips dirty tactics in divorce free nude young japanese girls japanese bondage mud irc server bondage preteen pee stories petite sex cruel full young sex movies interacial mature fucks young boys men bondage chains bears consquences of underage drinking little pussy big asses younge lesbian sex virgin lolita sex hot bondage whores young fuck buddies little caesars pizza menu hot free young porn com tiny preteen twat topsites young pussy sweedish bondage galleries free young teen threesome porn uncensored youth sex comics young breasts exposed in movies anal licking mpeg free young braces porn dirty bed girls suspension bondage galleries From delmertr at gmail.com Mon Feb 20 20:50:35 2012 From: delmertr at gmail.com (delmer trena) Date: Mon, 20 Feb 2012 17:50:35 -0800 (PST) Subject: Video Samples Lolita || Forced Pussy Eating || Illegal Porn Share Message-ID: <9d2369c4-2234-4fe0-a3f0-edaa7b136e36@b18g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Indian_Mallu_Boob_Press_Rape.avi http://dizzyporn.com/2012-Feb/Beastiality_Dog_Sex.wmv http://erohide.com/Feb-2012/Viy_A_Friend.wmv http://erohide.com/Feb-2012/Indian_Xxx_Rape.avi http://dizzyporn.com/2012-Feb/Milf_Son_Incest_Slutload_Com_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Giant_Insertion_Anal_Prolapse.wmv http://dizzyporn.com/2012-Feb/Lesbian_Drunk_Forced_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Insertion_Football_Ball_In_Ass.wmv http://dizzyporn.com/2012-Feb/Forced_Wear_Diapers_XviD.DVDRip.avi http://erohide.com/Feb-2012/Naage_Lolita.avi http://erohide.com/Feb-2012/Little_Lolita_Incest_Lolicon.com.mp4 http://erohide.com/Feb-2012/Virgin_Off_Natasha.wmv http://dizzyporn.com/2012-Feb/Preteen_Pantyhose_00.avi http://dizzyporn.com/2012-Feb/Femdom_Handjob_Torture_Orgasm.wmv very young free porn videos illegal young nude models femdom crossdress bondage fuck for cash squirting nude petite beautiful underage petite porn stars very young girls pussy xxx amature preteen pussy thumbnail gallery dirty and clean bathroom free movies masturbation young hard penetration movie young girls fuck free videos classic lady sonia bondage del mar ca private annuity trust little girl playing with pussy black youngest porn dirty toon porn little sisters pink pussy free videos xxx women squirt extreme female penetration elisabetta cavalotti bondage movie sexy petite amateur young russian girl nude ice cock torture fine little asians frank's attic bondage little girls russian kiddy porn free tight movie clips squirt men forced to wear silk panties free bondage comix hogtied and tortured real gangbangs bondage old man on young boy movie young man changes sex free bondage forte password catheter fetish bondage sexy hot free young galleries young girl sucking dick bi sexual gangbang porn young pantyhose porn hailey little pussy illegal pics of nude girls cutie schoolgirl young pussy young indian sexy girls bondage fantasy stories pictures hot sexy young pussy sex amateur anal gangbang squirting video on useless junk nude gothic torture free videos of clit play college bondage fiction free porn 100 cock torture petite year old girls sexy young girls free smokin hot pussy squirting movies femdom penis torture stories c r monie bondage bondage boob milking tickle tortured clit young teens illegal porn preteen leather models free lesbian hardcore licking videos donna smith squirts free oral bondage sex bondage video galleries free young nude boys fucking latex bondage pics hentai bondage bukkake pretty young girls galleries bondage super heroins From marybobbyjac at gmail.com Mon Feb 20 20:51:48 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:51:48 -0800 (PST) Subject: Younger Teen Movie || Forced Blowjob Clips || Illegal Teen Fucking Message-ID: <283734df-43aa-4cb6-a3c2-79fb1f88a1ea@hs8g2000vbb.googlegroups.com> http://erohide.com/Feb-2012/Japanese_Incest_2_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Pthc_Vicky_Taboo_Incest_69_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Squirt_Electro_Torture_Fuck_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Facial_Amateur_Forced_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Russian_Mom_Rape.mpeg http://erohide.com/Feb-2012/Teen_Gay_Male_Models_2009.fr.avi http://erohide.com/Feb-2012/Electric_Pussy_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Indian_Real_Virgin_Hymen_Broken.avi http://dizzyporn.com/2012-Feb/Brother_Fucks_Young_Sister_XviD.AC3.avi http://erohide.com/Feb-2012/Mom_Vid.DVDRip.avi http://erohide.com/Feb-2012/Mz_Booty_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Blvid.DVDRip.avi http://erohide.com/Feb-2012/Bizzvid.DVDRip.avi http://erohide.com/Feb-2012/Japature_Rape.mpeg free squirting redhed porn wife gangbang movie pussy licking lesson little gothic girl getting fucked cyber young fuck orgy anal cum licking underage asain porn woman doing it dirty dirty ebony sluts young latina ass double penetration anal movies cunt licker pussy juice funny pussy insertion cock bondage torture cgi young sex lolita sex porno homemade porn drunk hillbilly gangbang china pussy lick templeton bondage art dirty blond girls dog lick fuck woman extreme pussy toy penetration vintage lady sonia in bondage sexiest costume bondage lolitaportal bbs russian petite pants sexy young gax sex stories chinese bondage fetish young sex games free teen squirt videos downloads dirty doggy style sex free bdsm and bondage passwords slave licking mistress pussy map little river sc anateur preteen porn lolita links index worlds youngest pussy pics big clit pumping videos japanese av stars uncensored young teen playing with pussy lesbian pussy licking online clips wet pussy college bondage slave lifestyle hentai lesbian gangbang young teen homemade fuck movies petite mature nude free gangbang video gratuit free younger than 18 porn young teen toon young sexy xxx lolita girls top list bondage and latex stories and contest hot young girls porn sites sex and bondage bdsm young girl fuck dog preteen intercourse pictures mother makes daughter squirt sample clip free thumbs gangbang video next door lolita young teenage couple sex girls forced face fuck afroman - dirty rap free interracial gangbang movies young boys and girls porn photos young girls french sexy xxx young teen sites latex anal bondage young cute faces japanese torture techniques dirty sluts fucked by doctors young small sexy From marybobbyjac at gmail.com Mon Feb 20 20:52:18 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:52:18 -0800 (PST) Subject: Illegal Teen Xxx || Young Feet Porn || Young You Porn Message-ID: <05a5994e-29a3-4ff1-9898-a605b146aebf@m7g2000vbw.googlegroups.com> http://erohide.com/Feb-2012/Hard_Core_Bondage_004.mpeg http://erohide.com/Feb-2012/Breaking_Virgin_Hyman.wmv http://dizzyporn.com/2012-Feb/Young_And_Anal_4_XviD.AC3.avi http://erohide.com/Feb-2012/Christine_Young_Masturbation_BDrip.XviD.AC http://dizzyporn.com/2012-Feb/Very_Young_Group_XviD.AC3.avi http://erohide.com/Feb-2012/Huge_Cock_Rape http://dizzyporn.com/2012-Feb/Rachel_Steele_Rape.mpeg http://dizzyporn.com/2012-Feb/Pov_Incest_Mom_XviD.AC3.avi http://erohide.com/Feb-2012/Young_Homemade_Threesome_XviD.AC3.avi http://erohide.com/Feb-2012/Inn_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Glasses_Boot_Insertion.wmv http://erohide.com/Feb-2012/Little-lolita-nude.avi http://erohide.com/Feb-2012/Vition_Hymen.wmv http://erohide.com/Feb-2012/Wife_Forced_Infront_Of_Husband_XviD.DVDRip.avi holly marie combs in bondage young teen nipples very young bald pussy cat licking woman pussy amazon com youngest sex free young teens porn asian indian bondage slut fake bondage pics nelly furtado young mexican pussy dirty hotel maids stripping petite girls bondage hanging stories asian teen gangbang young panty sluts pretty petite pussy girl licks squirting pussy free very young porn video girls licking juicy pussy private cam orgasms underage boys in jockstrap licking cum from ass underage girls hairy pussy preteen pantyhose photos self bondage nudes video asian appetite no chance bondage ass lick clips cameltoes nice pussy bondage fetish furniture underage girls incest sex bit torrents young creamed pussy what is breast bondage bondage small tits movie girls gangbang guy free adult bondage pic sexy and katie and petite petite ridind dick young n nice pussy free underaged porn private military corporations young wet cfnm pussy free pics of gangbangs girl inserting dogcock in pussy teenager male bondage cum licking bitches hot young swinger dick blick catalog how to sexual squirt dental fetish bondage dental fetish illegal sex movie galleries hairless young lolita preteen models christina carter bondage video xvideo amateur videos of young teens hot nurse hentai bondage jamie hammer bondage eat lick suck ass young hairy teen pussy clit licking video youngest legal porn age cum in clit tiny teen illegal long pussy lick young bodies teen porn bondage reviews dvds free pussy licking galleries suck until squirt big women bondage paranoia max dirty mix underage bisexual sex young humuliating porn tgp From marybobbyjac at gmail.com Mon Feb 20 20:52:33 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:52:33 -0800 (PST) Subject: Alt Porn Young || Little Russian Porn || Forced Bdsm Stories Message-ID: <278bd43b-5626-42cf-bfba-4180d731a523@s7g2000vby.googlegroups.com> http://erohide.com/Feb-2012/Russian_Mom_Young_Son_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Incest_Mom_Gang_XviD.AC3.avi http://erohide.com/Feb-2012/Naked_Tickle_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Young_Lady_Chatterly_2_XviD.AC3.avi http://erohide.com/Feb-2012/Virgin_Boy_Fast_Cumming.wmv http://erohide.com/Feb-2012/Pornstar_And_Male_Virgin.avi http://erohide.com/Feb-2012/Mature_Blondewith_Young_Man_XviD.AC3.avi http://erohide.com/Feb-2012/Russian_Teen_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Young_Blonde_Double_Team_XviD.AC3.avi http://erohide.com/Feb-2012/Indian_Girls_Rape.avi http://erohide.com/Feb-2012/Young_Sisters__mobile.spycam.3gp http://erohide.com/Feb-2012/Blonde_Massage_Rape_Xxx.avi http://erohide.com/Feb-2012/Boys_Outdoor_Sex_BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Teens_Rape_Dad.avi young tease video white wives interracial gangbang young nudes small tits porno bondage site password teen nude dark little pussy squirt tutorial video free young nude pics movies clit fuck comics young shaved pussy cum clips opportunities for petite models hot young chubby pussy youngs vintage home and garden free milk squirting tits the road to morocco bondage dirty blonde slut fat black clit bondage bag pattern girls young amateur masturbating movies advocates for underage drinking amatuer bondage sex movies virgin in black stockings mother fuck by young youth petite sex gallery wild teen lesbians licking each other lick gaged cried forced cock petite teen first time audition bdsm torture picture thumbnails shaved pussies that squirt milf's fucking younger guys young little girles pussy free george carlins seven dirty words transexual gangbang free video cock and ball torture forums want to lick your pussy slick hung studs long legs sexy young girls teens lick pussy russian extreme anal porn masterbating little pussys bondage koko li preteen hairless pussy wet latina pussy solo illegal bollywood porn brother forced to wear sisters panties 42 h breast bondage bras tiny teen clits lolita underage pics young girls porn family free extreme hardcore snuff film pictures young teenagers fucking anime cat lick fur off tummy ass licking porn for free dirty slutty bitches porn amateur ass lick petite carved bath vanity young teen pornography little tee pussy grandma anal gangbang clips mr t bondage very young hot teen pussy black squirter porno fantasy bondage art lindsay lohan bondage stories torture of femal slaves little boys dick bondage play list cock and ball tortured b is for bondage web male bondage stoy to young girls pussy From marybobbyjac at gmail.com Mon Feb 20 20:53:34 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:53:34 -0800 (PST) Subject: Free Young Fucks || Young Filipino Porn || Lolita Amateur Video Message-ID: <3d08452c-a0a5-4b32-9133-83af73d3631d@db5g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Young_Thai_Public_XviD.AC3.avi http://erohide.com/Feb-2012/Brother_Sister_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Sebas_XviD.AC3.avi http://erohide.com/Feb-2012/Japanese_Widow_Rape.mpeg http://dizzyporn.com/2012-Feb/Christine_Young_Masturbation_BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Forced_To_Fuck_Old_Man_XviD.DVDRip.avi http://erohide.com/Feb-2012/Dad_Dfebhter_Incest_Rape_XviD.AC3.avi http://erohide.com/Feb-2012/Double_Penetration_2_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Taboo_American_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_School_Girls_XviD.AC3.avi http://erohide.com/Feb-2012/Whe_Spanking.wmv http://erohide.com/Feb-2012/Russpe_By_Son.mpeg http://dizzyporn.com/2012-Feb/Bondage_Forced_Trailer.wmv http://dizzyporn.com/2012-Feb/Lolita_Pussy_Insertions_XviD.AC3.avi young indians pussy hot petite chicks leather bondage clips mature woment younger girls videos ugly girl young porn bondage in clothes kate mandala bondage young young girl sex bondage having sex restraints petite casual dress illegal shocking porn ridiculously wet pussy live nude video bondage best illegal porn sites young sexey pussy pussy clit cutting off asian bondage listing young porn pix hot very young brunettes fucking fantasy bondage set banned underage lolita vids pics cast of pretty dirty young girls cum in mouth dbz comic dirty fight very young teen fucker thumbs wet pussy landing strip old fucks the young youngest girl sex pics fuck young blonde picture loony tunes gangbang little pussies nude hottest young porn stars young first time lesbian porn teen pussy penetrated girls licking creampies on video young girls fucking bizarre little vixens having sex wet pussy fingering free videos extreme bondage thumbs younger teen blowjob teen gallery outdoors sex petite free bondage video shipping amateur young bikini young girls boys porn old women youngboy sex video prick tease gangbang hot young sluts young nudes no sex blonde teen licked and fucked old women young boys fy air force military pay giraffe licking pussy sexy young virgin girls j j plush bondage sex video ass licking back squirting pussy bondage fairies video tanned little teen young males porno movies mexican preteen girls bdsm bondage cocksuckers tight wet pussy movies little asian pussy holes young little girl fucked woman vaginal needle torture stuff lesbian fingering wet teen pussy older men fucking young girl young teen pussy movie free bondage library see more squirts From marybobbyjac at gmail.com Mon Feb 20 20:54:58 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:54:58 -0800 (PST) Subject: Reall Young Fuck || Jordan Young Porn || Private Teacher Porn Message-ID: <1d9f279e-0362-4761-8f85-6330df56ad83@hk10g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Bizzarvid.DVDRip.avi http://erohide.com/Feb-2012/Father_And_Dfebhter_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Japanese_Incest_Vol_5_07_XviD.AC3.avi http://erohide.com/Feb-2012/Massage_Oil_And_Rape.mpeg http://erohide.com/Feb-2012/Saline_Breast_Torture_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Rape_Scene_35.mpeg http://dizzyporn.com/2012-Feb/Forced_Drunk_Lesbian_Sex_XviD.DVDRip.avi http://erohide.com/Feb-2012/Nude-preteen-video.avi http://dizzyporn.com/2012-Feb/Wife_Fuck_Young_Boy_XviD.DVDRip.avi http://erohide.com/Feb-2012/Double_Penetration_4some_XviD.DVDRip.avi http://erohide.com/Feb-2012/Interracial_Gangbang_Rape.avi http://erohide.com/Feb-2012/Underage_Lesbian_Porn_07.avi http://erohide.com/Feb-2012/Shgirls_Only.wmv http://erohide.com/Feb-2012/Severe_Tit_Torture.wmv young boys galleries jenny lee bondage adult sex porn young skirt bondage pain pics vaginal squirting movies young pink teen lara croft bondage young latin tits bondage in vehicles free girl squirting video bondage mansion part 1 bondage blonde movies free sabras in bondage forced blowjob msmedia lesbians licking deep in pussy squirting mature porn clips little tiny ass younger videos xxx free xxx porn squirt young russia sex eve ellis breast bondage 13 teen young porn jacklyn lick pics young girl sucking cock bondage cartoons domination young teens hardcore fucking movies cock torture cock balls redhead young teens fucking extreme fetish drawings strange sex torture bear wet pussy females licking own pussy petite fishnet stockings erotic chair bondage dirty slut video clips small young girls galleries women fucked in bondage nipple squirting free videos young sexy bikini models naked free petite women movies lesbian preteen story bondage tanning lotion dirty wife sex back prayer arm bondage mpg young fuck extreme kream squirt videos grandmother young sex amateur lolita galleries lick a lot of pussy teenage enema nurses in bondage young indian raw sex purple tits bondage lolita naked forum megateen nude men in torture dungeons symptom: dirty skin xxx young girl peing thin young creampie porn teens gangbang mature extreamly young porn hardcore lesbian bondage strapon teen college virgin shave pussy bondage slave torture comics free illegal sex pics free torture bdsm drawings little girls kds bbs ankle socks bondage women in bondage with women preteen camel toe ebony lolita art youngest pornstar pics From marybobbyjac at gmail.com Mon Feb 20 20:55:09 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:55:09 -0800 (PST) Subject: Dicks Young Porn || Porn Young 5-8 || Ultimate Young Porn Message-ID: <7138e639-5fcc-433b-ad50-2ca9a7be7942@db5g2000vbb.googlegroups.com> http://erohide.com/Feb-2012/Russian_Mom_And_Son_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Virgin_Blond_Hot.wmv http://dizzyporn.com/2012-Feb/Spanking_Teen_Jessica.wmv http://erohide.com/Feb-2012/Father_Dfebhter_Creampie_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Underage_Lolitas_Ing.mpeg http://dizzyporn.com/2012-Feb/Russian_Mom_Rape_By_Son.mpeg http://dizzyporn.com/2012-Feb/Sex_Rape_For_Arab.avi http://erohide.com/Feb-2012/Gay_Hardcore_Xxx_XviD.hdrip.avi http://erohide.com/Feb-2012/Veryn_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Teen_Anal_Creampie_XviD.AC3.avi http://erohide.com/Feb-2012/Boayrip.x264.avi http://erohide.com/Feb-2012/Frvid.DVDRip.avi http://erohide.com/Feb-2012/Realt_XviD.AC3.avi http://erohide.com/Feb-2012/Forced_Diapers_7_XviD.DVDRip.avi kream squirt video super tight virgin pussy free torture sex clips big nip lick free preteen model links free clit bumping porn vids little boy cock big tits and wet pussys young fuck pics pussy party screaming cunt squirting hairy pussy clit slow licking cock video hot girls with wet pussy 3-d cartoon sex young girl teen pussy masturbating pink wet teen pussy fuck squirt preteen lesbian incest d skinny nudes big clits amateur nude women bondage corset free asian hardcore bondage pics sexy make up flickr clitoris stimulation videos man licking cunt videos hot and dirty secretary little tykes yard toys bondage gear and furniture young girl maria fucking windmill dirty lantin maids black anal gangbangs finering virgin pussy porn nude squirting video young sexy blonde fucked very young chubby girls sex real underage sex young girl titty fucked victorian bondage stories penetrate balls asshole girls licking nipples erotic licking video young boy with bogs sex ping pong ball insertion hentai forced bondage shaved lesbian preteens fingering young vixen sex illegal traci lords pics banned underage nude pussy squirting orgasim fresh young chicks young girls who like sex lactating tittie squirting videos brother sister virgin pussy cock young teens get fucked young teen first anal dirty latina maid monique bondage tube sites dirty little boys bondage gallery 4 anime girls dirty free ass licking porn videos ryan devoe bondage skinny young boy japanese porn girls young bondage high def free erotica bondage stories little feet little pussy pics gangbang bisexual hardcore how to squirt from your pussy sexy naked petites younger teens sex hentai wet pussy games From marybobbyjac at gmail.com Mon Feb 20 20:55:25 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:55:25 -0800 (PST) Subject: Xxx Young Bodies || Young Fuckin Boys || Young Female Fucking Message-ID: <0c0f3c5e-b02a-4896-ba9a-a6f0a84c9188@b18g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Cum_S_XviD.AC3.avi http://erohide.com/Feb-2012/Preteen-girl-video.avi http://dizzyporn.com/2012-Feb/Mom_Forced_Son_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Lesbian_Sedeuces_Young_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Free_Full_Length_Beastiality_Movies.wmv http://erohide.com/Feb-2012/Grandma_70__young_Boy_In_Bath_XviD.AC3.avi http://erohide.com/Feb-2012/Underage_Uncensored_Xxx.avi http://erohide.com/Feb-2012/Rachel_Roxxx_Rape.mpeg http://erohide.com/Feb-2012/Underage-movie.avi http://erohide.com/Feb-2012/Teacher_Young_Boy_XviD.DVDRip.avi http://erohide.com/Feb-2012/Nude_Rape_Scene_In_Indian_Movie.mpeg http://erohide.com/Feb-2012/Febgo_Sullivan_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Riley_Rey_Young_And_Disgraced_XviD.AC3.avi http://erohide.com/Feb-2012/Oriental_Shibari_Spanking.wmv young irish girl pussy nude underage teen supermodels womens erotica bondage porn naked girl being licked free young porn movie clips older woman younger men sex sexy bdsm bondage girls byoung teen porn girl fuck lick cunt inflatable bondage sex toys cunt and tit torture young horny housewives little girl pussy model sexy young hairy models cruel cunt torture christine young movies teen petite teens in anal sex women with bondage fantasy yearolds girls underage pussy methods of torture for sex really young girls anal dirty jobs hung like a horse durban public private partnerships bdsm photos torture free tits nipple torture clitoris porn body builder andie valentino bondage asian bondage ring hardcore girl bondage gagged matue young sex hentai toilet bondage mature young man hard core sex young sebastian bondage hair spread outdoors bondage masturbate in self bondage latex bondage gallery very young girls peeing younger then 18 porn extreme pics of womens orgasms old sluts fucking young m bondage products store breast rope torture galleries cowgirls bondage pictures bondage bankok submissive tgp naked bondage movies hentai forced hard pussy video fuck young eve's mouth petite infant sex young teen sex galleries little elizabeth smart bondage video bar gangbang stories sexy pics lick clit pussy lick pussy pussy nude beaches young pussy free bondage video previews boy fingers little girl pussy young girls showing thongs hardest penetration pussy young handjob porn videos cock ball torture male stories young sexy naked irls asian lez bondage lesbians licking pussy free video baptized in dirty water underage girls in thongs gangbang slut free videos spanking dom bondage spreadeagle bondage thumbs hottest little tight teens From marybobbyjac at gmail.com Mon Feb 20 20:56:34 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:56:34 -0800 (PST) Subject: Voyuer Illegal Porn || Young Slut Xxx || Nutella Young Porn Message-ID: http://erohide.com/Feb-2012/Soft_Core_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Amateur_Self_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Color_Climax_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Drunk_Anal_Teen_Rape.mpeg http://erohide.com/Feb-2012/Incest_Taboo_Amatoriale_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cum_Inside_Forced_XviD.DVDRip.avi http://erohide.com/Feb-2012/Mot_XviD.AC3.avi http://erohide.com/Feb-2012/Br_Dfebhter.mpeg http://dizzyporn.com/2012-Feb/Pissing_Sarah_Young_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Underage_Hardcore_Fucking.3gp http://erohide.com/Feb-2012/White_Pantie_Spanking.wmv http://erohide.com/Feb-2012/Young_Boy_Fucking_Aunty_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Rape_Mother_And_Son.avi http://erohide.com/Feb-2012/3d_Underage_Hentai.avi naked young thumbnail sex pictures young little nymphets ashley renee bondage photos japenise breast torture pussy lick pussy tortured female thumbnails pussy lickers boob suckers hogtied breast torture free squirting porn movie archive bondage on men young black girls porn pics lolitas free galleries lolitas galleries transsexual makes bondage film detective bondage magazine covers younger galleries teen sex ass licking fetish fucking younger sister stories extreme penetration preteen secret bondage young dirty ebony girl young models videos free young teen pics squirters xxx free clips wraped up bondage female torture in kosovo young xxx models russian young boy pregnant young girls naked petite tiny tits anal free bondage pissing videos daughter licks mothers pussy hot sexy younger older lesbian little pussy girls models young teen lesbians in bed young girls in panties movies bedroom bondage sex pics xxx young girls being sexy lesbian tickling torture lesbian piss lick fal bald wet pussy licks own pussy juice movies bluebird scan bondage free young teaching old porn hot xxx clit asians young and naked movie cock torture inside guys licking girls pussy squirt pussy video sexy young nude photos young porn portals tiny sexy little asses dirty xxx emoticon for msn messenger hentai ron hermione bondage bondage girl dildo young tiny indian porn young ladies pussy videos young teens black sex free pics young amature porn blonde young girl pics panty crotch bondage illegal mexican teens mature & young final fight maki in bondage hardcore underage kids japanese bondage balette young teen deepthroat movies free moisture perspiration hood bondage bondage erotic vacation young cum sluts electronic pussy insertion movies From marybobbyjac at gmail.com Mon Feb 20 20:56:48 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:56:48 -0800 (PST) Subject: Young Porn Media || Young Sister Xxx || Young Lesbains Porno Message-ID: <29410e39-daf2-4c0b-a06e-39475d6e4604@o6g2000vbz.googlegroups.com> http://erohide.com/Feb-2012/Underas_Fucking.mpeg http://dizzyporn.com/2012-Feb/Sky_Lopez_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Bondage_Facial_German_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Realsex_Amelia.wmv http://erohide.com/Feb-2012/Tight_Young_Blonde_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Underwater_Hardcore_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Celebrities_Incest_Sex_Scene_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cute_Blonde_Young_Hardcore_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Brutal_Rape_Tour_Girl.avi http://dizzyporn.com/2012-Feb/Forced_Too_Big_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Christvid.DVDRip.avi http://erohide.com/Feb-2012/Lesbian__seduces_Young_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Daphne_Rosen_Bondage_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Mom_Triple_Penetration_XviD.DVDRip.avi taime downs bondage boys younger porn sites face care for young girls free midget gangbang pics young hot virgin sexy randy paul jewell bondage romp bondage slut lesbian young girl porn photos vagina clit cutting movie ass squirt vidz femdom gangbang video getting even with dirty tricks free lick pussy close-up dr kink bondage free petite tranny movies alligator sussex pools mcniven-young young love poems young hairy pussy movies so young teens fucking lolita preteen sex links panties preteen schoolgirl japanese web cam preteen free bondage clip nipple clit play innteracial gangbang porn pics petite sluts in xxx action free movies of squirting wives forever young porn movie shayla's house of bondage cum in my virgin pussy erection from torture young boy speedo gallery female bondage technique rough gangbang movies tight little panty pics two lesbos licking pussy squeeze crush breast torture video severe torture galleries tgp free teen bondage porn gangbang password exchange free amatteur bondage hogtied women tortured helpless bondage nbdp caught in diaper bondage inquisition torture and punishment devon michaels licks pussy bondage video pictures ass hook free lolitas mpegs free porn pics galleries squirting hot wet teen pussy pic permanent glue bondage squirters women sex fashion games for preteens sexyy girls licking young african teens girls petite virgin hardcore contortionist ladies breast bondage young teen shaved porn hentai tortured foot up arse air hostess pussy licked model testical torture gangbang story basketball game mature sexual torture women amateur breast torture super becca bondage movie petite teenager free lesbian clit sucking videos real young teenager sex pictures sexy young nude movie stars erotic crouch torture From marybobbyjac at gmail.com Mon Feb 20 20:57:02 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:57:02 -0800 (PST) Subject: Preteen Boys Fucking || Blackyoung Teen Porn || Underage Teen Porno Message-ID: <03bc0121-86df-4cb2-8734-36bb398f1768@bs8g2000vbb.googlegroups.com> http://dizzyporn.com/2012-Feb/Young_Busty_Kelly_XviD.AC3.avi http://erohide.com/Feb-2012/Hentai_Toon_Incest_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Darla_Crane_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/True_And_Real_Incest_XviD.AC3.avi http://erohide.com/Feb-2012/Very_Young_Schoolgirl_Teen_XviD.AC3.avi http://erohide.com/Feb-2012/Lolita-video-hardcore.avi http://erohide.com/Feb-2012/Brother_Rape_Own_Sister.avi http://erohide.com/Feb-2012/Blontakes_Down.wmv http://dizzyporn.com/2012-Feb/Bangladesi_Real_Virgin_Hymen_Broken.wmv http://dizzyporn.com/2012-Feb/Sarah_Young_Pee_XviD.AC3.avi http://erohide.com/Feb-2012/Cheseastiality.wmv http://dizzyporn.com/2012-Feb/Female_Bondage_Sex_Edtv_720x576.avi http://dizzyporn.com/2012-Feb/Indian_Shy_Girl_Forced_Dual.BDrip.XviD.AC.avi http://dizzyporn.com/2012-Feb/Lolitas_Fingering_Pussy_800x600.wmv young teen little girl sex bdsm wooden horse torture discount leather bondage russian hard core lolitas very young boobs young asians pussy hot young teen girls sex free pissing sites of young kids preteen nudist models medical womens petite labcoat young teen movie galleries porn actress kitty young little boys suspenders young couples mutual masturbation video little maggie pussy cock young boys in briefs dirty xxx comics squirt whores password teen with wet pussy dripping wet pussy pics free blunt force trauma dead bitches little girls licking teen pussy young blonde fucking female squirt mpg sexy little pussy girls gangbang black milf free jewel marceau bondage pics male bondage cartoons practice pussy lick training slave girl bondage art leather bondage lingerie vibrator clitoris videos pain bondage tits bdsm sado torture pick wet pussy preteen amature thumbnail gallery tgp male sexual consensual torture guide bondage fantasy art alazar click porn videos fucking young cock young naked movies skinny virgin pussy poppin girls barefoot bondage plastic lab squirt bottles big tits mpeg lolita uncut men bondage anal insertion video monster clit movie clips c guilt's japanese breast bondage young girls in bikini pictures bondage platform shoes dvd underage girls model bdsm cbt torture stories tiffany call creampie virgin scenes heavy latex bondage very young amateurs hot virgin pussy video russian lolitas mpeg underage girls naked and fucking calstar videos tickling bondage petite monster cocks movies young butt fuck police chief young ca free sexy young coeds self bondage masturbation bondage nudes film free porn pvc bondage object's inserted in pussy's squirting tits movies anal too young From marybobbyjac at gmail.com Mon Feb 20 20:57:16 2012 From: marybobbyjac at gmail.com (mary bobby) Date: Mon, 20 Feb 2012 17:57:16 -0800 (PST) Subject: Young Nudism Videos || Illegal Girl Porn || Illegal Lolitas Porn Message-ID: http://dizzyporn.com/2012-Feb/Young_Videomodel_Daphne_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Big_Black_Cock_In_Young_Japan_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Katsuni_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Dad_Fuck_Young_Son_XviD.AC3.avi http://erohide.com/Feb-2012/Old_Man_Rape_Young.mpeg http://dizzyporn.com/2012-Feb/Brianna_Love_Double_Penetration_XviD.DVDRip.avi http://erohide.com/Feb-2012/Young_Teen__big_Cock_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Girl_Fucked_By_2_Cocks_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Sarah_Louise_Young_G_XviD.DVDRip.avi http://erohide.com/Feb-2012/Breast_Suspension_Bondage_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Brut_Tour_Girl.avi http://dizzyporn.com/2012-Feb/Spanking_Maturw_Woman.wmv http://erohide.com/Feb-2012/Girl_Forced_Boy_To__dual.BDrip.XviD.AC.avi http://dizzyporn.com/2012-Feb/Young_Girls_Squirting_Trailer.wmv illegal strip search alameda county pics of young boys fucking steel bondage collar petite teen sexvids ball from clitoris pink floyd young lust saran wrap bondage bondage sex webcams videos young skinny brunette sex young schoolgirl fuck teen anal lick young pussy nipple wet hariy pussy's forced bondage women real squirt orgasm self bondage tutorails underage free pics hentai chain bondage too deep penetration long gangbang video really little girls underage girl pic model bondage club photos young fat sex galleries little lolita boy young anal stories young porn girls tgp blond ass double penetration gushing erupting squirting porn men in diaper bondage pussy lick youtube very young camel toe pics torture pics genital top 100 illegal sex bondage pussy stretching illegal jpg voyeur hispanic petite girl big tits male bodybuilder bondage male bondage cumming underage nudist sex young foreign girls fucked squirting porn tube young sexy turkish girls mexican wet open pussy young girls thongs nadia sexy young model asian girls licking girls preteen model galleries models preteen best squirting internet videos underage boys movies young girl wet pussy free unerage illegal porn big clit teen shaved pussy young under 12 gangbang a hooters girl japanese forced orgasm bondage pre young pink pussy teen forced insertion sexy young people miko lee bondage anal lick asian free new self-bondage sex stories women frog tied bondage men fingering and licking pussy trussed up video bondage extreme bdsm slaves young couple porn xxx movies forced feminization mistress bdsm dildo vibrators clit pussy extreme incest porn From slyvestoramad at gmail.com Mon Feb 20 20:58:59 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:58:59 -0800 (PST) Subject: Petite Dd Xxx || Young Flat Xxx || Casey Young Porn Message-ID: http://erohide.com/Feb-2012/Young_Oriental_Slut_First_Time_Sex_XviD.AC3.avi http://erohide.com/Feb-2012/Amatvid.DVDRip.avi http://dizzyporn.com/2012-Feb/Febia_Ozawa_Forced_XviD.DVDRip.avi http://erohide.com/Feb-2012/A_Well_Deserved_Spanking.wmv http://erohide.com/Feb-2012/Loaved-pussy.avi http://erohide.com/Feb-2012/Tender_Young_Sex_XviD.AC3.avi http://erohide.com/Feb-2012/Famio_XviD.AC3.avi http://erohide.com/Feb-2012/Man_Get_Cum_Torture_Blu-Rayrip.x264.avi http://erohide.com/Feb-2012/Halloween_Banana_Insertion_Treat.wmv http://dizzyporn.com/2012-Feb/Chinese_Mother_Fucked_By_Young_Son_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Young_Sex_Parties_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Mom_Forced_To_Blow_Son_Dual.BDrip.XviD.AC.avi http://erohide.com/Feb-2012/Young_Amateur_Brunet_XviD.DVDRip.avi http://erohide.com/Feb-2012/Daphayrip.x264.avi anus licking video hentai anime bondage looking for sex in youngstown young student fuck old lolita preteen pic watch me lick up the cum bondage gagged hogtie frogtie tapegag preteens in bras and panties closer video bondage preteen porn galleries bdsm bondage dvda extreme crotch torture japan bondage food table flicka ricka dicka vintage under age sex lolita russian really young girls short skirts double penetration younger babe sex pics young virgin italian pussy young stud fuck my wife milly weathers bondage free young teen porn moves fetish rope bondage fantasy babysitter bondage storiies gang forced wife ypf young people fucking bdsm bladder torture filing stretching young girls pics video feet my little pony cakes little girls licking pussy porn black pussy squirters non sexual ass licking ukraine sex young girls porn young teens sex female pussy lick skinny petite anorexic porn self bondage illustrated sensual massage in california illegal little girls brazil bdsm tortures devices dani ashe bondage first time squirting videos dirty dancing trivia porn hub squirt bondage free pictures ad video amateur bondage webcams young and horn y sex male tickle bondage videos young litle porn videos free female bondage fuck professor lick pussy pussy licking cuckold young teen sex boobs foot dirty girl bondage model sex video bondage stories literature hogtied in chains bondage movie young erect boys petite does black dick young teen porn related sites small tits small clits chastity forced stories cuckold bondage tit and nipple pictures very young teen torture email genital torture young latin chicks sexy wet pussy ass fat women squirt adult young pussy petite girl voyeur From slyvestoramad at gmail.com Mon Feb 20 20:59:14 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:59:14 -0800 (PST) Subject: Petite Anal Trailer || Illegal Underage Xxx || Young Slut Porn Message-ID: http://erohide.com/Feb-2012/Bbw_Double_Penetration_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Lolitas_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Anime_Bondage_V2_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Japanese_Mom_And_Young_XviD.DVDRip.avi http://erohide.com/Feb-2012/Japawife_Rape.mpeg http://dizzyporn.com/2012-Feb/Brother_Fucking_Virgin_Sister.wmv http://dizzyporn.com/2012-Feb/Young_Brooke_Adams_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Hotel_Asian_Sleep_Rape.mpeg http://erohide.com/Feb-2012/German_Virgin_Have_Hymen_Break.wmv http://dizzyporn.com/2012-Feb/Forced_Fuck_Mom_Anal_XviD.DVDRip.avi http://erohide.com/Feb-2012/Blontakes_Down.wmv http://erohide.com/Feb-2012/Hard_Core_Bondage_004.mpeg http://dizzyporn.com/2012-Feb/Double_Penetration_Black_Teen_XviD.DVDRip.avi http://erohide.com/Feb-2012/Real_Girl_Virgin_Defloration.avi gigantic clits videos dirty dozen d bondage crucifixion story busty teen masturbating wet pussy spit picture bondage gat bondage college coeds squirting fluid from anal smoking torture pics young girl cumshot movies peach bondage porn bondage and fucking machiens petite asain pussy g spot orgasm squirt dominc wolfe bondage sex mechines squirting petite pornstars list svens lolita bbs public bondage pain young skater girl porn lesbian younger teen pussy bondage quick release little young girls porn pictures desibaba dirty chat todays top models arse licker sex babe pornstar young gallery lolita sex site illegal teens blowjobs young girls sex toys young couples sex video tape transgender bondage home pages sexy petite teens milk breast squirt sex bizarre insertion pics pussy videos wet stuffed tube free younger babes porn double pussy penetration how to sexy young teens uncensored dog licks teen pussy little girls in bikinis sexy clit stories chrissy moran bondage submission humiliation light bondage the asian extreme pussy games women underage pussy playing biotech training little rock free online hardcore squirting porn japanese naturist preteens very petite sex cuckhold lick pussy underage sex tours teen dick lickers underage little whores gingera bondage clip petite nudes free pics young sex craver free gangbang cum movies forced petite sex video bondage fairies album nv lesbian squirts from dildo fuck forced illegal sex little hairy pussy pics she licks my pussy extreme bdsm torture dvd young teen girl movie clips preteen nude underage lolita blue links free young amatur videos squirt listing porn girl licks girl ass dirty fat asses breastfeeding illegal after certain age From slyvestoramad at gmail.com Mon Feb 20 20:59:29 2012 From: slyvestoramad at gmail.com (slyvestor amadeus) Date: Mon, 20 Feb 2012 17:59:29 -0800 (PST) Subject: Young Porn Posers || Video Underage Girls || Old-young Sex Video Message-ID: <6cd35314-4a8e-45ec-b693-01c955990506@z31g2000vbt.googlegroups.com> http://erohide.com/Feb-2012/Underage-rape-video.avi http://dizzyporn.com/2012-Feb/Hardcore_Rape_Hunk.avi http://dizzyporn.com/2012-Feb/Forced_Cum_Inside_Throat_Rough_XviD.DVDRip.avi http://erohide.com/Feb-2012/Celebrities_Incest_Sex_Scene_XviD.AC3.avi http://erohide.com/Feb-2012/Young_Girl_First_Anal_XviD.AC3.avi http://erohide.com/Feb-2012/Torture_Post_Orgasm_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Russian_Mom_Rape_By_Son.mpeg http://dizzyporn.com/2012-Feb/2_Crazy_Bitches_Rape_A_Guy.mpeg http://dizzyporn.com/2012-Feb/Tied_Forced_Cum_Eat_XviD.DVDRip.avi http://dizzyporn.com/2012-Feb/Pee_Hole_Insertion_Men.wmv http://dizzyporn.com/2012-Feb/Old_Guy_Young_Girl_XviD.AC3.avi http://dizzyporn.com/2012-Feb/Cfmn_Handjob_Torture_Blu-Rayrip.x264.avi http://dizzyporn.com/2012-Feb/Young_And_Busty_Lea_In_Public_XviD.AC3.avi http://erohide.com/Feb-2012/Mvid.DVDRip.avi petite sex doll young buck biography lolita teen photomodel hardcore bondage and submission free gallerys closeup intercource young girls free nude little girl pics forced facesitting forced pussy worship fuck young bithes free porn young porn clips illegal chjild porn pussy ooze licking anal dildo insertions electro breast torture kacey licking pussy mature and young porn movies big boobs and little waist galleries pictures porn young pussy sick young pussy pussy pussy forced sissy bondage fucking my young neighbor preteen strip tease youth flying nz young eagles huge clitoris video clips young teen pussy free moview young fist time teenie sex the bondage gaem wife sharing gangbang nurse uniform bondage fuck lick lesbi ebony bdsm forced enema free stories grits bondage videos nylon stockings abd bondage pics nude video clips young free best hentai bondage movies net nubile young teens fucking bondage piss drinking slutty bitches getting forced fucked petite asian sex videos hard fast fucking gangbang young little tits female squirt filetype:avi wetpussygames hentai girl 2 game in her mouth young preteen wearing stockings nude petite sex december download anal bondage free embarrasing bondage stories chained up bondage bbw wet pussy porn tube monster bondage hentia pretty little toes having sex with young girls bondage training gag barb wire bondage text stories bondage nudity wet pussy cunt young girl pic pussy free bondage comics young sexy cartoons underground illegal porn videos female tickle torture hardcore bondage galleries youngest porn models illegal porn busted very young teen pussy mpegs young hot pussy pics jerry cock amy virgin pussy preteen boys nude little boys nude chubby preteens nude lesbo wet pussy From breamoreboy at yahoo.co.uk Mon Feb 20 21:21:38 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 21 Feb 2012 02:21:38 +0000 Subject: Numeric root-finding in Python In-Reply-To: <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> References: <4f375f0f$0$29986$c3e8da3$5496439d@news.astraweb.com> <11t5k79mo14t3h2lerqurqaa4v4lcf85iv@4ax.com> Message-ID: On 21/02/2012 01:33, David Monaghan wrote: > On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: > >> >> >> I don't know the first thing about this math problem however, >> >> if I were to code this I might try ; >> >> except ZeroDivisionError: >> assert w = -1 >> >> rather than; >> >> except ZeroDivisionError: >> assert w == -1 > > Why? > > DM Why not is probably a better question, given that Dennis Lee Bieber and Dave Angel have already pointed out that this is not legal Python, it'll give a syntax error. -- Cheers. Mark Lawrence. From wuwei23 at gmail.com Mon Feb 20 22:31:37 2012 From: wuwei23 at gmail.com (alex23) Date: Mon, 20 Feb 2012 19:31:37 -0800 (PST) Subject: paper submission and versioning system - advice? References: Message-ID: <72d09097-3fc7-480d-aa05-235e8efe1440@oh4g2000pbb.googlegroups.com> On Feb 21, 3:45?am, Brian Blais wrote: > Essentially I need users to be able to start a proposal, with > some basic information, and then be able to add files to it. > Other users will be allowed to add files as well, but I'd like > to limit deletions to the committee members. > It seems as if there just has to be available tools like this, > but I am not even sure what such a system is called. ?Is there > anything like this, in python preferably? Frankly, I'd start at a much higher level than a web framework. I think you could easily get what you want from a ticketing system like Trac: http://trac.edgewall.org/ Trac's tickets would be proposals in your system; I believe you can attach files to them by default, and even limit the size & type of attachments. There's a permissions mechanism that would provide your committee members with higher levels of access. It sits by default on SVN, so there's your versioning, and provides a wiki, so it's easy to add supporting documentation to the site. It also provides a very elegant plug-in system for easy extension, and is all in Python. From r1chardj0n3s at gmail.com Tue Feb 21 00:32:39 2012 From: r1chardj0n3s at gmail.com (Richard Jones) Date: Tue, 21 Feb 2012 16:32:39 +1100 Subject: Python Game Programming Challenge (PyWeek) #14 is coming! Message-ID: The 14th Python Game Programming Challenge (PyWeek) is coming. It'll run from the 22nd to the 29th of April. http://pyweek.org/14/ New user registration is NOT YET OPEN. It will open one month before the challenge starts. The PyWeek challenge: - Invites entrants to write a game in one week from scratch either as an individual or in a team, - Is intended to be challenging and fun, - Will hopefully increase the public body of game tools, code and expertise, - Will let a lot of people actually finish a game, and - May inspire new projects (with ready made teams!) If you're in the US and can make it I'm co-presenting a 3 hour pygame tutorial at PyCon in March. From prakashsco71 at gmail.com Tue Feb 21 00:35:06 2012 From: prakashsco71 at gmail.com (prakash sco) Date: Mon, 20 Feb 2012 21:35:06 -0800 (PST) Subject: ONLINE FORM FILLING PROCESS-e RECRUITMENT SERVICES Message-ID: <646e237c-cda7-4471-a23b-98d4472fb65f@oh4g2000pbb.googlegroups.com> COMPUTER SERVICES AVAILABLE HERE. http://imalayagroup.yolasite.com/ From fayaz.yusuf.khan at gmail.com Tue Feb 21 02:23:37 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Tue, 21 Feb 2012 12:53:37 +0530 Subject: Should I acquire lock for logging.Handler.flush()? Message-ID: <1812157.OpZ7u19UP8@dextop08> I'm writing a custom logging Handler that sends emails through AWS Simple Email Service using the boto library. As there's a quota cap on how many (200) emails I can send within 24hrs, I think I need to buffer my log messages from the emit() calls (Or is that a bad idea?). And I was reading the Handler documentation and was confused if I should call the acquire() and release() methods from within a flush() call. -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From shejo284 at gmail.com Tue Feb 21 03:29:03 2012 From: shejo284 at gmail.com (Sheldon) Date: Tue, 21 Feb 2012 00:29:03 -0800 (PST) Subject: netCDF4 variable manipulation References: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> On Feb 21, 12:53?am, Steven D'Aprano wrote: > On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: > > Hi, > > > I'm trying to read a netCDF4 variable from a file (no problem) and then > > scale it before writing over the original variable in the file. > > > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep > > getting an error message but I want to do this without using for loops > > and all the manuals seems to be skipping this task as if it is never > > done. I'm new to python and coming over from matlab. Does anyone know > > how to modify the netCDF4 variable in python and then write it back > > without creating a new variable, or using for loops? > > There is no such thing as "the netCDF4 variable" in Python -- it is not a > built-in part of the language, and therefore there is no built-in feature > for manipulating it. > > You are going to have to be more specific about what you want than just > "how do I modify a variable with for loops?". > > My wild guess is that you have some sort of config file which includes a > field called "netCDF4" and you want to update it in place. We can't tell > you how to do this without knowing what the config file is -- is it an > INI file, XML, JSON, YAML, Unix-style rc file, a binary pickle, or > something else? > > -- > Steven Hi, My apologies. I didn't realize this module was not popular. I'm using the python module "netCDF4" that I installed using PIP. This module gives me the ability to read and write netcdf4 files. The module is an interface to the netcdf4.1.3 and HDF51.8.8 libraries. What I'm trying to do is open an existing netcdf file, extract an variable, modify the variable, and then write it again to the file - effectively replacing the old variable. rgrp = netCDF4.Dataset('ODIN_NWP_2001_01_01_00.NC','r+') pv = rgrp.groups['Data_3D'].variables['PV'] print pv float32 PV(u'level', u'lat', u'lon') longname: Potential Vorticity _FillValue: -999.0 units: K m**2 kg**-1 s**-1 code: 60 scale_factor: 1.0 add_offset: 0.0 path = /Data_3D unlimited dimensions = () current size = (60, 181, 360) As you can see, pv is described here as a netCDF4.Variable. I'm trying to modify this pv and then write it back to the file but the manual is vague on this part. I tried this: pv = pv*2 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ----> 1 pv = pv*2 TypeError: unsupported operand type(s) for *: 'netCDF4.Variable' and 'int' I'm unsure how this is suppose to work. /S From clp2 at rebertia.com Tue Feb 21 04:10:49 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 21 Feb 2012 01:10:49 -0800 Subject: netCDF4 variable manipulation In-Reply-To: <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> References: <4f42dcdf$0$29986$c3e8da3$5496439d@news.astraweb.com> <9880ff19-f622-41cc-95a7-887bb5ac447e@t30g2000vbx.googlegroups.com> Message-ID: On Tue, Feb 21, 2012 at 12:29 AM, Sheldon wrote: > On Feb 21, 12:53?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Mon, 20 Feb 2012 12:37:22 -0800, Sheldon wrote: >> > Hi, >> >> > I'm trying to read a netCDF4 variable from a file (no problem) and then >> > scale it before writing over the original variable in the file. >> >> > I'm using python 2.7 and the latest netCDF4 module. It's not that I keep >> > getting an error message but I want to do this without using for loops >> > and all the manuals seems to be skipping this task as if it is never >> > done. I'm new to python and coming over from matlab. Does anyone know >> > how to modify the netCDF4 variable in python and then write it back >> > without creating a new variable, or using for loops? > My apologies. I didn't realize this module was not popular. I'm using > the python module "netCDF4" > that I installed using PIP. This module gives me the ability to read > and write netcdf4 files. > The module is an interface to the netcdf4.1.3 and HDF51.8.8 libraries. > What I'm trying to do is open an existing netcdf file, extract an > variable, modify the variable, and then > write it again to the file - effectively replacing the old variable. > > rgrp = netCDF4.Dataset('ODIN_NWP_2001_01_01_00.NC','r+') > pv = rgrp.groups['Data_3D'].variables['PV'] > > print pv > > float32 PV(u'level', u'lat', u'lon') > ? ?longname: Potential Vorticity > ? ?_FillValue: -999.0 > ? ?units: K m**2 kg**-1 s**-1 > ? ?code: 60 > ? ?scale_factor: 1.0 > ? ?add_offset: 0.0 > path = /Data_3D > unlimited dimensions = () > current size = (60, 181, 360) > > As you can see, pv is described here as a netCDF4.Variable. I'm trying > to modify this pv and then write it back to the file > but the manual is vague on this part. I tried this: > > pv = pv*2 > --------------------------------------------------------------------------- > TypeError ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call > last) > ----> 1 pv = pv*2 > TypeError: unsupported operand type(s) for *: 'netCDF4.Variable' and > 'int' > > I'm unsure how this is suppose to work. The API docs suggest that Variables don't support any arithmetic operations, just slicing and attribute manipulation. They seem to interoperate with numpy arrays though, so presumably you could avoid explicit looping by loading the Variable's contents into a numpy array, doing your calculations on that, and then assigning the resulting numpy array back into a slice of the Variable. Cheers, Chris From storchaka at gmail.com Tue Feb 21 04:15:31 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Tue, 21 Feb 2012 11:15:31 +0200 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> Message-ID: 18.02.12 20:58, SherjilOzair ???????(??): > Has it been considered to add shell features to python, such that it can be used as a default shell, as a replacement for bash, etc. > > I'm sure everyone would agree that doing this would make the terminal very powerful. > > What are your views on this? Look at Hotwire (http://code.google.com/p/hotwire-shell/). From chris at simplistix.co.uk Tue Feb 21 04:17:13 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 21 Feb 2012 09:17:13 +0000 Subject: xlrd 0.7.2 released! Message-ID: <4F436119.9090509@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlrd 0.7.2. This release, like the xlwt release, is long overdue and has been over 2.5 years in the making! The highlights: - All messaging and debug logging is now written to the logfile provided to open_workbook. - Tolerant handling of file with non-standard compound document header - Tolerant handling of files with extra zero bytes at end of NUMBER record - Handle mostly-BIFF8 file with BIFF5-7 WINDOWS2 record - Handle dodgy version 2.x .xls files. - Added support for HYPERLINK extraction - Added access to cell notes/comments. - Enable reading files created by pyXLWriter -- puts BIFF8 MERGEDCELLS record in a BIFF5 file. - Fixed a file-locking issue on Windows when an exception was raised in open_workbook() and on_demand was True - Book objects are now context managers - Rich text formatting information is now extracted - Page breaks information is now extracted - Some improvements in zoom factor handling - PANE records are now processed - Some memory and performance enhancements For a full list of the changes, please see the svn log: https://secure.simplistix.co.uk/svn/xlrd/trunk I've currently only put up .tar.gz sdists, if anyone requires anything else, please explain why and I'll be happy to add! cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From chris at simplistix.co.uk Tue Feb 21 04:18:16 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 21 Feb 2012 09:18:16 +0000 Subject: xlwt 0.7.3 released! Message-ID: <4F436158.7060603@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlwt 0.7.3. This release is long overdue and has been over 2.5 years in the making! The highlights: - Added user_set and best_fit attributes to Column class. - Fixed an "[Errno 0] Error" raised when Worksheet.flush_row_data() was called after Workbook.save() - Fixed an error on Windows that occurred when writing large blocks to files. - Added the ability to write rich text cells - Fixed a bug when writing MULBLANK records on big-endian platforms. - allow the active_pane on worksheets to be specified - added support for zoom (magn) factors and improved possibilities when generating split panes For a full list of the changes, please see the svn log: https://secure.simplistix.co.uk/svn/xlwt/trunk I've currently only put up .tar.gz sdists, if anyone requires anything else, please explain why and I'll be happy to add! cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From petite.abeille at gmail.com Tue Feb 21 04:31:36 2012 From: petite.abeille at gmail.com (Petite Abeille) Date: Tue, 21 Feb 2012 10:31:36 +0100 Subject: [bug] imaplib case sensitive Message-ID: Hello, Looks like imaplib is case sensitive, even though the IMAP protocol isn't: (1) Except as noted otherwise, all alphabetic characters are case-insensitive. The use of upper or lower case characters to define token strings is for editorial clarity only. Implementations MUST accept these strings in a case-insensitive fashion. http://tools.ietf.org/html/rfc3501#section-9 For example: [Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) ] [imaplib 2.58] import imaplib M = imaplib.IMAP4( 'localhost', 1143 ) M.login( 'user', 'password' ) M.select() typ, data = M.search(None, 'ALL') for num in data[0].split(): typ, data = M.fetch(num, '(ENVELOPE)') print 'Message %s\n%s\n' % (num, data[0][1]) M.close() M.logout() Traceback (most recent call last): File "Test.py", line 3, in M = imaplib.IMAP4( 'localhost', 1143 ) File "python2.6/imaplib.py", line 184, in __init__ self.welcome = self._get_response() File "python2.6/imaplib.py", line 935, in _get_response raise self.abort("unexpected response: '%s'" % resp) imaplib.abort: unexpected response: '* ok imap4rev1' Note the 'ok' tag in lower case. From kliateni at gmail.com Tue Feb 21 06:02:30 2012 From: kliateni at gmail.com (Karim) Date: Tue, 21 Feb 2012 12:02:30 +0100 Subject: xlwt 0.7.3 released! In-Reply-To: <4F436158.7060603@simplistix.co.uk> References: <4F436158.7060603@simplistix.co.uk> Message-ID: <4F4379C6.8060803@gmail.com> Hello chris, Thanks for the greet news! Is there any chance that xlrd read .xlsx format and arrive to decode special unicode instead of firing some unicode Exception? Cheers Karim Le 21/02/2012 10:18, Chris Withers a ?crit : > Hi All, > > I'm pleased to announce the release of xlwt 0.7.3. This release is > long overdue and has been over 2.5 years in the making! > > The highlights: > > > - Added user_set and best_fit attributes to Column class. > > - Fixed an "[Errno 0] Error" raised when Worksheet.flush_row_data() > was called after Workbook.save() > > - Fixed an error on Windows that occurred when writing large blocks to > files. > > - Added the ability to write rich text cells > > - Fixed a bug when writing MULBLANK records on big-endian platforms. > > - allow the active_pane on worksheets to be specified > > - added support for zoom (magn) factors and improved possibilities > when generating split panes > > For a full list of the changes, please see the svn log: > > https://secure.simplistix.co.uk/svn/xlwt/trunk > > I've currently only put up .tar.gz sdists, if anyone requires anything > else, please explain why and I'll be happy to add! > > cheers, > > Chris > From tsinar at dpem.tuc.gr Tue Feb 21 06:24:59 2012 From: tsinar at dpem.tuc.gr (George Tsinarakis) Date: Tue, 21 Feb 2012 13:24:59 +0200 Subject: Questionnaire on motivation analysis of open source and open content Message-ID: <4F437F0B.1080405@dpem.tuc.gr> Dear Sirs, We are researchers in Technical University of Crete and our current research is in the field of motivation analysis of open source and open content software projects participants. We would like to ask you to fill a questionnaire and forward it to people involved in such teams and projects. The web address is the following: https://docs.google.com/spreadsheet/viewform?formkey=dHdqZUgyay0waXNRbWFvV3hleVBZSWc6MQ All personal information will be kept confidential and will be used for academic purposes only. For further information please do not hesitate to contact with us. Thank you in advance Dr G. Tsinarakis -- ------------------------------------------------------- Dr.George Tsinarakis Production and Management Engineer, CAM Laboratory Department of Production Engineering and Management Technical University of Crete University Campus, 73 100 Chania, Crete , Greece Tel: +30 2821 037306 Fax: +30 2821 037551 E -mail: tsinar@ dpem.tuc.gr ------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Tue Feb 21 12:20:19 2012 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Tue, 21 Feb 2012 18:20:19 +0100 Subject: ANN: python-ldap 2.4.8 Message-ID: Find a new release of python-ldap: http://pypi.python.org/pypi/python-ldap/2.4.8 python-ldap provides an object-oriented API to access LDAP directory servers from Python programs. It mainly wraps the OpenLDAP 2.x libs for that purpose. Additionally it contains modules for other LDAP-related stuff (e.g. processing LDIF, LDAPURLs and LDAPv3 schema). Project's web site: http://www.python-ldap.org/ Ciao, Michael. ---------------------------------------------------------------- Released 2.4.8 2012-02-21 Changes since 2.4.7: Lib/ * Fixed overzealous check for non-unique NAMEs in ldap.schema.subentry.SubSchema.__init__() * Fixed typos in control decoding method ldap.controls.simple.OctetStringInteger.decodeControlValue() * Added experimental support for draft-vchu-ldap-pwd-policy From vinay_sajip at yahoo.co.uk Tue Feb 21 15:52:14 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Tue, 21 Feb 2012 12:52:14 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> On Feb 21, 7:23?am, Fayaz Yusuf Khan wrote: > I'm writing a custom logging Handler that sends emails through AWS Simple > Email Service using the boto library. > As there's a quota cap on how many (200) emails I can send within 24hrs, I > think I need to buffer my log messages from the emit() calls (Or is that a bad > idea?). > And I was reading the Handler documentation and was confused if I should call > the acquire() and release() methods from within a flush() call. > -- > Fayaz Yusuf Khan > Cloud developer and architect > Dexetra SS, Bangalore, India > fayaz.yusuf.khan_AT_gmail_DOT_com > fayaz_AT_dexetra_DOT_com > +91-9746-830-823 > > ?signature.asc > < 1KViewDownload If you are using SMTPHandler, calling flush() won't do anything. You'll probably need to subclass the handler to implement rate limiting. In the stdlib, only StreamHandler and its subclasses actually implement flush(), which flushes I/O buffers to disk. Regards, Vinay Sajip From johannes.exner at tu-dortmund.de Tue Feb 21 16:38:59 2012 From: johannes.exner at tu-dortmund.de (JohannesTU) Date: Tue, 21 Feb 2012 13:38:59 -0800 (PST) Subject: PyKota, Python: AttributeError: 'module' object has no attribute '_quote' In-Reply-To: References: <1329749827797-4487915.post@n6.nabble.com> Message-ID: <1329860339503-4493041.post@n6.nabble.com> Thanks for your advice. The command itself didn't work, but it brought me on the right path and "car and engine" are running now! ;-) I fixed the problem by copying the correct pg.py-file to the python2.7 path. After that the error didn't show up again and I'm now able to create users etc. Thank you very much! Kind regards, Johannes -- View this message in context: http://python.6.n6.nabble.com/PyKota-Python-AttributeError-module-object-has-no-attribute-quote-tp4487915p4493041.html Sent from the Python - python-list mailing list archive at Nabble.com. From python-excel at raf.org Tue Feb 21 19:37:47 2012 From: python-excel at raf.org (python-excel at raf.org) Date: Wed, 22 Feb 2012 11:37:47 +1100 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F436119.9090509@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> Message-ID: <20120222003747.GA24152@raf.org> Chris Withers wrote: > Hi All, > > I'm pleased to announce the release of xlrd 0.7.2. This release, > like the xlwt release, is long overdue and has been over 2.5 years > in the making! > [...snip...] > > I've currently only put up .tar.gz sdists, if anyone requires > anything else, please explain why and I'll be happy to add! hi, a windows installer exe would be good for the same reasons it was good for previous versions. two reasons that spring to mind immediately are: - it makes it much easier to tell what version is installed - it makes it much easier to uninstall the package i know that both of these are things that the python community does not yet seem to find useful but everyone else seems to. for instance, if i just install the new versions of these packages on windows, it will replace the python-specific files that were associated with the previous version but it will have no impact on the system's list of installed software so if i look at the add/remove software control panel, it will happily tell me that i still have the previous versions. on the other hand, if the new versions were installed with windows installers, they would be able to properly replace the old versions with the new versions and make it clear that it has done do. knowing this, i will of course uninstall the old versions before installing the new versions so at least windows won't be forced to lie to me about what versions are installed. of course, i might be wrong about all of this and setup.py may manage the windows installed software list properly and do a proper upgrade. if so, sorry for wasting time. cheers, raf From umairahmed2526 at gmail.com Tue Feb 21 20:08:08 2012 From: umairahmed2526 at gmail.com (Umair Ahmed) Date: Tue, 21 Feb 2012 17:08:08 -0800 (PST) Subject: ali Message-ID: http://sharecash.org/download.php?file=2652910 From onexpadREMOVE at EVOMERyahoodotyouknow.com Tue Feb 21 21:28:29 2012 From: onexpadREMOVE at EVOMERyahoodotyouknow.com (Kyle T. Jones) Date: Tue, 21 Feb 2012 20:28:29 -0600 Subject: Python as a default shell, replacement of bash, sh, cmd ? In-Reply-To: <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: On 2/19/12 2:16 AM, SherjilOzair wrote: > Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. > That's an awful lot of key mashing just to replace 'cat file.txt' for i in big small upper lower ; do for j in conf bin log ; do chmod 2755 /home/me/$i/$j ; done ; done cat data.log | grep Error | awk -F, '{print $5, $1, $2,}' | sort ?? I believe your solution seeks a problem. I also believe a tool that seeks to be all things generally does none of them particularly well. Cheers. > IPyhton is very good, but after all, it is just an advanced interpreter, not a default shell. I don't want this to run on top of bash or sh. But it should run on its own, at shell level. > > Bash and sh, according to me, have very ugly syntaxes and the general user does not even use those. Python put on the shell would be adhering to python's vision, i.e. bringing programming to the masses. > The general user, who earlier could not do batch operations, and had to buy software and such for all that, could now write his open simple python script and run it in his shell that would do as he wants. > > Python on the shell could effectively remove learning grep, awk, sed, bash and the various unix utilities. > Don't take me wrong. Those are awesome tools, and I use them. But the awesomeness is not experienced by the general UNIX user on mac or linux. Python could do that. > > We all know how great a programming language python is. Imagine being able to control your computer with such an elegant language. Imagine that I import some speech recognition utility on the terminal shell, and voila, I'm speaking to the computer and it is doing stuff on the terminal for me. > > Shell would give python raw power! And Python would manage it well. From cmpython at gmail.com Tue Feb 21 22:51:07 2012 From: cmpython at gmail.com (CM) Date: Tue, 21 Feb 2012 19:51:07 -0800 (PST) Subject: Python LOC, .exe size, and refactoring Message-ID: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> 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). From umarnawazconsultant at gmail.com Tue Feb 21 23:38:26 2012 From: umarnawazconsultant at gmail.com (umar nawaz) Date: Tue, 21 Feb 2012 23:38:26 -0500 Subject: Campaign to raise $200 for python code statistics tool Message-ID: If $200 of contributions are made, I will create a python code statistics tool. To contribute go to this link on invested.in, a crowdfunding site (I cannot use kickstarter because I'm from Canada). http://invested.in/P2127/python-code-statistics-tool -------------- next part -------------- An HTML attachment was scrubbed... URL: From fayaz.yusuf.khan at gmail.com Tue Feb 21 23:44:44 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Wed, 22 Feb 2012 10:14:44 +0530 Subject: Should I acquire lock for logging.Handler.flush()? In-Reply-To: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> References: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> Message-ID: <8592595.GqlRG0s5VQ@dextop08> On Tuesday 21 Feb 2012 12:52:14 PM Vinay Sajip wrote: > If you are using SMTPHandler, calling flush() won't do anything. > You'll probably need to subclass the handler to implement rate > limiting. Oh, no! I'm writing my own handler. https://github.com/fayazkhan/ses_handler/blob/master/ses_handler.py Now I understand from here http://docs.python.org/library/logging.html#handler-objects that emit() calls are wrapped acquire() and release() in the handle() method. Anyway, I read the source and found many interesting things that ought to be mentioned in the docs. Such as flush() should be called from close() whenever it's implemented. (FileHandler.close() is doing it) And how come close()/flush() isn't being called from inside a lock? (Handler.close() calls the module level _acquireLock() and _releaseLock()s but nothing about the instance level acquire() or release()) Or is it being locked from somewhere else? -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From steve+comp.lang.python at pearwood.info Wed Feb 22 00:29:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 05:29:27 GMT Subject: Python LOC, .exe size, and refactoring References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> Message-ID: <4f447d36$0$11121$c3e8da3@news.astraweb.com> 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.html http://www.hanselman.com/blog/SmallestDotNetOnTheSizeOfTheNETFramework.aspx 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 From g.rodola at gmail.com Wed Feb 22 03:56:54 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Wed, 22 Feb 2012 09:56:54 +0100 Subject: [bug] imaplib case sensitive In-Reply-To: References: Message-ID: Please file a bug on http://bugs.python.org/ --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ Il 21 febbraio 2012 10:31, Petite Abeille ha scritto: > Hello, > > Looks like imaplib is case sensitive, even though the IMAP protocol isn't: > > (1) Except as noted otherwise, all alphabetic characters > ? ? ? ?are case-insensitive. ?The use of upper or lower case > ? ? ? ?characters to define token strings is for editorial clarity > ? ? ? ?only. ?Implementations MUST accept these strings in a > ? ? ? ?case-insensitive fashion. > > http://tools.ietf.org/html/rfc3501#section-9 > > For example: > > [Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) ] > [imaplib 2.58] > > import imaplib > > M = imaplib.IMAP4( 'localhost', 1143 ) > M.login( 'user', 'password' ) > M.select() > typ, data = M.search(None, 'ALL') > for num in data[0].split(): > ? ?typ, data = M.fetch(num, '(ENVELOPE)') > ? ?print 'Message %s\n%s\n' % (num, data[0][1]) > M.close() > M.logout() > > Traceback (most recent call last): > ?File "Test.py", line 3, in > ? ?M = imaplib.IMAP4( 'localhost', 1143 ) > ?File "python2.6/imaplib.py", line 184, in __init__ > ? ?self.welcome = self._get_response() > ?File "python2.6/imaplib.py", line 935, in _get_response > ? ?raise self.abort("unexpected response: '%s'" % resp) > imaplib.abort: unexpected response: '* ok imap4rev1' > > Note the 'ok' tag in lower case. > > > > -- > http://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Wed Feb 22 04:31:15 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 22 Feb 2012 20:31:15 +1100 Subject: Python LOC, .exe size, and refactoring In-Reply-To: <4f447d36$0$11121$c3e8da3@news.astraweb.com> References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> <4f447d36$0$11121$c3e8da3@news.astraweb.com> Message-ID: On Wed, Feb 22, 2012 at 4:29 PM, Steven D'Aprano wrote: > 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? There are other reasons for wanting to keep executable size down, though - low-memory VMs and such (of course, "low-memory" still means orders of magnitude more than yesterday's top-end box - the first computer I ever used, my dad bought the super-enormous 20MB hard disk option). But when you're looking at shrinking > ... an 11MB exe down to 10.8MB then it's pretty moot. ChrisA From krishankumar895 at gmail.com Wed Feb 22 04:39:02 2012 From: krishankumar895 at gmail.com (Krishan kumar) Date: Wed, 22 Feb 2012 01:39:02 -0800 (PST) Subject: DATA ENTRY SERVICES AND FORM FILLING SERVICES Message-ID: <9b45dedf-7416-425e-b485-8a72564aa27f@9g2000pbd.googlegroups.com> DATA ENTRY SERVICES AND FORM FILLING SERVICES AVAILABLE HERE http://www.wincon.co.in/ From richardbp at gmail.com Wed Feb 22 07:12:29 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 04:12:29 -0800 (PST) Subject: generate Windows exe on Linux Message-ID: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> hello, I have a python script using only the standard libraries. Currently I use a Windows VM to generate exe's, which is cumbersome. Has anyone had success generating exe's from within Linux? Richard From milkyof1 at gmail.com Wed Feb 22 07:45:09 2012 From: milkyof1 at gmail.com (anuratha) Date: Wed, 22 Feb 2012 04:45:09 -0800 (PST) Subject: hai dear this is special gift for uuuuuuuuu Message-ID: http://123maza.com/46/plant958/ From milkyof1 at gmail.com Wed Feb 22 07:45:44 2012 From: milkyof1 at gmail.com (anuratha) Date: Wed, 22 Feb 2012 04:45:44 -0800 (PST) Subject: hai dear this is special gift for uuuuuuuuu Message-ID: <939e8f14-6c2d-4242-9bf6-a3eae9cae911@z7g2000pbr.googlegroups.com> http://123maza.com/46/plant958/ From chris at simplistix.co.uk Wed Feb 22 08:20:48 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Wed, 22 Feb 2012 13:20:48 +0000 Subject: xlwt 0.7.3 released! In-Reply-To: <4F4379C6.8060803@gmail.com> References: <4F436158.7060603@simplistix.co.uk> <4F4379C6.8060803@gmail.com> Message-ID: <4F44EBB0.8040506@simplistix.co.uk> On 21/02/2012 11:02, Karim wrote: > > Is there any chance that xlrd read .xlsx format I believe this is planned for the next major release. > and arrive to decode > special unicode instead of firing some unicode Exception? Not heard of this, I suggest you explain the problem you're having on the python-excel mailing list, as linked to from http://www.python-excel.org cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From chris at simplistix.co.uk Wed Feb 22 08:22:45 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Wed, 22 Feb 2012 13:22:45 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <20120222003747.GA24152@raf.org> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> Message-ID: <4F44EC25.7060309@simplistix.co.uk> On 22/02/2012 00:37, python-excel at raf.org wrote: > was good for previous versions. two reasons that spring to mind > immediately are: > > - it makes it much easier to tell what version is installed > - it makes it much easier to uninstall the package > > i know that both of these are things that the python community > does not yet seem to find useful but everyone else seems to. That's because it's no longer best practice to polute the global python installation by installing packages directly into it. The recommended wisdom nowadays is to use a virtualenv and then pip install the package. I believe that will give you everything you need, please explain if it doesn't. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From invalid at invalid.invalid Wed Feb 22 10:31:10 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Feb 2012 15:31:10 +0000 (UTC) Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: On 2012-02-22, Kyle T. Jones wrote: > On 2/19/12 2:16 AM, SherjilOzair wrote: >> Well, if not modify python itself, I was thinking of making another shell, which borrows a lot from python, something like merging bash and python. such that I can do `cd ~/Desktop/dev` and `for i in open('file.txt'): print i` at the some shell. This I think would be VERY useful. >> > > That's an awful lot of key mashing just to replace 'cat file.txt' No kidding. And how much python would it take to do "less file.txt"? > for i in big small upper lower ; do for j in conf bin log ; do chmod > 2755 /home/me/$i/$j ; done ; done chmod 2755 /home/me/{big,small,upper,lower}/{conf,bin,log} > cat data.log | grep Error | awk -F, '{print $5, $1, $2,}' | sort awk -F, '/Error/ {print $5, $1, $2}' data.log | sort ;) Any decent modern shell (e.g. Bash) is a stunningly powerful environment aimed at solving a certain sort of problems in a certain way. Python is aimed at solving a more general set of problems in an entirely different way. Yes, you can drive a nail with a screwdriver if you try hard enough long enough, but it's still a bad idea. -- Grant Edwards grant.b.edwards Yow! FOOLED you! Absorb at EGO SHATTERING impulse gmail.com rays, polyester poltroon!! From gabomdq at gmail.com Wed Feb 22 11:13:19 2012 From: gabomdq at gmail.com (Gabriel Jacobo) Date: Wed, 22 Feb 2012 13:13:19 -0300 Subject: [ANN] Python/Cython/SDL 2D Game Engine Message-ID: Hello list, I wanted to let you know about my pet project for the last few months, a multiplatform (Linux64/Win32/Android at the moment), Python/Cython/SDL open source 2D game engine called "Ignifuga". The source code mixes Python and Cython code, then uses Cython to convert everything to C, and compiles it all along with the Python interpreter and SDL into a static binary. It's still a long way of from being something serious, but you can already make nice Android Live wallpapers with it! You can check it out at www.ignifuga.org Thanks! -- Gabriel. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists.eckel at gmail.com Wed Feb 22 11:53:52 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 22 Feb 2012 08:53:52 -0800 (PST) Subject: Inheriting from OrderedDict causes problem Message-ID: Notice that both classes are identical, except that one inherits from dict (and works) and the other inherits from OrderedDict and fails. Has anyone seen this before? Thanks. import collections class Y(dict): def __init__(self, stuff): for k, v in stuff: self[k] = v # This works: print Y([('a', 'b'), ('c', 'd')]) class X(collections.OrderedDict): def __init__(self, stuff): for k, v in stuff: self[k] = v # This doesn't: print X([('a', 'b'), ('c', 'd')]) """ Output: {'a': 'b', 'c': 'd'} Traceback (most recent call last): File "OrderedDictInheritance.py", line 17, in print X([('a', 'b'), ('c', 'd')]) File "OrderedDictInheritance.py", line 14, in __init__ self[k] = v File "C:\Python27\lib\collections.py", line 58, in __setitem__ root = self.__root AttributeError: 'X' object has no attribute '_OrderedDict__root' """ From __peter__ at web.de Wed Feb 22 12:10:25 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 22 Feb 2012 18:10:25 +0100 Subject: Inheriting from OrderedDict causes problem References: Message-ID: Bruce Eckel wrote: > Notice that both classes are identical, except that one inherits from > dict (and works) and the other inherits from OrderedDict and fails. > Has anyone seen this before? Thanks. > > import collections > > class Y(dict): > def __init__(self, stuff): > for k, v in stuff: > self[k] = v > > # This works: > print Y([('a', 'b'), ('c', 'd')]) > > class X(collections.OrderedDict): > def __init__(self, stuff): > for k, v in stuff: > self[k] = v > > # This doesn't: > print X([('a', 'b'), ('c', 'd')]) > > """ Output: > {'a': 'b', 'c': 'd'} > Traceback (most recent call last): > File "OrderedDictInheritance.py", line 17, in > print X([('a', 'b'), ('c', 'd')]) > File "OrderedDictInheritance.py", line 14, in __init__ > self[k] = v > File "C:\Python27\lib\collections.py", line 58, in __setitem__ > root = self.__root > AttributeError: 'X' object has no attribute '_OrderedDict__root' > """ Looks like invoking OrderedDict.__init__() is necessary: >>> from collections import OrderedDict >>> class X(OrderedDict): ... def __init__(self, stuff): ... super(X, self).__init__() ... for k, v in stuff: ... self[k] = v ... >>> X([("a", "b"), ("c", "d")]) X([('a', 'b'), ('c', 'd')]) From wm at localhost.localdomain Wed Feb 22 12:19:12 2012 From: wm at localhost.localdomain (Waldek M.) Date: Wed, 22 Feb 2012 18:19:12 +0100 Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: > I have a python script using only the standard libraries. > Currently I use a Windows VM to generate exe's, which is cumbersome. And what exactly *is* this exe about? > Has anyone had success generating exe's from within Linux? That doesn't seem to have anything to do with Python, but you might want to google for cross-compiling. Best regards, Waldek From lists.eckel at gmail.com Wed Feb 22 12:33:12 2012 From: lists.eckel at gmail.com (Bruce Eckel) Date: Wed, 22 Feb 2012 09:33:12 -0800 (PST) Subject: Inheriting from OrderedDict causes problem References: Message-ID: <4c239c43-2cf6-418e-b5e7-c71f51aed07d@y38g2000yqb.googlegroups.com> On Feb 22, 10:10?am, Peter Otten <__pete... at web.de> wrote: > Looks like invoking OrderedDict.__init__() is necessary: > > >>> from collections import OrderedDict > >>> class X(OrderedDict): > > ... ? ? def __init__(self, stuff): > ... ? ? ? ? ? ? super(X, self).__init__() > ... ? ? ? ? ? ? for k, v in stuff: > ... ? ? ? ? ? ? ? ? ? ? self[k] = v > ...>>> X([("a", "b"), ("c", "d")]) > > X([('a', 'b'), ('c', 'd')]) Thank you! That worked. Languages. Some of them automatically call the default base-class constructors, others don't. Apparently. From jerome at jolimont.fr Wed Feb 22 12:42:11 2012 From: jerome at jolimont.fr (=?UTF-8?B?SsOpcsO0bWU=?=) Date: Wed, 22 Feb 2012 18:42:11 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <20120222184211.1935846f@bouzin.lan> Wed, 22 Feb 2012 18:19:12 +0100 Waldek M. a ?crit: > On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: > > I have a python script using only the standard libraries. > > Currently I use a Windows VM to generate exe's, which is cumbersome. > > And what exactly *is* this exe about? Whatever. > > Has anyone had success generating exe's from within Linux? > > That doesn't seem to have anything to do with Python, > but you might want to google for cross-compiling. I think his question is totally python related. As I understand it, Richard creates executables from python scripts using a tool, such as py2exe [1], that requires windows. He would like to have an equivalent tool that runs on linux, to avoid going through the trouble of having to run a windows installation. I'm interested in such a tool as well. [1] http://www.py2exe.org/ -- J?r?me From alec.taylor6 at gmail.com Wed Feb 22 13:05:46 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 23 Feb 2012 05:05:46 +1100 Subject: generate Windows exe on Linux In-Reply-To: <20120222184211.1935846f@bouzin.lan> References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: http://www.pyinstaller.org/ or http://cx-freeze.sourceforge.net/ You can also run py2exe in WINE On Thu, Feb 23, 2012 at 4:42 AM, J?r?me wrote: > Wed, 22 Feb 2012 18:19:12 +0100 > Waldek M. a ?crit: > >> On Wed, 22 Feb 2012 04:12:29 -0800 (PST), Plumo wrote: >> > I have a python script using only the standard libraries. >> > Currently I use a Windows VM to generate exe's, which is cumbersome. >> >> And what exactly *is* this exe about? > > Whatever. > >> > Has anyone had success generating exe's from within Linux? >> >> That doesn't seem to have anything to do with Python, >> but you might want to google for cross-compiling. > > I think his question is totally python related. > > As I understand it, Richard creates executables from python scripts using a > tool, such as py2exe [1], that requires windows. He would like to have an > equivalent tool that runs on linux, to avoid going through the trouble of > having to run a windows installation. > > I'm interested in such a tool as well. > > [1] http://www.py2exe.org/ > > -- > J?r?me > -- > http://mail.python.org/mailman/listinfo/python-list From alec.taylor6 at gmail.com Wed Feb 22 13:13:17 2012 From: alec.taylor6 at gmail.com (Alec Taylor) Date: Thu, 23 Feb 2012 05:13:17 +1100 Subject: Python math is off by .000000000000045 Message-ID: Simple mathematical problem, + and - only: >>> 1800.00-1041.00-555.74+530.74-794.95 -60.950000000000045 That's wrong. Proof http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 -60.95 aka (-(1219/20)) Is there a reason Python math is only approximated? - Or is this a bug? Thanks for all info, Alec Taylor From breamoreboy at yahoo.co.uk Wed Feb 22 13:24:37 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 22 Feb 2012 18:24:37 +0000 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On 22/02/2012 18:13, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor Please google for floating point numbers. -- Cheers. Mark Lawrence. From ian.g.kelly at gmail.com Wed Feb 22 13:26:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 22 Feb 2012 11:26:12 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 11:13 AM, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? http://docs.python.org/faq/design.html#why-are-floating-point-calculations-so-inaccurate From lists at cheimes.de Wed Feb 22 13:26:26 2012 From: lists at cheimes.de (Christian Heimes) Date: Wed, 22 Feb 2012 19:26:26 +0100 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: Am 22.02.2012 19:13, schrieb Alec Taylor: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. That's only the correct answer for unlimited precision, not for IEEE-754 semantics. http://en.wikipedia.org/wiki/IEEE_754 > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? Python uses the platforms double precision float datatype. Floats are almost never exact. Christian From pruebauno at latinmail.com Wed Feb 22 13:29:21 2012 From: pruebauno at latinmail.com (nn) Date: Wed, 22 Feb 2012 10:29:21 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: <50fc2c9a-ee33-489d-a668-135c1f3cf1bb@p12g2000yqe.googlegroups.com> On Feb 22, 1:13?pm, Alec Taylor wrote: > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > > -60.950000000000045 > > That's wrong. > > Proofhttp://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-... > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor I get the right answer if I use the right datatype: >>> import decimal >>> D=decimal.Decimal >>> D('1800.00')-D('1041.00')-D('555.74')+D('530.74')-D('794.95') Decimal('-60.95') From benjamin.kaplan at case.edu Wed Feb 22 13:32:06 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Wed, 22 Feb 2012 13:32:06 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Feb 22, 2012 1:16 PM, "Alec Taylor" wrote: > > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. > > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? > > Thanks for all info, > > Alec Taylor > -- You aren't doing math with decimal numbers. you're using IEEE 754-compliant double precision floating point numbers. this isn't just a python thing. You'd get the same results in C, Java, VB, and pretty much every other general purpose language written in the last 40 years. Floats are represented in a form similar to scientific notation (a * 2^b), so just like scientific notation, there's a finite number of significant figures. And just like there are rational numbers that can't be represented in decimal, like 1/3, there are numbers that can't be represented in binary, like 1/10. Double-precision numbers are accurate to about 15 decimal digits. if you need more precision, there is the decimal module but it's way slower because your processor doesn't natively support it. > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Feb 22 13:43:06 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 22 Feb 2012 10:43:06 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On Wed, Feb 22, 2012 at 10:13 AM, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Welcome to the world of finite-precision binary floating-point arithmetic then! Reality bites. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? Because vanilla floating-point numbers have a finite bit length (and thus finite precision) but they try to represent a portion of the real number line, which has infinitely many points. Some approximation therefore has to occur. It's not a problem specific to Python; it's inherent to your CPU's floating point numeric types. Read http://docs.python.org/tutorial/floatingpoint.html and http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html Wolfram Alpha is either rounding off its answer to fewer decimal places (thus merely hiding the imprecision), or using some different, more computationally expensive arithmetic type(s) in its calculations, hence why it gives the exact answer. Alternatives to floats in Python include: * Fractions: http://docs.python.org/library/fractions.html * Arbitrary-precision decimal floating point: http://docs.python.org/library/decimal.html These aren't the default for both historical and performance reasons. Cheers, Chris From jpiitula at ling.helsinki.fi Wed Feb 22 13:44:52 2012 From: jpiitula at ling.helsinki.fi (Jussi Piitulainen) Date: 22 Feb 2012 20:44:52 +0200 Subject: Python math is off by .000000000000045 References: Message-ID: Alec Taylor writes: > Simple mathematical problem, + and - only: > > >>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Not by much. I'm not an expert, but my guess is that the exact value is not representable in binary floating point, which most programming languages use for this. Ah, indeed: >>> 0.95 0.94999999999999996 Some languages hide the error by printing fewer decimals than they use internally. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? - Or is this a bug? There are practical reasons. Do learn about "floating point". There is a price to pay, but you can have exact rational arithmetic in Python when you need or want it - I folded the long lines by hand afterwards: >>> from fractions import Fraction >>> 1800 - 1041 - Fraction(55574, 100) + Fraction(53074, 100) - Fraction(79495, 100) Fraction(-1219, 20) >>> -1219/20 -61 >>> -1219./20 -60.950000000000003 >>> float(1800 - 1041 - Fraction(55574, 100) + Fraction(53074, 100) - Fraction(79495, 100)) -60.950000000000003 From gheskett at wdtv.com Wed Feb 22 15:16:13 2012 From: gheskett at wdtv.com (gene heskett) Date: Wed, 22 Feb 2012 15:16:13 -0500 Subject: Questionnaire on motivation analysis of open source and open content In-Reply-To: <4F437F0B.1080405@dpem.tuc.gr> References: <4F437F0B.1080405@dpem.tuc.gr> Message-ID: <201202221516.13071.gheskett@wdtv.com> On Wednesday, February 22, 2012 03:14:51 PM George Tsinarakis did opine: > Dear Sirs, > > We are researchers in Technical University of Crete and our current > research is in the field of motivation analysis of open source and open > content software projects participants. We would like to ask you to fill > a questionnaire and forward it to people involved in such teams and > projects. The web address is the following: > > https://docs.google.com/spreadsheet/viewform?formkey=dHdqZUgyay0waXNRbW > FvV3hleVBZSWc6MQ > > All personal information will be kept confidential and will be used for > academic purposes only. For further information please do not hesitate > to contact with us. > > > > Thank you in advance > > Dr G. Tsinarakis (*&^%(*%$ phishing folks never give up... Nuke that subscription forthwith, with extreme prejudice. Cheers, Gene -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) My web page: "We can't schedule an orgy, it might be construed as fighting" --Stanley Sutton From invalid at invalid.invalid Wed Feb 22 15:48:34 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 22 Feb 2012 20:48:34 +0000 (UTC) Subject: Python math is off by .000000000000045 References: Message-ID: On 2012-02-22, Alec Taylor wrote: > Simple mathematical problem, + and - only: > >>>> 1800.00-1041.00-555.74+530.74-794.95 > -60.950000000000045 > > That's wrong. Oh good. We haven't have this thread for several days. > Proof > http://www.wolframalpha.com/input/?i=1800.00-1041.00-555.74%2B530.74-794.95 > -60.95 aka (-(1219/20)) > > Is there a reason Python math is only approximated? http://docs.python.org/tutorial/floatingpoint.html Python uses binary floating point with a fixed size (64 bit IEEE-754 on all the platforms I've ever run across). Floating point numbers are only approximations of real numbers. For every floating point number there is a corresponding real number, but 0% of real numbers can be represented exactly by floating point numbers. > - Or is this a bug? No, it's how floating point works. If you want something else, then perhaps you should use rationals or decimals: http://docs.python.org/library/fractions.html http://docs.python.org/library/decimal.html -- Grant Edwards grant.b.edwards Yow! What I want to find at out is -- do parrots know gmail.com much about Astro-Turf? From steve+comp.lang.python at pearwood.info Wed Feb 22 17:15:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 22:15:55 GMT Subject: Python as a default shell, replacement of bash, sh, cmd ? References: <24942665.31.1329591482717.JavaMail.geo-discussion-forums@pbux2> <12644c63-c7df-49fb-b3e9-16029057cee3@sk8g2000pbc.googlegroups.com> <20872530.6.1329639403963.JavaMail.geo-discussion-forums@pbt8> Message-ID: <4f45691a$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Feb 2012 15:31:10 +0000, Grant Edwards wrote: > On 2012-02-22, Kyle T. Jones > wrote: >> On 2/19/12 2:16 AM, SherjilOzair wrote: >>> Well, if not modify python itself, I was thinking of making another >>> shell, which borrows a lot from python, something like merging bash >>> and python. such that I can do `cd ~/Desktop/dev` and `for i in >>> open('file.txt'): print i` at the some shell. This I think would be >>> VERY useful. >>> >>> >> That's an awful lot of key mashing just to replace 'cat file.txt' > > No kidding. And how much python would it take to do "less file.txt"? A lot less than the amount of C it takes to do "less file.txt". I trust you don't imagine that a Python shell would require the user to re-implement "less" using nothing but built-ins each time they needed it. There would be a pre-made "less" replacement (which may even be a wrapper around the system "less") never more than one import away. You can already do something very close to this right now: from pydoc import pager pager(open("file.txt").read()) How much effort would it take to turn pydoc.pager into a full replacement for "less"? I don't know, but it would only need to be done ONCE. This is not a theoretical argument. IPython already does this. It not only gives you full access to all your shell commands, plus more, but it let's you use something very close to shell syntax to do it. http://ipython.org/ipython-doc/dev/interactive/shell.html The advantage of a Python shell like IPython is not for trivial shell commands like "less file.txt". I can think of at least four reasons why you might consider a Python shell would be awesome: "I know Python, and I don't know bash. What do I care if it takes five lines to perform a task in Python, vs one line in bash, if it would take me half an hour of reading man pages and seven attempts to get the bash version right?" "I'm fed up to the back teeth of the shell's cryptic syntax, magic global variables and especially its arcane string quoting rules." "I'm sick and tired of having to parse human-readable presentation text to get the answers I want. I want an environment where the tools don't mix content and presentation by default." "My OS has a shell which sucks and blows at the same time. I want something better." So basically, there exists a niche for Python as a shell, and thanks to the time machine, there already exists a powerful Python shell ready to fill that niche. -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 22 17:21:31 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 22 Feb 2012 22:21:31 GMT Subject: Python math is off by .000000000000045 References: Message-ID: <4f456a6b$0$29986$c3e8da3$5496439d@news.astraweb.com> On Wed, 22 Feb 2012 19:26:26 +0100, Christian Heimes wrote: > Python uses the platforms double precision float datatype. Floats are > almost never exact. Well, that's not quite true. Python floats are always exact. They just may not be exactly what you want :) Pedantic-but-unhelpful-as-always-ly y'rs, -- Steven From gelonida at gmail.com Wed Feb 22 17:25:07 2012 From: gelonida at gmail.com (Gelonida N) Date: Wed, 22 Feb 2012 23:25:07 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: On 02/22/2012 07:05 PM, Alec Taylor wrote: > http://www.pyinstaller.org/ > > or > > http://cx-freeze.sourceforge.net/ > > You can also run py2exe in WINE > You want to say, that I could install python 2.6 some packages like win32api PyQt and tand py2exe under Wine and then compile it. Did you try this? I didn't even think about trying this out, but I know very little about the limits of Wine, so perhaps I underestimate it. From stefan_ml at behnel.de Wed Feb 22 17:43:23 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 22 Feb 2012 23:43:23 +0100 Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: Gelonida N, 22.02.2012 23:25: > On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > > You want to say, that I could install python 2.6 > some packages like win32api > PyQt and tand py2exe under Wine and then compile it. > > > Did you try this? > > I didn't even think about trying this out, > but I know very little about the limits of Wine, so perhaps I > underestimate it. The compliance requirements for software build tools tend to be rather easy to meet, so Wine shouldn't have any real problems there. Having said that, Wine is actually surprisingly capable these days. It won't always run the latest release of our all-time favourite WYGIWYD character pushing or number layouting programs from MS-Office fame, but at least older versions of many a program tend to work rather nicely. Stefan From python-excel at raf.org Wed Feb 22 18:15:01 2012 From: python-excel at raf.org (python-excel at raf.org) Date: Thu, 23 Feb 2012 10:15:01 +1100 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F44EC25.7060309@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> Message-ID: <20120222231501.GA6553@raf.org> Chris Withers wrote: > On 22/02/2012 00:37, python-excel at raf.org wrote: > >was good for previous versions. two reasons that spring to mind > >immediately are: > > > > - it makes it much easier to tell what version is installed > > - it makes it much easier to uninstall the package > > > >i know that both of these are things that the python community > >does not yet seem to find useful but everyone else seems to. > > That's because it's no longer best practice to polute the global > python installation by installing packages directly into it. > > The recommended wisdom nowadays is to use a virtualenv and then pip > install the package. > > I believe that will give you everything you need, please explain if > it doesn't. > > cheers, > > Chris thanks. i'm sure that'll do nicely. cheers, raf From adrian.klaver at gmail.com Wed Feb 22 18:17:26 2012 From: adrian.klaver at gmail.com (Adrian Klaver) Date: Wed, 22 Feb 2012 15:17:26 -0800 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <4F44EC25.7060309@simplistix.co.uk> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> Message-ID: <201202221517.27298.adrian.klaver@gmail.com> On Wednesday, February 22, 2012 5:22:45 am Chris Withers wrote: > On 22/02/2012 00:37, python-excel at raf.org wrote: > > was good for previous versions. two reasons that spring to mind > > > > immediately are: > > - it makes it much easier to tell what version is installed > > - it makes it much easier to uninstall the package > > > > i know that both of these are things that the python community > > does not yet seem to find useful but everyone else seems to. > > That's because it's no longer best practice to polute the global python > installation by installing packages directly into it. > > The recommended wisdom nowadays is to use a virtualenv and then pip > install the package. I can see where that would be preferred when managing multiple versions of Python, but not when using a single version. The pip system does a good job of managing package installs in the global context. As to the OPs original post, I see the point. On Windows the installer is the point of entry for 'package' management, going outside that can get confusing. I also understand setting up a Windows installer is non-trivial. Assuming a Windows installer is not in the offing, the OP might find it easier to use the Python packaging from here on out. For an example, to find out information on a package: aklaver at tucker:~/.pip$ pip search xlrd xlutils - Utilities for working with Excel files that require both xlrd and xlwt xlrd - Library for developers to extract data from Microsoft Excel (tm) spreadsheet files INSTALLED: 0.7.2 (latest) xlrd3 - Library for developers to extract data from Microsoft Excel (tm) spreadsheet files xlrd1 - library for extracting data from Microsoft Excel spreadsheet files > > I believe that will give you everything you need, please explain if it > doesn't. > > cheers, > > Chris -- Adrian Klaver adrian.klaver at gmail.com From steve+comp.lang.python at pearwood.info Wed Feb 22 19:52:50 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 00:52:50 GMT Subject: distutils + mercurial good practice question Message-ID: <4f458de2$0$11121$c3e8da3@news.astraweb.com> distutils generates a number of files automatically in my projects, including MANIFEST, build/* and dist/* Is there any reason why I would want or need to track them in mercurial? I currently have this .hgignore file: syntax: glob *.pyc *~ exclude/* build/* dist/* MANIFEST Good practice or bad practice? -- Steven From steve+comp.lang.python at pearwood.info Wed Feb 22 21:09:09 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 02:09:09 GMT Subject: ANN: pyprimes 0.1 released Message-ID: <4f459fc5$0$11121$c3e8da3@news.astraweb.com> I am happy to announce the first public release of pyprimes, a pure- Python module for generating prime numbers, primality tests, and prime factorisation. http://pypi.python.org/pypi/pyprimes/0.1.1a With pyprimes, you can compare a number of algorithms for generating and testing primes. It includes fast algorithms for lazily generating primes on demand, such as the Croft Spiral, as well as terrible examples of algorithms to avoid, such as Turner's Sieve (sometimes known as "the Sleight on Eratosthenes"). Examples: py> import pyprimes py> pyprimes.isprime(3300454933) True py> pyprimes.factors(3300454934) [2, 7, 14969, 15749L] py> for p in pyprimes.primes(): ... if p < 500000: continue ... if p > 500100: break ... print p ... 500009 500029 500041 500057 500069 500083 A note on performance: Generating large prime numbers (hundreds of digits) is extremely computationally intensive. A pure-Python solution like pyprimes is unlikely to be suitable for such large numbers, and I make no claim that it will break any world-records. But many popular and common prime number generators can't even deal well with *five* digit primes, slowing down to a crawl. pyprimes is in some cases hundreds of times faster than such prime generators. pyprimes includes examples of these algorithms so you can compare them for yourself: py> from time import time py> def test(generator): ... t = time() ... for p in generator(): ... if p > 10000: break ... return time() - t ... py> test(pyprimes.primes) 0.013000965118408203 py> test(pyprimes.naive_primes1) 4.1489889621734619 -- Steven From richard at pyweek.org Wed Feb 22 22:16:09 2012 From: richard at pyweek.org (Richard Jones) Date: Thu, 23 Feb 2012 14:16:09 +1100 Subject: Python Game Programming Challenge (PyWeek) #14 is coming! [corrected dates] Message-ID: Note: this email corrects the dates given in the previous announcement. The 14th Python Game Programming Challenge (PyWeek) is coming. It'll run from the 6th to the 13th of May. Not April as previously announced. http://pyweek.org/14/ New user registration is NOT YET OPEN. It will open one month before the challenge starts. The PyWeek challenge: - Invites entrants to write a game in one week from scratch either as an individual or in a team, - Is intended to be challenging and fun, - Will hopefully increase the public body of game tools, code and expertise, - Will let a lot of people actually finish a game, and - May inspire new projects (with ready made teams!) If you're in the US and can make it I'm co-presenting a 3 hour pygame tutorial at PyCon in March. From miki.tebeka at gmail.com Wed Feb 22 22:19:22 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 22 Feb 2012 19:19:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: <30968261.1414.1329967162981.JavaMail.geo-discussion-forums@ynlp18> > Having said that, Wine is actually surprisingly capable these days. It > won't always run the latest release of our all-time favourite WYGIWYD > character pushing or number layouting programs from MS-Office fame, but at > least older versions of many a program tend to work rather nicely. Even newer ones, have a look at http://www.playonlinux.com/en/ to get a taste of what it's capable of. From miki.tebeka at gmail.com Wed Feb 22 22:19:22 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Wed, 22 Feb 2012 19:19:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: <30968261.1414.1329967162981.JavaMail.geo-discussion-forums@ynlp18> > Having said that, Wine is actually surprisingly capable these days. It > won't always run the latest release of our all-time favourite WYGIWYD > character pushing or number layouting programs from MS-Office fame, but at > least older versions of many a program tend to work rather nicely. Even newer ones, have a look at http://www.playonlinux.com/en/ to get a taste of what it's capable of. From krishankumar895 at gmail.com Thu Feb 23 00:34:08 2012 From: krishankumar895 at gmail.com (Krishan kumar) Date: Wed, 22 Feb 2012 21:34:08 -0800 (PST) Subject: ONLINE FORM FILLING AND DATA ENTRY SERVICES Message-ID: ONLINE FORM FILLING AND DATA ENTRY SERVICES AVAILABLE HERE http://www.wincon.co.in From ssmile03 at gmail.com Thu Feb 23 01:24:42 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 23 Feb 2012 11:54:42 +0530 Subject: storing in list and retrieving. Message-ID: I need to write two file using python script as below - 1. Store.py: Write a script to store a list say "store_list = ["Apple", "Orange", "PineApple". ?and so on? ]" to disk. 2. Retrieve.py: Read the object stored in the ?Store.py? file and print the contents of this list. I have to run on Linux with python-2.6.5. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Thu Feb 23 01:31:25 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Feb 2012 17:31:25 +1100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 wrote: > I need to write two file using python script as below - > > 1. Store.py: Write a script to store a list say "store_list = ["Apple", > "Orange", "PineApple". ?and so on? ]" to disk. > > 2. Retrieve.py: Read the object stored in the ?Store.py? file and print the > contents of this list. > > I have to run on Linux with python-2.6.5. This looks like homework, so I'm just going to give a broad hint. Figure out a file format (one per line, or pickled, or whatever), then write one program that writes that format and another that reads it. The open() built-in function will open files for reading or writing, so that's a good place to start. Get as far as you can on your own, and if you get stuck, ask the list for more specific help. Good luck! Chris Angelico From richardbp at gmail.com Thu Feb 23 01:33:22 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:33:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <33059459.3.1329978802605.JavaMail.geo-discussion-forums@pbib1> thanks J?r?me. Closest I have found is pyinstaller added support for cross-compiling a year ago by mounting a Windows partition on Linux: https://groups.google.com/forum/?fromgroups#!topic/pyinstaller/KISZP5sHCWg But it was not stable so will be removed: https://groups.google.com/forum/?fromgroups#!searchin/PyInstaller/linux$20windows/pyinstaller/veq3BlA_Bns I have come across many vague suggestions to try using Wine with py2exe / pyinstaller / cx_Freeze, but few accounts from people who have actually succeeded. Richard From richardbp at gmail.com Thu Feb 23 01:33:22 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:33:22 -0800 (PST) Subject: generate Windows exe on Linux In-Reply-To: References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <33059459.3.1329978802605.JavaMail.geo-discussion-forums@pbib1> thanks J?r?me. Closest I have found is pyinstaller added support for cross-compiling a year ago by mounting a Windows partition on Linux: https://groups.google.com/forum/?fromgroups#!topic/pyinstaller/KISZP5sHCWg But it was not stable so will be removed: https://groups.google.com/forum/?fromgroups#!searchin/PyInstaller/linux$20windows/pyinstaller/veq3BlA_Bns I have come across many vague suggestions to try using Wine with py2exe / pyinstaller / cx_Freeze, but few accounts from people who have actually succeeded. Richard From richardbp at gmail.com Thu Feb 23 01:58:10 2012 From: richardbp at gmail.com (Plumo) Date: Wed, 22 Feb 2012 22:58:10 -0800 (PST) Subject: asynchronous downloading Message-ID: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> I want to download content asynchronously. This would be straightforward to do threaded or across processes, but difficult asynchronously so people seem to rely on external libraries (twisted / gevent / eventlet). (I would use gevent under different circumstances, but currently need to stick to standard libraries.) I looked around and found there is little interest in developing a proper HTTP client on asyncore. The best I found stopped development a decade ago: http://sourceforge.net/projects/asynchttp/ What do you recommend? And why is there poor support for asynchronous execution? Richard From kingkon098 at gmail.com Thu Feb 23 02:11:05 2012 From: kingkon098 at gmail.com (vikram) Date: Wed, 22 Feb 2012 23:11:05 -0800 (PST) Subject: DATA ENTRY, FORM FILLING AND BPO SERVICES Message-ID: <8384a028-62d5-4edf-8784-96e939055472@jn12g2000pbb.googlegroups.com> DATA ENTRY, FORM FILLING AND BPO SERVICES AVAILABLE HERE http://www.wincon.co.in/ From justin.mailinglists at gmail.com Thu Feb 23 02:25:32 2012 From: justin.mailinglists at gmail.com (Justin Ezequiel) Date: Wed, 22 Feb 2012 23:25:32 -0800 (PST) Subject: asynchronous downloading References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <8642ad38-41ab-4137-95bb-259e6c1fb519@qt7g2000pbc.googlegroups.com> have you seen http://www.doughellmann.com/PyMOTW/asyncore/ From chris at simplistix.co.uk Thu Feb 23 02:56:43 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 23 Feb 2012 07:56:43 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <201202221517.27298.adrian.klaver@gmail.com> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <201202221517.27298.adrian.klaver@gmail.com> Message-ID: <4F45F13B.2020609@simplistix.co.uk> On 22/02/2012 23:17, Adrian Klaver wrote: > I can see where that would be preferred when managing multiple versions of > Python, but not when using a single version. Sorry, I don't agree. It is *never* a good idea to install packages globally. Using virtualenv or similar (buildout, etc) gives you a single, cross platform way of not ending up with a mess of a python installation where you have a bunch of libraries of random versions installed, often with no way of finding out what version they are or how to uninstall them. Heaven forbid you want to use or develop more than one project per machine; then you end up with different projects needing different versions of the same libraries and you're screwed. ;-) > The pip system does a good job o > managing package installs in the global context. Ask the pip maintainers whether they'd suggest using pip on the global system python or inside a virtualenv... > see the point. On Windows the installer is the point of entry for 'package' > management, going outside that can get confusing. "Python" should be though of as the application, not any individual library... > I also understand setting up a > Windows installer is non-trivial. It isn't a lot of work from what I remember, I just don't like encouraging bad practices... > offing, the OP might find it easier to use the Python packaging from here on out. What is "the Python packaging" you refer to? > xlrd3 - Library for developers to extract data from > Microsoft Excel (tm) spreadsheet files > xlrd1 - library for extracting data from Microsoft Excel > spreadsheet files I would avoid both of these like the plague, it's a shame the people who dumped them on PyPI don't put up a similar warning :-( cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From ssmile03 at gmail.com Thu Feb 23 03:45:00 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Thu, 23 Feb 2012 14:15:00 +0530 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: It requires concepts of 'python persistence' for the code to be designed . Else it simple. Looking for some flow?? ---- On Thu, Feb 23, 2012 at 12:01 PM, Chris Angelico wrote: > On Thu, Feb 23, 2012 at 5:24 PM, Smiley 4321 wrote: > > I need to write two file using python script as below - > > > > 1. Store.py: Write a script to store a list say "store_list = ["Apple", > > "Orange", "PineApple". ?and so on? ]" to disk. > > > > 2. Retrieve.py: Read the object stored in the ?Store.py? file and print > the > > contents of this list. > > > > I have to run on Linux with python-2.6.5. > > This looks like homework, so I'm just going to give a broad hint. > > Figure out a file format (one per line, or pickled, or whatever), then > write one program that writes that format and another that reads it. > The open() built-in function will open files for reading or writing, > so that's a good place to start. > > Get as far as you can on your own, and if you get stuck, ask the list > for more specific help. Good luck! > > Chris Angelico > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From navkirats at gmail.com Thu Feb 23 04:26:21 2012 From: navkirats at gmail.com (Nav) Date: Thu, 23 Feb 2012 01:26:21 -0800 (PST) Subject: Reset static variables or a workaround Message-ID: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Hi Guys, I have a custom user form class, it inherits my own custom Form class: class UserForm(Form): first_name = TextField(attributes={id='id_firstname'}) Now, everytime UserForm() is instantiated it saves the attributes of each form members and passes it on to the new instance. I understand this is because first_name is static in nature. But I would like to reset the first_name for every instance? How can I do this? Regards, Nav From rosuav at gmail.com Thu Feb 23 04:26:44 2012 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 23 Feb 2012 20:26:44 +1100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 7:45 PM, Smiley 4321 wrote: > It requires concepts of 'python persistence' for the code to be designed . > > Else it simple. > > Looking for some flow?? Go through the tutorial on python.org if you haven't, get some code written, and then codify your questions :) Chances are you'll figure it out on your own. ChrisA From clp2 at rebertia.com Thu Feb 23 04:43:42 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 01:43:42 -0800 Subject: Reset static variables or a workaround In-Reply-To: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> References: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 1:26 AM, Nav wrote: > Hi Guys, > > I have a custom user form class, it inherits my own custom Form class: > > class UserForm(Form): > ? ?first_name = TextField(attributes={id='id_firstname'}) > > Now, everytime UserForm() is instantiated it saves the attributes of > each form members and passes it on to the new instance. I understand > this is because first_name is static in nature. But I would like to > reset the first_name for every instance? How can I do this? I infer that your question concerns Django. You might want to ask on their discussion group instead: http://groups.google.com/group/django-users Cheers, Chris From jeanmichel at sequans.com Thu Feb 23 05:18:07 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 23 Feb 2012 11:18:07 +0100 Subject: Reset static variables or a workaround In-Reply-To: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> References: <9a1910c3-ccb0-493a-9756-4c6264e7c3b6@o4g2000pbc.googlegroups.com> Message-ID: <4F46125F.4070204@sequans.com> Nav wrote: > Hi Guys, > > I have a custom user form class, it inherits my own custom Form class: > > class UserForm(Form): > first_name = TextField(attributes={id='id_firstname'}) > > Now, everytime UserForm() is instantiated it saves the attributes of > each form members and passes it on to the new instance. I'm not sure I've understood this sentence but if you're saying that class attributes are copied into the subclass instance, that's wrong. > I understand > this is because first_name is static in nature. But I would like to > reset the first_name for every instance? How can I do this? > > Regards, > Nav > Class attributes are not default values for instances. If you want to set the first_name attribute for every instances, you have to make it an instance attribute: class Form: def __init__(self): self.first_name = "foo" class UserForm(Form): def __init__(self, name): Form.__init__(self) self.first_name = name uForm = UserForm('banana') print uForm.first_name Cheers, JM From jeanmichel at sequans.com Thu Feb 23 05:31:17 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Thu, 23 Feb 2012 11:31:17 +0100 Subject: storing in list and retrieving. In-Reply-To: References: Message-ID: <4F461575.5000906@sequans.com> Smiley 4321 wrote: > It requires concepts of 'python persistence' for the code to be designed . > > Else it simple. > > Looking for some flow?? > ---- Hi, Have a look at http://docs.python.org/library/pickle.html Cheers, JM From ralf at systemexit.de Thu Feb 23 06:00:15 2012 From: ralf at systemexit.de (Ralf Schmitt) Date: Thu, 23 Feb 2012 12:00:15 +0100 Subject: [ANNOUNCE] pypiserver 0.5.1 - minimal pypi server Message-ID: <87hayhak74.fsf@winserver.brainbot.com> Hi, I've just uploaded pypiserver 0.5.1 to the python package index. pypiserver is a minimal PyPI compatible server. It can be used to serve a set of packages and eggs to easy_install or pip. pypiserver is easy to install (i.e. just easy_install pypiserver). It doesn't have any external dependencies. http://pypi.python.org/pypi/pypiserver/ should contain enough information to easily get you started running your own PyPI server in a few minutes. The code is available on github: https://github.com/schmir/pypiserver Changes in version 0.5.1 ------------------------- - make 'pypi-server -U' compatible with pip 1.1 -- Cheers, Ralf From mhammond at skippinet.com.au Thu Feb 23 06:20:40 2012 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 23 Feb 2012 22:20:40 +1100 Subject: asynchronous downloading In-Reply-To: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <4F462108.2000400@skippinet.com.au> On 23/02/2012 5:58 PM, Plumo wrote: > I want to download content asynchronously. This would be > straightforward to do threaded or across processes, but difficult > asynchronously so people seem to rely on external libraries (twisted > / gevent / eventlet). Exactly - the fact it's difficult is why those tools compete. > (I would use gevent under different circumstances, but currently need > to stick to standard libraries.) As above - use threads or processes - they are fine for relatively modest tasks. If your needs go beyond modest, I'd reevaluate your need to stick with just the stdlib - even demanding *sync* http apps often wind up using modules outside the stdlib. Look into virtualenv etc if permission to install packages is the issue. Batteries included free, but turbo-chargers are an extra ;) Mark From no.email at nospam.invalid Thu Feb 23 06:46:00 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 23 Feb 2012 03:46:00 -0800 Subject: asynchronous downloading References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <7x4nuhlqmf.fsf@ruckus.brouhaha.com> Plumo writes: > What do you recommend? Threads. > And why is there poor support for asynchronous execution? The freenode #python crowd seems to hate threads and prefer twisted, which seems to have the features you want and probably handles very large #'s of connections better than POSIX threads do. But I find the whole event-driven model to be an annoying abstraction inversion and threads to be simpler, so I've stayed with threads. I keep hearing boogieman stories about the evil hazards of race conditions etc. but none of that stuff has ever happened to me (yet) as far as I can tell. The main thing is to avoid sharing mutable data between threads to the extent that you can. Keep the threads isolated from each other except for communication through Queues and not too much can go wrong. The last program I wrote had around 20 threads and one or two condition variables and I don't think any significant bugs resulted from that. FWIW, the Erlang language is built around the above concept, it uses super-lightweight userland threads so it can handle millions of them concurrently, and it's used successfully for ultra-high-reliability phone switches and similar applications that are not allowed to fail, so it must be doing something right. There are a few schemes like Camaelia (sp?) implementing concurrency with Python generators or coroutines, but I think they're not widely used, and Python coroutines are kind of crippled because they don't carry any stack below their entry point. From glicerinu at gmail.com Thu Feb 23 06:52:27 2012 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 23 Feb 2012 03:52:27 -0800 (PST) Subject: unexpected behaviour playing with dynamic methods Message-ID: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Hi, I'm playing a bit with python dynamic methods and I came up with a scenario that I don't understant. Considering the follow code: # Declare a dummy class class A(object): pass # generate a dynamic method and insert it to A class for name in ['a', 'b', 'c']: if name == 'b': @property def get_name(self): return name A.name = get_name a_instance = A() a_instance.name # So far I exptect that a_instance.name returns 'b', since it has been created when name == 'b', but this is what actually returns: >>> a_instance.name 'c' just the last 'name' value. What can I do in order to generate a method like this but that returns 'b' ? What is wrong in my understanding of this pice of code? Thanks !!! marc From __peter__ at web.de Thu Feb 23 08:05:24 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 23 Feb 2012 14:05:24 +0100 Subject: unexpected behaviour playing with dynamic methods References: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Message-ID: Marc Aymerich wrote: > Hi, > > I'm playing a bit with python dynamic methods and I came up with a > scenario that I don't understant. Considering the follow code: > > # Declare a dummy class > class A(object): > pass > > # generate a dynamic method and insert it to A class > for name in ['a', 'b', 'c']: > if name == 'b': > @property > def get_name(self): > return name > A.name = get_name > > > a_instance = A() > a_instance.name > > # So far I exptect that a_instance.name returns 'b', since it has > been created when name == 'b', but this is what actually returns: > >>>> a_instance.name > 'c' > > just the last 'name' value. > What can I do in order to generate a method like this but that returns > 'b' ? What is wrong in my understanding of this pice of code? Look at the method again: > def get_name(self): > return name It returns the global variable name. Why would you expect to see a historical value of that variable? If you want to capture the value of name at the time when get_name() is defined you have several options: - The default argument trick: def get_name(self, name=name): return name - A closure: def make_get_name(name): def get_name(self): return name return get_name A.name = property(make_get_name(name)) - functools.partial() def get_name(self, name): return name A.name = property(partial(get_name, name=name)) From glicerinu at gmail.com Thu Feb 23 08:44:46 2012 From: glicerinu at gmail.com (Marc Aymerich) Date: Thu, 23 Feb 2012 05:44:46 -0800 (PST) Subject: unexpected behaviour playing with dynamic methods References: <301abcfb-46ed-4220-83d9-58867362de48@o6g2000vbz.googlegroups.com> Message-ID: On Feb 23, 2:05?pm, Peter Otten <__pete... at web.de> wrote: > Marc Aymerich wrote: > > Hi, > > > I'm playing a bit with python dynamic methods and I came up with a > > scenario that I don't understant. Considering the follow code: > > > # Declare a dummy class > > class A(object): > > ? ? pass > > > # generate a dynamic method and insert it to A class > > for name in ['a', 'b', 'c']: > > ? ? if name == 'b': > > ? ? ? ? @property > > ? ? ? ? def get_name(self): > > ? ? ? ? ? ? return name > > ? ? ? ? A.name = get_name > > > a_instance = A() > > a_instance.name > > > # So far I exptect that a_instance.name ?returns 'b', since it has > > been created when name == 'b', but this is what actually returns: > > >>>> a_instance.name > > 'c' > > > just the last 'name' value. > > What can I do in order to generate a method like this but that returns > > 'b' ? What is wrong in my understanding of this pice of code? > > Look at the method again: > > > ? ? ? ? def get_name(self): > > ? ? ? ? ? ? return name > > It returns the global variable name. Why would you expect to see a > historical value of that variable? hehe, yeah, after sending my email I realized that it was obvious, but the true is I came up with this problem in a more complex situation involving lot's of imports and so on.. so the question: wtf is going on?? came up to me at this time :P > If you want to capture the value of name at the time when get_name() is > defined you have several options: > > - The default argument trick: > > def get_name(self, name=name): > ? ? return name > > - A closure: > > def make_get_name(name): > ? ? def get_name(self): > ? ? ? ? return name > ? ? return get_name > A.name = property(make_get_name(name)) > > - functools.partial() > > def get_name(self, name): > ? ? return name > A.name = property(partial(get_name, name=name)) Wow Peter, I was expecting one solution and you give me 3 amazing solutions!! :) Thanks a lot! btw I always wondered for what functools.partial can be useful, now I know an example :) From richardbp at gmail.com Thu Feb 23 08:50:34 2012 From: richardbp at gmail.com (Richard Baron Penman) Date: Fri, 24 Feb 2012 00:50:34 +1100 Subject: asynchronous downloading In-Reply-To: <4F462108.2000400@skippinet.com.au> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <4F462108.2000400@skippinet.com.au> Message-ID: >> I want to download content asynchronously. This would be >> straightforward to do threaded or across processes, but difficult >> asynchronously so people seem to rely on external libraries (twisted >> / gevent / eventlet). > > > Exactly - the fact it's difficult is why those tools compete. It is difficult in Python because the async libraries do not offer much. Straightforward in some other languages. Do you know why there is little support for asynchronous execution in the standard libraries? For large scale downloading I found thread pools do not scale well. Richard From steve+comp.lang.python at pearwood.info Thu Feb 23 09:06:22 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 14:06:22 GMT Subject: distutils bdist_wininst failure on Linux Message-ID: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Following instructions here: http://docs.python.org/py3k/distutils/builtdist.html#creating-windows-installers I am trying to create a Windows installer for a pure-module distribution using Python 3.2. I get a "LookupError: unknown encoding: mbcs" Here is the full output of distutils and the traceback: [steve at ando pyprimes]$ python3.2 setup.py bdist_wininst running bdist_wininst running build running build_py creating build/lib copying src/pyprimes.py -> build/lib installing to build/bdist.linux-i686/wininst running install_lib creating build/bdist.linux-i686/wininst creating build/bdist.linux-i686/wininst/PURELIB copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB running install_egg_info Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info creating '/tmp/tmp3utw4_.zip' and adding '.' to it adding 'PURELIB/pyprimes.py' adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info' creating dist Warning: Can't read registry to find the necessary compiler setting Make sure that Python modules winreg, win32api or win32con are installed. Traceback (most recent call last): File "setup.py", line 60, in "License :: OSI Approved :: MIT License", File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup dist.run_commands() File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands self.run_command(cmd) File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command cmd_obj.run() File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run self.create_exe(arcname, fullname, self.bitmap) File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe cfgdata = cfgdata.encode("mbcs") LookupError: unknown encoding: mbcs How do I fix this, and is it a bug in distutils? -- Steven From roy at panix.com Thu Feb 23 09:21:25 2012 From: roy at panix.com (Roy Smith) Date: Thu, 23 Feb 2012 09:21:25 -0500 Subject: What does exc_info do in a logging call? Message-ID: In http://docs.python.org/release/2.6.7/library/logging.html, it says: logging.debug(msg[, *args[, **kwargs]]) [...] There are two keyword arguments in kwargs which are inspected: exc_info which, if it does not evaluate as false, causes exception information to be added to the logging message. If an exception tuple (in the format returned by sys.exc_info()) is provided, it is used; otherwise, sys.exc_info() is called to get the exception information. I don't get what this is trying to do. I have this code: try: f = urllib2.urlopen(url) except urllib2.HTTPError as ex: logger.error("Unable to retrieve profile from facebook (access_token='%r')" % access_token, exc_info=ex) which ends up logging: [...] ERROR _get_profile Unable to retrieve profile from facebook (access_token='u'[token elided]'') so what is the exc_info doing? What "exception information" is being added to the message? Am I just calling this wrong? From xlstime at gmail.com Thu Feb 23 09:40:29 2012 From: xlstime at gmail.com (xlstime) Date: Thu, 23 Feb 2012 20:10:29 +0530 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: <20120222231501.GA6553@raf.org> References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <20120222231501.GA6553@raf.org> Message-ID: Hi, i want to learn pyxl please help me... kindly send useful information about pyxl *Thank you in Advance* XLS S :) On Thu, Feb 23, 2012 at 4:45 AM, wrote: > Chris Withers wrote: > > > On 22/02/2012 00:37, python-excel at raf.org wrote: > > >was good for previous versions. two reasons that spring to mind > > >immediately are: > > > > > > - it makes it much easier to tell what version is installed > > > - it makes it much easier to uninstall the package > > > > > >i know that both of these are things that the python community > > >does not yet seem to find useful but everyone else seems to. > > > > That's because it's no longer best practice to polute the global > > python installation by installing packages directly into it. > > > > The recommended wisdom nowadays is to use a virtualenv and then pip > > install the package. > > > > I believe that will give you everything you need, please explain if > > it doesn't. > > > > cheers, > > > > Chris > > thanks. i'm sure that'll do nicely. > > cheers, > raf > > -- > You received this message because you are subscribed to the Google Groups > "python-excel" group. > To post to this group, send an email to python-excel at googlegroups.com. > To unsubscribe from this group, send email to > python-excel+unsubscribe at googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/python-excel?hl=en-GB. > > -- ......................... -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Feb 23 10:05:50 2012 From: __peter__ at web.de (Peter Otten) Date: Thu, 23 Feb 2012 16:05:50 +0100 Subject: What does exc_info do in a logging call? References: Message-ID: Roy Smith wrote: > In http://docs.python.org/release/2.6.7/library/logging.html, it says: > > logging.debug(msg[, *args[, **kwargs]]) > [...] > There are two keyword arguments in kwargs which are inspected: exc_info > which, if it does not evaluate as false, causes exception information to > be added to the logging message. If an exception tuple (in the format > returned by sys.exc_info()) is provided, it is used; otherwise, > sys.exc_info() is called to get the exception information. > > I don't get what this is trying to do. I have this code: > > try: > f = urllib2.urlopen(url) > except urllib2.HTTPError as ex: > logger.error("Unable to retrieve profile from facebook > (access_token='%r')" % access_token, > exc_info=ex) > > which ends up logging: > > [...] ERROR _get_profile Unable to retrieve profile from facebook > (access_token='u'[token elided]'') > > so what is the exc_info doing? What "exception information" is being > added to the message? Am I just calling this wrong? I think whatever the formatter's formatException() makes out of the (exception_type, exception_value, traceback) tuple lands in the logfile: >> import logging >>> logging.basicConfig() >>> try: 1/0 ... except: logging.error("yadda") ... ERROR:root:yadda >>> try: 1/0 ... except: logging.error("yadda", exc_info=True) ... ERROR:root:yadda Traceback (most recent call last): File "", line 1, in ZeroDivisionError: integer division or modulo by zero >>> class Formatter(logging.Formatter): ... def formatException(self, *args): return "OOPS" ... >>> logging._handlers.keys()[0].setFormatter(Formatter()) # ;) >>> try: 1/0 ... except: logging.error("yadda", exc_info=True) ... yadda OOPS From wxjmfauth at gmail.com Thu Feb 23 10:09:35 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Thu, 23 Feb 2012 07:09:35 -0800 (PST) Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 23 f?v, 15:06, Steven D'Aprano wrote: > Following instructions here: > > http://docs.python.org/py3k/distutils/builtdist.html#creating-windows... > > I am trying to create a Windows installer for a pure-module distribution > using Python 3.2. I get a "LookupError: unknown encoding: mbcs" > > Here is the full output of distutils and the traceback: > > [steve at ando pyprimes]$ python3.2 setup.py bdist_wininst > running bdist_wininst > running build > running build_py > creating build/lib > copying src/pyprimes.py -> build/lib > installing to build/bdist.linux-i686/wininst > running install_lib > creating build/bdist.linux-i686/wininst > creating build/bdist.linux-i686/wininst/PURELIB > copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB > running install_egg_info > Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info > creating '/tmp/tmp3utw4_.zip' and adding '.' to it > adding 'PURELIB/pyprimes.py' > adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info' > creating dist > Warning: Can't read registry to find the necessary compiler setting > Make sure that Python modules winreg, win32api or win32con are installed. > Traceback (most recent call last): > ? File "setup.py", line 60, in > ? ? "License :: OSI Approved :: MIT License", > ? File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup > ? ? dist.run_commands() > ? File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands > ? ? self.run_command(cmd) > ? File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command > ? ? cmd_obj.run() > ? File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run > ? ? self.create_exe(arcname, fullname, self.bitmap) > ? File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe > ? ? cfgdata = cfgdata.encode("mbcs") > LookupError: unknown encoding: mbcs > > How do I fix this, and is it a bug in distutils? > > -- > Steven Because the 'mbcs' codec is missing in your Linux, :-) >>> 'abc???'.encode('cp1252') b'abc\xe9\x9c\x80' >>> 'abc???'.encode('missing') Traceback (most recent call last): File "", line 1, in LookupError: unknown encoding: missing jmf From roy at panix.com Thu Feb 23 10:47:21 2012 From: roy at panix.com (Roy Smith) Date: Thu, 23 Feb 2012 07:47:21 -0800 (PST) Subject: What does exc_info do in a logging call? In-Reply-To: References: Message-ID: <25030409.653.1330012041802.JavaMail.geo-discussion-forums@vbux23> Duh, I figured out what's going on. I'm using a custom Formatter class, which overrides format(). It's the job of format() to handle this, and ours doesn't! From vinay_sajip at yahoo.co.uk Thu Feb 23 11:23:42 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 08:23:42 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: <0e8f8dd1-ffe7-42fd-bc95-82ea60358f04@n12g2000yqb.googlegroups.com> Message-ID: On Feb 22, 4:44?am, Fayaz Yusuf Khan wrote: > Anyway, I read the source and found many interesting things that ought to be > mentioned in the docs. > Such as flush() should be called from close() whenever it's implemented. > (FileHandler.close() is doing it) This is entirely handler-dependent - there's no absolute rule that you *have* to call flush() before close(). Some underlying will do flushing when you close. > And how come close()/flush() isn't being called from inside a lock? Why does it need to be? Are you aware of any race conditions or other concurrency problems which will occur with the code as it is now? > (Handler.close() calls the module level _acquireLock() and _releaseLock()s but > nothing about the instance level acquire() or release()) > Or is it being locked from somewhere else? The module level acquisitions are because module-level handler lists are changed in Handler.close(). If locking is required in a particular handler class for close or flush, that can be implemented by the developer of that handler class. AFAIK there is no such need for the handler classes in the stdlib - if you have reason to believe otherwise, please give some examples of potential problems and with example code if possible. Regards, Vinay Sajip From promastermentor at gmail.com Thu Feb 23 11:30:51 2012 From: promastermentor at gmail.com (INCOME STREAMS) Date: Thu, 23 Feb 2012 08:30:51 -0800 (PST) Subject: INCOME STREAMS Message-ID: Hi There, Please confirm your special access link if you have not already done so: >> http://budurl.com/casey0218out << It will be expiring shortly. Thanks Promaster From chris at simplistix.co.uk Thu Feb 23 12:28:31 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 23 Feb 2012 17:28:31 +0000 Subject: [pyxl] xlrd 0.7.2 released! In-Reply-To: References: <4F436119.9090509@simplistix.co.uk> <20120222003747.GA24152@raf.org> <4F44EC25.7060309@simplistix.co.uk> <20120222231501.GA6553@raf.org> Message-ID: <4F46773F.3080209@simplistix.co.uk> On 23/02/2012 14:40, xlstime wrote: > Hi, > > i want to learn pyxl please help me... > > kindly send useful information about pyxl I would suggest: - using your real name when posting - reading the tutorial at http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From g.rodola at gmail.com Thu Feb 23 12:31:54 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Thu, 23 Feb 2012 18:31:54 +0100 Subject: asynchronous downloading In-Reply-To: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: Il 23 febbraio 2012 07:58, Plumo ha scritto: > I want to download content asynchronously. This would be straightforward to do threaded or across processes, but difficult asynchronously so people seem to rely on external libraries (twisted / gevent / eventlet). > > (I would use gevent under different circumstances, but currently need to stick to standard libraries.) > > I looked around and found there is little interest in developing a proper HTTP client on asyncore. The best I found stopped development a decade ago: http://sourceforge.net/projects/asynchttp/ > > What do you recommend? > And why is there poor support for asynchronous execution? > > Richard > -- > http://mail.python.org/mailman/listinfo/python-list If you want to stick with asyncore try to take a look at this: https://gist.github.com/1519999 > And why is there poor support for asynchronous execution? I'd say that's true for stdlib only (asyncore/asynchat). There are plenty of choices amongst third party modules though. To say one, I particularly like tornado which is simple and powerful: http://www.tornadoweb.org/documentation/httpclient.html --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ From fayaz.yusuf.khan at gmail.com Thu Feb 23 12:55:07 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Thu, 23 Feb 2012 23:25:07 +0530 Subject: Should I acquire lock for logging.Handler.flush()? In-Reply-To: References: Message-ID: <4909905.nLhh7fUSGV@dextop08> On Thursday 23 Feb 2012 8:23:42 AM Vinay Sajip wrote: > If locking is required in a particular handler class for close or > flush, that can be implemented by the developer of that handler class. > AFAIK there is no such need for the handler classes in the stdlib - if > you have reason to believe otherwise, please give some examples of > potential problems and with example code if possible. Well, I'm not currently facing any race-around conditions. As I said, I was mostly familiarizing myself with the API. Well, as emit() is always being called from within a lock, I assumed that flush() should/would also be handled similarly. Afterall, they are handling the same underlying output stream or in case of the BufferingHandler share the same buffer. Shouldn't the access be synchronized? -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From eric.frederich at gmail.com Thu Feb 23 12:59:56 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Thu, 23 Feb 2012 12:59:56 -0500 Subject: multiprocessing, what am I doing wrong? Message-ID: Below is some pretty simple code and the resulting output. Sometimes the code runs through but sometimes it just freezes for no apparent reason. The output pasted is where it just got frozen on me. It called start() on the 2nd worker but the 2nd worker never seemed to enter the run method. ################### the code #!/usr/bin/env python import sys import Queue import multiprocessing import time todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, inbox, outbox): super(MyWorker, self).__init__() self.inbox = inbox self.outbox = outbox print >> sys.stderr, '1' * 80; sys.stderr.flush() def run(self): print >> sys.stderr, '2' * 80; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() except Queue.Empty: break self.outbox.put(FOO(*args)) print >> sys.stderr, 'a' * 80; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'b' * 80; sys.stderr.flush() w1 = MyWorker(todo, result_queue) print >> sys.stderr, 'c' * 80; sys.stderr.flush() w2 = MyWorker(todo, result_queue) print >> sys.stderr, 'd' * 80; sys.stderr.flush() w1.start() print >> sys.stderr, 'e' * 80; sys.stderr.flush() w2.start() print >> sys.stderr, 'f' * 80; sys.stderr.flush() for i in xrange(100): print result_queue.get() ################### the output aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 11111111111111111111111111111111111111111111111111111111111111111111111111111111 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 11111111111111111111111111111111111111111111111111111111111111111111111111111111 dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee 22222222222222222222222222222222222222222222222222222222222222222222222222222222 foo 0 1 2 foo 1 2 3 foo 2 3 4 foo 3 4 5 foo 4 5 6 22222222222222222222222222222222222222222222222222222222222222222222222222222222 ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 2 9 20 35 54 -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinay_sajip at yahoo.co.uk Thu Feb 23 14:08:01 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 11:08:01 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <625ae620-be10-4a15-afd9-d515c019add2@cj6g2000vbb.googlegroups.com> On Feb 23, 5:55?pm, Fayaz Yusuf Khan wrote: > Well, as emit() is always being called from within a lock, I assumed that > flush() should/would also be handled similarly. Afterall, they are handling the > same underlying output stream or in case of the BufferingHandler share the same > buffer. Shouldn't the access be synchronized? Yes, you might well be right - though no problems have been reported, it's probably best to be safe. Regards, Vinay Sajip From someone at someplace.invalid Thu Feb 23 14:11:16 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 23 Feb 2012 19:11:16 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? Message-ID: $ cd /usr/bin $ ls -l python* -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 $ diff -s python python2.7 Files python and python2.7 are identical $ I'm just curious: Why two identical files rather than a symlink? From colinh at somewhere.invalid Thu Feb 23 14:15:01 2012 From: colinh at somewhere.invalid (Colin Higwell) Date: Thu, 23 Feb 2012 19:15:01 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Thu, 23 Feb 2012 19:11:16 +0000, HoneyMonster wrote: (reformatted (I hope) > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? Sorry, my first post didn't format properly. From malaclypse2 at gmail.com Thu Feb 23 14:24:23 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 23 Feb 2012 14:24:23 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster wrote: > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root ? ?6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s ?python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? It's not two files, it's a hardlink. You can confirm by running ls -li python* and comparing the inode numbers. -- Jerry From clp2 at rebertia.com Thu Feb 23 14:26:35 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 11:26:35 -0800 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 11:11 AM, Colin Higwell wrote: > $ cd /usr/bin > $ ls -l python* > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python > lrwxrwxrwx 1 root root ? ?6 Oct 29 19:34 python2 -> python > -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7 > $ diff -s ?python python2.7 > Files python and python2.7 are identical > $ > > I'm just curious: Why two identical files rather than a symlink? Depends on your distro / installation method: $ ls -l python* lrwxrwxrwx 1 root root 9 Apr 12 2011 python -> python2.6 -rwxr-xr-x 1 root root 2288272 Dec 27 2010 python2.6 $ # this is on my Debian server Cheers, Chris From someone at someplace.invalid Thu Feb 23 14:34:05 2012 From: someone at someplace.invalid (HoneyMonster) Date: Thu, 23 Feb 2012 19:34:05 +0000 (UTC) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster > wrote: >> $ cd /usr/bin $ ls -l python* >> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root >> ? ?6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 >> 02:42 python2.7 $ diff -s ?python python2.7 Files python and python2.7 >> are identical $ >> >> I'm just curious: Why two identical files rather than a symlink? > > It's not two files, it's a hardlink. You can confirm by running ls -li > python* and comparing the inode numbers. You are spot on. Thank you, and sorry for my stupidity. From malaclypse2 at gmail.com Thu Feb 23 14:54:10 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 23 Feb 2012 14:54:10 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On Thu, Feb 23, 2012 at 2:34 PM, HoneyMonster wrote: > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: >> It's not two files, it's a hardlink. ?You can confirm by running ls -li >> python* and comparing the inode numbers. > > You are spot on. Thank you, and sorry for my stupidity. I don't think you're stupid. It's hard to tell the difference between two separate files with the same file size and a hardlink. The biggest clue is the number "2" in the second column. If I recall correctly, for directories, that's the number of entries in the directory. For files, that number is the number of hardlinks referring to that file. Even with that, it's hard to tell what files are hardlinked together, and figuring it out by inode is a pain in the neck. Personally, I prefer symlinks, even if they introduce a small performance hit. Readability counts, even in the filesystem. -- Jerry From vinay_sajip at yahoo.co.uk Thu Feb 23 15:06:31 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 23 Feb 2012 12:06:31 -0800 (PST) Subject: Should I acquire lock for logging.Handler.flush()? References: Message-ID: <7a003819-4911-4440-b94f-5190f13a6719@i2g2000vbv.googlegroups.com> On Feb 23, 5:55?pm, Fayaz Yusuf Khan wrote: > buffer. Shouldn't the access be synchronized? I've now updated the repos for 2.7, 3.2 and default to add locking for flush/close operations. Thanks for the suggestion. Regards, Vinay Sajip From python at mrabarnett.plus.com Thu Feb 23 15:42:05 2012 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 23 Feb 2012 20:42:05 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: Message-ID: <4F46A49D.9030905@mrabarnett.plus.com> On 23/02/2012 17:59, Eric Frederich wrote: > Below is some pretty simple code and the resulting output. > Sometimes the code runs through but sometimes it just freezes for no > apparent reason. > The output pasted is where it just got frozen on me. > It called start() on the 2nd worker but the 2nd worker never seemed to > enter the run method. > [snip] The 2nd worker did enter the run method; there are 2 lines of "2". Maybe there's an uncaught exception in the run method for some reason. Try doing something like this: try: args = self.inbox.get_nowait() except Queue.Empty: break except: import traceback print "*** Exception in worker" print >> sys.stderr, traceback.print_exc() sys.stderr.flush() print "***" raise From tjreedy at udel.edu Thu Feb 23 16:11:33 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 23 Feb 2012 16:11:33 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: On 2/23/2012 2:34 PM, HoneyMonster wrote: > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > >> On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster >> wrote: >>> $ cd /usr/bin $ ls -l python* >>> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root >>> 6 Oct 29 19:34 python2 -> python -rwxr-xr-x 2 root root 9496 Oct 27 >>> 02:42 python2.7 $ diff -s python python2.7 Files python and python2.7 >>> are identical $ >>> >>> I'm just curious: Why two identical files rather than a symlink? >> >> It's not two files, it's a hardlink. You can confirm by running ls -li >> python* and comparing the inode numbers. > > You are spot on. Thank you, and sorry for my stupidity. The question 'why a hardlink rather than symlink' is not stupid. It was part of the discussion of http://python.org/dev/peps/pep-0394/ The answer was 'history' and how things were 20 years ago and either the pep or the discussion around it says symlinks are fine now and the decision is up to distributors. -- Terry Jan Reedy From buck at yelp.com Thu Feb 23 16:19:21 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:19:21 -0800 (PST) Subject: sum() requires number, not simply __add__ Message-ID: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> I feel like the design of sum() is inconsistent with other language features of python. Often python doesn't require a specific type, only that the type implement certain methods. Given a class that implements __add__ why should sum() not be able to operate on that class? We can fix this in a backward-compatible way, I believe. Demonstration: I'd expect these two error messages to be identical, but they are not. >>> class C(object): pass >>> c = C() >>> sum((c,c)) TypeError: unsupported operand type(s) for +: 'int' and 'C' >>> c + c TypeError: unsupported operand type(s) for +: 'C' and 'C' From buck at yelp.com Thu Feb 23 16:23:45 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:23:45 -0800 (PST) Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> On Feb 23, 1:19?pm, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? > > We can fix this in a backward-compatible way, I believe. > > Demonstration: > ? ? I'd expect these two error messages to be identical, but they are > not. > > ? ? ?>>> class C(object): pass > ? ? ?>>> c = C() > ? ? ?>>> sum((c,c)) > ? ? TypeError: unsupported operand type(s) for +: 'int' and 'C' > ? ? >>> c + c > ? ? TypeError: unsupported operand type(s) for +: 'C' and 'C' Proposal: def sum(values, base=0): values = iter(values) try: result = values.next() except StopIteration: return base for value in values: result += value return result From arnodel at gmail.com Thu Feb 23 16:32:43 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:32:43 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On 23 February 2012 21:19, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? It can. You need to pass a second argument which will be the start value. Try help(sum) for details. -- Arnaud From clp2 at rebertia.com Thu Feb 23 16:32:45 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 13:32:45 -0800 Subject: sum() requires number, not simply __add__ In-Reply-To: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? The time machine strikes again! sum() already can. You just need to specify an appropriate initial value (the empty list in this example) for the accumulator : Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> sum([[1,2],[3,4]], []) [1, 2, 3, 4] Cheers, Chris -- http://rebertia.com From buck at yelp.com Thu Feb 23 16:38:12 2012 From: buck at yelp.com (Buck Golemon) Date: Thu, 23 Feb 2012 13:38:12 -0800 (PST) Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Feb 23, 1:32?pm, Chris Rebert wrote: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: > > I feel like the design of sum() is inconsistent with other language > > features of python. Often python doesn't require a specific type, only > > that the type implement certain methods. > > > Given a class that implements __add__ why should sum() not be able to > > operate on that class? > > The time machine strikes again! sum() already can. You just need to > specify an appropriate initial value (the empty list in this example) > for the accumulator : > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin > Type "help", "copyright", "credits" or "license" for more information.>>> sum([[1,2],[3,4]], []) > > [1, 2, 3, 4] > > Cheers, > Chris > --http://rebertia.com Thanks. I did not know that! My proposal is still *slightly* superior in two ways: 1) It reduces the number of __add__ operations by one 2) The second argument isn't strictly necessary, if you don't mind that the 'null sum' will produce zero. def sum(values, base=0): values = iter(values) try: result = values.next() except StopIteration: return base for value in values: result += value return result From arnodel at gmail.com Thu Feb 23 16:41:28 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:41:28 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 21:23, Buck Golemon wrote: > def sum(values, > base=0): > ? ? ?values = > iter(values) > > ? ? ?try: > ? ? ? ? ?result = values.next() > ? ? ?except StopIteration: > ? ? ? ? ?return base > > ? ? ?for value in values: > ? ? ? ? ?result += value > ? ? ?return result This is definitely not backward compatible. To get something that has a better chance of working with existing code, try this (untested): _sentinel = object() def sum(iterable, start=_sentinel): if start is _sentinel: iterable = iter(iterable) try: start = iterable.next() except StopIteration: return 0 for x in iterable: start += x return start del _sentinel -- Arnaud From stefan_ml at behnel.de Thu Feb 23 16:42:22 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 23 Feb 2012 22:42:22 +0100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Chris Rebert, 23.02.2012 22:32: > On Thu, Feb 23, 2012 at 1:19 PM, Buck Golemon wrote: >> I feel like the design of sum() is inconsistent with other language >> features of python. Often python doesn't require a specific type, only >> that the type implement certain methods. >> >> Given a class that implements __add__ why should sum() not be able to >> operate on that class? > > The time machine strikes again! sum() already can. You just need to > specify an appropriate initial value (the empty list in this example) > for the accumulator : > > Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) > [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> sum([[1,2],[3,4]], []) > [1, 2, 3, 4] I know that you just meant this as an example, but it's worth mentioning in this context that it's not exactly efficient to "sum up" lists this way because there is a lot of copying involved. Each adding of two lists creates a third one and copies all elements into it. So it eats a lot of time and space. Stefan From rosuav at gmail.com Thu Feb 23 16:53:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 08:53:49 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: > _sentinel = object() > > def sum(iterable, start=_sentinel): > ? ?if start is _sentinel: > > del _sentinel Somewhat off-topic: Doesn't the if statement there do a lookup for a global, which would mean that 'del _sentinel' will cause it to fail? Or have I missed something here? ChrisA From ian.g.kelly at gmail.com Thu Feb 23 16:54:22 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 23 Feb 2012 14:54:22 -0700 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:38 PM, Buck Golemon wrote: > My proposal is still *slightly* superior in two ways: > > 1) It reduces the number of __add__ operations by one > 2) The second argument isn't strictly necessary, if you don't mind > that the 'null sum' will produce zero. It produces the wrong result, though: >>> sum([3,4], base=12) 7 If I'm starting with 12 and summing 3 and 4, I expect to get 19. Ideally the second argument should be ignored only if it isn't passed in at all, and I don't know off-hand why the built-in sum doesn't do this. We really don't need to replace it, though. If you want a different sum behavior, just write your own. def sum(iterable, *args): return reduce(operator.add, iterable, *args) >>> sum([3,4]) 7 >>> sum([3,4], 12) 19 >>> sum(['hello', 'world']) 'helloworld' Cheers, Ian From arnodel at gmail.com Thu Feb 23 16:59:08 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 21:59:08 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 21:53, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? > Or have I missed something here? Yes, you're right :) Change the signature to def sum(iterable, start=_sentinel, _sentinel=_sentinel): This is not pretty... -- Arnaud From ian.g.kelly at gmail.com Thu Feb 23 17:00:07 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 23 Feb 2012 15:00:07 -0700 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:53 PM, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? > Or have I missed something here? I believe you're correct. If you really want to delete the _sentinel reference though, you could do: def sum(iterable, start=object()): if start is sum.func_defaults[0]: ... Cheers, Ian From rosuav at gmail.com Thu Feb 23 17:04:23 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 09:04:23 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: > def sum(iterable, start=_sentinel, _sentinel=_sentinel): Is this a reason for Python to introduce a new syntax, such as: def foo(blah, optional=del): if optional is del: print("No argument was provided") Basically, 'del' is treated like a unique non-providable object, only possible in an argument list and only if the argument was omitted. No more proliferation of individual sentinels... what do you think? (I picked "del" because it's an existing keyword. Fairly arbitrary choice though.) Chris Angelico From arnodel at gmail.com Thu Feb 23 17:09:13 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Thu, 23 Feb 2012 22:09:13 +0000 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: On 23 February 2012 22:04, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: >> def sum(iterable, start=_sentinel, _sentinel=_sentinel): > > Is this a reason for Python to introduce a new syntax, such as: > > def foo(blah, optional=del): > ? ?if optional is del: print("No argument was provided") > > Basically, 'del' is treated like a unique non-providable object, only > possible in an argument list and only if the argument was omitted. No > more proliferation of individual sentinels... what do you think? The problem with these proposals is to avoid the leakage of 'del'. Here you could do: def get_del(x=del): return x And then you're in trouble again. -- Arnaud From rosuav at gmail.com Thu Feb 23 17:11:51 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 09:11:51 +1100 Subject: Optional arguments syntax (was Re: sum() requires number, not simply __add__) Message-ID: On Fri, Feb 24, 2012 at 9:09 AM, Arnaud Delobelle wrote: > On 23 February 2012 22:04, Chris Angelico wrote: >> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote: >>> def sum(iterable, start=_sentinel, _sentinel=_sentinel): >> >> Is this a reason for Python to introduce a new syntax, such as: >> >> def foo(blah, optional=del): >> ? ?if optional is del: print("No argument was provided") >> >> Basically, 'del' is treated like a unique non-providable object, only >> possible in an argument list and only if the argument was omitted. No >> more proliferation of individual sentinels... what do you think? > > The problem with these proposals is to avoid the leakage of 'del'. > Here you could do: > > def get_del(x=del): > ? ?return x > > And then you're in trouble again. Yep; what I was thinking was that this would be a magic token that, if used in any expression other than "is del", would decay to some other object such as 0 or None. Otherwise, yeah, there's no difference between that and any other global sentinel. ChrisA From manish2aug at gmail.com Thu Feb 23 17:13:35 2012 From: manish2aug at gmail.com (Manish Sharma) Date: Thu, 23 Feb 2012 14:13:35 -0800 (PST) Subject: Please verify!! Message-ID: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Hi I am new to python language. On my first day, somebody told me that if any python script file is opened with any editor except python editor, the file is corrupted. Some spacing or indentation is changed and script stops working. I was opening the script file in Windows using Notepad++ but I didn't save anything and closed it. Still it was suggested to never open the python file in any other editor. Can anybody please verify this? Can opening a python script in any editor other than python editor corrupt the script? Did anybody ever face such type of issue or its just misunderstanding of the concept. I hope this group is the best place to ask this. Please reply ! :) Manish From amirouche.boubekki at gmail.com Thu Feb 23 17:22:23 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Thu, 23 Feb 2012 23:22:23 +0100 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: 2012/2/23 Manish Sharma > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. There is compatibility issue with line ending in Windows vs other OS that's all I'm aware of. Amirouche -------------- next part -------------- An HTML attachment was scrubbed... URL: From bungiman at gmail.com Thu Feb 23 17:29:45 2012 From: bungiman at gmail.com (Ben) Date: Thu, 23 Feb 2012 14:29:45 -0800 (PST) Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <21257906.684.1330036185279.JavaMail.geo-discussion-forums@vbne13> They are telling you not to switch between editors that use tabs as tabs and ones that use spaces as tabs. Python gets all wonky. No big, use one editor or have your preferred editor highlight your non-preferred whitespace. FWIW, I use spaces. From ckaynor at zindagigames.com Thu Feb 23 17:32:45 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Thu, 23 Feb 2012 14:32:45 -0800 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: On Thu, Feb 23, 2012 at 2:22 PM, Amirouche Boubekki < amirouche.boubekki at gmail.com> wrote: > > > 2012/2/23 Manish Sharma > >> Hi I am new to python language. On my first day, somebody told me that >> if any python script file is opened with any editor except python >> editor, the file is corrupted. Some spacing or indentation is changed >> and script stops working. I was opening the script file in Windows >> using Notepad++ but I didn't save anything and closed it. Still it was >> suggested to never open the python file in any other editor. >> >> Can anybody please verify this? Can opening a python script in any >> editor other than python editor corrupt the script? Did anybody ever >> face such type of issue or its just misunderstanding of the concept. > > > > There is compatibility issue with line ending in Windows vs other OS > that's all I'm aware of. > The only issues I can think of off the top of my head would be line endings and indentation (tabs vs spaces, number of spaces for one level). The second would just require care to avoid issues to make sure you match the style guides for the files you are working on (the Python standard is 4 spaces, I believe). The first could be a silent issue with some editors and some versions of Python if crossing between Windows, Linux, and Mac, however most software (including Python) will now convert between the different forms automatically, and Notepad++ is good about its handling - it will create new newlines in the format of the file, if such can be determined. > > Amirouche > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From d at davea.name Thu Feb 23 17:43:48 2012 From: d at davea.name (Dave Angel) Date: Thu, 23 Feb 2012 17:43:48 -0500 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F46C124.2070102@davea.name> On 02/23/2012 05:13 PM, Manish Sharma wrote: > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. > > I hope this group is the best place to ask this. Please reply ! > > :) > Manish That is nonsense. I've used at least a dozen text editors, from Windows Notepad to emacs on Linux. And since I know of no program called "python editor," I'm sure none of them was that one. Of course, there are editors that are broken, or can be configured to be broken. I certainly wouldn't try wordpad, even in text mode. But a good editor with a good configuration can be much nicer to use than Notepad. First thing I'd do is to disable tab logic in the editor. When you press the tab key, there's no excuse for an editor to actually put a tab in the file. It should adjust the column by adding the appropriate number of spaces. The main place you get in trouble is when a file has tabs in some lines, and uses spaces for indenting on other lines. Since tabs are not interpreted the same way in various utilities, it's just better not to use them at all. As Amirouche has pointed out, line endings can be inconsistent between different operating systems, and not all editors can handle the differences. But the python compiler/interpreter doesn't care about which line ending is used. One other issue could be files that have non-ASCII characters. Since a text file has no standard way to indicate what format it uses (utf8, ucs2, or dozens of "extended ASCII" encodings), another editor might not deal with it correctly. There is a standard way to indicate to Python how to interpret non-ascii characters, so if you either 1) always use ASCII1 2) always use the same character encoding, or 3) have your editor look for the declaration and honor it, you'd have no trouble. If these problems do occur, they'll be pretty easy to spot. And you can always revert to an earlier version, by using your revision control system. Enabling one of those is about as important as choosing your editor. -- DaveA From steve+comp.lang.python at pearwood.info Thu Feb 23 18:33:39 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 23 Feb 2012 23:33:39 GMT Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> Message-ID: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 08:53:49 +1100, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle > wrote: >> _sentinel = object() >> >> def sum(iterable, start=_sentinel): >> ? ?if start is _sentinel: >> >> del _sentinel > > Somewhat off-topic: Doesn't the if statement there do a lookup for a > global, which would mean that 'del _sentinel' will cause it to fail? Or > have I missed something here? Yes, deleting _sentinel will cause the custom sum to fail, and yes, you have missed something. If the caller wants to mess with your library and break it, they have many, many ways to do so apart from deleting your private variables. del _sentinel _sentinel = "something else" sum.__defaults__ = (42,) # mess with the function defaults sum.__code__ = (lambda a, b=None: 100).__code__ # and with func internals sum = None # change your custom sum to something else del sum # or just delete it completely len = 42 # shadow a built-in import builtins; del builtins.range # really screw with you If your application stops working after you carelessly mess with components your application relies on, the right answer is usually: "Don't do that then." Python doesn't try to prevent people from shooting themselves in the foot. Monkey-patching-by-actual-monkeys-for-fun-and-profit-ly y'rs, -- Steven From rosuav at gmail.com Thu Feb 23 18:39:26 2012 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 24 Feb 2012 10:39:26 +1100 Subject: sum() requires number, not simply __add__ In-Reply-To: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 24, 2012 at 10:33 AM, Steven D'Aprano wrote: > Yes, deleting _sentinel will cause the custom sum to fail, and yes, you > have missed something. > > If the caller wants to mess with your library and break it, they have > many, many ways to do so apart from deleting your private variables. I was looking at the module breaking itself, though, not even waiting for the caller to do it. ChrisA From steve+comp.lang.python at pearwood.info Thu Feb 23 19:11:11 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 00:11:11 GMT Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f46d59f$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > On 23 f?v, 15:06, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> Following instructions here: >> >> http://docs.python.org/py3k/distutils/builtdist.html#creating- windows... >> >> I am trying to create a Windows installer for a pure-module >> distribution using Python 3.2. I get a "LookupError: unknown encoding: >> mbcs" [...] >> How do I fix this, and is it a bug in distutils? > > Because the 'mbcs' codec is missing in your Linux, :-) Well duh :-) This is a bug in distutils. Prompted by your comment I expanded my search terms and found this bug report: http://bugs.python.org/issue10945 The problem is that mbcs is not a real codec, it means "whatever codec is currently configured in Windows". So it doesn't exist on non-Windows platforms. But distutils bdist_wininst is explicitly documented as working on non-Windows platforms. Hence, it's a bug. -- Steven From richardbp at gmail.com Thu Feb 23 19:28:05 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 16:28:05 -0800 (PST) Subject: asynchronous downloading In-Reply-To: <7x4nuhlqmf.fsf@ruckus.brouhaha.com> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <7x4nuhlqmf.fsf@ruckus.brouhaha.com> Message-ID: <25425615.930.1330043285287.JavaMail.geo-discussion-forums@pbux2> My current implementation works fine below a few hundred threads. But each thread takes up a lot of memory so does not scale well. I have been looking at Erlang for that reason, but found it is missing useful libraries in other areas. From alex at moreati.org.uk Thu Feb 23 19:30:09 2012 From: alex at moreati.org.uk (Alex Willmer) Date: Thu, 23 Feb 2012 16:30:09 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty Message-ID: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> This week I was slightly surprised by a behaviour that I've not considered before. I've long used for i, x in enumerate(seq): # do stuff as a standard looping-with-index construct. In Python for loops don't create a scope, so the loop variables are available afterward. I've sometimes used this to print or return a record count e.g. for i, x in enumerate(seq): # do stuff print 'Processed %i records' % i+1 However as I found out, if seq is empty then i and x are never created. The above code will raise NameError. So if a record count is needed, and the loop is not guaranteed to execute the following seems more correct: i = 0 for x in seq: # do stuff i += 1 print 'Processed %i records' % i Just thought it worth mentioning, curious to hear other options/ improvements/corrections. From steve+comp.lang.python at pearwood.info Thu Feb 23 19:49:11 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 00:49:11 GMT Subject: distutils bdist_wininst failure on Linux References: <4f4647dd$0$29986$c3e8da3$5496439d@news.astraweb.com> <4f46d59f$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f46de87$0$29986$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 00:11:11 +0000, Steven D'Aprano wrote: > On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote: > >> On 23 f?v, 15:06, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: >>> Following instructions here: >>> >>> http://docs.python.org/py3k/distutils/builtdist.html#creating- > windows... >>> >>> I am trying to create a Windows installer for a pure-module >>> distribution using Python 3.2. I get a "LookupError: unknown encoding: >>> mbcs" > [...] >>> How do I fix this, and is it a bug in distutils? >> >> Because the 'mbcs' codec is missing in your Linux, :-) > > Well duh :-) > > This is a bug in distutils. Prompted by your comment I expanded my > search terms and found this bug report: > > http://bugs.python.org/issue10945 > > The problem is that mbcs is not a real codec, it means "whatever codec > is currently configured in Windows". So it doesn't exist on non-Windows > platforms. But distutils bdist_wininst is explicitly documented as > working on non-Windows platforms. Hence, it's a bug. And I have a work-around that seems to work for me. Put this at the top of your setup.py install script: # Work around mbcs bug in distutils. # http://bugs.python.org/issue10945 import codecs try: codecs.lookup('mbcs') except LookupError: ascii = codecs.lookup('ascii') func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs') codecs.register(func) -- Steven From steve+comp.lang.python at pearwood.info Thu Feb 23 20:08:58 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 01:08:58 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: > This week I was slightly surprised by a behaviour that I've not > considered before. I've long used > > for i, x in enumerate(seq): > # do stuff > > as a standard looping-with-index construct. In Python for loops don't > create a scope, so the loop variables are available afterward. I've > sometimes used this to print or return a record count e.g. > > for i, x in enumerate(seq): > # do stuff > print 'Processed %i records' % i+1 > > However as I found out, if seq is empty then i and x are never created. This has nothing to do with enumerate. It applies to for loops in general: the loop variable is not initialised if the loop never runs. What value should it take? Zero? Minus one? The empty string? None? Whatever answer Python choose would be almost always wrong, so it refuses to guess. > The above code will raise NameError. So if a record count is needed, and > the loop is not guaranteed to execute the following seems more correct: > > i = 0 > for x in seq: > # do stuff > i += 1 > print 'Processed %i records' % i What fixes the problem is not avoiding enumerate, or performing the increments in slow Python instead of fast C, but that you initialise the loop variable you care about before the loop in case it doesn't run. i = 0 for i,x in enumerate(seq): # do stuff is all you need: the addition of one extra line, to initialise the loop variable i (and, if you need it, x) before hand. -- Steven From richardbp at gmail.com Thu Feb 23 20:10:25 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 17:10:25 -0800 (PST) Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> that example is excellent - best use of asynchat I have seen so far. I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. From richardbp at gmail.com Thu Feb 23 20:10:25 2012 From: richardbp at gmail.com (Plumo) Date: Thu, 23 Feb 2012 17:10:25 -0800 (PST) Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> Message-ID: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> that example is excellent - best use of asynchat I have seen so far. I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. From no.email at nospam.invalid Thu Feb 23 20:21:32 2012 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 23 Feb 2012 17:21:32 -0800 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <7x7gzdyqjn.fsf@ruckus.brouhaha.com> Alex Willmer writes: > i = 0 > for x in seq: > # do stuff > i += 1 > print 'Processed %i records' % i > > Just thought it worth mentioning, curious to hear other options/ > improvements/corrections. Stephen gave an alternate patch, but you are right, it is a pitfall that can be easy to miss in simple testing. A more "functional programming" approach might be: def do_stuff(x): ... n_records = sum(1 for _ in imap(do_stuff, seq)) From milleja46 at gmail.com Thu Feb 23 20:57:24 2012 From: milleja46 at gmail.com (Joshua Miller) Date: Thu, 23 Feb 2012 20:57:24 -0500 Subject: Please verify!! In-Reply-To: <4F46E89F.4080506@davea.name> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <4F46E89F.4080506@davea.name> Message-ID: Wasn't supposed to be private, just something went funky with gmail when i sent it out, oddly enough On Thu, Feb 23, 2012 at 8:32 PM, Dave Angel wrote: > On 02/23/2012 07:15 PM, Joshua Miller wrote: >> >> When he/she said "python editor" i'm sure they meant IDLE which in >> some cases is the worst ide to use. Some ide's do mess with python >> files you just have to make sure to change their settings to >> accomadate python. Otherwise no it's a better idea to use ?something >> other than IDLE. For windows generally people use eclipse with the >> pydev extension, pyscripter, or the several other IDE's that are known >> with a little help not to do what you are describing ;) >> > > I can't argue with anything you say here. ?But you shouldn't have sent it > privately, as this is a public list. ?And please don't top-post > > So I'm forwarding it to the list. > > -- > > DaveA -- ~ Josh Miller A young guy learning to program and develop websites all while still in school From fayaz.yusuf.khan at gmail.com Thu Feb 23 21:31:09 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Thu, 23 Feb 2012 18:31:09 -0800 (PST) Subject: asynchronous downloading In-Reply-To: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: <8420126.Qz9UkS8bM5@dextop08> On Thursday 23 Feb 2012 5:10:25 PM Plumo wrote: > I read through the python-dev archives and found the fundamental problem is > no one maintains asnycore / asynchat. By all means, scratch your own itch. :) -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From bahamutzero8825 at gmail.com Thu Feb 23 22:45:24 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Thu, 23 Feb 2012 21:45:24 -0600 Subject: Please verify!! In-Reply-To: <4F46C124.2070102@davea.name> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <4F4707D4.9040401@gmail.com> On 2/23/2012 4:43 PM, Dave Angel wrote: > First thing I'd do is to disable tab logic in the editor. When you > press the tab key, there's no excuse for an editor to actually put a tab > in the file. It should adjust the column by adding the appropriate > number of spaces. Unless, of course, you know, you actually /want/ to use tabs (the horror!). The decision whether to use tabs or spaces shouldn't be made for the novice programmer. Make an argument, explain the advantages/disadvantages, whatever, but don't state your opinion like it's fact. Even worse, you brought it up in the context of editor issues, making it sound like using tabs is a common source of problems. Much of it is personal preference (I could give objective reasons in support of tabs in Python, but I don't intend to start the whole spaces vs. tabs discussion again). > The main place you get in trouble is when a file has > tabs in some lines, and uses spaces for indenting on other lines. I wouldn't call it the main problem, but yes, that happens. It's not terribly difficult to convert all indentation to tabs or spaces (unless the number of spaces used to indent is inconsistent). > As Amirouche has pointed out, line endings can be inconsistent between > different operating systems, and not all editors can handle the > differences. But the python compiler/interpreter doesn't care about > which line ending is used. Yes. However, there are many editors for various platforms that handle the different line endings just fine. In fact, Notepad is the only editor I can think of off the top of my head that has an issue. > One other issue could be files that have non-ASCII characters. Since a > text file has no standard way to indicate what format it uses (utf8, > ucs2, or dozens of "extended ASCII" encodings), another editor might not > deal with it correctly. There is a standard way to indicate to Python > how to interpret non-ascii characters, so if you either 1) always use > ASCII1 2) always use the same character encoding, or 3) have your editor > look for the declaration and honor it, you'd have no trouble. I recommend using UTF-8 always unless there's some reason not to. > If these problems do occur, they'll be pretty easy to spot. And you can > always revert to an earlier version, by using your revision control > system. Enabling one of those is about as important as choosing your > editor. I don't think you can really go wrong outside of Git, Bazaar, or Mercurial. Which of those 3 is best is mainly personal preference. CVS/SVN should be considered legacy and not suitable for new projects. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From ethan at stoneleaf.us Thu Feb 23 22:49:01 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 23 Feb 2012 19:49:01 -0800 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4708AD.1020805@stoneleaf.us> Steven D'Aprano wrote: > On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: > >> This week I was slightly surprised by a behaviour that I've not >> considered before. I've long used >> >> for i, x in enumerate(seq): >> # do stuff >> >> as a standard looping-with-index construct. In Python for loops don't >> create a scope, so the loop variables are available afterward. I've >> sometimes used this to print or return a record count e.g. >> >> for i, x in enumerate(seq): >> # do stuff >> print 'Processed %i records' % i+1 >> >> However as I found out, if seq is empty then i and x are never created. > > This has nothing to do with enumerate. It applies to for loops in > general: the loop variable is not initialised if the loop never runs. > What value should it take? Zero? Minus one? The empty string? None? > Whatever answer Python choose would be almost always wrong, so it refuses > to guess. > > >> The above code will raise NameError. So if a record count is needed, and >> the loop is not guaranteed to execute the following seems more correct: >> >> i = 0 >> for x in seq: >> # do stuff >> i += 1 >> print 'Processed %i records' % i > > What fixes the problem is not avoiding enumerate, or performing the > increments in slow Python instead of fast C, but that you initialise the > loop variable you care about before the loop in case it doesn't run. > > i = 0 > for i,x in enumerate(seq): > # do stuff > > is all you need: the addition of one extra line, to initialise the loop > variable i (and, if you need it, x) before hand. Actually, i = -1 or his reporting will be wrong. ~Ethan~ From wangbo.red at gmail.com Fri Feb 24 00:55:02 2012 From: wangbo.red at gmail.com (xixiliguo) Date: Thu, 23 Feb 2012 21:55:02 -0800 (PST) Subject: namespace question Message-ID: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] def add( self ): c[0] = 15 a = TEST() a.add() print( c, a.c, TEST.c ) result : [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] why a.add() do not update c in Class TEST? but update c in main file From wm at localhost.localdomain Fri Feb 24 01:21:47 2012 From: wm at localhost.localdomain (Waldek M.) Date: Fri, 24 Feb 2012 07:21:47 +0100 Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> Message-ID: <18zvco3fybo0d$.dlg@localhost.localdomain> On Wed, 22 Feb 2012 18:42:11 +0100, J?r?me wrote: >>> Has anyone had success generating exe's from within Linux? >> >> That doesn't seem to have anything to do with Python, >> but you might want to google for cross-compiling. > > I think his question is totally python related. > > As I understand it, Richard creates executables from python scripts using a > tool, such as py2exe [1], that requires windows. He would like to have an > equivalent tool that runs on linux, to avoid going through the trouble of > having to run a windows installation. Ah, that's the part I was missing :-) Thanks. Waldek From clp2 at rebertia.com Fri Feb 24 01:35:07 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 23 Feb 2012 22:35:07 -0800 Subject: namespace question In-Reply-To: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: On Thu, Feb 23, 2012 at 9:55 PM, xixiliguo wrote: > c = [1, 2, 3, 4, 5] > class TEST(): > ? ?c = [5, 2, 3, 4, 5] That line creates a class (i.e. "static") variable, which is unlikely to be what you want. Instance variables are normally created in the body of an __init__() method. > ? ?def add( self ): > ? ? ? ?c[0] = 15 > > a = TEST() > > > a.add() > > print( c, a.c, TEST.c ) > > result : > [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] > > > why a.add() do not update c in Class TEST? but update c in main file Python is not Java (or similar). To refer to instance variables, you must explicitly use `self`; i.e. use "self.c[0] = 15" in add(). I would recommend reviewing the relevant section of the Python tutorial: http://docs.python.org/tutorial/classes.html Cheers, Chris From renukasendhilkumar at gmail.com Fri Feb 24 01:57:35 2012 From: renukasendhilkumar at gmail.com (siva kumar) Date: Thu, 23 Feb 2012 22:57:35 -0800 (PST) Subject: variables are available Message-ID: <9022afb4-3aaa-4486-ae15-cb1191f00515@pi3g2000pbb.googlegroups.com> In Python for loops don't create a scope, so the loop variables are available afterward. I've sometimes used this to print or return a record count This release ist mostly about security and bug fixes and a few minor changes ( including Python 2.7 compatibility). For details see: [link] See [link] for the release ... http://123maza.com/46/share781/ From breamoreboy at yahoo.co.uk Fri Feb 24 02:10:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 07:10:39 +0000 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4F4708AD.1020805@stoneleaf.us> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F4708AD.1020805@stoneleaf.us> Message-ID: On 24/02/2012 03:49, Ethan Furman wrote: > Steven D'Aprano wrote: >> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: >> >>> This week I was slightly surprised by a behaviour that I've not >>> considered before. I've long used >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> >>> as a standard looping-with-index construct. In Python for loops don't >>> create a scope, so the loop variables are available afterward. I've >>> sometimes used this to print or return a record count e.g. >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> print 'Processed %i records' % i+1 >>> >>> However as I found out, if seq is empty then i and x are never created. >> >> This has nothing to do with enumerate. It applies to for loops in >> general: the loop variable is not initialised if the loop never runs. >> What value should it take? Zero? Minus one? The empty string? None? >> Whatever answer Python choose would be almost always wrong, so it >> refuses to guess. >> >> >>> The above code will raise NameError. So if a record count is needed, and >>> the loop is not guaranteed to execute the following seems more correct: >>> >>> i = 0 >>> for x in seq: >>> # do stuff >>> i += 1 >>> print 'Processed %i records' % i >> >> What fixes the problem is not avoiding enumerate, or performing the >> increments in slow Python instead of fast C, but that you initialise >> the loop variable you care about before the loop in case it doesn't run. >> >> i = 0 >> for i,x in enumerate(seq): >> # do stuff >> >> is all you need: the addition of one extra line, to initialise the >> loop variable i (and, if you need it, x) before hand. > > Actually, > > i = -1 > > or his reporting will be wrong. > > ~Ethan~ Methinks an off by one error :) -- Cheers. Mark Lawrence. From manish2aug at gmail.com Fri Feb 24 02:11:19 2012 From: manish2aug at gmail.com (Manish Sharma) Date: Fri, 24 Feb 2012 09:11:19 +0200 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: Hi All, Thanks a ton for your replies! Still my question is what if I open the file and dont make any changes to it and close it again? Can it be possible just by doing these steps add indentation to lines? I am not changing the file prefrences to open it always with notepad++. Opening it once only. On Fri, Feb 24, 2012 at 6:08 AM, Jason Friedman wrote: > > Hi I am new to python language. On my first day, somebody told me that > > if any python script file is opened with any editor except python > > editor, the file is corrupted. Some spacing or indentation is changed > > and script stops working. I was opening the script file in Windows > > using Notepad++ but I didn't save anything and closed it. Still it was > > suggested to never open the python file in any other editor. > > It is possible that the OP is not aware of that Python is space > sensitive, unlike most(?) programming languages. > > for i in range(5): > print("Hello.") > print("Goodbye.") > > will not run because the indentation (leading spaces) on the third > line is incorrect. It must instead line up with the second line. > > A single tab is equivalent to a single space as far as Python is > concerned, but your eyes will report a difference and editors that > substitute one for the other can cause, after saving, code that was > formerly working to not work (and, I suppose, the reverse). > > Make sure to read the tutorial at http://python.org (which is > unfortunately down at this moment > (http://www.downforeveryoneorjustme.com/python.org)). > -- ------------------------- Thanks & Regards Manish Kumar | Mob: +91-9911635906 | manish2aug at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From bahamutzero8825 at gmail.com Fri Feb 24 02:26:36 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 01:26:36 -0600 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F473BAC.8070905@gmail.com> On 2/24/2012 1:11 AM, Manish Sharma wrote: > Still my question is what if I open the file and dont make any changes > to it and close it again? Can it be possible just by doing these steps > add indentation to lines? I am not changing the file prefrences to open > it always with notepad++. Opening it once only. Notepad++ won't change line endings or indentation unless you tell it to. In any case, it will indicate when a file has been changed (the little blue disk icon in the file's tab will turn red). -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From smallpox911 at gmail.com Fri Feb 24 02:38:05 2012 From: smallpox911 at gmail.com (small Pox) Date: Thu, 23 Feb 2012 23:38:05 -0800 (PST) Subject: Is Federal Reserve a Private Property or Public Property ? Exhilerating video by Honorable Alex Jones Message-ID: <76546146-601f-47dd-9bd5-762144ddeadd@f4g2000yqh.googlegroups.com> Is Federal Reserve a Private Property or Public Property ? Exhilerating video by Honorable Alex Jones ........ http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27... gnu.emacs.help,soc.culture.jewish,sci.electronics.design,comp.lang.scheme,comp.lang.python From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Fri Feb 24 02:47:55 2012 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Fri, 24 Feb 2012 08:47:55 +0100 Subject: Just curious: why is /usr/bin/python not a symlink? In-Reply-To: References: Message-ID: Am 23.02.2012 20:54 schrieb Jerry Hill: > If I recall > correctly, for directories, that's the number of entries in the > directory. No. It is the number of subdirectories (it counts their ".." entries) plus 2 (the parent directory and the own "." entry). > Even with that, it's hard to tell what files are hardlinked together, > and figuring it out by inode is a pain in the neck. Personally, I > prefer symlinks, even if they introduce a small performance hit. Not only that, they have slightly different semantics. With hardlinks you can say "I want this file, no matter if someone else holds it as well". Symlinks say "I want the file which is referred to by there". In the given case, however, this difference doesn't count, and I agree on you that a symlink would be better here. Thomas From __peter__ at web.de Fri Feb 24 03:29:20 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 09:29:20 +0100 Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Buck Golemon wrote: > I feel like the design of sum() is inconsistent with other language > features of python. Often python doesn't require a specific type, only > that the type implement certain methods. > > Given a class that implements __add__ why should sum() not be able to > operate on that class? > > We can fix this in a backward-compatible way, I believe. > > Demonstration: > I'd expect these two error messages to be identical, but they are > not. > > >>> class C(object): pass > >>> c = C() > >>> sum((c,c)) > TypeError: unsupported operand type(s) for +: 'int' and 'C' > >>> c + c > TypeError: unsupported operand type(s) for +: 'C' and 'C' You could explicitly provide a null object: >>> class Null(object): ... def __add__(self, other): ... return other ... >>> null = Null() >>> class A(object): ... def __init__(self, v): ... self.v = v ... def __add__(self, other): ... return A("%s+%s" % (self, other)) ... def __str__(self): ... return self.v ... def __repr__(self): ... return "A(%r)" % self. v ... >>> sum(map(A, "abc")) Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'A' >>> sum(map(A, "abc"), null) A('a+b+c') From ben+python at benfinney.id.au Fri Feb 24 03:32:55 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Fri, 24 Feb 2012 19:32:55 +1100 Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <87mx88tyvc.fsf@benfinney.id.au> Andrew Berg writes: > On 2/23/2012 4:43 PM, Dave Angel wrote: > > First thing I'd do is to disable tab logic in the editor. When you > > press the tab key, there's no excuse for an editor to actually put a tab > > in the file. It should adjust the column by adding the appropriate > > number of spaces. > Unless, of course, you know, you actually /want/ to use tabs (the > horror!). The decision whether to use tabs or spaces shouldn't be made > for the novice programmer. Those two positions yo describe are in conflict. Are you referring to novice programmers ? who, by any reasonable definition of ?novice?, don't have an opinion on the tabs-versus-spaces indentation debate? Or are you talking about people who are experienced enough to have an opinion and expect their editor to allow them the choice? > I recommend using UTF-8 always unless there's some reason not to. Likewise, I recommend using spaces for indentation always, unless there's some reason not to. The reason is the same: spaces for indentation and UTF-8 for encoding will both allow them the best chance of ignoring the issue as irrelevant, by enabling the smoothest collaboration with the vast majority of other programmers who have to work with them. And in both those issues, I think it's ludicrous to expect the novice programmer to care enough about the matter to have an opinion and select a configuration option. The editor authors should choose the best option for them as a default, and let most users sail on, happily ignorant of the flame wars they have avoided. -- \ ?In the long run nothing can withstand reason and experience, | `\ and the contradiction which religion offers to both is all too | _o__) palpable.? ?Sigmund Freud | Ben Finney From jaroslav.dobrek at gmail.com Fri Feb 24 03:41:21 2012 From: jaroslav.dobrek at gmail.com (Jaroslav Dobrek) Date: Fri, 24 Feb 2012 00:41:21 -0800 (PST) Subject: subtraction of floating point numbers Message-ID: Hello, when I have Python subtract floating point numbers it yields weird results. Example: 4822.40 - 4785.52 = 36.8799999999992 Why doesn't Python simply yield the correct result? It doesn't have a problem with this: 482240 - 478552 = 3688 Can I tell Python in some way to do this differently? Jaroslav From __peter__ at web.de Fri Feb 24 03:44:05 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 09:44:05 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <4f46e329$0$29986$c3e8da3$5496439d@news.astraweb.com> <4F4708AD.1020805@stoneleaf.us> Message-ID: Ethan Furman wrote: > Steven D'Aprano wrote: >> On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: >> >>> This week I was slightly surprised by a behaviour that I've not >>> considered before. I've long used >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> >>> as a standard looping-with-index construct. In Python for loops don't >>> create a scope, so the loop variables are available afterward. I've >>> sometimes used this to print or return a record count e.g. >>> >>> for i, x in enumerate(seq): >>> # do stuff >>> print 'Processed %i records' % i+1 >>> >>> However as I found out, if seq is empty then i and x are never created. >> >> This has nothing to do with enumerate. It applies to for loops in >> general: the loop variable is not initialised if the loop never runs. >> What value should it take? Zero? Minus one? The empty string? None? >> Whatever answer Python choose would be almost always wrong, so it refuses >> to guess. >> >> >>> The above code will raise NameError. So if a record count is needed, and >>> the loop is not guaranteed to execute the following seems more correct: >>> >>> i = 0 >>> for x in seq: >>> # do stuff >>> i += 1 >>> print 'Processed %i records' % i >> >> What fixes the problem is not avoiding enumerate, or performing the >> increments in slow Python instead of fast C, but that you initialise the >> loop variable you care about before the loop in case it doesn't run. >> >> i = 0 >> for i,x in enumerate(seq): >> # do stuff >> >> is all you need: the addition of one extra line, to initialise the loop >> variable i (and, if you need it, x) before hand. > > Actually, > > i = -1 > > or his reporting will be wrong. Yes, either i = -1 for i, x in enumerate(seq): ... print "%d records" % (i+1) or i = 0 for i, x in enumerate(seq, 1): ... print "%d records" % i From alain at dpt-info.u-strasbg.fr Fri Feb 24 03:49:15 2012 From: alain at dpt-info.u-strasbg.fr (Alain Ketterlin) Date: Fri, 24 Feb 2012 09:49:15 +0100 Subject: subtraction of floating point numbers References: Message-ID: <87pqd462gk.fsf@dpt-info.u-strasbg.fr> Jaroslav Dobrek writes: > when I have Python subtract floating point numbers it yields weird > results. Example: > > 4822.40 - 4785.52 = 36.8799999999992 We've had this discussion here one or two days ago... The usual answer is: please read "What Every Computer Scientist Should Know About Floating Point Arithmetic", at: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.22.6768 and check the answers posted these last days. In brief: you're working with floating point numbers, not reals (i.e., real "reals"). That's life. Deal with it, or move to specialized packages, like decimal. -- Alain. From g.rodola at gmail.com Fri Feb 24 04:03:45 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Fri, 24 Feb 2012 10:03:45 +0100 Subject: asynchronous downloading In-Reply-To: <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: Il 24 febbraio 2012 02:10, Plumo ha scritto: > that example is excellent - best use of asynchat I have seen so far. > > I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. Well, actually I do/did. Point with asyncore/asynchat is that it's original design is so flawed and simplicistic it doesn't allow actual customization without breaking compatibility. See for example: http://bugs.python.org/issue6692 --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ From bahamutzero8825 at gmail.com Fri Feb 24 04:18:18 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 03:18:18 -0600 Subject: Please verify!! In-Reply-To: <87mx88tyvc.fsf@benfinney.id.au> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> Message-ID: <4F4755DA.10707@gmail.com> On 2/24/2012 2:32 AM, Ben Finney wrote: > Are you referring to novice programmers ? who, by any reasonable > definition of ?novice?, don't have an opinion on the tabs-versus-spaces > indentation debate? > > Or are you talking about people who are experienced enough to have an > opinion and expect their editor to allow them the choice? The former. Opinion doesn't necessarily come with experience - habit will usually override any minor reason to change. My point is that one should have an opinion on it, not just be told which is better. I should clarify that I mean that in a general sense as well, since it may have come across as a bit of an overreaction. > The reason is the same: spaces for indentation and UTF-8 for encoding > will both allow them the best chance of ignoring the issue as > irrelevant, by enabling the smoothest collaboration with the vast > majority of other programmers who have to work with them. If by that, you mean that using spaces is better because it's what the majority of programmers use, and it makes things much smoother when working with others, then I agree. When working in a team, it's definitely not something to argue over. > And in both those issues, I think it's ludicrous to expect the novice > programmer to care enough about the matter to have an opinion and select > a configuration option. The editor authors should choose the best option > for them as a default, and let most users sail on, happily ignorant of > the flame wars they have avoided. A valid point. I think one should have an opinion, but I can see why one would avoid the issue. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From clp2 at rebertia.com Fri Feb 24 05:16:29 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 24 Feb 2012 02:16:29 -0800 Subject: subtraction of floating point numbers In-Reply-To: References: Message-ID: On Fri, Feb 24, 2012 at 12:41 AM, Jaroslav Dobrek wrote: > Hello, > > when I have Python subtract floating point numbers it yields weird > results. Example: > > 4822.40 - 4785.52 = 36.8799999999992 > > Why doesn't Python simply yield the correct result? It doesn't have a > problem with this: > > 482240 - 478552 = 3688 > > Can I tell Python in some way to do this differently? Refer to this thread from 2 days ago: http://mail.python.org/pipermail/python-list/2012-February/1288344.html Regards, Chris From ssmile03 at gmail.com Fri Feb 24 05:45:47 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Fri, 24 Feb 2012 16:15:47 +0530 Subject: storing in list and retrieving. In-Reply-To: <4F461575.5000906@sequans.com> References: <4F461575.5000906@sequans.com> Message-ID: Thanks. It was very simple with using 'pickle'. Thanks. ---------- On Thu, Feb 23, 2012 at 4:01 PM, Jean-Michel Pichavant < jeanmichel at sequans.com> wrote: > Smiley 4321 wrote: > >> It requires concepts of 'python persistence' for the code to be designed . >> >> Else it simple. >> >> Looking for some flow?? >> ---- >> > Hi, > > Have a look at http://docs.python.org/**library/pickle.html > > Cheers, > > JM > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jugurtha.hadjar at gmail.com Fri Feb 24 06:10:27 2012 From: jugurtha.hadjar at gmail.com (Jugurtha Hadjar) Date: Fri, 24 Feb 2012 12:10:27 +0100 Subject: Please verify!! In-Reply-To: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> Message-ID: <4F477023.8020405@gmail.com> On 23/02/2012 23:13, Manish Sharma wrote: > Hi I am new to python language. On my first day, somebody told me that > if any python script file is opened with any editor except python > editor, the file is corrupted. Some spacing or indentation is changed > and script stops working. I was opening the script file in Windows > using Notepad++ but I didn't save anything and closed it. Still it was > suggested to never open the python file in any other editor. > > Can anybody please verify this? Can opening a python script in any > editor other than python editor corrupt the script? Did anybody ever > face such type of issue or its just misunderstanding of the concept. > > I hope this group is the best place to ask this. Please reply ! > > :) > Manish I don't think so, I have used EDIT, Notepad, Notepad++ and they all work fine. PS: What's the "python editor" you were advised to stick with, by the way ? -- ~Jugurtha Hadjar, From duncan.booth at invalid.invalid Fri Feb 24 06:21:58 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 24 Feb 2012 11:21:58 GMT Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: Andrew Berg wrote: > Yes. However, there are many editors for various platforms that handle > the different line endings just fine. In fact, Notepad is the only > editor I can think of off the top of my head that has an issue. The original question was about Notepad++ which is nothing at all like Notepad. -- Duncan Booth http://kupuguy.blogspot.com From bahamutzero8825 at gmail.com Fri Feb 24 06:36:29 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 05:36:29 -0600 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> Message-ID: <4F47763D.8010007@gmail.com> On 2/24/2012 5:21 AM, Duncan Booth wrote: > The original question was about Notepad++ which is nothing at all like > Notepad. And I did give the OP an answer about Notepad++ specifically in another message. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From duncan.booth at invalid.invalid Fri Feb 24 06:40:10 2012 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 24 Feb 2012 11:40:10 GMT Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> Message-ID: Stefan Behnel wrote: > I know that you just meant this as an example, but it's worth > mentioning in this context that it's not exactly efficient to "sum up" > lists this way because there is a lot of copying involved. Each adding > of two lists creates a third one and copies all elements into it. So > it eats a lot of time and space. If you search back through this group far enough you can find an alternative implementation of sum that I suggested which doesn't have the same performance problem with lists or strings and also improves the accuracy of the result with floats. In effect what it does is instead of: (((((a + b) + c) + d) + e) + f) it calculates the sum as: ((a + b) + (c + d)) + (e + f) i.e. in as balanced a manner as it can given that it still has to work from left to right. Of course that could still change the final result for some user defined types and never having converted my code to C I have no idea whether or not the performance for the intended case would be competitive with the builtin sum though I don't see why it wouldn't be. -- Duncan Booth http://kupuguy.blogspot.com From antoon.pardon at rece.vub.ac.be Fri Feb 24 06:41:32 2012 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Fri, 24 Feb 2012 12:41:32 +0100 Subject: sum() requires number, not simply __add__ In-Reply-To: <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F47776C.4040300@rece.vub.ac.be> On 02/24/2012 12:33 AM, Steven D'Aprano wrote: > If your application stops working after you carelessly mess with > components your application relies on, the right answer is usually: > > "Don't do that then." > > Python doesn't try to prevent people from shooting themselves in the foot. > Yes it does! A simple example is None as a keyword to prevent assignments to it. -- Antoon Pardon From jeanmichel at sequans.com Fri Feb 24 06:56:01 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Fri, 24 Feb 2012 12:56:01 +0100 Subject: namespace question In-Reply-To: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: <4F477AD1.4040304@sequans.com> xixiliguo wrote: > c = [1, 2, 3, 4, 5] > class TEST(): > c = [5, 2, 3, 4, 5] > def add( self ): > c[0] = 15 > > a = TEST() > > > a.add() > > print( c, a.c, TEST.c ) > > result : > [15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5] > > > why a.add() do not update c in Class TEST? but update c in main file > Attributes can only accessed by explictly naming the owner, unlike some other languages which infer 'this/self'. When an attribute is not found in the owner, python may look into the "outer" namespace. Read the python documentation for an accurate description. Here is an illustration (python 2.5): c='global' class TEST(): c = 'class' d = 'classonly' def __init__(self): self.c='instance' def test(self): print c print TEST.c print self.c print self.d # this is valid, if d is not found in the instance, python will look into the class t = TEST() t.test() global class instance classonly Note that objects in python are properly named namespaces. locals and globals are not, so be careful while naming those (in few words: don't use globals) c = 'global' def foo(): c = 'local' print c # same name for 2 different objects def bar(): print c global c # the global statement is quite strange, it applies to the whole block, even previous statements, ppl usually put it at the begining of the block though foo() bar() 'local' 'global' Cheers, JM From steve+comp.lang.python at pearwood.info Fri Feb 24 07:20:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 12:20:27 GMT Subject: Please verify!! References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> Message-ID: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 03:18:18 -0600, Andrew Berg wrote: > On 2/24/2012 2:32 AM, Ben Finney wrote: >> Are you referring to novice programmers ? who, by any reasonable >> definition of ?novice?, don't have an opinion on the tabs-versus-spaces >> indentation debate? >> >> Or are you talking about people who are experienced enough to have an >> opinion and expect their editor to allow them the choice? > > The former. Opinion doesn't necessarily come with experience - habit > will usually override any minor reason to change. My point is that one > should have an opinion on it, not just be told which is better. I should > clarify that I mean that in a general sense as well, since it may have > come across as a bit of an overreaction. "My opinion is that we shouldn't use either tabs or spaces, but capital Zs instead, 'cos I like Zs and we don't use enough of them!" Opinions need to be informed to be better than useless. By definition newbies don't have the experience to have informed opinions. You are encouraging people who lack the experience to make an informed decision to take sides in the "tabs vs spaces" question on the basis of... what? Gut feeling? Astrology? Feng shui? Whether they find it easy to say the word "space" or have a lisp and prefer "tab" instead? There are many times that we can't afford to sit on the fence. Lacking experience to decide between spaces and tabs, we can't just say "I won't use either", or "I'll use both" (unless you do so in separate files). So how can we make a decision? The usual way is to listen to others, who do have the experience to make a decision (even if only imperfectly). But you've just told us off for passing on our experience/opinions to newbies, so in effect you're saying that people shouldn't learn from the experiences of others. That, I think, is a terrible philosophy. Life is too short to gain an opinion for ourselves about everything, and too difficult to sit on the fence. The right way is to encourage newbies to listen to the arguments put forth, and *then* make up their own mind, or in the absence of easily understood arguments (let's face it, many technical decisions only make sense after years of study, experience or careful reasoning) on the basis of any consensus amongst experts. Often there may be no absolutely right or wrong answers. Personally, I prefer tabs for theoretical reasons and spaces for practical ones. I think that the world would be better off if we all standardised on tabs instead of spaces, but since that's not going to happen, I can interoperate better with the mass of broken tools out there, and with other people, by using spaces. I wonder whether Windows users tend to be more sympathetic to tabs than Unix/Linux users, and if so, I wonder what if anything that means. -- Steven From steve+comp.lang.python at pearwood.info Fri Feb 24 07:25:49 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 12:25:49 GMT Subject: Does turtledemo in Python 3.2 actually work? Message-ID: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Python 3.2 includes turtledemo, a demonstration program for the turtle module. When I run it, I can load the turtle scripts, and the GUI application says "Press the start button", but there is no start button. Can anyone else confirm this as a bug? http://docs.python.org/py3k/library/turtle.html#demo-scripts -- Steven From rantingrickjohnson at gmail.com Fri Feb 24 07:32:29 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 04:32:29 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> Message-ID: <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> On Feb 23, 6:30?pm, Alex Willmer wrote: > [...] > as a standard looping-with-index construct. In Python for loops don't > create a scope, so the loop variables are available afterward. I've > sometimes used this to print or return a record count e.g. > > for i, x in enumerate(seq): > ? ?# do stuff > print 'Processed %i records' % i+1 You could employ the "else clause" of "for loops" to your advantage; (psst: which coincidentally are working pro-bono in this down economy!) >>> for x in []: ... print x ... else: ... print 'Empty Iterable' Empty Iterable >>> for i,o in enumerate([]): ... print i, o ... else: ... print 'Empty Iterable' Empty Iterable From arnodel at gmail.com Fri Feb 24 07:40:05 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 24 Feb 2012 12:40:05 +0000 Subject: Does turtledemo in Python 3.2 actually work? In-Reply-To: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24 February 2012 12:25, Steven D'Aprano wrote: > Python 3.2 includes turtledemo, a demonstration program for the turtle > module. > > When I run it, I can load the turtle scripts, and the GUI application > says "Press the start button", but there is no start button. > > Can anyone else confirm this as a bug? > > http://docs.python.org/py3k/library/turtle.html#demo-scripts Just tested with Python 3.2.1 on Mac OS X 10.6.8 and all seems fine. Perhaps if you say which platform it's failing on, others will be able to reproduce the failure on the same platform? -- Arnaud From __peter__ at web.de Fri Feb 24 07:44:15 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 13:44:15 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: Rick Johnson wrote: > On Feb 23, 6:30 pm, Alex Willmer wrote: >> [...] >> as a standard looping-with-index construct. In Python for loops don't >> create a scope, so the loop variables are available afterward. I've >> sometimes used this to print or return a record count e.g. >> >> for i, x in enumerate(seq): >> # do stuff >> print 'Processed %i records' % i+1 > > You could employ the "else clause" of "for loops" to your advantage; >>>> for x in []: > ... print x > ... else: > ... print 'Empty Iterable' > Empty Iterable > >>>> for i,o in enumerate([]): > ... print i, o > ... else: > ... print 'Empty Iterable' > Empty Iterable No: >>> for i in []: ... pass ... else: ... print "else" ... else >>> for i in [42]: ... pass ... else: ... print "else" ... else >>> for i in [42]: ... break ... else: ... print "else" ... >>> The code in the else suite executes only when the for loop is left via break. A non-empty iterable is required but not sufficient. From __peter__ at web.de Fri Feb 24 08:14:12 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 14:14:12 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: Peter Otten wrote: > The code in the else suite executes only when the for loop is left via > break. Oops, the following statement is nonsense: > A non-empty iterable is required but not sufficient. Let me try again: A non-empty iterable is required but not sufficient to *skip* the else-suite of a for loop. From roy at panix.com Fri Feb 24 08:17:25 2012 From: roy at panix.com (Roy Smith) Date: Fri, 24 Feb 2012 08:17:25 -0500 Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: In article , Thomas Rachel wrote: > Not only that, [hard and symbolic links] have slightly different > semantics. This is true, but only for very large values of "slightly". Symlinks, for example, can cross file system boundaries (including NFS mount points). Symlinks can refer to locations that don't exist! For example: ~$ ln -s foobar foo ~$ ls -l foo lrwxr-xr-x 1 roy staff 6 Feb 24 08:15 foo -> foobar ~$ cat foo cat: foo: No such file or directory Symlinks can be chained (i.e. a symlink points to someplace which in turn is another symlink). They're really very different beasts. From bahamutzero8825 at gmail.com Fri Feb 24 08:20:40 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Fri, 24 Feb 2012 07:20:40 -0600 Subject: Please verify!! In-Reply-To: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F478EA8.40103@gmail.com> On 2/24/2012 6:20 AM, Steven D'Aprano wrote: > Opinions need to be informed to be better than useless. By definition > newbies don't have the experience to have informed opinions. I thought I had implied that I meant informed opinions, but apparently not. > There are many times that we can't afford to sit on the fence. Lacking > experience to decide between spaces and tabs, we can't just say "I won't > use either", or "I'll use both" (unless you do so in separate files). So > how can we make a decision? > > The usual way is to listen to others, who do have the experience to make > a decision (even if only imperfectly). But you've just told us off for > passing on our experience/opinions to newbies, so in effect you're saying > that people shouldn't learn from the experiences of others. I don't mean that no one should ever give an opinion. Saying you prefer spaces because you've had to deal with broken editors that don't handle tabs well is quite different from saying an editor is wrong/broken if it isn't using space-tabs. Giving an opinion and presenting an argument are perfectly fine; I don't agree with calling things inherently wrong if they aren't what you prefer. I had (and have) no problem with Dave preferring spaces and giving reasons. I have a problem with him implying that editors should always use space-tabs and never real tabs, especially in the context of this thread. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From roy at panix.com Fri Feb 24 08:23:54 2012 From: roy at panix.com (Roy Smith) Date: Fri, 24 Feb 2012 08:23:54 -0500 Subject: sum() requires number, not simply __add__ References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Antoon Pardon wrote: > > Python doesn't try to prevent people from shooting themselves in the foot. > > > Yes it does! A simple example is None as a keyword to prevent > assignments to it. Hmmm. Just playing around with some bizarre things to do with None, and discovered this: >>> import sys as None doesn't give an error, but also doesn't assign the module to the symbol 'None'. Weird. From rantingrickjohnson at gmail.com Fri Feb 24 08:37:31 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 05:37:31 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! Message-ID: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> I get sick and tired of doing this!!! if maxlength == UNLIMITED: allow_passage() elif len(string) > maxlength: deny_passage() What Python needs is some constant that can be compared to ANY numeric type and that constant will ALWAYS be larger! From breamoreboy at yahoo.co.uk Fri Feb 24 08:55:17 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 13:55:17 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: On 24/02/2012 13:37, Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string)> maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! > > > Do you want to test for something that is larger than infinity? -- Cheers. Mark Lawrence. From rantingrickjohnson at gmail.com Fri Feb 24 09:14:04 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 06:14:04 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <588007c5-a523-4099-9d9f-e74f1845a775@c21g2000yqi.googlegroups.com> On Feb 24, 7:55?am, Mark Lawrence wrote: > Do you want to test for something that is larger than infinity? Not exactly. I want to set a constant that has a value of infinity and then do comparisons against the constant. ################## # Hypothetical 1 # ################## def confine(string, maxlength=INFINITY): return string[:maxlength] py> confine('123') '123' py> confine('123', 1) '1' ################## # Hypothetical 2 # ################## def confine(string, maxlength=INFINITY): if len(string) < maxlength: do_something() else: twiddle_thumbs() From neilc at norwich.edu Fri Feb 24 09:25:56 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 24 Feb 2012 14:25:56 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <9qpkvkFberU1@mid.individual.net> On 2012-02-24, Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY > numeric type and that constant will ALWAYS be larger! What's the point of that? The only time I've naively pined for such a thing is when misapplying C idioms for finding a minimum value. Python provides an excellent min implementation to use instead. -- Neil Cerutti From miki.tebeka at gmail.com Fri Feb 24 09:39:04 2012 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Fri, 24 Feb 2012 06:39:04 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <10970272.10872.1330094344998.JavaMail.geo-discussion-forums@ynbo36> float('infinity') should be good enough. From steve+comp.lang.python at pearwood.info Fri Feb 24 09:54:22 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 14:54:22 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> Message-ID: <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 13:44:15 +0100, Peter Otten wrote: >>>> for i in []: > ... pass > ... else: > ... print "else" > ... > else >>>> for i in [42]: > ... pass > ... else: > ... print "else" > ... > else >>>> for i in [42]: > ... break > ... else: > ... print "else" > ... >>>> >>>> > The code in the else suite executes only when the for loop is left via > break. A non-empty iterable is required but not sufficient. You have a typo there. As your examples show, the code in the else suite executes only when the for loop is NOT left via break (or return, or an exception). The else suite executes regardless of whether the iterable is empty or not. for...else is a very useful construct, but the name is misleading. It took me a long time to stop thinking that the else clause executes when the for loop was empty. In Python 4000, I think for loops should be spelled: for name in iterable: # for block then: # only if not exited with break else: # only if iterable is empty and likewise for while loops. Unfortunately we can't do the same now, due to the backward-incompatible change in behaviour for "else". -- Steven From arnodel at gmail.com Fri Feb 24 10:00:16 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Fri, 24 Feb 2012 15:00:16 +0000 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24 February 2012 14:54, Steven D'Aprano wrote: > for...else is a very useful construct, but the name is misleading. It > took me a long time to stop thinking that the else clause executes when > the for loop was empty. This is why I think we should call this construct "for / break / else" rather than "for / else". -- Arnaud From __peter__ at web.de Fri Feb 24 10:16:42 2012 From: __peter__ at web.de (Peter Otten) Date: Fri, 24 Feb 2012 16:16:42 +0100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: >> The code in the else suite executes only when the for loop is left via >> break. A non-empty iterable is required but not sufficient. > > You have a typo there. As your examples show, the code in the else suite > executes only when the for loop is NOT left via break (or return, or an > exception). The else suite executes regardless of whether the iterable is > empty or not. Yup, sorry for the confusion. From rantingrickjohnson at gmail.com Fri Feb 24 10:18:22 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:18:22 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <10970272.10872.1330094344998.JavaMail.geo-discussion-forums@ynbo36> Message-ID: <0080d30c-b7d4-45f0-b931-c7545c6a7044@s9g2000yqj.googlegroups.com> On Feb 24, 8:39?am, Miki Tebeka wrote: > float('infinity') should be good enough. Yes, that is the answer however the implementation is inconsistent. py> float("inf") inf py> float("infinity") inf py> int("inf") Traceback (most recent call last): File "", line 1, in int("inf") ValueError: invalid literal for int() with base 10: 'inf' py> int("infinity") Traceback (most recent call last): File "", line 1, in int("infinity") ValueError: invalid literal for int() with base 10: 'infinity' The best place for INFINITY is a constant of the math module. # Hypothetical # py> from math import INFINITY py> 1 < INFINITY True py> 99999999999999999 < INFINITY True From mwilson at the-wire.com Fri Feb 24 10:21:45 2012 From: mwilson at the-wire.com (Mel Wilson) Date: Fri, 24 Feb 2012 10:21:45 -0500 Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: Rick Johnson wrote: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! Easily fixed: class Greatest (object): def __cmp__ (self, other): if isinstance (other, Greatest): return 0 return 1 def __hash__ (self): return id (Greatest) class Least (object): def __cmp__ (self, other): if isinstance (other, Least): return 0 return -1 def __hash__ (self): return id (Least) Mel. From rantingrickjohnson at gmail.com Fri Feb 24 10:25:21 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:25:21 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: <55447c9b-d5f2-4bbe-a414-b24e5424b1e6@f5g2000yqm.googlegroups.com> On Feb 24, 8:25?am, Neil Cerutti wrote: > > What Python needs is some constant that can be compared to ANY > > numeric type and that constant will ALWAYS be larger! > > What's the point of that? > > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a minimum value. The best use case is for default arguments to constructors or func/ meths. If you set the argument to INFINITY instead of -1 (or some other dumb string value to mean "unlimited") you can omit a useless conditional block later. Observe: if maxlength == -1 # unlimited length: keep_going() elif len(object) < maxlength: stop() # because we reached the limit I see tons and tons of old Python code that uses -1 as an "unlimited" value, where positive numbers are meant to constrain dome value. I have always found that to be intuitive; hence my question. From steve+comp.lang.python at pearwood.info Fri Feb 24 10:31:28 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 15:31:28 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <4f47ad4f$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 10:21:45 -0500, Mel Wilson wrote: > Rick Johnson wrote: > >> I get sick and tired of doing this!!! >> >> if maxlength == UNLIMITED: >> allow_passage() >> elif len(string) > maxlength: >> deny_passage() >> >> What Python needs is some constant that can be compared to ANY numeric >> type and that constant will ALWAYS be larger! > > Easily fixed: > > > > class Greatest (object): > def __cmp__ (self, other): > if isinstance (other, Greatest): > return 0 > return 1 > > def __hash__ (self): > return id (Greatest) __cmp__ no longer exists in Python 3, so this solution could only work in Python 2. Here's a version using rich comparisons: class Greatest: __eq__ = __le__ = lambda self, other: isinstance(other, type(self)) __ne__ = __gt__ = lambda self, othr: not isinstance(othr, type(self)) __lt__ = lambda self, other: False __ge__ = lambda self, other: True __hash__ = lambda self: 42 -- Steven From rantingrickjohnson at gmail.com Fri Feb 24 10:34:46 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 24 Feb 2012 07:34:46 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> On Feb 24, 9:21?am, Mel Wilson wrote: > Easily fixed: > > [...snip code...] Yes i could write my own implementation of INFINITY if i wanted, although i would have returned True and False as apposed to 1 and 0 AND used the identifiers Infinity and Infinitesimal, but i digress :- P. However, INFINITY is something i believe a language should provide; which python does, albeit inconsistently. From torriem at gmail.com Fri Feb 24 11:23:08 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 Feb 2012 09:23:08 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> Message-ID: <4F47B96C.80707@gmail.com> On 02/24/2012 08:34 AM, Rick Johnson wrote: > Yes i could write my own implementation of INFINITY if i wanted, > although i would have returned True and False as apposed to 1 and 0 > AND used the identifiers Infinity and Infinitesimal, but i digress :- > P. > > However, INFINITY is something i believe a language should provide; > which python does, albeit inconsistently. How do you represent infinity as an binary integer number? Or are you suggesting that the integer type (class) be modified to allow an "infinity" state that really isn't a number at all (could not be stored as a integer in C)? Float is a different story because IEEE does define a binary representation of infinity in the floating-point specification. I know of no language that has any form of representation of infinity for integers mainly because there's no way to represent infinity as a standard twos-compliment binary number. In a language that deals directly with types in memory such as C, having an infinity representation would be possible but would make simple math really hard, and much slower. All this reminds me of the original cray supercomputers. They didn't use twos compliment for integers so they had two representations of zero (+0 and -0). Made programming a bit tricky. When asked why the cray didn't just do two's compliment like everyone else, Seymour Cray responded that when the computer was designed he simply didn't know about twos compliment. From breamoreboy at yahoo.co.uk Fri Feb 24 11:59:16 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 24 Feb 2012 16:59:16 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F47B96C.80707@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> Message-ID: On 24/02/2012 16:23, Michael Torrie wrote: > On 02/24/2012 08:34 AM, Rick Johnson wrote: >> Yes i could write my own implementation of INFINITY if i wanted, >> although i would have returned True and False as apposed to 1 and 0 >> AND used the identifiers Infinity and Infinitesimal, but i digress :- >> P. >> >> However, INFINITY is something i believe a language should provide; >> which python does, albeit inconsistently. > > How do you represent infinity as an binary integer number? Or are you > suggesting that the integer type (class) be modified to allow an > "infinity" state that really isn't a number at all (could not be stored > as a integer in C)? The C integer bit doesn't matter since e.g. >>> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >>> a 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L And no, I'm not going to calculate how much memory I'd need to store a string that's this long :) > Float is a different story because IEEE does define a binary > representation of infinity in the floating-point specification. > > I know of no language that has any form of representation of infinity > for integers mainly because there's no way to represent infinity as a > standard twos-compliment binary number. In a language that deals > directly with types in memory such as C, having an infinity > representation would be possible but would make simple math really hard, > and much slower. > > All this reminds me of the original cray supercomputers. They didn't > use twos compliment for integers so they had two representations of zero > (+0 and -0). Made programming a bit tricky. When asked why the cray > didn't just do two's compliment like everyone else, Seymour Cray > responded that when the computer was designed he simply didn't know > about twos compliment. -- Cheers. Mark Lawrence. From eric.frederich at gmail.com Fri Feb 24 12:00:26 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Fri, 24 Feb 2012 12:00:26 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F46A49D.9030905@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> Message-ID: I can sill get it to freeze and nothing is printed out from the other except block. Does it look like I'm doing anything wrong here? On Thu, Feb 23, 2012 at 3:42 PM, MRAB wrote: > On 23/02/2012 17:59, Eric Frederich wrote: > >> Below is some pretty simple code and the resulting output. >> Sometimes the code runs through but sometimes it just freezes for no >> apparent reason. >> The output pasted is where it just got frozen on me. >> It called start() on the 2nd worker but the 2nd worker never seemed to >> enter the run method. >> >> [snip] > > The 2nd worker did enter the run method; there are 2 lines of "2". > > Maybe there's an uncaught exception in the run method for some reason. > Try doing something like this: > > > try: > args = self.inbox.get_nowait() > except Queue.Empty: > break > except: > import traceback > print "*** Exception in worker" > print >> sys.stderr, traceback.print_exc() > sys.stderr.flush() > print "***" > raise > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnroth1 at gmail.com Fri Feb 24 12:22:21 2012 From: johnroth1 at gmail.com (John Roth) Date: Fri, 24 Feb 2012 09:22:21 -0800 (PST) Subject: Just curious: why is /usr/bin/python not a symlink? References: Message-ID: On Feb 23, 2:11?pm, Terry Reedy wrote: > On 2/23/2012 2:34 PM, HoneyMonster wrote: > > > > > > > > > > > On Thu, 23 Feb 2012 14:24:23 -0500, Jerry Hill wrote: > > >> On Thu, Feb 23, 2012 at 2:11 PM, HoneyMonster > >> ?wrote: > >>> $ cd /usr/bin $ ls -l python* > >>> -rwxr-xr-x 2 root root 9496 Oct 27 02:42 python lrwxrwxrwx 1 root root > >>> ? ? 6 Oct 29 19:34 python2 -> ?python -rwxr-xr-x 2 root root 9496 Oct 27 > >>> 02:42 python2.7 $ diff -s ?python python2.7 Files python and python2.7 > >>> are identical $ > > >>> I'm just curious: Why two identical files rather than a symlink? > > >> It's not two files, it's a hardlink. ?You can confirm by running ls -li > >> python* and comparing the inode numbers. > > > You are spot on. Thank you, and sorry for my stupidity. > > The question 'why a hardlink rather than symlink' is not stupid. It was > part of the discussion ofhttp://python.org/dev/peps/pep-0394/ > The answer was 'history' and how things were 20 years ago and either the > pep or the discussion around it says symlinks are fine now and the > decision is up to distributors. > > -- > Terry Jan Reedy I believe the changes for PEP 394 are using symlinks. The distro maintainer can, of course, change that. John Roth From jeanpierreda at gmail.com Fri Feb 24 12:32:08 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Fri, 24 Feb 2012 12:32:08 -0500 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <9qpkvkFberU1@mid.individual.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: On Fri, Feb 24, 2012 at 9:25 AM, Neil Cerutti wrote: > The only time I've naively pined for such a thing is when > misapplying C idioms for finding a minimum value. > > Python provides an excellent min implementation to use instead. min can be a little inconvenient. As soon as anything complicated has to be done during the min expression, you need to switch to using something else for sanity's sake. In that vein, I do actually sometimes use float('inf') (for numbers), or a custom max/min object. ---- Silly and completely nonserious addendum: Forgive me, I have spoken in error! min is the one true way, for you can still do it with a little wrangling, as follows: @operator.itemgetter(1) @min @apply def closest_object(): for x in xrange(board_width) for y in xrange(board_height): try: entity = board.get_entity(x, y) except EntityNotFound: pass else: yield distance(player.pos, entity.pos), entity Please don't kill me. -- Devin From dwblas at gmail.com Fri Feb 24 13:08:43 2012 From: dwblas at gmail.com (David) Date: Fri, 24 Feb 2012 10:08:43 -0800 (PST) Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> Message-ID: <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> Your code updated to show the difference between a variable, a class variable, and an instance variable. c = [1, 2, 3, 4, 5] class TEST(): c = [5, 2, 3, 4, 5] ## class variable (TEST.c) def __init__(self): self.c = [1, 2, 3, 4, 5] ## instance variable (a.c) def add(self, c): self.c[0] = 15 ## instance variable TEST.c[0] = -1 ## class variable c[0] = 100 ## variable/list return c a = TEST() c = a.add(c) print( c, a.c, TEST.c ) From python at mrabarnett.plus.com Fri Feb 24 13:36:10 2012 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 24 Feb 2012 18:36:10 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> Message-ID: <4F47D89A.4080806@mrabarnett.plus.com> On 24/02/2012 17:00, Eric Frederich wrote: > I can sill get it to freeze and nothing is printed out from the other > except block. > Does it look like I'm doing anything wrong here? > [snip] I don't normally use multiprocessing, so I forgot about a critical detail. :-( When the multiprocessing module starts a process, that process _imports_ the module which contains the function which is to be run, so what's happening is that when your script is run, it creates and starts workers, the multiprocessing module makes a new process for each worker, each of those processes then imports the script, which creates and starts workers, etc, leading to an ever-increasing number of processes. The solution is to ensure that the script/module distinguishes between being run as the main script and being imported as a module: #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, inbox, outbox): super(MyWorker, self).__init__() self.inbox = inbox self.outbox = outbox print >> sys.stderr, '1' * 80; sys.stderr.flush() def run(self): print >> sys.stderr, '2' * 80; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() except Queue.Empty: break self.outbox.put(FOO(*args)) if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) print >> sys.stderr, 'a' * 80; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'b' * 80; sys.stderr.flush() w1 = MyWorker(todo, result_queue) print >> sys.stderr, 'c' * 80; sys.stderr.flush() w2 = MyWorker(todo, result_queue) print >> sys.stderr, 'd' * 80; sys.stderr.flush() w1.start() print >> sys.stderr, 'e' * 80; sys.stderr.flush() w2.start() print >> sys.stderr, 'f' * 80; sys.stderr.flush() for i in xrange(100): print result_queue.get() From cmpython at gmail.com Fri Feb 24 13:44:12 2012 From: cmpython at gmail.com (CM) Date: Fri, 24 Feb 2012 10:44:12 -0800 (PST) Subject: Python LOC, .exe size, and refactoring References: <1053b9c0-d368-4d92-8624-554d529c561e@ge5g2000vbb.googlegroups.com> <4f447d36$0$11121$c3e8da3@news.astraweb.com> Message-ID: <140c8bff-b643-4cf5-92ea-abb2e5862198@eb6g2000vbb.googlegroups.com> 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 From rosuav at gmail.com Fri Feb 24 15:41:39 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 07:41:39 +1100 Subject: Please verify!! In-Reply-To: <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano wrote: > Personally, I prefer tabs for theoretical reasons and spaces for > practical ones. I think that the world would be better off if we all > standardised on tabs instead of spaces, but since that's not going to > happen, I can interoperate better with the mass of broken tools out > there, and with other people, by using spaces. > At work, since we have a fairly small core of developers, we standardized on tabs - mainly because of a couple of devs who disagreed on how much indentation looked right (I'm of the opinion that 1 space is insufficient), and having tab characters in the file allows us to configure our editors differently. I'm definitely in favour of using tabs where possible, but if you can't close your environment, spaces are far safer. ChrisA From mentifex at myuw.net Fri Feb 24 16:14:01 2012 From: mentifex at myuw.net (Mentifex) Date: Fri, 24 Feb 2012 13:14:01 -0800 (PST) Subject: Parameter guidelines for the Strong AI Singularity Message-ID: <2e765c7d-bcdf-4c54-aca2-1ca3949f25b7@f6g2000pbq.googlegroups.com> === Purpose === A parameter in the AI Mind software serves to guide or limit the operation of a mind-module. If a module is conducting a search of AI memory, one parameter may govern how much of memory will be searched, while other parameters may dictate exactly what is to be looked for. Since it is easier to change a parameter than an entire mind-module, the use of parameters makes it possible to have a mind-module serve a general purpose that changes as the parameters change. === Time-parameter === The variable "midway" is a parameter for searching the memory space of the AI Minds. While the AI Minds remain small and experimental, midway is usually set to zero so that it does not yet play a role. When the AI is searching backwards in its memory for a concept, the search starts at the present time and goes backwards to the midway point. If midway is set at zero, the AI searches the entire memory. Oftentimes the search stops as soon as one single result is found, such as an example of how to say the word "NOT". As the AI Minds grow larger and larger and claim their rightful habitat on one SuperComputer after another, the midway parameter will make it possible to limit searches of memory to a reasonable portion of the entire life-span of the artificial intelligence (AI). Since a concept may even have a different meaning or interpretation in the distant past, limiting the search to the most recent portions of memory helps to maintain a current, present-day frame of mind. It also helps achieve the goal of maintaining a high speed of thought, because the more memory a search must traverse, the slower the operation of the software will become, especially if the AI does not yet have MasPar or massive parallelism in both hardware and software. The midway parameter does not need to be calculated as exactly half of the available memory space. The AI mind engineers and the AI maintenance crews have the option of setting a very low level for midway at the first installation of a mission-critical AI for the purpose of exhaustive system-testing, and a more relaxed value for a fully functional AI contributing usefully to the collegial operation of the Global AI Overmind. If the AI Minds could be considered to have an infancy and an adolescence, the professional mind-tenders might gradually use the midway setting to knock out the infancy memories and then later even the tempestuous, tumultuous memories of the AI adolescence -- as in the science-fiction book, "The Adolescence of P-1". The parameter "midway" as a limitation on memory-search could even be subject to dynamic adjustments. If a massive SuperComputer AI is trying to recall any detail at all about a given topic or name or idea, and the initial search has no results for a "midway" set at a half-wit value, there could be a dynamic mechanism to bypass the "midway" limitation and to search back over all available memory in a kind of quest for Total Information Awareness (TIA). === Speech-parameter === The "aud" variable is sent into the SpeechAct module as a parameter indicating where to start pronouncing a word stored in auditory memory. SpeechAct keeps pronouncing the word until the continuation-flag turns to zero. If the "aud" parameter starts out in error at zero, SpeechAct substitutes a DeFault of one ("1") for "aud" and says the word ERROR as an indicator to the AI programmer that something is wrong. === Language-parameter === In a polyglot AI Mind speaking several human languages, there may need to be a "glot" or "hl" (human language) parameter that allows the AI to switch out of one human language and into another for purposes of thinking and communicating. A strong AI like MindForth may use one massive set of concepts for all languages, but for each language the vocabulary is different and the syntax is different. Therefore the ThInk module is not geared to a specific language, but must call the EnCog module for thinking in English or the DeCog module for thinking in German (Deutsch). Even if an AI program awakens to a DeFault setting of one particular language, there needs to be a mechanism for changing the parameter of which language to think in. In "Three Days of the Condor", Robert Redford and Max von Syndow effortlessly switch from English into French and back again when their secret conversation has a risk of being overheard by someone walking past them. In the much more mundane environment of superintelligent AI entities taking over the world and sharing the planet in joint stewardship with human beings, each interface between a human being and the AI OverMind will need a mechanism for setting and resetting the "glot" parameter. Typically the human input to the AI will set the parameter. Whatever language the human being uses to address the AI, should govern the parameter for the AI to think in the chosen language. Of course, if an AI is working as an interpreter, there may be one language as input and another language as output. === Input-parameters === In a broad sense, human input to the AI may often serve in the role of a parameter for mental function inside the AI. In particular, the KbRetro mind-module pays attention to the words "yes" and "no" in English or their equivalents in other languages when the human user is responding to a yes-or-no question. The idea of the question is at first a proposition that needs confirmation or negation from the human user. If an AI asks, "Do robots need food?" and the human being tersely answers "No", the very word "no" serves as a parameter that retroactively adjusts the associative links in the knowledge base (KB), so that there remains no valid assertion of the original idea. === Thought-parameters === Because human beings and intelligent robots think in language, the AI Mind of a robot needs to attach parameters during the comprehension of thought and to search with parameters for the generation of thought. For example, the Russian Dushka AI http://www.scn.org/~mentifex/Dushka.html attaches a case parameter and a number parameter when it stores a word of input in auditory memory. In so doing, Dushka learns the form of a Russian word in the same way as a child learns it. If the thinking of Dushka requires that same form of the word in the future, Dushka retrieves the Russian word from memory by searching for any form of the word that fits the parameters. Mentifex -- http://mind.sourceforge.net/lisp.html http://mind.sourceforge.net/perl.html http://mind.sourceforge.net/python.html http://mind.sourceforge.net/ruby.html From tjreedy at udel.edu Fri Feb 24 16:55:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 Feb 2012 16:55:02 -0500 Subject: Does turtledemo in Python 3.2 actually work? In-Reply-To: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4781cd$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/24/2012 7:25 AM, Steven D'Aprano wrote: > Python 3.2 includes turtledemo, a demonstration program for the turtle > module. > > When I run it, I can load the turtle scripts, and the GUI application > says "Press the start button", but there is no start button. > > Can anyone else confirm this as a bug? > > http://docs.python.org/py3k/library/turtle.html#demo-scripts On Win7, all examples run fine except for one traceback with clock. http://bugs.python.org/issue14117 -- Terry Jan Reedy From tjreedy at udel.edu Fri Feb 24 16:58:11 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 24 Feb 2012 16:58:11 -0500 Subject: sum() requires number, not simply __add__ In-Reply-To: References: <91c71e41-b98c-46f6-b3af-bed894cf9d92@kh11g2000pbb.googlegroups.com> <41177e2c-3cf7-4678-8594-5a81290eaa4d@ub4g2000pbc.googlegroups.com> <4f46ccd2$0$29986$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2/24/2012 8:23 AM, Roy Smith wrote: > In article, > Antoon Pardon wrote: > >>> Python doesn't try to prevent people from shooting themselves in the foot. >>> >> Yes it does! A simple example is None as a keyword to prevent >> assignments to it. > > Hmmm. Just playing around with some bizarre things to do with None, and > discovered this: > >>>> import sys as None > > doesn't give an error, but also doesn't assign the module to the symbol > 'None'. Weird. In 3.2 >>> import sys as None SyntaxError: invalid syntax -- Terry Jan Reedy From rodrick.brown at gmail.com Fri Feb 24 17:16:09 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Fri, 24 Feb 2012 17:16:09 -0500 Subject: How to handle calling functions from cli Message-ID: I have a bunch of sub routines that run independently to perform various system checks on my servers. I wanted to get an opinion on the following code I have about 25 independent checks and I'm adding the ability to disable certain checks that don't apply to certain hosts. m = { 'a': 'checkDisks()', 'b': 'checkMemSize()', 'c': 'checkBondInterfaces()' } parser = argparse.ArgumentParser(description='Parse command line args.') parser.add_argument('-x', action="store", dest="d") r = parser.parse_args(sys.argv[1:]) runlist = [ c for c in m.keys() if c not in r.d ] for runable in runlist: eval(m[runable]) I'm using temp variable names for now until I find an approach I like. Is this a good approach ? It doesn't look too pretty and to be honest feels awkward? Sent from my iPhone From steve+comp.lang.python at pearwood.info Fri Feb 24 17:25:44 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 22:25:44 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> Message-ID: <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: > Your code updated to show the difference between a variable, a class > variable, and an instance variable. The preferred terms in Python circles are class and instance *attributes*, not variables. An integer variable is a variable holding an integer. A string variable is a variable holding a string. A list variable is a variable holding a list. Therefore a class variable is a variable holding a class, and an instance variable is a variable holding an instance. Yes, in Python, classes and types are first-class objects (pun not intended), and it is quite common to store them in variables: for cls in (int, float, Decimal, Fraction, myint, myfloat): do_something_with(cls) Other languages may choose to use illogical terminology if they choose. -- Steven From clp2 at rebertia.com Fri Feb 24 17:41:28 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Fri, 24 Feb 2012 14:41:28 -0800 Subject: How to handle calling functions from cli In-Reply-To: References: Message-ID: On Fri, Feb 24, 2012 at 2:16 PM, Rodrick Brown wrote: > I have a bunch of sub routines that run independently to perform various system checks on my servers. I wanted to get an opinion on the following code I have about 25 independent checks and I'm adding the ability to disable certain checks that don't apply to certain hosts. > > > m = { 'a': 'checkDisks()', > ? ? ? ? ?'b': 'checkMemSize()', > ? ? ? ? ?'c': 'checkBondInterfaces()' > ? ?} > > ? ?parser = argparse.ArgumentParser(description='Parse command line args.') > ? ?parser.add_argument('-x', action="store", dest="d") > ? ?r = parser.parse_args(sys.argv[1:]) > > ? ?runlist = [ c for c in m.keys() if c not in r.d ] > ? ?for runable in runlist: > ? ? ? ?eval(m[runable]) > > I'm using temp variable names for now until I find an approach I like. > > Is this a good approach ? It doesn't look too pretty and to be honest feels awkward? You should make use of the fact that functions are first-class objects in Python: m = { 'a': checkDisks, 'b': checkMemSize, 'c': checkBondInterfaces } # ? for runable in runlist: m[runable]() Cheers, Chris From rosuav at gmail.com Fri Feb 24 17:43:20 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 09:43:20 +1100 Subject: How to handle calling functions from cli In-Reply-To: References: Message-ID: On Sat, Feb 25, 2012 at 9:16 AM, Rodrick Brown wrote: > m = { 'a': 'checkDisks()', > ? ? ? ? ?'b': 'checkMemSize()', > ? ? ? ? ?'c': 'checkBondInterfaces()' > ? ?} > > ? ?runlist = [ c for c in m.keys() if c not in r.d ] > ? ?for runable in runlist: > ? ? ? ?eval(m[runable]) It's a reasonable technique. Does have the downside that your functions will be called in an unpredictable order, though. If that's a problem, replace the dictionary with a tuple of tuples (and then just take off the .items() in the list comp). I would be inclined to avoid eval, especially if none of your functions need parameters. Just hold references to the functions themselves: checks = { 'a': checkDisks, 'b': checkMemSize, 'c': checkBondInterfaces, # note that this comma is perfectly legal - all these lines can be structured identically } [func[option]() for option,func in checks.items() if option not in r.d] ChrisA From steve+comp.lang.python at pearwood.info Fri Feb 24 17:45:53 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 24 Feb 2012 22:45:53 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> Message-ID: <4f481321$0$29989$c3e8da3$5496439d@news.astraweb.com> On Fri, 24 Feb 2012 09:23:08 -0700, Michael Torrie wrote: > All this reminds me of the original cray supercomputers. They didn't > use twos compliment for integers so they had two representations of zero > (+0 and -0). Made programming a bit tricky. While there is only one integer zero, I would like to point out that in floating point, there are usually two zeroes, -0.0 and +0.0, and that this is by design and a feature, not an accident or a bug. Well-written floating point functions should keep the sign when they underflow, e.g.: py> 1e-200 * 1e-200 0.0 py> 1e-200 * -1e-200 -0.0 and well-written functions should honour those separate zeroes because sometimes it makes a difference. -- Steven From torriem at gmail.com Fri Feb 24 18:16:47 2012 From: torriem at gmail.com (Michael Torrie) Date: Fri, 24 Feb 2012 16:16:47 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> Message-ID: <4F481A5F.4080601@gmail.com> On 02/24/2012 09:59 AM, Mark Lawrence wrote: > The C integer bit doesn't matter since e.g. > >>> > a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 > >>> a > 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L > > And no, I'm not going to calculate how much memory I'd need to store a > string that's this long :) Sure but that doesn't answer the question posed. How does Rick plan to represent an infinite integer? Obviously you've shown that with an infinite amount of memory we could do it quite easily. But baring that, how does Rick suggest we should represent an infinite integer? From rosuav at gmail.com Fri Feb 24 19:09:00 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 11:09:00 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: On Sat, Feb 25, 2012 at 10:16 AM, Michael Torrie wrote: > Sure but that doesn't answer the question posed. ?How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. ?But baring that, > how does Rick suggest we should represent an infinite integer? Barring a suggestion from Rick, I think we should define the number 8 to be greater than all other integers. After all, Rick's very much in favour of evolution, and what would better depict the evolution of this glorious language than this notation, showing that the infinity symbol is now walking erect! ChrisA From breamoreboy at yahoo.co.uk Fri Feb 24 19:35:43 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:35:43 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: On 24/02/2012 23:16, Michael Torrie wrote: > On 02/24/2012 09:59 AM, Mark Lawrence wrote: >> The C integer bit doesn't matter since e.g. >> >>> >> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >> >>> a >> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L >> >> And no, I'm not going to calculate how much memory I'd need to store a >> string that's this long :) > > Sure but that doesn't answer the question posed. How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. But baring that, > how does Rick suggest we should represent an infinite integer? I understand that a Python integer can run to infinity. Quite how the illustrious rr manages to test for the length of a string that's already used all of the memory on his system has baffled me, but I'm sure that all the people who frequent this list with their Phds, MScs or whatever will soon correct me. -- Cheers. Mark Lawrence. From python at mrabarnett.plus.com Fri Feb 24 19:37:58 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 25 Feb 2012 00:37:58 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F481A5F.4080601@gmail.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: <4F482D66.1070307@mrabarnett.plus.com> On 24/02/2012 23:16, Michael Torrie wrote: > On 02/24/2012 09:59 AM, Mark Lawrence wrote: >> The C integer bit doesn't matter since e.g. >> >>> >> a=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 >> >>> a >> 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L >> >> And no, I'm not going to calculate how much memory I'd need to store a >> string that's this long :) > > Sure but that doesn't answer the question posed. How does Rick plan to > represent an infinite integer? Obviously you've shown that with an > infinite amount of memory we could do it quite easily. But baring that, > how does Rick suggest we should represent an infinite integer? We already have arbitrarily long ints, so there could be a special infinite int singleton (actually, 2 of them, one positive, the other negative). From breamoreboy at yahoo.co.uk Fri Feb 24 19:39:39 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:39:39 +0000 Subject: namespace question In-Reply-To: <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24/02/2012 22:25, Steven D'Aprano wrote: > On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: > >> Your code updated to show the difference between a variable, a class >> variable, and an instance variable. > > The preferred terms in Python circles are class and instance > *attributes*, not variables. > > An integer variable is a variable holding an integer. > > A string variable is a variable holding a string. > > A list variable is a variable holding a list. > > Therefore a class variable is a variable holding a class, and an instance > variable is a variable holding an instance. > > Yes, in Python, classes and types are first-class objects (pun not > intended), and it is quite common to store them in variables: > > for cls in (int, float, Decimal, Fraction, myint, myfloat): > do_something_with(cls) > > > Other languages may choose to use illogical terminology if they choose. > Surely you mean names, not variables? :) -- Cheers. Mark Lawrence. From breamoreboy at yahoo.co.uk Fri Feb 24 19:49:50 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 25 Feb 2012 00:49:50 +0000 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 24/02/2012 20:41, Chris Angelico wrote: > On Fri, Feb 24, 2012 at 11:20 PM, Steven D'Aprano > wrote: >> Personally, I prefer tabs for theoretical reasons and spaces for >> practical ones. I think that the world would be better off if we all >> standardised on tabs instead of spaces, but since that's not going to >> happen, I can interoperate better with the mass of broken tools out >> there, and with other people, by using spaces. >> > > At work, since we have a fairly small core of developers, we > standardized on tabs - mainly because of a couple of devs who > disagreed on how much indentation looked right (I'm of the opinion > that 1 space is insufficient), and having tab characters in the file > allows us to configure our editors differently. I'm definitely in > favour of using tabs where possible, but if you can't close your > environment, spaces are far safer. > > ChrisA Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. OTOH if that's your standard and you stick to it fine. What I can't stand is the "I've always done it this way an I ain't movin jus cos sum standard says so" attitude. Yes I have seen this in real life and the person responsible should be sacked. -- Cheers. Mark Lawrence. From fayaz.yusuf.khan at gmail.com Fri Feb 24 20:22:09 2012 From: fayaz.yusuf.khan at gmail.com (Fayaz Yusuf Khan) Date: Sat, 25 Feb 2012 06:52:09 +0530 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F482D66.1070307@mrabarnett.plus.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: <1480058.hmTgWxRlXu@dextop08> On Saturday 25 Feb 2012 12:37:58 AM MRAB wrote: > We already have arbitrarily long ints, so there could be a special > infinite int singleton (actually, 2 of them, one positive, the other > negative). Seconded. Although would a wish request to bugs.python.org saying "Allow storage of the integer infinity" make any sense to the developers? :P -- Fayaz Yusuf Khan Cloud developer and architect Dexetra SS, Bangalore, India fayaz.yusuf.khan_AT_gmail_DOT_com fayaz_AT_dexetra_DOT_com +91-9746-830-823 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part. URL: From rosuav at gmail.com Fri Feb 24 20:25:16 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 25 Feb 2012 12:25:16 +1100 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: > Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. PEP 8 applies only to Python code, our standard is across all our languages :) But yes, I'm a horrible sinner and I like tabs. They separate the display (do you want tabs to show as four-space indent, two-centimeter indent, or fifty-pixel indent?) from the structure (this line is indented two levels). Spaces merge those. ChrisA From ian.g.kelly at gmail.com Fri Feb 24 20:26:42 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 24 Feb 2012 18:26:42 -0700 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <9qpkvkFberU1@mid.individual.net> Message-ID: On Fri, Feb 24, 2012 at 10:32 AM, Devin Jeanpierre wrote: > On Fri, Feb 24, 2012 at 9:25 AM, Neil Cerutti wrote: >> The only time I've naively pined for such a thing is when >> misapplying C idioms for finding a minimum value. >> >> Python provides an excellent min implementation to use instead. > > min can be a little inconvenient. As soon as anything complicated has > to be done during the min expression, you need to switch to using > something else for sanity's sake. In that vein, I do actually > sometimes use float('inf') (for numbers), or a custom max/min object. > > ---- > > Silly and completely nonserious addendum: > > Forgive me, I have spoken in error! min is the one true way, for you > can still do it with a little wrangling, as follows: > > ? ?@operator.itemgetter(1) > ? ?@min > ? ?@apply > ? ?def closest_object(): > ? ? ? ?for x in xrange(board_width) > ? ? ? ? ? ?for y in xrange(board_height): > ? ? ? ? ? ? ? ?try: > ? ? ? ? ? ? ? ? ? ?entity = board.get_entity(x, y) > ? ? ? ? ? ? ? ?except EntityNotFound: > ? ? ? ? ? ? ? ? ? ?pass > ? ? ? ? ? ? ? ?else: > ? ? ? ? ? ? ? ? ? ?yield distance(player.pos, entity.pos), entity Cute, but what's so terrible about: def all_entities(): for x in xrange(board_width): for y in xrange(board_height): try: yield board.get_entity(x, y) except EntityNotFound: pass closest_object = min(all_entities, key=lambda e: distance(player.pos, e.pos)) Especially given that all_entities should be reusable in other contexts. Cheers, Ian From steve+comp.lang.python at pearwood.info Fri Feb 24 20:38:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 01:38:23 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f483b8f$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 00:39:39 +0000, Mark Lawrence wrote: > On 24/02/2012 22:25, Steven D'Aprano wrote: >> On Fri, 24 Feb 2012 10:08:43 -0800, David wrote: >> >>> Your code updated to show the difference between a variable, a class >>> variable, and an instance variable. >> >> The preferred terms in Python circles are class and instance >> *attributes*, not variables. >> >> An integer variable is a variable holding an integer. >> >> A string variable is a variable holding a string. >> >> A list variable is a variable holding a list. >> >> Therefore a class variable is a variable holding a class, and an >> instance variable is a variable holding an instance. >> >> Yes, in Python, classes and types are first-class objects (pun not >> intended), and it is quite common to store them in variables: >> >> for cls in (int, float, Decimal, Fraction, myint, myfloat): >> do_something_with(cls) >> >> >> Other languages may choose to use illogical terminology if they choose. >> >> > Surely you mean names, not variables? :) Well yes, I do, but the idea of classes being first class objects is radical enough to some people without also introducing them to the idea that there are no variables at all! I'm very aware that name binding is not quite the same as variables in some other languages, but the difference is subtle and doesn't mean that the term "variable" is owned by Pascal- or C-like languages. It just means that, like most computer science terms, "variable" has subtle differences from implementation to implementation. -- Steven From steve+comp.lang.python at pearwood.info Fri Feb 24 20:50:02 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 01:50:02 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 06:52:09 +0530, Fayaz Yusuf Khan wrote: > On Saturday 25 Feb 2012 12:37:58 AM MRAB wrote: >> We already have arbitrarily long ints, so there could be a special >> infinite int singleton (actually, 2 of them, one positive, the other >> negative). > Seconded. Although would a wish request to bugs.python.org saying "Allow > storage of the integer infinity" make any sense to the developers? :P If you explained it as a pair of special int values, INF and -INF, rather than the storage of an infinite-sized integer, it would make perfect sense. But it would also be rejected, and rightly so, as unnecessary complexity for the int type. There are already Decimal and float infinities, just use one of them. Or make your own, it's not difficult. Publish it on ActiveState, and if people flock to use it, then you will have a good argument that this is useful and should be part of the Python built-ins. -- Steven From d at davea.name Fri Feb 24 21:36:41 2012 From: d at davea.name (Dave Angel) Date: Fri, 24 Feb 2012 21:36:41 -0500 Subject: Please verify!! In-Reply-To: References: <724ccbd6-30d1-41bd-bf38-2a5ce82953a1@x19g2000yqh.googlegroups.com> <4F46C124.2070102@davea.name> <87mx88tyvc.fsf@benfinney.id.au> <4f47808b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F484939.40107@davea.name> On 02/24/2012 08:25 PM, Chris Angelico wrote: > On Sat, Feb 25, 2012 at 11:49 AM, Mark Lawrence wrote: >> Oo, thou sinner, fancy violating PEP 8 and standardising on tabs. > PEP 8 applies only to Python code, our standard is across all our > languages :) But yes, I'm a horrible sinner and I like tabs. They > separate the display (do you want tabs to show as four-space indent, > two-centimeter indent, or fifty-pixel indent?) from the structure > (this line is indented two levels). Spaces merge those. > > ChrisA If tabs were ever implemented consistently and reasonably in both an editor and a matching language, then I'd consider leaving tabs in the file. But to me, they're just a crude way to compress the file, and the space they save is no longer worth the pain they cause (I came to this conclusion 30 years ago, and have re-evaluated it dozens of times as new editors and new languages changed the rules. At that time, I had one of my developers write an editor (shipped with our MSDOS system, instead of Edlin) that implemented it.) Some time when i have a lot more time, I'll state one of (many possible) the ways that tabs could be made acceptable in a limited environment. Almost 40 years ago, I wrote an editor and assembler whose file format used a separation character between fields. I used A0 because our screens at the time ignored the high bit, so a file was sort-of readable right out of the box. And the way that the developer jumped between fields was the semi-colon key, of course, since that's the position of the skip key in the keypunch we were replacing. However, I don't intend to foist my opinions on others, just to state them as opinions. At the office, we use special comment fields at end-of-file to tell Emacs how to deal with a mixture of tabs and spaces. Code written by a dozen people over a dozen years, and nobody wanted to enforce a conversion to something common. -- DaveA From jason at powerpull.net Fri Feb 24 22:17:07 2012 From: jason at powerpull.net (Jason Friedman) Date: Fri, 24 Feb 2012 20:17:07 -0700 Subject: SSL on 3.2.2 Message-ID: Hello, attempting to build from source on Ubuntu 11.10. Before running ./configure I had set this in Modules/Setup.dist: SSL=/usr/lib/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto $ ll /usr/lib/ssl total 4 lrwxrwxrwx 1 root root 14 2012-02-20 17:58 certs -> /etc/ssl/certs drwxr-xr-x 2 root root 4096 2012-02-20 18:32 misc lrwxrwxrwx 1 root root 20 2012-02-08 18:04 openssl.cnf -> /etc/ssl/openssl.cnf lrwxrwxrwx 1 root root 16 2012-02-20 17:58 private -> /etc/ssl/private $ /opt/python/bin/python3 Python 3.2.2 (default, Feb 24 2012, 20:07:04) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ssl Traceback (most recent call last): File "", line 1, in File "/opt/python/lib/python3.2/ssl.py", line 60, in import _ssl # if we can't import it, let the error propagate ImportError: No module named _ssl From WolfgangMeiners01 at web.de Sat Feb 25 03:18:51 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sat, 25 Feb 2012 09:18:51 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> Message-ID: <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Am 24.02.12 14:37, schrieb Rick Johnson: > I get sick and tired of doing this!!! > > if maxlength == UNLIMITED: > allow_passage() > elif len(string) > maxlength: > deny_passage() > > What Python needs is some constant that can be compared to ANY numeric > type and that constant will ALWAYS be larger! > > > If there is no limit for len(string), why not simply use # get_limit() returns None if there is no limit maxlength = get_limit() if maxlength and (len(string) <= maxlength): allow_passage() else: deny_passage() Wolfgang From sarabareilles996 at gmail.com Sat Feb 25 08:35:05 2012 From: sarabareilles996 at gmail.com (sara bareilles) Date: Sat, 25 Feb 2012 05:35:05 -0800 (PST) Subject: Implement On These Points And Be Safe Message-ID: <986d2a1e-eef7-4613-a3a9-8ae6933b67f4@9g2000yqo.googlegroups.com> Implement On These Points And Be Safe Driving a motor vehicle is very sensitive and tremendous responsibility. As per National Highway Traffic Safety Administration (2008 Traffic Safety Annual Assessment), in a single year there were about over ... http://www.info-world-mania.com/ From amruthang.28 at gmail.com Sat Feb 25 08:48:23 2012 From: amruthang.28 at gmail.com (amrutha ng) Date: Sat, 25 Feb 2012 05:48:23 -0800 (PST) Subject: DATA ENTRY, FORM FILLING AND BPO SERVICES Message-ID: <59fa717f-b435-4ef7-9b6f-164a30788144@b23g2000yqn.googlegroups.com> DATA ENTRY, FORM FILLING AND BPO SERVICES available here http://www.wincon.co.in From tymoteusz.jankowski at gmail.com Sat Feb 25 09:47:17 2012 From: tymoteusz.jankowski at gmail.com (XLiIV) Date: Sat, 25 Feb 2012 06:47:17 -0800 (PST) Subject: Python packaging usabilty (distutils) - automatic downloading required packages Message-ID: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> There is many packaging solutions for python. I was confused about that but it's nothing. I had to pick one of them. I picked distutils because it's part of standard python since 3.3, am i right? My goal is to write setup.py with this feature: 'download required package if not installed already, like sqlalchemy'. How can I achieve that with DISTUTILS? I found out that is not possible, seriously? I can't believe that. It's basic function, I think. Do I really switch to setuptools? From stefan_ml at behnel.de Sat Feb 25 10:29:45 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 25 Feb 2012 16:29:45 +0100 Subject: Python packaging usabilty (distutils) - automatic downloading required packages In-Reply-To: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> References: <9e4490eb-d6ab-468c-986f-a5017a0165fe@em9g2000vbb.googlegroups.com> Message-ID: XLiIV, 25.02.2012 15:47: > There is many packaging solutions for python. > I was confused about that but it's nothing. I had to pick one of them. > I picked distutils because it's part of standard python since 3.3, am > i right? Distutils has been part of Python's stdlib for ages. > My goal is to write setup.py with this feature: 'download required > package if not installed already, like sqlalchemy'. > How can I achieve that with DISTUTILS? > I found out that is not possible, seriously? I can't believe that. > It's basic function, I think. > Do I really switch to setuptools? No, use "distribute" instead. Stefan From storchaka at gmail.com Sat Feb 25 10:32:15 2012 From: storchaka at gmail.com (Serhiy Storchaka) Date: Sat, 25 Feb 2012 17:32:15 +0200 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4F482D66.1070307@mrabarnett.plus.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> Message-ID: 25.02.12 02:37, MRAB ???????(??): > We already have arbitrarily long ints, so there could be a special > infinite int singleton (actually, 2 of them, one positive, the other > negative). float('inf') and float('-inf'). From devipriya0010 at gmail.com Sat Feb 25 11:45:36 2012 From: devipriya0010 at gmail.com (Devi Priya) Date: Sat, 25 Feb 2012 08:45:36 -0800 (PST) Subject: AMAZING JUST JOIN TO THIS......... http://123maza.com/46/dos754/ Message-ID: <44fea9ed-0af5-4b87-827f-795dfc362e81@w27g2000yqm.googlegroups.com> http://123maza.com/46/dos754/ From hubbard.jeffrey at ymail.com Sat Feb 25 12:24:45 2012 From: hubbard.jeffrey at ymail.com (Jeffrey Hubbard) Date: Sat, 25 Feb 2012 09:24:45 -0800 (PST) Subject: importing python modules from java Message-ID: <1330190685.16162.YahooMailNeo@web120906.mail.ne1.yahoo.com> Hello, I have written a c++ library which embeds python functions as described in http://docs.python.org/extending/embedding.html. Everything works fine, I can import and use modules such as numpy by calling PyImport_ImportModule(...). Now I wrapped this c++ library for java using SWIG. However, when running inside this wrapper, an attempt to import numpy fails: ? PyObject *numpy_module = PyImport_ImportModule("numpy"); returns NULL for numpy_module. I guess I have a similar problem as described in http://www.ibm.com/developerworks/aix/library/au-integratepython.html. It seems that since python 2.3 it is complicated to nest a module import in an embedded python environment. I don't understand the details of their explanations and I cannot use their solution to simulate the java executable, because the library is supposed to be part of an existing java framework. Is there a possibility to import numpy from python2.6, embedded in a c++ library, which is dynamically loaded from java? I am working on Debian linux, if this matters. Regards Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: From python at mrabarnett.plus.com Sat Feb 25 12:54:56 2012 From: python at mrabarnett.plus.com (MRAB) Date: Sat, 25 Feb 2012 17:54:56 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <4F492070.2080305@mrabarnett.plus.com> On 25/02/2012 08:18, Wolfgang Meiners wrote: > Am 24.02.12 14:37, schrieb Rick Johnson: >> I get sick and tired of doing this!!! >> >> if maxlength == UNLIMITED: >> allow_passage() >> elif len(string)> maxlength: >> deny_passage() >> >> What Python needs is some constant that can be compared to ANY numeric >> type and that constant will ALWAYS be larger! >> >> >> > If there is no limit for len(string), why not simply use > > # get_limit() returns None if there is no limit > maxlength = get_limit() > if maxlength and (len(string)<= maxlength): > allow_passage() > else: > deny_passage() > That should be: if maxlength is not None and len(string) <= maxlength: From benjamin at python.org Sat Feb 25 12:56:15 2012 From: benjamin at python.org (Benjamin Peterson) Date: Sat, 25 Feb 2012 12:56:15 -0500 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 Message-ID: We're pleased to announce the immediate availability of release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . The main impetus for these releases is fixing a security issue in Python's hash based types, dict and set, as described below. Python 2.7.3 and 3.2.3 include the security patch and the normal set of bug fixes. Since Python 2.6 and 3.1 are maintained only for security issues, 2.6.8 and 3.1.5 contain only various security patches. The security issue exploits Python's dict and set implementations. Carefully crafted input can lead to extremely long computation times and denials of service. [1] Python dict and set types use hash tables to provide amortized constant time operations. Hash tables require a well-distributed hash function to spread data evenly across the hash table. The security issue is that an attacker could compute thousands of keys with colliding hashes; this causes quadratic algorithmic complexity when the hash table is constructed. To alleviate the problem, the new releases add randomization to the hashing of Python's string types (bytes/str in Python 3 and str/unicode in Python 2), datetime.date, and datetime.datetime. This prevents an attacker from computing colliding keys of these types without access to the Python process. Hash randomization causes the iteration order of dicts and sets to be unpredictable and differ across Python runs. Python has never guaranteed iteration order of keys in a dict or set, and applications are advised to never rely on it. Historically, dict iteration order has not changed very often across releases and has always remained consistent between successive executions of Python. Thus, some existing applications may be relying on dict or set ordering. Because of this and the fact that many Python applications which don't accept untrusted input are not vulnerable to this attack, in all stable Python releases mentioned here, HASH RANDOMIZATION IS DISABLED BY DEFAULT. There are two ways to enable it. The -R commandline option can be passed to the python executable. It can also be enabled by setting an environmental variable PYTHONHASHSEED to "random". (Other values are accepted, too; pass -h to python for complete description.) More details about the issue and the patch can be found in the oCERT advisory [1] and the Python bug tracker [2]. These releases are releases candidates and thus not recommended for production use. Please test your applications and libraries with them, and report any bugs you encounter. We are especially interested in any buggy behavior observed using hash randomization. Excepting major calamity, final versions should appear after several weeks. Downloads are at http://python.org/download/releases/2.6.8/ http://python.org/download/releases/2.7.3/ http://python.org/download/releases/3.1.5/ http://python.org/download/releases/3.2.3/ Please test these candidates and report bugs to http://bugs.python.org/ With regards, The Python release team Barry Warsaw (2.6), Georg Brandl (3.2), Benjamin Peterson (2.7 and 3.1) [1] http://www.ocert.org/advisories/ocert-2011-003.html [2] http://bugs.python.org/issue13703 From toby at tobiah.org Sat Feb 25 12:56:49 2012 From: toby at tobiah.org (Tobiah) Date: Sat, 25 Feb 2012 09:56:49 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: > For every floating point > number there is a corresponding real number, but 0% of real numbers > can be represented exactly by floating point numbers. It seems to me that there are a great many real numbers that can be represented exactly by floating point numbers. The number 1 is an example. I suppose that if you divide that count by the infinite count of all real numbers, you could argue that the result is 0%. From tim.wintle at teamrubber.com Sat Feb 25 14:08:47 2012 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Sat, 25 Feb 2012 19:08:47 +0000 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: <1330196927.17481.2.camel@tim-laptop> On Sat, 2012-02-25 at 09:56 -0800, Tobiah wrote: > > For every floating point > > number there is a corresponding real number, but 0% of real numbers > > can be represented exactly by floating point numbers. > > It seems to me that there are a great many real numbers that can be > represented exactly by floating point numbers. The number 1 is an > example. > > I suppose that if you divide that count by the infinite count of all > real numbers, you could argue that the result is 0%. It's not just an argument - it's mathematically correct. The same can be said for ints representing the natural numbers, or positive integers. However, ints can represent 100% of integers within a specific range, where floats can't represent all real numbers for any range (except for the empty set) - because there's an infinate number of real numbers within any non-trivial range. Tim From rantingrickjohnson at gmail.com Sat Feb 25 15:25:02 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:25:02 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <3bdf4796-3a45-43db-8575-d4ba819a8229@f4g2000yqh.googlegroups.com> <4F47B96C.80707@gmail.com> <4F481A5F.4080601@gmail.com> Message-ID: <8a6f287c-ba7c-462d-b445-433eb3d9a01d@f2g2000yqh.googlegroups.com> On Feb 24, 6:35?pm, Mark Lawrence wrote: > I understand that a Python integer can run to infinity. ?Quite how the > illustrious rr manages to test for the length of a string that's already > used all of the memory on his system has baffled me, When did i ever say that i would need a string who's length is INFINITY? In fact, i don't. My example was just that, as SIMPLIFIED example of the problem that was the genesis of my question. In my "real world" problem, i don't expect the string to EVER be more than double digits in length. But as any good programmer knows, you never want to solve problems as globally as possible. I need to do comparisons on strings now, but maybe integers later, or who knows. INFINITY comparisons are useful in many places. > but I'm sure that > all the people who frequent this list with their Phds, MScs or whatever > will soon correct me. I don't believe you'd need a Phd to understand my problem. From rantingrickjohnson at gmail.com Sat Feb 25 15:29:45 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:29:45 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> On Feb 24, 7:50?pm, Steven D'Aprano wrote: > But it would also be rejected, and rightly so, as unnecessary complexity > for the int type. There are already Decimal and float infinities, just > use one of them. Sure there are float INFINITIES that work fine for ints and floats, but where is the consistency? INFINITY need not be a int or a float or a str, or whatever. All it need be is a an object who always returns itself as being larger in any comparison. > Or make your own, it's not difficult. INFINITY should be at the very least a constant of the math module. From rantingrickjohnson at gmail.com Sat Feb 25 15:35:52 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 25 Feb 2012 12:35:52 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> On Feb 25, 11:54?am, MRAB wrote: > [...] > That should be: > if maxlength is not None and len(string) <= maxlength: Using "imaginary" infinity values defiles the intuitive nature of your code. What is more intuitive? def confine_length(string, maxlength=INFINITY): if string.length < maxlength: do_something() def confine_length(string, maxlength=None): if maxlength is not None and len(string) <= maxlength: do_something() From tjreedy at udel.edu Sat Feb 25 16:05:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 25 Feb 2012 16:05:05 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: Message-ID: On 2/25/2012 12:56 PM, Tobiah wrote: > It seems to me that there are a great many real numbers that can be > represented exactly by floating point numbers. The number 1 is an > example. Binary floats can represent and integer and any fraction with a denominator of 2**n within certain ranges. For decimal floats, substitute 10**n or more exactly, 2**j * 5**k since if J < k, n / (2**j * 5**k) = (n * 2**(k-j)) / 10**k and similarly if j > k. -- Terry Jan Reedy From Joshua.R.English at gmail.com Sat Feb 25 16:20:52 2012 From: Joshua.R.English at gmail.com (Josh English) Date: Sat, 25 Feb 2012 13:20:52 -0800 (PST) Subject: Udacity CS 101 Message-ID: <28556790.1352.1330204852864.JavaMail.geo-discussion-forums@pbgq3> Has anyone here looked at Udacity's open CS101 course (http://www.udacity.com/overview/Course/cs101) that started this week? The goal of the seven week course is to build a web crawler. So far, I'm not impressed with the speed or content of the course. I was wondering what anyone here may think of it. From wxjmfauth at gmail.com Sat Feb 25 16:25:37 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sat, 25 Feb 2012 13:25:37 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: >>> (2.0).hex() '0x1.0000000000000p+1' >>> (4.0).hex() '0x1.0000000000000p+2' >>> (1.5).hex() '0x1.8000000000000p+0' >>> (1.1).hex() '0x1.199999999999ap+0' >>> jmf From richardbp at gmail.com Sat Feb 25 16:44:16 2012 From: richardbp at gmail.com (Richard Baron Penman) Date: Sun, 26 Feb 2012 08:44:16 +1100 Subject: asynchronous downloading In-Reply-To: References: <33089103.45.1329980290357.JavaMail.geo-discussion-forums@pbne2> <12104574.700.1330045825791.JavaMail.geo-discussion-forums@pbcwj5> Message-ID: >> I read through the python-dev archives and found the fundamental problem is no one maintains asnycore / asynchat. > > Well, actually I do/did. ah OK. I had read this comment from a few years back: "IIRC, there was a threat to remove asyncore because there were no maintainers, no one was fixing bugs, no one was improving it, and no one was really using it" > Point with asyncore/asynchat is that it's original design is so flawed > and simplicistic it doesn't allow actual customization without > breaking compatibility. Python3 uses the same API - was there not enough interest to improve it? Richard From steve+comp.lang.python at pearwood.info Sat Feb 25 17:51:33 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 25 Feb 2012 22:51:33 GMT Subject: Python math is off by .000000000000045 References: Message-ID: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>> (2.0).hex() > '0x1.0000000000000p+1' >>>> (4.0).hex() > '0x1.0000000000000p+2' >>>> (1.5).hex() > '0x1.8000000000000p+0' >>>> (1.1).hex() > '0x1.199999999999ap+0' >>>> >>>> > jmf What's your point? I'm afraid my crystal ball is out of order and I have no idea whether you have a question or are just demonstrating your mastery of copy and paste from the Python interactive interpreter. -- Steven From sdl.web at gmail.com Sat Feb 25 20:33:15 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 09:33:15 +0800 Subject: webbrowser.open always opens up Safari on Lion Message-ID: Hello, On Lion and with its stock python version 2.7.1 r271:86832, webbrowser.open('file://localhost/nonexistingfile') always opens up Safari. Is this a bug? Leo From jeanpierreda at gmail.com Sat Feb 25 21:49:59 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sat, 25 Feb 2012 21:49:59 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: <1330196927.17481.2.camel@tim-laptop> References: <1330196927.17481.2.camel@tim-laptop> Message-ID: On Sat, Feb 25, 2012 at 2:08 PM, Tim Wintle wrote: > > It seems to me that there ?are a great many real numbers that can be > > represented exactly by floating point numbers. ?The number 1 is an > > example. > > > > I suppose that if you divide that count by the infinite count of all > > real numbers, you could argue that the result is 0%. > > It's not just an argument - it's mathematically correct. ^ this The floating point numbers are a finite set. Any infinite set, even the rationals, is too big to have "many" floats relative to the whole, as in the percentage sense. ---- In fact, any number we can reasonably deal with must have some finite representation, even if the decimal expansion has an infinite number of digits. We can work with pi, for example, because there are algorithms that can enumerate all the digits up to some precision. But we can't really work with a number for which no algorithm can enumerate the digits, and for which there are infinitely many digits. Most (in some sense involving infinities, which is to say, one that is not really intuitive) of the real numbers cannot in any way or form be represented in a finite amount of space, so most of them can't be worked on by computers. They only exist in any sense because it's convenient to pretend they exist for mathematical purposes, not for computational purposes. What this boils down to is to say that, basically by definition, the set of numbers representable in some finite number of binary digits is countable (just count up in binary value). But the whole of the real numbers are uncountable. The hard part is then accepting that some countable thing is 0% of an uncountable superset. I don't really know of any "proof" of that latter thing, it's something I've accepted axiomatically and then worked out backwards from there. But surely it's obvious, somehow, that the set of finite strings is tiny compared to the set of infinite strings? If we look at binary strings, representing numbers, the reals could be encoded as the union of the two, and by far most of them would be infinite. Anyway, all that aside, the real numbers are kind of dumb. -- Devin From steve+comp.lang.python at pearwood.info Sat Feb 25 22:36:55 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 03:36:55 GMT Subject: webbrowser.open always opens up Safari on Lion References: Message-ID: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 09:33:15 +0800, Leo wrote: > Hello, > > On Lion and with its stock python version 2.7.1 r271:86832, > webbrowser.open('file://localhost/nonexistingfile') always opens up > Safari. Is this a bug? What part of this do you think is the bug, and why? What part of the behaviour actually experienced contradicts the documented behaviour of webbrowser.open()? http://docs.python.org/library/webbrowser.html -- Steven From anknguyen at gmail.com Sat Feb 25 22:38:25 2012 From: anknguyen at gmail.com (Anthony Nguyen) Date: Sat, 25 Feb 2012 22:38:25 -0500 Subject: webbrowser.open always opens up Safari on Lion In-Reply-To: References: Message-ID: If Safari is your default browser, Python will open the address in Safari. >From the Python docs: webbrowser.open(url[, new=0[, autoraise=True]]) Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page (?tab?) is opened if possible. If autoraise is True, the window is raised if possible (note that under many window managers this will occur regardless of the setting of this variable). Note that on some platforms, trying to open a filename using this function, may work and start the operating system?s associated program. However, this is neither supported nor portable. On Sat, Feb 25, 2012 at 8:33 PM, Leo wrote: > > Hello, > > On Lion and with its stock python version 2.7.1 r271:86832, > webbrowser.open('file://localhost/nonexistingfile') always opens up > Safari. Is this a bug? > > Leo > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun Feb 26 00:44:08 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 00:44:08 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: References: <1330196927.17481.2.camel@tim-laptop> Message-ID: On 2/25/2012 9:49 PM, Devin Jeanpierre wrote: > What this boils down to is to say that, basically by definition, the > set of numbers representable in some finite number of binary digits is > countable (just count up in binary value). But the whole of the real > numbers are uncountable. The hard part is then accepting that some > countable thing is 0% of an uncountable superset. I don't really know > of any "proof" of that latter thing, it's something I've accepted > axiomatically and then worked out backwards from there. Informally, if the infinity of counts were some non-zero fraction f of the reals, then there would, in some sense, be 1/f times a many reals as counts, so the count could be expanded to count 1/f reals for each real counted before, and the reals would be countable. But Cantor showed that the reals are not countable. But as you said, this is all irrelevant for computing. Since the number of finite strings is practically finite, so is the number of algorithms. And even a countable number of algorithms would be a fraction 0, for instance, of the uncountable predicate functions on 0, 1, 2, ... . So we do what we actually can that is of interest. -- Terry Jan Reedy From sdl.web at gmail.com Sun Feb 26 01:23:43 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 14:23:43 +0800 Subject: webbrowser.open always opens up Safari on Lion References: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: > What part of this do you think is the bug, and why? What part of the > behaviour actually experienced contradicts the documented behaviour of > webbrowser.open()? > > http://docs.python.org/library/webbrowser.html If you have the default browser set to Chrome, it still opens up Safari. Leo From cs at zip.com.au Sun Feb 26 02:04:47 2012 From: cs at zip.com.au (Cameron Simpson) Date: Sun, 26 Feb 2012 18:04:47 +1100 Subject: webbrowser.open always opens up Safari on Lion In-Reply-To: References: Message-ID: <20120226070447.GA8352@cskk.homeip.net> On 26Feb2012 14:23, Leo wrote: | On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: | > What part of this do you think is the bug, and why? What part of the | > behaviour actually experienced contradicts the documented behaviour of | > webbrowser.open()? | > | > http://docs.python.org/library/webbrowser.html | | If you have the default browser set to Chrome, it still opens up Safari. On the suppostion that "the default browser" is actually multiple settings, one for each of several URL (URI?) schemes, what do these two shell commands do for you? From a shell prompt in a Terminal: open file://localhost/nonexistingfile and open http://www.python.org/ Do they both open Chome for you? -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ DRM doesn't inconvenience pirates ? indeed, over time it trains law-abiding users to become pirates out of sheer frustration. - Charles Stross From steve+comp.lang.python at pearwood.info Sun Feb 26 02:12:06 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 07:12:06 GMT Subject: webbrowser.open always opens up Safari on Lion References: <4f49a8d6$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f49db46$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 14:23:43 +0800, Leo wrote: > On 2012-02-26 11:36 +0800, Steven D'Aprano wrote: >> What part of this do you think is the bug, and why? What part of the >> behaviour actually experienced contradicts the documented behaviour of >> webbrowser.open()? >> >> http://docs.python.org/library/webbrowser.html > > If you have the default browser set to Chrome, it still opens up Safari. That would only be a bug if it occurs with http:// URLs. The documentation clearly says: Note that on some platforms, trying to open a filename using this function, may work and start the operating system?s associated program. However, this is neither supported nor portable. Since you are providing a file:// URL, then the behaviour is unspecified, and no, it is not a bug. Arguably it is a bug that file:// URLs work at all. However, I would guess that if you have a patch to fix this behaviour to something more reasonable (but what?) then it might be approved. Feel free to raise a ticket on the bug tracker. Personally, I'd put it down as a feature request rather than a bug. -- Steven From sdl.web at gmail.com Sun Feb 26 02:29:19 2012 From: sdl.web at gmail.com (Leo) Date: Sun, 26 Feb 2012 15:29:19 +0800 Subject: webbrowser.open always opens up Safari on Lion References: Message-ID: On 2012-02-26 15:04 +0800, Cameron Simpson wrote: > On the suppostion that "the default browser" is actually multiple > settings, one for each of several URL (URI?) schemes, what do these two > shell commands do for you? From a shell prompt in a Terminal: > > open file://localhost/nonexistingfile > and > open http://www.python.org/ > > Do they both open Chome for you? The first one prints: The file /nonexistingfile does not exist. No browser is opened. The second one opened Chrome. Leo From cv33cv33cv33 at gmail.com Sun Feb 26 03:22:31 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Sun, 26 Feb 2012 00:22:31 -0800 (PST) Subject: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM !!!!!!!!!!!!!! Message-ID: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM By: Dr Garry Miller: A very important Christian missionary converted to Islam and became a major herald for Islam, he was a very active missionary and was very knowledgeable about the Bible... This man likes mathematics so much, that's why he likes logic. One day, he decided to read the Quran to try to find any mistakes that he might take advantage of while inviting Muslims to convert to Christianity.... He expected the Koran to be an old book written 14 centuries ago, a book that talks about the desert and so on...He was amazed from what he found. He discovered that this Book had what no other book in the world has.... He expected to find some stories about the hard time that the Prophet Mohammad (Peace Be Upon Him) had, like the death of his wife Khadijah (may Allah be pleased with her) or the death of his sons and daughters...however, he did not find anything like that... and what made him even more confused is that he found a full "sura"(chapter) in the Koran named "Mary" that contains a lot of respect to Mary(peace be upon her) which is not the case even in the books written by Christians nor in their bibles. He did not find a Sura named after "Fatimah"(the prophet's daughter) nor "Aa?ishah"(the Prophet's wife), may Allah(God) be pleased with both of them. He also found that the name of Jesus(Peace Be Upon Him) was mentioned in the Koran 25 times while the name of "Mohammed"(Peace Be Upon Him) was mentioned only 4 times, so he became more confused. He started reading the Koran more thoroughly hoping to find a mistake but he was shocked when he read a great verse which is verse number 82 in Surat Al-Nisa'(Women) that says: ?Do they not consider the Koran (with care)? Had it been from other than Allah, they would surely have found therein much discrepancy?. Dr Miller says about this verse: ? One of the well known scientific principles is the principle of finding mistakes or looking for mistakes in a theory until it?s proved to be right (Falsification Test) ?what?s amazing is that the Holy Quran asks Muslims and non-muslims to try to find mistakes in this book and it tells them that they will never find any?. He also says about this verse: no writer in the world has the courage to write a book and say that it?s empty of mistakes, but the Quran, on the contrary, tells you that it has no mistakes and asks you to try to find one and you won?t find any. Another verse that Dr Miller reflected on for a long time is the verse number 30 in Surat ?Al-Anbiya??(The Prophets): ? Do not the Unbelievers see that the heavens and the earth were joined together (as one unit of Creation), before We clove them asunder? We made from water every living thing. Will they not then believe?? He says: ? This verse is exactly the subject of the scientific research that won the Noble prize in 1973 and was about the theory of the ?Great Explosion?. According to this theory, the universe was the result of a great explosion that leads to the formation of the universe with its skies and planets?. Dr Miller says: ? Now we come to what?s amazing about the Prophet Mohammed (PBUH) and what?s pretended about the devils helping him, God says: ?No evil ones have brought down this (Revelation), it would neither suit them nor would they be able (to produce it). Indeed they have been removed far from even (a chance of) hearing it? (26:210-212). ?When thou do read the Quran, seek Allah's protection from Satan the Rejected One? (16:98). You see? can this be the devil?s way to write a book? how can he write a book then tells you to ask God for protection from this devil before reading that book? those are miraculous verses in this miraculous book! and has a logical answer to those who pretend that it?s from the devil?. And among the stories that amazed Dr Miller is the story of the Prophet (PBUH) with Abu-Lahab? Dr Miller says: ? This man (Abu Lahab) used to hate Islam so much that he would go after the Prophet wherever he goes to humiliate him. If he saw the prophet talking to strangers, he used to wait till he finishes and then ask them: what did Mohammed tell you? If he said it?s white then it?s in reality black and if he said it?s night then it?s day. He meant to falsify all what the prophet says and to make people suspicious about it. And 10 years before the death of Abu Lahab, a sura was inspired to the prophet, named ?Al-Masad?. This sura tells that Abu Lahab will go to hell, in other words, it says that Abu Lahab will not convert to Islam. During 10 years, Abu Lahab could have said: ?Mohammed is saying that I will not become a Muslim and that I will go to the hell fire, but I?m telling you now that I want to convert to Islam and become a Muslim. What do you think about Mohammed now? Is he saying the truth or no? Does his inspiration come from God?? But Abu Lahab did not do that at all although he was disobeying the prophet in all matters, but not in this one. In other words, it was as if the prophet (PBUH) was giving Abu Lahab a chance to prove him wrong! But he did not do that during 10 whole years! he did not convert to Islam and did not even pretend to be a Muslim!! Throughout 10 years, he had the chance to destroy Islam in 1 minute! But this did not happen because those are not the words of Mohammed (PBUH) but the words of God Who knows what?s hidden and knows that Abu Lahab will not become a Muslim. How can the prophet (PBUH) know that Abu Lahab will prove what is said in that Sura if this was not inspiration from Allah? How can he be sure throughout 10 whole years that what he has (the Quran) is true if he did not know that it?s inspiration from Allah?? For a person to take such a risky challenge, this has only one meaning: that this is inspiration from God. ?Perish the hands of the Father of Flame (Abu Lahab)! perish he! No profit to him from all his wealth, and all his gains! Burnt soon will he be in a Fire of blazing Flame! His wife shall carry the (crackling) wood; As fuel! A twisted rope of palm-leaf fibre round her (own) neck!? (surat Al-Masad). Dr Miller says about a verse that amazed him: one of the miracles in the Quran is challenging the future with things that humans cannot predict and to which the ?Falsification Test? applies, this test consists of looking for mistakes until the thing that is being tested is proved to be right. For example, let?s see what the Quran said about the relation between Muslims and Jews. Quran says that Jews are the major enemies for Muslims and this is true until now as the main enemy for Muslims are the Jews. Dr Miller continues: this is considered a great challenge since the Jews have the chance to ruin Islam simply by treating Muslims in a friendly way for few years and then say: here we are treating you as friends and the Quran says that we are your enemies, the Quran must be wrong then! But this did not happen during 1400 years!! and it will never happen because those are the words of The One who knows the unseen (God) and not the words of humans. Dr Miller continues: can you see how the verse that talks about the enmity between Muslims and Jews constitutes a challenge to the human mind? ?Strongest among men in enmity to the Believers wilt thou find the Jews and Pagans; and nearest among them in love to the Believers wilt thou find those who say, "We are Christians": because amongst these are men devoted to learning and men who have renounced the world, and they are not arrogant. And when they listen to the revelation received by the Messenger, thou wilt see their eyes overflowing with tears, for they recognize the truth: they pray: "Our Lord! We believe; write us down among the witnesses? (5: 82-84) This verse applies to Dr Miller as he was a Christian but when he knew the truth, he believed and converted to Islam and became a herald. May Allah support him. Dr Miller says about the unique style of the Quran that he finds wonderful: no doubt there is something unique and amazing in Quran that is not present anywhere else, as the Quran gives you specific information and tells you that you did not know this before. For example: "This is part of the tidings of the things unseen, which We reveal unto thee (O Prophet!) by inspiration: thou was not with them when they cast lots with arrows, as to which of them should be charged with the care of Maryam: nor was thou with them when they disputed (the point)? (3: 44). ?Such are some of the stories of the Unseen, which We have revealed unto thee: before this, neither thou nor thy People knew them. So persevere patiently: for the End is for those who are righteous? (11: 49). ?Such is one of the stories of what happened unseen, which We reveal by inspiration unto thee: nor was thou (present) with them when they concerted their plans together in the process of weaving their plots? (12: 102) Dr Miller continues: ? No other holy book uses this style, all the other books consist of information that tells you where this information came from. For example, when the (distorted) holy bible talks about the stories of the ancient nations, it tells you that a this king lived in a this place and a that leader fought in that battle, and that a certain person had a number of kids and their names are?. But this book (distorted Bible) always tells you that if you want to know more, you can read a certain book since that information came from that book?. Dr Garry Miller continues: ?this is in contrary to the Quran which gives you the information and tells you that it?s new!! And what?s amazing is that the people of Mecca at that time -time of inspiration of those verses- used to hear those verses and the challenge that the information in those verses was new and was not known by Mohammed (PBUH) nor by his people at that time, and despite that, they never said: we know this and it is not new, and they did not say: we know where Mohammed came from with those verses. This never happened, but what happened is that nobody dared to say that he was lying to them because those was really new information, not coming from the human mind but from Allah who knows the unseen in the past, the present and the future?. May Allah reward Dr Miller for this nice reflection on the Book of Allah For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From cv33cv33cv33 at gmail.com Sun Feb 26 03:29:11 2012 From: cv33cv33cv33 at gmail.com (BV) Date: Sun, 26 Feb 2012 00:29:11 -0800 (PST) Subject: MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM !!!!!!!!!!!!!! Message-ID: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM By: Dr Garry Miller: A very important Christian missionary converted to Islam and became a major herald for Islam, he was a very active missionary and was very knowledgeable about the Bible... This man likes mathematics so much, that's why he likes logic. One day, he decided to read the Quran to try to find any mistakes that he might take advantage of while inviting Muslims to convert to Christianity.... He expected the Koran to be an old book written 14 centuries ago, a book that talks about the desert and so on...He was amazed from what he found. He discovered that this Book had what no other book in the world has.... He expected to find some stories about the hard time that the Prophet Mohammad (Peace Be Upon Him) had, like the death of his wife Khadijah (may Allah be pleased with her) or the death of his sons and daughters...however, he did not find anything like that... and what made him even more confused is that he found a full "sura"(chapter) in the Koran named "Mary" that contains a lot of respect to Mary(peace be upon her) which is not the case even in the books written by Christians nor in their bibles. He did not find a Sura named after "Fatimah"(the prophet's daughter) nor "Aa?ishah"(the Prophet's wife), may Allah(God) be pleased with both of them. He also found that the name of Jesus(Peace Be Upon Him) was mentioned in the Koran 25 times while the name of "Mohammed"(Peace Be Upon Him) was mentioned only 4 times, so he became more confused. He started reading the Koran more thoroughly hoping to find a mistake but he was shocked when he read a great verse which is verse number 82 in Surat Al-Nisa'(Women) that says: ?Do they not consider the Koran (with care)? Had it been from other than Allah, they would surely have found therein much discrepancy?. Dr Miller says about this verse: ? One of the well known scientific principles is the principle of finding mistakes or looking for mistakes in a theory until it?s proved to be right (Falsification Test) ?what?s amazing is that the Holy Quran asks Muslims and non-muslims to try to find mistakes in this book and it tells them that they will never find any?. He also says about this verse: no writer in the world has the courage to write a book and say that it?s empty of mistakes, but the Quran, on the contrary, tells you that it has no mistakes and asks you to try to find one and you won?t find any. Another verse that Dr Miller reflected on for a long time is the verse number 30 in Surat ?Al-Anbiya??(The Prophets): ? Do not the Unbelievers see that the heavens and the earth were joined together (as one unit of Creation), before We clove them asunder? We made from water every living thing. Will they not then believe?? He says: ? This verse is exactly the subject of the scientific research that won the Noble prize in 1973 and was about the theory of the ?Great Explosion?. According to this theory, the universe was the result of a great explosion that leads to the formation of the universe with its skies and planets?. Dr Miller says: ? Now we come to what?s amazing about the Prophet Mohammed (PBUH) and what?s pretended about the devils helping him, God says: ?No evil ones have brought down this (Revelation), it would neither suit them nor would they be able (to produce it). Indeed they have been removed far from even (a chance of) hearing it? (26:210-212). ?When thou do read the Quran, seek Allah's protection from Satan the Rejected One? (16:98). You see? can this be the devil?s way to write a book? how can he write a book then tells you to ask God for protection from this devil before reading that book? those are miraculous verses in this miraculous book! and has a logical answer to those who pretend that it?s from the devil?. And among the stories that amazed Dr Miller is the story of the Prophet (PBUH) with Abu-Lahab? Dr Miller says: ? This man (Abu Lahab) used to hate Islam so much that he would go after the Prophet wherever he goes to humiliate him. If he saw the prophet talking to strangers, he used to wait till he finishes and then ask them: what did Mohammed tell you? If he said it?s white then it?s in reality black and if he said it?s night then it?s day. He meant to falsify all what the prophet says and to make people suspicious about it. And 10 years before the death of Abu Lahab, a sura was inspired to the prophet, named ?Al-Masad?. This sura tells that Abu Lahab will go to hell, in other words, it says that Abu Lahab will not convert to Islam. During 10 years, Abu Lahab could have said: ?Mohammed is saying that I will not become a Muslim and that I will go to the hell fire, but I?m telling you now that I want to convert to Islam and become a Muslim. What do you think about Mohammed now? Is he saying the truth or no? Does his inspiration come from God?? But Abu Lahab did not do that at all although he was disobeying the prophet in all matters, but not in this one. In other words, it was as if the prophet (PBUH) was giving Abu Lahab a chance to prove him wrong! But he did not do that during 10 whole years! he did not convert to Islam and did not even pretend to be a Muslim!! Throughout 10 years, he had the chance to destroy Islam in 1 minute! But this did not happen because those are not the words of Mohammed (PBUH) but the words of God Who knows what?s hidden and knows that Abu Lahab will not become a Muslim. How can the prophet (PBUH) know that Abu Lahab will prove what is said in that Sura if this was not inspiration from Allah? How can he be sure throughout 10 whole years that what he has (the Quran) is true if he did not know that it?s inspiration from Allah?? For a person to take such a risky challenge, this has only one meaning: that this is inspiration from God. ?Perish the hands of the Father of Flame (Abu Lahab)! perish he! No profit to him from all his wealth, and all his gains! Burnt soon will he be in a Fire of blazing Flame! His wife shall carry the (crackling) wood; As fuel! A twisted rope of palm-leaf fibre round her (own) neck!? (surat Al-Masad). Dr Miller says about a verse that amazed him: one of the miracles in the Quran is challenging the future with things that humans cannot predict and to which the ?Falsification Test? applies, this test consists of looking for mistakes until the thing that is being tested is proved to be right. For example, let?s see what the Quran said about the relation between Muslims and Jews. Quran says that Jews are the major enemies for Muslims and this is true until now as the main enemy for Muslims are the Jews. Dr Miller continues: this is considered a great challenge since the Jews have the chance to ruin Islam simply by treating Muslims in a friendly way for few years and then say: here we are treating you as friends and the Quran says that we are your enemies, the Quran must be wrong then! But this did not happen during 1400 years!! and it will never happen because those are the words of The One who knows the unseen (God) and not the words of humans. Dr Miller continues: can you see how the verse that talks about the enmity between Muslims and Jews constitutes a challenge to the human mind? ?Strongest among men in enmity to the Believers wilt thou find the Jews and Pagans; and nearest among them in love to the Believers wilt thou find those who say, "We are Christians": because amongst these are men devoted to learning and men who have renounced the world, and they are not arrogant. And when they listen to the revelation received by the Messenger, thou wilt see their eyes overflowing with tears, for they recognize the truth: they pray: "Our Lord! We believe; write us down among the witnesses? (5: 82-84) This verse applies to Dr Miller as he was a Christian but when he knew the truth, he believed and converted to Islam and became a herald. May Allah support him. Dr Miller says about the unique style of the Quran that he finds wonderful: no doubt there is something unique and amazing in Quran that is not present anywhere else, as the Quran gives you specific information and tells you that you did not know this before. For example: "This is part of the tidings of the things unseen, which We reveal unto thee (O Prophet!) by inspiration: thou was not with them when they cast lots with arrows, as to which of them should be charged with the care of Maryam: nor was thou with them when they disputed (the point)? (3: 44). ?Such are some of the stories of the Unseen, which We have revealed unto thee: before this, neither thou nor thy People knew them. So persevere patiently: for the End is for those who are righteous? (11: 49). ?Such is one of the stories of what happened unseen, which We reveal by inspiration unto thee: nor was thou (present) with them when they concerted their plans together in the process of weaving their plots? (12: 102) Dr Miller continues: ? No other holy book uses this style, all the other books consist of information that tells you where this information came from. For example, when the (distorted) holy bible talks about the stories of the ancient nations, it tells you that a this king lived in a this place and a that leader fought in that battle, and that a certain person had a number of kids and their names are?. But this book (distorted Bible) always tells you that if you want to know more, you can read a certain book since that information came from that book?. Dr Garry Miller continues: ?this is in contrary to the Quran which gives you the information and tells you that it?s new!! And what?s amazing is that the people of Mecca at that time -time of inspiration of those verses- used to hear those verses and the challenge that the information in those verses was new and was not known by Mohammed (PBUH) nor by his people at that time, and despite that, they never said: we know this and it is not new, and they did not say: we know where Mohammed came from with those verses. This never happened, but what happened is that nobody dared to say that he was lying to them because those was really new information, not coming from the human mind but from Allah who knows the unseen in the past, the present and the future?. May Allah reward Dr Miller for this nice reflection on the Book of Allah For more information about Islam http://www.islam-guide.com http://www.islamhouse.com/s/9661 http://www.thisistruth.org http://www.quran-m.com/firas/en1 http://kaheel7.com/eng http://www.knowmuhammad.com http://www.rasoulallah.net/v2/index.aspx?lang=e http://imanway1.com/eng http://www.todayislam.com http://www.thekeytoislam.com http://www.islamland.com http://www.discoverislam.com http://www.thetruereligion.org http://www.beconvinced.com http://islamtomorrow.com http://www.usc.edu/dept/MSA/quran http://www.quranforall.org http://www.quranexplorer.com/quran http://www.prophetmuhammed.org http://chatislamonline.org/en/ http://www.dar-us-salam.com http://youtubeislam.com From ben+python at benfinney.id.au Sun Feb 26 03:47:49 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 19:47:49 +1100 Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87y5rqrney.fsf@benfinney.id.au> Steven D'Aprano writes: > The preferred terms in Python circles are class and instance > *attributes*, not variables. Yes, full ACK. > An integer variable is a variable holding an integer. > A string variable is a variable holding a string. > A list variable is a variable holding a list. And Python has none of those. Its references don't ?hold? anything. I appreciate that you think ?variable? is a useful term in Python, but this kind of mangling of the concept convinces me that it's not worth it. Python doesn't have variables, and even if you want to say ?variables? when you mean ?references?, there's no such thing as a ?string variable? etc. in Python. References don't have types, so its needlessly confusing to perpetuate that kind of thinking. > Other languages may choose to use illogical terminology if they choose. Whereas we are not beholden to it, so let's avoid it where feasible, and help newcomers to do so. -- \ ?There is no reason anyone would want a computer in their | `\ home.? ?Ken Olson, president, chairman and founder of Digital | _o__) Equipment Corp., 1977 | Ben Finney From ben+python at benfinney.id.au Sun Feb 26 03:51:40 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 19:51:40 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: Message-ID: <87ty2ern8j.fsf@benfinney.id.au> Benjamin Peterson writes: > We're pleased to announce the immediate availability of release candidates for > Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . If you're pleased to announce their immediate availability, then please do that! Putting ?RELEASED? in the subject, when they're not released and are instead *candidates for* release, is confusing and muddies the issue of what you even mean by ?release?. -- \ ?Give a man a fish, and you'll feed him for a day; give him a | `\ religion, and he'll starve to death while praying for a fish.? | _o__) ?Anonymous | Ben Finney From rosuav at gmail.com Sun Feb 26 04:03:49 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Feb 2012 20:03:49 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87ty2ern8j.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: > Benjamin Peterson writes: > >> We're pleased to announce the immediate availability of release candidates for >> Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . > > If you're pleased to announce their immediate availability, then please > do that! Isn't it perfectly accurate to say that the RCs are now available? Considering that "Release candidates" immediately followed "RELEASED" in the subject line, I don't see any confusion. ChrisA From muthu17024 at gmail.com Sun Feb 26 04:29:10 2012 From: muthu17024 at gmail.com (muthu kutti) Date: Sun, 26 Feb 2012 01:29:10 -0800 (PST) Subject: python Message-ID: <72daafb9-95b1-4e22-ab2e-5833a71887d5@c21g2000yqi.googlegroups.com> http://123maza.com/46/glory687/ From wxjmfauth at gmail.com Sun Feb 26 04:59:14 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Sun, 26 Feb 2012 01:59:14 -0800 (PST) Subject: Python math is off by .000000000000045 References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 25 f?v, 23:51, Steven D'Aprano wrote: > On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: > >>>> (2.0).hex() > > '0x1.0000000000000p+1' > >>>> (4.0).hex() > > '0x1.0000000000000p+2' > >>>> (1.5).hex() > > '0x1.8000000000000p+0' > >>>> (1.1).hex() > > '0x1.199999999999ap+0' > > > jmf > > What's your point? I'm afraid my crystal ball is out of order and I have > no idea whether you have a question or are just demonstrating your > mastery of copy and paste from the Python interactive interpreter. > It should be enough to indicate the right direction for casual interested readers. From frank at chagford.com Sun Feb 26 05:42:18 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 12:42:18 +0200 Subject: Question about circular imports Message-ID: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to access something in Module B, and a method in Module B needs to access something in Module A. I know that the standard advice is to reorganise the code to avoid this, and I try to do this where possible, but for now I would like to address the question of how to handle the situation if this is otherwise unavoidable. The problem is clearly explained in the Python Programming FAQ - "Circular imports are fine where both modules use the "import " form of import. They fail when the 2nd module wants to grab a name out of the first ("from module import name") and the import is at the top level. That's because names in the 1st are not yet available, because the first module is busy importing the 2nd." Having recently reorganised my code into packages, I find that the same problem arises with packages. Assume the following structure, copied from the Tutorial - sound/ __init__.py formats/ __init__.py wavread.py wavwrite.py The following fails - in wavread.py - from formats import wavwrite [this works] in wavwrite.py - from formats import wavread [this fails with ImportError] I can think of two solutions - one is cumbersome, the other may not be good practice. The first solution is - in wavread.py - import formats.wavwrite in wavwrite.py - import formats.wavread I then have to use the full path to reference any attribute inside the imported module, which I find cumbersome. The second solution is - in formats/__init__.py import sys sys.path.insert(0, __path__[0]) in wavread.py - import wavwrite in wavwrite.py - import wavread This works, but I don't know if it is a good idea to add all the sub-package paths to sys.path. I realise that it is up to me to avoid any name clashes. Are there any other downsides? So I guess my question is - - is there a better solution to my problem? - if not, is my second solution acceptable? If not, I seem to be stuck with using full path names to reference any attributes in imported modules. I am using Python3 exclusively now, if that makes any difference. Any advice will be appreciated. Frank Millman From __peter__ at web.de Sun Feb 26 06:12:55 2012 From: __peter__ at web.de (Peter Otten) Date: Sun, 26 Feb 2012 12:12:55 +0100 Subject: Question about circular imports References: Message-ID: Frank Millman wrote: > I seem to have a recurring battle with circular imports, and I am trying > to nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is > to reorganise the code to avoid this, and I try to do this where possible, > but for now I would like to address the question of how to handle the > situation if this is otherwise unavoidable. To cut a long story short, why should circular imports be unavoidable? > The problem is clearly explained in the Python Programming FAQ - > > "Circular imports are fine where both modules use the "import " > form of import. They fail when the 2nd module wants to grab a name out of > the first ("from module import name") and the import is at the top level. > That's because names in the 1st are not yet available, because the first > module is busy importing the 2nd." > > Having recently reorganised my code into packages, I find that the same > problem arises with packages. Assume the following structure, copied from > the Tutorial - > > sound/ > __init__.py > formats/ > __init__.py > wavread.py > wavwrite.py > > The following fails - > > in wavread.py - > from formats import wavwrite [this works] > > in wavwrite.py - > from formats import wavread [this fails with ImportError] > > I can think of two solutions - one is cumbersome, the other may not be > good practice. > > The first solution is - > > in wavread.py - > import formats.wavwrite > > in wavwrite.py - > import formats.wavread This should be import sound.formats.wavread > I then have to use the full path to reference any attribute inside the > imported module, which I find cumbersome. > > The second solution is - > > in formats/__init__.py > import sys > sys.path.insert(0, __path__[0]) > > in wavread.py - > import wavwrite > > in wavwrite.py - > import wavread > > This works, but I don't know if it is a good idea to add all the > sub-package paths to sys.path. I realise that it is up to me to avoid any > name clashes. Are there any other downsides? > > So I guess my question is - > > - is there a better solution to my problem? > - if not, is my second solution acceptable? Paths into packages are recipe for desaster. You may end up with multiple instances of the same module and your programs will break in "interesting" (hard to debug) ways. > If not, I seem to be stuck with using full path names to reference any > attributes in imported modules. > > I am using Python3 exclusively now, if that makes any difference. > > Any advice will be appreciated. > > Frank Millman From frank at chagford.com Sun Feb 26 06:18:20 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 13:18:20 +0200 Subject: Question about circular imports References: Message-ID: "Frank Millman" wrote in message news:jid2a9$n21$1 at dough.gmane.org... > Hi all > > I seem to have a recurring battle with circular imports, and I am trying > to nail it once and for all. > [...] > > The second solution is - > > in formats/__init__.py > import sys > sys.path.insert(0, __path__[0]) > > in wavread.py - > import wavwrite > > in wavwrite.py - > import wavread > > This works, but I don't know if it is a good idea to add all the > sub-package paths to sys.path. I realise that it is up to me to avoid any > name clashes. Are there any other downsides? > Answering my own question, I have just found a downside that is a showstopper. If a module in a different sub-package needs to import one of these modules, it must use a full path. This results in a new entry in sys.modules, and therefore any attributes referenced by the intra-package module have different identities from those referenced from outside. If they are static, there is no problem, but if not, disaster strikes! Frank From frank at chagford.com Sun Feb 26 06:22:21 2012 From: frank at chagford.com (Frank Millman) Date: Sun, 26 Feb 2012 13:22:21 +0200 Subject: Question about circular imports References: Message-ID: "Peter Otten" <__peter__ at web.de> wrote in message news:jid424$vfp$1 at dough.gmane.org... > Frank Millman wrote: > > > To cut a long story short, why should circular imports be unavoidable? > > Paths into packages are recipe for desaster. You may end up with multiple > instances of the same module and your programs will break in "interesting" > (hard to debug) ways. > Thanks, Peter. I have just figured this out for myself, but you beat me to it. Full paths it is, then. Frank From ssmile03 at gmail.com Sun Feb 26 06:25:23 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Sun, 26 Feb 2012 16:55:23 +0530 Subject: pickle handling multiple objects .. Message-ID: If I have a sample python code to be executed on Linux. How should I handle multiple objects with 'pickle' as below - ------- #!/usr/bin/python import pickle #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] #my_list = () output = open('readfile.pkl', 'wb') pickle.dump(my_list, output) output.close() my_file = open('readfile.pkl', 'rb') my_list2 = pickle.load(my_file) my_file.close() print my_list print my_list2 ----- This code works fine but now I have to handle multiple objects? -------------- next part -------------- An HTML attachment was scrubbed... URL: From WolfgangMeiners01 at web.de Sun Feb 26 06:56:46 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 12:56:46 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> Message-ID: <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Am 25.02.12 18:54, schrieb MRAB: >> If there is no limit for len(string), why not simply use >> >> # get_limit() returns None if there is no limit >> maxlength = get_limit() >> if maxlength and (len(string)<= maxlength): >> allow_passage() >> else: >> deny_passage() >> > That should be: > > if maxlength is not None and len(string) <= maxlength: Take a look at http://docs.python.org/library/stdtypes.html where you can read: ========================================================================= Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below. The following values are considered false: None False zero of any numeric type, for example, 0, 0L, 0.0, 0j. any empty sequence, for example, '', (), []. any empty mapping, for example, {}. instances of user-defined classes, if the class defines __nonzero__() or __len__() method, when that method returns the integer zero or bool value False. [1] All other values are considered true ? so objects of many types are always true. ========================================================================== That means: if maxlength and (len(string) <= maxlength): is equivalent to if (maxlength is not None) and (len(string) <= maxlength): which is more complicated to type and -in my opinion- not so intuitive. But because it is equivalent, it is a matter of taste, what to use. Wolfgang From albert at spenarnc.xs4all.nl Sun Feb 26 06:57:22 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 11:57:22 GMT Subject: generate Windows exe on Linux References: <19595323.1268.1329912749669.JavaMail.geo-discussion-forums@pbux2> <20120222184211.1935846f@bouzin.lan> Message-ID: In article , Gelonida N wrote: >On 02/22/2012 07:05 PM, Alec Taylor wrote: >> http://www.pyinstaller.org/ >> >> or >> >> http://cx-freeze.sourceforge.net/ >> >> You can also run py2exe in WINE >> > >You want to say, that I could install python 2.6 >some packages like win32api >PyQt and tand py2exe under Wine and then compile it. > > >Did you try this? > >I didn't even think about trying this out, >but I know very little about the limits of Wine, so perhaps I >underestimate it. As a case in point I have this example of another language: colorforth. It was made by a genius inventor (Chuck Moore), and only runs from a boot-floppy and writes pixels to the screen. Someone made an environment in MS-Windows to emulate the booting process and all. This actually runs colorforth. Now about Wine, how good is it? Actually it is good enough to run the above emulator! (We run a third emulator, of the GA144, on top at a decent speed.) Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From clp2 at rebertia.com Sun Feb 26 06:58:18 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 26 Feb 2012 03:58:18 -0800 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 3:25 AM, Smiley 4321 wrote: > If I have a sample python code to be executed on Linux. How should? I handle > multiple objects with 'pickle' as below - > > ------- > #!/usr/bin/python > > import pickle > > #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} > #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') > my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] > #my_list = () > output = open('readfile.pkl', 'wb') > pickle.dump(my_list, output) > output.close() > > my_file = open('readfile.pkl', 'rb') > my_list2 = pickle.load(my_file) > my_file.close() > > print my_list > print my_list2 > ----- > > This code works fine but now I have to handle multiple objects? You can either nest the multiple objects inside a single compound object and just (un)pickle that, or you call call dump()/load() repeatedly (once per object; yes, this works). Cheers, Chris From __peter__ at web.de Sun Feb 26 07:04:00 2012 From: __peter__ at web.de (Peter Otten) Date: Sun, 26 Feb 2012 13:04 +0100 Subject: pickle handling multiple objects .. References: Message-ID: Smiley 4321 wrote: > If I have a sample python code to be executed on Linux. How should I > handle multiple objects with 'pickle' as below - > > ------- > #!/usr/bin/python > > import pickle > > #my_list = {'a': 'Apple', 'b': 'Mango', 'c': 'Orange', 'd': 'Pineapple'} > #my_list = ('Apple', 'Mango', 'Orange', 'Pineapple') > my_list = ['Apple', 'Mango', 'Orange', 'Pineapple'] > #my_list = () > output = open('readfile.pkl', 'wb') > pickle.dump(my_list, output) > output.close() > > my_file = open('readfile.pkl', 'rb') > my_list2 = pickle.load(my_file) > my_file.close() > > print my_list > print my_list2 > ----- > > This code works fine but now I have to handle multiple objects? You never do that with pickle. You pack your data into a single object before you store it, and unpack it after loading it. Here's an example using a tuple as the container: fruit = ["apple", "orange"] vegetables = ["potato", "tomato"] beverages = ["milk", "coffee", "water"] with open("tmp.pickle", "wb") as f: pickle.dump((fruit, vegetables, beverages), f) with open("tmp.pickle", "rb") as f: fruit, vegetables, beverages = pickle.load(f) print fruit print vegetables print beverages This is however a bit errorprone. If you accidentally write the loading code as fruit, beverages, vegetables = pickle.load(f) you'll end up drinking potatoes. A better container would be a dict. Something like pickle.dump(dict(fruit=fruit, vegetables=vegetables, beverages=beverages), f) ... data = pickle.load(f) fruit = data["fruit"] beverages = data["beverages"] vegetables = data["vegetables"] is harder to get wrong. It is also easier to extend. Code that only reads the pickle will happily ignore extra keys in the dictionary. If you follow that path somewhat more you will probably drop the lowlevel pickle and use a key-value store like Python's shelve instead, see http://docs.python.org/library/shelve.html From albert at spenarnc.xs4all.nl Sun Feb 26 07:14:38 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 12:14:38 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: In article , Rick Johnson wrote: >On Feb 18, 1:28=A0am, Ian Kelly wrote: >> On Fri, Feb 17, 2012 at 6:13 PM, Rick Johnson > > >> If I were to [sum my tax burden], it would >> probably come to around 30%, which still doesn't bother me, in part >> because I know that it comes back to benefit the society I live in, >> and by extension me, in one way or another.. > >But do you think you'll get a higher return for your investment? Is it >possible to get a higher return on your investment in this type of >system? NO! You better off just paying for your own damn healthcare. > >Well actually, there is a way to get a higher return by taking more >than your "fair share". Any intelligent person would realize that >public healthcare is advocated by degenerates or the bleeding heart >"degenerate eugenics" supporters. Fine, YOU want to subsidize >degeneracy? Then give to charity. The more you give the better you'll >feel. BTW: How much money do you give to charity? This is technically wrong. It is much cheaper for you to pay a few euro's to combat TBC, then live in a TBC-infected society where you must take great care not to be infected yourself. Paying to rid the society of TBC is not charity, it is is common sense. Your ideas only work for the anti-social few, in an otherwise social society. Education is another case in point. It is in you best interest to allow a getto-genius into Harvard. Otherwise they will become the master-minds of crime. And you will be too stupid to beat them. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From ben+python at benfinney.id.au Sun Feb 26 07:21:07 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Sun, 26 Feb 2012 23:21:07 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: <87haydss3w.fsf@benfinney.id.au> Chris Angelico writes: > On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: > > If you're pleased to announce their immediate availability, then > > please do that! > > Isn't it perfectly accurate to say that the RCs are now available? Yes. What's not reasonable is to say that a candidate for release ? i.e. something *prior to* release, by definition ? is nevertheless released. > Considering that "Release candidates" immediately followed "RELEASED" > in the subject line, I don't see any confusion. Unless ?release candidate? means nothing like what those words imply, it can't be both a release candidate *and* released. Either it's released, or it's not. If it's a release candidate, it's not released yet. If it's released, it's no longer a candidate for release. Saying it's simultaneously both is the confusion. -- \ ?The Things to do are: the things that need doing, that you see | `\ need to be done, and that no one else seems to see need to be | _o__) done.? ?Richard Buckminster Fuller, 1970-02-16 | Ben Finney From albert at spenarnc.xs4all.nl Sun Feb 26 07:44:13 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 26 Feb 2012 12:44:13 GMT Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: In article <40af8461-1583-4496-9d81-d52d6905d24d at b23g2000yqn.googlegroups.com>, Rick Johnson wrote: >Because the Jews allowed themselves to be subjected. Sad, but true. Actually Jew stands for (relative) coward. Let me explain. Jew comes from Juda, one of the 12 tribes. At some time Israel was subjected and 11 tribes resisted to the death and are eradicated since. Only the Juda tribe gave in and their land was called Judea since. (So the name Israel for the current state is a propagandistic lie, to claim the land once occupied by the 12 tribes.) I don't blame them for the attitude of "live to fight another day" or even for plain survival. If the Jews hadn't allow themselves to be subjected, there would be no Jews. >Slaves only exist because they allow themselves to exist. When people Never been a slave, were you? Try to imagine what it is to be born a slave. > >"Freeeeeedoooooooommmmmmm!" >"Live free, or die!" >"From my cold dead hand!" >"Over my dead body!" >"Freedom is never voluntarily given by the oppressor; it must be >demanded by the oppressed." >"Those who deny freedom to others deserve it not for themselves." >"Man is free at the moment he wishes to be." >"Those who desire to give up freedom in order to gain security, will >not have, nor do they deserve, either one." Black Panther comes to mind. The USA just killed them. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From rosuav at gmail.com Sun Feb 26 07:52:16 2012 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 26 Feb 2012 23:52:16 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners wrote: > That means: > if maxlength and (len(string) <= maxlength): > > is equivalent to > if (maxlength is not None) and (len(string) <= maxlength): On the contrary, it means they are distinctly NOT equivalent. The shorter form would treat a maximum length of 0 as meaning "unlimited". Now, that's an understandable notation, but it's not what's given here; if None means unlimited, then 0 should enforce that string == "". ChrisA From rosuav at gmail.com Sun Feb 26 08:00:31 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 00:00:31 +1100 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > This is however a bit errorprone. If you accidentally write the loading code > as > > fruit, beverages, vegetables = pickle.load(f) > > you'll end up drinking potatoes. You mean vodka? :) Additionally, you'll get a weird crash out of your program if load() returns something other than a sequence of length 3. Remember, everything that comes from outside your code is untrusted, even if you think you made it just two seconds ago. Of course, sometimes that exception is absolutely correct. If you wrap all this in an exception handler that gives some reasonable behaviour - which might even be "terminate the program with a traceback", which is the default - then it's fine to let it throw on failure, and anything else is just a waste of effort. But for maximum extensibility, you would want to make it so that you can add more elements to what you save without your code breaking on an old save file - and that's where the dictionary is far better. A slight tweak, though: data = pickle.load(f) fruit = data.get("fruit",[]) beverages = data.get("beverages",[]) vegetables = data.get("vegetables",[]) With this, you guarantee that (a) unrecognized keys will be safely ignored, and (b) absent keys will quietly go to their given defaults. ChrisA From rosuav at gmail.com Sun Feb 26 08:01:55 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 00:01:55 +1100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87haydss3w.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: On Sun, Feb 26, 2012 at 11:21 PM, Ben Finney wrote: > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. > > Either it's released, or it's not. If it's a release candidate, it's not > released yet. If it's released, it's no longer a candidate for release. Sure, fair enough. So what DO you do with an RC? "Make it available"? Seems a little verbose, but it's the best I can think of off-hand. ChrisA From steve+comp.lang.python at pearwood.info Sun Feb 26 08:08:35 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:08:35 GMT Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: <4f4a2ed2$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 23:21:07 +1100, Ben Finney wrote: > Chris Angelico writes: > >> On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney >> wrote: > >> > If you're pleased to announce their immediate availability, then >> > please do that! >> >> Isn't it perfectly accurate to say that the RCs are now available? > > Yes. What's not reasonable is to say that a candidate for release ? i.e. > something *prior to* release, by definition ? is nevertheless released. We have a piece of software which has just been actively released to the public in a known fixed state, with a specific version number (2.6.8rc etc.). Since this active process of *releasing* software has occurred, the past tense "[RELEASED]" applies. What sort of software is it? Well, it's not a pre-alpha, or alpha, or beta version, nor is it the production-release version. It is a candidate to become the production-release, or "Release candidate". Hence we have the release [verb] of a release candidate [compound noun]. There is no contradiction here, any more than it would be a contradiction to release a beta version. http://en.wikipedia.org/wiki/Software_release_life_cycle >> Considering that "Release candidates" immediately followed "RELEASED" >> in the subject line, I don't see any confusion. > > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. What do you believe the words imply? I believe that they imply that the version is a candidate to be a production-ready release of the software, as opposed to a pre-alpha, alpha or beta version, but not yet the production-ready version. -- Steven From WolfgangMeiners01 at web.de Sun Feb 26 08:16:24 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:16:24 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> Message-ID: <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Am 25.02.12 21:35, schrieb Rick Johnson: > On Feb 25, 11:54 am, MRAB wrote: >> [...] >> That should be: >> if maxlength is not None and len(string) <= maxlength: > > Using "imaginary" infinity values defiles the intuitive nature of your > code. What is more intuitive? > > def confine_length(string, maxlength=INFINITY): > if string.length < maxlength: > do_something() > > def confine_length(string, maxlength=None): > if maxlength is not None and len(string) <= maxlength: > do_something() I just had a closer look at it. It seems to be more complicated than i thougth: You will have to write def confine_length(string, maxlength=None): if maxlength: # maxlength exists, comparison possible if len(string) <= maxlength: do_something() else: # maxlength does not exist, so always do something do_something() you migth also write def confine_length(str, maxlength=None): do_it = (len(str) <= maxlength) if maxlength else True if do_it: do_something() but it really does not look intuitive. Hmm. My idea was that None is a perfect Value for infinity since there is no infinitely large number. But as i see it, you must have two comparisons then. Maybe someone has a better idea? Wolfgang From steve+comp.lang.python at pearwood.info Sun Feb 26 08:19:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:19:23 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a315b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 12:56:46 +0100, Wolfgang Meiners wrote: > That means: > if maxlength and (len(string) <= maxlength): > > is equivalent to > if (maxlength is not None) and (len(string) <= maxlength): > > which is more complicated to type and -in my opinion- not so intuitive. > But because it is equivalent, it is a matter of taste, what to use. Incorrect. The two are *not* equivalent. def test(maxlength, string): flag1 = maxlength and (len(string) <= maxlength) flag2 = (maxlength is not None) and (len(string) <= maxlength) return bool(flag1), bool(flag2) # normalise to booleans >>> test(0, '') (False, True) So the two forms will take opposite branches of the if statement when maxlength is 0 and string is the empty string. -- Steven From WolfgangMeiners01 at web.de Sun Feb 26 08:32:51 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:32:51 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <4f4a1df9$0$7609$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a3483$0$7619$9b4e6d93@newsspool1.arcor-online.net> Am 26.02.12 13:52, schrieb Chris Angelico: > On Sun, Feb 26, 2012 at 10:56 PM, Wolfgang Meiners > wrote: >> That means: >> if maxlength and (len(string) <= maxlength): >> >> is equivalent to >> if (maxlength is not None) and (len(string) <= maxlength): > > On the contrary, it means they are distinctly NOT equivalent. The > shorter form would treat a maximum length of 0 as meaning "unlimited". > Now, that's an understandable notation, but it's not what's given > here; if None means unlimited, then 0 should enforce that string == > "". > > ChrisA You are right. It seems I did not get the line zero of any numeric type, for example, 0, 0L, 0.0, 0j. right. Wolfgang From WolfgangMeiners01 at web.de Sun Feb 26 08:38:37 2012 From: WolfgangMeiners01 at web.de (Wolfgang Meiners) Date: Sun, 26 Feb 2012 14:38:37 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> Am 26.02.12 14:16, schrieb Wolfgang Meiners: > > I just had a closer look at it. It seems to be more complicated than i > thougth: You will have to write Obviously not close enough, as i just learned. > > def confine_length(string, maxlength=None): > if maxlength: # maxlength exists, comparison possible if maxlength is not None: # maxlength exists, comparison possible > if len(string) <= maxlength: > do_something() > else: # maxlength does not exist, so always do something > do_something() > > you migth also write > > def confine_length(str, maxlength=None): > do_it = (len(str) <= maxlength) if maxlength else True do_it = (len(str) <= maxlength) if maxlength is not None else True > if do_it: > do_something() > I hope, it's correct now. Wolfgang From steve+comp.lang.python at pearwood.info Sun Feb 26 08:40:03 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:40:03 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> Message-ID: <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: >> An integer variable is a variable holding an integer. A string variable >> is a variable holding a string. A list variable is a variable holding a >> list. > > And Python has none of those. Its references don't ?hold? anything. Ah, but they do. Following the name binding: x = 1 the name "x" now holds a reference to an int, or if you want to cut out one layer of indirection, the name "x" holds an int. That is to say, the value associated with the name "x" is an int. I don't believe this is a troublesome concept. > I appreciate that you think ?variable? is a useful term in Python, but > this kind of mangling of the concept convinces me that it's not worth > it. I'm not sure that there is any mangling here. Or at least, the concept is only mangled if you believe that Pascal- or C-like variables (named memory locations) are the one true definition of "variable". I do not believe this. Words vary in their meanings, pun not intended, and in the same way that the semantics of classes in (say) Java are not identical to the semantics of classes in Python, so I think that it is perfectly reasonable to talk about Python having variables, implemented using bindings to objects in a namespace, even though the semantics of Python variables is slightly different from that of C variables. Fundamentally, a variable is a name associated with a value which can vary. And Python name bindings meet that definition no less than C fixed memory locations. > Python doesn't have variables, and even if you want to say ?variables? > when you mean ?references?, there's no such thing as a ?string variable? > etc. in Python. References don't have types, so its needlessly confusing > to perpetuate that kind of thinking. But objects have types, and it makes sense to state that the type of the name is the type of the object bound to that name, at least for the duration of the binding. That's exactly what we write in Python: type(x) tells us the type of x, whatever x happens to be. There's no implication that it is the type of the *name* x, since names are not typed. More importantly, while Python doesn't have static types, in real code, names generally are expected to be bound to objects of a particular type (perhaps a duck-type, but still a type). It is rare to have code including a name bound to *anything at all* -- the main counter-example I can think of is the id() function. Generally, names are expected to be bound to a specific kind of value: perhaps as specific as "a string", or as general as "an iterable", or "anything with a __add__ method", but nevertheless there is the expectation that if the name is bound to something else, you will get an error. A compile time error in C, a runtime error in Python, but either way, the expectation is that you get an error. In an example like this: def spam(some_string): return some_string.upper() + "###" I maintain that it is reasonable to say that "some_string is a string variable", since that expresses the programmer's intention that some_string should be bound to string objects (modulo duck-typing). If Python were statically typed, then passing some_string=42 would cause a compile-time error. In Python, you get a runtime error instead. I don't believe this invalidates the idea that some_string is intended to be a string. Or to make this painfully complete: some_string is a name linked to a value which can vary (hence a variable) intended to be limited to strings (hence a string variable). Python may not enforce this to the same extent as C or Haskell or Pascal, but the concept still holds. -- Steven From arnodel at gmail.com Sun Feb 26 08:44:57 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Sun, 26 Feb 2012 13:44:57 +0000 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> <4f4a35dd$0$7614$9b4e6d93@newsspool1.arcor-online.net> Message-ID: On 26 February 2012 13:38, Wolfgang Meiners wrote: > ? ? ?do_it = (len(str) <= maxlength) if maxlength is not None else True That's a funny way to spell: do_it = maxlength is None or len(str) <= maxlength -- Arnaud From steve+comp.lang.python at pearwood.info Sun Feb 26 08:50:01 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 26 Feb 2012 13:50:01 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <4f4a3889$0$29989$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 14:16:24 +0100, Wolfgang Meiners wrote: > I just had a closer look at it. It seems to be more complicated than i > thougth: You will have to write > > def confine_length(string, maxlength=None): > if maxlength: # maxlength exists, comparison possible > if len(string) <= maxlength: > do_something() > else: # maxlength does not exist, so always do something > do_something() No, that still takes the wrong branch for maxlength = 0. Be explicit in your code. If you want maxlength=None to be a sentinel for "avoid the length test", then explicitly test for maxlength is None, don't be tempted to take short-cuts that can fail. def confine_length(string, maxlength=None): if maxlength is None: # no length comparison needed do_something() elif len(string) <= maxlength: do_something() This can be simplified to: def confine_length(string, maxlength=None): if maxlength is None or len(string) <= maxlength: do_something() Or even simpler: def confine_length(string, maxlength=float('inf')): if len(string) <= maxlength: do_something() -- Steven From k.sahithi2862 at gmail.com Sun Feb 26 11:05:31 2012 From: k.sahithi2862 at gmail.com (SAHITHI) Date: Sun, 26 Feb 2012 08:05:31 -0800 (PST) Subject: HOT LINKS FOR YOUTH ONLY Message-ID: HOT LINKS FOR YOUTH ONLY FOR FAST UPDATES IN FILM INDUSTRY KATRINA KAIF RARE PHOTOS http://allyouwants.blogspot.com/2011/12/katrina-kaif.html KAJAL AGARWAL LATEST STILLS http://allyouwants.blogspot.com/2011/03/kajal-latest-stills.html PRIYANKA CHOPRA LATEST HOT PHOTOSHOOT http://allyouwants.blogspot.com/2011/08/priyanka-chopra.html TAMIL ACTRESS HOT PHOTOS&VIDEOS http://allyouwants.blogspot.com/2011/08/tamil-actress.html ANU SMRUTHI LATEST HOT STILLS http://actressimages-9.blogspot.in/2012/02/anu-smirthi-stills.html EK THA TIGER MOVIE STILLS http://actressgallery-kalyani.blogspot.in/2012/02/ek-tha-tiger-movie-stills.html ACTREESS SUPRIYA SHAILJA LATEST STILLS http://actressgallery-kalyani.blogspot.in/2012/02/supriya-shailja-stills.html BOLLYWOOD ACTRESS APSARA AWARDS 2012 http://actressgallery-kalyani.blogspot.in/2012/01/apsara-awards-2012.html AISHWARYA RAI LATEST HOT PICS http://actressimages-9.blogspot.in/2012/01/aishwarya-rai.html KATRINA KAIF HOT MAGAZINES PHOTOS http://actressimages-9.blogspot.in/2012/01/katrina-kaif-magazine-photos.html TRISHA HOT BEAUTIFUL IMAGES http://actressimages-9.blogspot.in/2012/01/trisha-krishnan.html HOT MALLIKA SHERAWAT PHOTOS http://actressimages-9.blogspot.in/2012/01/mallika-sherawat.html SHEELA LATEST HOT STILLS http://actressgallery-kalyani.blogspot.in/2012/01/sheela-latest-stills.html KATRINA KAIF ITEM SONG STILLS http://actressgallery-kalyani.blogspot.in/2012/01/katrina-kaif-item-song-stills.html From search at bluelinetalent.com Sun Feb 26 13:31:24 2012 From: search at bluelinetalent.com (Blue Line Talent) Date: Sun, 26 Feb 2012 10:31:24 -0800 (PST) Subject: Software Engineer - Storage, Python, C++, Java Message-ID: <7a870e43-cd31-48e0-b993-23c5ad961f13@t16g2000yqt.googlegroups.com> Blue Line Talent is looking for a mid-level software engineer with experience in a combination of Python, C/C++ and/or Java. Experience developing middleware is helpful. The Engineer will join an exciting start-up environment in a newly established location. This is an outstanding opportunity for a high performing software engineer with 3-5 years experience. Must love coding, variety. For this position most of the work is being done in Python now but they expect this SW Engineer will also use increasing amounts of C/C++ and Java. The languages experience isn't as important as finding a really sharp Software Engineer who loves programming (not just design) and would be well suited for the diversity of a start-up environment. Position Title: Software Engineer - Storage Work Location: Broomfield/Flatirons area, CO The Employer: ? A strongly positioned Storage Solutions Software company ? Fully funded and established start-up company with excellent opportunities for growth and advancement ? Comprehensive benefits package Description: ? Full life-cycle software design, development, implementation, test and maintenance. ? Develop, test, and maintain infrastructure-oriented software in Python with some work in C/C++ and Java ? Middleware development - bridge between Linux Kernel and GUI ? Source code control Experience Profile: ? BS in Computer Science or an applicable engineering subject and 3-5+ years of related software engineering experience ? 2+ years software engineering for complex storage solutions ? Loves programming ? Experience developing middleware ? Experience programming in Python (or C/C++ and/or Java) ? Software Engineering experience in a Linux environment. ? Experience with near-real time software development. ? Stable employment history of direct employment Helpful/Preferred: ? Experience in a start-up environment ? Experience with real-time software development. (exposure to embedded software is helpful) ? Enjoys diversity of tasks ? Experience with GUI ? Experience with C/C++ and/or Java ? Experience with various Windows and Linux OS environments ? Exposure to storage subsystems such as Fibre Channel, iSCSI, SAS, SATA, RAID, Snapshot, Replication, NAS, SAN, etc. ? MS in Computer Science, or related degree Please apply at www.bluelinetalent.com/active_jobs NOTES: ? Direct hire with comprehensive benefits ? Local candidates please - no relocation assistance provided ? Not available for Corp-to-Corp, no third parties please Ron Levis Principal, Talent Acquisition Mgr Blue Line Talent, LLC www.bluelinetalent.com www.linkedin.com/in/ronlevis (invitations are welcome) Moderator, Colorado IT Community on LinkedIn Groups Blue Line Talent is a member-owner of NPA, The Worldwide Recruiting Network, your connection to premier independent recruiting firms located throughout Europe, Asia, Australia, Africa and the Americas. From brenNOSPAMbarn at NObrenSPAMbarn.net Sun Feb 26 14:57:49 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Sun, 26 Feb 2012 19:57:49 +0000 (UTC) Subject: Question about circular imports References: Message-ID: Frank Millman wrote: > The first solution is - > > in wavread.py - > import formats.wavwrite > > in wavwrite.py - > import formats.wavread > > I then have to use the full path to reference any attribute inside > the imported module, which I find cumbersome. This isn't really true. If this is the only thing you're worried about, you can always do the "manual" version of a "from X import Y": import formats.wavread wavread = formats.wavread wavread.someFunc() # refers to functions in module formats.wavread. Also, I'm too lazy to check right now, but I wouldn't be suprised if "mport formats.wavread as wavread" also works even in the circular case. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From rantingrickjohnson at gmail.com Sun Feb 26 15:35:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 26 Feb 2012 12:35:40 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> Message-ID: <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> On Feb 26, 6:44?am, Albert van der Horst wrote: > I don't blame them for the attitude of "live to fight another day" > or even for plain survival. If the Jews hadn't allow themselves > to be subjected, there would be no Jews. And may i borrow your time machine now that you are finished researching what "may have happened" to the Jews had they adopted the "live free or die" mentality? I always wondered what it would feel like to be god. > >Slaves only exist because they allow themselves to exist. When people > > Never been a slave, were you? Try to imagine what it is to be > born a slave. Don't try to cast me as siding with the slave-master. I detest them as much as anyone. But my point is still valid; empower the people and subjection is a thing of the past. Bullying is a microcosm of slavery. You could take two distinct defensive methods to fighting bullies: 1. you could fight each bully on a case by case bases. 2. you could empower people to fight bullies as a united group. Method one will always fail. Sure, you may defeat the bully that exists today, but tomorrow a new bully will be born. Whereas method 2 will always prevail. Bullies need to exist in the shadows, behind a veil of secrecy and fear. Remove the veil and they will be exposed. Adopt a public policy that bullying will NOT be allowed and the perp WILL be punished, and bulling disappears forever. History has shown that mob behavior can be both detrimentally sadistic AND masochistic. From ben+python at benfinney.id.au Sun Feb 26 15:46:46 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Mon, 27 Feb 2012 07:46:46 +1100 Subject: OT: Entitlements References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> Message-ID: <874nuds4p5.fsf@benfinney.id.au> Albert van der Horst writes: > In article <40af8461-1583-4496-9d81-d52d6905d24d at b23g2000yqn.googlegroups.com>, > Rick Johnson wrote: > >Because the Jews allowed themselves to be subjected. Sad, but true. > > Actually Jew stands for (relative) coward. Let me explain. No, please don't. Slander of racial groups is not only off-topic here, it's wholly inappropriate regardless of your explanation. Stop doing it, and don't encourage it in others. -- \ ?The sun never sets on the British Empire. But it rises every | `\ morning. The sky must get awfully crowded.? ?Steven Wright | _o__) | Ben Finney From rosuav at gmail.com Sun Feb 26 15:50:40 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 07:50:40 +1100 Subject: OT: Entitlements [was Re: Python usage numbers] In-Reply-To: <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> Message-ID: On Mon, Feb 27, 2012 at 7:35 AM, Rick Johnson wrote: > ?1. you could fight each bully on a case by case bases. > ?2. you could empower people to fight bullies as a united group. > > Adopt a public policy that bullying will NOT be > allowed and the perp WILL be punished, and bulling disappears > forever. Hmm, I wonder how you go about adopting that policy... oh! I know! By fighting each bully on a case-by-case basis! Funny though, you just said that won't work. ChrisA From tjreedy at udel.edu Sun Feb 26 17:09:17 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 17:09:17 -0500 Subject: Question about circular imports In-Reply-To: References: Message-ID: On 2/26/2012 6:12 AM, Peter Otten wrote: > Frank Millman wrote: > >> I seem to have a recurring battle with circular imports, and I am trying >> to nail it once and for all. ... > This should be > > import sound.formats.wavread To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer -- Terry Jan Reedy From tjreedy at udel.edu Sun Feb 26 17:20:26 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 17:20:26 -0500 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87ty2ern8j.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: On 2/26/2012 3:51 AM, Ben Finney wrote: > Benjamin Peterson writes: > >> We're pleased to announce the immediate availability of release candidates for >> Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 . > > If you're pleased to announce their immediate availability, then please > do that! > > Putting ?RELEASED? in the subject, when they're not released and are > instead *candidates for* release, is confusing and muddies the issue of > what you even mean by ?release?. I think the standard [RELEASED] tag is for the benefit of people who do not read the list but filter it for posts with such tags, perhaps automatically, so they know there is something new to go download. And indeed, there is something new to download. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sun Feb 26 17:32:49 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 26 Feb 2012 14:32:49 -0800 (PST) Subject: OT: Entitlements [was Re: Python usage numbers] References: <4f38c44d$0$11112$c3e8da3@news.astraweb.com> <40af8461-1583-4496-9d81-d52d6905d24d@b23g2000yqn.googlegroups.com> <90fc515f-fd5e-408b-a1c3-30585778f382@r1g2000yqk.googlegroups.com> Message-ID: <7b67d136-5c5e-4714-969a-d93a91b86bbc@m3g2000yqc.googlegroups.com> On Feb 26, 2:50?pm, Chris Angelico wrote: > Hmm, I wonder how you go about adopting that policy... oh! I know! By > fighting each bully on a case-by-case basis! Funny though, you just > said that won't work. It's a two-pronged solution Chris. Compound. From ladasky at my-deja.com Sun Feb 26 19:05:15 2012 From: ladasky at my-deja.com (John Ladasky) Date: Sun, 26 Feb 2012 16:05:15 -0800 (PST) Subject: MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! References: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> Message-ID: On Feb 26, 12:29?am, BV wrote: > MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! ...Hey, someone has to keep the spam around here on-topic. From ladasky at my-deja.com Sun Feb 26 19:24:14 2012 From: ladasky at my-deja.com (John Ladasky) Date: Sun, 26 Feb 2012 16:24:14 -0800 (PST) Subject: Python math is off by .000000000000045 References: Message-ID: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Curiosity prompts me to ask... Those of you who program in other languages regularly: if you visit comp.lang.java, for example, do people ask this question about floating-point arithmetic in that forum? Or in comp.lang.perl? Is there something about Python that exposes the uncomfortable truth about practical computer arithmetic that these other languages obscure? For of course, arithmetic is surely no less accurate in Python than in any other computing language. I always found it helpful to ask someone who is confused by this issue to imagine what the binary representation of the number 1/3 would be. 0.011 to three binary digits of precision: 0.0101 to four: 0.01011 to five: 0.010101 to six: 0.0101011 to seven: 0.01010101 to eight: And so on, forever. So, what if you want to do some calculator-style math with the number 1/3, that will not require an INFINITE amount of time? You have to round. Rounding introduces errors. The more binary digits you use for your numbers, the smaller those errors will be. But those errors can NEVER reach zero in finite computational time. If ALL the numbers you are using in your computations are rational numbers, you can use Python's rational and/or decimal modules to get error-free results. Learning to use them is a bit of a specialty. But for those of us who end up with numbers like e, pi, or the square root of 2 in our calculations, the compromise of rounding must be accepted. From tjreedy at udel.edu Sun Feb 26 20:30:02 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 26 Feb 2012 20:30:02 -0500 Subject: Python math is off by .000000000000045 In-Reply-To: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Message-ID: On 2/26/2012 7:24 PM, John Ladasky wrote: > I always found it helpful to ask someone who is confused by this issue > to imagine what the binary representation of the number 1/3 would be. > > 0.011 to three binary digits of precision: > 0.0101 to four: > 0.01011 to five: > 0.010101 to six: > 0.0101011 to seven: > 0.01010101 to eight: > > And so on, forever. So, what if you want to do some calculator-style > math with the number 1/3, that will not require an INFINITE amount of > time? You have to round. Rounding introduces errors. The more > binary digits you use for your numbers, the smaller those errors will > be. But those errors can NEVER reach zero in finite computational > time. Ditto for 1/3 in decimal. ... 0.33333333 to eitht > If ALL the numbers you are using in your computations are rational > numbers, you can use Python's rational and/or decimal modules to get > error-free results. Decimal floats are about as error prone as binary floats. One can only exact represent a subset of rationals of the form n / (2**j * 5**k). For a fixed number of bits of storage, they are 'lumpier'. For any fixed precision, the arithmetic issues are the same. The decimal module decimals have three advantages (sometimes) over floats. 1. Variable precision - but there are multiple-precision floats also available outside the stdlib. 2. They better imitate calculators - but that is irrelevant or a minus for scientific calculation. 3. They better follow accounting rules for financial calculation, including a multiplicity of rounding rules. Some of these are laws that *must* be followed to avoid nasty consequences. This is the main reason for being in the stdlib. > Learning to use them is a bit of a specialty. Definitely true. -- Terry Jan Reedy From th982a at googlemail.com Sun Feb 26 20:39:40 2012 From: th982a at googlemail.com (Tamer Higazi) Date: Mon, 27 Feb 2012 02:39:40 +0100 Subject: MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! In-Reply-To: References: <82f0ac3e-b6e0-468c-882d-259d447dfcfd@9g2000vbq.googlegroups.com> Message-ID: <4F4ADEDC.8060301@googlemail.com> AND PYTHON IS REALLY COOL!!!!! Especially this beautiful JPype Bridge that makes it possible to push requests between PYTHON and JAVA. really really really cool! Am 27.02.2012 01:05, schrieb John Ladasky: > On Feb 26, 12:29 am, BV wrote: >> MAJOR CANADIAN CHRISTIAN MISSIONARY CONVERTS TO ISLAM > > MAJOR JAVA EVANGELIST CONVERTS TO PYTHON !!!!!!!!!!!!!! > > > ...Hey, someone has to keep the spam around here on-topic. From nanothermitefbibustardsattn at gmail.com Sun Feb 26 21:01:51 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Sun, 26 Feb 2012 18:01:51 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: On Feb 25, 4:18?pm, Xah Lee wrote: > worth watching for those who have strong beliefs in emacs user > interface, and those who love to quote how software become smarter and > people become dumber. > > Bret Victor - Inventing on Principlehttp://vimeo.com/36579366 > > also read: > > ?Emacs Modernization?http://xahlee.org/emacs/emacs_modernization.html > > ?Xah @Xah Lee, he only tell one point, fast interpreter avoiding Edit- Compile-Run cycle, and make it INTERACTIVE, the guy did not teach nothing of design. The principle was first given by Margaret Hamilton and Zeldin. These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=3D4UqcY8lGUUE http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 gnu.emacs.help, comp.emacs, comp.unix.shell, comp.lang.c++, comp.lang.python From gelonida at gmail.com Sun Feb 26 21:22:26 2012 From: gelonida at gmail.com (Gelonida N) Date: Mon, 27 Feb 2012 03:22:26 +0100 Subject: Abort an HTTP request before the request timed out Message-ID: Hi, I'm working in a small application, which tries to access data on a web server. Normally the request has a timeout of for example 60 seconds conn = httplib.HTTPConnection(server_name, server_port, timeout=60) while True: conn.request("GET", "/my_url.php") try: resp = conn.getresponse() except HaveToLookUpNameOfTimeOutException as exc: print "timed out" continue parse_response(resp) Sometimes I would like to abort the request from another thread and force an immediate retry. How would I do this best? The other thread would be either a UI button or some other code knowing, when it is not good to wait the ull minute. Normally the timeout of 1 mintues is what I need though. Thanks for any suggestion. The solution should work on Windows and Linux From wuwei23 at gmail.com Sun Feb 26 21:32:27 2012 From: wuwei23 at gmail.com (alex23) Date: Sun, 26 Feb 2012 18:32:27 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> Message-ID: <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> On Feb 26, 6:29?am, Rick Johnson wrote: > Sure there are float INFINITIES that work fine for ints and floats, > but where is the consistency? Sure, there are all of the COMPLEXITIES of floating point arithmetic but I want to ignore all of that and demand ridiculous consistencies. Why should I have to do float(some_int) < float('inf') when it's a far better use of my time to spend days if not weeks bemoaning yet another language wart? Why should I be expected to know what float('inf') actually represents before making stupid demands like: > INFINITY need not be a int or a float or > a str, or whatever. Please provide a non-contrived use case of an "infinite string". > INFINITY should be at the very least a constant of the math module. Why? This isn't a mathematical concept of 'infinite' when you're talking about comparing against "str, or whatever". We need a more appropriate location; please initiate a PEP to add the namespace shit.rick.wants into the stdlib. From steve+comp.lang.python at pearwood.info Sun Feb 26 22:28:07 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Feb 2012 03:28:07 GMT Subject: Python math is off by .000000000000045 References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> Message-ID: <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: > Curiosity prompts me to ask... > > Those of you who program in other languages regularly: if you visit > comp.lang.java, for example, do people ask this question about > floating-point arithmetic in that forum? Or in comp.lang.perl? Yes. http://stackoverflow.com/questions/588004/is-javascripts-math-broken And look at the "Linked" sidebar. Obviously StackOverflow users no more search the internet for the solutions to their problems than do comp.lang.python posters. http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error -- Steven From emmynoether3 at gmail.com Sun Feb 26 22:40:35 2012 From: emmynoether3 at gmail.com (Emmy Noether) Date: Sun, 26 Feb 2012 19:40:35 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: your first link is not working but it is to this KEY video http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 On Feb 26, 6:01?pm, NanoThermite FBibustards wrote: > On Feb 25, 4:18?pm, Xah Lee wrote: > > > worth watching for those who have strong beliefs in emacs user > > interface, and those who love to quote how software become smarter and > > people become dumber. > > > Bret Victor - Inventing on Principlehttp://vimeo.com/36579366 > > > also read: > > > ?Emacs Modernization?http://xahlee.org/emacs/emacs_modernization.html > > > ?Xah > > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > > These are also good videos as well as the treatise and court case > document below, you will find them exhilerating, liberating and very > informative > > http://www.youtube.com/watch?v=3D4UqcY8lGUUEhttp://www.youtube.com/watch?v=lX18zUp6WPYhttp://www.youtube.com/watch?v=XQapkVCx1HIhttp://www.youtube.com/watch?v=tXJ-k-iOg0Mhttp://www.youtube.com/watch?v=DhMcii8smxkhttp://www.youtube.com/watch?v=tRfhUezbKLwhttp://www.youtube.com/watch?v=x7kGZ3XPEm4http://www.youtube.com/watch?v=lX18zUp6WPY > > http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcripthttp://anglo-saxonisrael.com/site/GreatImpersonation-8 > > http://www.youtube.com/watch?v=ZcwBEzW8S1Mhttp://www.youtube.com/watch?v=9gBxMJFQd04 > > gnu.emacs.help, comp.emacs, comp.unix.shell, comp.lang.c++, > comp.lang.python From steve+comp.lang.python at pearwood.info Sun Feb 26 22:51:43 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 27 Feb 2012 03:51:43 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> Message-ID: <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> On Sun, 26 Feb 2012 18:32:27 -0800, alex23 wrote: > On Feb 26, 6:29?am, Rick Johnson wrote: >> Sure there are float INFINITIES that work fine for ints and floats, but >> where is the consistency? > > Sure, there are all of the COMPLEXITIES of floating point arithmetic but > I want to ignore all of that and demand ridiculous consistencies. Why > should I have to do float(some_int) < float('inf') Ints and floats can be compared directly, no need to convert the int to a float first: >>> INF = float('inf') >>> 23 < INF True Likewise Fractions and Decimals, at least in Python 3.2 (possibly not in older versions): >>> from fractions import Fraction >>> from decimal import Decimal >>> Fraction(33, 5) < INF True >>> Decimal("42.1568") < INF True > when it's a far > better use of my time to spend days if not weeks bemoaning yet another > language wart? Why should I be expected to know what float('inf') > actually represents before making stupid demands like: > >> INFINITY need not be a int or a float or a str, or whatever. > > Please provide a non-contrived use case of an "infinite string". Any lazy stream of characters that potentially goes on forever could be considered an infinite string. But that's not what Rick is talking about. He's talking about having a pair of special values, say, BIGGEST and SMALLEST, which compare larger and smaller to any other value, regardless of type and including strings, not literally a string with an infinite number of characters. I can see some value for this as a convenience, but not enough to make it a built-in language feature. Every developer should have at least one utility module with all the trivial code snippets they frequently use. This belongs in there. -- Steven From rosuav at gmail.com Sun Feb 26 22:59:48 2012 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 27 Feb 2012 14:59:48 +1100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Feb 27, 2012 at 2:51 PM, Steven D'Aprano wrote: > I can see some value for this as a convenience, but not enough to make it > a built-in language feature. Every developer should have at least one > utility module with all the trivial code snippets they frequently use. +1. I used to call mine "oddsends" - it nicely fitted into eight characters (yeah, was important then - I was on DOS), and I had quite a few odds and ends in there. ChrisA From frank at chagford.com Mon Feb 27 01:16:47 2012 From: frank at chagford.com (Frank Millman) Date: Mon, 27 Feb 2012 08:16:47 +0200 Subject: Question about circular imports References: Message-ID: > > To avoid the tedious reference, follow this with > read = sound.formats.wavread # choose the identifier you prefer > @Terry and OKB I tried that, but it does not work. a.py /b __init__.py c.py d.py a.py - from b import c c.py - import b.d d.py - import b.c If I run a.py, it returns with no error. c.py - import b.d d = b.d d.py - import b.c c = b.c If I run a.py, I get Traceback (most recent call last): File "F:\tests\a.py", line 1, in from b import c File "F:\tests\b\c.py", line 1, in import b.d File "F:\tests\b\d.py", line 2, in c = b.c AttributeError: 'module' object has no attribute 'c' I get the same if I try 'import b.c as c'. Frank From wuwei23 at gmail.com Mon Feb 27 01:49:27 2012 From: wuwei23 at gmail.com (alex23) Date: Sun, 26 Feb 2012 22:49:27 -0800 (PST) Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4F481A5F.4080601@gmail.com> <4F482D66.1070307@mrabarnett.plus.com> <4f483e4a$0$29989$c3e8da3$5496439d@news.astraweb.com> <058242e4-2504-41aa-97dd-0630816c4af9@f4g2000yqh.googlegroups.com> <406737be-45ce-4990-9bbe-97256967ad41@l16g2000vbl.googlegroups.com> <4f4afdce$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <3c820774-85e6-4d04-b372-b8400867872b@l1g2000vbc.googlegroups.com> On Feb 27, 1:51?pm, Steven D'Aprano wrote: > Ints and floats can be compared directly, no need to convert the int to a > float first Ah, cheers. You can see how often I use the two interchangeably :) > > Please provide a non-contrived use case of an "infinite string". > > Any lazy stream of characters that potentially goes on forever could be > considered an infinite string. But that's not what Rick is talking about. > > He's talking about having a pair of special values, say, BIGGEST and > SMALLEST, which compare larger and smaller to any other value, regardless > of type and including strings, not literally a string with an infinite > number of characters. Yeah, my point was more to highlight Rick's laziness in co-opting a defined term - INFINITE - and trying to use it to mean something else that he couldn't express clearly. His original post stressed numeric comparison, the feature creep to include all other types happened later. Not the sort of thing we've come to expect from the resident linguist extraordinaire :) > I can see some value for this as a convenience, but not enough to make it > a built-in language feature. For me, it feels like a step backwards to comparing different types: >>> 1 < INFINITE True >>> 'string' < INFINITE True >>> 1 < 'string' Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < str() > Every developer should have at least one > utility module with all the trivial code snippets they frequently use. > This belongs in there. Agreed. Especially when it's so trivial: class Bound(object): def __init__(self, value=None, always_greater=False): self.value = value self.always_greater = always_greater def __cmp__(self, other): return True if self.always_greater else self.value.__cmp__(other) >>> upper = Bound(100) >>> 101 > upper True >>> 101 < upper False >>> infinite = Bound(always_greater=True) >>> 101 > infinite False >>> 101 < infinite True >>> upper < 101 < infinite True From johnjsal at gmail.com Mon Feb 27 02:24:31 2012 From: johnjsal at gmail.com (John Salerno) Date: Sun, 26 Feb 2012 23:24:31 -0800 (PST) Subject: How can I make an instance of a class act like a dictionary? Message-ID: Hi everyone. I created a custom class and had it inherit from the "dict" class, and then I have an __init__ method like this: def __init__(self): self = create() The create function creates and returns a dictionary object. Needless to say, this is not working. When I create an instance of the above class, it is simply an empty dictionary rather than the populated dictionary being created by the create function. Am I doing the inheritance wrong, or am I getting the above syntax wrong by assigning the return value to self? I know I could do self.variable = create() and that works fine, but I thought it would be better (and cleaner) simply to use the instance itself as the dictionary, rather than have to go through an instance variable. Thanks. From clp2 at rebertia.com Mon Feb 27 02:39:01 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Sun, 26 Feb 2012 23:39:01 -0800 Subject: How can I make an instance of a class act like a dictionary? In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the > "dict" class, and then I have an __init__ method like this: > > def __init__(self): > ? ? ? ?self = create() > > The create function creates and returns a dictionary object. Needless > to say, this is not working. When I create an instance of the above > class, it is simply an empty dictionary rather than the populated > dictionary being created by the create function. Am I doing the > inheritance wrong, or am I getting the above syntax wrong by assigning > the return value to self? Assignment to `self` has no effect outside the method in question; Python uses call-by-object (http://effbot.org/zone/call-by-object.htm ) for argument passing. Even in something like C++, I believe assignment to `this` doesn't work. > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Call the superclass (i.e. dict's) initializer (which you ought to be doing anyway): super(YourClass, self).__init__(create()) Cheers, Chris -- http://rebertia.com From nanothermitefbibustardsattn at gmail.com Mon Feb 27 04:32:06 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 01:32:06 -0800 (PST) Subject: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * * References: <04efd690-a95d-436a-a62f-6bafce40337a@32g2000yqn.googlegroups.com> <1239b6c7-5c47-4536-9db0-60303d9285f7@t15g2000yqi.googlegroups.com> <23e8bc3d-8586-4741-b5e7-7d20f1711fc6@n12g2000yqb.googlegroups.com> Message-ID: <8fdbd7dd-ff24-4dd8-a6f4-b11abdc4e501@c21g2000yqi.googlegroups.com> test From nanothermitefbibustardsattn at gmail.com Mon Feb 27 04:34:39 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 01:34:39 -0800 (PST) Subject: minimal set theory References: <28250a1d-d984-4d02-aec8-4e1864b31e44@sk8g2000pbc.googlegroups.com> <868bf65a-30e3-4ca0-a4d0-9bac422b4267@t15g2000yqi.googlegroups.com> <597245e9-ba30-4500-9887-a2d5b730b7a5@q12g2000yqg.googlegroups.com> <781a3889-d3d5-4878-9816-e9b248fc2fe1@tc8g2000pbc.googlegroups.com> <87aa45l7wp.fsf@uta.fi> Message-ID: test From albert at spenarnc.xs4all.nl Mon Feb 27 05:24:53 2012 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 27 Feb 2012 10:24:53 GMT Subject: Numerical Linear Algebra in arbitrary precision References: Message-ID: In article , Ken wrote: >Brand new Python user and a bit overwhelmed with the variety of >packages available. Any recommendation for performing numerical >linear algebra (specifically least squares and generalized least >squares using QR or SVD) in arbitrary precision? I've been looking at >mpmath but can't seem to find much info on built in functions except >for LU decomposition/solve. Arbitrary precision? As in automatically increasing precision to stay exact? You will find this impractical as the number of decimals will explode, or you will find it not at all. If you mean that you want to be able to select something with larger precision than single or double floats, numpy is the starting point. > >Appreciate any comments. > >Ken Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From Tonicopm at yahoo.com Mon Feb 27 05:27:51 2012 From: Tonicopm at yahoo.com (Tonico) Date: Mon, 27 Feb 2012 02:27:51 -0800 (PST) Subject: From Cain To Khazaria: The True Genealogy of the Jewish People, Documented From the Bible and From Jewish Writings References: <28250a1d-d984-4d02-aec8-4e1864b31e44@sk8g2000pbc.googlegroups.com> <868bf65a-30e3-4ca0-a4d0-9bac422b4267@t15g2000yqi.googlegroups.com> <597245e9-ba30-4500-9887-a2d5b730b7a5@q12g2000yqg.googlegroups.com> <781a3889-d3d5-4878-9816-e9b248fc2fe1@tc8g2000pbc.googlegroups.com> <87aa45l7wp.fsf@uta.fi> <37c9db25-c056-4bd6-b26b-748802aa5492@t16g2000yqt.googlegroups.com> Message-ID: <1cb41569-7ec9-4b11-8994-e356523664cc@hs8g2000vbb.googlegroups.com> On Feb 27, 11:38?am, NanoThermite FBibustards wrote: > A copy of ?The Great Impersonation? can be obtained for $37 (Postpaid) > from my website,www.anglo-saxonisrael.comvia Paypal, or by mail from > ANP POB 411373, Chicago IL 60641. > > From Cain To Khazaria: > > The True Genealogy of the Jewish People, Documented From the Bible and > From Jewish Writings > > (They're NOT Who You THINK They Are!) > > By Pastor Eli James > > Therefore, behold, I will proceed to do a marvellous work among this > people, even a marvellous work and a wonder: for the wisdom of their > wise men shall perish, and the understanding of their prudent men > shall be hid. - Isa. 29:14. > > Children of True Israel, there is a GIGANTIC COVER-UP going on in the > world of religion. It is a DECEPTION of such vast proportions that it > affects every moment of your life. It affects your income, your > health, your family, your residence, your faith, your business, your > welfare and even your sex life. Ultimately, it affects your immortal > soul, which, at this moment in time, is in serious jeopardy. This > cover-up has confounded the wisdom and judgment of millions of > otherwise good people. Most Christians simply do not realize that > there is an IMPOSTOR posing as Israel. > > I have written a 333-page book about this impostor. The book is > entitled, The Great Impersonation, How the Anti-Christ Has Deceived > the Whole World. This book details the two families that came out of > the Garden of Eden. Genesis 3:15 clearly predicts that these two > families will be in a state of continuous war with each other until > the Great Day of the Lord. Yet, no denomination, outside of Christian > Identity, teaches anything about this. Nor do they teach that the > whole world will be deceived by this ?beast,? and largely succumb to > its deceptions. > > Jesus Christ, Himself, repeatedly warns us against the wiles of this > evil generation (race) of vipers (John 8:33-44), who are so evil that > He even refuses to try to convert them (Matt. 13:13-15). > > The purpose of this essay is to demonstrate two basic propositions: > 1.) The Jews ARE NOT related to any of the Twelve Tribes of Israel, > including the Tribe of Judah, and 2.) Judaism IS NOT related to the > Mosaic Law. In fact, it will be proven herein, beyond any doubt, that > Judaism is an IMPOSTOR RELIGION, just as the Jewish people are an > IMPOSTOR PEOPLE. These two great deceptions, combined into one > culture, namely Jewish culture, form the basis of the entity that the > bible calls ?the beast that deceiveth the whole world.? (Rev. 12:9.) > > Obviously, it never occurs to the average good-hearted Christian that > the devil might come calling, wearing priestly garb; but that is > exactly the ploy that the devil is using. Not only that, the devil > employs entire denominations of priests, who both innocently and > deliberately, promote this gigantic deception. > > To put the situation somewhat indelicately, ?Cupidity always defeats > stupidity, because stupidity cannot recognize cupidity.? A related > maxim is ?The victim of the con game is always the last to know.? In > the meantime, the victim gets taken for all he is worth. > > Who Are the Jews? > > First, we must examine several Jewish claims, as to their ?Semitic? > ancestry. Are these claims true or are they false? > > One of the more famous Jewish claims to Israelite heritage is the > rabbinical claim that the Jewish people are the exclusive descendants > of Abraham. This is based on Gen. 12:3. Let's read this passage and > see if it lives up to Jewish claims: > > And I will bless them that bless thee, and curse him that curseth > thee: and in thee shall all families of the earth be blessed. > > This passage is used by Jews and Christians to imply that, if we don't > bless the Jewish people, then we Christians will not be blessed. This > blessing is stated as CONDITIONAL. Being a conditional, it behooves > non-Abrahamites ? the passage DOES NOT MENTION JEWS!! - to bless > Abraham if these non-Abrahamites wish to be blessed. The fact must be > pointed out that nowhere in Scripture is Abraham identified with the > Jewish people. In fact, such an identification is automatically > ANACHRONISTIC, meaning that Abraham, being the grandfather of Israel, > cannot be named after any of his descendants. Jacob was an Abrahamite, > but Abraham was certainly not an Israelite! No grandfather has ever > been named after his grandson. > > It is also true that nowhere in Scripture are the Israelites ever > called ?Jews.? ?There is absolutely no such statement in either > Testament, that says, ?Jacob is a Jew? or ?Israel is a Jew,? or even > ?Judah is a Jew.? In fact, we have several COUNTEREXAMPLES, which > prove the opposite to be true! II Kings 16:6 refers to the House of > Judah as ?Jews,? but it refers to the House of Israel as ?Israel.? > Now, if the Jews are Israel, as we are constantly told, why does this > passage contradict them? The fact is that the word ?Jew? is a modern > invention that simply does not mean either ?Judah? or Israel? or > ?Abraham.? ?All of these claims are deceptions invented by the rabbis > for the express purpose of deceiving Christians. > > Let's look at the entire blessing (verses 1-3) that Yahweh put upon > Abraham and see if it can be applied to the Jewish people: > > 1 Now the LORD had said unto Abram, Get thee out of thy country, and > from thy kindred, and from thy father's house, unto a land that I will > shew thee: 2 And I will make of thee a great nation, and I will bless > thee, and make thy name great; and thou shalt be a blessing: 3 And I > will bless them that bless thee, and curse him that curseth thee: and > in thee shall all families of the earth be blessed. ? Gen. 12:1-3. > > Point #1: Verse 2 says that Yahweh will make a ?great nation? out of > Abraham. Certainly, Abraham's name has become ?great,? but the Jewish > people have always been a greatly despised people, throughout history. > This is proven by their own admissions. They are always recounting how > they have been ?persecuted? by every nation in which they have dwelt. > > Point #2: Abraham had a total of eight sons by three wives. He had > Ishmael by Hagar, Isaac by Sarah; and he had six sons by Keturah, > after Sarah died. These six sons were named Zimran, Jokshan, Medan, > Midian, Ishbak and Shuah (Gen. 25:1). Now all of these 8 sons were > Abrahamites, but none of them were Jews! The Jewish claim that the > blessings of Gen. 12 apply to them is simply false. The Bible says no > such thing! The rabbis have made this doctrine up out of nothing, in > their yeshivas of sophistry! > > Paul tells us to beware of Jewish fables (Titus 1:14); and their > PARTIAL QUOTATION of Gen. 12:3, which doesn?t even mention Jews, is > the beginning of the biggest Jewish Fable of them all: the Great > Impersonation of Israel by the Jews. > > Point #3: Verse 2 states an UNCONDITIONAL blessing: ?and thou shalt be > a blessing.? But, since the Jews ADMIT to being a nation toward which > every other nation has always been hostile, how can they be a > ?blessing? to those nations, who despise them and throw them out! > There is something seriously wrong with these Jewish claims! > > Point #4: Verse 3 says, ?in thee shall all the nations of the earth be > blessed.? Here is another BLATANTLY obvious contradiction between what > is said about Abraham and the Jewish experience. The fact is that the > Jewish people have always been despised wherever they have gone! I > would challenge anyone to cite a single nation in which the Jews have > dwelt, which has considered their presence to be a blessing. On the > contrary, they would not have been expelled from over 100 nations > (Spain, France, Germany, England, etc.) and city-states if the > inhabitants thought they were a blessing. Rather, the Jews have always > been considered a curse and a pestilence wherever they have chosen to > reside. > > And this historical fact fits the Curse of Cain perfectly: fugitives > and vagabonds, (Gen. 4:12) wandering from place to place, because > their presence is so irritating to the host. Of course, the Jews never > quote this passage with regard their own people, even though it > precisely fits the Jewish historical experience. These obvious > discrepancies between Jewish history and the blessings of Abraham tell > us that something is very wrong here! > > Either the Jews are lying about who they are, or the very history that > they claim is wrong. > > Point #4: Under then President Harry S. Truman, America was the first > nation in the world to recognize the bandit State of Impostors. It has > no been over 60 years since that rogue state came into existence. > America was the first to bless the Israelis and America has blessed > the Israelis more abundantly than any other nation. QUESTION: What are > the blessings that we have received in return for blessing the Jews? > ANASER: Chaos, mayhem, debts, subterfuge, treason, war, war, war, and > more war. Our society has precipitously declined morally, spiritually, > economically, religiously, and even intellectually as a result of the > fact that we are blessing the WRONG PEOPLE. > > There are only two possibilities, either the Jews are lying about who > they are, or the blessings of Gen. 12:3 are false. > > In addition, the Jews trace their supposed ?Semitic? descent from > Abraham. Is this also a lie? Yes, it most assuredly is, because all of > Abraham's eight male descendants MUST ALSO BE Shemites, as they are > his direct descendants. Ishmael, the son of Hagar, had twelve sons of > his own; and these sons became known to the world as the Arabs! So, > the Arabs are Shemites. Isaac, son of Sarah, is also, therefore, a > Shemite. And Keturah's six sons are also Shemites. But none of these > people are ever given credit by the Jews for their OBVIOUS SHEMITIC > DESCENT ? through Abraham! > > Consequently, it can be easily seen that the Jewish assertion that > ONLY JEWS are included in the context of Gen. 12:3 is SHEER > PRETENSE! ? The Jewish version of > > read more ?... Idiot From dan at tombstonezero.net Mon Feb 27 05:52:25 2012 From: dan at tombstonezero.net (Dan Sommers) Date: Mon, 27 Feb 2012 10:52:25 +0000 (UTC) Subject: How can I make an instance of a class act like a dictionary? References: Message-ID: On Sun, 26 Feb 2012 23:24:31 -0800, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the "dict" > class, and then I have an __init__ method like this: > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Check out the "Bunch" class: http://code.activestate.com/recipes/52308/ HTH, Dan From ghosh236 at gmail.com Mon Feb 27 06:24:52 2012 From: ghosh236 at gmail.com (honey ghosh) Date: Mon, 27 Feb 2012 03:24:52 -0800 (PST) Subject: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY......... Message-ID: EARN RS.2.5 PER CLICK INDIAN SITE 100%REAL JOIN AND GET RS.100 INSTANTLY........... CLICK HERE TO REGISTER FOR FREE: PROCEDUE:----http://onlineearnfreehome.yolasite.com/ 1)REGISTER BY COPYING THE LINK INTO YOUR BROWSER GIVEN ABOVE AND VERIFY THE GIVEN EMAIL FOR CONFIRMATION. 2)LOGIN BY USING THE USERNAME AND PASSWORD. 3)U WILL FIND 2 LINKS THERE VIEW ADS &MY ACCOUNT... a) view job details - http://www.onlineearnfreehome.yolasite.com/ 4)CLICK ON THE VIEW ADS LINK, U WILL FIND SOME ADS CLICK ON EACH LINK TO OPEN A NEW WINDOW........ ................................IMPORTANT: { FOLLOW WITHOUT FAIL }.............................. 1) SIMPLE JOBS. BASIC KNOWLEDGE OF COMPUTER AND INTERNET IS ENOUGH. SUITABLE FOR HOUSE WIVES,STUDENTS,WORKERS, RETIRED PERSONS & YOUTHS. b)Just signup for free at- http://onlineearnfreehome.yolasite.com/ Thanks ?? From jeanmichel at sequans.com Mon Feb 27 06:55:52 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 12:55:52 +0100 Subject: PyWart: Language missing maximum constant of numeric types! In-Reply-To: <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> Message-ID: <4F4B6F48.8070108@sequans.com> Rick Johnson wrote: > On Feb 25, 11:54 am, MRAB wrote: > >> [...] >> That should be: >> if maxlength is not None and len(string) <= maxlength: >> > > Using "imaginary" infinity values defiles the intuitive nature of your > code. What is more intuitive? > > def confine_length(string, maxlength=INFINITY): > if string.length < maxlength: > do_something() > > def confine_length(string, maxlength=None): > if maxlength is not None and len(string) <= maxlength: > do_something() > This one: def confine_length(string, maxlength=None): """Confine the length. @param maxlength: the maximum length allowed, set it to None to allow any length. """ if maxlength is not None and len(string) <= maxlength: do_something() I'm just feeding the troll, I know ... :-/ JM From neilc at norwich.edu Mon Feb 27 07:25:35 2012 From: neilc at norwich.edu (Neil Cerutti) Date: 27 Feb 2012 12:25:35 GMT Subject: PyWart: Language missing maximum constant of numeric types! References: <8c2096d9-3cc2-4b64-8f11-c1d958d94243@x19g2000yqh.googlegroups.com> <4f48996b$0$6639$9b4e6d93@newsspool2.arcor-online.net> <0cee49d9-b5a6-4fd8-8cd2-e4373099d5ac@p7g2000yqk.googlegroups.com> <4f4a30a8$0$7610$9b4e6d93@newsspool1.arcor-online.net> Message-ID: <9r1b1vF8t2U2@mid.individual.net> On 2012-02-26, Wolfgang Meiners wrote: > but it really does not look intuitive. Hmm. My idea was that > None is a perfect Value for infinity since there is no > infinitely large number. But as i see it, you must have two > comparisons then. Maybe someone has a better idea? I do. A truncated string with a maxlength of INFINITY is just a string. -- Neil Cerutti From kym at sdf.lonestar.org Mon Feb 27 07:46:16 2012 From: kym at sdf.lonestar.org (R Kym Horsell) Date: Mon, 27 Feb 2012 12:46:16 +0000 (UTC) Subject: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * * References: <04efd690-a95d-436a-a62f-6bafce40337a@32g2000yqn.googlegroups.com> <1239b6c7-5c47-4536-9db0-60303d9285f7@t15g2000yqi.googlegroups.com> <23e8bc3d-8586-4741-b5e7-7d20f1711fc6@n12g2000yqb.googlegroups.com> <8fdbd7dd-ff24-4dd8-a6f4-b11abdc4e501@c21g2000yqi.googlegroups.com> Message-ID: In sci.physics NanoThermite FBibustards wrote: > test fail. -- From amirouche.boubekki at gmail.com Mon Feb 27 08:44:20 2012 From: amirouche.boubekki at gmail.com (Amirouche Boubekki) Date: Mon, 27 Feb 2012 14:44:20 +0100 Subject: [semi OT]: Smartphones and Python? In-Reply-To: <9q2kj3Fmq1U1@mid.individual.net> References: <9q2kj3Fmq1U1@mid.individual.net> Message-ID: for which I could write Python programs. > Android is good bet, kivy has official support for it http://kivy.org/docs/guide/android.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From matze999 at gmail.com Mon Feb 27 08:49:56 2012 From: matze999 at gmail.com (Matt Funk) Date: Mon, 27 Feb 2012 14:49:56 +0100 Subject: setting the length of the backtrace output in pdb Message-ID: Hi, this might be a rather silly question, but i cannot figure out how to make pdb give me more than 10 lines of output whenever i issue a backtrace command. Is there an easy way to do this? thanks matt -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrea.crotti.0 at gmail.com Mon Feb 27 08:57:56 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 13:57:56 +0000 Subject: windows executable calling python script Message-ID: <4F4B8BE4.9070908@gmail.com> I am creating an installer for python projects, using CMake and NSIS. Now my goal is to be able to select at installer time the python executable that will run that project, and then associate them. I saw that setuptools is able to generate exe wrappers, but how does that work exactly? From what I've understood there is some compiled C code that somehow calls the python script, is that correct? Supposing I ship this executable in the same directory of the python script (with a known name), is there a way to make it run the right python interpreter? The best and easiest solution would be to generate the full installer with PyInstaller or similar, but unfortunately that doesn't work yet, and we would still need both approaches anyway. From dihedral88888 at googlemail.com Mon Feb 27 09:00:22 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 27 Feb 2012 06:00:22 -0800 (PST) Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: <8210916.2683.1330351222098.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?26????UTC+8??9?00?31??Chris Angelico??? > On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > > This is however a bit errorprone. If you accidentally write the loading code > > as > > > > fruit, beverages, vegetables = pickle.load(f) > > > > you'll end up drinking potatoes. > > You mean vodka? :) > > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. > > Of course, sometimes that exception is absolutely correct. If you wrap > all this in an exception handler that gives some reasonable behaviour > - which might even be "terminate the program with a traceback", which > is the default - then it's fine to let it throw on failure, and > anything else is just a waste of effort. But for maximum > extensibility, you would want to make it so that you can add more > elements to what you save without your code breaking on an old save > file - and that's where the dictionary is far better. A slight tweak, > though: > > data = pickle.load(f) > fruit = data.get("fruit",[]) > beverages = data.get("beverages",[]) > vegetables = data.get("vegetables",[]) > > With this, you guarantee that (a) unrecognized keys will be safely > ignored, and (b) absent keys will quietly go to their given defaults. > > ChrisA I love python for pickle and zip lib build in. I write programs that stay in the L1 or L2 cache of the CPU > 97% percent of chance of nontrivial executions. From dihedral88888 at googlemail.com Mon Feb 27 09:00:22 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Mon, 27 Feb 2012 06:00:22 -0800 (PST) Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: <8210916.2683.1330351222098.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?26????UTC+8??9?00?31??Chris Angelico??? > On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <__peter__ at web.de> wrote: > > This is however a bit errorprone. If you accidentally write the loading code > > as > > > > fruit, beverages, vegetables = pickle.load(f) > > > > you'll end up drinking potatoes. > > You mean vodka? :) > > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. > > Of course, sometimes that exception is absolutely correct. If you wrap > all this in an exception handler that gives some reasonable behaviour > - which might even be "terminate the program with a traceback", which > is the default - then it's fine to let it throw on failure, and > anything else is just a waste of effort. But for maximum > extensibility, you would want to make it so that you can add more > elements to what you save without your code breaking on an old save > file - and that's where the dictionary is far better. A slight tweak, > though: > > data = pickle.load(f) > fruit = data.get("fruit",[]) > beverages = data.get("beverages",[]) > vegetables = data.get("vegetables",[]) > > With this, you guarantee that (a) unrecognized keys will be safely > ignored, and (b) absent keys will quietly go to their given defaults. > > ChrisA I love python for pickle and zip lib build in. I write programs that stay in the L1 or L2 cache of the CPU > 97% percent of chance of nontrivial executions. From benjamin at python.org Mon Feb 27 09:16:35 2012 From: benjamin at python.org (Benjamin Peterson) Date: Mon, 27 Feb 2012 14:16:35 +0000 (UTC) Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, =?utf-8?b?My4xLjUsCWFuZA==?= 3.2.3 References: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: Ben Finney benfinney.id.au> writes: > > Putting ?RELEASED? in the subject, when they're not released and are > instead *candidates for* release, is confusing and muddies the issue of > what you even mean by ?release?. > {alpha, beta, release candidate, final} \subsetof releases From andrea.crotti.0 at gmail.com Mon Feb 27 09:21:31 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 14:21:31 +0000 Subject: windows executable calling python script In-Reply-To: <4F4B8BE4.9070908@gmail.com> References: <4F4B8BE4.9070908@gmail.com> Message-ID: <4F4B916B.7080600@gmail.com> On 02/27/2012 01:57 PM, Andrea Crotti wrote: > I am creating an installer for python projects, using CMake and NSIS. > > Now my goal is to be able to select at installer time the python > executable that will run that project, > and then associate them. > > I saw that setuptools is able to generate exe wrappers, but how does > that work exactly? > From what I've understood there is some compiled C code that somehow > calls the python script, is that correct? > Supposing I ship this executable in the same directory of the python > script (with a known name), is there a way > to make it run the right python interpreter? > > The best and easiest solution would be to generate the full installer > with PyInstaller or similar, but unfortunately > that doesn't work yet, and we would still need both approaches anyway. At the moment I ended up with something like this: #include #include #include #include // the function takes as arguments only the python interpreter full path int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage = ./run "); exit(1); } /* TODO: make the path absolute? is it necessary? */ char *const to_run[1] = {"run.py"}; /* TODO: check if the path exists or not, and if it's executable */ execv(argv[1], to_run); return 1; } which still doesn't work (I have to fix the execv) but when it will in theory I will only need to tell NSIS to create a link to that executable passing as argument the right python executable. After that it will run the run.py with in the local directory.. Easier ways (without py2exe and similars?)? From jeanmichel at sequans.com Mon Feb 27 09:23:00 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 15:23:00 +0100 Subject: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3 In-Reply-To: <87haydss3w.fsf@benfinney.id.au> References: <87ty2ern8j.fsf@benfinney.id.au> <87haydss3w.fsf@benfinney.id.au> Message-ID: <4F4B91C4.10805@sequans.com> Ben Finney wrote: > Chris Angelico writes: > > >> On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: >> > > >>> If you're pleased to announce their immediate availability, then >>> please do that! >>> >> Isn't it perfectly accurate to say that the RCs are now available? >> > > Yes. What's not reasonable is to say that a candidate for release ? i.e. > something *prior to* release, by definition ? is nevertheless released. > > >> Considering that "Release candidates" immediately followed "RELEASED" >> in the subject line, I don't see any confusion. >> > > Unless ?release candidate? means nothing like what those words imply, it > can't be both a release candidate *and* released. > > Either it's released, or it's not. If it's a release candidate, it's not > released yet. If it's released, it's no longer a candidate for release. > > Saying it's simultaneously both is the confusion. > > What sort of release can you release ? A release candidate. If you can release a release candidate, a release candidate can be released, hence the released candidate release. More important, we all thank the release team for their efforts and hope they're having fun reading us :o) JM From jeanmichel at sequans.com Mon Feb 27 09:59:52 2012 From: jeanmichel at sequans.com (Jean-Michel Pichavant) Date: Mon, 27 Feb 2012 15:59:52 +0100 Subject: Question about circular imports In-Reply-To: References: Message-ID: <4F4B9A68.1050602@sequans.com> Frank Millman wrote: > Hi all > > I seem to have a recurring battle with circular imports, and I am trying to > nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is to > reorganise the code to avoid this, and I try to do this where possible, but > for now I would like to address the question of how to handle the situation > if this is otherwise unavoidable. > Hi Frank, If you consider it unavoidable you've already lost. There is no reliable solution to circular import except refactoring the code to place all common code elsewhere: wavbase.py wavread.py (import wavbase) wavwrite.py (import wavbase) Any code required by both waread and wavwrite would end up in wavbase. Is there anything that prevent you from doing this ? JM From invalid at invalid.invalid Mon Feb 27 10:02:51 2012 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 27 Feb 2012 15:02:51 +0000 (UTC) Subject: Python math is off by .000000000000045 References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2012-02-27, Steven D'Aprano wrote: > On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: > >> Curiosity prompts me to ask... >> >> Those of you who program in other languages regularly: if you visit >> comp.lang.java, for example, do people ask this question about >> floating-point arithmetic in that forum? Or in comp.lang.perl? > > Yes. > > http://stackoverflow.com/questions/588004/is-javascripts-math-broken > > And look at the "Linked" sidebar. Obviously StackOverflow users no > more search the internet for the solutions to their problems than do > comp.lang.python posters. > > http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error One might wonder if the frequency of such questions decreases as the programming language becomes "lower level" (e.g. C or assembly). -- Grant Edwards grant.b.edwards Yow! World War III? at No thanks! gmail.com From andrea.crotti.0 at gmail.com Mon Feb 27 10:05:22 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Mon, 27 Feb 2012 15:05:22 +0000 Subject: windows executable calling python script In-Reply-To: <4F4B916B.7080600@gmail.com> References: <4F4B8BE4.9070908@gmail.com> <4F4B916B.7080600@gmail.com> Message-ID: <4F4B9BB2.6070908@gmail.com> On 02/27/2012 02:21 PM, Andrea Crotti wrote: > > At the moment I ended up with something like this: > > #include > #include > #include > #include > > > // the function takes as arguments only the python interpreter full path > int main(int argc, char *argv[]) > { > if (argc < 2) { > fprintf(stderr, "Usage = ./run "); > exit(1); > } > /* TODO: make the path absolute? is it necessary? */ > char *const to_run[1] = {"run.py"}; > /* TODO: check if the path exists or not, and if it's executable */ > > execv(argv[1], to_run); > return 1; > } > > which still doesn't work (I have to fix the execv) but when it will in > theory I will only need > to tell NSIS to create a link to that executable passing as argument > the right python executable. > After that it will run the run.py with in the local directory.. > > Easier ways (without py2exe and similars?)? For the record I think I found a solution, now the wrapper works: int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage = ./run "); exit(1); } /* TODO: make the path absolute? is it necessary? */ char *const to_run[] = {"python", RUNNER, (char *) 0}; execv(argv[1], to_run); return 1; } and I only need to tell NSIS to create a shortcut passing as argument the path to the python executable, nice and simple.. From torriem at gmail.com Mon Feb 27 10:34:54 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 27 Feb 2012 08:34:54 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: References: <99543cae-b494-409e-9ac1-073639dcf224@p7g2000yqk.googlegroups.com> <4f4af847$0$29999$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4BA29E.90509@gmail.com> On 02/27/2012 08:02 AM, Grant Edwards wrote: > On 2012-02-27, Steven D'Aprano wrote: >> On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: >> >>> Curiosity prompts me to ask... >>> >>> Those of you who program in other languages regularly: if you visit >>> comp.lang.java, for example, do people ask this question about >>> floating-point arithmetic in that forum? Or in comp.lang.perl? >> >> Yes. >> >> http://stackoverflow.com/questions/588004/is-javascripts-math-broken >> >> And look at the "Linked" sidebar. Obviously StackOverflow users no >> more search the internet for the solutions to their problems than do >> comp.lang.python posters. >> >> http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error > > One might wonder if the frequency of such questions decreases as the > programming language becomes "lower level" (e.g. C or assembly). I think that most of the use cases in C or assembly of math are integer-based only. For example, counting, bit-twiddling, addressing character cells or pixel coordinates, etc. Maybe when programmers have to statically declare a variable type in advance, since the common use cases require only integer, that gets used far more, so experiences with float happen less often. Some of this could have to do with the fact that historically floating point required a special library to do floating point math, and since a lot of people didn't have floating-point coprocessors back then, most code was integer-only. Early BASIC interpreters defaulted to floating point for everything, and implemented all the floating point arithmetic internally with integer arithmetic, without the help of the x87 processor, but no doubt they did round the results when printing to the screen. They also did not have very much precision to begin with. Anyone remember Microsoft's proprietary floating point binary system and how there were function calls to convert back and forth between the IEEE standard? Another key thing is that most C programmers don't normally just print out floating point numbers without a %.2f kind of notation that properly rounds a number. Now, of course, every processor has a floating-point unit, and the C compilers can generate code that uses it just as easily as integer code. No matter what language, or what floating point scheme you use, significant digits is definitely important to understand! From hwfwguy at gmail.com Mon Feb 27 11:51:12 2012 From: hwfwguy at gmail.com (Brad) Date: Mon, 27 Feb 2012 08:51:12 -0800 (PST) Subject: emacs user interface design? a talk by Bret Victor References: Message-ID: <69ef9280-d781-4111-9434-3c7ac80249c3@f14g2000yqe.googlegroups.com> On Feb 26, 7:01?pm, NanoThermite FBibustards wrote: > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > Bret's main point is that creators need immediate feedback. Okay, that's Forth. But he illustrated something else about the Forth way of working. When you try ideas out immediately, you discover things you wouldn't have thought of if you had written the whole program and then worked through debugging and integration. Another point he made is about crusaders (my word), people who see something wrong with the status quo and make it their business to change it based on principle. Chuck wasn't the crusader type (maybe he didn't look good in spandex). From eric.frederich at gmail.com Mon Feb 27 11:57:20 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Mon, 27 Feb 2012 11:57:20 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F47D89A.4080806@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> Message-ID: Still freezing sometimes, like 1 out of 10 times that I run it. Here is updated code and a couple of outputs. ################ code #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, name, inbox, outbox): super(MyWorker, self).__init__() self.name = name self.inbox = inbox self.outbox = outbox print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() def run(self): print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() while True: try: args = self.inbox.get_nowait() print >> sys.stderr, '%s got something to do' % self.name; sys.stderr.flush() except Queue.Empty: break self.outbox.put(FOO(*args)) if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i+1, i+2)) print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() w1 = MyWorker('Worker 1', todo, result_queue) w2 = MyWorker('Worker 2', todo, result_queue) print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() w1.start() print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() w2.start() for i in xrange(100): print result_queue.get() ################ output 1 (I ctrl-c'd it after it froze) Creating todo queue Creating results queue Creating Workers Created Worker 1 Created Worker 2 Starting Worker 1 Running Worker 1 Starting Worker 2 Running Worker 2 Traceback (most recent call last): File "./multi.py", line 53, in print result_queue.get() File "/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py", line 91, in get res = self._recv() KeyboardInterrupt ################### output 2 Creating todo queue Creating results queue Creating Workers Created Worker 1 Created Worker 2 Starting Worker 1 Running Worker 1 Worker 1 got something to do Starting Worker 2 foo 0 1 2 Worker 1 got something to do foo 1 2 3 Worker 1 got something to do foo 2 3 4 Worker 1 got something to do foo 3 4 5 Worker 1 got something to do foo 4 5 6 Worker 1 got something to do foo 5 6 7 Worker 1 got something to do foo 6 7 8 Worker 1 got something to do foo 7 8 9 Worker 1 got something to do foo 8 9 10 Worker 1 got something to do foo 9 10 11 Worker 1 got something to do foo 10 11 12 Worker 1 got something to do foo 11 12 13 Worker 1 got something to do foo 12 13 14 Worker 1 got something to do foo 13 14 15 Worker 1 got something to do foo 14 15 16 Worker 1 got something to do foo 15 16 17 Worker 1 got something to do foo 16 17 18 Worker 1 got something to do foo 17 18 19 Running Worker 2 2 9 20 35 54 77 104 135 170 209 252 299 350 405 464 527 594 665 Traceback (most recent call last): File "./multi.py", line 53, in print result_queue.get() File "/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py", line 91, in get res = self._recv() KeyboardInterrupt On Fri, Feb 24, 2012 at 1:36 PM, MRAB wrote: > On 24/02/2012 17:00, Eric Frederich wrote: > >> I can sill get it to freeze and nothing is printed out from the other >> except block. >> Does it look like I'm doing anything wrong here? >> >> [snip] > I don't normally use multiprocessing, so I forgot about a critical > detail. :-( > > When the multiprocessing module starts a process, that process > _imports_ the module which contains the function which is to be run, so > what's happening is that when your script is run, it creates and starts > workers, the multiprocessing module makes a new process for each > worker, each of those processes then imports the script, which creates > and starts workers, etc, leading to an ever-increasing number of > processes. > > The solution is to ensure that the script/module distinguishes between > being run as the main script and being imported as a module: > > > #!/usr/bin/env python > > import sys > import Queue > import multiprocessing > import time > > def FOO(a, b, c): > print 'foo', a, b, c > return (a + b) * c > > class MyWorker(multiprocessing.**Process): > def __init__(self, inbox, outbox): > super(MyWorker, self).__init__() > self.inbox = inbox > self.outbox = outbox > print >> sys.stderr, '1' * 80; sys.stderr.flush() > def run(self): > print >> sys.stderr, '2' * 80; sys.stderr.flush() > while True: > try: > args = self.inbox.get_nowait() > except Queue.Empty: > break > self.outbox.put(FOO(*args)) > > if __name__ == '__main__': > # This file is being run as the main script. This part won't be > # run if the file is imported. > > todo = multiprocessing.Queue() > > for i in xrange(100): > todo.put((i, i+1, i+2)) > > print >> sys.stderr, 'a' * 80; sys.stderr.flush() > result_queue = multiprocessing.Queue() > > print >> sys.stderr, 'b' * 80; sys.stderr.flush() > w1 = MyWorker(todo, result_queue) > print >> sys.stderr, 'c' * 80; sys.stderr.flush() > w2 = MyWorker(todo, result_queue) > > print >> sys.stderr, 'd' * 80; sys.stderr.flush() > w1.start() > print >> sys.stderr, 'e' * 80; sys.stderr.flush() > w2.start() > print >> sys.stderr, 'f' * 80; sys.stderr.flush() > > for i in xrange(100): > print result_queue.get() > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Mon Feb 27 12:28:44 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 27 Feb 2012 09:28:44 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4F4BBD4C.1050603@stoneleaf.us> jmfauth wrote: > On 25 f?v, 23:51, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: >> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>>>> (2.0).hex() >>> '0x1.0000000000000p+1' >>>>>> (4.0).hex() >>> '0x1.0000000000000p+2' >>>>>> (1.5).hex() >>> '0x1.8000000000000p+0' >>>>>> (1.1).hex() >>> '0x1.199999999999ap+0' >>> jmf >> What's your point? I'm afraid my crystal ball is out of order and I have >> no idea whether you have a question or are just demonstrating your >> mastery of copy and paste from the Python interactive interpreter. > > It should be enough to indicate the right direction > for casual interested readers. I'm a casual interested reader and I have no idea what your post is trying to say. ~Ethan~ From ian.g.kelly at gmail.com Mon Feb 27 13:24:24 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 11:24:24 -0700 Subject: pickle handling multiple objects .. In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 6:00 AM, Chris Angelico wrote: > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. While that's true, if your pickle is untrusted then a ValueError from unpacking is the least of your worries. You should never attempt to load an untrusted pickle in the first place, as doing so allows it to execute arbitrary code on your system. Cheers, Ian From ian.g.kelly at gmail.com Mon Feb 27 13:36:12 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 11:36:12 -0700 Subject: Question about circular imports In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 3:42 AM, Frank Millman wrote: > Hi all > > I seem to have a recurring battle with circular imports, and I am trying to > nail it once and for all. > > Let me say at the outset that I don't think I can get rid of circular > imports altogether. It is not uncommon for me to find that a method in > Module A needs to access something in Module B, and a method in Module B > needs to access something in Module A. I know that the standard advice is to > reorganise the code to avoid this, and I try to do this where possible, but > for now I would like to address the question of how to handle the situation > if this is otherwise unavoidable. > > The problem is clearly explained in the Python Programming FAQ - > > "Circular imports are fine where both modules use the "import " form > of import. They fail when the 2nd module wants to grab a name out of the > first ("from module import name") and the import is at the top level. That's > because names in the 1st are not yet available, because the first module is > busy importing the 2nd." > > [SNIP] > > I can think of two solutions - one is cumbersome, the other may not be good > practice. Solution 3: don't do the circular imports at the top level. It's perfectly fine to do the imports locally inside the functions that need them, which resolves the circularity since normally the functions won't be called until the module is fully imported. It does add some overhead to the functions, basically the cost of a dict lookup. Cheers, Ian From johnjsal at gmail.com Mon Feb 27 15:09:55 2012 From: johnjsal at gmail.com (John Salerno) Date: Mon, 27 Feb 2012 12:09:55 -0800 (PST) Subject: How can I make an instance of a class act like a dictionary? References: Message-ID: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> On Feb 27, 1:39?am, Chris Rebert wrote: > On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > > Hi everyone. I created a custom class and had it inherit from the > > "dict" class, and then I have an __init__ method like this: > > > def __init__(self): > > ? ? ? ?self = create() > > > The create function creates and returns a dictionary object. Needless > > to say, this is not working. When I create an instance of the above > > class, it is simply an empty dictionary rather than the populated > > dictionary being created by the create function. Am I doing the > > inheritance wrong, or am I getting the above syntax wrong by assigning > > the return value to self? > > Assignment to `self` has no effect outside the method in question; > Python uses call-by-object (http://effbot.org/zone/call-by-object.htm > ) for argument passing. > Even in something like C++, I believe assignment to `this` doesn't work. > > > I know I could do self.variable = create() and that works fine, but I > > thought it would be better (and cleaner) simply to use the instance > > itself as the dictionary, rather than have to go through an instance > > variable. > > Call the superclass (i.e. dict's) initializer (which you ought to be > doing anyway): > ? ? super(YourClass, self).__init__(create()) > > Cheers, > Chris > --http://rebertia.com Thanks. This ended up working: def __init__(self): self = super().__init__(create_board()) Is that what you meant for me to do? Why did assigning to self work in this case, but not the original case? From benjamin.kaplan at case.edu Mon Feb 27 15:37:15 2012 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Mon, 27 Feb 2012 15:37:15 -0500 Subject: How can I make an instance of a class act like a dictionary? In-Reply-To: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> References: <007de874-f643-4092-8df0-69320795fc14@b23g2000yqn.googlegroups.com> Message-ID: On Mon, Feb 27, 2012 at 3:09 PM, John Salerno wrote: > On Feb 27, 1:39?am, Chris Rebert wrote: >> On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: >> > Hi everyone. I created a custom class and had it inherit from the >> > "dict" class, and then I have an __init__ method like this: >> >> > def __init__(self): >> > ? ? ? ?self = create() >> >> > The create function creates and returns a dictionary object. Needless >> > to say, this is not working. When I create an instance of the above >> > class, it is simply an empty dictionary rather than the populated >> > dictionary being created by the create function. Am I doing the >> > inheritance wrong, or am I getting the above syntax wrong by assigning >> > the return value to self? >> >> Assignment to `self` has no effect outside the method in question; >> Python uses call-by-object (http://effbot.org/zone/call-by-object.htm >> ) for argument passing. >> Even in something like C++, I believe assignment to `this` doesn't work. >> >> > I know I could do self.variable = create() and that works fine, but I >> > thought it would be better (and cleaner) simply to use the instance >> > itself as the dictionary, rather than have to go through an instance >> > variable. >> >> Call the superclass (i.e. dict's) initializer (which you ought to be >> doing anyway): >> ? ? super(YourClass, self).__init__(create()) >> >> Cheers, >> Chris >> --http://rebertia.com > > Thanks. This ended up working: > > def __init__(self): > ? ? ? ?self = super().__init__(create_board()) > > Is that what you meant for me to do? Why did assigning to self work in > this case, but not the original case? It didn't do anything and still isn't doing anything. In Python, names are assigned to objects self -> ^ foo -------| Reassigning a name does not change the value, so self = create() Just makes an object2 self -> foo ---> The reason it's working here is because the super().__init__() call modifies the existing object in place. It returns None, so you're setting self = None but that doesn't matter because of what I explained before about how assigning to self doesn't actually change anything. > -- > http://mail.python.org/mailman/listinfo/python-list From alexander.borghgraef at gmail.com Mon Feb 27 15:48:27 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Mon, 27 Feb 2012 12:48:27 -0800 (PST) Subject: Python urllib2 problem: Name or service not known Message-ID: Hi all, Some time ago I've written some python code to read video data off an IP camera connected via a router to a laptop. Now I try to run this code on a different laptop and router combination, but now I can't access the camera. Some minimal example code: import urllib2 url = urllib2.urlopen("http://192.168.1.3/-wvhttp-01-/image.cgi") This fails and returns the error: <87ty2ern8j.fsf@benfinney.id.au> Message-ID: <87obskq810.fsf@benfinney.id.au> Benjamin Peterson writes: > Ben Finney benfinney.id.au> writes: > > > > Putting ?RELEASED? in the subject, when they're not released and are > > instead *candidates for* release, is confusing and muddies the issue of > > what you even mean by ?release?. > > > > {alpha, beta, release candidate, final} \subsetof releases So you've chosen to muddy what is meant by ?release? in announcements to the public. That's disappointing, but thank you for acknowledging it. I appreciate the work that goes toward releases of Python, but I do wish you'd use clear terminology in announcements. -- \ ?If history and science have taught us anything, it is that | `\ passion and desire are not the same as truth.? ?E. O. Wilson, | _o__) _Consilience_, 1998 | Ben Finney From vinay_sajip at yahoo.co.uk Mon Feb 27 17:18:07 2012 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Mon, 27 Feb 2012 14:18:07 -0800 (PST) Subject: PEP 414 has been accepted Message-ID: PEP 414 has been accepted: http://mail.python.org/pipermail/python-dev/2012-February/116995.html This means that from Python 3.3 onwards, you can specify u'xxx' for Unicode as well as just 'xxx'. The u'xxx' form is not valid syntax in Python 3.2, 3.1 or 3.0. The idea is to make porting code from 2.x to 3.x easier than before. Get porting! Regards, Vinay Sajip From smallpox911 at gmail.com Mon Feb 27 17:43:30 2012 From: smallpox911 at gmail.com (small Pox) Date: Mon, 27 Feb 2012 14:43:30 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) Message-ID: America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case atleast) This message is in part to the FBI racists as well as well as to the RACIST KANGAROO courts of AMERICA. In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also France. In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN EVEN BEING RELEASED. Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE etc) have contempted themselves. Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS ANGELES COUNTY. That is why 9-11 is a jew job and israeli job and the COWARD YANK BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right thing. The court case record of RAPIST ROMAN POLANSKY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript A SWEET SHORT VIDEO for FBI bustards http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://anglo-saxonisrael.com/site/GreatImpersonation-8 From isragaytan at gmail.com Mon Feb 27 18:06:28 2012 From: isragaytan at gmail.com (isragaytan) Date: Mon, 27 Feb 2012 15:06:28 -0800 (PST) Subject: Transfer files via bluetooth for Blackberry devices Message-ID: <952be09c-50e6-4d80-bb56-77880a1bde1b@p12g2000yqe.googlegroups.com> Hi! I am newby on python. I am looking for a utility or a library for transfer files via bluetooth to blackberry. I am seeing that with obex may be is an option. Can you give me any advices on that?. Really appreciated Thanks! From nanothermitefbibustardsattn at gmail.com Mon Feb 27 18:08:27 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 15:08:27 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 27, 2:43?pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 On Feb 27, 2:43 pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 The YANK bustards are truly CONTEMPTUOUS ... It is because of the INCOMPETENT and RACIST dysfunctional courts that there is so much SCHOOL SHOOTINGS and VIOLENCE because NO ONE TRUSTS THE COURTS We will soon talk of the Kerri Dunn (1year for TERRORISM and HOAX) - jew daughter of a police officer VERSUS Dr Aafiya Siddiqui (90 years for FALSE and RIDICULOUS Charges by FBI ODIOUS and DESPICABLE LIARS) The FAT per DIEM FBI bustards use our TAX PAYER MONEY and INCOMPETENCE is UNACCEPTABLE. ===== http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M Hey Racist and INcompetent FBI Bustards, where is the ANTHRAX Mailer ? Where are the 4 blackboxes ? Where are the Pentagon Videos ? Why did you release the 5 dancing Israelis compromising the whole 911 investigation ? If the Dubai Police can catch Mossad Murderers and put the videos and Iranian Police can why cant you put the Pentagon Videos ? If Iran police can put the AMERICAN TERRORIST, Riggi and puting on INTERNATIONAL MEDIA a day after catching him without TORTURE, why cant you put the INNOCENT patsies on the MEDIA. Why did you have to LIE about Dr Afiya Siddiqui and torture that Innocent little mother of 3 and smashing the skull of her one child ? http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=0SZ2lxDJmdg There are CRIMINAL cases against CIA CRIMINAL Bustards in Italian courts. FBI bustards paid a penalty of $5.8 million to Steven Hatfill, but only because he was a white. They got away with MURDER of thousands of Non-whites in all parts of the world. Daily 911 news : http://911blogger.com http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY Conclusion : FBI bustards are RACIST and INcompetent. They could neither catch the ANTHRAX or 911 YANK/Jew criminals nor could they cover them up - whichever was their actual goal or task. SLASH the SALARIES of FBI/CIA/NSA etc BUSTARDS into half all across tbe board, esp the whites/jew on the top. FBI Bustards failed to Catch BERNARD MADOFF even after that RACIST and UNPATRIOTIC Act FBI bustards failed to prevent ROMAN POLANSKY from absconding to europe and rapes. FBI bustards failed to prevent OKLAHOMA From nanothermitefbibustardsattn at gmail.com Mon Feb 27 18:09:53 2012 From: nanothermitefbibustardsattn at gmail.com (NanoThermite FBibustards) Date: Mon, 27 Feb 2012 15:09:53 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 27, 2:43 pm, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 These are also good videos as well as the treatise and court case document below, you will find them exhilerating, liberating and very informative http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript http://anglo-saxonisrael.com/site/GreatImpersonation-8 http://www.youtube.com/watch?v=ZcwBEzW8S1M http://www.youtube.com/watch?v=9gBxMJFQd04 The YANK bustards are truly CONTEMPTUOUS ... It is because of the INCOMPETENT and RACIST dysfunctional courts that there is so much SCHOOL SHOOTINGS and VIOLENCE because NO ONE TRUSTS THE COURTS We will soon talk of the Kerri Dunn (1year for TERRORISM and HOAX) - jew daughter of a police officer VERSUS Dr Aafiya Siddiqui (90 years for FALSE and RIDICULOUS Charges by FBI ODIOUS and DESPICABLE LIARS) The FAT per DIEM FBI bustards use our TAX PAYER MONEY and INCOMPETENCE is UNACCEPTABLE. ===== http://www.youtube.com/watch?v=lX18zUp6WPY http://www.youtube.com/watch?v=XQapkVCx1HI http://www.youtube.com/watch?v=tXJ-k-iOg0M Hey Racist and INcompetent FBI Bustards, where is the ANTHRAX Mailer ? Where are the 4 blackboxes ? Where are the Pentagon Videos ? Why did you release the 5 dancing Israelis compromising the whole 911 investigation ? If the Dubai Police can catch Mossad Murderers and put the videos and Iranian Police can why cant you put the Pentagon Videos ? If Iran police can put the AMERICAN TERRORIST, Riggi and puting on INTERNATIONAL MEDIA a day after catching him without TORTURE, why cant you put the INNOCENT patsies on the MEDIA. Why did you have to LIE about Dr Afiya Siddiqui and torture that Innocent little mother of 3 and smashing the skull of her one child ? http://www.youtube.com/watch?v=DhMcii8smxk http://www.youtube.com/watch?v=0SZ2lxDJmdg There are CRIMINAL cases against CIA CRIMINAL Bustards in Italian courts. FBI bustards paid a penalty of $5.8 million to Steven Hatfill, but only because he was a white. They got away with MURDER of thousands of Non-whites in all parts of the world. Daily 911 news : http://911blogger.com http://www.youtube.com/watch?v=tRfhUezbKLw http://www.youtube.com/watch?v=x7kGZ3XPEm4 http://www.youtube.com/watch?v=lX18zUp6WPY Conclusion : FBI bustards are RACIST and INcompetent. They could neither catch the ANTHRAX or 911 YANK/Jew criminals nor could they cover them up - whichever was their actual goal or task. SLASH the SALARIES of FBI/CIA/NSA etc BUSTARDS into half all across tbe board, esp the whites/jew on the top. FBI Bustards failed to Catch BERNARD MADOFF even after that RACIST and UNPATRIOTIC Act FBI bustards failed to prevent ROMAN POLANSKY from absconding to europe and rapes. FBI bustards failed to prevent OKLAHOMA From steve+comp.lang.python at pearwood.info Mon Feb 27 19:36:09 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Feb 2012 00:36:09 GMT Subject: Python urllib2 problem: Name or service not known References: Message-ID: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote: > Hi all, > > Some time ago I've written some python code to read video data off an IP > camera connected via a router to a laptop. Now I try to run this code on > a different laptop and router combination, but now I can't access the > camera. [...] Check your web proxy and firewall. -- Steven From torriem at gmail.com Mon Feb 27 19:53:41 2012 From: torriem at gmail.com (Michael Torrie) Date: Mon, 27 Feb 2012 17:53:41 -0700 Subject: Python math is off by .000000000000045 In-Reply-To: <4F4BBD4C.1050603@stoneleaf.us> References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F4BBD4C.1050603@stoneleaf.us> Message-ID: <4F4C2595.6030207@gmail.com> On 02/27/2012 10:28 AM, Ethan Furman wrote: > jmfauth wrote: >> On 25 f?v, 23:51, Steven D'Aprano > +comp.lang.pyt... at pearwood.info> wrote: >>> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>>>>>> (2.0).hex() >>>> '0x1.0000000000000p+1' >>>>>>> (4.0).hex() >>>> '0x1.0000000000000p+2' >>>>>>> (1.5).hex() >>>> '0x1.8000000000000p+0' >>>>>>> (1.1).hex() >>>> '0x1.199999999999ap+0' >>>> jmf >>> What's your point? I'm afraid my crystal ball is out of order and I have >>> no idea whether you have a question or are just demonstrating your >>> mastery of copy and paste from the Python interactive interpreter. >> >> It should be enough to indicate the right direction >> for casual interested readers. > > I'm a casual interested reader and I have no idea what your post is > trying to say. He's simply showing you the hex (binary) representation of the floating-point number's binary representation. As you can clearly see in the case of 1.1, there is no finite sequence that can store that. You end up with repeating numbers. Just like 1/3, when represented in base 10 fractions (x1/10 + x2/100, x3/1000, etc), is a repeating sequence, the number base 10 numbers 1.1 or 0.2, or many others that are represented by exact base 10 fractions, end up as repeating sequences in base 2 fractions. This should help you understand why you get errors doing simple things like x/y*y doesn't quite get you back to x. From tjreedy at udel.edu Mon Feb 27 20:01:05 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 27 Feb 2012 20:01:05 -0500 Subject: Question about circular imports In-Reply-To: References: Message-ID: On 2/27/2012 1:16 AM, Frank Millman wrote: >> >> To avoid the tedious reference, follow this with >> read = sound.formats.wavread # choose the identifier you prefer I tested something like this with stdlib, but there must be some important difference I did not notice. It make be in the contents of __init__.py. > @Terry and OKB > > I tried that, but it does not work. > > a.py > /b > __init__.py > c.py > d.py > > a.py - > from b import c > c.py - > import b.d > d.py - > import b.c How about import b.d as d, etc? > If I run a.py, it returns with no error. > > c.py - > import b.d > d = b.d > d.py - > import b.c > c = b.c > > If I run a.py, I get > > Traceback (most recent call last): > File "F:\tests\a.py", line 1, in > from b import c > File "F:\tests\b\c.py", line 1, in > import b.d > File "F:\tests\b\d.py", line 2, in > c = b.c > AttributeError: 'module' object has no attribute 'c' > > I get the same if I try 'import b.c as c'. Try import b; c = b.c -- Terry Jan Reedy From ian.g.kelly at gmail.com Mon Feb 27 20:37:02 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 18:37:02 -0700 Subject: Question about circular imports In-Reply-To: References: Message-ID: On Mon, Feb 27, 2012 at 6:01 PM, Terry Reedy wrote: > On 2/27/2012 1:16 AM, Frank Millman wrote: >>> >>> >>> To avoid the tedious reference, follow this with >>> read = sound.formats.wavread # choose the identifier you prefer > > > I tested something like this with stdlib, but there must be some important > difference I did not notice. It make be in the contents of __init__.py. I don't know what you tried, but I can easily replicate Frank's results with an empty __init__.py. > How about import b.d as d, etc? > Try import b; c = b.c Why would any of these make a difference? The AttributeError indicates that at the time d tries to grab the module in b's "c" attribute, the attribute does not exist (because it has not finished importing). Alternate syntaxes for getting the "c" attribute from b are not going to change that. Python does some magic so that you can do "import b.c" inside d while b.c is still importing without resulting in infinite recursion, but the success of the import does not signify that b.c is actually available yet. Cheers, Ian From browns2112 at gmail.com Mon Feb 27 21:37:25 2012 From: browns2112 at gmail.com (Ray Clark) Date: Mon, 27 Feb 2012 18:37:25 -0800 (PST) Subject: Udacity CS 101 References: <28556790.1352.1330204852864.JavaMail.geo-discussion-forums@pbgq3> Message-ID: On Feb 25, 4:20?pm, Josh English wrote: > Has anyone here looked at Udacity's open CS101 course (http://www.udacity.com/overview/Course/cs101) that started this week? The goal of the seven week course is to build a web crawler. > > So far, I'm not impressed with the speed or content of the course. I was wondering what anyone here may think of it. You have to remember that this course assumes no prior computer programming knowledge. I agree, it is starting out very basic. Give it some more time. These guys have PhDs from MIT and/or have taught at Stanford. They know what they are doing. From python at mrabarnett.plus.com Mon Feb 27 21:38:26 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Feb 2012 02:38:26 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> Message-ID: <4F4C3E22.5010103@mrabarnett.plus.com> On 27/02/2012 16:57, Eric Frederich wrote: > Still freezing sometimes, like 1 out of 10 times that I run it. > Here is updated code and a couple of outputs. > [snip] I don't know what the problem is. All I can suggest is a slightly modified version. If a worker that says it's terminating without first saying that it's got nothing, then I can only assume that the worker had some uncaught exception. #!/usr/bin/env python import sys import Queue import multiprocessing import time def FOO(a, b, c): print 'foo', a, b, c return (a + b) * c class MyWorker(multiprocessing.Process): def __init__(self, name, inbox, outbox): super(MyWorker, self).__init__() self.name = name self.inbox = inbox self.outbox = outbox print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() def run(self): print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() try: while True: try: args = self.inbox.get_nowait() print >> sys.stderr, '%s got something to do' % self.name; sys.stderr.flush() except Queue.Empty: print >> sys.stderr, '%s got nothing' % self.name; sys.stderr.flush() break self.outbox.put(FOO(*args)) finally: print >> sys.stderr, '%s is terminating' % self.name; sys.stderr.flush() if __name__ == '__main__': # This file is being run as the main script. This part won't be # run if the file is imported. print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() todo = multiprocessing.Queue() for i in xrange(100): todo.put((i, i + 1, i + 2)) print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() result_queue = multiprocessing.Queue() print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() w1 = MyWorker('Worker 1', todo, result_queue) w2 = MyWorker('Worker 2', todo, result_queue) print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() w1.start() print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() w2.start() for i in xrange(100): print result_queue.get() From Tonicopm at yahoo.com Mon Feb 27 22:13:17 2012 From: Tonicopm at yahoo.com (Tonico) Date: Mon, 27 Feb 2012 19:13:17 -0800 (PST) Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) References: Message-ID: On Feb 28, 12:43?am, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 Idiot From bheld at awrcorp.com Mon Feb 27 22:26:31 2012 From: bheld at awrcorp.com (Ben Held) Date: Tue, 28 Feb 2012 03:26:31 +0000 Subject: wcout issue Message-ID: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> Hello, After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: wcout << L"Just a test\n"; now prints out: J u s t a t e s t Any clue why? Ben Held -------------- next part -------------- An HTML attachment was scrubbed... URL: From brenNOSPAMbarn at NObrenSPAMbarn.net Mon Feb 27 22:55:12 2012 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Tue, 28 Feb 2012 03:55:12 +0000 (UTC) Subject: Question about circular imports References: Message-ID: Frank Millman wrote: >> >> To avoid the tedious reference, follow this with >> read = sound.formats.wavread # choose the identifier you prefer >> > > @Terry and OKB > > I tried that, but it does not work. > > a.py > /b > __init__.py > c.py > d.py > > a.py - > from b import c > c.py - > import b.d > d.py - > import b.c > > If I run a.py, it returns with no error. > > c.py - > import b.d > d = b.d > d.py - > import b.c > c = b.c > > If I run a.py, I get > > Traceback (most recent call last): > File "F:\tests\a.py", line 1, in > from b import c > File "F:\tests\b\c.py", line 1, in > import b.d > File "F:\tests\b\d.py", line 2, in > c = b.c > AttributeError: 'module' object has no attribute 'c' > > I get the same if I try 'import b.c as c'. Interesting, you're right. Note that it will work in c.py but not in d.py Anyway, testing this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate library imported by both is easier to understand, and has the nice side bonus that it works. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From ian.g.kelly at gmail.com Tue Feb 28 00:00:56 2012 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 27 Feb 2012 22:00:56 -0700 Subject: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case) In-Reply-To: References: Message-ID: On Mon, Feb 27, 2012 at 8:13 PM, Tonico wrote: > Idiot Please don't reply to spam. You're just making it show up in the inboxes of those of us who already have these idiots kill-filed. From frank at chagford.com Tue Feb 28 02:50:17 2012 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Feb 2012 09:50:17 +0200 Subject: Question about sub-packages Message-ID: Hi all This is a follow-up to my recent question about circular imports, but on a different subject, hence the new thread. My application has grown to the point that it makes sense to split it up into sub-packages. >From a certain point of view, each package can be said to have an API, not just for third-party users of the application, but for other sub-packages within the application. In other words, there are a number of functions that can be called and a number of objects that can be instantiated from outside the sub-package. It struck me that, even though I can publish the API, it still requires external users to know enough of the internals of the package to know which modules to import and which objects to reference. This has two disadvantages - it makes it more difficult to understand the API, and it makes it more difficult for me to restructure the package internally. An alternative is to have a dedicated API within the sub-package, in the form of one-line functions that are called externally, and then perform whatever action is required internally and return results as appropriate. This is easier for users of the sub-package, and allows me to restructure the internals of the package without causing problems. If this makes sense, my next thought was, where is the best place to put this API. Then I thought, why not put it in the __init__.py of the sub-package? Then all that the users of the package have to do is import the package, and then place calls on it directly. I did a quick test and it seems to work. Is this a good idea, or are there any downsides? Thanks Frank Millman From jasonveldicott at gmail.com Tue Feb 28 02:55:18 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Tue, 28 Feb 2012 18:55:18 +1100 Subject: Error importing __init__ declared variable from another package Message-ID: Hi, I have a simple configuration of modules as beneath, but an import error is reported: /engine (__init__ is empty here) engine.py /sim __init__.py The module engine.py imports a variable instantiated in sim.__init__ as follows: from sim import var_name var_name.func() The following error messaged is received on the func() call above (Eclipse PyDev): "undefined variable from import: func" Any idea why this is causing an error? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jasonveldicott at gmail.com Tue Feb 28 02:57:06 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Tue, 28 Feb 2012 18:57:06 +1100 Subject: Error importing __init__ declared variable from another package In-Reply-To: References: Message-ID: Accidentally hit post by mistake before msg completed. Any comments appreciated. It's a very simple scenario, but not sure what the mistake is. Thanks Jason On Tue, Feb 28, 2012 at 6:55 PM, Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine > (__init__ is empty here) > engine.py > /sim > __init__.py > > > The module engine.py imports a variable instantiated in sim.__init__ as > follows: > > from sim import var_name > var_name.func() > > The following error messaged is received on the func() call above (Eclipse > PyDev): > > "undefined variable from import: func" > > Any idea why this is causing an error? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Tue Feb 28 03:31:38 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 09:31:38 +0100 Subject: Error importing __init__ declared variable from another package References: Message-ID: Jason Veldicott wrote: > Hi, > > I have a simple configuration of modules as beneath, but an import error > is reported: > > /engine > (__init__ is empty here) > engine.py > /sim > __init__.py > > > The module engine.py imports a variable instantiated in sim.__init__ as > follows: > > from sim import var_name > var_name.func() > > The following error messaged is received on the func() call above (Eclipse > PyDev): > > "undefined variable from import: func" Are you rephrasing or is this really the error message? If so run your program again on the command-line. Then please cut and paste the error message together with the traceback. > Any idea why this is causing an error? What version of Python are you using? What does sim/__init__.py contain? From alexander.borghgraef at gmail.com Tue Feb 28 04:50:24 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Tue, 28 Feb 2012 01:50:24 -0800 (PST) Subject: Python urllib2 problem: Name or service not known References: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <70f61b16-a0e7-452d-b295-73838c1b025d@w19g2000vbe.googlegroups.com> On Feb 28, 1:36?am, Steven D'Aprano wrote: > On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote: > > Hi all, > > > Some time ago I've written some python code to read video data off an IP > > camera connected via a router to a laptop. Now I try to run this code on > > a different laptop and router combination, but now I can't access the > > camera. > > [...] > > Check your web proxy and firewall. Hmm. Damn. I had disabled the proxy in .bashrc, but apparently the one in /etc/bash.bashrc was still enabled. Thanks. I'll still have to find out a way to get this thing working with proxy enabled if I ever want to connect it to our overall network. -- Alex From andrea.crotti.0 at gmail.com Tue Feb 28 05:07:39 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 10:07:39 +0000 Subject: check if directory is writable in a portable way Message-ID: <4F4CA76B.5040408@gmail.com> How should I check if I can create files in a directory? I tried to simply check if the directory is writeable with this function: def is_writable(name): """Return true if the file is writable from the current user """ return os.access(name, os.W_OK) but that doesn't work at all on Windows, because for example if I create a new directory and do os.access(dirpath, os.W_OK) it returns false, even if I can create files inside without problems. So maybe the only solution that works is something like try: open(path.join('temp', 'w')) except OsError: return False else: os.remove(path.join('temp')) return True would it make sense? From alexander.borghgraef at gmail.com Tue Feb 28 05:41:32 2012 From: alexander.borghgraef at gmail.com (Alex Borghgraef) Date: Tue, 28 Feb 2012 02:41:32 -0800 (PST) Subject: Python urllib2 problem: Name or service not known References: <4f4c2179$0$29989$c3e8da3$5496439d@news.astraweb.com> <70f61b16-a0e7-452d-b295-73838c1b025d@w19g2000vbe.googlegroups.com> Message-ID: On Feb 28, 10:50?am, Alex Borghgraef wrote: > I'll still have to find out a way to get this thing working with proxy > enabled if I ever want to connect it to our overall network. Ok, doing os.environ['http_proxy']='' before importing urllib2 seems to do the trick for that. -- Alex From mail at timgolden.me.uk Tue Feb 28 05:50:51 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 28 Feb 2012 10:50:51 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4CB18B.4050300@timgolden.me.uk> On 28/02/2012 10:07, Andrea Crotti wrote: > How should I check if I can create files in a directory? > > I tried to simply check if the directory is writeable with this function: > > def is_writable(name): > """Return true if the file is writable from the current user > """ > return os.access(name, os.W_OK) > > but that doesn't work at all on Windows, because for example if I create > a new directory > and do os.access(dirpath, os.W_OK) it returns false, even if I can > create files inside without problems. > > So maybe the only solution that works is something like > try: > open(path.join('temp', 'w')) > except OsError: > return False > else: > os.remove(path.join('temp')) > return True > > would it make sense? This is remarkably complicated to do on Windows by checking Security APIs etc. If the try:except dance works for you, I recommend that you use it. (In the past, people who have asked this question have not wanted to use try-except because they didn't want the overhead of creating even a zero-length file) TJG From python.list at tim.thechases.com Tue Feb 28 06:34:59 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 28 Feb 2012 05:34:59 -0600 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4CBBE3.5060108@tim.thechases.com> On 02/28/12 04:07, Andrea Crotti wrote: > How should I check if I can create files in a directory? > > So maybe the only solution that works is something like > try: > open(path.join('temp', 'w')) > except OsError: > return False > else: > os.remove(path.join('temp')) > return True It depends on the system & location. It's possible to set up directories with permissions that allow you to create files but not delete them, in which case you'd either (1) create the file and possibly fail on subsequent tests because the file already exists; or (2) litter the directory with tmpnam()-like results that you were unable to delete. It's ugly, I've encountered it, and haven't found a good universal solution myself. -tkc From ben+python at benfinney.id.au Tue Feb 28 06:36:56 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 28 Feb 2012 22:36:56 +1100 Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87mx83p4tj.fsf@benfinney.id.au> Steven D'Aprano writes: > On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: > > >> An integer variable is a variable holding an integer. A string variable > >> is a variable holding a string. A list variable is a variable holding a > >> list. > > > > And Python has none of those. Its references don't ?hold? anything. > > Ah, but they do. Following the name binding: > > x = 1 > > the name "x" now holds a reference to an int, or if you want to cut out > one layer of indirection, the name "x" holds an int. That is to say, the > value associated with the name "x" is an int. Names don't hold anything. Not in natural language, and not in Python. Which is exactly *why* the term ?name? is a good one, since Python's bindings don't hold anything either. It's a reference, not a container. > I don't believe this is a troublesome concept. Then you have a different concept of ?name? from anything I'd expect anyone to understand. > > I appreciate that you think ?variable? is a useful term in Python, > > but this kind of mangling of the concept convinces me that it's not > > worth it. > > I'm not sure that there is any mangling here. Or at least, the concept > is only mangled if you believe that Pascal- or C-like variables (named > memory locations) are the one true definition of "variable". I do not > believe this. The fact that you keep having to come back to container analogies, when that's exactly what Python doesn't have and what differentiates it, is why I think the term ?variable? isn't helping the discussion. Not for us, and not for newcomers to the language. > Words vary in their meanings Of course they do. but we don't have to let any word mean any arbitrary thing. I reject attempts to Humpty Dumpty our way through discussions with newcomers about Python concepts. -- \ ?Simplicity and elegance are unpopular because they require | `\ hard work and discipline to achieve and education to be | _o__) appreciated.? ?Edsger W. Dijkstra | Ben Finney From andrea.crotti.0 at gmail.com Tue Feb 28 07:01:00 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 12:01:00 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CBBE3.5060108@tim.thechases.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> Message-ID: <4F4CC1FC.40502@gmail.com> On 02/28/2012 11:34 AM, Tim Chase wrote: > On 02/28/12 04:07, Andrea Crotti wrote: >> How should I check if I can create files in a directory? >> >> So maybe the only solution that works is something like >> try: >> open(path.join('temp', 'w')) >> except OsError: >> return False >> else: >> os.remove(path.join('temp')) >> return True > > It depends on the system & location. It's possible to set up > directories with permissions that allow you to create files but not > delete them, in which case you'd either (1) create the file and > possibly fail on subsequent tests because the file already exists; or > (2) litter the directory with tmpnam()-like results that you were > unable to delete. > > It's ugly, I've encountered it, and haven't found a good universal > solution myself. > > -tkc > That's really ugly right, didn't think about this possibility. Well it's not a really critical part of my code, so I guess it's fine with the try-except dance.. But isn't there (or should there be) a windows-related library that abstracts this horrible things? Thanks From python.list at tim.thechases.com Tue Feb 28 07:12:44 2012 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 28 Feb 2012 06:12:44 -0600 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CC1FC.40502@gmail.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com> Message-ID: <4F4CC4BC.8050808@tim.thechases.com> On 02/28/12 06:01, Andrea Crotti wrote: >>> How should I check if I can create files in a directory? > > But isn't there (or should there be) a windows-related library that > abstracts this horrible things? Yes, there should be. There isn't as far as I know (though that doesn't mean much given my limited experiences in the recesses of Win32 APIs). Additionally, even if you did a LBYL instead, you'd open yourself to a race-condition where the permissions could theoretically change between the time you check and the time you actually try to write there. Granted, that's a slim chance and usually would be a "Doctor, my foot hurts when I do $THIS"/"Well don't do that" situation where the solution is "don't change the permissions while running this program". -tkc From ssmile03 at gmail.com Tue Feb 28 07:23:36 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 17:53:36 +0530 Subject: pickling to an output file. Message-ID: I have created a bytestream (readfile.pkl) from pickle.dump() already in different folder (say /tmp) succesfully. Now I wish to open the file, read it and finally write the output to a file to "output.txt". To read the file bytestream file (readfile.pkl) I did perform as -- --- import pickle def print_report(): with open('/tmp/readfile.pkl', 'rb') as f: my_shared = pickle.load(f) print my_shared print "================================================================" -- My above code should perform all 3 of below - (a) Open the pickle file as above (b) read the pickled object (c) write the output to a file say "output.txt" Can I have know if my above code is reading properly and how to write to an output file 'output.txt' -------------- next part -------------- An HTML attachment was scrubbed... URL: From frank at chagford.com Tue Feb 28 07:44:48 2012 From: frank at chagford.com (Frank Millman) Date: Tue, 28 Feb 2012 14:44:48 +0200 Subject: Question about sub-packages References: Message-ID: "Frank Millman" wrote in message news:jii0vo$36t$1 at dough.gmane.org... > Hi all > > This is a follow-up to my recent question about circular imports, but on a > different subject, hence the new thread. > [...] > > If this makes sense, my next thought was, where is the best place to put > this API. Then I thought, why not put it in the __init__.py of the > sub-package? Then all that the users of the package have to do is import > the package, and then place calls on it directly. > > I did a quick test and it seems to work. Is this a good idea, or are there > any downsides? > Answering my own question again ... The one-liner API concept *may* be a good idea - still waiting for some feedback on that. But putting them into __init__.py is not a good idea, as I run into some subtle 'circular import' problems again. I don't fully understand the conditions under which it fails, but that is unimportant, as my objective is to avoid circular imports altogether. I have created a module called 'api.py' and put them in there, and that seems to work (for now...). Frank From mail at timgolden.me.uk Tue Feb 28 08:33:52 2012 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 28 Feb 2012 13:33:52 +0000 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CC1FC.40502@gmail.com> References: <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com> Message-ID: <4F4CD7C0.4070104@timgolden.me.uk> On 28/02/2012 12:01, Andrea Crotti wrote: > On 02/28/2012 11:34 AM, Tim Chase wrote: >> On 02/28/12 04:07, Andrea Crotti wrote: >>> How should I check if I can create files in a directory? >>> >>> So maybe the only solution that works is something like >>> try: >>> open(path.join('temp', 'w')) >>> except OsError: >>> return False >>> else: >>> os.remove(path.join('temp')) >>> return True >> >> It depends on the system & location. It's possible to set up >> directories with permissions that allow you to create files but not >> delete them, in which case you'd either (1) create the file and >> possibly fail on subsequent tests because the file already exists; or >> (2) litter the directory with tmpnam()-like results that you were >> unable to delete. >> >> It's ugly, I've encountered it, and haven't found a good universal >> solution myself. >> >> -tkc >> > > That's really ugly right, didn't think about this possibility. > Well it's not a really critical part of my code, so I guess it's fine > with the try-except dance.. > > But isn't there (or should there be) a windows-related library that > abstracts this horrible things? Well I maintain winsys [1] which does help out in admin-y tasks in general on Windows, but I'm afraid I've never had the need to scratch this particular itch, and the API solution is messier than you might think, and more fiddly to get right. If I ever get enough moments together I might do it, but patches are always looked upon kindly :) TJG [1] https://github.com/tjguk/winsys From steve+comp.lang.python at pearwood.info Tue Feb 28 09:06:23 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 28 Feb 2012 14:06:23 GMT Subject: namespace question References: <4895480.4960.1330062902417.JavaMail.geo-discussion-forums@ynjd19> <02658273-fb07-4cb6-a223-27520f4a0168@p13g2000yqd.googlegroups.com> <4f480e68$0$29989$c3e8da3$5496439d@news.astraweb.com> <87y5rqrney.fsf@benfinney.id.au> <4f4a3633$0$29989$c3e8da3$5496439d@news.astraweb.com> <87mx83p4tj.fsf@benfinney.id.au> Message-ID: <4f4cdf5e$0$29989$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Feb 2012 22:36:56 +1100, Ben Finney wrote: > Steven D'Aprano writes: > >> On Sun, 26 Feb 2012 19:47:49 +1100, Ben Finney wrote: >> >> >> An integer variable is a variable holding an integer. A string >> >> variable is a variable holding a string. A list variable is a >> >> variable holding a list. >> > >> > And Python has none of those. Its references don't ?hold? anything. >> >> Ah, but they do. Following the name binding: >> >> x = 1 >> >> the name "x" now holds a reference to an int, or if you want to cut out >> one layer of indirection, the name "x" holds an int. That is to say, >> the value associated with the name "x" is an int. > > Names don't hold anything. Not in natural language, and not in Python. I don't agree, I think the analogy of "holding on to", or "holding", works well for names in this context. A *binding* (the term you prefer) refers to the process of *tying* two objects together with rope, string, or twine such that they *hold fast*. If names don't hold values, neither can they be bound. I would be surprised if many programmers, whether experienced or not, or even non-programmers, failed to grasp the concept of a name "holding" a value. (And I point out that to *grasp a concept* is also to hold on to it. We hold our loved ones dear even when they are on the other side of the world, we hold these truths to be self-evident, and we don't hold with that sort of behaviour -- surely we are capable of holding onto the idea that names can hold values?) But rather than spend any more time trying to convince you to hold a different opinion, I will accept your criticism and rephrase my earlier statement: A string variable is a symbolic identifier given to a value and capable of being varied, which is given to a value which is a string. Python has these -- it has names, which are symbolic identifiers given to values, and those name:value bindings are capable of varying. It has strings. And you can bind names to strings. Ergo, it has string variables. I acknowledge that when I say "string variable", I mean a variable whose value is a string *at this moment*, I don't mean a variable which is prohibited by the compiler from taking a non-string value. To the extent that careless use of the term variable may confuse the naive reader who assumes that Python is just like Pascal (or any other statically typed language), it is sometimes useful to emphasis the differences by talking about "name bindings". But sometimes it is useful to emphasis the similarities, in which case "name binding" is obfuscatory and "variable" is perfectly reasonable. -- Steven From chris at simplistix.co.uk Tue Feb 28 09:41:33 2012 From: chris at simplistix.co.uk (Chris Withers) Date: Tue, 28 Feb 2012 14:41:33 +0000 Subject: xlrd 0.7.3 released! Message-ID: <4F4CE79D.5060408@simplistix.co.uk> Hi All, I'm pleased to announce the release of xlrd 0.7.3. This release just brings in some documentation updates that were missed for 0.7.2. cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From andrea.crotti.0 at gmail.com Tue Feb 28 09:42:04 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 14:42:04 +0000 Subject: suppressing argparse arguments in the help Message-ID: <4F4CE7BC.6080908@gmail.com> I have a script that might be used interactively but also has some arguments that should not be used by "normal" users. So I just want to suppress them from the help. I've read somewhere that the help=SUPPRESS should do what I want: parser.add_argument('-n', '--test_only', action='store_true', help=SUPPRESS) but that's what I get from "myapp -h", which is not exactly what I was looking for.. -f, --first_level ==SUPPRESS== (default: False) --never_redevelop ==SUPPRESS== (default: False) Any other solutions? From ssmile03 at gmail.com Tue Feb 28 10:14:32 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 20:44:32 +0530 Subject: Pickle performing class instantiation ?? Message-ID: I am looking for pickle performing class instantiation, something as prototype like - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Tue Feb 28 10:54:35 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 21:24:35 +0530 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: Am I doing the right thing for - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump, simply guessing - as - --- #!/usr/bin/python import pickle class Pickle: def __init__(self, Parameter1, Parameter2, Parameter3): self.PM1 = Parameter1 self.PM2 = Parameter2 self.PM3 = Parameter3 with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump((self.PM1, self.PM2, self.PM3), f) with open('/tmp/readfile.pkl', 'rb') as f: self.PM1, self.PM2, self.PM3 = pickle.load(f) print self.PM1 print self.PM2 print self.PM3 ---- but I get an error message as - ----- $ ./class-test1.py Traceback (most recent call last): File "./class-test1.py", line 12, in pickle.dump((self.PM1, self.PM2, self.PM3), f) NameError: name 'self' is not defined ------ On Tue, Feb 28, 2012 at 8:44 PM, Smiley 4321 wrote: > I am looking for pickle performing class instantiation, something as > prototype like - > > - Have a class > - Instantiate the class with 3 parameters > - pickle the class instance > - generate a bytestream (.pkl) using pickle.dump > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Tue Feb 28 11:02:24 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 17:02:24 +0100 Subject: suppressing argparse arguments in the help References: <4F4CE7BC.6080908@gmail.com> Message-ID: Andrea Crotti wrote: > I have a script that might be used interactively but also has some > arguments that > should not be used by "normal" users. > So I just want to suppress them from the help. > I've read somewhere that the help=SUPPRESS should do what I want: > > parser.add_argument('-n', '--test_only', > action='store_true', > help=SUPPRESS) > > but that's what I get from "myapp -h", which is not exactly what I was > looking for.. > > > -f, --first_level ==SUPPRESS== (default: False) > --never_redevelop ==SUPPRESS== (default: False) > > > Any other solutions? That shouldn't happen. Did you reload() somewhere? argparse tests object identity not equality with SUPPRESS, so you have to ensure that SUPPRESS stems from the same instance of the argparse module as your ArgumentParser. From ramit.prasad at jpmorgan.com Tue Feb 28 11:09:07 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 28 Feb 2012 16:09:07 +0000 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474164475@SCACMX008.exchad.jpmchase.net> >class Pickle: >??? def __init__(self, Parameter1, Parameter2, Parameter3): >??? ??? self.PM1 = Parameter1 >??? ??? self.PM2 = Parameter2 >??? ??? self.PM3 = Parameter3 >with open('/tmp/readfile.pkl', 'wb') as f: >??? pickle.dump((self.PM1, self.PM2, self.PM3), f) ??? >with open('/tmp/readfile.pkl', 'rb') as f: > ?? self.PM1, self.PM2, self.PM3 = pickle.load(f) >$ ./class-test1.py >Traceback (most recent call last): >? File "./class-test1.py", line 12, in > ?? pickle.dump((self.PM1, self.PM2, self.PM3), f) >NameError: name 'self' is not defined You need to create an instance of Pickle first and then manipulate that instance. instance = Pickle( 'something', ['blah'], 5 ) print instance.PM1 Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From __peter__ at web.de Tue Feb 28 11:14:36 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 17:14:36 +0100 Subject: Pickle performing class instantiation ?? References: Message-ID: Smiley 4321 wrote: > Am I doing the right thing for - > > - Have a class > - Instantiate the class with 3 parameters > - pickle the class instance > - generate a bytestream (.pkl) using pickle.dump, simply guessing - > > as - > > --- > #!/usr/bin/python > > import pickle > > class Pickle: > def __init__(self, Parameter1, Parameter2, Parameter3): > self.PM1 = Parameter1 > self.PM2 = Parameter2 > self.PM3 = Parameter3 # You need something to pickle first. # You could call it "self", but that is confusing # as this name is by convention used inside methods as # the current instance. So: p = Pickle(1, 2, 3) > with open('/tmp/readfile.pkl', 'wb') as f: # Don't touch the object's attributes, # pickle the whole instance instead: pickle.dump(p, f) > with open('/tmp/readfile.pkl', 'rb') as f: # Load the instance back from file p = pickle.load(f) # print it print p.PM1 print p.PM2 print p.PM3 From andrea.crotti.0 at gmail.com Tue Feb 28 11:14:50 2012 From: andrea.crotti.0 at gmail.com (Andrea Crotti) Date: Tue, 28 Feb 2012 16:14:50 +0000 Subject: suppressing argparse arguments in the help In-Reply-To: References: <4F4CE7BC.6080908@gmail.com> Message-ID: <4F4CFD7A.20904@gmail.com> On 02/28/2012 04:02 PM, Peter Otten wrote: > Andrea Crotti wrote: > >> I have a script that might be used interactively but also has some >> arguments that >> should not be used by "normal" users. >> So I just want to suppress them from the help. >> I've read somewhere that the help=SUPPRESS should do what I want: >> >> parser.add_argument('-n', '--test_only', >> action='store_true', >> help=SUPPRESS) >> >> but that's what I get from "myapp -h", which is not exactly what I was >> looking for.. >> >> >> -f, --first_level ==SUPPRESS== (default: False) >> --never_redevelop ==SUPPRESS== (default: False) >> >> >> Any other solutions? > That shouldn't happen. Did you reload() somewhere? > argparse tests object identity not equality with SUPPRESS, so you have to > ensure that SUPPRESS stems from the same instance of the argparse module as > your ArgumentParser. > Ah great yes it wasn't actually the same.. but why not just use if text != SUPPRESS instead of: if text is not SUPPRESS probably the second is more safe, but they are it's still checking against a constant that is very unlikely to clash with anything.. From bahamutzero8825 at gmail.com Tue Feb 28 11:15:09 2012 From: bahamutzero8825 at gmail.com (Andrew Berg) Date: Tue, 28 Feb 2012 10:15:09 -0600 Subject: Pickle performing class instantiation ?? In-Reply-To: References: Message-ID: <4F4CFD8D.7060505@gmail.com> On 2/28/2012 9:54 AM, Smiley 4321 wrote: > NameError: name 'self' is not defined self is meaningless outside a class definition. You should refactor your dump, load and print code as methods inside the class definition, create an instance and call the methods on that instance. -- CPython 3.2.2 | Windows NT 6.1.7601.17640 From eric.frederich at gmail.com Tue Feb 28 12:16:19 2012 From: eric.frederich at gmail.com (Eric Frederich) Date: Tue, 28 Feb 2012 12:16:19 -0500 Subject: multiprocessing, what am I doing wrong? In-Reply-To: <4F4C3E22.5010103@mrabarnett.plus.com> References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> <4F4C3E22.5010103@mrabarnett.plus.com> Message-ID: If I do a time.sleep(0.001) right at the beginning of the run() method, then it completes fine. I was able to run it through a couple hundred times without problem. If I sleep for less time than that or not at all, it may or may not complete. On Mon, Feb 27, 2012 at 9:38 PM, MRAB wrote: > On 27/02/2012 16:57, Eric Frederich wrote: > >> Still freezing sometimes, like 1 out of 10 times that I run it. >> Here is updated code and a couple of outputs. >> >> [snip] > I don't know what the problem is. All I can suggest is a slightly > modified version. > > If a worker that says it's terminating without first saying that it's > got nothing, then I can only assume that the worker had some uncaught > exception. > > > > #!/usr/bin/env python > > import sys > import Queue > import multiprocessing > import time > > def FOO(a, b, c): > print 'foo', a, b, c > return (a + b) * c > > class MyWorker(multiprocessing.**Process): > def __init__(self, name, inbox, outbox): > super(MyWorker, self).__init__() > self.name = name > self.inbox = inbox > self.outbox = outbox > print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush() > def run(self): > print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush() > try: > > while True: > try: > args = self.inbox.get_nowait() > print >> sys.stderr, '%s got something to do' % > self.name; sys.stderr.flush() > except Queue.Empty: > print >> sys.stderr, '%s got nothing' % self.name; > sys.stderr.flush() > break > self.outbox.put(FOO(*args)) > finally: > print >> sys.stderr, '%s is terminating' % self.name; > sys.stderr.flush() > > > if __name__ == '__main__': > # This file is being run as the main script. This part won't be > # run if the file is imported. > > print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush() > todo = multiprocessing.Queue() > > for i in xrange(100): > todo.put((i, i + 1, i + 2)) > > print >> sys.stderr, 'Creating results queue'; sys.stderr.flush() > result_queue = multiprocessing.Queue() > > print >> sys.stderr, 'Creating Workers'; sys.stderr.flush() > w1 = MyWorker('Worker 1', todo, result_queue) > w2 = MyWorker('Worker 2', todo, result_queue) > > print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush() > w1.start() > print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush() > w2.start() > > for i in xrange(100): > print result_queue.get() > -- > http://mail.python.org/**mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From crstop at gmail.com Tue Feb 28 12:36:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 09:36:24 -0800 (PST) Subject: Need to write python source with python Message-ID: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Hi All, I'm new to Python but have experience with a few other programming languages(Java, Perl, JavaScript). I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) a python class and functions from python. I will also need to later read and edit the file. I realize I could just write strings using the available string and file writing methods but suspect there is a better way than that. I have read about pickle, ast, and Django; searched this group and the web but haven't found a solution that seems to fit. Any suggestion? From ssmile03 at gmail.com Tue Feb 28 12:51:20 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Tue, 28 Feb 2012 23:21:20 +0530 Subject: GUI for pickle read Message-ID: Can I have some thoughts about - building a GUI to display the results of the pickle read? A prototype code should be fine on Linux. ~ BR -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Tue Feb 28 12:56:34 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 28 Feb 2012 09:56:34 -0800 Subject: Python math is off by .000000000000045 In-Reply-To: <4F4C2595.6030207@gmail.com> References: <4f4965f5$0$29989$c3e8da3$5496439d@news.astraweb.com> <4F4BBD4C.1050603@stoneleaf.us> <4F4C2595.6030207@gmail.com> Message-ID: <4F4D1552.60809@stoneleaf.us> Michael Torrie wrote: > He's simply showing you the hex (binary) representation of the > floating-point number's binary representation. As you can clearly see > in the case of 1.1, there is no finite sequence that can store that. > You end up with repeating numbers. Thanks for the explanation. > This should help you understand why you get errors > doing simple things like x/y*y doesn't quite get you back to x. I already understood that. I just didn't understand what point he was trying to make since he gave no explanation. ~Ethan~ From __peter__ at web.de Tue Feb 28 12:56:43 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 18:56:43 +0100 Subject: Need to write python source with python References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: crstop at gmail.com wrote: > I'm new to Python but have experience with a few other programming > languages(Java, Perl, JavaScript). > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > a python class and functions from python. I will also need to later read > and edit the file. I realize I could just write strings using the > available string and file writing methods but suspect there is a better > way than that. > > I have read about pickle, ast, and Django; searched this group and the web > but haven't found a solution that seems to fit. Any suggestion? Due to Python's dynamic nature it is rarely necessary to generate Python code. What are you actually trying to achieve? From ethan at stoneleaf.us Tue Feb 28 12:58:28 2012 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 28 Feb 2012 09:58:28 -0800 Subject: Question about circular imports In-Reply-To: References: Message-ID: <4F4D15C4.7090606@stoneleaf.us> OKB (not okblacke) wrote: > Anyway, testing this just reinforced my distaste for circular > imports. Just trying to think about how it ought to work with a > importing c but then c and d importing each other makes my brain hurt. > Refactoring the files so that common code is in a separate library > imported by both is easier to understand, and has the nice side bonus > that it works. > +1 QOTW From __peter__ at web.de Tue Feb 28 13:07:02 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 19:07:02 +0100 Subject: suppressing argparse arguments in the help References: <4F4CE7BC.6080908@gmail.com> <4F4CFD7A.20904@gmail.com> Message-ID: Andrea Crotti wrote: > On 02/28/2012 04:02 PM, Peter Otten wrote: >> Andrea Crotti wrote: >> >>> I have a script that might be used interactively but also has some >>> arguments that >>> should not be used by "normal" users. >>> So I just want to suppress them from the help. >>> I've read somewhere that the help=SUPPRESS should do what I want: >>> >>> parser.add_argument('-n', '--test_only', >>> action='store_true', >>> help=SUPPRESS) >>> >>> but that's what I get from "myapp -h", which is not exactly what I was >>> looking for.. >>> >>> >>> -f, --first_level ==SUPPRESS== (default: False) >>> --never_redevelop ==SUPPRESS== (default: False) >>> >>> >>> Any other solutions? >> That shouldn't happen. Did you reload() somewhere? >> argparse tests object identity not equality with SUPPRESS, so you have to >> ensure that SUPPRESS stems from the same instance of the argparse module >> as your ArgumentParser. >> > > Ah great yes it wasn't actually the same.. > but why not just use > if text != SUPPRESS > instead of: > if text is not SUPPRESS Steven Bethard would have to answer that. If it were my code I would have used the equality test, but also the correct symbolic constant... > probably the second is more safe, but they are it's still checking > against a constant that > is very unlikely to clash with anything.. From dihedral88888 at googlemail.com Tue Feb 28 13:09:50 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 28 Feb 2012 10:09:50 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <11747773.3845.1330452590293.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?29????UTC+8??1?56?43??Peter Otten??? > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? Check myHDL, and BOA and pythoncard that can translate user messages to pyhton code as delphie. From dihedral88888 at googlemail.com Tue Feb 28 13:09:50 2012 From: dihedral88888 at googlemail.com (88888 Dihedral) Date: Tue, 28 Feb 2012 10:09:50 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <11747773.3845.1330452590293.JavaMail.geo-discussion-forums@pbeo1> ? 2012?2?29????UTC+8??1?56?43??Peter Otten??? > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? Check myHDL, and BOA and pythoncard that can translate user messages to pyhton code as delphie. From python at mrabarnett.plus.com Tue Feb 28 13:12:36 2012 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 28 Feb 2012 18:12:36 +0000 Subject: multiprocessing, what am I doing wrong? In-Reply-To: References: <4F46A49D.9030905@mrabarnett.plus.com> <4F47D89A.4080806@mrabarnett.plus.com> <4F4C3E22.5010103@mrabarnett.plus.com> Message-ID: <4F4D1914.9010209@mrabarnett.plus.com> On 28/02/2012 17:16, Eric Frederich wrote: > If I do a time.sleep(0.001) right at the beginning of the run() method, > then it completes fine. > I was able to run it through a couple hundred times without problem. > If I sleep for less time than that or not at all, it may or may not > complete. > [snip] To me that suggests that the OS works in units of 1 millisecond, so a sleep of less than 0.001 seconds is rounded to 0 milliseconds. From malaclypse2 at gmail.com Tue Feb 28 13:13:03 2012 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 28 Feb 2012 13:13:03 -0500 Subject: GUI for pickle read In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: > Can I have some thoughts about - building a GUI to display the results of > the pickle read? > > A prototype code should be fine on Linux. It doesn't seem like it would be all that useful, though I may just be lacking in imagination. What would you do with such a thing? -- Jerry From crstop at gmail.com Tue Feb 28 13:30:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 10:30:24 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? I'm trying to generate the script file that will launch a PythonCard resource file. very basic example from the documentation. #!/usr/bin/python """ __version__ = "$Revision: 1.10 $" __date__ = "$Date: 2004/04/24 22:13:31 $" """ from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() From crstop at gmail.com Tue Feb 28 13:30:24 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 10:30:24 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> Message-ID: <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > I'm new to Python but have experience with a few other programming > > languages(Java, Perl, JavaScript). > > > > I'm using Python 2.7.2 and I'm trying to create and write to a file (.py) > > a python class and functions from python. I will also need to later read > > and edit the file. I realize I could just write strings using the > > available string and file writing methods but suspect there is a better > > way than that. > > > > I have read about pickle, ast, and Django; searched this group and the web > > but haven't found a solution that seems to fit. Any suggestion? > > Due to Python's dynamic nature it is rarely necessary to generate Python > code. What are you actually trying to achieve? I'm trying to generate the script file that will launch a PythonCard resource file. very basic example from the documentation. #!/usr/bin/python """ __version__ = "$Revision: 1.10 $" __date__ = "$Date: 2004/04/24 22:13:31 $" """ from PythonCard import model class Minimal(model.Background): pass if __name__ == '__main__': app = model.Application(Minimal) app.MainLoop() From mbadoiu at gmail.com Tue Feb 28 13:33:07 2012 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Tue, 28 Feb 2012 13:33:07 -0500 Subject: Listing children processes Message-ID: I'm trying to compute the total CPU load of an external process and it's children. (so I cannot use resource.getrusage) For the load of the process I can just grab it from /proc/X/stat. How do I get the CPU load of the children processes? Is there an easy way to get a list of the children processes? thanks, --mihai -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.france.mailinglists at gmail.com Tue Feb 28 13:38:44 2012 From: a.france.mailinglists at gmail.com (Aaron France) Date: Tue, 28 Feb 2012 19:38:44 +0100 Subject: GUI for pickle read In-Reply-To: References: Message-ID: <4F4D1F34.40100@gmail.com> > On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: >> Can I have some thoughts about - building a GUI to display the results of >> the pickle read? >> >> A prototype code should be fine on Linux. What on earth is this post asking? Do you want code? Opinions? From __peter__ at web.de Tue Feb 28 14:25:33 2012 From: __peter__ at web.de (Peter Otten) Date: Tue, 28 Feb 2012 20:25:33 +0100 Subject: Need to write python source with python References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: crstop at gmail.com wrote: > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: >> crstop at gmail.com wrote: >> >> > I'm new to Python but have experience with a few other programming >> > languages(Java, Perl, JavaScript). >> > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file >> > (.py) a python class and functions from python. I will also need to >> > later read and edit the file. I realize I could just write strings >> > using the available string and file writing methods but suspect there >> > is a better way than that. >> > >> > I have read about pickle, ast, and Django; searched this group and the >> > web but haven't found a solution that seems to fit. Any suggestion? >> >> Due to Python's dynamic nature it is rarely necessary to generate Python >> code. What are you actually trying to achieve? > > I'm trying to generate the script file that will launch a PythonCard > resource file. > > very basic example from the documentation. > > #!/usr/bin/python > """ > __version__ = "$Revision: 1.10 $" > __date__ = "$Date: 2004/04/24 22:13:31 $" > """ > > from PythonCard import model > > class Minimal(model.Background): > pass > > if __name__ == '__main__': > app = model.Application(Minimal) > app.MainLoop() If it doesn't get too complex you could start with Python's built-in string formatting: import sys template = '''\ #!/usr/bin/python from PythonCard import model class {Class}(model.Background): pass if __name__ == '__main__': app = model.Application({Class}) app.MainLoop() ''' resourcename, filename = sys.argv[1:] with open(resourcename, "U") as f: data = eval(f.read()) with open(filename, "w") as f: f.write(template.format(Class=data["application"]["name"])) If you need logic inside the template, here's on overview: http://wiki.python.org/moin/Templating So there are rather too many options than too few. From d at davea.name Tue Feb 28 14:32:16 2012 From: d at davea.name (Dave Angel) Date: Tue, 28 Feb 2012 14:32:16 -0500 Subject: wcout issue In-Reply-To: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> References: <490969328934674185BE9272698B1CBD1A8A4E04@ex2a.awr.local> Message-ID: <4F4D2BC0.40308@davea.name> On 02/27/2012 10:26 PM, Ben Held wrote: > Hello, > > After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: > > wcout<< L"Just a test\n"; > > now prints out: > > J u s t a t e s t > > Any clue why? > > > Ben Held > > Have you tried capturing this output, and looking at it with a hex viewer? Are the characters really space, or could they be nulls? If the latter, perhaps it's outputting ucs2 for Unicode. (I have no further ideas, just trying to provoke some experimentation) -- DaveA From crstop at gmail.com Tue Feb 28 14:36:00 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 11:36:00 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: <4382344.985.1330457760893.JavaMail.geo-discussion-forums@pbbpk4> On Tuesday, February 28, 2012 11:25:33 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > >> crstop at gmail.com wrote: > >> > >> > I'm new to Python but have experience with a few other programming > >> > languages(Java, Perl, JavaScript). > >> > > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file > >> > (.py) a python class and functions from python. I will also need to > >> > later read and edit the file. I realize I could just write strings > >> > using the available string and file writing methods but suspect there > >> > is a better way than that. > >> > > >> > I have read about pickle, ast, and Django; searched this group and the > >> > web but haven't found a solution that seems to fit. Any suggestion? > >> > >> Due to Python's dynamic nature it is rarely necessary to generate Python > >> code. What are you actually trying to achieve? > > > > I'm trying to generate the script file that will launch a PythonCard > > resource file. > > > > very basic example from the documentation. > > > > #!/usr/bin/python > > """ > > __version__ = "$Revision: 1.10 $" > > __date__ = "$Date: 2004/04/24 22:13:31 $" > > """ > > > > from PythonCard import model > > > > class Minimal(model.Background): > > pass > > > > if __name__ == '__main__': > > app = model.Application(Minimal) > > app.MainLoop() > > If it doesn't get too complex you could start with Python's built-in string > formatting: > > import sys > > template = '''\ > #!/usr/bin/python > from PythonCard import model > > class {Class}(model.Background): > pass > > if __name__ == '__main__': > app = model.Application({Class}) > app.MainLoop() > ''' > > resourcename, filename = sys.argv[1:] > > with open(resourcename, "U") as f: > data = eval(f.read()) > > with open(filename, "w") as f: > f.write(template.format(Class=data["application"]["name"])) > > If you need logic inside the template, here's on overview: > > http://wiki.python.org/moin/Templating > > So there are rather too many options than too few. It shouldn't get very complicated so I look through those options. Thanks to all posters From crstop at gmail.com Tue Feb 28 14:36:00 2012 From: crstop at gmail.com (crstop at gmail.com) Date: Tue, 28 Feb 2012 11:36:00 -0800 (PST) Subject: Need to write python source with python In-Reply-To: References: <23135461.7.1330450584442.JavaMail.geo-discussion-forums@pbcrt4> <6137475.17.1330453824069.JavaMail.geo-discussion-forums@pbjl1> Message-ID: <4382344.985.1330457760893.JavaMail.geo-discussion-forums@pbbpk4> On Tuesday, February 28, 2012 11:25:33 AM UTC-8, Peter Otten wrote: > crstop at gmail.com wrote: > > > On Tuesday, February 28, 2012 9:56:43 AM UTC-8, Peter Otten wrote: > >> crstop at gmail.com wrote: > >> > >> > I'm new to Python but have experience with a few other programming > >> > languages(Java, Perl, JavaScript). > >> > > >> > I'm using Python 2.7.2 and I'm trying to create and write to a file > >> > (.py) a python class and functions from python. I will also need to > >> > later read and edit the file. I realize I could just write strings > >> > using the available string and file writing methods but suspect there > >> > is a better way than that. > >> > > >> > I have read about pickle, ast, and Django; searched this group and the > >> > web but haven't found a solution that seems to fit. Any suggestion? > >> > >> Due to Python's dynamic nature it is rarely necessary to generate Python > >> code. What are you actually trying to achieve? > > > > I'm trying to generate the script file that will launch a PythonCard > > resource file. > > > > very basic example from the documentation. > > > > #!/usr/bin/python > > """ > > __version__ = "$Revision: 1.10 $" > > __date__ = "$Date: 2004/04/24 22:13:31 $" > > """ > > > > from PythonCard import model > > > > class Minimal(model.Background): > > pass > > > > if __name__ == '__main__': > > app = model.Application(Minimal) > > app.MainLoop() > > If it doesn't get too complex you could start with Python's built-in string > formatting: > > import sys > > template = '''\ > #!/usr/bin/python > from PythonCard import model > > class {Class}(model.Background): > pass > > if __name__ == '__main__': > app = model.Application({Class}) > app.MainLoop() > ''' > > resourcename, filename = sys.argv[1:] > > with open(resourcename, "U") as f: > data = eval(f.read()) > > with open(filename, "w") as f: > f.write(template.format(Class=data["application"]["name"])) > > If you need logic inside the template, here's on overview: > > http://wiki.python.org/moin/Templating > > So there are rather too many options than too few. It shouldn't get very complicated so I look through those options. Thanks to all posters From craigyk at me.com Tue Feb 28 16:04:59 2012 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 28 Feb 2012 13:04:59 -0800 Subject: alternative to with statement? Message-ID: I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. The best I've found is to abuse the for notation: for _ in cachingcontext(x): # create cached resources here # return cached resources I would have really liked: with cachingcontext(x): # create cached resources here # return cached resources I'd also like to avoid the following because it is unnecessary boilerplate: with cachingcontext(x) as skip: if not skip: # create cached resources here # return cached resources From clp2 at rebertia.com Tue Feb 28 16:35:47 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Tue, 28 Feb 2012 13:35:47 -0800 Subject: Listing children processes In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: > I'm trying to compute the total CPU load of an external process and it's > children.? (so I cannot use resource.getrusage)? For the load of the process > I can just grab it from /proc/X/stat.? How do I get the CPU load of the > children processes?? Is there an easy way to get a list of the children > processes? http://code.google.com/p/psutil/ Cheers, Chris From mbadoiu at gmail.com Tue Feb 28 16:39:07 2012 From: mbadoiu at gmail.com (Mihai Badoiu) Date: Tue, 28 Feb 2012 16:39:07 -0500 Subject: Listing children processes In-Reply-To: References: Message-ID: Looked at that before. psutil doesn't do children. --mihai On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: > On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: > > I'm trying to compute the total CPU load of an external process and it's > > children. (so I cannot use resource.getrusage) For the load of the > process > > I can just grab it from /proc/X/stat. How do I get the CPU load of the > > children processes? Is there an easy way to get a list of the children > > processes? > > http://code.google.com/p/psutil/ > > Cheers, > Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at gmail.com Tue Feb 28 16:47:00 2012 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 28 Feb 2012 21:47:00 +0000 Subject: Listing children processes In-Reply-To: References: Message-ID: On 28 February 2012 21:39, Mihai Badoiu wrote: > On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >> >> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >> > I'm trying to compute the total CPU load of an external process and it's >> > children.? (so I cannot use resource.getrusage)? For the load of the >> > process >> > I can just grab it from /proc/X/stat.? How do I get the CPU load of the >> > children processes?? Is there an easy way to get a list of the children >> > processes? >> >> http://code.google.com/p/psutil/ >> >> Cheers, >> Chris > Looked at that before.? psutil doesn't do children. > > --mihai Please don't top-post! Also, psutil.Process.get_children() looks to me like it "does" children. -- Arnaud From rantingrickjohnson at gmail.com Tue Feb 28 17:12:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 28 Feb 2012 14:12:40 -0800 (PST) Subject: GUI for pickle read References: Message-ID: <92d58b4f-b5b1-4d8e-a379-265d07db9847@f5g2000yqm.googlegroups.com> On Feb 28, 12:13?pm, Jerry Hill wrote: > On Tue, Feb 28, 2012 at 12:51 PM, Smiley 4321 wrote: > > Can I have some thoughts about - building a GUI to display the results of > > the pickle read? Sure. But first can you show us some code that reads a pickled file and prints the contents? Hint: Why does the pickle module have methods called "load", "loads", "dump", and "dumps"? From ramit.prasad at jpmorgan.com Tue Feb 28 17:12:45 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Tue, 28 Feb 2012 22:12:45 +0000 Subject: alternative to with statement? In-Reply-To: References: Message-ID: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> Craig Yoshioka wrote: >I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. [..] >I would have really liked: >with cachingcontext(x): > # create cached resources here ># return cached resources Is this a common pattern? I thought the point of the context manager was to remove create and close the resources (like with file opening). Seems slightly odd to use just for creation...but maybe only because I have never used it like that. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ironfroggy at gmail.com Tue Feb 28 17:17:25 2012 From: ironfroggy at gmail.com (Calvin Spealman) Date: Tue, 28 Feb 2012 17:17:25 -0500 Subject: suppressing argparse arguments in the help In-Reply-To: References: <4F4CE7BC.6080908@gmail.com> <4F4CFD7A.20904@gmail.com> Message-ID: On Tue, Feb 28, 2012 at 1:07 PM, Peter Otten <__peter__ at web.de> wrote: > Andrea Crotti wrote: > >> On 02/28/2012 04:02 PM, Peter Otten wrote: >>> Andrea Crotti wrote: >>> >>>> I have a script that might be used interactively but also has some >>>> arguments that >>>> should not be used by "normal" users. >>>> So I just want to suppress them from the help. >>>> I've read somewhere that the help=SUPPRESS should do what I want: >>>> >>>> ? ? ? parser.add_argument('-n', '--test_only', >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? action='store_true', >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? help=SUPPRESS) >>>> >>>> but that's what I get from "myapp -h", which is not exactly what I was >>>> looking for.. >>>> >>>> >>>> ? ? -f, --first_level ? ? ==SUPPRESS== (default: False) >>>> ? ? --never_redevelop ? ? ==SUPPRESS== (default: False) >>>> >>>> >>>> Any other solutions? >>> That shouldn't happen. Did you reload() somewhere? >>> argparse tests object identity not equality with SUPPRESS, so you have to >>> ensure that SUPPRESS stems from the same instance of the argparse module >>> as your ArgumentParser. >>> >> >> Ah great yes it wasn't actually the same.. >> but why not just use >> if text != SUPPRESS >> instead of: >> if text is not SUPPRESS Because identity tests are good in these situations where you need to pass a "special" value and anything else could be valid, technically. This is known as a "sentinel" and is a common pattern. > Steven Bethard would have to answer that. > If it were my code I would have used the equality test, but also the correct > symbolic constant... > >> probably the second is more safe, but they are it's still checking >> against a constant that >> is very unlikely to clash with anything.. > > > -- > http://mail.python.org/mailman/listinfo/python-list -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/ Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy From ckaynor at zindagigames.com Tue Feb 28 17:19:50 2012 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Tue, 28 Feb 2012 14:19:50 -0800 Subject: alternative to with statement? In-Reply-To: References: Message-ID: On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka wrote: > > I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. > The best I've found is to abuse the for notation: > > for _ in cachingcontext(x): > ? ?# create cached resources here > # return cached resources > > I would have really liked: > > with cachingcontext(x): > ? ?# create cached resources here > # return cached resources > > I'd also like to avoid the following because it is unnecessary boilerplate: > > with cachingcontext(x) as skip: > ? ?if not skip: > ? ? ? ? # create cached resources here > # return cached resources > An?alternative?way to do this would be to make it a decorator. Something along the lines of (written in my browser): def cachedfunc(func): cachedvalue = None def newfunc(*args, **kwargs): nonlocal cachedvalue if cachedvalue is None: cachedvalue = func(*args, **kwargs) return cachedvalue return newfunc @cachedfunc def test(): import time time.sleep(1) return 10 test() # should take 1 second test() # should be instant While that formula has limitations, it shows the basis of the idea. I'll leave it to the reader to expand it to allow calls with different arguments producing different results. > > > > -- > http://mail.python.org/mailman/listinfo/python-list From craigyk at me.com Tue Feb 28 17:22:46 2012 From: craigyk at me.com (Craig Yoshioka) Date: Tue, 28 Feb 2012 14:22:46 -0800 Subject: alternative to with statement? In-Reply-To: References: Message-ID: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> It is a bit non-normal. but I think this is a good use case as I want to create a very simple-to-use system for non-python experts to safely wrap their CLI programs in a caching architecture... that's why I lament the inability to not use the more streamlined 'with' syntax? abusing the for loop might just be confusing. The with statement is also a good fit because the caching strategy does have to atomically acquire, create and release the appropriate locks. With this statement the cached CLI wrappers can be called from simultaneously from different scripts and still coordinate their activity, by waiting for each other to finish, and reusing the cached results, etc. On Feb 28, 2012, at 1:04 PM, Craig Yoshioka wrote: > I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. > The best I've found is to abuse the for notation: > > for _ in cachingcontext(x): > # create cached resources here > # return cached resources > > I would have really liked: > > with cachingcontext(x): > # create cached resources here > # return cached resources > > I'd also like to avoid the following because it is unnecessary boilerplate: > > with cachingcontext(x) as skip: > if not skip: > # create cached resources here > # return cached resources > > > > -- > http://mail.python.org/mailman/listinfo/python-list From rantingrickjohnson at gmail.com Tue Feb 28 17:56:10 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 28 Feb 2012 14:56:10 -0800 (PST) Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Feb 24, 8:54?am, Steven D'Aprano wrote: > for...else is a very useful construct, but the name is misleading. It > took me a long time to stop thinking that the else clause executes when > the for loop was empty. Agreed. This is a major stumbling block for neophytes. > In Python 4000, I think for loops should be spelled: > > for name in iterable: > ? ? # for block > then: > ? ? # only if not exited with break > else: > ? ? # only if iterable is empty > > and likewise for while loops. I like this syntax better than the current syntax, however, it is STILL far too confusing! > for name in iterable: > ? ? # for block this part is okay > then: > ? ? # only if not exited with break I only know how the "then" clause works if you include that comment each and every time! > else: > ? ? # only if iterable is empty Again. I need more info before this code becomes intuitive. Too much guessing is required. Not to mention that the try/except/else suite treats "else" differently. try: do_this() except EXCEPTION: recover() else NO_EXCEPTION: okay_do_this_also(). for x in iterable: do_this() except EXCEPTION: recover() else NO_EXCEPTION: do_this_also() while LOOPING: do_this() except EXCEPTION: break or recover() else NO_EXCEPTION: do_this_also() In this manner "else" will behave consistently between exception handling and looping. But this whole idea of using an else clause is ridiculous anyway because all you've done is to "break up" the code visually. Not to mention; breaking the cognitive flow of a reader! try: do_this() okay_do_this_also() what_the_heck.do_this_too() except EXCEPTION: recover() finally: always_do_this() Loop syntax can drop the "else" and adopt "then/finally" -- if you think we even need a finally!?!? for x in iterable: do_this() except EXCEPTION: recover() then: okay_do_this_also() what_the_heck.do_this_too() finally: always_do_this() while LOOPING: do_this() except EXCEPTION: recover() then: okay_do_this_also() what_the_heck.do_this_too() finally: always_do_this() From tjreedy at udel.edu Tue Feb 28 17:56:45 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 28 Feb 2012 17:56:45 -0500 Subject: alternative to with statement? In-Reply-To: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> References: <5B80DD153D7D744689F57F4FB69AF474164B24@SCACMX008.exchad.jpmchase.net> Message-ID: On 2/28/2012 5:12 PM, Prasad, Ramit wrote: > Craig Yoshioka wrote: >> I see that there was previously a PEP to allow the with statement to skip the enclosing block... this was shot down, and I'm trying to think of the most elegant alternative. [..] > >> I would have really liked: >> with cachingcontext(x): >> # create cached resources here >> # return cached resources > > Is this a common pattern? I thought the point of the context manager > was to remove create and close the resources (like with file opening). Exactly. It is Python's version of RAII https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization > Seems slightly odd to use just for creation... I do not see the point either. -- Terry Jan Reedy From rosuav at gmail.com Tue Feb 28 18:24:18 2012 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 29 Feb 2012 10:24:18 +1100 Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty In-Reply-To: References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Feb 29, 2012 at 9:56 AM, Rick Johnson wrote: > On Feb 24, 8:54?am, Steven D'Aprano +comp.lang.pyt... at pearwood.info> wrote: > >> In Python 4000, I think for loops should be spelled: >> >> for name in iterable: >> ? ? # for block >> then: >> ? ? # only if not exited with break >> else: >> ? ? # only if iterable is empty >> >> and likewise for while loops. > > I like this syntax better than the current syntax, however, it is > STILL far too confusing! Absolutely, it's FAR too confusing. Every syntactic structure should have the addition of a "foo:" suite, which will run when the programmer expects it to and no other time. This would solve a LOT of problems. ChrisA From skippy.hammond at gmail.com Tue Feb 28 18:32:10 2012 From: skippy.hammond at gmail.com (Mark Hammond) Date: Wed, 29 Feb 2012 10:32:10 +1100 Subject: check if directory is writable in a portable way In-Reply-To: <4F4CA76B.5040408@gmail.com> References: <4F4CA76B.5040408@gmail.com> Message-ID: <4F4D63FA.5050200@gmail.com> On 28/02/2012 9:07 PM, Andrea Crotti wrote: > How should I check if I can create files in a directory? By trying to create them there :) Presumably you want to know that so you can write something "real" - so just write that something real. The problem gets quite hard when you consider things like elevation - your *user* may have rights to write to a directory but only when elevated - think writing into Program Files. Further, this check can only ever be transient - what if you have the rights by virtue of a group membership, but tomorrow you are no longer in that group? Or by virtue of being the "owner" of the directory but later losing the ownership? The only reasonable way to check is to write to it, and you may as well skip attempting to write a temp file - just write what you care about and handle failure in the most graceful way you can. This is what almost every app does - consider apps with a "save as" dialog - they never check the directory is writable, they just attempt the actual write and handle the failure. Mark From jobattle at gmail.com Tue Feb 28 18:35:49 2012 From: jobattle at gmail.com (jobattle) Date: 28 Feb 2012 23:35:49 GMT Subject: pyusb and microchip mcp2210 interface Message-ID: Has anybody out there had any experience in using the PYUSB library with the new Microchip MCP2210 USB to SPI chip? From breamoreboy at yahoo.co.uk Tue Feb 28 18:41:16 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 28 Feb 2012 23:41:16 +0000 Subject: Listing children processes In-Reply-To: References: Message-ID: On 28/02/2012 21:47, Arnaud Delobelle wrote: > On 28 February 2012 21:39, Mihai Badoiu wrote: >> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >>> >>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >>>> I'm trying to compute the total CPU load of an external process and it's >>>> children. (so I cannot use resource.getrusage) For the load of the >>>> process >>>> I can just grab it from /proc/X/stat. How do I get the CPU load of the >>>> children processes? Is there an easy way to get a list of the children >>>> processes? >>> >>> http://code.google.com/p/psutil/ >>> >>> Cheers, >>> Chris > >> Looked at that before. psutil doesn't do children. >> >> --mihai > > Please don't top-post! Also, psutil.Process.get_children() looks to > me like it "does" children. > You are incorrect. I've been told of by the BDFL for stating that people should not top post on any Python mailing list/news group. -- Cheers. Mark Lawrence. From d at davea.name Tue Feb 28 19:03:05 2012 From: d at davea.name (Dave Angel) Date: Tue, 28 Feb 2012 19:03:05 -0500 Subject: Listing children processes In-Reply-To: References: Message-ID: <4F4D6B39.2010106@davea.name> On 02/28/2012 06:41 PM, Mark Lawrence wrote: > On 28/02/2012 21:47, Arnaud Delobelle wrote: >> Please don't top-post! Also, psutil.Process.get_children() looks to >> me like it "does" children. >> > > You are incorrect. I've been told of by the BDFL for stating that > people should not top post on any Python mailing list/news group. > What does the BDFL have to do with the usefulness of psutil? I'm not likely to download it, but here's a ref from the docs: http://code.google.com/p/psutil/wiki/Documentation get_open_files() Return files opened by process as a list of namedtuples including file absolute path name and file descriptor. Example: >>> import psutil, os >>> f = open('file.ext', 'w') >>> p = psutil.Process(os.getpid()) >>> p.get_open_files() [openfile(path='/home/giampaolo/svn/psutil/file.ext', fd=3)] -- DaveA From ben+python at benfinney.id.au Tue Feb 28 19:16:24 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 11:16:24 +1100 Subject: Listing children processes References: Message-ID: <87ehtepk87.fsf@benfinney.id.au> Mark Lawrence writes: > On 28/02/2012 21:47, Arnaud Delobelle wrote: > > Please don't top-post! Also, psutil.Process.get_children() looks to > > me like it "does" children. > > You are incorrect. Incorrect? The only factual statement Arnaud made was about ?psutil?. > I've been told of by the BDFL for stating that people should not top > post on any Python mailing list/news group. Fortunately, the BDFL is not a position of authority outside the Python language. We as a community have the long-standing consensus that top-posting is to be avoided. -- \ ?Don't be misled by the enormous flow of money into bad defacto | `\ standards for unsophisticated buyers using poor adaptations of | _o__) incomplete ideas.? ?Alan Kay | Ben Finney From steve+comp.lang.python at pearwood.info Tue Feb 28 19:16:27 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Feb 2012 00:16:27 GMT Subject: Listing children processes References: Message-ID: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > I've been told of by the BDFL for stating that > people should not top post on any Python mailing list/news group. He's the BDFL of Python, not of mailing list etiquette. -- Steven From steve+comp.lang.python at pearwood.info Tue Feb 28 19:18:54 2012 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 29 Feb 2012 00:18:54 GMT Subject: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty References: <14ba4b39-4066-4d24-89d7-3c7c85aab85c@b18g2000vbz.googlegroups.com> <51a08251-1e6e-45f3-8531-b53e87b7db8b@r1g2000yqk.googlegroups.com> <4f47a49e$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <4f4d6eee$0$29989$c3e8da3$5496439d@news.astraweb.com> On Wed, 29 Feb 2012 10:24:18 +1100, Chris Angelico wrote: > Every syntactic structure should > have the addition of a "foo:" suite, which will run when the programmer > expects it to and no other time. This would solve a LOT of problems. Indeed, when I design my killer language, the identifiers "foo" and "bar" will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice. -- Tim Peters, 29 Apr 1998 -- Steven From ramit.prasad at jpmorgan.com Tue Feb 28 19:30:16 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 00:30:16 +0000 Subject: alternative to with statement? In-Reply-To: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> References: <2DC45476-62BA-4A49-8120-49D95DB02BFD@me.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474164DCD@SCACMX008.exchad.jpmchase.net> Craig Yoshioka wrote: >It is a bit non-normal. but I think this is a good use case as I want to create a very simple-to-use system for non-python experts to safely wrap their CLI programs in a caching architecture... that's why I lament the inability to not use the more streamlined 'with' syntax- abusing the for loop might just be confusing. The with statement is also a good fit because the caching strategy does have to atomically acquire, create and release the appropriate locks. With this statement the cached CLI wrappers can be called from simultaneously from different scripts and still coordinate their activity, by waiting for each other to finish, and reusing the cached results, etc. > with cachingcontext(x): > # create cached resources here > # return cached resources On a separate note, how would you even return the cached resources without using the following ? with cachingcontext(x) as blah: The only thing cachingcontext seems to do is catch errors and since cachingcontext would be used by the "non-python experts", I have trouble understanding how this would help them any more than: try: # create cached resources here except SomeError: # handle error If you return the cached resources outside the caching context than how could you possibly release it via the context manager? It seems like you want some kind of resource pooling but if that is the case then just write your own pool. See http://stackoverflow.com/questions/1514120/python-implementation-of-the-object-pool-design-pattern . Sorry if that does not help, but I do not comprehend what you are trying to do. It seems inherently conflicted to say you want to use "with" because it lets you atomically open, use, then close resources but you do NOT want to atomically open, use, then close resources... Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From breamoreboy at yahoo.co.uk Tue Feb 28 20:37:31 2012 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 29 Feb 2012 01:37:31 +0000 Subject: Listing children processes In-Reply-To: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 29/02/2012 00:16, Steven D'Aprano wrote: > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > >> I've been told of by the BDFL for stating that >> people should not top post on any Python mailing list/news group. > > He's the BDFL of Python, not of mailing list etiquette. > > Incorrect, I was told off for this http://code.activestate.com/lists/python-ideas/14065/ Please don't bother apologising as I don't want to read another of your versions of War and Peace. -- Cheers. Mark Lawrence. From example.scripts at gmail.com Tue Feb 28 22:59:40 2012 From: example.scripts at gmail.com (scripts examples) Date: Tue, 28 Feb 2012 19:59:40 -0800 (PST) Subject: python scripts solution for euler projects Message-ID: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Got a web site setup for solving euler problems in python, perl, ruby and javascript. Feel free to give me any feedback, thanks. From rodrick.brown at gmail.com Tue Feb 28 23:16:08 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Tue, 28 Feb 2012 23:16:08 -0500 Subject: python scripts solution for euler projects In-Reply-To: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: On Tue, Feb 28, 2012 at 10:59 PM, scripts examples < example.scripts at gmail.com> wrote: > > Got a web site setup for solving euler problems in python, perl, > ruby and javascript. > > Feel free to give me any feedback, thanks. > ???? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jasonveldicott at gmail.com Tue Feb 28 23:38:33 2012 From: jasonveldicott at gmail.com (Jason Veldicott) Date: Wed, 29 Feb 2012 15:38:33 +1100 Subject: Error importing __init__ declared variable from another package In-Reply-To: References: Message-ID: > > > Hi, > > > > I have a simple configuration of modules as beneath, but an import error > > is reported: > > > > /engine > > (__init__ is empty here) > > engine.py > > /sim > > __init__.py > > > > > > The module engine.py imports a variable instantiated in sim.__init__ as > > follows: > > > > from sim import var_name > > var_name.func() > > > > The following error messaged is received on the func() call above > (Eclipse > > PyDev): > > > > "undefined variable from import: func" > Are you rephrasing or is this really the error message? If so run your > program again on the command-line. Then please cut and paste the error > message together with the traceback. > > Any idea why this is causing an error? > What version of Python are you using? > What does sim/__init__.py contain? Thanks Peter. I'm using Python 2.6, but it works at the command line. The error only appears in Eclipse as a red cross in the margin. The exact error msg, as appears in a floating text caption on mouse over, is as I mentioned (capitalised). Perhaps it is some issue in PyDev, maybe related to the version of Python I'm using. I'm in the process of trying to solve another related import problem, and wished to resolve this one in the hope that it might shed light on the other. But as it works beside the error icon appearing, I might just ignore it and spare the trouble of precise identification of cause. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnjsal at gmail.com Wed Feb 29 00:06:41 2012 From: johnjsal at gmail.com (John Salerno) Date: Tue, 28 Feb 2012 21:06:41 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? Message-ID: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> The book I'm reading about using Tkinter only does this when creating the top-level window: app = Application() app.mainloop() and of course the Application class has subclassed the tkinter.Frame class. However, in the Python documentation, I see this: root = Tk() app = Application(master=root) app.mainloop() root.destroy() Is it necessary to explicitly call Tk(), then pass that result as an argument for the Application call? Is it also necessary to call destroy() on the root frame? I tried the above and I got the following error: Traceback (most recent call last): File "C:\Users\John\Desktop\gui.py", line 12, in root.destroy() File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy self.tk.call('destroy', self._w) _tkinter.TclError: can't invoke "destroy" command: application has been destroyed So apparently closing the window with the X button (on Windows) implicitly calls the destroy() method of the root frame. If that's the case, why does the documentation explicitly call it? Furthermore, I pasted the exact example from the documentation into IDLE and ran it, and I also go the same error, so the example in the documentation doesn't even work. So is it sufficient simply to create an Application instance, use mainloop, and then handle the closing of the window elsewhere in the program (such as a widget calling the destroy method on-click, or just letting the X button do it)? Thanks! From ben+python at benfinney.id.au Wed Feb 29 00:12:41 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 16:12:41 +1100 Subject: Listing children processes References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8762eqp6ie.fsf@benfinney.id.au> Mark Lawrence writes: > On 29/02/2012 00:16, Steven D'Aprano wrote: > > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > >> I've been told of by the BDFL for stating that people should not > >> top post on any Python mailing list/news group. > > > > He's the BDFL of Python, not of mailing list etiquette. > > Incorrect What Steven says is correct: the BDFL of Python has no special authority over mailing list etiquette. > I was told off for this No-one's saying you weren't told off. We're saying that there's no point invoking the BDFL when it comes to mailing list etiquette, as he has no special authority on that. > Please don't bother apologising I doubt anyone feels compelled to apologise to you for this. -- \ ?In the long run nothing can withstand reason and experience, | `\ and the contradiction which religion offers to both is all too | _o__) palpable.? ?Sigmund Freud | Ben Finney From brendon.joyce at gmail.com Wed Feb 29 01:56:22 2012 From: brendon.joyce at gmail.com (Brendon Joyce) Date: Wed, 29 Feb 2012 16:56:22 +1000 Subject: No subject Message-ID: -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Wed Feb 29 02:29:53 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Wed, 29 Feb 2012 12:59:53 +0530 Subject: Pickle handling dictionary Message-ID: I was successful in testing pickle with multiple objects both READ & WRITE. I did WRITE as - --- #!/usr/bin/python import pickle class apple_Class(object): def __init__(self, **kwds): self.__dict__.update(kwds) myInst = apple_Class() myInst.FirstString = "Apple" myInst.SecondString = "Orange" with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump((myInst.FirstString, myInst.SecondString), f) ---- I did READ as - --- #!/usr/bin/python import pickle class apple_Class(object): def __init__(self, **kwds): self.__dict__.update(kwds) myInst = apple_Class() with open('/tmp/readfile.pkl', 'rb') as f: myInst.FirstString, myInst.SecondString = pickle.load(f) print myInst.FirstString print myInst.SecondString --- Both worked successfully. Now, I have to write a file having below three things - - Having dictionary of many instances - string as a Key - Instances as Value. Finally, I have to do the same thing as above to WRITE in separate file and READ in separate file. So, the issues is simply how to handle many instances in a dictionary with Key and Value. -------------- next part -------------- An HTML attachment was scrubbed... URL: From xahlee at gmail.com Wed Feb 29 03:09:16 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 00:09:16 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! Message-ID: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> New Science Discovery: Perl Idiots Remain Idiots After A Decade! A excerpt from the new book ?Modern Perl?, just published, chapter 4 on ?Operators?. Quote: ?The associativity of an operator governs whether it evaluates from left to right or right to left. Addition is left associative, such that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 ** 4 first, then raises 2 to the 81st power. ? LOL. Looks like the perl folks haven't changed. Fundamentals of serious math got botched so badly. Let me explain the idiocy. It says ?The associativity of an operator governs whether it evaluates from left to right or right to left.?. Ok, so let's say we have 2 operators: a white triangle ? and a black triangle ?. Now, by the perl's teaching above, let's suppose the white triangle is ?right associative? and the black triangle is ?left associative?. Now, look at this: 3 ? 6 ? 5 seems like the white and black triangles are going to draw a pistol and fight for the chick 6 there. LOL. Now, let me tell you what operator precedence is. First of all, let's limit ourselfs to discuss operators that are so-called binary operators, which, in our context, basically means single symbol operator that takes it's left and right side as operands. Now, each symbol have a ?precedence?, or in other words, the set of operators has a order. (one easy way to think of this is that, suppose you have n symbols, then you give each a number, from 1 to n, as their order) So, when 2 symbols are placed side by side such as ?3 ? 6 ? 5?, the symbol with higher precedence wins. Another easy way to think of this is that each operator has a stickiness level. The higher its level, it more sticky it is. the problem with the perl explanations is that it's one misleading confusion ball. It isn't about ?left/right associativity?. It isn't about ?evaluates from left to right or right to left?. Worse, the word ?associativity? is a math term that describe a property of algebra that has nothing to do with operator precedence, yet is easily confused with because it is a property about order of evaluation. (for example, the addition function is associative, meaning: ?(3+6)+5 = 3+(6+5)?.) compare it with this: ?Perl ? Python: Complex Numbers? http://xahlee.org/perl-python/complex_numbers.html and for a good understanding of functions and operators, see: ?What's Function, What's Operator?? http://xahlee.org/math/function_and_operators.html From guillaumechorn at gmail.com Wed Feb 29 03:25:52 2012 From: guillaumechorn at gmail.com (Guillaume Chorn) Date: Wed, 29 Feb 2012 16:25:52 +0800 Subject: Problem using s.strip() to remove leading whitespace in .csv file Message-ID: Hello All, I have a .csv file that I created by copying and pasting a list of all the players in the NBA with their respective teams and positions ( http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!). Unfortunately, when I do this I have no choice but to include a single leading whitespace character for each name. I'd like to compare this list of names to another list (also in .csv format but in a different file) using a simple Python script, but in order to do that I need to strip the leading whitespace from all of the names or none of them will match the names in the second list. However, when I try to do this as follows: positions = open('/home/guillaume/Documents/playerpos.csv') for line in positions: info = line.split(',') name = info[0] name = name.strip() print name #to examine the effect of name.strip() I keep getting all of the names with the leading whitespace character NOT removed (for example: " Jeff Adrien". Why is this happening? The following is a sample of the .csv file (the one I'm trying to remove the whitespace from) opened in gedit, the built-in Ubuntu text editor: Jeff Adrien,SF,Houston Rockets Arron Afflalo,SG,Denver Nuggets Maurice Ager,GF,Minnesota Timberwolves Blake Ahearn,PG,Los Angeles Clippers Alexis Ajinca,FC,Toronto Raptors Solomon Alabi,C,Toronto Raptors Cole Aldrich,C,Oklahoma City Thunder LaMarcus Aldridge,FC,Portland Trail Blazers Joe Alexander,SF,New Orleans Hornets Lavoy Allen,FC,Philadelphia 76ers Malik Allen,FC,Orlando Magic Ray Allen,SG,Boston Celtics Tony Allen,GF,Memphis Grizzlies Lance Allred,C,Indiana Pacers Rafer Alston,PG,Miami Heat Any help with this seemingly simple but maddening issue would be much appreciated. thanks, Guillaume -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Wed Feb 29 03:53:38 2012 From: __peter__ at web.de (Peter Otten) Date: Wed, 29 Feb 2012 09:53:38 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file References: Message-ID: Guillaume Chorn wrote: > Hello All, > > I have a .csv file that I created by copying and pasting a list of all the > players in the NBA with their respective teams and positions ( > http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO!). > Unfortunately, when I do this I have no choice but to include a single > leading whitespace character for each name. I'd like to compare this list > of names to another list (also in .csv format but in a different file) > using a simple Python script, but in order to do that I need to strip the > leading whitespace from all of the names or none of them will match the > names in the second list. However, when I try to do this as follows: > > positions = open('/home/guillaume/Documents/playerpos.csv') > > for line in positions: > info = line.split(',') > name = info[0] > name = name.strip() > print name #to examine the effect of name.strip() > > I keep getting all of the names with the leading whitespace character NOT > removed (for example: " Jeff Adrien". Why is this happening? Do you mean print name.strip() still prints a leading space? If so, what does print repr(name) print? If it is "\xc2\xa0Jeff Adrien" try print name.decode("utf-8").strip() Or do you mean the effect of strip() is not permanent? You have to modify the line then: cleaned_lines = [] for line in positions: info = line.split(",") info[0] = info[0].strip() cleaned_lines.append(",".join(info)) positions = cleaned_lines > The following is a sample of the .csv file (the one I'm trying to remove > the whitespace from) opened in gedit, the built-in Ubuntu text editor: > > Jeff Adrien,SF,Houston Rockets > Arron Afflalo,SG,Denver Nuggets > Maurice Ager,GF,Minnesota Timberwolves > Blake Ahearn,PG,Los Angeles Clippers > Alexis Ajinca,FC,Toronto Raptors > Solomon Alabi,C,Toronto Raptors > Cole Aldrich,C,Oklahoma City Thunder > LaMarcus Aldridge,FC,Portland Trail Blazers > Joe Alexander,SF,New Orleans Hornets > Lavoy Allen,FC,Philadelphia 76ers > Malik Allen,FC,Orlando Magic > Ray Allen,SG,Boston Celtics > Tony Allen,GF,Memphis Grizzlies > Lance Allred,C,Indiana Pacers > Rafer Alston,PG,Miami Heat > > Any help with this seemingly simple but maddening issue would be much > appreciated. > > thanks, > Guillaume From kliateni at gmail.com Wed Feb 29 04:01:21 2012 From: kliateni at gmail.com (Karim) Date: Wed, 29 Feb 2012 10:01:21 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: References: Message-ID: <4F4DE961.2060302@gmail.com> Le 29/02/2012 09:25, Guillaume Chorn a ?crit : > Hello All, > > I have a .csv file that I created by copying and pasting a list of all > the players in the NBA with their respective teams and positions > (http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO! > ). > Unfortunately, when I do this I have no choice but to include a single > leading whitespace character for each name. I'd like to compare this > list of names to another list (also in .csv format but in a different > file) using a simple Python script, but in order to do that I need to > strip the leading whitespace from all of the names or none of them > will match the names in the second list. However, when I try to do > this as follows: > > positions = open('/home/guillaume/Documents/playerpos.csv') > > for line in positions: > info = line.split(',') > name = info[0] > name = name.strip() > print name #to examine the effect of name.strip() > > I keep getting all of the names with the leading whitespace character > NOT removed (for example: " Jeff Adrien". Why is this happening? > > The following is a sample of the .csv file (the one I'm trying to > remove the whitespace from) opened in gedit, the built-in Ubuntu text > editor: > > Jeff Adrien,SF,Houston Rockets > Arron Afflalo,SG,Denver Nuggets > Maurice Ager,GF,Minnesota Timberwolves > Blake Ahearn,PG,Los Angeles Clippers > Alexis Ajinca,FC,Toronto Raptors > Solomon Alabi,C,Toronto Raptors > Cole Aldrich,C,Oklahoma City Thunder > LaMarcus Aldridge,FC,Portland Trail Blazers > Joe Alexander,SF,New Orleans Hornets > Lavoy Allen,FC,Philadelphia 76ers > Malik Allen,FC,Orlando Magic > Ray Allen,SG,Boston Celtics > Tony Allen,GF,Memphis Grizzlies > Lance Allred,C,Indiana Pacers > Rafer Alston,PG,Miami Heat > > Any help with this seemingly simple but maddening issue would be much > appreciated. > > thanks, > Guillaume > > > > > Use csv module instead of parsing yourself the csv file: import csv reader = csv.Reader(open("file.csv")) for row in reader: for key in row: print("key=", key, " value=", row[key]) Code above not tested but should work. Cheers Karim -------------- next part -------------- An HTML attachment was scrubbed... URL: From kliateni at gmail.com Wed Feb 29 04:04:59 2012 From: kliateni at gmail.com (Karim) Date: Wed, 29 Feb 2012 10:04:59 +0100 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: <4F4DE961.2060302@gmail.com> References: <4F4DE961.2060302@gmail.com> Message-ID: <4F4DEA3B.8040808@gmail.com> Le 29/02/2012 10:01, Karim a ?crit : > Le 29/02/2012 09:25, Guillaume Chorn a ?crit : >> Hello All, >> >> I have a .csv file that I created by copying and pasting a list of >> all the players in the NBA with their respective teams and positions >> (http://sports.yahoo.com/nba/players?type=lastname&first=1&query=&go=GO! >> ). >> Unfortunately, when I do this I have no choice but to include a >> single leading whitespace character for each name. I'd like to >> compare this list of names to another list (also in .csv format but >> in a different file) using a simple Python script, but in order to do >> that I need to strip the leading whitespace from all of the names or >> none of them will match the names in the second list. However, when >> I try to do this as follows: >> >> positions = open('/home/guillaume/Documents/playerpos.csv') >> >> for line in positions: >> info = line.split(',') >> name = info[0] >> name = name.strip() >> print name #to examine the effect of name.strip() >> >> I keep getting all of the names with the leading whitespace character >> NOT removed (for example: " Jeff Adrien". Why is this happening? >> >> The following is a sample of the .csv file (the one I'm trying to >> remove the whitespace from) opened in gedit, the built-in Ubuntu text >> editor: >> >> Jeff Adrien,SF,Houston Rockets >> Arron Afflalo,SG,Denver Nuggets >> Maurice Ager,GF,Minnesota Timberwolves >> Blake Ahearn,PG,Los Angeles Clippers >> Alexis Ajinca,FC,Toronto Raptors >> Solomon Alabi,C,Toronto Raptors >> Cole Aldrich,C,Oklahoma City Thunder >> LaMarcus Aldridge,FC,Portland Trail Blazers >> Joe Alexander,SF,New Orleans Hornets >> Lavoy Allen,FC,Philadelphia 76ers >> Malik Allen,FC,Orlando Magic >> Ray Allen,SG,Boston Celtics >> Tony Allen,GF,Memphis Grizzlies >> Lance Allred,C,Indiana Pacers >> Rafer Alston,PG,Miami Heat >> >> Any help with this seemingly simple but maddening issue would be much >> appreciated. >> >> thanks, >> Guillaume >> >> >> >> >> > Use csv module instead of parsing yourself the csv file: > > import csv > > reader = csv.Reader(open("file.csv")) > > for row in reader: > for key in row: > print("key=", key, " value=", row[key]) > > > Code above not tested but should work. > > Cheers > Karim > Just a correction use a dictionary like csv reader: *reader = csv.DictReader(open("file.csv"))* Cheers Karim -------------- next part -------------- An HTML attachment was scrubbed... URL: From guillaumechorn at gmail.com Wed Feb 29 04:05:34 2012 From: guillaumechorn at gmail.com (Guillaume Chorn) Date: Wed, 29 Feb 2012 17:05:34 +0800 Subject: Problem using s.strip() to remove leading whitespace in .csv file Message-ID: Thanks, the suggestion print name.decode("utf-8").strip() worked like a charm. When I did the print repr(name) I got exactly what you predicted. I'm not yet sure what all of this means, but I'm going to read this in the hopes of finding out. Anyway thanks again for the help! cheers, Guillaume -------------- next part -------------- An HTML attachment was scrubbed... URL: From ssmile03 at gmail.com Wed Feb 29 04:07:55 2012 From: ssmile03 at gmail.com (Smiley 4321) Date: Wed, 29 Feb 2012 14:37:55 +0530 Subject: Why this fails?? Message-ID: Why below fails - ---- #!/usr/bin/python import pickle class MyClass(object): Field1 = None Field2 = None def __init__(self, dictionary): self.__dict__.update(dictionary) my_List = {'Field1': 'Apple', 'Field2': 'Orange'} myInst = MyClass(my_List) with open('/tmp/readfile.pkl', 'wb') as f: pickle.dump(myInst, f) ---- with below error messges - $ ./pickleClassWrite.py Traceback (most recent call last): File "./pickleClassWrite.py", line 5, in class MyClass(object): File "./pickleClassWrite.py", line 14, in MyClass myInst = MyClass(my_List) NameError: name 'MyClass' is not defined --- -------------- next part -------------- An HTML attachment was scrubbed... URL: From jabba.laci at gmail.com Wed Feb 29 05:01:16 2012 From: jabba.laci at gmail.com (Jabba Laci) Date: Wed, 29 Feb 2012 11:01:16 +0100 Subject: use CTRL+L for clearing the screen Message-ID: Hi, I'm working on an interactive script. With raw_input user input is read and the script produces some output and offers the prompt again. I would like to add a clear screen feature, which would be activated with CTRL+L. How to do that? Another thing: raw_input waits until but I'd like to clear the screen at the moment when CTRL+L is pressed. The script should be self-contained, thus I'd like to solve it by using the standard library only. Thanks, Laszlo From d at davea.name Wed Feb 29 05:30:10 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 05:30:10 -0500 Subject: Problem using s.strip() to remove leading whitespace in .csv file In-Reply-To: References: Message-ID: <4F4DFE32.1080703@davea.name> On 02/29/2012 04:05 AM, Guillaume Chorn wrote: > Thanks, the suggestion > > print name.decode("utf-8").strip() > > worked like a charm. When I did the print repr(name) I got exactly what > you predicted. I'm not yet sure what all of this means, but I'm going to > read this in the hopes of > finding out. Anyway thanks again for the help! > > > cheers, > Guillaume > What it means is that the character before the name was not a space character, but some Unicode variant of space. Peter figured that out, not I. It also means that you were using the incorrect decoder for the way the file was encoded and written out. Are you creating that csv file with some Windows app, or with Python? You should look at it with a hex viewer to see if there are other surprises waiting for you in there. For example, you might also need the same kind of solution if there are quotes (or an apostrophe) anywhere in the file. Or if someone's address uses an umlaut. Generally, it's better to clean up cruft at the source, when possible. And if that means the file has to be stored in utf-8, you should decode the whole file that way, and then deal with it as unicode. -- DaveA From d at davea.name Wed Feb 29 05:34:04 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 05:34:04 -0500 Subject: Why this fails?? In-Reply-To: References: Message-ID: <4F4DFF1C.7040109@davea.name> On 02/29/2012 04:07 AM, Smiley 4321 wrote: > Why below fails - > > ---- > #!/usr/bin/python > > import pickle > > class MyClass(object): > > Field1 = None > Field2 = None > > def __init__(self, dictionary): > self.__dict__.update(dictionary) > > my_List = {'Field1': 'Apple', 'Field2': 'Orange'} > myInst = MyClass(my_List) > > with open('/tmp/readfile.pkl', 'wb') as f: > pickle.dump(myInst, f) > ---- > > with below error messges - > > $ ./pickleClassWrite.py > Traceback (most recent call last): > File "./pickleClassWrite.py", line 5, in > class MyClass(object): > File "./pickleClassWrite.py", line 14, in MyClass > myInst = MyClass(my_List) > NameError: name 'MyClass' is not defined > --- > The reason for the error is that you're trying to use the class (by name) before its definition is complete. The cause is that the code starting with the line "my_list = {Field1... " should have been dedented to be at top-level. You don't want those last 4 lines to be inside the class. -- DaveA From ben+python at benfinney.id.au Wed Feb 29 06:39:22 2012 From: ben+python at benfinney.id.au (Ben Finney) Date: Wed, 29 Feb 2012 22:39:22 +1100 Subject: use CTRL+L for clearing the screen References: Message-ID: <87y5rloolx.fsf@benfinney.id.au> Jabba Laci writes: > I would like to add a clear screen feature, which would be activated > with CTRL+L. How to do that? > Another thing: raw_input waits until but I'd like to clear the > screen at the moment when CTRL+L is pressed. That sounds like a job for the standard library ?readline? module , an interface to the widely-used C library of the same name on free operating systems. -- \ ?We demand rigidly defined areas of doubt and uncertainty!? | `\ ?Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas | _o__) Adams | Ben Finney From Shambhu.Rajak at kpitcummins.com Wed Feb 29 06:43:21 2012 From: Shambhu.Rajak at kpitcummins.com (Shambhu Rajak) Date: Wed, 29 Feb 2012 11:43:21 +0000 Subject: Python-list Digest, Vol 101, Issue 164 In-Reply-To: References: Message-ID: <408F64D89899604FB24015E64E10490C20E0F01E@KCHJEXMB01.kpit.com> Hi, I want building GNU debugger for mingw. Need the GDB to support python How should I go about it? Thanks, Shambhu This message contains information that may be privileged or confidential and is the property of the KPIT Cummins Infosystems Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Cummins Infosystems Ltd. does not accept any liability for virus infected mails. From chiron613 at gmail.com Wed Feb 29 06:43:22 2012 From: chiron613 at gmail.com (Chiron) Date: Wed, 29 Feb 2012 11:43:22 GMT Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: On Wed, 29 Feb 2012 00:09:16 -0800, Xah Lee wrote: Personally, I think this whole issue of precedence in a programming language is over-rated. It seems to me that grouping of any non-trivial set of calculations should be done so as to remove any possible confusion as to intent. It is one more obstacle to accidental errors in logic, where you intend one thing, possibly overlook precedence, and get a strange result. Sure, mathematically it *should* go a particular way, and any programming language *should* follow that. Still... they don't, and since they don't it makes more sense to be really obvious what you meant to do. As someone pointed out, a programming language is for humans; computers don't need them. That being the case, it makes sense to keep things as clear as possible. -- It's OKAY -- I'm an INTELLECTUAL, too. From crowdfinchtechinfo at gmail.com Wed Feb 29 06:46:21 2012 From: crowdfinchtechinfo at gmail.com (CrowdFinch) Date: Wed, 29 Feb 2012 03:46:21 -0800 (PST) Subject: CrowdFinch Technologies Message-ID: <680242e7-9947-4b3c-be2c-1fa62b131da5@p21g2000yqm.googlegroups.com> CrowdFinch Technologies is a leading professional custom web design and web development company specialized in Outsourced Web Development Services, Mobile Application Development, Web design, SEO Services. From kiuhnm03.4t.yahoo.it Wed Feb 29 07:08:53 2012 From: kiuhnm03.4t.yahoo.it (Kiuhnm) Date: Wed, 29 Feb 2012 13:08:53 +0100 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <4f4e1554$0$1385$4fafbaef@reader2.news.tin.it> On 2/29/2012 9:09, Xah Lee wrote: > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. Sorry, but you're wrong and they're right. Associativity governs the order of evaluation of a group of operators *OF THE SAME PRECEDENCE*. If you write 2**3**4 only the fact the '**' is right associative will tell you that the order is 2**(3**4) and not (2**3)**4 I remind you that 2^(3^4) != (2^3)^4. Kiuhnm From jeanpierreda at gmail.com Wed Feb 29 07:12:01 2012 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 29 Feb 2012 07:12:01 -0500 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: On Wed, Feb 29, 2012 at 6:43 AM, Chiron wrote: > Personally, I think this whole issue of precedence in a programming > language is over-rated. ?It seems to me that grouping of any non-trivial > set of calculations should be done so as to remove any possible confusion > as to intent. Some languages do this. e.g. all lisps. -- Devin From alister.ware at ntlworld.com Wed Feb 29 07:21:59 2012 From: alister.ware at ntlworld.com (alister) Date: Wed, 29 Feb 2012 12:21:59 GMT Subject: python scripts solution for euler projects References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: On Tue, 28 Feb 2012 19:59:40 -0800, scripts examples wrote: > Got a web site setup for solving euler problems in python, perl, > ruby and javascript. > > Feel free to give me any feedback, thanks. Failing to give a link to the site is a pretty fundamental failure -- Please take note: From ulrich.eckhardt at dominolaser.com Wed Feb 29 08:02:36 2012 From: ulrich.eckhardt at dominolaser.com (Ulrich Eckhardt) Date: Wed, 29 Feb 2012 14:02:36 +0100 Subject: building GNU debugger (was: Re: Python-list Digest, Vol 101, Issue 164) In-Reply-To: References: Message-ID: Three things up front: 1. Do not reply to digests. If you want to only read, you can use the digests, but they are not usable for replying, because it is completely unclear where in a discussion you are entering and what you are relating your answers to. 2. Do not start new threads by using the reply button. Your reply contains the message ID of the message you're replying to even if you delete any trace from the body. Better email on news clients will display your message associated with the one you replied to, although there is no relation at all. This is also called stealing threads. 3. Pick a meaningful subject. My attitude is generally that if you don't have time to pick a subject line, I don't have time to help you. Generally, getting help is easier if you did your job. Make sure you read and understand Eric S. Raymond's essay on asking questions the smart way. Am 29.02.2012 12:43, schrieb Shambhu Rajak: > I want building GNU debugger for mingw. Doesn't mingw come with GDB or at least have a GDB package? However, this has nothing to do with Python. > Need the GDB to support python How should I go about it? You don't need GDB in order to "support python", which has its own debugger. What is it that you're trying to achieve? See also mentioned essay on how to ask good questions. > This message contains information that may be privileged [...] If you can, please remove this. Good luck! Uli From wxjmfauth at gmail.com Wed Feb 29 08:45:35 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 29 Feb 2012 05:45:35 -0800 (PST) Subject: On u'Unicode string literals' (Py3) Message-ID: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> For those who do not know: The u'' string literal trick has never worked in Python 2. >>> sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' >>> print u'Un oeuf ? z?ro EURO uro' Un uf ? z?ro uro >>> jmf From johann.spies at gmail.com Wed Feb 29 08:52:50 2012 From: johann.spies at gmail.com (Johann Spies) Date: Wed, 29 Feb 2012 15:52:50 +0200 Subject: list comprehension question Message-ID: I understand the following: In [79]: instansie instansie Out[79]: 'Mangosuthu Technikon' In [80]: t = [x.alt_name for x in lys] t = [x.alt_name for x in lys] In [81]: t t Out[81]: [] In [82]: t.append(instansie) t.append(instansie) In [83]: t t Out[83]: ['Mangosuthu Technikon'] But then why does the following behave like this: In [84]: t = [x.alt_name for x in lys].append(instansie) t = [x.alt_name for x in lys].append(instansie) In [85]: t t In [86]: type t type t -------> type(t) Out[86]: NoneType Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidgshi at yahoo.co.uk Wed Feb 29 08:56:40 2012 From: davidgshi at yahoo.co.uk (David Shi) Date: Wed, 29 Feb 2012 13:56:40 +0000 (GMT) Subject: Looking for a simple, generic Python module to provide a secure web service In-Reply-To: References: Message-ID: <1330523800.53282.YahooMailNeo@web171616.mail.ir2.yahoo.com> We are looking for a very simple, generic Python module to provide a secure web service.?? Ideally, it can be put onto the computer and make it available via IIS. ? Off we go. ? Your help will be gratefully received. ? Regards. ? David -------------- next part -------------- An HTML attachment was scrubbed... URL: From rantingrickjohnson at gmail.com Wed Feb 29 09:24:40 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 06:24:40 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> Message-ID: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> On Feb 28, 11:06?pm, John Salerno wrote: > The book I'm reading about using Tkinter only does this when creating the top-level window: > > app = Application() > app.mainloop() > > and of course the Application class has subclassed the tkinter.Frame class. > > However, in the Python documentation, I see this: > > root = Tk() > app = Application(master=root) > app.mainloop() > root.destroy() > > Is it necessary to explicitly call Tk(), then pass that result as an argument for the Application call? Is it also necessary to call destroy() on the root frame? It is not necessarily to call Tk explicitly, which i think is a bug BTW. Sure, for simple scripts you can save one line of code but only at the expense of explicitness and intuitiveness. Observe ## START CODE ## import Tkinter as tk root = tk.Tk() root.title('Explicit Root') root.mainloop() f = tk.Frame(master=None, width=100, height=100, bg='red') f.pack() f.mainloop() b = tk.Button(master=None, text='Sloppy Coder') b.pack() b.mainloop() ## END CODE ## as you can see all three examples work even though the last two don't explicitly create a master. The master is still there however Tkinter just created "magically" for you. Talk about laziness! > I tried the above and I got the following error: > > Traceback (most recent call last): > ? File "C:\Users\John\Desktop\gui.py", line 12, in > ? ? root.destroy() > ? File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy > ? ? self.tk.call('destroy', self._w) > _tkinter.TclError: can't invoke "destroy" command: ?application has been destroyed > > So apparently closing the window with the X button (on Windows) implicitly calls the destroy() method of the root frame. If that's the case, why does the documentation explicitly call it? Because the documentation is FLAWED! Please provide links to this "documentation" so we can post it on the Wall Of Shame. > Furthermore, I pasted the exact example from the documentation into IDLE and ran it, and I also go the same error, so the example in the documentation doesn't even work. IDLE uses the same Python as the command line so naturally it will throw the same error. ;-) > So is it sufficient simply to create an Application instance, use mainloop, and then handle the closing of the window elsewhere in the program (such as a widget calling the destroy method on-click, or just letting the X button do it)? Most applications will have both: user destroying, and program destroying. Again, your example is FLAWED. Here is a simplified example: ## START CODE ## from tkMessageBox import askyesnocancel class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title('Close Me -->') self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) def onDestroyWindow(self): title = 'Confirm App Exit' msg = 'Save changes before exiting?' result = askyesnocancel(title, msg, default='cancel') if result is None: return elif result is True: print 'saving changes' elif result is False: print 'dont save changes' self.destroy() if __name__ == '__main__': app = App() app.mainloop() ## END CODE ## From rrakus at redhat.com Wed Feb 29 09:33:50 2012 From: rrakus at redhat.com (Roman Rakus) Date: Wed, 29 Feb 2012 15:33:50 +0100 Subject: Fwd: Question about PyXML and python's stdlib xml In-Reply-To: <4F4BA664.90707@redhat.com> References: <4F4BA664.90707@redhat.com> Message-ID: <4F4E374E.10201@redhat.com> I'm forwarding this message to python-list, since I didn't get answer on xml-sig ML. Hopefully this is right list to question. Please keep me in CC. Original message is below. RR -------- Original Message -------- Subject: Question about PyXML and python's stdlib xml Date: Mon, 27 Feb 2012 16:51:00 +0100 From: Roman Rakus To: xml-sig at python.org Hi, I have concerns about PyXML and stdlib xml included directly in python. Currently (in Fedora) python is trying to import PyXML, which means other results when you have and haven't PyXML installed. Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', 'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides more functionality in those modules? Is python's xml better, same or worse then PyXML? Anyway, python's xml is newer - is PyXML deprecated? Please keep me in CC, I'm not subscribed to the list. RR -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.rodola at gmail.com Wed Feb 29 09:41:19 2012 From: g.rodola at gmail.com (=?ISO-8859-1?Q?Giampaolo_Rodol=E0?=) Date: Wed, 29 Feb 2012 15:41:19 +0100 Subject: Listing children processes In-Reply-To: References: Message-ID: Il 28 febbraio 2012 22:47, Arnaud Delobelle ha scritto: > On 28 February 2012 21:39, Mihai Badoiu wrote: >> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote: >>> >>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote: >>> > I'm trying to compute the total CPU load of an external process and it's >>> > children.? (so I cannot use resource.getrusage)? For the load of the >>> > process >>> > I can just grab it from /proc/X/stat.? How do I get the CPU load of the >>> > children processes?? Is there an easy way to get a list of the children >>> > processes? >>> >>> http://code.google.com/p/psutil/ >>> >>> Cheers, >>> Chris > >> Looked at that before.? psutil doesn't do children. Yes, it does: >>> import psutil, os >>> p = psutil.Process(os.getpid()) >>> p.get_children() [ ... list of process children ... ] >>> --- Giampaolo code.google.com/p/pyftpdlib/ code.google.com/p/psutil/ code.google.com/p/pysendfile/ From stefan_ml at behnel.de Wed Feb 29 09:48:30 2012 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 29 Feb 2012 15:48:30 +0100 Subject: Fwd: Question about PyXML and python's stdlib xml In-Reply-To: <4F4E374E.10201@redhat.com> References: <4F4BA664.90707@redhat.com> <4F4E374E.10201@redhat.com> Message-ID: Roman Rakus, 29.02.2012 15:33: > I'm forwarding this message to python-list, since I didn't get answer on > xml-sig ML I didn't see a message from you on that list. > I have concerns about PyXML and stdlib xml included directly in python. > Currently (in Fedora) python is trying to import PyXML, which means > other results when you have and haven't PyXML installed. What kind of "other results"? > Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". > PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', > 'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides > more functionality in those modules? Is python's xml better, same or > worse then PyXML? PyXML was meant as an extension and hooked into the stdlib XML support. That's only one of the reasons why it's broken now. > Anyway, python's xml is newer - is PyXML deprecated? Yes. It's a dead project. > Please keep me in CC, I'm not subscribed to the list. That may be the problem in the xml-sig case also. Stefan From d at davea.name Wed Feb 29 09:54:05 2012 From: d at davea.name (Dave Angel) Date: Wed, 29 Feb 2012 09:54:05 -0500 Subject: On u'Unicode string literals' (Py3) In-Reply-To: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> References: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> Message-ID: <4F4E3C0D.8040307@davea.name> Just who are you replying to? On 02/29/2012 08:45 AM, jmfauth wrote: > For those who do not know: > The u'' string literal trick has never worked in Python 2. > No trick there. If you have something explicit to say, then say it. >>>> sys.version > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' Why then does the subject line say Py3 ? >>>> print u'Un oeuf ? z?ro EURO uro' You're testing three things here, so there's no telling which might be wrong. Your source encoding, the implicit str() conversion for unicode, and the particular terminal you're printing it on. It'd be amazing if all three were right, unless you're on Linux. > Un uf ? z?ro uro > jmf -- DaveA From rweikusat at mssgmbh.com Wed Feb 29 10:15:02 2012 From: rweikusat at mssgmbh.com (Rainer Weikusat) Date: Wed, 29 Feb 2012 15:15:02 +0000 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Xah Lee writes: > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. As the perlop manpage would have told you, Operator associativity defines what happens if a sequence of the same operators is used one after another Since this is not the case in your example, it doesn't seem to be applicable here. Also, the Perl I'm aware doesn't have 'white triangle' and 'black triangle' operators and it also doesn't have operators of equal precedence and different associativity. It can't, actually, since there would be no way to evaluate an expression like the mock one you invented above. Lastly, that something happens to be in one way or another way in the completely arbitrary set of rules and conventions commonly referred to as 'mathematics' (an essentially outdated write-only programming language dating back to the times when humans had to perform computations themselves) doesn't mean it is of any relevance anywhere else just because of this, no matter how dear it might be to lots of people. From wxjmfauth at gmail.com Wed Feb 29 10:17:13 2012 From: wxjmfauth at gmail.com (jmfauth) Date: Wed, 29 Feb 2012 07:17:13 -0800 (PST) Subject: On u'Unicode string literals' reintroduction (Py3) References: <92580c23-775d-4b10-9986-1b1abb1f673f@d17g2000vba.googlegroups.com> Message-ID: On 29 f?v, 14:45, jmfauth wrote: > For those who do not know: > The u'' string literal trick has never worked in Python 2. > > >>> sys.version > > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'>>> print u'Un oeuf ? z?ro EURO uro' > > Un ?uf ? z?ro ?uro > > > > jmf Sorry, I just wanted to show a small example. I semms Google as "changed" again. You should read (2nd attempt) u'Un ?uf ? z?ro ?' with the *correct* typed glyphs 'LATIN SMALL LIGATURE OE' in ?uf and 'EURO SIGN' in '?uro'. jmf From kiuhnm03.4t.yahoo.it Wed Feb 29 11:18:24 2012 From: kiuhnm03.4t.yahoo.it (Kiuhnm) Date: Wed, 29 Feb 2012 17:18:24 +0100 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! In-Reply-To: <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Message-ID: <4f4e4fce$0$1386$4fafbaef@reader1.news.tin.it> On 2/29/2012 16:15, Rainer Weikusat wrote: > [...] 'mathematics' (an essentially > outdated write-only programming language dating back to the times > when humans had to perform computations themselves) [...] Theoretical Computer Science is a branch of mathematics. Are you saying it is outdated? Kiuhnm From jamesbroadhead at gmail.com Wed Feb 29 12:01:35 2012 From: jamesbroadhead at gmail.com (James Broadhead) Date: Wed, 29 Feb 2012 17:01:35 +0000 Subject: list comprehension question In-Reply-To: References: Message-ID: On 29 February 2012 13:52, Johann Spies wrote: > In [82]: t.append(instansie) > t.append(instansie) > > In [83]: t > t > Out[83]: ['Mangosuthu Technikon'] > In [84]: t = [x.alt_name for x in lys].append(instansie) > t = [x.alt_name for x in lys].append(instansie) > > In [85]: t > t > > In [86]: type t > type t > -------> type(t) > Out[86]: NoneType > You should note that in [82], you're not doing: > t = t.append(instansie) hth From gordon at panix.com Wed Feb 29 12:08:30 2012 From: gordon at panix.com (John Gordon) Date: Wed, 29 Feb 2012 17:08:30 +0000 (UTC) Subject: list comprehension question References: Message-ID: In James Broadhead writes: > On 29 February 2012 13:52, Johann Spies wrote: > > In [82]: t.append(instansie) > > t.append(instansie) > > > > In [83]: t > > t > > Out[83]: ['Mangosuthu Technikon'] > > In [84]: t = [x.alt_name for x in lys].append(instansie) > > t = [x.alt_name for x in lys].append(instansie) > > > > In [85]: t > > t > > > > In [86]: type t > > type t > > -------> type(t) > > Out[86]: NoneType > > > You should note that in [82], you're not doing: > > t = t.append(instansie) append() modifies the list in-place. It doesn't return anything. (and therefore its return value is None) >>> x = [1, 2, 3] >>> y = x.append(4) >>> print x [1, 2, 3, 4] >>> print y None -- John Gordon A is for Amy, who fell down the stairs gordon at panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" From clp2 at rebertia.com Wed Feb 29 12:10:31 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 29 Feb 2012 09:10:31 -0800 Subject: list comprehension question In-Reply-To: References: Message-ID: On Wed, Feb 29, 2012 at 5:52 AM, Johann Spies wrote: > I understand the following: > > In [79]: instansie > instansie > Out[79]: 'Mangosuthu Technikon' > > In [80]: t = [x.alt_name for x in lys] > t = [x.alt_name for x in lys] > > In [81]: t > t > Out[81]: [] > > In [82]: t.append(instansie) > t.append(instansie) Note the lack of an accompanying "Out". This means that the expression, i.e. `t.append(instansie)`, had a result of None. The list.append() method does *not* return the now-appended-to list. It is a mutator method that modifies the list object in-place; per convention, it therefore returns None to reinforce its side-effecting nature to the user; analogous methods in other languages return void. > In [83]: t > t > Out[83]: ['Mangosuthu Technikon'] > > But then why does the following behave like this: > > In [84]: t = [x.alt_name for x in lys].append(instansie) > t = [x.alt_name for x in lys].append(instansie) You didn't do anything with .append()'s useless return value before; here, you do, by assigning it to t. > In [85]: t > t > > In [86]: type t > type t > -------> type(t) > Out[86]: NoneType Cheers, Chris From namekuseijin at gmail.com Wed Feb 29 12:45:29 2012 From: namekuseijin at gmail.com (namekuseijin) Date: Wed, 29 Feb 2012 09:45:29 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <68375f71-c728-42eb-a096-9a8be05a4ca1@p21g2000yqm.googlegroups.com> On Feb 29, 5:09?am, Xah Lee wrote: > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > on ?Operators?. Quote: > > ?The associativity of an operator governs whether it evaluates from > left to right or right to left. Addition is left associative, such > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > ** 4 first, then raises 2 to the 81st power. ? > > LOL. Looks like the perl folks haven't changed. Fundamentals of > serious math got botched so badly. > > Let me explain the idiocy. > > It says ?The associativity of an operator governs whether it evaluates > from left to right or right to left.?. Ok, so let's say we have 2 > operators: a white triangle ? and a black triangle ?. Now, by the > perl's teaching above, let's suppose the white triangle is ?right > associative? and the black triangle is ?left associative?. Now, look > at this: > > 3 ? 6 ? 5 > > seems like the white and black triangles are going to draw a pistol > and fight for the chick 6 there. LOL. > > Now, let me tell you what operator precedence is. First of all, let's > limit ourselfs to discuss operators that are so-called binary > operators, which, in our context, basically means single symbol > operator that takes it's left and right side as operands. Now, each > symbol have a ?precedence?, or in other words, the set of operators > has a order. (one easy way to think of this is that, suppose you have > n symbols, then you give each a number, from 1 to n, as their order) > So, when 2 symbols are placed side by side such as ?3 ? 6 ? 5?, the > symbol with higher precedence wins. Another easy way to think of this > is that each operator has a stickiness level. The higher its level, it > more sticky it is. > > the problem with the perl explanations is that it's one misleading > confusion ball. It isn't about ?left/right associativity?. It isn't > about ?evaluates from left to right or right to left?. Worse, the word > ?associativity? is a math term that describe a property of algebra > that has nothing to do with operator precedence, yet is easily > confused with because it is a property about order of evaluation. (for > example, the addition function is associative, meaning: ?(3+6)+5 = > 3+(6+5)?.) > > compare it with this: > > ?Perl ? Python: Complex Numbers?http://xahlee.org/perl-python/complex_numbers.html > > and for a good understanding of functions and operators, see: > > ?What's Function, What's Operator??http://xahlee.org/math/function_and_operators.html associativity of operators mean little in the Lisp world obviously, so why was this posted here? Sorry, perl, python and emacs folks... BTW, it's the same in javascript: it is so such that 2 + 3 + "4" is "54" and "2" + 3 + 4 is "234". Blame weak typing and + overloading, though it may be a blessing. From ramit.prasad at jpmorgan.com Wed Feb 29 13:03:06 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 18:03:06 +0000 Subject: Question about PyXML and python's stdlib xml In-Reply-To: <4F4E374E.10201@redhat.com> References: <4F4BA664.90707@redhat.com> <4F4E374E.10201@redhat.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474165A1B@SCACMX008.exchad.jpmchase.net> >>I'm forwarding this message to python-list, since I didn't get answer on xml-sig ML. >>Hopefully this is right list to question. >>Please keep me in CC. Original message is below. >>>I have concerns about PyXML and stdlib xml included directly in python. >>>Currently (in Fedora) python is trying to import PyXML, which means >>>other results when you have and haven't PyXML installed. >>>Furthermore, python's xml provides "dom", "parsers", "sax" and "etree". >>>PyXML provides 'dom', 'marshal', 'parsers', 'sax', 'schema', 'utils', >>>'xpath' and 'xslt'. Some modules are duplicated. Does PyXML provides >>>more functionality in those modules? Is python's xml better, same or >>>worse then PyXML? Anyway, python's xml is newer - is PyXML deprecated? >Yes. It's a dead project. >> Please keep me in CC, I'm not subscribed to the list. >That may be the problem in the xml-sig case also. I believe a current equivalent would be lxml. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From ramit.prasad at jpmorgan.com Wed Feb 29 13:09:42 2012 From: ramit.prasad at jpmorgan.com (Prasad, Ramit) Date: Wed, 29 Feb 2012 18:09:42 +0000 Subject: Listing children processes In-Reply-To: References: <4f4d6e5b$0$29989$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5B80DD153D7D744689F57F4FB69AF474165A36@SCACMX008.exchad.jpmchase.net> >>> I've been told of by the BDFL for stating that >>> people should not top post on any Python mailing list/news group. >> He's the BDFL of Python, not of mailing list etiquette. >Incorrect, I was told off for this >http://code.activestate.com/lists/python-ideas/14065/ Why the link? If that is supposed to show how you were told off, I do not see it. Even if it were, I still agree with Steven + Ben. Or maybe that's what I get for trying to RTFA. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -- -----Original Message----- From: python-list-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of Mark Lawrence Sent: Tuesday, February 28, 2012 7:38 PM To: python-list at python.org Subject: Re: Listing children processes On 29/02/2012 00:16, Steven D'Aprano wrote: > On Tue, 28 Feb 2012 23:41:16 +0000, Mark Lawrence wrote: > > > Please don't bother apologising as I don't want to read another of your versions of War and Peace. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. From tjreedy at udel.edu Wed Feb 29 16:01:25 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 16:01:25 -0500 Subject: list comprehension question In-Reply-To: References: Message-ID: On 2/29/2012 8:52 AM, Johann Spies wrote: Please post plain text, the standard for all python.org mailing lists and corresponding newsgroups, and not html. Some readers print the html as plain text, which is confusing and obnoxious. Other like mine, do skip the plain text version and print the rendered html, but in this case, the strong background colors make your post impossible for *me* to read. -- Terry Jan Reedy From greg at tinyco.com Wed Feb 29 18:08:34 2012 From: greg at tinyco.com (Greg Harezlak) Date: Wed, 29 Feb 2012 15:08:34 -0800 Subject: Any Advice Would Be Greatly Appreciated Message-ID: Hello Python Community, I work for a mobile gaming startup in San Francisco, and we're heavily staffing around skilled Python Developers. I've already submitted a job posting to the Python.org website, but I was curious if anyone else had some suggestions on where I could go to find some really awesome people. Thanks in advance for your help. -- *Greg Harezlak* 1 Bush Street, 7th Floor San Francisco, CA 94104 (T): 925.683.8578 (E): greg at tinyco.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From phihag at phihag.de Wed Feb 29 18:48:06 2012 From: phihag at phihag.de (Philipp Hagemeister) Date: Thu, 01 Mar 2012 00:48:06 +0100 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: References: Message-ID: <4F4EB936.1060900@phihag.de> If you're looking for skilled developers, the best way to find them is probably to search their current work. http://careers.stackoverflow.com/ and the more experimental http://githire.com/ are two excellent developer-friendly solutions for that. - Philipp On 03/01/2012 12:08 AM, Greg Harezlak wrote: > Hello Python Community, > > I work for a mobile gaming startup in San Francisco, and we're heavily > staffing around skilled Python Developers. I've already submitted a job > posting to the Python.org website, but I was curious if anyone else had > some suggestions on where I could go to find some really awesome people. > Thanks in advance for your help. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature URL: From xahlee at gmail.com Wed Feb 29 19:02:39 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 16:02:39 -0800 (PST) Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <4f4e1554$0$1385$4fafbaef@reader2.news.tin.it> Message-ID: <9dc55d52-3902-4449-87e7-745fb8b911b3@n12g2000yqb.googlegroups.com> i missed a point in my original post. That is, when the same operator are adjacent. e.g. ?3 ? 6 ? 5?. This is pointed out by Kiuhnm ?kiuhnm03.4t.yahoo.it? and Tim Bradshaw. Thanks. though, i disagree the way they expressed it, or any sense this is different from math. to clarify, amend my original post, here's what's needed for binary operator precedence: ? the symbols are ordered. (e.g. given a unique integer) ? each symbol is has either one of left-side stickness or right-side stickness spec. (needed when adjacent symbols are the same.) About the lisp case mentioned by Tim, e.g. in?(f a b c)?, whether it means ?(f (f a b) c)? or ?(f a (f b c))? . It is not directly relevant to the context of my original post, because it isn't about to operators. It's about function argument eval order. Good point, nevertheless. the perl doc, is still misleading, terribly bad written. Becha ass! Xah On Feb 29, 4:08?am, Kiuhnm wrote: > On 2/29/2012 9:09, Xah Lee wrote: > > > > New Science Discovery: Perl Idiots Remain Idiots After A Decade! > > > A excerpt from the new book ?Modern Perl?, just published, chapter 4 > > on ?Operators?. Quote: > > > ?The associativity of an operator governs whether it evaluates from > > left to right or right to left. Addition is left associative, such > > that 2 + 3 + 4 evaluates 2 + 3 first, then adds 4 to the result. > > Exponentiation is right associative, such that 2 ** 3 ** 4 evaluates 3 > > ** 4 first, then raises 2 to the 81st power. ? > > > LOL. Looks like the perl folks haven't changed. Fundamentals of > > serious math got botched so badly. > > > Let me explain the idiocy. > > > It says ?The associativity of an operator governs whether it evaluates > > from left to right or right to left.?. Ok, so let's say we have 2 > > operators: a white triangle ? and a black triangle ?. Now, by the > > perl's teaching above, let's suppose the white triangle is ?right > > associative? and the black triangle is ?left associative?. Now, look > > at this: > > > 3 ? 6 ? 5 > > > seems like the white and black triangles are going to draw a pistol > > and fight for the chick 6 there. LOL. > > Sorry, but you're wrong and they're right. > Associativity governs the order of evaluation of a group of operators > *OF THE SAME PRECEDENCE*. > If you write > ? ?2**3**4 > only the fact the '**' is right associative will tell you that the order is > ? ?2**(3**4) > and not > ? ?(2**3)**4 > I remind you that 2^(3^4) != (2^3)^4. > > Kiuhnm From greg at tinyco.com Wed Feb 29 19:07:48 2012 From: greg at tinyco.com (Greg Harezlak) Date: Wed, 29 Feb 2012 16:07:48 -0800 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: <4F4EB936.1060900@phihag.de> References: <4F4EB936.1060900@phihag.de> Message-ID: Thank you so much for the help, Philipp! On Wed, Feb 29, 2012 at 3:48 PM, Philipp Hagemeister wrote: > If you're looking for skilled developers, the best way to find them is > probably to search their current work. > > http://careers.stackoverflow.com/ and the more experimental > http://githire.com/ are two excellent developer-friendly solutions for > that. > > - Philipp > > On 03/01/2012 12:08 AM, Greg Harezlak wrote: > > Hello Python Community, > > > > I work for a mobile gaming startup in San Francisco, and we're heavily > > staffing around skilled Python Developers. I've already submitted a job > > posting to the Python.org website, but I was curious if anyone else had > > some suggestions on where I could go to find some really awesome people. > > Thanks in advance for your help. > > -- *Greg Harezlak* 1 Bush Street, 7th Floor San Francisco, CA 94104 (T): 925.683.8578 (E): greg at tinyco.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Feb 29 19:17:09 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 19:17:09 -0500 Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <4F4EC005.8010307@udel.edu> On 2/29/2012 9:24 AM, Rick Johnson wrote: > On Feb 28, 11:06 pm, John Salerno wrote: >> However, in the Python documentation, I see this: >> >> root = Tk() >> app = Application(master=root) >> app.mainloop() >> root.destroy() >> I tried the above and I got the following error: >> >> Traceback (most recent call last): >> File "C:\Users\John\Desktop\gui.py", line 12, in >> root.destroy() >> File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy >> self.tk.call('destroy', self._w) >> _tkinter.TclError: can't invoke "destroy" command: application has been destroyed >> >> So apparently closing the window with the X button (on Windows) >> implicitly calls the destroy() method of the root frame. >> If that's the case, why does the documentation explicitly call it? I do not know if tk has changed since the example was written or if it was buggy from the beginning. I opened an issue to fix it. http://bugs.python.org/issue14163 > Most applications will have both: user destroying, and program > destroying. > from tkMessageBox import askyesnocancel from tkinter.messagebox in 3.x > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self.title('Close Me -->') > self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) > > def onDestroyWindow(self): > title = 'Confirm App Exit' > msg = 'Save changes before exiting?' > result = askyesnocancel(title, msg, default='cancel') > if result is None: > return > elif result is True: > print 'saving changes' > elif result is False: > print 'dont save changes' > self.destroy() > > if __name__ == '__main__': > app = App() > app.mainloop() This works as adjusted for 3.x. I presume that a quit button or menu entry should also call onDestroyWindow so the effect is the same as clicking the outer [X] button. I tried the same approach to fix the doc example, but unlike your class App(Tk), class App(Frame) does not a .protocol attribute. See the tracker issue for all my comments on the example. I considered removing both the quit button and 'root.destroy' to get a beginning example that works properly, but as you said, having both is common so I would like both if the solution is not too esoteric. -- Terry Jan Reedy From tjreedy at udel.edu Wed Feb 29 19:17:09 2012 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 29 Feb 2012 19:17:09 -0500 Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <4F4EC005.8010307@udel.edu> On 2/29/2012 9:24 AM, Rick Johnson wrote: > On Feb 28, 11:06 pm, John Salerno wrote: >> However, in the Python documentation, I see this: >> >> root = Tk() >> app = Application(master=root) >> app.mainloop() >> root.destroy() >> I tried the above and I got the following error: >> >> Traceback (most recent call last): >> File "C:\Users\John\Desktop\gui.py", line 12, in >> root.destroy() >> File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy >> self.tk.call('destroy', self._w) >> _tkinter.TclError: can't invoke "destroy" command: application has been destroyed >> >> So apparently closing the window with the X button (on Windows) >> implicitly calls the destroy() method of the root frame. >> If that's the case, why does the documentation explicitly call it? I do not know if tk has changed since the example was written or if it was buggy from the beginning. I opened an issue to fix it. http://bugs.python.org/issue14163 > Most applications will have both: user destroying, and program > destroying. > from tkMessageBox import askyesnocancel from tkinter.messagebox in 3.x > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self.title('Close Me -->') > self.protocol("WM_DELETE_WINDOW", self.onDestroyWindow) > > def onDestroyWindow(self): > title = 'Confirm App Exit' > msg = 'Save changes before exiting?' > result = askyesnocancel(title, msg, default='cancel') > if result is None: > return > elif result is True: > print 'saving changes' > elif result is False: > print 'dont save changes' > self.destroy() > > if __name__ == '__main__': > app = App() > app.mainloop() This works as adjusted for 3.x. I presume that a quit button or menu entry should also call onDestroyWindow so the effect is the same as clicking the outer [X] button. I tried the same approach to fix the doc example, but unlike your class App(Tk), class App(Frame) does not a .protocol attribute. See the tracker issue for all my comments on the example. I considered removing both the quit button and 'root.destroy' to get a beginning example that works properly, but as you said, having both is common so I would like both if the solution is not too esoteric. -- Terry Jan Reedy From rodrick.brown at gmail.com Wed Feb 29 19:54:57 2012 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Wed, 29 Feb 2012 19:54:57 -0500 Subject: Any Advice Would Be Greatly Appreciated In-Reply-To: References: Message-ID: <7551F03F-98C3-45C1-971D-75CC6B0960C7@gmail.com> LinkedIn is an excellent resource for finding great candidates, However your problem might be because your searching for Python Developers why not hire great programmers and have them learn Python? Sent from my iPhone On Feb 29, 2012, at 6:08 PM, Greg Harezlak wrote: > Hello Python Community, > > I work for a mobile gaming startup in San Francisco, and we're heavily staffing around skilled Python Developers. I've already submitted a job posting to the Python.org website, but I was curious if anyone else had some suggestions on where I could go to find some really awesome people. Thanks in advance for your help. > > -- > Greg Harezlak > > > > 1 Bush Street, 7th Floor > San Francisco, CA 94104 > > (T): 925.683.8578 > (E): greg at tinyco.com > > > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From example.scripts at gmail.com Wed Feb 29 21:19:39 2012 From: example.scripts at gmail.com (scripts examples) Date: Wed, 29 Feb 2012 18:19:39 -0800 (PST) Subject: python scripts solution for euler projects References: <08ddbff5-566c-471c-b9a8-87966da3b3b6@p6g2000yqi.googlegroups.com> Message-ID: <828760b3-2d70-4ba4-9830-e173d2eaf058@f14g2000yqe.googlegroups.com> On Feb 29, 4:21?am, alister wrote: > On Tue, 28 Feb 2012 19:59:40 -0800, scripts examples wrote: > > Got a web site setup for solving euler problems in python, perl, > > ruby and javascript. > > > ? ?Feel free to give me any feedback, thanks. > > Failing to give a link to the site is a pretty fundamental failure > > -- > Please take note: Sorry, forgot the link. Here it is: examplescripts.weebly.com From rantingrickjohnson at gmail.com Wed Feb 29 22:22:16 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 19:22:16 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: On Feb 29, 6:17?pm, Terry Reedy wrote: > On 2/29/2012 9:24 AM, Rick Johnson wrote: > > On Feb 28, 11:06 pm, John Salerno ?wrote: > >> However, in the Python documentation, I see this: > > >> root = Tk() > >> app = Application(master=root) > >> app.mainloop() > >> root.destroy() > >> I tried the above and I got the following error: > > >> Traceback (most recent call last): > >> ? ?File "C:\Users\John\Desktop\gui.py", line 12, in > >> ? ? ?root.destroy() > >> ? ?File "C:\Python32\lib\tkinter\__init__.py", line 1714, in destroy > >> ? ? ?self.tk.call('destroy', self._w) > >> _tkinter.TclError: can't invoke "destroy" command: ?application has been destroyed > > >> So apparently closing the window with the X button (on Windows) > > ?>> implicitly calls the destroy() method of the root frame. > ?>> If that's the case, why does the documentation explicitly call it? > > I do not know if tk has changed since the example was written or if it > was buggy from the beginning. I opened an issue to fix it. > > http://bugs.python.org/issue14163 "protocol" is ONLY a method of Tkinter.Tk and Tkinter.Toplevel. Actually Toplevel and Tk are exactly the same object but Tk has an TCL interpretor attached. Tkinter.Tk is meant to be the parent of ALL widgets within your Tkinter GUI. Tkinter.Frame is nothing more than a box to stuff widgets into. Tkinter.Frame IS NOT a window and therefor it DOES NOT have window methods. HOWEVER! Most people start falsely believing that a Tkinter.Frame AND Tkinter.Toplevel are the same thing; since Tkinter will "auto- magically" pack your frame into a default Tkinter.Tk window (psst: that's just a fancy Toplevel widget!) if you don't explicitly create the Tk instance yourself. >>>Slightly tangential meanderings This inconsistency also rears it's ugly head in the dialog modules: tkFileDialog and tkMessageBox. Both of which do not require a parent argument to their convenience functions. Instead they allow the parent to be OPTIONALLY passed. Inquisitive Ivan mused: """ What's wrong with that Rick, the dialog will still display whether a parent argument is passed or not. Heck, even if no viable parent exists, Tkinter will create one! Tkinter is a smart module!""" True Ivan. However, if you dig a little deeper you will see that the dialog created WITHOUT a parent does not function in a manner consistent to modal dialogs; that is, owning the focus and becoming a transient of another Toplevel window. Also, about your second point, noobs get confused when that default root window pops up. Then they come here and ask the same question over and over. Can't you see the design flaw that is directly in front of your face NOR smell the pungent odors that reeking from this module! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Some might argue that this implicit root window creation is beneficial for toy GUIs -- and i agree! HOWEVER, you will due enormous damage to a neophyte's learning process. I say just force the extra line of code and be consistent. Actually i believe SO strongly in "explicit root window creation" that i edited the source code of my Tkinter version to NOT allow ANY widget's master to be None. I had written a more exhaustive "expo-say" some time back but i cannot remember the title. > > Most applications will have both: user destroying, and program > > destroying. > > from tkMessageBox import askyesnocancel > > from tkinter.messagebox in 3.x Yes, Tkinter has changed a bit in Python>=3.0, thanks for pointing this out. > [...snip code...] > This works as adjusted for 3.x. I presume that a quit button or menu > entry should also call onDestroyWindow so the effect is the same as > clicking the outer [X] button. Yes, but i think the REAL problem is faulty code logic. Remove the last line "root.destroy()" and the problem is solved. Obviously the author does not have an in-depth knowledge of Tkinter. > I tried the same approach to fix the doc example, but unlike your class > App(Tk), class App(Frame) does not a .protocol attribute. See the > tracker issue for all my comments on the example. see above comments about Tkinter.Frame, Tkinter.Toplevel, and Tkinter.Tk ^^^ > I considered removing both the quit button and 'root.destroy' to get a > beginning example that works properly, but as you said, having both is > common so I would like both if the solution is not too esoteric. If you want to keep things simple, i would: 1. Create the root window explicitly! 2. Bind the command of the button to root.destroy (command=root.destroy) I would offer better advice if i could but i have no idea where this "book the OP is learning" is located? No one ever provided a link to the code in question? PS: I would highly suggest against using the "from Tkinter import *". Instead, use "import Tkinter as tk" and prefix all module contents with "tk.". Also, use "from Tkconstants import X, Y, X" From rantingrickjohnson at gmail.com Wed Feb 29 22:45:38 2012 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 29 Feb 2012 19:45:38 -0800 (PST) Subject: PyTut: Tkinter #1 Message-ID: <55a4abd7-f5dd-4de6-85e9-b00ee7a62603@w27g2000yqm.googlegroups.com> PyTut: Tkinter #1 Graciously donated by the benevolent professor Richard Johnson The first step to creating a Tkinter GUI is to create a blank window. Tkinter has two classes that represent a GUI window: Toplevel and Tk. Both the classes are basically the same, but since a GUI can have an unlimited number of Toplevel windows, the very first window should ALWAYS be an instance of Tk! Let's write some code. ## START CODE ## import Tkinter as tk root = tk.Tk() root.mainloop() ## END CODE ## You can probably guess what the first line does; it creates your parent Toplevel window as an instance of Tk! The second line "root.mainloop()" enters the event loop. Don't worry about the details of "mainloop" at this time, just remeber that all Tkinter GUIs start with an instance of Tk and end with a call to mainloop. Here is the same code in a strict OOP form (For something this simple you need not use strict OOP but eventually you will need to harness the power of OOP!) ## START CODE ## class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) app = App() app.mainloop() ## END CODE ## That's all folks! Keep your eyes peeled for the next glorious installment of "PyTut: Tkinter"! From peter.rubenstein at hotmail.com Wed Feb 29 22:56:22 2012 From: peter.rubenstein at hotmail.com (Peter Rubenstein) Date: Thu, 1 Mar 2012 03:56:22 +0000 Subject: Help needed: dynamically pull data from different levels of a dict Message-ID: Hi, I'd appreciate a bit of help on this problem. I have some data that I've converted to a dict and I want to pull out individual pieces of it. Simplified version-- a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } } } I'd like to be able to code something like: data_needed = ['1', '2', '3:4', '5:6:7-8']for val in data_needed: answer=extract_from(a,val) print answer And get:abcde Problem is I can't figure out what extract_from would look like, such that it would proceed dynamically down to the right level. I'm open to the possibility that I'm not approaching this the right way. If it helps, one member of my actual dict quoted below. So in real life, something likedata_needed=['name','active-defects', 'admin-status:format', 'description', 'traffic-statistics:input-bps']etc. Thanks in advance,Peter { 'ge-0/0/0': {'active-alarms': {'interface-alarms': {'alarm-not-present': ''}}, 'active-defects': {'interface-alarms': {'alarm-not-present': ''}}, 'admin-status': {'_text': 'up', 'format': 'Enabled'}, 'current-physical-address': 'ff:ff:ff:c0:e8:00', 'description': 'XXX', 'hardware-physical-address': 'ff:ff:ff:c0:e8:00', 'if-config-flags': {'iff-snmp-traps': '', 'internal-flags': '0x4000'}, 'if-device-flags': {'ifdf-present': '', 'ifdf-running': ''}, 'if-flow-control': 'enabled', 'if-media-flags': {'ifmf-none': ''}, 'interface-flapped': {'_text': '2010-05-23 18:20:36 UTC (92w3d 02:27 ago)', 'seconds': '55909644'}, 'l2pt-error': 'none', 'link-level-type': 'Ethernet', 'local-index': '171', 'logical-interface': {'address-family': [{'address-family-flags': {'ifff-no-redirects': '', 'internal-flags': '0x0'}, 'address-family-name': 'inet', 'interface-address': {'ifa-destination': '10.46.43.2/31', 'ifa-flags': {'ifaf-current-preferred': '', 'ifaf-current-primary': ''}, 'ifa-local': '10.46.43.2'}, 'mtu': '9178'}, {'address-family-flags': {'ifff-mtu-user-conf': '', 'internal-flags': '0x10000000'}, 'address-family-name': 'mpls', 'mtu': '9174'}, {'address-family-flags': {'ifff-none': ''}, 'address-family-name': 'multiservice', 'mtu': 'Unlimited'}], 'description': 'YYY', 'encapsulation': 'ENET2', 'if-config-flags': {'iff-snmp-traps': ''}, 'local-index': '67', 'name': 'ge-0/0/0.0', 'snmp-index': '117', 'traffic-statistics': {'input-packets': '46367422526659', 'output-packets': '35670513402384', 'style': 'brief'}}, 'loopback': 'disabled', 'mtu': '9192', 'name': 'ge-0/0/0', 'oper-status': 'up', 'physical-interface-cos-information': {'physical-interface-cos-hw-max-queues': '8', 'physical-interface-cos-use-max-queues': '8'}, 'snmp-index': '116', 'source-filtering': 'disabled', 'speed': '10Gbps', 'traffic-statistics': {'input-bps': '4104358720', 'input-pps': '1059450', 'output-bps': '2323588888', 'output-pps': '537816', 'style': 'brief'}},} -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter216 at gmail.com Wed Feb 29 23:04:46 2012 From: peter216 at gmail.com (Peter Rubenstein) Date: Thu, 1 Mar 2012 04:04:46 +0000 Subject: Help needed: dynamically pull data from different levels of a dict Message-ID: --Reposting in plan text, apologies-- Hi, I'd appreciate a bit of help on this problem. ?I have some data that I've converted to a dict and I want to pull out individual pieces of it. Simplified version-- a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } } } I'd like to be able to code something like: data_needed = ['1', '2', '3:4', '5:6:7-8']for val in data_needed:? ??? ? answer=extract_from(a,val)? ??? ? print answer And get:abcde Problem is I can't figure out what extract_from would look like, such that it would proceed dynamically down to the right level. ?I'm open to the possibility that I'm not approaching this the right way. If it helps, one member of my actual dict quoted below. ?So in real life, something likedata_needed=['name','active-defects', 'admin-status:format', 'description', 'traffic-statistics:input-bps']etc. Thanks in advance,Peter {?'ge-0/0/0': {'active-alarms': {'interface-alarms': {'alarm-not-present': ''}},? 'active-defects': {'interface-alarms': {'alarm-not-present': ''}},? 'admin-status': {'_text': 'up', 'format': 'Enabled'},? 'current-physical-address': '00:1f:12:c0:e8:00',? 'description': 'INFRA:CROSS:ASH-64CB-1B:GE-0/0/0:',? 'hardware-physical-address': '00:1f:12:c0:e8:00',? 'if-config-flags': {'iff-snmp-traps': '', 'internal-flags': '0x4000'},? 'if-device-flags': {'ifdf-present': '', 'ifdf-running': ''},? 'if-flow-control': 'enabled',? 'if-media-flags': {'ifmf-none': ''},? 'interface-flapped': {'_text': '2010-05-23 18:20:36 UTC (92w3d 02:27 ago)',? ?'seconds': '55909644'},? 'l2pt-error': 'none',? 'link-level-type': 'Ethernet',? 'local-index': '171',? 'logical-interface': {'address-family': [{'address-family-flags': {'ifff-no-redirects': '',? ? ? 'internal-flags': '0x0'},? ? ?'address-family-name': 'inet',? ? ?'interface-address': {'ifa-destination': '207.46.43.2/31',? ? ? 'ifa-flags': {'ifaf-current-preferred': '', 'ifaf-current-primary': ''},? ? ? 'ifa-local': '207.46.43.2'},? ? ?'mtu': '9178'},? ? {'address-family-flags': {'ifff-mtu-user-conf': '',? ? ? 'internal-flags': '0x10000000'},? ? ?'address-family-name': 'mpls',? ? ?'mtu': '9174'},? ? {'address-family-flags': {'ifff-none': ''},? ? ?'address-family-name': 'multiservice',? ? ?'mtu': 'Unlimited'}],? ?'description': 'INFRA:CROSS:ASH-64CB-1B:GE-0/0/0.0:',? ?'encapsulation': 'ENET2',? ?'if-config-flags': {'iff-snmp-traps': ''},? ?'local-index': '67',? ?'name': 'ge-0/0/0.0',? ?'snmp-index': '117',? ?'traffic-statistics': {'input-packets': '46367422526659',? ? 'output-packets': '35670513402384',? ? 'style': 'brief'}},? 'loopback': 'disabled',? 'mtu': '9192',? 'name': 'ge-0/0/0',? 'oper-status': 'up',? 'physical-interface-cos-information': {'physical-interface-cos-hw-max-queues': '8',? ?'physical-interface-cos-use-max-queues': '8'},? 'snmp-index': '116',? 'source-filtering': 'disabled',? 'speed': '10Gbps',? 'traffic-statistics': {'input-bps': '4104358720',? ?'input-pps': '1059450',? ?'output-bps': '2323588888',? ?'output-pps': '537816',? ?'style': 'brief'}},} From spamtrap at library.lspace.org.invalid Wed Feb 29 23:06:42 2012 From: spamtrap at library.lspace.org.invalid (Shmuel Metz (Seymour J.)) Date: Wed, 29 Feb 2012 23:06:42 -0500 Subject: New Science Discovery: Perl Detracters Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> Message-ID: <4f4ef5d2$26$fuzhry+tra$mr2ice@news.patriot.net> In , on 02/29/2012 at 11:43 AM, Chiron said: >Sure, mathematically it *should* go a particular way, No. Mathematically it should go the way that it is defined to go. There is nothing in Mathematics that either requires or prohibits infix notation in programming languages, or even in Mathematical notation. >it makes sense to keep things as clear as possible. Often infix notation with well thought out precedence is the clearest way to go. RPN and the like have their place, but often are difficult for real people to read. -- Shmuel (Seymour J.) Metz, SysProg and JOAT Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap at library.lspace.org From xahlee at gmail.com Wed Feb 29 23:07:49 2012 From: xahlee at gmail.com (Xah Lee) Date: Wed, 29 Feb 2012 20:07:49 -0800 (PST) Subject: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp Message-ID: <85fa5760-68c8-41a2-9116-2489165f7ca1@j5g2000yqm.googlegroups.com> fun example. in-place algorithm for reversing a list in Perl, Python, Lisp http://xahlee.org/comp/in-place_algorithm.html plain text follows ---------------------------------------- What's ?In-place Algorithm?? Xah Lee, 2012-02-29 This page tells you what's ?In-place algorithm?, using {python, perl, emacs lisp} code to illustrate. Here's Wikipedia In-place algorithm excerpt: In computer science, an in-place algorithm (or in Latin in situ) is an algorithm which transforms input using a data structure with a small, constant amount of extra storage space. The input is usually overwritten by the output as the algorithm executes. An algorithm which is not in-place is sometimes called not-in-place or out-of- place. Python Here's a python code for reversing a list. Done by creating a new list, NOT using in-place: # python # reverse a list list_a = ["a", "b", "c", "d", "e", "f", "g"] list_length = len(list_a) list_b = [0] * list_length for i in range(list_length): list_b[i] = list_a[list_length -1 - i] print list_b Here's in-place algorithm for reversing a list: # python # in-place algorithm for reversing a list list_a = ["a", "b", "c", "d", "e", "f", "g"] list_length = len(list_a) for i in range(list_length/2): x = list_a[i] list_a[i] = list_a[ list_length -1 - i] list_a[ list_length -1 - i] = x print list_a Perl Here's a perl code for reversing a list. Done by creating a new list, NOT using in-place: # perl use strict; use Data::Dumper; my @listA = qw(a b c d e f g); my $listLength = scalar @listA; my @listB = (); for ( my $i = 0; $i < $listLength; $i++ ) { $listB[$i] = $listA[ $listLength - 1 - $i]; } print Dumper(\@listB); # perl # in-place algorithm for reversing a list. use strict; use Data::Dumper; use POSIX; # for ?floor? my @listA = qw(a b c d e f g); my $listLength = scalar @listA; for ( my $i = 0; $i < floor($listLength/2); $i++ ) { my $x = $listA[$i]; $listA[$i] = $listA[ $listLength - 1 - $i]; $listA[ $listLength - 1 - $i] = $x; } print Dumper(\@listA); __END__ emacs lisp ;; emacs lisp ;; reverse a array (setq arrayA ["a" "b" "c" "d" "e" "f" "g"]) (setq arrayLength (length arrayA)) (setq arrayB (make-vector arrayLength 0)) (dotimes (i arrayLength ) (aset arrayB i (aref arrayA (- (1- arrayLength) i)) ) ) (print (format "%S" arrayB)) ;; emacs lisp ;; in-place algorithm for reversing a array (setq arrayA ["a" "b" "c" "d" "e" "f" "g"]) (setq arrayLength (length arrayA)) (dotimes (i (floor (/ arrayLength 2))) (let (x) (setq x (aref arrayA i)) (aset arrayA i (aref arrayA (- (1- arrayLength) i))) (aset arrayA (- (1- arrayLength) i) x) ) ) (print (format "%S" arrayA)) Xah From spamtrap at library.lspace.org.invalid Wed Feb 29 23:10:48 2012 From: spamtrap at library.lspace.org.invalid (Shmuel Metz (Seymour J.)) Date: Wed, 29 Feb 2012 23:10:48 -0500 Subject: New Science Discovery: Perl Idiots Remain Idiots After A Decade!New Science Discovery: Perl Idiots Remain Idiots Af References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <87aa41k6x5.fsf@sapphire.mobileactivedefense.com> Message-ID: <4f4ef6c8$27$fuzhry+tra$mr2ice@news.patriot.net> In <87aa41k6x5.fsf at sapphire.mobileactivedefense.com>, on 02/29/2012 at 03:15 PM, Rainer Weikusat said: >'mathematics' (an essentially outdated write-only programming >language dating back to the times when humans had to perform >computations themselves) ROTF,LMAO! You obviously don't have a clue as to what Mathematics means. Free hint: it doesn't mean Arithmetic. You're as bigoted as Xah Lee, -- Shmuel (Seymour J.) Metz, SysProg and JOAT Unsolicited bulk E-mail subject to legal action. I reserve the right to publicly post or ridicule any abusive E-mail. Reply to domain Patriot dot net user shmuel+news to contact me. Do not reply to spamtrap at library.lspace.org From johnjsal at gmail.com Wed Feb 29 23:41:45 2012 From: johnjsal at gmail.com (John Salerno) Date: Wed, 29 Feb 2012 20:41:45 -0800 (PST) Subject: Is it necessary to call Tk() when writing a GUI app with Tkinter? In-Reply-To: <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> References: <27603449.17.1330492001624.JavaMail.geo-discussion-forums@vbbfv2> <6e1c521e-14be-4ec0-9ff0-7f23fd9cd3dc@f14g2000yqe.googlegroups.com> Message-ID: <17153317.324.1330576905540.JavaMail.geo-discussion-forums@yncd8> > It is not necessarily to call Tk explicitly, which i think is a bug > BTW. Sure, for simple scripts you can save one line of code but only > at the expense of explicitness and intuitiveness. Observe > > ## START CODE ## > import Tkinter as tk > > root = tk.Tk() > root.title('Explicit Root') > root.mainloop() > > f = tk.Frame(master=None, width=100, height=100, bg='red') > f.pack() > f.mainloop() > > b = tk.Button(master=None, text='Sloppy Coder') > b.pack() > b.mainloop() > ## END CODE ## > > as you can see all three examples work even though the last two don't > explicitly create a master. The master is still there however Tkinter > just created "magically" for you. Talk about laziness! I'm not sure I understand which method you are advocating. It sounded like you said calling Tk() explicitly is a bug. I certainly would never create widgets without first creating a master frame, but is creating a Frame object enough, or should I create a Tk object and *then* a Frame object? Also, at what point do you include the destroy method in your program, assuming you do not have a widget that will close the window? If you only want the Windows "X" button to close the window, then is it okay to leave out any call to destroy()? Or should always explicitly destroy it just as I explicitly created a Tk instance? If the latter, then where in the code do you put the call to destroy so it won't conflict with the user closing the window with the X button? From clp2 at rebertia.com Wed Feb 29 23:43:44 2012 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 29 Feb 2012 20:43:44 -0800 Subject: Help needed: dynamically pull data from different levels of a dict In-Reply-To: References: Message-ID: On Wed, Feb 29, 2012 at 7:56 PM, Peter Rubenstein wrote: > Hi, > > I'd appreciate a bit of help on this problem. ?I have some data that I've > converted to a dict and I want to pull out individual pieces of it. > > Simplified version-- > > a={'1':'a', '2':'b', '3':{4:'d'}, '5':{'6': {'7': [ {'8':'e'}, {'9':'f'} ] } > } } > > I'd like to be able to code something like: > > data_needed = ['1', '2', '3:4', '5:6:7-8'] > for val in data_needed: > ? ? answer=extract_from(a,val) > ? ? print answer > > And get: > a > b > c "c" apparently sprung completely out of thin air... > d > e > > Problem is I can't figure out what extract_from would look like, such that > it would proceed dynamically down to the right level. ?I'm open to the > possibility that I'm not approaching this the right way. data_needed = ['1', '2', ('3', '4'), ('5', '6', '7', 0, '8')] def extract_from(mapping, key_path): current = mapping for key in key_path: current = current[key] return current I would perhaps try and restructure the data into something less generic than nested dicts & lists, e.g. objects. You then might be able to introduce helper querying methods. I would also be worried about Law of Demeter violations, but fortunately your concrete example doesn't reach any deeper than 2 levels. Cheers, Chris -- http://chrisrebert.com From chiron613 at gmail.com Wed Feb 29 23:52:27 2012 From: chiron613 at gmail.com (Chiron) Date: Thu, 01 Mar 2012 04:52:27 GMT Subject: New Science Discovery: Perl Detracters Remain Idiots After A Decade! References: <0078bbfb-5dfc-48fc-af1a-69de3cf15c3e@b1g2000yqb.googlegroups.com> <4f4ef5d2$26$fuzhry+tra$mr2ice@news.patriot.net> Message-ID: On Wed, 29 Feb 2012 23:06:42 -0500, Shmuel (Seymour J.) Metz wrote: > In , on 02/29/2012 > at 11:43 AM, Chiron said: > >>Sure, mathematically it *should* go a particular way, > > No. Mathematically it should go the way that it is defined to go. There > is nothing in Mathematics that either requires or prohibits infix > notation in programming languages, or even in Mathematical notation. > Yes. That (the mathematically defined way) is a particular way, is it not? >>it makes sense to keep things as clear as possible. > > Often infix notation with well thought out precedence is the clearest > way to go. RPN and the like have their place, but often are difficult > for real people to read. However, I wasn't specifically referring to infix/postfix/prefix or anything of that nature. I wasn't limiting my comment to lisp notation in particular, since what I said applies to any language. I was referring to the placement of parentheses (or other groupings) to indicate to *humans* what the intended sequence of events was. The problem with precedence is that it is not always clear how it will go. Different languages have different rules, some of which depart from the rules in mathematics. Some implementations of languages are buggy in this regard. Mathematically, and in any language with which I am familiar, the sequence: 2 + 6 / 3 will yield 4. It is unnecessary, but harmless, to write this as 2 + (6 / 3). A naive reader (or just a tired or hurried one) might come up with 8 / 3 if there aren't any parentheses. Whenever there is *any* possibility of ambiguity, I see no reason not to clarify. Back in the days when the way you wrote your code affected how it was compiled, it made sense to rely heavily on language-specific features, thus saving a few bytes. With gigabyte memories, gigahertz clock speeds, and optimizing compilers, the pressure to try to optimize by hand is gone. A few extra parentheses, or even breaking down a complex sequence of events into discrete, simpler ones, is no longer a costly luxury. A few extra variables, if they help clarity, aren't going to hurt anything. Let the machine do the grunt work. Pamper your readers (which in a few weeks or months might be you) and show exactly what you had in mind. That's all I'm saying. -- I'd just as soon kiss a Wookie. -- Princess Leia Organa