ANN: SfePy 2012.3
I am pleased to announce release 2012.3 of SfePy. Description --- SfePy (simple finite elements in Python) is a software for solving systems of coupled partial differential equations by the finite element method. The code is based on NumPy and SciPy packages. It is distributed under the new BSD license. Home page: http://sfepy.org Downloads, mailing list, wiki: http://code.google.com/p/sfepy/ Git (source) repository, issue tracker: http://github.com/sfepy Highlights of this release -- - several new terms - material parameters can be defined per region using region names - base function values can be defined per element - support for global options For full release notes see http://docs.sfepy.org/doc/release_notes.html#id1 (rather long and technical). Best regards, Robert Cimrman and Contributors (*) (*) Contributors to this release (alphabetical order): Alec Kalinin, Vladimír Lukeš -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: confused in decorate and closure
月忧茗 wrote: HI, I have some test code: def num(num): def deco(func): def wrap(*args, **kwargs): inputed_num = num return func(*args, **kwargs) return wrap return deco @num(5) def test(a): return a + inputed_num print test(1) when run this code, I got an error shows that 'inputed_num' is not defined My question is: In wrap function, is there not a closure that func can got 'inputed_num' ? Anyway, If not, how should I do to got my aim: Initialize some value, and use this value directly in the main function. Variable scopes are determined statically. In def test(a): return a + inputed_num inputed_num is a global variable. @num(5) is not a macro, but a shortcut that tells Python to execute test = num(5)(test) and thus does not change the scopes. To get the desired effect you have to turn inputed_num into an explicit function argument, for example: def num(n): ... def deco(f): ... def wrap(*args, **kw): ... return f(n, *args, **kw) ... return wrap ... return deco ... @num(42) ... def test(n, a): ... return n + a ... test(1) 43 -- http://mail.python.org/mailman/listinfo/python-list
Java Python Developer Required at NYC NY
Hi, I am looking for a Java Python developer at NYC NY for one of our direct client. It is a 6 Months contract position. We need a person with experience in developing trading applications and very good with Python Development. If interested, please send me your resume to my email address, ie sanith_n...@artechinfo.com Thanks Sanith Nair Lead Recruiter Artech Information Systems LLC 240 Cedar Knolls Road, Suite 100 | Cedar Knolls, NJ 07927 Office: 973.967.3522 | Fax: 973.998.2599 Email: sanith_n...@artechinfo.com | Website: www.artechinfo.com Artech is the #10 Largest IT Staffing Company in the US About Artech Information Systems LLC Artech is an employer-of-choice for over 5,500 consultants across the globe. We recruit world-class talent for over 55 Fortune 500 companies coast-to-coast across the US, India, China and Mexico. We are one of the fastest-growing companies in the US, and this may be your opportunity to join us! Want to read more about Artech? Click here to visit our website or click on the following links to read what others are saying about us: Better Business Bureau, Hoovers, The Wall Street Journal, Inc., Entrepreneur, eWeek, NMSDC, dBusiness News, Diversity Careers, The Artech Circle, NJTVOnline Email secured by Check Point image/pngimage/jpeg-- http://mail.python.org/mailman/listinfo/python-list
Re: using subprocess.Popen does not suppress terminal window on Windows
Thanks for answer, but that's not helping. I'm making a little embedded system programming IDE so I need to run .exe(windows only), make commands, perl python scripts etc(multiplatform). I'm using subprocess.Popen for all of them and it works fine except that blank console window and btw it pop's out under linux too. Maybe the problem is that original python script has .pyw extension, so it hides his own console, but I don't need thatone too. P.S. If it makes a diffrence I'm using wxPython 2.9. Python 2.7.2. -- http://mail.python.org/mailman/listinfo/python-list
Re: submit jobs on multi-core
On 13/09/12 03:59, Jason Friedman wrote: Or if Python 3.2 is an option, the concurrent.futures module would be very well suited for this task. Also available as an external download for Python 2.* ... http://pypi.python.org/pypi/futures/ Matěj -- http://mail.python.org/mailman/listinfo/python-list
Re: avoid the redefinition of a function
MRAB wrote: On 12/09/2012 19:04, Alister wrote: On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: For example: def install_java(): pass def install_tomcat(): pass Thanks for the answers. I decided to use numbers in the name of the functions to facilitate function calls. Now if you have this menu option for instance: (5) install mc You can type just 5 as user input and step_5() is called automatically. If I use descriptive names like install_java() then selecting a menu point would be more difficult. And I don't want users to type java, I want to stick to simple numbers. Laszlo No No NO! you cant just pass user input to system calls without validating it first (google sql injection for examples of the damage unsanitised input can cause, it is not just as SQL problem) it is just as easy so select a reasonably named function as a bad one option=raw_input('select your option :') if option ==1: install_java() if option ==2: install_other() alternatively you cold add your functions into a dictionary an call them from that opts={'1':install java,'2':install_other} option=raw_input('select your option :') opts[option] Poorly named functions are a major example of poor programming style. one of the fundamental pillars for python is readability! Or you could do this: def install_java(): Install Java print Installing Java def install_tomcat(): Install Tomcat print Installing Tomcat menu = [install_java, install_tomcat] for index, func in enumerate(menu, start=1): print {0}) {1}.format(index, func.__doc__) option = raw_input(Select your option : ) try: opt = int(option) except ValueError: print Not a valid option else: if 1 = opt len(menu): menu[opt - 1]() else: print Not a valid option I'd still argue that a function index is the wrong approach. You can use tab completion to make entering descriptive names more convenient: import cmd class Cmd(cmd.Cmd): prompt = Enter a command (? for help): def do_EOF(self, args): return True def do_quit(self, args): return True @classmethod def install_command(class_, f): def wrapped(self, arg): if arg: print Discarding argument {!r}.format(arg) return f() wrapped.__doc__ = f.__doc__ wrapped.__name__ = f.__name__ class_._add_method(do_ + f.__name__, wrapped) return f @classmethod def _add_method(class_, methodname, method): if hasattr(class_, methodname): raise ValueError(Duplicate command {!r}.format(methodname)) setattr(class_, methodname, method) command = Cmd.install_command @command def install_java(): Install Java print Installing Java @command def install_tomcat(): Install Tomcat print Installing Tomcat if __name__ == __main__: Cmd().cmdloop() -- http://mail.python.org/mailman/listinfo/python-list
python2.7 lack necessary bit to build module
I'm in ubuntu10.04 and I decide to compile python2.7 from source myself to build a GAE app.As a result,when I done with make command,it comes out with the following warning: Python build finished, but the necessary bits to build these modules were not found: _bsddb _sqlite3 _tkinter_ssl bsddb185 dbmgdbm sunaudiodev I ignore them and continue with make install.However when I run my GAE app,it comes out with no module named _ssl and _sqlite3. I figure out _ssl problem by compile ssl myself and add --with-ssl option in configure. I want to fix all this and install all of the package which annoys me. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: using subprocess.Popen does not suppress terminal window on Windows
On Thu, 13 Sep 2012 00:27:10 -0700 (PDT), janis.judvai...@gmail.com wrote: I'm making a little embedded system programming IDE so I need to run .exe(windows only), make commands, perl python scripts etc(multiplatform). I'm using subprocess.Popen for all of them and it works fine except that blank console window and btw it pop's out under linux too. Maybe the problem is that original python script has .pyw extension, so it hides his own console, but I don't need thatone too. P.S. If it makes a diffrence I'm using wxPython 2.9. Python 2.7.2. Perhaps wxPython is causing the problem. Does the 'terminal' look like a normal terminal? Does it only appear if you actually print something? Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: using subprocess.Popen does not suppress terminal window on Windows
On 13 September 2012 10:22, Oscar Benjamin oscar.j.benja...@gmail.comwrote: On Thu, 13 Sep 2012 00:27:10 -0700 (PDT), janis.judvai...@gmail.com wrote: I'm making a little embedded system programming IDE so I need to run .exe(windows only), make commands, perl python scripts etc(multiplatform). I'm using subprocess.Popen for all of them and it works fine except that blank console window and btw it pop's out under linux too. Maybe the problem is that original python script has .pyw extension, so it hides his own console, but I don't need thatone too. P.S. If it makes a diffrence I'm using wxPython 2.9. Python 2.7.2. Perhaps wxPython is causing the problem. Does the 'terminal' look like a normal terminal? Does it only appear if you actually print something? Are you using app = wx.App(redirect=False) to prevent wxPython from redirecting stdout/stderr into special wxPython output windows? Oscar -- http://mail.python.org/mailman/listinfo/python-list
equiv of perl regexp grammar?
I noticed this and thought it looked interesting: http://search.cpan.org/~dconway/Regexp- Grammars-1.021/lib/Regexp/Grammars.pm#DESCRIPTION I'm wondering if python has something equivalent? -- http://mail.python.org/mailman/listinfo/python-list
Re: python2.7 lack necessary bit to build module
On Thursday, 13 September 2012 14:17:29 UTC+5:30, 钟驰宇 wrote: I'm in ubuntu10.04 and I decide to compile python2.7 from source myself to build a GAE app.As a result,when I done with make command,it comes out with the following warning: Python build finished, but the necessary bits to build these modules were not found: _bsddb _sqlite3 _tkinter_ssl bsddb185 dbmgdbm sunaudiodev I ignore them and continue with make install.However when I run my GAE app,it comes out with no module named _ssl and _sqlite3. I figure out _ssl problem by compile ssl myself and add --with-ssl option in configure. I want to fix all this and install all of the package which annoys me. Thanks! You need to the install the development packages for the libraries required by the modules. They end with -dev. -- http://mail.python.org/mailman/listinfo/python-list
Re: python2.7 lack necessary bit to build module
Am 13.09.2012 10:47, schrieb 钟驰宇: I'm in ubuntu10.04 and I decide to compile python2.7 from source [...] However when I run my GAE app,it comes out with no module named _ssl and _sqlite3. There are Debian-specific ways to ease this task that should work in Ubuntu, too. First is apt-get build-dep, which will install all libraries that are needed to build Python as it was built by the distributor. The second is apt-get source and more specifically the file debian/rules within the unpacked sources then, which contains the command line that is used to configure the according package. Note that using dpkg-buildpackage you could even build customized Debian packages, in case you want to replace the system Python. Uli -- http://mail.python.org/mailman/listinfo/python-list
Re: using subprocess.Popen does not suppress terminal window on Windows
It looks like normal terminal to me, could You define normal? Looks like it appears only when target script prints something, but it shouldn't cus I'm using pipes on stdout and stderr. If anyone is interested I'm using function doPopen from here: http://code.google.com/p/mansos/source/browse/trunk/tools/IDE/src/helperFunctions.py -- http://mail.python.org/mailman/listinfo/python-list
Python2.4 on Win32 suddenly started crashing last night
I'm not sure if this is some Win32 update that was silently applied by our netadmin, but when I simply import socket at the command line, it's crashing (with the Do you want to send this information to Microsoft debug/crash dialog). It was working as of last night, and to the best of my knowledge, nothing was changed on the system. It took a while to track it down, but it came from importing smtplib which in turn imports socket. I've tried import socket and it crashes, but then tried importing each of the modules that are imported in socket.py and nothing dies: C:\Program Files\Python24\Libpython Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import _socket from _socket import * import _ssl from _ssl import * import os, sys from errno import EBADF sys.platform 'win32' import socket [win32 crash happens here] Does anybody have any hints? I'm unfortunately somewhat bound to 2.4 due to some external binary libraries that we're tied to. Thanks, -tkc -- http://mail.python.org/mailman/listinfo/python-list
main and dependent objects
I am in a situation where I have a class Obj which contains many attributes, and also contains logically another object of class Dependent. This dependent_object, however, also needs to access many fields of the original class, so at the moment we did something like this: class Dependent: def __init__(self, orig): self.orig = orig def using_other_attributes(self): print(Using attr1, self.orig.attr1) class Obj: def __init__(self): self.attr1 = attr1 self.attr2 = attr2 self.attr3 = attr3 self.dependent_object = Dependent(self) But I'm not so sure it's a good idea, it's a bit smelly.. Any other suggestion about how to get a similar result? I could of course passing all the arguments needed to the constructor of Dependent, but it's a bit tedious.. Thanks, Andrea -- http://mail.python.org/mailman/listinfo/python-list
Re: Some questions about atexit
In article mailman.587.1347503376.27098.python-l...@python.org, Terry Reedy tjre...@udel.edu wrote: On 9/12/2012 8:58 PM, Roy Smith wrote: The atexit docs (http://docs.python.org/library/atexit.html) are very confusing. In one place they say, The order in which the functions are called is not defined. In another place, all functions registered are called in last in, first out order. Which is correct? Check the tracker (bugs.python.org) for atexit issues, open and closed. Thanks for the pointer. The operative one seems to be http://bugs.python.org/issue15233 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python2.4 on Win32 suddenly started crashing last night
On 09/13/12 07:42, Tim Chase wrote: It was working as of last night, and to the best of my knowledge, nothing was changed on the system. It took a while to track it down, but it came from importing smtplib which in turn imports socket. I've tried import socket and it crashes, but then tried importing each of the modules that are imported in socket.py and nothing dies: C:\Program Files\Python24\Libpython Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import _socket from _socket import * import _ssl from _ssl import * import os, sys from errno import EBADF sys.platform 'win32' import socket [win32 crash happens here] Further diagnostics (copying socket.py to suckit.py and adding a sys.exit(1) at various points and then importing sucket) seem to point to this line in socket.py: __all__.extend(os._get_exports_list(_socket)) So I can reduce the case to import _socket import os os._get_exports_list(_socket) and it goes kablooie. If I do the same with _ssl: import _ssl import os os._get_exports_list(_ssl) and it works fine. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python2.4 on Win32 suddenly started crashing last night
On 13/09/2012 13:42, Tim Chase wrote: I'm not sure if this is some Win32 update that was silently applied by our netadmin, but when I simply import socket at the command line, it's crashing (with the Do you want to send this information to Microsoft debug/crash dialog). It was working as of last night, and to the best of my knowledge, nothing was changed on the system. It took a while to track it down, but it came from importing smtplib which in turn imports socket. I've tried import socket and it crashes, but then tried importing each of the modules that are imported in socket.py and nothing dies: C:\Program Files\Python24\Libpython Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. import _socket from _socket import * import _ssl from _ssl import * import os, sys from errno import EBADF sys.platform 'win32' import socket [win32 crash happens here] Does anybody have any hints? I'm unfortunately somewhat bound to 2.4 due to some external binary libraries that we're tied to. I've just downloaded, installed and tested Python 2.4.4. No crash. This is with Windows XP Pro (32-bit). -- http://mail.python.org/mailman/listinfo/python-list
Re: main and dependent objects
- Original Message - I am in a situation where I have a class Obj which contains many attributes, and also contains logically another object of class Dependent. This dependent_object, however, also needs to access many fields of the original class, so at the moment we did something like this: class Dependent: def __init__(self, orig): self.orig = orig def using_other_attributes(self): print(Using attr1, self.orig.attr1) class Obj: def __init__(self): self.attr1 = attr1 self.attr2 = attr2 self.attr3 = attr3 self.dependent_object = Dependent(self) But I'm not so sure it's a good idea, it's a bit smelly.. Any other suggestion about how to get a similar result? I could of course passing all the arguments needed to the constructor of Dependent, but it's a bit tedious.. Thanks, Andrea -- http://mail.python.org/mailman/listinfo/python-list Nothing shocking right here imo. It looks like a classic parent-child implementation. However it seems the relation between Obj and Dependent are 1-to-1. Since Dependent need to access all Obj attributes, are you sure that Dependent and Obj are not actually the same class ? JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Python2.4 on Win32 suddenly started crashing last night
On 09/13/12 08:12, MRAB wrote: I've just downloaded, installed and tested Python 2.4.4. No crash. This is with Windows XP Pro (32-bit). Could I get the MD5 of your $PYTHONDIR\DLLs\_socket.pyd to see if it matches mine? data = file('_socket.pyd', 'rb').read() import md5 md5.md5(data).hexdigest() '7a7fc2d9e9df65690658c989bd9e95bb' It's looking like it might be a corrupt DLL or something to which it links is causing issues. Alternatively, it might be possible to find/download the 2.4.3 _socket.pyd, or possibly overwrite it with a 2.4.4 _socket.pyd (I don't know how backwards compatible the ABI is for binary modules) Thanks! -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python2.4 on Win32 suddenly started crashing last night
On 2012-09-13 14:35, Tim Chase wrote: On 09/13/12 08:12, MRAB wrote: I've just downloaded, installed and tested Python 2.4.4. No crash. This is with Windows XP Pro (32-bit). Could I get the MD5 of your $PYTHONDIR\DLLs\_socket.pyd to see if it matches mine? data = file('_socket.pyd', 'rb').read() import md5 md5.md5(data).hexdigest() '7a7fc2d9e9df65690658c989bd9e95bb' It's looking like it might be a corrupt DLL or something to which it links is causing issues. Alternatively, it might be possible to find/download the 2.4.3 _socket.pyd, or possibly overwrite it with a 2.4.4 _socket.pyd (I don't know how backwards compatible the ABI is for binary modules) I get this: Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. data = file(r'C:\Python24\DLLs\_socket.pyd', 'rb').read() import md5 md5.md5(data).hexdigest() '166f1020fedc254d6f25ccee0994caff' -- http://mail.python.org/mailman/listinfo/python-list
Re: [SOLVED] Python2.4 on Win32 suddenly started crashing last night
On 09/13/12 08:51, MRAB wrote: I get this: Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. data = file(r'C:\Python24\DLLs\_socket.pyd', 'rb').read() import md5 md5.md5(data).hexdigest() '166f1020fedc254d6f25ccee0994caff' Thanks for taking the time to hammer on this. I archived off my binary module from the site-packages directory, uninstalled 2.4.3, reinstalled using 2.4.4 and copied back in the item to the site-packages directory, and everything is working now. I can only attribute it to bitrot, sun-spots, or some such oddity. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: main and dependent objects
2012/9/13 Jean-Michel Pichavant jeanmic...@sequans.com: Nothing shocking right here imo. It looks like a classic parent-child implementation. However it seems the relation between Obj and Dependent are 1-to-1. Since Dependent need to access all Obj attributes, are you sure that Dependent and Obj are not actually the same class ? JM Yes well the main class is already big enough, and the relation is 1-1 but the dependent class can be also considered separate to split things more nicely.. So I think it will stay like this for now and see how it goes. -- http://mail.python.org/mailman/listinfo/python-list
Guides for communicating with business accounting systems
Howdy all, What material should a team of programmers read before designing a database model and export format for sending commerce transactions to a business accounting system? I'm especially not wanting ad hoc advice in this thread; this is surely an old, complex problem with a lot of ground already covered. Primers on pitfalls to avoid and non-obvious best practices are what I'd like to be directed toward. Constraints: * The shop is already written, and is maintained internally. Ideally we would use a widely-tested and third-party-maintained solution, but that's a struggle still ahead of us. For now, we must work with our private code base. * None of the developer team are have much experience with the field of business accounting, so if possible we need to learn from the past design mistakes of others without making them ourselves. * Our application is operating in Australia, with the sales tax tracking requirements that come with that. Australia-specific information is particularly desirable. * The business has switched to a different accounting service recently; it may well change again soon. We want to at least consider robustness of our shop's transaction tracking design in the face of a possible future switch to a different accounting system. I'm happy to asnwer questions, but I'm not about to hash out the design in this thread; that's our development team's job. What I want is pointers to a putative “What every programmer needs to know about storing commercial transactions for business accounting” general guide. Does that information already exist where I can point our team to it? -- \ “I went to a general store. They wouldn't let me buy anything | `\ specifically.” —Steven Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
SciPy for Python 2.6?
Is there a version for SciPy/numpy available for Python 2.6? I could only find a version for 2.7 on the SciPy site. A search on the Scipy mailing list archive did not turn up anything. The link to the Scipy-user list signup appeared to be broken. -- http://mail.python.org/mailman/listinfo/python-list
Re: main and dependent objects
Am 13.09.2012 14:51, schrieb andrea crotti: I am in a situation where I have a class Obj which contains many attributes, and also contains logically another object of class Dependent. This dependent_object, however, also needs to access many fields of the original class, so at the moment we did something like this: [...] I could of course passing all the arguments needed to the constructor of Dependent, but it's a bit tedious.. Jean-Michel already asked a good question, i.e. whether those two classes should be separate at all. I'll ask a similar question: Can't the shared data be put into a third, separate class? That way passing all the needed arguments wouldn't be tedious any more. Also, it makes clear that both outer and inner class depend on common data, but that the inner class doesn't depend on the outer beyond that. Now, just to get at least something Python-specific into this, you could override the __getitem__ of the inner class and transparently look up the item in the outer class if the inner class doesn't have it. Uli -- http://mail.python.org/mailman/listinfo/python-list
subprocess call is not waiting.
I have a subprocess.call which tries to download a data from a remote server using HTAR. I put the call in a while loop, which tests to see if the download was successful, and if not, loops back around up to five times, just in case my internet connection has a hiccup. Subprocess.call is supposed to wait. But it doesn't work as intended. The loop quickly runs 5 times, starting a new htar command each time. After five times around, my program tells me my download failed, because the target file doesn't yet exist. But it turns out that the download is still happening---five times. When I run htar from the shell, I don't get a shell prompt again until after the download is complete. How come control is returned to python before the htar command is through? I've tried using Popen with wait and/or communicate, but no waiting ever happens. This is troublesome not only because I don't get to post process my data, but because when I run this script for multiple datasets (checking to see whether I have local copies), I quickly get a Too many open files error. (I began working on that by trying to use Popopen with fds_close, etc.) Should I just go back to os.system? -- http://mail.python.org/mailman/listinfo/python-list
Re: main and dependent objects
- Original Message - 2012/9/13 Jean-Michel Pichavant jeanmic...@sequans.com: Nothing shocking right here imo. It looks like a classic parent-child implementation. However it seems the relation between Obj and Dependent are 1-to-1. Since Dependent need to access all Obj attributes, are you sure that Dependent and Obj are not actually the same class ? JM Yes well the main class is already big enough, and the relation is 1-1 but the dependent class can be also considered separate to split things more nicely.. So I think it will stay like this for now and see how it goes. Difficult to say given the meaningless names you provided. Just in case, you can still split things nicely in 2 classes and still get Dependent to be the same thing than Obj : by inheritance. It is a common way to extend one class's features. class Obj class Dependent(Obj) But do it only if Dependent **is** actually an Obj. If Dependent not an Obj but part of an Obj, then your original implementation is probably the way to go. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: SciPy for Python 2.6?
On 2012-09-13 16:04, garyr wrote: Is there a version for SciPy/numpy available for Python 2.6? I could only find a version for 2.7 on the SciPy site. A search on the Scipy mailing list archive did not turn up anything. The link to the Scipy-user list signup appeared to be broken. There's numpy 1.6.2 here: http://pypi.python.org/pypi/numpy -- http://mail.python.org/mailman/listinfo/python-list
Re: Guides for communicating with business accounting systems
On Fri, Sep 14, 2012 at 1:02 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: What I want is pointers to a putative “What every programmer needs to know about storing commercial transactions for business accounting” general guide. Does that information already exist where I can point our team to it? Not a guide per se, but a keyword to look for: ACID compliance. You'll be maintaining multiple pieces of information that depend on each other (simple example being a ledger table showing transactions and an accounts table holding balances), and you need to guarantee that the database is consistent. Log aggressively. I'm sure nobody would ever dream of maintaining customer balances without an associated ledger showing how that balance came to be; it's less obvious but just as helpful in many other areas. If anything happens to corrupt your data, you should be able to recognize from internal evidence that something's wrong. GST isn't particularly complicated, but again, be really REALLY clear what's going on. It's better to be massively verbose in the database and then squash things down for display than to be left wondering, when you trace back through things, what money went where. Be aware of your ninths/elevenths; when there's 10% tax in a $10 item, the ex tax price is $9.090909... which will annoy everyone with 1c errors. Don't use MySQL. :) Okay, that's hardly a *rule*, but it's a strong recommendation. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
- Original Message - I have a subprocess.call which tries to download a data from a remote server using HTAR. I put the call in a while loop, which tests to see if the download was successful, and if not, loops back around up to five times, just in case my internet connection has a hiccup. Subprocess.call is supposed to wait. But it doesn't work as intended. The loop quickly runs 5 times, starting a new htar command each time. After five times around, my program tells me my download failed, because the target file doesn't yet exist. But it turns out that the download is still happening---five times. When I run htar from the shell, I don't get a shell prompt again until after the download is complete. How come control is returned to python before the htar command is through? I've tried using Popen with wait and/or communicate, but no waiting ever happens. This is troublesome not only because I don't get to post process my data, but because when I run this script for multiple datasets (checking to see whether I have local copies), I quickly get a Too many open files error. (I began working on that by trying to use Popopen with fds_close, etc.) Should I just go back to os.system? -- http://mail.python.org/mailman/listinfo/python-list A related subset of code would be useful. You can use subprocess.PIPE to redirect stdout stderr et get them with communicate, something like: proc = subprocess.Popen(['whatever'], stdout=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = proc.communicate() print stdout print stderr Just by looking at stdout and stderr, you should be able to see why htar is returning so fast. JM PS : if you see nothing wrong, is it possible that htar runs asynchronously ? -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
On 2012-09-13 16:17, paulsta...@gmail.com wrote: I have a subprocess.call which tries to download a data from a remote server using HTAR. I put the call in a while loop, which tests to see if the download was successful, and if not, loops back around up to five times, just in case my internet connection has a hiccup. Subprocess.call is supposed to wait. But it doesn't work as intended. The loop quickly runs 5 times, starting a new htar command each time. After five times around, my program tells me my download failed, because the target file doesn't yet exist. But it turns out that the download is still happening---five times. When I run htar from the shell, I don't get a shell prompt again until after the download is complete. How come control is returned to python before the htar command is through? I've tried using Popen with wait and/or communicate, but no waiting ever happens. This is troublesome not only because I don't get to post process my data, but because when I run this script for multiple datasets (checking to see whether I have local copies), I quickly get a Too many open files error. (I began working on that by trying to use Popopen with fds_close, etc.) Should I just go back to os.system? Which OS? Is there some documentation somewhere? -- http://mail.python.org/mailman/listinfo/python-list
datetime
How do I set the time in Python? Also, is there any *direct* way to shift it? Say, it's 09:00 now and Python makes it 11:30 *without* me having specified 11:30 but only given Python the 2h30m interval. Note that any indirect methods may need complicated ways to keep track of the milliseconds lost while running them. It even took around one second in some virtual machine guest systems. So I'm hoping Python happens to have the magic needed to do the job for me. -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
On Fri, Sep 14, 2012 at 1:19 AM, Max read...@hushmail.com wrote: Say, it's 09:00 now and Python makes it 11:30 *without* me having specified 11:30 but only given Python the 2h30m interval. Could you cheat and change the timezone offset? :D ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
On 2012-09-13 16:34, Jean-Michel Pichavant wrote: - Original Message - I have a subprocess.call which tries to download a data from a remote server using HTAR. I put the call in a while loop, which tests to see if the download was successful, and if not, loops back around up to five times, just in case my internet connection has a hiccup. Subprocess.call is supposed to wait. But it doesn't work as intended. The loop quickly runs 5 times, starting a new htar command each time. After five times around, my program tells me my download failed, because the target file doesn't yet exist. But it turns out that the download is still happening---five times. When I run htar from the shell, I don't get a shell prompt again until after the download is complete. How come control is returned to python before the htar command is through? I've tried using Popen with wait and/or communicate, but no waiting ever happens. This is troublesome not only because I don't get to post process my data, but because when I run this script for multiple datasets (checking to see whether I have local copies), I quickly get a Too many open files error. (I began working on that by trying to use Popopen with fds_close, etc.) Should I just go back to os.system? -- http://mail.python.org/mailman/listinfo/python-list A related subset of code would be useful. You can use subprocess.PIPE to redirect stdout stderr et get them with communicate, something like: proc = subprocess.Popen(['whatever'], stdout=subprocess.PIPE, stdout=subprocess.PIPE) stdout, stderr = proc.communicate() print stdout print stderr Just by looking at stdout and stderr, you should be able to see why htar is returning so fast. JM PS : if you see nothing wrong, is it possible that htar runs asynchronously ? The OP says that it waits when run from the shell. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
In mailman.617.1347552022.27098.python-l...@python.org andrea crotti andrea.crott...@gmail.com writes: For my experience if I only see code in slides I tend not to believe that it works somehow Presumably you will have some credibility with your audience so they won't just assume you're making it up? I think slides would be fine. -- 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: Guides for communicating with business accounting systems
On 9/13/2012 8:02 AM Ben Finney said... Howdy all, What material should a team of programmers read before designing a database model and export format for sending commerce transactions to a business accounting system? The only standard I'm aware of is the EDI specification which I first encountered in the mid 70's and which is updated routinely. The full spec is the size of a telephone book (do they even still make those?) and both trading partners select from it the documents they intend to exchange. The back end integration is then left to both parties. If your data structure is sufficient to supply the content expected in the EDI specs for the documents you'd expect to exchange you should be OK on your database model. Unfortunately, the spec resembles the RS232 spec in that it leaves the details as an implementation issue to be settled between the two trading partners. Another problem is that the spec is privately (through an association) controlled and I've often had issues getting my hands on the proper documentation when I wasn't working with a trading partner. (I didn't want to pay the association fees to join and thereby gain access to the documentation directly.) There's a good overview at http://www.linktionary.com/e/edi.html HTH, Emile I'm especially not wanting ad hoc advice in this thread; this is surely an old, complex problem with a lot of ground already covered. Primers on pitfalls to avoid and non-obvious best practices are what I'd like to be directed toward. Constraints: * The shop is already written, and is maintained internally. Ideally we would use a widely-tested and third-party-maintained solution, but that's a struggle still ahead of us. For now, we must work with our private code base. * None of the developer team are have much experience with the field of business accounting, so if possible we need to learn from the past design mistakes of others without making them ourselves. * Our application is operating in Australia, with the sales tax tracking requirements that come with that. Australia-specific information is particularly desirable. * The business has switched to a different accounting service recently; it may well change again soon. We want to at least consider robustness of our shop's transaction tracking design in the face of a possible future switch to a different accounting system. I'm happy to asnwer questions, but I'm not about to hash out the design in this thread; that's our development team's job. What I want is pointers to a putative “What every programmer needs to know about storing commercial transactions for business accounting” general guide. Does that information already exist where I can point our team to it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
Am Thu, 13 Sep 2012 17:00:19 +0100 schrieb andrea crotti: I have to give a couple of Python presentations in the next weeks, and I'm still thinking what is the best approach. My idea for an introductory presentation of python was to prepare some code snippets (all valid python), show them in the editor, explain them, then run in a console. Beginners could then use these code snippets for their own experiments. HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
On Thu, Sep 13, 2012 at 9:19 AM, Max read...@hushmail.com wrote: How do I set the time in Python? On what platform? I don't know of any libraries for this, so it would be a matter of making the necessary system calls (which is all that a library would do anyway). Also, is there any *direct* way to shift it? Only by changing the timezone setting. Any method of offsetting the system clock itself is going to involve at some level reading the current value, adding or subtracting, and then setting the new value. Note that any indirect methods may need complicated ways to keep track of the milliseconds lost while running them. It even took around one second in some virtual machine guest systems. So I'm hoping Python happens to have the magic needed to do the job for me. If you're concerned about individual seconds, then you probably should do this in a low-level language like C. Also, the clock is going to drift naturally over time anyway. How are you going to keep it in sync if not with ntp? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
2012/9/13 William R. Wing (Bill Wing) w...@mac.com: [byte] Speaking from experience as both a presenter and an audience member, please be sure that anything you demo interactively you include in your slide deck (even if only as an addendum). I assume your audience will have access to the deck after your talk (on-line or via hand-outs), and you want them to be able to go home and try it out for themselves. Nothing is more frustrating than trying to duplicate something you saw a speaker do, and fail because of some detail you didn't notice at the time of the talk. A good example is one that was discussed on the matplotlib-users list several weeks ago: http://www.loria.fr/~rougier/teaching/matplotlib/ -Bill Yes that's a good point thanks, in general everything is already in a git repository, now only in my dropbox but later I will make it public. Even the code that I should write there should already written anyway, and to make sure everything is available I could use the save function of IPython and add it to the repository... In general I think that explaining code on a slide (if it involves some new concepts in particular) it's better, but then showing what it does it's always a plus. It's not the same if you say this will go 10x faster than the previous one, and showing that it actually does on your machine.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On Sep 13, 2012, at 12:00 PM, andrea crotti andrea.crott...@gmail.com wrote: I have to give a couple of Python presentations in the next weeks, and I'm still thinking what is the best approach. In one presentation for example I will present decorators and context managers, and my biggest doubt is how much I should show and explain in slides and how much in an interactive way (with ipython for example). [byte] Speaking from experience as both a presenter and an audience member, please be sure that anything you demo interactively you include in your slide deck (even if only as an addendum). I assume your audience will have access to the deck after your talk (on-line or via hand-outs), and you want them to be able to go home and try it out for themselves. Nothing is more frustrating than trying to duplicate something you saw a speaker do, and fail because of some detail you didn't notice at the time of the talk. A good example is one that was discussed on the matplotlib-users list several weeks ago: http://www.loria.fr/~rougier/teaching/matplotlib/ -Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
It possibly requires a shell=True, but without any code on any way to test, we can not say. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
- Original Message - I have to give a couple of Python presentations in the next weeks, and I'm still thinking what is the best approach. In one presentation for example I will present decorators and context managers, and my biggest doubt is how much I should show and explain in slides and how much in an interactive way (with ipython for example). For my experience if I only see code in slides I tend not to believe that it works somehow, but also only looking at someone typing can be hard to follow and understand what is going on.. So maybe I should do first slides and then interactive demo, or the other way around, showing first how everything works and then explaining the code with slides. What do you think work best in general? -- http://mail.python.org/mailman/listinfo/python-list I don't like decorators, I think they're not worth the mental effort. So if I were to intend to your presentation, I'd really like you to start demonstrating how decorators are life savers, or with less emphasis, how they can be worth the effort and make me regret all these years without decorators. Some features in python have this WoW! effect, try to trigger it in front of your audience, that should really help them focus on the subject and be interested in your presentation. Also try to keep the presentation interactive by asking questions to your audience (unless some of them are already participating), otherwise people will be snoring or texting after 20 minutes. I think the key for a presentation is to make people interested in the subject and make them realize they can benefit from what you're presenting. Everyone can then google 'python decorators' for the technical and boring details. I must add that I'm not en experienced presenter, so take my advices for what they're worth (hmm not sure about this grammatical construct :-/ ) JM -- http://mail.python.org/mailman/listinfo/python-list
Re: avoid the redefinition of a function
On Thu, 13 Sep 2012 10:23:22 +0200, Peter Otten wrote: MRAB wrote: On 12/09/2012 19:04, Alister wrote: On Wed, 12 Sep 2012 18:56:46 +0200, Jabba Laci wrote: For example: def install_java(): pass def install_tomcat(): pass Thanks for the answers. I decided to use numbers in the name of the functions to facilitate function calls. Now if you have this menu option for instance: (5) install mc You can type just 5 as user input and step_5() is called automatically. If I use descriptive names like install_java() then selecting a menu point would be more difficult. And I don't want users to type java, I want to stick to simple numbers. Laszlo No No NO! you cant just pass user input to system calls without validating it first (google sql injection for examples of the damage unsanitised input can cause, it is not just as SQL problem) it is just as easy so select a reasonably named function as a bad one option=raw_input('select your option :') if option ==1: install_java() if option ==2: install_other() alternatively you cold add your functions into a dictionary an call them from that opts={'1':install java,'2':install_other} option=raw_input('select your option :') opts[option] Poorly named functions are a major example of poor programming style. one of the fundamental pillars for python is readability! Or you could do this: def install_java(): Install Java print Installing Java def install_tomcat(): Install Tomcat print Installing Tomcat menu = [install_java, install_tomcat] for index, func in enumerate(menu, start=1): print {0}) {1}.format(index, func.__doc__) option = raw_input(Select your option : ) try: opt = int(option) except ValueError: print Not a valid option else: if 1 = opt len(menu): menu[opt - 1]() else: print Not a valid option I'd still argue that a function index is the wrong approach. You can use tab completion to make entering descriptive names more convenient: import cmd class Cmd(cmd.Cmd): prompt = Enter a command (? for help): def do_EOF(self, args): return True def do_quit(self, args): return True @classmethod def install_command(class_, f): def wrapped(self, arg): if arg: print Discarding argument {!r}.format(arg) return f() wrapped.__doc__ = f.__doc__ wrapped.__name__ = f.__name__ class_._add_method(do_ + f.__name__, wrapped) return f @classmethod def _add_method(class_, methodname, method): if hasattr(class_, methodname): raise ValueError(Duplicate command {!r}.format(methodname)) setattr(class_, methodname, method) command = Cmd.install_command @command def install_java(): Install Java print Installing Java @command def install_tomcat(): Install Tomcat print Installing Tomcat if __name__ == __main__: Cmd().cmdloop() To be honest I prefer the if X do Y approach for readability but a dictionary can be undated dynamically used to automatically create the menu so it can have its place -- I'll see you... on the dark side of the moon... -- Pink Floyd -- http://mail.python.org/mailman/listinfo/python-list
RE: How to print something only if it exists?
tinn...@isbd.co.uk wrote: I want to print a series of list elements some of which may not exist, e.g. I have a line:- print day, fld[1], balance, fld[2] fld[2] doesn't always exist (fld is the result of a split) so the print fails when it isn't set. I know I could simply use an if but ultimately there may be more elements of fld in the print and the print may well become more complex (most like will be formatted for example). Thus it would be good if there was some way to say print this if it exists. You can use an inline if-else statement. print day, fld[1], balance, fld[2] if len(fld) = 3 else '' Ramit -- 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: datetime
On 9/13/2012 11:19 AM, Max wrote: How do I set the time in Python? If you look up 'time' in the index of the current manual, it directs you to the time module. time.clock_settime(clk_id, time) Set the time of the specified clock clk_id. Availability: Unix. New in version 3.3. You did not specify *which* time to set, but ... time.CLOCK_REALTIME System-wide real-time clock. Setting this clock requires appropriate privileges. Availability: Unix. New in version 3.3. Chris already suggested an approach for changing your process's idea of time. However, setting time.timezone seems to have no effect Also, is there any *direct* way to shift it? If you mean time.clock_shift(clk_id, shift_seconds), no. time.clock_settime(clk_id, time.clock_gettime(clk_id) + delta_seconds) Note that any indirect methods may need complicated ways to keep track of the milliseconds lost while running them. Whay would a millisecond matter? System clocks are never synchronized to official UTC time that closely without special hardware to receive time broadcasts. It even took around one second in some virtual machine guest systems. So I'm hoping Python happens to have the magic needed to do the job for me. The above should be well under a second. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
Also try to keep the presentation interactive by asking questions to your audience (unless some of them are already participating), otherwise people will be snoring or texting after 20 minutes. That is a v good suggestion. the best presentation I ever attended was one on using an emergency life raft presented by a member of the local sailing club (I was a scuba diver at the time our club was lending them some pool time) The whole presentation consisted of a sequence of questions fired at the audience to get them to think the problem trough arrive at the correct sequence of events. Genius -- The best prophet of the future is the past. -- http://mail.python.org/mailman/listinfo/python-list
Batching HTTP requests with httplib (Python 2.7)
I'm writing a simple library that communicates with a web service and am wondering if there are any generally well regarded methods for batching HTTP requests? The problem with most web services is that they require a list of sequential commands to be executed in a certain order to complete a given task (or at least the one I am using does) so having to manually call each command is a bit of a pain. How would you go about the design of a library to interact with these services? Any help is greatly appreciated :). -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
Thanks, guys. MRAB-RedHat 6 64-bit, Python 2.6.5 JM-Here's the relevant stuff from my last try. I've also tried with subprocess.call. Just now I tried shell=True, but it made no difference. sticking a print(out) in there just prints a blank line in between each iteration. It's not until the 5 trials are finished that I am told: download failed, etc. from os.path import exists from subprocess import call from subprocess import Popen from shlex import split from time import sleep while (exists(file)==0) and (nTries 5): a = Popen(split('htar -xvf ' + htarArgs), stdout=PIPE, stderr=PIPE) (out,err) = a.communicate() if exists(file)==0: nTries += 1 sleep(0.5) if exists(file)==0: # now that the file should be moved print('download failed: ' + file) return 1 I've also tried using shell=True with popopen. -- http://mail.python.org/mailman/listinfo/python-list
Re: equiv of perl regexp grammar?
On Thu, Sep 13, 2012 at 7:30 AM, Neal Becker ndbeck...@gmail.com wrote: I noticed this and thought it looked interesting: http://search.cpan.org/~dconway/Regexp- Grammars-1.021/lib/Regexp/Grammars.pm#DESCRIPTION I'm wondering if python has something equivalent? If you mean regex, it's import re. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: equiv of perl regexp grammar?
On Thu, Sep 13, 2012 at 5:30 AM, Neal Becker ndbeck...@gmail.com wrote: I noticed this and thought it looked interesting: http://search.cpan.org/~dconway/Regexp- Grammars-1.021/lib/Regexp/Grammars.pm#DESCRIPTION I'm wondering if python has something equivalent? The pyparsing module is a good option for building grammar parsers. There's nothing that I know of that tries to slot them into regular expressions like that. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
mblume於 2012年9月14日星期五UTC+8上午12時26分17秒寫道: Am Thu, 13 Sep 2012 17:00:19 +0100 schrieb andrea crotti: I have to give a couple of Python presentations in the next weeks, and I'm still thinking what is the best approach. My idea for an introductory presentation of python was to prepare some code snippets (all valid python), show them in the editor, explain them, then run in a console. Beginners could then use these code snippets for their own experiments. HTH Martin I'll contribute one point in Python. def powerlist(x, n): # n is a natural number result=[] y=1 for i in xrange(n): result.append(y) y*=x return result # any object in the local function can be returned -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
Terry Reedy tjreedy at udel.edu writes: You did not specify *which* time to set, but ... If you mean time.clock_shift(clk_id, shift_seconds), no. time.clock_settime(clk_id, time.clock_gettime(clk_id) + delta_seconds) I am talking about the system-wide clock on Debian. What should I use as clk_id? BTW, if by version 3.3 you mean python 3, I am only using 2.x. -- http://mail.python.org/mailman/listinfo/python-list
RE: Comparing strings from the back?
Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. Ramit -- 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: Comparing strings from the back?
On Thu, Sep 13, 2012 at 2:39 PM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. Ramit Why don't you read the OP: Let's assume you're testing two strings for equality. You've already done the obvious quick tests (i.e they're the same length), and you're down to the O(n) part of comparing every character. I'm wondering if it might be faster to start at the ends of the strings instead of at the beginning? If the strings are indeed equal, it's the same amount of work starting from either end. But, if it turns out that for real-life situations, the ends of strings have more entropy than the beginnings, the odds are you'll discover that they're unequal quicker by starting at the end. and this one from me: First include len(string)/2, in order to include starting at the center of the string, and threading/weaving by 2 processes out. import timeit do the the rest, and see which has the fastest time. -- Why don't take the time to read the OP, and ramit in your head? Remember that you're in the middle of a conversation where the OP is following as it goes along, so anyone reading the entire set of postings should get it. But for people who just want to jump in, and assume that the only thing that matters is one piece, without reading the entire content of the conversation, will always have something out of context for them. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 13/09/2012 19:39, Prasad, Ramit wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. Ramit You're wasting your time, I've been described as a jackass for having the audacity to ask for context :) -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter bug in Entry widgets on OS X
In article k1qhgn$me0$1...@dont-email.me, Kevin Walzer k...@codebykevin.com wrote: On 8/31/12 6:18 AM, Arnaud Delobelle wrote: I'm very inexperienced with Tkinter (I've never used it before). All I'm looking for is a workaround, i.e. a way to somehow suppress that output. What are you trying to do? Navigate the focus to another widget? You should use the tab bar for that, not the arrow key. The entry widget is a single-line widget, and doesn't have up/down as the text widget does. Based on other replies it looks as if the OP found a way to intercept the event with suitable binding. But I can answer the why: on Mac OS X in a one-line text box up-arrow should move the cursor to the beginning and down-arrow to the end. That's standard behavior. In any case I can't imagine ever wanting to see special chars get added when arrow keys are pressed. The default behavior of the Entry widget is unfortunate. -- Russell -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 13 September 2012 20:53, Mark Lawrence breamore...@yahoo.co.uk wrote: On 13/09/2012 19:39, Prasad, Ramit wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. You're wasting your time, I've been described as a jackass for having the audacity to ask for context :) I'm pretty sure you are in the wrong, acting as if what he said didn't make sense! Just read it, he obviously was telling you to time it, as eit lops are inside thmax input/ which, as you should know if you *bothered to read the thread*, is incrementing. don' is short for don't, by the way. -- http://mail.python.org/mailman/listinfo/python-list
Re: using subprocess.Popen does not suppress terminal window on Windows
On 13 September 2012 13:33, janis.judvai...@gmail.com wrote: It looks like normal terminal to me, could You define normal? Looks like it appears only when target script prints something, but it shouldn't cus I'm using pipes on stdout and stderr. If anyone is interested I'm using function doPopen from here: http://code.google.com/p/mansos/source/browse/trunk/tools/IDE/src/helperFunctions.py -- http://mail.python.org/mailman/listinfo/python-list I asked about the terminal window since you mentioned that it pops up under linux which would suggest you're not having the usual Windows console/gui problem. In any case, have you tried this: http://code.activestate.com/recipes/409002-launching-a-subprocess-without-a-console-window/ Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Thu, Sep 13, 2012 at 4:34 PM, Joshua Landau joshua.landau...@gmail.com wrote: On 13 September 2012 20:53, Mark Lawrence breamore...@yahoo.co.uk wrote: On 13/09/2012 19:39, Prasad, Ramit wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. You're wasting your time, I've been described as a jackass for having the audacity to ask for context :) I'm pretty sure you are in the wrong, acting as if what he said didn't make sense! Just read it, he obviously was telling you to time it, as eit lops are inside thmax input/ which, as you should know if you bothered to read the thread, is incrementing. don' is short for don't, by the way. -- http://mail.python.org/mailman/listinfo/python-list It's the fact that I consider the entire conversation the context. Reading the OP's being the primary, and things they responded positively to. There are other things that get mixed up as well, like not hitting the ... in gmail, and so that content doesn't show, or hitting reply, instead of reply all, and things getting jumbled for the others involved in the conversation. Then there is the problem of people saying you posted too much of the context, or not inline with the OP, just at the end, or top posting. I try to keep it along the line of what the OP has read, and they know the context in which it's meant. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On 13/09/2012 21:34, Joshua Landau wrote: On 13 September 2012 20:53, Mark Lawrence breamore...@yahoo.co.uk wrote: On 13/09/2012 19:39, Prasad, Ramit wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. You're wasting your time, I've been described as a jackass for having the audacity to ask for context :) I'm pretty sure you are in the wrong, acting as if what he said didn't make sense! Just read it, he obviously was telling you to time it, as eit lops are inside thmax input/ which, as you should know if you *bothered to read the thread*, is incrementing. don' is short for don't, by the way. I do grovellingly apologize for my appalling breach of netiquette. I am of course assuming that the rules have changed and that it's now my responsibility to wade back through maybe a couple of hundred responses on a long thread to find the context. I also guess that I'm never going to achieve my ambition of being a pot smoking hippy CEO of a web development company :( -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Least-lossy string.encode to us-ascii?
I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible, just stripping accents, cedillas, tildes, etc. So serviço móvil becomes servico movil. Is there anything stock that I've missed? I can do mystring.encode('us-ascii', 'replace') but that doesn't keep as much information as I'd hope. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Thu, Sep 13, 2012 at 5:17 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 13/09/2012 21:34, Joshua Landau wrote: On 13 September 2012 20:53, Mark Lawrence breamore...@yahoo.co.uk wrote:acci sequence On 13/09/2012 19:39, Prasad, Ramit wrote: Dwight Hutto wrote: Why don' you just time it,eit lops through incrementing thmax input/ What? Without context I have no idea what this means. You're wasting your time, I've been described as a jackass for having the audacity to ask for context :) I'm pretty sure you are in the wrong, acting as if what he said didn't make sense! Just read it, he obviously was telling you to time it, as eit lops are inside thmax input/ which, as you should know if you *bothered to read the thread*, is incrementing. don' is short for don't, by the way. I do grovellingly apologize for my appalling breach of netiquette. I am of course assuming that the rules have changed and that it's now my responsibility to wade back through maybe a couple of hundred responses on a long thread to find the context. I also guess that I'm never going to achieve my ambition of being a pot smoking hippy CEO of a web development company :( -- Cheers. Cheers usually implies you're an alcoholic pressing buttons, with the half of rest of the coders on the net. So don't give up hope, you might be able to take a medication that doesn't impair your judgement with the side effects alcohol has, And of course leaves you without the ability to read any of the responses to say you were right in certain instances, so something must be wrong with your mail reader, or your alcoholic mind. Also, without reading the other posts, you're probably just placing in a duplicate answer sometimes, which might make you seem like a copy cat. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
2012/9/13 Tim Chase python.l...@tim.thechases.com: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible, just stripping accents, cedillas, tildes, etc. So serviço móvil becomes servico movil. Is there anything stock that I've missed? I can do mystring.encode('us-ascii', 'replace') but that doesn't keep as much information as I'd hope. -tkc Hi, would something like the following be enough for your needs? Unfortunately, I can't check it reliably with regard to Portuguese. import unicodedata unicodedata.normalize(NFD, userviço móvil).encode(ascii, ignore).decode(ascii) u'servico movil' There is also Unidecode, but I haven't used it myself sofar... http://pypi.python.org/pypi/Unidecode/ hth, vbr -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
Am 13.09.2012 23:26, schrieb Tim Chase: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible, just stripping accents, cedillas, tildes, etc. So serviço móvil becomes servico movil. Is there anything stock that I've missed? I can do mystring.encode('us-ascii', 'replace') but that doesn't keep as much information as I'd hope. The unidecode [1] package contains a large mapping of unicode chars to ASCII. It even supports cool stuff like Chinese to ASCII: import unidecode print u\u5317\u4EB0 北亰 print unidecode.unidecode(u\u5317\u4EB0) Bei Jing icu4c and pyicu [2] may contain more methods for conversion but they require binary extensions. By the way ICU can do a lot of cool, too: import icu rbf = icu.RuleBasedNumberFormat(icu.URBNFRuleSetTag.SPELLOUT, icu.Locale.getUS()) rbf.format(23) u'twenty-three' rbf.format(10) u'one hundred thousand' Regards, Christian [1] http://pypi.python.org/pypi/Unidecode/0.04.9 [2] http://pypi.python.org/pypi/PyICU/1.4 -- http://mail.python.org/mailman/listinfo/python-list
Re: [SOLVED] Least-lossy string.encode to us-ascii?
On 09/13/12 16:44, Vlastimil Brom wrote: import unicodedata unicodedata.normalize(NFD, userviço móvil).encode(ascii, ignore).decode(ascii) u'servico movil' Works well for all the test-cases I threw at it. Thanks! -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On 13.09.2012 21:01, 8 Dihedral wrote: def powerlist(x, n): # n is a natural number result=[] y=1 for i in xrange(n): result.append(y) y*=x return result # any object in the local function can be returned def powerlist(x, n): result=[1] for i in xrange(n-1): result.append(result[-1]*x) return result def powerlist(x,n): if n==1: return [1] p = powerlist(x,n-1) return p + [p[-1]*x] -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
[sorry for the direct reply, Tim] Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible, just stripping accents, cedillas, tildes, etc. So serviço móvil becomes servico movil. Is there anything stock that I've missed? I can do mystring.encode('us-ascii', 'replace') but that doesn't keep as much information as I'd hope. I haven't yet used it myself, but I've heard good things about http://pypi.python.org/pypi/Unidecode/ ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On Fri, Sep 14, 2012 at 8:33 AM, Alexander Blinne n...@blinne.net wrote: On 13.09.2012 21:01, 8 Dihedral wrote: def powerlist(x, n): # n is a natural number result=[] y=1 for i in xrange(n): result.append(y) y*=x return result # any object in the local function can be returned def powerlist(x, n): result=[1] for i in xrange(n-1): result.append(result[-1]*x) return result def powerlist(x,n): if n==1: return [1] p = powerlist(x,n-1) return p + [p[-1]*x] Eh, much simpler. def powerlist(x,n): return [x*i for i in xrange(n-1)] But you're responding to a bot there. Rather clever as bots go, though. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
What do you think work best in general? I find typing during class (other than small REPL examples) time consuming and error prone. What works well for me is to create a slidy HTML presentation with asciidoc, then I can include code snippets that can be also run from the command line. (Something like: [source,python,numbered] --- include::src/sin.py[] --- Output example: http://i.imgur.com/Aw9oQ.png ) Let me know if you're interested and I'll send you a example project. HTH, -- Miki -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On 09/13/2012 11:58 PM, Miki Tebeka wrote: What do you think work best in general? I find typing during class (other than small REPL examples) time consuming and error prone. What works well for me is to create a slidy HTML presentation with asciidoc, then I can include code snippets that can be also run from the command line. (Something like: [source,python,numbered] --- include::src/sin.py[] --- Output example: http://i.imgur.com/Aw9oQ.png ) Let me know if you're interested and I'll send you a example project. HTH, -- Miki Yes please send me something and I'll have a look. For my slides I'm using hieroglyph: http://heiroglyph.readthedocs.org/en/latest/index.html which works with sphinx, so in theory I might be able to run the code as well.. But in general probably the best way is to copy and paste in a ipython session, to show that what I just explained actually works as expected.. -- http://mail.python.org/mailman/listinfo/python-list
RE: pythonOCC examples doesn't work?
Dwight Hutto wrote: [snip] On Wed, Sep 12, 2012 at 3:37 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: [snip] Others would be able to see this for themselves but you insist on sending email without context. Please don't do this. How are my emails without context? I'm referring the OP to the docs, as well as posts related to their question. It goes to use google, and RTFM, and putting it politely to them. I have noticed that you do not always quote what you are talking about. Sometimes I can guess or look at another message and see what you are talking about, but not always. This list philosophy seems to be quote what is relevant and trim what is not. Not on a go lookup the previous message to find context. I could summarize, but they have to do the real reading. I'm not researching this, and if I was, I'd charge for the time. This is to show that things can get complex if you don't use google, or read the docs. Context is not the same as explaining absolutely everything. It means that I, the reader, can see *what* you are talking about and what you are responding *to*. I do agree with the stance not to spoon feed OP(s). Why does the OP keep asking here, when there are answers out there. especially on the pywin list, which Windows users are usually referred to. I was not aware that Windows users were usually referred anywhere. Most referrals are on a case-by-case basis as many problems or questions from Windows Python developers are Python questions and not specific to pywin. Please point out what's out of context. The links and references place it into context if the OP finds them useful, and I believe I searched well for them. Would the OP like to tell me I wasn't helpful? Because now they're probably on a search to figure out how to make these compatible, which means more questions, and more reading. Nobody is claiming you are not helpful. I appreciate your effort, I just do not always know what is going on in a thread especially if I see the thread jump to something I can contribute to but now have no context with which to help. Not to mention that the archive for this list is searchable. Your answer is much more useful for future searchers if you leave some context for someone reading this. [snip] Let's not argue about this, I was pointing them to what I saw as the best possible resources to overcome his current problem, and it was all in context of the conversation as far as I'm concerned. It is in context of the thread, but the context of the conversation was lost. 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: datetime
On 9/13/2012 3:06 PM, readmax wrote: Terry Reedy tjreedy at udel.edu writes: You did not specify *which* time to set, but ... If you mean time.clock_shift(clk_id, shift_seconds), no. time.clock_settime(clk_id, time.clock_gettime(clk_id) + delta_seconds) I am talking about the system-wide clock on Debian. What should I use as clk_id? Read the doc. BTW, if by version 3.3 you mean python 3 x.y in the doc means pythonx.y -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
RE: Which Version of Python?
Ramchandra Apte wrote: On Wednesday, 12 September 2012 14:11:56 UTC+5:30, Ramchandra Apte wrote: On Wednesday, 12 September 2012 14:04:56 UTC+5:30, alex23 wrote: On 12 Sep, 16:31, Mark Lawrence breamore...@yahoo.co.uk wrote: Perhaps this will sway youhttp://docs.python.org/dev/whatsnew/3.3.html There is no longer an equivalent document for the Python 1.x or 2.x series of releases. Perhaps not for 1.x but the 2.x series is still covered: http://docs.python.org/dev/whatsnew/index.html Actually, 1.6 is included here: http://www.python.org/download/releases/1.6.1/ I think he meant the length of the document. Sorry, Mark must have meant theres no What's New document of the same length (its very long). Would you mind trimming your responses of blank lines? The double line spacing makes it difficult to read. I know that it may be google groups that is doubling line spaces but it would help if you could remove the extra lines that you can when replying (as I have done above). Thanks, Ramit 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: Least-lossy string.encode to us-ascii?
On 9/13/2012 5:26 PM, Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible,just stripping accents, cedillas, tildes, etc. 'keep as much information as possible' would mean an effectively lossless transliteration, which you could do with a dict. {o-with-accent: 'o', c-cedilla: 'c,' (or pick something that would never occur in normal text of the sort you are transmitting), ...} -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Python presentations
On 13Sep2012 17:00, andrea crotti andrea.crott...@gmail.com wrote: | I have to give a couple of Python presentations in the next weeks, and | I'm still thinking what is the best approach. | | In one presentation for example I will present decorators and context | managers, and my biggest doubt is how much I should show and explain in | slides and how much in an interactive way (with ipython for example). | | For my experience if I only see code in slides I tend not to believe | that it works somehow, but also only looking at someone typing can be | hard to follow and understand what is going on.. | | So maybe I should do first slides and then interactive demo, or the | other way around, showing first how everything works and then explaining | the code with slides. Slides first. My own experience is that someone typing code where I've not seen at least a summary explaination ahead of time slides straight off my brain. Ideally, two projectors: the current slides and an interactive python environment for demos. That way people can cross reference. But otherwise: a few slides, then a short demo if what was just spoken about, then slides... -- Cameron Simpson c...@zip.com.au Standing on the faces of midgets, I can see for yards. - David N Stivers D0D#857 s...@stat.rice.edu -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
On 09/13/12 18:36, Terry Reedy wrote: On 9/13/2012 5:26 PM, Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible,just stripping accents, cedillas, tildes, etc. 'keep as much information as possible' would mean an effectively lossless transliteration, which you could do with a dict. {o-with-accent: 'o', c-cedilla: 'c,' (or pick something that would never occur in normal text of the sort you are transmitting), ...} Vlastimil's solution kept the characters but stripped them of their accents/tildes/cedillas/etc, doing just what I wanted, all using the stdlib. Hard to do better than that :-) -tkc -- http://mail.python.org/mailman/listinfo/python-list
How to implement a combo Web and Desktop app in python.
I am somewhat new to python. I am still learning it. I am starting an app that I ma not quite sure how to best implement it. In the grand scheme, there will be 4 apps total. There will be a core shared between them that allows them to easily talk to each other (ill explain) and communicate with a database, as well as redis for pubsub events. I also need things to work on both web, and desktop. So i will likely have to keep the UI and the core of each app in their own separate apps entirely. The main core on the web will be a REST interface with proper content negotiation, depending on what is requested. Normally, if the desktop is online, you may think If you have a good rest interface, this makes the desktop version pointless. While true for some cases, the reason I need a desktop implementation, is because the end user still needs to be able to use the app while there is no internet connectivity. For example, an in store POS system. They would still need to process transactions like cash while offline, and they would also need access to their inventory. This is also good for intermittent connection problems, and for speed. So they don't have to worry about networking issues to do things. For this reason a local database is also needed. And when online, it keeps in sync with the remote database. So I need to find a way I can implement this in the best way, to help prevent code duplication, and reduce the amount of time it takes to get into production. If possible, I would like to use some kind of built in webkit for desktop as well, so users have the same experience both online and locally. So i would likely need to package a webserver as well (tornado/gunicorn?) If it was entirely online, I see how I could implement this, but when needing to have a desktop version, I feel like I would need to split things up differently. Here is so far, how I would think that I need to structure everything. Core: this is the CORE api to talk to the server, and interact with the systems. I should be able to do most things using this interface, and the individual apps may (or may not) add onto this for specific functionality. App: this is the individual apps. going along with my example, these could be the actual POS interface, a shopping cart, product catalog/inventory management, and an admin/backend that would tie into everything and be able to show things like product/customer stats and so on. Presentation: the actual user interfaces for each app. I also feel like I should put it all into one app, bundled, and only split up the ui based on web vs desktop. The different 4 apps may also be at 4 web addresses. such as: http://main.com (would probably include the admin app) http://pos.com http://products.com so what is avaiable to the end user, will also be dependant on the domain as well. If they are all on one core, with only the UI separated out, the rest interface would likely be on all of them and only allow things based on what app you are looking at. Unless you are on the master domain where everything is allowed. I understand this is a complex question about implementation, and could be philosophically different depending on the developer. But im not sure how to best go about it, so I was hoping to get some ideas and input. Should I do it an entirely different way? Currently for the apps themselves, I am looking at using either flask, bottle, web2py, or pyramid. I need to understand how I am going to implement it more before I choose a framework. Django is nice, but it doesnt seem to fit what I need to do. There are rest api plugins available for it, but if the core of my app is based on REST, it seemed to make more sense to start with something that has REST built into the core of the framework. Any input or advice is much appreciated. Thanks. - Shawn McElroy -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonOCC examples doesn't work?
On Thu, Sep 13, 2012 at 7:26 PM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Dwight Hutto wrote: [snip] On Wed, Sep 12, 2012 at 3:37 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: [snip] Others would be able to see this for themselves but you insist on sending email without context. Please don't do this. How are my emails without context? I'm referring the OP to the docs, as well as posts related to their question. It goes to use google, and RTFM, and putting it politely to them. I have noticed that you do not always quote what you are talking about. Sometimes I can guess or look at another message and see what you are talking about, but not always. This list philosophy seems to be quote what is relevant and trim what is not. Not on a go lookup the previous message to find context. I could summarize, but they have to do the real reading. I'm not researching this, and if I was, I'd charge for the time. This is to show that things can get complex if you don't use google, or read the docs. Context is not the same as explaining absolutely everything. It means that I, the reader, can see *what* you are talking about and what you are responding *to*. I do agree with the stance not to spoon feed OP(s). Why does the OP keep asking here, when there are answers out there. especiThey would still need to process transactions like cash while offline, and they would also need access to their inventory.ally on the pywin list, which Windows users are usually referred to. I was not aware that Windows users were usually referred anywhere. Most referrals are on a case-by-case basis as many problems or questions from Windows Python developers are Python questions and not specific to pywin. Please point out what's out of context. The links and references place it into context if the OP finds them useful, and I believe I searched well for them. Would the OP like to tell me I wasn't helpful? Because now they're probably on a search to figure out how to make these compatible, which means more questions, and more reading. Nobody is claiming you are not helpful. I appreciate your effort, I just do not always know what is going on in a thread especially if I see the thread jump to something I can contribute to but now have no context with which to help. Not to mention that the archive for this list is searchable. Your answer is much more useful for future searchers if you leave some context for someone reading this. [snip] Let's not argue about this, I was pointing them to what I saw as the best possible resources to overcome his current problem, and it was all in context of the conversation as far as I'm concerned. It is in context of the thread, but the context of the conversation was lost. 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 Your point is taken. Most of the time, if it's in an in line response I would write the email line by line, with the referenced text shown above my response. However, when it seems like a conversation, I just trim the above, and respond. That's how I view an e-mail, like an ongoing conversation. From now on, I'll leave the mailing I'm responding to above, and delete the point's I'm not talking about, which is about what I usually do. So being attacked about no context(which was an attack out of context, based on a few messages one night), when the whole conversation is in the topic reader/gmail/etc seemed a little ignorant to reading through. All he had to do was look back up to the email s just above my response, and see, or read just through mine, not read everyone. But anyway, I'll be more informative as to exactly what I was referencing, instead of treating it like an ongoing conversation where everyone was present, and paying attention to the whole of the topic. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonOCC examples doesn't work?
On Thu, Sep 13, 2012 at 9:11 PM, Dwight Hutto dwightdhu...@gmail.com wrote: On Thu, Sep 13, 2012 at 7:26 PM, Prasad, Ramit ramit.pra...@jpmorgan.com wrote: Dwight Hutto wrote: [snip] On Wed, Sep 12, 2012 at 3:37 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: [snip] Others would be able to see this for themselves but you insist on sending email without context. Please don't do this. How are my emails without context? I'm referring the OP to the docs, as well as posts related to their question. It goes to use google, and RTFM, and putting it politely to them. I have noticed that you do not always quote what you are talking about. Sometimes I can guess or look at another message and see what you are talking about, but not always. This list philosophy seems to be quote what is relevant and trim what is not. Not on a go lookup the previous message to find context. I could summarize, but they have to do the real reading. I'm not researching this, and if I was, I'd charge for the time. This is to show that things can get complex if you don't use google, or read the docs. Context is not the same as explaining absolutely everything. It means that I, the reader, can see *what* you are talking about and what you are responding *to*. I do agree with the stance not to spoon feed OP(s). Why does the OP keep asking here, when there are answers out there. especiThey would still need to process transactions like cash while offline, and they would also need access to their inventory.ally on the pywin list, which Windows users are usually referred to. I was not aware that Windows users were usually referred anywhere. Most referrals are on a case-by-case basis as many problems or questions from Windows Python developers are Python questions and not specific to pywin. Please point out what's out of context. The links and references place it into context if the OP finds them useful, and I believe I searched well for them. Would the OP like to tell me I wasn't helpful? Because now they're probably on a search to figure out how to make these compatible, which means more questions, and more reading. Nobody is claiming you are not helpful. I appreciate your effort, I just do not always know what is going on in a thread especially if I see the thread jump to something I can contribute to but now have no context with which to help. Not to mention that the archive for this list is searchable. Your answer is much more useful for future searchers if you leave some context for someone reading this. [snip] Let's not argue about this, I was pointing them to what I saw as the best possible resources to overcome his current problem, and it was all in context of the conversation as far as I'm concerned. It is in context of the thread, but the context of the conversation was lost. 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 Your point is taken. Most of the time, if it's in an in line response I would write the email line by line, with the referenced text shown above my response. However, when it seems like a conversation, I just trim the above, and respond. That's how I view an e-mail, like an ongoing conversation. From now on, I'll leave the mailing I'm responding to above, and delete the point's I'm not talking about, which is about what I usually do. So being attacked about no context(which was an attack out of context, based on a few messages one night), when the whole conversation is in the topic reader/gmail/etc seemed a little ignorant to reading through. All he had to do was look back up to the email s just above my response, and see, or read just through mine, not read everyone. But anyway, I'll be more informative as to exactly what I was referencing, instead of treating it like an ongoing conversation where everyone was present, and paying attention to the whole of the topic. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com And if you look at the above in gmail, you can see the ...'s that when not clicked, won't show some of the responses I leave just above, and it clips my signature line as well. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Decorators not worth the effort
On Sep 14, 3:54 am, Jean-Michel Pichavant jeanmic...@sequans.com wrote: I don't like decorators, I think they're not worth the mental effort. Because passing a function to a function is a huge cognitive burden? -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: On 09/13/12 18:36, Terry Reedy wrote: On 9/13/2012 5:26 PM, Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible,just stripping accents, cedillas, tildes, etc. 'keep as much information as possible' would mean an effectively lossless transliteration, which you could do with a dict. {o-with-accent: 'o', c-cedilla: 'c,' (or pick something that would never occur in normal text of the sort you are transmitting), ...} Vlastimil's solution kept the characters but stripped them of their accents/tildes/cedillas/etc, doing just what I wanted, all using the stdlib. Hard to do better than that :-) -tkc How about using UTF-7 for transmission and decode on the other end? This keeps the transmission all 7-bit, and no loss. s=userviço móvil.encode('utf-7') print s servi+AOc-o m+APM-vil print s.decode('utf-7') serviço móvil -Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: main and dependent objects
On Sep 13, 10:52 pm, andrea crotti andrea.crott...@gmail.com wrote: I am in a situation where I have a class Obj which contains many attributes, and also contains logically another object of class Dependent. But I'm not so sure it's a good idea, it's a bit smelly.. It's actually a well regarded technique known as composition: http://en.wikipedia.org/wiki/Object_composition While it has an ostensible focus on game development, I found this article to be very good at explaining the concept: http://gameprogrammingpatterns.com/component.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
On 13Sep2012 18:58, alex23 wuwe...@gmail.com wrote: | On Sep 14, 3:54 am, Jean-Michel Pichavant jeanmic...@sequans.com | wrote: | I don't like decorators, I think they're not worth the mental effort. | | Because passing a function to a function is a huge cognitive burden? It is for me when I'm _writing_ the decorator:-) But if I get it right and name it well I find it dramaticly _decreases_ the cognitive burden of the code using the decorator... -- Cameron Simpson c...@zip.com.au Observing the first balloon ascent in Paris, [Ben] Franklin heard a scoffer ask, What good is it? He spoke for a generation of scientists in his retort, What good is a newly born infant? - John F. Kasson -- http://mail.python.org/mailman/listinfo/python-list
Re: Batching HTTP requests with httplib (Python 2.7)
On 13Sep2012 19:34, Chicken McNuggets chic...@mcnuggets.com wrote: | I'm writing a simple library that communicates with a web service and am | wondering if there are any generally well regarded methods for batching | HTTP requests? | | The problem with most web services is that they require a list of | sequential commands to be executed in a certain order to complete a | given task (or at least the one I am using does) so having to manually | call each command is a bit of a pain. How would you go about the design | of a library to interact with these services? | | Any help is greatly appreciated :). Maybe I'm missing something. What's hard about: - wrapping the web services calls in a simple wrapper which composes the call, runs it, and returns the result parts This lets you hide all the waffle about the base URL, credentials etc in the wrapper and only supply the essentials at call time. - writing your workflow thing then as a simple function: def doit(...): web_service_call1(...) web_service_call2(...) web_service_call3(...) with whatever internal control is required? This has worked for me for simple things. What am I missing about the larger context? -- Cameron Simpson c...@zip.com.au Clymer's photographs of this procedure show a very clean head. This is a lie. There is oil in here, and lots of it. - Mike Mitten, rec.moto, 29sep1993 -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
On 09/13/12 21:09, Mark Tolonen wrote: On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: Vlastimil's solution kept the characters but stripped them of their accents/tildes/cedillas/etc, doing just what I wanted, all using the stdlib. Hard to do better than that :-) How about using UTF-7 for transmission and decode on the other end? This keeps the transmission all 7-bit, and no loss. s=userviço móvil.encode('utf-7') print s servi+AOc-o m+APM-vil print s.decode('utf-7') serviço móvil Nice if I control both ends of the pipe. Unfortunately, I only control what goes in, and I want it to be as un-screw-uppable as possible when it comes out the other end (may be web, CSV files, PDFs, FTP'ed file dumps, spreadsheets, word-processing documents, etc), and us-ascii is the lowest-common-denominator of unscrewuppableness while requiring nothing of the the other end. :-) -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: Decorators not worth the effort
On Sep 14, 12:12 pm, Cameron Simpson c...@zip.com.au wrote: On 13Sep2012 18:58, alex23 wuwe...@gmail.com wrote: | On Sep 14, 3:54 am, Jean-Michel Pichavant jeanmic...@sequans.com| wrote: | I don't like decorators, I think they're not worth the mental effort. | | Because passing a function to a function is a huge cognitive burden? It is for me when I'm _writing_ the decorator:-) But if I get it right and name it well I find it dramaticly _decreases_ the cognitive burden of the code using the decorator... Okay, I will concede that point :) -- http://mail.python.org/mailman/listinfo/python-list
Re: datetime
On Thu, 13 Sep 2012 15:19:32 +, Max wrote: How do I set the time in Python? You don't. You ask the operating system to set the time. If you don't have permission to change the time, which regular users shouldn't have because it is a security threat, it will (rightly) fail. E.g.: import os os.system('date -s %s' % date_str) In Python 3.3 there is a wrapper in the time module that allows you to set the clock without an explicit system call. Again, you need permission to set the clock, or it will fail. Also, is there any *direct* way to shift it? Say, it's 09:00 now and Python makes it 11:30 *without* me having specified 11:30 but only given Python the 2h30m interval. Certainly. Just call: time.sleep(2*60**2 + 30*60) and when it returns, the clock will have shifted forward by 2h30m, just like magic! *wink* Note that any indirect methods may need complicated ways to keep track of the milliseconds lost while running them. It even took around one second in some virtual machine guest systems. So I'm hoping Python happens to have the magic needed to do the job for me. No. Setting the clock is not the business of any user-space application. It is the job of the operating system, which will do it the right way. At most, the application can call the OS, directly or indirectly, but it has no control over how many milliseconds are lost when you do so. On Linux, Unix or Mac, that right way is to use NTP, which will keep your computer's clock syncronised with a trusted external source. In a virtual machine, the right way is to use NTP to syncronise the VM host's time, and then tell the host to synchronise itself with the VM. On Windows, well you'll have to ask a Windows expert. If you want to bypass NTP and manage time yourself -- say, you want to simulate what happens when the clock strikes midnight? without having to wait for midnight -- then you probably don't need millisecond precision. If you do need millisecond precision -- why??? -- *and* expect to do it from a user-space application, you're going to have a bad time. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Thu, 13 Sep 2012 17:06:23 -0400, Dwight Hutto wrote: Then there is the problem of people saying you posted too much of the context, or not inline with the OP, just at the end, or top posting. The solution to you quoted too much unnecessary verbiage is not quote nothing. It is quote only the parts that are relevant. I try to keep it along the line of what the OP has read, and they know the context in which it's meant. You're assuming that people read your posts immediately after they read the post you replied to. Always imagine that your reply will be read a week after the post you replied to. Do you still expect the reader to understand what you're talking about? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Sep 14, 5:37 am, Dwight Hutto dwightdhu...@gmail.com wrote: Why don't take the time to read the OP, and ramit in your head? Please, don't be a dick. -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
On Thu, 13 Sep 2012 16:26:07 -0500, Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). That could mean two things: 1) The receiver is incapable of dealing with Unicode in 2012, which is frankly appalling, but what can I do about it? 2) The transport mechanism I use to transmit the data is only capable of dealing with 7-bit ASCII strings, which is sad but pretty much standard. In the case of 1), I suggest you look at the Unicode Hammer, a.k.a. The Stupid American: http://code.activestate.com/recipes/251871 and especially the very many useful comments. In the case of 2), just binhex or uuencode your data for transport. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Least-lossy string.encode to us-ascii?
On Thu, 13 Sep 2012 21:34:52 -0500, Tim Chase wrote: On 09/13/12 21:09, Mark Tolonen wrote: On Thursday, September 13, 2012 4:53:13 PM UTC-7, Tim Chase wrote: Vlastimil's solution kept the characters but stripped them of their accents/tildes/cedillas/etc, doing just what I wanted, all using the stdlib. Hard to do better than that :-) How about using UTF-7 for transmission and decode on the other end? This keeps the transmission all 7-bit, and no loss. s=userviço móvil.encode('utf-7') print s servi+AOc-o m+APM-vil print s.decode('utf-7') serviço móvil Nice if I control both ends of the pipe. Unfortunately, I only control what goes in, and I want it to be as un-screw-uppable as possible when it comes out the other end (may be web, CSV files, PDFs, FTP'ed file dumps, spreadsheets, word-processing documents, etc), and us-ascii is the lowest-common-denominator of unscrewuppableness while requiring nothing of the the other end. :-) Wrong. It requires support for US-ASCII. What if the other end is an IBM mainframe using EBCDIC? Frankly, I am appalled that you are intentionally perpetuating the ignorance of US-ASCII-only applications, not because you have no choice about inter-operating with some ancient, brain-dead application, but because you artificially choose to follow an obsolete *and incorrect* standard. It is *incorrect* because you can change the meaning of text by stripping accents and deleting characters. Consequences can include murder and suicide: http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail At least tell me that ASCII only is merely an *option* for your application, not the only choice, and that it defaults to UTF-8 which is the right standard to use for text. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Fri, Sep 14, 2012 at 1:39 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You're assuming that people read your posts immediately after they read the post you replied to. Always imagine that your reply will be read a week after the post you replied to. And a week is extremely generous too; these posts get archived on the web. I *frequently* find myself hitting mailing list archives when researching obscurities. This is also another good reason to post follow-ups to the list, rather than in private email. You might never be thanked, but somebody years down the track may find the question and an associated answer. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Thu, Sep 13, 2012 at 11:48 PM, alex23 wuwe...@gmail.com wrote: On Sep 14, 5:37 am, Dwight Hutto dwightdhu...@gmail.com wrote: Why don't take the time to read the OP, and ramit in your head? Please, don't be a dick. For telling him to ramit into his head that you should read the OP? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Sep 14, 2:46 pm, Dwight Hutto dwightdhu...@gmail.com wrote: For telling him to ramit into his head that you should read the OP? Yes. I'm not sure if it was intentionally racist, but you come across as a bit of a dwight supremacist. -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
On Thu, Sep 13, 2012 at 11:36 AM, paulsta...@gmail.com wrote: Thanks, guys. MRAB-RedHat 6 64-bit, Python 2.6.5 In your Unix shell, what does the command: type htar output? JM-Here's the relevant stuff from my last try. If you could give a complete, self-contained example, it would assist us in troubleshooting your problem. I've also tried with subprocess.call. Just now I tried shell=True, but it made no difference. It's possible that htar uses some trickery to determine whether it's being invoked from a terminal or by another program, and changes its behavior accordingly, although I could not find any evidence of that based on scanning its manpage. sticking a print(out) in there just prints a blank line in between each iteration. It's not until the 5 trials are finished that I am told: download failed, etc. from os.path import exists from subprocess import call from subprocess import Popen from shlex import split from time import sleep while (exists(file)==0) and (nTries 5): `file` is the name of a built-in type in Python; it should therefore not be used as a variable name. Also, one would normally write that as: while not exists(file) and nTries 5: a = Popen(split('htar -xvf ' + htarArgs), stdout=PIPE, stderr=PIPE) What's the value of `htarArgs`? (with any sensitive parts anonymized) Also, you really shouldn't use shlex.split() at run-time like that. Unless `htarArgs` is already quoted/escaped, you'll get bad results for many inputs. Use shlex.split() once at the interactive interpreter to figure out the general form of the tokenization, then use the static result in your program as a template. (out,err) = a.communicate() if exists(file)==0: nTries += 1 sleep(0.5) if exists(file)==0: # now that the file should be moved print('download failed: ' + file) return 1 I've also tried using shell=True with popopen. I presume you meant Popen. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess call is not waiting.
On Thu, Sep 13, 2012 at 8:17 AM, paulsta...@gmail.com wrote: I have a subprocess.call snip But it doesn't work as intended. snip Should I just go back to os.system? Did the os.system() version work? As of recent Python versions, os.system() is itself implemented using the `subprocess` module, so if it does work, then it assuredly can be made to work using the `subprocess` module instead. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: hi
Hey, how are you? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: hi
Wait, that was out of context. Subject: Hi On Fri, Sep 14, 2012 at 1:09 AM, genban tade tadegen...@gmail.com wrote: -- http://mail.python.org/mailman/listinfo/python-list Hey, how are you? -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing strings from the back?
On Fri, Sep 14, 2012 at 12:54 AM, alex23 wuwe...@gmail.com wrote: On Sep 14, 2:46 pm, Dwight Hutto dwightdhu...@gmail.com wrote: For telling him to ramit into his head that you should read the OP? Yes. I'm not sure if it was intentionally racist, but you come across as a bit of a dwight supremacist. Please explain any logic whatsoever that would give you that conclusion. Seems more like propaganda, and you're not very good at it. I think you're referring to a play on words(ramit). Ain't I so punny. -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com -- http://mail.python.org/mailman/listinfo/python-list