OSCON Python Django Meetup - Tuesday 7/22
Going to OSCON 2008? Join local and visiting Pythonistas and Djangonauts for a casual get-together on the rooftop deck at Jax. * Tuesday, July 22nd 7pm - 10pm * Jax Bar and Restaurant 826 SW 2nd Ave Portland, OR 97204 Getting to Jax from the convention center is easy. Find directions and more info at http://oscon.pdxpython.org/ Cheers! -Jason -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python game programming challenge, NUMBER 7, in September!
The date for the SEVENTH bi-annual PyWeek challenge has been set: Sunday 7th September to Sunday 14th September (00:00UTC to 00:00UTC). http://pyweek.org/ The PyWeek challenge invites entrants to write a game in one week from scratch either as an individual or in a team. Entries must be developed in Python, during the challenge, and must incorporate some theme chosen at the start of the challenge. REGISTRATION IS NOT YET OPEN -- In order to reduce the number of unnecessary registrations, we will open the challenge for registration one month before the start date. See the competition timetable and rules: http://www.pyweek.org/ PLANNING FOR THE CHALLENGE -- Make sure you have working versions of the libraries you're going to use. The rules page has a list of libraries and other resources. Make sure you know how to build an MD5 sum for your submission. See the challenge help page for more information. Make sure you can build packages to submit as your final submission (if you're going to use py2exe, make sure you know how to use it and that it works). If you don't have access to Linux, Windows or a Mac to test on, contact friends, family or other competitors to find someone who is able to test for you. -- Visit the PyWeek website: http://www.pyweek.org/ -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Question
On Jul 19, 2:27 am, [EMAIL PROTECTED] wrote: Why is Perl so much better than python? Because dollar signs are a superior form of punctuation. Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Question
On Jul 19, 10:27 am, [EMAIL PROTECTED] wrote: Why is Perl so much better than python? Coz its endorsed by: Chernobble valve controls. Barings Bank. The society of the Mortgage Brokers of America. The Bush Disaster relief fund for the Southern States. And, of course, is the tool of choice when looking for weapons of mass destruction in Iraq. - Paddy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Not entirely serious: recursive lambda?
On 20 Jul., 04:43, Michael Tobis [EMAIL PROTECTED] wrote: Can a lambda call itself without giving itself a name? Sure, use a fixed point combinator. I've just added this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/576366 Google was not my friend on this one, and I suspect there is no answer. Even the Great Google can't help if you don't use the right keywords ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: MethodChain
On Sun, Jul 20, 2008 at 1:01 AM, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: The methods are a problem IMHO. You can't add an own method/function with the name `fire()` or `toFunction()`. `MethodChain` has to know all functions/methods in advance. You can add the methods of whole classes at once and there are over 300 pre-added, this begs for name clashes. Name clashes aren't an issue, since MethodChain doesn't apply any special meaning to the method names it knows; the limitation is because JavaScript doesn't allow you to modify property lookup behavior. And since we can make the chain object callable, we don't need fire or toFunction methods. ### from functools import partial class MethodChain(object): # The implementation of this could be cleaner. I would prefer # chain.foo() to return a new object instead of modifying chain. # But this is easier to write and closer to the JavaScript implementation. def __init__(self): self._methodname = None self._chain = [] def __getattr__(self, methodname): assert self._methodname is None self._methodname = methodname return self def __call__(self, *args, **kwargs): if self._methodname is None: assert len(args) == 1 and not kwargs result = args[0] for method in self._chain: result = getattr(result, method[0])(*method[1], **method[2]) return result else: self._chain.append((self._methodname, args, kwargs)) self._methodname = None return self def compose(*callables): def composition(arg): result = arg for callable in callables: # or should that be reversed(callables)? to be mathematically # accurate, yes, probably; however, it also makes sense to # specify the callables in the order they'll be applied result = callable(result) return result return composition chain = MethodChain().lower().replace('ello,', 'ey').title().split() print chain('HELLO, world') func = compose(chain, partial(map, lambda s: s+'!'), ' '.join) print func('HELLO, world') ### -Miles -- http://mail.python.org/mailman/listinfo/python-list
Genetic programming: pygene, pygp, AST, or (gasp) Lisp?
Hi folks, I've played around with neural nets for a while. I wrote my own slow, pure-Python NN package. I knew that there were Python NN packages out there -- but I couldn't really understand their features and documentation at first, not without some hands-on experience. I haven't yet solved any interesting problems with NN, but I learned a lot about both NN and about Python along the way. One of the unpleasant things I learned about NN was their propensity for becoming trapped in local minima. I also learned about overfitting, wasting many hours of CPU time in the process. In short, simple neural nets have disappointed me. I have now asked myself: wouldn't it be cool if, when you ceased to make progress on an optimization algorithm, you could divide your data set with an if statement, which would evolve a useful dividing line through your data set -- and then, develop divergent solutions to explain each subset better? In mathematical terms: Round 1 of evolutionary programming leads to a single, but sub-optimal solution, probably a solution in a local minimum: b = f(a) Round 2 would start by elaborating the solution of round 1, adding a condition that is initially meaningless: if disc(a) c: b = f1(a) else: b = f2(a) Initially, f1() = f2() = the original f(). Therefore, the output of the starting state of round 2 will be identical to the output of the final state of round 1, regardless of the initial state of the discriminant function, disc(). But then, f1(), f2(), and disc() will all be permitted to evolve. This may provide a chance to pop out of the local minimum, without sacrificing any of the progress made in defining the solution of round 1. Of course, f(), f1(), f2(), and disc() could be complex functions. They would best be described with parse trees, which I've just discovered (I'm not formally trained in computer science). Some reading has led me to conclude that what I'm proposing is basically genetic programming. http://en.wikipedia.org/wiki/Genetic_programming I've tried my hand at this already in Python. I have devised a code tree class, which functions as a parse tree for functions and also handles multiple-line statements. I've tried cobbling together program strings from code trees, and then using the exec() function to run them. This is all very cool, but I'm finding it VERY cumbersome! As with neural nets, I know that there are genetic programming packages offered for Python: http://www.freenet.org.nz/python/pygene/ http://sourceforge.net/projects/pygp/ But I can't really understand what they do -- both of these packages are, alas, minimally documented. Is anyone out there using either of these? I can't tell whether they will implement algorithms of the type I've described here. Specifically, I don't know if conditional statements are included in their repertoire. Also, Pygene SEEMS to have a bent toward Boolean logic. I'm working with analog data, and I want complex, nonlinear functions. So, as with neural nets, shall I once again proceed on my own? There is apparently a layer in the Python interpreter at which code is represented as an abstract syntax tree (AST). http://docs.python.org/lib/ast.html Why not do genetic programming directly on Python code? Maybe my code tree data structure is redundant to something which already exists? But apparently Python's _ast module offers only one-way access -- it will generate an AST from a piece of code, but you can't modify an AST, and turn it back into executable code? I would definitely need this latter feature. ALTERNATELY -- and I don't mention this to start a flame war -- in pondering this problem I've noticed the frightening fact that Lisp seems set up to handle genetic programming by design. The s- expression syntax IS essentially a parse tree. Now, I've spent a few hours with Lisp so far, and I can't make it do much of anything -- but I DO see how Lisp could be helpful. Still, I'm reluctant to pursue a language I don't know, and which I'm finding much harder to grasp than any language I've tried before. Is there a way to interface Lisp to Python, so that I can do all the interface programming in the language I already know best -- and just do the genetic parts in Lisp? I haven't seen exception handling in Lisp, a feature I've come to love in Python. Since it is fairly easy for a randomly-generated program to generate illegal output (I already know this from my initial experiments in Python), I don't think I can live without exception handling. I also think that Python has a higher-level understanding of a variable's type or an object's class than Lisp does -- if I'm hacking at a parse tree and I want to minimize syntax errors, I need to know more than the fact that an element in an expression is an atom or a list. Producing human-readable code from my genetic programming search would be a great bonus -- and for me, at this moment, this seems to mean Algol-style
Re: matplotlib: Plotting a graph against time
On Jul 19, 3:09 pm, Durand [EMAIL PROTECTED] wrote: Hi, I'm trying to plot a simple graph against date or time using matplotlib. I've read about date_plot but I'm not really sure how to use it. At the moment, I have some data arranged into lists, where list1 contains x values (time) and list2 contains y values just like is needed for the normal plot function. The time values are simply the output of datetime.date.today(), etc which I don't mind changing the format of. My question is, how do I plot the graph with list1 on the x axis and list2 on the y axis. Using plot and unixtime I get a very ugly scale as is to be expected so I want to know how to use the date_plot function efficiently. At the moment, I'm only concerned about the actual plotting but help with Locater Ticks (Months and Years) is also very appreciated. Thanks a lot! I'm not sure if this is what you're looking for, but here's a quick sample that uses plot_date to plot some random values. import pylab, random from datetime import datetime, timedelta today = datetime.now() dates = [today + timedelta(days=i) for i in range(10)] values = [random.randint(1, 20) for i in range(10)] pylab.plot_date(pylab.date2num(dates), values, linestyle='-') -- http://mail.python.org/mailman/listinfo/python-list
Re: Genetic programming: pygene, pygp, AST, or (gasp) Lisp?
On 20 Jul., 09:52, John Ladasky [EMAIL PROTECTED] wrote: Why not do genetic programming directly on Python code? Maybe my code tree data structure is redundant to something which already exists? But apparently Python's _ast module offers only one-way access -- it will generate an AST from a piece of code, but you can't modify an AST, and turn it back into executable code? Why not? You can compile ASTs. Another option is to use EasyExtend http://www.fiber-space.de/EasyExtend/doc/EE.html which is a bit heavyweight though without prior knowledge of the framework. EE provides some generic functions over languages like parse/unparse. Python is just a special case. So you can do the following from EasyExtend.langlets.zero.langlet import parse, unparse src = if disc(a) c: b = f1(a) else: b = f2(a) parse(src)# yields a parse tree unparse(parse(src)) # yields the source code of the parse tree Here `zero` means Python which is just the trivial/featureless langlet of the system or some kind of embedding. For meshing fragments together on random one can use cst.py. For each rule in Pythons grammar cst.py implements a corresponding function that produces the parse tree accordingly. So if there is a rule test: or_test ['if' or_test 'else' test] | lambdef a corresponding function test(*args) exists that produces a parse tree from components that were built using or_test(), test() or lambdef(). chaining these functions is just like building s-expr. I would definitely need this latter feature. ALTERNATELY -- and I don't mention this to start a flame war -- in pondering this problem I've noticed the frightening fact that Lisp seems set up to handle genetic programming by design. Definitely. But this is nothing new. Lisp was the original language used by John Koza to implement GP. The s- expression syntax IS essentially a parse tree. Now, I've spent a few hours with Lisp so far, and I can't make it do much of anything -- but I DO see how Lisp could be helpful. Still, I'm reluctant to pursue a language I don't know, and which I'm finding much harder to grasp than any language I've tried before. You can write a primitive s-expr evaluator/manipulator using Pythons overloading capabilities. But this way you will just produce s-expr and not Python functions. Kay -- http://mail.python.org/mailman/listinfo/python-list
Re: MethodChain
Name clashes aren't an issue, since MethodChain doesn't apply any special meaning to the method names it knows; the limitation is because JavaScript doesn't allow you to modify property lookup behavior. And since we can make the chain object callable, we don't need fire or toFunction methods. I'm the author of MethodChain, so just thought I'd confirm the above statement. All MethodChain does is store method calls so they can later be replayed on any object. All methods in MethodChain simply add their name and arguments to an array inside the MethodChain instance, they don't implement any concrete functionality. All that's important is the names of the methods -- the object the chain is fired on will decide how to handle those calls itself, so naming clashes aren't a problem. For example: var chain = it().toLowerCase().split('-').map(function() {...}); chain.fire('my-String'); is the same as 'my-String'.toLowerCase().split('-').map(function() {...}); So split() gets called on 'my-string', map() gets called on ['my', 'string']. The methods 'fire' and 'toFunction' are a problem but I can't see any way around having them in JavaScript -- you need some way of getting the method list out of the chain object. if JavaScript had method_missing, we wouldn't need to tell MethodChain about names in advance either. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with curses
On Jul 13, 6:22 pm, Clay Hobbs [EMAIL PROTECTED] wrote: On Sat, 12 Jul 2008 20:49:56 -0400, Clay Hobbs wrote: Unfortunately, the error message isn't very helpful. But it would be helpful to tell it. If you get exceptions, always copy'n'paste the traceback here. People might know what the exception means and share their wisdom. Here is the error message: Traceback (most recent call last): File ./text_adventure.py, line 25, in module curses.wrapper(main) File /usr/lib/python2.5/curses/wrapper.py, line 44, in wrapper return func(stdscr, *args, **kwds) File ./text_adventure.py, line 19, in main stdscr.scroll(3) _curses.error: scroll() returned ERR -- Ratfink You need to put a stdscr.scrollok(True) in the beginning. That should avoid the exception. -Siddhant -- http://mail.python.org/mailman/listinfo/python-list
RE: __del__ methods
In Python 2.x, classic classes (which are not part of the unified type hierarchy) are deprecated, and exist only for backward compatibility with old code. You need to create new-style classes URL:http://www.python.org/doc/newstyle/ by inheriting from some class that is part of the unified type hierarchy; if there is no obvious candidate, 'object' is the recommended choice. Thanks Ben, This isn’t something I'd seen before (god that makes me feel stupid). I've always based my code off the odd example that's dotted around and hadn’t ever done any proper reading on these new type classes. I've done a little reading this morning and really love a great deal of the concepts, I'll be upgrading my app to this spec in the next few days. Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: __del__ methods
Robert Rawlins [EMAIL PROTECTED] writes: This isn’t something I'd seen before (god that makes me feel stupid). No need to feel stupid, unless you've had the opportunity to learn and passed it by. I've always based my code off the odd example that's dotted around Time to fix that, then, with some documentation URL:http://www.python.org/doc/, and by working through the Python tutorial URL:http://www.python.org/doc/tut/. -- \ “I was married by a judge. I should have asked for a jury.” | `\ —Groucho Marx | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
RE: __del__ methods
Time to fix that, then, with some documentation URL:http://www.python.org/doc/, and by working through the Python tutorial URL:http://www.python.org/doc/tut/. Thanks Ben, I'll be sure to read through these. I also read through this http://www.geocities.com/foetsch/python/new_style_classes.htm earlier this morning which was also a nice little resource. Just about all of it makes sense at the moment, apart from the new constructor types which are constructors at a class level opposed to at instance level. I found this a little confusing but who knows. Presumably this is where you would deal with setting things which exist in every instance of a class, and properties that can vary from instance to instance go into the standard __init_(), have I got that right? Cheers Ben, Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Not entirely serious: recursive lambda?
Kay Schluehr: Sure, use a fixed point combinator. I've just added this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/576366 Does it work? Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list
Re: __del__ methods
Robert Rawlins a écrit : Time to fix that, then, with some documentation URL:http://www.python.org/doc/, and by working through the Python tutorial URL:http://www.python.org/doc/tut/. Thanks Ben, I'll be sure to read through these. I also read through this http://www.geocities.com/foetsch/python/new_style_classes.htm earlier this morning which was also a nice little resource. Just about all of it makes sense at the moment, apart from the new constructor types which are constructors at a class level opposed to at instance level. I found this a little confusing but who knows. Are you talking about the __new__ method ? Or about metaclasses ? -- http://mail.python.org/mailman/listinfo/python-list
Re: Writing a program under GNU/Linux for MS Windows.
On 7/18/08, Levi Campbell [EMAIL PROTECTED] wrote: Hi, I'm trying to write a program for a friend of mine who uses windows but I use GNU/Linux. I know you can use mingw and link to the python dll, but is there a way to create a win32 service under Linux? -- http://mail.python.org/mailman/listinfo/python-list Hi Levi (First off, I apologise if I sound a bit incoherent, but I've got flu and I'm on medication :( ) After having just completed a project where had to write a windows service I can offer you some insight. Writing of a service on windows, as opposed to a daemon on linux/unix in python - you will need to use the pywin32 module (http://sourceforge.net/projects/pywin32/) The libraries in the pywin32 package you will need to use are most likely going to be the followowing: 1) win32service 2) win32serviceutil 3) win32api 4) win32con and 5) servicemanager The fact that the pywin32 package is just an interface to the win32api means (as far as I understand) that [sadly] you will need to develop this in windows. Some stuff you might want to check out: 1) http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html (I don't recommend this one - a bit dated) 2) http://groups.google.com/group/comp.lang.python/msg/3775b8265f1b220f (this is the template for the win32 service i finally used.) Also as an interesting alternative, something I recently came across - you can create a windows service, using the web2py web framework (http://mdp.cti.depaul.edu/AlterEgo/default/show/77). This could save you some time, as all the libraries/modules are already set up for you in the source download (http://mdp.cti.depaul.edu/examples/default/download) Hope this helps. Regards Nicolaas -- Peesowt -- http://mail.python.org/mailman/listinfo/python-list
Re: Help Tracing urllib2 Error, Please?
Larry Hale [EMAIL PROTECTED] writes: Since it seems I have a unique problem, I wonder if anyone could point me in the general/right direction for tracking down the issue and resolving it myself. See my prior post @ http://groups.google.com/group/comp.lang.python/browse_thread/thread/44775994a6b55161?hl=en# for more info. (Python 2.5.2 on Win XP 64 == Squid Proxy requiring Authentication == Internet not working.) I've looked the urllib2 source over, but am having trouble following it. As previously mentioned, urllib2 initiates the request, Squid replies 407 error that auth's required, and then urllib2 just stops, throwing error 407. Any though(s) on what to check out? It's frustrating (to say the least) that it seems so many are successfully accomplishing this task, and all's working perfectly for them, but I'm failing miserably. Would any quotes viewed in the HTTP traffic help? (Wireshark shows all! :) I don't even know what other info could help. Any info to get about Squid's configuration that might make it non standard in a way that could cause my problem? Any question(s) I should ask my Net Admin to relay info to you all? Maybe Squid is configured to not allow sending authentication directly in URI. Or maybe there is only digest scheme allowed. Try this: def getopener(proxy=None, digest=False): opener = urllib2.build_opener(urllib2.HTTPHandler) if proxy: passwd_mgr = urllib2.HTTPPasswordMgr() passwd_mgr.add_password(None, 'http://localhost:3128', 'user', 'password') if digest: proxy_support = urllib2.ProxyDigestAuthHandler(passwd_mgr) else: proxy_support = urllib2.ProxyBasicAuthHandler(passwd_mgr) opener.add_handler(proxy_support) return opener def fetchurl(url, opener): f = opener.open(url) data = f.read() f.close() return data print fetchurl('http://www.python.org', getopener('127.0.0.1:3128')) print fetchurl('http://www.python.org', getopener('127.0.0.1:3128', digest=True)) HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list
RE: __del__ methods
Are you talking about the __new__ method ? Or about metaclasses ? Sorry Bruno, I should have made that a little clearer. I was talking about the __new__ method. Cheers mate, Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: Not entirely serious: recursive lambda?
On 20 Jul., 13:08, [EMAIL PROTECTED] wrote: Kay Schluehr: Sure, use a fixed point combinator. I've just added this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/576366 Does it work? Bye, bearophile There are lots of informal derivations of the Y combinator on the web. I used one a while ago and translated the result into Python. So if there isn't an implementation bug it shall work. I added two examples for illustration purposes. -- http://mail.python.org/mailman/listinfo/python-list
Re: Genetic programming: pygene, pygp, AST, or (gasp) Lisp?
On Sunday 20 July 2008 09:52, John Ladasky wrote: Is there a way to interface Lisp to Python, so that I can do all the interface programming in the language I already know best -- and just do the genetic parts in Lisp? I haven't seen exception handling in Lisp, a feature I've come to love in Python. Since it is fairly easy for a randomly-generated program to generate illegal output (I already know this from my initial experiments in Python), I don't think I can live without exception handling. Just searching the Web for Python and Lisp yielded some interesting projects: http://www.biostat.wisc.edu/~annis/creations/PyLisp/ http://www.livelogix.net/logix/ I've no idea if they're really that relevant to your problem, but they might lead somewhere useful. David -- http://mail.python.org/mailman/listinfo/python-list
getting with statement to deal with various exceptions
Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException finally: tear_it_down() Verbose, not very readable. OK, with to the rescue? Let's take a textbook example from PEP: with open('/etc/passwd', 'r') as f: BLOCK Well, great, it's neat that with closes the file after BLOCK has finished execution, but what if the file isn't there and attempt to open it raises IOException? I'd like to be able to catch it precisely to avoid writing verbose try: .. except: .. finally: .. blocks which as I understand has been much of the rationale behind creating with statement in the first place. with statement only allows easy dealing with prepare() and tear_it_down(). When I try to get it to deal with exceptions that might happen, it becomes more complicated: class FileContextManager: def __enter__(self, filename, mode): f = open(filename, mode) return f def __exit__(self, etype, evalue, etraceback): print etype, etype, evalue, evalue, etraceback, etraceback with FileContextManager(somefile, r) as f: a = f.readlines() Traceback (most recent call last): File pyshell#36, line 1, in module with FileContextManager(somefile, r) as f: TypeError: this constructor takes no arguments Bummer. Plus, no documentation I've read (on effbot, in PEP 343, etc) says how to deal with the exception happening in __enter__ method of context manager, which is precisely what I'd like to do. This is only natural, isn't it? When e.g. reading the file, preparation phase is typically checking if it can be opened in the first place. So it falls into __enter__ method of context manager. with limited only to successful execution of a_statement from with a_statement seems like limited benefit to me. I'd like to be able to write smth like class FileContextManager: def __enter__(self, filename, mode): f = open(filename, mode) return f def __except__(IOError, err): do_this print err def __except__(RuntimeError, err): do_that print something bad happened, err def __exit__(self, etype, evalue, etraceback): print etype, etype, evalue, evalue, etraceback, etraceback __exit__ deals with exceptions happening in the BLOCK below with statement, not with exceptions raised in a_statement, when executing with a_statement as var: BLOCK In the above way with would give me the benefit of more terse, but still understandable and efficient code. Well, I can always do this: try: with open(somefile.txt) as txtfile: for line in txtfile: print line except IOError: print No such file. No such file. But that's just ugly, nested too many times (flat is better than nested, right?) and not all that more readable. -- http://mail.python.org/mailman/listinfo/python-list
Re: Genetic programming: pygene, pygp, AST, or (gasp) Lisp?
David Boddie a écrit : On Sunday 20 July 2008 09:52, John Ladasky wrote: Is there a way to interface Lisp to Python, so that I can do all the interface programming in the language I already know best -- and just do the genetic parts in Lisp? I haven't seen exception handling in Lisp, a feature I've come to love in Python. Since it is fairly easy for a randomly-generated program to generate illegal output (I already know this from my initial experiments in Python), I don't think I can live without exception handling. Just searching the Web for Python and Lisp yielded some interesting projects: http://www.biostat.wisc.edu/~annis/creations/PyLisp/ http://www.livelogix.net/logix/ I've no idea if they're really that relevant to your problem, but they might lead somewhere useful. David CLPython seems also a good alternative : http://common-lisp.net/project/clpython/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Not entirely serious: recursive lambda?
Michael Tobis wrote: I realize that lambda is something of an orphan and was arguably a bad idea for anything besides obfuscation, but obfuscation is exactly my purpose here. Can a lambda call itself without giving itself a name? Google was not my friend on this one, and I suspect there is no answer. Relax, I am not going to submit a PEP about it. gerson kurz' writings on lambdaization might be helpful (or not): http://www.p-nand-q.com/python/lambdaizing_quicksort.html http://www.p-nand-q.com/python/stupid_lambda_tricks.html /F -- http://mail.python.org/mailman/listinfo/python-list
a question that can accelerate learning python?
I am new to python .But interest in it . I think if python could provide a method that show every method of an object or an module.it will be great! We can save a lot of time to find the document take win32com as an example: if code like this win32com.query(or some other name that means query) it would return a list of module or method that win32com have. Does python have implement such interface yet? 'cause I have not so familiar with python. best wishes! -- http://mail.python.org/mailman/listinfo/python-list
Re: Unusual Exception Behaviour
On Jul 18, 5:12 pm, Robert Rawlins [EMAIL PROTECTED] wrote: This is really quite frustrating as I'd much rather use a conf file than work this programmatically. I get the feeling that it's because in the config file I was not attaching any handlers to the root logger, but I don't know. There's no reason why not having a handler for the root logger would cause any particular problem. For example, the following script: #- start of logconftest.py -- import logging, logging.config logging.config.fileConfig(log.conf) app_logger = logging.getLogger(application) sa_logger = logging.getLogger(sqlalchemy) loggers = [app_logger, sa_logger] def func1(): raise Exception(Exception from func1) def func2(): raise TypeError(TypeError from func2) def func3(): raise ValueError(ValueError from func3) funcs = [func1, func2, func3] for x in range(10): try: f = funcs[x % 3] f() except Exception, e: loggers[x % 2].exception(%d. Problem in %s, x, f.__name__) #- end of logconftest.py together with the following configuration file (almost the same as yours): ;-- start of log.conf --- [loggers] keys=root,application,sqlalchemy [handlers] keys=hand01,hand03 [formatters] keys=form01 [logger_root] level=DEBUG handlers= [logger_application] level=DEBUG handlers=hand01 qualname=application [logger_sqlalchemy] level=DEBUG handlers=hand03 qualname=sqlalchemy [handler_hand01] class=handlers.RotatingFileHandler level=DEBUG formatter=form01 args=('application.log', 'a', 80, 5) [handler_hand03] class=handlers.RotatingFileHandler level=DEBUG formatter=form01 args=('sqlalchemy.log', 'a', 80, 5) [formatter_form01] format=%(asctime)s %(filename)s %(lineno)d %(levelname)-8s %(message)s datefmt= class=logging.Formatter ;-- end of log.conf - gives the following output: -- start of application.log - 2008-07-20 14:47:05,608 logconftest.py 26 ERROR0. Problem in func1 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 11, in func1 raise Exception(Exception from func1) Exception: Exception from func1 2008-07-20 14:47:05,608 logconftest.py 26 ERROR2. Problem in func3 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 17, in func3 raise ValueError(ValueError from func3) ValueError: ValueError from func3 2008-07-20 14:47:05,608 logconftest.py 26 ERROR4. Problem in func2 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 14, in func2 raise TypeError(TypeError from func2) TypeError: TypeError from func2 2008-07-20 14:47:05,608 logconftest.py 26 ERROR6. Problem in func1 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 11, in func1 raise Exception(Exception from func1) Exception: Exception from func1 2008-07-20 14:47:05,608 logconftest.py 26 ERROR8. Problem in func3 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 17, in func3 raise ValueError(ValueError from func3) ValueError: ValueError from func3 -- end of application.log --- -- start of sqlalchemy.log -- 2008-07-20 14:47:05,608 logconftest.py 26 ERROR1. Problem in func2 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 14, in func2 raise TypeError(TypeError from func2) TypeError: TypeError from func2 2008-07-20 14:47:05,608 logconftest.py 26 ERROR3. Problem in func1 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 11, in func1 raise Exception(Exception from func1) Exception: Exception from func1 2008-07-20 14:47:05,608 logconftest.py 26 ERROR5. Problem in func3 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 17, in func3 raise ValueError(ValueError from func3) ValueError: ValueError from func3 2008-07-20 14:47:05,608 logconftest.py 26 ERROR7. Problem in func2 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 14, in func2 raise TypeError(TypeError from func2) TypeError: TypeError from func2 2008-07-20 14:47:05,625 logconftest.py 26 ERROR9. Problem in func1 Traceback (most recent call last): File C:\Temp\logconftest.py, line 24, in module f() File C:\Temp\logconftest.py, line 11, in func1 raise Exception(Exception from func1) Exception: Exception from func1 -- end of sqlalchemy.log which is,
running a script with an input file
I'd like to run a program so that it reads the input() or raw_input() statements from an input file instead of reading from keyboard. I'd also like it to write the print statements in an output file rather than on the screen. I'm on windows XP and when I run: prog_name.py input_file output_file I get an EOF error. What should I do to make this work? Thx, David -- http://mail.python.org/mailman/listinfo/python-list
Re: matplotlib: Plotting a graph against time
On Jul 20, 8:55 am, arsyed [EMAIL PROTECTED] wrote: On Jul 19, 3:09 pm, Durand [EMAIL PROTECTED] wrote: Hi, I'm trying to plot a simple graph against date or time using matplotlib. I've read about date_plot but I'm not really sure how to use it. At the moment, I have some data arranged into lists, where list1 contains x values (time) and list2 contains y values just like is needed for the normal plot function. The time values are simply the output of datetime.date.today(), etc which I don't mind changing the format of. My question is, how do I plot the graph with list1 on the x axis and list2 on the y axis. Using plot and unixtime I get a very ugly scale as is to be expected so I want to know how to use the date_plot function efficiently. At the moment, I'm only concerned about the actual plotting but help with Locater Ticks (Months and Years) is also very appreciated. Thanks a lot! I'm not sure if this is what you're looking for, but here's a quick sample that uses plot_date to plot some random values. import pylab, random from datetime import datetime, timedelta today = datetime.now() dates = [today + timedelta(days=i) for i in range(10)] values = [random.randint(1, 20) for i in range(10)] pylab.plot_date(pylab.date2num(dates), values, linestyle='-') Oooh, this is almost what I want but I'm not really sure how I'd incorporate this into real dates... If I have a list of dates like ['2008-07-18 14:36:53.494013', '2008-07-20 14:37:01.508990', '2008-07-28 14:49:26.183256'], how would I convert it to a format that pylab can understand? When I tried type(datetime.now()) it gave me datetime.datetime whereas the objects in this list are strings...Am I doing something wrong here? -- http://mail.python.org/mailman/listinfo/python-list
Re: a question that can accelerate learning python?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simple. dir(object) [EMAIL PROTECTED] wrote: I am new to python .But interest in it . I think if python could provide a method that show every method of an object or an module.it will be great! We can save a lot of time to find the document take win32com as an example: if code like this win32com.query(or some other name that means query) it would return a list of module or method that win32com have. Does python have implement such interface yet? 'cause I have not so familiar with python. best wishes! -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkiDRGMACgkQLMI5fndAv9g76ACdGJsxrSuaFot0SnHmlnFYaw7W muoAn0KZvyG2PgE2hoaQZLIjD5YvBYuK =WFxU -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
scanf equivalent in python
Hello, I often need to parse strings which contain a mix of characters, integers and floats, the C-language scanf function is very practical for this purpose. I've been looking for such a feature and I have been quite surprised to find that it has been discussed as far back as 2001 but never implemented. The recommended approach seems to be to use split and then atoi or atof or to use regex and then atoi and atof. Both approaches seem to be a lot less natural and much more cumbersome than scanf. If python already has a % string operator that behaves like printf, why not implement either a %% or string operator to behave like scanf, use could be like the followng: a, b, c = %d %f %5c %% 1 2.0 abcde or a, b, c = %d %f %5c 1 2.0 abcde %% is closer to the % operator seems more intuitive to me either of this methods seems to me much simpler than: lst = 1 2;0 abcde.split() a = int(lst[0]) b = float(lst[1]) c = lst[2] or even worse when using regular expressions to parse such simple input. I like python because it is concise and easy to read and I really think it could use such an operator. I know this has been discussed before and many times, but all previous threads I found seem to be dead and I would like to invite further investigation of this topic. Cheers, André M. Descombes -- http://mail.python.org/mailman/listinfo/python-list
Re: Rotating a cube
Fredrik Lundh wrote: David Lyon wrote: But is the question about display graphics ? ie rotating a cube using a python framework ? With something like python and OpenGL ? or Python and PovRay... or perphaps python and imagemagick ? can you name one graphics framework that represents a cube as x + 4*y + 16*z ? no, but ... I don't think the notation is so strange, in electronics (and others) I'm used to a 2-dimensional complex notation: vector = 3 + 4*i = 3*x +4*y but although my English isn;t very well, a cube of 4*4 looks strange to me. cheers, Stef /F -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: regex doubts
John Machin wrote: try [LRM]+$ (an L or an R or an M, one or more times, all the way to the end of the string). Ummm ... with the default flag settings, shouldn't that be \Z instead of $ ? Why? The OP was reading input from a user; whether he gets a trailing newline or not depends on the input method, and $ does the right thing for all normal input methods. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: round function error???
On Jul 19, 12:20 am, John Machin [EMAIL PROTECTED] wrote: On Jul 19, 8:05 am, Mark Dickinson [EMAIL PROTECTED] wrote: for more information. But I'm guessing that you're questioning the fact that a value that's apparently *less* than 3499.35 is rounded up to 3499.4, rather than down to 3499.3. ? apparently being the operative word. Well, it's not just an apparent problem: the closest floating-point number to 3499.35 really *is* less than 3499.35. A nice way to check this is using the new fractions module in 2.6, which allows exact conversions of floats and Decimals into rational numbers: Python 2.6b2+ (trunk:65155, Jul 20 2008, 15:39:46) [GCC 4.0.1 (Apple Inc. build 5484)] on darwin Type help, copyright, credits or license for more information. from decimal import Decimal from fractions import Fraction x = 3499.35 y = Decimal('3499.35') Fraction.from_float(x) Fraction(7695152029315891, 219902322) Fraction.from_decimal(y) Fraction(69987, 20) [54933 refs] Fraction.from_float(x) Fraction.from_decimal(y) True Mark -- http://mail.python.org/mailman/listinfo/python-list
Passing keywords
I've a constructor with several values that must be used by any functions: --- class foo: def __init__(self, foo1, foo2, foon): self.__check(foo1=foo1, foo2=foo2, foon=foon) self.__check2(foo1=foo1, foo2=foo2, foon=foon) def __check(self, foo1, foo2, foon): ... def __check2(self, foo1, foo2, foon): ... --- How simplify all that? I could use the next but I don't think... --- def __check(self, **keywords): --- -- http://mail.python.org/mailman/listinfo/python-list
Web Server
As part of a Python app I wrote recently (for Windows), I would like to give the option of an HTTP (HTTPS if possible, but not necessary) front end, which would then call some existing python scripts. My question is - I know I can write a simple HTTP server in Python, but if there's something simple already out there, I'd prefer to just use that. Basically all I need is a simple (i.e. preferably a single executable) web server that can serve up my content - the only thing I want the user to be able to configure is the port the web server listens on (or ports if HTTPS also), and the location of the HTML files... thanks in advance for your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Server
[EMAIL PROTECTED] wrote: As part of a Python app I wrote recently (for Windows), I would like to give the option of an HTTP (HTTPS if possible, but not necessary) front end, which would then call some existing python scripts. My question is - I know I can write a simple HTTP server in Python, but if there's something simple already out there, I'd prefer to just use that. Basically all I need is a simple (i.e. preferably a single executable) web server that can serve up my content - the only thing I want the user to be able to configure is the port the web server listens on (or ports if HTTPS also), and the location of the HTML files... thanks in advance for your help. import SimpleHTTPServer ? sample code here: http://effbot.org/librarybook/simplehttpserver.htm /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing keywords
Kless wrote: I could use the next but I don't think... --- def __check(self, **keywords): --- don't think what? if you keep using the same variables in all submethods you call from a method inside the class, why not make them attributes? otherwise, using the **-form when *calling* the methods might work. you can use the **-form in the functions to ignore arguments that you're not interested in. self.__check(**kwargs) self.__check2(**kwargs) def __check(self, foo1, foo2, **extra): # use foo1 and foo2 here; ignore the rest etc. /F -- http://mail.python.org/mailman/listinfo/python-list
Run as Service
I have, in the past, used SRVANY to run a Python app as a Windows service. However, now I am interested in distributing my scripts and want to make it as painless for the end user as possible (hands-off is best :). How can you go about running a Python app as a Windows service without SRVANY? -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Server
Thanks, Fredrik - that definitely works. Now to get a little greedy - is there something along those lines that is a bit more secure (i.e. allows HTTPS, possibly with authentication)? Basically something that you would feel more comfortable opening up to the Internet.. -- http://mail.python.org/mailman/listinfo/python-list
Re: getting with statement to deal with various exceptions
mk [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException finally: tear_it_down() Verbose, not very readable. OK, with to the rescue? Let's take a textbook example from PEP: with open('/etc/passwd', 'r') as f: BLOCK Well, great, it's neat that with closes the file after BLOCK has finished execution, but what if the file isn't there and attempt to open it raises IOException? I'd like to be able to catch it precisely to avoid writing verbose try: .. except: .. finally: .. blocks which as I understand has been much of the rationale behind creating with statement in the first place. with statement only allows easy dealing with prepare() and tear_it_down(). When I try to get it to deal with exceptions that might happen, it becomes more complicated: class FileContextManager: def __enter__(self, filename, mode): f = open(filename, mode) return f def __exit__(self, etype, evalue, etraceback): print etype, etype, evalue, evalue, etraceback, etraceback with FileContextManager(somefile, r) as f: a = f.readlines() Traceback (most recent call last): File pyshell#36, line 1, in module with FileContextManager(somefile, r) as f: TypeError: this constructor takes no arguments Bummer. Plus, no documentation I've read (on effbot, in PEP 343, etc) says how to deal with the exception happening in __enter__ method of context manager, which is precisely what I'd like to do. This is only natural, isn't it? When e.g. reading the file, preparation phase is typically checking if it can be opened in the first place. So it falls into __enter__ method of context manager. with limited only to successful execution of a_statement from with a_statement seems like limited benefit to me. I'd like to be able to write smth like class FileContextManager: def __enter__(self, filename, mode): f = open(filename, mode) return f def __except__(IOError, err): do_this print err def __except__(RuntimeError, err): do_that print something bad happened, err def __exit__(self, etype, evalue, etraceback): print etype, etype, evalue, evalue, etraceback, etraceback __exit__ deals with exceptions happening in the BLOCK below with statement, not with exceptions raised in a_statement, when executing with a_statement as var: BLOCK In the above way with would give me the benefit of more terse, but still understandable and efficient code. Well, I can always do this: try: with open(somefile.txt) as txtfile: for line in txtfile: print line except IOError: print No such file. No such file. But that's just ugly, nested too many times (flat is better than nested, right?) and not all that more readable. I just started looking at the with statement myself. How about: from __future__ import with_statement class ExceptionManager(object): def __enter__(self): pass def __exit__(self,exc_type,exc_value,tb): if exc_type == IOError: print 'IOError',exc_value[1] return True # suppress it with ExceptionManager(): with open('test.txt') as f: f.read() -- Mark -- http://mail.python.org/mailman/listinfo/python-list
Re: singletons
In article [EMAIL PROTECTED], Craig Allen [EMAIL PROTECTED] wrote: (option 2) Therefore option two is a family of options where class level members can be used to share whatever needs to be shared, though strictly the class is not a singleton since multiple instances are created which merely share the data that should be single (say a big dictionary of configuration information the class manages). That's only true if you actually instantiate the class. You can just use the class directly -- that's what I do. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Adopt A Process -- stop killing all your children! -- http://mail.python.org/mailman/listinfo/python-list
Re: trying to match a string
John Machin wrote: On Jul 20, 11:14 am, Andrew Freeman [EMAIL PROTECTED] wrote: John Machin wrote: (4) I highly doubt that this code was actually to be used in an interactive session, The offending code is a nonsense wherever it is used. the False/True output was truncated intentionally, What meaning are you attaching to truncated? I'm attaching the meaning of deleted the line (manually (not in python)) to truncated, I'm actually using ipython, but though it would be a good practice to type it out as if it come from the standard interpretor. I also though it would be OK to leave out some output which I considered unnecessary. -- http://mail.python.org/mailman/listinfo/python-list
re: question
Nobody any sensible answers. Too complicated I suppose! -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
... the thunks were necessary at the machine-language level to /implement/ ALGOL 60, but they could not be expressed /in/ ALGOL. Ah, thanks for the clarification. Is that info in the appropriate WikiPedia page? If not, maybe you would edit it in? From: John W Kennedy [EMAIL PROTECTED] It is explained s.v. thunk, which is referenced from ALGOL 60. The ALGOL pass-by-name argument/parameter matching was perhaps the most extreme example ever of a language feature that was elegant but insane. What it meant, in effect, was that, unless otherwise marked, every argument was passed as two closures, one that returned a fresh evaluation of the expression given as the argument, which was called every time the parameter was read, and one that set the argument to a new value, which was called every time the parameter was set. Wow! All these years when I occasionally heard of a thunk I never was told, until now, what it really meant. Thanks for the info!! Followup question #1: I assume these are lexical closures in the environment of the point of the call, right? Followup question #2: For simple arithmetic expressions, I can possibly understand how the UPDATE closure might be implemeted (expressed in Lisp to make the intent clear): Call form: MyFunction(X+2); GET closure: (+ closedX 2) UPDATE closure: (lambda (newval) (setf closedX (- newval 2)) Thus from inside MyFunction where formal parameter Arg1 is bound to actual parameter X+2, after doing Arg1 := 7; X will have the value 5 so that calling Arg1 will return 7 as expected, right? But if the actual argument is something complicated, especially if it makes a nested function call, how can that possibly be implemented? Given an arbitrary expression that calls some external function, how can assigning a value to that expression make sufficient changes in the runtime environment such that subsequently evaluating that expression will yield the expected value i.e. the value that had been assigned? Or is the default of passing two closures (GET and UPDATE) *only* if the actual-argument expression is simple enough that it's invertible, and in complicated cases only a GET closure is passed (or the UPDATE closure is simply a signal of a runtime error that you're not allowed to assign a value to a complicated expression)? IMO the right way to pass parameters that can be modified is to use locatatives as in the Lisp Machine. That converts the idea of a place (as used by SETF in Common Lisp) into a first class citizen which can be passed around and stored etc., compared to a SETF place which is merely a compiletime-macro trick to convert place-references in source code into direct calls to the appropriate accessor just above the place followed by specialized SETter call to do the act. A hack to emulate a locative in CL would be to pass a closure where the code to find the object directly containing the place, and any parameters needed to find that place, and the function needed to perform the act. Then the called function would need to know it's going to get such a thunk-like closure, but since it's expecting to modify one of its parameters anyway, that's reasonable. Sketch of implementation (two special cases): (defun make-thunk-cadr (topptr) (let* ((midptr (cdr topptr)) (getclo (make-getter-closure :PARENT midptr :GETTERFN #'car :PARMS nil)) (setclo (make-setter-closure :PARENT midptr :SETTERFN #'rplaca :PARMS nil))) (make-thunk getclo setclo)) (defun make-thunk-aref1 (topptr arrindex1) (let ((getclo (make-getter-closure :PARENT topptr :GETTERFN #'aref1 :PARMS (list arrindex1))) (setclo (make-setter-closure :PARENT midptr :SETTERFN #'setaref1 :PARMS (list arrindex1 (make-thunk getclo setclo)) (defun swap (thunk1 thunk2) (prog (tmp) (setq tmp (thunk-get thunk1)) (thunk-set thunk1 (thunk-get thunk2)) (thunk-set thunk2 tmp))) ;Definitions of make-getter-closure make-setter-closure make-thunk ; thunk-get thunk-set not shown because they depend on whether ; closures and thunks are implemented via tagged assoc lists or ; DEFSTRUCT structures or CLOS objects or whatever. But I made the ; call to the constructors explicit enough that it should be obvious ; what components are inside each type of object. Note that with ; CLOS objects, this could all be condensed to have a single CLOS ; object which is the thunk which has two methods GET and SET, no ; need to make closures for get and set separately, templates for ; those closures are made automatically when the CLOS class is ; defined, and closures are generated from those templates whenever ; a new CLOS thunk-object is made. Thus: ; ... (make-CLOS-thunk :PARENT topptr :GETTERFN #'aref1 :SETTERFN #'setaref1 ; :PARMS (list arrindex1)) ... ;Example that should actually work: (format t
Re: Run as Service
On Jul 20, 10:48 am, [EMAIL PROTECTED] wrote: I have, in the past, used SRVANY to run a Python app as a Windows service. However, now I am interested in distributing my scripts and want to make it as painless for the end user as possible (hands-off is best :). How can you go about running a Python app as a Windows service without SRVANY? I have used CherryPy sucessfully as a windows service. You can probably glean what you need from. http://tools.cherrypy.org/wiki/WindowsService HTH. ... Jay Graves -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Server
[EMAIL PROTECTED] wrote: Thanks, Fredrik - that definitely works. Now to get a little greedy - is there something along those lines that is a bit more secure (i.e. allows HTTPS, possibly with authentication)? Basically something that you would feel more comfortable opening up to the Internet.. open up to whom? I'm not sure I like the combination of windows app and opened up to the internet, really... but assuming that you're aware of the issues involved, and want a light-weight HTTP server for Windows, this one's pretty nice: http://www.aprelium.com/abyssws/ there's also apache, of course, and a bunch of others, including several Python solutions (more or less pre-packaged). but the open up part still sounds a bit risky. maybe you could turn things around, and let the application push data to your server instead? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if an object IS in a list
(1) You are searching through lists to find float objects by identity, not by value -- http://mail.python.org/mailman/listinfo/python-list
Re: question
On Jul 20, 6:39 pm, [EMAIL PROTECTED] wrote: Nobody any sensible answers. Too complicated I suppose! The sensible question was? -- http://mail.python.org/mailman/listinfo/python-list
Re: question
I think the question was: why does anyone still use perl when Python is clearly the better language? On Sun, Jul 20, 2008 at 2:17 PM, Paddy [EMAIL PROTECTED] wrote: On Jul 20, 6:39 pm, [EMAIL PROTECTED] wrote: Nobody any sensible answers. Too complicated I suppose! The sensible question was? -- http://mail.python.org/mailman/listinfo/python-list -- | _ | * | _ | | _ | _ | * | | * | * | * | -- http://mail.python.org/mailman/listinfo/python-list
Re: re: question
On Sun, 20 Jul 2008 18:39:52 +0100, Perl_Wizard wrote: Nobody any sensible answers. Too complicated I suppose! I've often been asked that, i'd be able to buy me a mars bar! Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Testing out NewsProxy
Please excuse this post, but I am seeing if NewsProxy actually filters out Google Groups or not. -- http://mail.python.org/mailman/listinfo/python-list
Testing out Newsproxy.
Going to see if Newsproxy actually blocks google groups. -=___=- David M Lemcoe Jr. Roswell, Georgia http://www.davidlemcoe.com/ [EMAIL PROTECTED] QRZ: KI4YJL AIM: lemcoe9 YIM: lemcoe9 GTalk: [EMAIL PROTECTED] MSN: [EMAIL PROTECTED] Xfire: shawtylo1 ICQ: 359114839 Alternate e-mail: [EMAIL PROTECTED] -=___=- -- http://mail.python.org/mailman/listinfo/python-list
Re: regex doubts
On Jul 21, 12:30 am, Fredrik Lundh [EMAIL PROTECTED] wrote: John Machin wrote: try [LRM]+$ (an L or an R or an M, one or more times, all the way to the end of the string). Ummm ... with the default flag settings, shouldn't that be \Z instead of $ ? Why? The OP was reading input from a user; whether he gets a trailing newline or not depends on the input method, and $ does the right thing for all normal input methods. The goal as far as I can tell was to produce a pattern that matched one (maybe zero) or more instances of 'L', 'R', or 'M', and no other characters. bool(re.match(r'[LRM]+\Z', 'MRL\n')) False bool(re.match(r'[LRM]+$', 'MRL\n')) True '\n' is an other character. Perhaps you could explain what you mean by $ does the right thing. -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if an object IS in a list
On Jul 21, 4:33 am, [EMAIL PROTECTED] wrote: (1) You are searching through lists to find float objects by identity, not by value You wrote I used short lists (a list of 20 floats) and the element checked was not in the list. (That was the case I usually deals with in my code.) -- http://mail.python.org/mailman/listinfo/python-list
Re: round function error???
On Jul 21, 12:56 am, Mark Dickinson [EMAIL PROTECTED] wrote: On Jul 19, 12:20 am, John Machin [EMAIL PROTECTED] wrote: On Jul 19, 8:05 am, Mark Dickinson [EMAIL PROTECTED] wrote: for more information. But I'm guessing that you're questioning the fact that a value that's apparently *less* than 3499.35 is rounded up to 3499.4, rather than down to 3499.3. ? apparently being the operative word. Well, it's not just an apparent problem: the closest floating-point number to 3499.35 really *is* less than 3499.35. I'm well aware of that. My point is that I hope that you weren't planning on changing that behaviour in an unannounced unstaged manner. -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Server
Fredrik Lundh [EMAIL PROTECTED] wrote: there's also apache, of course, and a bunch of others, including several Python solutions (more or less pre-packaged). but the open up part still sounds a bit risky. maybe you could turn things around, and let the application push data to your server instead? Either way requires an open port, otherwise there's no way to negotiate new clients. If your in a closed environment that's not a concern, you could just define what clients to push to and when, but it sounds like he wants something a bit more dynamic. -- James Tanis Technical Coordinator Monsignor Donovan Catholic High School e: [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: regex doubts
On Jul 19, 10:44 pm, John Machin [EMAIL PROTECTED] wrote: On Jul 20, 6:35 am, MRAB [EMAIL PROTECTED] wrote: On Jul 19, 9:12 pm, John Machin [EMAIL PROTECTED] wrote: On Jul 20, 5:04 am, Fredrik Lundh [EMAIL PROTECTED] wrote: Mr SZ wrote: I am taking a string as an input from the user and it should only contain the chars:L , M or R I tried the folllowing in kodos but they are still not perfect: [^A-K,^N-Q,^S-Z,^0-9] [L][M][R] [LRM]?L?[LRM]? etc but they do not exactly meet what I need. For eg: LRLRLRLRLM is ok but LRLRLRNL is not as it has 'N' .like that. try [LRM]+$ (an L or an R or an M, one or more times, all the way to the end of the string). Ummm ... with the default flag settings, shouldn't that be \Z instead of $ ? $ means end of string unless the multiline flag is used, in which case it means end of line. What manual are you quoting that from? What version of Python are you using? Can you demonstrate that the pattern [LRM]+$ will fail to match the string L\n? I see what you mean: $ does match end of line if the newline is the last character of the string. -- http://mail.python.org/mailman/listinfo/python-list
Re: examples of pipe usage?
On Sun, Jul 20, 2008 at 5:27 PM, Sean McIlroy [EMAIL PROTECTED] wrote: hola i'd like to control another interpreter from idle. i don't have any experience using unix but i think a pipe is what i need. am i right about this? can anybody point me to a simple example of using a pipe (if that's the right thing) for this kind of task? thanks if you can help. Take a look at the URL below which has a bunch of examples of using the subprocess module to interact with other processes. http://blog.doughellmann.com/2007/07/pymotw-subprocess.html -- http://mail.python.org/mailman/listinfo/python-list
Re: checking if an object IS in a list
On 20 juil, 23:18, John Machin [EMAIL PROTECTED] wrote: On Jul 21, 4:33 am, [EMAIL PROTECTED] wrote: (1) You are searching through lists to find float objects by identity, not by value You wrote I used short lists (a list of 20 floats) and the element checked was not in the list. (That was the case I usually deals with in my code.) :-D -- http://mail.python.org/mailman/listinfo/python-list
Re: The Importance of Terminology's Quality
Robert Maas, http://tinyurl.com/uh3t wrote: ... the thunks were necessary at the machine-language level to /implement/ ALGOL 60, but they could not be expressed /in/ ALGOL. Ah, thanks for the clarification. Is that info in the appropriate WikiPedia page? If not, maybe you would edit it in? From: John W Kennedy [EMAIL PROTECTED] It is explained s.v. thunk, which is referenced from ALGOL 60. The ALGOL pass-by-name argument/parameter matching was perhaps the most extreme example ever of a language feature that was elegant but insane. What it meant, in effect, was that, unless otherwise marked, every argument was passed as two closures, one that returned a fresh evaluation of the expression given as the argument, which was called every time the parameter was read, and one that set the argument to a new value, which was called every time the parameter was set. Wow! All these years when I occasionally heard of a thunk I never was told, until now, what it really meant. Thanks for the info!! Followup question #1: I assume these are lexical closures in the environment of the point of the call, right? Yes. (Actually, subprogram calls are first described as working like macro expansions, but then the specification adds that there must be magic fixups so that variable names are resolved in point-of-call context anyway.) At this point in the history of computing, the conceptual distinction between subprograms and macros was not at all clear. It was quite possible to have macros that generated an out-of-line subprogram once and then generated calling code the first time and every time thereafter (it was a way of life on systems without linkage editors or linking loaders), and it was also quite possible to refer to in-line macro expansions as subprograms. I suspect that the triumph of FORTRAN may have had something to do with cleaning up the terminological mess by the mid-60s. Into the 60s, indeed, there were still machines being made that had no instruction comparable to the mainframe BASx/BALx family, or to Intel's CALL. You had to do a subprogram call by first overwriting the last instruction of what you were calling with a branch instruction that would return back to you. Followup question #2: For simple arithmetic expressions, I can possibly understand how the UPDATE closure might be implemeted (expressed in Lisp to make the intent clear): Call form: MyFunction(X+2); GET closure: (+ closedX 2) UPDATE closure: (lambda (newval) (setf closedX (- newval 2)) Thus from inside MyFunction where formal parameter Arg1 is bound to actual parameter X+2, after doing Arg1 := 7; X will have the value 5 so that calling Arg1 will return 7 as expected, right? But if the actual argument is something complicated, especially if it makes a nested function call, how can that possibly be implemented? It was forbidden. In the formal definition of ALGOL 60, there was no such thing as an external subprogram (except for non-ALGOL code, which was treated as magic), so the whole program was supposed to be one compile. Therefore, a theoretical compiler could verify that any parameter used as an LHS was always matched with an argument that was a variable. (However, a thunk was still required to evaluate any array index and, possibly, to convert between REAL and INTEGER variables.) Many actual compilers /did/ support separate complication as a language extension -- I suppose they had to use run-time checking. -- John W. Kennedy Compact is becoming contract, Man only earns and pays. -- Charles Williams. Bors to Elayne: On the King's Coins -- http://mail.python.org/mailman/listinfo/python-list
Python Written in C?
I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each MPU chip out there. Otherwise, if, say, they've written it in C#, then it looks like the REAL, generally useful language to learn is C# and Python is akin to Visual Basic or something: a specialty languagewhereas REAL WORLD programmers who want to be generally useful go and learn C#. So I was suspecting the Python compiler or interpreter is written in a REAL language like C#. So, Wiki says it's written in C! It's almost as if it were an intentional trick...write your own, new language in an OLD, real world language that is passe. Compile it into executable modules of course, so it is a real, working compiler, alright. But the SOURCE is some old, high level language which no one wants to use anymore! So now you've got a hot new language package and no one can say well, it is written in, the SOURCE code is written in, a REAL language. No, it's not! The source is some outdated language and compiler and no one is going to prefer learning THAT to learning your hot new language! I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 21, 8:50 am, [EMAIL PROTECTED] wrote: I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. The advantage of Python over C - to me - is in the higher order abstractions it provides, not in pointless discussions of purity. Even better, Python allows me to -mix- both C Python together, to take advantage of the strengths of each as appropriate. Try writing something of complexity in Python. Then write the same thing in C. -Then- make your decision which you prefer. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 20, 5:50�pm, [EMAIL PROTECTED] wrote: I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each MPU chip out there. Otherwise, if, say, they've written it in C#, then it looks like the REAL, generally useful language to learn is C# and Python is akin to Visual Basic or something: a specialty languagewhereas REAL WORLD programmers who want to be generally useful go and learn C#. Python is for people who want to program, not REAL WORLD programmers. So I was suspecting the Python compiler or interpreter is written in a REAL language like C#. So, Wiki says it's written in C! It's almost as if it were an intentional trick...write your own, new language in an OLD, real world language that is passe. Compile it into executable modules of course, so it is a real, working compiler, alright. But the SOURCE is some old, high level language C isn't a high level language, that's part of its problem. which no one wants to use anymore! So now you've got a hot new language package and no one can say well, it is written in, the SOURCE code is written in, a REAL language. No, it's not! The source is some outdated language and compiler and no one is going to prefer learning THAT to learning your hot new language! I'm not dissing Python, here. Yes, you are. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. Then go learn C, nobody's stopping you. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
In article [EMAIL PROTECTED], Mensanator [EMAIL PROTECTED] wrote: C isn't a high level language, that's part of its problem. C is the highest level assembler language I've ever used. And I've used a few. It really is cool that you can add two 32-bit integers and not have to worry about all those carry bits. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 21, 8:50 am, [EMAIL PROTECTED] wrote: I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each MPU chip out there. Why do that, when gcc has a code generator for just about every MPU chip out there? Otherwise, if, say, they've written it in C#, then it looks like the REAL, generally useful language to learn is C# A bit of a non sequitur and C# is available on how many different MPU chips? and Python is akin to Visual Basic chuckle/ or something: a specialty language whereas REAL WORLD programmers who want to be generally useful go and learn C#. ? So I was suspecting the Python compiler or interpreter is written in a REAL language like C#. So, Wiki says it's written in C! It's almost as if it were an intentional trick...write your own, new language in an OLD, real world language that is passe. Compile it into executable modules of course, so it is a real, working compiler, alright. But the SOURCE is some old, high level language which no one wants to use anymore! Nobody wants to use C any more? So now you've got a hot new language package and no one can say well, it is written in, the SOURCE code is written in, a REAL language. No, it's not! The source is some outdated language and compiler and no one is going to prefer learning THAT to learning your hot new language! I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. It should be sublimely irrelevant to most people learning LanguageX what language LanguageX is written in. Some other implementations of Python: PyPy (written in Python), Jython (written in Java) and IronPython (written in C#). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 20, 6:50 pm, [EMAIL PROTECTED] wrote: I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. I somehow doubt the Python community will feel much of a loss if you decide to learn some other language. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
[EMAIL PROTECTED] writes: I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? Well, yes, the interpreter and a handful of the core modules are written in C. However, most of Python -- especially the cool bits -- aren't written in C. They're written in ... Python! -- Teiresias -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
Giveitawhril wrote... REAL WORLD programmers who want to be generally useful go and learn C#. No: Real programmers first eat a quiche and then return to their Pascal programming. But the SOURCE is some old, high level language which no one wants to use anymore! C is alive and kicking. Every language has its place. Plus, there exists implementations of Python written in Python itself; see PyPy: http://codespeak.net/pypy/dist/pypy/doc/home.html Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. Many major text/word processing programs (Emacs, vi, MS-Word) are also written in C. Does that mean you should do all your text processing in C? Greetings, -- The ability of the OSS process to collect and harness the collective IQ of thousands of individuals across the Internet is simply amazing. - Vinod Vallopillil http://www.catb.org/~esr/halloween/halloween4.html -- http://mail.python.org/mailman/listinfo/python-list
db question
Hi... simple test mysql cmd - select * from foo where dog like %small%; sql =select * from foo where dog like %%%s%% c.execute(sql, (var,)) the above doesn't work, and I can't seem to figure out how to display/print out the sql as i't actually been excuted, so I can see where the issue is. i've tried to / escape, as well as a few other things, now of which shed any light on the issue. haven't found any information via google either. the above works if i have something like sql=select * from foo where dog=%s c.execute(sql,(var,)) so.. any help/pointers on what i've screwed up/missed would be helpful. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Sun, Jul 20, 2008 at 9:18 PM, Michiel Overtoom [EMAIL PROTECTED] wrote: Giveitawhril wrote... REAL WORLD programmers who want to be generally useful go and learn C#. No: Real programmers first eat a quiche and then return to their Pascal programming. Bah, new-fangled languages like Pascal... Real programmers write Fortran. But the SOURCE is some old, high level language which no one wants to use anymore! C is alive and kicking. Every language has its place. Plus, there exists implementations of Python written in Python itself; see PyPy: http://codespeak.net/pypy/dist/pypy/doc/home.html Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. Many major text/word processing programs (Emacs, vi, MS-Word) are also written in C. Does that mean you should do all your text processing in C? Don't you? /snark -- http://mail.python.org/mailman/listinfo/python-list
db question
update... in using the mysql_query log function, i get the following query being registered: select * from foo where dog like %'small'% so.. if i can figure out how to get rid of the ' inside the % the query should/will work... thanks Hi... simple test mysql cmd - select * from foo where dog like %small%; sql =select * from foo where dog like %%%s%% c.execute(sql, (var,)) the above doesn't work, and I can't seem to figure out how to display/print out the sql as i't actually been excuted, so I can see where the issue is. i've tried to / escape, as well as a few other things, now of which shed any light on the issue. haven't found any information via google either. the above works if i have something like sql=select * from foo where dog=%s c.execute(sql,(var,)) so.. any help/pointers on what i've screwed up/missed would be helpful. thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 20, 7:37�pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], �Mensanator [EMAIL PROTECTED] wrote: C isn't a high level language, that's part of its problem. C is the highest level assembler language Isn't that like bragging about being the smartest kid on the short bus? I've ever used. �And I've used a few. �It really is cool that you can add two 32-bit integers and not have to worry about all those carry bits. Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? THIS is cool: j = ((invert(xyz[1]-xyz[0],xyz[1]**(k-1))*(xyz[1]**(k-1)-prev_gen[2])) % xyz[1]**(k-1))/xyz[1]**(k-2) -- http://mail.python.org/mailman/listinfo/python-list
Solutions Fast Track - Monitoring and Intrusion
Dear Reader, Designing for Detection - Get the right equipment from the start. Make sure all of the features you need, or will need, are available from the start. - Know your environment. Identify potential physical barriers and possible sources of interference. - If possible, integrate security monitoring and intrusion detection in your network from its inception. Defensive Monitoring Considerations -- - Define your wireless network boundaries, and monitor to know if they’re being exceeded. - Limit signal strength to contain your network. - Make a list of all authorized wireless Access Points (APs) in your environment. Knowing what’s there can help you immediately identify rogue APs. Intrusion Detection Strategies --- - Watch for unauthorized traffic on your network. Odd traffic can be a warning sign. - Choose an intrusion detection software that best suits the needs of your environment. Make sure it supports customizable and updateable signatures. - Keep your signature files current.Whether modifying them yourself, or downloading updates from the manufacturer, make sure this step isn’t forgotten. Conducting Vulnerability Assessments --- - Use tools like NetStumbler and various client software to measure the strength of your 802.11b signal. - Identify weaknesses in your wireless and wired security infrastructure. - Use the findings to know where to fortify your defenses. - Increase monitoring of potential trouble spots. Incident Response and Handling -- - If you already have a standard incident response policy, make updates to it to reflect new potential wireless incidents. - Great incident response policy templates can be found on the Internet. - While updating the policy for wireless activity, take the opportunity to review the policy in its entirety, and make changes where necessary to stay current. An out-of-date incident response policy can be as damaging as not having one at all. Conducting Site Surveys for Rogue Access Points --- - The threat is real, so be prepared. Have a notebook computer handy to use specifically for scanning networks. - Conduct walkthroughs of your premises regularly, even if you don’t have a wireless network. - Keep a list of all authorized APs. Remember, Rogue APs aren’t necessarily only placed by attackers.A well-meaning employee can install APs as well. --- Thank You --- James Conack http://www.centronet.uni.cc -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? THIS is cool: j = ((invert(xyz[1]-xyz[0],xyz[1]**(k-1))*(xyz[1]**(k-1)-prev_gen[2])) % xyz[1]**(k-1))/xyz[1]**(k-2) You call that cool. I call it unreadable. -Steve Johnson -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On 2008-07-21, Dan Upton [EMAIL PROTECTED] wrote: REAL WORLD programmers who want to be generally useful go and learn C#. No: Real programmers first eat a quiche and then return to their Pascal programming. Bah, new-fangled languages like Pascal... Real programmers write Fortran. Using punch-cards and paper-tape. Real programmers can edit their programs with a pointy stick and some home-made sticky-tape. -- Grant Edwards grante Yow! While I'm in at LEVITTOWN I thought I'd visi.comlike to see the NUCLEAR FAMILY!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Sun, Jul 20, 2008 at 5:06 PM, Grant Edwards [EMAIL PROTECTED] wrote: On 2008-07-21, Dan Upton [EMAIL PROTECTED] wrote: Using punch-cards and paper-tape. Real programmers can edit their programs with a pointy stick and some home-made sticky-tape. Doesn't everyone know that REAL programmers use butterflies. http://xkcd.com/378/ -- http://mail.python.org/mailman/listinfo/python-list
Re: % sign in python?
Terry Reedy [EMAIL PROTECTED] wrote: Tim Roberts wrote: Steven Howe [EMAIL PROTECTED] wrote: Terry Reedy wrote: korean_dave wrote: What does this operator do? Specifically in this context test.log( [[Log level %d: %s]] % ( level, msg ), description ) I thought, in this contexted, it was mapping operator. You miss clipped. I never wrote that. Please be careful, especially about attributing mis-information. If you count the signs, you'll see that I correctly attributed the question to korean_dave, and the answer to Steve Howe. Steve's reply contained your name, but there was no text from you in my post. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 20, 10:05�pm, Stephen Johnson [EMAIL PROTECTED] wrote: Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? THIS is cool: j = ((invert(xyz[1]-xyz[0],xyz[1]**(k-1))*(xyz[1]**(k-1)-prev_gen[2])) % xyz[1]**(k-1))/xyz[1]**(k-2) You call that cool. I call it unreadable. Ok, but not in the sense that something like Scheme is unreadable as this is nothing but algebra (albeit complicaed). -Steve Johnson -- http://mail.python.org/mailman/listinfo/python-list
Re: Any Game Developers here?
In article [EMAIL PROTECTED], Python Nutter [EMAIL PROTECTED] wrote: There are two books I know of currently in print on game programming, both use PyGame as it was out first. One book is horrible and only worth for cleaning yourself up after you use the bathroom. The second is really well written (The L express game programming book) and highly recommended if you need to get some basic game design and programming under your belt in Python. Unfortunately, there are some serious bugs in the L-line book because the author doesn't really understand Python. (I know this because I was one of the tech editors.) -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ Adopt A Process -- stop killing all your children! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Sun, Jul 20, 2008 at 11:51 PM, Mensanator [EMAIL PROTECTED] wrote: On Jul 20, 10:05�pm, Stephen Johnson [EMAIL PROTECTED] wrote: Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? THIS is cool: j = ((invert(xyz[1]-xyz[0],xyz[1]**(k-1))*(xyz[1]**(k-1)-prev_gen[2])) % xyz[1]**(k-1))/xyz[1]**(k-2) You call that cool. I call it unreadable. Ok, but not in the sense that something like Scheme is unreadable as this is nothing but algebra (albeit complicaed). Scheme doesn't *have* to be unreadable... any more unreadable than any other language when poorly documented/formatted, anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
Mensanator wrote: On Jul 20, 7:37�pm, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], �Mensanator [EMAIL PROTECTED] wrote: C isn't a high level language, that's part of its problem. C is the highest level assembler language Isn't that like bragging about being the smartest kid on the short bus? I've ever used. �And I've used a few. �It really is cool that you can add two 32-bit integers and not have to worry about all those carry bits. Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? Perhaps you missed the wonderful humor in Roy's post. It was rather brilliant. Sorry you missed it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
[EMAIL PROTECTED] wrote: I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. Definitely one of the most non-sequitor statements I have ever heard. Actually your entire post doesn't make much sense. Maybe you are a brother bot to castropini? Perhaps a less-trained one, although none of castropini's posts seem to make sense either. The AI needs a bit of work. I am very confused over your incoherent ramblings about C# being some how more real than C, or Python, or Visual Basic, or any other language. I fail to grasp what connection the syntax of a language has to do with anything being real or not. You first say you hope someone was writing optimized assembly for python on the different platforms (I'm not familiar with the acronym MPU.) and then go on to say it should have been written with C#. I'm confused as to what C# has to do with optimized, platform-specific assembly. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
I think your mixing things up. Even modern C compiler are mostly written in some other high level language. See GCC, for instance: it's mostly written in C. Many languages are made for build other major systems: * C was made in order to ease the build of Unix * Ada was made in order to ease the build of Air Traffic Control Systems. * and so on... On the other hand, Python's language features are, in a way, orthogonal to those of the underlying language in which Python *may* be implemented (take a look at PyPy: http://en.wikipedia.org/wiki/PyPy). I mean, I really don't care how Python mappings are implemented in C. What I care about is that I think in terms of (key, value) mappings, regardless of how lookups, insertions, deletions, and so are made internally. In C, I would have to resort to implement a hash table or so. Let's summarize: Python is a *new* language. C was the option to make it happen, there are others. Manuel. [EMAIL PROTECTED] wrote: I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each MPU chip out there. Otherwise, if, say, they've written it in C#, then it looks like the REAL, generally useful language to learn is C# and Python is akin to Visual Basic or something: a specialty languagewhereas REAL WORLD programmers who want to be generally useful go and learn C#. So I was suspecting the Python compiler or interpreter is written in a REAL language like C#. So, Wiki says it's written in C! It's almost as if it were an intentional trick...write your own, new language in an OLD, real world language that is passe. Compile it into executable modules of course, so it is a real, working compiler, alright. But the SOURCE is some old, high level language which no one wants to use anymore! So now you've got a hot new language package and no one can say well, it is written in, the SOURCE code is written in, a REAL language. No, it's not! The source is some outdated language and compiler and no one is going to prefer learning THAT to learning your hot new language! I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
On Jul 20, 11:08 pm, Dan Upton [EMAIL PROTECTED] wrote: On Sun, Jul 20, 2008 at 11:51 PM, Mensanator [EMAIL PROTECTED] wrote: On Jul 20, 10:05�pm, Stephen Johnson [EMAIL PROTECTED] wrote: Carry bits? Who worries about carry bits when you have unlimited precision arithmetic? You want cool? THIS is cool: j = ((invert(xyz[1]-xyz[0],xyz[1]**(k-1))*(xyz[1]**(k-1)-prev_gen[2])) % xyz[1]**(k-1))/xyz[1]**(k-2) You call that cool. I call it unreadable. Ok, but not in the sense that something like Scheme is unreadable as this is nothing but algebra (albeit complicaed). Scheme doesn't *have* to be unreadable... any more unreadable than any other language when poorly documented/formatted, anyway. When I needed to whip up a variation on Ulam's Spiral recently, I went and got the Scheme version I wrote 4 years ago when I briefly toyed with Scheme and thought I'd just translate the plotting part to Python. Couldn't make any sense of it and ended up doing the Python version with Turtle Graphics. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
[EMAIL PROTECTED] wrote: I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each MPU chip out there. ... No one writes compilers in assembly language. Most people don't even write assemblers in assembly language. So I was suspecting the Python compiler or interpreter is written in a REAL language like C#. So, Wiki says it's written in C! It's almost as if it were an intentional trick...write your own, new language in an OLD, real world language that is passe. You seem to believe that, because YOU are just learning about Python, that necessarily means that Python itself is new. That is incorrect. Python was originally conceived and developed in 1990. Anders Hejlsberg, who designed C#, was still at Borland at that time, and had not even created Delphi yet. C++ was still many years away from becoming an ISO standard. I'm not dissing Python, here. Just noting that, if it is written in C, that throws a curve at me in trying to balance the value of learning Python vs. some other major language. I would say you have a very strange criteria for deciding whether a language is worth learning. -- Tim Roberts, [EMAIL PROTECTED] Providenza Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Written in C?
Grant Edwards wrote: On 2008-07-21, Dan Upton [EMAIL PROTECTED] wrote: REAL WORLD programmers who want to be generally useful go and learn C#. No: Real programmers first eat a quiche and then return to their Pascal programming. Bah, new-fangled languages like Pascal... Real programmers write Fortran. Using punch-cards and paper-tape. Real programmers can edit their programs with a pointy stick and some home-made sticky-tape. Bah. Butterflies! http://xkcd.com/378/ -- http://mail.python.org/mailman/listinfo/python-list
ANNOUNCE: wxPython 2.8.8.1
Announcing -- The 2.8.8.1 release of wxPython is now available for download at http://wxpython.org/download.php. This is a minor bugfix release with several fixes for problems discovered in the 2.8.8.0 release. Source code is available, as well as binaries for Python 2.3, 2.4 and 2.5, for Windows and Mac, as well some packages for various Linux distributions. A summary of changes is listed below and also at http://wxpython.org/recentchanges.php. What is wxPython? - wxPython is a GUI toolkit for the Python programming language. It allows Python programmers to create programs with a robust, highly functional graphical user interface, simply and easily. It is implemented as a Python extension module that wraps the GUI components of the popular wxWidgets cross platform library, which is written in C++. wxPython is a cross-platform toolkit. This means that the same program will usually run on multiple platforms without modifications. Currently supported platforms are 32-bit Microsoft Windows, most Linux or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most cases the native widgets are used on each platform to provide a 100% native look and feel for the application. Changes in 2.8.8.1 -- wx.richtext: Added wrappers for the RichTextPrinting and RichTextPrintout classes. Make it easier to replace the check box images used in the CheckListCtrlMixin class. Fixed bug in wx.ScrolledWindow when child focus events caused unneccessary or incorrect scrolling. Fixed a bug in wx.GridBagSizer where hidden items were not ignored in part of the layout algorithm. Several other bugs also fixed. Added builds for Ubuntu Hardy (8.04) -- Robin Dunn Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython! -- http://mail.python.org/mailman/listinfo/python-list
[issue3322] bugs in scanstring_str() and scanstring_unicode() of _json module
Georg Brandl [EMAIL PROTECTED] added the comment: Was merged in r65148. -- resolution: - fixed status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3322 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3216] Scarce msilib documentation
Martin v. Löwis [EMAIL PROTECTED] added the comment: As for how to use the module: what do you want to use the module for, and what kind of information would you need for that? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3216 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3420] 2to3 fails to run on Mac OS X 10.4 PPC 3.0b2
New submission from Barry Alan Scott [EMAIL PROTECTED]: $ sw_vers ProductName:Mac OS X ProductVersion: 10.4.11 BuildVersion: 8S165 $ python3.0 Python 3.0b2 (r30b2:65080, Jul 20 2008, 08:46:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type help, copyright, credits or license for more information. $ /Library/Frameworks/Python.framework//Versions/3.0/bin/2to3 a.py Traceback (most recent call last): File /Library/Frameworks/Python.framework//Versions/3.0/bin/2to3, line 5, in module sys.exit(refactor.main(lib2to3/fixes)) File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 81, in main rt = RefactoringTool(fixer_dir, options) File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 160, in __init__ self.pre_order, self.post_order = self.get_fixers() File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 182, in get_fixers fix_names = get_all_fix_names(self.fixer_dir) File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 95, in get_all_fix_names names = os.listdir(fixer_dir) OSError: [Errno 2] No such file or directory: 'lib2to3/fixes' -- assignee: collinwinter components: 2to3 (2.x to 3.0 conversion tool) messages: 70065 nosy: barry-scott, collinwinter severity: normal status: open title: 2to3 fails to run on Mac OS X 10.4 PPC 3.0b2 type: crash versions: Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3420 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3420] 2to3 fails to run on Mac OS X 10.4 PPC 3.0b2
Barry Alan Scott [EMAIL PROTECTED] added the comment: Fixing 2to3 with the full path to the fixes folder gets this traceback: $ ./2to3 /dev/null Traceback (most recent call last): File ./2to3, line 5, in module sys.exit(refactor.main(/Library/Frameworks/Python.framework//Versions/3.0/lib/python3.0/lib2to3/fixes)) File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 81, in main rt = RefactoringTool(fixer_dir, options) File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 160, in __init__ self.pre_order, self.post_order = self.get_fixers() File /Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/lib2to3/refactor.py, line 185, in get_fixers mod = __import__(fixer_pkg + .fix_ + fix_name, {}, {}, [*]) ValueError: Empty module name ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3420 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3120] subprocess module truncates handles on AMD64
Roger Upole [EMAIL PROTECTED] added the comment: This fixes the problem I had on 64-bit Vista, and all of python's own tests still pass. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3120 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3359] add 'rbU' mode to open()
anatoly techtonik [EMAIL PROTECTED] added the comment: That's fine with me. I just need a 'rbU' mode to know in which format should I write the output file if I want to preserve proper line endings regardless of platform. As for Python 2.6 note - I would replace may convert with converts. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3359 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3359] add 'rbU' mode to open()
Georg Brandl [EMAIL PROTECTED] added the comment: If you want to write your own line endings, read with rU and write with rb. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3359 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1905] PythonLauncher not working correctly on OS X 10.5/Leopad
Georg Brandl [EMAIL PROTECTED] added the comment: No complaints were voiced, so I'm closing this. -- nosy: +georg.brandl status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1905 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3104] overzealous garbage collector (dict)
Georg Brandl [EMAIL PROTECTED] added the comment: No complaints were voiced, so I'm closing this. -- status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3104 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3181] ConfigParsers are classic classes
Georg Brandl [EMAIL PROTECTED] added the comment: When creating your own subclass, you can always inherit from object too to create a new-style class. -- status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3181 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1711] socket functions that should return unsigned int return signed int
Changes by Georg Brandl [EMAIL PROTECTED]: -- status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1711 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1619130] 64-bit Universal Binary build broken
Georg Brandl [EMAIL PROTECTED] added the comment: No complaints were voiced, so I'm closing this. -- nosy: +georg.brandl status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1619130 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1391872] floating point literals don't work in non-US locale in 2.5
Georg Brandl [EMAIL PROTECTED] added the comment: It seems it has been fixed. -- nosy: +georg.brandl status: pending - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue1391872 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com