Re: question about function pointer
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 -- http://mail.python.org/mailman/listinfo/python-list
PHP Tutorials
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". -- http://mail.python.org/mailman/listinfo/python-list
Re: format a measurement result and its error in "scientific" way
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: question about function pointer
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} -- http://mail.python.org/mailman/listinfo/python-list
Re: format a measurement result and its error in "scientific" way
>> 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: format a measurement result and its error in "scientific" way
>> 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating class definitions at runtime in memory from XSD or JSON
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(). -- http://mail.python.org/mailman/listinfo/python-list
Re: Numerical Linear Algebra in arbitrary precision
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make PyDev pep8 friendly?
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: format a measurement result and its error in "scientific" way
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: format a measurement result and its error in "scientific" way
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating class definitions at runtime in memory from XSD or JSON
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Undoing character read from file
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
Re: question about function pointer
在 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Sarge, a library wrapping the subprocess module, has been released.
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 -- http://mail.python.org/mailman/listinfo/python-list
Python code file prototype
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python code file prototype
In <66ea0353-02ee-4152-947a-97b44ff3e...@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 gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list
Re: Python code file prototype
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python code file prototype
On 2012-02-17, John Gordon wrote: > In <66ea0353-02ee-4152-947a-97b44ff3e...@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 -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Sarge, a library wrapping the subprocess module, has been released.
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Sarge, a library wrapping the subprocess module, has been released.
Check PY2EXE, PYREX and PSYChO. I must use these packages to relase commercial products with my own dll in c. -- http://mail.python.org/mailman/listinfo/python-list
signed to unsigned
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: signed to unsigned
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python code file prototype
> 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: signed to unsigned
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. >>> 0x & -327681234 3967286062 -- http://mail.python.org/mailman/listinfo/python-list
Re: signed to unsigned
> 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: signed to unsigned
> >>> 0x & -327681234 > > 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0x & -9151314442815602945 9295429630893948671L -- http://mail.python.org/mailman/listinfo/python-list
Re: signed to unsigned
On 02/17/2012 02:22 PM, Brad Tilley wrote: 0x& -327681234 3967286062 Very nice! Thanks for that example. Unsigned long longs: 0x& -9151314442815602945 9295429630893948671L Or more generally, use modulo -13452324 % 2^64 -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
RE: OT: Entitlements [was Re: Python usage numbers]
>> 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: XSLT to Python script conversion?
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] rri...@csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: XSLT to Python script conversion?
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: XSLT to Python script conversion?
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] rri...@csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter.Toplevel
On Feb 16, 8:39 pm, y...@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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Entitlements [was Re: Python usage numbers]
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 ta
Re: OT: Entitlements [was Re: Python usage numbers]
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT]: Smartphones and Python?
On 02/16/2012 10:25 PM, 8 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 waaa 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Entitlements [was Re: Python usage numbers]
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Entitlements [was Re: Python usage numbers]
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. -- http://mail.python.org/mailman/listinfo/python-list
Re: Undoing character read from file
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 * -- http://mail.python.org/mailman/listinfo/python-list
Re: Undoing character read from file
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 * -- http://mail.python.org/mailman/listinfo/python-list
Re: Undoing character read from file
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT]: Smartphones and Python?
-- http://mail.python.org/mailman/listinfo/python-list
Re: [OT]: Smartphones and Python?
在 2012年2月18日星期六UTC+8上午9时51分13秒,Michael Torrie写道: > On 02/16/2012 10:25 PM, 8 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 waaa 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT]: Smartphones and Python?
On 2/17/2012 10:51 PM, 8 Dihedral wrote: > 在 2012年2月18日星期六UTC+8上午9时51分13秒,Michael Torrie写道: >> On 02/16/2012 10:25 PM, 8 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 waaa 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. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Entitlements [was Re: Python usage numbers]
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